@staix/agent-hub 0.51.0 → 0.52.0

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 (299) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +1 -1
  3. package/docs/adding-an-ai-tool.md +24 -2
  4. package/docs/agent-notes/adapters.md +1 -0
  5. package/docs/agent-notes/budget.md +8 -2
  6. package/docs/agent-notes/daemon.md +13 -8
  7. package/docs/agent-notes/security-review.md +6 -5
  8. package/docs/agent-notes/tasks.md +5 -2
  9. package/docs/agent-notes/tests.md +4 -3
  10. package/docs/cooperbench.md +1 -1
  11. package/docs/design/adapters.md +4 -0
  12. package/docs/design/cli-output-inventory.md +162 -152
  13. package/docs/design/cli-output.md +4 -3
  14. package/docs/design/guidance-probes.md +1 -0
  15. package/docs/design/roadmap.md +2 -0
  16. package/docs/design/task-board.md +1 -0
  17. package/docs/dogfood.md +14 -0
  18. package/docs/events.md +4 -2
  19. package/docs/memory.md +5 -3
  20. package/docs/operations.md +210 -16
  21. package/docs/quickstart.md +12 -2
  22. package/docs/roles.md +1 -1
  23. package/docs/sdlc.md +26 -3
  24. package/docs/security.md +11 -5
  25. package/docs/specs/2026-09-19-agent-hub-design.md +43 -0
  26. package/docs/specs/2026-09-19-multi-project-design.md +4 -0
  27. package/docs/specs/2026-09-20-upgrade-recovery-design.md +17 -0
  28. package/docs/specs/mcp-endpoint.md +63 -0
  29. package/docs/verification/2026-11-30-capability-listing-shape-1808.md +45 -0
  30. package/docs/verification/2026-11-30-upgrade-keep-1807.md +174 -0
  31. package/docs/verification/2026-12-01-1811-confirmation-receipt.md +19 -0
  32. package/docs/verification/2026-12-01-1811-orca-agent-list.md +20 -0
  33. package/docs/verification/2026-12-01-1811-orca-pane-key.md +21 -0
  34. package/docs/verification/2026-12-02-1819-claude-process-after-renewal.md +54 -0
  35. package/docs/verification/2026-12-02-agy-1.5.21.md +74 -0
  36. package/docs/verification/2026-12-02-claude-implementer-2.1.334.md +44 -0
  37. package/docs/verification/2026-12-02-cli-import-graph.md +33 -0
  38. package/docs/verification/2026-12-03-0.52.0.md +150 -0
  39. package/docs/verification/2026-12-03-codex-0173-reviewer-isolation.md +53 -0
  40. package/docs/verification/2026-12-03-codex-0173-reviewer-tool-call.md +34 -0
  41. package/docs/verification/2026-12-03-jcode-1.3.0.md +25 -0
  42. package/docs/verification/agy/README.md +17 -0
  43. package/docs/verification/agy/cli-surface.ts +68 -0
  44. package/docs/verification/agy/interactive-bridge.ts +92 -0
  45. package/docs/verification/agy/interactive-session.ts +131 -0
  46. package/docs/verification/agy/launcher-nonce.ts +215 -0
  47. package/docs/verification/agy/native-hooks.ts +210 -0
  48. package/docs/verification/agy/originals/agent-hub-681/cli-surface.ts +87 -0
  49. package/docs/verification/agy/originals/agent-hub-681/native-hooks-adapted.ts +91 -0
  50. package/docs/verification/agy/originals/agent-hub-681/tui-actual.ts +200 -0
  51. package/docs/verification/agy/originals/agent-hub-684/probe.ts +107 -0
  52. package/docs/verification/agy/originals.json +25 -0
  53. package/docs/verification/agy/permission-new-functions.ts +128 -0
  54. package/docs/verification/agy/run-probe.py +108 -0
  55. package/docs/verification/agy/runtime.ts +171 -0
  56. package/docs/verification/agy/tmux-helper-control.ts +6 -0
  57. package/docs/verification/agy/tmux-session.ts +235 -0
  58. package/docs/verified.json +82 -41
  59. package/package.json +3 -3
  60. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  61. package/plugins/agent-hub/compat.json +157 -0
  62. package/plugins/agent-hub/kimi-hook.js +621 -865
  63. package/plugins/agent-hub/server.js +17423 -32962
  64. package/src/adapters/agy/definition.ts +7 -24
  65. package/src/adapters/channel-peer.ts +3 -1
  66. package/src/adapters/claude-channel.ts +38 -257
  67. package/src/adapters/claude-implementer.ts +3 -1
  68. package/src/adapters/codex-appserver.ts +77 -15
  69. package/src/adapters/compat.ts +74 -11
  70. package/src/adapters/configured-acp.ts +23 -163
  71. package/src/adapters/configured-adapter-policy.ts +160 -0
  72. package/src/adapters/configured-pull-entry.ts +53 -0
  73. package/src/adapters/configured-pull.ts +38 -0
  74. package/src/adapters/conformance/fakes/app-server.ts +9 -2
  75. package/src/adapters/declaration-catalog.ts +25 -0
  76. package/src/adapters/declaration-data.ts +342 -0
  77. package/src/adapters/declaration-resolution.ts +53 -0
  78. package/src/adapters/definitions/builtin-metadata.ts +61 -83
  79. package/src/adapters/definitions/jcode-launch.ts +13 -0
  80. package/src/adapters/definitions/native-adapter-policy.ts +390 -0
  81. package/src/adapters/definitions/native-cli-claude-launch.ts +3 -2
  82. package/src/adapters/definitions/native-cli-codex-launch.ts +2 -1
  83. package/src/adapters/definitions/native-cli-entry-jcode.ts +4 -2
  84. package/src/adapters/definitions/native-cli-entry-types.ts +9 -2
  85. package/src/adapters/definitions/native-cli-launch-common.ts +2 -2
  86. package/src/adapters/definitions/native-cli-retained.ts +1 -1
  87. package/src/adapters/definitions/native-configuration.ts +18 -0
  88. package/src/adapters/definitions/native-help.ts +24 -0
  89. package/src/adapters/definitions/native-launch-declarations.ts +34 -0
  90. package/src/adapters/definitions/native-launch-policy.ts +4 -0
  91. package/src/adapters/definitions/native-launch-settings.ts +72 -0
  92. package/src/adapters/definitions/native-light-cli.ts +18 -0
  93. package/src/adapters/definitions/native-light-preview.ts +10 -0
  94. package/src/adapters/definitions/native-wrapper-launch.ts +10 -0
  95. package/src/adapters/definitions/qwen.ts +6 -29
  96. package/src/adapters/definitions/reviewer-variants.ts +7 -8
  97. package/src/adapters/external-declarations.ts +31 -0
  98. package/src/adapters/external-modules.ts +4 -29
  99. package/src/adapters/jcode.ts +3 -12
  100. package/src/adapters/native-capabilities.ts +18 -8
  101. package/src/adapters/native-proof-ports.ts +1 -1
  102. package/src/adapters/presets.ts +136 -0
  103. package/src/adapters/qwen-dual.ts +2 -2
  104. package/src/adapters/registry-types.ts +3 -0
  105. package/src/adapters/registry.ts +20 -81
  106. package/src/adapters/reviewer-print.ts +26 -9
  107. package/src/adapters/role-eligibility.ts +2 -1
  108. package/src/cli/accounts-import.ts +72 -0
  109. package/src/cli/agents-latest-table.ts +88 -0
  110. package/src/cli/agents-latest.ts +22 -0
  111. package/src/cli/agents-output.ts +10 -0
  112. package/src/cli/agents-presets.ts +100 -0
  113. package/src/cli/agents.ts +1 -1
  114. package/src/cli/attention.ts +3 -2
  115. package/src/cli/autonomy-homes.ts +7 -2
  116. package/src/cli/budget-renew-guidance.ts +129 -0
  117. package/src/cli/claude-homes.ts +9 -5
  118. package/src/cli/command-context.ts +3 -0
  119. package/src/cli/command-table.ts +123 -0
  120. package/src/cli/commands/accounts.ts +8 -0
  121. package/src/cli/commands/agents.ts +18 -0
  122. package/src/cli/commands/answer.ts +28 -0
  123. package/src/cli/commands/ask.ts +17 -0
  124. package/src/cli/commands/autonomy.ts +83 -0
  125. package/src/cli/commands/backlog.ts +46 -0
  126. package/src/cli/commands/bench.ts +60 -0
  127. package/src/cli/commands/board.ts +48 -0
  128. package/src/cli/commands/broker.ts +9 -0
  129. package/src/cli/commands/budget.ts +96 -0
  130. package/src/cli/commands/capabilities.ts +12 -0
  131. package/src/cli/commands/check-path.ts +55 -0
  132. package/src/cli/commands/completion.ts +8 -0
  133. package/src/cli/commands/console.ts +12 -0
  134. package/src/cli/commands/daemon.ts +8 -0
  135. package/src/cli/commands/deliverables.ts +25 -0
  136. package/src/cli/commands/doctor.ts +249 -0
  137. package/src/cli/commands/down.ts +3 -0
  138. package/src/cli/commands/export.ts +15 -0
  139. package/src/cli/commands/facts.ts +15 -0
  140. package/src/cli/commands/goal.ts +22 -0
  141. package/src/cli/commands/guidance.ts +102 -0
  142. package/src/cli/commands/help.ts +17 -0
  143. package/src/cli/commands/host.ts +45 -0
  144. package/src/cli/commands/init.ts +121 -0
  145. package/src/cli/commands/instructed.ts +19 -0
  146. package/src/cli/commands/instruction-hook.ts +15 -0
  147. package/src/cli/commands/intake.ts +24 -0
  148. package/src/cli/commands/kill.ts +15 -0
  149. package/src/cli/commands/learn.ts +23 -0
  150. package/src/cli/commands/lineage.ts +30 -0
  151. package/src/cli/commands/logs.ts +21 -0
  152. package/src/cli/commands/manager.ts +15 -0
  153. package/src/cli/commands/memory.ts +21 -0
  154. package/src/cli/commands/model.ts +25 -0
  155. package/src/cli/commands/models.ts +40 -0
  156. package/src/cli/commands/native.ts +39 -0
  157. package/src/cli/commands/pause.ts +5 -0
  158. package/src/cli/commands/peer.ts +32 -0
  159. package/src/cli/commands/permission.ts +26 -0
  160. package/src/cli/commands/permit.ts +12 -0
  161. package/src/cli/commands/pet.ts +24 -0
  162. package/src/cli/commands/projects.ts +49 -0
  163. package/src/cli/commands/queue.ts +70 -0
  164. package/src/cli/commands/recovery-run.ts +13 -0
  165. package/src/cli/commands/recovery.ts +130 -0
  166. package/src/cli/commands/release.ts +23 -0
  167. package/src/cli/commands/releases.ts +9 -0
  168. package/src/cli/commands/remember.ts +6 -0
  169. package/src/cli/commands/report.ts +27 -0
  170. package/src/cli/commands/research.ts +53 -0
  171. package/src/cli/commands/reset.ts +89 -0
  172. package/src/cli/commands/restart.ts +5 -0
  173. package/src/cli/commands/results.ts +31 -0
  174. package/src/cli/commands/resume.ts +5 -0
  175. package/src/cli/commands/review.ts +24 -0
  176. package/src/cli/commands/roadmap.ts +21 -0
  177. package/src/cli/commands/role.ts +34 -0
  178. package/src/cli/commands/roles.ts +30 -0
  179. package/src/cli/commands/room.ts +14 -0
  180. package/src/cli/commands/roster.ts +48 -0
  181. package/src/cli/commands/route.ts +9 -0
  182. package/src/cli/commands/say.ts +21 -0
  183. package/src/cli/commands/schedule.ts +17 -0
  184. package/src/cli/commands/sdlc.ts +321 -0
  185. package/src/cli/commands/settings.ts +148 -0
  186. package/src/cli/commands/setup.ts +89 -0
  187. package/src/cli/commands/shared-refusals.ts +25 -0
  188. package/src/cli/commands/smoke.ts +44 -0
  189. package/src/cli/commands/source.ts +64 -0
  190. package/src/cli/commands/specs.ts +13 -0
  191. package/src/cli/commands/status.ts +28 -0
  192. package/src/cli/commands/stop.ts +17 -0
  193. package/src/cli/commands/structure.ts +60 -0
  194. package/src/cli/commands/study.ts +39 -0
  195. package/src/cli/commands/tail.ts +19 -0
  196. package/src/cli/commands/task.ts +114 -0
  197. package/src/cli/commands/title.ts +17 -0
  198. package/src/cli/commands/turns.ts +10 -0
  199. package/src/cli/commands/ui.ts +47 -0
  200. package/src/cli/commands/undo.ts +77 -0
  201. package/src/cli/commands/up.ts +39 -0
  202. package/src/cli/commands/upgrade.ts +5 -0
  203. package/src/cli/commands/usage.ts +33 -0
  204. package/src/cli/commands/version.ts +5 -0
  205. package/src/cli/commands/watch.ts +30 -0
  206. package/src/cli/commands/worktrees.ts +31 -0
  207. package/src/cli/console-state.ts +5 -138
  208. package/src/cli/console-versions.ts +1 -1
  209. package/src/cli/help.ts +37 -15
  210. package/src/cli/identity.ts +23 -4
  211. package/src/cli/launch-check.ts +1 -2
  212. package/src/cli/launch.ts +13 -82
  213. package/src/cli/light-dispatch.ts +29 -0
  214. package/src/cli/main.js +8 -1
  215. package/src/cli/main.ts +233 -2816
  216. package/src/cli/orca-probe.ts +119 -0
  217. package/src/cli/output.ts +31 -2
  218. package/src/cli/preview.ts +10 -5
  219. package/src/cli/recovery-version-preflight.ts +28 -9
  220. package/src/cli/replace-process.ts +22 -0
  221. package/src/cli/report-layout.ts +142 -0
  222. package/src/cli/roadmap-usage.ts +16 -0
  223. package/src/cli/roadmap.ts +3 -16
  224. package/src/cli/sdlc-doctor.ts +27 -0
  225. package/src/cli/sdlc-output.ts +55 -1
  226. package/src/cli/setup-homes.ts +1 -1
  227. package/src/cli/start-agents-run.ts +1 -1
  228. package/src/cli/statusline-tee.ts +25 -4
  229. package/src/cli/terminal-recovery.ts +53 -10
  230. package/src/cli/upgrade-interactive.ts +1 -0
  231. package/src/cli/upgrade-runtime.ts +11 -0
  232. package/src/cli/upgrade.ts +4 -15
  233. package/src/hub/accounts.ts +148 -0
  234. package/src/hub/addons.ts +20 -0
  235. package/src/hub/agent-drift.ts +2 -1
  236. package/src/hub/budget-projection.ts +39 -7
  237. package/src/hub/budget.ts +231 -16
  238. package/src/hub/channel-project.ts +3 -3
  239. package/src/hub/conductor-peer.ts +24 -0
  240. package/src/hub/conductor.ts +2 -21
  241. package/src/hub/config-apply.ts +24 -13
  242. package/src/hub/config-edit.ts +1 -1
  243. package/src/hub/config-tier.ts +2 -0
  244. package/src/hub/config.ts +31 -14
  245. package/src/hub/control-client.ts +48 -0
  246. package/src/hub/daemon.ts +421 -61
  247. package/src/hub/events.ts +3 -0
  248. package/src/hub/home-tag.ts +12 -0
  249. package/src/hub/host.ts +217 -0
  250. package/src/hub/hub-tools.ts +2 -1
  251. package/src/hub/instance-budget.ts +2 -2
  252. package/src/hub/instance-config.ts +15 -126
  253. package/src/hub/instances.ts +22 -6
  254. package/src/hub/instruction-receipt.ts +2 -2
  255. package/src/hub/kimi-usage.ts +38 -11
  256. package/src/hub/lifecycle.ts +86 -4
  257. package/src/hub/mcp-bridge-core.ts +98 -0
  258. package/src/hub/mcp-channel-push.ts +20 -0
  259. package/src/hub/mcp-endpoint-serve.ts +178 -0
  260. package/src/hub/mcp-endpoint.ts +226 -0
  261. package/src/hub/mcp-tool-call.ts +181 -0
  262. package/src/hub/operational-settings.ts +2 -0
  263. package/src/hub/orca-env.ts +6 -0
  264. package/src/hub/orca-state.ts +84 -0
  265. package/src/hub/peers.ts +5 -1
  266. package/src/hub/permission-mode.ts +2 -1
  267. package/src/hub/project.ts +20 -0
  268. package/src/hub/protocol-window.ts +58 -0
  269. package/src/hub/quota-origin.ts +20 -0
  270. package/src/hub/registry.ts +36 -2
  271. package/src/hub/report.ts +1 -1
  272. package/src/hub/research.ts +1 -1
  273. package/src/hub/review-brief.ts +47 -2
  274. package/src/hub/roster.ts +6 -3
  275. package/src/hub/routing.ts +9 -2
  276. package/src/hub/sdlc-check.ts +205 -0
  277. package/src/hub/sdlc-sync.ts +146 -0
  278. package/src/hub/sdlc.ts +33 -4
  279. package/src/hub/settings.ts +7 -4
  280. package/src/hub/start-agents.ts +1 -1
  281. package/src/hub/start-mode.ts +11 -4
  282. package/src/hub/structure-budget.ts +131 -0
  283. package/src/hub/structure-scan.ts +149 -0
  284. package/src/hub/tasks-experiment.ts +455 -0
  285. package/src/hub/tasks-guidance.ts +606 -0
  286. package/src/hub/tasks-roadmap-plan.ts +419 -0
  287. package/src/hub/tasks-roadmap.ts +491 -0
  288. package/src/hub/tasks-study.ts +661 -0
  289. package/src/hub/tasks-survey.ts +192 -0
  290. package/src/hub/tasks.ts +319 -2548
  291. package/src/hub/terminal-open.ts +5 -3
  292. package/src/hub/tooling.ts +3 -19
  293. package/src/hub/usage-rollup.ts +9 -3
  294. package/src/local/tools.ts +5 -0
  295. package/src/ui/index.html +1 -1
  296. package/src/ui/needs.ts +17 -5
  297. package/src/ui/peer-palette.ts +2 -4
  298. package/templates/presets/agents.json +60 -0
  299. package/templates/presets/confirmation-matrix.json +8 -8
@@ -1,6 +1,6 @@
1
1
  import { closeSync, fstatSync, openSync, readSync, constants } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { DOCTOR_PLUGIN_PROBE } from "../adapters/registry.ts";
3
+ import { DOCTOR_PLUGIN_PROBE } from "../adapters/definitions/native-cli-doctor.ts";
4
4
  import { childEnv } from "../hub/child-process.ts";
5
5
  import { withoutOrcaEnv } from "../hub/orca-env.ts";
6
6
  import { displayVersion } from "../version.ts";
package/src/cli/help.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { ADAPTERS, deriveAdapterLists, type AdapterDefinition } from "../adapters/registry.ts";
1
+ import type { AdapterDefinition } from "../adapters/registry.ts";
2
+ import { compareNativeRank, NATIVE_CLI_HELP } from "../adapters/definitions/native-help.ts";
2
3
  import { VERSION } from "../version.ts";
3
- import { ROADMAP_FORMS } from "./roadmap.ts";
4
- import { paint, wrap, Report as LayoutReport, type Span } from "./console-state.ts";
4
+ import { ROADMAP_FORMS } from "./roadmap-usage.ts";
5
+ import { paint, wrap, Report as LayoutReport, type Span } from "./report-layout.ts";
5
6
 
6
7
  /** One usage form of `ahub help`: the usage starts with `ahub <command>`, alternatives joined by `|`. */
7
8
  export interface HelpEntry { section: string; usage: string; description: string; /** #1504: the overview row of a native agent, from the third element of its definition's `cli.usage` entry; never a table in this file that names a peer. */ summary?: string }
@@ -46,7 +47,9 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
46
47
  ["ahub pet [--short]", "read attention without connecting; --short prints ahub!N only when action is needed"],
47
48
  ["ahub pet --window [--close]", "retired floating-window options: run acon ui and open Mini"],
48
49
  ["ahub pet --palette <blue|teal|violet|ochre>", "retired floating-window option: run acon ui and open Mini"],
49
- ["ahub sdlc status [task] | explain <task> [--json] [--color=auto|always|never] | export <task> | record <task> <receipt-json>", "read head-bound lifecycle gates and the next actor/action; status and explain are open to any agent as a public view (private tasks stay stubs), export and record are person only; export stays JSON"],
50
+ ["ahub sdlc status [--all] [task] | explain <task> [--json] [--color=auto|always|never] | export <task> | record <task> <receipt-json>", "read head-bound lifecycle gates and the next actor/action; status and explain are open to any agent as a public view (private tasks stay stubs), export and record are person only; export stays JSON"],
51
+ ["ahub sdlc check [--json] [--color=auto|always|never]", "read-only audit of the lifecycle setup (config, roles, required checks, bindings, roadmap hygiene); each warning names its cause and next command; exit 1 only when a row fails; `ahub doctor` shows the offline sdlc row (#1856)"],
52
+ ["ahub sdlc sync [--write-roadmap] [--close-settled-issues] [--json] [--color=auto|always|never] | sync <same flags> --apply --confirm <fingerprint> [--json] [--color=auto|always|never]", "preview board receipt repairs (title issue link, open PR and head binding, merged-PR adoption) with a 64-hex fingerprint and write nothing; apply re-plans and refuses on drift; person or the configured conductor; --write-roadmap refreshes the tracked roadmap files, --close-settled-issues closes issues whose tasks are approved at merged PRs and whose body has no open item, under roadmap apply authority only (#1856)"],
50
53
  ["ahub sdlc queue <owner/repo> | release <owner/repo> [live-issue...] [--json] [--color=auto|always|never]", "read-only merge and release evidence; open to any agent as public readback of the checkout's repositories, never an authorization"],
51
54
  ["ahub sdlc survey start [--focus bugs|tests|debt|deps|dx|docs] [--json] [--color=auto|always|never]", "person or current conductor: file one read-only planner survey at a pinned source ref; only explicitly vetted findings produce backlog cards"],
52
55
  ["ahub sdlc survey show <task> [--json] [--color=auto|always|never]", "read findings and their vet decisions; unchanged or unknown prior rejections remain rejected before, and reconsideration needs an explicit vetted reason"],
@@ -74,8 +77,13 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
74
77
  ["ahub doctor [--json] [--full] [--ascii] [--color=auto|always|never]", "check the tools, daemon, plugin, gateway, models, memory library and memory capture setup (read from `amem setup <tool> --json`, a preview) this project uses, the runtime capture pruning ledger, whether the shared config.json tracking matches the AGENTS.md roles sentence, and who holds conductor, planner and reviewer as the loader settled them (a warning, never a failure), the hub skills of the Claude plugin and every other agent host (installed, stale, missing, modified, foreign or linked, with a repair command), and any rostered implementer that no routing class lists (a warning); warn when the CLI or plugin is older than its running daemon"],
75
78
  ["ahub doctor --stale-anchors [--json]", "read-only bounded report of public memory symbol anchors at current HEAD; private or unavailable evidence stays unknown"],
76
79
  ["ahub doctor --orphans [--kill] [--json] [--color=auto|always|never]", "person: inspect missing-root registrations; conductor --kill: selected project only; signed hub ownership is required before any stop"],
80
+ ["ahub accounts import --from orca", "person only: print an `accounts` block for config.local.json from `orca account list --json`, labels only, nothing written"],
77
81
  ["ahub agents [--json]", "show each gated agent CLI's installed version and verdict (verified, in-line, trusted, refused or unknown)"],
82
+ ["ahub agents --latest [--json]", "person only, reads the network: say, for each refused or trusted agent CLI, which release verifies the version installed here, read from the newest published release's compat.json (advice only, writes nothing, admits nothing; the hub never reads the network for it)"],
78
83
  ["ahub agents trust <id> <version> [--revoke]", "accept an untested agent CLI version on this machine (person only; runtime proofs still run)"],
84
+ ["ahub agents presets [--json]", "person only: list the shipped agent presets (gemini, opencode, kiro, copilot) with the recorded CLI version and whether a verification receipt backs each (verified) or not (untested)"],
85
+ ["ahub agents add <preset> [--as <kind>] [--pull]", "person only: write the preset's headless launch line as a configured kind into the untracked .agenthub/config.local.json; with --pull write a pull kind (the CLI in your own terminal, owns no task) and print the command that registers the hub bridge in that CLI. Refuses an existing kind, a missing executable or, without --pull, a preset with no launch line"],
86
+ ["ahub <kind> [--print-command | --dry-run] [args...]", "start a configured pull kind's CLI in your terminal with its peer identity, passing any other args to it (person only; the kind must be loaded by the hub and on the roster); --print-command or --dry-run prints the launch as JSON and starts nothing"],
79
87
  ["ahub kill", "stop this project's hub"],
80
88
  ["ahub down", "stop this project's hub, the counterpart of ahub up (same as ahub kill)"],
81
89
  ["ahub reset [--all] [--yes]", "list, then with --yes stop the hub and discard every queued and needs_review delivery, clear holds and pauses and drop session pointers; --all moves the state directory to .agenthub/archive instead"],
@@ -86,6 +94,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
86
94
  ["ahub recovery dispose [<operation-id>] --fresh-session codex|claude --reason <text>", "end a partial operation by starting that peer as a new session, recording the lost conversation"],
87
95
  ["ahub recovery dispose [<operation-id>] --stop-and-archive --reason <text>", "end a partial operation: stop its own targets, archive its snapshot and release the lock; the upgrade is abandoned, not completed"],
88
96
  ["ahub daemon [--unattended]", "internal: the detached hub process that ahub up or the dashboard manager starts"],
97
+ ["ahub host --runtime <root> [--add-current] [--unattended]", "internal: the host process several projects of one runtime share when their config sets host.shared (off by default)"],
89
98
  ["ahub recovery-run <operation-id>", "internal: a detached runner; conductor use is limited to the captured operation continuation, not a general command"],
90
99
  ]],
91
100
  ["Agents", [
@@ -126,6 +135,8 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
126
135
  ["ahub task propose [--class <c> | <class>] <title...> [--owner <peer>] [--path <p>]... [--after <id>]... [--urgent] [--needs-network] [--needs-worktree] [--backlog] [--detail <text>]", "put a task on the board; --needs-network keeps it away from a peer whose shell has none; --needs-worktree keeps it away from a sandboxed peer unless the hub can make the task worktree for it (it makes it, commits and pushes at done); a first word that names a class is taken as the class; while a task named by --after is not approved yet, --owner reserves the task for that peer, offered to it first once it is ready; otherwise --owner assigns it now"],
127
136
  ["ahub task handoff --list | --sync | --project <root|id> [<class>] <title...> [--path <p>]... [--issue <n>] [--task <n>] [--detail <text>] [--duplicate-ok <reason>] [--key <uuid>] [--json] [--color=auto|always|never]", "person only: register work that belongs to ANOTHER project that runs agent-hub on that project's board (an ownerless proposal its own roles take from there); the target must be registered and running, nothing is queued; a feature or behavior change first needs a spec issue there (--issue), and an issue that already has an open task there is refused with those ids unless --duplicate-ok <reason>; a handoff the target did not confirm is reported as outcome_unknown with a key, and --key <uuid> files the same request once; --list shows each handoff with its age and whether its target is reachable (reachable, unreachable with the cause, or moved), and --sync asks every target now instead of at the next 5-minute pass; its state changes show in ahub board --handoffs (an agent that hands off gets them as task messages)"],
128
137
  ["ahub backlog list [--json] [--full] [--color=auto|always|never] | add <class> <title...> | plan <id> <revision> <fields-json> <reason...> | pin <id> <revision> true|false <reason...> | person <id> <revision> true|false <reason...> | undo <id> <revision> [--json] [--color=auto|always|never]", "person only: plan work with a reason; {} records a note-only revision, fields.sdlc sets backlog repo/issue identity and clears old spec acceptance; preserve pins/frozen scope and refuse stale edits; person marks a leg only the person can run (live receipts, their accounts or approvals): no agent is offered it, auto pull and the idle sweep skip it, and it counts toward no planner WIP; list is by rank and shows it as waiting on the person (--json: raw listing)"],
138
+ ["ahub structure check [--json]", "check project file budgets and shared names using .agenthub/sdlc.toml"],
139
+ ["ahub structure baseline --write", "create an initial baseline for review, or shrink the existing baseline"],
129
140
  [`ahub roadmap ${ROADMAP_FORMS.list} | ${ROADMAP_FORMS.show}`, "read public milestone membership and computed progress; private work is a count, unavailable evidence stays unknown"],
130
141
  [`ahub roadmap ${ROADMAP_FORMS.new}`, "planner or conductor: create a milestone without GitHub writes or roadmap model calls"],
131
142
  [`ahub roadmap ${ROADMAP_FORMS.edit}`, "edit at the current revision; reload roadmap show after a stale-revision refusal"],
@@ -174,6 +185,8 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
174
185
  ]],
175
186
  ["Budget", [
176
187
  ["ahub budget [--json] [--full] [--color=auto|always|never]", "quota windows per peer with each number's kind (native, count, manual) and source, what is left and when the window would reach its limit at the recent hourly burn rate (or why there is no forecast), why a peer shows no number, who is paused until when, and the reviewer quota admission rule"],
188
+ ["ahub budget renew <peer> --reset [--json] [--color=auto|always|never]", "person only: clear the account's earlier quota readings after refreshing the same account and retain the budget gate"],
189
+ ["ahub budget renew <peer> --switched [--json] [--color=auto|always|never]", "person only: clear earlier quota readings after switching accounts, with a Codex home comparison and restart steps where required"],
177
190
  ["ahub budget set <peer> <0..1> [--resets-in 30m] [--window 5h|week]", "feed a reading by hand (also: test the relay)"],
178
191
  ["ahub budget resume <peer>", "override a budget pause; readings are ignored for that peer until the window resets"],
179
192
  ["ahub budget execution status [id] [--json] [--color=auto|always|never]", "read execution counters and limits"],
@@ -229,10 +242,15 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
229
242
  ["ahub manager", "internal: the dashboard manager process that ahub ui --all starts"],
230
243
  ]],
231
244
  ];
232
- export function helpEntries(definitions: readonly AdapterDefinition[] = ADAPTERS): readonly HelpEntry[] {
245
+ type HelpDefinition = Pick<AdapterDefinition, "kind" | "projection" | "instances"> & {
246
+ cli: Pick<AdapterDefinition["cli"], "usage">;
247
+ };
248
+
249
+ export function helpEntries(definitions: readonly HelpDefinition[] = Object.values(NATIVE_CLI_HELP)): readonly HelpEntry[] {
233
250
  const byKind = new Map(definitions.map(definition => [definition.kind, definition]));
234
- const order = deriveAdapterLists(definitions).HELP_ORDER;
235
- const native: readonly (readonly [string, string, string?])[] = order.flatMap(kind => byKind.get(kind)?.cli.usage ?? []);
251
+ const order = [...definitions].sort((left, right) => compareNativeRank(left.projection?.helpRank, right.projection?.helpRank))
252
+ .map(definition => definition.kind);
253
+ const native = order.flatMap(kind => byKind.get(kind)?.cli.usage ?? []);
236
254
  const instanceKinds = order.filter(kind => byKind.get(kind)?.instances !== undefined);
237
255
  const instances: readonly [string, string] = [`ahub ${instanceKinds.join("|")} --as <instance> [options...]`, "start an extra instance of that kind declared under instances in .agenthub/config.local.json"];
238
256
  return SECTIONS.flatMap(([section, rows]) => {
@@ -262,9 +280,9 @@ const SUMMARIES: Readonly<Record<string, string>> = {
262
280
  "--live-test": "user-authorized console delegation (person only)", help: "this overview, or one command's usage", version: "print the installed version", completion: "print a shell completion script",
263
281
  up: "start the daemon and this project's default agents", console: "open the human console", pet: "read attention without connecting", sdlc: "read lifecycle gates and the next action",
264
282
  "Daemon and runtime/backlog": "return accepted untouched work to the backlog", status: "is the hub OK, and what to do next", logs: "show the hub log", doctor: "check tools, daemon, plugin, models and memory",
265
- agents: "show each agent CLI's version and verdict", kill: "stop this project's hub", down: "stop this project's hub (same as kill)", reset: "discard queued deliveries and clear holds",
283
+ agents: "show each agent CLI's version and verdict", accounts: "print an accounts block from Orca (person only)", kill: "stop this project's hub", down: "stop this project's hub (same as kill)", reset: "discard queued deliveries and clear holds",
266
284
  restart: "recover this project's runtime", upgrade: "review and upgrade this project", recovery: "inspect, resume or abort a held operation",
267
- daemon: "internal: the detached hub process", "recovery-run": "internal: a detached recovery runner",
285
+ daemon: "internal: the detached hub process", host: "internal: the shared per-runtime host process", "recovery-run": "internal: a detached recovery runner",
268
286
  role: "read catalog guidance for a role", stop: "stop a hub-owned headless peer", peer: "hand the attached session to a standby", models: "inspect local model state",
269
287
  say: "send a message as the console user", watch: "watch a headless ACP peer's activity", tail: "live stream of messages and states", permission: "inspect or set a peer's permission mode",
270
288
  permit: "answer a permission request", answer: "list and answer open hub_ask questions", results: "list what your runs left behind", roster: "every known peer and its participation",
@@ -275,7 +293,7 @@ const SUMMARIES: Readonly<Record<string, string>> = {
275
293
  source: "register inputs as content-hashed sources", schedule: "list and run machine-local schedules", intake: "turn a plain request into a draft backlog card",
276
294
  capabilities: "list the skills each attached peer offers", learn: "review recurring-criterion candidates", study: "research campaign contracts",
277
295
  deliverables: "what each task delivered and a reviewer approved", review: "give a review verdict on a task", route: "why a task went where it did",
278
- ask: "answer from the board, memory and the log", remember: "save a note to shared memory", budget: "quota windows per peer and why one is paused",
296
+ ask: "answer from the board, memory and the log", remember: "save a note to shared memory", structure: "check file budgets and shared names", budget: "quota windows per peer and why one is paused",
279
297
  instructed: "run a confirmed exact or intent instruction",
280
298
  guidance: "guidance declarations and the probe lifecycle", lineage: "execution metadata and evidence strengths", turns: "recent turns and the files each changed",
281
299
  undo: "put back the files a turn changed", report: "turns, tokens, messages and task events", usage: "tokens per group from the roll-up", export: "events as JSON lines",
@@ -320,6 +338,7 @@ export const EXAMPLES: Readonly<Record<string, readonly string[]>> = {
320
338
  instructed: ["ahub instructed run", "ahub instructed run task assign 12 claude"],
321
339
  help: ["ahub help task"], version: ["ahub version"], "--version": ["ahub --version"], completion: ["ahub completion zsh"],
322
340
  up: ["ahub up --no-console"], console: ["ahub console --panels"], pet: ["ahub pet --short"],
341
+ structure: ["ahub structure check", "ahub structure baseline --write"],
323
342
  sdlc: ["ahub sdlc status 12", "ahub sdlc explain 12 --json"], backlog: ["ahub backlog list --full", "ahub backlog return 12 3 waiting on a spec"],
324
343
  status: ["ahub status --verbose"], logs: ["ahub logs -f"], doctor: ["ahub doctor --json"], agents: ["ahub agents --json"],
325
344
  kill: ["ahub kill"], down: ["ahub down"], tail: ["ahub tail"],
@@ -339,7 +358,7 @@ export const EXAMPLES: Readonly<Record<string, readonly string[]>> = {
339
358
  bench: ["ahub bench list"], "check-path": ["ahub check-path src/cli/help.ts"], memory: ["ahub memory search sweep"], goal: ["ahub goal list"], ui: ["ahub ui --no-open"],
340
359
  };
341
360
  /** Commands nobody types: a process the hub starts, or a hook a tool calls. They have no example. */
342
- export const INTERNAL_COMMANDS: readonly string[] = ["daemon", "recovery-run", "manager", "facts"];
361
+ export const INTERNAL_COMMANDS: readonly string[] = ["daemon", "host", "recovery-run", "manager", "facts"];
343
362
 
344
363
  /** One example per native agent, from its own definition: `ahub <kind> --print-command` when its usage has that flag (it prints the launch and starts nothing), else the bare command. */
345
364
  function nativeExample(command: string, entries: readonly HelpEntry[]): string[] {
@@ -380,6 +399,7 @@ export function helpFlags(command: string, entries: readonly HelpEntry[] = HELP)
380
399
  * file adds) falls back to the forms that take it, and `test/help.test.ts` fails a flag of any command in this file that has no line.
381
400
  */
382
401
  export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
402
+ "structure --write": "write the initial or reduced baseline",
383
403
  "--json": "one JSON document on stdout, never colored",
384
404
  "--color": "auto, always or never; auto follows NO_COLOR, FORCE_COLOR and the terminal",
385
405
  // in many commands
@@ -400,10 +420,11 @@ export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
400
420
  "--shadow": "hub-owned snapshots for a non-git folder", "--release-guard": "install the tag pre-push hook", "--focus": "area the survey looks at", "--review": "review scope: full, delta or none",
401
421
  "--reviewers": "number of reviewers", "--ci": "CI scope: full, focused or reuse", "--reserved": "reserve the card for this peer", "--unreserve": "clear the card's reservation", "--to": "version to upgrade to", "--all-stopped": "retarget every stopped project's runtime",
402
422
  "--version": "print the installed version",
423
+ "--write-roadmap": "also refresh tracked roadmap files here", "--close-settled-issues": "also close settled issues (authority needed)",
403
424
  // daemon, agents and recovery
404
- "--unattended": "no permission prompts; the agent acts alone", "--no-console": "do not enter the console", "--no-agents": "do not start the default agents", "--wait": "attach wait in seconds (default 15, max 600)", "--panels": "start in panels mode",
425
+ "--unattended": "no permission prompts; the agent acts alone", "--runtime": "the runtime root this host serves", "--add-current": "add this project when the host starts", "--no-console": "do not enter the console", "--no-agents": "do not start the default agents", "--wait": "attach wait in seconds (default 15, max 600)", "--panels": "start in panels mode",
405
426
  "--no-pet": "turn the attention pet off", "--short": "print ahub!N only when action is needed", "--palette": "retired: run acon ui and open Mini", "pet --window": "retired: run acon ui and open Mini", "--close": "retired: no window is opened", "-f": "follow new lines",
406
- "--stale-anchors": "report stale memory symbol anchors", "--orphans": "inspect registrations whose root is gone", "--kill": "stop the selected orphan's hub", "--revoke": "withdraw a trusted version",
427
+ "--stale-anchors": "report stale memory symbol anchors", "--orphans": "inspect registrations whose root is gone", "--kill": "stop the selected orphan's hub", "--revoke": "withdraw a trusted version", "--pull": "add a pull kind, print its registration", "--latest": "read the newest release's table; person only",
407
428
  "--fresh-session": "restart the peer as a new session", "--stop-and-archive": "stop its targets and archive the snapshot", "--print-command": "print the launch command, start nothing", "--as": "name of the extra instance",
408
429
  "--mode": "tui or headless", "--session-id": "session id to resume or pin", "--provider-profile": "Jcode provider profile to use", "--headless": "run without a terminal", "--backend": "Pi backend: auto, dgx or mlx",
409
430
  "--session-file": "Pi session file to open", "--replace-session": "replace the saved session", "--route": "routing.toml route to use", "--group": "only this catalog group", "--no-thoughts": "hide the peer's reasoning lines",
@@ -422,6 +443,7 @@ export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
422
443
  "--campaign": "campaign id", "--events-after": "continue its events after this number", "--plan": "plan hash to compare under", "--baseline": "baseline attempt id", "--approved": "only approved tasks",
423
444
  "--check": "measure the files now, mark changed ones", "--unmet": "criterion not met (repeatable)", "--head": "head commit SHA the verdict is for", "--findings": "findings as JSON", "--security-pass": "security pass result as JSON",
424
445
  // history, reports and memory
446
+ "--reset": "renew quota after a reset on the same account", "--switched": "renew quota after changing accounts",
425
447
  "--remember": "also save the answer to memory", "--resets-in": "when the window resets, such as 30m", "--window": "5h or week", "--root": "execution root reference as JSON", "--task-scope": "task the root is scoped to",
426
448
  "--nodes": "at most this many nodes", "--edges": "at most this many edges", "--bytes": "at most this many bytes", "--ref": "execution reference as JSON", "--from": "reference the link comes from, as JSON",
427
449
  "--context": "also drop a Codex turn from its conversation", "--dogfood": "print the dogfood scorecard", "--dataset": "directory for the per-project datasets", "--arm": "label of the arm being run", "--repeat": "attempts per task",
@@ -430,13 +452,13 @@ export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
430
452
  "--db": "claude-mem database to read", "--restart": "revisit rows skipped under an earlier policy", "--days": "older than this many days (default 90)", "--depends": "goal it depends on (repeatable)", "--shared": "share the goal across machines",
431
453
  "--force": "void other machines' claims", "--no-open": "print the link, do not open it", "--settings": "open with a settings session", "--stop": "stop the dashboard manager", "--hook": "run as a Claude Code hook; never blocks",
432
454
  // a flag one command uses for something other than its own entry
433
- "--all": "include everything, not the default subset", "status --all": "every registered project", "ui --all": "the unified project dashboard", "reset --all": "archive the state directory instead", "queue --all": "include rows already settled",
455
+ "--all": "include everything, not the default subset", "sdlc --all": "also list settled tasks (the first 100)", "status --all": "every registered project", "ui --all": "the unified project dashboard", "reset --all": "archive the state directory instead", "queue --all": "include rows already settled",
434
456
  "learn --all": "include decided candidates", "learn --accepted": "the followed checklist lines and their status", "research --all": "every registered project", "goal --all": "include completed goals", "sdlc --mode": "off or advise", "sdlc --profile": "audit depth: quick or standard",
435
457
  "sdlc --since": "git ref, or a date for metrics", "memory --since": "only entries since this ISO time", "memory --label": "name for this machine", "bench --memory": "memory state: off, claude-mem, native or both",
436
458
  "task --model": "model label the verdict was given under", "room --action": "accept or discard the application", "room --label": "label for your member", "room --confirm": "member fingerprint prefix",
437
459
  "worktrees --confirm": "fingerprint of the preview to run", "board --label": "only issues with this label", "board --milestone": "only issues of this milestone", "board --repo": "repository to import from", "goal --milestone": "milestone of the goal (repeatable)",
438
460
  "broker --owner": "owner fingerprint allowed (repeatable)", "releases --kind": "capture, source or registry install", "study --after": "continue after this id", "--live-test --project": "project to run the command in", "task --project": "project to hand the work to",
439
- "task --revision": "refuse if the task has moved on", "study --revision": "revision of the evidence to read", "usage --by": "peer, task, issue, pr, release, day or model", "report --by": "group by task", "check-path --peer": "the peer asking (default: this one)",
461
+ "task --revision": "refuse if the task has moved on", "agents --as": "kind name to write instead of the preset id", "study --revision": "revision of the evidence to read", "usage --by": "peer, task, issue, pr, release, day or model", "report --by": "group by task", "check-path --peer": "the peer asking (default: this one)",
440
462
  };
441
463
  /** The widest a flag's line may be, except the standard's two flags: it sits beside the longest label (30 cells and a gap) within 80 columns. */
442
464
  export const FLAG_LINE = 46;
@@ -1,7 +1,17 @@
1
1
  import { conductorOperation, OPERATIONAL_PERSON_GUIDANCE } from "../hub/operational-authority.ts";
2
2
  import { nativeCliMarkerPeer } from "../adapters/definitions/native-identity-defaults.ts";
3
3
  import { recoveryPresentationFlag } from "./recovery-presentation-options.ts";
4
- import { definitionOf, kindOf, type KindMap, type ProjectAdapterCatalog } from "../adapters/registry.ts";
4
+ import { declaredKind } from "../adapters/declaration-resolution.ts";
5
+ import { NATIVE_ADAPTER_POLICY } from "../adapters/definitions/native-adapter-policy.ts";
6
+ import { isBuiltinAdapterKind } from "../adapters/definitions/native-help.ts";
7
+ import type { AdapterDefinition, KindMap, ProjectAdapterCatalog } from "../adapters/registry-types.ts";
8
+
9
+ const builtinKinds = { has: isBuiltinAdapterKind };
10
+
11
+ function builtinCliPolicy(kind: string): Pick<AdapterDefinition, "cli"> | undefined {
12
+ return isBuiltinAdapterKind(kind) ? NATIVE_ADAPTER_POLICY[kind] : undefined;
13
+ }
14
+
5
15
 
6
16
  /** Recovery reads this declaration before delegating to another package's CLI. */
7
17
  export const LIVE_TEST_SUPPORTED = true;
@@ -14,6 +24,9 @@ function recoveryAction(args: readonly string[]): string | undefined {
14
24
  export const LIVE_TEST_PERSON_REFUSAL = "live-test cannot write person-attributed content; use peer tools or a person's terminal";
15
25
 
16
26
  /** Person verdicts and user-authored workflow content are never delegated. */
27
+ const isBudgetRenewal = (command: string, args: readonly string[]): boolean =>
28
+ command === "budget" && args.find(arg => !["--json", "--full", "--ascii"].includes(arg) && !arg.startsWith("--color=")) === "renew";
29
+
17
30
  export function liveTestRefusal(command: string, args: readonly string[], context: { repairedFresh?: boolean } = {}): boolean {
18
31
  if (command === "roadmap" && ![undefined, "list", "show", "--json"].includes(args[0])) return true;
19
32
  if (command === "roadmap" && args[0] === "--json" && ![undefined, "list", "show"].includes(args[1])) return true;
@@ -27,6 +40,7 @@ export function liveTestRefusal(command: string, args: readonly string[], contex
27
40
  if (command === "sdlc" && args[0] === "survey" && args[1] !== "show") return true;
28
41
  // #1403 A4: starting a security audit files a task; only `show` stays a live-test read.
29
42
  if (command === "sdlc" && args[0] === "audit" && args[1] !== "show") return true;
43
+ if (isBudgetRenewal(command, args)) return true;
30
44
  if (command === "model") return true; // #1317: even listing runtime overrides is person-only, never live-test delegated.
31
45
  if (command === "sdlc" && (args[0] === "authorize-release" || args[0] === "plan-review" || args[0] === "release-assign" || args[0] === "merge" || args[0] === "train" && args[1] !== "report")) return true;
32
46
  if (args.some(arg => arg === "--as-user" || arg.startsWith("--as-user="))) return true;
@@ -48,6 +62,8 @@ export function liveTestRefusal(command: string, args: readonly string[], contex
48
62
  // #1057: removing a worktree and its branch is the person's own act, in their own terminal; no delegation, live-test or otherwise, may confirm a tidy.
49
63
  || (command === "worktrees" && args.some(arg => arg === "--confirm" || arg.startsWith("--confirm=")))
50
64
  || (command === "agents" && !args.every(arg => arg === "--json"))
65
+ // #1811 T4: reading Orca for account labels is the person's own step; an agent shell never imports account declarations.
66
+ || command === "accounts"
51
67
  // #1053: an answer is the person's choice, recorded as the person's; an agent that could run it through `--live-test` would answer its own hub_ask as the person. Any operand answers (the set, a pick, --other); a bare listing stays allowed.
52
68
  || (command === "answer" && args.some(arg => arg !== "--json" && arg !== "--full" && !arg.startsWith("--color=")))
53
69
  // #1054: a receipt is the person's record that they read a result and clears their unread need; no delegation, live-test or otherwise, may write one. A plain listing stays allowed.
@@ -75,7 +91,7 @@ export function detectCliIdentity(env: Readonly<Record<string, string | undefine
75
91
  if (session !== undefined && claude === undefined) return invalid("CLAUDE_CODE_SESSION_ID without CLAUDECODE marker");
76
92
  if (claude !== undefined && codex !== undefined) return invalid("conflicting native agent markers");
77
93
  const native = nativeCliMarkerPeer(claude !== undefined, codex !== undefined);
78
- if (hub !== undefined && native !== undefined && (kindOf(hub, instances) ?? hub) !== native) return invalid("AGENTHUB_PEER_ID conflicts with native agent marker");
94
+ if (hub !== undefined && native !== undefined && (isBuiltinAdapterKind(hub) ? hub : declaredKind(hub, instances, builtinKinds) ?? hub) !== native) return invalid("AGENTHUB_PEER_ID conflicts with native agent marker");
79
95
  const peer = hub ?? native;
80
96
  return peer === undefined ? { role: "console" } : { role: "tools", peer };
81
97
  }
@@ -165,7 +181,7 @@ const isPeerReadForm = (command: string, args: readonly string[]): boolean => {
165
181
  export function classifyPeerCommand(command: string, args: readonly string[], catalog?: ProjectAdapterCatalog): PeerCommandAccess {
166
182
  if (command === "model") return "console";
167
183
  if (command === "recovery" && recoveryAction(args) === "reattach") return "console";
168
- const native = catalog?.definitionOf(command) ?? definitionOf(command);
184
+ const native = catalog?.definitionOf(command) ?? builtinCliPolicy(command);
169
185
  if (native?.cli.personOnlyFlags?.some(flag => args.includes(flag))) return "console";
170
186
  if (command === "permission" || command === "watch") return "console";
171
187
  if (args.some((arg) => arg === "--as-user" || arg.startsWith("--as-user="))) return "console";
@@ -201,6 +217,7 @@ export function classifyPeerCommand(command: string, args: readonly string[], ca
201
217
  if (command === "route") return args[0] === "explain" ? "allowed" : "console";
202
218
  // #691: reading agent CLI versions is harmless; trusting an untested version on this machine is a person's.
203
219
  if (command === "agents") return args.every(arg => arg === "--json") ? "allowed" : "console";
220
+ if (command === "accounts") return "console";
204
221
  // #247: reading the research measures and records is harmless (ids and counts only); #933 made backfill a conductor operation (above).
205
222
  if (command === "research") return args[0] === "backfill" ? "console" : "allowed";
206
223
  // #1522 (hub task 969): an agent shell runs the memory family as itself. The CLI wraps the writers in amem's agent attribution (`memoryCommand`), so the recorded and displayed actor is the agent, never the person.
@@ -239,6 +256,7 @@ export function cliCommandLabel(command: string, args: readonly string[], catalo
239
256
  if (command === "lineage") return ["show", "link"].includes(args[0] ?? "") ? `lineage ${args[0]}` : "lineage";
240
257
  if (command === "guidance") return ["create", "list", "show", "withdraw"].includes(args[0] ?? "") ? `guidance ${args[0]}` : "guidance";
241
258
  if (command === "model") return ["list", "set", "clear"].includes(args[0] ?? "") ? `model ${args[0]}` : "model";
259
+ if (isBudgetRenewal(command, args)) return "budget renew";
242
260
  if (command === "peer") return args[0] === "takeover" ? "peer takeover" : "peer";
243
261
  if (command === "backlog") return ["list", "add", "pull", "pull-ready", "split", "return", "plan", "pin", "undo"].includes(args[0] ?? "") ? `backlog ${args[0]}` : "backlog";
244
262
  if (command === "board" && args[0] === "import") return "board import";
@@ -265,12 +283,13 @@ export function cliCommandLabel(command: string, args: readonly string[], catalo
265
283
  if (command === "usage") return args[0] === "limits" || args[0] === "total" ? `usage ${args[0]}` : "usage";
266
284
  if (command === "deliverables") return "deliverables";
267
285
  if (command === "title") return "title";
286
+ if (command === "structure") return args[0] === "check" || args[0] === "baseline" ? `structure ${args[0]}` : "structure";
268
287
  // #1054: a result id is the hub's, but the audit names the action only, never the id.
269
288
  if (command === "results") return ["--read-all", "--unread-last"].find(flag => args.includes(flag))?.slice(2) ? `results ${["--read-all", "--unread-last"].find(flag => args.includes(flag))!.slice(2)}` : args.includes("--read") || args.some(arg => arg.startsWith("--read=")) ? "results read" : "results";
270
289
  if (command === "specs") return ["list", "check", "covers", "stamp"].includes(args[0] ?? "") ? `specs ${args[0]}` : "specs";
271
290
  // #1057: the audit names the subcommand and whether it confirms, never a path, a branch or a fingerprint.
272
291
  if (command === "worktrees") return args[0] === "tidy" ? (args.some(arg => arg === "--confirm" || arg.startsWith("--confirm=")) ? "worktrees tidy confirm" : "worktrees tidy") : "worktrees";
273
- if (!(catalog?.definitionOf(command) ?? definitionOf(command)) && !["upgrade", "restart", "recovery", "recovery-run", "help", "--help", "--version", "version", "completion", "projects", "ui", "manager", "setup", "init", "daemon", "up", "console", "stop", "roles", "models", "say", "queue", "tail", "watch", "budget", "board", "task", "review", "remember", "ask", "route", "pause", "resume", "permit", "answer", "permission", "results", "settings", "roster", "status", "pet", "logs", "export", "report", "research", "memory", "goal", "bench", "sdlc", "role", "facts", "instruction-hook", "instructed", "check-path", "turns", "undo", "kill", "down", "reset", "doctor", "agents", "source", "releases", "broker", "schedule", "intake", "learn", "study"].includes(command)) return "unknown";
292
+ if (!(catalog?.definitionOf(command) ?? builtinCliPolicy(command)) && !["accounts", "upgrade", "restart", "recovery", "recovery-run", "help", "--help", "--version", "version", "completion", "projects", "ui", "manager", "setup", "init", "daemon", "host", "up", "console", "stop", "roles", "models", "say", "queue", "tail", "watch", "budget", "board", "task", "review", "remember", "ask", "route", "pause", "resume", "permit", "answer", "permission", "results", "settings", "roster", "status", "pet", "logs", "export", "report", "research", "memory", "goal", "bench", "sdlc", "role", "facts", "instruction-hook", "instructed", "check-path", "turns", "undo", "kill", "down", "reset", "doctor", "agents", "source", "releases", "broker", "schedule", "intake", "learn", "study"].includes(command)) return "unknown";
274
293
  if (["task", "queue", "budget", "route", "recovery", "models", "projects", "research", "memory", "goal", "bench", "agents", "roster", "settings"].includes(command)) {
275
294
  const sub = command === "bench" || command === "memory" || command === "goal" ? args.find((arg) => arg !== "--json") : args[0];
276
295
  if (sub && ["propose", "show", "assign", "unassign", "escalate", "cancel", "claim", "label", "list", "add", "resolve", "resume", "set", "execution", "explain", "status", "abort", "dispose", "reattach", "setup", "start", "stop", "remove", "discard", "export", "backfill", "addons", "run", "report", "compare", "search", "graph", "promote", "demote", "forget", "supersede", "dedupe", "decay", "rebuild", "sync", "machine", "import", "suggestions", "confirm", "reject", "new", "link", "state", "done", "take", "trust"].includes(sub)) return `${command} ${sub}`;
@@ -86,8 +86,7 @@ export interface StartHookReading { hubCheck?: HubCheck; thisLaunch?: boolean }
86
86
 
87
87
  /** A check that must stay clearly below the hook entry's own timeout, process start included. */
88
88
  export const START_HOOK_TOTAL_MS = 2_500;
89
- /** The timeout registered for the start entry; the total above must stay under it with room for the process to start. */
90
- export const START_HOOK_TIMEOUT_S = 5;
89
+ export { START_HOOK_TIMEOUT_S } from "../adapters/definitions/native-launch-settings.ts";
91
90
  const POLL_MS = 300;
92
91
 
93
92
  export interface StartHookNotice {
package/src/cli/launch.ts CHANGED
@@ -8,18 +8,20 @@ import { resolve, join, basename, dirname, isAbsolute } from "node:path";
8
8
  import { processLiveness, processSignature } from "../pi/process-signature.ts";
9
9
  import { realPath } from "../hub/project.ts";
10
10
  import { peerChildEnv, processTable } from "../hub/child-process.ts";
11
- import { definitionOf } from "../adapters/registry.ts";
12
- import { START_HOOK_TIMEOUT_S } from "./launch-check.ts";
11
+ import { nativeLaunchDeclaration } from "../adapters/definitions/native-launch-declarations.ts";
12
+ import { nativeWrapperLaunch } from "../adapters/definitions/native-wrapper-launch.ts";
13
+ import type { FactsHook, Launch, StatusLineTee } from "../adapters/definitions/native-launch-settings.ts";
13
14
  import type { InstancesConfig } from "../hub/instances.ts";
14
15
  import { kimiAcpCommand } from "../adapters/definitions/native-daemon-kimi.ts";
15
16
  import { warnLine } from "./warn-line.ts";
16
- export const CLAUDE_CHANNEL = "plugin:agent-hub@agent-hub";
17
+ export { CLAUDE_CHANNEL, sessionSettings, statusLineSettings, UNATTENDED_WARNING } from "../adapters/definitions/native-launch-settings.ts";
18
+ export type { FactsHook, Launch, StatusLineTee } from "../adapters/definitions/native-launch-settings.ts";
17
19
 
18
20
  export { retainedLaunchWarning } from "../adapters/definitions/native-cli-retained.ts";
19
21
 
20
22
  /** Consume only ahub's selector, never native arguments after the passthrough delimiter. */
21
23
  export function instanceLaunchArguments(command: string, raw: readonly string[], instances?: InstancesConfig): { instance?: string; args: string[]; hubStarted?: true } {
22
- if (!definitionOf(command)) return { args: [...raw] };
24
+ if (!nativeLaunchDeclaration(command)) return { args: [...raw] };
23
25
  const args: string[] = [];
24
26
  let instance: string | undefined, hubStarted = false;
25
27
  for (let index = 0; index < raw.length; index++) {
@@ -30,14 +32,14 @@ export function instanceLaunchArguments(command: string, raw: readonly string[],
30
32
  const id = arg === "--as" ? raw[++index] : arg.slice("--as=".length);
31
33
  if (!id || id.startsWith("--")) throw new Error("--as needs a declared instance id");
32
34
  const declaration = instances && Object.hasOwn(instances, id) ? instances[id] : undefined;
33
- if (!declaration || declaration.kind !== command || !definitionOf(id, instances)) throw new Error("--as must name a declared instance of this command's native kind");
35
+ if (!declaration || declaration.kind !== command || !nativeLaunchDeclaration(id, instances)) throw new Error("--as must name a declared instance of this command's native kind");
34
36
  // #223: a headless reviewer is started by the hub, never from this terminal.
35
- const runtime = definitionOf(id, instances), base = definitionOf(command);
37
+ const runtime = nativeLaunchDeclaration(id, instances), base = nativeLaunchDeclaration(command);
36
38
  hubStarted = runtime === base?.reviewerVariant || runtime === base?.headlessVariant;
37
39
  instance = id;
38
40
  }
39
41
  if (hubStarted && args.some(arg => arg !== "--print-command" && arg !== "--dry-run")) {
40
- const writer = definitionOf(instance!, instances) === definitionOf(command)?.headlessVariant;
42
+ const writer = nativeLaunchDeclaration(instance!, instances) === nativeLaunchDeclaration(command)?.headlessVariant;
41
43
  throw new Error(`${instance} is a headless ${writer ? "implementer the hub runs per task" : "reviewer the hub runs per review"}: ahub ${command} --as ${instance} takes no launch arguments`);
42
44
  }
43
45
  return { ...(instance ? { instance } : {}), args, ...(hubStarted ? { hubStarted: true as const } : {}) };
@@ -62,25 +64,12 @@ export function nativeLaunchEnv(tool: string, source: NodeJS.ProcessEnv, instanc
62
64
  const env = peerChildEnv(tool, source, { preserveOrca: true });
63
65
  delete env.AGENTHUB_UNATTENDED;
64
66
  // Channel evidence for the plugin (issue #205): set beside the development-channel flag `buildLaunch` always passes.
65
- const definition = definitionOf(tool, instances);
66
- if (definition?.identity.mcp === "channel-plugin" && !definition.attach?.pullOnlyForms?.includes("tui")) env.AGENTHUB_CHANNEL = "1";
67
- if (definition?.attach?.pullOnlyForms?.includes("tui")) delete env.AGENTHUB_MODE; // its MCP child must attach pull-only, never as a tools socket
67
+ const definition = nativeLaunchDeclaration(tool, instances);
68
+ if (definition?.identity.mcp === "channel-plugin" && !definition.pullOnly) env.AGENTHUB_CHANNEL = "1";
69
+ if (definition?.pullOnly) delete env.AGENTHUB_MODE; // its MCP child must attach pull-only, never as a tools socket
68
70
  return env;
69
71
  }
70
72
 
71
- export const UNATTENDED_WARNING =
72
- "WARNING: --unattended disables permission prompts. Other agents' messages are untrusted input and this agent will act on its own judgment without asking you.";
73
-
74
- export interface Launch {
75
- cmd: string;
76
- args: string[];
77
- warning?: string;
78
- permissionHook?: boolean;
79
- hookPurpose?: FactsHook["purpose"];
80
- settingsFile?: string;
81
- unattended?: boolean;
82
- }
83
-
84
73
  /** Retire only our prior private Claude settings file, after the replacement launch record is committed. */
85
74
  export function cleanupClaudeSettings(stateDir: string, previous: unknown): void {
86
75
  if (typeof previous !== "string" || !isAbsolute(previous) || !/^claude-settings-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.json$/.test(basename(previous))) return;
@@ -290,40 +279,6 @@ export async function runClaudeLaunch(launch: Launch, options: { cwd: string; en
290
279
  });
291
280
  }
292
281
 
293
- export interface StatusLineTee {
294
- /** absolute path of src/cli/statusline-tee.ts */
295
- script: string;
296
- stateDir: string;
297
- /** the user's own statusLine setting, wrapped so the status line looks the same */
298
- original?: { command?: string; refreshInterval?: number; padding?: number };
299
- }
300
-
301
- const sh = (s: string) => `'${s.replace(/'/g, `'\\''`)}'`;
302
-
303
- /**
304
- * Settings for one session that put the tee in front of the user's status line command. Claude Code's status line
305
- * input carries `rate_limits`; this is the hub's Claude quota source. `~/.claude/settings.json` is never edited.
306
- */
307
- export function statusLineSettings(tee: StatusLineTee): string {
308
- const command = `AGENTHUB_STATE_DIR=${sh(tee.stateDir)} AGENTHUB_STATUSLINE_CMD=${sh(tee.original?.command ?? "")} bun ${sh(tee.script)}`;
309
- return JSON.stringify({ statusLine: { type: "command", command, refreshInterval: tee.original?.refreshInterval ?? 10, ...(tee.original?.padding !== undefined ? { padding: tee.original.padding } : {}) } });
310
- }
311
-
312
- /** Shared facts, native observation and permission hook transport. */
313
- export interface FactsHook {
314
- script: string;
315
- stateDir: string;
316
- /** The same hook transport can observe native turns without injecting facts. */
317
- purpose?: "facts" | "idle" | "facts-and-idle" | "permission";
318
- /** Observe native sessions/turns for every enabled facts, idle or conductor hook configuration. */
319
- observeNative?: boolean;
320
- /**
321
- * #1798 T3: add the session-start Hub check entry. Opt-in: only the interactive `ahub claude` entry and its preview set it.
322
- * `claudeObservationHooks` never does, and the headless implementer and benchmarks call `sessionSettings` without it.
323
- */
324
- startCheck?: boolean;
325
- }
326
-
327
282
  /** Shared by actual launch and preview; permissions are always enabled, advisory facts remain disabled. */
328
283
  export function claudeObservationHooks(config: { coordination?: string; task_sweep?: { enabled: boolean }; roles?: Record<string, string[]> }, paths: Pick<FactsHook, "script" | "stateDir">): FactsHook {
329
284
  const facts = config.coordination === "turn-free";
@@ -332,36 +287,12 @@ export function claudeObservationHooks(config: { coordination?: string; task_swe
332
287
  return { ...paths, purpose: facts ? (idle ? "facts-and-idle" : "facts") : idle || observeNative ? "idle" : "permission", ...(observeNative ? { observeNative: true } : {}) };
333
288
  }
334
289
 
335
- /**
336
- * The one `--settings` value of a hub-launched Claude session: the status line tee, and in a turn-free project the
337
- * facts hook before and after every tool call and at the end of each turn (issue #108; the turn end is the quiescence
338
- * evidence of issue #107).
339
- */
340
- export function sessionSettings(tee?: StatusLineTee, facts?: FactsHook): string {
341
- const settings = (tee ? JSON.parse(statusLineSettings(tee)) : {}) as Record<string, unknown>;
342
- if (facts) {
343
- const hooks = [{ type: "command", command: `AGENTHUB_STATE_DIR=${sh(facts.stateDir)} AGENTHUB_HOOK_PURPOSE=${sh(facts.purpose ?? "facts")} bun ${sh(facts.script)}`, timeout: 5 }];
344
- settings.hooks = { PreToolUse: [{ matcher: "*", hooks }], ...(facts.purpose !== "permission" ? { PostToolUse: [{ matcher: "*", hooks }], Stop: [{ hooks }] } : {}) };
345
- if (facts.observeNative) Object.assign(settings.hooks as object, { SessionStart: [{ matcher: "*", hooks }], UserPromptSubmit: [{ hooks }] });
346
- }
347
- if (facts?.startCheck) {
348
- // Reads and prints only: its own command, so it records no native session or turn facts and turns on no idle, facts or sweep behavior. Where the
349
- // observation entry also fires on SessionStart the notice is a second, separate entry in the same array (the check appears once per session start).
350
- const check = { type: "command", command: `AGENTHUB_STATE_DIR=${sh(facts.stateDir)} AGENTHUB_HOOK_PURPOSE='start-check' bun ${sh(facts.script)}`, timeout: START_HOOK_TIMEOUT_S };
351
- const hooks = (settings.hooks ?? (settings.hooks = {})) as Record<string, unknown[]>;
352
- hooks.SessionStart = [...(hooks.SessionStart ?? []), { matcher: "startup|resume", hooks: [check] }];
353
- }
354
- return JSON.stringify(settings);
355
- }
356
-
357
290
  export function buildLaunch(
358
291
  tool: "claude" | "codex",
359
292
  userArgs: string[],
360
293
  ctx: { instance?: string; unattended: boolean; proxyUrl?: string; launchTokenEnv?: string; codexBin?: string; statusLine?: StatusLineTee; facts?: FactsHook; preview?: boolean },
361
294
  ): Launch {
362
- const adapter = definitionOf(tool);
363
- if (!adapter) throw new Error("native launch definition unavailable");
364
- const { metadata: _metadata, ...launch } = adapter.start.launch!({
295
+ const { metadata: _metadata, ...launch } = nativeWrapperLaunch(tool, {
365
296
  instance: ctx.instance ?? tool, form: "tui", projectRoot: process.cwd(), stateDir: ctx.facts?.stateDir ?? ctx.statusLine?.stateDir ?? "",
366
297
  entrypoint: resolve(import.meta.dir, "main.js"), userArgs, env: {}, ...ctx,
367
298
  });
@@ -0,0 +1,29 @@
1
+ // #1778 T7: the light path of `src/cli/main.js`. A command that needs nothing from the shared invocation setup in `main.ts`
2
+ // (project selection, caller identity, audit) reaches its command module from here, and never loads `main.ts` or `hub/config.ts`.
3
+ // Anything else returns false and `main.js` falls through to `main.ts`, so no command changes behavior.
4
+ import { commandLoader } from "./command-table.ts";
5
+ import type { CommandContext } from "./command-context.ts";
6
+
7
+ /** The environment markers `detectCliIdentity` reads. With none set, and no recovery, instructed-child or project marker, the caller is the person's own shell (`role: "console"`). */
8
+ const MARKER = /^(?:AGENTHUB_(?:PEER_ID|PROJECT_DIR|INSTRUCTED|RECOVERY)|CLAUDECODE$|CLAUDE_CODE_SESSION_ID$|CODEX_THREAD_ID$)/;
9
+
10
+ /** The commands whose behavior for that caller is exactly what their module does: `version` prints, `instruction-hook` returns unless the caller is an agent. */
11
+ const LIGHT = new Set(["version", "--version", "instruction-hook"]);
12
+
13
+ // used-by: src/cli/main.js (through runLight)
14
+ export function isLightInvocation(argv: readonly string[], env: Readonly<Record<string, string | undefined>>): boolean {
15
+ if (argv.length !== 1 || !LIGHT.has(argv[0]!)) return false;
16
+ return !Object.keys(env).some(key => MARKER.test(key));
17
+ }
18
+
19
+ // used-by: src/cli/main.js
20
+ /** Runs the command and answers true, or answers false without side effects when the invocation is not a light one. */
21
+ export async function runLight(argv: readonly string[], env: Readonly<Record<string, string | undefined>>): Promise<boolean> {
22
+ if (!isLightInvocation(argv, env)) return false;
23
+ const load = commandLoader(argv[0]!, []);
24
+ if (!load) return false;
25
+ // Only what these modules read: the person's shell has no hub connection to make.
26
+ const context = { args: [], caller: { role: "console" }, liveTest: false, connect: async () => { throw new Error("no hub connection on the light path"); } } as unknown as CommandContext;
27
+ await (await load()).run(context);
28
+ return true;
29
+ }
package/src/cli/main.js CHANGED
@@ -18,4 +18,11 @@ if (process.env.AGENTHUB_INSTRUCTED_IPC !== undefined) {
18
18
  if (process.argv[2] === "__complete") {
19
19
  const { completeWords } = await import("./completion.ts");
20
20
  console.log(completeWords(process.argv.slice(process.argv[3] === "--" ? 4 : 3)).join("\n"));
21
- } else await import("./main.ts");
21
+ } else if (!lightEligible() || !await (await import("./light-dispatch.ts")).runLight(process.argv.slice(2), process.env)) await import("./main.ts");
22
+
23
+ // #1778 T7: the cheap half of the light gate, so nothing else is imported for a call that cannot be light. src/cli/light-dispatch.ts holds the same marker pattern and re-checks it.
24
+ function lightEligible() {
25
+ const argv = process.argv.slice(2);
26
+ if (argv.length !== 1 || !["version", "--version", "instruction-hook"].includes(argv[0])) return false;
27
+ return !Object.keys(process.env).some(key => /^(?:AGENTHUB_(?:PEER_ID|PROJECT_DIR|INSTRUCTED|RECOVERY)|CLAUDECODE$|CLAUDE_CODE_SESSION_ID$|CODEX_THREAD_ID$)/.test(key));
28
+ }