@phnx-labs/agents-cli 1.22.53 → 1.22.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CHANGELOG.md +190 -0
  2. package/README.md +41 -8
  3. package/dist/bootstrap.js +55 -154
  4. package/dist/cli/command-registry.d.ts +5 -0
  5. package/dist/cli/command-registry.js +8 -1
  6. package/dist/commands/accounts.js +219 -173
  7. package/dist/commands/apply.js +6 -3
  8. package/dist/commands/auth-mint.d.ts +8 -0
  9. package/dist/commands/auth-mint.js +96 -0
  10. package/dist/commands/auth.js +5 -1
  11. package/dist/commands/browser.js +1 -1
  12. package/dist/commands/cost.js +8 -2
  13. package/dist/commands/daemon.js +2 -2
  14. package/dist/commands/doctor.js +6 -1
  15. package/dist/commands/exec.js +10 -8
  16. package/dist/commands/focus.d.ts +1 -0
  17. package/dist/commands/focus.js +2 -2
  18. package/dist/commands/go.d.ts +5 -4
  19. package/dist/commands/go.js +7 -7
  20. package/dist/commands/insights.js +9 -0
  21. package/dist/commands/monitors.js +85 -30
  22. package/dist/commands/output.js +8 -2
  23. package/dist/commands/repo.js +18 -0
  24. package/dist/commands/secrets.js +33 -14
  25. package/dist/commands/sessions.d.ts +20 -12
  26. package/dist/commands/sessions.js +64 -20
  27. package/dist/commands/setup-accounts.d.ts +8 -0
  28. package/dist/commands/setup-accounts.js +47 -0
  29. package/dist/commands/setup.d.ts +1 -1
  30. package/dist/commands/setup.js +11 -2
  31. package/dist/commands/share.d.ts +52 -3
  32. package/dist/commands/share.js +262 -18
  33. package/dist/commands/ssh.d.ts +7 -0
  34. package/dist/commands/ssh.js +18 -2
  35. package/dist/commands/status.js +14 -0
  36. package/dist/commands/view.d.ts +3 -1
  37. package/dist/commands/view.js +5 -4
  38. package/dist/lib/account-registry.js +15 -3
  39. package/dist/lib/accounting/rotate.d.ts +20 -6
  40. package/dist/lib/accounting/rotate.js +38 -7
  41. package/dist/lib/accounting/usage.d.ts +37 -1
  42. package/dist/lib/accounting/usage.js +71 -6
  43. package/dist/lib/agent-spec/agents.d.ts +5 -2
  44. package/dist/lib/agent-spec/agents.js +25 -7
  45. package/dist/lib/analytics/mix-commands.js +12 -6
  46. package/dist/lib/auth-mint.d.ts +150 -0
  47. package/dist/lib/auth-mint.js +434 -0
  48. package/dist/lib/browser/remote-control.d.ts +9 -7
  49. package/dist/lib/browser/remote-control.js +9 -7
  50. package/dist/lib/claude-account-token.d.ts +10 -0
  51. package/dist/lib/claude-account-token.js +14 -4
  52. package/dist/lib/config-drift.d.ts +37 -0
  53. package/dist/lib/config-drift.js +72 -0
  54. package/dist/lib/daemon/auth-sync-service.d.ts +19 -0
  55. package/dist/lib/daemon/auth-sync-service.js +34 -0
  56. package/dist/lib/daemon/daemon.js +30 -4
  57. package/dist/lib/daemon-services.d.ts +1 -1
  58. package/dist/lib/daemon-services.js +5 -0
  59. package/dist/lib/device-config.d.ts +3 -3
  60. package/dist/lib/device-config.js +5 -5
  61. package/dist/lib/devices/connect.d.ts +26 -0
  62. package/dist/lib/devices/connect.js +48 -1
  63. package/dist/lib/devices/doctor-findings.d.ts +5 -1
  64. package/dist/lib/devices/doctor-findings.js +19 -1
  65. package/dist/lib/exec.d.ts +28 -0
  66. package/dist/lib/exec.js +73 -7
  67. package/dist/lib/feed/feed.d.ts +1 -1
  68. package/dist/lib/feed/feed.js +23 -1
  69. package/dist/lib/feed-broadcast.js +1 -1
  70. package/dist/lib/fleet/apply.d.ts +11 -0
  71. package/dist/lib/fleet/apply.js +23 -3
  72. package/dist/lib/fleet/auth-sync.js +5 -3
  73. package/dist/lib/help.d.ts +9 -0
  74. package/dist/lib/help.js +29 -1
  75. package/dist/lib/hosts/passthrough.d.ts +1 -10
  76. package/dist/lib/hosts/passthrough.js +1 -13
  77. package/dist/lib/installations/versions.js +9 -1
  78. package/dist/lib/linux-userns.d.ts +58 -0
  79. package/dist/lib/linux-userns.js +116 -0
  80. package/dist/lib/memory.d.ts +26 -0
  81. package/dist/lib/memory.js +80 -1
  82. package/dist/lib/monitors/config.d.ts +11 -0
  83. package/dist/lib/monitors/config.js +8 -0
  84. package/dist/lib/monitors/engine.js +8 -1
  85. package/dist/lib/monitors/state.d.ts +37 -1
  86. package/dist/lib/monitors/state.js +79 -4
  87. package/dist/lib/permissions-registry.d.ts +2 -0
  88. package/dist/lib/permissions-registry.js +116 -14
  89. package/dist/lib/permissions.d.ts +5 -3
  90. package/dist/lib/permissions.js +25 -27
  91. package/dist/lib/profiles.d.ts +8 -7
  92. package/dist/lib/profiles.js +12 -0
  93. package/dist/lib/project-key.d.ts +9 -0
  94. package/dist/lib/project-key.js +11 -0
  95. package/dist/lib/secrets/bundles.d.ts +35 -0
  96. package/dist/lib/secrets/bundles.js +78 -1
  97. package/dist/lib/secrets/push.d.ts +3 -8
  98. package/dist/lib/secrets/push.js +18 -14
  99. package/dist/lib/secrets/remote.d.ts +9 -18
  100. package/dist/lib/secrets/remote.js +11 -26
  101. package/dist/lib/secrets/reserved-sync.d.ts +65 -0
  102. package/dist/lib/secrets/reserved-sync.js +129 -0
  103. package/dist/lib/self-heal/checks/hook-manifest.d.ts +2 -0
  104. package/dist/lib/self-heal/checks/hook-manifest.js +56 -0
  105. package/dist/lib/self-heal/registry.js +4 -0
  106. package/dist/lib/self-heal/types.d.ts +1 -1
  107. package/dist/lib/session/active.js +1 -4
  108. package/dist/lib/session/db.d.ts +39 -4
  109. package/dist/lib/session/db.js +130 -29
  110. package/dist/lib/session/discover.d.ts +32 -4
  111. package/dist/lib/session/discover.js +119 -25
  112. package/dist/lib/session/insights.d.ts +14 -0
  113. package/dist/lib/session/insights.js +25 -2
  114. package/dist/lib/session/linear.js +1 -1
  115. package/dist/lib/session/shell-programs.d.ts +17 -0
  116. package/dist/lib/session/shell-programs.js +21 -0
  117. package/dist/lib/session/state.js +2 -1
  118. package/dist/lib/session/stream-render.js +2 -1
  119. package/dist/lib/session/tool-calls.js +2 -5
  120. package/dist/lib/session/trajectory-html.js +2 -1
  121. package/dist/lib/session/trajectory.js +3 -12
  122. package/dist/lib/session/types.d.ts +8 -0
  123. package/dist/lib/share/publish.d.ts +53 -5
  124. package/dist/lib/share/publish.js +99 -17
  125. package/dist/lib/share/worker-template.js +582 -57
  126. package/dist/lib/startup/root-command.js +2 -1
  127. package/dist/lib/state.d.ts +16 -0
  128. package/dist/lib/state.js +178 -46
  129. package/dist/lib/sync-status.d.ts +4 -0
  130. package/dist/lib/sync-status.js +3 -0
  131. package/dist/lib/traces/classify.js +24 -19
  132. package/dist/lib/usage-refresh.js +2 -1
  133. package/dist/lib/view-types.d.ts +2 -0
  134. package/package.json +2 -1
package/dist/bootstrap.js CHANGED
@@ -59,9 +59,9 @@ if (IS_DEV_BUILD) {
59
59
  // registerAllEagerCommands path was removed (RUSH-2329): unknown/typo commands
60
60
  // spellcheck against KNOWN_TOP_LEVEL_COMMANDS and register only the corrected
61
61
  // name.
62
- import { COMMAND_LOADERS, LAZY_COMMAND_NAMES, KNOWN_TOP_LEVEL_COMMANDS, RETIRED_TOP_LEVEL_COMMANDS, } from './cli/command-registry.js';
62
+ import { COMMAND_LOADERS, LAZY_COMMAND_NAMES, KNOWN_TOP_LEVEL_COMMANDS, RETIRED_TOP_LEVEL_COMMANDS, registerAllCommands, } from './cli/command-registry.js';
63
63
  import { closestTopLevelCommand } from './lib/startup/spellcheck.js';
64
- import { applyGlobalHelpConventions } from './lib/help.js';
64
+ import { applyGlobalHelpConventions, FRONT_DOOR_COMMAND_GROUPS, registerCommandGroups, setCompactRootHelp, } from './lib/help.js';
65
65
  import { renderWhatsNew } from './lib/whats-new.js';
66
66
  import { getCliLaunch } from './lib/cli-entry.js';
67
67
  import { emit, emitFriction, redactArgs } from './lib/feed/events.js';
@@ -75,6 +75,8 @@ import { hasHostRoutingFlag } from './lib/hosts/routing-flag.js';
75
75
  // unset) resolves to 'agents' and everything below is byte-identical to before.
76
76
  const BRAND = resolveBrandName();
77
77
  const program = configureRootCommand(new Command(), BRAND, VERSION);
78
+ registerCommandGroups(program, FRONT_DOOR_COMMAND_GROUPS);
79
+ program.option('--help-all', 'Show help for all commands');
78
80
  // ─── Audit backbone ────────────────────────────────────────────────────────────
79
81
  // One choke point logs every `agents <module> <cmd>` invocation to the structured
80
82
  // event log — so team create/disband, agent run, secrets access, and everything
@@ -176,128 +178,6 @@ program.hook('postAction', (_thisCommand, actionCommand) => {
176
178
  // Best-effort completion record; the start line is the durable audit fact.
177
179
  }
178
180
  });
179
- /**
180
- * Skin the static root help for a brand: rewrite the visible `agents` command
181
- * examples to the brand name and drop lines for commands this brand disabled.
182
- * A no-op for the unbranded `agents` CLI with nothing disabled.
183
- */
184
- function brandRootHelp(raw) {
185
- let text = raw;
186
- if (BRAND !== 'agents') {
187
- text = text
188
- .replace(/Usage: agents /g, `Usage: ${BRAND} `)
189
- .replace(/^ {2}agents /gm, ` ${BRAND} `)
190
- .replace(/Run 'agents /g, `Run '${BRAND} `);
191
- }
192
- const disabled = disabledCommandsForActiveBrand();
193
- if (disabled.size > 0) {
194
- text = text
195
- .split('\n')
196
- .filter((line) => {
197
- const m = line.match(/^ {2}([a-z][\w-]*)/);
198
- return !(m && disabled.has(m[1]));
199
- })
200
- .join('\n');
201
- }
202
- return text;
203
- }
204
- // Custom help for the main program only
205
- const originalHelpInformation = program.helpInformation.bind(program);
206
- program.helpInformation = function () {
207
- if (this.name() === BRAND && !this.parent) {
208
- return brandRootHelp(`Usage: agents [command] [options]
209
-
210
- Install, configure, run, and dispatch AI coding agents from one place.
211
- Works with Claude, Codex, Antigravity, Cursor, OpenCode, OpenClaw, and Droid.
212
-
213
- Quick start:
214
- agents setup First-time setup (interactive); setup beta enables preview features
215
- agents view See what's installed
216
- agents run <agent> ["prompt"] Run an agent (interactive without prompt, headless with)
217
- agents sessions Browse past sessions across all agents
218
-
219
- Agent versions:
220
- add <agent>[@version] Install an agent CLI (e.g. agents add grok or agents add codex)
221
- import <agent> Adopt an existing global install (npm/homebrew) into agents-cli
222
- update <agent>[@version] Move an installed agent to a new release, keeping its name (agents-cli itself is 'agents upgrade')
223
- prune <agent>[@version] Uninstall a version
224
- remove <agent>[@version] Alias for prune
225
- use <agent>@<version> Set the default version
226
- prune cleanup [target] Remove orphan resources and older duplicate version installs
227
- trash Inspect and restore soft-deleted version directories
228
- view [agent[@version]] List versions, inspect one in detail, or --merged for the cross-layer resource surface
229
- inspect <target> Deep details for one agent+version, or a DotAgents repo (user|system|project|alias|path)
230
-
231
- Agent configuration (synced across versions):
232
- rules Instructions given to agents (CLAUDE.md, etc.)
233
- commands Slash commands (/commit, /test, etc.)
234
- skills Knowledge packs (SKILL.md + supporting files)
235
- mcp MCP servers (stdio or HTTP)
236
- permissions Allow/deny rules for tool calls
237
- hooks Shell scripts that run on agent events (hooks.yaml in agents.yaml)
238
- subagents Named sub-agent definitions
239
- plugins Bundles of skills, hooks, and scripts
240
-
241
- Packages:
242
- search <query> Find MCP servers and skills in registries
243
- install <pkg> Install from registry (mcp:name, skill:user/repo)
244
-
245
- Run and dispatch:
246
- run <agent|profile> [prompt] Run an agent. Omit prompt for interactive mode.
247
- config Configure run defaults, project root, device options, and spend caps (config budget)
248
- teams Coordinate multiple agents on shared work
249
- routines Run agents on a cron schedule (scheduler auto-starts)
250
- daemon Runtime status/control for the always-on daemon (secrets broker, browser IPC, scheduler)
251
- webhook Receive signed GitHub/Linear webhooks for trigger routines
252
- funnel Expose a webhook receiver through Tailscale Funnel
253
- sessions Browse, search, and replay past runs (live-search in TTY; grouped by workspace)
254
- logs [id] Show a run's log — host-dispatch task or session; -f to follow
255
- browser Automate a browser — navigate, click, screenshot, console, network
256
- pty Drive interactive terminal programs (REPLs, TUIs) via a persistent PTY session
257
- artifacts Publish what an agent made (plans, reports, visuals) to a shareable link
258
-
259
- Observe (read the fleet — no store merge):
260
- feed Needs-you inbox (open blocks waiting on you); agent posts = feed --filter updates
261
- sessions --active Live agents (who is running right now)
262
- events Unified ops + activity event trail
263
- events audit Dispatched-run outcomes (alias of events --include runs)
264
- sync status Sync/drift only (not the live fleet snapshot)
265
- devices snapshot One-process inventory + active sessions poll
266
-
267
- Credentials (harness keys):
268
- harness Custom (host CLI + model + auth) harnesses; replaces former profiles command
269
- secrets Keychain-backed env bundles; synced vault: secrets vault unlock|lock
270
- accounts Provider credentials + native OAuth logout
271
-
272
- Diagnostics:
273
- doctor [agent[@version]] Diagnose CLI availability, sync status, and resource divergence; --check for the CI drift gate
274
- usage [agent] Show rate-limit and quota usage per agent
275
- insights How work looks — behaviour (default), mix, cost, and output
276
- perf Latency rollups (hooks, commands, runs) from the disposable perf warehouse
277
-
278
- Config sync:
279
- repo pull [alias] Git pull a repo (system | user | <extra>)
280
- sync [agent] Re-materialize installed version homes; --local to skip fetching
281
- repo init --path <dir> Scaffold your own editable repo from a template
282
- repo add <path|gh:user/repo> Merge an extra repo after the system repo
283
-
284
- Automation tips:
285
- Pass explicit names/IDs Avoid pickers: agents sessions <id> --markdown
286
- Use --yes for defaults Auto-accept sync/default prompts on add/use/pull
287
- Use --names for central items e.g. agents commands add --names review-pr,debug
288
- Use agent@version targets e.g. --agents grok@0.1.218,claude@2.1.79,codex@default
289
- Non-TTY shells apply defaults Omitted required selections fail with a plain hint
290
-
291
- Options:
292
- -V, --version Show version number
293
- -h, --help Show help
294
- --verbose Show startup self-heal details on stderr
295
-
296
- System config lives in ~/.agents/.system/. Run 'agents <command> --help' for details.
297
- `);
298
- }
299
- return originalHelpInformation();
300
- };
301
181
  /** Compare two semver version strings. Returns 1 if a > b, -1 if a < b, 0 if equal. */
302
182
  function compareVersions(a, b) {
303
183
  const partsA = a.split('.').map(Number);
@@ -595,15 +475,15 @@ async function checkForUpdates() {
595
475
  }
596
476
  }
597
477
  }
598
- async function maybeBootstrapShimIntegration(requestedCommand, helpOrVersionRequested, verboseStartup) {
478
+ async function maybeBootstrapShimIntegration(requestedCommand, isDocumentationRequest, verboseStartup) {
599
479
  if (!verboseStartup && (!process.stdin.isTTY || !process.stdout.isTTY)) {
600
480
  return;
601
481
  }
602
482
  // Pure documentation paths must never trigger interactive repair — mirrors
603
- // the helpOrVersionRequested gate around ensureInitialized below. Covers
483
+ // the isDocumentationRequest gate around ensureInitialized below. Covers
604
484
  // both bare `agents --version` (requestedCommand === undefined) and
605
485
  // `agents <subcommand> --help` (requestedCommand === subcommand name).
606
- if (helpOrVersionRequested) {
486
+ if (isDocumentationRequest) {
607
487
  return;
608
488
  }
609
489
  if (requestedCommand === 'sync' || requestedCommand === 'refresh-rules') {
@@ -973,9 +853,11 @@ if (passedArgs[0] === 'sessions') {
973
853
  }
974
854
  const requestedCommand = passedArgs.find((arg) => !arg.startsWith('-'));
975
855
  const verboseStartup = passedArgs.includes('--verbose');
856
+ const helpAllRequested = passedArgs.includes('--help-all');
976
857
  // Help and version output are pure documentation — they must never gate on
977
858
  // setup, otherwise `agents <cmd> --help` becomes useless on a fresh box.
978
859
  const helpOrVersionRequested = passedArgs.some((arg) => arg === '--help' || arg === '-h' || arg === '--version' || arg === '-V');
860
+ const isDocumentationRequest = helpOrVersionRequested || helpAllRequested;
979
861
  // White-label: a brand can hide built-in top-level commands. A hidden command
980
862
  // must behave as if it doesn't exist under this brand (unknown-command +
981
863
  // spellcheck), while `agents` itself is unaffected. `brandDisabled` is empty for
@@ -995,7 +877,7 @@ const requestedIsDisabled = requestedCommand !== undefined && brandDisabled.has(
995
877
  // scan itself is the same work those four scans do, at ~0.001ms on an 11-token
996
878
  // argv — free next to the module graph it avoids on the majority path.
997
879
  if (requestedCommand !== undefined &&
998
- !helpOrVersionRequested &&
880
+ !isDocumentationRequest &&
999
881
  !requestedIsDisabled &&
1000
882
  hasHostRoutingFlag(passedArgs)) {
1001
883
  const { maybeRunOnHost } = await import('./lib/hosts/passthrough.js');
@@ -1006,6 +888,11 @@ if (requestedCommand !== undefined &&
1006
888
  // Register only the command(s) this invocation actually uses. Lazy commands
1007
889
  // (sessions/teams/cloud) are handled after applyGlobalHelpConventions below.
1008
890
  const isLazyRequest = requestedCommand !== undefined && LAZY_COMMAND_NAMES.has(requestedCommand);
891
+ // Root help (--help, --help-all, or bare invocation) needs the full command tree
892
+ // so the formatter can render real descriptions and the compact front-door
893
+ // pointer can point at the real remaining surface.
894
+ const rootHelpRequested = requestedCommand === undefined &&
895
+ (helpAllRequested || passedArgs.includes('--help') || passedArgs.includes('-h') || passedArgs.length === 0);
1009
896
  // Set when the requested name maps to no command. Spellcheck uses the plain
1010
897
  // KNOWN_TOP_LEVEL_COMMANDS string set — never registerAllEagerCommands just to
1011
898
  // build the candidate list (RUSH-2329; was 250-330ms of module evaluation).
@@ -1014,19 +901,24 @@ if (requestedIsDisabled) {
1014
901
  // Brand hid this command: resolve as unknown without loading the full tree.
1015
902
  requestedIsUnknown = true;
1016
903
  }
904
+ else if (rootHelpRequested) {
905
+ await registerAllCommands(program);
906
+ }
1017
907
  else if (requestedCommand !== undefined && !isLazyRequest) {
1018
908
  const known = await registerEagerForRequest(requestedCommand);
1019
909
  if (!known) {
1020
910
  requestedIsUnknown = true;
1021
911
  }
1022
912
  }
1023
- // When requestedCommand is undefined (bare invocation, --version, --help, -h) no
1024
- // command modules are needed: --version is built in and the root help text is a
1025
- // static string.
1026
913
  // Mirror main: help conventions are applied after the eager command tree and
1027
914
  // before the lazy commands, so the latter inherit the root's custom help
1028
915
  // formatter instead of getting the per-command recursive pass.
1029
916
  applyGlobalHelpConventions(program);
917
+ // Compact root help shows only the measured front-door groups plus a pointer to
918
+ // the full surface. --help-all disables compact mode so every command is listed.
919
+ if (!helpAllRequested) {
920
+ setCompactRootHelp(program);
921
+ }
1030
922
  // Lazy commands pull in the SQLite-backed session/cloud stack; register them
1031
923
  // only when explicitly requested, keeping lightweight commands off that path.
1032
924
  if (isLazyRequest && !requestedIsDisabled) {
@@ -1060,7 +952,7 @@ else if (requestedIsUnknown && requestedCommand) {
1060
952
  else {
1061
953
  await registerEagerForRequest(closest);
1062
954
  }
1063
- if (!helpOrVersionRequested && hasHostRoutingFlag(passedArgs)) {
955
+ if (!isDocumentationRequest && hasHostRoutingFlag(passedArgs)) {
1064
956
  const { maybeRunOnHost } = await import('./lib/hosts/passthrough.js');
1065
957
  if (await maybeRunOnHost(closest, passedArgs)) {
1066
958
  process.exit(process.exitCode ?? 0);
@@ -1085,10 +977,18 @@ if (brandDisabled.size > 0) {
1085
977
  program.commands = kept;
1086
978
  }
1087
979
  }
1088
- // Pure documentation paths (--version / --help / -h) return immediately: skip
1089
- // the update check (PATH scan + cache read) and the detached background sync
1090
- // (spawns a child process) that every other invocation runs.
1091
- if (!helpOrVersionRequested) {
980
+ // --help-all is a custom root option: render the full (non-compact) tree and
981
+ // exit before migrations/update checks. It is not the built-in --help, so
982
+ // commander would otherwise treat a bare program-with-subcommands as missing a
983
+ // command and exit with an error after displaying help.
984
+ if (helpAllRequested) {
985
+ program.outputHelp();
986
+ process.exit(0);
987
+ }
988
+ // Pure documentation paths (--version / --help / -h / --help-all) return
989
+ // immediately: skip the update check (PATH scan + cache read) and the detached
990
+ // background sync (spawns a child process) that every other invocation runs.
991
+ if (!isDocumentationRequest) {
1092
992
  // Run update check before parsing so the upgrade notice/prompt precedes output.
1093
993
  await checkForUpdates();
1094
994
  // Fire-and-forget the background sync. System repo gets a real fast-forward
@@ -1128,11 +1028,11 @@ const SETUP_EXEMPT_COMMANDS = new Set(['setup', 'help', 'uninstall']);
1128
1028
  // would otherwise skip this step on every existing install. Idempotent —
1129
1029
  // no-ops when legacy is missing or already a symlink.
1130
1030
  //
1131
- // Skipped for --help/--version (RUSH-2454): pure documentation paths must not
1132
- // load any migration graph. Loaded from migrate-fold.js (leaf: fs + createLink),
1133
- // not migrate.js, so a real command pays only the fold hop unless the v20
1134
- // sentinel is missing and runMigration() is required below.
1135
- if (process.env.AGENTS_SKIP_MIGRATION !== '1' && !helpOrVersionRequested) {
1031
+ // Skipped for --help/--version/--help-all (RUSH-2454): pure documentation paths
1032
+ // must not load any migration graph. Loaded from migrate-fold.js (leaf: fs +
1033
+ // createLink), not migrate.js, so a real command pays only the fold hop unless
1034
+ // the v20 sentinel is missing and runMigration() is required below.
1035
+ if (process.env.AGENTS_SKIP_MIGRATION !== '1' && !isDocumentationRequest) {
1136
1036
  try {
1137
1037
  const { foldLegacySystemRepo } = await import('./lib/migrate-fold.js');
1138
1038
  foldLegacySystemRepo();
@@ -1142,7 +1042,7 @@ if (process.env.AGENTS_SKIP_MIGRATION !== '1' && !helpOrVersionRequested) {
1142
1042
  if (!firstRun &&
1143
1043
  requestedCommand &&
1144
1044
  !SETUP_EXEMPT_COMMANDS.has(requestedCommand) &&
1145
- !helpOrVersionRequested) {
1045
+ !isDocumentationRequest) {
1146
1046
  const { ensureInitialized } = await import('./commands/setup.js');
1147
1047
  await ensureInitialized(program);
1148
1048
  }
@@ -1153,12 +1053,13 @@ if (!firstRun &&
1153
1053
  // AGENTS_SKIP_MIGRATION=1 disables the bootstrap-time run for tests and
1154
1054
  // scripted invocations that prepare their own legacy fixtures.
1155
1055
  //
1156
- // Skipped for --help/--version (RUSH-2454): same pure-docs gate as fold, the
1157
- // update check, background sync, ensureInitialized, and the menu-bar self-heal.
1158
- // The sentinel check itself is pure fs and does not load migrate.js — only a
1159
- // missing/stale sentinel pays for `await import('./lib/installations/migrate.js')` (which
1160
- // pulls the hosts/routine/teams/daemon/menubar graph).
1161
- if (process.env.AGENTS_SKIP_MIGRATION !== '1' && !helpOrVersionRequested) {
1056
+ // Skipped for --help/--version/--help-all (RUSH-2454): same pure-docs gate as
1057
+ // fold, the update check, background sync, ensureInitialized, and the menu-bar
1058
+ // self-heal. The sentinel check itself is pure fs and does not load migrate.js
1059
+ // — only a missing/stale sentinel pays for
1060
+ // `await import('./lib/installations/migrate.js')` (which pulls the
1061
+ // hosts/routine/teams/daemon/menubar graph).
1062
+ if (process.env.AGENTS_SKIP_MIGRATION !== '1' && !isDocumentationRequest) {
1162
1063
  try {
1163
1064
  const sentinel = getMigratedSentinelPath();
1164
1065
  // Sentinel is keyed to the migration SCHEMA version, not the binary version.
@@ -1192,13 +1093,13 @@ if (process.env.AGENTS_SKIP_MIGRATION !== '1' && !helpOrVersionRequested) {
1192
1093
  // a lightweight startup self-heal (two existsSync checks then return) rather
1193
1094
  // than a migration-sentinel bump, so it covers fresh installs AND upgrades
1194
1095
  // without re-running the full migration for the whole user base (issue #20).
1195
- // Skipped for --help/--version: those are pure documentation paths, so they
1196
- // pay neither the dynamic import (child_process, the version/layout resolver,
1197
- // the bundle installer) nor the self-heal's filesystem checks — same gate the
1198
- // update check, background sync, and ensureInitialized above already use.
1096
+ // Skipped for --help/--version/--help-all: those are pure documentation paths,
1097
+ // so they pay neither the dynamic import (child_process, the version/layout
1098
+ // resolver, the bundle installer) nor the self-heal's filesystem checks — same
1099
+ // gate the update check, background sync, and ensureInitialized above already use.
1199
1100
  if (process.platform === 'darwin' &&
1200
1101
  process.env.AGENTS_SKIP_MIGRATION !== '1' &&
1201
- !helpOrVersionRequested) {
1102
+ !isDocumentationRequest) {
1202
1103
  try {
1203
1104
  const { installMenubarLaunchAgentOnUpgrade } = await import('./lib/menubar/install-menubar.js');
1204
1105
  installMenubarLaunchAgentOnUpgrade();
@@ -1215,7 +1116,7 @@ if (passedArgs.length === 0) {
1215
1116
  process.exit(0);
1216
1117
  }
1217
1118
  try {
1218
- await maybeBootstrapShimIntegration(requestedCommand, helpOrVersionRequested, verboseStartup);
1119
+ await maybeBootstrapShimIntegration(requestedCommand, isDocumentationRequest, verboseStartup);
1219
1120
  await program.parseAsync();
1220
1121
  }
1221
1122
  catch (err) {
@@ -127,3 +127,8 @@ export declare const COMMAND_LOADERS: Record<string, ModuleLoader[]>;
127
127
  * are closures over entry-point state that src/index.ts registers directly.
128
128
  */
129
129
  export declare function buildFullCommandTree(): Promise<Command>;
130
+ /**
131
+ * Register every module in {@link COMMAND_LOADERS} onto the given program.
132
+ * Used by help paths that need the complete visible command tree.
133
+ */
134
+ export declare function registerAllCommands(program: Command): Promise<void>;
@@ -228,6 +228,14 @@ export const COMMAND_LOADERS = {
228
228
  export async function buildFullCommandTree() {
229
229
  const packageJson = JSON.parse(readFileSync(fileURLToPath(new URL('../../package.json', import.meta.url)), 'utf8'));
230
230
  const program = configureRootCommand(new Command(), 'agents', packageJson.version);
231
+ await registerAllCommands(program);
232
+ return program;
233
+ }
234
+ /**
235
+ * Register every module in {@link COMMAND_LOADERS} onto the given program.
236
+ * Used by help paths that need the complete visible command tree.
237
+ */
238
+ export async function registerAllCommands(program) {
231
239
  const done = new Set();
232
240
  for (const loaders of Object.values(COMMAND_LOADERS)) {
233
241
  for (const loader of loaders) {
@@ -237,5 +245,4 @@ export async function buildFullCommandTree() {
237
245
  (await loader())(program);
238
246
  }
239
247
  }
240
- return program;
241
248
  }