mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-10-15 12:15:11 +00:00
SDK 仓已迁到 GitHub 作为权威源,go module 路径同步: `gitcode.com/JianFeeeee/homeagent-sdk` → `github.com/JianFeeeee/homeagentsdk` ## 范围 74 个文件:71 个 Go 源码 + go.mod/go.sum + hmapdev 模板 + CI 与打包脚本。 主仓(HomeAgent)侧对应改动是 6d38a164。本仓这些文件当时**不在工作树上** (见下),所以那次的批量替换扫不到它们——这里是补偿。 ## 为何这批文件当时不在工作树上(事故与恢复) 10-08 07:58 主仓做 checkout/cherry-pick 序列时,把本仓工作树的 20 个文件 误清理了(`example/*/plugin.go` + `plg.json`,10 个示例)。 根因是**结构误判**:本仓是「一目录两仓库」结构下主仓 `third_party/` 里的 **独立 git 仓库**,而主仓 .gitignore 忽略了 `example/`,于是它在主仓 `git status` 里不可见 —— 看着像「不受跟踪的构建产物」,实际是本仓受跟踪的源码。 已全部恢复(`git checkout -- <D 文件>`,只恢复删除、不动迁移改动), 20 个文件与 HEAD 逐字节一致。 **破坏的连锁后果**:恢复出来的 `plugin.go` 仍写着旧 module 路径, 因为迁移时它们已不在工作树上。所以这次补偿是必须的,不是可选优化。 ## 保留 gitcode 引用 以下位置的 `gitcode` **有意保留**,不要"顺手清掉": - README.md / docs 里「二进制实际分发地址目前是 gitcode」的说明 - mkdocs.yml 的 gitcode 镜像链接(国内直连更快) - `tools/hmapdev/templates.go` 里「SDK 已从 gitcode 迁到 GitHub」的注释 gitcode 仍是**只读镜像**(源码同步;release 附件暂时仍在那边)。 ## 验证 - 本仓根 module:`go build ./...` + `go test ./...` 全通过 - 全部 20 个 example:`go vet` 通过(补偿前 10 个因旧 module 路径失败) - example/qq:`go test` 通过,且能从源码 build 出可用 plugin 产物
84 lines
2.4 KiB
Go
84 lines
2.4 KiB
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"io"
|
||
"os"
|
||
"runtime"
|
||
|
||
"github.com/JianFeeeee/homeagentsdk/meta"
|
||
)
|
||
|
||
func main() {
|
||
if len(os.Args) < 2 {
|
||
help()
|
||
return
|
||
}
|
||
switch os.Args[1] {
|
||
case "init":
|
||
cmdInit(os.Args[2:])
|
||
case "build":
|
||
cmdBuild(os.Args[2:])
|
||
case "clean":
|
||
cmdClean(os.Args[2:])
|
||
case "debug":
|
||
cmdDebug(os.Args[2:])
|
||
case "sdk":
|
||
cmdSDK(os.Args[2:])
|
||
case "skill":
|
||
cmdSkill(os.Args[2:])
|
||
case "version", "-v", "--version":
|
||
printVersion()
|
||
default:
|
||
help()
|
||
}
|
||
}
|
||
|
||
// printVersion 输出工具链自身的版本身份。
|
||
//
|
||
// 为何必须有:此前工具链不报版本,而插件产物与内核是**协议绑定**的——
|
||
// 手里是哪一版工具链、能不能配当前内核,只能靠翻文件名或猜。
|
||
// 版本号来自 meta.Version(与 SDK 发布同源,由 -ldflags -X 注入);
|
||
// lnflags 未注入时它是源码里的默认值,此时提示它可能是开发构建。
|
||
func printVersion() {
|
||
printVersionTo(os.Stdout)
|
||
}
|
||
|
||
// printVersionTo 把版本身份写到 w(抽出来是为了能被测试钉住)。
|
||
func printVersionTo(w io.Writer) {
|
||
fmt.Fprintf(w, "hmapdev %s\n", meta.Version)
|
||
fmt.Fprintf(w, " SDK 模块: %s\n", "github.com/JianFeeeee/homeagentsdk")
|
||
if meta.Commit != "" && meta.Commit != "unknown" {
|
||
fmt.Fprintf(w, " 构建提交: %s\n", meta.Commit)
|
||
}
|
||
if meta.BuildTime != "" && meta.BuildTime != "unknown" {
|
||
fmt.Fprintf(w, " 构建时间: %s\n", meta.BuildTime)
|
||
}
|
||
fmt.Fprintf(w, " 构建用 Go: %s\n", runtime.Version())
|
||
fmt.Fprintf(w, " 可执行文件: %s\n", os.Args[0])
|
||
}
|
||
|
||
func help() {
|
||
fmt.Print(`HomeAgent Plugin Dev Tool
|
||
|
||
Usage:
|
||
hmapdev version Print toolchain version
|
||
hmapdev init <name> Scaffold a new plugin project
|
||
hmapdev init <name> --lua Create Lua plugin
|
||
hmapdev init <name> --type remotedevice
|
||
Create C remote device adapter
|
||
hmapdev build [flags] Compile and package plugin
|
||
hmapdev clean Clean build/dist artifacts
|
||
hmapdev debug [dir] Interpret and debug plugin source
|
||
hmapdev sdk <command> Manage SDK versions
|
||
hmapdev skill <command> Install plugin-dev skills into agent skill dirs
|
||
|
||
Flags:
|
||
--outdir Output directory (default: dist)
|
||
--target Target OS/arch (e.g. linux/amd64), repeatable
|
||
--lua Create Lua plugin (for init)
|
||
--type Project type: "remotedevice" (for init)
|
||
-t Alias for --type
|
||
`)
|
||
}
|