@staix/agent-hub 0.50.0 → 0.52.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 +51 -0
- package/README.md +1 -1
- package/docs/adding-an-ai-tool.md +26 -4
- package/docs/agent-notes/README.md +1 -0
- package/docs/agent-notes/adapters.md +4 -3
- package/docs/agent-notes/budget.md +8 -2
- package/docs/agent-notes/daemon.md +13 -8
- package/docs/agent-notes/local-worker.md +3 -3
- package/docs/agent-notes/security-review.md +6 -5
- package/docs/agent-notes/tasks.md +10 -3
- package/docs/agent-notes/tests.md +4 -3
- package/docs/cooperbench.md +1 -1
- package/docs/design/adapters.md +21 -0
- package/docs/design/cli-output-inventory.md +165 -150
- package/docs/design/cli-output.md +4 -3
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/roadmap.md +3 -1
- package/docs/design/task-board.md +35 -0
- package/docs/dogfood.md +21 -3
- package/docs/events.md +4 -2
- package/docs/memory.md +5 -3
- package/docs/operations.md +259 -19
- package/docs/quickstart.md +29 -2
- package/docs/roadmap.json +20 -20
- package/docs/roadmap.md +2 -2
- package/docs/roles.md +1 -1
- package/docs/sdlc.md +29 -5
- package/docs/security.md +11 -5
- package/docs/specs/2026-09-19-agent-hub-design.md +44 -0
- package/docs/specs/2026-09-19-multi-project-design.md +4 -0
- package/docs/specs/2026-09-20-upgrade-recovery-design.md +17 -0
- package/docs/specs/mcp-endpoint.md +63 -0
- package/docs/verification/2026-11-29-agy-1.5.20.md +33 -0
- package/docs/verification/2026-11-29-claude-profile-hook.md +12 -0
- package/docs/verification/2026-11-29-idle-daemon-footprint.md +75 -0
- package/docs/verification/2026-11-29-kimi-281-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-29-kimi-tui-281.md +12 -0
- package/docs/verification/2026-11-30-0.51.0.md +91 -0
- package/docs/verification/2026-11-30-account-switch-1806.md +445 -0
- package/docs/verification/2026-11-30-capability-listing-shape-1808.md +45 -0
- package/docs/verification/2026-11-30-upgrade-keep-1807.md +174 -0
- package/docs/verification/2026-12-01-1811-confirmation-receipt.md +19 -0
- package/docs/verification/2026-12-01-1811-orca-agent-list.md +20 -0
- package/docs/verification/2026-12-01-1811-orca-pane-key.md +21 -0
- package/docs/verification/2026-12-02-1819-claude-process-after-renewal.md +54 -0
- package/docs/verification/2026-12-02-agy-1.5.21.md +74 -0
- package/docs/verification/2026-12-02-claude-implementer-2.1.334.md +44 -0
- package/docs/verification/2026-12-02-cli-import-graph.md +33 -0
- package/docs/verification/2026-12-03-0.52.0.md +150 -0
- package/docs/verification/2026-12-03-codex-0173-reviewer-isolation.md +53 -0
- package/docs/verification/2026-12-03-codex-0173-reviewer-tool-call.md +34 -0
- package/docs/verification/2026-12-03-jcode-1.3.0.md +25 -0
- package/docs/verification/agy/README.md +17 -0
- package/docs/verification/agy/cli-surface.ts +68 -0
- package/docs/verification/agy/interactive-bridge.ts +92 -0
- package/docs/verification/agy/interactive-session.ts +131 -0
- package/docs/verification/agy/launcher-nonce.ts +215 -0
- package/docs/verification/agy/native-hooks.ts +210 -0
- package/docs/verification/agy/originals/agent-hub-681/cli-surface.ts +87 -0
- package/docs/verification/agy/originals/agent-hub-681/native-hooks-adapted.ts +91 -0
- package/docs/verification/agy/originals/agent-hub-681/tui-actual.ts +200 -0
- package/docs/verification/agy/originals/agent-hub-684/probe.ts +107 -0
- package/docs/verification/agy/originals.json +25 -0
- package/docs/verification/agy/permission-new-functions.ts +128 -0
- package/docs/verification/agy/run-probe.py +108 -0
- package/docs/verification/agy/runtime.ts +171 -0
- package/docs/verification/agy/tmux-helper-control.ts +6 -0
- package/docs/verification/agy/tmux-session.ts +235 -0
- package/docs/verified.json +87 -42
- package/package.json +3 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/compat.json +157 -0
- package/plugins/agent-hub/kimi-hook.js +1416 -24985
- package/plugins/agent-hub/server.js +17415 -32755
- package/scripts/check-docs.mjs +1 -1
- package/src/adapters/acp.ts +13 -13
- package/src/adapters/agy/definition.ts +9 -26
- package/src/adapters/agy/entry.ts +2 -0
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel-evidence.ts +7 -3
- package/src/adapters/claude-channel.ts +38 -257
- package/src/adapters/claude-implementer.ts +3 -1
- package/src/adapters/codex-appserver.ts +77 -15
- package/src/adapters/compat.ts +78 -14
- package/src/adapters/configured-acp.ts +23 -163
- package/src/adapters/configured-adapter-policy.ts +160 -0
- package/src/adapters/configured-pull-entry.ts +53 -0
- package/src/adapters/configured-pull.ts +38 -0
- package/src/adapters/conformance/fakes/app-server.ts +9 -2
- package/src/adapters/declaration-catalog.ts +25 -0
- package/src/adapters/declaration-data.ts +342 -0
- package/src/adapters/declaration-resolution.ts +53 -0
- package/src/adapters/definitions/builtin-metadata.ts +62 -84
- package/src/adapters/definitions/jcode-launch.ts +13 -0
- package/src/adapters/definitions/native-adapter-policy.ts +390 -0
- package/src/adapters/definitions/native-cli-claude-launch.ts +6 -3
- package/src/adapters/definitions/native-cli-codex-launch.ts +2 -1
- package/src/adapters/definitions/native-cli-entry-claude.ts +17 -2
- package/src/adapters/definitions/native-cli-entry-codex.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-jcode.ts +6 -2
- package/src/adapters/definitions/native-cli-entry-kimi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-pi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-qwen.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-types.ts +12 -3
- package/src/adapters/definitions/native-cli-jcode-home-init.ts +1 -1
- package/src/adapters/definitions/native-cli-launch-common.ts +2 -2
- package/src/adapters/definitions/native-cli-preview-common.ts +1 -1
- package/src/adapters/definitions/native-cli-retained.ts +1 -1
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-configuration.ts +18 -0
- package/src/adapters/definitions/native-help.ts +24 -0
- package/src/adapters/definitions/native-launch-declarations.ts +34 -0
- package/src/adapters/definitions/native-launch-policy.ts +4 -0
- package/src/adapters/definitions/native-launch-settings.ts +72 -0
- package/src/adapters/definitions/native-light-cli.ts +18 -0
- package/src/adapters/definitions/native-light-preview.ts +10 -0
- package/src/adapters/definitions/native-wrapper-launch.ts +10 -0
- package/src/adapters/definitions/qwen.ts +6 -29
- package/src/adapters/definitions/reviewer-variants.ts +7 -8
- package/src/adapters/external-declarations.ts +31 -0
- package/src/adapters/external-modules.ts +4 -29
- package/src/adapters/jcode.ts +19 -12
- package/src/adapters/native-capabilities.ts +18 -8
- package/src/adapters/native-facts-hooks.ts +12 -0
- package/src/adapters/native-proof-ports.ts +1 -1
- package/src/adapters/presets.ts +136 -0
- package/src/adapters/qwen-dual.ts +2 -2
- package/src/adapters/registry-types.ts +3 -0
- package/src/adapters/registry.ts +20 -81
- package/src/adapters/reviewer-print.ts +26 -9
- package/src/adapters/role-eligibility.ts +2 -1
- package/src/cli/accounts-import.ts +72 -0
- package/src/cli/agents-latest-table.ts +88 -0
- package/src/cli/agents-latest.ts +22 -0
- package/src/cli/agents-output.ts +10 -0
- package/src/cli/agents-presets.ts +100 -0
- package/src/cli/agents.ts +1 -1
- package/src/cli/attention.ts +3 -2
- package/src/cli/autonomy-homes.ts +7 -2
- package/src/cli/autonomy-offline.ts +1 -1
- package/src/cli/bench.ts +1 -1
- package/src/cli/budget-renew-guidance.ts +129 -0
- package/src/cli/claude-homes.ts +9 -5
- package/src/cli/claude-profile-hook.ts +31 -11
- package/src/cli/command-context.ts +3 -0
- package/src/cli/command-table.ts +123 -0
- package/src/cli/commands/accounts.ts +8 -0
- package/src/cli/commands/agents.ts +18 -0
- package/src/cli/commands/answer.ts +28 -0
- package/src/cli/commands/ask.ts +17 -0
- package/src/cli/commands/autonomy.ts +83 -0
- package/src/cli/commands/backlog.ts +46 -0
- package/src/cli/commands/bench.ts +60 -0
- package/src/cli/commands/board.ts +48 -0
- package/src/cli/commands/broker.ts +9 -0
- package/src/cli/commands/budget.ts +96 -0
- package/src/cli/commands/capabilities.ts +12 -0
- package/src/cli/commands/check-path.ts +55 -0
- package/src/cli/commands/completion.ts +8 -0
- package/src/cli/commands/console.ts +12 -0
- package/src/cli/commands/daemon.ts +8 -0
- package/src/cli/commands/deliverables.ts +25 -0
- package/src/cli/commands/doctor.ts +249 -0
- package/src/cli/commands/down.ts +3 -0
- package/src/cli/commands/export.ts +15 -0
- package/src/cli/commands/facts.ts +15 -0
- package/src/cli/commands/goal.ts +22 -0
- package/src/cli/commands/guidance.ts +102 -0
- package/src/cli/commands/help.ts +17 -0
- package/src/cli/commands/host.ts +45 -0
- package/src/cli/commands/init.ts +121 -0
- package/src/cli/commands/instructed.ts +19 -0
- package/src/cli/commands/instruction-hook.ts +15 -0
- package/src/cli/commands/intake.ts +24 -0
- package/src/cli/commands/kill.ts +15 -0
- package/src/cli/commands/learn.ts +23 -0
- package/src/cli/commands/lineage.ts +30 -0
- package/src/cli/commands/logs.ts +21 -0
- package/src/cli/commands/manager.ts +15 -0
- package/src/cli/commands/memory.ts +21 -0
- package/src/cli/commands/model.ts +25 -0
- package/src/cli/commands/models.ts +40 -0
- package/src/cli/commands/native.ts +39 -0
- package/src/cli/commands/pause.ts +5 -0
- package/src/cli/commands/peer.ts +32 -0
- package/src/cli/commands/permission.ts +26 -0
- package/src/cli/commands/permit.ts +12 -0
- package/src/cli/commands/pet.ts +24 -0
- package/src/cli/commands/projects.ts +49 -0
- package/src/cli/commands/queue.ts +70 -0
- package/src/cli/commands/recovery-run.ts +13 -0
- package/src/cli/commands/recovery.ts +130 -0
- package/src/cli/commands/release.ts +23 -0
- package/src/cli/commands/releases.ts +91 -0
- package/src/cli/commands/remember.ts +6 -0
- package/src/cli/commands/report.ts +27 -0
- package/src/cli/commands/research.ts +53 -0
- package/src/cli/commands/reset.ts +89 -0
- package/src/cli/commands/restart.ts +5 -0
- package/src/cli/commands/results.ts +31 -0
- package/src/cli/commands/resume.ts +5 -0
- package/src/cli/commands/review.ts +24 -0
- package/src/cli/commands/roadmap.ts +21 -0
- package/src/cli/commands/role.ts +34 -0
- package/src/cli/commands/roles.ts +30 -0
- package/src/cli/commands/room.ts +14 -0
- package/src/cli/commands/roster.ts +48 -0
- package/src/cli/commands/route.ts +9 -0
- package/src/cli/commands/say.ts +21 -0
- package/src/cli/commands/schedule.ts +17 -0
- package/src/cli/commands/sdlc.ts +321 -0
- package/src/cli/commands/settings.ts +148 -0
- package/src/cli/commands/setup.ts +89 -0
- package/src/cli/commands/shared-refusals.ts +25 -0
- package/src/cli/commands/smoke.ts +44 -0
- package/src/cli/commands/source.ts +64 -0
- package/src/cli/commands/specs.ts +13 -0
- package/src/cli/commands/status.ts +28 -0
- package/src/cli/commands/stop.ts +17 -0
- package/src/cli/commands/structure.ts +60 -0
- package/src/cli/commands/study.ts +39 -0
- package/src/cli/commands/tail.ts +19 -0
- package/src/cli/commands/task.ts +114 -0
- package/src/cli/commands/title.ts +17 -0
- package/src/cli/commands/turns.ts +10 -0
- package/src/cli/commands/ui.ts +47 -0
- package/src/cli/commands/undo.ts +77 -0
- package/src/cli/commands/up.ts +39 -0
- package/src/cli/commands/upgrade.ts +5 -0
- package/src/cli/commands/usage.ts +33 -0
- package/src/cli/commands/version.ts +5 -0
- package/src/cli/commands/watch.ts +30 -0
- package/src/cli/commands/worktrees.ts +31 -0
- package/src/cli/conductor-recovery.ts +1 -1
- package/src/cli/console-state.ts +5 -138
- package/src/cli/console-versions.ts +1 -1
- package/src/cli/facts-hook.ts +11 -4
- package/src/cli/help.ts +44 -20
- package/src/cli/identity.ts +27 -4
- package/src/cli/init-prompt.ts +1 -1
- package/src/cli/init-settings.ts +4 -35
- package/src/cli/init.ts +1 -1
- package/src/cli/json-text-spans.ts +57 -0
- package/src/cli/launch-check.ts +156 -0
- package/src/cli/launch.ts +19 -70
- package/src/cli/light-dispatch.ts +29 -0
- package/src/cli/main.js +8 -1
- package/src/cli/main.ts +257 -2799
- package/src/cli/memory.ts +1 -1
- package/src/cli/orca-probe.ts +119 -0
- package/src/cli/output.ts +45 -3
- package/src/cli/preview.ts +11 -6
- package/src/cli/recovery-launch.ts +1 -1
- package/src/cli/recovery-version-preflight.ts +28 -9
- package/src/cli/replace-process.ts +22 -0
- package/src/cli/report-layout.ts +142 -0
- package/src/cli/roadmap-usage.ts +16 -0
- package/src/cli/roadmap.ts +3 -16
- package/src/cli/sdlc-doctor.ts +27 -0
- package/src/cli/sdlc-output.ts +55 -1
- package/src/cli/setup-homes.ts +2 -2
- package/src/cli/start-agents-run.ts +85 -7
- package/src/cli/start-check.ts +28 -0
- package/src/cli/statusline-tee.ts +25 -4
- package/src/cli/terminal-recovery.ts +53 -10
- package/src/cli/upgrade-interactive.ts +1 -0
- package/src/cli/upgrade-runtime.ts +12 -1
- package/src/cli/upgrade.ts +4 -15
- package/src/cli/warn-line.ts +1 -1
- package/src/hub/accounts.ts +148 -0
- package/src/hub/addons.ts +20 -0
- package/src/hub/agent-drift.ts +2 -1
- package/src/hub/budget-projection.ts +39 -7
- package/src/hub/budget.ts +231 -16
- package/src/hub/channel-project.ts +3 -3
- package/src/hub/ci-watch.ts +311 -79
- package/src/hub/conductor-peer.ts +24 -0
- package/src/hub/conductor.ts +2 -21
- package/src/hub/config-apply.ts +25 -14
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +2 -0
- package/src/hub/config.ts +535 -0
- package/src/hub/control-client.ts +49 -1
- package/src/hub/daemon.ts +492 -569
- package/src/hub/delivery-public.ts +11 -0
- package/src/hub/events.ts +3 -0
- package/src/hub/home-tag.ts +12 -0
- package/src/hub/host.ts +217 -0
- package/src/hub/hub-check.ts +125 -0
- package/src/hub/hub-tools.ts +2 -1
- package/src/hub/instance-budget.ts +2 -2
- package/src/hub/instance-config.ts +15 -126
- package/src/hub/instances.ts +22 -6
- package/src/hub/instruction-receipt.ts +2 -2
- package/src/hub/kimi-usage.ts +38 -11
- package/src/hub/lifecycle.ts +86 -4
- package/src/hub/mcp-bridge-core.ts +98 -0
- package/src/hub/mcp-channel-push.ts +20 -0
- package/src/hub/mcp-endpoint-serve.ts +178 -0
- package/src/hub/mcp-endpoint.ts +226 -0
- package/src/hub/mcp-tool-call.ts +181 -0
- package/src/hub/operational-settings.ts +2 -0
- package/src/hub/orca-env.ts +6 -0
- package/src/hub/orca-state.ts +84 -0
- package/src/hub/path-policy.ts +1 -1
- package/src/hub/peers.ts +5 -1
- package/src/hub/permission-mode.ts +5 -41
- package/src/hub/permission-paths.ts +41 -0
- package/src/hub/project.ts +20 -0
- package/src/hub/protocol-window.ts +58 -0
- package/src/hub/quota-origin.ts +20 -0
- package/src/hub/recovery-policy.ts +1 -1
- package/src/hub/registry.ts +36 -2
- package/src/hub/releases-inventory.ts +198 -0
- package/src/hub/report.ts +1 -1
- package/src/hub/research.ts +1 -1
- package/src/hub/review-brief.ts +47 -2
- package/src/hub/roster.ts +6 -3
- package/src/hub/routing.ts +9 -2
- package/src/hub/runtime-capture-prune.ts +25 -3
- package/src/hub/runtime-prune-health.ts +8 -1
- package/src/hub/sdlc-check.ts +205 -0
- package/src/hub/sdlc-release-authorization.ts +42 -21
- package/src/hub/sdlc-release-diagnostics.ts +5 -0
- package/src/hub/sdlc-release-policy.ts +21 -7
- package/src/hub/sdlc-release.ts +80 -20
- package/src/hub/sdlc-sync.ts +146 -0
- package/src/hub/sdlc.ts +38 -5
- package/src/hub/settings.ts +7 -4
- package/src/hub/start-agents.ts +1 -1
- package/src/hub/start-mode.ts +11 -4
- package/src/hub/structure-budget.ts +131 -0
- package/src/hub/structure-scan.ts +149 -0
- package/src/hub/tasks-experiment.ts +455 -0
- package/src/hub/tasks-guidance.ts +606 -0
- package/src/hub/tasks-roadmap-plan.ts +419 -0
- package/src/hub/tasks-roadmap.ts +491 -0
- package/src/hub/tasks-study.ts +661 -0
- package/src/hub/tasks-survey.ts +192 -0
- package/src/hub/tasks.ts +457 -2584
- package/src/hub/terminal-open.ts +5 -3
- package/src/hub/tooling.ts +3 -19
- package/src/hub/usage-rollup.ts +9 -3
- package/src/local/tools.ts +5 -0
- package/src/ui/index.html +1 -1
- package/src/ui/needs.ts +17 -5
- package/src/ui/peer-palette.ts +2 -4
- package/src/ui/plugin.ts +1 -1
- package/templates/presets/agents.json +60 -0
- package/templates/presets/confirmation-matrix.json +8 -8
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { loadRoleCatalog } from "../../hub/roles.ts";
|
|
2
|
+
import { type SettingRow } from "../../hub/settings.ts";
|
|
3
|
+
import { paint } from "../console-state.ts";
|
|
4
|
+
import type { CommandContext } from "../command-context.ts";
|
|
5
|
+
|
|
6
|
+
export async function run(context: CommandContext) {
|
|
7
|
+
const { args, connect, cwd, peerDefinition, requireNamedPeerFeature, takeFlags } = context;
|
|
8
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
9
|
+
const catalog = loadRoleCatalog(cwd);
|
|
10
|
+
if (args[0] === "list") {
|
|
11
|
+
const { one, rest } = takeFlags(args.slice(1), ["--group"], []);
|
|
12
|
+
if (rest.length) fail("usage: ahub role list [--group <group>]");
|
|
13
|
+
return console.log(paint([{ text: JSON.stringify({ roles: [...catalog.roles.values()].filter(role => !one["--group"] || role.group === one["--group"]).map(({ body: _body, review: _review, ...role }) => role), errors: catalog.errors }, null, 2) }], false));
|
|
14
|
+
}
|
|
15
|
+
if (args[0] === "show" && args.length === 2) {
|
|
16
|
+
const role = catalog.roles.get(args[1]!); if (!role) fail("unknown catalog role; run ahub role list");
|
|
17
|
+
return console.log(paint([{ text: JSON.stringify(role, null, 2) }], false));
|
|
18
|
+
}
|
|
19
|
+
if (["assign", "clear"].includes(args[0] ?? "")) {
|
|
20
|
+
const [op, peer, id] = args;
|
|
21
|
+
if (!peer || !peerDefinition(peer) || !id && op === "assign" || args.length > 3) fail("usage: ahub role assign <peer> <id> | clear <peer> [<id>]");
|
|
22
|
+
const hub = await connect();
|
|
23
|
+
try {
|
|
24
|
+
requireNamedPeerFeature(hub, peer);
|
|
25
|
+
const view = await hub.request({ t: "settings_get" }); if (!view.ok) fail(view.error);
|
|
26
|
+
const row = (view.rows as SettingRow[]).find(row => row.key === `catalog_roles.${peer}`); if (!row) fail("this hub does not support catalog role settings");
|
|
27
|
+
const current = Array.isArray(row!.pending) ? row!.pending : Array.isArray(row!.value) ? row!.value : [];
|
|
28
|
+
const value = op === "assign" ? [...new Set([...current, id!])] : id ? current.filter(role => role !== id) : [];
|
|
29
|
+
const reply = await hub.request({ t: "settings_set", key: row!.key, value }); if (!reply.ok) fail(reply.error); console.log(reply.text);
|
|
30
|
+
} finally { hub.close(); }
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
fail("usage: ahub role list [--group <group>] | show <id> | assign <peer> <id> | clear <peer> [<id>]");
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { hubGitSync } from "../../hub/git.ts";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { ControlClient } from "../../hub/control-client.ts";
|
|
5
|
+
import { projectContext, realPath } from "../../hub/project.ts";
|
|
6
|
+
import { renderRoles, rolesView } from "../output.ts";
|
|
7
|
+
import type { CommandContext } from "../command-context.ts";
|
|
8
|
+
|
|
9
|
+
export async function run(context: CommandContext) {
|
|
10
|
+
const { connect, cwd, identity, outputArguments, outputOptions, printOutput, stateDir } = context;
|
|
11
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
12
|
+
const options = outputOptions();
|
|
13
|
+
if (outputArguments().length) fail("usage: ahub roles [--json]");
|
|
14
|
+
// A task worktree has no .agenthub of its own, and projectContext deliberately never joins it to the main checkout's hub (#604). This read changes nothing,
|
|
15
|
+
// so a linked worktree with no hub of its own reads the main worktree's hub, under the same identity.
|
|
16
|
+
let target = { root: cwd, stateDir };
|
|
17
|
+
if (!existsSync(join(cwd, ".agenthub"))) {
|
|
18
|
+
const common = hubGitSync(["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd, encoding: "utf8", timeout: 3000 });
|
|
19
|
+
const main = common.status === 0 ? dirname(common.stdout.trim()) : undefined;
|
|
20
|
+
if (main && realPath(main) !== cwd && existsSync(join(main, ".agenthub"))) target = projectContext(main);
|
|
21
|
+
}
|
|
22
|
+
const hub = target.root === cwd ? await connect() : await ControlClient.connect(target.stateDir, identity.role === "tools"
|
|
23
|
+
? { role: "tools", peer: identity.peer, projectRoot: target.root } : { role: "console", projectRoot: target.root }, 3000);
|
|
24
|
+
try {
|
|
25
|
+
const { status } = await hub.request({ t: "status" });
|
|
26
|
+
const view = rolesView(status);
|
|
27
|
+
if (options.json) return console.log(JSON.stringify(view, null, 2));
|
|
28
|
+
printOutput(renderRoles(view, options.columns), options.color);
|
|
29
|
+
} finally { hub.close(); }
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LIVE_TEST_PERSON_REFUSAL } from "../identity.ts";
|
|
2
|
+
import { asciiMarkers } from "../console-state.ts";
|
|
3
|
+
import type { CommandContext } from "../command-context.ts";
|
|
4
|
+
|
|
5
|
+
export async function run(context: CommandContext) {
|
|
6
|
+
const { args, connect, liveTest, outputOptions } = context;
|
|
7
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
8
|
+
if (liveTest && !["list", "status"].includes(args[0] ?? "")) fail(LIVE_TEST_PERSON_REFUSAL);
|
|
9
|
+
const { runRoomCommand, roomCommandError } = await import("../room.ts");
|
|
10
|
+
const hub = await connect();
|
|
11
|
+
try { const look = outputOptions([]); await runRoomCommand(args, message => hub.request(message), undefined, { columns: look.columns, color: look.color, ascii: asciiMarkers(process.env, false) }); }
|
|
12
|
+
catch (error) { fail(roomCommandError(error)); }
|
|
13
|
+
finally { hub.close(); }
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { staleInstanceKey } from "../../hub/roster.ts";
|
|
2
|
+
import { shellQuote } from "../shell-quote.ts";
|
|
3
|
+
import { loadConfig } from "../../hub/config.ts";
|
|
4
|
+
import { rosterPreflight, rosterPreflightLines } from "../../adapters/definitions/native-cli-jcode-home-init.ts";
|
|
5
|
+
import { createInterface } from "node:readline/promises";
|
|
6
|
+
import { renderRoster } from "../output.ts";
|
|
7
|
+
import type { CommandContext } from "../command-context.ts";
|
|
8
|
+
|
|
9
|
+
export async function run(context: CommandContext) {
|
|
10
|
+
const { args, connect, cwd, outputArguments, outputOptions, peerDefinition, printOutput, projectCatalog, requireNamedPeerFeature } = context;
|
|
11
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
12
|
+
const options = outputOptions(), flags = args.filter(arg => arg.startsWith("--")), positional = outputArguments().filter(arg => arg !== "--yes" && arg !== "--now");
|
|
13
|
+
const [sub = "list", peer, ...extra] = positional;
|
|
14
|
+
if (!["list", "add", "remove"].includes(sub) || extra.length || (sub === "list" ? peer !== undefined : !peerDefinition(peer) && !(sub === "remove" && typeof peer === "string" && staleInstanceKey(peer, projectCatalog))) || flags.some(flag => !["--json", "--full", "--yes", "--now"].includes(flag) && !flag.startsWith("--color=")) || (sub !== "list" && options.json) || (sub === "list" && flags.some(flag => ["--yes", "--now"].includes(flag))) || (sub === "add" && flags.includes("--now"))) fail("usage: ahub roster [--json] | add <peer> [--yes] | remove <peer> [--yes] [--now]");
|
|
15
|
+
const hub = await connect();
|
|
16
|
+
try {
|
|
17
|
+
requireNamedPeerFeature(hub, peer);
|
|
18
|
+
const request = async (message: Record<string, unknown>) => { const reply = await hub.request(message, 35_000); if (reply.ok !== true) fail(String(reply.error ?? "roster request refused"),reply.refusalAudited===true,reply.authorityRefused); return reply; };
|
|
19
|
+
if (sub === "list") {
|
|
20
|
+
const view = await request({ t: "settings_get" });
|
|
21
|
+
if (!Array.isArray(view.roster)) fail("upgrade the running hub to use ahub roster");
|
|
22
|
+
return options.json ? console.log(JSON.stringify(view.roster, null, 2)) : printOutput(renderRoster(view.roster, options.columns), options.color);
|
|
23
|
+
}
|
|
24
|
+
// A key whose instance is no longer declared is deleted (null), never set to false: there is no peer left for it to switch off (#225).
|
|
25
|
+
const key = `roster.${peer}`, stale = sub === "remove" && !peerDefinition(peer) && staleInstanceKey(peer!, projectCatalog), value = stale ? null : sub === "add";
|
|
26
|
+
const preview = await request({ t: "settings_preview", key, value });
|
|
27
|
+
printOutput((preview.lines ?? []).map((text: string) => [{ text }]), options.color);
|
|
28
|
+
// #1627 B: adding a peer shows what it would start with, and asks first. Without a terminal and without --yes nothing is changed; a conductor that passes --yes keeps today's authority.
|
|
29
|
+
if (sub === "add") {
|
|
30
|
+
const config = loadConfig(cwd), kind = peerDefinition(peer)?.kind ?? peer!;
|
|
31
|
+
printOutput(rosterPreflightLines(peer!, rosterPreflight(peer!, kind, cwd, config, process.env)).map(text => [{ text }]), options.color);
|
|
32
|
+
if (!flags.includes("--yes")) {
|
|
33
|
+
if (!process.stdin.isTTY) fail(`not a terminal: nothing was changed; rerun with: cd ${shellQuote(cwd)} && ahub roster add ${peer} --yes`);
|
|
34
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
35
|
+
let answer: string; try { answer = await rl.question(`Add ${peer} to the roster? [y/N] `); } finally { rl.close(); }
|
|
36
|
+
if (!/^(y|yes)$/i.test(answer.trim())) return console.log("nothing was changed");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (sub === "remove" && !flags.includes("--yes")) {
|
|
40
|
+
if (!process.stdin.isTTY) fail("not a terminal: nothing was changed; rerun with --yes after reviewing the preview");
|
|
41
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
42
|
+
let answer: string; try { answer = await rl.question(`Remove ${peer}? [y/N] `); } finally { rl.close(); }
|
|
43
|
+
if (!/^(y|yes)$/i.test(answer.trim())) return console.log("nothing was changed");
|
|
44
|
+
}
|
|
45
|
+
const result = await request({ t: "settings_set", key, value, ...(sub === "remove" ? { confirm: peer, now: flags.includes("--now") } : {}) });
|
|
46
|
+
printOutput([[{ text: result.text }]], options.color);
|
|
47
|
+
} finally { hub.close(); }
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandContext } from "../command-context.ts";
|
|
2
|
+
|
|
3
|
+
export async function run(context: CommandContext) {
|
|
4
|
+
const { args, takeFlags, taskOp } = context;
|
|
5
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
6
|
+
if (args[0] !== "explain") fail("usage: ahub route explain <id> | --class <class> <title...>");
|
|
7
|
+
const flags = takeFlags(args.slice(1), ["--class"], []);
|
|
8
|
+
console.log(await taskOp("route_explain", flags.one["--class"] ? { class: flags.one["--class"], title: flags.rest.join(" ") } : { id: flags.rest[0] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { sayRecipients } from "../say-input.ts";
|
|
2
|
+
import { freeText } from "../free-text.ts";
|
|
3
|
+
import { paint } from "../console-state.ts";
|
|
4
|
+
import type { CommandContext } from "../command-context.ts";
|
|
5
|
+
|
|
6
|
+
export async function run(context: CommandContext) {
|
|
7
|
+
const { args, connect } = context;
|
|
8
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
9
|
+
let addressed: ReturnType<typeof sayRecipients>;
|
|
10
|
+
try { addressed = sayRecipients(args); } catch (error) { return fail((error as Error).message); }
|
|
11
|
+
const { to, text } = addressed;
|
|
12
|
+
const body = text.length ? freeText(text, "ahub say [@peer ...] <text>") : "";
|
|
13
|
+
const hub = await connect();
|
|
14
|
+
const res = await hub.request({ t: "send", body, to });
|
|
15
|
+
hub.close();
|
|
16
|
+
if (!res.ok) fail(res.error);
|
|
17
|
+
if (res.recorded) return console.log("recorded only ([FYI]); no peer was interrupted");
|
|
18
|
+
if (res.dropped === "hop") return console.log(res.notice);
|
|
19
|
+
console.log(paint([{ text: res.targets.length ? `queued for: ${res.targets.join(", ")}` : "no peers attached; nothing delivered" }], false));
|
|
20
|
+
if (typeof res.notice === "string" && res.notice) console.log(paint([{ text: res.notice }], false));
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { renderScheduleChange, renderScheduleList, renderScheduleRun } from "../schedule-output.ts";
|
|
2
|
+
import type { CommandContext } from "../command-context.ts";
|
|
3
|
+
|
|
4
|
+
export async function run(context: CommandContext) {
|
|
5
|
+
const { args, outputOptions, showToolText, splitPresentation, taskOp } = context;
|
|
6
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
7
|
+
// #335 (#512 AC3 and AC4): the person's schedule commands; #933: run, pause and resume are the configured conductor's too, admitted and audited by the daemon.
|
|
8
|
+
// The hub keeps the schedules, their periods and the pause; this process only asks.
|
|
9
|
+
const split = splitPresentation(args);
|
|
10
|
+
const present = outputOptions(split.flags); // before any request: an invalid --color must refuse before a mutation is sent
|
|
11
|
+
const [sub, id, ...extra] = split.operands;
|
|
12
|
+
const usage = "usage: ahub schedule list | run <id> | pause <id> | resume <id> [--json] [--color=auto|always|never]";
|
|
13
|
+
if (sub === "list" && id === undefined) return showToolText((data, _c, now, ascii) => renderScheduleList(data, present.columns, now, ascii), await taskOp("schedule_list", {}), present);
|
|
14
|
+
if (!["run", "pause", "resume"].includes(sub ?? "") || !id || extra.length) return fail(usage);
|
|
15
|
+
if (sub === "run") return showToolText((data, _c, now, ascii) => renderScheduleRun(data, present.columns, now, ascii), await taskOp("schedule_run", { id }, false, undefined, 90_000), present);
|
|
16
|
+
return showToolText((data, _c, now, ascii) => renderScheduleChange(sub as "pause" | "resume", data, present.columns, now, ascii), await taskOp(sub === "pause" ? "schedule_pause" : "schedule_resume", { id }), present);
|
|
17
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { roadmapWorktree, writeRoadmap as writeRoadmap_ } from "../roadmap-write.ts";
|
|
2
|
+
import { loadConfig } from "../../hub/config.ts";
|
|
3
|
+
import { sdlcCheckExitCode } from "../../hub/sdlc-check.ts";
|
|
4
|
+
import { hubGitSync, hubGitEnv } from "../../hub/git.ts";
|
|
5
|
+
import { parseReleaseGuardArgv, parseReleasePushUpdates } from "../sdlc-release-guard.ts";
|
|
6
|
+
import { validReleaseVersion } from "../../hub/sdlc-release-authorization.ts";
|
|
7
|
+
import { ControlClient } from "../../hub/control-client.ts";
|
|
8
|
+
import { asciiMarkers } from "../console-state.ts";
|
|
9
|
+
import { renderTaskShow } from "../task-output.ts";
|
|
10
|
+
import { SURVEY_FOCUS } from "../../hub/advisor-survey.ts";
|
|
11
|
+
import { renderAuthorization, renderSdlcCosts, renderSdlcExplain, renderSdlcMerge, renderSdlcMetrics, renderSdlcQueue, renderSdlcRelease, renderSdlcStatus, renderSdlcAudit, renderSdlcCheck, renderSdlcConfiguration, renderSdlcSync, renderSdlcSurvey, renderSdlcReceipt, renderSdlcReadback, renderSdlcTrain } from "../sdlc-output.ts";
|
|
12
|
+
import type { CommandContext, SdlcReceiptOutput } from "../command-context.ts";
|
|
13
|
+
|
|
14
|
+
export async function run(context: CommandContext, receiptOutput?: SdlcReceiptOutput) {
|
|
15
|
+
const { SDLC_READ, connect, cwd, outputArguments, outputOptions, printOutput, sdlcOperands, showToolText, splitPresentation, takeFlags, taskOp } = context;
|
|
16
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
17
|
+
const args = sdlcOperands(), present = SDLC_READ.includes(args[0] ?? "") ? outputOptions() : undefined;
|
|
18
|
+
/** The human form (#814). Each site keeps its own `if (present.json) console.log(JSON.stringify(...))`, so the JSON branch stays visible to the guard test. */
|
|
19
|
+
const human = (render: Parameters<typeof showToolText>[0], data: unknown, display = present ?? outputOptions([])) =>
|
|
20
|
+
printOutput(render(data, display.columns, Date.now(), asciiMarkers(process.env, process.argv.includes("--ascii"))), display.color);
|
|
21
|
+
const receipt = (title: string, ...lines: string[]) => human(renderSdlcReceipt, { title, lines });
|
|
22
|
+
const toolReport = async (render: Parameters<typeof showToolText>[0], result: Promise<string>) => showToolText(render, await result, outputOptions([]));
|
|
23
|
+
const sub = args[0], id = args[1] === undefined ? undefined : Number(args[1]);
|
|
24
|
+
if (sub === "configure") {
|
|
25
|
+
const parsed = takeFlags(args.slice(1), ["--mode", "--required-checks"], []);
|
|
26
|
+
if (parsed.rest.length || !Object.keys(parsed.one).length || ["--mode", "--required-checks"].some(flag => args.filter(arg => arg === flag).length > 1)
|
|
27
|
+
|| parsed.one["--mode"] !== undefined && !["off", "advise"].includes(parsed.one["--mode"]))
|
|
28
|
+
fail("usage: ahub sdlc configure [--mode off|advise] [--required-checks check,lint]");
|
|
29
|
+
const hub = await connect();
|
|
30
|
+
try {
|
|
31
|
+
const result = await hub.request({ t: "sdlc", op: "configure", instructionClaim: true,
|
|
32
|
+
...(parsed.one["--mode"] === undefined ? {} : { mode: parsed.one["--mode"] }),
|
|
33
|
+
...(parsed.one["--required-checks"] === undefined ? {} : { required_checks: parsed.one["--required-checks"] === "" ? [] : parsed.one["--required-checks"].split(",").map(name => name.trim()) }) });
|
|
34
|
+
if (!result.ok) fail(/unknown SDLC operation|does not know/.test(String(result.error)) ? "running hub does not support instructed SDLC configuration; upgrade and restart it first" : result.error);
|
|
35
|
+
const { rid: _transportId, ...receipt } = result;
|
|
36
|
+
if (present!.json) console.log(JSON.stringify(receipt, null, 2)); else human(renderSdlcConfiguration, receipt);
|
|
37
|
+
} finally { hub.close(); }
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (sub === "check") {
|
|
41
|
+
// #1856 T2: a read-only audit; exit 1 only on a fail row (CLI output standard v1), warnings and unknowns change nothing.
|
|
42
|
+
if (args.length !== 1) fail("usage: ahub sdlc check [--json]");
|
|
43
|
+
const hub = await connect();
|
|
44
|
+
try {
|
|
45
|
+
const reply = await hub.request({ t: "sdlc", op: "check" }, 45_000);
|
|
46
|
+
if (!reply.ok && /unknown SDLC operation/.test(String(reply.error))) fail("running hub does not support ahub sdlc check; upgrade and restart it first");
|
|
47
|
+
if (!reply.ok) fail(`ahub sdlc check refused: ${String(reply.error)}; run ahub doctor to see whether the hub is healthy`);
|
|
48
|
+
const { rid: _transportId, ok: _ok, ...report } = reply;
|
|
49
|
+
if (present!.json) console.log(JSON.stringify(report, null, 2)); else human(renderSdlcCheck, report);
|
|
50
|
+
if (sdlcCheckExitCode(report)) process.exitCode = 1;
|
|
51
|
+
} finally { hub.close(); }
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (sub === "sync") {
|
|
55
|
+
// #1856 T3: the preview writes nothing; `--apply --confirm <fingerprint>` re-plans first and refuses on any drift.
|
|
56
|
+
// #1856 T4: the two opt-in actions are named again on apply, so the re-plan covers exactly what the preview showed.
|
|
57
|
+
const rest = args.slice(1), writeRoadmap = rest.includes("--write-roadmap"), closeSettled = rest.includes("--close-settled-issues");
|
|
58
|
+
const tail = rest.filter(arg => arg !== "--write-roadmap" && arg !== "--close-settled-issues"), apply = tail[0] === "--apply";
|
|
59
|
+
if (apply ? tail.length !== 3 || tail[1] !== "--confirm" || !/^[a-f0-9]{64}$/.test(tail[2]!) : tail.length) fail("usage: ahub sdlc sync [--write-roadmap] [--close-settled-issues] [--json] | ahub sdlc sync [--write-roadmap] [--close-settled-issues] --apply --confirm <fingerprint> [--json]");
|
|
60
|
+
let root: string | undefined, tracked = false;
|
|
61
|
+
if (writeRoadmap) {
|
|
62
|
+
try {
|
|
63
|
+
root = roadmapWorktree(cwd, context.invokedFrom);
|
|
64
|
+
tracked = ["docs/roadmap.json", "docs/roadmap.md"].some(file => hubGitSync(["-C", root!, "ls-files", "--error-unmatch", file], { encoding: "utf8", timeout: 5000 }).status === 0);
|
|
65
|
+
} catch { fail("--write-roadmap needs a Git worktree of this project; cd into the project checkout and run ahub sdlc sync --write-roadmap again"); }
|
|
66
|
+
}
|
|
67
|
+
const hub = await connect();
|
|
68
|
+
try {
|
|
69
|
+
const reply = await hub.request({ t: "sdlc", op: "sync", ...(writeRoadmap ? { writeRoadmap: true, roadmapTracked: tracked } : {}), ...(closeSettled ? { closeSettled: true } : {}), ...(apply ? { apply: true, confirm: tail[2] } : {}) }, 90_000);
|
|
70
|
+
if (!reply.ok && /unknown SDLC operation/.test(String(reply.error))) fail("running hub does not support ahub sdlc sync; upgrade and restart it first");
|
|
71
|
+
if (!reply.ok) fail(`ahub sdlc sync refused: ${String(reply.error)}`);
|
|
72
|
+
if (apply && reply.roadmapFiles && root) {
|
|
73
|
+
try { const policy = loadConfig(cwd); writeRoadmap_(root, reply.roadmapFiles, { deny: policy.local.deny, readOnly: policy.data?.readonly ?? [], pii: policy.pii?.paths ?? [] }); reply.results.push({ task: 0, kind: "roadmap refresh", ok: true }); }
|
|
74
|
+
catch (error) { reply.results.push({ task: 0, kind: "roadmap refresh", ok: false, error: error instanceof Error ? error.message : "roadmap files were not written" }); }
|
|
75
|
+
delete reply.roadmapFiles;
|
|
76
|
+
}
|
|
77
|
+
const { rid: _transportId, ok: _ok, ...report } = reply;
|
|
78
|
+
if (present!.json) console.log(JSON.stringify(report, null, 2)); else human(renderSdlcSync, report);
|
|
79
|
+
if (apply && Array.isArray(report.results) && report.results.some((row: { ok: boolean }) => !row.ok)) process.exitCode = 1;
|
|
80
|
+
} finally { hub.close(); }
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (sub === "authorize-release") {
|
|
84
|
+
if (args.length !== 2 || !validReleaseVersion(args[1])) fail("usage: ahub sdlc authorize-release <version>");
|
|
85
|
+
const result = hubGitSync(["rev-parse", "--verify", "HEAD"], { cwd, env: hubGitEnv(process.env, { repositoryIsolation: true }), encoding: "utf8", timeout: 2000 });
|
|
86
|
+
const commit = result.stdout?.trim();
|
|
87
|
+
if (result.status !== 0 || !commit || !/^[a-f0-9]{40}$/.test(commit)) fail("candidate commit unavailable");
|
|
88
|
+
const hub = await connect();
|
|
89
|
+
try { const reply = await hub.request({ t: "sdlc", op: sub, version: args[1], commit }, 30_000); if (!reply.ok) fail(reply.error); if (present!.json) console.log(JSON.stringify(reply.authorization, null, 2)); else human(renderAuthorization, reply.authorization); }
|
|
90
|
+
finally { hub.close(); }
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (sub === "release-guard" || sub === "release-guard-hook") {
|
|
94
|
+
let original: Buffer | undefined;
|
|
95
|
+
let request: Record<string, unknown>;
|
|
96
|
+
if (sub === "release-guard-hook") {
|
|
97
|
+
if (args.length !== 3) fail("release hook needs its remote name and URL");
|
|
98
|
+
const chunks: Buffer[] = []; let size = 0;
|
|
99
|
+
for await (const chunk of process.stdin) { const bytes = Buffer.from(chunk); size += bytes.length; if (size > 128 * 1024) fail("release push inventory exceeds the guard bound"); chunks.push(bytes); }
|
|
100
|
+
original = Buffer.concat(chunks);
|
|
101
|
+
let input: string;
|
|
102
|
+
try { input = new TextDecoder("utf-8", { fatal: true }).decode(original); } catch { fail("release push inventory is not UTF-8"); }
|
|
103
|
+
const parsed = parseReleasePushUpdates(args[1]!, args[2]!, input);
|
|
104
|
+
if (!parsed.ok) fail(parsed.reason);
|
|
105
|
+
// Ordinary branch pushes keep working with the daemon offline.
|
|
106
|
+
if (!parsed.updates.length) { process.stdout.write(original); return; }
|
|
107
|
+
request = { t: "sdlc", op: sub, remoteName: parsed.remoteName, remoteUrl: parsed.remoteUrl, stdin: input };
|
|
108
|
+
} else {
|
|
109
|
+
if (args[1] !== "--") fail("usage: ahub sdlc release-guard -- git push origin v<version> | gh release create v<version> | npm publish");
|
|
110
|
+
const argv = args.slice(2), parsed = parseReleaseGuardArgv(argv);
|
|
111
|
+
if (!parsed.ok) fail(parsed.reason);
|
|
112
|
+
// Literal preflights cannot attest a command redirected by ambient target selectors.
|
|
113
|
+
const selectors = ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", ...(parsed.request.kind === "gh-release" ? ["GH_REPO", "GH_HOST"] : []), ...(parsed.request.kind === "npm-publish" ? Object.keys(process.env).filter(key => /^npm_config_(?:prefix|workspace|workspaces|userconfig|globalconfig|registry)$/i.test(key)) : [])];
|
|
114
|
+
if (selectors.some(key => process.env[key] !== undefined)) fail("release guard refuses ambient target selectors");
|
|
115
|
+
request = { t: "sdlc", op: sub, argv };
|
|
116
|
+
}
|
|
117
|
+
let hub: ControlClient | undefined;
|
|
118
|
+
try {
|
|
119
|
+
hub = await connect();
|
|
120
|
+
const reply = await hub.request(request, 30_000);
|
|
121
|
+
if (!reply.ok) fail(reply.error ?? "release authorization refused");
|
|
122
|
+
if (original) process.stdout.write(original); else receipt("Release guard", "release authorization matched");
|
|
123
|
+
} catch { fail("release authorization unavailable; the daemon must be reachable with a matching person approval"); }
|
|
124
|
+
finally { hub?.close(); }
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (sub === "survey") {
|
|
128
|
+
const action = args[1];
|
|
129
|
+
if (action === "start") {
|
|
130
|
+
const flags = takeFlags(args.slice(2), ["--focus"], []);
|
|
131
|
+
if (flags.rest.length || args.filter(arg => arg === "--focus").length > 1 || flags.one["--focus"] !== undefined && !(SURVEY_FOCUS as readonly string[]).includes(flags.one["--focus"])) fail("usage: ahub sdlc survey start [--focus bugs|tests|debt|deps|dx|docs]");
|
|
132
|
+
const hub = await connect();
|
|
133
|
+
try {
|
|
134
|
+
const reply = await hub.request({ t: "sdlc", op: "survey-start", ...(flags.one["--focus"] === undefined ? {} : { focus: flags.one["--focus"] }) }, 60_000);
|
|
135
|
+
if (!reply.ok) fail(/unknown SDLC operation|does not know/.test(String(reply.error)) ? "running hub does not support advisor surveys; upgrade and restart it first" : reply.error);
|
|
136
|
+
const receipt = { task: reply.task, survey: reply.survey, ref: reply.ref, ...(reply.focus === undefined ? {} : { focus: reply.focus }) };
|
|
137
|
+
if (present!.json) console.log(JSON.stringify(receipt, null, 2)); else human(renderSdlcSurvey, receipt);
|
|
138
|
+
} finally { hub.close(); }
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (action === "show" && args.length === 3 && /^[1-9]\d*$/.test(args[2]!) && Number.isSafeInteger(Number(args[2]))) {
|
|
142
|
+
const hub = await connect();
|
|
143
|
+
try {
|
|
144
|
+
const reply = await hub.request({ t: "sdlc", op: "survey-show", id: Number(args[2]) });
|
|
145
|
+
if (!reply.ok) fail(reply.error);
|
|
146
|
+
if (present!.json) console.log(JSON.stringify(reply.survey ?? null, null, 2)); else human(renderSdlcSurvey, reply.survey);
|
|
147
|
+
} finally { hub.close(); }
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
fail("usage: ahub sdlc survey start [--focus bugs|tests|debt|deps|dx|docs] | ahub sdlc survey show <task>");
|
|
151
|
+
}
|
|
152
|
+
if (sub === "audit") {
|
|
153
|
+
// #1403 A4: `audit start [--profile quick|standard] [--since <ref>]` files the read-only audit task and seeds its ledger; `audit show [<audit>]` reads the newest or the named one.
|
|
154
|
+
const action = args[1];
|
|
155
|
+
if (action === "start") {
|
|
156
|
+
const flags = takeFlags(args.slice(2), ["--profile", "--since"], []);
|
|
157
|
+
if (flags.rest.length || (flags.one["--profile"] !== undefined && !["quick", "standard"].includes(flags.one["--profile"]))) fail("usage: ahub sdlc audit start [--profile quick|standard] [--since <ref>]");
|
|
158
|
+
const hub = await connect();
|
|
159
|
+
try {
|
|
160
|
+
const reply = await hub.request({ t: "sdlc", op: "audit-start", ...(flags.one["--profile"] !== undefined ? { profile: flags.one["--profile"] } : {}), ...(flags.one["--since"] !== undefined ? { since: flags.one["--since"] } : {}) }, 60_000);
|
|
161
|
+
if (!reply.ok) fail(/unknown SDLC operation|does not know/.test(String(reply.error)) ? `${reply.error}; the running hub does not support security audits; upgrade agent-hub and run ahub restart before retrying` : reply.error);
|
|
162
|
+
if (present!.json) console.log(JSON.stringify({ task: reply.task, audit: reply.audit, units: reply.units, planned: reply.planned, carried: reply.carried, partial: reply.partial, ref: reply.ref }, null, 2));
|
|
163
|
+
else receipt("Audit start", `task #${reply.task}: security audit ${reply.audit} started at ${String(reply.ref).slice(0, 12)}, ${reply.units} units (${reply.planned} planned, ${reply.carried} carried over)${reply.partial ? ", partial" : ""}`);
|
|
164
|
+
} finally { hub.close(); }
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (action === "show") {
|
|
168
|
+
const given = args[2] === undefined ? undefined : Number(args[2]);
|
|
169
|
+
if (args.length > 3 || given !== undefined && (!Number.isSafeInteger(given) || given <= 0)) fail("usage: ahub sdlc audit show [<audit>]");
|
|
170
|
+
const hub = await connect();
|
|
171
|
+
try {
|
|
172
|
+
const reply = await hub.request({ t: "sdlc", op: "audit-show", ...(given !== undefined ? { id: given } : {}) }, 30_000);
|
|
173
|
+
if (!reply.ok) fail(reply.error);
|
|
174
|
+
if (present!.json) console.log(JSON.stringify(reply.audit ?? null, null, 2)); else human(renderSdlcAudit, reply);
|
|
175
|
+
} finally { hub.close(); }
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
fail("usage: ahub sdlc audit start [--profile quick|standard] [--since <ref>] | ahub sdlc audit show [<audit>]");
|
|
179
|
+
}
|
|
180
|
+
if (sub === "queue" || sub === "release") {
|
|
181
|
+
const repo = args[1], liveIssues = args.slice(2).map(Number);
|
|
182
|
+
if (!repo || args.length > 34 || (sub === "queue" && args.length !== 2) || liveIssues.some(id => !Number.isSafeInteger(id) || id <= 0)) fail("usage: ahub sdlc queue <owner/repository> | release <owner/repository> [live-issue...]");
|
|
183
|
+
const hub = await connect();
|
|
184
|
+
try { const reply = await hub.request({ t: "sdlc", op: sub, repo, liveIssues }, 30_000); if (!reply.ok) fail(reply.error); if (present!.json) console.log(JSON.stringify(reply, null, 2)); else human(sub === "queue" ? renderSdlcQueue : renderSdlcRelease, reply); }
|
|
185
|
+
finally { hub.close(); }
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (sub === "train") {
|
|
189
|
+
const operation = args[1], releaseId = Number(args[2]), revision = Number(args[3]);
|
|
190
|
+
if (!Number.isSafeInteger(releaseId) || releaseId <= 0) fail("usage: ahub sdlc train report|configure|cut <release-id> [revision] [configuration-json]");
|
|
191
|
+
if (operation === "report" && args.length === 3) return toolReport(renderSdlcTrain, taskOp("hub_release_report", { id: releaseId }));
|
|
192
|
+
if (!Number.isSafeInteger(revision) || revision < 0) fail("train mutation requires its current revision");
|
|
193
|
+
if (operation === "cut" && args.length === 4) return toolReport(renderSdlcTrain, taskOp("hub_release_cut", { id: releaseId, revision }));
|
|
194
|
+
if (operation === "configure" && args.length === 5) {
|
|
195
|
+
let fields;
|
|
196
|
+
try { fields = JSON.parse(args[4]!); } catch { return fail("release train configuration must be JSON"); }
|
|
197
|
+
if (!fields || typeof fields !== "object" || Array.isArray(fields) || Object.keys(fields).some(key => !["state", "cut", "hotfix"].includes(key))) fail("invalid release train configuration fields");
|
|
198
|
+
return toolReport(renderSdlcTrain, taskOp("hub_release_configure", { ...fields, id: releaseId, revision }));
|
|
199
|
+
}
|
|
200
|
+
fail("usage: ahub sdlc train report|configure|cut <release-id> [revision] [configuration-json]");
|
|
201
|
+
}
|
|
202
|
+
if (sub === "release-assign") {
|
|
203
|
+
const revision = Number(args[2]), release = args[3] === "none" ? null : Number(args[3]);
|
|
204
|
+
if (!Number.isSafeInteger(id) || id! <= 0 || !Number.isSafeInteger(revision) || revision < 0 || release !== null && (!Number.isSafeInteger(release) || release <= 0) || args.length < 5) fail("usage: ahub sdlc release-assign <task> <planning-revision> <release-id|none> <reason...>");
|
|
205
|
+
return toolReport(renderTaskShow, taskOp("hub_release_assign", { id, revision, release, reason: args.slice(4).join(" ") }));
|
|
206
|
+
}
|
|
207
|
+
if (sub === "costs") {
|
|
208
|
+
if (args.length > 2) fail("usage: ahub sdlc costs [owner/repository]");
|
|
209
|
+
const text = await taskOp("hub_sdlc_costs", { ...(args[1] ? { repo: args[1] } : {}) });
|
|
210
|
+
return showToolText((data, columns, now) => renderSdlcCosts(data, columns, now, asciiMarkers(process.env, process.argv.includes("--ascii"))), text, present!);
|
|
211
|
+
}
|
|
212
|
+
if (sub === "metrics") {
|
|
213
|
+
const flags = takeFlags(args.slice(1), ["--since"], []);
|
|
214
|
+
if (flags.rest.length) fail("usage: ahub sdlc metrics [--since <YYYY-MM-DD|ISO time>]");
|
|
215
|
+
const text = await taskOp("hub_sdlc_metrics", { ...(flags.one["--since"] !== undefined ? { since: flags.one["--since"] } : {}) });
|
|
216
|
+
return showToolText((data, columns, now) => renderSdlcMetrics(data, columns, now, asciiMarkers(process.env, process.argv.includes("--ascii"))), text, present!);
|
|
217
|
+
}
|
|
218
|
+
if (sub === "plan-review") {
|
|
219
|
+
const revision = Number(args[2]);
|
|
220
|
+
if (!Number.isSafeInteger(id) || id! <= 0 || !Number.isSafeInteger(revision) || revision < 0 || args.length < 4) fail("usage: ahub sdlc plan-review <task> <revision> <reason...>");
|
|
221
|
+
const flags = takeFlags(args.slice(3), ["--review", "--reviewers", "--ci"], []);
|
|
222
|
+
const scope = flags.one["--review"], reviewers = flags.one["--reviewers"];
|
|
223
|
+
if (!flags.rest.length || (scope === undefined) !== (reviewers === undefined)) fail("plan-review needs a reason and both --review and --reviewers when supplying review scope");
|
|
224
|
+
return toolReport(renderTaskShow, taskOp("hub_plan_review", { id, revision, reason: flags.rest.join(" "), ...(scope !== undefined ? { review: { scope, reviewers: Number(reviewers) } } : {}), ...(flags.one["--ci"] !== undefined ? { ci: flags.one["--ci"] } : {}) }));
|
|
225
|
+
}
|
|
226
|
+
if (sub === "accept-departure") {
|
|
227
|
+
const head = args[2], rawReason = args.slice(3).join(" "), reason = rawReason.trim();
|
|
228
|
+
if (!Number.isSafeInteger(id) || id! <= 0 || typeof head !== "string" || !/^[a-f0-9]{40}$/.test(head) || !reason || rawReason.length > 2048) fail("usage: ahub sdlc accept-departure <task> <head> <reason...>");
|
|
229
|
+
const hub = await connect();
|
|
230
|
+
try {
|
|
231
|
+
const reply = await hub.request({ t: "sdlc", op: "accept-departure", id, head, reason }, 30_000);
|
|
232
|
+
if (!reply.ok) fail(reply.error);
|
|
233
|
+
receiptOutput?.("Accept departure", `task #${id}: plan departure accepted for the reviewed head`);
|
|
234
|
+
} finally { hub.close(); }
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (sub === "adopt-merge") {
|
|
238
|
+
const flags = takeFlags(args.slice(2), ["--pr"], []), pr = Number(flags.one["--pr"]);
|
|
239
|
+
if (flags.rest.length || !Number.isSafeInteger(id) || id! <= 0 || !Number.isSafeInteger(pr) || pr <= 0) fail("usage: ahub sdlc adopt-merge <task> --pr <n>");
|
|
240
|
+
const hub = await connect();
|
|
241
|
+
try {
|
|
242
|
+
const reply = await hub.request({ t: "sdlc", op: "adopt-merge", id, pr }, 60_000);
|
|
243
|
+
if (!reply.ok) {
|
|
244
|
+
const reason = typeof reply.error === "string" ? reply.error : "merge adoption failed without a reason; inspect the hub log and retry ahub sdlc adopt-merge";
|
|
245
|
+
if (/unknown SDLC operation|does not know|SDLC readback is console only/.test(reason)) fail(`${reason}; the running hub does not support adopt-merge; upgrade agent-hub and run ahub restart before retrying ahub sdlc adopt-merge`);
|
|
246
|
+
fail(reason);
|
|
247
|
+
}
|
|
248
|
+
receipt("Adopt merge", `task #${id}: merged outside the hub; approved`);
|
|
249
|
+
} finally { hub.close(); }
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (sub === "merge") {
|
|
253
|
+
// #786 T1: the guarded merge of one approved task; a person or the configured conductor asks, the daemon re-reads every gate.
|
|
254
|
+
// #899: the decision prints for a person; `--json` is the same view as a document. The presentation flags are read before the
|
|
255
|
+
// request, so an invalid --color refuses before a mutation is sent, and they never reach the hub.
|
|
256
|
+
const split = splitPresentation(args.slice(1)), display = outputOptions(split.flags);
|
|
257
|
+
const task = Number(split.operands[0]), flags = takeFlags(split.operands.slice(1), [], []);
|
|
258
|
+
const dryRun = flags.rest.includes("--dry-run");
|
|
259
|
+
if (flags.rest.some(arg => arg !== "--dry-run") || !Number.isSafeInteger(task) || task <= 0) fail("usage: ahub sdlc merge <task> [--dry-run] [--json]");
|
|
260
|
+
const hub = await connect();
|
|
261
|
+
try {
|
|
262
|
+
const reply = await hub.request({ t: "sdlc", op: "merge", id: task, ...(dryRun ? { dryRun: true } : {}) }, 60_000);
|
|
263
|
+
if (!reply.ok) fail(reply.error);
|
|
264
|
+
const view = { task: reply.task, mode: reply.mode, ran: reply.ran, decision: reply.decision, ...(reply.argv ? { argv: reply.argv } : {}), ...(reply.refused ? { refused: reply.refused } : {}), ...(reply.result ? { result: reply.result } : {}) };
|
|
265
|
+
if (display.json) console.log(JSON.stringify(view, null, 2));
|
|
266
|
+
else printOutput(renderSdlcMerge(view, display.columns, Date.now(), asciiMarkers(process.env, process.argv.includes("--ascii"))), display.color);
|
|
267
|
+
if (reply.decision === "refused" || reply.ran && reply.result?.state !== "merged") process.exitCode = 1;
|
|
268
|
+
} finally { hub.close(); }
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (sub === "readback") {
|
|
272
|
+
// #1658: a read-back is a report for the person, started and read by the person or the current conductor.
|
|
273
|
+
const options = outputOptions(), words = outputArguments(), op = words[1], target = words[2];
|
|
274
|
+
if (!["start", "show"].includes(op ?? "") || words.length !== 3) fail("usage: ahub sdlc readback start <task> [--json] | ahub sdlc readback show <task> [--json]");
|
|
275
|
+
const task = Number(target);
|
|
276
|
+
if (!Number.isSafeInteger(task) || task <= 0) fail("usage: ahub sdlc readback start <task> [--json] | ahub sdlc readback show <task> [--json]");
|
|
277
|
+
const hub = await connect();
|
|
278
|
+
try {
|
|
279
|
+
const reply = await hub.request({ t: "sdlc", op: op === "start" ? "readback-start" : "readback-show", id: task }, 30_000);
|
|
280
|
+
if (!reply.ok) fail(reply.error, false, undefined, `check ahub sdlc status ${task} for the task's lifecycle receipt, then retry`);
|
|
281
|
+
const view = reply.readback;
|
|
282
|
+
if (options.json) return console.log(JSON.stringify(op === "start" ? reply : view ?? null, null, 2));
|
|
283
|
+
human(renderSdlcReadback, { task, op, reply }, options);
|
|
284
|
+
} finally { hub.close(); }
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (sub === "accept") {
|
|
288
|
+
// #481 S1: the person accepts the task's spec issue at its current body; agent shells are refused before this runs.
|
|
289
|
+
const flags = takeFlags(args.slice(2), ["--issue", "--repo"], []);
|
|
290
|
+
const issue = Number(flags.one["--issue"]), repo = flags.one["--repo"];
|
|
291
|
+
if (flags.rest.length || !Number.isSafeInteger(id) || id! <= 0 || !Number.isSafeInteger(issue) || issue <= 0) fail("usage: ahub sdlc accept <task> --issue <n> [--repo owner/repository]");
|
|
292
|
+
const hub = await connect();
|
|
293
|
+
try {
|
|
294
|
+
const reply = await hub.request({ t: "sdlc", op: "accept", id, issue, ...(repo ? { repo } : {}) }, 30_000);
|
|
295
|
+
if (!reply.ok) fail(reply.error);
|
|
296
|
+
// #1658 AC6: the line names the read-back state read before the acceptance; the acceptance proceeds in every state.
|
|
297
|
+
receipt("Accept spec", ...(reply.readback ? [reply.readback] : []),
|
|
298
|
+
`task #${id}: spec issue #${issue} accepted at body edit ${reply.acceptance?.lastEditedAt ?? "never"}`);
|
|
299
|
+
} finally { hub.close(); }
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (sub === "record") {
|
|
303
|
+
if (args.length !== 3 || !Number.isSafeInteger(id) || id! <= 0 || Buffer.byteLength(args[2]!) > 32768) fail("usage: ahub sdlc record <task> '<receipt JSON>'");
|
|
304
|
+
let receipt: unknown; try { receipt = JSON.parse(args[2]!); } catch { fail("receipt must be valid JSON"); }
|
|
305
|
+
return console.log(await taskOp("hub_sdlc_record", { id, receipt }));
|
|
306
|
+
}
|
|
307
|
+
// #1856 T1: `--all` belongs to `status` only; without it and without a task, status lists the unsettled tasks.
|
|
308
|
+
const all = sub === "status" && args.includes("--all");
|
|
309
|
+
const operands = all ? args.filter(arg => arg !== "--all") : args;
|
|
310
|
+
const taskId = operands[1] === undefined ? undefined : Number(operands[1]);
|
|
311
|
+
if (!["status", "explain", "export"].includes(sub ?? "") || operands.length > 2 || (["explain", "export"].includes(sub ?? "") && taskId === undefined) || (taskId !== undefined && (!Number.isSafeInteger(taskId) || taskId <= 0))) fail("usage: ahub sdlc status [--all] [task] | explain <task> | export <task>");
|
|
312
|
+
const hub = await connect();
|
|
313
|
+
try {
|
|
314
|
+
const reply = await hub.request({ t: "sdlc", op: sub, ...(taskId === undefined ? {} : { id: taskId }), ...(all ? { all: true } : {}) }, 30_000);
|
|
315
|
+
if (!reply.ok) fail(reply.error);
|
|
316
|
+
// `sdlc export` is a data format by purpose (#814): it stays JSON and never reaches a renderer.
|
|
317
|
+
if (sub === "export") console.log(JSON.stringify(reply, null, 2));
|
|
318
|
+
else if (present!.json) console.log(JSON.stringify(reply, null, 2));
|
|
319
|
+
else human(sub === "explain" ? renderSdlcExplain : renderSdlcStatus, reply);
|
|
320
|
+
} finally { hub.close(); }
|
|
321
|
+
}
|