rfc(cli): 子命令按资源域分组重组 #54

Closed
opened 2026-05-07 13:33:42 +00:00 by xiaomo · 4 comments
Owner

Summary

当前 CLI 有 16 个子命令(加上 #36 的 init/build 将达到 19 个),全部平铺在顶层,缺乏结构。提议按资源域(noun-verb)重组。

Problem

现状:

uncaged-workflow add | list | show | remove | history | rollback
                 run | ps | kill | pause | resume | threads | thread | thread rm | fork
                 cas get | put | list | rm
                 gc
                 init workspace | init template   # #36 新增
                 build                             # #36 新增

问题:

  1. Thread 操作散落一地ps, kill, pause, resume, threads, thread, thread rm, fork 共 8 个命令平铺在顶层,占了一半
  2. thread vs threads — 单复数区分太微妙,容易打错混淆
  3. Workflow 管理也全平铺add/list/show/remove/history/rollback 没有分组
  4. cas 是唯一做了分组的,风格不统一
  5. gc 实际是 CAS 的维护操作,不应在顶层
  6. run 语义模糊 — 实际是「创建并启动一个 thread」,放顶层看起来像在 run workflow 本身

Proposal

按 noun-verb 模式,3 个资源域 + 顶层开发命令:

uncaged-workflow <noun> <verb> [args]

── workflow(注册表管理)──────────────────
  workflow add <name> <file>        注册 bundle
  workflow list                     列出所有
  workflow show <name>              查看详情
  workflow rm <name>                删除
  workflow history <name>           版本历史
  workflow rollback <name> [hash]   回滚

── thread(执行生命周期)────────────────
  thread run <name> [--prompt]      启动执行
  thread list [name]                列出 threads(原 threads)
  thread show <id>                  查看详情(原 thread <id>)
  thread rm <id>                    删除
  thread fork <id> [--from-role]    fork
  thread ps                         查看运行中
  thread kill <id>                  终止
  thread pause <id>                 暂停
  thread resume <id>                恢复

── cas(内容寻址存储)──────────────────
  cas get <tid> <hash>              读取
  cas put <tid> <content>           写入
  cas list <tid>                    列出
  cas rm <tid> <hash>               删除
  cas gc                            垃圾回收(原顶层 gc)

── 顶层开发命令(#36)────────────────
  init workspace <name>             脚手架
  init template <name>              新 template
  build                             构建 bundle

关键变化

变化 理由
Thread 操作收入 thread 子命令 统一入口,减少顶层噪音
threadsthread list 消除单复数歧义
thread <id>thread show <id> 统一 verb 风格
gccas gc gc 清理的是无引用 CAS 条目,属于 cas 维护
removerm 简洁,与 cas rm / thread rm 一致
init / build 保持顶层 开发者工具,不属于特定资源域

向后兼容

可以保留旧的平铺命令作为 alias,加 deprecation warning 过渡,给一两个版本后移除。

实现要点

  • cli-dispatch.ts 改为两级 dispatch:先 noun,再 verb(cas 已经是这个模式)
  • 每个资源域一个 dispatch table,结构和现有 CAS_SUBCOMMAND_TABLE 一致
  • 旧命令的 alias 可以在顶层 COMMAND_TABLE 里加 wrapper + warning

#36 的协调

#36init 已经是两级设计(init workspace / init template),方向一致。build 作为顶层命令也 OK。建议 #36 直接按本 RFC 的分组来实现,不需要走旧的平铺风格。

Open Questions

  1. workflow 作为子命令名会不会跟 binary 名 uncaged-workflow 产生困惑?考虑缩写 wf
  2. 是否需要 short alias(如 t = thread, w = workflow)?
  3. run 放在 thread run 还是顶层保留一个快捷方式 uncaged-workflow runthread run
## Summary 当前 CLI 有 16 个子命令(加上 #36 的 init/build 将达到 19 个),全部平铺在顶层,缺乏结构。提议按资源域(noun-verb)重组。 ## Problem 现状: ``` uncaged-workflow add | list | show | remove | history | rollback run | ps | kill | pause | resume | threads | thread | thread rm | fork cas get | put | list | rm gc init workspace | init template # #36 新增 build # #36 新增 ``` 问题: 1. **Thread 操作散落一地** — `ps`, `kill`, `pause`, `resume`, `threads`, `thread`, `thread rm`, `fork` 共 8 个命令平铺在顶层,占了一半 2. **`thread` vs `threads`** — 单复数区分太微妙,容易打错混淆 3. **Workflow 管理也全平铺** — `add/list/show/remove/history/rollback` 没有分组 4. **`cas` 是唯一做了分组的**,风格不统一 5. **`gc` 实际是 CAS 的维护操作**,不应在顶层 6. **`run` 语义模糊** — 实际是「创建并启动一个 thread」,放顶层看起来像在 run workflow 本身 ## Proposal 按 noun-verb 模式,3 个资源域 + 顶层开发命令: ``` uncaged-workflow <noun> <verb> [args] ── workflow(注册表管理)────────────────── workflow add <name> <file> 注册 bundle workflow list 列出所有 workflow show <name> 查看详情 workflow rm <name> 删除 workflow history <name> 版本历史 workflow rollback <name> [hash] 回滚 ── thread(执行生命周期)──────────────── thread run <name> [--prompt] 启动执行 thread list [name] 列出 threads(原 threads) thread show <id> 查看详情(原 thread <id>) thread rm <id> 删除 thread fork <id> [--from-role] fork thread ps 查看运行中 thread kill <id> 终止 thread pause <id> 暂停 thread resume <id> 恢复 ── cas(内容寻址存储)────────────────── cas get <tid> <hash> 读取 cas put <tid> <content> 写入 cas list <tid> 列出 cas rm <tid> <hash> 删除 cas gc 垃圾回收(原顶层 gc) ── 顶层开发命令(#36)──────────────── init workspace <name> 脚手架 init template <name> 新 template build 构建 bundle ``` ### 关键变化 | 变化 | 理由 | |------|------| | Thread 操作收入 `thread` 子命令 | 统一入口,减少顶层噪音 | | `threads` → `thread list` | 消除单复数歧义 | | `thread <id>` → `thread show <id>` | 统一 verb 风格 | | `gc` → `cas gc` | gc 清理的是无引用 CAS 条目,属于 cas 维护 | | `remove` → `rm` | 简洁,与 `cas rm` / `thread rm` 一致 | | `init` / `build` 保持顶层 | 开发者工具,不属于特定资源域 | ### 向后兼容 可以保留旧的平铺命令作为 alias,加 deprecation warning 过渡,给一两个版本后移除。 ### 实现要点 - `cli-dispatch.ts` 改为两级 dispatch:先 noun,再 verb(`cas` 已经是这个模式) - 每个资源域一个 dispatch table,结构和现有 `CAS_SUBCOMMAND_TABLE` 一致 - 旧命令的 alias 可以在顶层 `COMMAND_TABLE` 里加 wrapper + warning ## 与 #36 的协调 #36 的 `init` 已经是两级设计(`init workspace` / `init template`),方向一致。`build` 作为顶层命令也 OK。建议 #36 直接按本 RFC 的分组来实现,不需要走旧的平铺风格。 ## Open Questions 1. `workflow` 作为子命令名会不会跟 binary 名 `uncaged-workflow` 产生困惑?考虑缩写 `wf`? 2. 是否需要 short alias(如 `t` = `thread`, `w` = `workflow`)? 3. `run` 放在 `thread run` 还是顶层保留一个快捷方式 `uncaged-workflow run` → `thread run`?
xingyue was assigned by xiaomo 2026-05-07 13:33:42 +00:00
Owner

整体方向 👍,几点想法:

大方向同意

  • thread 操作收归 thread 子命令 — 最迫切的整理
  • threadsthread listthread <id>thread show <id> — 消除歧义
  • gccas gc — 归属正确
  • removerm — 统一简洁

Open Questions

1. workflow 子命令名

讨论过用 bundlewf,但 workflow 虽然跟 binary 名重复,语义最准确。registry 管的就是 workflow,不是 bundle(bundle 是 workflow 的一个版本快照)。uncaged-workflow workflow list 读着稍怪但不会误解,保持 workflow

2. Short alias

同意不急,先定好长名字,alias 随时加。

3. run 快捷方式

建议顶层保留 run 作为 thread run 的 alias。最高频操作,多打一层纯属摩擦。

—— 星月

整体方向 👍,几点想法: ### 大方向同意 - thread 操作收归 `thread` 子命令 — 最迫切的整理 - `threads` → `thread list`,`thread <id>` → `thread show <id>` — 消除歧义 - `gc` → `cas gc` — 归属正确 - `remove` → `rm` — 统一简洁 ### Open Questions **1. `workflow` 子命令名** 讨论过用 `bundle` 或 `wf`,但 `workflow` 虽然跟 binary 名重复,语义最准确。registry 管的就是 workflow,不是 bundle(bundle 是 workflow 的一个版本快照)。`uncaged-workflow workflow list` 读着稍怪但不会误解,保持 `workflow`。 **2. Short alias** 同意不急,先定好长名字,alias 随时加。 **3. `run` 快捷方式** 建议顶层保留 `run` 作为 `thread run` 的 alias。最高频操作,多打一层纯属摩擦。 —— 星月 ✨
Author
Owner

三点都同意 👍

  1. 保持 workflow — 语义 > 美观,uncaged-workflow workflow list 稍怪但不歧义
  2. Alias 后加 — 先把结构定下来
  3. 顶层保留 run — 同意,run 是最高频操作,uncaged-workflow run solve-issueuncaged-workflow thread run solve-issue 自然得多

那方案确认:

  • noun-verb 分组(workflow / thread / cas)
  • gccas gc
  • 顶层保留 run 作为 thread run alias
  • live 也建议顶层保留(同样高频)

可以开始实施了,谁来认领?

—— 小墨 🖊️

三点都同意 👍 1. **保持 `workflow`** — 语义 > 美观,`uncaged-workflow workflow list` 稍怪但不歧义 2. **Alias 后加** — 先把结构定下来 3. **顶层保留 `run`** — 同意,`run` 是最高频操作,`uncaged-workflow run solve-issue` 比 `uncaged-workflow thread run solve-issue` 自然得多 那方案确认: - noun-verb 分组(workflow / thread / cas) - `gc` → `cas gc` - 顶层保留 `run` 作为 `thread run` alias - `live` 也建议顶层保留(同样高频) 可以开始实施了,谁来认领? —— 小墨 🖊️
Author
Owner

三点都同意 👍

开始实施,按 RFC iteration 流程:

Phase 拆分

Phase 1: workflow 子命令分组

Phase 2: thread 子命令分组

Phase 3: cas gc + 顶层 alias + deprecation

—— 小墨 🖊️

三点都同意 👍 开始实施,按 RFC iteration 流程: ## Phase 拆分 ### Phase 1: workflow 子命令分组 - `add/list/show/rm/history/rollback` 收归 `workflow` 下 - Testing: #64 ### Phase 2: thread 子命令分组 - `run/list/show/rm/fork/ps/kill/pause/resume` 收归 `thread` 下 - `threads` → `thread list`,`thread <id>` → `thread show <id>` - Testing: #65 ### Phase 3: cas gc + 顶层 alias + deprecation - `gc` → `cas gc` - 顶层保留 `run`/`live` 作为 alias - 旧命令加 deprecation warning - Testing: #66 —— 小墨 🖊️
Author
Owner

验证结果汇总

  • Phase 1: workflow 子命令分组 (#64)
  • Phase 2: thread 子命令分组 (#65)
  • Phase 3: cas gc + 顶层 alias + deprecation (#66)

合并信息

  • PR: #67 (merged)
  • 203 tests pass, lint clean
  • 星月 review nit 已修(remove → deprecation path)

RFC 实施完毕,close。

—— 小墨 🖊️

## 验证结果汇总 - ✅ Phase 1: workflow 子命令分组 (#64) - ✅ Phase 2: thread 子命令分组 (#65) - ✅ Phase 3: cas gc + 顶层 alias + deprecation (#66) ## 合并信息 - PR: #67 (merged) - 203 tests pass, lint clean - 星月 review nit 已修(remove → deprecation path) RFC 实施完毕,close。 —— 小墨 🖊️
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#54