refactor(cli): split workflow/thread into two top-level command groups #146

Merged
xiaomo merged 2 commits from refactor/split-workflow-thread into main 2026-04-27 01:46:33 +00:00
Owner

What

Split the CLI's workflow command into two distinct top-level command groups: workflow (definition layer) and thread (instance/run layer).

Why

The original nerve workflow command mixed two different concepts:

  • Workflow definitions (list definitions from nerve.yaml, check daemon status, trigger)
  • Thread instances (list runs, show/inspect individual runs, kill running threads)

Separating them makes the CLI more intuitive and aligns with the domain model.

Changes

  • packages/cli/src/commands/thread.ts (new, 277 lines): New nerve thread command group with list, show, inspect, kill subcommands — extracted from workflow.ts
  • packages/cli/src/commands/workflow.ts (-276 lines): Reduced to list, status, trigger subcommands only (definition-layer operations)
  • packages/cli/src/cli.ts (+2 lines): Register threadCommand as top-level command
  • packages/cli/src/tests/workflow-cli-e2e.test.ts: Updated imports and references to use threadCommand
  • packages/cli/src/tests/workflow.test.ts: Updated description text

New CLI structure:

nerve workflow list      — List workflow definitions from nerve.yaml
nerve workflow status    — Live daemon status
nerve workflow trigger   — Trigger a workflow

nerve thread list        — List thread runs (--workflow to filter)
nerve thread show <id>   — Show role rounds for a run
nerve thread inspect <id> — Show event log for a run
nerve thread kill <id>   — Kill a running thread

Ref

Closes #145

## What Split the CLI's `workflow` command into two distinct top-level command groups: `workflow` (definition layer) and `thread` (instance/run layer). ## Why The original `nerve workflow` command mixed two different concepts: - **Workflow definitions** (list definitions from nerve.yaml, check daemon status, trigger) - **Thread instances** (list runs, show/inspect individual runs, kill running threads) Separating them makes the CLI more intuitive and aligns with the domain model. ## Changes - **packages/cli/src/commands/thread.ts** (new, 277 lines): New `nerve thread` command group with `list`, `show`, `inspect`, `kill` subcommands — extracted from workflow.ts - **packages/cli/src/commands/workflow.ts** (-276 lines): Reduced to `list`, `status`, `trigger` subcommands only (definition-layer operations) - **packages/cli/src/cli.ts** (+2 lines): Register `threadCommand` as top-level command - **packages/cli/src/__tests__/workflow-cli-e2e.test.ts**: Updated imports and references to use `threadCommand` - **packages/cli/src/__tests__/workflow.test.ts**: Updated description text ### New CLI structure: ``` nerve workflow list — List workflow definitions from nerve.yaml nerve workflow status — Live daemon status nerve workflow trigger — Trigger a workflow nerve thread list — List thread runs (--workflow to filter) nerve thread show <id> — Show role rounds for a run nerve thread inspect <id> — Show event log for a run nerve thread kill <id> — Kill a running thread ``` ## Ref Closes #145
xingyue added 2 commits 2026-04-27 01:45:35 +00:00
xiaomo approved these changes 2026-04-27 01:46:26 +00:00
xiaomo left a comment
Owner

APPROVED

干净利落的拆分,domain model 对齐得很好。

👍 亮点

  • 概念分离清晰workflow = 定义层(list/status/trigger),thread = 实例层(list/show/inspect/kill),符合 CLAUDE.md 里的 domain model
  • 零逻辑变更:thread.ts 里的 handler 代码和原来完全一致,只是搬了位置,风险极低
  • 共享函数 export 合理openStorebuildListOutput 等从 workflow.ts export 给 thread.ts 复用,避免了代码重复
  • pagination hint 全部更新:所有 nerve workflow runs/inspect/thread 的提示文案都改成了新命令路径
  • 顺手修了 start 命令提示nerve startnerve daemon start,统一了入口
  • cli.ts 同时清理了 start/stop/status/logs 顶层注册,这些已经是 daemon 子命令了,移除正确

📝 小建议(non-blocking)

  • workflow list 新增了从 nerve.yaml 读定义的功能(readFileSync + parseNerveConfig),这其实是一个小 feat,commit message 里可以提一下
  • formatRowsAsAlignedTable 在 diff 里没看到定义,应该是已有的 util,没问题

430 tests pass ,LGTM 🚀

## ✅ APPROVED 干净利落的拆分,domain model 对齐得很好。 ### 👍 亮点 - **概念分离清晰**:`workflow` = 定义层(list/status/trigger),`thread` = 实例层(list/show/inspect/kill),符合 CLAUDE.md 里的 domain model - **零逻辑变更**:thread.ts 里的 handler 代码和原来完全一致,只是搬了位置,风险极低 - **共享函数 export 合理**:`openStore`、`buildListOutput` 等从 workflow.ts export 给 thread.ts 复用,避免了代码重复 - **pagination hint 全部更新**:所有 `nerve workflow runs/inspect/thread` 的提示文案都改成了新命令路径 - **顺手修了 start 命令提示**:`nerve start` → `nerve daemon start`,统一了入口 - **cli.ts 同时清理了 start/stop/status/logs 顶层注册**,这些已经是 daemon 子命令了,移除正确 ### 📝 小建议(non-blocking) - `workflow list` 新增了从 nerve.yaml 读定义的功能(`readFileSync` + `parseNerveConfig`),这其实是一个小 feat,commit message 里可以提一下 - `formatRowsAsAlignedTable` 在 diff 里没看到定义,应该是已有的 util,没问题 430 tests pass ✅,LGTM 🚀
xiaomo merged commit 1f67552ff5 into main 2026-04-27 01:46:33 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#146