Skip to content

feat(cli): scriptable output, shell completion, and CLI refactor#51

Closed
Remeic wants to merge 4 commits into
mainfrom
feat/senior-polish
Closed

feat(cli): scriptable output, shell completion, and CLI refactor#51
Remeic wants to merge 4 commits into
mainfrom
feat/senior-polish

Conversation

@Remeic
Copy link
Copy Markdown
Owner

@Remeic Remeic commented Jun 1, 2026

Summary

Senior-polish pass that builds on the already-solid foundation (100% coverage + 100% mutation, multi-OS CI, release automation). Focus: scriptability, CLI craft, and removing duplication — plus docs that surface the genuinely sophisticated transactional design.

Changes

Refactor — refactor(cli)

  • src/lib/errors.ts — shared formatError (was duplicated in profile-store.ts + profile-config-copy.ts)
  • src/lib/ui.ts — central output/colors/icons on node:util styleText; NO_COLOR / non-TTY aware (clean strings in pipes, color in a terminal)
  • src/lib/run-action.ts — uniform CLI error handling (✗ message + exit 1); removes ~9 duplicated catch blocks and fixes list which previously had none (raw stack trace instead of clean error)

Features — feat(cli)

  • ccm list --json / ccm status --json — machine-readable output for scripting/piping; shared projection in profile-view.ts (emits null, not the placeholder)
  • ccm completion <bash|zsh|fish> — completion script with the command list derived from the live registry, so it never drifts as commands are added

Docs — docs

  • ARCHITECTURE.md — state reconciliation, the transactional stage→mutate→finalize + rollback protocol, the testability DI seam, and why error handling lives in runAction not index.ts
  • CLAUDE.md, .editorconfig, README (--json + completion sections), CONTRIBUTING link

Quality gates

  • ✅ Lint (Biome) clean
  • ✅ Build (tsup)
  • 365 tests pass (was 326)
  • ✅ Coverage 100% (statements / branches / functions / lines)
  • ✅ Mutation (Stryker) 100.00%, 0 survivors — every new lib/command file added to mutate[]; list.ts/status.ts newly added to the mutate set and brought to 100%

Notes

  • Zero new runtime dependencies — color via node:util styleText, completion hand-derived from program.commands.
  • Open questions resolved with defaults: CLAUDE.md only (no AGENTS.md), flat-array JSON shape, static command-name completion.

Verify

ccm list --json | jq '.[] | select(.loggedIn) | .name'
ccm completion zsh
NO_COLOR=1 ccm status   # no ANSI escapes

Remeic added 4 commits June 1, 2026 12:00
Extract shared formatError (errors.ts), terminal output/colors/icons
(ui.ts, NO_COLOR/TTY-aware via styleText), and a runAction wrapper that
gives every command uniform error UX. Removes duplicated catch blocks and
ANSI magic strings; fixes list-style commands lacking error handling.
list/status gain --json for scriptable output (shared projection in
profile-view.ts; null instead of the — placeholder). New ccm completion
<bash|zsh|fish> derives the command list from the live registry so it
never drifts. All new modules added to the Stryker mutate set.
ARCHITECTURE.md covers state reconciliation, the transactional
stage/rollback protocol, the testability DI seam, and why error handling
lives in runAction rather than index.ts. README documents --json and shell
completion; CLAUDE.md captures the build/test/mutation invariants.
@Remeic Remeic force-pushed the feat/senior-polish branch from 8acc222 to c57743c Compare June 1, 2026 10:01
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7bd68d5) to head (c57743c).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #51   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        25    +6     
  Lines          554       585   +31     
  Branches       137       135    -2     
=========================================
+ Hits           554       585   +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Remeic Remeic closed this Jun 1, 2026
@Remeic Remeic deleted the feat/senior-polish branch June 1, 2026 10:04
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.

1 participant