refactor(cli): standardize operational scripts on a shared command runner - #352
Draft
s6pa1rta3n-lab wants to merge 1 commit into
Draft
refactor(cli): standardize operational scripts on a shared command runner#352s6pa1rta3n-lab wants to merge 1 commit into
s6pa1rta3n-lab wants to merge 1 commit into
Conversation
…nner - Create @sub-rosa/command package providing runCommand, context helpers, standard exit codes, signal handling, and structured diagnostics - Migrate all root check scripts and operational service scripts to runCommand - Eliminate raw process.exit calls in operational scripts, delegating process termination to the runner - Add scripts/check-command-runner.mjs and test to guard against command runner drift - Register command:test, command:typecheck, command-runner:check, and command-runner:test in root package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #237.
This PR introduces
@sub-rosa/command, a shared CLI and operational script command runner package, and migrates all root check scripts and service operational scripts to standardize lifecycle handling, signal termination, structured diagnostic logging, and deterministic exit codes.Key Changes
@sub-rosa/command):runCommand()with automaticnode:util.parseArgsargument parsing and--helpgeneration.CommandError,UsageError,ConfigError,DependencyError, andInterruptedError.CommandContext) with parsedoptions,positionals, repository root discovery (repoRoot), environment variables, andAbortSignalfor graceful shutdown.@sub-rosa/loggingand handles JSON error serialization when configured..d.ts).packages/command/test/runner.test.tscovering error classes, signal aborts, custom options, help text, and exit codes (11/11 pass).services/receipt-cli: Migrated all subcommands (verify,audit,export) torunCommand, eliminated rawprocess.exitinvocations.services/keeper: Migratedrun.ts,watch.ts,serve.ts,queue.ts, and end-to-end scripts (keeper-e2e.ts,lifecycle-e2e.ts,mainnet-settle.ts,usdc-setup.ts).packages/sdk: Migratedlive-smoke.ts,mainnet-ready.ts,mainnet-verify.ts, andmainnet-micro.ts.packages/tlock: Migratedrecover-identities.cli.ts.services/appraisal-api: Migratedusdc-setup.tsandx402-e2e.ts.services/agent: Migratedusdc-setup.tsandagents-e2e.ts.services/auction-template: Migratedsealed-auction.ts.check-links.js,check-deploy-docs.mjs,check-snapshots.mjs,check-threat-model-anchors.mjs,check-fixture-sizes.mjs,check-round-errors.mjs,check-direct-time-access.mjs,run-ts-coverage.mjs) onrunCommand.scripts/check-logging.mjstorunCommand.scripts/check-command-runner.mjsandscripts/check-command-runner.test.mjs.@sub-rosa/commandusage and prevent rawprocess.exitcalls.command:test,command:typecheck,command-runner:check, andcommand-runner:testtopackage.json.Verification
pnpm command:typecheckpasses with zero errors.pnpm command:testpasses all 11 test cases.pnpm command-runner:checkpasses across all 29 target scripts.pnpm command-runner:testpasses all unit tests.pnpm logging:checkandpnpm logging:testpass.pnpm receipt:typecheckandpnpm receipt:testpass (19/19 tests).pnpm keeper:typecheckandpnpm keeper:testpass (73/73 tests).pnpm --filter @sub-rosa/appraisal-api typecheckand test pass (49/49 tests).pnpm --filter @sub-rosa/agent typecheckand test pass (21/21 tests).pnpm --filter @sub-rosa/tlock typecheckand test pass (58/58 tests).node scripts/run-ts-coverage.mjspasses weighted coverage gate at 78.78% (threshold: 70.00%).Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC