@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,114 @@
|
|
|
1
|
+
import { parseSynthesisManifest, synthesisManifestHash } from "../../hub/synthesis-readiness.ts";
|
|
2
|
+
import { renderHandoffReceipt, renderHandoffs } from "../handoff-output.ts";
|
|
3
|
+
import { parseHandoffArgs } from "../handoff-args.ts";
|
|
4
|
+
import { resolveProfile } from "../../hub/profiles.ts";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { CLASSES } from "../../hub/board.ts";
|
|
7
|
+
import { unknownOption, unknownOptionRefusal, withoutSeparator } from "../free-text.ts";
|
|
8
|
+
import { readEvents } from "../../hub/events.ts";
|
|
9
|
+
import { appendRecords, LABELS, labelTarget, RESEARCH_SCHEMA, projectKey, readStores, type Label, type TaskRecord } from "../../hub/research.ts";
|
|
10
|
+
import { refuseSynthesisTaskMismatch } from "../commands/shared-refusals.ts";
|
|
11
|
+
import { type Span } from "../console-state.ts";
|
|
12
|
+
import { subcommandUsage } from "../help.ts";
|
|
13
|
+
import { renderTaskCancel, renderTaskShow } from "../task-output.ts";
|
|
14
|
+
import type { CommandContext } from "../command-context.ts";
|
|
15
|
+
|
|
16
|
+
export async function run(context: CommandContext) {
|
|
17
|
+
const { args, connect, contract, identity, missingTaskText, outputOptions, projectConfig, researchProject, showToolText, splitPresentation, stateDir, takeFlags, taskOp, warn } = context;
|
|
18
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
19
|
+
const presentation = splitPresentation(args, { valueFlags: ["--reason", "--superseded-by", "--revision"], edges: true });
|
|
20
|
+
const shownTask = (render: (data: any, columns?: number, now?: number, ascii?: boolean) => Span[][]) => async (text: Promise<string>) => showToolText(render, await text, outputOptions(presentation.flags));
|
|
21
|
+
// task show and task cancel read their presentation options before the request goes out (a refusal after a cancel would invite a retry of work already done)
|
|
22
|
+
if (["show", "cancel"].includes(args[0] ?? "")) outputOptions(presentation.flags);
|
|
23
|
+
const [sub, ...rest] = ["show", "cancel"].includes(args[0] ?? "") ? presentation.operands : args;
|
|
24
|
+
if (sub === "role") {
|
|
25
|
+
if (rest.length !== 2 || !/^[1-9]\d*$/.test(rest[0]!)) fail("usage: ahub task role <id> <role|none>");
|
|
26
|
+
const hub = await connect();
|
|
27
|
+
try { const reply = await hub.request({ t: "task_catalog_role", id: Number(rest[0]), role: rest[1] === "none" ? null : rest[1] }); if (!reply.ok) fail(reply.error); console.log(reply.text); }
|
|
28
|
+
finally { hub.close(); }
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (sub === "cancel") {
|
|
32
|
+
const { one, rest: positional } = takeFlags(rest, ["--reason", "--superseded-by", "--revision"], []);
|
|
33
|
+
const revision = one["--revision"] === undefined ? undefined : Number(one["--revision"]);
|
|
34
|
+
if (positional.length !== 1 || !/^[1-9]\d*$/.test(positional[0]!) || !one["--reason"]?.trim() || (revision !== undefined && (!/^\d+$/.test(one["--revision"]!) || !Number.isSafeInteger(revision)))) fail("usage: ahub task cancel <id> --reason <text> [--superseded-by <ref>] [--revision N]");
|
|
35
|
+
return shownTask(renderTaskCancel)(taskOp("hub_task_cancel", { id: Number(positional[0]), reason: one["--reason"], ...(one["--superseded-by"] === undefined ? {} : { superseded_by: one["--superseded-by"] }), ...(revision === undefined ? {} : { revision }) }));
|
|
36
|
+
}
|
|
37
|
+
if (sub === "show") {
|
|
38
|
+
// a stray operand (for example the value of a `--color always` that is not the `--color=` form) is a usage error, never silently ignored
|
|
39
|
+
if (rest.length !== 1) fail("usage: ahub task show <id> [--json] [--full] [--color=auto|always|never]");
|
|
40
|
+
// CLI output standard v1: a lookup that finds nothing is a failure (stderr, exit 1), not a successful print. The daemon answers a missing id with a JSON string
|
|
41
|
+
// (`"no task #N"`) while a found task is an object. The exit code is the standard's and is set apart from the format: `--json` keeps printing the hub's own document
|
|
42
|
+
// byte for byte on stdout, and exits 1 like the human path, which prints the error and a next step on stderr instead.
|
|
43
|
+
const shown = taskOp("task_show", { id: rest[0] });
|
|
44
|
+
const missing = missingTaskText(await shown);
|
|
45
|
+
if (missing !== undefined && !outputOptions(presentation.flags).json) return fail(missing, false, undefined, "ahub board");
|
|
46
|
+
await shownTask(renderTaskShow)(shown);
|
|
47
|
+
if (missing !== undefined) process.exitCode = 1; // --json printed the hub's document above; a lookup that found nothing still fails
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (sub === "claim") {
|
|
51
|
+
// #901: a person's verdict on one declared plan claim. The claim is named by its 1-based slot and its text is never typed, stored or printed here.
|
|
52
|
+
const { one, rest: positional } = takeFlags(rest, ["--model", "--model-said", "--manifest", "--disposition"], []);
|
|
53
|
+
if (positional.length !== 3 || !/^[1-9]\d*$/.test(positional[0]!) || !/^[1-9]\d*$/.test(positional[1]!) || !["supported", "unsupported", "unclear"].includes(positional[2]!)
|
|
54
|
+
|| (one["--manifest"] === undefined) !== (one["--disposition"] === undefined)
|
|
55
|
+
|| one["--manifest"] !== undefined && !["resolved", "qualified"].includes(one["--disposition"]!)) fail("usage: ahub task claim <id> <slot> <supported|unsupported|unclear> [--model <label>] [--model-said <supported|unsupported|unclear>] [--manifest <manifest.json> --disposition <resolved|qualified>]");
|
|
56
|
+
const manifest = one["--manifest"] === undefined ? undefined : parseSynthesisManifest(contract(one["--manifest"], "manifest"));
|
|
57
|
+
if (manifest && manifest.taskId !== Number(positional[0])) return refuseSynthesisTaskMismatch(fail);
|
|
58
|
+
const reply = JSON.parse(await taskOp("claim_verdict", { id: Number(positional[0]), slot: Number(positional[1]), verdict: positional[2], ...(one["--model"] === undefined ? {} : { model: one["--model"] }), ...(one["--model-said"] === undefined ? {} : { modelVerdict: one["--model-said"] }), ...(manifest === undefined ? {} : { manifest, synthesis: { manifestSha256: synthesisManifestHash(manifest), disposition: one["--disposition"] } }) })) as { task: number; recorded?: { slot: number; verdict: string; model?: string; modelVerdict?: string; synthesis?: { manifestSha256: string; disposition: string } } };
|
|
59
|
+
return console.log(`task #${reply.task}: claim ${reply.recorded?.slot} recorded as ${reply.recorded?.verdict}${reply.recorded?.model ? ` (model ${reply.recorded.model}` : ""}${reply.recorded?.modelVerdict ? `${reply.recorded?.model ? ", " : " ("}model said ${reply.recorded.modelVerdict}` : ""}${reply.recorded?.model || reply.recorded?.modelVerdict ? ")" : ""}${reply.recorded?.synthesis ? `; synthesis ${reply.recorded.synthesis.disposition} @ ${reply.recorded.synthesis.manifestSha256}` : ""}`);
|
|
60
|
+
}
|
|
61
|
+
if (sub === "escalate") return console.log(await taskOp("task_escalate", { id: rest[0] }));
|
|
62
|
+
if (sub === "assign") {
|
|
63
|
+
const { one, rest: positional } = takeFlags(rest, ["--role", "--revision"], []);
|
|
64
|
+
const role = one["--role"] ?? "owner", rawRevision = one["--revision"], revision = rawRevision === undefined ? undefined : Number(rawRevision);
|
|
65
|
+
if (positional.length !== 2 || !["owner", "reviewer", "planner"].includes(role) || (rawRevision !== undefined && (!/^\d+$/.test(rawRevision) || !Number.isSafeInteger(revision)))) fail("usage: ahub task assign <id> <peer> [--role owner|reviewer|planner] [--revision N]");
|
|
66
|
+
return console.log(await taskOp(revision === undefined ? "task_assign" : "task_assign_checked", { id: positional[0], peer: positional[1], ...(role !== "owner" ? { role } : {}), ...(revision === undefined ? {} : { revision }) }));
|
|
67
|
+
}
|
|
68
|
+
if (sub === "unassign") {
|
|
69
|
+
const { one, rest: positional } = takeFlags(rest, ["--role", "--revision"], []);
|
|
70
|
+
const role = one["--role"] ?? "owner", rawRevision = one["--revision"], revision = rawRevision === undefined ? undefined : Number(rawRevision);
|
|
71
|
+
if (positional.length !== 1 || !["owner", "reviewer"].includes(role) || (rawRevision !== undefined && (!/^\d+$/.test(rawRevision) || !Number.isSafeInteger(revision)))) fail("usage: ahub task unassign <id> [--role owner|reviewer] [--revision N]");
|
|
72
|
+
return console.log(await taskOp("task_unassign", { id: positional[0], role, ...(revision === undefined ? {} : { revision }) }));
|
|
73
|
+
}
|
|
74
|
+
if (sub === "label") {
|
|
75
|
+
// #247: a later verdict on an approved task, for research records (#933: an agent's own task only, attributed to it).
|
|
76
|
+
const { one, rest: positional } = takeFlags(rest, ["--created"], []);
|
|
77
|
+
const id = Number(positional[0]), label = positional[1] as Label;
|
|
78
|
+
if (positional.length !== 2 || !/^[1-9]\d*$/.test(positional[0]!) || !Number.isSafeInteger(id) || !(LABELS as readonly string[]).includes(label)) fail(`usage: ahub task label <id> ${LABELS.join("|")} [--created <time from ahub research export>]`);
|
|
79
|
+
// #933: the daemon checks the current board row only, so an agent never names an earlier task with this id from before a reset.
|
|
80
|
+
if (identity.role === "tools" && one["--created"] !== undefined) fail("--created names an earlier task with this id; only the person labels it (ahub console or a terminal)");
|
|
81
|
+
const project = researchProject();
|
|
82
|
+
// #933: an agent labels only its own task, which the daemon checks by role; its record names it, so it never reads as the person's verdict.
|
|
83
|
+
if (identity.role === "tools") await taskOp("task_label_check", { id });
|
|
84
|
+
let record: TaskRecord;
|
|
85
|
+
try { record = labelTarget(readStores(project.id), readEvents(join(stateDir, "events.jsonl")), id, one["--created"]); } catch (error) { fail((error as Error).message); }
|
|
86
|
+
appendRecords(project.id, [{ schema: RESEARCH_SCHEMA, kind: "label", project: projectKey(project.id), task: id, createdAt: record!.createdAt!, label, at: new Date().toISOString(), ...(identity.role === "tools" ? { by: identity.peer } : {}) }]);
|
|
87
|
+
return console.log(`task #${id} (approved ${record!.approvedAt}) labelled ${label} in the research records`);
|
|
88
|
+
}
|
|
89
|
+
if (sub === "handoff") {
|
|
90
|
+
// #604: work that belongs to ANOTHER project that runs agent-hub goes onto that project's board. The person's form (a console command: the classifier gives an agent `console` for it, and an
|
|
91
|
+
// agent uses hub_task_handoff); the hub resolves the target, asks its daemon and records the answer. Nothing is queued: a target that is not running is named with the action.
|
|
92
|
+
const present = outputOptions(splitPresentation(rest, { valueFlags: ["--project", "--path", "--issue", "--task", "--detail", "--duplicate-ok", "--key"], edges: true }).flags);
|
|
93
|
+
const parsed = parseHandoffArgs(splitPresentation(rest, { valueFlags: ["--project", "--path", "--issue", "--task", "--detail", "--duplicate-ok", "--key"], edges: true }).operands);
|
|
94
|
+
if ("usage" in parsed) return fail(parsed.usage);
|
|
95
|
+
// #734: the person's list (age and reachability of each target) and sync (ask the targets now); both read the same rows `ahub board --handoffs` shows.
|
|
96
|
+
if ("view" in parsed) return showToolText((data, _c, now, ascii) => renderHandoffs(data, present.columns, now, ascii), await taskOp(parsed.view === "sync" ? "hub_task_handoff_sync" : "hub_task_handoffs", {}), present);
|
|
97
|
+
const text = await taskOp("hub_task_handoff", { ...parsed });
|
|
98
|
+
return showToolText((data, _c, now, ascii) => renderHandoffReceipt(data, present.columns, now, ascii), text, present);
|
|
99
|
+
}
|
|
100
|
+
if (sub !== "propose" || rest.length < 1) fail("usage: ahub task propose [<class>] <title...> | show <id> | assign <id> <peer> | unassign <id> | cancel <id> --reason <text> | escalate <id> | handoff --project <root|id> <title...>");
|
|
101
|
+
// `--class` is the explicit form. A first word that is a class name is still taken as the class (the documented
|
|
102
|
+
// short form), but said out loud: "review the auth module" would otherwise be filed as class review, silently.
|
|
103
|
+
const urgent = rest.includes("--urgent"), backlog = rest.includes("--backlog"), needsNetwork = rest.includes("--needs-network"), needsWorktree = rest.includes("--needs-worktree");
|
|
104
|
+
const flags = takeFlags(rest.filter((a) => a !== "--urgent" && a !== "--backlog" && a !== "--needs-network" && a !== "--needs-worktree"), ["--owner", "--detail", "--class"], ["--path", "--after"]);
|
|
105
|
+
const positional = !flags.one["--class"] && ((CLASSES as readonly string[]).includes(flags.rest[0] ?? "") || Object.hasOwn((() => { const config = projectConfig(); return resolveProfile(config.profile, config.profile_overrides); })().classes, flags.rest[0] ?? "")) && flags.rest.length > 1;
|
|
106
|
+
// #1433: a title word that is an option the command does not know, or -h, is refused before anything is filed. A lone `--` ends the options, so a title that starts with dashes can still be typed.
|
|
107
|
+
const stray = unknownOption(flags.rest);
|
|
108
|
+
if (stray) fail(unknownOptionRefusal(stray, "ahub task propose", subcommandUsage("task", "propose")));
|
|
109
|
+
const textWords = withoutSeparator(flags.rest);
|
|
110
|
+
const cls = flags.one["--class"] ?? (positional ? textWords[0] : undefined);
|
|
111
|
+
const title = (positional ? textWords.slice(1) : textWords).join(" ");
|
|
112
|
+
if (positional) warn(`"${cls}" was taken as the class and left out of the title`, "use --class <c> when the title itself starts with that word");
|
|
113
|
+
console.log(await taskOp("hub_task_propose", { ...(cls ? { class: cls } : {}), title, owner: flags.one["--owner"], detail: flags.one["--detail"], ...(flags.many["--path"]?.length ? { refs: { paths: flags.many["--path"] } } : {}), ...(flags.many["--after"]?.length ? { after: flags.many["--after"].map(Number) } : {}), ...(urgent ? { urgent: true } : {}), ...(needsNetwork ? { needs_network: true } : {}), ...(needsWorktree ? { needs_worktree: true } : {}), ...(backlog ? { backlog: true } : {}) }));
|
|
114
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { shellQuote } from "../shell-quote.ts";
|
|
2
|
+
import type { CommandContext } from "../command-context.ts";
|
|
3
|
+
|
|
4
|
+
export async function run(context: CommandContext) {
|
|
5
|
+
const { args, connect, cwd } = context;
|
|
6
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
7
|
+
const [peer, ...words] = args;
|
|
8
|
+
if (!peer || !words.length) fail("usage: ahub title <peer> <text...>");
|
|
9
|
+
const hub = await connect();
|
|
10
|
+
try {
|
|
11
|
+
const reply = await hub.request({ t: "title", peer, title: words.join(" ") }, 35_000).catch(() => ({ ok: false, error: "session title result is unconfirmed; the title may have been applied; check ahub status before retrying" }));
|
|
12
|
+
if (reply.ok === false && reply.error === "no answer from the hub within 35 s") fail("session title request timed out; the title may have been applied; check ahub status before retrying");
|
|
13
|
+
if (reply.ok !== true) fail(String(reply.error ?? `session title refused: ${String(reply.reason ?? "invalid")}; refresh ahub status, then retry`));
|
|
14
|
+
console.log(`${peer}: session title updated`);
|
|
15
|
+
if (typeof reply.previousTitle === "string") console.log(`To restore the previous title in a terminal:\ncd ${shellQuote(cwd)} && ahub title ${shellQuote(peer!)} ${shellQuote(reply.previousTitle)}`);
|
|
16
|
+
} finally { hub.close(); }
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { renderTurns } from "../output.ts";
|
|
2
|
+
import type { CommandContext } from "../command-context.ts";
|
|
3
|
+
|
|
4
|
+
export function run({ outputArguments, outputOptions, printOutput, takeFlags, turnRecords }: CommandContext) {
|
|
5
|
+
const options = outputOptions();
|
|
6
|
+
const { one, rest } = takeFlags(outputArguments(), ["--limit"], []);
|
|
7
|
+
const turns = turnRecords(t => t.list(rest[0], Number(one["--limit"]) || 20), []);
|
|
8
|
+
if (options.json) return console.log(JSON.stringify(turns, null, 2));
|
|
9
|
+
printOutput(renderTurns(turns, options.columns, Date.now()), options.color);
|
|
10
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { openManager, stopManager } from "../../hub/manager.ts";
|
|
3
|
+
import type { CommandContext } from "../command-context.ts";
|
|
4
|
+
|
|
5
|
+
export async function run(context: CommandContext) {
|
|
6
|
+
const { args, connect, delegatedPeer, setJsonBlockers, warn } = context;
|
|
7
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
8
|
+
const display = { json: args.includes("--json") };
|
|
9
|
+
setJsonBlockers(display.json);
|
|
10
|
+
const all = args.includes("--all");
|
|
11
|
+
const stop = args.includes("--stop"), noOpen = args.includes("--no-open");
|
|
12
|
+
const invalid = args.some(arg => !["--no-open", "--all", "--stop", "--settings", "--json"].includes(arg));
|
|
13
|
+
if (display.json && (invalid || (stop ? !all || noOpen : !noOpen)))
|
|
14
|
+
fail("usage: ahub ui [--settings] [--no-open [--json]] | --all [--no-open [--json]] | --all --stop [--json]");
|
|
15
|
+
if (invalid) fail("usage: ahub ui [--settings] [--no-open] | --all [--no-open] | --all --stop");
|
|
16
|
+
// #269: a settings session belongs to one project's hub; the unified dashboard stays an ordinary session.
|
|
17
|
+
const settings = args.includes("--settings");
|
|
18
|
+
if (settings && all) fail("ahub ui --settings opens one project's dashboard; run it without --all");
|
|
19
|
+
if (stop) {
|
|
20
|
+
if (!all || noOpen) fail("usage: ahub ui --all --stop");
|
|
21
|
+
await stopManager();
|
|
22
|
+
if (display.json) return console.log(JSON.stringify({ ok: true, stopped: true }));
|
|
23
|
+
return console.log("dashboard manager stopped; project hubs were kept running");
|
|
24
|
+
}
|
|
25
|
+
let url: string;
|
|
26
|
+
if (all) url = await openManager({ liveTest: !!delegatedPeer });
|
|
27
|
+
else {
|
|
28
|
+
const hub = await connect();
|
|
29
|
+
try {
|
|
30
|
+
const res = await hub.request({ t: "ui", ...(settings ? { settings: true } : {}), ...(delegatedPeer ? { liveTest: true } : {}) }, 10_000);
|
|
31
|
+
if (!res.ok) fail(res.error);
|
|
32
|
+
if (delegatedPeer && res.liveTest !== true) fail("this hub cannot restrict delegated dashboard content; use a live-test-capable hub");
|
|
33
|
+
// A hub older than #269 ignores the field and would hand out an ordinary session without saying so.
|
|
34
|
+
if (settings && res.settings !== true) fail("this hub does not open settings sessions; upgrade the running hub to use ahub ui --settings");
|
|
35
|
+
url = res.url;
|
|
36
|
+
} finally { hub.close(); }
|
|
37
|
+
}
|
|
38
|
+
if (settings) warn("Settings session: for 15 minutes this dashboard session may change permission modes, routing and start settings");
|
|
39
|
+
if (display.json) return console.log(JSON.stringify({
|
|
40
|
+
ok: true, url, origin: new URL(url).origin, mode: all ? "manager" : "hub", settings,
|
|
41
|
+
}));
|
|
42
|
+
if (args.includes("--no-open")) return console.log(url);
|
|
43
|
+
const opener = process.platform === "darwin" ? "open" : "xdg-open";
|
|
44
|
+
const opened = spawnSync(opener, [url], { stdio: "ignore", timeout: 10_000 });
|
|
45
|
+
if (opened.error || opened.status !== 0) console.log(`Open this one-time link within 60 seconds:\n${url}`);
|
|
46
|
+
else console.log("Dashboard opened. The session expires in one hour; run ahub ui to reopen it.");
|
|
47
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { effectiveInstanceRoles } from "../../hub/instances.ts";
|
|
2
|
+
import { resolveInstanceExecutionCwd } from "../../hub/instance-execution.ts";
|
|
3
|
+
import { readInstanceConfig } from "../../hub/instance-config.ts";
|
|
4
|
+
import { matchesPolicy } from "../../hub/path-policy.ts";
|
|
5
|
+
import { projectedDiff } from "../../hub/projected-diff.ts";
|
|
6
|
+
import { TextProjections } from "../../hub/text-projection.ts";
|
|
7
|
+
import { terminalText } from "../console-state.ts";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { realPath } from "../../hub/project.ts";
|
|
10
|
+
import { hasTree, planUndo, repoOf, restore } from "../../hub/snapshots.ts";
|
|
11
|
+
import { asciiMarkers } from "../console-state.ts";
|
|
12
|
+
import { renderLifecycleReceipt, renderUndoPlan } from "../reset-output.ts";
|
|
13
|
+
import type { CommandContext } from "../command-context.ts";
|
|
14
|
+
|
|
15
|
+
export async function run(context: CommandContext) {
|
|
16
|
+
const { args, cwd, printOutput, projectConfig, stateDir, taskOp, turnRecords, warn } = context;
|
|
17
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
18
|
+
const id = args.find((a) => !a.startsWith("--")) ?? fail("usage: ahub undo <turn> [--yes] [--context]");
|
|
19
|
+
const turn = turnRecords((t) => t.get(id), undefined) ?? fail(`no turn ${id} recorded (ahub turns lists them)`);
|
|
20
|
+
if (!turn.ended) fail(`turn ${id} is still running`);
|
|
21
|
+
const { start_tree: startTree, end_tree: endTree } = turn;
|
|
22
|
+
if (!startTree || !endTree) fail(`turn ${id} has no ${startTree ? "end" : "start"} snapshot: the hub stopped during it, or a snapshot failed (see hub.log)`);
|
|
23
|
+
const recordedWorkspace = turnRecords(t => t.workspace(id), undefined);
|
|
24
|
+
const undoWorkspace = (): string => {
|
|
25
|
+
// Old turns, including external peers and ids declared only later, belong to the canonical checkout.
|
|
26
|
+
if (recordedWorkspace === undefined) return cwd;
|
|
27
|
+
const { instances: declarations, catalog } = readInstanceConfig(cwd);
|
|
28
|
+
if (!declarations || !Object.hasOwn(declarations, turn.peer)) fail(`turn ${id}'s recorded instance is no longer declared; nothing was restored`);
|
|
29
|
+
const config = projectConfig();
|
|
30
|
+
const current = resolveInstanceExecutionCwd(cwd, turn.peer, declarations, effectiveInstanceRoles(turn.peer, declarations, config.roles, catalog), catalog);
|
|
31
|
+
if (realPath(current) !== realPath(recordedWorkspace)) fail(`turn ${id}'s recorded execution workspace changed; nothing was restored`);
|
|
32
|
+
return current;
|
|
33
|
+
};
|
|
34
|
+
const undoCwd = undoWorkspace();
|
|
35
|
+
const requireUndoWorkspace = () => {
|
|
36
|
+
if (realPath(undoWorkspace()) !== realPath(undoCwd)) fail(`turn ${id}'s execution workspace changed; nothing was restored`);
|
|
37
|
+
};
|
|
38
|
+
const repo = repoOf(undoCwd) ?? fail(`${undoCwd} is not in a git work tree`);
|
|
39
|
+
if (!hasTree(repo, startTree) || !hasTree(repo, endTree)) fail(`turn ${id}'s snapshots are gone from the git object store (git gc prunes them after two weeks)`);
|
|
40
|
+
// Another peer's turn that overlapped this one in time has its changes in this turn's diff as well.
|
|
41
|
+
const undoConfig = projectConfig();
|
|
42
|
+
const keep = Math.max(1, Number(undoConfig.snapshots.keep) || 20);
|
|
43
|
+
const overlapping = turnRecords((t) => t.overlapping(turn, keep), { paths: [] as string[], unknown: [] as string[] });
|
|
44
|
+
if (overlapping.unknown.length) fail(`refusing to undo ${id}: these turns of other peers ran at the same time and their changes are not known (still running, cut short, or not snapshotted): ${overlapping.unknown.join(", ")}`);
|
|
45
|
+
let reverted = false;
|
|
46
|
+
const plan = () => {
|
|
47
|
+
const p = planUndo(repo, { start_tree: startTree, end_tree: endTree, changed: turn.changed }, overlapping.paths);
|
|
48
|
+
if (p.undone) return p;
|
|
49
|
+
const why = [
|
|
50
|
+
p.changedSince.length ? `these files changed again after it ended, and restoring them would lose that work:\n ${p.changedSince.join("\n ")}` : "",
|
|
51
|
+
p.concurrent.length ? `these files were also changed by another peer's turn running at the same time, so the change may be theirs:\n ${p.concurrent.join("\n ")}` : "",
|
|
52
|
+
].filter(Boolean);
|
|
53
|
+
if (why.length) fail(`refusing to undo ${id}: ${why.join("\n")}${reverted ? "\nCodex's conversation was already reverted; restore the files later with ahub undo without --context" : ""}`);
|
|
54
|
+
return p;
|
|
55
|
+
};
|
|
56
|
+
// #798 D3: the hub saw these submodules dirty when the turn ended and cannot see inside them: they are never restored, and never counted as "no change".
|
|
57
|
+
const unobserved = turn.unobserved ?? [];
|
|
58
|
+
const first = plan();
|
|
59
|
+
printOutput(renderUndoPlan({ id, restore: first.restore, unobserved, undone: first.undone }, undefined, undefined, asciiMarkers(process.env)), false);
|
|
60
|
+
if (first.undone) return;
|
|
61
|
+
const projections = new TextProjections({ cwd: undoCwd, stateDir, config: undoConfig.text_projection ?? {}, deny: undoConfig.local.deny, readAllow: undoConfig.local.read_allow, log: line => warn(line) });
|
|
62
|
+
const preview = projectedDiff({ repo, from: endTree, to: startTree, paths: first.restore, projections, deny: undoConfig.local.deny, privatePath: path => matchesPolicy(undoCwd, join(repo.top, path), undoConfig.pii?.paths ?? []) });
|
|
63
|
+
if (preview) printOutput(renderLifecycleReceipt({ lines: [terminalText("Undo preview (end snapshot to start snapshot):\n" + preview)] }), false);
|
|
64
|
+
|
|
65
|
+
if (!args.includes("--yes")) return printOutput(renderLifecycleReceipt({ lines: ["nothing was changed; add --yes to restore these files"] }), false);
|
|
66
|
+
requireUndoWorkspace();
|
|
67
|
+
if (args.includes("--context")) {
|
|
68
|
+
printOutput(renderLifecycleReceipt({ lines: [await taskOp("turn_revert", { turn: id })] }), false);
|
|
69
|
+
reverted = true;
|
|
70
|
+
}
|
|
71
|
+
// A peer may have written meanwhile (the revert alone can take seconds): plan again right before restoring.
|
|
72
|
+
const second = plan();
|
|
73
|
+
if (second.restore.join("\0") !== first.restore.join("\0")) fail(`the project changed while undoing; nothing was restored, run ahub undo again${reverted ? " without --context (Codex's conversation was already reverted)" : ""}`);
|
|
74
|
+
requireUndoWorkspace();
|
|
75
|
+
restore(repo, startTree, second.restore);
|
|
76
|
+
if (second.restore.length) printOutput(renderLifecycleReceipt({ lines: [`restored to their state before ${id}`] }), false);
|
|
77
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { terminalText } from "../console-state.ts";
|
|
2
|
+
import { loadConfig } from "../../hub/config.ts";
|
|
3
|
+
import { hubHome } from "../../hub/project.ts";
|
|
4
|
+
import { startProject } from "../../hub/lifecycle.ts";
|
|
5
|
+
import { UNATTENDED_WARNING } from "../launch.ts";
|
|
6
|
+
import { personEnv } from "../../hub/child-process.ts";
|
|
7
|
+
import { effectiveStartAgents, startProjectAgents } from "../start-agents-run.ts";
|
|
8
|
+
import { runConsole } from "../console.ts";
|
|
9
|
+
import type { CommandContext } from "../command-context.ts";
|
|
10
|
+
|
|
11
|
+
export async function run(context: CommandContext) {
|
|
12
|
+
const { args, caller, connect, consoleInstalled, continuationId, continuationPeer, cwd, identity, liveTest, recoveryLauncherCurrent, registeredProject, stateDir, unattendedEnv, upHubCheck, upJsonDocument, warn } = context;
|
|
13
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
14
|
+
// #1798: --wait is checked before the hub or any agent starts, so a bad value costs nothing (`upWait` is the one place it is read).
|
|
15
|
+
const waitIndex = args.indexOf("--wait"), waitText = waitIndex >= 0 ? args[waitIndex + 1] : undefined;
|
|
16
|
+
const upWaitS = waitIndex < 0 ? 15 : waitText === undefined || !/^\d+$/.test(waitText) ? NaN : Number(waitText);
|
|
17
|
+
if (!(upWaitS <= 600)) return fail(`--wait needs a whole number of seconds from 0 to 600, got ${waitText === undefined || waitText === "" ? "nothing" : `"${terminalText(waitText)}"`}; nothing was started. Next: ahub up --wait 15`);
|
|
18
|
+
const unattended = unattendedEnv || args.includes("--unattended");
|
|
19
|
+
if (unattended) console.error(UNATTENDED_WARNING);
|
|
20
|
+
const status = await startProject(registeredProject(), { unattended, liveTest, starting: pid => console.error(`ahub: hub is still starting, pid ${pid}; waiting for readiness, run ahub status in another terminal to inspect progress`), ...(recoveryLauncherCurrent ? { current: recoveryLauncherCurrent, env: { ...personEnv(process.env), AGENTHUB_RECOVERY_OPERATION: continuationId, AGENTHUB_PEER_ID: continuationPeer, AGENTHUB_RECOVERY_CONDUCTOR: continuationPeer, AGENTHUB_RECOVERY_CONTINUATION: continuationId } } : {}) });
|
|
21
|
+
// #1798: under --json stdout holds exactly one JSON document, so the banner and the start lines go to stderr; their text is unchanged.
|
|
22
|
+
const upJson = args.includes("--json") && !recoveryLauncherCurrent, stdoutLog = console.log;
|
|
23
|
+
if (upJson) console.log = (...parts: unknown[]) => { process.stderr.write(`${parts.join(" ")}\n`); };
|
|
24
|
+
console.log(`ahub up (ws://127.0.0.1:${status.controlPort}), state in ${stateDir}`);
|
|
25
|
+
if (recoveryLauncherCurrent) { recoveryLauncherCurrent(); return; }
|
|
26
|
+
// #608: the default agent set, only for a person's own `ahub up` (never an agent's, a live test's, or an upgrade or recovery relaunch, which set AGENTHUB_RECOVERY_OPERATION).
|
|
27
|
+
let upAgents: readonly string[] | undefined;
|
|
28
|
+
if (!args.includes("--no-agents") && !liveTest && caller.role === "console" && identity.role === "console" && !process.env.AGENTHUB_RECOVERY_OPERATION) {
|
|
29
|
+
try {
|
|
30
|
+
const chosen = effectiveStartAgents(cwd, loadConfig(cwd).start.agents, hubHome(), [cwd]);
|
|
31
|
+
if (chosen.notice) warn(chosen.notice);
|
|
32
|
+
for (const line of await startProjectAgents({ root: cwd, stateDir }, chosen.agents)) console.log(terminalText(line));
|
|
33
|
+
upAgents = chosen.agents;
|
|
34
|
+
} catch (error) { warn(`default agents were not started: ${terminalText((error as Error).message)}`); }
|
|
35
|
+
}
|
|
36
|
+
const upCheck = upAgents && await upHubCheck(upAgents, upWaitS, upJson);
|
|
37
|
+
if (upJson) { console.log = stdoutLog; await upJsonDocument(upCheck); return; }
|
|
38
|
+
if (process.stdin.isTTY && process.stdout.isTTY && !args.includes("--no-console")) await runConsole({ client: await connect(), cwd, stateDir, liveTest, installed: consoleInstalled() });
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { refuseMissingFlagValue } from "./shared-refusals.ts";
|
|
2
|
+
import { USAGE_GROUPS, LIMITS_MAX } from "../../hub/usage-rollup.ts";
|
|
3
|
+
import { renderUsage, renderLimits, renderTotal } from "../output.ts";
|
|
4
|
+
import type { CommandContext } from "../command-context.ts";
|
|
5
|
+
|
|
6
|
+
export async function run(context: CommandContext) {
|
|
7
|
+
const { args, connect, outputArguments, outputOptions, printOutput, since } = context;
|
|
8
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
9
|
+
const options = outputOptions();
|
|
10
|
+
const rest = outputArguments();
|
|
11
|
+
const sub = rest[0] !== undefined && !rest[0].startsWith("--") ? rest[0] : undefined;
|
|
12
|
+
if (sub !== undefined && !["limits", "total"].includes(sub)) fail("usage: ahub usage [--since 7d|<iso>] [--by peer|task|issue|pr|release|day|model] [--json] | limits [--peer <id>] [--limit <n>] [--json] | total [--json]");
|
|
13
|
+
const flags = sub === undefined ? rest : rest.slice(1);
|
|
14
|
+
const valueFlags = sub === "limits" ? ["--peer", "--limit"] : sub === undefined ? ["--since", "--by"] : [];
|
|
15
|
+
for (let i = 0; i < flags.length; i++) {
|
|
16
|
+
if (!valueFlags.includes(flags[i]!)) fail(`unknown argument ${JSON.stringify(flags[i]!.slice(0, 40))}; run ahub help`);
|
|
17
|
+
if (flags[++i] === undefined || flags[i]!.startsWith("--")) refuseMissingFlagValue(fail, flags[i - 1]);
|
|
18
|
+
}
|
|
19
|
+
const value = (flag: string) => { const at = args.indexOf(flag); return at >= 0 ? args[at + 1] : undefined; };
|
|
20
|
+
const by = value("--by"), peer = value("--peer"), limitText = value("--limit");
|
|
21
|
+
const limit = limitText === undefined ? undefined : /^\d+$/.test(limitText) ? Number(limitText) : NaN;
|
|
22
|
+
if (limit !== undefined && !(limit >= 1 && limit <= LIMITS_MAX)) fail(`--limit takes a whole number from 1 to ${LIMITS_MAX}`);
|
|
23
|
+
if (by !== undefined && !(USAGE_GROUPS as readonly string[]).includes(by)) fail(`--by takes ${USAGE_GROUPS.join(", ")}`);
|
|
24
|
+
const from = since();
|
|
25
|
+
const hub = await connect();
|
|
26
|
+
const reply = await hub.request(sub === "limits" ? { t: "usage", op: "limits", ...(peer ? { peer } : {}), ...(limit !== undefined ? { limit } : {}) } : sub === "total" ? { t: "usage", op: "total" }
|
|
27
|
+
: { t: "usage", op: "query", by: by ?? "peer", ...(from ? { since: from } : {}) }, 35_000);
|
|
28
|
+
hub.close();
|
|
29
|
+
if (!reply.ok) return fail(String(reply.error ?? "usage refused"));
|
|
30
|
+
if (reply.behind) process.stderr.write("ahub: the usage roll-up is still catching up with the event log: these numbers are partial; run it again in a few seconds\n");
|
|
31
|
+
if (options.json) return console.log(JSON.stringify(sub === "limits" ? { limits: reply.limits, current: reply.current } : sub === "total" ? reply.total : reply.usage, null, 2));
|
|
32
|
+
printOutput(sub === "limits" ? renderLimits(reply.limits, reply.current, options.columns) : sub === "total" ? renderTotal(reply.total, options.columns) : renderUsage(reply.usage, options.columns), options.color);
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { attachWatch } from "../watch.ts";
|
|
2
|
+
import { resolveColor, streamEnv } from "../console-state.ts";
|
|
3
|
+
import type { CommandContext } from "../command-context.ts";
|
|
4
|
+
|
|
5
|
+
export async function run(context: CommandContext) {
|
|
6
|
+
const { args, connect, peerDefinition } = context;
|
|
7
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
8
|
+
const peer = args[0];
|
|
9
|
+
if (typeof peer !== "string" || !peerDefinition(peer)?.capabilities?.watch) fail("usage: ahub watch kimi|qwen [--no-thoughts] [--color=auto|always|never]");
|
|
10
|
+
if (args.slice(1).some(arg => arg !== "--no-thoughts" && !/^--color=(auto|always|never)$/.test(arg))) fail("unsupported watch option");
|
|
11
|
+
const color = resolveColor(args.find(arg => arg.startsWith("--color="))?.slice(8), streamEnv(!!process.stdout.isTTY), "ahub");
|
|
12
|
+
if (color instanceof Error) fail(color.message);
|
|
13
|
+
const hub = await connect();
|
|
14
|
+
const input = process.stdin;
|
|
15
|
+
const raw = !!input.isRaw;
|
|
16
|
+
let leave = () => {};
|
|
17
|
+
const closed = new Promise<void>(resolve => { leave = resolve; });
|
|
18
|
+
const key = (chunk: Buffer) => { if (chunk.includes(3) || chunk.toString().includes("q")) leave(); };
|
|
19
|
+
hub.onClose = leave;
|
|
20
|
+
process.on("SIGINT", leave);
|
|
21
|
+
try {
|
|
22
|
+
await attachWatch(hub, peer, line => console.log(line), { columns: () => process.stdout.columns || 80, color, noThoughts: args.includes("--no-thoughts") });
|
|
23
|
+
if (input.isTTY) { input.setRawMode(true); input.on("data", key); input.resume(); }
|
|
24
|
+
await closed;
|
|
25
|
+
} finally {
|
|
26
|
+
input.off("data", key); process.off("SIGINT", leave);
|
|
27
|
+
if (input.isTTY) input.setRawMode(raw);
|
|
28
|
+
input.pause(); hub.close();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { hubGitSync, hubGitEnv } from "../../hub/git.ts";
|
|
2
|
+
import { confirmTidy, planTidy, realTidyGit, rowsFromReply, type TidyGit } from "../worktree-tidy.ts";
|
|
3
|
+
import { renderTidyPreview, renderTidyResult, renderWorktrees } from "../worktrees-output.ts";
|
|
4
|
+
import { asciiMarkers } from "../console-state.ts";
|
|
5
|
+
import type { CommandContext } from "../command-context.ts";
|
|
6
|
+
|
|
7
|
+
export async function run(context: CommandContext) {
|
|
8
|
+
const { connect, cwd, outputArguments, outputOptions, printOutput } = context;
|
|
9
|
+
const fail: CommandContext["fail"] = context.fail;
|
|
10
|
+
const options = outputOptions();
|
|
11
|
+
const rest = outputArguments();
|
|
12
|
+
const sub = rest[0] === "tidy" ? "tidy" : undefined;
|
|
13
|
+
const flags = sub ? rest.slice(1) : rest;
|
|
14
|
+
const at = flags.indexOf("--confirm");
|
|
15
|
+
const fingerprint = at >= 0 ? flags[at + 1] : undefined;
|
|
16
|
+
const known = flags.every((arg, i) => arg === "--confirm" || i === at + 1 && at >= 0);
|
|
17
|
+
if ((rest.length && !sub && rest.some(arg => !arg.startsWith("--"))) || !known || (at >= 0 && (!sub || fingerprint === undefined || fingerprint.startsWith("--"))) || (sub === undefined && at >= 0)) fail("usage: ahub worktrees [--json] | tidy [--json] | tidy --confirm <fingerprint>");
|
|
18
|
+
const hub = await connect();
|
|
19
|
+
const reply = await hub.request({ t: "worktrees" }, 20_000);
|
|
20
|
+
hub.close();
|
|
21
|
+
if (!reply.ok) return fail(String(reply.error ?? "the worktree shelf is unavailable"));
|
|
22
|
+
if (!sub) return options.json ? console.log(JSON.stringify({ live: reply.live, settled: reply.settled, complete: reply.complete }, null, 2)) : printOutput(renderWorktrees(reply, options.columns, Date.now(), asciiMarkers(process.env, process.argv.includes("--ascii"))), options.color);
|
|
23
|
+
// tidy: read-only git in this process to decide what is safe; the daemon only said which rows are settled.
|
|
24
|
+
const git: TidyGit = realTidyGit((argv, dir) => { const run = hubGitSync(argv, { cwd: dir, encoding: "utf8", timeout: 20_000, maxBuffer: 4 * 1024 * 1024, env: hubGitEnv(process.env, { repositoryIsolation: true }) }); return run.error ? undefined : { status: run.status, stdout: String(run.stdout ?? "") }; });
|
|
25
|
+
const plan = planTidy(rowsFromReply(reply.settled ?? [], cwd, git), cwd, git);
|
|
26
|
+
if (at < 0) return options.json ? console.log(JSON.stringify({ entries: plan.entries, removable: plan.removable, fingerprint: plan.fingerprint }, null, 2)) : printOutput(renderTidyPreview(plan, options.columns, Date.now(), asciiMarkers(process.env, process.argv.includes("--ascii"))), options.color);
|
|
27
|
+
const result = confirmTidy(plan, fingerprint!, cwd, git);
|
|
28
|
+
if (!result.ok) return fail(result.error);
|
|
29
|
+
if (options.json) return console.log(JSON.stringify({ outcomes: result.outcomes }, null, 2));
|
|
30
|
+
printOutput(renderTidyResult(result.outcomes, options.columns, Date.now(), asciiMarkers(process.env, process.argv.includes("--ascii"))), options.color);
|
|
31
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { ControlClient, readControl } from "../hub/control-client.ts";
|
|
4
|
-
import { loadConfig, type HubConfig } from "../hub/
|
|
4
|
+
import { loadConfig, type HubConfig } from "../hub/config.ts";
|
|
5
5
|
import { captureRecoveryPolicy, readRecoveryPolicyInputs, type RecoveryPolicyInputs } from "../hub/recovery-policy.ts";
|
|
6
6
|
import { authorizeConductorRecovery, assertConductorRecovery, retireConductorRecovery, RecoveryAuthorityError, type ConductorRecoveryBinding } from "../hub/recovery-authority.ts";
|
|
7
7
|
import { operationPath } from "../hub/recovery-store.ts";
|