@staix/agent-hub 0.45.0 → 0.46.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 (107) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +10 -4
  3. package/docs/adding-an-ai-tool.md +1 -0
  4. package/docs/agent-notes/adapters.md +33 -4
  5. package/docs/agent-notes/budget.md +2 -1
  6. package/docs/agent-notes/daemon.md +5 -1
  7. package/docs/agent-notes/security-review.md +3 -2
  8. package/docs/agent-notes/tasks.md +3 -1
  9. package/docs/agent-notes/tests.md +1 -1
  10. package/docs/design/adapters.md +16 -0
  11. package/docs/design/agent-hub-architecture.md +12 -0
  12. package/docs/design/cli-output.md +2 -0
  13. package/docs/design/roadmap.md +86 -5
  14. package/docs/design/task-board.md +2 -2
  15. package/docs/dogfood.md +15 -0
  16. package/docs/events.md +2 -2
  17. package/docs/operations.md +102 -20
  18. package/docs/quickstart.md +9 -3
  19. package/docs/security.md +7 -5
  20. package/docs/smoke.md +1 -1
  21. package/docs/verification/2026-11-05-hardcoded-values-classification-rules.md +28 -0
  22. package/docs/verification/2026-11-22-agy-1.5.14.md +27 -0
  23. package/docs/verification/2026-11-22-claude-instruction-hook.md +35 -0
  24. package/docs/verification/2026-11-22-instructed-ipc.md +9 -0
  25. package/docs/verification/2026-11-22-jcode-1.0.3.md +71 -0
  26. package/docs/verification/2026-11-22-jcode-separate-home.md +14 -0
  27. package/docs/verification/2026-11-22-qwen-0283-acp.md +28 -0
  28. package/docs/verification/2026-11-22-qwen-0283-dual-output.md +33 -0
  29. package/docs/verification/2026-11-22-roadmap-r5-view-receipt.md +63 -0
  30. package/docs/verification/2026-11-23-0.46.0.md +44 -0
  31. package/docs/verification/assets/1483-r5-detail-1440-light.png +0 -0
  32. package/docs/verification/assets/1483-r5-detail-390-light.png +0 -0
  33. package/docs/verification/assets/1483-r5-view-1440-dark.png +0 -0
  34. package/docs/verification/assets/1483-r5-view-1440-light.png +0 -0
  35. package/docs/verification/assets/1483-r5-view-390-dark.png +0 -0
  36. package/docs/verification/assets/1483-r5-view-390-light.png +0 -0
  37. package/docs/verification/assets/1483-r5-view-820-dark.png +0 -0
  38. package/docs/verification/assets/1483-r5-view-820-light.png +0 -0
  39. package/docs/verified.json +23 -23
  40. package/package.json +3 -2
  41. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  42. package/plugins/agent-hub/kimi-hook.js +5951 -5499
  43. package/plugins/agent-hub/server.js +1136 -1015
  44. package/plugins/agent-hub/skills/ahub/SKILL.md +17 -0
  45. package/plugins/agent-hub/skills/ahub-manage/SKILL.md +37 -0
  46. package/plugins/agent-hub/skills/ahub-status/SKILL.md +14 -0
  47. package/plugins/agent-hub/skills/ahub-use/SKILL.md +12 -0
  48. package/src/adapters/claude-channel.ts +2 -1
  49. package/src/adapters/compat.ts +12 -11
  50. package/src/adapters/definitions/native-cli-claude-setup.ts +9 -1
  51. package/src/adapters/definitions/native-cli-doctor.ts +8 -5
  52. package/src/adapters/definitions/native-cli-jcode-home-init.ts +158 -0
  53. package/src/adapters/definitions/native-cli-jcode-home.ts +72 -0
  54. package/src/adapters/definitions/native-cli-jcode-mcp.ts +20 -0
  55. package/src/adapters/definitions/native-cli-skills.ts +29 -0
  56. package/src/cli/claude-profile-hook.ts +40 -3
  57. package/src/cli/console-state.ts +55 -26
  58. package/src/cli/console-usage.ts +5 -3
  59. package/src/cli/console.ts +35 -4
  60. package/src/cli/help.ts +15 -10
  61. package/src/cli/identity.ts +2 -1
  62. package/src/cli/instruction-hook.ts +28 -0
  63. package/src/cli/jcode-mcp.ts +2 -1
  64. package/src/cli/main.js +8 -0
  65. package/src/cli/main.ts +138 -18
  66. package/src/cli/output-standard.ts +3 -55
  67. package/src/cli/output.ts +8 -2
  68. package/src/cli/recovery-package.ts +47 -11
  69. package/src/cli/roadmap.ts +37 -3
  70. package/src/cli/setup-homes.ts +1 -0
  71. package/src/cli/setup.ts +1 -1
  72. package/src/cli/skills-install.ts +463 -0
  73. package/src/cli/task-output.ts +1 -1
  74. package/src/cli/upgrade-presentation-flags.ts +1 -1
  75. package/src/hub/board.ts +42 -4
  76. package/src/hub/budget-projection.ts +99 -0
  77. package/src/hub/claude-launch-proof.ts +5 -1
  78. package/src/hub/conductor.ts +8 -3
  79. package/src/hub/config-apply.ts +3 -2
  80. package/src/hub/config-tier.ts +1 -1
  81. package/src/hub/config-trust.ts +1 -1
  82. package/src/hub/control-client.ts +9 -2
  83. package/src/hub/daemon.ts +457 -26
  84. package/src/hub/events.ts +1 -1
  85. package/src/hub/execution-budget.ts +29 -8
  86. package/src/hub/hub-tools.ts +2 -2
  87. package/src/hub/inference.ts +1 -1
  88. package/src/hub/instances.ts +10 -1
  89. package/src/hub/instructed-exact.ts +95 -0
  90. package/src/hub/instructed-intent.ts +64 -0
  91. package/src/hub/instructed-ipc.ts +33 -0
  92. package/src/hub/instructed-runtime.ts +19 -0
  93. package/src/hub/instruction-receipt.ts +218 -0
  94. package/src/hub/manager.ts +46 -3
  95. package/src/hub/registry.ts +1 -1
  96. package/src/hub/roadmap-decompose.ts +60 -1
  97. package/src/hub/roadmap-sync.ts +2 -2
  98. package/src/hub/roadmap.ts +19 -1
  99. package/src/hub/routing.ts +18 -1
  100. package/src/hub/runtime-capture-prune.ts +2 -1
  101. package/src/hub/settings.ts +2 -1
  102. package/src/hub/tasks.ts +194 -12
  103. package/src/hub/ui.ts +6 -2
  104. package/src/hub/usage-rollup.ts +42 -2
  105. package/src/ui/index.html +342 -8
  106. package/src/ui/plugin.ts +6 -2
  107. package/src/ui/roadmap-model.ts +70 -0
@@ -1,3 +1,4 @@
1
+ import { Report as SharedReport, paint as sharedPaint, wrap as sharedWrap } from "@staix/cli-output";
1
2
  import { consoleNeeds, characterAttentionLine, attentionCommand } from "./attention.ts";
2
3
  import { CHARACTERS, petFrame, petSize, petFooterRows, type CharacterId, type PetSize, type PetPose } from "../pet/frame.ts";
3
4
  import { PEER_PALETTE } from "../ui/peer-palette.ts";
@@ -72,6 +73,8 @@ export interface ConsoleState {
72
73
  usage?: UsageState; usageTask?: number;
73
74
  /** Absent on older hubs, null when the current hub cannot report room status. */
74
75
  rooms?: RoomStatusView[] | null; roomSelection?: string;
76
+ /** #1483 R5: the Roadmap panel (9): the public milestones, the drift count read when the panel opens, and why either is missing. */
77
+ roadmap?: ConsoleMilestone[]; roadmapKnown?: boolean; roadmapProblem?: string; roadmapDrift?: { at: number; findings: number; unknown?: number; problem?: string };
75
78
  actionLock?: { prefix: string[]; id: string; revision: number; state: string; owner?: string; reserved?: string; reviewer?: string; waiting?: boolean; syntax?: "planning" | "ownerless-return"; revisionField?: "planningRevision" | "flowRevision" };
76
79
  confirm?: { type: "permission"; id: string; option: string; peer: string } | { type: "command"; args: string[]; prompt?: string; lock?: ConsoleState["actionLock"] } | { type: "permission_default"; peer: string; source: string };
77
80
  optionChoice?: string;
@@ -84,6 +87,12 @@ export interface ConsoleState {
84
87
  permissionDefaultsHandled: string[];
85
88
  }
86
89
  const roomsVisible = (s: Pick<ConsoleState, "rooms">) => s.rooms === null || Array.isArray(s.rooms) && s.rooms.length > 0;
90
+ /** #1483 R5: what the Roadmap panel shows per milestone; `approved`/`total` are its task roll-up and `withheld` counts private members. */
91
+ export interface ConsoleMilestone { id: number; title: string; horizon: string; state: string; order: number; approved: number; total: number; withheld: number }
92
+ const ROADMAP_LANES = ["now", "next", "later"] as const;
93
+ const laneOrder = (horizon: string) => { const at = ROADMAP_LANES.indexOf(horizon as typeof ROADMAP_LANES[number]); return at < 0 ? ROADMAP_LANES.length : at; };
94
+ /** The Roadmap panel is offered only by a hub that advertises it, so an older hub keeps its eight tabs. */
95
+ const roadmapVisible = (s: Pick<ConsoleState, "features">) => s.features?.includes("roadmap") === true;
87
96
  /** A detail view: text as the stream shows it, or labeled fields. */
88
97
  export type Detail = string | Record<string, unknown>;
89
98
  export type ConsoleEffect = { type: "exit" } | { type: "permit"; id: string; option?: string } | { type: "answer"; set: string; answers: { questionId: string; optionIds: string[]; other?: string }[] } | { type: "peer_takeover"; peer: string; standbyId: string } |
@@ -127,6 +136,7 @@ export function permissionDefaultText(row: Pick<PermissionDefault, "peer" | "sou
127
136
  return `never-ask default for ${row.peer} from ${quoted(row.source)}\n${permissionBoundary(row.peer, undefined, createProjectAdapterCatalog())}\nUntil you answer y, this default stays ask. y enables; n cancels for this hub; Esc defers.`;
128
137
  }
129
138
  /** Strip terminal controls before any daemon or child output reaches a terminal. Preserve printable Unicode. */
139
+ // Preserve the hub's control and header policy for non-Report output.
130
140
  export function terminalText(value: unknown): string {
131
141
  return sanitize(String(value ?? "")
132
142
  .replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\|$)/g, "")
@@ -147,11 +157,7 @@ export const TONE_ROLE: Readonly<Partial<Record<Tone, Role>>> = Object.freeze({
147
157
  info: "accent", strong: "header", success: "success", attention: "warning", failure: "error", muted: "hint", number: "value",
148
158
  });
149
159
  export function paint(line: Span[], color: boolean): string {
150
- return line.map(span => {
151
- const text = terminalText(span.text);
152
- const sgr = span.role && Object.hasOwn(ROLE_SGR, span.role) ? ROLE_SGR[span.role] : span.tone && Object.hasOwn(PALETTE, span.tone) ? PALETTE[span.tone] : undefined;
153
- return color && sgr && text ? sgr + text + SGR_RESET : text;
154
- }).join("");
160
+ return sharedPaint(line.map(({ tone, ...span }) => ({ ...span, text: terminalText(span.text), ...(tone ? { style: tone } : {}) })), color, PALETTE);
155
161
  }
156
162
  /** Console stream headers only. Tokenize sanitized text; bodies and command output stay plain. */
157
163
  export function streamTokens(value: string, eventTone?: Tone, kind?: string): Span[] {
@@ -235,6 +241,7 @@ export function wrapStreamTokens(value: string, columns: number, tone?: Tone, ki
235
241
  * and summary line. Blank lines follow the standard: exactly one before each section, none after it, never two in a row, none at the
236
242
  * end. Lines are Span arrays; `paint(line, color)` prints them. The builder never colors by itself: it names roles.
237
243
  */
244
+ // Shared Report supplies matching primitives; layout uses shared wrapping with the legacy fallback below.
238
245
  export class Report {
239
246
  private readonly out: Span[][] = [];
240
247
  /** `columns` undefined means no wrap width: standard v1 wraps on a pipe only when COLUMNS is set, so a script reading `ahub doctor | grep` gets whole lines. */
@@ -246,13 +253,13 @@ export class Report {
246
253
  private push(line: Span[]) { this.out.push(line); }
247
254
  /** ` <tool> <Report>` in `header`, then one line of context in `hint` on the same line. At most one per report. */
248
255
  header(tool: string, name: string, context?: string): this {
249
- this.push([{ text: ` ${tool} ${name}`, role: "header" }, ...(context ? [{ text: ` ${context}`, role: "hint" as const }] : [])]);
256
+ this.out.push(...new SharedReport(this.columns, this.ascii).header(tool, name, context).lines());
250
257
  return this;
251
258
  }
252
259
  /** One blank line, then `▸ <Name>` (ASCII `> <Name>`) in `section`, with an optional count in `hint`. */
253
260
  section(name: string, count?: string): this {
254
261
  if (this.out.length && this.out.at(-1)!.length) this.push([]);
255
- this.push([{ text: `${this.ascii ? SECTION_MARKER.ascii : SECTION_MARKER.glyph} ${name}`, role: "section" }, ...(count ? [{ text: ` (${count})`, role: "hint" as const }] : [])]);
262
+ this.out.push(...new SharedReport(this.columns, this.ascii).section(name, count).lines());
256
263
  return this;
257
264
  }
258
265
  /**
@@ -295,19 +302,13 @@ export class Report {
295
302
  }
296
303
  /** ` → <command>` in `accent`: complete and copyable, never shortened. */
297
304
  next(command: string): this {
298
- this.push([{ text: " " }, { text: `${markerCell("next", this.ascii)} ${terminalText(command)}`, role: "accent" }]);
305
+ this.out.push(...new SharedReport(this.columns, this.ascii, { sanitize: terminalText, sanitizeFirst: true, wrapNext: false }).next(command).lines());
299
306
  return this;
300
307
  }
301
308
  /** The last line of a check command: `✗ 2 failed ⚠ 3 warnings ✓ 18 ok`, zero counts omitted, unknowns as `? 2 unknown`. */
302
309
  summary(counts: { failed?: number; warnings?: number; unknown?: number; ok?: number }): this {
303
- const parts: Span[] = [];
304
- const add = (n: number | undefined, name: MarkerName, word: string) => {
305
- if (!n) return;
306
- if (parts.length) parts.push({ text: " " });
307
- parts.push({ text: `${this.ascii ? MARKERS[name].ascii : MARKERS[name].glyph} ${n} ${word}`, role: MARKERS[name].role });
308
- };
309
- add(counts.failed, "fail", "failed"); add(counts.warnings, "warn", counts.warnings === 1 ? "warning" : "warnings"); add(counts.unknown, "unknown", "unknown"); add(counts.ok, "ok", "ok");
310
- if (parts.length) { if (this.out.length) this.push([]); this.push(parts); }
310
+ const lines = new SharedReport(this.columns, this.ascii).summary(counts).lines();
311
+ if (lines.length) { if (this.out.length) this.push([]); this.out.push(...lines); }
311
312
  return this;
312
313
  }
313
314
  lines(): Span[][] { return this.out.map(line => line.map(item => ({ ...item }))); }
@@ -354,13 +355,21 @@ export function fit(value: unknown, columns: number): string {
354
355
  * at whitespace, which they drop; only a word longer than a whole line is split. A tab counts as one space.
355
356
  * Lines come out sanitized: a width counts the `> ` that sanitize() puts before a line starting like a hub header.
356
357
  */
358
+ const wrapGraphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
357
359
  export function wrap(value: unknown, columns: number, hang = 4): string[] {
360
+ const text = terminalText(value);
361
+ // A bare chunk ending in "--- from" becomes a header marker when table padding follows it.
362
+ const quoteChunk = (chunk: string) => sanitize(chunk + " ").slice(0, -1);
363
+ let complex = false;
364
+ if (/[^\p{ASCII}]/u.test(text)) for (const { segment } of wrapGraphemes.segment(text)) {
365
+ if (segment !== Array.from(segment)[0]) { complex = true; break; }
366
+ }
367
+ if (Number.isFinite(columns) && columns >= 1 && !complex) return sharedWrap(text, columns, hang, quoteChunk);
368
+ // Retain code-point splitting and non-positive widths for legacy output: STAIxBWLB/cli-output#36.
358
369
  const lines: string[] = [];
359
370
  const half = Math.floor(columns / 2);
360
- // A bare chunk ending in "--- from" becomes a header marker when table padding follows it.
361
- const quoteChunk = (text: string) => sanitize(text + " ").slice(0, -1);
362
- const width = (text: string) => Bun.stringWidth(quoteChunk(text));
363
- for (const part of terminalText(value).replace(/\t/g, " ").split("\n")) {
371
+ const width = (chunk: string) => Bun.stringWidth(quoteChunk(chunk));
372
+ for (const part of text.replace(/\t/g, " ").split("\n")) {
364
373
  const indent = /^\s*/.exec(part)![0];
365
374
  const lead = Math.min(Bun.stringWidth(indent), half);
366
375
  const pad = " ".repeat(Math.min(lead + hang, half));
@@ -517,9 +526,10 @@ const KEYS: [string, string[]][] = [
517
526
  ["Usage", ["7 Usage panel", "Enter view a peer", "tokens today/7d/lifetime with sources", "task from Tasks (3)"]],
518
527
  ];
519
528
  /** The `?` key table: one group per panel, its keys kept whole and packed into the width after the group column. */
520
- export function keyTable(columns: number, attention = false, characters = false, roomsAvailable = false): Span[][] {
529
+ export function keyTable(columns: number, attention = false, characters = false, roomsAvailable = false, roadmapAvailable = false): Span[][] {
521
530
  const lines: Span[][] = []; const pad = 12;
522
- for (const [group, items] of [...KEYS, ...(roomsAvailable ? [["Rooms", ["8 Rooms panel (read only)", "j/k move", "Enter details"]] as [string, string[]]] : []), ...(attention ? [[characters ? "Pet" : "Attention", ["n next need", characters ? "P next character/off" : "P STAI/off"]] as [string, string[]]] : [])]) {
531
+ for (const [group, items] of [...KEYS, ...(roomsAvailable ? [["Rooms", ["8 Rooms panel (read only)", "j/k move", "Enter details"]] as [string, string[]]] : []),
532
+ ...(roadmapAvailable ? [["Roadmap", ["9 Roadmap panel", "Enter show a milestone", "lanes now/next/later"]] as [string, string[]]] : []), ...(attention ? [[characters ? "Pet" : "Attention", ["n next need", characters ? "P next character/off" : "P STAI/off"]] as [string, string[]]] : [])]) {
523
533
  let text = ""; let head = group;
524
534
  const flush = () => { lines.push([span(head.padEnd(pad), head ? "info" : undefined), span(text)]); head = ""; text = ""; };
525
535
  for (const item of items) { if (text && pad + Bun.stringWidth(`${text} ${item}`) > columns) flush(); text = text ? `${text} ${item}` : item; }
@@ -579,6 +589,8 @@ export function commandNeedsConfirmation(args: string[]): boolean {
579
589
  export function panelRows(s: ConsoleState): any[] {
580
590
  if (s.panel === 1) return Object.entries(s.peers).map(([id, peer]) => ({ id, ...peer, budget: s.budget[id] }));
581
591
  if (s.panel === 8) return s.rooms ?? [];
592
+ // #1483 R5: lanes are the horizon order (now, next, later), then the milestone's own order; an unknown horizon trails.
593
+ if (s.panel === 9) return [...(s.roadmap ?? [])].sort((left, right) => laneOrder(left.horizon) - laneOrder(right.horizon) || left.order - right.order || left.id - right.id);
582
594
  if (s.panel === 2) return s.approvals;
583
595
  if (s.panel === 3) {
584
596
  if (s.backlogView) return s.tasks.filter(t => t.state === "backlog").sort((a, b) => (a.rank ?? Number.MAX_SAFE_INTEGER) - (b.rank ?? Number.MAX_SAFE_INTEGER) || a.id - b.id);
@@ -863,6 +875,7 @@ export function reduceConsole(state: ConsoleState, key: string, now = Date.now()
863
875
  s.panel = panel; s.selection = panel === 5 ? newestEvent(s) : 0; s.taskSelection = undefined; s.queueSelection = undefined; s.roomSelection = undefined; s.detail = undefined; s.requestDetail = undefined; return done(); };
864
876
  if (s.mode === "panels" && /^[1-7]$/.test(key) && !s.optionChoice) return switchPanel(Number(key));
865
877
  if (s.mode === "panels" && key === "8" && !s.optionChoice && roomsVisible(s)) return switchPanel(8);
878
+ if (s.mode === "panels" && key === "9" && !s.optionChoice && roadmapVisible(s)) return switchPanel(9);
866
879
  // Right and Left are the digit of the next or previous tab, wrapping at both ends (#309); the same guards as the
867
880
  // digits apply (the confirm, mode-choice, key-table and editing branches above returned already).
868
881
  if (s.mode === "panels" && (key === "\x1b[C" || key === "\x1b[D") && !s.optionChoice) return switchPanel(s.panel >= 6 ? key === "\x1b[C" ? 1 : 5 : (s.panel + (key === "\x1b[C" ? 0 : 3)) % 5 + 1);
@@ -956,6 +969,7 @@ export function reduceConsole(state: ConsoleState, key: string, now = Date.now()
956
969
  const item = selected?.id;
957
970
  if (s.mode === "panels" && row && s.detail === undefined && (key === "\r" || key === "\n")) {
958
971
  if (s.panel === 3 || s.panel === 4) effects.push({ type: "show", panel: s.panel, id: String(row.id) });
972
+ else if (s.panel === 9) effects.push({ type: "show", panel: 9, id: String(row.id) }); // the hub's public milestone view, with its links and roll-up
959
973
  else if (s.panel === 2) { s.requestDetail = row.id; s.detailOffset = 0; } // the row is the selected request
960
974
  else if (s.panel === 7) { s.detail = { usagePeer: row.id }; s.detailOffset = 0; } // rendered live from s.usage, so a refresh updates it
961
975
  else if (s.panel === 8) { s.roomSelection = row.name; s.detail = { roomName: row.name }; s.detailOffset = 0; }
@@ -1071,6 +1085,8 @@ export const TABLES: Record<number, string[]> = {
1071
1085
  6: ["GROUP", "KEY", "VALUE", "SOURCE", "APPLIES"],
1072
1086
  7: USAGE_HEAD,
1073
1087
  8: ["ROOM", "LINK", "MEMBERS", "REMOTE"],
1088
+ // `PRIVATE` is a count: a withheld member is never named here (#1483 R5).
1089
+ 9: ["ID", "HORIZON", "STATE", "PROGRESS", "PRIVATE", "TITLE"],
1074
1090
  };
1075
1091
  const showPermissionModes = (s: ConsoleState) => Object.values(s.peers).some(peer => peer.permissionMode && peer.permissionMode !== "ask");
1076
1092
  const count = (n: unknown) => typeof n === "number" && n ? String(n) : "-";
@@ -1082,6 +1098,9 @@ export function cells(s: ConsoleState, row: any, selected: boolean, now: number,
1082
1098
  if (s.panel === 8) return [id(row.name, "info"), span(row.link ?? "unknown", row.link ? stateTone(row.link) : "muted"),
1083
1099
  span(row.memberCount === null ? "unknown" : String(row.memberCount), row.memberCount === null ? "muted" : undefined),
1084
1100
  span(row.remotePeers === null ? "unknown" : String(row.remotePeers.length), row.remotePeers === null ? "muted" : undefined)];
1101
+ if (s.panel === 9) return [id(String(row.id), "info"), span(String(row.horizon ?? "later"), row.horizon === "now" ? "attention" : undefined), span(String(row.state ?? "")),
1102
+ span(row.total ? `${row.approved}/${row.total}` : "-", row.total ? undefined : "muted"),
1103
+ span(row.withheld ? String(row.withheld) : "-", row.withheld ? "muted" : undefined), span(String(row.title ?? ""))];
1085
1104
  if (s.panel === 1) {
1086
1105
  const b = s.budget[row.id];
1087
1106
  const wip = s.taskWip?.[row.id];
@@ -1147,6 +1166,7 @@ function roomDetail(row: RoomStatusView): Record<string, unknown> {
1147
1166
  * widest cell or header (Bun.stringWidth, at most a third of the width, wider cells cut with the marker); the last column
1148
1167
  * takes the rest. One-shot callers may supply widths for already-wrapped cells; console defaults stay unchanged.
1149
1168
  */
1169
+ // Local tables retain styled separators, untouched final cells and narrow STAGE geometry: STAIxBWLB/cli-output#37.
1150
1170
  export function table(head: string[], rows: Span[][], columns: number, explicitWidths?: readonly number[]): Span[][] {
1151
1171
  const cap = Math.max(24, Math.floor(columns / 3));
1152
1172
  const width = (cell: Span | undefined) => Bun.stringWidth(flat(cell?.text));
@@ -1239,9 +1259,11 @@ function header(s: ConsoleState, columns: number): Span[] {
1239
1259
  // The tabs can fill an 80-column line, which would squeeze the project name out: below that, one space before a tab instead of two (#683 U3).
1240
1260
  const build = (lead: string) => {
1241
1261
  const tabs: Span[] = [];
1242
- const names = ["Peers", "Approvals", "Tasks", "Queue", "Events", "Settings", "Usage", ...(roomsVisible(s) ? ["Rooms"] : [])];
1243
- for (const [i, name] of names.entries()) {
1244
- const number = i === 7 ? 8 : i + 1, active = number === s.panel, tone = active ? "strong" : "info";
1262
+ // Each tab carries its own number, so hiding Rooms never renumbers the Roadmap panel (#1483 R5).
1263
+ const names: [number, string][] = [[1, "Peers"], [2, "Approvals"], [3, "Tasks"], [4, "Queue"], [5, "Events"], [6, "Settings"], [7, "Usage"],
1264
+ ...(roomsVisible(s) ? [[8, "Rooms"] as [number, string]] : []), ...(roadmapVisible(s) ? [[9, "Roadmap"] as [number, string]] : [])];
1265
+ for (const [i, [number, name]] of names.entries()) {
1266
+ const active = number === s.panel, tone = active ? "strong" : "info";
1245
1267
  tabs.push(span(active ? lead.slice(1) + "[" : lead, tone), span(`${number} ${name}`, tone));
1246
1268
  if (counts[i]) tabs.push(span(` ${counts[i]}`, i === 1 ? "attention" : "failure"));
1247
1269
  tabs.push(span(active ? "]" : " ", tone));
@@ -1364,7 +1386,7 @@ export function renderConsoleLines(s: ConsoleState, columns: number, rows = 24,
1364
1386
  // Options that do not fit even wrapped are shown one per line (clipped to the width, but a label is at most 80 characters) rather than dropped: no option is ever off screen.
1365
1387
  lines.push([span(body.head, "attention")], ...shown.map(text => [span(text)]), ...(optionLines.length <= height - 1 ? optionLines : body.options.map(option => fitLine([span(option, "info")], columns))));
1366
1388
  }
1367
- else if (s.help) lines.push(...keyTable(columns, !!s.petEnabled || !!s.petChoices?.length, !!s.petChoices?.length, roomsVisible(s)));
1389
+ else if (s.help) lines.push(...keyTable(columns, !!s.petEnabled || !!s.petChoices?.length, !!s.petChoices?.length, roomsVisible(s), roadmapVisible(s)));
1368
1390
  else if (s.detail !== undefined || (s.requestDetail && permission)) {
1369
1391
  const usagePeer = s.panel === 7 && s.detail && typeof s.detail === "object" ? (s.detail as { usagePeer?: unknown }).usagePeer : undefined;
1370
1392
  const roomName = s.panel === 8 && s.detail && typeof s.detail === "object" ? (s.detail as { roomName?: unknown }).roomName : undefined;
@@ -1410,6 +1432,13 @@ export function renderConsoleLines(s: ConsoleState, columns: number, rows = 24,
1410
1432
  }
1411
1433
  if (s.panel === 1 && s.versions) lines.push(fitLine(versionsLine(s), columns));
1412
1434
  if (s.panel === 8 && s.rooms === null) lines.push(fitLine([span("Room status unavailable", "attention")], columns));
1435
+ if (s.panel === 9) {
1436
+ const drift = s.roadmapDrift;
1437
+ const note = s.roadmapProblem ? `roadmap unavailable: ${s.roadmapProblem}` : !s.roadmapKnown ? "roadmap loading..."
1438
+ : drift?.problem ? `drift: ${drift.problem}`
1439
+ : `drift ${drift ? `${plural(drift.findings, "finding")}${drift.unknown ? `, ${drift.unknown} unknown` : ""}` : "not checked yet"}${drift ? `, ${relative(drift.at, now)}` : ""}; lanes now, next, later`;
1440
+ lines.push(fitLine([span(note, s.roadmapProblem || drift?.problem ? "failure" : !s.roadmapKnown ? "attention" : "info")], columns));
1441
+ }
1413
1442
  if (s.panel === 3 && s.backlogView) {
1414
1443
  lines.push(fitLine([span(s.tasksKnown === false ? "backlog loading..." : `backlog ${data.length}`, s.tasksKnown === false ? "attention" : "info")], columns));
1415
1444
  } else if (s.panel === 3) {
@@ -1,5 +1,6 @@
1
1
  import { windowKind, type WindowKind } from "../hub/window-kind.ts";
2
2
  import type { Counter, LimitsResult, UsageResult, UsageRow } from "../hub/usage-rollup.ts";
3
+ import { projectionText, type ExhaustionProjection } from "../hub/budget-projection.ts";
3
4
 
4
5
  // #683 U3: what the console's Usage panel shows, as plain strings. No terminal code and no state import here: console-state.ts renders it.
5
6
  // Every number names its source, an unknown counter reads `unknown` (never 0), and a private task is `#id [pii]` with no title.
@@ -33,9 +34,10 @@ export function usagePeers(usage: UsageState | undefined, budget: Record<string,
33
34
  return [...ids].sort().map(id => ({ id }));
34
35
  }
35
36
 
36
- interface Budget { windows?: { id: string; used: number; resetsAt?: number; kind?: string; source?: string }[]; paused?: { resetsAt: number }; note?: string }
37
- const windowText = (w: { id: string; used: number; resetsAt?: number }, rel: (at: number) => string) =>
38
- `${w.id} ${Math.round(w.used * 100)}%${typeof w.resetsAt === "number" ? ` ${rel(w.resetsAt)}` : ""}`;
37
+ interface Budget { windows?: { id: string; used: number; resetsAt?: number; kind?: string; source?: string; left?: number | null; projection?: ExhaustionProjection }[]; paused?: { resetsAt: number }; note?: string }
38
+ // #1513 AC2: the console cell carries the same remainder and forecast the dashboard row and `ahub budget` print.
39
+ const windowText = (w: { id: string; used: number; resetsAt?: number; left?: number | null; projection?: ExhaustionProjection }, rel: (at: number) => string) =>
40
+ `${w.id} ${Math.round(w.used * 100)}%${typeof w.left === "number" ? ` (${Math.round(w.left * 100)}% left)` : ""}${w.projection ? `, ${projectionText(w.projection, rel)}` : ""}${typeof w.resetsAt === "number" ? ` ${rel(w.resetsAt)}` : ""}`;
39
41
  const lastResets = (limits: LimitsResult | undefined, peer: string, count: number) =>
40
42
  (limits?.history ?? []).filter(h => h.type === "quota_reset" && h.peer === peer).slice(-count).reverse();
41
43
 
@@ -95,7 +95,7 @@ function labeled(text: string): Detail {
95
95
  /** One terminal client, no daemon ownership. All text crosses terminalText before writing. */
96
96
  export async function runConsole(options: ConsoleOptions): Promise<void> {
97
97
  const { client } = options; const terminal = options.terminal ?? nativeTerminal();
98
- const color = options.color ?? resolveColor(undefined, streamEnv(terminal.isTTY)) === true;
98
+ const color = options.color ?? resolveColor(undefined, streamEnv(terminal.isTTY), "ahub") === true;
99
99
  let state = initialConsoleState(!!options.panels); state.project = basename(options.cwd);
100
100
  let pet = loadPetConfig(options.cwd);
101
101
  let petSignature = JSON.stringify([pet.enabled, pet.character, pet.size, pet.glyphs, pet.blink, pet.bell]);
@@ -216,6 +216,15 @@ export async function runConsole(options: ConsoleOptions): Promise<void> {
216
216
  client.request({ t: "usage", by: "peer" }, 5000), client.request({ t: "usage", op: "limits", limit: 1000 }, 5000),
217
217
  ...(usageTask !== undefined ? [client.request({ t: "usage", by: "peer", task: usageTask }, 5000)] : [])]);
218
218
  })() : undefined;
219
+ // #1483 R5: the Roadmap panel reads the public milestone list while it is open, and the drift check at most every five minutes.
220
+ // Both are read-only hub ops; an older hub never sees either because its status does not advertise `roadmap`.
221
+ const roadmapOpen = panels && state.panel === 9 && state.features?.includes("roadmap") === true;
222
+ const roadmapReplies = roadmapOpen ? await (async () => {
223
+ const list = await client.request({ t: "task", op: "hub_roadmap_list", args: {} }, 5000);
224
+ const stale = list.ok !== false && (!state.roadmapDrift || Date.now() - state.roadmapDrift.at > 300_000);
225
+ const drift = stale ? await client.request({ t: "task", op: "hub_roadmap_check", args: {} }, 30_000) : undefined;
226
+ return { list, drift };
227
+ })() : undefined;
219
228
  if (!active) return;
220
229
  // #1053 T4: the person's own read of the open questions, asked only of a hub whose status lists the `questions` feature: an older hub is never sent a request it does not know.
221
230
  const hasQuestions = Array.isArray(replies[0]?.status?.features) && replies[0].status.features.includes("questions");
@@ -293,6 +302,28 @@ export async function runConsole(options: ConsoleOptions): Promise<void> {
293
302
  else state.usage = { today: today.usage, week: week.usage, life: life.usage, limits: limits.limits, at: Date.now(), ...(usageReplies.some(reply => reply?.behind) ? { behind: true } : {}),
294
303
  ...(usageTask !== undefined && task?.usage && state.usageTask === usageTask ? { task: task.usage, taskId: usageTask } : {}) };
295
304
  }
305
+ if (roadmapReplies) {
306
+ const { list, drift } = roadmapReplies;
307
+ if (list.ok === false) { state.roadmap = []; state.roadmapKnown = false; state.roadmapProblem = String(list.error ?? "the hub refused the roadmap read"); }
308
+ else {
309
+ let report: any;
310
+ try { report = JSON.parse(String(list.text ?? "")); } catch { report = undefined; }
311
+ const rows = Array.isArray(report?.milestones) ? report.milestones : [];
312
+ state.roadmap = rows.filter((row: any) => row && Number.isSafeInteger(Number(row.id))).map((row: any) => ({
313
+ id: Number(row.id), title: String(row.title ?? ""), horizon: String(row.horizon ?? "later"), state: String(row.state ?? ""), order: Number(row.order ?? 0),
314
+ approved: Number(row.rollup?.tasks?.approved ?? 0), total: Number(row.rollup?.tasks?.total ?? 0), withheld: Number(row.withheld ?? 0) }));
315
+ state.roadmapKnown = true; state.roadmapProblem = undefined;
316
+ }
317
+ if (drift) {
318
+ if (drift.ok === false) state.roadmapDrift = { at: Date.now(), findings: 0, problem: String(drift.error ?? "the hub refused the drift check") };
319
+ else {
320
+ let report: any;
321
+ try { report = JSON.parse(String(drift.text ?? "")); } catch { report = undefined; }
322
+ state.roadmapDrift = { at: Date.now(), findings: Array.isArray(report?.findings) ? report.findings.length : 0,
323
+ ...(Array.isArray(report?.unknown) && report.unknown.length ? { unknown: report.unknown.length } : {}), ...(report?.truncated === true ? { problem: "more findings exist; run ahub roadmap check" } : {}) };
324
+ }
325
+ }
326
+ }
296
327
  if (tasks?.ok) { const parsed = JSON.parse(tasks.text); if (Array.isArray(parsed)) {
297
328
  const readyIds = new Set(ready?.ok ? JSON.parse(ready.text).map((task: any) => task.id) : []);
298
329
  state.tasks = parsed.map(task => ({ ...task, ready: readyIds.has(task.id) }));
@@ -416,15 +447,15 @@ export async function runConsole(options: ConsoleOptions): Promise<void> {
416
447
  if (!action.option) stream({ text: ` ! denial requested for permission ${action.id}`, kind: "permission", tone: "failure" });
417
448
  return;
418
449
  }
419
- if (action.type === "keys") return stream({ text: keyTable(columns, !!state.petEnabled || !!state.petChoices?.length, !!state.petChoices?.length, state.rooms === null || Array.isArray(state.rooms) && state.rooms.length > 0).map(line => paint(line, false)).join("\n"), kind: "console" }, false);
450
+ if (action.type === "keys") return stream({ text: keyTable(columns, !!state.petEnabled || !!state.petChoices?.length, !!state.petChoices?.length, state.rooms === null || Array.isArray(state.rooms) && state.rooms.length > 0, state.features?.includes("roadmap") === true).map(line => paint(line, false)).join("\n"), kind: "console" }, false);
420
451
  if (action.type === "print") return stream({ text: action.text, kind: action.kind, ...(action.tone ? { tone: action.tone } : {}) }, false);
421
452
  if (action.type === "show") {
422
- const result = await client.request(action.panel === 3 ? { t: "task", op: "task_show", args: { id: action.id } } : { t: "queue", op: "show", id: action.id }, 3000);
453
+ const result = await client.request(action.panel === 3 ? { t: "task", op: "task_show", args: { id: action.id } } : action.panel === 9 ? { t: "task", op: "hub_roadmap_show", args: { id: Number(action.id) } } : { t: "queue", op: "show", id: action.id }, 3000);
423
454
  // A late reply is for the panel and row it was asked for: once the person has moved on, it would show one item
424
455
  // while the keys act on another, so it is dropped.
425
456
  if (!active || state.mode !== "panels" || state.panel !== action.panel || state.help || state.detail !== undefined || String(selectedPanelRow(state)?.id) !== action.id) return;
426
457
  state.detailOffset = 0;
427
- state.detail = result.ok === false ? String(result.error) : action.panel === 3 ? labeled(String(result.text)) : result.delivery ?? "delivery not found";
458
+ state.detail = result.ok === false ? String(result.error) : action.panel === 3 || action.panel === 9 ? labeled(String(result.text)) : result.delivery ?? "delivery not found";
428
459
  draw(); return;
429
460
  }
430
461
  if (childRunning) { notice("a command is already running"); draw(); return; }
package/src/cli/help.ts CHANGED
@@ -29,11 +29,13 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
29
29
  ["ahub --project <path|id> <command>", "select a repository or worktree explicitly"],
30
30
  ["ahub projects [--json] [--full] [--color=auto|always|never]", "list registered projects and live status"],
31
31
  ["ahub projects remove <id>", "forget a stopped registration (keeps project files)"],
32
- ["ahub setup [--yes] [--agents <a,b>] [--research|--no-research]", "install or update the channel plugin and project-neutral hook in Claude configuration homes in use, preserving unrelated profile settings, ask once which agents ahub up starts (--agents answers it, --yes keeps the current choice or claude,codex, no terminal keeps the default), save the research default only with explicit --research/--no-research (ordinary setup leaves it unchanged), register the acon console plugin (console/plugins/ahub.json in the hub home, read at acon's next start), then run doctor"],
33
- ["ahub init [--profile dev|research|writing|general|<pack>] [--agents <a,b,...|none>] [--sdlc off|advise|enforce] [--required-checks <a,b,...>] [--coordination advisory|turn-free] [--memory|--no-memory] [--research|--no-research] [--snapshots|--no-snapshots] [--pi|--no-pi] [--specs|--no-specs] [--spec-review off|report|require] [--conductor <peer>|none] [--planner <a,b,...>] [--reviewer <a,b,...>|person] [--track-config|--no-track-config] [--autonomy inherit|off] [--shadow] [--release-guard] [--yes] [--dry-run --json]", "preview or write .agenthub/config.json and the AGENTS.md marker block (drops a legacy CLAUDE.md block); a pack is a shipped one (writing-pack, analysis, ops) or a project file .agenthub/roles/<name>.pack.json; a new project inherits a trusted machine autonomy default and the agent set chosen at ahub setup (start.agents) into config.local.json. Settings flags (#1065): --agents sets start.agents (none starts no agent), --research/--no-research sets research.enabled (new project default: the trusted setup choice, else off) and --autonomy off skips the autonomy inheritance, all in config.local.json; --sdlc sets sdlc.toml mode (off writes no file on a new project); advise/enforce discovers required checks from CI or literal workflow job names; --required-checks overrides discovery, and enforce without names refuses before writes; --coordination, --memory, --snapshots and --pi set their keys in config.json. On an existing project only a flag you give changes anything, and --dry-run shows each change as old -> new (--dry-run --json adds a settings array); a value equal to the current one is a no-op, an invalid value is refused with the allowed ones and nothing is written. --specs/--no-specs and --spec-review set the design-specs keys (and the AGENTS.md specs block). --track-config keeps .agenthub/config.json, routing.toml and sdlc.toml visible to git (a rule that ignores one is named and nothing is written; a routing.toml that names a machine endpoint stays ignored) and lists them to commit; --no-track-config ignores them; either sets the AGENTS.md role sentence, and neither keeps what git and the block say today. A person at a terminal who runs ahub init on a new project with no flag that sets anything and no --yes is asked each setting in turn with its default in brackets (Enter keeps it, a wrong answer asks again, and a third wrong answer ends init with nothing written), sees the plan and answers y/N; N, Ctrl-C and Ctrl-D write nothing. A peer, a live test, a pipe and --dry-run are never asked, and --yes takes the defaults. Success prints next steps to commit shared init changes, start with ahub up or ahub claude and, for advise/enforce, accept specs/departures and use guarded merge. --conductor, --planner and --reviewer (#1408) choose who conducts, plans and reviews, each on its own: the shared config.json roles are written as an explicit list for every peer whose roles change (the one that loses a role too), implementer and verifier are untouched, a peer that cannot hold the role (a headless conductor, a kind that cannot plan) is refused before any write with the reason and the eligible peers, --conductor none leaves the person conducting from ahub console and --reviewer person sends reviews to the person; Executables, secrets, models and permissions stay file edits"],
32
+ ["ahub setup [--yes] [--agents <a,b>] [--research|--no-research] [--undo]", "install or update the channel plugin and project-neutral hook in Claude configuration homes in use, preserving unrelated profile settings, ask once which agents ahub up starts (--agents answers it, --yes keeps the current choice or claude,codex, no terminal keeps the default), save the research default only with explicit --research/--no-research (ordinary setup leaves it unchanged), install the hub's own skills in every other agent host installed here (Codex, Kimi, Qwen, Jcode, Pi, agy; each tree carries a .ahub-skill.json marker and a tree the hub did not write unmodified is reported and left alone), register the acon console plugin (console/plugins/ahub.json in the hub home, read at acon's next start), then run doctor; --undo removes only the hub's own unmodified skill trees and asks once unless --yes is given"],
33
+ ["ahub init [--profile dev|research|writing|general|<pack>] [--agents <a,b,...|none>] [--sdlc off|advise|enforce] [--required-checks <a,b,...>] [--coordination advisory|turn-free] [--memory|--no-memory] [--research|--no-research] [--snapshots|--no-snapshots] [--pi|--no-pi] [--specs|--no-specs] [--spec-review off|report|require] [--conductor <peer>|none] [--planner <a,b,...>] [--reviewer <a,b,...>|person] [--track-config|--no-track-config] [--no-jcode-home] [--autonomy inherit|off] [--shadow] [--release-guard] [--yes] [--dry-run --json]", "preview or write .agenthub/config.json and the AGENTS.md marker block (drops a legacy CLAUDE.md block); a pack is a shipped one (writing-pack, analysis, ops) or a project file .agenthub/roles/<name>.pack.json; a new project inherits a trusted machine autonomy default and the agent set chosen at ahub setup (start.agents) into config.local.json. Settings flags (#1065): --agents sets start.agents (none starts no agent), --research/--no-research sets research.enabled (new project default: the trusted setup choice, else off) and --autonomy off skips the autonomy inheritance, all in config.local.json; --sdlc sets sdlc.toml mode (off writes no file on a new project); advise/enforce discovers required checks from CI or literal workflow job names; --required-checks overrides discovery, and enforce without names refuses before writes; --coordination, --memory, --snapshots and --pi set their keys in config.json. On an existing project only a flag you give changes anything, and --dry-run shows each change as old -> new (--dry-run --json adds a settings array); a value equal to the current one is a no-op, an invalid value is refused with the allowed ones and nothing is written. --specs/--no-specs and --spec-review set the design-specs keys (and the AGENTS.md specs block). --track-config keeps .agenthub/config.json, routing.toml and sdlc.toml visible to git (a rule that ignores one is named and nothing is written; a routing.toml that names a machine endpoint stays ignored) and lists them to commit; --no-track-config ignores them; either sets the AGENTS.md role sentence, and neither keeps what git and the block say today. A person at a terminal who runs ahub init on a new project with no flag that sets anything and no --yes is asked each setting in turn with its default in brackets (Enter keeps it, a wrong answer asks again, and a third wrong answer ends init with nothing written), sees the plan and answers y/N; N, Ctrl-C and Ctrl-D write nothing. A peer, a live test, a pipe and --dry-run are never asked, and --yes takes the defaults. Success prints next steps to commit shared init changes, start with ahub up or ahub claude and, for advise/enforce, accept specs/departures and use guarded merge. --conductor, --planner and --reviewer (#1408) choose who conducts, plans and reviews, each on its own: the shared config.json roles are written as an explicit list for every peer whose roles change (the one that loses a role too), implementer and verifier are untouched, a peer that cannot hold the role (a headless conductor, a kind that cannot plan) is refused before any write with the reason and the eligible peers, --conductor none leaves the person conducting from ahub console and --reviewer person sends reviews to the person; Executables, secrets, models and permissions stay file edits"],
34
34
  ["ahub --live-test [--project <path|id>] <command> [args...]", "user-authorized operational console delegation; ordinary calls retain peer identity; person-authored content refuses"],
35
35
  ["ahub help [command [--ascii]]", "this help, or one command's entries; also --help and -h"],
36
36
  ["ahub version | --version", "print the installed version"],
37
+ ["ahub instructed run [<operation> <args...>]", "with a confirmed managed Claude receipt, run the person's exact command with no arguments or a supported intent command with arguments; unsafe or unclassified forms stay closed"],
38
+ ["ahub instruction-hook", "internal Claude prompt and Stop hook; pending evidence grants no authority"],
37
39
  ["ahub completion zsh|bash|fish", "print a shell completion script; its candidates come from these help entries"],
38
40
  ]],
39
41
  ["Daemon and runtime", [
@@ -66,7 +68,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
66
68
  ["ahub status [--json] [--full] [--verbose] [--ascii] [--color=auto|always|never]", "is the hub OK, and what to do next: an Attention list (each item with its next command), then the hub, peers and tasks; --verbose or --full prints every detail (model backends, specs, queue pressure, schedules, per-peer notes)"],
67
69
  ["ahub status --all [--json] [--color=auto|always|never]", "show every registered project"],
68
70
  ["ahub logs [-f]", "person: last 100 hub.log lines (-f starts at 10); conductor: bounded public lines and follow while authority remains"],
69
- ["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); warn when the CLI or plugin is older than its running daemon"],
71
+ ["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"],
70
72
  ["ahub doctor --stale-anchors [--json]", "read-only bounded report of public memory symbol anchors at current HEAD; private or unavailable evidence stays unknown"],
71
73
  ["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"],
72
74
  ["ahub agents [--json]", "show each gated agent CLI's installed version and verdict (verified, in-line, trusted, refused or unknown)"],
@@ -102,11 +104,11 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
102
104
  ["ahub results [--unread] [--read <id> | --read-all | --unread-last] [--json] [--color=auto|always|never]", "person only: list what the runs you started left behind (unread ones marked *); --read marks one read, --read-all every one, --unread-last lights the most recent read one again; listing never marks anything"],
103
105
  ["ahub roster [list] [--json] [--color=auto|always|never]", "every known peer, participation, start mode and retained work"],
104
106
  ["ahub roles [--json] [--color=auto|always|never]", "each rostered peer's flow roles as the running hub settled them, the planner and who reviews when no reviewer can run; works from a task worktree"],
105
- ["ahub roster add <peer> | remove <peer> [--yes] [--now]", "person or configured conductor: change live participation through settings; removal previews retained messages and task handoff; remove also deletes the roster key of an instance no longer declared"],
107
+ ["ahub roster add <peer> [--yes] | remove <peer> [--yes] [--now]", "person or configured conductor: change live participation through settings; add shows a preflight (CLI version, start mode, for jcode its home and MCP servers) and asks y/N, or needs --yes without a terminal; removal previews retained messages and task handoff; remove also deletes the roster key of an instance no longer declared"],
106
108
  ["ahub autonomy on [--all-projects] [--yes] | off [--all-projects] | status [--json]", "person only: apply the autonomy preset and machine default with one confirmation, optionally to every registered project; off removes fixed preset keys (manual edits included); status reports modes, floor enforcement and Claude homes; settings undo restores a live-hub project write"],
107
109
  ["ahub model set <peer> <model> | clear <peer> | list [--json]", "person only: select a runtime model at the next turn, clear its override, or inspect effective models and pending changes; unsupported peers need a restart"],
108
110
  ["ahub settings [list] [--json] | get <key> [--json]", "the settings the dashboard can change, each with its value, the file it comes from and when it applies; get sdlc.mode or sdlc.required_checks reads running and file values without adding writable keys"],
109
- ["ahub settings set <key> <value|inherit> [--yes] [--preview] [--now] | undo | reload", "validated settings: memory.sync_interval_min applies live (0 disables sync); conductor set is limited to exact live operational keys; undo/reload and other keys are person only; --preview saves nothing; conductor writes keep the person undo record"],
111
+ ["ahub settings set <key> <value|inherit> [--yes] [--preview] [--now] | undo | reload", "validated settings: memory.sync_interval_min applies live (0 disables sync); conductor set is limited to exact live operational keys; instructed.mode is a person-only terminal choice stored in hub.db; its local file is a display copy; undo/reload and other keys are person only; --preview saves nothing; conductor writes keep the person undo record"],
110
112
  ["ahub settings edit <config.local.json|sdlc.toml> (set <path> <json> | remove <path>)... [--reason <text>] [--preview] [--yes] | backups [--json]", "human only: structural config (instances, review, snapshots, approvals, context.gate, research.runners, sdlc.toml mode and required_checks) validated by the hub's own loaders, previewed as a diff and written with a backup; a key that runs code or locates secrets needs its name typed, never --yes"],
111
113
  ["ahub pause|resume <peer>", "hold a peer's deliveries in its queue / release them"],
112
114
  ["ahub title <peer> <text...>", "person only: replace a Pi or local-worker session title; native-title peers rename in their own UI"],
@@ -127,7 +129,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
127
129
  [`ahub roadmap ${ROADMAP_FORMS.link} | ${ROADMAP_FORMS.unlink} | ${ROADMAP_FORMS.order} | ${ROADMAP_FORMS.state}`, "planner or conductor: link and order; done and dropped require the person"],
128
130
  [`ahub roadmap ${ROADMAP_FORMS.unplaced}`, "read open issues, tasks and active or draft specs no milestone places, each with why; private tasks are a count; partial means a lower bound"],
129
131
  [`ahub roadmap ${ROADMAP_FORMS.triage} | ${ROADMAP_FORMS.accept} | ${ROADMAP_FORMS.reject}`, "planner or conductor: the hub model suggests a milestone for unplaced work, citing ids and words; nothing is linked until accept"],
130
- [`ahub roadmap ${ROADMAP_FORMS.decompose}`, "planner or conductor: the hub model proposes parts for one milestone from its outcome, the specs it links and the issues it links; each part cites a linked id and says whether it needs its own spec issue or goes straight to a task. Saved as a pending model answer; nothing is intaken, linked or published. --accept <part> instead holds that part as an intake draft linked to the milestone, offered to nobody until the person releases it with ahub intake approve"],
132
+ [`ahub roadmap ${ROADMAP_FORMS.decompose}`, "planner or conductor: the hub model proposes parts for one milestone from its outcome, the specs it links and the issues it links; each part cites a linked id and says whether it needs its own spec issue or goes straight to a task. Saved as a pending model answer; nothing is intaken, linked or published. --accept <part> instead holds that part as an intake draft linked to the milestone, offered to nobody until the person releases it with ahub intake approve. --publish previews the GitHub issue each held spec part would create and writes nothing; --apply with the preview's fingerprint creates them behind roadmap.github_write and links each to the milestone, and a private part is never published"],
131
133
  [`ahub roadmap ${ROADMAP_FORMS.importGithub}`, "person only: create proposed milestones from open GitHub milestones and link their issues; a dry run unless --apply, idempotent, never writes GitHub"],
132
134
  [`ahub roadmap ${ROADMAP_FORMS.check} | ${ROADMAP_FORMS.sync} | ${ROADMAP_FORMS.export}`, "check drift, preview an opt-in GitHub mirror or export a screened roadmap; GitHub apply requires a confirmed preview"],
133
135
  ["ahub release new <name> <goal> <order> | list | show <name> | plan <name> <revision> <dates-json> | activate|freeze|ship|drop <name> <revision> [--json] [--color=auto|always|never]", "person only, except show (any agent, public metadata): planned UTC millisecond dates and phased scope; ship records a time after approval, never tags or publishes"],
@@ -166,11 +168,11 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
166
168
  ["ahub remember <text...>", "save a note to the memory all agents share"],
167
169
  ]],
168
170
  ["Budget", [
169
- ["ahub budget [--json] [--full] [--color=auto|always|never]", "quota windows per peer with each number's kind (native, count, manual) and source, why a peer shows no number, who is paused until when, and the reviewer quota admission rule"],
171
+ ["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"],
170
172
  ["ahub budget set <peer> <0..1> [--resets-in 30m] [--window 5h|week]", "feed a reading by hand (also: test the relay)"],
171
173
  ["ahub budget resume <peer>", "override a budget pause; readings are ignored for that peer until the window resets"],
172
174
  ["ahub budget execution status [id] [--json] [--color=auto|always|never]", "read execution counters and limits"],
173
- ["ahub budget execution configure <config.json> | disable <id> [--json] [--color=auto|always|never]", "opt-in limits on model calls, tool calls, time and tokens for pi and local"],
175
+ ["ahub budget execution configure <config.json> [--reason <text>] | disable <id> [--json] [--color=auto|always|never]", "opt-in limits on model calls, tool calls, time and tokens for pi and local; an optional reason is kept with the person and the time"],
174
176
  ]],
175
177
  ["History and reports", [
176
178
  [`ahub guidance probe ${Object.values(GUIDANCE_PROBE_USAGE).join(" | ")}`, "person or configured conductor only: bounded T1 declaration and fake-only probe lifecycle; receipts reads the sealed receipts, the outcome denominator and the comparability reasons, read-only; production execution is unavailable"],
@@ -268,6 +270,7 @@ const SUMMARIES: Readonly<Record<string, string>> = {
268
270
  capabilities: "list the skills each attached peer offers", learn: "review recurring-criterion candidates", study: "research campaign contracts",
269
271
  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",
270
272
  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",
273
+ instructed: "run a confirmed exact or intent instruction",
271
274
  guidance: "guidance declarations and the probe lifecycle", lineage: "execution metadata and evidence strengths", turns: "recent turns and the files each changed",
272
275
  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",
273
276
  research: "success and rework rates per approved task", bench: "run a benchmark suite against attached peers", "History and reports/check-path": "other owners' open tasks that claim a file",
@@ -309,6 +312,7 @@ export function helpOverviewRows(entries: readonly HelpEntry[] = HELP): Overview
309
312
  export const EXAMPLES: Readonly<Record<string, readonly string[]>> = {
310
313
  specs: ["ahub specs check --require-fresh", "ahub specs covers src/cli/help.ts"], worktrees: ["ahub worktrees tidy"], "--project": ["ahub --project ../other-repo status"],
311
314
  projects: ["ahub projects --json"], "--live-test": ["ahub --live-test status"], setup: ["ahub setup --agents claude,codex"], init: ["ahub init --profile dev --sdlc advise --dry-run --json"],
315
+ instructed: ["ahub instructed run", "ahub instructed run task assign 12 claude"],
312
316
  help: ["ahub help task"], completion: ["ahub completion zsh"],
313
317
  up: ["ahub up --no-console"], console: ["ahub console --panels"], pet: ["ahub pet --short"],
314
318
  sdlc: ["ahub sdlc status 12", "ahub sdlc explain 12 --json"], backlog: ["ahub backlog list --full", "ahub backlog return 12 3 waiting on a spec"],
@@ -382,9 +386,10 @@ export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
382
386
  "--attempt": "attempt id (ra-...)", "--task-created": "creation time of the task, in milliseconds", "--owner": "peer that owns the task", "--after": "wait for this task id (repeatable)", "--milestone": "milestone to use",
383
387
  // setup, init and sdlc
384
388
  "--require-fresh": "also fail on stale documents", "--base": "compare against this git ref", "--agents": "agents ahub up starts", "--research": "turn research records on", "--no-research": "turn research records off",
389
+ "--undo": "remove only the hub's unmodified skill trees",
385
390
  "--profile": "role profile or pack", "--sdlc": "SDLC mode: off, advise or enforce", "--required-checks": "CI check names that must pass", "--coordination": "advisory or turn-free", "--memory": "turn shared memory on",
386
391
  "--no-memory": "turn shared memory off", "--snapshots": "turn per-turn snapshots on", "--no-snapshots": "turn per-turn snapshots off", "--pi": "turn the Pi peer on", "--no-pi": "turn the Pi peer off",
387
- "--specs": "turn design specs on", "--no-specs": "turn design specs off", "--spec-review": "how covering specs are reviewed", "--conductor": "the peer that conducts, or none", "--planner": "peers that plan",
392
+ "--specs": "turn design specs on", "--no-specs": "turn design specs off", "--no-jcode-home": "init: do not create the hub-owned jcode home", "--spec-review": "how covering specs are reviewed", "--conductor": "the peer that conducts, or none", "--planner": "peers that plan",
388
393
  "--reviewer": "peers that review, or person", "--track-config": "share config.json through git", "--no-track-config": "keep config.json out of git", "--autonomy": "inherit the machine preset, or not",
389
394
  "--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",
390
395
  "--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",
@@ -407,7 +412,7 @@ export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
407
412
  "--superseded-by": "work that replaces this task", "--created": "when the label applies (person only)", "--title": "milestone title", "--outcome": "the outcome the milestone delivers", "--horizon": "now, next or later",
408
413
  "--order": "position among its siblings", "--target": "target date (YYYY-MM-DD) or none", "--parent": "parent milestone id, or none", "--write": "write the export to the caller's worktree", "--project-id": "id of the disposable project", "--receipt": "file to write the receipt to",
409
414
  "--timeout-ms": "time limit, 100 to 120000 ms", "--hostname": "interface to listen on", "--port": "port to listen on", "--public-url": "public ws or wss URL", "--state-dir": "directory for the relay's state",
410
- "--broker": "relay URL", "--accept": "request to accept", "--name": "name to join the room under", "--roster": "signed roster to join with", "--frame": "digest of the incoming frame", "--source": "registered src: id (repeatable)",
415
+ "--broker": "relay URL", "--accept": "request to accept", "--publish": "preview the GitHub issues, write nothing", "--name": "name to join the room under", "--roster": "signed roster to join with", "--frame": "digest of the incoming frame", "--source": "registered src: id (repeatable)",
411
416
  "--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",
412
417
  "--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",
413
418
  // history, reports and memory
@@ -180,6 +180,7 @@ export function classifyPeerCommand(command: string, args: readonly string[], ca
180
180
  if (conductorOperation(command,args)) return "conductor";
181
181
  if (command === "stop") return "console";
182
182
  if (command === "sdlc" && ["release-guard", "release-guard-hook"].includes(args[0] ?? "")) return "allowed";
183
+ if (command === "instruction-hook" || command === "instructed" && args[0] === "run") return "allowed";
183
184
  // #786, #1063, #1328: guarded merge, merge adoption and explicitly instructed release consent admit the person or unique configured conductor; the daemon checks the role.
184
185
  if (command === "sdlc" && ["merge", "authorize-release", "adopt-merge", "configure"].includes(args[0] ?? "")) return "conductor";
185
186
  if (command === "role") return ["list", "show"].includes(args[0] ?? "") ? "allowed" : "console";
@@ -265,7 +266,7 @@ export function cliCommandLabel(command: string, args: readonly string[], catalo
265
266
  if (command === "specs") return ["list", "check", "covers", "stamp"].includes(args[0] ?? "") ? `specs ${args[0]}` : "specs";
266
267
  // #1057: the audit names the subcommand and whether it confirms, never a path, a branch or a fingerprint.
267
268
  if (command === "worktrees") return args[0] === "tidy" ? (args.some(arg => arg === "--confirm" || arg.startsWith("--confirm=")) ? "worktrees tidy confirm" : "worktrees tidy") : "worktrees";
268
- 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", "check-path", "turns", "undo", "kill", "down", "reset", "doctor", "agents", "source", "broker", "schedule", "intake", "learn", "study"].includes(command)) return "unknown";
269
+ 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", "broker", "schedule", "intake", "learn", "study"].includes(command)) return "unknown";
269
270
  if (["task", "queue", "budget", "route", "recovery", "models", "projects", "research", "memory", "goal", "bench", "agents", "roster", "settings"].includes(command)) {
270
271
  const sub = command === "bench" || command === "memory" || command === "goal" ? args.find((arg) => arg !== "--json") : args[0];
271
272
  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}`;
@@ -0,0 +1,28 @@
1
+ import { homedir } from "node:os";
2
+ import { isAbsolute } from "node:path";
3
+ import { realPath } from "../hub/project.ts";
4
+ import { canonicalInstruction, instructionHash } from "../hub/instruction-receipt.ts";
5
+
6
+ const MAX_HOOK_BYTES = 1024 * 1024;
7
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8
+ export type InstructionHookMessage =
9
+ | { t: "instruction_hook"; op: "pending"; session: string; promptId: string; transcript: string; home: string; cwd: string; hash: string }
10
+ | { t: "instruction_hook"; op: "stop"; session: string };
11
+
12
+ /** Never return the submitted prompt: the control link gets only its canonical hash. */
13
+ export function parseInstructionHook(stdin: string, env: NodeJS.ProcessEnv = process.env): InstructionHookMessage | undefined {
14
+ if (Buffer.byteLength(stdin, "utf8") > MAX_HOOK_BYTES) return;
15
+ try {
16
+ const value: unknown = JSON.parse(stdin);
17
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
18
+ const input = value as Record<string, unknown>;
19
+ if (typeof input.session_id !== "string" || !UUID.test(input.session_id) || env.CLAUDE_CODE_SESSION_ID !== input.session_id) return;
20
+ if (input.hook_event_name === "Stop") return { t: "instruction_hook", op: "stop", session: input.session_id };
21
+ if (input.hook_event_name !== "UserPromptSubmit" || typeof input.prompt_id !== "string" || !UUID.test(input.prompt_id)
22
+ || typeof input.transcript_path !== "string" || !isAbsolute(input.transcript_path) || typeof input.cwd !== "string" || !isAbsolute(input.cwd)) return;
23
+ const args = canonicalInstruction(input.prompt); if (args === undefined) return;
24
+ const cwd = realPath(input.cwd), home = realPath(env.CLAUDE_CONFIG_DIR || `${homedir()}/.claude`);
25
+ if (cwd !== realPath(process.cwd())) return;
26
+ return { t: "instruction_hook", op: "pending", session: input.session_id, promptId: input.prompt_id, transcript: input.transcript_path, home, cwd, hash: instructionHash(args) };
27
+ } catch { return; }
28
+ }
@@ -1,2 +1,3 @@
1
1
  /** Compatibility exports; the project MCP layer is native adapter policy. */
2
- export { JCODE_MCP_FILE, JCODE_MCP_NAME, jcodeMcpEntry, jcodeMcpReady, configureJcodeMcp, jcodeExtraMcpServers } from "../adapters/definitions/native-cli-jcode-mcp.ts";
2
+ export { JCODE_MCP_FILE, JCODE_MCP_NAME, jcodeMcpEntry, jcodeMcpReady, configureJcodeMcp, jcodeExtraMcpServers, splitJcodeMcpServers } from "../adapters/definitions/native-cli-jcode-mcp.ts";
3
+ export { jcodeOwnHome, sameJcodeHome, hubJcodeHomePath, planJcodeHome, applyJcodeHome, jcodeLoginCommand, type JcodeHomePlan } from "../adapters/definitions/native-cli-jcode-home.ts";
package/src/cli/main.js CHANGED
@@ -6,6 +6,14 @@ if (!version || !(Number(version[1]) > 1 || (Number(version[1]) === 1 && (Number
6
6
  process.exit(1);
7
7
  }
8
8
 
9
+ // An instructed child is confined to its inherited daemon IPC channel; a WebSocket cannot be substituted.
10
+ if (process.env.AGENTHUB_INSTRUCTED_IPC !== undefined) {
11
+ const OriginalWebSocket = globalThis.WebSocket;
12
+ globalThis.WebSocket = class extends OriginalWebSocket {
13
+ constructor() { throw new Error("WebSocket unavailable in an instructed child"); }
14
+ };
15
+ }
16
+
9
17
  // Shell completion asks on every Tab: answer from the help entries without loading the CLI (#603).
10
18
  if (process.argv[2] === "__complete") {
11
19
  const { completeWords } = await import("./completion.ts");