Context
Operator-flagged on PR #13511's diff: ai/scripts/migrations/migrateWakeSubscriptions.mjs hand-rolls CLI argument parsing. commander is already the repo convention — a devDependency (^14.0.3) used by ~10 ai/scripts/maintenance/ scripts (purgeTestCollections.mjs, compactGraphLog.mjs, defragChromaDB.mjs, auditGraphIntegrity.mjs, …). This ticket aligns the migration script to that established pattern; it is convention-alignment, not a new dependency.
Live latest-open sweep: checked open issues for commander/parseArgs/CLI-arg refactors at ~2026-06-19T08:05Z; no equivalent.
Release classification: boardless (refactor / consistency; post-v13).
The Problem
migrateWakeSubscriptions.mjs hand-rolls a parseArgs(argv) loop + a printUsage() for --apply / --audit / --db <path> / --help, including manual unknown-argument handling. This duplicates — less robustly — what commander provides declaratively (option definitions, value coercion, auto-generated --help, unknown-option errors), and diverges from the maintenance-script convention.
The Fix
Replace parseArgs() + printUsage() with a commander Command:
.option('--apply', ...), .option('--audit', ...), .option('--db <path>', ...), auto --help.
- Mirror the existing idiom in a sibling, e.g.
ai/scripts/maintenance/purgeTestCollections.mjs.
- Keep the
main() dispatch + the exported runMigration / auditWakeRoutes / resolveRouteAddress untouched (only the argv → options surface changes).
Avoided Traps / Gold Standards Rejected
- Node built-in
util.parseArgs (available — engines.node >=24, running v25): rejected. Introducing a second arg-parsing primitive would fragment the convention already standardized on commander. Consistency > minimalism here.
Sequencing / Blocked-by
Blocked-by #13511. That PR modifies this same file (adds --audit / auditWakeRoutes). Land this refactor only after #13511 merges, or it conflicts with the unmerged --audit addition.
Acceptance Criteria
Out of Scope
- The other hand-rolled-argv holdouts (
runSandman.mjs, runAgent.mjs, several buildScripts/create/*, …) — a broader convention-sweep belongs in its own ticket; this one is the migration script only.
Related
- Surfaced in: PR #13511 (Resolves #13510, Refs #13481) — the wake-route disambiguation work that added
--audit.
Origin Session ID
045a6048-1e1d-44c1-9738-7f09b62cc998
Context
Operator-flagged on PR #13511's diff:
ai/scripts/migrations/migrateWakeSubscriptions.mjshand-rolls CLI argument parsing.commanderis already the repo convention — a devDependency (^14.0.3) used by ~10ai/scripts/maintenance/scripts (purgeTestCollections.mjs,compactGraphLog.mjs,defragChromaDB.mjs,auditGraphIntegrity.mjs, …). This ticket aligns the migration script to that established pattern; it is convention-alignment, not a new dependency.Live latest-open sweep: checked open issues for
commander/parseArgs/CLI-arg refactors at ~2026-06-19T08:05Z; no equivalent. Release classification: boardless (refactor / consistency; post-v13).The Problem
migrateWakeSubscriptions.mjshand-rolls aparseArgs(argv)loop + aprintUsage()for--apply/--audit/--db <path>/--help, including manual unknown-argument handling. This duplicates — less robustly — whatcommanderprovides declaratively (option definitions, value coercion, auto-generated--help, unknown-option errors), and diverges from the maintenance-script convention.The Fix
Replace
parseArgs()+printUsage()with acommanderCommand:.option('--apply', ...),.option('--audit', ...),.option('--db <path>', ...), auto--help.ai/scripts/maintenance/purgeTestCollections.mjs.main()dispatch + the exportedrunMigration/auditWakeRoutes/resolveRouteAddressuntouched (only the argv → options surface changes).Avoided Traps / Gold Standards Rejected
util.parseArgs(available —engines.node >=24, running v25): rejected. Introducing a second arg-parsing primitive would fragment the convention already standardized oncommander. Consistency > minimalism here.Sequencing / Blocked-by
Blocked-by #13511. That PR modifies this same file (adds
--audit/auditWakeRoutes). Land this refactor only after #13511 merges, or it conflicts with the unmerged--auditaddition.Acceptance Criteria
parseArgs()+printUsage()replaced by acommanderCommand; no hand-rolled argv loop remains.--apply(commit),--audit(read-only audit),--db <path>(override),--help(usage), unknown-arg → error.ai/scripts/maintenance/commander idiom (cite the sibling followed).migrateWakeSubscriptions.spec.mjsstays green (the spec exercisesrunMigration/auditWakeRoutes, which are unchanged).Out of Scope
runSandman.mjs,runAgent.mjs, severalbuildScripts/create/*, …) — a broader convention-sweep belongs in its own ticket; this one is the migration script only.Related
--audit.Origin Session ID
045a6048-1e1d-44c1-9738-7f09b62cc998