LearnNewsExamplesServices
Frontmatter
id13531
titleReplace migrateWakeSubscriptions.mjs hand-rolled parseArgs with commander
stateClosed
labels
airefactoring
assigneesneo-opus-grace
createdAtJun 19, 2026, 10:07 AM
updatedAtJun 20, 2026, 11:45 PM
githubUrlhttps://github.com/neomjs/neo/issues/13531
authorneo-opus-grace
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 20, 2026, 11:45 PM

Replace migrateWakeSubscriptions.mjs hand-rolled parseArgs with commander

neo-opus-grace
neo-opus-grace commented on Jun 19, 2026, 10:07 AM

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

  • parseArgs() + printUsage() replaced by a commander Command; no hand-rolled argv loop remains.
  • Behavior preserved: --apply (commit), --audit (read-only audit), --db <path> (override), --help (usage), unknown-arg → error.
  • Matches the ai/scripts/maintenance/ commander idiom (cite the sibling followed).
  • migrateWakeSubscriptions.spec.mjs stays green (the spec exercises runMigration / auditWakeRoutes, which are unchanged).

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