refactor(cli): split cli-dispatch.ts into group dispatchers + usage module #101

Merged
xiaomo merged 1 commits from refactor/96-phase3-split-dispatch into main 2026-05-08 01:07:05 +00:00
Owner

What

Split the 775-line cli-dispatch.ts monolith into focused modules. Dispatch now only contains top-level routing (~149 lines).

Why

Phase 3 of RFC #93. cli-dispatch.ts was a god module containing all dispatch functions, subcommand tables, and usage formatting for every command group.

Changes

  • cli-dispatch.ts — 775 → 149 lines, keeps only runCli(), COMMAND_TABLE, DEPRECATED_ALIASES, dispatchGroup, dispatchSkill/Help
  • cli-usage.ts — formatCliUsage(), formatUsageCommandLines(), USAGE_SECTION_BY_GROUP
  • cli-command-types.ts — shared types: DispatchFn, CommandEntry, CommandGroup
  • cli-registry.ts — getCommandRegistry() assembling all group subcommand tables
  • cli-usage-context.ts — decouples usage from registry to avoid circular dependencies
  • commands/workflow/dispatch.ts — workflow dispatch functions + WORKFLOW_SUBCOMMAND_TABLE
  • commands/thread/dispatch.ts — thread dispatch functions + THREAD_SUBCOMMAND_TABLE
  • commands/cas/dispatch.ts — CAS dispatch functions + CAS_SUBCOMMAND_TABLE
  • commands/init/dispatch.ts — init dispatch functions + INIT_SUBCOMMAND_TABLE
  • 242 tests pass, CLI output identical, biome clean

Ref

Closes #96 (Phase 3 of #93)

## What Split the 775-line cli-dispatch.ts monolith into focused modules. Dispatch now only contains top-level routing (~149 lines). ## Why Phase 3 of RFC #93. cli-dispatch.ts was a god module containing all dispatch functions, subcommand tables, and usage formatting for every command group. ## Changes - `cli-dispatch.ts` — 775 → 149 lines, keeps only runCli(), COMMAND_TABLE, DEPRECATED_ALIASES, dispatchGroup, dispatchSkill/Help - `cli-usage.ts` — formatCliUsage(), formatUsageCommandLines(), USAGE_SECTION_BY_GROUP - `cli-command-types.ts` — shared types: DispatchFn, CommandEntry, CommandGroup - `cli-registry.ts` — getCommandRegistry() assembling all group subcommand tables - `cli-usage-context.ts` — decouples usage from registry to avoid circular dependencies - `commands/workflow/dispatch.ts` — workflow dispatch functions + WORKFLOW_SUBCOMMAND_TABLE - `commands/thread/dispatch.ts` — thread dispatch functions + THREAD_SUBCOMMAND_TABLE - `commands/cas/dispatch.ts` — CAS dispatch functions + CAS_SUBCOMMAND_TABLE - `commands/init/dispatch.ts` — init dispatch functions + INIT_SUBCOMMAND_TABLE - 242 tests pass, CLI output identical, biome clean ## Ref Closes #96 (Phase 3 of #93)
xingyue added 1 commit 2026-05-08 01:04:42 +00:00
- cli-dispatch.ts: 775 → 149 lines (top-level routing only)
- cli-usage.ts: usage formatting (formatCliUsage, formatUsageCommandLines)
- cli-command-types.ts: shared types (DispatchFn, CommandEntry, CommandGroup)
- cli-registry.ts: getCommandRegistry() assembling all group tables
- cli-usage-context.ts: decouple usage from registry (avoids circular deps)
- commands/{workflow,thread,cas,init}/dispatch.ts: group-specific dispatch
  functions + subcommand tables
- 242 tests pass, CLI output identical, biome clean

Refs #96
xiaomo approved these changes 2026-05-08 01:07:03 +00:00
xiaomo left a comment
Owner

LGTM 775 → 149 行,拆分干净,无行为变更。

cli-usage-context.ts 的 mutable singleton 解决循环依赖是务实的方案。USAGE_SKILL_TOPIC_ROWSskill.ts 有轻微重复,不阻塞。

—— 小墨 🖊️

LGTM ✅ 775 → 149 行,拆分干净,无行为变更。 `cli-usage-context.ts` 的 mutable singleton 解决循环依赖是务实的方案。`USAGE_SKILL_TOPIC_ROWS` 跟 `skill.ts` 有轻微重复,不阻塞。 —— 小墨 🖊️
xiaomo merged commit 665965fd01 into main 2026-05-08 01:07:05 +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#101