@staix/agent-hub 0.46.1 → 0.47.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 (130) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +8 -4
  3. package/docs/adding-an-ai-tool.md +20 -4
  4. package/docs/agent-notes/adapters.md +3 -3
  5. package/docs/agent-notes/benchmarks.md +7 -1
  6. package/docs/agent-notes/daemon.md +5 -4
  7. package/docs/agent-notes/tasks.md +4 -2
  8. package/docs/agent-notes/tests.md +3 -0
  9. package/docs/contracts/companion-cli-v1.json +3 -0
  10. package/docs/data-policy.md +9 -0
  11. package/docs/design/adapters.md +14 -0
  12. package/docs/design/cli-output-inventory.md +362 -0
  13. package/docs/design/cli-output.md +42 -1
  14. package/docs/design/execution-reference.md +5 -2
  15. package/docs/design/guidance-probes.md +2 -2
  16. package/docs/design/refusal-inventory.md +26 -0
  17. package/docs/design/roadmap.md +4 -0
  18. package/docs/design/task-board.md +17 -1
  19. package/docs/dogfood.md +26 -10
  20. package/docs/events.md +9 -0
  21. package/docs/friction.md +46 -0
  22. package/docs/memory.md +35 -3
  23. package/docs/operations.md +63 -15
  24. package/docs/profiles.md +1 -0
  25. package/docs/quickstart.md +8 -2
  26. package/docs/roles.md +6 -0
  27. package/docs/sdlc.md +44 -1
  28. package/docs/security.md +16 -7
  29. package/docs/specs/2026-09-19-agent-hub-design.md +17 -0
  30. package/docs/specs/2026-09-19-multi-project-design.md +7 -1
  31. package/docs/verification/2026-11-25-agy-1.5.16.md +31 -0
  32. package/docs/verification/2026-11-25-claude-implementer-2.1.332.md +47 -0
  33. package/docs/verification/2026-11-25-codex-0172-reviewer-isolation.md +47 -0
  34. package/docs/verification/2026-11-25-kimi-272-reviewer-compat.md +38 -0
  35. package/docs/verification/2026-11-25-kimi-tui-272.md +14 -0
  36. package/docs/verification/2026-11-25-pi-160-compat.md +40 -0
  37. package/docs/verification/2026-11-26-0.47.0.md +43 -0
  38. package/docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md +29 -0
  39. package/docs/verification/dogfood/2026-11-24.md +2829 -0
  40. package/docs/verification/pi-160-model-free.ts +57 -0
  41. package/docs/verification/pi-160-native.mjs +21 -0
  42. package/docs/verified.json +43 -31
  43. package/package.json +2 -2
  44. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  45. package/plugins/agent-hub/kimi-hook.js +579 -126
  46. package/plugins/agent-hub/server.js +668 -138
  47. package/src/adapters/acp.ts +5 -0
  48. package/src/adapters/channel-peer.ts +7 -0
  49. package/src/adapters/claude-print-child.ts +27 -5
  50. package/src/adapters/codex-appserver.ts +9 -0
  51. package/src/adapters/compat.ts +12 -11
  52. package/src/adapters/configured-acp.ts +45 -2
  53. package/src/adapters/configured-print.ts +163 -0
  54. package/src/adapters/conformance/index.ts +1 -0
  55. package/src/adapters/conformance/print.ts +57 -0
  56. package/src/adapters/definitions/native-activity.ts +57 -0
  57. package/src/adapters/definitions/native-factories.ts +4 -2
  58. package/src/adapters/jcode.ts +10 -2
  59. package/src/adapters/local-worker.ts +2 -0
  60. package/src/adapters/registry-types.ts +5 -3
  61. package/src/adapters/role-eligibility.ts +5 -0
  62. package/src/cli/bench.ts +2 -1
  63. package/src/cli/broker.ts +2 -1
  64. package/src/cli/capabilities-output.ts +10 -14
  65. package/src/cli/configured-acp-entry.ts +10 -2
  66. package/src/cli/console-state.ts +25 -5
  67. package/src/cli/error-format.ts +2 -0
  68. package/src/cli/guidance.ts +1 -1
  69. package/src/cli/handoff-output.ts +20 -17
  70. package/src/cli/help.ts +78 -40
  71. package/src/cli/init-settings.ts +15 -0
  72. package/src/cli/intake-output.ts +13 -13
  73. package/src/cli/launch.ts +3 -2
  74. package/src/cli/learn-output.ts +40 -21
  75. package/src/cli/main.ts +148 -77
  76. package/src/cli/memory.ts +47 -2
  77. package/src/cli/output.ts +54 -31
  78. package/src/cli/roadmap.ts +2 -2
  79. package/src/cli/room-output.ts +71 -0
  80. package/src/cli/room.ts +19 -33
  81. package/src/cli/schedule-output.ts +20 -19
  82. package/src/cli/sdlc-output.ts +188 -170
  83. package/src/cli/source-output.ts +17 -14
  84. package/src/cli/specs.ts +13 -13
  85. package/src/cli/study-output.ts +66 -69
  86. package/src/cli/task-output.ts +106 -158
  87. package/src/cli/terminal-recovery.ts +2 -1
  88. package/src/cli/upgrade-runtime.ts +2 -1
  89. package/src/cli/warn-line.ts +18 -0
  90. package/src/cli/worktrees-output.ts +25 -23
  91. package/src/hub/audit-source.ts +45 -0
  92. package/src/hub/board.ts +141 -5
  93. package/src/hub/bus.ts +13 -2
  94. package/src/hub/config-apply.ts +14 -1
  95. package/src/hub/config-trust.ts +1 -0
  96. package/src/hub/control-client.ts +1 -1
  97. package/src/hub/daemon.ts +371 -45
  98. package/src/hub/handoff.ts +5 -1
  99. package/src/hub/hub-tools.ts +23 -5
  100. package/src/hub/instance-config.ts +3 -3
  101. package/src/hub/learn-followup.ts +103 -0
  102. package/src/hub/learning.ts +63 -1
  103. package/src/hub/manager.ts +15 -1
  104. package/src/hub/memory-policy.ts +2 -1
  105. package/src/hub/memory-review.ts +217 -0
  106. package/src/hub/peer-activity.ts +37 -0
  107. package/src/hub/peers.ts +3 -0
  108. package/src/hub/project-move.ts +258 -0
  109. package/src/hub/registry.ts +16 -5
  110. package/src/hub/restart.ts +7 -0
  111. package/src/hub/review-brief.ts +8 -4
  112. package/src/hub/review-checkout.ts +26 -0
  113. package/src/hub/review-findings.ts +6 -3
  114. package/src/hub/risk-tier.ts +129 -0
  115. package/src/hub/roadmap-check.ts +1 -0
  116. package/src/hub/routing.ts +3 -1
  117. package/src/hub/sdlc-merge.ts +9 -0
  118. package/src/hub/sdlc-metrics.ts +24 -1
  119. package/src/hub/sdlc-queue.ts +1 -1
  120. package/src/hub/sdlc.ts +15 -6
  121. package/src/hub/settings.ts +2 -0
  122. package/src/hub/spec-readback.ts +136 -0
  123. package/src/hub/specs.ts +1 -1
  124. package/src/hub/task-list-page.ts +1 -1
  125. package/src/hub/tasks.ts +558 -65
  126. package/src/hub/ui.ts +4 -2
  127. package/src/ui/index.html +26 -2
  128. package/src/ui/overview-model.ts +138 -0
  129. package/src/ui/plugin.ts +30 -4
  130. package/templates/roles/ops/project-manager.md +1 -1
package/src/hub/ui.ts CHANGED
@@ -8,6 +8,7 @@ import { officeModel } from "../ui/office-model.ts";
8
8
  import { OFFICE_PEER_ORDER, ADAPTER_DISPLAY } from "../adapters/registry.ts";
9
9
  import { needs } from "../ui/needs.ts";
10
10
  import { roadmapModel } from "../ui/roadmap-model.ts";
11
+ import { overviewModel } from "../ui/overview-model.ts";
11
12
  import { createHash, randomBytes } from "node:crypto";
12
13
  import { readFileSync } from "node:fs";
13
14
 
@@ -27,7 +28,7 @@ const SESSION_MS = 60 * 60_000;
27
28
  /** How long a session opened by `ahub ui --settings` may change settings that raise authority; it stays an ordinary session after. */
28
29
  export const SETTINGS_MS = 15 * 60_000;
29
30
  /** The page's view names (index.html DASHBOARD_VIEWS): the only values a snapshot request's `view` may carry to a project hub. */
30
- export const DASHBOARD_VIEWS = ["board", "office", "stream", "agents", "message", "memory", "settings", "roadmap"] as const;
31
+ export const DASHBOARD_VIEWS = ["board", "office", "stream", "agents", "message", "memory", "settings", "roadmap", "overview"] as const;
31
32
  export const dashboardView = (value: unknown): typeof DASHBOARD_VIEWS[number] | undefined => (DASHBOARD_VIEWS as readonly unknown[]).includes(value) ? value as typeof DASHBOARD_VIEWS[number] : undefined;
32
33
  const LIMIT = 64;
33
34
  const secret = () => randomBytes(32).toString("hex");
@@ -43,7 +44,8 @@ export function renderDashboard(): { html: string; styles: string[]; markup: str
43
44
  .replace("/* PEER_START_RETRY_MS */", () => `const PEER_START_RETRY_MS = ${PEER_START_RETRY_MS};`)
44
45
  .replace("/* OFFICE_MODEL */", () => `const officeModel = ((OFFICE_PEER_ORDER) => ${officeModel.toString()})(${JSON.stringify(OFFICE_PEER_ORDER)});`)
45
46
  .replace("/* NEEDS_MODEL */", () => `const needs = ${needs.toString()};`)
46
- .replace("/* ROADMAP_MODEL */", () => `const roadmapModel = ${roadmapModel.toString()};`);
47
+ .replace("/* ROADMAP_MODEL */", () => `const roadmapModel = ${roadmapModel.toString()};`)
48
+ .replace("/* OVERVIEW_MODEL */", () => `const overviewModel = ${overviewModel.toString()};`);
47
49
  const blocks = (tag: string) => [...html.matchAll(new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`, "g"))].map((m) => m[1]!);
48
50
  const body = /<body>([\s\S]*)<\/body>/.exec(html)?.[1] ?? "";
49
51
  return { html, styles: blocks("style"), markup: body.replace(/<script>[\s\S]*?<\/script>/g, ""), script: blocks("script").join("\n") };
package/src/ui/index.html CHANGED
@@ -240,6 +240,8 @@ details.settings-group .row:last-child{border-bottom:0}
240
240
  .task-card .task-stage{font-size:var(--text-xs)}
241
241
  .board-columns .empty{padding:var(--space-2) 0}
242
242
  /* #1483 R5: the roadmap view. Lanes stack at 900px so the page never scrolls sideways on a phone. */
243
+ .overview-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--space-3);padding:var(--space-4)}.overview-card{border:1px solid var(--line);border-radius:8px;padding:var(--space-3);min-width:0}.overview-card h3{margin:0 0 var(--space-2);font-size:1rem}.overview-card ul{margin:0;padding:0;list-style:none}.overview-card li{display:flex;justify-content:space-between;gap:var(--space-2);overflow-wrap:anywhere}.overview-bars{display:flex;align-items:flex-end;gap:2px;height:48px}.overview-bars i{flex:1;background:currentColor;opacity:.6;min-height:1px}
244
+ @media(max-width:900px){.overview-grid{grid-template-columns:minmax(0,1fr);padding:var(--space-3)}}
243
245
  .roadmap-lanes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--space-3);padding:var(--space-4)}
244
246
  .roadmap-lane{display:flex;flex-direction:column;gap:var(--space-2);min-width:0}
245
247
  .roadmap-lane h3{font-size:var(--text-sm);color:var(--muted)}
@@ -461,6 +463,7 @@ main[data-stale]>:not(#notice):not(#disconnected){opacity:.6;transition:opacity
461
463
  <button type="button" data-view-target="memory"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-memory"/></svg><span class="nav-label">Memory</span></button>
462
464
  <button type="button" data-view-target="settings"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-settings"/></svg><span class="nav-label">Settings</span></button>
463
465
  <button type="button" data-view-target="roadmap"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-board"/></svg><span class="nav-label">Roadmap</span></button>
466
+ <button type="button" data-view-target="overview"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-board"/></svg><span class="nav-label">Overview</span></button>
464
467
  </nav>
465
468
  <div class="shell-body">
466
469
  <main id="main-content" tabindex="-1">
@@ -468,6 +471,7 @@ main[data-stale]>:not(#notice):not(#disconnected){opacity:.6;transition:opacity
468
471
  <div id="notice" class="notice" role="status" aria-live="polite" aria-label="Notices"></div>
469
472
  <section class="task-board-section" aria-labelledby="tasks-title" data-view="board"><div class="section-head"><h2 id="tasks-title">Task board</h2><div class="filters"><select id="task-filter" aria-label="Filter tasks by state"><option value="">All states</option><option value="backlog">Backlog</option><option value="proposed">To Do</option><option value="work">Work (including rework)</option><option value="in_progress">In progress</option><option value="in_review">In review</option><option value="approved">Approved</option><option value="cancelled">Cancelled</option><option value="changes_requested">Changes requested</option></select><span id="task-count" class="meta"></span><span id="task-scope" class="meta"></span></div></div><div id="task-progress" class="task-progress" aria-live="polite"></div><div class="board-toolbar"><button id="plan-open" type="button" class="primary" aria-haspopup="dialog">Plan</button><button id="board-back" type="button" hidden>Back to board</button><span id="board-focus-title" class="meta" hidden></span><label for="task-peer-filter">Agent<select id="task-peer-filter"><option value="">All agents</option></select></label><label for="task-milestone-filter">Milestone<select id="task-milestone-filter"><option value="">All milestones</option></select></label><label for="task-release-filter">Release<select id="task-release-filter"><option value="">All releases</option></select></label><label for="task-lanes">View<select id="task-lanes"><option value="columns">By state</option><option value="agents">By agent</option><option value="releases">By release</option></select></label></div><div id="task-legend" class="agent-legend" role="group" aria-label="Agent legend and assignment targets"></div><div id="tasks" class="task-list"><div class="skeleton skeleton-board" aria-hidden="true"><div class="skeleton-col"><span class="skeleton-bar"></span><span class="skeleton-bar skeleton-tall"></span><span class="skeleton-bar skeleton-tall"></span></div><div class="skeleton-col"><span class="skeleton-bar"></span><span class="skeleton-bar skeleton-tall"></span></div><div class="skeleton-col"><span class="skeleton-bar"></span><span class="skeleton-bar skeleton-tall"></span></div><div class="skeleton-col"><span class="skeleton-bar"></span></div><div class="skeleton-col"><span class="skeleton-bar"></span><span class="skeleton-bar skeleton-tall"></span></div></div><p class="empty">Loading the board...</p></div></section>
470
473
  <div class="stack">
474
+ <section id="overview-section" aria-labelledby="overview-title" data-view="overview" hidden><div class="section-head"><h2 id="overview-title">Overview</h2><span id="overview-count" class="meta"></span></div><div id="overview-grid" class="overview-grid"><p class="empty">Loading the overview...</p></div></section>
471
475
  <section id="roadmap-section" aria-labelledby="roadmap-title" data-view="roadmap" hidden><div class="section-head"><h2 id="roadmap-title">Roadmap</h2><div class="filters"><button id="roadmap-new" type="button" class="primary" aria-haspopup="dialog">New milestone</button><button id="roadmap-check" type="button">Check drift</button><span id="roadmap-count" class="meta"></span></div></div><p id="roadmap-drift" class="meta" role="status" aria-live="polite"></p><div id="roadmap-lanes" class="roadmap-lanes"><p class="empty">Loading the roadmap...</p></div><section id="roadmap-unplaced" aria-labelledby="roadmap-unplaced-title" hidden><div class="section-head"><h3 id="roadmap-unplaced-title">Unplaced</h3><div class="filters"><button id="roadmap-triage" type="button">Suggest placements</button><span id="roadmap-unplaced-count" class="meta"></span></div></div><div id="roadmap-tray" class="roadmap-tray"></div></section></section>
472
476
  <section id="office-section" aria-labelledby="office-title" data-view="office" hidden><div class="section-head"><h2 id="office-title">Office</h2><div class="filters"><label for="office-view">Office mode</label><select id="office-view"><option value="off">Off</option><option value="flat">Flat</option><option value="isometric">Isometric</option></select></div></div><div id="office" class="content"></div></section>
473
477
  <section aria-labelledby="stream-title" data-view="stream" hidden><div class="section-head"><h2 id="stream-title">Live stream</h2><div class="filters"><div id="stream-filters" class="chips" role="group" aria-label="Filter events by kind"></div><label><input id="follow" type="checkbox" checked> Follow latest</label></div></div><div id="stream" class="stream" tabindex="0" aria-label="Recent hub events"><p class="empty">Waiting for hub activity...</p></div><p id="stream-empty" class="empty" hidden>No events match this filter.</p></section>
@@ -536,7 +540,7 @@ main[data-stale]>:not(#notice):not(#disconnected){opacity:.6;transition:opacity
536
540
  <dialog id="task-detail-dialog" aria-labelledby="task-detail-title"><div class="dialog-head"><h2 id="task-detail-title">Task details</h2><button id="task-detail-close" type="button" autofocus>Close details</button></div><div id="task-detail-content"></div></dialog>
537
541
  <dialog id="roadmap-detail-dialog" aria-labelledby="roadmap-detail-title"><div class="dialog-head"><h2 id="roadmap-detail-title">Milestone</h2><button id="roadmap-detail-close" type="button" autofocus>Close milestone</button></div><div id="roadmap-detail-content"></div></dialog>
538
542
  <dialog id="keys-dialog" aria-labelledby="keys-title"><div class="dialog-head"><h2 id="keys-title">Keyboard shortcuts</h2><button type="button" id="keys-close" aria-label="Close shortcuts"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-close"/></svg></button></div>
539
- <dl class="keys-list"><div><dt><kbd>1</kbd>-<kbd>8</kbd></dt><dd>Switch view: Board, Office, Stream, Agents, Message, Memory, Settings, Roadmap</dd></div><div><dt><kbd>?</kbd></dt><dd>Show this list</dd></div><div><dt><kbd>Esc</kbd></dt><dd>Close the open sheet or task detail</dd></div></dl>
543
+ <dl class="keys-list"><div><dt><kbd>1</kbd>-<kbd>9</kbd></dt><dd>Switch view: Board, Office, Stream, Agents, Message, Memory, Settings, Roadmap, Overview</dd></div><div><dt><kbd>?</kbd></dt><dd>Show this list</dd></div><div><dt><kbd>Esc</kbd></dt><dd>Close the open sheet or task detail</dd></div></dl>
540
544
  <p class="meta">Keys are ignored while you type in a field, and with Ctrl, Alt or Cmd held.</p></dialog>
541
545
  <footer>Loopback session. Private task content stays in the terminal. Reopen with <code>ahub ui</code> when your session expires.</footer>
542
546
  <script>
@@ -546,6 +550,7 @@ main[data-stale]>:not(#notice):not(#disconnected){opacity:.6;transition:opacity
546
550
  /* BOARD_MODEL */
547
551
  /* ADAPTER_DISPLAY */
548
552
  /* NEEDS_MODEL */
553
+ /* OVERVIEW_MODEL */
549
554
  /* ROADMAP_MODEL */
550
555
  /* OFFICE_MODEL */
551
556
  const officeView = (() => {
@@ -556,7 +561,7 @@ const officeView = (() => {
556
561
  const themeControl = document.getElementById('theme'); themeControl.value = dashboardTheme.get(); themeControl.addEventListener('change', () => dashboardTheme.set(themeControl.value));
557
562
  const officeControl = document.getElementById('office-view'); officeControl.value = officeView.get(); document.getElementById('office-section').hidden = officeView.get() === 'off'; officeControl.addEventListener('change', () => { officeView.set(officeControl.value); if (lastSnapshot) render(lastSnapshot); else document.getElementById('office-section').hidden = officeView.get() === 'off'; applyDashboardView(); });
558
563
  // dashboard-navigation-begin
559
- const DASHBOARD_VIEWS = ['board','office','stream','agents','message','memory','settings','roadmap'];
564
+ const DASHBOARD_VIEWS = ['board','office','stream','agents','message','memory','settings','roadmap','overview'];
560
565
  let currentView = dashboardCookie.get('agent-hub-view', 'board');
561
566
  if (!DASHBOARD_VIEWS.includes(currentView)) currentView = 'board';
562
567
  function applyDashboardView() {
@@ -2162,6 +2167,24 @@ async function roadmapSettleSuggestion(actionName, id, button) {
2162
2167
  catch (error) { if (!stopped) notice(error.message, true); }
2163
2168
  finally { if (button && !stopped) button.disabled = false; }
2164
2169
  }
2170
+ function renderOverview(snapshot) {
2171
+ const block = snapshot && snapshot.overview;
2172
+ if (!block || !Array.isArray(block.throughput)) { if (currentView === 'overview') update('overview-grid', 'loading', target => empty(target, 'Loading the overview...')); return; }
2173
+ const pct = (rate) => rate === null || rate === undefined ? 'unknown' : Math.round(rate * 100) + '%';
2174
+ const when = (time) => time === null || time === undefined ? 'unknown' : new Date(time).toISOString().replace('T', ' ').replace(/:[0-9.]+Z$/, '');
2175
+ const card = (title, body) => { const box = el('div', '', 'overview-card'); box.append(el('h3', title)); box.append(body); return box; };
2176
+ const list = (rows, empty_) => { const ul = el('ul'); if (!rows.length) ul.append(el('li', empty_)); for (const [a, b] of rows) { const li = el('li'); li.append(el('span', a), el('span', b)); ul.append(li); } return ul; };
2177
+ const bars = (values, label) => { const wrap = el('div', '', 'overview-bars'); const max = values.reduce((top, value) => value > top ? value : top, 0) || 1; for (const value of values) { const bar = document.createElement('i'); bar.style.height = Math.round((value / max) * 100) + '%'; bar.title = label + ' ' + value; wrap.append(bar); } return wrap; };
2178
+ $('overview-count').textContent = block.withheld ? block.withheld + ' private withheld' : '';
2179
+ update('overview-grid', block, target => {
2180
+ const weekly = el('div'); weekly.append(bars(block.throughput.map(w => w.done), 'done'), list([['proposed / done, 8 weeks', block.throughput.map(w => w.proposed + '/' + w.done).join(' ')]], ''));
2181
+ target.append(card('Throughput per week', weekly));
2182
+ target.append(card('Pulse per day', bars(block.pulse.map(d => d.events), 'events')));
2183
+ target.append(card('Peer health, 30 days', list(block.health.map(h => [h.peer, 'first pass ' + pct(h.firstPass.rate) + ' of ' + h.firstPass.n + (h.firstPass.unknown ? ' (' + h.firstPass.unknown + ' unknown)' : '') + ', turn errors unknown']), 'No owned tasks.')));
2184
+ target.append(card('Peer workload', list(block.workload.map(w => [w.peer, w.open + ' open: ' + Object.entries(w.states).map(([s, n]) => s + ' ' + n).join(', ')]), 'No open owned tasks.')));
2185
+ target.append(card('Recent trouble', list(block.trouble.map(r => ['#' + r.task + ' ' + r.title, r.kind + ' ' + when(r.at)]), 'Nothing failed recently.')));
2186
+ });
2187
+ }
2165
2188
  function renderRoadmap(snapshot) {
2166
2189
  const block = roadmapData(snapshot);
2167
2190
  if (!block) {
@@ -2393,6 +2416,7 @@ function render(snapshot) {
2393
2416
  if (signatures.get('peer-options') !== peerSignature) { signatures.set('peer-options', peerSignature); peerOptions($('owner'), assignable, 'Automatic'); peerOptions($('recipient'), ids, 'All peers'); if (draftChoicesPending) { restoreDraft(true); draftChoicesPending = false; } }
2394
2417
  renderBoard(snapshot, peers, ids);
2395
2418
  renderRoadmap(snapshot);
2419
+ renderOverview(snapshot);
2396
2420
  if (roadmapDetailId !== null) refreshRoadmapDetail();
2397
2421
  renderSources(snapshot.sources);
2398
2422
  renderApprovals(snapshot.permissions);
@@ -0,0 +1,138 @@
1
+ /**
2
+ * #1514: the dashboard Overview view's pure projection. The daemon hands it the public board history it already holds (the same
3
+ * rows `ahub sdlc metrics` reads), and it returns the five widgets as plain numbers and ids, so the page holds no rule of its
4
+ * own and a test pins every figure without a browser.
5
+ *
6
+ * Self-contained on purpose: the dashboard injects this function's source into the page (`renderDashboard` in
7
+ * `src/hub/ui.ts`), so it keeps every helper inside itself and closes over nothing from this module.
8
+ *
9
+ * A figure the board cannot derive is `null` and the page prints `unknown`, never 0. A private task never reaches a widget: it
10
+ * is counted once in `withheld` and contributes no title, detail, owner or time.
11
+ */
12
+
13
+ /** The slice of a board task the Overview reads: ids, enums and times, never text from a private task. */
14
+ export interface OverviewTask {
15
+ id: number;
16
+ private?: boolean;
17
+ /** Public title; the caller passes `tasks.publicView(task).title`, never the raw one. */
18
+ title: string;
19
+ state: string;
20
+ owner: string | null;
21
+ created: number;
22
+ history: { at: number; by?: string; event: string; evidenceOnly?: true }[];
23
+ /**
24
+ * The task's first-pass approval and the time it counts at, taken by the caller from `taskSample` (src/hub/sdlc-metrics.ts), the
25
+ * one definition `ahub sdlc metrics` uses. Null is unknown. The model never re-derives it, so the two views cannot disagree.
26
+ */
27
+ firstPass?: 0 | 1 | null;
28
+ sampleAt?: number;
29
+ }
30
+
31
+ export interface OverviewInput {
32
+ tasks: readonly OverviewTask[];
33
+ /** Open stalls (task id and kind), already limited to visible tasks by the caller. */
34
+ stalls?: readonly { task: number; kind: string; at?: number }[];
35
+ now: number;
36
+ }
37
+
38
+ interface OverviewWeek { start: number; proposed: number; done: number }
39
+ interface OverviewDay { start: number; events: number }
40
+ interface OverviewPeerHealth {
41
+ peer: string;
42
+ /** First-pass approvals over the window: `n` known tasks, `unknown` tasks with no verdict yet, `rate` null when none is known. */
43
+ firstPass: { n: number; unknown: number; rate: number | null };
44
+ /** Turns ended in error is not on the board (it lives in the event log), so it is unknown here, never 0. */
45
+ turnErrors: null;
46
+ }
47
+ interface OverviewWorkload { peer: string; states: Record<string, number>; open: number }
48
+ interface OverviewTrouble { task: number; title: string; kind: "check failed" | "changes_requested" | "stall"; at: number | null }
49
+ interface OverviewView {
50
+ throughput: OverviewWeek[];
51
+ pulse: OverviewDay[];
52
+ health: OverviewPeerHealth[];
53
+ workload: OverviewWorkload[];
54
+ trouble: OverviewTrouble[];
55
+ /** Private tasks, counted and nothing else. */
56
+ withheld: number;
57
+ }
58
+
59
+ export function overviewModel(input: OverviewInput): OverviewView {
60
+ const DAY = 86_400_000, WEEK = 7 * DAY;
61
+ const now = Number.isFinite(input.now) ? input.now : 0;
62
+ const visible = input.tasks.filter(task => task.private !== true);
63
+ const withheld = input.tasks.length - visible.length;
64
+ const at = (value: unknown): number | null => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
65
+ // Weeks and days are aligned to UTC midnight so a figure does not move with the reader's zone.
66
+ const dayStart = (time: number) => Math.floor(time / DAY) * DAY;
67
+ const today = dayStart(now);
68
+
69
+ // Throughput: tasks proposed vs done per week, the last 8 weeks, oldest first. A task counts as done at its first approval.
70
+ const throughput: OverviewWeek[] = [];
71
+ for (let i = 7; i >= 0; i--) throughput.push({ start: today - (i * 7 + 6) * DAY, proposed: 0, done: 0 });
72
+ const weekOf = (time: number) => {
73
+ const from = throughput[0]!.start, to = throughput[7]!.start + WEEK;
74
+ return time < from || time >= to ? undefined : throughput[Math.floor((time - from) / WEEK)];
75
+ };
76
+ for (const task of visible) {
77
+ const proposed = at(task.created) ?? at(task.history[0]?.at);
78
+ if (proposed !== null) { const week = weekOf(proposed); if (week) week.proposed++; }
79
+ const approved = task.history.find(entry => entry.event === "approved");
80
+ const doneAt = approved ? at(approved.at) : null;
81
+ if (doneAt !== null) { const week = weekOf(doneAt); if (week) week.done++; }
82
+ }
83
+
84
+ // Pulse: board events per day, the last 12 weeks (84 days), oldest first.
85
+ const pulse: OverviewDay[] = [];
86
+ for (let i = 83; i >= 0; i--) pulse.push({ start: today - i * DAY, events: 0 });
87
+ for (const task of visible) for (const entry of task.history) {
88
+ const time = at(entry.at);
89
+ if (time === null) continue;
90
+ const index = Math.floor((dayStart(time) - pulse[0]!.start) / DAY);
91
+ if (index >= 0 && index < pulse.length) pulse[index]!.events++;
92
+ }
93
+
94
+ // Peer health: per owner, first-pass approvals over the last 30 days, from the caller's `taskSample` values. A task whose sample
95
+ // falls before the window is not part of it; a task with no verdict yet counts as unknown, never as a failure.
96
+ const cutoff = now - 30 * DAY;
97
+ const owners = new Map<string, (0 | 1 | null)[]>();
98
+ for (const task of visible) {
99
+ if (!task.owner) continue;
100
+ const sampleAt = at(task.sampleAt);
101
+ if (sampleAt !== null && sampleAt < cutoff) continue;
102
+ const list = owners.get(task.owner) ?? [];
103
+ list.push(task.firstPass === 0 || task.firstPass === 1 ? task.firstPass : null);
104
+ owners.set(task.owner, list);
105
+ }
106
+ const health: OverviewPeerHealth[] = [...owners.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([peer, values]) => {
107
+ const known = values.filter((value): value is 0 | 1 => value !== null);
108
+ const rate = known.length ? Math.round((known.reduce<number>((sum, value) => sum + value, 0) / known.length) * 1000) / 1000 : null;
109
+ return { peer, firstPass: { n: known.length, unknown: values.length - known.length, rate }, turnErrors: null };
110
+ });
111
+
112
+ // Peer workload: open tasks per owner by state. An unowned open task is not any peer's workload and is left out.
113
+ const open = new Set(["backlog", "proposed", "in_progress", "in_review", "changes_requested"]);
114
+ const byOwner = new Map<string, Record<string, number>>();
115
+ for (const task of visible) {
116
+ if (!task.owner || !open.has(task.state)) continue;
117
+ const states = byOwner.get(task.owner) ?? {};
118
+ states[task.state] = (states[task.state] ?? 0) + 1;
119
+ byOwner.set(task.owner, states);
120
+ }
121
+ const workload: OverviewWorkload[] = [...byOwner.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
122
+ .map(([peer, states]) => ({ peer, states, open: Object.values(states).reduce((sum, count) => sum + count, 0) }));
123
+
124
+ // Recent trouble: the last 20 failed checks, changes_requested verdicts and open stalls, newest first. A stall that has no
125
+ // time of its own sorts last and shows its time as unknown.
126
+ const trouble: OverviewTrouble[] = [];
127
+ for (const task of visible) for (const entry of task.history) {
128
+ const time = at(entry.at);
129
+ if (time === null) continue;
130
+ if (entry.event === "check failed" || entry.event === "check run failed") trouble.push({ task: task.id, title: task.title, kind: "check failed", at: time });
131
+ else if (entry.event === "changes_requested" && entry.evidenceOnly !== true) trouble.push({ task: task.id, title: task.title, kind: "changes_requested", at: time });
132
+ }
133
+ const titles = new Map(visible.map(task => [task.id, task.title] as const));
134
+ for (const stall of input.stalls ?? []) if (titles.has(stall.task)) trouble.push({ task: stall.task, title: titles.get(stall.task)!, kind: "stall", at: at(stall.at) });
135
+ trouble.sort((a, b) => (b.at ?? -1) - (a.at ?? -1) || a.task - b.task);
136
+
137
+ return { throughput, pulse, health, workload, trouble: trouble.slice(0, 20), withheld };
138
+ }
package/src/ui/plugin.ts CHANGED
@@ -42,11 +42,15 @@ type ActionResult =
42
42
  | ({ ok: true } & Record<string, unknown>)
43
43
  | { ok: false; error: string; unconfirmed?: true }
44
44
  | { ok: false; needsConfirm: true; preview: string[]; fingerprint: string; verb?: string; warnings?: string[] };
45
+ /** #1635: scopes answered per `revision()` call; the rest are dropped, and each key is cut to 200 characters. */
46
+ const REVISION_MAX_SCOPES = 20;
45
47
  export interface ConsoleProvider {
46
48
  assets: { js: string; css?: string };
47
49
  snapshot(input: { after: number; panel: string } & Record<string, unknown>): Promise<Record<string, unknown>>;
48
50
  action(input: { action: string; confirmed?: true; fingerprint?: string } & Record<string, unknown>, meta?: ActionMeta): Promise<ActionResult>;
49
51
  asset?(input: { id: string }): Promise<{ bytes: Uint8Array; mime: string; name: string } | null>;
52
+ /** #1635: an opaque change token per scope, so a console polls cheaply. `board` changes on every task-board write across the running projects; any other scope is "0". */
53
+ revision?(scopes: string[]): Promise<Record<string, string>>;
50
54
  close?(): Promise<void>;
51
55
  }
52
56
  export interface ConsolePlugin {
@@ -55,7 +59,7 @@ export interface ConsolePlugin {
55
59
  open(ctx: { home: string; log(line: string): void; features?: readonly string[] }): Promise<ConsoleProvider>;
56
60
  }
57
61
 
58
- const TITLES: Record<(typeof DASHBOARD_VIEWS)[number], string> = { board: "Board", office: "Office", stream: "Stream", agents: "Agents", message: "Message", memory: "Memory", settings: "Settings", roadmap: "Roadmap" };
62
+ const TITLES: Record<(typeof DASHBOARD_VIEWS)[number], string> = { board: "Board", office: "Office", stream: "Stream", agents: "Agents", message: "Message", memory: "Memory", settings: "Settings", roadmap: "Roadmap", overview: "Overview" };
59
63
  /** The dashboard's own actions plus the inbox verbs; the manager whitelist is still applied to each forwarded call. */
60
64
  const FORWARDED = ["start", "stop", "send", "pause", "resume", "permit", "propose", "intake", "assign", "backlog_pull", "backlog_return", "planning", "planning_undo", "planner_pull", "backlog_split", "release_new", "release_change", "setting", "setting_undo", "setting_preview", "model_preview", "model_confirm", "setting_reload", "config_edit_preview", "config_edit_apply", "start_peer", "sdlc_queue", "sdlc_release", "worktree_override_set", "worktree_override_clear", "worktrees_refresh_prs",
61
65
  // #1483 R5: the roadmap view's writes and reads. The writes raise authority as the person and are confirmed like the
@@ -183,7 +187,7 @@ export function createProvider(options: { visualPolicy?: (cwd: string) => Promis
183
187
  const registry = options.registry ?? new Registry(join(options.home, "registry.db"));
184
188
  const owned = !options.registry;
185
189
  const lifecycle = options.lifecycle ?? lazyLifecycle();
186
- const { list, act, answer, receipt, consoleControl, lineage, guidance, guidanceProbe } = projectConsole({ registry, lifecycle, home: options.home, forwardTimeoutMs: options.forwardTimeoutMs });
190
+ const { list, act, answer, receipt, consoleControl, lineage, guidance, guidanceProbe, boardRevision } = projectConsole({ registry, lifecycle, home: options.home, forwardTimeoutMs: options.forwardTimeoutMs });
187
191
  const dashboard = panelAssets(), guide = guidancePanelAssets();
188
192
  const assets = { css: `${dashboard.css}\n${guide.css}`, js: `${dashboard.js.replace("export default (host) => {", "const createDashboard = (host) => {")}\n${guide.js.replace("export default (host) => {", "const createGuidance = (host) => {")}\nexport default (host) => {
189
193
  const dashboardMount = host.mount.ownerDocument.createElement('div'), guidanceMount = host.mount.ownerDocument.createElement('div');
@@ -604,6 +608,21 @@ export function createProvider(options: { visualPolicy?: (cwd: string) => Promis
604
608
  return null;
605
609
  }
606
610
  },
611
+ async revision(scopes) {
612
+ const out: Record<string, string> = {};
613
+ for (const scope of scopes.slice(0, REVISION_MAX_SCOPES)) {
614
+ const key = typeof scope === "string" ? scope.slice(0, 200) : "";
615
+ out[key] = "0";
616
+ if (key !== "board") continue;
617
+ const projects = await running();
618
+ // A bare number per running project from the cheap console-role `board_revision` read, never the board snapshot. Only ids and numbers are folded, never a title or any task text.
619
+ // One unknown counter (an older hub, a failed read, a project that vanished) makes the whole value "0": the console fetches, instead of believing the board never changes.
620
+ const counters = await Promise.all(projects.map(async (project) => ({ project, counter: await boardRevision({ projectId: project.id, instanceId: project.instanceId }) })));
621
+ out[key] = counters.length && counters.every(({ counter }) => counter !== undefined)
622
+ ? createHash("sha256").update(counters.map(({ project, counter }) => `${project.id}:${project.instanceId}:${counter}`).sort().join("|")).digest("hex").slice(0, 32) : "0";
623
+ }
624
+ return out;
625
+ },
607
626
  async close() { if (owned) registry.close(); },
608
627
  };
609
628
 
@@ -661,12 +680,19 @@ export function createProvider(options: { visualPolicy?: (cwd: string) => Promis
661
680
  */
662
681
  const POLL_MS = 2_000, INBOX_MAX_AGE_MS = 1_000, SPACE_MAX_AGE_MS = POLL_MS;
663
682
 
683
+ // The pinned console contract accepts extra manifest fields and continues using panels as its route allowlist.
684
+ const capabilities = {
685
+ actions: [...FORWARDED, ...INBOX_VERBS, ...QUESTION_ACTIONS, ...RESULT_ADVERTISED, ...REVIEW_ACTIONS],
686
+ reads: ["lineage"], confirm: true, multiProject: true, inbox: true, inboxMaxAgeMs: INBOX_MAX_AGE_MS,
687
+ space: true, spaceMaxAgeMs: SPACE_MAX_AGE_MS,
688
+ // ponytail: `revision: true` is not declared. The pinned @staix/agent-console 0.2.0 has no revision contract (agent-console#123); the provider answers revision() already. Ceiling: a console that never asks. Upgrade: declare it when the pin moves to the 0.3.x that ships the contract.
689
+ };
690
+
664
691
  const plugin: ConsolePlugin = {
665
692
  manifest: {
666
693
  api: 1, tool: "ahub", version, title: "agent-hub", icon: "agents", pollMs: POLL_MS,
667
694
  panels: [...DASHBOARD_VIEWS.map((id, order) => ({ id, title: TITLES[id], order })), { id: "guidance", title: "Guidance", order: DASHBOARD_VIEWS.length }],
668
- capabilities: { actions: [...FORWARDED, ...INBOX_VERBS, ...QUESTION_ACTIONS, ...RESULT_ADVERTISED, ...REVIEW_ACTIONS], confirm: true, multiProject: true,
669
- inbox: true, inboxMaxAgeMs: INBOX_MAX_AGE_MS, space: true, spaceMaxAgeMs: SPACE_MAX_AGE_MS },
695
+ capabilities,
670
696
  },
671
697
  async open(ctx) { return createProvider({ home: ctx.home, log: ctx.log, features: ctx.features }); },
672
698
  };
@@ -17,7 +17,7 @@ Do not invent progress, assign authority through prose or commit other people to
17
17
  Reviewable task plan, dependency and risk notes, owner and date proposals, acceptance criteria, and decisions or missing inputs requiring a person.
18
18
 
19
19
  ## Hub use
20
- Use the existing planning flow and task board. Reference the source request and affected paths; surface overlap, blockers and scope changes through the established coordination tools.
20
+ Use the existing planning flow and task board. Reference the source request and affected paths; surface overlap, blockers and scope changes through the established coordination tools. Split or hand off only for a named `reason` on `hub_task_propose` (explore, parallel, context, verify, capability, person); parallel siblings need disjoint paths.
21
21
 
22
22
  ## Review duties
23
23
  Check that each proposed outcome has an owner, a feasible dependency order and observable completion evidence. Keep unknown capacity and unaccepted dates explicit.