Skip to content

Cleanup: Make index.ts a composition root#75

Merged
z00b merged 4 commits intomainfrom
phase-2c/composition-root
Mar 14, 2026
Merged

Cleanup: Make index.ts a composition root#75
z00b merged 4 commits intomainfrom
phase-2c/composition-root

Conversation

@schurchleycci
Copy link
Contributor

@schurchleycci schurchleycci commented Mar 10, 2026

Summary

  • Moves command-specific help text, options, and parser helpers from src/index.ts into corresponding src/commands/* modules
  • Each command module now exports a register*Command(program) function
  • src/index.ts reduced to ~50 lines: program creation, registration calls, and error handling

Will wait until #74 is merged and rebase this branch so we don't have to move things around twice.

Test plan

  • bun run typecheck passes
  • All tests pass
  • CLI commands still work (--help, etc.)

🤖 Generated with Claude Code

@schurchleycci schurchleycci force-pushed the phase-2c/composition-root branch from c841a6a to 685874a Compare March 10, 2026 17:28
@schurchleycci schurchleycci force-pushed the phase-2a/fix-import-direction branch from ffddafb to 19ef5b5 Compare March 10, 2026 18:29
@schurchleycci schurchleycci force-pushed the phase-2c/composition-root branch from 685874a to 9402298 Compare March 10, 2026 18:30
@schurchleycci schurchleycci changed the title Phase 2c: Make index.ts a composition root Cleanup Phase 2c: Make index.ts a composition root Mar 10, 2026
@schurchleycci schurchleycci force-pushed the phase-2a/fix-import-direction branch from 19ef5b5 to 6f5faf8 Compare March 10, 2026 19:55
Base automatically changed from phase-2a/fix-import-direction to main March 10, 2026 20:33
@danmux
Copy link
Contributor

danmux commented Mar 11, 2026

src/commands/build-prompt.ts:90 - The .action() callback uses an explicit options: ParsedBuildPromptFlags type annotation instead of relying on Commander's inferred type. If the .option() definitions drift from ParsedBuildPromptFlags, this cast would silently hide the mismatch. Could this use Commander's inferred type instead?

@schurchleycci schurchleycci force-pushed the phase-2c/composition-root branch 2 times, most recently from 08e5371 to f5a54d9 Compare March 11, 2026 14:12
@schurchleycci
Copy link
Contributor Author

src/commands/build-prompt.ts:90 - The .action() callback uses an explicit options: ParsedBuildPromptFlags type annotation instead of relying on Commander's inferred type. If the .option() definitions drift from ParsedBuildPromptFlags, this cast would silently hide the mismatch. Could this use Commander's inferred type instead?

Good catch, this is addressed now!

@schurchleycci schurchleycci marked this pull request as ready for review March 11, 2026 14:18
@schurchleycci schurchleycci changed the title Cleanup Phase 2c: Make index.ts a composition root Cleanup: Make index.ts a composition root Mar 11, 2026
schurchleycci and others added 3 commits March 12, 2026 10:40
Move command-specific CLI definitions (flags, help text, examples, parser
helpers, option defaults) out of src/index.ts into their respective
src/commands/* modules. Each command module now exports a register*()
function that takes the Commander program and registers itself, following
the same pattern already used by @chunk/hook's registerHookCommands().

This keeps index.ts limited to program creation, command registration
calls, and top-level error handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Drop explicit ParsedBuildPromptFlags annotation on .action() callback,
  letting Commander infer the type (consistent with task.ts)
- Un-export ParsedBuildPromptFlags, runAuthStatus, runAuthLogout since
  they are now only used within their own modules
- Remove duplicate -h/--help line from build-prompt addHelpText

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unnecessary exports from runConfigShow, runConfigSet, and
runTaskConfig now that registration functions are the public API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hanabel1 hanabel1 force-pushed the phase-2c/composition-root branch from 39868c6 to c59951b Compare March 12, 2026 17:41
Move sandbox command registration out of index.ts and into a
registerSandboxCommands() function in commands/sandbox.ts, matching
the pattern used by all other command modules. Handler functions are
made private; validatePublicKey and resolvePublicKeyFile remain exported
for unit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@z00b
Copy link
Contributor

z00b commented Mar 14, 2026

/chunk-review agrees with my assessment that this is in good shape. one non-urgent suggestion that i will put up in a separate PR.

@z00b z00b merged commit 6f73fec into main Mar 14, 2026
5 checks passed
@z00b z00b deleted the phase-2c/composition-root branch March 14, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants