@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.
- package/CHANGELOG.md +79 -0
- package/README.md +8 -4
- package/docs/adding-an-ai-tool.md +20 -4
- package/docs/agent-notes/adapters.md +3 -3
- package/docs/agent-notes/benchmarks.md +7 -1
- package/docs/agent-notes/daemon.md +5 -4
- package/docs/agent-notes/tasks.md +4 -2
- package/docs/agent-notes/tests.md +3 -0
- package/docs/contracts/companion-cli-v1.json +3 -0
- package/docs/data-policy.md +9 -0
- package/docs/design/adapters.md +14 -0
- package/docs/design/cli-output-inventory.md +362 -0
- package/docs/design/cli-output.md +42 -1
- package/docs/design/execution-reference.md +5 -2
- package/docs/design/guidance-probes.md +2 -2
- package/docs/design/refusal-inventory.md +26 -0
- package/docs/design/roadmap.md +4 -0
- package/docs/design/task-board.md +17 -1
- package/docs/dogfood.md +26 -10
- package/docs/events.md +9 -0
- package/docs/friction.md +46 -0
- package/docs/memory.md +35 -3
- package/docs/operations.md +63 -15
- package/docs/profiles.md +1 -0
- package/docs/quickstart.md +8 -2
- package/docs/roles.md +6 -0
- package/docs/sdlc.md +44 -1
- package/docs/security.md +16 -7
- package/docs/specs/2026-09-19-agent-hub-design.md +17 -0
- package/docs/specs/2026-09-19-multi-project-design.md +7 -1
- package/docs/verification/2026-11-25-agy-1.5.16.md +31 -0
- package/docs/verification/2026-11-25-claude-implementer-2.1.332.md +47 -0
- package/docs/verification/2026-11-25-codex-0172-reviewer-isolation.md +47 -0
- package/docs/verification/2026-11-25-kimi-272-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-25-kimi-tui-272.md +14 -0
- package/docs/verification/2026-11-25-pi-160-compat.md +40 -0
- package/docs/verification/2026-11-26-0.47.0.md +43 -0
- package/docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md +29 -0
- package/docs/verification/dogfood/2026-11-24.md +2829 -0
- package/docs/verification/pi-160-model-free.ts +57 -0
- package/docs/verification/pi-160-native.mjs +21 -0
- package/docs/verified.json +43 -31
- package/package.json +2 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +579 -126
- package/plugins/agent-hub/server.js +668 -138
- package/src/adapters/acp.ts +5 -0
- package/src/adapters/channel-peer.ts +7 -0
- package/src/adapters/claude-print-child.ts +27 -5
- package/src/adapters/codex-appserver.ts +9 -0
- package/src/adapters/compat.ts +12 -11
- package/src/adapters/configured-acp.ts +45 -2
- package/src/adapters/configured-print.ts +163 -0
- package/src/adapters/conformance/index.ts +1 -0
- package/src/adapters/conformance/print.ts +57 -0
- package/src/adapters/definitions/native-activity.ts +57 -0
- package/src/adapters/definitions/native-factories.ts +4 -2
- package/src/adapters/jcode.ts +10 -2
- package/src/adapters/local-worker.ts +2 -0
- package/src/adapters/registry-types.ts +5 -3
- package/src/adapters/role-eligibility.ts +5 -0
- package/src/cli/bench.ts +2 -1
- package/src/cli/broker.ts +2 -1
- package/src/cli/capabilities-output.ts +10 -14
- package/src/cli/configured-acp-entry.ts +10 -2
- package/src/cli/console-state.ts +25 -5
- package/src/cli/error-format.ts +2 -0
- package/src/cli/guidance.ts +1 -1
- package/src/cli/handoff-output.ts +20 -17
- package/src/cli/help.ts +78 -40
- package/src/cli/init-settings.ts +15 -0
- package/src/cli/intake-output.ts +13 -13
- package/src/cli/launch.ts +3 -2
- package/src/cli/learn-output.ts +40 -21
- package/src/cli/main.ts +148 -77
- package/src/cli/memory.ts +47 -2
- package/src/cli/output.ts +54 -31
- package/src/cli/roadmap.ts +2 -2
- package/src/cli/room-output.ts +71 -0
- package/src/cli/room.ts +19 -33
- package/src/cli/schedule-output.ts +20 -19
- package/src/cli/sdlc-output.ts +188 -170
- package/src/cli/source-output.ts +17 -14
- package/src/cli/specs.ts +13 -13
- package/src/cli/study-output.ts +66 -69
- package/src/cli/task-output.ts +106 -158
- package/src/cli/terminal-recovery.ts +2 -1
- package/src/cli/upgrade-runtime.ts +2 -1
- package/src/cli/warn-line.ts +18 -0
- package/src/cli/worktrees-output.ts +25 -23
- package/src/hub/audit-source.ts +45 -0
- package/src/hub/board.ts +141 -5
- package/src/hub/bus.ts +13 -2
- package/src/hub/config-apply.ts +14 -1
- package/src/hub/config-trust.ts +1 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +371 -45
- package/src/hub/handoff.ts +5 -1
- package/src/hub/hub-tools.ts +23 -5
- package/src/hub/instance-config.ts +3 -3
- package/src/hub/learn-followup.ts +103 -0
- package/src/hub/learning.ts +63 -1
- package/src/hub/manager.ts +15 -1
- package/src/hub/memory-policy.ts +2 -1
- package/src/hub/memory-review.ts +217 -0
- package/src/hub/peer-activity.ts +37 -0
- package/src/hub/peers.ts +3 -0
- package/src/hub/project-move.ts +258 -0
- package/src/hub/registry.ts +16 -5
- package/src/hub/restart.ts +7 -0
- package/src/hub/review-brief.ts +8 -4
- package/src/hub/review-checkout.ts +26 -0
- package/src/hub/review-findings.ts +6 -3
- package/src/hub/risk-tier.ts +129 -0
- package/src/hub/roadmap-check.ts +1 -0
- package/src/hub/routing.ts +3 -1
- package/src/hub/sdlc-merge.ts +9 -0
- package/src/hub/sdlc-metrics.ts +24 -1
- package/src/hub/sdlc-queue.ts +1 -1
- package/src/hub/sdlc.ts +15 -6
- package/src/hub/settings.ts +2 -0
- package/src/hub/spec-readback.ts +136 -0
- package/src/hub/specs.ts +1 -1
- package/src/hub/task-list-page.ts +1 -1
- package/src/hub/tasks.ts +558 -65
- package/src/hub/ui.ts +4 -2
- package/src/ui/index.html +26 -2
- package/src/ui/overview-model.ts +138 -0
- package/src/ui/plugin.ts +30 -4
- package/templates/roles/ops/project-manager.md +1 -1
package/src/cli/source-output.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
// Human output for `ahub source add|list` (#508). Pure: data in, spans out, no I/O. `--json` is the caller's branch and prints the same data.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type { Span } from "./console-state.ts";
|
|
2
|
+
import { grid, moment, s } from "./sdlc-output.ts";
|
|
3
|
+
import { Report, type Span } from "./console-state.ts";
|
|
5
4
|
|
|
6
5
|
const list = (value: unknown): any[] => Array.isArray(value) ? value : [];
|
|
7
6
|
const size = (bytes: unknown) => typeof bytes === "number" && Number.isFinite(bytes) ? bytes < 1024 ? `${bytes} B` : bytes < 1024 * 1024 ? `${(bytes / 1024).toFixed(1)} KiB` : `${(bytes / 1024 / 1024).toFixed(1)} MiB` : "unknown";
|
|
8
7
|
|
|
9
8
|
/** `ahub source add`: what was registered, and whether it was new or an upgrade of an existing record. */
|
|
10
|
-
export function renderSourceAdd(result: unknown, columns?: number): Span[][] {
|
|
11
|
-
const r = result as any
|
|
12
|
-
out
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export function renderSourceAdd(result: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
10
|
+
const r = result as any;
|
|
11
|
+
const out = new Report(columns, ascii).titled("ahub", r?.created ? `Registered ${r?.id}` : r?.upgraded ? `Already registered ${r?.id}; now private` : `Already registered ${r?.id}`);
|
|
12
|
+
// Keys are padded to an 8-cell label column without a colon: the layout `ahub source add` has always printed and its tests pin.
|
|
13
|
+
const rows: [string, unknown][] = [["kind", r?.kind ?? "unknown"], ["origin", r?.origin ?? "unknown"], ["sha256", r?.sha256 ?? "unknown"], ["size", size(r?.bytes)], ["private", r?.private ? "yes" : "no"], ["text", r?.text ? "projected" : "none (no converter handles these bytes)"]];
|
|
14
|
+
if (list(r?.reasons).length) rows.push(["because", list(r.reasons).join("; ")]);
|
|
15
|
+
out.section("Source").kv(rows.map(([key, value]): [string, unknown] => [key.padEnd(8), value]), 2, { colon: false });
|
|
16
|
+
if (r?.private) out.bullet("warn", "private source");
|
|
17
|
+
return out.lines();
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
/** `ahub source list`: one row per registered source, newest last. The person sees every origin of a private source. */
|
|
19
|
-
export function renderSourceList(rows: unknown, columns?: number, now = Date.now()): Span[][] {
|
|
21
|
+
export function renderSourceList(rows: unknown, columns?: number, now = Date.now(), ascii = false): Span[][] {
|
|
20
22
|
const sources = list(rows);
|
|
23
|
+
// An empty list is one bare line, as `ahub board` prints it: there is nothing to put under a header.
|
|
21
24
|
if (!sources.length) return [[s("no sources registered; add one with ahub source add <path|url>", "muted")]];
|
|
22
|
-
const out
|
|
23
|
-
out.
|
|
25
|
+
const out = new Report(columns, ascii).titled("ahub", `Sources (${sources.length})`);
|
|
26
|
+
out.section("Registered", String(sources.length)).append(grid(["ID", "KIND", "SIZE", "PRIVATE", "ADDED", "ORIGIN"], sources.map((row: any) => [
|
|
24
27
|
s(row.id, "issueRef"), s(row.kind), s(size(row.bytes)), s(row.private ? "yes" : "no", row.private ? "attention" : "muted"), s(moment(row.added_at, now)), s(row.origin),
|
|
25
28
|
]), columns));
|
|
26
29
|
const many = sources.filter((row: any) => list(row.origins).length > 1);
|
|
27
|
-
|
|
28
|
-
return out;
|
|
30
|
+
if (many.length) out.section("Several origins", String(many.length)).kv(many.map((row: any): [string, unknown] => [String(row.id), `${list(row.origins).length} origins: ${list(row.origins).map((o: any) => `${o.origin}${o.private ? " (private)" : ""}`).join("; ")}`]));
|
|
31
|
+
return out.lines();
|
|
29
32
|
}
|
package/src/cli/specs.ts
CHANGED
|
@@ -20,7 +20,7 @@ export function runSpecs(args: readonly string[], root: string, config: SpecsCon
|
|
|
20
20
|
else if (arg === "--require-fresh" && command === "check" && !requireFresh) requireFresh = true;
|
|
21
21
|
else if (arg === "--base" && command === "check" && base === undefined) {
|
|
22
22
|
base = rest[++index];
|
|
23
|
-
if (!base || base.startsWith("-")) { io.error("specs: --base needs a Git reference; name a commit or branch"); return 1; }
|
|
23
|
+
if (!base || base.startsWith("-")) { io.error("ahub: specs: --base needs a Git reference; name a commit or branch"); return 1; }
|
|
24
24
|
} else if (command === "covers" && !arg.startsWith("-")) paths.push(arg);
|
|
25
25
|
else { io.error(usage); return 1; }
|
|
26
26
|
}
|
|
@@ -32,8 +32,8 @@ export function runSpecs(args: readonly string[], root: string, config: SpecsCon
|
|
|
32
32
|
if (json) io.out(JSON.stringify(report));
|
|
33
33
|
else {
|
|
34
34
|
for (const spec of report.specs) io.out(terminalText(`${spec.id} (${spec.path}): ${spec.title}`));
|
|
35
|
-
for (const item of report.items) io.error(terminalText(`specs: ${item.severity} ${item.code}: ${item.message}; ${item.nextSteps}`));
|
|
36
|
-
if (report.truncated) io.error("specs: scan truncated; narrow specs.roots and run ahub specs check again");
|
|
35
|
+
for (const item of report.items) io.error(terminalText(`ahub: specs: ${item.severity} ${item.code}: ${item.message}; ${item.nextSteps}`));
|
|
36
|
+
if (report.truncated) io.error("ahub: specs: scan truncated; narrow specs.roots and run ahub specs check again");
|
|
37
37
|
}
|
|
38
38
|
return report.errors ? 1 : 0;
|
|
39
39
|
}
|
|
@@ -49,7 +49,7 @@ export function runSpecs(args: readonly string[], root: string, config: SpecsCon
|
|
|
49
49
|
}
|
|
50
50
|
return report.errors || requireFresh && report.stale ? 1 : 0;
|
|
51
51
|
} catch (error) {
|
|
52
|
-
io.error(terminalText(`specs: ${error instanceof Error ? error.message : "inspection unavailable"}; check the repository and specs configuration, then run ahub specs check again`));
|
|
52
|
+
io.error(terminalText(`ahub: specs: ${error instanceof Error ? error.message : "inspection unavailable"}; check the repository and specs configuration, then run ahub specs check again`));
|
|
53
53
|
return 1;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -104,15 +104,15 @@ export async function runSpecsStamp(args: readonly string[], root: string, confi
|
|
|
104
104
|
}
|
|
105
105
|
if (!targets.length) { io.error(STAMP_USAGE); return 1; }
|
|
106
106
|
if (!terminal.isTTY) {
|
|
107
|
-
io.error("specs: stamping records a person's review and needs a terminal, even with --yes; run ahub specs stamp in your own terminal, or in ahub console; nothing was written");
|
|
107
|
+
io.error("ahub: specs: stamping records a person's review and needs a terminal, even with --yes; run ahub specs stamp in your own terminal, or in ahub console; nothing was written");
|
|
108
108
|
return 1;
|
|
109
109
|
}
|
|
110
110
|
try {
|
|
111
111
|
const engine = new SpecsEngine(root, config);
|
|
112
112
|
const plan = engine.stampPlan(targets);
|
|
113
113
|
if (plan.refusals.length) {
|
|
114
|
-
for (const refusal of plan.refusals) io.error(terminalText(`specs: ${refusal}`));
|
|
115
|
-
io.error("specs: nothing was written");
|
|
114
|
+
for (const refusal of plan.refusals) io.error(terminalText(`ahub: specs: ${refusal}`));
|
|
115
|
+
io.error("ahub: specs: nothing was written");
|
|
116
116
|
return 1;
|
|
117
117
|
}
|
|
118
118
|
const short = (sha: string | null) => sha === null ? "none" : sha.slice(0, 12);
|
|
@@ -123,7 +123,7 @@ export async function runSpecsStamp(args: readonly string[], root: string, confi
|
|
|
123
123
|
// Every file's new bytes are made before anyone is asked, so a document that cannot be stamped is refused up front and no file is written for it, and what the person approves is
|
|
124
124
|
// exactly what is written. `original` is what the new bytes were made from.
|
|
125
125
|
const prepared = prepareStamps(engine.rootPath, changing);
|
|
126
|
-
if (typeof prepared === "string") { io.error(terminalText(`specs: ${prepared}; nothing was written`)); return 1; }
|
|
126
|
+
if (typeof prepared === "string") { io.error(terminalText(`ahub: specs: ${prepared}; nothing was written`)); return 1; }
|
|
127
127
|
if (!yes && !await terminal.ask(`Record that you reviewed ${changing.length === 1 ? "this document" : `these ${changing.length} documents`} against HEAD ${plan.head.slice(0, 12)}?`)) {
|
|
128
128
|
io.out("specs: not stamped; nothing was written");
|
|
129
129
|
return 0;
|
|
@@ -131,12 +131,12 @@ export async function runSpecsStamp(args: readonly string[], root: string, confi
|
|
|
131
131
|
// The answer may have taken minutes. Revalidate what the person was shown before any write: HEAD, every target's plan row (so a covered path that became dirty is refused), and each
|
|
132
132
|
// file's bytes. Any difference refuses the whole run.
|
|
133
133
|
const again = engine.stampPlan(targets);
|
|
134
|
-
const changed = again.refusals.length ? again.refusals.map(refusal => `specs: ${refusal}`)
|
|
135
|
-
: again.head !== plan.head || JSON.stringify(again.rows) !== JSON.stringify(plan.rows) ? ["specs: HEAD or a document's covered paths changed while you were deciding"]
|
|
136
|
-
: prepared.filter(file => !readFileSync(file.absolute).equals(file.original)).map(file => `specs: ${file.path} changed while you were deciding`);
|
|
134
|
+
const changed = again.refusals.length ? again.refusals.map(refusal => `ahub: specs: ${refusal}`)
|
|
135
|
+
: again.head !== plan.head || JSON.stringify(again.rows) !== JSON.stringify(plan.rows) ? ["ahub: specs: HEAD or a document's covered paths changed while you were deciding"]
|
|
136
|
+
: prepared.filter(file => !readFileSync(file.absolute).equals(file.original)).map(file => `ahub: specs: ${file.path} changed while you were deciding`);
|
|
137
137
|
if (changed.length) {
|
|
138
138
|
for (const line of changed) io.error(terminalText(line));
|
|
139
|
-
io.error("specs: nothing was written; review the current state and run ahub specs stamp again");
|
|
139
|
+
io.error("ahub: specs: nothing was written; review the current state and run ahub specs stamp again");
|
|
140
140
|
return 1;
|
|
141
141
|
}
|
|
142
142
|
// ponytail: a change in the instant between this recheck and the renames below is not seen; each rename is atomic and the diff is the person's to review before committing, so there is no lock. A lock file if two people stamp one checkout.
|
|
@@ -144,7 +144,7 @@ export async function runSpecsStamp(args: readonly string[], root: string, confi
|
|
|
144
144
|
io.out(`specs: stamped ${changing.length} document${changing.length === 1 ? "" : "s"} at ${plan.head.slice(0, 12)}; review the diff and commit it`);
|
|
145
145
|
return 0;
|
|
146
146
|
} catch (error) {
|
|
147
|
-
io.error(terminalText(`specs: ${error instanceof Error ? error.message : "stamping unavailable"}; check the repository and specs configuration, then run ahub specs stamp again`));
|
|
147
|
+
io.error(terminalText(`ahub: specs: ${error instanceof Error ? error.message : "stamping unavailable"}; check the repository and specs configuration, then run ahub specs stamp again`));
|
|
148
148
|
return 1;
|
|
149
149
|
}
|
|
150
150
|
}
|
package/src/cli/study-output.ts
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
// Human output for `ahub study draft|revise|approve|approve-protocol|close|show`. Pure: the hub's parsed JSON in, spans out, no I/O. `--json` is the caller's branch and prints the same text.
|
|
2
2
|
// A campaign is named by ids, revisions, states and counts. The hub already stubs private campaigns, tasks and sources; this file never asks for a question, scope, path or excerpt.
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
3
|
+
import { grid, s } from "./sdlc-output.ts";
|
|
4
|
+
import { Report, terminalText, wrap, type Span, type Tone } from "./console-state.ts";
|
|
5
5
|
|
|
6
6
|
const list = (value: unknown): any[] => Array.isArray(value) ? value : [];
|
|
7
7
|
const count = (value: unknown): number => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
8
8
|
const STATUS_TONE: Record<string, Tone | undefined> = { approved: undefined, draft: "attention", superseded: "muted", closed: "muted" };
|
|
9
9
|
|
|
10
10
|
/** `ahub study show` with no id: one page of campaigns of this project, with the command that continues it when the hub says there is more. */
|
|
11
|
-
export function renderStudyList(page: unknown, columns?: number): Span[][] {
|
|
11
|
+
export function renderStudyList(page: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
12
12
|
const campaigns = list((page as any)?.campaigns), next = typeof (page as any)?.next === "string" ? (page as any).next as string : undefined;
|
|
13
13
|
if (!campaigns.length) return [[s("no research campaigns in this project; a planner or you draft one with `ahub study draft <parent> <contract.json>`", "muted")]];
|
|
14
|
-
const out
|
|
15
|
-
out.
|
|
14
|
+
const out = new Report(columns, ascii).titled("ahub", `Research campaigns (${campaigns.length}${next ? ", more follow" : ""})`);
|
|
15
|
+
out.section("Campaigns", String(campaigns.length)).append(grid(["ID", "REV", "STATUS", "PARENT", "UNITS"], campaigns.map((row: any) => [
|
|
16
16
|
s(row.id, "issueRef"), s(`r${count(row.revision)}`), s(row.status, STATUS_TONE[row.status]), s(`#${count(row.parentTaskId)}`, "taskRef"), s(count(row.unitCount)),
|
|
17
17
|
]), columns));
|
|
18
|
-
if (next) out.
|
|
19
|
-
return out;
|
|
18
|
+
if (next) out.note(`more campaigns: ahub study show --after ${next}`);
|
|
19
|
+
return out.lines();
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const SUPPORT_TONE: Record<string, Tone | undefined> = { enforceable: undefined, supported: undefined, advisory: "muted", unavailable: "attention", unsupported: "attention", unknown: "attention" };
|
|
23
23
|
|
|
24
24
|
/** `ahub study show <id>`: the coverage and stop projection the hub computed. Held work is said first, with every reason. */
|
|
25
|
-
export function renderStudyShow(projection: unknown, columns?: number): Span[][] {
|
|
25
|
+
export function renderStudyShow(projection: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
26
26
|
const p = projection as any, units = list(p?.units), rounds = list(p?.discoveryRounds), reasons = list(p?.reasons);
|
|
27
|
-
const out
|
|
28
|
-
for (const reason of reasons) out.
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
out.
|
|
27
|
+
const out = new Report(columns, ascii).titled("ahub", `Research campaign ${p?.id ?? "?"}, revision ${count(p?.revision)}${p?.held ? ", dispatch HELD" : ""}`);
|
|
28
|
+
for (const reason of reasons) out.bullet("warn", `held: ${terminalText(reason)}`);
|
|
29
|
+
const facts: [string, unknown][] = [];
|
|
30
|
+
if (p?.sharedPeerLedger) facts.push(["budget", "one run ledger is shared by the peers"]);
|
|
31
|
+
if (rounds.length) facts.push(["rounds", rounds.map((round: any) => `${count(round.round)}: ${round.complete ? "discovery complete" : "discovery open"}`).join(", ")]);
|
|
32
|
+
if (facts.length) out.section("Campaign").kv(facts);
|
|
33
|
+
if (!units.length) return out.note("no units").lines();
|
|
34
|
+
out.section("Units", String(units.length)).append(grid(["UNIT", "ROUND", "TASK", "STATE", "PURPOSE", "HANDOFF", "SOURCES"], units.map((unit: any) => {
|
|
34
35
|
const handoff = unit.handoff ?? {};
|
|
35
36
|
const evidence = handoff.insufficientEvidence ? "insufficient evidence" : handoff.complete ? "complete" : handoff.present ? "incomplete" : "none";
|
|
36
37
|
const covered = list(unit.sourceIds).length;
|
|
@@ -42,32 +43,30 @@ export function renderStudyShow(projection: unknown, columns?: number): Span[][]
|
|
|
42
43
|
// `unavailable` or `advisory`. A campaign that names no budget has nothing to say (its `tokens` row reads `unavailable` whatever the ledger is), so the hub's `budgetNamed` decides, not the values.
|
|
43
44
|
const budgeted = units.flatMap((unit: any) => Object.entries(unit.budget ?? {}).filter(([, value]: [string, any]) => value && typeof value === "object").map(([name, value]: [string, any]) => ({ unit: unit.unitId, name, value })));
|
|
44
45
|
if (budgeted.length && p?.budgetNamed === true) {
|
|
45
|
-
out.
|
|
46
|
-
out.push(...grid(["UNIT", "RESOURCE", "SUPPORT", "USED", "LIMIT"], budgeted.map(({ unit, name, value }) => [
|
|
46
|
+
out.section("Budget", String(budgeted.length)).append(grid(["UNIT", "RESOURCE", "SUPPORT", "USED", "LIMIT"], budgeted.map(({ unit, name, value }) => [
|
|
47
47
|
s(unit, "issueRef"), s(name), s(value.support, SUPPORT_TONE[value.support]), s(value.used === null || value.used === undefined ? "-" : value.used), s(value.limit === null || value.limit === undefined ? "-" : value.limit),
|
|
48
48
|
]), columns));
|
|
49
49
|
}
|
|
50
|
-
return out;
|
|
50
|
+
return out.lines();
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const VERB: Record<string, string> = { draft: "drafted", revise: "drafted as the next revision", approve: "approved", close: "closed" };
|
|
54
54
|
|
|
55
55
|
/** The receipt of a draft, revision, approval or close. */
|
|
56
|
-
export function renderStudyReceipt(op: string, receipt: unknown, columns?: number): Span[][] {
|
|
56
|
+
export function renderStudyReceipt(op: string, receipt: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
57
57
|
const r = receipt as any, units = list(r?.units);
|
|
58
58
|
if (op === "approve_protocol") {
|
|
59
59
|
const hash = (value: unknown) => typeof value === "string" && value.length === 64 && /^[a-f0-9]{64}$/.test(value) ? value : "unknown";
|
|
60
60
|
const by = typeof r?.approvedBy === "string" && /^[a-z][a-z0-9_-]{0,63}$/.test(r.approvedBy) ? r.approvedBy : "unknown";
|
|
61
61
|
const at = typeof r?.approvedAt === "number" && Number.isFinite(r.approvedAt) && r.approvedAt >= 0 && r.approvedAt <= 8_640_000_000_000_000
|
|
62
62
|
? new Date(r.approvedAt).toISOString().slice(0, 19).replace("T", " ") + " UTC" : "unknown";
|
|
63
|
-
return
|
|
64
|
-
...pair("evaluator hash", hash(r?.evaluatorHash), columns, 16), ...pair("approved by", by, columns, 16), ...pair("approved at", at, columns, 16)];
|
|
63
|
+
return new Report(columns, ascii).titled("ahub", "Research protocol approval").section("Approval").kv([["protocol hash", hash(r?.protocolHash)], ["evaluator hash", hash(r?.evaluatorHash)], ["approved by", by], ["approved at", at]]).lines();
|
|
65
64
|
}
|
|
66
|
-
const out
|
|
67
|
-
out.
|
|
68
|
-
if (units.length) out.
|
|
69
|
-
if (op === "draft" || op === "revise") out.
|
|
70
|
-
return out;
|
|
65
|
+
const out = new Report(columns, ascii).titled("ahub", `Research campaign ${r?.id ?? "?"} revision ${count(r?.revision)} ${VERB[op] ?? op}`);
|
|
66
|
+
out.section("Campaign").kv([["status", terminalText(r?.status ?? "")], ["parent", `#${count(r?.parentTaskId)}`], ["units", count(r?.unitCount)]]);
|
|
67
|
+
if (units.length) out.section("Units", String(units.length)).append(grid(["UNIT", "TASK", "ROUND"], units.map((unit: any) => [s(unit.unitId, "issueRef"), s(`#${count(unit.taskId)}`, "taskRef"), s(count(unit.round))]), columns));
|
|
68
|
+
if (op === "draft" || op === "revise") out.note(`nothing is dispatched until you approve: ahub study approve ${r?.id} ${count(r?.revision)}`);
|
|
69
|
+
return out.lines();
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
const ATTEMPT_TONE: Record<string, Tone | undefined> = { succeeded: undefined, running: undefined, declared: "muted", failed: "attention", cancelled: "attention", unknown: "attention" };
|
|
@@ -86,24 +85,28 @@ const sourced = (cell: any): [string, string] => {
|
|
|
86
85
|
* no command and asks for no protocol text. Every row says whether it is approved, post-hoc or predeclared and that a repeat is not an independent reproduction; every value says where it
|
|
87
86
|
* came from; failed, cancelled and unknown attempts are in the counts. A private record arrives from the hub already as ids, counts and states.
|
|
88
87
|
*/
|
|
89
|
-
export function renderExperiments(view: unknown, columns?: number): Span[][] {
|
|
88
|
+
export function renderExperiments(view: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
90
89
|
const v = view as any, attempts = list(v?.attempts), counts = v?.counts ?? {}, statuses = counts.statuses ?? {};
|
|
91
|
-
const out
|
|
90
|
+
const out = new Report(columns, ascii).titled("ahub", `Experiment attempts (${attempts.length} of ${count(counts.all)} in this campaign${v?.nextCursor !== undefined ? ", more follow" : ""})`);
|
|
92
91
|
const order = ["declared", "running", "succeeded", "failed", "cancelled", "unknown"];
|
|
93
|
-
out.
|
|
92
|
+
out.section("Counts").kv([["all", order.map(name => `${name} ${count(statuses[name])}`).join(", ")]]);
|
|
94
93
|
if (v?.comparison) {
|
|
95
94
|
const c = v.comparison, compat = c.projection?.compatibility;
|
|
96
|
-
out.
|
|
97
|
-
|
|
95
|
+
out.section("Comparison");
|
|
96
|
+
const rows: [string, unknown][] = [];
|
|
97
|
+
if (c.projection === "[pii]") rows.push(["plan", `${String(c.planHash).slice(0, 12)}: withheld (a private source or record)`]);
|
|
98
98
|
else {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
rows.push(["plan", String(c.planHash).slice(0, 12)]);
|
|
100
|
+
rows.push(["compatible", compat?.compatible ? "yes, under this plan" : `no: ${compat?.field ?? "unknown"} differs (${compat?.side ?? "pair"}); shown, not ranked together`]);
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
out.
|
|
102
|
+
rows.push(["approved", c.approved ? "both protocols bound to a person's approval" : "not both approved"], ["pair", `${c.baselineAttemptId} (baseline) and ${c.variantAttemptId} (variant)`]);
|
|
103
|
+
out.kv(rows);
|
|
104
|
+
if (c.projection === "[pii]") out.bullet("warn", "comparison withheld");
|
|
105
|
+
else if (!compat?.compatible) out.bullet("warn", "not compatible: shown, not ranked together");
|
|
106
|
+
if (!c.approved) out.bullet("warn", "not both approved");
|
|
104
107
|
}
|
|
105
|
-
if (!attempts.length) return
|
|
106
|
-
out.
|
|
108
|
+
if (!attempts.length) return out.note("no attempts recorded").lines();
|
|
109
|
+
out.section("Attempts", String(attempts.length)).append(grid(["ATTEMPT", "TASK", "PHASE", "STATUS", "APPROVAL", "POST-HOC", "NOTE"], attempts.map((row: any) => [
|
|
107
110
|
s(row.id, "issueRef"), s(`#${count(row.taskId)}`, "taskRef"), s(row.phase), s(row.status, ATTEMPT_TONE[row.status]), s(row.approval, row.approval === "approved" ? undefined : "attention"), s(row.postHoc, row.postHoc === "post-hoc" ? "attention" : "muted"),
|
|
108
111
|
s([row.private ? "private, details withheld" : "", row.retryOf ? `retry of ${row.retryOf}` : "", row.reproducesAttemptId ? `repeat of ${row.reproducesAttemptId}, not independent` : "", row.eventsComplete === false ? "events continue" : ""].filter(Boolean).join("; ") || "-", "muted"),
|
|
109
112
|
]), columns));
|
|
@@ -118,36 +121,33 @@ export function renderExperiments(view: unknown, columns?: number): Span[][] {
|
|
|
118
121
|
const [sealed, sealedFrom] = sourced(declared?.sealed);
|
|
119
122
|
if (!runners.length) lines.push(["sealed", sealed, `${sealedFrom}; isolation unverified`]);
|
|
120
123
|
if (!lines.length) continue;
|
|
121
|
-
out.
|
|
124
|
+
out.section(`Evidence of ${row.id}`, String(lines.length)).append(grid(["FIELD", "VALUE", "SOURCE"], lines.map(([field, value, from]) => [s(field), s(value), s(from, PROVENANCE_TONE[from] ?? (from.startsWith("declared") ? "muted" : undefined))]), columns));
|
|
122
125
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
// A flush-left paragraph, as before: the fixture tests filter it out by its first words, because it names the stronger sources it warns about.
|
|
127
|
+
out.append(wrap(`declared values are an agent's own words; only host-observed, runner-attested or person-attested rows are evidence, and none of them proves the science. A repeat is never an independent reproduction.`, columns ?? Infinity, 0).map(line => [s(line, "muted")]));
|
|
128
|
+
if (v?.nextCursor !== undefined) out.note(`more attempts: ahub study experiments --campaign <id> --after ${v.nextCursor}`);
|
|
129
|
+
for (const row of attempts) if (row.eventsComplete === false && row.nextEventCursor !== undefined) { out.bullet("warn", `more events of ${row.id}: ahub study experiments --attempt ${row.id} --events-after ${row.nextEventCursor}`); out.note("the values above come from the events shown so far", "value"); }
|
|
130
|
+
return out.lines();
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
|
|
130
134
|
/** Screened passage or declared manifest-authoring metadata, never an entailment/quality claim. */
|
|
131
|
-
export function renderStudyEvidence(value: unknown, columns?: number): Span[][] {
|
|
135
|
+
export function renderStudyEvidence(value: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
132
136
|
const v = value as any;
|
|
133
|
-
if (v?.status !== "resolved" && v?.status !== "available") return
|
|
134
|
-
const out
|
|
137
|
+
if (v?.status !== "resolved" && v?.status !== "available") return new Report(columns, ascii).header("ahub", "Evidence").bullet("warn", `Evidence ${v?.status ?? "unavailable"}; use a visible research task and current public evidence`).lines();
|
|
138
|
+
const out = new Report(columns, ascii).titled("ahub", v.status === "resolved" ? `Evidence ${v.id} r${v.revision}` : `Declared evidence inventory, task ${v.taskId}`);
|
|
135
139
|
if (v.status === "resolved") {
|
|
136
|
-
out.
|
|
137
|
-
out.push(...pair("source", v.link?.sourceId, columns, 12));
|
|
138
|
-
out.push(...pair("scalars", `${v.locator?.start}..${v.locator?.end}`, columns, 12));
|
|
139
|
-
out.push(...pair("passage", v.excerpt, columns, 12));
|
|
140
|
+
out.section("Evidence").kv([["status", "resolved provenance only; no entailment or source-quality certification"], ["source", v.link?.sourceId], ["scalars", `${v.locator?.start}..${v.locator?.end}`], ["passage", v.excerpt]]);
|
|
140
141
|
} else {
|
|
141
|
-
out.
|
|
142
|
-
for (const artifact of list(v.deliverables)) out.push(...pair("artifact", `${artifact.id} ${artifact.format} ${artifact.sha256}`, columns, 12));
|
|
142
|
+
out.section("Inventory").kv([["incarnation", v.taskCreated], ...list(v.deliverables).map((artifact: any): [string, unknown] => ["artifact", `${artifact.id} ${artifact.format} ${artifact.sha256}`])]);
|
|
143
143
|
for (const claim of list(v.claims)) {
|
|
144
|
-
out.
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
out.section(`Claim ${terminalText(claim.claimId)}`).kv([["claim", `${claim.claimId} @ ${claim.claimRevision}`],
|
|
145
|
+
["inventory", claim.complete && claim.inventory ? `r${claim.inventory.revision} ${claim.inventory.sha256}` : "unknown/incomplete: obtain complete inventory before checking"],
|
|
146
|
+
...list(claim.evidence).map((link: any): [string, unknown] => ["link", `${link.id} r${link.revision} ${link.status}`])]);
|
|
147
147
|
}
|
|
148
|
-
out.
|
|
148
|
+
out.note("Declared bindings only. Select citation mappings in a synthesis manifest; invoke ahub study check explicitly.");
|
|
149
149
|
}
|
|
150
|
-
return out;
|
|
150
|
+
return out.lines();
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
const SYNTHESIS_NEXT: Record<string, string> = {
|
|
@@ -161,21 +161,18 @@ const SYNTHESIS_NEXT: Record<string, string> = {
|
|
|
161
161
|
read_complete_inventory: "obtain a complete readable inventory; split oversized tasks or repair stored evidence before retrying",
|
|
162
162
|
complete_manifest_claims: "include every current declared task claim in the manifest",
|
|
163
163
|
};
|
|
164
|
-
export function renderSynthesisReadiness(value: unknown, columns?: number): Span[][] {
|
|
165
|
-
const v = value as any
|
|
166
|
-
|
|
164
|
+
export function renderSynthesisReadiness(value: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
165
|
+
const v = value as any;
|
|
166
|
+
const out = new Report(columns, ascii).titled("ahub", `Synthesis ${v?.status ?? "unavailable"}`);
|
|
167
|
+
if (v?.status === "private") return out.bullet("warn", "Readiness withheld by current task/source/artifact privacy; no research content is disclosed.").lines();
|
|
167
168
|
if (!v?.scope) {
|
|
168
169
|
const reason = v?.cause === "source_input_limit" ? "Source input exceeds this bounded check; split the synthesis into smaller tasks."
|
|
169
170
|
: "Inputs or policy changed/unavailable; refresh current public bindings and run ahub study check again.";
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
out.push(...pair("scope", "structural/provenance only; not truth, entailment or source-quality verification", columns, 12));
|
|
173
|
-
for (const key of ["manifestSha256", "binding", "claimCoverage", "deliverable", "bibliography"]) out.push(...pair(key, v[key], columns, 12));
|
|
174
|
-
out.push(...pair("citations", `${v.citations?.state} (cited ${v.citations?.cited ?? "unknown"}, missing ${v.citations?.missing ?? "unknown"})`, columns, 12));
|
|
175
|
-
for (const claim of list(v.claims)) {
|
|
176
|
-
out.push(...heading(claim.claimId, columns));
|
|
177
|
-
for (const key of ["claim", "inventory", "citationKey", "evidenceLink", "locator", "provenance", "judgment", "personVerdict", "contradictionHistory", "contradiction"]) out.push(...pair(key, claim[key], columns, 14));
|
|
171
|
+
return out.bullet("warn", reason).lines();
|
|
178
172
|
}
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
out.section("Readiness").kv([["scope", "structural/provenance only; not truth, entailment or source-quality verification"], ...["manifestSha256", "binding", "claimCoverage", "deliverable", "bibliography"].map((key): [string, unknown] => [key, v[key]]),
|
|
174
|
+
["citations", `${v.citations?.state} (cited ${v.citations?.cited ?? "unknown"}, missing ${v.citations?.missing ?? "unknown"})`]]);
|
|
175
|
+
for (const claim of list(v.claims)) out.section(`Claim ${terminalText(claim.claimId)}`).kv(["claim", "inventory", "citationKey", "evidenceLink", "locator", "provenance", "judgment", "personVerdict", "contradictionHistory", "contradiction"].map((key): [string, unknown] => [key, claim[key]]));
|
|
176
|
+
for (const next of list(v.next)) out.bullet("warn", `next: ${SYNTHESIS_NEXT[next] ?? "inspect the current manifest bindings"}`);
|
|
177
|
+
return out.lines();
|
|
181
178
|
}
|