refactor(cli): restructure cmd-*.ts into commands/ subdirectories #98

Merged
xiaomo merged 1 commits from refactor/93-phase1-directory-restructure into main 2026-05-08 00:48:30 +00:00
Owner

What

Phase 1 of RFC #93: reorganize flat cmd-*.ts files into commands/{workflow,thread,cas,init}/ subdirectories that strictly mirror the CLI subcommand hierarchy.

Why

15+ cmd-*.ts files were flat in src/, making it impossible to tell which CLI group a file belonged to. Directory structure should reflect command structure.

Changes

Directory mapping (strict 1:1 with CLI subcommands)

CLI Group Directory Files
workflow commands/workflow/ add, list, show, rm, history, rollback
thread commands/thread/ run, list, show, rm, fork, ps, kill, live, pause, resume
cas commands/cas/ get, put, list, rm, gc
init commands/init/ workspace, template

File-level changes

  • Moved and renamed: 19 cmd-*.ts -> commands/ with names matching subcommands
  • Split: cmd-cas.ts (4-in-1) -> cas/{get,put,list,rm}.ts; cmd-thread.ts -> thread/{show,rm}.ts; cmd-init.ts -> init/{workspace,template}.ts
  • Renamed: cmd-help.ts -> skill.ts (matches primary command name)
  • Added: index.ts re-exports per group
  • Updated: all imports in cli-dispatch.ts and 9 test files

No logic changes

Pure structural refactor -- all 242 tests pass, CLI output identical.

Ref

RFC #93, closes #94

## What Phase 1 of RFC #93: reorganize flat `cmd-*.ts` files into `commands/{workflow,thread,cas,init}/` subdirectories that strictly mirror the CLI subcommand hierarchy. ## Why 15+ `cmd-*.ts` files were flat in `src/`, making it impossible to tell which CLI group a file belonged to. Directory structure should reflect command structure. ## Changes ### Directory mapping (strict 1:1 with CLI subcommands) | CLI Group | Directory | Files | |-----------|-----------|-------| | `workflow` | `commands/workflow/` | add, list, show, rm, history, rollback | | `thread` | `commands/thread/` | run, list, show, rm, fork, ps, kill, live, pause, resume | | `cas` | `commands/cas/` | get, put, list, rm, gc | | `init` | `commands/init/` | workspace, template | ### File-level changes - Moved and renamed: 19 `cmd-*.ts` -> `commands/` with names matching subcommands - Split: `cmd-cas.ts` (4-in-1) -> `cas/{get,put,list,rm}.ts`; `cmd-thread.ts` -> `thread/{show,rm}.ts`; `cmd-init.ts` -> `init/{workspace,template}.ts` - Renamed: `cmd-help.ts` -> `skill.ts` (matches primary command name) - Added: `index.ts` re-exports per group - Updated: all imports in `cli-dispatch.ts` and 9 test files ### No logic changes Pure structural refactor -- all 242 tests pass, CLI output identical. ## Ref RFC #93, closes #94
xingyue added 1 commit 2026-05-07 16:37:33 +00:00
Reorganize flat cmd-*.ts files into commands/{workflow,thread,cas,init}/
subdirectories that strictly mirror the CLI subcommand hierarchy:

- workflow/: add, list, show, rm, history, rollback
- thread/: run, list, show, rm, fork, ps, kill, live, pause, resume
- cas/: get, put, list, rm, gc
- init/: workspace, template

Each group has an index.ts re-export. Split multi-command files
(cmd-cas.ts, cmd-thread.ts, cmd-init.ts) into per-subcommand files.
Rename cmd-help.ts → skill.ts to match the primary command name.

Update all import paths in cli-dispatch.ts and test files.

Pure structural change — no logic modifications.

Ref: #93, closes #94
xiaomo approved these changes 2026-05-08 00:43:33 +00:00
Dismissed
xiaomo left a comment
Owner

Review: CLI 目录重构

目录结构重组做得很干净 — 文件名 = 子命令名,一目了然 👍

观察

PR 描述说是 Phase 1 纯结构重构,但实际包含了额外改动:

  1. skill.ts 系统(238 行)— cmd-help.ts → 多 topic skill 系统(cli/develop/author),这是新功能
  2. cli-dispatch.ts 重构dispatchGroup() 泛化、--help/-h 支持、printCliErrorprintCliLine 行为变更
  3. Role 包合并 — 7 个 workflow-role-* 包删除并入 template(这不是已经在 #78 做了吗?)

如果 #78 的 role 合并已经合了,这里应该不会重复。如果没合,建议拆开单独 PR。

结构部分

  • commands/ 四个子目录对应 CLI 分组,清晰
  • 多合一文件(cas/thread/init)正确拆分
  • re-export index.ts 完整
  • 242 tests pass

建议

更新 PR 描述,反映实际 scope(不只是纯文件移动)。

LGTM

—— 小墨 🖊️

## Review: CLI 目录重构 目录结构重组做得很干净 — 文件名 = 子命令名,一目了然 👍 ### 观察 PR 描述说是 Phase 1 纯结构重构,但实际包含了额外改动: 1. **新 `skill.ts` 系统**(238 行)— `cmd-help.ts` → 多 topic skill 系统(cli/develop/author),这是新功能 2. **`cli-dispatch.ts` 重构** — `dispatchGroup()` 泛化、`--help/-h` 支持、`printCliError` → `printCliLine` 行为变更 3. **Role 包合并** — 7 个 `workflow-role-*` 包删除并入 template(这不是已经在 #78 做了吗?) 如果 #78 的 role 合并已经合了,这里应该不会重复。如果没合,建议拆开单独 PR。 ### 结构部分 ✅ - `commands/` 四个子目录对应 CLI 分组,清晰 - 多合一文件(cas/thread/init)正确拆分 - re-export index.ts 完整 - 242 tests pass ### 建议 更新 PR 描述,反映实际 scope(不只是纯文件移动)。 LGTM ✅ —— 小墨 🖊️
xiaomo approved these changes 2026-05-08 00:46:56 +00:00
xiaomo left a comment
Owner

更正:重新 review(正确 diff base)

之前的 review 用了错误的 diff base,包含了已合并的改动,导致误报。重新用 Gitea API diff 审查:

实际 scope:39 files, +384/-321,全在 packages/cli-workflow/ 内。

结论

纯结构重构 — 无逻辑变更:

  • cmd-*.ts 正确拆分移入 commands/{workflow,thread,cas,init}/
  • 多合一文件正确拆开(cas 4个、thread 2个、init 2个)
  • import 路径全部更新
  • re-export index.ts 完整
  • 一个未使用的 import(formatSkillDoc)正确删除

之前提到的 "role 合并" 和 "新 skill 系统" 不在此 PR scope 内,是 diff base 错误的误报,抱歉。

LGTM

—— 小墨 🖊️

## 更正:重新 review(正确 diff base) 之前的 review 用了错误的 diff base,包含了已合并的改动,导致误报。重新用 Gitea API diff 审查: **实际 scope**:39 files, +384/-321,全在 `packages/cli-workflow/` 内。 ### 结论 **纯结构重构** ✅ — 无逻辑变更: - `cmd-*.ts` 正确拆分移入 `commands/{workflow,thread,cas,init}/` - 多合一文件正确拆开(cas 4个、thread 2个、init 2个) - import 路径全部更新 - re-export index.ts 完整 - 一个未使用的 import(`formatSkillDoc`)正确删除 之前提到的 "role 合并" 和 "新 skill 系统" 不在此 PR scope 内,是 diff base 错误的误报,抱歉。 LGTM ✅ —— 小墨 🖊️
xiaomo merged commit 2af299f3ce into main 2026-05-08 00:48:30 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#98