Reduce shipped CLI complexity hotspots
Merged
UN
4mo ago+1531+1531+0123456789012345678901234567890123456789-1263-1263-0123456789012345678901234567890123456789
Summary
- Extracted large CLI registration action bodies into named helpers across list/query, mutation, and operation command registration.
- Split shipped-code complexity hotspots in activity, close-many, commander usage guidance, extension doctor runtime activation diagnostics, and runtime schema normalization.
- Deduplicated shared option-string reading through
registration-helpers.tsand recorded the continuation under canonicalpm-92ifwithout creating a duplicate PM item.
PM Evidence
- Tracked under
pm-92ifwith linked source files, test commands, and evidence comments. pm-changelog@2026.6.30generated/check mode leftCHANGELOG.mdunchanged withitem_count=1388.
Verification
pnpm buildpnpm typecheck- Focused affected suite:
node scripts/run-tests.mjs test -- tests/unit/cli/register-list-query.spec.ts tests/unit/cli/cli-main-errors.spec.ts tests/unit/commands/history-activity-command.spec.ts tests/unit/commands/close-command.spec.ts tests/unit/commands/close-many-branch.spec.ts tests/unit/core/schema/runtime-schema-command-flags.spec.ts tests/unit/commands/contracts-command.spec.ts tests/unit/sdk/sdk-index.spec.ts tests/unit/extensions/extension-command.spec.ts(545 tests) - Final review-fix focused suite:
node scripts/run-tests.mjs test -- tests/unit/commands/history-activity-command.spec.ts tests/unit/cli/register-list-query.spec.ts tests/unit/cli/registration-helpers.spec.ts tests/unit/commands/contracts-command.spec.ts tests/unit/sdk/sdk-index.spec.ts(264 tests) pnpm lint(ESLint clean, jscpd 0 clones across 547 files, static quality passed)pnpm contracts:checknode scripts/run-tests.mjs coverage(262 files / 5277 tests / 100% statements, branches, functions, lines)node scripts/smoke-npx-from-pack.mjs(packed package smoke passed for 2026.7.2, packages=11)- Manual temp-directory installed-CLI smoke in
/tmp/tmp.5agjTscYIG:pm init,create,list-open, compactactivity,close,health pnpm security:scanandpnpm audit --audit-level moderatepm health --check-only --summary --jsonclean,pm validate --check-resolution --check-history-drift --jsonhistory drift ok with known resolution-metadata backlognode scripts/release/sentry-telemetry-gate.mjs --json --telemetry-mode best-effortokpnpm changelog:pmandpnpm changelog:pm:check- Pre-push
greptile review --branch main --json: final pass confidence 5, safe to merge, no comments
GitHub Sweep
- Open PRs/issues were empty before opening this PR.
- Secret scanning returned no alerts.
- Dependabot and CodeQL alert APIs returned only fixed alerts.
Summary by cubic
Refactors the CLI to reduce complexity by extracting helpers and splitting large flows. Improves maintainability with no user-facing changes and supports pm-92if.
- Refactors
- Extracted command registration actions into named helpers across list/query, mutations, and operations (e.g.,
registerListCommand,addHiddenOptions, lifecycle option builders). - Split large logic in
activity,close-many(plan orchestration and closeability checks), commander unknown-command guidance, extension doctor runtime activation path collection, and runtime schema status normalization into focused helpers. - Centralized option-string parsing with
readOptionStringinregistration-helpers.tsand removed duplicates in registration modules. - Continues progress toward
pm-92ifgoals for A+ CodeFactor and zero complexity/duplication issues.
- Extracted command registration actions into named helpers across list/query, mutations, and operations (e.g.,