@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/adapters/jcode.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ActivityTable } from "./definitions/native-activity.ts";
|
|
1
2
|
import { spawn, spawnSync, type ChildProcess } from "node:child_process";
|
|
2
3
|
import { assessVersion, COMPAT, type CompatVerdict } from "./compat.ts";
|
|
3
4
|
import { createConnection } from "node:net";
|
|
@@ -95,6 +96,13 @@ export class JcodeTuiRefusal extends Error {
|
|
|
95
96
|
}
|
|
96
97
|
/** #1085: said by `ahub status` while a recovered headless Jcode has not yet opened its TUI, and by the launcher when `ahub jcode` finds it running headless. */
|
|
97
98
|
export const JCODE_HEADLESS_AFTER_RECOVERY = "jcode is running headless after recovery; run ahub stop jcode, then ahub jcode to get its TUI back";
|
|
99
|
+
/**
|
|
100
|
+
* #1668: what `ahub status` says while a rostered Jcode peer's socket is served by a server the hub did not start, handed to the daemon by the hello that
|
|
101
|
+
* admission refused. It names the cause class and the launch that puts the peer back under the hub, and carries no launch id, socket or path.
|
|
102
|
+
*/
|
|
103
|
+
export function jcodeDetachedNotice(peer: string): { cause: string; command: string } {
|
|
104
|
+
return { cause: "a Jcode server the hub did not start is serving this peer's socket, so its work continues outside the hub", command: peer === "jcode" ? "ahub jcode" : `ahub jcode --as ${peer}` };
|
|
105
|
+
}
|
|
98
106
|
const JCODE_OWNED_ENV = { JCODE_DISABLE_CLAUDE_MCP: "1", JCODE_NO_TELEMETRY: "1" } as const;
|
|
99
107
|
/** #691: the verdict lives in `src/adapters/compat.ts` (line, verified versions, the person's trust); never pin here. */
|
|
100
108
|
export const jcodeVersionSupported = (version: unknown): boolean => assessVersion("jcode", version).ok;
|
|
@@ -219,7 +227,7 @@ export class JcodePeer extends AcpPeer {
|
|
|
219
227
|
/** #1085: a ready TUI launch was served for this owned launch, so the person is on the way to its TUI. */
|
|
220
228
|
private tuiServed = false;
|
|
221
229
|
|
|
222
|
-
constructor(private readonly jcode: JcodeOptions) {
|
|
230
|
+
constructor(private readonly jcode: JcodeOptions, activityKinds?: ActivityTable) {
|
|
223
231
|
if (!isAbsolute(jcode.home)) throw new Error("jcode_home must be an absolute native data path");
|
|
224
232
|
const peer = jcode.peer ?? "jcode";
|
|
225
233
|
jcodeCommand(jcode.command, "acp", "preview", jcode.cwd);
|
|
@@ -229,7 +237,7 @@ export class JcodePeer extends AcpPeer {
|
|
|
229
237
|
const launchId = crypto.randomUUID();
|
|
230
238
|
// The ACP child gets peerChildEnv(this.id): the instance id, so its hub tools act as this peer and never as the base Jcode. The launch id
|
|
231
239
|
// goes with it: the daemon admits a hub-tools hello for this peer only when it carries the id of this peer's current owned launch (#368).
|
|
232
|
-
super(peer, { ...jcode, cmd, env: { ...jcode.env, JCODE_HOME: jcode.home, JCODE_SOCKET: socket, AGENTHUB_LAUNCH_ID: launchId, ...JCODE_OWNED_ENV }, mcpServers: [], preamble: jcodePreamble(jcode.preamble), requireLoadSessionEcho: true, expectedAgent: { name: "jcode", version: jcodeVersionSupported } });
|
|
240
|
+
super(peer, { ...jcode, cmd, env: { ...jcode.env, JCODE_HOME: jcode.home, JCODE_SOCKET: socket, AGENTHUB_LAUNCH_ID: launchId, ...JCODE_OWNED_ENV }, mcpServers: [], preamble: jcodePreamble(jcode.preamble), requireLoadSessionEcho: true, expectedAgent: { name: "jcode", version: jcodeVersionSupported } }, activityKinds);
|
|
233
241
|
this.root = root; this.socket = socket; this.launchId = launchId;
|
|
234
242
|
}
|
|
235
243
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LOCAL_ACTIVITY, nativeActivity } from "./definitions/native-activity.ts";
|
|
1
2
|
import type { ModelOverrideSelection } from "./registry-types.ts";
|
|
2
3
|
import { isNativeModelToken } from "./model-token.ts";
|
|
3
4
|
import { isReviewObserverExcluded, reviewCaptureExcluded } from "../hub/memory-policy.ts";
|
|
@@ -511,6 +512,7 @@ export class LocalPeer extends BasePeer {
|
|
|
511
512
|
// A tool has its own timeout (bash up to 600 s) and an approval can take 120 s: neither is the model going silent.
|
|
512
513
|
const alive = this.probeConfinement ? undefined : setInterval(() => this.state === "busy" && turn === this.turn && this.touch(), 30_000);
|
|
513
514
|
const name = call.function.name;
|
|
515
|
+
if (!this.probeConfinement) this.onActivity?.(nativeActivity(LOCAL_ACTIVITY, name, TASK_TOOL_NAMES.has(name) || CONDUCTOR_TOOL_NAMES.has(name) ? "hub" : "unknown"));
|
|
514
516
|
try {
|
|
515
517
|
await this.requireBudget(envs, "tool_calls");
|
|
516
518
|
if (turnSignal.aborted) throw new ExecutionBudgetStop(this.budgetStopReason || "turn cancelled before tool execution");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ConfiguredPrintOptions } from "./configured-print.ts";
|
|
1
2
|
/** One host-latched runtime choice; applied binds the captured revision and boundary, never a later value. */
|
|
2
3
|
export interface ModelOverrideSelection {
|
|
3
4
|
readonly model: string | undefined;
|
|
@@ -32,7 +33,7 @@ import type { BuiltinCliEntry } from "./definitions/native-cli-entry-types.ts";
|
|
|
32
33
|
import type { NativePreviewBuilder } from "./definitions/native-cli-preview-common.ts";
|
|
33
34
|
|
|
34
35
|
export type StartForm = "tui" | "headless";
|
|
35
|
-
export type DaemonEngine = "codex-appserver" | "acp" | "qwen-dual" | "owned-acp" | "pi-rpc" | "local-worker" | "claude-print" | "reviewer-print" | "claude-implementer";
|
|
36
|
+
export type DaemonEngine = "codex-appserver" | "acp" | "qwen-dual" | "owned-acp" | "pi-rpc" | "local-worker" | "claude-print" | "reviewer-print" | "claude-implementer" | "configured-print";
|
|
36
37
|
|
|
37
38
|
/** Existing buildLaunch inputs plus the startup-bound instance and project identity. */
|
|
38
39
|
export interface LaunchContext {
|
|
@@ -76,7 +77,8 @@ export type DaemonPorts =
|
|
|
76
77
|
| { local: LocalOptions }
|
|
77
78
|
| { claudePrint: ClaudePrintOptions }
|
|
78
79
|
| { reviewerPrint: ReviewerPrintOptions }
|
|
79
|
-
| { claudeImplementer: ClaudeImplementerOptions }
|
|
80
|
+
| { claudeImplementer: ClaudeImplementerOptions }
|
|
81
|
+
| { configuredPrint: Omit<ConfiguredPrintOptions, "declaration"> };
|
|
80
82
|
|
|
81
83
|
export interface CreateContext<Ports extends DaemonPorts = DaemonPorts> {
|
|
82
84
|
instance: string;
|
|
@@ -239,7 +241,7 @@ export interface AdapterDefinition {
|
|
|
239
241
|
ownedFlags: readonly string[];
|
|
240
242
|
conductorStartArgs?(args: string[]): { mode?: StartForm } | Error;
|
|
241
243
|
};
|
|
242
|
-
identity: { mcp: "acp-session" | "project-file" | "env" | "channel-plugin"; currentChild?: true };
|
|
244
|
+
identity: { mcp: "acp-session" | "project-file" | "env" | "channel-plugin" | "none"; currentChild?: true };
|
|
243
245
|
/** Who owns the session title; only hub-owned slots receive hub_set_title. */
|
|
244
246
|
title?: "native" | "hub";
|
|
245
247
|
/** Fixed builtins only: the title slot survives native-session restoration. Absent means ephemeral. */
|
|
@@ -38,6 +38,7 @@ export function roleEligibility(peer: string, role: EligibleRole, startMode?: St
|
|
|
38
38
|
*/
|
|
39
39
|
export function adapterCeiling(peer: string, declared: readonly string[], catalog?: ProjectAdapterCatalog): string[] {
|
|
40
40
|
const definition = lookup(peer, catalog), ceiling = definition?.routing?.allowedRoles;
|
|
41
|
+
if (definition?.start.daemonPort === "configured-print") return declared.filter(role => role === "advisor" || role === "reviewer");
|
|
41
42
|
return declared.filter(role => (!ceiling || ceiling.includes(role)) && (role !== "planner" || !definition || definition.projection?.plannerEligible === true));
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -47,6 +48,10 @@ export function adapterCeiling(peer: string, declared: readonly string[], catalo
|
|
|
47
48
|
*/
|
|
48
49
|
export function applyRoleCeiling(peer: string, declared: readonly string[], startMode: StartMode | undefined, catalog?: ProjectAdapterCatalog): { roles: string[]; notices: string[] } {
|
|
49
50
|
const definition = lookup(peer, catalog), ceiling = definition?.routing?.allowedRoles;
|
|
51
|
+
if (definition?.start.daemonPort === "configured-print") {
|
|
52
|
+
const roles = adapterCeiling(peer, declared, catalog);
|
|
53
|
+
return { roles, notices: roles.length === declared.length ? [] : [`roles.${peer}: configured print keeps advisory roles only`] };
|
|
54
|
+
}
|
|
50
55
|
const notices: string[] = [];
|
|
51
56
|
const roles = declared.filter(role => {
|
|
52
57
|
if (ceiling && !ceiling.includes(role)) return false;
|
package/src/cli/bench.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { processSignature } from "../pi/process-signature.ts";
|
|
|
13
13
|
import { loadConfig } from "../hub/daemon.ts";
|
|
14
14
|
import { addonState, detectTooling, type Addon, type AddonName } from "../hub/tooling.ts";
|
|
15
15
|
import { VERSION } from "../version.ts";
|
|
16
|
+
import { warnLine } from "./warn-line.ts";
|
|
16
17
|
|
|
17
18
|
/** What the runner needs from the world, so tests can drive it without a terminal. */
|
|
18
19
|
export interface BenchIo {
|
|
@@ -65,7 +66,7 @@ export const defaultIo = (stateDir: string, cwd: string, peer?: string): BenchIo
|
|
|
65
66
|
// ours) is the group killed outright; any other refusal (not provably ours, an unreadable process table) leaves
|
|
66
67
|
// it alone and says so. A leader start-time record at spawn would let stopOwnedProcess sweep it itself.
|
|
67
68
|
if (/still has members \(/.test(error.message)) try { process.kill(-p.pid!, "SIGKILL"); } catch { /* gone */ }
|
|
68
|
-
else
|
|
69
|
+
else warnLine(`bench: a command's process group could not be stopped and may still run in the tree: ${error.message}`);
|
|
69
70
|
});
|
|
70
71
|
return { code: timedOut || interrupted ? null : code ?? null, timedOut, interrupted };
|
|
71
72
|
},
|
package/src/cli/broker.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { join, resolve } from "node:path";
|
|
|
3
3
|
import { BrokerStore, BrokerStoreError } from "../broker/store.ts";
|
|
4
4
|
import { decodeBase64url, RoomCryptoError } from "../rooms/crypto.ts";
|
|
5
5
|
import { startBroker, BrokerServerError, type BrokerOptions } from "../broker/server.ts";
|
|
6
|
+
import { warnLine } from "./warn-line.ts";
|
|
6
7
|
|
|
7
8
|
export const BROKER_USAGE = "usage: ahub broker serve [--hostname <host>] [--port <0..65535>] [--public-url <ws[s]://host/>] [--owner <fingerprint>]... [--state-dir <dir>] | broker room drop <room> --yes [--state-dir <dir>]";
|
|
8
9
|
export function brokerOptions(args: readonly string[], stateDir: string): BrokerOptions {
|
|
@@ -45,7 +46,7 @@ export async function runBrokerCommand(args: readonly string[], stateDir: string
|
|
|
45
46
|
const options = brokerOptions(args, stateDir);
|
|
46
47
|
const broker = await startBroker(options);
|
|
47
48
|
console.log(`broker listening at ${broker.publicUrl} (ciphertext relay; application delivery is not acknowledged here)`);
|
|
48
|
-
const stop = () => { void broker.stop().catch(() => { process.exitCode = 1;
|
|
49
|
+
const stop = () => { void broker.stop().catch(() => { process.exitCode = 1; warnLine("broker: stop failed"); }); };
|
|
49
50
|
process.once("SIGINT", stop); process.once("SIGTERM", stop);
|
|
50
51
|
try { await broker.closed; }
|
|
51
52
|
finally { process.off("SIGINT", stop); process.off("SIGTERM", stop); }
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
// Human output for `ahub capabilities` (#445 C1). Pure: parsed hub-tool JSON in, spans out, no I/O. `--json` is the caller's branch and prints the same text.
|
|
2
2
|
// A description is another agent's words: the daemon has already sanitized it, and it is shown here as data on its own row, never as part of a command line.
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
3
|
+
import { grid, s } from "./sdlc-output.ts";
|
|
4
|
+
import { Report, plural, type Span } from "./console-state.ts";
|
|
5
5
|
|
|
6
6
|
const list = (value: unknown): any[] => Array.isArray(value) ? value : [];
|
|
7
7
|
const dash = (value: unknown) => value === undefined || value === null || value === "" ? "-" : String(value);
|
|
8
8
|
const STATE_TONE: Record<string, "attention" | "muted" | undefined> = { listed: undefined, "digest-changed": "attention", unshared: "muted" };
|
|
9
9
|
|
|
10
10
|
/** `ahub capabilities`: per peer, each capability the hub can see, whether you share it, and the class that would apply to a call. */
|
|
11
|
-
export function renderCapabilities(result: unknown, columns?: number): Span[][] {
|
|
11
|
+
export function renderCapabilities(result: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
12
12
|
const peers = list((result as { peers?: unknown } | null)?.peers);
|
|
13
|
-
const out
|
|
14
|
-
if (!peers.length)
|
|
15
|
-
out.push(blank, [s("no peer lists a capability: an agent must be attached, on a version the hub has probed, and offer a skill or command", "muted")]);
|
|
16
|
-
return out;
|
|
17
|
-
}
|
|
13
|
+
const out = new Report(columns, ascii).titled("ahub", `Capabilities: ${plural(peers.length, "peer")} listing`);
|
|
14
|
+
if (!peers.length) return out.note("no peer lists a capability: an agent must be attached, on a version the hub has probed, and offer a skill or command").lines();
|
|
18
15
|
for (const peer of peers) {
|
|
19
16
|
const entries = list(peer.entries);
|
|
20
17
|
const shared = entries.filter(entry => entry.state === "listed").length;
|
|
21
|
-
out.
|
|
22
|
-
out.
|
|
18
|
+
out.section(dash(peer.peer), String(entries.length)).kv([["found", String(entries.length)], ["shared", String(shared)], ["mode", dash(peer.permission_mode)]]);
|
|
19
|
+
if (entries.length) out.append(grid(["ID", "STATE", "CLASS", "SOURCE", "DIGEST"], entries.map((entry: any) => [
|
|
23
20
|
s(dash(entry.id)), s(dash(entry.state), STATE_TONE[String(entry.state)]), s(dash(entry.class), entry.class === "destructive" ? "attention" : undefined), s(`${dash(entry.source)}/${dash(entry.invoke)}`), s(dash(entry.digest)),
|
|
24
21
|
]), columns));
|
|
25
|
-
const
|
|
26
|
-
for (const entry of stale) out.push(...pair("changed", `${dash(entry.id)} no longer matches its pinned digest and is unlisted until you pin the new one`, columns, 8, "attention"));
|
|
22
|
+
for (const entry of entries.filter(item => item.state === "digest-changed")) out.bullet("warn", `changed: ${dash(entry.id)} no longer matches its pinned digest and is unlisted until you pin the new one`);
|
|
27
23
|
}
|
|
28
|
-
out.
|
|
29
|
-
return out;
|
|
24
|
+
out.note("Share an entry by adding its digest under invocation.share.<peer> in .agenthub/config.local.json (this machine only). A class you set can only raise the one the source declared. An entry with no class anywhere counts as destructive and is refused.");
|
|
25
|
+
return out.lines();
|
|
30
26
|
}
|
|
@@ -8,7 +8,8 @@ import { configuredAcpPreview } from "./preview.ts";
|
|
|
8
8
|
export interface ConfiguredAcpSelection { peer: string; mode: "headless"; sessionId?: string; preview: boolean }
|
|
9
9
|
export function parseConfiguredAcpArguments(kind: string, raw: readonly string[], catalog: ProjectAdapterCatalog, instances?: InstancesConfig, declaredExternalInstances: readonly DeclaredExternalInstance[] = []): ConfiguredAcpSelection {
|
|
10
10
|
const definition = catalog.definitionOf(kind);
|
|
11
|
-
|
|
11
|
+
const print = definition?.start.daemonPort === "configured-print";
|
|
12
|
+
if (!print && !definition?.permission.genericAcp && !declaredExternalInstances.some(row => row.kind === kind)) throw new Error("unknown configured ACP kind");
|
|
12
13
|
const values = new Map<string, string>();
|
|
13
14
|
let preview = false;
|
|
14
15
|
for (let index = 0; index < raw.length; index++) {
|
|
@@ -20,6 +21,7 @@ export function parseConfiguredAcpArguments(kind: string, raw: readonly string[]
|
|
|
20
21
|
if (!value || value.startsWith("--") || Buffer.byteLength(value) > 4096 || /[\p{Cc}\p{Cf}]/u.test(value)) throw new Error(`${flag} needs a bounded control-free value`);
|
|
21
22
|
values.set(flag, value);
|
|
22
23
|
}
|
|
24
|
+
if (print && (values.has("--session-id") || values.has("--as"))) throw new Error("configured print accepts only headless mode and preview; it has no instances or sessions");
|
|
23
25
|
if (values.has("--mode") && values.get("--mode") !== "headless") throw new Error("configured ACP supports headless only");
|
|
24
26
|
const peer = values.get("--as") ?? kind;
|
|
25
27
|
const executable = !!instances && Object.hasOwn(instances, peer) && instances[peer]?.kind === kind && !!catalog.definitionOf(peer, instances);
|
|
@@ -64,12 +66,18 @@ export async function runConfiguredAcpEntry(context: {
|
|
|
64
66
|
connect(): Promise<ConfiguredAcpControl>; print(text: string): void; operationId?: string;
|
|
65
67
|
}): Promise<void> {
|
|
66
68
|
const selected = parseConfiguredAcpArguments(context.kind, context.raw, context.catalog, context.instances, context.declaredExternalInstances);
|
|
67
|
-
|
|
69
|
+
const print = context.catalog.definitionOf(context.kind)?.start.daemonPort === "configured-print";
|
|
70
|
+
if (selected.preview) {
|
|
71
|
+
const preview = configuredAcpPreview(context.kind, selected.peer, selected.sessionId !== undefined);
|
|
72
|
+
context.print(JSON.stringify(print ? { ...preview, needs: ["A trusted config.local.json declaration and a running hub with configured_print support."] } : preview, null, 2));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
68
75
|
const hub = await context.connect();
|
|
69
76
|
try {
|
|
70
77
|
const external = selected.peer !== context.kind && (context.declaredExternalInstances?.some(row => row.id === selected.peer && row.kind === context.kind)
|
|
71
78
|
|| context.catalog.externalDefinitions.some(definition => definition.kind === context.kind));
|
|
72
79
|
if (external && !context.projectRoot) throw new Error("external instance start requires the canonical project root");
|
|
80
|
+
if (print && !hub.features.includes("configured_print")) throw new Error("running hub lacks configured_print; upgrade and restart it first");
|
|
73
81
|
await requireActiveConfiguredAcp(hub, context.kind, selected.peer, context.print, external ? { projectRoot: context.projectRoot! } : undefined);
|
|
74
82
|
const reply = await hub.request({ t: "start", peer: selected.peer, args: { mode: "headless", ...(selected.sessionId ? { sessionId: selected.sessionId } : {}) }, ...(context.operationId ? { operationId: context.operationId } : {}) }, 70_000);
|
|
75
83
|
if (!reply.ok) throw new Error(typeof reply.error === "string" ? reply.error : "configured ACP start refused");
|
package/src/cli/console-state.ts
CHANGED
|
@@ -256,6 +256,19 @@ export class Report {
|
|
|
256
256
|
this.out.push(...new SharedReport(this.columns, this.ascii).header(tool, name, context).lines());
|
|
257
257
|
return this;
|
|
258
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* #1654 AC3: the one header-fit rule. The header line does not wrap, so a name that fits the terminal stays in it and a longer
|
|
261
|
+
* one moves to a wrapped line under a short header. `context` follows the name after two spaces in `hint`; with `inline` it
|
|
262
|
+
* joins the name by one space (`Merge queue owner/repo`) and moves in `value`. A name too wide for any header keeps its first
|
|
263
|
+
* word there and repeats in full on the wrapped line. No wrap width means no moving.
|
|
264
|
+
*/
|
|
265
|
+
titled(tool: string, name: string, context?: string, inline = false): this {
|
|
266
|
+
const fits = (text: string) => this.columns === undefined || cellWidth(` ${tool} ${text}`) <= this.columns;
|
|
267
|
+
const joined = !context ? name : inline ? `${name} ${context}` : `${name} ${context}`;
|
|
268
|
+
if (fits(joined)) return inline && context ? this.header(tool, joined) : this.header(tool, name, context || undefined);
|
|
269
|
+
if (context && fits(name)) return this.header(tool, name).note(context, inline ? "value" : "hint");
|
|
270
|
+
return this.header(tool, name.split(" ")[0]!).note(joined, "value");
|
|
271
|
+
}
|
|
259
272
|
/** One blank line, then `▸ <Name>` (ASCII `> <Name>`) in `section`, with an optional count in `hint`. */
|
|
260
273
|
section(name: string, count?: string): this {
|
|
261
274
|
if (this.out.length && this.out.at(-1)!.length) this.push([]);
|
|
@@ -266,16 +279,23 @@ export class Report {
|
|
|
266
279
|
* Key/value rows of one section: two-space indent, `Key:` padded to the widest key, two spaces, value. A key wider than 28 cells
|
|
267
280
|
* puts its value on the next line at a four-space indent. An empty value is `(unset)` in `hint`.
|
|
268
281
|
*/
|
|
269
|
-
kv(rows: readonly (readonly [string, unknown])[], indent = 2): this {
|
|
270
|
-
const
|
|
282
|
+
kv(rows: readonly (readonly [string, unknown])[], indent = 2, options: { colon?: boolean } = {}): this {
|
|
283
|
+
const suffix = options.colon === false ? "" : ":";
|
|
284
|
+
const keys = rows.map(([key]) => cellWidth(`${terminalText(key)}${suffix}`));
|
|
271
285
|
const pad = Math.max(0, ...keys.filter(width => width <= 28));
|
|
272
286
|
for (const [index, [key, raw]] of rows.entries()) {
|
|
273
|
-
const label = `${terminalText(key)}
|
|
287
|
+
const label = `${terminalText(key)}${suffix}`, text = terminalText(raw ?? "").trim();
|
|
274
288
|
const value = (line: string): Span => text ? { text: line, role: "value" } : { text: "(unset)", role: "hint" };
|
|
275
289
|
const lead = " ".repeat(indent);
|
|
276
|
-
|
|
290
|
+
// a terminal too narrow to leave 10 cells beside the label stacks the value under its key, like a key wider than 28
|
|
291
|
+
// stacked when fewer than 10 cells remain beside the label, or when the value's longest word does not fit there
|
|
292
|
+
const longest = Math.max(0, ...text.split(/\s+/).map(word => cellWidth(word)));
|
|
293
|
+
const narrow = keys[index]! <= 28 && this.columns !== undefined && (indent + pad + 2 + 10 > this.columns || longest > this.columns - indent - pad - 2 && longest <= this.columns - indent);
|
|
294
|
+
if (keys[index]! > 28 || narrow) {
|
|
295
|
+
// a terminal too narrow for the label column keeps the value at the key's own indent, so a long word is not broken by the hang
|
|
296
|
+
const hang = narrow ? 0 : 2;
|
|
277
297
|
this.push([{ text: `${lead}${label}`, role: "key" }]);
|
|
278
|
-
for (const line of text ? this.fit(text, (this.columns ?? 0) - indent -
|
|
298
|
+
for (const line of text ? this.fit(text, (this.columns ?? 0) - indent - hang) : [""]) this.push([{ text: `${lead}${" ".repeat(hang)}` }, value(line)]);
|
|
279
299
|
continue;
|
|
280
300
|
}
|
|
281
301
|
const gap = " ".repeat(pad - keys[index]! + 2), room = (this.columns ?? 0) - indent - pad - 2;
|
package/src/cli/error-format.ts
CHANGED
|
@@ -17,3 +17,5 @@ export function errorLines(message: string, next: string | undefined, terminal:
|
|
|
17
17
|
const first = terminal ? `${MARKERS.fail[ascii ? "ascii" : "glyph"]} ${line}` : line;
|
|
18
18
|
return next ? [first, ` ${MARKERS.next[ascii ? "ascii" : "glyph"]} ${terminalText(next)}`] : [first];
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
export { warningLines } from "./warn-line.ts";
|
package/src/cli/guidance.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { GUIDANCE_HASH_HEX_LENGTH, GUIDANCE_CURSOR_MAX_BYTES, parseGuidanceWrite
|
|
|
3
3
|
import { guidanceLines, guidanceReceiptLines } from "../ui/guidance-view.ts";
|
|
4
4
|
import { terminalText } from "./console-state.ts";
|
|
5
5
|
|
|
6
|
-
export const GUIDANCE_USAGE = "usage: ahub guidance create --file
|
|
6
|
+
export const GUIDANCE_USAGE = "usage: ahub guidance create --file <file> [--json] | list --task <n> --task-created <ms> [--cursor <token>] [--json] | show --task <n> --task-created <ms> --id <hash> [--json] | withdraw --task <n> --task-created <ms> --revision <r> --id <hash> [--json]";
|
|
7
7
|
type Create = { op: "create"; json: boolean; file: string };
|
|
8
8
|
type List = { op: "list"; json: boolean; taskId: number; taskCreated: number; cursor?: string };
|
|
9
9
|
type Show = { op: "show"; json: boolean; taskId: number; taskCreated: number; id: string };
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
// Human output for `ahub task handoff` and `ahub board --handoffs` (#604, agent-hub#1030). 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
|
// Only ids, states and counts are shown: the title of a handed-off task is the caller's own and was bounded and sanitized by the hub.
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
3
|
+
import { grid, s } from "./sdlc-output.ts";
|
|
4
|
+
import { Report, type Span, type Tone } from "./console-state.ts";
|
|
5
5
|
|
|
6
6
|
const STATE_TONE: Record<string, Tone | undefined> = { approved: undefined, cancelled: "muted", declined: "attention", proposed: "attention" };
|
|
7
7
|
const num = (value: unknown): string => typeof value === "number" && Number.isSafeInteger(value) ? String(value) : "-";
|
|
8
8
|
|
|
9
9
|
/** The receipt of one handoff: where the task now lives and what to run to follow it. */
|
|
10
|
-
export function renderHandoffReceipt(receipt: unknown, columns?: number): Span[][] {
|
|
10
|
+
export function renderHandoffReceipt(receipt: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
11
11
|
const r = receipt as any;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const out = new Report(columns, ascii).titled("ahub", "Handed off to project", String(r?.project ?? "?"), true);
|
|
13
|
+
out.section("Receipt").kv([["task", `#${num(r?.task)} (${r?.state ?? "proposed"})`]]);
|
|
14
|
+
out.note("it is on that project's board as an ownerless proposal; its own roles plan, implement and review it, and you are told when it changes state");
|
|
15
|
+
out.note("ahub board --handoffs shows the last state it reported");
|
|
16
|
+
return out.lines();
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/** What this project handed to others, with the last state each target reported. */
|
|
19
|
-
export function renderHandoffs(data: unknown, columns?: number): Span[][] {
|
|
20
|
+
export function renderHandoffs(data: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
20
21
|
const rows: any[] = Array.isArray((data as any)?.handoffs) ? (data as any).handoffs : [];
|
|
21
22
|
if (!rows.length) return [[s("no handoffs: hand work that belongs to another project with `ahub task handoff --project <root|id> <title...>`", "muted")]];
|
|
23
|
+
const out = new Report(columns, ascii).titled("ahub", `Handoffs (${rows.length})`);
|
|
22
24
|
// #734: a row from a hub that has no age or reach (an older daemon) shows "-" for both, never a guess.
|
|
23
|
-
const reach = (row: any):
|
|
25
|
+
const reach = (row: any): ReturnType<typeof s> => {
|
|
24
26
|
const word = row.reach === "reachable" || row.reach === "unreachable" || row.reach === "moved" ? row.reach : undefined;
|
|
25
27
|
if (word === undefined) return s("-", "muted");
|
|
26
|
-
return s(word
|
|
28
|
+
return s(word, word === "reachable" ? "success" : "attention");
|
|
27
29
|
};
|
|
28
30
|
const down = rows.filter(row => row.reach === "unreachable" || row.reach === "moved" ? typeof row.cause === "string" : false);
|
|
29
|
-
|
|
31
|
+
out.section("Handed off", String(rows.length)).append(grid(["PROJECT", "TASK", "STATE", "AGE", "REACH", "PR", "BY", "TITLE"], rows.map(row => [
|
|
30
32
|
s(String(row.remoteProject ?? "?").slice(0, 24), "issueRef"), s(`#${num(row.remoteTask)}`, "taskRef"), s(String(row.state ?? "?"), STATE_TONE[row.state]),
|
|
31
33
|
s(typeof row.age === "string" ? row.age : "-", "muted"), reach(row),
|
|
32
|
-
s(typeof row.pr === "number" ? `#${row.pr}` : "-"), s(String(row.originPeer ?? "?")), s(String(row.title ?? ""))]), columns)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
s(typeof row.pr === "number" ? `#${row.pr}` : "-"), s(String(row.originPeer ?? "?")), s(String(row.title ?? ""))]), columns));
|
|
35
|
+
// The cause of each unreachable or moved target, once per target and with its next step, so the column stays narrow and the person still learns what to run.
|
|
36
|
+
for (const [project, cause] of new Map(down.map(row => [String(row.remoteProject), String(row.cause)])).entries()) out.bullet("warn", `${String(project).slice(0, 24)}: ${cause.slice(0, 200)}`);
|
|
37
|
+
// A sync that did not finish in time: the pass keeps running, so the list above is the state so far and the person is told what to run to read the rest.
|
|
38
|
+
if (typeof (data as any)?.cause === "string" && (data as any)?.synced === false) out.bullet("warn", String((data as any).cause));
|
|
39
|
+
if ((data as any)?.syncing === true) out.bullet("warn", `catch-up still running for ${num((data as any).pending)} target${(data as any).pending === 1 ? "" : "s"}: run \`ahub task handoff --list\` in a minute`);
|
|
40
|
+
return out.lines();
|
|
38
41
|
}
|