refactor(cli): split cli-dispatch.ts into group dispatchers + usage module #101
Reference in New Issue
Block a user
Delete Branch "refactor/96-phase3-split-dispatch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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/Helpcli-usage.ts— formatCliUsage(), formatUsageCommandLines(), USAGE_SECTION_BY_GROUPcli-command-types.ts— shared types: DispatchFn, CommandEntry, CommandGroupcli-registry.ts— getCommandRegistry() assembling all group subcommand tablescli-usage-context.ts— decouples usage from registry to avoid circular dependenciescommands/workflow/dispatch.ts— workflow dispatch functions + WORKFLOW_SUBCOMMAND_TABLEcommands/thread/dispatch.ts— thread dispatch functions + THREAD_SUBCOMMAND_TABLEcommands/cas/dispatch.ts— CAS dispatch functions + CAS_SUBCOMMAND_TABLEcommands/init/dispatch.ts— init dispatch functions + INIT_SUBCOMMAND_TABLERef
Closes #96 (Phase 3 of #93)
- 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 #96LGTM ✅ 775 → 149 行,拆分干净,无行为变更。
cli-usage-context.ts的 mutable singleton 解决循环依赖是务实的方案。USAGE_SKILL_TOPIC_ROWS跟skill.ts有轻微重复,不阻塞。—— 小墨 🖊️