Skip to content

Conversation

@boneskull
Copy link
Owner

chore(cli): split index.ts into focused modules

Reorganize the CLI codebase from a single 1118-line file into 13 focused
modules:

  • index.ts: Thin entry point (115 lines)
  • builder.ts: Command registration with bargs
  • context.ts: CliContext type and dependency injection
  • handlers.ts: Signal handlers for graceful shutdown
  • theme.ts: Synthwave color theme
  • parsers/: Directory for all bargs parser definitions
    • global.ts, run.ts, init.ts, analyze.ts, test.ts
    • history.ts, baseline.ts (subcommand parsers)
    • index.ts (re-exports)

Co-Authored-By: Claude [email protected]

chore(cli): use camelCaseValues transform for cleaner property access

Apply bargs' camelCaseValues transform to all parsers with kebab-case
options. This enables cleaner property access in command handlers:

  • values.noColor instead of values['no-color']
  • values.outputFile instead of values['output-file']
  • values.excludeTag instead of values['exclude-tag']
  • etc.

Co-Authored-By: Claude [email protected]

fix(cli): use process.exitCode instead of process.exit() in async handlers

process.exit() terminates immediately without letting async operations
complete properly. Using process.exitCode allows the event loop to drain
naturally.

Co-Authored-By: Claude [email protected]

Copilot AI review requested due to automatic review settings January 9, 2026 21:29
@github-actions github-actions bot added bug Something isn't working chore Build tooling, tests, configuration, overhead labels Jan 9, 2026
Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

boneskull and others added 3 commits January 9, 2026 13:32
Reorganize the CLI codebase from a single 1118-line file into 13 focused
modules:

- index.ts: Thin entry point (115 lines)
- builder.ts: Command registration with bargs
- context.ts: CliContext type and dependency injection
- handlers.ts: Signal handlers for graceful shutdown
- theme.ts: Synthwave color theme
- parsers/: Directory for all bargs parser definitions
  - global.ts, run.ts, init.ts, analyze.ts, test.ts
  - history.ts, baseline.ts (subcommand parsers)
  - index.ts (re-exports)

Co-Authored-By: Claude <[email protected]>
Apply bargs' camelCaseValues transform to all parsers with kebab-case
options. This enables cleaner property access in command handlers:

- values.noColor instead of values['no-color']
- values.outputFile instead of values['output-file']
- values.excludeTag instead of values['exclude-tag']
- etc.

Co-Authored-By: Claude <[email protected]>
…dlers

process.exit() terminates immediately without letting async operations
complete properly. Using process.exitCode allows the event loop to drain
naturally.

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the CLI codebase by splitting a monolithic 1118-line index.ts file into 13 focused modules for better maintainability. The refactoring includes:

  • Applying bargs' camelCaseValues transform for cleaner property access (e.g., values.noColor instead of values['no-color'])
  • Using process.exitCode instead of process.exit() in async command handlers to allow proper event loop drainage
  • Organizing code into focused modules: parsers, builders, handlers, context, and theme

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/cli/index.ts Refactored to thin entry point (115 lines), delegating to new modules
src/cli/builder.ts Command registration logic with bargs, uses process.exitCode for async handlers
src/cli/context.ts CLI context type and dependency injection, correctly uses camelCase properties
src/cli/handlers.ts Signal handlers extracted for graceful shutdown
src/cli/theme.ts Synthwave color theme configuration
src/cli/parsers/global.ts Global options with camelCaseValues transform
src/cli/parsers/run.ts Run command parser with validation (has critical bug with property access order)
src/cli/parsers/init.ts Init command parser with camelCaseValues transform
src/cli/parsers/analyze.ts Analyze command parser with validation
src/cli/parsers/test.ts Test command parser definition
src/cli/parsers/history.ts History subcommand parsers (has critical bug with property access order)
src/cli/parsers/baseline.ts Baseline subcommand parsers with camelCaseValues
src/cli/parsers/index.ts Re-exports all parser modules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 9, 2026 21:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@boneskull boneskull merged commit d830782 into main Jan 9, 2026
16 checks passed
@boneskull boneskull deleted the refactor-cli branch January 9, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working chore Build tooling, tests, configuration, overhead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants