refactor(cli): registry-driven command dispatch module - #1451
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
0626634 to
487d644
Compare
0bb19e1 to
ee7fdbe
Compare
487d644 to
3562810
Compare
Ingwannu
left a comment
There was a problem hiding this comment.
I am deferring the content review because the stack no longer has reviewable ancestry after the root rewrite.
Current state:
- #1446 now has head
35628105on currentdev@87e3ff9f. - #1451's head
cb952c07is 6 commits ahead and 8 behind that new base; GitHub reportsmergeable: false,mergeable_state: dirty, andrebaseable: false. - #1455, #1456, and #1457 are stacked on the old #1451 lineage. Their previously green jobs therefore do not validate the stack that would actually land after the #1446 rewrite.
- The new exact-head #1446 run is currently red in Linux shard 3 and macOS (with shard 4 still running at the time of review). #1457's old run also ended red because the aggregate test job was cancelled after shard 3 hit the 15-minute bound. Those failures should not be “fixed” on stale child heads.
Please rebuild the stack sequentially: rebase #1451 onto the current #1446 head, then #1455 onto the new #1451 head, #1456 onto the new #1455 head, and #1457 onto the new #1456 head. Resolve the root exact-head CI failure first, then rerun CI on every resulting child head. Once ancestry is linear and the exact commits are green, request review again; reviewing the current diverged diff would mostly review code that the rebase will discard or rewrite.
Phase 3 of the CLI deepening: extract the command switch out of src/cli/index.ts into src/cli/dispatch.ts as a registry-driven runner table. index.ts becomes a thin main that passes its local lifecycle helpers through CliDispatchDeps; aliases resolve via the registry alias map. - dispatchCommand(head, deps) replaces the 61-case switch - behavior preserved: restore/sync/sync-cache/claude/route/integration/ health/ready/gui/codex-shim/update runners match the original bodies - source-level tests migrated to read dispatch.ts - typecheck green; CLI suite 211 pass (4 known pre-existing failures)
Phase 3 moved the command switch into src/cli/dispatch.ts as runner keys, but tests/codex-app-server-processes.test.ts still sliced the old case labels out of src/cli/index.ts. Update it to read the sync, sync-cache, v2, and gui runner bodies from dispatch.ts (using deps.args), which restores the #476 sync/sync-cache app-server-wiring assertions.
cb952c0 to
46b18f0
Compare
Summary
Extract command dispatch out of the entry module into a registry-driven runner table.
src/cli/dispatch.ts:dispatchCommand(head, deps)replaces the 61-case switch insrc/cli/index.ts. Each command is a runner keyed by name; aliases (setup/eject/remove/model) resolve through the registry alias map.src/cli/index.tsbecomes a thin main: it runs the head, then callsdispatchCommandwith its local lifecycle helpers (handleStart,handleStop,handleEnsure,handleStatus,handleReady, …) passed asCliDispatchDeps.dispatch.ts(cli-registry,cli-ready,grok-lifecycle,stale-state-purge,update*,uninstall,windows-deploy-*,codex-retained-root-serialization).Behavior is preserved: the
restore,sync,sync-cache,claude,route,integration,health,ready,gui,codex-shim, andupdaterunners match their original case bodies, including exit codes and the--helpshort-circuit.Verification
bun run typecheck— exit 0.cli-restore-back(2) andPOST /api/syncTask Scheduler (2) cases, proven identical on clean upstream/dev and unrelated to this change.ocx --version—opencodex 2.10.2, exit 0.ocx help nosuch— exit 1,Unknown command: nosuch.ocx ready --timeout 5— exit 64.ocx sync --help—Usage: ocx sync …, exit 0.No GUI changes; no screenshot required.
Checklist
Review notes (stacked PR): this PR stacks on #1446 (
codex/cli-registry). It does not targetdev. The diff here is only the dispatch extraction (7feb16c42..0bb19e1e): 11 files, +585/−513. Merge only after #1444 and #1446 land; the base will be retargeted then.Summary by CodeRabbit
New Features
Bug Fixes
Tests