Skip to content

Phase P0: moved-command table and --apply helper - #2316

Merged
neuromechanist merged 7 commits into
feature/issue-2307-epic-admin-treefrom
feature/issue-2308-phase0-moved-commands
Nov 22, 2026
Merged

neuromechanist merged 7 commits into
feature/issue-2307-epic-admin-treefrom
feature/issue-2308-phase0-moved-commands

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Scaffolding for the admin command tree restructure (ADR 0135). No command path changes.

  • src/lib/moved-commands.ts: one table, MOVED_COMMANDS: { oldPath, newPath }[], and registerMovedCommands(root, rows), which registers each old path as a hidden stub (helpOption(false), allowUnknownOption, allowExcessArguments) that prints one stderr line naming the new path, calls markReportedExit() and exits 1. The three ADR 0125 stubs (publish, withdraw, restore) move into the table with their wording unchanged. Later phases append rows only.
  • Old paths under a live group (fleet annex-policy while fleet stays) register a leaf stub under that group; old paths under a gone group (s3 lock once s3 dissolves) share one stub on the gone group, which picks the longest matching row. Registration throws on an old path that is still a live command, a duplicate row, or a gone group with no row of its own.
  • exitIfMovedCommand(program, argv) runs in src/index.ts right after the tree is built and before the update check, the notices hook and Commander's parse, so a stub wins over the root's -v/--version, prints no update banner and makes no request; before this, the three stubs fetched /notices before failing. The root preAction hook also skips /notices for a stub (isMovedCommandStub) as a second line.
  • A stub now answers --help with its pointer and exit 1 instead of printing an empty help page with exit 0 (the plan's P4 analysis already assumed exit 1).
  • src/lib/apply-flag.ts: addApplyOption(cmd, description, aliases) declares --apply plus hidden --execute, --write or --fix aliases that set apply and remove their own key. No command is converted yet.

Closes #2308

Part of epic #2307

Test plan

  • bun run lint and bun run typecheck clean
  • test/moved-commands.unit.test.ts (61, pure tier: the stand-in is set as the account's stored apiUrl): every table row spawned through bun run src/index.ts with seven argument shapes (bare, a real call with --execute --yes, --help, junk options, --version 2.0.0, -v, --debug) exits 1, prints exactly the one pointer line, prints nothing on stdout, and sends no request to a Bun.serve stand-in that records every request (isolated NEMAR_CONFIG_DIR with an admin key); each new path answers --help with exit 0; nested and gone-group rows checked through a fixture tree with the same root options, and a walk of that tree proving every stub it registers is recognized as one; an outdated CLI (seeded update cache, with a control showing the banner on a live command) still prints only the pointer; the three refusal cases of registerMovedCommands
  • test/apply-flag.unit.test.ts (8): every spelling sets opts.apply, aliases are absent from help and leave no key, an undeclared alias stays an unknown option
  • test/admin-restructure.test.ts and test/help-tiers.unit.test.ts pass (99 tests across the four files)
  • Mutation, forwarding direction: a stub that forwards to its new path instead of failing fails 16 of 25 tests; reverted
  • Mutation: dropping the /notices skip fails 12 tests on GET /notices; reverted
  • Mutation: dropping the early exitIfMovedCommand call fails 7 tests (every --version 2.0.0 and -v shape, and the banner test); reverted
  • Mutation: registering nested stubs outside the registry fails 3 tests; reverted
  • admin help <old path> gets the pointer for every row and in the fixture tree; admin users show publish, admin approve publish, admin repo publish --help and admin users show --query publish reach the live command or Commander's own error, never a pointer
  • Guard: no option on the root, admin or a group with a stub child takes a value (the walk skips option tokens only); adding --profile <name> to the root and --as <user> to admin fails both guard tests with the explanatory message; reverted
  • Mutation: dropping the help step fails 7 tests; restoring the old undefined-valued alias key fails 3 apply-flag tests; reverted
  • Full bun test not run (runs at epic to dev)

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2316

Version: 0.10.39-PR2316.7486488
Commit: 7486488


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 2c72ccc into feature/issue-2307-epic-admin-tree Nov 22, 2026
45 of 53 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2308-phase0-moved-commands branch November 22, 2026 17:37

This branch was previously deployed

1 inactive deployment
npm — 7486488a Deployed Nov 22, 2026 by neuromechanist via publish #4751
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