Go rewrite beta: native CLI distribution + daemon/relay parity#13
Merged
Conversation
Phase 0:Go 骨架 + npm 分发管道 - cobra root(--version/--help/NoArgs),ldflags 注入版本 - npm launcher(require.resolve 平台子包二进制并 spawn 透传 exit code) - scripts/build-go.sh:交叉编译 5 平台(darwin/linux x64+arm64、win32 x64) → dist-native/ 原始二进制 + dist-npm/ 主包(optionalDependencies)+平台子包(os/cpu) - scripts/gen-pkg.mjs 生成各包 package.json Phase 1:地基层 + 核心命令(端到端验证) - errs/fsutil/paths/config:错误码、原子写、目录布局、schema (json.Unmarshal 覆盖默认值复现 deepMerge;点号路径 get/set/unset/coerce/mask) - keychain/creds:security|secret-tool shell-out;env/file/keychain/inline 引用; api-key 分层解析 + multi-key + gateway token(忠实移植 store.ts) - notif:通知查询匹配 + app 中英文别名 + date-key 收集(读侧) - output/clictx/prompt/daemon(lock 读侧):json|pretty|table|ndjson 输出对齐 JS - cli:handler wrapper + 全局 flags + config/profile/auth/notification/doctor 与现有 TS 实现同仓共存,不影响现有 npm 发布线(并行重写策略)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- internal/logread:daemon 日志检索(current + 轮转文件,最新行靠前) - cmd_log:log [keyword] + +errors - cmd_migrate:from-openclaw(dry-run 计划 + 目录递归复制 + api-key 迁移) fsutil.CopyDir / CountFiles - cmd_update:update self(查 npm registry,按可执行路径推断 npm/native 升级命令) version.Dist() 运行期探测安装来源 - skills:go:embed 把 skills/ 整个嵌入二进制(assets.SkillsFS), install 解包复制到 agent 目录(claude/codex 探测);list/targets/install 接线 至此 Phase 1 只读 CLI 命令面基本齐备(11 个 service);image/recording 读侧 留待 Phase 2 与其存储模型一并落地。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CLI 现在能跑起 daemon 并经 HTTP 接收手机通知,打通 ingest→存储→查询全链路。 - notif 写侧:NewStorage ingest(id 去重 + content-key sha256 去重 + 飞书归一化 feishu.go + retentionDays 过期清理),sync.Mutex 串行化写入 - daemon/logger:按日期轮转的文件 logger(行格式对齐 logread) - daemon/lock:WriteLock/RemoveLock;proc_unix/windows 增 detach attr + terminate/forceKill - daemon/server:前台主循环 + 端口占用自动 +1;路由 /health、/daemon/status|stop|reload、 POST /notifications、/gateway/notifications.push;鉴权(gateway-token / http-api-key / local) - daemon/spawn:fork 脱离会话子进程跑 run-foreground,轮询 lock;Stop 走 SIGTERM/端点 + 10s 强杀 - daemon/client:CLI↔daemon HTTP RPC,连接被拒报 DAEMON_NOT_RUNNING - cli:daemon start/stop/restart/reload/status/logs/run-foreground 接线; config init 自动拉起 daemon;auth check 走 daemon /daemon/status 端到端验证:daemon start(detach,端口回退)→ POST 通知 ingest=1 → 重复 POST dedupedById=1 → notification search 命中 → daemon stop(SIGTERM 优雅退出)→ status 报未运行 exit1。 Relay 隧道与 recordings/images/light/monitor 留待 Phase 3 / 后续。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- internal/recording:读 recordings/index.json + state/events.jsonl - internal/image:读 images/index.json + 相对路径解析 - cli recording:list/status/storage-path/setup-asr/events/+latest (setup-asr 写 AsrConfig 兼容结构;events 按 id/since/limit 过滤) - cli image:list/status/path/storage-path/+latest (list 支持 status/client/app 别名/from-to/limit;path 校验 synced + IMAGE_NOT_READY) 验证:合成 index.json/events.jsonl 跑通 recording list/+latest/events/setup-asr、 image list(wechat 别名匹配 source_app)/path 解析。ingest 写侧(含 OSS 下载)待后续。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- internal/monitor:state/monitors.json 定义 CRUD(list/get/create/delete/setEnabled) - daemon/server_services:/monitors(GET/POST/DELETE/enable|disable)+ /tunnel/* (standalone-http 语义;+test 走本地 echo ingest 回环) - cli daemon-services 代理命令: monitor list/show/create/delete/enable/disable(经 daemon /monitors) tunnel status/reconnect/+test、gateway test、api <method> <path>(raw 直通) 验证(daemon 在跑):monitor 全 CRUD、gateway test(probe ingested=1)、 tunnel status standalone、tunnel +test echo 回环 ok、api GET /daemon/status 直通。 light/lightrule 待 light 硬件 vendor 端口移植后接入(下一focused pass)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
移植 src/notification/sync.ts:日期级 .checkpoint.json 消费进度, scan 扫描待同步、fetch 按批快照(SyncFetchLimit=300 + --max-end-index)、 commit 推进进度(exact-end-index / legacy-batch-limit 两模式,含回退/越界/ 跳批校验)。复用 notif 包既有 listDateKeys/readDateFile,纯本地无 daemon。 全绿 + 5 平台交叉编译。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
移植 src/vendor/light/* 与 light-rules/*:
- internal/light:repeat 归一、线协议逐字节编码(Unicode 档位 + 量化 + 色彩
系数)、segments 校验(errors/warnings)、内置 presets(embed presets-v1.json)、
发往灯效云 API 的 sender。协议用 presets 自带 base64 golden 逐字节验证(8/8)。
- internal/lightrule:meta.json 文件 CRUD(<profile>/light-rules/tasks/<name>),
ALREADY_EXISTS / NOT_FOUND 语义 + 写路径串行化。
- daemon:新增 POST /light/send(segments/preset/rule 三选一)与
/gateway/lightrules.{list,create,update,delete}({ok,data} 外壳)。
- CLI:light send / +blink,lightrule list/show/create/update/delete/
enable/disable/+on/+off,对齐 daemon-services.ts 代理形态。
端到端烟测通过:CRUD、校验报错、去重、light send 直达灯效云(空 key 优雅
拒绝)。gofmt/vet 全绿 + 5 平台交叉编译。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR moves
@yoooclaw/clionto the Go rewrite path and wires the npm distribution to a thin JS launcher plus platform-specific Go binary packages.It includes:
Release Notes
Published and verified beta:
@yoooclaw/cli@0.2.0-beta.1on npmbetacli-v0.2.0-beta.10.2.0-beta.0was published first, then deprecated after real install testing exposed a platform binary executable-bit issue.0.2.0-beta.1fixes that by declaring the platform binary as a package bin and making the launcher defensively chmod non-Windows binaries before spawn.Validation
Local:
go test ./...go vet ./...scripts/build-go.sh 0.2.0-beta.1npm install @yoooclaw/cli@0.2.0-beta.1yc --version->0.2.0-beta.1yoooclaw --version->0.2.0-beta.1yc --helpYOOOCLAW_HOME=<tmp> yc --format json config init --non-interactive --from-file config.json --no-startYOOOCLAW_HOME=<tmp> yc --format json config showCI:
cli-v0.2.0-beta.1Security sanity: