@staix/agent-hub 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/README.md +28 -12
- package/docs/adding-an-ai-tool.md +7 -5
- package/docs/agent-notes/README.md +23 -0
- package/docs/agent-notes/adapters.md +9 -5
- package/docs/agent-notes/benchmarks.md +2 -0
- package/docs/agent-notes/budget.md +9 -0
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +21 -9
- package/docs/agent-notes/local-worker.md +4 -2
- package/docs/agent-notes/security-review.md +56 -0
- package/docs/agent-notes/tasks.md +22 -6
- package/docs/agent-notes/tests.md +10 -9
- package/docs/contracts/companion-cli-v1.json +4 -0
- package/docs/design/adapters.md +142 -0
- package/docs/design/agent-hub-architecture.md +46 -1
- package/docs/design/agent-hub.md +10 -0
- package/docs/design/bus.md +7 -0
- package/docs/design/cli-output.md +183 -0
- package/docs/design/execution-reference.md +6 -1
- package/docs/design/roadmap.md +191 -0
- package/docs/design/task-board.md +185 -5
- package/docs/dogfood.md +30 -9
- package/docs/events.md +7 -7
- package/docs/memory.md +5 -5
- package/docs/operations.md +315 -54
- package/docs/profiles.md +101 -8
- package/docs/quickstart.md +47 -6
- package/docs/research.md +6 -3
- package/docs/roles.md +52 -0
- package/docs/sdlc.md +190 -2
- package/docs/security.md +90 -15
- package/docs/text-projection.md +1 -0
- package/docs/verification/2026-11-13-claude-implementer-2.1.323.md +59 -0
- package/docs/verification/2026-11-13-codex-01672-reviewer-isolation.md +69 -0
- package/docs/verification/2026-11-14-0.39.0.md +51 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-isolation.md +70 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md +48 -0
- package/docs/verification/2026-11-14-pi-152-compat.md +45 -0
- package/docs/verification/2026-11-15-0.40.0.md +39 -0
- package/docs/verification/2026-11-16-pi-loopback-1447.md +39 -0
- package/docs/verification/pi-152-model-free.ts +57 -0
- package/docs/verification/pi-152-native.mjs +21 -0
- package/docs/verified.json +48 -25
- package/package.json +4 -4
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +2266 -530
- package/plugins/agent-hub/kimi-review-policy-worker.js +16 -11
- package/plugins/agent-hub/server.js +2423 -645
- package/src/adapters/acp-model-policy.ts +1 -1
- package/src/adapters/acp-session-model.ts +35 -0
- package/src/adapters/acp.ts +14 -0
- package/src/adapters/agy/definition.ts +2 -2
- package/src/adapters/agy/hooks.ts +7 -0
- package/src/adapters/claude-channel.ts +1 -1
- package/src/adapters/claude-implementer.ts +8 -0
- package/src/adapters/claude-print-child.ts +26 -2
- package/src/adapters/claude-print.ts +4 -0
- package/src/adapters/codex-appserver.ts +90 -16
- package/src/adapters/codex-review-isolation.ts +63 -17
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/conformance/fakes/acp-server.ts +11 -2
- package/src/adapters/conformance/fakes/app-server.ts +5 -1
- package/src/adapters/conformance/fakes/pi-rpc.ts +1 -1
- package/src/adapters/definitions/builtin-metadata.ts +12 -12
- package/src/adapters/definitions/native-cli-jcode-mcp.ts +18 -3
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-config-policy.ts +1 -1
- package/src/adapters/definitions/native-quota.ts +122 -0
- package/src/adapters/definitions/native-recovery.ts +3 -0
- package/src/adapters/definitions/qwen.ts +2 -2
- package/src/adapters/kimi-review.ts +23 -0
- package/src/adapters/kimi-wire-usage.ts +39 -16
- package/src/adapters/local-worker.ts +9 -4
- package/src/adapters/pi-state-model.ts +12 -0
- package/src/adapters/pi.ts +76 -11
- package/src/adapters/print-result-model.ts +24 -0
- package/src/adapters/registry-types.ts +12 -2
- package/src/adapters/registry.ts +19 -2
- package/src/adapters/reviewer-print.ts +132 -16
- package/src/adapters/role-eligibility.ts +99 -0
- package/src/adapters/same-directory.ts +16 -0
- package/src/cli/agy-mcp.ts +18 -7
- package/src/cli/answer-args.ts +11 -3
- package/src/cli/console-question.ts +1 -1
- package/src/cli/console-state.ts +98 -11
- package/src/cli/console.ts +6 -2
- package/src/cli/error-format.ts +19 -0
- package/src/cli/free-text.ts +20 -0
- package/src/cli/handoff-args.ts +1 -1
- package/src/cli/help.ts +350 -30
- package/src/cli/identity-audit.ts +8 -7
- package/src/cli/identity.ts +27 -4
- package/src/cli/init-prompt.ts +31 -2
- package/src/cli/init-roles.ts +156 -0
- package/src/cli/init-settings.ts +24 -2
- package/src/cli/init.ts +232 -17
- package/src/cli/main.js +2 -2
- package/src/cli/main.ts +250 -69
- package/src/cli/model.ts +1 -1
- package/src/cli/output-standard.ts +56 -0
- package/src/cli/output.ts +199 -9
- package/src/cli/preview.ts +1 -1
- package/src/cli/recovery-launch.ts +114 -0
- package/src/cli/recovery-package.ts +14 -7
- package/src/cli/recovery-version-preflight.ts +104 -0
- package/src/cli/roadmap.ts +215 -0
- package/src/cli/role-doctor.ts +39 -0
- package/src/cli/sdlc-output.ts +66 -1
- package/src/cli/smoke-pty-bridge.ts +7 -24
- package/src/cli/study-output.ts +54 -0
- package/src/cli/study.ts +14 -1
- package/src/cli/task-output.ts +3 -1
- package/src/cli/terminal-recovery.ts +14 -0
- package/src/cli/upgrade-presentation-flags.ts +2 -2
- package/src/cli/upgrade-presentation.ts +4 -0
- package/src/cli/upgrade-restore-state.ts +12 -3
- package/src/cli/upgrade-runtime.ts +40 -2
- package/src/cli/upgrade.ts +8 -4
- package/src/hub/advisor-survey.ts +139 -0
- package/src/hub/audit-source.ts +66 -0
- package/src/hub/board.ts +677 -15
- package/src/hub/budget.ts +54 -4
- package/src/hub/bus.ts +9 -0
- package/src/hub/check-runner.ts +3 -4
- package/src/hub/ci-watch.ts +19 -4
- package/src/hub/conductor.ts +14 -8
- package/src/hub/config-apply.ts +2 -1
- package/src/hub/config-edit-host.ts +77 -5
- package/src/hub/considered-findings.ts +47 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +585 -98
- package/src/hub/deliverable-files.ts +17 -1
- package/src/hub/dogfood-profile.ts +3 -2
- package/src/hub/events.ts +25 -4
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/folder-trigger.ts +11 -4
- package/src/hub/github-import.ts +81 -0
- package/src/hub/hub-tools.ts +117 -20
- package/src/hub/install-policy.ts +23 -0
- package/src/hub/kimi-usage.ts +34 -2
- package/src/hub/lifecycle-schema.ts +3 -3
- package/src/hub/memory-profile.ts +9 -1
- package/src/hub/memory-sync-state.ts +1 -0
- package/src/hub/model-overrides.ts +2 -1
- package/src/hub/no-writes.ts +5 -0
- package/src/hub/operational-authority.ts +8 -1
- package/src/hub/operational-view.ts +6 -2
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-failure.ts +7 -0
- package/src/hub/plan-conformance.ts +20 -2
- package/src/hub/question-desk.ts +26 -7
- package/src/hub/questions.ts +33 -5
- package/src/hub/quota-account.ts +34 -0
- package/src/hub/recovery-policy.ts +18 -4
- package/src/hub/research-evidence.ts +51 -3
- package/src/hub/research.ts +77 -13
- package/src/hub/restart.ts +21 -0
- package/src/hub/review-budget.ts +88 -0
- package/src/hub/review-findings.ts +93 -12
- package/src/hub/reviewer-pool-config.ts +6 -2
- package/src/hub/reviewer-pool.ts +39 -6
- package/src/hub/roadmap-triage.ts +86 -0
- package/src/hub/roadmap-unplaced.ts +169 -0
- package/src/hub/roadmap-view.ts +83 -0
- package/src/hub/roadmap.ts +127 -0
- package/src/hub/routing.ts +7 -3
- package/src/hub/sdlc-merge.ts +6 -5
- package/src/hub/sdlc-queue.ts +17 -7
- package/src/hub/sdlc-release.ts +1 -1
- package/src/hub/sdlc.ts +47 -8
- package/src/hub/security-audit.ts +178 -0
- package/src/hub/security-pass.ts +115 -0
- package/src/hub/settings.ts +11 -5
- package/src/hub/source-read.ts +80 -2
- package/src/hub/sources.ts +57 -9
- package/src/hub/specs-task.ts +7 -0
- package/src/hub/startup-event-seeds.ts +5 -3
- package/src/hub/startup-timing.ts +1 -0
- package/src/hub/synthesis-readiness.ts +279 -0
- package/src/hub/task-sweep.ts +29 -2
- package/src/hub/task-worktree.ts +37 -0
- package/src/hub/tasks.ts +1464 -76
- package/src/hub/text-projection.ts +11 -1
- package/src/memory/capture.ts +2 -1
- package/src/pi/dependency-publish.ts +50 -0
- package/src/pi/extension.ts +1 -1
- package/src/pi/launch.ts +1 -1
- package/src/pi/task-dependencies.ts +249 -0
- package/src/ui/index.html +56 -13
- package/src/ui/office-model.ts +11 -3
- package/src/ui/office-space.ts +50 -30
- package/src/ui/plugin-questions.ts +5 -0
- package/src/ui/plugin.ts +27 -12
- package/templates/config.json +1 -1
package/src/cli/main.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { runtimePruneHealth } from "../hub/runtime-prune-health.ts";
|
|
|
4
4
|
import { conductorLocalOperation, conductorOperation, OPERATIONAL_PERSON_GUIDANCE } from "../hub/operational-authority.ts";
|
|
5
5
|
import { sayRecipients } from "./say-input.ts";
|
|
6
6
|
import { parseAnswerArgs } from "./answer-args.ts";
|
|
7
|
+
import { parseRoadmapArgs, renderRoadmap } from "./roadmap.ts";
|
|
7
8
|
import type { DeliverableRow } from "../hub/tasks.ts";
|
|
8
9
|
import { kimiSourceRow } from "../hub/budget-notes.ts";
|
|
9
10
|
import { hubGitSync, hubGitEnv } from "../hub/git.ts";
|
|
@@ -14,8 +15,8 @@ import { assessVersion, COMPAT, configuredCommands } from "../adapters/compat.ts
|
|
|
14
15
|
import { claudePeer as defaultChannelPeer } from "../hub/claude-state.ts";
|
|
15
16
|
import { effectiveInstanceRoles } from "../hub/instances.ts";
|
|
16
17
|
import { resolveInstanceExecutionCwd } from "../hub/instance-execution.ts";
|
|
17
|
-
import { readInstanceRoleConfig, readInstanceConfig, type InstanceRoleConfig } from "../hub/instance-config.ts";
|
|
18
|
-
import { staleInstanceKey } from "../hub/roster.ts";
|
|
18
|
+
import { readInstanceRoleConfig, readInstanceConfig, readInstanceConfigLayers, type InstanceRoleConfig } from "../hub/instance-config.ts";
|
|
19
|
+
import { staleInstanceKey, rosterAllows } from "../hub/roster.ts";
|
|
19
20
|
import { parseConfiguredAcpArguments, runConfiguredAcpEntry, requireActiveConfiguredAcp } from "./configured-acp-entry.ts";
|
|
20
21
|
import type { NativeCliEntryContext } from "../adapters/definitions/native-cli-entry-types.ts";
|
|
21
22
|
import { BUILTIN_CLI_ENTRIES, createProjectAdapterCatalog, definitionOf, DOCTOR_TOOL_PROBES, DOCTOR_MEMORY_CAPTURE_PEERS, DOCTOR_PLUGIN_PROBE, nativeDoctorCheck, nativeMemoryCaptureRow, type MemorySetupReading, nativeDoctorRecoveryIdentity, nativeDoctorOptionalProbes } from "../adapters/registry.ts";
|
|
@@ -23,17 +24,18 @@ import { parsePiFlags } from "../adapters/definitions/native-cli-pi.ts";
|
|
|
23
24
|
import { supportsBoardReleaseFilter, supportsBoardColumnMetadata, readAllTasks } from "./board-read.ts";
|
|
24
25
|
import { matchesPolicy } from "../hub/path-policy.ts";
|
|
25
26
|
import { projectedDiff } from "../hub/projected-diff.ts";
|
|
26
|
-
import { TextProjections } from "../hub/text-projection.ts";
|
|
27
|
-
import { fetchSourceUrl, MAX_SOURCE_BYTES, publicSourceView, screenRegistration, SourceRegistry, validSourceId, type SourceMeta } from "../hub/sources.ts";
|
|
27
|
+
import { TextProjections, type ProjectedText } from "../hub/text-projection.ts";
|
|
28
|
+
import { fetchSourceUrl, MAX_SOURCE_BYTES, publicSourceView, screenRegistration, sourceProjectionReceipt, SourceRegistry, validSourceId, type SourceMeta } from "../hub/sources.ts";
|
|
28
29
|
import { renderSourceAdd, renderSourceList } from "./source-output.ts";
|
|
29
30
|
import { renderScheduleChange, renderScheduleList, renderScheduleRun } from "./schedule-output.ts";
|
|
30
31
|
import { renderIntake, renderIntakeChange } from "./intake-output.ts";
|
|
31
32
|
import { renderLearnChange, renderLearnList } from "./learn-output.ts";
|
|
32
33
|
import { renderCapabilities } from "./capabilities-output.ts";
|
|
34
|
+
import { parseSynthesisManifest, synthesisManifestHash } from "../hub/synthesis-readiness.ts";
|
|
33
35
|
import { parseStudyArgs } from "./study.ts";
|
|
34
36
|
import { parseBacklogReturn } from "./backlog-return-args.ts";
|
|
35
37
|
import { parseResultsArgs } from "./results-args.ts";
|
|
36
|
-
import { renderExperiments, renderStudyList, renderStudyReceipt, renderStudyShow } from "./study-output.ts";
|
|
38
|
+
import { renderStudyEvidence, renderSynthesisReadiness, renderExperiments, renderStudyList, renderStudyReceipt, renderStudyShow } from "./study-output.ts";
|
|
37
39
|
import { renderHandoffReceipt, renderHandoffs } from "./handoff-output.ts";
|
|
38
40
|
import { parseHandoffArgs } from "./handoff-args.ts";
|
|
39
41
|
import { terminalText } from "./console-state.ts";
|
|
@@ -60,6 +62,7 @@ import { qwenSessionId } from "../hub/crash.ts";
|
|
|
60
62
|
import { isPermissionMode } from "../hub/permission-mode.ts";
|
|
61
63
|
import { parseSettingText, settingDef, settingText, undoableDef, type SettingRow } from "../hub/settings.ts";
|
|
62
64
|
import { startModeOf } from "../hub/start-mode.ts";
|
|
65
|
+
import { rolesRow } from "./role-doctor.ts";
|
|
63
66
|
import { currentRouting, OVERLAY_FILE, parseOverlay, parseRouting, routingText, type Routing, type RoutingOverlay } from "../hub/routing.ts";
|
|
64
67
|
import { spawn, spawnSync } from "node:child_process";
|
|
65
68
|
import { chmodSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -77,9 +80,10 @@ import { inspectProject, startProject, stopProject, runProjectDaemon } from "../
|
|
|
77
80
|
import { processLiveness, processSignature } from "../pi/process-signature.ts";
|
|
78
81
|
import { openManager, startManager, stopManager } from "../hub/manager.ts";
|
|
79
82
|
import { OmniRoute } from "../omniroute/client.ts";
|
|
80
|
-
import { autonomyInheritanceChange, init, initNextSteps, initResearchDefault, withInitResearch, initSettingRows, planInit } from "./init.ts";
|
|
83
|
+
import { autonomyInheritanceChange, init, initNextSteps, initResearchDefault, withInitResearch, initSettingRows, planInit, sharedConfigRow } from "./init.ts";
|
|
81
84
|
import { discoverInitChecks, withInitChecks } from "./init-required-checks.ts";
|
|
82
85
|
import { INIT_USAGE, parseInitSettings } from "./init-settings.ts";
|
|
86
|
+
import { installedPeers } from "./init-roles.ts";
|
|
83
87
|
import { promptGate, runInitPrompt, settingLines, shadowOffered, type InitAnswers } from "./init-prompt.ts";
|
|
84
88
|
import { loadPacks } from "../hub/packs.ts";
|
|
85
89
|
import { launcherPreview } from "./preview.ts";
|
|
@@ -88,7 +92,7 @@ import { configureKimiMcp } from "./kimi-mcp.ts";
|
|
|
88
92
|
import { nextStep, parseList, pluginState, type InstalledPlugin, type Marketplace } from "./setup.ts";
|
|
89
93
|
import { CLASSES } from "../hub/board.ts";
|
|
90
94
|
import { VERSION } from "../version.ts";
|
|
91
|
-
import { freeText } from "./free-text.ts";
|
|
95
|
+
import { freeText, unknownOption, unknownOptionRefusal, withoutSeparator } from "./free-text.ts";
|
|
92
96
|
import { createInterface } from "node:readline/promises";
|
|
93
97
|
import { createInterface as lineReader } from "node:readline";
|
|
94
98
|
import { activeOperation, assertLifecycleAvailable, operationIdPattern, readOperation, writeOperation, recoveryLock, recoveryRunner, signedRunner, stopSignedRunner, supportsAction } from "../hub/recovery-store.ts";
|
|
@@ -116,7 +120,7 @@ import { runSpecs, runSpecsStamp } from "./specs.ts";
|
|
|
116
120
|
import { confirmTidy, planTidy, realTidyGit, rowsFromReply, type TidyGit } from "./worktree-tidy.ts";
|
|
117
121
|
import { renderTidyPreview, renderTidyResult, renderWorktrees } from "./worktrees-output.ts";
|
|
118
122
|
import { formatMemoryStaleAnchors } from "../hub/memory-stale-anchors.ts";
|
|
119
|
-
import { AGENT_MEM_VERSION, assertAgentMemVersion, selectedMemoryProfile } from "../hub/memory-profile.ts";
|
|
123
|
+
import { AGENT_MEM_VERSION, assertAgentMemVersion, memoryIndexExists, selectedMemoryProfile } from "../hub/memory-profile.ts";
|
|
120
124
|
import { checkMemoryProfiles, formatMemoryProfileCheck } from "../hub/memory-profile-check.ts";
|
|
121
125
|
import { addonReport, appendRecords, closedAtOf, formatAddons, formatResearch, LABELS, labelTarget, RESEARCH_SCHEMA, projectKey, readStores, researchReport, taskRecords, toCsv, type Label, type TaskRecord } from "../hub/research.ts";
|
|
122
126
|
import { summarize, summarizeByTask } from "../hub/report.ts";
|
|
@@ -130,12 +134,14 @@ import { agentShellCause, classifyPeerCommand, cliCommandLabel, detectCliIdentit
|
|
|
130
134
|
import { recordCliAudit, recordDelegatedCliAudit } from "./identity-audit.ts";
|
|
131
135
|
import { runConsole } from "./console.ts";
|
|
132
136
|
import { installedVersions } from "./console-versions.ts";
|
|
133
|
-
import {
|
|
137
|
+
import { errorLines, failureExitCode } from "./error-format.ts";
|
|
138
|
+
import { asciiMarkers, paint, permissionBoundary, resolveColor, streamEnv, wrap, type Span } from "./console-state.ts";
|
|
134
139
|
import { queueResolveArgsValid } from "../hub/person-command.ts";
|
|
135
|
-
import { outputWidth, renderRuntimeModels, renderRoster, renderStatus, renderBoard, renderBacklog, renderBoardColumns, boardColumnModel, renderBudget, renderDoctor, renderProjects, renderQueue, renderTurns, renderOrphans, renderOrphanCleanup, renderQueueShow, renderModelsStatus, renderExecutionBudgetStatus, renderReport, renderUsage, renderLimits, renderTotal, type DoctorCheck } from "./output.ts";
|
|
136
|
-
import { renderHelp, configuredAcpHelp } from "./help.ts";
|
|
140
|
+
import { outputWidth, renderRuntimeModels, renderRoster, renderRoles, rolesView,renderStatus, renderStatusDefault, renderBoard, renderBacklog, renderBoardColumns, boardColumnModel, renderBudget, renderDoctor, renderProjects, renderQueue, renderTurns, renderOrphans, renderOrphanCleanup, renderQueueShow, renderModelsStatus, renderExecutionBudgetStatus, renderReport, renderUsage, renderLimits, renderTotal, type DoctorCheck } from "./output.ts";
|
|
141
|
+
import { renderHelp, configuredAcpHelp, guidanceProbeUsage, listsSubcommand, subcommandUsage } from "./help.ts";
|
|
137
142
|
import { renderBacklogResult, renderGroom, renderReleaseChange, renderReleaseList, renderReleaseNew, renderReleaseShow, renderTaskCancel, renderTaskShow } from "./task-output.ts";
|
|
138
|
-
import {
|
|
143
|
+
import { SURVEY_FOCUS } from "../hub/advisor-survey.ts";
|
|
144
|
+
import { renderAuthorization, renderSdlcCosts, renderSdlcExplain, renderSdlcMerge, renderSdlcMetrics, renderSdlcQueue, renderSdlcRelease, renderSdlcStatus, renderSdlcAudit, renderSdlcConfiguration, renderSdlcSurvey } from "./sdlc-output.ts";
|
|
139
145
|
import { renderTailEvent } from "./tail-render.ts";
|
|
140
146
|
import { archiveProblem, archiveState, damagedState, failureText, MANIFEST, planReset, resetLines, resetRuntime, startState, type ResetPlan } from "./reset.ts";
|
|
141
147
|
|
|
@@ -224,10 +230,11 @@ try {
|
|
|
224
230
|
} else nativeSelection = instanceLaunchArguments(given, rest, declaredInstances);
|
|
225
231
|
} catch (error) { fail(startupDiagnostic(error)); }
|
|
226
232
|
const selectedInstance = nativeSelection.instance;
|
|
227
|
-
// `ahub <command> -h` alone asks for that command's help instead of running it
|
|
228
|
-
// (`ahub say try ls -h`), and claude and codex pass their arguments on to the agent.
|
|
233
|
+
// `ahub <command> -h` alone asks for that command's help instead of running it, and so does `ahub <command> <sub> -h` when the help lists that subcommand (#1433: `ahub task propose --help` once
|
|
234
|
+
// filed a task titled --help). Elsewhere `-h` may be message text (`ahub say try ls -h`), and claude and codex pass their arguments on to the agent.
|
|
229
235
|
const asksHelp = (a: string | undefined) => a === "--help" || a === "-h";
|
|
230
|
-
const
|
|
236
|
+
const subcommandHelp = !!given && nativeSelection.args.length === 2 && asksHelp(nativeSelection.args[1]) && listsSubcommand(given, nativeSelection.args[0]!);
|
|
237
|
+
const cmd = asksHelp(given) || (definitionOf(given)?.start.passthrough !== true && ((nativeSelection.args.length === 1 && asksHelp(nativeSelection.args[0])) || subcommandHelp)) ? "help" : given;
|
|
231
238
|
const args = cmd === "help" && given !== "help" && !asksHelp(given) ? [given] : nativeSelection.args;
|
|
232
239
|
|
|
233
240
|
/** Resolve a named peer only against this project's current trusted declarations. */
|
|
@@ -289,13 +296,14 @@ operationalAuditReady=identity.role==="tools" && commandAccess==="conductor" &&
|
|
|
289
296
|
function audit(outcome: "run" | "refused" | "invalid"): void {
|
|
290
297
|
if (caller.role === "console") return;
|
|
291
298
|
if(outcome==="refused" && operationalAuditReady){if(operationalRefusalRecorded)return;operationalRefusalRecorded=true;}
|
|
292
|
-
try { recordCliAudit(stateDir, caller.role === "tools" ? caller.peer : "unknown", commandLabel, outcome); }
|
|
299
|
+
try { recordCliAudit(stateDir, caller.role === "tools" ? caller.peer : "unknown", commandLabel, outcome, cmd === "answer" && args.includes("--instructed")); }
|
|
293
300
|
catch {
|
|
294
301
|
if (delegatedPeer) fail("live-test delegation audit unavailable; nothing was executed");
|
|
295
302
|
console.error("ahub: CLI audit could not be recorded (outbox unavailable or full)");
|
|
296
303
|
}
|
|
297
304
|
}
|
|
298
305
|
if (identity.role === "invalid") { audit("invalid"); fail(`${identity.reason}; use ahub console or a terminal with no agent markers`); }
|
|
306
|
+
if (delegationRefused && cmd === "answer" && args.includes("--instructed")) { audit("refused"); fail(`${LIVE_TEST_PERSON_REFUSAL}; the person can answer with ahub console`); }
|
|
299
307
|
if (delegationRefused) { audit("refused"); fail(LIVE_TEST_PERSON_REFUSAL); }
|
|
300
308
|
if (identity.role === "tools" && commandAccess === "console") { audit("refused"); fail(peerCommandRefusal(identity.peer, commandLabel)); }
|
|
301
309
|
// Recovery keeps its authoritative delegation audit in the operation receipt, independent of an old source drain.
|
|
@@ -342,9 +350,9 @@ try { process.chdir(cwd); } catch { fail(`project directory is unavailable: ${cw
|
|
|
342
350
|
function outputOptions(source: readonly string[] = args) {
|
|
343
351
|
const flags = source.filter(arg => arg.startsWith("--color="));
|
|
344
352
|
if (flags.length > 1 || source.includes("--color")) fail(`usage: ahub ${cmd} [--color=auto|always|never] [--json] [--full]`);
|
|
345
|
-
const color = resolveColor(flags[0]?.slice("--color=".length),
|
|
353
|
+
const color = resolveColor(flags[0]?.slice("--color=".length), streamEnv(!!process.stdout.isTTY));
|
|
346
354
|
if (color instanceof Error) fail(`usage: ahub ${cmd} [--color=auto|always|never] [--json] [--full]`);
|
|
347
|
-
return { color: color === true, json: source.includes("--json"), full: source.includes("--full"),
|
|
355
|
+
return { color: color === true, json: source.includes("--json"), full: source.includes("--full"), verbose: source.includes("--verbose"),
|
|
348
356
|
columns: outputWidth({ isTTY: !!process.stdout.isTTY, columns: process.stdout.columns, COLUMNS: process.env.COLUMNS }) };
|
|
349
357
|
}
|
|
350
358
|
/**
|
|
@@ -376,6 +384,10 @@ function outputArguments(): string[] {
|
|
|
376
384
|
return args.filter(arg => arg !== "--json" && arg !== "--full" && !arg.startsWith("--color="));
|
|
377
385
|
}
|
|
378
386
|
/** `sdlc` operands: the read subcommands that print for a person (#814) drop `--json`, `--full` and `--color=`; every other subcommand keeps its argv exactly. */
|
|
387
|
+
/** The daemon answers a missing task id with a JSON string (`"no task #N"`), a found task with an object: the sentence for a missing one, otherwise undefined. */
|
|
388
|
+
function missingTaskText(text: string): string | undefined {
|
|
389
|
+
try { const value: unknown = JSON.parse(text); return typeof value === "string" && /^no task #\d+$/.test(value) ? value : undefined; } catch { return undefined; }
|
|
390
|
+
}
|
|
379
391
|
/** A hub tool answers JSON text. Text that does not parse is printed as it came: a renderer never sees it, so it cannot read as an empty report. */
|
|
380
392
|
function showToolText(render: (data: any, columns?: number, now?: number) => Span[][], text: string, present: ReturnType<typeof outputOptions>): void {
|
|
381
393
|
let data: unknown;
|
|
@@ -383,7 +395,7 @@ function showToolText(render: (data: any, columns?: number, now?: number) => Spa
|
|
|
383
395
|
if (present.json) return console.log(text);
|
|
384
396
|
printOutput(render(data, present.columns, Date.now()), present.color);
|
|
385
397
|
}
|
|
386
|
-
const SDLC_READ = ["status", "explain", "queue", "release", "metrics", "costs", "authorize-release"];
|
|
398
|
+
const SDLC_READ = ["status", "explain", "queue", "release", "metrics", "costs", "authorize-release", "audit", "configure", "survey"];
|
|
387
399
|
function sdlcOperands(): string[] { return SDLC_READ.includes(args[0] ?? "") ? outputArguments() : args; }
|
|
388
400
|
function printOutput(lines: Span[][], color: boolean): void {
|
|
389
401
|
for (const line of lines) console.log(paint(line, color));
|
|
@@ -560,12 +572,17 @@ function startupDiagnostic(error: unknown): string {
|
|
|
560
572
|
return message.replace(/[\p{Cc}\p{Cf}]/gu, " ").replace(/\s+/g, " ").trim().slice(0, 512) || "invalid startup configuration";
|
|
561
573
|
}
|
|
562
574
|
|
|
563
|
-
|
|
575
|
+
/**
|
|
576
|
+
* CLI output standard v1, Messages: `ahub: <what failed>: <why>` on stderr; with a terminal on stderr it leads with the fail marker, and a piped line
|
|
577
|
+
* keeps the plain `ahub: ` form so a script or agent matching it still works. `next` is a complete, copyable command printed on a second line (ASCII
|
|
578
|
+
* `->` when the locale is not UTF-8); a caller passes it only where the fix is known, and a daemon refusal is passed through without one.
|
|
579
|
+
* A usage error exits 2, any other failure 1; a usage error is one whose text starts with `usage:` (the form every call site already uses) or names an unknown command.
|
|
580
|
+
*/
|
|
581
|
+
function fail(message: string, refusalAudited=false, authorityRefused?:boolean, next?: string): never {
|
|
564
582
|
if(operationalAuditReady && authorityRefused!==false){if(refusalAudited)operationalRefusalRecorded=true;if(!operationalRefusalRecorded)audit("refused");}
|
|
565
|
-
console.error(
|
|
566
|
-
process.exit(
|
|
583
|
+
console.error(errorLines(message, next, !!process.stderr.isTTY, asciiMarkers(process.env, process.argv.includes("--ascii"))).join("\n"));
|
|
584
|
+
process.exit(failureExitCode(message));
|
|
567
585
|
}
|
|
568
|
-
|
|
569
586
|
function operationalIncomplete(result: {complete?:boolean;incompleteReason?:unknown;truncated?:boolean}, history: "log"|"event"): void {
|
|
570
587
|
if(result.complete===false)console.error(`ahub: operational output is incomplete: ${typeof result.incompleteReason==="string"?terminalText(result.incompleteReason).replace(/[\r\n]+/g," ").slice(0,200):"public privacy or history coverage unavailable"}`);
|
|
571
588
|
else if(result.truncated)console.error(`ahub: operational ${history} history is truncated`);
|
|
@@ -575,6 +592,8 @@ async function taskOp(op: string, a: Record<string, unknown>, throwOnError = fal
|
|
|
575
592
|
const hub = connection ?? await connect();
|
|
576
593
|
try {
|
|
577
594
|
if (op === "hub_task_cancel" && !hub.features.includes("task_cancel")) fail("this daemon does not support task cancellation; upgrade it first");
|
|
595
|
+
if ((op === "study_evidence" || op === "study_check" || op === "claim_verdict" && a.synthesis !== undefined) && !hub.features.includes("research_synthesis"))
|
|
596
|
+
fail("running hub lacks research_synthesis; upgrade and restart the hub before requesting synthesis evidence or recording a manifest-bound verdict");
|
|
578
597
|
const res = await hub.request({ t: "task", op, args: a }, timeoutMs ?? (op === "github_import" ? 60_000 : 30_000));
|
|
579
598
|
if (!res.ok) {
|
|
580
599
|
if (throwOnError) throw new Error(res.error);
|
|
@@ -631,7 +650,7 @@ async function hold(t: "pause" | "resume"): Promise<void> {
|
|
|
631
650
|
function recoveryDisplay() {
|
|
632
651
|
// A terminal gives its own width; a pipe gives COLUMNS when set, else 80 (#814: a person reads a pipe too).
|
|
633
652
|
const width = process.stdout.columns ?? outputWidth({ isTTY: false, COLUMNS: process.env.COLUMNS }) ?? 80;
|
|
634
|
-
return readRecoveryPresentationFlags(args, {
|
|
653
|
+
return readRecoveryPresentationFlags(args, { ...streamEnv(!!process.stdout.isTTY), columns: width });
|
|
635
654
|
}
|
|
636
655
|
const humanRecovery = (json: boolean) => !json && !!process.stdin.isTTY && !!process.stdout.isTTY;
|
|
637
656
|
const printRecovery = (lines: readonly string[]) => { for (const line of lines) console.log(line); };
|
|
@@ -879,8 +898,31 @@ const LOCAL_OPERATION_ARGS: Record<string, () => void> = {
|
|
|
879
898
|
"source add": () => { const operands = args.filter(arg => arg !== "--json" && arg !== "--full" && !arg.startsWith("--color=")); if (operands[0] !== "add" || operands.length !== 2 || !operands[1]) fail(SOURCE_USAGE); },
|
|
880
899
|
};
|
|
881
900
|
|
|
901
|
+
const contract = (file: string, kind: "contract" | "manifest" = "contract"): unknown => {
|
|
902
|
+
// One descriptor decides everything: opened non-blocking and without following a final symlink (a FIFO would otherwise block the open), checked to be a regular file with fstat, and
|
|
903
|
+
// read for at most the cap plus one byte, so a file that grows or is replaced after the check, or a device that reports size zero, cannot exhaust memory or hang this process.
|
|
904
|
+
const cap = 64 * 1024;
|
|
905
|
+
let text: string;
|
|
906
|
+
try {
|
|
907
|
+
const fd = openSync(resolve(invokedFrom, file), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
908
|
+
try {
|
|
909
|
+
if (!fstatSync(fd).isFile()) return fail(`the ${kind} file is not a regular file`);
|
|
910
|
+
const bytes = Buffer.alloc(cap + 1); let got = 0;
|
|
911
|
+
while (got < bytes.length) { const n = readSync(fd, bytes, got, bytes.length - got, null); if (!n) break; got += n; }
|
|
912
|
+
if (got > cap) return fail(`the ${kind} file is over 64 KiB`);
|
|
913
|
+
text = bytes.subarray(0, got).toString("utf8");
|
|
914
|
+
} finally { closeSync(fd); }
|
|
915
|
+
}
|
|
916
|
+
catch { return fail(`cannot read the ${kind} file`); }
|
|
917
|
+
try { return JSON.parse(text); } catch { return fail(`the ${kind} file is not valid JSON`); }
|
|
918
|
+
};
|
|
919
|
+
|
|
882
920
|
// Outside the command bodies: test/lifecycle-starting-1232.test.ts runs the `up` body as a plain function, where import.meta does not parse.
|
|
883
921
|
const consoleInstalled = () => installedVersions(join(import.meta.dir, "..", ".."));
|
|
922
|
+
/** `ahub goal new` options: those that take a value, and all it knows. The words they leave are the title. */
|
|
923
|
+
const GOAL_NEW_VALUE_FLAGS = ["--milestone", "--depends"], GOAL_NEW_FLAGS = [...GOAL_NEW_VALUE_FLAGS, "--shared", "--json"];
|
|
924
|
+
/** `ahub doctor` exits 1 on a failed row; `ahub setup` runs the same function and keeps its own exit behavior. */
|
|
925
|
+
let doctorSetsExit = true;
|
|
884
926
|
const commands: Record<string, () => Promise<void> | void> = {
|
|
885
927
|
upgrade: () => upgrade("upgrade"),
|
|
886
928
|
restart: () => upgrade("restart"),
|
|
@@ -1003,10 +1045,10 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1003
1045
|
else if (conductorPeer) retireConductorOperation(result, conductorPeer);
|
|
1004
1046
|
},
|
|
1005
1047
|
help: () => {
|
|
1006
|
-
const color = resolveColor(undefined,
|
|
1048
|
+
const color = resolveColor(undefined, streamEnv(!!process.stdout.isTTY)) === true;
|
|
1007
1049
|
const topic = asksHelp(args[0]) ? undefined : args[0];
|
|
1008
1050
|
const text = topic && !definitionOf(topic) && projectCatalog.definitionOf(topic)?.permission.genericAcp !== undefined
|
|
1009
|
-
? configuredAcpHelp(topic) : renderHelp(process.stdout.columns ?? 80, color, topic);
|
|
1051
|
+
? configuredAcpHelp(topic) : renderHelp(process.stdout.columns ?? 80, color, topic, undefined, asciiMarkers(process.env, args.includes("--ascii")));
|
|
1010
1052
|
if (!text) fail(`unknown command "${topic}"; run ahub help`);
|
|
1011
1053
|
console.log(text);
|
|
1012
1054
|
},
|
|
@@ -1112,7 +1154,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1112
1154
|
const acon = registerAconPlugin(hubHome(), join(root, "src", "ui", "plugin.ts"));
|
|
1113
1155
|
console.log("error" in acon ? `acon plugin not registered: ${acon.error}` : acon.changed ? `acon plugin registered: ${acon.path}` : `acon plugin up to date: ${acon.path}`);
|
|
1114
1156
|
if (recoveryLauncherCurrent) recoveryLauncherCurrent();
|
|
1115
|
-
else await commands.doctor!();
|
|
1157
|
+
else { doctorSetsExit = false; await commands.doctor!(); }
|
|
1116
1158
|
},
|
|
1117
1159
|
|
|
1118
1160
|
init: async () => {
|
|
@@ -1148,7 +1190,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1148
1190
|
let result: Awaited<ReturnType<typeof runInitPrompt>>;
|
|
1149
1191
|
try {
|
|
1150
1192
|
result = await runInitPrompt({ ask, print: line => console.log(terminalText(line)) },
|
|
1151
|
-
{ ...(machine.startAgents ? { machineAgents: machine.startAgents } : {}), machineResearch: initResearchDefault(cwd, initMachine?.researchEnabled), packs: [...loadPacks(cwd).packs.keys()], discoverChecks: async () => (await discoverInitChecks(cwd)).names, shadowAvailable: shadowOffered(repoOf(cwd)) }, preview);
|
|
1193
|
+
{ ...(machine.startAgents ? { machineAgents: machine.startAgents } : {}), machineResearch: initResearchDefault(cwd, initMachine?.researchEnabled), installedPeers: installedPeers(), packs: [...loadPacks(cwd).packs.keys()], discoverChecks: async () => (await discoverInitChecks(cwd)).names, shadowAvailable: shadowOffered(repoOf(cwd)) }, preview);
|
|
1152
1194
|
} finally { rl.close(); }
|
|
1153
1195
|
if (!result.ok) { console.error(`ahub init: ${result.reason === "refused" ? result.message : result.reason === "interrupted" ? `interrupted; ${result.message}` : result.message}`); process.exitCode = result.reason === "refused" ? 1 : 0; return; }
|
|
1154
1196
|
requestedProfile = result.answers.profile; request = result.answers.request; asked = Object.keys(request.values).length > 0; shadow = result.answers.shadow; releaseGuard = result.answers.releaseGuard;
|
|
@@ -1199,7 +1241,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1199
1241
|
|
|
1200
1242
|
console: async () => {
|
|
1201
1243
|
if (args.some(arg => arg !== "--panels" && arg !== "--no-pet" && !arg.startsWith("--color=")) || args.filter(arg => arg.startsWith("--color=")).length > 1) fail("usage: ahub console [--panels] [--no-pet] [--color=auto|always|never]");
|
|
1202
|
-
const color = resolveColor(args.find(arg => arg.startsWith("--color="))?.slice("--color=".length),
|
|
1244
|
+
const color = resolveColor(args.find(arg => arg.startsWith("--color="))?.slice("--color=".length), streamEnv(!!process.stdin.isTTY && !!process.stdout.isTTY));
|
|
1203
1245
|
if (color instanceof Error) return fail("usage: ahub console [--panels] [--no-pet] [--color=auto|always|never]");
|
|
1204
1246
|
await runConsole({ client: await connect(), cwd, stateDir, liveTest, panels: args.includes("--panels"), noPet: args.includes("--no-pet"), color, installed: consoleInstalled() });
|
|
1205
1247
|
},
|
|
@@ -1255,7 +1297,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1255
1297
|
parseGuidanceProbePublicReceipt, parseGuidanceProbePublicStatus, parseGuidanceProbeReceiptExport } = await import("../hub/guidance-probes.ts");
|
|
1256
1298
|
const { guidanceProbeStatusLines } = await import("../ui/guidance-view.ts");
|
|
1257
1299
|
let probeCommand;
|
|
1258
|
-
try { probeCommand = parseGuidanceProbeSubcommand(args); } catch { return fail(
|
|
1300
|
+
try { probeCommand = parseGuidanceProbeSubcommand(args); } catch { return fail(guidanceProbeUsage(args)); }
|
|
1259
1301
|
if (probeCommand) {
|
|
1260
1302
|
if (liveTest) return fail("live-test cannot perform guidance probe operations as the person; use a current person or configured conductor session");
|
|
1261
1303
|
let registration: ReturnType<typeof parseGuidanceProbeRegistration> | undefined;
|
|
@@ -1502,7 +1544,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1502
1544
|
const peer = args[0];
|
|
1503
1545
|
if (typeof peer !== "string" || !peerDefinition(peer)?.capabilities?.watch) fail("usage: ahub watch kimi|qwen [--no-thoughts] [--color=auto|always|never]");
|
|
1504
1546
|
if (args.slice(1).some(arg => arg !== "--no-thoughts" && !/^--color=(auto|always|never)$/.test(arg))) fail("unsupported watch option");
|
|
1505
|
-
const color = resolveColor(args.find(arg => arg.startsWith("--color="))?.slice(8),
|
|
1547
|
+
const color = resolveColor(args.find(arg => arg.startsWith("--color="))?.slice(8), streamEnv(!!process.stdout.isTTY));
|
|
1506
1548
|
if (color instanceof Error) fail(color.message);
|
|
1507
1549
|
const hub = await connect();
|
|
1508
1550
|
const input = process.stdin;
|
|
@@ -1575,7 +1617,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1575
1617
|
const res = await hub.request({ t: "budget", ...(set ? { set } : {}) });
|
|
1576
1618
|
hub.close();
|
|
1577
1619
|
if (!res.ok) fail(res.error);
|
|
1578
|
-
const data = { budget: res.budget, ...(res.peers ? { peers: res.peers } : {}), gate: res.gate };
|
|
1620
|
+
const data = { budget: res.budget, ...(res.peers ? { peers: res.peers } : {}), ...(res.review ? { review: res.review } : {}), gate: res.gate };
|
|
1579
1621
|
if (options.json) return console.log(JSON.stringify(data, null, 2));
|
|
1580
1622
|
printOutput(renderBudget(data, options.columns, Date.now(), options.full), options.color);
|
|
1581
1623
|
},
|
|
@@ -1619,6 +1661,14 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1619
1661
|
return shown((data, columns, now) => renderBacklogResult(sub === "person" ? "plan" : sub as "plan" | "pin", data, columns, now))(taskOp("hub_backlog_plan", { id: Number(id), revision: Number(revision), fields, reason: reason.join(" ") }));
|
|
1620
1662
|
},
|
|
1621
1663
|
|
|
1664
|
+
roadmap: async () => {
|
|
1665
|
+
let options;
|
|
1666
|
+
try { options = parseRoadmapArgs(args); } catch (error) { return fail(`${error instanceof Error ? error.message : "invalid roadmap arguments"}; see ahub help roadmap`); }
|
|
1667
|
+
// R3 (#1481): the GitHub reads and the model call each carry their own deadline, so these ops wait longer than the 30 s default.
|
|
1668
|
+
const text = await taskOp(options.op, options.args, false, undefined, ["hub_roadmap_unplaced", "hub_roadmap_triage", "roadmap_import_github"].includes(options.op) ? 60_000 : undefined);
|
|
1669
|
+
if (options.json) console.log(text);
|
|
1670
|
+
else console.log(renderRoadmap(text, outputOptions().columns));
|
|
1671
|
+
},
|
|
1622
1672
|
release: async () => {
|
|
1623
1673
|
const split = splitPresentation(args, { edges: true }), operands = split.operands;
|
|
1624
1674
|
const [sub, name, revision, value] = operands;
|
|
@@ -1726,12 +1776,14 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1726
1776
|
} catch (error) { return fail(`cannot register ${isUrl ? "that URL" : target}: ${(error as Error).message}`); }
|
|
1727
1777
|
const projections = new TextProjections({ cwd, stateDir, config: config.text_projection ?? {}, deny: config.local.deny, readAllow: config.local.read_allow, log: line => console.error(line) });
|
|
1728
1778
|
const extension = /\.[A-Za-z0-9]{1,16}$/.exec(isUrl ? new URL(origin).pathname : origin)?.[0] ?? "";
|
|
1779
|
+
let converted: ProjectedText | undefined;
|
|
1729
1780
|
const verdict = screenRegistration({ bytes, kind, ...(absolute ? { path: absolute, typedPath: resolve(cwd, target) } : {}) }, {
|
|
1730
1781
|
piiPaths: config.pii?.paths ?? [], piiPatterns: currentRouting(cwd).signals.pii_patterns, cwd, matchesPolicy,
|
|
1731
|
-
project: data => extension ? projections.projectBytes(join(cwd, `source${extension.toLowerCase()}`), data)
|
|
1782
|
+
project: data => { converted = extension ? projections.projectBytes(join(cwd, `source${extension.toLowerCase()}`), data) : undefined; return converted?.text; },
|
|
1732
1783
|
});
|
|
1784
|
+
const projection = sourceProjectionReceipt(bytes, verdict.text, converted ? { extension: extension.toLowerCase(), value: converted } : undefined);
|
|
1733
1785
|
let added;
|
|
1734
|
-
try { added = registry.add({ bytes, kind, origin, private: verdict.private, ...(verdict.text !== undefined ? { text: verdict.text } : {}) }); }
|
|
1786
|
+
try { added = registry.add({ bytes, kind, origin, private: verdict.private, ...(verdict.text !== undefined ? { text: verdict.text } : {}), ...(projection ? { projection } : {}) }); }
|
|
1735
1787
|
catch (error) { return fail(`cannot register ${isUrl ? "that URL" : target}: ${(error as Error).message}`); }
|
|
1736
1788
|
const meta = registry.get(added.id);
|
|
1737
1789
|
if (!meta) return fail(`the record for ${added.id} cannot be read after it was registered; inspect ${join(stateDir, "sources")}`);
|
|
@@ -1761,24 +1813,17 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1761
1813
|
const present = outputOptions(split.flags); // before any request: an invalid --color must refuse before a mutation is sent
|
|
1762
1814
|
const parsed = parseStudyArgs(split.operands);
|
|
1763
1815
|
if ("usage" in parsed) return fail(parsed.usage);
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
if (got > cap) return fail("the contract file is over 64 KiB");
|
|
1776
|
-
text = bytes.subarray(0, got).toString("utf8");
|
|
1777
|
-
} finally { closeSync(fd); }
|
|
1778
|
-
}
|
|
1779
|
-
catch { return fail("cannot read the contract file"); }
|
|
1780
|
-
try { return JSON.parse(text); } catch { return fail("the contract file is not valid JSON"); }
|
|
1781
|
-
};
|
|
1816
|
+
|
|
1817
|
+
if (parsed.op === "evidence") return showToolText(data => renderStudyEvidence(data, present.columns), await taskOp("hub_evidence_read", { id: parsed.id, ...(parsed.revision === undefined ? {} : { revision: parsed.revision }) }), present);
|
|
1818
|
+
if (parsed.op === "evidence_inventory") return showToolText(data => renderStudyEvidence(data, present.columns), await taskOp("study_evidence", { taskId: parsed.taskId }), present);
|
|
1819
|
+
if (parsed.op === "check") {
|
|
1820
|
+
const manifest = parseSynthesisManifest(contract(parsed.file, "manifest"));
|
|
1821
|
+
if (manifest.taskId !== parsed.taskId) return fail("synthesis manifest names another task; refresh its task binding and retry");
|
|
1822
|
+
const text = await taskOp("study_check", { taskId: parsed.taskId, manifest });
|
|
1823
|
+
showToolText(data => renderSynthesisReadiness(data, present.columns), text, present);
|
|
1824
|
+
if (JSON.parse(text).status !== "ready") process.exitCode = 1;
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1782
1827
|
if (parsed.op === "experiments") {
|
|
1783
1828
|
// A read of the records Tasks keeps (hub_experiment_show): it runs no command and reads no file, and the hub blanks a private record itself.
|
|
1784
1829
|
const args = parsed.attempt ? { attemptId: parsed.attempt, ...(parsed.eventsAfter === undefined ? {} : { eventAfter: parsed.eventsAfter }) } : parsed.plan ? { planHash: parsed.plan, baselineAttemptId: parsed.baseline, variantAttemptId: parsed.variant } : { campaignId: parsed.campaign, ...(parsed.after === undefined ? {} : { after: parsed.after }) };
|
|
@@ -1904,6 +1949,22 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1904
1949
|
/** 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. */
|
|
1905
1950
|
const human = (render: (data: any, columns?: number, now?: number) => Span[][], data: unknown) => printOutput(render(data, present!.columns, Date.now()), present!.color);
|
|
1906
1951
|
const sub = args[0], id = args[1] === undefined ? undefined : Number(args[1]);
|
|
1952
|
+
if (sub === "configure") {
|
|
1953
|
+
const parsed = takeFlags(args.slice(1), ["--mode", "--required-checks"], []);
|
|
1954
|
+
if (parsed.rest.length || !Object.keys(parsed.one).length || ["--mode", "--required-checks"].some(flag => args.filter(arg => arg === flag).length > 1)
|
|
1955
|
+
|| parsed.one["--mode"] !== undefined && !["off", "advise"].includes(parsed.one["--mode"]))
|
|
1956
|
+
fail("usage: ahub sdlc configure [--mode off|advise] [--required-checks check,lint]");
|
|
1957
|
+
const hub = await connect();
|
|
1958
|
+
try {
|
|
1959
|
+
const result = await hub.request({ t: "sdlc", op: "configure", instructionClaim: true,
|
|
1960
|
+
...(parsed.one["--mode"] === undefined ? {} : { mode: parsed.one["--mode"] }),
|
|
1961
|
+
...(parsed.one["--required-checks"] === undefined ? {} : { required_checks: parsed.one["--required-checks"] === "" ? [] : parsed.one["--required-checks"].split(",").map(name => name.trim()) }) });
|
|
1962
|
+
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);
|
|
1963
|
+
const { rid: _transportId, ...receipt } = result;
|
|
1964
|
+
if (present!.json) console.log(JSON.stringify(receipt, null, 2)); else human(renderSdlcConfiguration, receipt);
|
|
1965
|
+
} finally { hub.close(); }
|
|
1966
|
+
return;
|
|
1967
|
+
}
|
|
1907
1968
|
if (sub === "authorize-release") {
|
|
1908
1969
|
if (args.length !== 2 || !validReleaseVersion(args[1])) fail("usage: ahub sdlc authorize-release <version>");
|
|
1909
1970
|
const result = hubGitSync(["rev-parse", "--verify", "HEAD"], { cwd, env: hubGitEnv(process.env, { repositoryIsolation: true }), encoding: "utf8", timeout: 2000 });
|
|
@@ -1948,6 +2009,59 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1948
2009
|
finally { hub?.close(); }
|
|
1949
2010
|
return;
|
|
1950
2011
|
}
|
|
2012
|
+
if (sub === "survey") {
|
|
2013
|
+
const action = args[1];
|
|
2014
|
+
if (action === "start") {
|
|
2015
|
+
const flags = takeFlags(args.slice(2), ["--focus"], []);
|
|
2016
|
+
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]");
|
|
2017
|
+
const hub = await connect();
|
|
2018
|
+
try {
|
|
2019
|
+
const reply = await hub.request({ t: "sdlc", op: "survey-start", ...(flags.one["--focus"] === undefined ? {} : { focus: flags.one["--focus"] }) }, 60_000);
|
|
2020
|
+
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);
|
|
2021
|
+
const receipt = { task: reply.task, survey: reply.survey, ref: reply.ref, ...(reply.focus === undefined ? {} : { focus: reply.focus }) };
|
|
2022
|
+
if (present!.json) console.log(JSON.stringify(receipt, null, 2)); else human(renderSdlcSurvey, receipt);
|
|
2023
|
+
} finally { hub.close(); }
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
2026
|
+
if (action === "show" && args.length === 3 && /^[1-9]\d*$/.test(args[2]!) && Number.isSafeInteger(Number(args[2]))) {
|
|
2027
|
+
const hub = await connect();
|
|
2028
|
+
try {
|
|
2029
|
+
const reply = await hub.request({ t: "sdlc", op: "survey-show", id: Number(args[2]) });
|
|
2030
|
+
if (!reply.ok) fail(reply.error);
|
|
2031
|
+
if (present!.json) console.log(JSON.stringify(reply.survey ?? null, null, 2)); else human(renderSdlcSurvey, reply.survey);
|
|
2032
|
+
} finally { hub.close(); }
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
fail("usage: ahub sdlc survey start [--focus bugs|tests|debt|deps|dx|docs] | ahub sdlc survey show <task>");
|
|
2036
|
+
}
|
|
2037
|
+
if (sub === "audit") {
|
|
2038
|
+
// #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.
|
|
2039
|
+
const action = args[1];
|
|
2040
|
+
if (action === "start") {
|
|
2041
|
+
const flags = takeFlags(args.slice(2), ["--profile", "--since"], []);
|
|
2042
|
+
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>]");
|
|
2043
|
+
const hub = await connect();
|
|
2044
|
+
try {
|
|
2045
|
+
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);
|
|
2046
|
+
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);
|
|
2047
|
+
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));
|
|
2048
|
+
else console.log(`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" : ""}`);
|
|
2049
|
+
} finally { hub.close(); }
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
if (action === "show") {
|
|
2053
|
+
const given = args[2] === undefined ? undefined : Number(args[2]);
|
|
2054
|
+
if (args.length > 3 || given !== undefined && (!Number.isSafeInteger(given) || given <= 0)) fail("usage: ahub sdlc audit show [<audit>]");
|
|
2055
|
+
const hub = await connect();
|
|
2056
|
+
try {
|
|
2057
|
+
const reply = await hub.request({ t: "sdlc", op: "audit-show", ...(given !== undefined ? { id: given } : {}) }, 30_000);
|
|
2058
|
+
if (!reply.ok) fail(reply.error);
|
|
2059
|
+
if (present!.json) console.log(JSON.stringify(reply.audit ?? null, null, 2)); else human(renderSdlcAudit, reply);
|
|
2060
|
+
} finally { hub.close(); }
|
|
2061
|
+
return;
|
|
2062
|
+
}
|
|
2063
|
+
fail("usage: ahub sdlc audit start [--profile quick|standard] [--since <ref>] | ahub sdlc audit show [<audit>]");
|
|
2064
|
+
}
|
|
1951
2065
|
if (sub === "queue" || sub === "release") {
|
|
1952
2066
|
const repo = args[1], liveIssues = args.slice(2).map(Number);
|
|
1953
2067
|
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...]");
|
|
@@ -2091,14 +2205,26 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2091
2205
|
if (sub === "show") {
|
|
2092
2206
|
// a stray operand (for example the value of a `--color always` that is not the `--color=` form) is a usage error, never silently ignored
|
|
2093
2207
|
if (rest.length !== 1) fail("usage: ahub task show <id> [--json] [--full] [--color=auto|always|never]");
|
|
2094
|
-
|
|
2208
|
+
// 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
|
|
2209
|
+
// (`"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
|
|
2210
|
+
// byte for byte on stdout, and exits 1 like the human path, which prints the error and a next step on stderr instead.
|
|
2211
|
+
const shown = taskOp("task_show", { id: rest[0] });
|
|
2212
|
+
const missing = missingTaskText(await shown);
|
|
2213
|
+
if (missing !== undefined && !outputOptions(presentation.flags).json) return fail(missing, false, undefined, "ahub board");
|
|
2214
|
+
await shownTask(renderTaskShow)(shown);
|
|
2215
|
+
if (missing !== undefined) process.exitCode = 1; // --json printed the hub's document above; a lookup that found nothing still fails
|
|
2216
|
+
return;
|
|
2095
2217
|
}
|
|
2096
2218
|
if (sub === "claim") {
|
|
2097
2219
|
// #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.
|
|
2098
|
-
const { one, rest: positional } = takeFlags(rest, ["--model", "--model-said"], []);
|
|
2099
|
-
if (positional.length !== 3 || !/^[1-9]\d*$/.test(positional[0]!) || !/^[1-9]\d*$/.test(positional[1]!) || !["supported", "unsupported", "unclear"].includes(positional[2]!)
|
|
2100
|
-
|
|
2101
|
-
|
|
2220
|
+
const { one, rest: positional } = takeFlags(rest, ["--model", "--model-said", "--manifest", "--disposition"], []);
|
|
2221
|
+
if (positional.length !== 3 || !/^[1-9]\d*$/.test(positional[0]!) || !/^[1-9]\d*$/.test(positional[1]!) || !["supported", "unsupported", "unclear"].includes(positional[2]!)
|
|
2222
|
+
|| (one["--manifest"] === undefined) !== (one["--disposition"] === undefined)
|
|
2223
|
+
|| 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>]");
|
|
2224
|
+
const manifest = one["--manifest"] === undefined ? undefined : parseSynthesisManifest(contract(one["--manifest"], "manifest"));
|
|
2225
|
+
if (manifest && manifest.taskId !== Number(positional[0])) return fail("synthesis manifest names another task; refresh its task binding and retry");
|
|
2226
|
+
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 } } };
|
|
2227
|
+
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}` : ""}`);
|
|
2102
2228
|
}
|
|
2103
2229
|
if (sub === "escalate") return console.log(await taskOp("task_escalate", { id: rest[0] }));
|
|
2104
2230
|
if (sub === "assign") {
|
|
@@ -2145,8 +2271,12 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2145
2271
|
const urgent = rest.includes("--urgent"), backlog = rest.includes("--backlog"), needsNetwork = rest.includes("--needs-network"), needsWorktree = rest.includes("--needs-worktree");
|
|
2146
2272
|
const flags = takeFlags(rest.filter((a) => a !== "--urgent" && a !== "--backlog" && a !== "--needs-network" && a !== "--needs-worktree"), ["--owner", "--detail", "--class"], ["--path", "--after"]);
|
|
2147
2273
|
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;
|
|
2148
|
-
|
|
2149
|
-
const
|
|
2274
|
+
// #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.
|
|
2275
|
+
const stray = unknownOption(flags.rest);
|
|
2276
|
+
if (stray) fail(unknownOptionRefusal(stray, "ahub task propose", subcommandUsage("task", "propose")));
|
|
2277
|
+
const textWords = withoutSeparator(flags.rest);
|
|
2278
|
+
const cls = flags.one["--class"] ?? (positional ? textWords[0] : undefined);
|
|
2279
|
+
const title = (positional ? textWords.slice(1) : textWords).join(" ");
|
|
2150
2280
|
if (positional) console.error(`note: "${cls}" was taken as the class and left out of the title; use --class <c> when the title itself starts with that word`);
|
|
2151
2281
|
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 } : {}) }));
|
|
2152
2282
|
},
|
|
@@ -2157,15 +2287,19 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2157
2287
|
if (args.length !== 2 || !/^\d+$/.test(args[1]!)) fail("usage: ahub review brief <task id>");
|
|
2158
2288
|
return console.log(await taskOp("review_brief", { id: Number(args[1]) }));
|
|
2159
2289
|
}
|
|
2160
|
-
const { one, many, rest } = takeFlags(args, ["--head", "--findings"], ["--unmet"]);
|
|
2290
|
+
const { one, many, rest } = takeFlags(args, ["--head", "--findings", "--security-pass"], ["--unmet"]);
|
|
2161
2291
|
const [id, verdict, ...note] = rest;
|
|
2162
|
-
if (!id || !verdict) fail("usage: ahub review <id> approved|changes_requested [note...] [--unmet <item>]... [--head <sha>] [--findings <json>] | ahub review brief <id>");
|
|
2292
|
+
if (!id || !verdict) fail("usage: ahub review <id> approved|changes_requested [note...] [--unmet <item>]... [--head <sha>] [--findings <json>] [--security-pass <json>] | ahub review brief <id>");
|
|
2293
|
+
let securityPass: unknown;
|
|
2294
|
+
if (one["--security-pass"] !== undefined) {
|
|
2295
|
+
try { securityPass = JSON.parse(one["--security-pass"]); } catch { fail("--security-pass must be a JSON object like {\"covered\":[\"unit\"],\"not_covered\":[]}"); }
|
|
2296
|
+
}
|
|
2163
2297
|
let findings: unknown;
|
|
2164
2298
|
if (one["--findings"] !== undefined) {
|
|
2165
2299
|
try { findings = JSON.parse(one["--findings"]); } catch { fail("--findings must be a JSON array"); }
|
|
2166
2300
|
if (!Array.isArray(findings)) fail("--findings must be a JSON array");
|
|
2167
2301
|
}
|
|
2168
|
-
console.log(await taskOp("hub_review", { id: Number(id), verdict, ...(one["--head"] ? { head: one["--head"] } : {}), note: note.join(" "), ...(findings === undefined ? {} : { findings }), ...(many["--unmet"]?.length ? { unmet: many["--unmet"] } : {}) }));
|
|
2302
|
+
console.log(await taskOp("hub_review", { id: Number(id), verdict, ...(one["--head"] ? { head: one["--head"] } : {}), note: note.join(" "), ...(findings === undefined ? {} : { findings }), ...(securityPass === undefined ? {} : { security_pass: securityPass }), ...(many["--unmet"]?.length ? { unmet: many["--unmet"] } : {}) }));
|
|
2169
2303
|
},
|
|
2170
2304
|
|
|
2171
2305
|
remember: async () => console.log(await taskOp("hub_remember", { text: freeText(args, "ahub remember <text>") })),
|
|
@@ -2500,7 +2634,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2500
2634
|
if (sub === "list" && row.group !== group) console.log(`${group ? "\n" : ""}${group = row.group}`);
|
|
2501
2635
|
const facts = [`from ${row.source}`, `file: ${settingText(row.fileValue === undefined ? row.pending ?? row.value : row.fileValue)}`, row.applies === "live" ? "applies at once" : row.applies === "next use" ? "applies at next use" : "pending restart", ...(row.restartReason ? [row.restartReason] : []), ...(row.note ? [row.note] : [])];
|
|
2502
2636
|
console.log(` ${row.key.padEnd(width)} ${settingText(row.value).padEnd(valueWidth)} ${facts.join("; ")}`);
|
|
2503
|
-
if (sub === "get") console.log(` ${row.label}; written to ${row.file}; takes ${row.type === "boolean" ? "true, false" : row.type === "integer" || row.type === "number" ? `a number from ${row.min ?? 0} to ${row.max ?? "the configured bound"}` : row.type === "peers" ? "a comma list of peer ids" : row.type === "roles" ? "up to two comma-separated catalog ids" : (row.values ?? []).join(", ")}${row.file === "this hub run" ? "" : ", or inherit to remove the machine-local value"}${row.risk === "raises" ? "; a dashboard needs a settings session (ahub ui --settings) to raise it" : ""}`);
|
|
2637
|
+
if (sub === "get") console.log(` ${row.label}; written to ${row.file}; takes ${row.type === "boolean" ? "true, false" : row.type === "number-or-off" ? `off or a number from ${row.min ?? 0} to ${row.max ?? "the configured bound"}` : row.type === "integer" || row.type === "number" ? `a number from ${row.min ?? 0} to ${row.max ?? "the configured bound"}` : row.type === "peers" ? "a comma list of peer ids" : row.type === "roles" ? "up to two comma-separated catalog ids" : (row.values ?? []).join(", ")}${row.file === "this hub run" ? "" : ", or inherit to remove the machine-local value"}${row.risk === "raises" ? "; a dashboard needs a settings session (ahub ui --settings) to raise it" : ""}`);
|
|
2504
2638
|
}
|
|
2505
2639
|
if (sub === "list" && view.pendingRestart?.length) console.log(`\npending restart: ${view.pendingRestart.map((entry: { key: string }) => entry.key).join(", ")}`);
|
|
2506
2640
|
if (sub === "list" && view.undo) console.log(`\nahub settings undo puts back the last write (${view.undo})`);
|
|
@@ -2541,10 +2675,10 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2541
2675
|
}
|
|
2542
2676
|
const parsed = parseAnswerArgs(operands);
|
|
2543
2677
|
if (!parsed.ok) return fail(parsed.error);
|
|
2544
|
-
const reply = await hub.request({ t: "answer", surface: "terminal", questionSet: parsed.value.set, answers: parsed.value.answers });
|
|
2678
|
+
const reply = await hub.request({ t: "answer", surface: "terminal", questionSet: parsed.value.set, answers: parsed.value.answers, ...(parsed.value.instruction === undefined ? {} : { instructed: parsed.value.instruction }) });
|
|
2545
2679
|
if (reply.ok === false) return fail(String(reply.error ?? "the answer was refused"));
|
|
2546
|
-
if (options.json) return console.log(JSON.stringify({ ok: true, questionSet: reply.questionSet, state: reply.state }));
|
|
2547
|
-
console.log(`answered ${reply.questionSet ?? parsed.value.set}`);
|
|
2680
|
+
if (options.json) return console.log(JSON.stringify({ ok: true, questionSet: reply.questionSet, state: reply.state, ...(reply.instructed ? { actor: reply.actor, instructed: true } : {}) }));
|
|
2681
|
+
console.log(`answered ${reply.questionSet ?? parsed.value.set}${reply.instructed && typeof reply.actor === "string" ? `; answered by ${terminalText(reply.actor)} on the person's instruction` : ""}`);
|
|
2548
2682
|
} finally { hub.close(); }
|
|
2549
2683
|
},
|
|
2550
2684
|
|
|
@@ -2596,6 +2730,27 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2596
2730
|
process.stdout.write(short ? text : text + "\n");
|
|
2597
2731
|
},
|
|
2598
2732
|
|
|
2733
|
+
// #1411 T2: the flow roles the running hub settled (defaults, overrides, ceilings), resolved from a worktree like every command.
|
|
2734
|
+
roles: async () => {
|
|
2735
|
+
const options = outputOptions();
|
|
2736
|
+
if (outputArguments().length) fail("usage: ahub roles [--json]");
|
|
2737
|
+
// 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,
|
|
2738
|
+
// so a linked worktree with no hub of its own reads the main worktree's hub, under the same identity.
|
|
2739
|
+
let target = { root: cwd, stateDir };
|
|
2740
|
+
if (!existsSync(join(cwd, ".agenthub"))) {
|
|
2741
|
+
const common = hubGitSync(["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd, encoding: "utf8", timeout: 3000 });
|
|
2742
|
+
const main = common.status === 0 ? dirname(common.stdout.trim()) : undefined;
|
|
2743
|
+
if (main && realPath(main) !== cwd && existsSync(join(main, ".agenthub"))) target = projectContext(main);
|
|
2744
|
+
}
|
|
2745
|
+
const hub = target.root === cwd ? await connect() : await ControlClient.connect(target.stateDir, identity.role === "tools"
|
|
2746
|
+
? { role: "tools", peer: identity.peer, projectRoot: target.root } : { role: "console", projectRoot: target.root }, 3000);
|
|
2747
|
+
try {
|
|
2748
|
+
const { status } = await hub.request({ t: "status" });
|
|
2749
|
+
const view = rolesView(status);
|
|
2750
|
+
if (options.json) return console.log(JSON.stringify(view, null, 2));
|
|
2751
|
+
printOutput(renderRoles(view, options.columns), options.color);
|
|
2752
|
+
} finally { hub.close(); }
|
|
2753
|
+
},
|
|
2599
2754
|
status: async () => {
|
|
2600
2755
|
const options = outputOptions();
|
|
2601
2756
|
if (args.includes("--all")) return printProjects(options);
|
|
@@ -2604,10 +2759,12 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2604
2759
|
const { status } = await hub.request({ t: "status", specs: true });
|
|
2605
2760
|
if (options.json) return console.log(JSON.stringify(status, null, 2));
|
|
2606
2761
|
const quota = await hub.request({ t: "budget" });
|
|
2607
|
-
|
|
2762
|
+
// CLI output standard v1: the default view answers "is it OK, and what do I do next"; every detail the older view printed stays behind --verbose (and --full, which adds the long ids).
|
|
2763
|
+
const data = { ...status, budget: quota.budget ?? {} };
|
|
2764
|
+
printOutput(options.verbose || options.full ? renderStatus(data, options.columns, Date.now(), options.full) : renderStatusDefault(data, options.columns, Date.now(), asciiMarkers(process.env, args.includes("--ascii"))), options.color);
|
|
2608
2765
|
if (status.needs) { const pet = loadPetConfig(cwd); if (pet.enabled) console.log(renderPet(petView(status), false, pet.character)); }
|
|
2609
2766
|
// #258: open long-term tasks and who holds them, as of this machine's last memory sync.
|
|
2610
|
-
if (status.memoryProfile ? status.memoryProfile.state === "ready" :
|
|
2767
|
+
if (status.memoryProfile ? status.memoryProfile.state === "ready" : memoryIndexExists(join(hubHome(), "memory"))) {
|
|
2611
2768
|
try { const lines = await goalCommand(["list"], cwd); if (!lines.startsWith("no open")) console.log(`\nlong-term tasks\n${lines}`); } catch { /* memory unreadable: status goes on */ }
|
|
2612
2769
|
}
|
|
2613
2770
|
} finally { hub.close(); }
|
|
@@ -2709,6 +2866,12 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2709
2866
|
try { const r = await hub.request({ t: "goal_link", goal, task: Number(task) }); if (!r.ok) throw new Error(String(r.error)); return String(r.text); }
|
|
2710
2867
|
finally { hub.close(); }
|
|
2711
2868
|
};
|
|
2869
|
+
// #1433: `goal new` takes its title from the words the flags leave, so `--help` or a mistyped flag would become the goal's title: refuse it before anything is written.
|
|
2870
|
+
if (args[0] === "new") {
|
|
2871
|
+
const titleWords = args.slice(1).filter((word, index, all) => !GOAL_NEW_FLAGS.includes(word) && !GOAL_NEW_VALUE_FLAGS.includes(all[index - 1] ?? ""));
|
|
2872
|
+
const stray = unknownOption(titleWords);
|
|
2873
|
+
if (stray) return fail(unknownOptionRefusal(stray, "ahub goal new", subcommandUsage("goal", "new")));
|
|
2874
|
+
}
|
|
2712
2875
|
try { console.log(await goalCommand(args, cwd, { link, person: caller.role === "console" })); } catch (e) { fail((e as Error).message); }
|
|
2713
2876
|
},
|
|
2714
2877
|
research: () => {
|
|
@@ -3110,6 +3273,20 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
3110
3273
|
row(stale ? undefined : true, "hub instructions", // a warning, never a failure: doctor's exit code stays what it was for a project that has not refreshed yet
|
|
3111
3274
|
stale ? `the managed block in AGENTS.md differs from this ahub version; preview with: cd ${cwd} && ahub init --dry-run; apply with: cd ${cwd} && ahub init --yes (text outside the markers is kept), then commit AGENTS.md` : "AGENTS.md managed block matches this ahub version");
|
|
3112
3275
|
} catch (error) { row(false, "hub instructions", `AGENTS.md could not be checked: ${error instanceof Error ? error.message : "unknown error"}; run ahub init --dry-run to see why`); }
|
|
3276
|
+
// #1411 T2: a warning, never a failure, like the row above.
|
|
3277
|
+
try { const shared = sharedConfigRow(cwd); if (shared) row(shared.ok, "shared config", shared.detail); }
|
|
3278
|
+
catch (error) { row(undefined, "shared config", `could not be checked: ${error instanceof Error ? error.message : "unknown error"}`); }
|
|
3279
|
+
// #1408 R2: who holds conductor, planner and reviewer as the loader settled them, and a conductor the loader ignored. A warning, never a failure, like the rows above.
|
|
3280
|
+
try {
|
|
3281
|
+
const settled = loadConfig(cwd), scope = readInstanceRoleConfig(cwd), layers = readInstanceConfigLayers(cwd);
|
|
3282
|
+
const declared: Record<string, string[]> = {}, modes: Record<string, "tui" | "headless"> = {};
|
|
3283
|
+
// The start mode the loader reads: the raw peers.<peer>.start_mode, a later layer winning, so doctor and the loader cannot disagree for an instance peer.
|
|
3284
|
+
for (const layer of layers) { const peers = layer.raw.peers; if (peers && typeof peers === "object" && !Array.isArray(peers)) for (const [peer, block] of Object.entries(peers as Record<string, unknown>)) { const mode = block && typeof block === "object" ? (block as { start_mode?: unknown }).start_mode : undefined; if (mode === "tui" || mode === "headless") modes[peer] = mode; } }
|
|
3285
|
+
for (const layer of layers) if (layer.raw.roles && typeof layer.raw.roles === "object" && !Array.isArray(layer.raw.roles)) for (const [peer, list] of Object.entries(layer.raw.roles as Record<string, unknown>)) if (Array.isArray(list)) declared[peer] = list.filter((role): role is string => typeof role === "string");
|
|
3286
|
+
const result = rolesRow({ roles: settled.roles, declared: Object.keys(declared).length ? declared : undefined, startMode: peer => modes[peer],
|
|
3287
|
+
rostered: peer => rosterAllows(settled.roster, peer, settled.pi.enabled, scope.instances, scope.catalog) });
|
|
3288
|
+
row(result.ok, "roles", result.detail);
|
|
3289
|
+
} catch (error) { row(undefined, "roles", `could not be checked: ${error instanceof Error ? error.message : "unknown error"}`); }
|
|
3113
3290
|
const catalog = loadRoleCatalog(cwd);
|
|
3114
3291
|
for (const error of catalog.errors) row(false, "catalog role", `${error.id}: ${error.reason}`);
|
|
3115
3292
|
try {
|
|
@@ -3219,7 +3396,10 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
3219
3396
|
} finally {
|
|
3220
3397
|
// Preserve findings already collected if a later probe (for example config parsing) throws.
|
|
3221
3398
|
if (options.json) console.log(JSON.stringify(checks, null, 2));
|
|
3222
|
-
else printOutput(renderDoctor(checks, options.columns, Date.now(), options.full), options.color);
|
|
3399
|
+
else printOutput(renderDoctor(checks, options.columns, Date.now(), options.full, asciiMarkers(process.env, args.includes("--ascii"))), options.color);
|
|
3400
|
+
// CLI output standard v1: a check command exits 1 when any row is a failure (warnings and unknowns change nothing), `--json` included; the document is unchanged.
|
|
3401
|
+
// `ahub setup` prints the same report but keeps its own exit code (`doctorSetsExit` is cleared there).
|
|
3402
|
+
if (doctorSetsExit && checks.some(check => check.level === "fail")) process.exitCode = 1;
|
|
3223
3403
|
}
|
|
3224
3404
|
},
|
|
3225
3405
|
};
|
|
@@ -3318,6 +3498,7 @@ async function runConductorCommand(): Promise<void> {
|
|
|
3318
3498
|
}
|
|
3319
3499
|
let op: string;
|
|
3320
3500
|
let input: Record<string, unknown>;
|
|
3501
|
+
if (cmd === "answer") return commands.answer!(); // The daemon checks instructed answer authority.
|
|
3321
3502
|
if (cmd === "sdlc") return commands.sdlc!(); // SDLC operational subcommands are role-checked by the daemon.
|
|
3322
3503
|
if (cmd === "task") {
|
|
3323
3504
|
op = args[0] === "assign" ? "hub_task_assign" : "hub_task_escalate";
|