@staix/agent-hub 0.38.0 → 0.40.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 +84 -0
- package/README.md +28 -12
- package/docs/adding-an-ai-tool.md +7 -5
- package/docs/agent-notes/README.md +23 -0
- package/docs/agent-notes/adapters.md +9 -5
- package/docs/agent-notes/benchmarks.md +2 -0
- package/docs/agent-notes/budget.md +9 -0
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +21 -9
- package/docs/agent-notes/local-worker.md +4 -2
- package/docs/agent-notes/security-review.md +56 -0
- package/docs/agent-notes/tasks.md +22 -6
- package/docs/agent-notes/tests.md +10 -9
- package/docs/contracts/companion-cli-v1.json +4 -0
- package/docs/design/adapters.md +142 -0
- package/docs/design/agent-hub-architecture.md +46 -1
- package/docs/design/agent-hub.md +10 -0
- package/docs/design/bus.md +7 -0
- package/docs/design/cli-output.md +183 -0
- package/docs/design/execution-reference.md +6 -1
- package/docs/design/roadmap.md +191 -0
- package/docs/design/task-board.md +185 -5
- package/docs/dogfood.md +30 -9
- package/docs/events.md +7 -7
- package/docs/memory.md +5 -5
- package/docs/operations.md +315 -54
- package/docs/profiles.md +101 -8
- package/docs/quickstart.md +47 -6
- package/docs/research.md +6 -3
- package/docs/roles.md +52 -0
- package/docs/sdlc.md +190 -2
- package/docs/security.md +90 -15
- package/docs/text-projection.md +1 -0
- package/docs/verification/2026-11-13-claude-implementer-2.1.323.md +59 -0
- package/docs/verification/2026-11-13-codex-01672-reviewer-isolation.md +69 -0
- package/docs/verification/2026-11-14-0.39.0.md +51 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-isolation.md +70 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md +48 -0
- package/docs/verification/2026-11-14-pi-152-compat.md +45 -0
- package/docs/verification/2026-11-15-0.40.0.md +39 -0
- package/docs/verification/2026-11-16-pi-loopback-1447.md +39 -0
- package/docs/verification/pi-152-model-free.ts +57 -0
- package/docs/verification/pi-152-native.mjs +21 -0
- package/docs/verified.json +48 -25
- package/package.json +4 -4
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +2266 -530
- package/plugins/agent-hub/kimi-review-policy-worker.js +16 -11
- package/plugins/agent-hub/server.js +2423 -645
- package/src/adapters/acp-model-policy.ts +1 -1
- package/src/adapters/acp-session-model.ts +35 -0
- package/src/adapters/acp.ts +14 -0
- package/src/adapters/agy/definition.ts +2 -2
- package/src/adapters/agy/hooks.ts +7 -0
- package/src/adapters/claude-channel.ts +1 -1
- package/src/adapters/claude-implementer.ts +8 -0
- package/src/adapters/claude-print-child.ts +26 -2
- package/src/adapters/claude-print.ts +4 -0
- package/src/adapters/codex-appserver.ts +90 -16
- package/src/adapters/codex-review-isolation.ts +63 -17
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/conformance/fakes/acp-server.ts +11 -2
- package/src/adapters/conformance/fakes/app-server.ts +5 -1
- package/src/adapters/conformance/fakes/pi-rpc.ts +1 -1
- package/src/adapters/definitions/builtin-metadata.ts +12 -12
- package/src/adapters/definitions/native-cli-jcode-mcp.ts +18 -3
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-config-policy.ts +1 -1
- package/src/adapters/definitions/native-quota.ts +122 -0
- package/src/adapters/definitions/native-recovery.ts +3 -0
- package/src/adapters/definitions/qwen.ts +2 -2
- package/src/adapters/kimi-review.ts +23 -0
- package/src/adapters/kimi-wire-usage.ts +39 -16
- package/src/adapters/local-worker.ts +9 -4
- package/src/adapters/pi-state-model.ts +12 -0
- package/src/adapters/pi.ts +76 -11
- package/src/adapters/print-result-model.ts +24 -0
- package/src/adapters/registry-types.ts +12 -2
- package/src/adapters/registry.ts +19 -2
- package/src/adapters/reviewer-print.ts +132 -16
- package/src/adapters/role-eligibility.ts +99 -0
- package/src/adapters/same-directory.ts +16 -0
- package/src/cli/agy-mcp.ts +18 -7
- package/src/cli/answer-args.ts +11 -3
- package/src/cli/console-question.ts +1 -1
- package/src/cli/console-state.ts +98 -11
- package/src/cli/console.ts +6 -2
- package/src/cli/error-format.ts +19 -0
- package/src/cli/free-text.ts +20 -0
- package/src/cli/handoff-args.ts +1 -1
- package/src/cli/help.ts +350 -30
- package/src/cli/identity-audit.ts +8 -7
- package/src/cli/identity.ts +27 -4
- package/src/cli/init-prompt.ts +31 -2
- package/src/cli/init-roles.ts +156 -0
- package/src/cli/init-settings.ts +24 -2
- package/src/cli/init.ts +232 -17
- package/src/cli/main.js +2 -2
- package/src/cli/main.ts +250 -69
- package/src/cli/model.ts +1 -1
- package/src/cli/output-standard.ts +56 -0
- package/src/cli/output.ts +199 -9
- package/src/cli/preview.ts +1 -1
- package/src/cli/recovery-launch.ts +114 -0
- package/src/cli/recovery-package.ts +14 -7
- package/src/cli/recovery-version-preflight.ts +104 -0
- package/src/cli/roadmap.ts +215 -0
- package/src/cli/role-doctor.ts +39 -0
- package/src/cli/sdlc-output.ts +66 -1
- package/src/cli/smoke-pty-bridge.ts +7 -24
- package/src/cli/study-output.ts +54 -0
- package/src/cli/study.ts +14 -1
- package/src/cli/task-output.ts +3 -1
- package/src/cli/terminal-recovery.ts +14 -0
- package/src/cli/upgrade-presentation-flags.ts +2 -2
- package/src/cli/upgrade-presentation.ts +4 -0
- package/src/cli/upgrade-restore-state.ts +12 -3
- package/src/cli/upgrade-runtime.ts +40 -2
- package/src/cli/upgrade.ts +8 -4
- package/src/hub/advisor-survey.ts +139 -0
- package/src/hub/audit-source.ts +66 -0
- package/src/hub/board.ts +677 -15
- package/src/hub/budget.ts +54 -4
- package/src/hub/bus.ts +9 -0
- package/src/hub/check-runner.ts +3 -4
- package/src/hub/ci-watch.ts +19 -4
- package/src/hub/conductor.ts +14 -8
- package/src/hub/config-apply.ts +2 -1
- package/src/hub/config-edit-host.ts +77 -5
- package/src/hub/considered-findings.ts +47 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +585 -98
- package/src/hub/deliverable-files.ts +17 -1
- package/src/hub/dogfood-profile.ts +3 -2
- package/src/hub/events.ts +25 -4
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/folder-trigger.ts +11 -4
- package/src/hub/github-import.ts +81 -0
- package/src/hub/hub-tools.ts +117 -20
- package/src/hub/install-policy.ts +23 -0
- package/src/hub/kimi-usage.ts +34 -2
- package/src/hub/lifecycle-schema.ts +3 -3
- package/src/hub/memory-profile.ts +9 -1
- package/src/hub/memory-sync-state.ts +1 -0
- package/src/hub/model-overrides.ts +2 -1
- package/src/hub/no-writes.ts +5 -0
- package/src/hub/operational-authority.ts +8 -1
- package/src/hub/operational-view.ts +6 -2
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-failure.ts +7 -0
- package/src/hub/plan-conformance.ts +20 -2
- package/src/hub/question-desk.ts +26 -7
- package/src/hub/questions.ts +33 -5
- package/src/hub/quota-account.ts +34 -0
- package/src/hub/recovery-policy.ts +18 -4
- package/src/hub/research-evidence.ts +51 -3
- package/src/hub/research.ts +77 -13
- package/src/hub/restart.ts +21 -0
- package/src/hub/review-budget.ts +88 -0
- package/src/hub/review-findings.ts +93 -12
- package/src/hub/reviewer-pool-config.ts +6 -2
- package/src/hub/reviewer-pool.ts +39 -6
- package/src/hub/roadmap-triage.ts +86 -0
- package/src/hub/roadmap-unplaced.ts +169 -0
- package/src/hub/roadmap-view.ts +83 -0
- package/src/hub/roadmap.ts +127 -0
- package/src/hub/routing.ts +7 -3
- package/src/hub/sdlc-merge.ts +6 -5
- package/src/hub/sdlc-queue.ts +17 -7
- package/src/hub/sdlc-release.ts +1 -1
- package/src/hub/sdlc.ts +47 -8
- package/src/hub/security-audit.ts +178 -0
- package/src/hub/security-pass.ts +115 -0
- package/src/hub/settings.ts +11 -5
- package/src/hub/source-read.ts +80 -2
- package/src/hub/sources.ts +57 -9
- package/src/hub/specs-task.ts +7 -0
- package/src/hub/startup-event-seeds.ts +5 -3
- package/src/hub/startup-timing.ts +1 -0
- package/src/hub/synthesis-readiness.ts +279 -0
- package/src/hub/task-sweep.ts +29 -2
- package/src/hub/task-worktree.ts +37 -0
- package/src/hub/tasks.ts +1464 -76
- package/src/hub/text-projection.ts +11 -1
- package/src/memory/capture.ts +2 -1
- package/src/pi/dependency-publish.ts +50 -0
- package/src/pi/extension.ts +1 -1
- package/src/pi/launch.ts +1 -1
- package/src/pi/task-dependencies.ts +249 -0
- package/src/ui/index.html +56 -13
- package/src/ui/office-model.ts +11 -3
- package/src/ui/office-space.ts +50 -30
- package/src/ui/plugin-questions.ts +5 -0
- package/src/ui/plugin.ts +27 -12
- package/templates/config.json +1 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { milestoneId, milestoneRevision, milestoneLinkRef, parseMilestoneInput, parseMilestonePatch, githubRepo, type MilestoneLinkKind } from "../hub/roadmap.ts";
|
|
2
|
+
import { terminalText, wrap } from "./console-state.ts";
|
|
3
|
+
|
|
4
|
+
const optionalFields = "[--horizon now|next|later] [--order <n>] [--target YYYY-MM-DD|none] [--parent <id>|none]";
|
|
5
|
+
export const ROADMAP_FORMS = {
|
|
6
|
+
list: "[list] [--json]", show: "show <id> [--json]",
|
|
7
|
+
new: `new --title <text> --outcome <text> ${optionalFields}`,
|
|
8
|
+
edit: `edit <id> --revision <n> [--title <text>] [--outcome <text>] ${optionalFields}`,
|
|
9
|
+
link: "link <id> <spec|issue|task|release> <ref>", unlink: "unlink <id> <kind> <ref>",
|
|
10
|
+
order: "order <id> <n>", state: "state <id> <proposed|planned|active|done|dropped>",
|
|
11
|
+
unplaced: "unplaced [--repo <owner/name>] [--json]",
|
|
12
|
+
triage: "triage [--repo <owner/name>] [--list] [--json]",
|
|
13
|
+
accept: "accept <suggestion>", reject: "reject <suggestion>",
|
|
14
|
+
importGithub: "import-github [--repo <owner/name>] [--apply] [--json]",
|
|
15
|
+
} as const;
|
|
16
|
+
export const ROADMAP_USAGE = `usage: ${Object.values(ROADMAP_FORMS).map(form => `ahub roadmap ${form}`).join(" | ")}`;
|
|
17
|
+
export interface RoadmapArgs {
|
|
18
|
+
op: "hub_roadmap_list" | "hub_roadmap_show" | "hub_roadmap_edit" | "hub_roadmap_unplaced" | "hub_roadmap_triage" | "roadmap_import_github";
|
|
19
|
+
args: Record<string, unknown>;
|
|
20
|
+
json: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** R3 commands: their flags are not milestone fields, so they are parsed apart from new/edit. */
|
|
23
|
+
const R3_COMMANDS = ["unplaced", "triage", "accept", "reject", "import-github"];
|
|
24
|
+
const R3_JSON = ["unplaced", "triage", "import-github"];
|
|
25
|
+
const fieldFlags = ["title", "outcome", "horizon", "order", "target", "parent"];
|
|
26
|
+
const usage = (message: string): never => { throw new Error(`${message}; ${ROADMAP_USAGE}`); };
|
|
27
|
+
function integer(value: string | undefined, zero = false): number {
|
|
28
|
+
if (value === undefined || !/^(0|[1-9][0-9]*)$/.test(value)) return usage("roadmap needs a whole-number operand");
|
|
29
|
+
return zero ? milestoneRevision(Number(value)) : milestoneId(Number(value));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function parseR3(command: string, rest: readonly string[], jsonSeen: boolean): RoadmapArgs {
|
|
33
|
+
let json = jsonSeen, list = false, apply = false, repo: string | undefined;
|
|
34
|
+
const operands: string[] = [];
|
|
35
|
+
for (let at = 0; at < rest.length; at++) {
|
|
36
|
+
const word = rest[at]!;
|
|
37
|
+
if (word === "--json") { if (json) return usage("duplicate roadmap --json flag"); json = true; continue; }
|
|
38
|
+
if (word === "--list" && command === "triage") { if (list) return usage("duplicate roadmap --list flag"); list = true; continue; }
|
|
39
|
+
if (word === "--apply" && command === "import-github") { if (apply) return usage("duplicate roadmap --apply flag"); apply = true; continue; }
|
|
40
|
+
if ((word === "--repo" || word.startsWith("--repo=")) && ["unplaced", "triage", "import-github"].includes(command)) {
|
|
41
|
+
if (repo !== undefined) return usage("duplicate roadmap --repo option");
|
|
42
|
+
const value = word === "--repo" ? rest[++at] : word.slice("--repo=".length);
|
|
43
|
+
if (value === undefined) return usage("roadmap --repo needs owner/name");
|
|
44
|
+
try { repo = githubRepo(value); } catch { return usage("roadmap --repo needs owner/name"); }
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (word.startsWith("-")) return usage("unknown roadmap option");
|
|
48
|
+
operands.push(word);
|
|
49
|
+
}
|
|
50
|
+
if (json && !R3_JSON.includes(command)) return usage(`roadmap ${command} has no --json form`);
|
|
51
|
+
if (command === "accept" || command === "reject") {
|
|
52
|
+
if (operands.length !== 1) return usage(`roadmap ${command} needs one suggestion id`);
|
|
53
|
+
return { op: "hub_roadmap_edit", args: { op: command, suggestion: integer(operands[0]) }, json };
|
|
54
|
+
}
|
|
55
|
+
if (operands.length) return usage(`roadmap ${command} takes no operands`);
|
|
56
|
+
const base = repo === undefined ? {} : { repo };
|
|
57
|
+
if (command === "unplaced") return { op: "hub_roadmap_unplaced", args: base, json };
|
|
58
|
+
if (command === "triage") return { op: "hub_roadmap_triage", args: { ...base, ...(list ? { list: true } : {}) }, json };
|
|
59
|
+
return { op: "roadmap_import_github", args: { ...base, ...(apply ? { apply: true } : {}) }, json };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Closed argv only. Values consumed by a text flag remain literal text, including '--json'. */
|
|
63
|
+
export function parseRoadmapArgs(argv: readonly string[]): RoadmapArgs {
|
|
64
|
+
let index = 0, json = false;
|
|
65
|
+
if (argv[index] === "--json") { json = true; index++; }
|
|
66
|
+
const command = argv[index] ?? "list";
|
|
67
|
+
if (argv[index] !== undefined) index++;
|
|
68
|
+
if (!["list", "show", "new", "edit", "link", "unlink", "order", "state", ...R3_COMMANDS].includes(command)) return usage("unknown roadmap command");
|
|
69
|
+
if (R3_COMMANDS.includes(command)) return parseR3(command, argv.slice(index), json);
|
|
70
|
+
const operands: string[] = [], flags = new Map<string, string>();
|
|
71
|
+
for (; index < argv.length; index++) {
|
|
72
|
+
const word = argv[index]!;
|
|
73
|
+
if (word === "--json") {
|
|
74
|
+
if (json) return usage("duplicate roadmap --json flag");
|
|
75
|
+
json = true; continue;
|
|
76
|
+
}
|
|
77
|
+
if (word.startsWith("--")) {
|
|
78
|
+
const equal = word.indexOf("="), name = word.slice(2, equal < 0 ? undefined : equal);
|
|
79
|
+
if (command !== "new" && command !== "edit" || ![...fieldFlags, ...(command === "edit" ? ["revision"] : [])].includes(name)) return usage("unknown roadmap option");
|
|
80
|
+
if (flags.has(name)) return usage("duplicate roadmap field option");
|
|
81
|
+
const value = equal < 0 ? argv[++index] : word.slice(equal + 1);
|
|
82
|
+
if (value === undefined) return usage("roadmap field option needs a value");
|
|
83
|
+
flags.set(name, value); continue;
|
|
84
|
+
}
|
|
85
|
+
if (word.startsWith("-")) return usage("unknown roadmap option");
|
|
86
|
+
operands.push(word);
|
|
87
|
+
}
|
|
88
|
+
if (json && command !== "list" && command !== "show") return usage("roadmap --json is available on list and show only");
|
|
89
|
+
if (command === "list") {
|
|
90
|
+
if (operands.length) return usage("roadmap list takes no operands");
|
|
91
|
+
return { op: "hub_roadmap_list", args: {}, json };
|
|
92
|
+
}
|
|
93
|
+
if (command === "show") {
|
|
94
|
+
if (operands.length !== 1) return usage("roadmap show needs one id");
|
|
95
|
+
return { op: "hub_roadmap_show", args: { id: integer(operands[0]) }, json };
|
|
96
|
+
}
|
|
97
|
+
if (command === "new" || command === "edit") {
|
|
98
|
+
if (operands.length !== (command === "new" ? 0 : 1)) return usage("roadmap new takes flags; edit needs one id");
|
|
99
|
+
const fields: Record<string, unknown> = {};
|
|
100
|
+
for (const name of fieldFlags) if (flags.has(name)) {
|
|
101
|
+
const value = flags.get(name)!;
|
|
102
|
+
fields[name] = name === "order" ? integer(value, true) : name === "parent" ? value === "none" ? null : integer(value) : name === "target" && value === "none" ? null : value;
|
|
103
|
+
}
|
|
104
|
+
// Validate without substituting normalized values: free text is passed exactly as supplied.
|
|
105
|
+
if (command === "new") parseMilestoneInput(fields); else parseMilestonePatch(fields);
|
|
106
|
+
const args: Record<string, unknown> = { op: command, fields };
|
|
107
|
+
if (command === "edit") {
|
|
108
|
+
if (!flags.has("revision")) return usage("roadmap edit requires --revision from roadmap show");
|
|
109
|
+
args.id = integer(operands[0]); args.revision = integer(flags.get("revision"), true);
|
|
110
|
+
}
|
|
111
|
+
return { op: "hub_roadmap_edit", args, json };
|
|
112
|
+
}
|
|
113
|
+
const required = command === "link" || command === "unlink" ? 3 : 2;
|
|
114
|
+
if (operands.length !== required) return usage("roadmap operation has missing or unused operands");
|
|
115
|
+
const id = integer(operands[0]);
|
|
116
|
+
if (command === "link" || command === "unlink") {
|
|
117
|
+
const kind = operands[1] as MilestoneLinkKind;
|
|
118
|
+
return { op: "hub_roadmap_edit", args: { op: command, id, kind, ref: milestoneLinkRef(kind, operands[2]) }, json };
|
|
119
|
+
}
|
|
120
|
+
if (command === "order") return { op: "hub_roadmap_edit", args: { op: command, id, order: integer(operands[1], true) }, json };
|
|
121
|
+
const fields = parseMilestonePatch({ state: operands[1] });
|
|
122
|
+
return { op: "hub_roadmap_edit", args: { op: command, id, state: fields.state }, json };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type Row = Record<string, unknown>;
|
|
126
|
+
const row = (value: unknown): Row => value !== null && typeof value === "object" && !Array.isArray(value) ? value as Row : {};
|
|
127
|
+
const list = (value: unknown): unknown[] => Array.isArray(value) ? value : [];
|
|
128
|
+
const text = (value: unknown): string => typeof value === "string" || typeof value === "number" ? terminalText(value) : "unknown";
|
|
129
|
+
const count = (value: unknown): string => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? String(value) : "unknown";
|
|
130
|
+
const ratio = (value: unknown, field: string): string => { const r = row(value); return `${count(r[field])}/${count(r.total)}`; };
|
|
131
|
+
|
|
132
|
+
/** Person-first plain text; rendering never reads the terminal, environment, files or network. */
|
|
133
|
+
export function renderRoadmap(input: unknown, width = 80): string {
|
|
134
|
+
if (typeof input === "string") {
|
|
135
|
+
try { input = JSON.parse(input); }
|
|
136
|
+
catch { return terminalText(input); }
|
|
137
|
+
}
|
|
138
|
+
const columns = Number.isFinite(width) && width >= 1 ? Math.floor(width) : 80;
|
|
139
|
+
const view = row(input), lines: string[] = [];
|
|
140
|
+
const add = (value: string) => { lines.push(...wrap(value, columns)); };
|
|
141
|
+
const milestone = (value: unknown) => {
|
|
142
|
+
const m = row(value), progress = row(m.rollup), specs = row(progress.specs), issues = row(progress.issues), releases = row(progress.releases);
|
|
143
|
+
add(`Milestone ${count(m.id)}: ${text(m.title)}`);
|
|
144
|
+
add(` ${text(m.state)} | ${text(m.horizon)} | order ${count(m.order)} | revision ${count(m.revision)}`);
|
|
145
|
+
add(` Outcome: ${text(m.outcome)}`);
|
|
146
|
+
if (m.target !== null && m.target !== undefined) add(` Target: ${text(m.target)}`);
|
|
147
|
+
if (m.parent !== null && m.parent !== undefined) add(` Parent: ${count(m.parent)}`);
|
|
148
|
+
add(` Tasks approved: ${ratio(progress.tasks, "approved")}; issues closed: ${ratio(issues, "closed")} (unknown ${count(issues.unknown)})`);
|
|
149
|
+
add(` Specs: fresh ${count(specs.fresh)}, stale ${count(specs.stale)}, unverified ${count(specs.unverified)}, unknown ${count(specs.unknown)}; total ${count(specs.total)}`);
|
|
150
|
+
add(` Releases shipped: ${ratio(releases, "shipped")} (unknown ${count(releases.unknown)})`);
|
|
151
|
+
if (m.withheld !== undefined) add(` Private tasks withheld: ${count(m.withheld)}`);
|
|
152
|
+
const tree = row(m.tree);
|
|
153
|
+
if (m.tree !== undefined && Number(tree.children) > 0) add(` With children (${count(tree.children)}): tasks ${ratio(tree.tasks, "approved")}, issues ${ratio(tree.issues, "closed")}, releases ${ratio(tree.releases, "shipped")}`);
|
|
154
|
+
const ready = row(m.readyToClose);
|
|
155
|
+
if (ready.ready === true) add(" Ready to close: every linked item is closed or approved. Only the person records done: ahub roadmap state " + count(m.id) + " done");
|
|
156
|
+
else if (m.readyToClose !== undefined && list(ready.reasons).length) add(` Not ready to close: ${list(ready.reasons).map(text).join("; ")}`);
|
|
157
|
+
for (const value of list(m.links)) {
|
|
158
|
+
const link = row(value); add(` Link ${text(link.kind)}: ${text(link.ref)}`);
|
|
159
|
+
}
|
|
160
|
+
for (const value of list(m.tasks)) {
|
|
161
|
+
const task = row(value), placement = row(task.placement);
|
|
162
|
+
const issue = /^(.+)#([1-9][0-9]*)$/.exec(text(placement.issue));
|
|
163
|
+
const basis = placement.rule === "source-issue" || placement.rule === "inherited" ? issue ? `inherited from #${issue[2]} (${issue[1]})` : `inherited from ${text(placement.issue)}` : placement.rule === "explicit" ? "explicit link" : "placement unknown";
|
|
164
|
+
add(` Task ${count(task.id)}: ${text(task.title)} (${text(task.state)}; ${basis})`);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const names = (rows: unknown[], one: (value: Row) => string) => { for (const value of rows) add(one(row(value))); };
|
|
168
|
+
if (Array.isArray(view.issues) && Array.isArray(view.tasks) && Array.isArray(view.specs) && view.privateTasks !== undefined) {
|
|
169
|
+
add(`Unplaced work${view.repo ? ` (${text(view.repo)})` : ""}`);
|
|
170
|
+
if (view.partial === true) add("Partial: the GitHub read stopped early or a list was cut, so these lists are a lower bound.");
|
|
171
|
+
for (const name of list(view.unavailable)) add(`Unavailable: ${text(name)} could not be read, so none are listed.`);
|
|
172
|
+
add(`Issues (${view.issues.length}${Number(row(view.more).issues) > 0 ? `, ${count(row(view.more).issues)} more` : ""})`);
|
|
173
|
+
names(view.issues, issue => ` ${text(issue.ref)}: ${text(issue.title)}\n why: ${text(issue.reason)}`);
|
|
174
|
+
add(`Tasks (${view.tasks.length}${Number(row(view.more).tasks) > 0 ? `, ${count(row(view.more).tasks)} more` : ""})`);
|
|
175
|
+
names(view.tasks, task => ` #${count(task.id)} ${text(task.title)} (${text(task.state)})\n why: ${text(task.reason)}`);
|
|
176
|
+
add(`Specs (${view.specs.length}${Number(row(view.more).specs) > 0 ? `, ${count(row(view.more).specs)} more` : ""})`);
|
|
177
|
+
names(view.specs, spec => ` ${text(spec.id)}: ${text(spec.title)} (${text(spec.status)})\n why: ${text(spec.reason)}`);
|
|
178
|
+
add(`Private tasks counted, not listed: ${count(view.privateTasks)}`);
|
|
179
|
+
return lines.join("\n");
|
|
180
|
+
}
|
|
181
|
+
if (Array.isArray(view.suggestions)) {
|
|
182
|
+
add(`Triage suggestions (${view.suggestions.length})`);
|
|
183
|
+
if (view.unavailable) add(`Triage unavailable: ${text(view.unavailable)}`);
|
|
184
|
+
if (view.partial === true) add("Partial: more unplaced work remains; run triage again after deciding these.");
|
|
185
|
+
if (view.asked !== undefined) add(`Asked about ${count(view.asked)} item${view.asked === 1 ? "" : "s"}; ${count(view.dropped)} model answer${view.dropped === 1 ? "" : "s"} dropped as unsupported.`);
|
|
186
|
+
names(view.suggestions, s => {
|
|
187
|
+
const proposal = row(s.proposal), target = s.milestone === null || s.milestone === undefined ? `new milestone: ${text(proposal.title)}` : `milestone ${count(s.milestone)}`;
|
|
188
|
+
return ` #${count(s.id)} ${text(s.kind)} ${text(s.ref)} -> ${target}\n item words: "${text(s.citeItem)}"${s.citeMilestone ? `\n milestone words: "${text(s.citeMilestone)}"` : ""}\n apply: ahub roadmap accept ${count(s.id)} drop: ahub roadmap reject ${count(s.id)}`;
|
|
189
|
+
});
|
|
190
|
+
if (!view.suggestions.length) add("Nothing pending. Nothing is linked until you run ahub roadmap accept <id>.");
|
|
191
|
+
return lines.join("\n");
|
|
192
|
+
}
|
|
193
|
+
if (view.suggestion !== undefined && typeof view.suggestion === "object") {
|
|
194
|
+
const s = row(view.suggestion);
|
|
195
|
+
add(`Suggestion ${count(s.id)} ${text(s.state)}: ${text(s.kind)} ${text(s.ref)}`);
|
|
196
|
+
if (view.milestone !== undefined) milestone(view.milestone);
|
|
197
|
+
return lines.join("\n");
|
|
198
|
+
}
|
|
199
|
+
if (Array.isArray(view.milestones) && view.apply !== undefined) {
|
|
200
|
+
add(`GitHub milestones (${text(view.repo)}): ${view.apply === true ? "applied" : "dry run, nothing written; add --apply to create them"}`);
|
|
201
|
+
if (view.partial === true) add("Partial: the GitHub read stopped early, so this list is a lower bound.");
|
|
202
|
+
names(view.milestones, m => ` GitHub #${count(m.number)} ${text(m.title)}: ${m.action === "create" ? "would create" : "already imported as"}${m.milestone ? ` milestone ${count(m.milestone)}` : ""}; ${list(m.issues).length} issue${list(m.issues).length === 1 ? "" : "s"}, ${count(m.newLinks)} new link${m.newLinks === 1 ? "" : "s"}`);
|
|
203
|
+
if (view.apply === true) add(`Created ${count(view.created)} milestone${view.created === 1 ? "" : "s"}, linked ${count(view.linked)} issue${view.linked === 1 ? "" : "s"}.`);
|
|
204
|
+
if (Number(view.withheld) > 0) add(`Withheld ${count(view.withheld)} milestone${view.withheld === 1 ? "" : "s"} whose text was not cleared for public planning.`);
|
|
205
|
+
return lines.join("\n");
|
|
206
|
+
}
|
|
207
|
+
if (Array.isArray(view.milestones)) {
|
|
208
|
+
add(`Roadmap (${view.milestones.length} milestones)`);
|
|
209
|
+
if (!view.milestones.length) add("No milestones recorded.");
|
|
210
|
+
for (const item of view.milestones) { lines.push(""); milestone(item); }
|
|
211
|
+
} else if (view.id !== undefined) milestone(view);
|
|
212
|
+
else if (view.milestone !== undefined) milestone(view.milestone);
|
|
213
|
+
else add("Roadmap unavailable: the hub returned no readable milestone view.");
|
|
214
|
+
return lines.join("\n");
|
|
215
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { roleEligibility } from "../adapters/role-eligibility.ts";
|
|
2
|
+
import { conductorPeer } from "../hub/conductor.ts";
|
|
3
|
+
import type { StartMode } from "../hub/start-mode.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* #1408 R2: `ahub doctor`'s `roles` row. Pure: the caller passes what the loader settled (`roles`, after every ceiling), what the config declared before the ceilings, each peer's effective
|
|
7
|
+
* start mode and the roster. A warning, never a failure, like the other advisory rows: doctor's exit code stays what it was for a project that has not looked at this yet.
|
|
8
|
+
*/
|
|
9
|
+
export interface RolesRowInput {
|
|
10
|
+
/** `roles` after the loader's ceilings (what the hub holds). */
|
|
11
|
+
roles: Readonly<Record<string, readonly string[]>>;
|
|
12
|
+
/** The raw `roles` block of the config layers merged, before any ceiling, or undefined when none is declared. */
|
|
13
|
+
declared?: Readonly<Record<string, readonly string[]>>;
|
|
14
|
+
startMode: (peer: string) => StartMode | undefined;
|
|
15
|
+
rostered: (peer: string) => boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface RolesRow { ok: boolean | undefined; detail: string }
|
|
18
|
+
|
|
19
|
+
const holders = (roles: RolesRowInput["roles"], role: string, rostered: (peer: string) => boolean) => Object.keys(roles).filter(peer => roles[peer]!.includes(role) && rostered(peer)).sort();
|
|
20
|
+
|
|
21
|
+
export function rolesRow(input: RolesRowInput): RolesRow {
|
|
22
|
+
const conductor = conductorPeer(input.roles), planners = holders(input.roles, "planner", input.rostered), reviewers = holders(input.roles, "reviewer", input.rostered);
|
|
23
|
+
const warnings: string[] = [];
|
|
24
|
+
// A declared conductor that the loader dropped is the case the person most needs to hear about: nobody else holds the role.
|
|
25
|
+
let ignored: string | null = null;
|
|
26
|
+
try { ignored = input.declared ? conductorPeer(input.declared) : null; } catch { ignored = null; }
|
|
27
|
+
if (ignored && ignored !== conductor) {
|
|
28
|
+
const verdict = roleEligibility(ignored, "conductor", input.startMode(ignored));
|
|
29
|
+
warnings.push(`conductor ${ignored} is ignored${verdict.reason ? `: ${verdict.reason}` : ""}${verdict.fix ? `; ${verdict.fix}` : ""}`);
|
|
30
|
+
}
|
|
31
|
+
if (!planners.length) warnings.push("no rostered planner is eligible (the hub falls back to the first eligible rostered kind, or has none)");
|
|
32
|
+
if (!reviewers.length) warnings.push("no rostered reviewer can run: reviews go to the person");
|
|
33
|
+
else {
|
|
34
|
+
const unfit = reviewers.filter(peer => !roleEligibility(peer, "reviewer").eligible);
|
|
35
|
+
if (unfit.length) warnings.push(`${unfit.join(", ")} cannot receive hub_review`);
|
|
36
|
+
}
|
|
37
|
+
const text = `conductor ${conductor ?? "none (the person conducts from ahub console)"}; planner ${planners.join(", ") || "none"}; reviewer ${reviewers.join(", ") || "the person"}`;
|
|
38
|
+
return warnings.length ? { ok: undefined, detail: `${text}. ${warnings.join(". ")}` } : { ok: true, detail: text };
|
|
39
|
+
}
|
package/src/cli/sdlc-output.ts
CHANGED
|
@@ -5,6 +5,44 @@
|
|
|
5
5
|
import { duration, plural, relative, table, terminalText, wrap, type Span, type Tone } from "./console-state.ts";
|
|
6
6
|
|
|
7
7
|
type Line = Span[];
|
|
8
|
+
/** Configuration remains restart-bound; the claim is caller provenance, not inferred release consent. */
|
|
9
|
+
export function renderSdlcConfiguration(value: unknown, columns?: number): Span[][] {
|
|
10
|
+
const row = value as any;
|
|
11
|
+
const out = heading(list(row?.restartPending).length ? "SDLC configuration saved; restart pending" : "SDLC configuration saved", columns);
|
|
12
|
+
out.push(...pair("actor", row?.by ?? "unknown", columns, 12));
|
|
13
|
+
out.push(...pair("instruction", "person's explicit instruction claimed for this session", columns, 12));
|
|
14
|
+
for (const line of list(row?.lines)) out.push(...para(String(line), columns));
|
|
15
|
+
if (row?.backup) out.push(...pair("backup", row.backup, columns, 12));
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
/** Survey fields already passed the host's task and security disclosure policy. */
|
|
19
|
+
export function renderSdlcSurvey(value: unknown, columns?: number): Span[][] {
|
|
20
|
+
const row = value as any;
|
|
21
|
+
if (!row) return [[s("no advisor survey", "muted")]];
|
|
22
|
+
const out: Span[][] = [...heading(`Advisor survey, task ${row.task ?? "unknown"}`, columns)];
|
|
23
|
+
for (const field of ["survey", "ref", "focus"]) if (row[field] !== undefined) out.push(...pair(field, row[field], columns, 12));
|
|
24
|
+
if (row.withheld || row.status === "private") return [...out, [s("report withheld by current privacy", "attention")]];
|
|
25
|
+
for (const item of list(row.items)) {
|
|
26
|
+
const finding = item.finding ?? item;
|
|
27
|
+
out.push(...pair("finding", finding.id, columns, 12));
|
|
28
|
+
if (finding.withheld || item.withheld) { out.push(...pair("details", "withheld", columns, 12)); continue; }
|
|
29
|
+
for (const field of ["evidence", "impact", "effort", "risk", "confidence", "fix_sketch"]) if (finding[field] !== undefined) out.push(...pair(field, finding[field], columns, 12));
|
|
30
|
+
if (item.decision) out.push(...pair("decision", item.decision.verdict, columns, 12));
|
|
31
|
+
else if (item.verdict) out.push(...pair("decision", item.verdict, columns, 12));
|
|
32
|
+
if (item.rejectedBefore?.rejectedBefore || item.rejectedBefore === true) out.push(...pair("history", "rejected before", columns, 12, "attention"));
|
|
33
|
+
for (const rejected of list(item.rejected)) {
|
|
34
|
+
out.push(...pair("rejected before", rejected.id, columns, 16));
|
|
35
|
+
if (rejected.change === "unknown") out.push(...pair("change", "unknown (suppression retained)", columns, 16, "attention"));
|
|
36
|
+
if (!rejected.withheld && rejected.reason) out.push(...pair("reason", rejected.reason, columns, 16));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const rejected of list(row.rejected)) {
|
|
40
|
+
out.push(...pair("rejected before", rejected.id, columns, 16));
|
|
41
|
+
if (rejected.status === "unknown" || rejected.change === "unknown") out.push(...pair("change", "unknown (suppression retained)", columns, 16, "attention"));
|
|
42
|
+
if (!rejected.withheld && rejected.reason) out.push(...pair("reason", rejected.reason, columns, 16));
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
8
46
|
export const s = (value: unknown, tone?: Tone): Span => ({ text: terminalText(value).replace(/[\n\t]/g, " "), ...(tone ? { tone } : {}) });
|
|
9
47
|
const room = (columns?: number) => columns ?? Infinity;
|
|
10
48
|
const list = (value: unknown): any[] => Array.isArray(value) ? value : [];
|
|
@@ -104,7 +142,7 @@ function taskBlock(row: any, columns: number | undefined, detail: boolean): Line
|
|
|
104
142
|
if (row.definition?.name || row.definition?.id) out.push(...pair("stage", row.definition.name ?? row.definition.id, columns, 11, undefined, " "));
|
|
105
143
|
out.push(...bullets("entry", list(row.entry), columns, undefined, " "), ...bullets("exit", list(row.exit), columns, undefined, " "));
|
|
106
144
|
const f = row.findings;
|
|
107
|
-
if (f) out.push(...pair("findings", `${plural(f.important ?? 0, "important")} (${f.openImportant ?? 0} open), ${plural(f.nit ?? 0, "nit")} (${f.openNit ?? 0} open), ${f.fixed ?? 0} fixed, ${f.falsePositive ?? 0} false positive, ${f.accepted ?? 0} accepted`, columns, 11, f.openImportant ? "attention" : undefined, " "));
|
|
145
|
+
if (f) out.push(...pair("findings", `${plural(f.important ?? 0, "important")} (${f.openImportant ?? 0} open), ${plural(f.nit ?? 0, "nit")} (${f.openNit ?? 0} open), ${f.fixed ?? 0} fixed, ${f.falsePositive ?? 0} false positive, ${f.accepted ?? 0} accepted${f.needsValidation ? `, ${f.needsValidation} needs validation (not blocking)` : ""}${f.preExisting ? `, ${f.preExisting} pre-existing (not blocking)` : ""}`, columns, 11, f.openImportant ? "attention" : undefined, " "));
|
|
108
146
|
const p = row.planConformance;
|
|
109
147
|
if (p) {
|
|
110
148
|
out.push(...pair("plan files", `${p.state}${p.accepted ? ", departure accepted" : ""}, ${list(p.outside).length} outside the plan, ${list(p.untouched).length} planned and untouched`, columns, 11, p.state === "departure" && !p.accepted ? "attention" : undefined, " "));
|
|
@@ -115,6 +153,13 @@ function taskBlock(row: any, columns: number | undefined, detail: boolean): Line
|
|
|
115
153
|
out.push(...pair("tests", `${t.applicability === "bug" ? "bug fix" : t.applicability === "not_bug" ? "not a bug fix" : "bug status unknown"}, red-first ${String(t.redFirst).replace("_", " ")}, files ${t.fileState}`, columns, 11, undefined, " "));
|
|
116
154
|
out.push(...bullets("modified tests", list(t.modifiedTests), columns, undefined, " "), ...bullets("test blockers", list(t.blockers), columns, "attention", " "));
|
|
117
155
|
}
|
|
156
|
+
const sp = row.securityPass;
|
|
157
|
+
if (sp) {
|
|
158
|
+
const shown = sp.state === "required" ? `required (${sp.matched} sensitive path${sp.matched === 1 ? "" : "s"} changed), none recorded at this head`
|
|
159
|
+
: sp.state === "recorded" ? `recorded at this head (${sp.recorded?.covered ?? 0} covered, ${sp.recorded?.notCovered ?? 0} not covered)`
|
|
160
|
+
: sp.state === "unknown" ? "unknown (PR file inventory incomplete or unreadable)" : "not required";
|
|
161
|
+
out.push(...pair("security pass", `${shown}${list(sp.companions).length ? `; companions ${list(sp.companions).join(", ")}` : ""}`, columns, 11, sp.state === "required" || sp.state === "unknown" ? "attention" : undefined, " "));
|
|
162
|
+
}
|
|
118
163
|
const e = row.evalGate;
|
|
119
164
|
if (e) {
|
|
120
165
|
const shown = e.state === "not_configured" ? "eval check not configured (suite choice pending the person)" : e.state === "coverage_unknown" ? "PR file coverage unknown" : `${e.check} ${String(e.state)}${e.passRate !== undefined ? `, pass rate ${e.passRate}` : ""}${e.suite !== undefined ? `, suite ${e.suite}` : ""}`;
|
|
@@ -164,6 +209,24 @@ export function renderSdlcQueue(reply: unknown, columns?: number, _now = Date.no
|
|
|
164
209
|
if (list(report.conflicts).length) out.push(blank, ...bullets("file conflicts", list(report.conflicts).map((c: any) => `#${c.left} and #${c.right} share ${plural(c.files ?? 0, "file")} (${c.order === "person_required" ? "the person orders them" : "dependency order"})`), columns, "attention"));
|
|
165
210
|
return out;
|
|
166
211
|
}
|
|
212
|
+
/** One line for the audit's unit states, shared by `audit show` and the release readback. */
|
|
213
|
+
function auditStates(a: any): string {
|
|
214
|
+
const c = a?.counts ?? {};
|
|
215
|
+
return `${c.covered ?? 0} covered${a?.prior ? ` (${a.prior} prior)` : ""}, ${c.deferred ?? 0} deferred, ${c.out_of_scope ?? 0} out of scope, ${c.planned ?? 0} planned`;
|
|
216
|
+
}
|
|
217
|
+
/** `ahub sdlc audit show`: the ledger's counts first, then each unit, then the findings. An open important finding shows its id and status only, unless the caller is the person. */
|
|
218
|
+
export function renderSdlcAudit(reply: unknown, columns?: number, _now = Date.now()): Span[][] {
|
|
219
|
+
const a = (reply as any)?.audit;
|
|
220
|
+
if (!a) return [...heading("Security audit", columns), ...pair("audits", "none started: run ahub sdlc audit start", columns, 10, "muted")];
|
|
221
|
+
const out: Line[] = [...heading(`Security audit ${a.audit} (task #${a.task})`, columns)];
|
|
222
|
+
out.push(...pair("source", `${short(a.ref)}, profile ${a.profile}${a.scoped ? ", scoped" : ""}`, columns, 10), ...pair("coverage", `${a.partial ? "partial: " : ""}${auditStates(a)}`, columns, 10, a.partial || a.counts?.planned ? "attention" : undefined));
|
|
223
|
+
const f = a.findings ?? {};
|
|
224
|
+
out.push(...pair("findings", `${f.verified ?? 0} verified, ${f.candidate ?? 0} candidate (unverified), ${f.needsValidation ?? 0} needs validation, ${f.rejected ?? 0} rejected, ${f.settled ?? 0} settled, ${f.other ?? 0} other`, columns, 10, f.candidate ? "attention" : undefined));
|
|
225
|
+
for (const u of list(a.units)) out.push(...pair(String(u.state).replace("_", " "), `${u.unit}${u.prior ? ` (prior audit ${u.prior.audit})` : ""}${u.reason ? `: ${u.reason}` : ""}`, columns, 14, u.state === "planned" ? "attention" : undefined, " "));
|
|
226
|
+
for (const item of list(a.items)) out.push(...pair(String(item.status), `${item.id} (${item.severity}, ${item.disposition})${item.withheld ? ", details withheld" : item.path ? ` ${item.path}` : ""}`, columns, 14, item.status === "candidate" ? "attention" : undefined, " "));
|
|
227
|
+
if (a.withheld) out.push(...pair("withheld", `${a.withheld} open important finding${a.withheld === 1 ? "" : "s"}: boundary text is shown to the person only`, columns, 10, "muted"));
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
167
230
|
/** `ahub sdlc release <repo> [live-issue...]`: source, document, issue and authorization evidence, then what blocks the release. */
|
|
168
231
|
export function renderSdlcRelease(reply: unknown, columns?: number, now = Date.now()): Span[][] {
|
|
169
232
|
const r = (reply as any)?.report ?? {};
|
|
@@ -185,6 +248,8 @@ export function renderSdlcRelease(reply: unknown, columns?: number, now = Date.n
|
|
|
185
248
|
if (a) out.push(blank, ...pair("authorization", `${a.state}: version ${a.receipt?.version ?? "unknown"} at ${short(a.receipt?.commit)}, approved ${moment(a.receipt?.at, now)}`, columns, w, a.state === "matched" ? "success" : "attention"));
|
|
186
249
|
else out.push(blank, ...pair("authorization", r.releasePolicy ? `none recorded for ${r.releasePolicy.versionSource}: run ahub sdlc authorize-release <version>` : "none recorded: run ahub sdlc authorize-release <version>", columns, w, "muted"));
|
|
187
250
|
for (const t of list(r.trains)) out.push(...pair(`train #${t.release?.id ?? "?"}`, `${t.readiness?.trigger ?? "unknown"}${list(t.readiness?.blockers).length ? `, ${list(t.readiness.blockers).join("; ")}` : ""}`, columns, w, list(t.readiness?.blockers).length ? "attention" : undefined));
|
|
251
|
+
const sa = r.securityAudit;
|
|
252
|
+
if (sa) out.push(blank, ...pair("security audit", `${short(sa.ref)} ${sa.profile}${sa.partial ? " (partial)" : ""}: ${auditStates(sa)}${sa.findings?.candidate ? `, ${sa.findings.candidate} unverified candidate${sa.findings.candidate === 1 ? "" : "s"}` : ""}`, columns, w, sa.partial || sa.counts?.planned ? "attention" : undefined));
|
|
188
253
|
const rm = r.releaseMetrics;
|
|
189
254
|
if (rm) {
|
|
190
255
|
const mean = (values: unknown[]) => { const known = values.filter((v): v is number => typeof v === "number" && Number.isFinite(v)); return known.length ? span(known.reduce((a, b) => a + b, 0) / known.length) : "unknown"; };
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
// macOS script(1) requires a terminal on its own stdin, including when its child gets a PTY.
|
|
2
2
|
// Keep a real PTY in this owned bridge instead; the outer Node child remains tracked by stopOwnedProcess.
|
|
3
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
|
-
* #560: Bun up to 1.4.3
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* real command (same pid, same session, same terminal). The wait has no bound of its own: a bridge that dies before it opens the gate closes the pty, which hangs the shell up (the trap below), and a bridge
|
|
12
|
-
* that is alive but never opens it is a hung bridge, which `runPty` stops with its group.
|
|
13
|
-
* ponytail: ceiling and upgrade path. The gate exists only because of oven-sh/bun#45300 on Bun up to 1.4.3 (this repo pins 1.4.2 in `.bun-version`); the upgrade path is to delete GATE_SCRIPT, `gate` and `gateDir` once the pinned Bun is 1.4.4 or newer, which is its own task because it
|
|
14
|
-
* touches CI and every OS leg. The parent-death stop below stays whatever the Bun version: an orphaned bridge is this repository's bug, not Bun's. The gate costs about one shell start (a few ms).
|
|
5
|
+
* #560: the bridge used to hold its child behind a shell until `Bun.spawn` had returned, because Bun up to 1.4.3 could hang for good inside `Bun.spawn({ terminal })` on macOS when the child wrote and
|
|
6
|
+
* started exiting before the call returned (oven-sh/bun#45300, fixed in 1.4.4; 26 of 96 runs hung at 12 in parallel on 1.4.3 and 0 of 180 on 1.4.4). The repository pins Bun 1.4.4 now (`.bun-version`),
|
|
7
|
+
* so the child starts directly. The parent-death stop below stays whatever the Bun version: an orphaned bridge is this repository's bug, not Bun's.
|
|
15
8
|
*/
|
|
16
|
-
// The shell removes its own gate (file, then directory) once released and when it is hung up or terminated (a bridge killed with SIGKILL runs no cleanup, and the pty closing
|
|
17
|
-
// sends the shell SIGHUP), so no path leaves a directory behind. `exec` resets the traps for the real command.
|
|
18
|
-
const GATE_SCRIPT = 'd=${0%/*}; trap "rm -f \\"$0\\"; rmdir \\"$d\\" 2>/dev/null; exit 125" HUP TERM INT; while [ ! -e "$0" ]; do sleep 0.01; done; rm -f "$0"; rmdir "$d" 2>/dev/null; exec "$@"';
|
|
19
9
|
/** A bridge whose caller died is stopped instead of running on: its child holds a terminal nobody reads and, under launchd, nothing else would ever stop it. */
|
|
20
10
|
const PARENT_POLL_MS = 250;
|
|
21
11
|
const PARENT_TERM_GRACE_MS = 1_000;
|
|
22
12
|
const PARENT_HARD_EXIT_MS = 3_000;
|
|
23
13
|
|
|
24
|
-
// The caller is whoever started this bridge, read before anything that can take time: a caller that dies while `Bun.spawn` runs
|
|
14
|
+
// The caller is whoever started this bridge, read before anything that can take time: a caller that dies while `Bun.spawn` runs has already reparented this process by the
|
|
25
15
|
// time the call returns, and a parent read after it would be launchd and never change.
|
|
26
16
|
const parent = process.ppid;
|
|
27
17
|
const callerGone = (): boolean => process.ppid !== parent;
|
|
@@ -31,11 +21,9 @@ if (!argv.length) {
|
|
|
31
21
|
} else {
|
|
32
22
|
let streamClosed!: () => void;
|
|
33
23
|
const eof = new Promise<void>(resolve => { streamClosed = resolve; });
|
|
34
|
-
const gateDir = process.platform === "darwin" ? mkdtempSync(join(tmpdir(), "ahub-pty-gate-")) : undefined;
|
|
35
|
-
const gate = gateDir ? join(gateDir, "open") : undefined;
|
|
36
24
|
let watch: ReturnType<typeof setInterval> | undefined;
|
|
37
25
|
try {
|
|
38
|
-
const child = Bun.spawn(
|
|
26
|
+
const child = Bun.spawn(argv, {
|
|
39
27
|
cwd: process.cwd(), env: process.env,
|
|
40
28
|
terminal: {
|
|
41
29
|
cols: 120, rows: 40, name: "xterm-256color",
|
|
@@ -52,13 +40,9 @@ if (!argv.length) {
|
|
|
52
40
|
setTimeout(() => { try { child.kill("SIGKILL"); } catch { /* already gone */ } }, PARENT_TERM_GRACE_MS).unref();
|
|
53
41
|
setTimeout(() => process.exit(129), PARENT_HARD_EXIT_MS).unref();
|
|
54
42
|
};
|
|
55
|
-
// A caller that died while Bun.spawn ran
|
|
56
|
-
// Abandoning once is enough: the interval below exists only while the caller is still there, and clears itself the first time it is not.
|
|
43
|
+
// A caller that died while Bun.spawn ran has its child stopped at once. Abandoning once is enough: the interval below exists only while the caller is still there, and clears itself the first time it is not.
|
|
57
44
|
if (callerGone()) abandon();
|
|
58
|
-
else {
|
|
59
|
-
if (gate) writeFileSync(gate, "");
|
|
60
|
-
watch = setInterval(() => { if (callerGone()) abandon(); }, PARENT_POLL_MS);
|
|
61
|
-
}
|
|
45
|
+
else watch = setInterval(() => { if (callerGone()) abandon(); }, PARENT_POLL_MS);
|
|
62
46
|
try {
|
|
63
47
|
const code = await child.exited;
|
|
64
48
|
// Drain the PTY before closing it; a descendant holding a slave cannot make the bridge wait forever.
|
|
@@ -76,7 +60,6 @@ if (!argv.length) {
|
|
|
76
60
|
process.exitCode = 125;
|
|
77
61
|
} finally {
|
|
78
62
|
if (watch) clearInterval(watch);
|
|
79
|
-
if (gateDir) rmSync(gateDir, { recursive: true, force: true });
|
|
80
63
|
}
|
|
81
64
|
}
|
|
82
65
|
export {};
|
package/src/cli/study-output.ts
CHANGED
|
@@ -125,3 +125,57 @@ export function renderExperiments(view: unknown, columns?: number): Span[][] {
|
|
|
125
125
|
for (const row of attempts) if (row.eventsComplete === false && row.nextEventCursor !== undefined) out.push([s(`more events of ${row.id}: ahub study experiments --attempt ${row.id} --events-after ${row.nextEventCursor}; the values above come from the events shown so far`, "attention")]);
|
|
126
126
|
return out;
|
|
127
127
|
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/** Screened passage or declared manifest-authoring metadata, never an entailment/quality claim. */
|
|
131
|
+
export function renderStudyEvidence(value: unknown, columns?: number): Span[][] {
|
|
132
|
+
const v = value as any;
|
|
133
|
+
if (v?.status !== "resolved" && v?.status !== "available") return [[s(`Evidence ${v?.status ?? "unavailable"}; use a visible research task and current public evidence`, "attention")]];
|
|
134
|
+
const out: Span[][] = [...heading(v.status === "resolved" ? `Evidence ${v.id} r${v.revision}` : `Declared evidence inventory, task ${v.taskId}`, columns)];
|
|
135
|
+
if (v.status === "resolved") {
|
|
136
|
+
out.push(...pair("status", "resolved provenance only; no entailment or source-quality certification", columns, 12));
|
|
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
|
+
} else {
|
|
141
|
+
out.push(...pair("incarnation", v.taskCreated, columns, 12));
|
|
142
|
+
for (const artifact of list(v.deliverables)) out.push(...pair("artifact", `${artifact.id} ${artifact.format} ${artifact.sha256}`, columns, 12));
|
|
143
|
+
for (const claim of list(v.claims)) {
|
|
144
|
+
out.push(...pair("claim", `${claim.claimId} @ ${claim.claimRevision}`, columns, 12));
|
|
145
|
+
out.push(...pair("inventory", claim.complete && claim.inventory ? `r${claim.inventory.revision} ${claim.inventory.sha256}` : "unknown/incomplete: obtain complete inventory before checking", columns, 12));
|
|
146
|
+
for (const link of list(claim.evidence)) out.push(...pair("link", `${link.id} r${link.revision} ${link.status}`, columns, 12));
|
|
147
|
+
}
|
|
148
|
+
out.push([s("Declared bindings only. Select citation mappings in a synthesis manifest; invoke ahub study check explicitly.", "muted")]);
|
|
149
|
+
}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const SYNTHESIS_NEXT: Record<string, string> = {
|
|
154
|
+
refresh_manifest: "refresh claim, link, inventory and artifact bindings in the manifest",
|
|
155
|
+
provide_artifact: "register unchanged public Markdown/BibTeX deliverables through the existing deliverable workflow",
|
|
156
|
+
repair_citations: "repair declared Markdown citation keys and their BibTeX entries",
|
|
157
|
+
record_evidence: "record current claim evidence with hub_evidence_record",
|
|
158
|
+
resolve_locator: "inspect ahub study evidence for current public registered projection/locator provenance",
|
|
159
|
+
record_person_judgment: "a person records the claim's verdict with ahub task claim; model labels do not count",
|
|
160
|
+
resolve_contradiction: "a person adjudicates or explicitly qualifies the current manifest-bound conclusion",
|
|
161
|
+
read_complete_inventory: "obtain a complete readable inventory; split oversized tasks or repair stored evidence before retrying",
|
|
162
|
+
complete_manifest_claims: "include every current declared task claim in the manifest",
|
|
163
|
+
};
|
|
164
|
+
export function renderSynthesisReadiness(value: unknown, columns?: number): Span[][] {
|
|
165
|
+
const v = value as any, out: Span[][] = [...heading(`Synthesis ${v?.status ?? "unavailable"}`, columns)];
|
|
166
|
+
if (v?.status === "private") return [...out, [s("Readiness withheld by current task/source/artifact privacy; no research content is disclosed.", "attention")]];
|
|
167
|
+
if (!v?.scope) {
|
|
168
|
+
const reason = v?.cause === "source_input_limit" ? "Source input exceeds this bounded check; split the synthesis into smaller tasks."
|
|
169
|
+
: "Inputs or policy changed/unavailable; refresh current public bindings and run ahub study check again.";
|
|
170
|
+
return [...out, [s(reason, "attention")]];
|
|
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));
|
|
178
|
+
}
|
|
179
|
+
for (const next of list(v.next)) out.push(...pair("next", SYNTHESIS_NEXT[next] ?? "inspect the current manifest bindings", columns, 12, "attention"));
|
|
180
|
+
return out;
|
|
181
|
+
}
|
package/src/cli/study.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// Argument parsing for `ahub study` (#601). Pure: argv in, one request description or a usage line out, so the I/O in main.ts stays a thin dispatcher and every form is testable without a daemon.
|
|
2
|
-
export const STUDY_USAGE = "usage: ahub study draft <parent> <contract.json> | revise <id> <revision> <contract.json> | approve <id> <revision> | approve-protocol <hash> | close <id> <revision> --reason <text> | show [<id> | --after <id>] | experiments (--campaign <id> [--after <n>] | --attempt <ra-id> [--events-after <n>] | --plan <hash> --baseline <ra-id> --variant <ra-id>) [--json] [--color=auto|always|never]";
|
|
2
|
+
export const STUDY_USAGE = "usage: ahub study draft <parent> <contract.json> | revise <id> <revision> <contract.json> | approve <id> <revision> | approve-protocol <hash> | close <id> <revision> --reason <text> | evidence <ev-id> [--revision <n>] | evidence --task <task> | check <task> <manifest.json> | show [<id> | --after <id>] | experiments (--campaign <id> [--after <n>] | --attempt <ra-id> [--events-after <n>] | --plan <hash> --baseline <ra-id> --variant <ra-id>) [--json] [--color=auto|always|never]";
|
|
3
3
|
|
|
4
4
|
export type StudyRequest =
|
|
5
|
+
| { op: "evidence"; id: string; revision?: number }
|
|
6
|
+
| { op: "evidence_inventory"; taskId: number }
|
|
7
|
+
| { op: "check"; taskId: number; file: string }
|
|
5
8
|
| { op: "draft"; parentTaskId: number; file: string }
|
|
6
9
|
| { op: "revise"; id: string; revision: number; file: string }
|
|
7
10
|
| { op: "approve"; id: string; revision: number }
|
|
@@ -18,6 +21,16 @@ export function parseStudyArgs(operands: readonly string[]): StudyRequest | { us
|
|
|
18
21
|
const [sub, ...rest] = operands;
|
|
19
22
|
const id = (value: string | undefined) => value !== undefined && ID.test(value) ? value : undefined;
|
|
20
23
|
const int = (value: string | undefined) => value !== undefined && INT.test(value) ? Number(value) : undefined;
|
|
24
|
+
if (sub === "check") {
|
|
25
|
+
const taskId = int(rest[0]);
|
|
26
|
+
return rest.length === 2 && taskId !== undefined && !!rest[1] ? { op: "check", taskId, file: rest[1] } : usage("check needs a task id and a bounded synthesis manifest file");
|
|
27
|
+
}
|
|
28
|
+
if (sub === "evidence") {
|
|
29
|
+
if (rest[0] === "--task") { const taskId = int(rest[1]); return rest.length === 2 && taskId !== undefined ? { op: "evidence_inventory", taskId } : usage(); }
|
|
30
|
+
const evidence = rest[0], revision = rest.length === 3 && rest[1] === "--revision" ? int(rest[2]) : undefined;
|
|
31
|
+
return evidence !== undefined && /^ev:[a-f0-9]{32}$/.test(evidence) && (rest.length === 1 || rest.length === 3 && revision !== undefined)
|
|
32
|
+
? { op: "evidence", id: evidence, ...(revision === undefined ? {} : { revision }) } : usage("evidence needs a recorded ev:<32 hex> id or --task <task>");
|
|
33
|
+
}
|
|
21
34
|
if (sub === "approve-protocol") {
|
|
22
35
|
if (rest.length !== 1) return usage();
|
|
23
36
|
const hash = rest[0];
|
package/src/cli/task-output.ts
CHANGED
|
@@ -104,6 +104,8 @@ function taskBlock(task: any, columns: number | undefined, now: number, detail:
|
|
|
104
104
|
...pair("class", dash(task?.class), columns, w, undefined, " "), ...pair("owner", taskHolderText(task, "owner"), columns, w, undefined, " "), ...pair("reviewer", taskHolderText(task, "reviewer"), columns, w, undefined, " "));
|
|
105
105
|
if (task?.planner !== undefined) out.push(...pair("planner", taskHolderText(task, "planner"), columns, w, undefined, " "));
|
|
106
106
|
if (task?.reserved) out.push(...pair("reserved", task.reserved, columns, w, undefined, " "));
|
|
107
|
+
// #1454: a recorded wait, with whether it has passed: a passed one means the idle ladder restarts, so it reads as attention.
|
|
108
|
+
if (task?.wait && typeof task.wait.until === "number") out.push(...pair("waiting", `${task.wait.passed ? "passed " : "until "}${new Date(task.wait.until).toISOString()}${task.wait.by ? `, set by ${task.wait.by}` : ""}${task.wait.reason ? `: ${task.wait.reason}` : ""}`, columns, w, task.wait.passed ? "attention" : undefined, " "));
|
|
107
109
|
if (task?.handoffOrigin) out.push(...pair("from", `project ${task.handoffOrigin.projectId}, handed off by ${task.handoffOrigin.peer}${typeof task.handoffOrigin.task === "number" ? ` (their task #${task.handoffOrigin.task})` : ""}`, columns, w, "attention", " "));
|
|
108
110
|
out.push(...pair("after", ids(task?.deps), columns, w, undefined, " "));
|
|
109
111
|
if (typeof task?.release === "number") out.push(...pair("release", `#${task.release}`, columns, w, undefined, " "));
|
|
@@ -177,7 +179,7 @@ export function renderBacklogResult(op: keyof typeof BACKLOG_HEAD, result: unkno
|
|
|
177
179
|
return out;
|
|
178
180
|
}
|
|
179
181
|
|
|
180
|
-
const GROOM_TEXT: Record<string, string> = { "text-dependency": "text names a dependency the card does not declare", overlap: "overlaps other open work", duplicate: "may duplicate another card", "over-wip": "its owner is over the WIP limit", stale: "has not moved for a long time", superseded: "was superseded", blocked: "cannot be routed", "closed-issue": "its issue is closed" };
|
|
182
|
+
const GROOM_TEXT: Record<string, string> = { "text-dependency": "text names a dependency the card does not declare", overlap: "overlaps other open work", duplicate: "may duplicate another card", "over-wip": "its owner is over the WIP limit", stale: "has not moved for a long time", superseded: "was superseded", blocked: "cannot be routed", "closed-issue": "its issue is closed", "wait-passed": "its recorded wait has passed, so the idle sweep runs again: record a new wait or check the owner" };
|
|
181
183
|
/** `ahub backlog groom`: what the planner would look at, one line per finding. */
|
|
182
184
|
export function renderGroom(digest: unknown, columns?: number, _now = Date.now()): Span[][] {
|
|
183
185
|
const d = digest as any;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RecoveryLaunchFailure } from "./recovery-launch.ts";
|
|
1
2
|
import { shellQuote } from "./shell-quote.ts";
|
|
2
3
|
export { shellQuote } from "./shell-quote.ts";
|
|
3
4
|
import { createProjectAdapterCatalog, definitionOf, type ProjectAdapterCatalog, type KindMap } from "../adapters/registry.ts";
|
|
@@ -77,9 +78,11 @@ export interface RecoveryBlocker {
|
|
|
77
78
|
| "terminal-orphaned"
|
|
78
79
|
| "command-error"
|
|
79
80
|
| "ambiguous-create"
|
|
81
|
+
| "launch-failed"
|
|
80
82
|
| "launcher-exited"
|
|
81
83
|
| "terminal-gone";
|
|
82
84
|
message: string;
|
|
85
|
+
failure?: RecoveryLaunchFailure;
|
|
83
86
|
peer?: TerminalPeer;
|
|
84
87
|
handle?: string;
|
|
85
88
|
/** Stable terminal reference when Orca supplied one, for operator reconciliation. */
|
|
@@ -149,6 +152,8 @@ export interface TerminalCreateResult {
|
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
export interface TerminalRecoveryOptions {
|
|
155
|
+
/** Host-owned per-attempt exit observation; diagnostic only, never a readiness proof. */
|
|
156
|
+
launchFailure?: () => RecoveryLaunchFailure | undefined;
|
|
152
157
|
runner?: CommandRunner;
|
|
153
158
|
/** Exact execution root returned by authenticated extra startup; checked against the current declaration. */
|
|
154
159
|
executionCwd?: string;
|
|
@@ -286,6 +291,7 @@ function normalizeOptions(options?: CommandRunner | TerminalRecoveryOptions): Re
|
|
|
286
291
|
const config: TerminalRecoveryOptions = typeof options === "function" ? { runner: options } : options ?? {};
|
|
287
292
|
const orcaExecutable = config.orcaExecutable ?? resolveOrcaExecutable();
|
|
288
293
|
return {
|
|
294
|
+
launchFailure: config.launchFailure ?? (() => undefined),
|
|
289
295
|
runner: config.runner ?? defaultRunner(orcaExecutable),
|
|
290
296
|
orcaExecutable,
|
|
291
297
|
packageEntrypoint: config.packageEntrypoint ?? defaultEntrypoint,
|
|
@@ -666,6 +672,7 @@ function blocker(code: RecoveryBlocker["code"], message: string, peer?: Terminal
|
|
|
666
672
|
code === "ambiguous-create" ? "inspect the existing terminal and attach the original session before resuming" :
|
|
667
673
|
code === "terminal-orphaned" ? `reattach the pane with orca terminal switch --terminal ${shellQuote(handle!)}; then refresh in ahub upgrade ([r] on the plan, [s] on an open operation), or rerun it` :
|
|
668
674
|
code === "terminal-unready" ? "finish or cancel the active terminal turn, then resume recovery" :
|
|
675
|
+
code === "launch-failed" ? "fix the launch refusal, then resume this recovery operation" :
|
|
669
676
|
code === "launcher-exited" ? "the session was not restored; the coordinator's error names the choices" :
|
|
670
677
|
code === "terminal-gone" ? "the terminal was closed; inspect the project's terminals in Orca before resuming recovery" :
|
|
671
678
|
"inspect the named terminal and resume recovery after the identity is verified";
|
|
@@ -990,10 +997,16 @@ export async function createTerminal(binding: TerminalBinding, options?: Command
|
|
|
990
997
|
// incarnation and no recorded launcher may still run. One that never recorded itself is left to the readiness
|
|
991
998
|
// bound and to the coordinator's reconciliation of its pending receipt.
|
|
992
999
|
const exited = (why: string) => ({ created: true, ready: false, manualRequired: true, blockers: [blocker("launcher-exited", `the ${binding.peer} restoration launcher in terminal ${createdHandle} ${why} before its TUI was ready`, binding.peer, createdHandle)] });
|
|
1000
|
+
const failed = () => {
|
|
1001
|
+
const failure = config.launchFailure();
|
|
1002
|
+
return failure ? { created: true, ready: false, manualRequired: true, blockers: [{ ...blocker("launch-failed", `restoration command exited ${failure.exitCode}: ${failure.firstLine}; fix the cause, then resume this recovery operation`, binding.peer, createdHandle), failure }] } : undefined;
|
|
1003
|
+
};
|
|
993
1004
|
const deadline = Date.now() + Math.min(timeoutMs, MAX_WAIT_MS);
|
|
994
1005
|
const slice = () => Math.max(1, Math.min(EXIT_SLICE_MS, deadline - Date.now())); // Orca refuses --timeout-ms 0
|
|
1006
|
+
const earlyFailure = failed(); if (earlyFailure) return earlyFailure;
|
|
995
1007
|
let idle = await waitForIdle(replacement, slice(), config);
|
|
996
1008
|
for (;;) {
|
|
1009
|
+
const failure = failed(); if (failure) return failure;
|
|
997
1010
|
if (idle.blockers[0]?.code === "terminal-gone") {
|
|
998
1011
|
const launch = await launches();
|
|
999
1012
|
if (launch.gone) return exited("exited");
|
|
@@ -1015,6 +1028,7 @@ export async function createTerminal(binding: TerminalBinding, options?: Command
|
|
|
1015
1028
|
// An idle terminal may be the login shell the launcher returned to, or a TUI that has not yet recorded its
|
|
1016
1029
|
// launch or been identified by Orca (#599): poll until it maps, contradicts, or the deadline passes.
|
|
1017
1030
|
for (;;) {
|
|
1031
|
+
const failure = failed(); if (failure) return failure;
|
|
1018
1032
|
const launch = await launches();
|
|
1019
1033
|
if (launch.gone) return exited("exited");
|
|
1020
1034
|
const shown = await showBinding(replacement, config);
|