@tokenfactory/acc-runner 0.41.7 → 0.43.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/README.md +87 -4
- package/dist/acc.d.ts +3 -0
- package/dist/acc.d.ts.map +1 -0
- package/dist/acc.js +21 -0
- package/dist/acc.js.map +1 -0
- package/dist/cli-name.d.ts +29 -0
- package/dist/cli-name.d.ts.map +1 -0
- package/dist/cli-name.js +17 -0
- package/dist/cli-name.js.map +1 -0
- package/dist/cli.d.ts +20 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +45 -289
- package/dist/cli.js.map +1 -1
- package/dist/engines/account-probe.d.ts +24 -0
- package/dist/engines/account-probe.d.ts.map +1 -1
- package/dist/engines/account-probe.js +18 -1
- package/dist/engines/account-probe.js.map +1 -1
- package/dist/keychain.d.ts +17 -0
- package/dist/keychain.d.ts.map +1 -1
- package/dist/keychain.js +36 -0
- package/dist/keychain.js.map +1 -1
- package/dist/login.d.ts +45 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/login.js +91 -4
- package/dist/login.js.map +1 -1
- package/dist/machine-capabilities/index.d.ts +21 -0
- package/dist/machine-capabilities/index.d.ts.map +1 -0
- package/dist/machine-capabilities/index.js +21 -0
- package/dist/machine-capabilities/index.js.map +1 -0
- package/dist/machine-capabilities/probe.d.ts +61 -0
- package/dist/machine-capabilities/probe.d.ts.map +1 -0
- package/dist/machine-capabilities/probe.js +243 -0
- package/dist/machine-capabilities/probe.js.map +1 -0
- package/dist/machine-capabilities/redact.d.ts +42 -0
- package/dist/machine-capabilities/redact.d.ts.map +1 -0
- package/dist/machine-capabilities/redact.js +160 -0
- package/dist/machine-capabilities/redact.js.map +1 -0
- package/dist/machine-capabilities/report.d.ts +107 -0
- package/dist/machine-capabilities/report.d.ts.map +1 -0
- package/dist/machine-capabilities/report.js +211 -0
- package/dist/machine-capabilities/report.js.map +1 -0
- package/dist/machine-capabilities/types.d.ts +115 -0
- package/dist/machine-capabilities/types.d.ts.map +1 -0
- package/dist/machine-capabilities/types.js +11 -0
- package/dist/machine-capabilities/types.js.map +1 -0
- package/dist/migration-seq-guard.d.ts +78 -0
- package/dist/migration-seq-guard.d.ts.map +1 -0
- package/dist/migration-seq-guard.js +304 -0
- package/dist/migration-seq-guard.js.map +1 -0
- package/dist/node-version.d.ts +132 -0
- package/dist/node-version.d.ts.map +1 -0
- package/dist/node-version.js +318 -0
- package/dist/node-version.js.map +1 -0
- package/dist/prepr-gate.d.ts +120 -0
- package/dist/prepr-gate.d.ts.map +1 -1
- package/dist/prepr-gate.js +202 -3
- package/dist/prepr-gate.js.map +1 -1
- package/dist/program.d.ts +16 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +355 -0
- package/dist/program.js.map +1 -0
- package/dist/runtime/review-chunking.d.ts +101 -0
- package/dist/runtime/review-chunking.d.ts.map +1 -0
- package/dist/runtime/review-chunking.js +192 -0
- package/dist/runtime/review-chunking.js.map +1 -0
- package/dist/runtime/review-diff.d.ts +30 -0
- package/dist/runtime/review-diff.d.ts.map +1 -0
- package/dist/runtime/review-diff.js +59 -0
- package/dist/runtime/review-diff.js.map +1 -0
- package/dist/runtime/reviewer.d.ts +40 -19
- package/dist/runtime/reviewer.d.ts.map +1 -1
- package/dist/runtime/reviewer.js +252 -51
- package/dist/runtime/reviewer.js.map +1 -1
- package/dist/serve-scope/command.d.ts +12 -0
- package/dist/serve-scope/command.d.ts.map +1 -0
- package/dist/serve-scope/command.js +89 -0
- package/dist/serve-scope/command.js.map +1 -0
- package/dist/serve-scope/index.d.ts +130 -0
- package/dist/serve-scope/index.d.ts.map +1 -0
- package/dist/serve-scope/index.js +148 -0
- package/dist/serve-scope/index.js.map +1 -0
- package/dist/task-runner.d.ts +11 -0
- package/dist/task-runner.d.ts.map +1 -1
- package/dist/task-runner.js +69 -0
- package/dist/task-runner.js.map +1 -1
- package/dist/user-auth/device-login.d.ts +47 -0
- package/dist/user-auth/device-login.d.ts.map +1 -0
- package/dist/user-auth/device-login.js +189 -0
- package/dist/user-auth/device-login.js.map +1 -0
- package/dist/user-auth/liveness.d.ts +27 -0
- package/dist/user-auth/liveness.d.ts.map +1 -0
- package/dist/user-auth/liveness.js +128 -0
- package/dist/user-auth/liveness.js.map +1 -0
- package/dist/user-auth/session.d.ts +82 -0
- package/dist/user-auth/session.d.ts.map +1 -0
- package/dist/user-auth/session.js +172 -0
- package/dist/user-auth/session.js.map +1 -0
- package/dist/user-cli/chat.d.ts +44 -0
- package/dist/user-cli/chat.d.ts.map +1 -0
- package/dist/user-cli/chat.js +199 -0
- package/dist/user-cli/chat.js.map +1 -0
- package/dist/user-cli/client.d.ts +20 -0
- package/dist/user-cli/client.d.ts.map +1 -0
- package/dist/user-cli/client.js +60 -0
- package/dist/user-cli/client.js.map +1 -0
- package/dist/user-cli/tasks.d.ts +37 -0
- package/dist/user-cli/tasks.d.ts.map +1 -0
- package/dist/user-cli/tasks.js +131 -0
- package/dist/user-cli/tasks.js.map +1 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.d.ts.map +1 -1
- package/dist/watch.js +28 -0
- package/dist/watch.js.map +1 -1
- package/package.json +3 -2
package/dist/program.js
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE command tree, built for whichever binary name invoked it.
|
|
3
|
+
*
|
|
4
|
+
* The package ships two bins — `acc` (unified) and `acc-runner` (the original
|
|
5
|
+
* name, kept as a deprecated alias) — over this single tree. Almost every
|
|
6
|
+
* command is registered identically for both; the exception is `login` /
|
|
7
|
+
* `logout`, and the reason is compatibility rather than taste.
|
|
8
|
+
*
|
|
9
|
+
* WHY `login` IS NAME-DEPENDENT
|
|
10
|
+
* ----------------------------------------------------------------------------
|
|
11
|
+
* There are two lanes, and the published meaning of the old name is already
|
|
12
|
+
* spoken for:
|
|
13
|
+
*
|
|
14
|
+
* * the MACHINE lane — enrol this host into the fleet, mint an ACC-signed JWT
|
|
15
|
+
* that impersonates its owner, create a runner row. That is what
|
|
16
|
+
* `acc-runner login` has always meant, and it is baked into docker
|
|
17
|
+
* entrypoints, launchd plists and the enrollment guidance the UI prints.
|
|
18
|
+
* * the PERSON lane — sign the human at the keyboard in as themselves, via the
|
|
19
|
+
* generalized device flow, with no runner row. That is what a command called
|
|
20
|
+
* `acc login` must mean; a unified CLI whose `login` enrolled a server would
|
|
21
|
+
* be actively misleading.
|
|
22
|
+
*
|
|
23
|
+
* Silently redefining `acc-runner login` to the person lane would be a breaking
|
|
24
|
+
* change wearing an alias costume — every existing enrollment script would stop
|
|
25
|
+
* producing a runner and start producing a session. So the mapping is:
|
|
26
|
+
*
|
|
27
|
+
* acc login → person acc runner login → machine
|
|
28
|
+
* acc-runner login → machine acc-runner auth login → person
|
|
29
|
+
*
|
|
30
|
+
* Both spellings of each lane exist under both names, so nothing an operator or
|
|
31
|
+
* a script types today changes meaning, and `acc runner login` is the forward
|
|
32
|
+
* name for what the alias called `login`.
|
|
33
|
+
*/
|
|
34
|
+
import { realpathSync } from "node:fs";
|
|
35
|
+
import { fileURLToPath } from "node:url";
|
|
36
|
+
import { Command } from "commander";
|
|
37
|
+
import chalk from "chalk";
|
|
38
|
+
import { loadConfig } from "./config.js";
|
|
39
|
+
import { fetchPricing } from "./cost-pricing.js";
|
|
40
|
+
import { loginCommand } from "./login.js";
|
|
41
|
+
import { logoutCommand } from "./logout.js";
|
|
42
|
+
import { watchCommand } from "./watch.js";
|
|
43
|
+
import { companionCommand, companionInstallCommand, companionStatusCommand, companionUninstallCommand, } from "./companion-run.js";
|
|
44
|
+
import { authLoginCommand, authLogoutCommand, authStatusCommand, } from "./user-auth/device-login.js";
|
|
45
|
+
import { ensureUserSessionLive } from "./user-auth/liveness.js";
|
|
46
|
+
import { chatCommand } from "./user-cli/chat.js";
|
|
47
|
+
import { taskListCommand, taskShowCommand } from "./user-cli/tasks.js";
|
|
48
|
+
import { doctorCommand } from "./doctor.js";
|
|
49
|
+
import { serveScopeCommand } from "./serve-scope/command.js";
|
|
50
|
+
import { clarifyCommand } from "./clarification.js";
|
|
51
|
+
import { clearQuarantine, getQuarantine } from "./runtime/quarantine.js";
|
|
52
|
+
import { clearChatCircuit, getChatCircuit } from "./runtime/chat-circuit-breaker.js";
|
|
53
|
+
import { runCommitGuardHook } from "./commit-guard.js";
|
|
54
|
+
import { PROTOCOL_VERSION } from "./types.js";
|
|
55
|
+
import { PACKAGE_VERSION } from "./pkg-version.js";
|
|
56
|
+
/** Every action shares this shape: report the message, set a failing exit code. */
|
|
57
|
+
function guard(fn) {
|
|
58
|
+
return async () => {
|
|
59
|
+
try {
|
|
60
|
+
await fn();
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error(chalk.red(`✗ ${err.message}`));
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A person-lane command that ACTS on the operator's credential, rather than one
|
|
70
|
+
* that manages it. These check first that the credential still exists server-side,
|
|
71
|
+
* because a revoke on Settings → Sessions cannot reach into this machine's
|
|
72
|
+
* keychain: without the check, a revoked terminal keeps reading the board until
|
|
73
|
+
* its access token expires (see user-auth/liveness.ts). Login / logout / whoami
|
|
74
|
+
* are deliberately NOT wrapped — logging in has nothing to check yet, and logging
|
|
75
|
+
* out of a session that is already gone must still clear the keychain.
|
|
76
|
+
*/
|
|
77
|
+
function personGuard(fn) {
|
|
78
|
+
return guard(async () => {
|
|
79
|
+
await ensureUserSessionLive();
|
|
80
|
+
await fn();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export function buildProgram(options = {}) {
|
|
84
|
+
const invokedAs = options.invokedAs ?? "acc-runner";
|
|
85
|
+
const unified = invokedAs === "acc";
|
|
86
|
+
const program = new Command();
|
|
87
|
+
program
|
|
88
|
+
.name(invokedAs)
|
|
89
|
+
.description(unified
|
|
90
|
+
? "Agent Control Center. Sign in, read the board, ask ACC, and run agents on this machine."
|
|
91
|
+
: "Agent Control Center local runner. Subscribes to ACC, spawns Claude Code on assignment, and opens a PR when done.")
|
|
92
|
+
.version(`${PACKAGE_VERSION} (protocol v${PROTOCOL_VERSION})`);
|
|
93
|
+
// ── The person lane ───────────────────────────────────────────────────────
|
|
94
|
+
// Registered under `auth <verb>` for BOTH names (so `acc-runner auth login`
|
|
95
|
+
// is untouched), and additionally promoted to the top level under `acc`,
|
|
96
|
+
// where `login` is free to mean what a person expects it to mean.
|
|
97
|
+
const registerPersonLane = (parent, verbs) => {
|
|
98
|
+
parent
|
|
99
|
+
.command("login")
|
|
100
|
+
.description("Sign in via device-code and store a user session in the OS keychain.")
|
|
101
|
+
.action(guard(() => authLoginCommand()));
|
|
102
|
+
parent
|
|
103
|
+
.command(verbs.status)
|
|
104
|
+
.description("Show who this terminal is signed in as.")
|
|
105
|
+
.action(guard(() => authStatusCommand()));
|
|
106
|
+
parent
|
|
107
|
+
.command("logout")
|
|
108
|
+
.description("Revoke this terminal's user session and clear the keychain entry.")
|
|
109
|
+
.action(guard(() => authLogoutCommand()));
|
|
110
|
+
};
|
|
111
|
+
const authCmd = program
|
|
112
|
+
.command("auth")
|
|
113
|
+
.description("Sign in to ACC as yourself (no runner registration).");
|
|
114
|
+
registerPersonLane(authCmd, { status: "status" });
|
|
115
|
+
// ── The machine lane ──────────────────────────────────────────────────────
|
|
116
|
+
const registerMachineLane = (parent) => {
|
|
117
|
+
parent
|
|
118
|
+
.command("login")
|
|
119
|
+
.description("Sign in via device-code OAuth and register this machine.")
|
|
120
|
+
.action(guard(() => loginCommand()));
|
|
121
|
+
parent
|
|
122
|
+
.command("logout")
|
|
123
|
+
.description("Clear the local session and mark this runner offline.")
|
|
124
|
+
.action(guard(() => logoutCommand()));
|
|
125
|
+
};
|
|
126
|
+
registerMachineLane(program
|
|
127
|
+
.command("runner")
|
|
128
|
+
.description("Enrol or retire THIS machine as a runner in the fleet."));
|
|
129
|
+
if (unified) {
|
|
130
|
+
registerPersonLane(program, { status: "whoami" });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
registerMachineLane(program);
|
|
134
|
+
}
|
|
135
|
+
// ── Reading the board ─────────────────────────────────────────────────────
|
|
136
|
+
const taskCmd = program
|
|
137
|
+
.command("task")
|
|
138
|
+
.description("Read the task board as yourself (read-only).");
|
|
139
|
+
taskCmd
|
|
140
|
+
.command("list")
|
|
141
|
+
.description("List tasks visible to you, newest first.")
|
|
142
|
+
.option("--status <status>", "Only tasks in this status (e.g. in_progress).")
|
|
143
|
+
.option("--repo <slug>", "Only tasks for this repo (owner/name).")
|
|
144
|
+
.option("--limit <n>", "How many rows (1-100, default 25).")
|
|
145
|
+
.option("--json", "Emit raw JSON instead of a table.")
|
|
146
|
+
.action((opts) => personGuard(() => taskListCommand(opts))());
|
|
147
|
+
taskCmd
|
|
148
|
+
.command("show")
|
|
149
|
+
.description("Show one task in full.")
|
|
150
|
+
.argument("<id>", "Task id, e.g. T-1234.")
|
|
151
|
+
.option("--json", "Emit raw JSON instead of fields.")
|
|
152
|
+
.action((id, opts) => personGuard(() => taskShowCommand(id, opts))());
|
|
153
|
+
program
|
|
154
|
+
.command("chat")
|
|
155
|
+
.description("Ask ACC. Pass a question, pipe one in, or run bare for a session.")
|
|
156
|
+
.argument("[message...]", "The question. Omit for an interactive session.")
|
|
157
|
+
.option("--conversation <id>", "Continue an existing conversation.")
|
|
158
|
+
.option("--json", "Emit the turn as JSON instead of streaming it.")
|
|
159
|
+
.action((words, opts) => personGuard(() => chatCommand(words ?? [], opts))());
|
|
160
|
+
// ── Running agents on this machine ────────────────────────────────────────
|
|
161
|
+
program
|
|
162
|
+
.command("watch")
|
|
163
|
+
.description("Long-running. Receive task assignments and execute them.")
|
|
164
|
+
.action(guard(async () => {
|
|
165
|
+
// Warm the cost-pricing cache before the realtime loop opens.
|
|
166
|
+
// fetchPricing handles its own logging; embedded fallback governs
|
|
167
|
+
// if the endpoint is unreachable.
|
|
168
|
+
await fetchPricing(loadConfig().publicUrl);
|
|
169
|
+
await watchCommand();
|
|
170
|
+
// Keep the process alive — stop() runs in the SIGINT handler.
|
|
171
|
+
await new Promise(() => { });
|
|
172
|
+
}));
|
|
173
|
+
// COMPANION: companion mode — an owner-affinity chat runner. Serves ONLY the
|
|
174
|
+
// logged-in owner's interactive chat turns (no code tasks), mirrors the turn
|
|
175
|
+
// stream to the same-machine browser over a loopback socket, and on exit
|
|
176
|
+
// requeues in-flight turns so an Auto turn fails over to the fleet.
|
|
177
|
+
const companionCmd = program
|
|
178
|
+
.command("companion")
|
|
179
|
+
.description("Long-running. Serve the owner's interactive chat turns (companion mode).")
|
|
180
|
+
.action(guard(async () => {
|
|
181
|
+
const handle = await companionCommand();
|
|
182
|
+
const shutdown = () => {
|
|
183
|
+
void handle.stop().finally(() => process.exit(0));
|
|
184
|
+
};
|
|
185
|
+
process.on("SIGINT", shutdown);
|
|
186
|
+
process.on("SIGTERM", shutdown);
|
|
187
|
+
// Keep the process alive; the loop runs on timers until a signal.
|
|
188
|
+
await new Promise(() => { });
|
|
189
|
+
}));
|
|
190
|
+
companionCmd
|
|
191
|
+
.command("status")
|
|
192
|
+
.description("Print the one-line companion status (menu-bar friendly).")
|
|
193
|
+
.action(guard(() => companionStatusCommand()));
|
|
194
|
+
companionCmd
|
|
195
|
+
.command("install")
|
|
196
|
+
.description("Install the companion login agent (autostart at login).")
|
|
197
|
+
.action(guard(() => companionInstallCommand()));
|
|
198
|
+
companionCmd
|
|
199
|
+
.command("uninstall")
|
|
200
|
+
.description("Remove the companion login agent.")
|
|
201
|
+
.action(guard(() => companionUninstallCommand()));
|
|
202
|
+
// AX-H2 (SERVE-SCOPE-CONSENT): whose work this machine serves. Lives at the
|
|
203
|
+
// machine because the thing being consented to — this host's gh credential,
|
|
204
|
+
// git identity and Claude subscription — is in front of the person deciding,
|
|
205
|
+
// and because acc.set_runner_serve_scope will only accept the answer from the
|
|
206
|
+
// machine's bound owner anyway.
|
|
207
|
+
program
|
|
208
|
+
.command("serve-scope")
|
|
209
|
+
.description("Show or set whose work this machine serves (owner-only by default).")
|
|
210
|
+
.argument("[scope]", "\"owner\" (this machine's owner only) or \"org\" (the whole org).")
|
|
211
|
+
.option("--yes", "Consent to org-wide serving. Required — widening is never implied.")
|
|
212
|
+
.option("--reason <text>", "Recorded on the consent ledger row.")
|
|
213
|
+
.action((scope, opts) => guard(() => serveScopeCommand({ scope, yes: opts.yes, reason: opts.reason }))());
|
|
214
|
+
program
|
|
215
|
+
.command("doctor")
|
|
216
|
+
.description("Run environment checks. Exit 0 if all green, 1 otherwise.")
|
|
217
|
+
.option("--strict", "Treat advisory warnings (missing ANTHROPIC_API_KEY, version drift, etc.) as failures.")
|
|
218
|
+
.action(async (opts) => {
|
|
219
|
+
const code = await doctorCommand({ strict: opts.strict === true });
|
|
220
|
+
process.exitCode = code;
|
|
221
|
+
});
|
|
222
|
+
// NEEDS-INFO-HALT: a spawned agent that needs clarification / approval /
|
|
223
|
+
// missing information raises a needs_clarification halt for its task and hands
|
|
224
|
+
// the question off to JOJO, instead of guessing or dead-lettering. The operator
|
|
225
|
+
// answers by resolving the halt, which resumes the SAME task blocked -> queued.
|
|
226
|
+
program
|
|
227
|
+
.command("clarify")
|
|
228
|
+
.description("Raise a needs_clarification halt for a task and hand the question off to JOJO.")
|
|
229
|
+
.requiredOption("--task <id>", "Task id the agent is blocked on (e.g. T-1234).")
|
|
230
|
+
.requiredOption("--question <text>", "The question / missing info the operator must answer.")
|
|
231
|
+
.option("--context <json>", "Optional JSON object merged into the halt payload.")
|
|
232
|
+
.action((opts) => guard(() => clarifyCommand(opts))());
|
|
233
|
+
// Quarantine management. The runner enters quarantine automatically when the
|
|
234
|
+
// failure classifier detects a machine-level failure. An operator resolves the
|
|
235
|
+
// underlying issue then clears the quarantine to resume work.
|
|
236
|
+
const quarantineCmd = program
|
|
237
|
+
.command("quarantine")
|
|
238
|
+
.description("Inspect or clear the runner quarantine state.");
|
|
239
|
+
quarantineCmd
|
|
240
|
+
.command("status")
|
|
241
|
+
.description("Show quarantine state.")
|
|
242
|
+
.action(guard(async () => {
|
|
243
|
+
const q = await getQuarantine();
|
|
244
|
+
if (!q) {
|
|
245
|
+
console.log("Runner is not quarantined.");
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
console.log(chalk.red.bold(`QUARANTINED (${q.cause})`));
|
|
249
|
+
console.log(` Detail: ${q.detail}`);
|
|
250
|
+
console.log(` Task: ${q.taskId}`);
|
|
251
|
+
console.log(` Since: ${q.classifiedAt}`);
|
|
252
|
+
// Consecutive instant-empty count (1 = definitive, 2 = heuristic
|
|
253
|
+
// confirmed by retry). Omitted for states written before it existed.
|
|
254
|
+
if (q.consecutive !== undefined) {
|
|
255
|
+
console.log(` Streak: ${q.consecutive} consecutive instant-empty exit(s)`);
|
|
256
|
+
}
|
|
257
|
+
console.log(chalk.gray(`\nResolve the underlying ${q.cause} issue, then run \`${invokedAs} quarantine clear\`.`));
|
|
258
|
+
process.exitCode = 1;
|
|
259
|
+
}));
|
|
260
|
+
quarantineCmd
|
|
261
|
+
.command("clear")
|
|
262
|
+
.description("Clear quarantine and allow the runner to resume claiming tasks.")
|
|
263
|
+
.action(guard(async () => {
|
|
264
|
+
await clearQuarantine();
|
|
265
|
+
console.log(chalk.green("✓ Quarantine cleared. Runner will resume on next task assignment."));
|
|
266
|
+
}));
|
|
267
|
+
// TURN-LANE: chat-circuit management. The runner opens the chat circuit
|
|
268
|
+
// automatically when a `claude_exit_1`-class fault surfaces while serving a
|
|
269
|
+
// chat turn — benching ONLY the chat lane (code/review keep running). An
|
|
270
|
+
// operator resolves the credential/host issue then clears it to resume chat.
|
|
271
|
+
const chatCircuitCmd = program
|
|
272
|
+
.command("chat-circuit")
|
|
273
|
+
.description("Inspect or clear the chat-capability circuit breaker (chat lane only).");
|
|
274
|
+
chatCircuitCmd
|
|
275
|
+
.command("status")
|
|
276
|
+
.description("Show chat circuit state.")
|
|
277
|
+
.action(guard(async () => {
|
|
278
|
+
const c = await getChatCircuit();
|
|
279
|
+
if (!c) {
|
|
280
|
+
console.log("Chat circuit is closed (chat lane serving).");
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
console.log(chalk.red.bold(`CHAT CIRCUIT OPEN (${c.cause})`));
|
|
284
|
+
console.log(` Detail: ${c.detail}`);
|
|
285
|
+
console.log(` Turn: ${c.turnId}`);
|
|
286
|
+
console.log(` Conversation: ${c.conversationId}`);
|
|
287
|
+
console.log(` Since: ${c.trippedAt}`);
|
|
288
|
+
console.log(chalk.gray(`\nResolve the underlying ${c.cause} issue, then run \`${invokedAs} chat-circuit clear\`. ` +
|
|
289
|
+
`Code/review lanes are unaffected.`));
|
|
290
|
+
process.exitCode = 1;
|
|
291
|
+
}));
|
|
292
|
+
chatCircuitCmd
|
|
293
|
+
.command("clear")
|
|
294
|
+
.description("Close the chat circuit and allow the runner to resume claiming chat turns.")
|
|
295
|
+
.action(guard(async () => {
|
|
296
|
+
await clearChatCircuit();
|
|
297
|
+
console.log(chalk.green("✓ Chat circuit closed. Runner will resume claiming chat turns."));
|
|
298
|
+
}));
|
|
299
|
+
// The git pre-commit hook the runner installs into a task worktree (see
|
|
300
|
+
// commit-guard.ts) re-invokes this hidden subcommand. It scans the STAGED text
|
|
301
|
+
// files and exits non-zero (with an actionable message on stderr) when a NUL
|
|
302
|
+
// byte / invalid UTF-8 / binary-blob-where-text is found, so git aborts the
|
|
303
|
+
// commit and the agent fixes it in-session. Hidden — it is a hook entry point,
|
|
304
|
+
// not an operator command.
|
|
305
|
+
program
|
|
306
|
+
.command("_precommit-guard", { hidden: true })
|
|
307
|
+
.description("Internal: commit-time mechanical guard (pre-commit hook entry).")
|
|
308
|
+
.action(async () => {
|
|
309
|
+
try {
|
|
310
|
+
const result = await runCommitGuardHook();
|
|
311
|
+
if (!result.ok) {
|
|
312
|
+
console.error(result.message);
|
|
313
|
+
process.exitCode = 1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch (err) {
|
|
317
|
+
// Fail OPEN on an internal error: a guard bug must never wedge the agent's
|
|
318
|
+
// ability to commit. The pre-PR gate (prepr-gate.ts) is the backstop.
|
|
319
|
+
console.error(chalk.yellow(`commit-guard skipped (internal error): ${err.message}`));
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
program
|
|
323
|
+
.command("version")
|
|
324
|
+
.description("Print CLI + protocol versions.")
|
|
325
|
+
.action(() => {
|
|
326
|
+
const label = Math.max(invokedAs.length, "protocol".length);
|
|
327
|
+
console.log(`${invokedAs.padEnd(label)} ${PACKAGE_VERSION}`);
|
|
328
|
+
console.log(`${"protocol".padEnd(label)} ${PROTOCOL_VERSION}`);
|
|
329
|
+
});
|
|
330
|
+
return program;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* True when `moduleUrl` is the process entry point — NOT when it is imported by
|
|
334
|
+
* a test. realpath resolves the npm bin symlink to the built file so the compare
|
|
335
|
+
* holds for a globally-installed CLI.
|
|
336
|
+
*/
|
|
337
|
+
export function isMainModule(moduleUrl) {
|
|
338
|
+
const entry = process.argv[1];
|
|
339
|
+
if (!entry)
|
|
340
|
+
return false;
|
|
341
|
+
try {
|
|
342
|
+
return realpathSync(entry) === realpathSync(fileURLToPath(moduleUrl));
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/** Parse argv and turn a thrown error into a red line + exit 1. */
|
|
349
|
+
export function runProgram(program) {
|
|
350
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
351
|
+
console.error(chalk.red(`✗ ${err.message}`));
|
|
352
|
+
process.exit(1);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAA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CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REVIEWER-DIFF-CAP — make a large PR REVIEWABLE instead of unreviewable.
|
|
3
|
+
*
|
|
4
|
+
* MEASURED FAULT (PR #1815, 140,456 chars / 13 files against a 60,000-char cap):
|
|
5
|
+
* the runner-local reviewer truncated the diff, then spent three review cycles
|
|
6
|
+
* turning that truncation into code verdicts —
|
|
7
|
+
* 1. an advisory hold (infra),
|
|
8
|
+
* 2. a reject citing files "not present in the reviewable diff",
|
|
9
|
+
* 3. a reject stating "more than half the PR is not visible and cannot be
|
|
10
|
+
* verified".
|
|
11
|
+
* Zero defects were ever demonstrated, the PR deadlocked mergeable, and the
|
|
12
|
+
* rework loop it triggered could never succeed — reworking code does not shrink
|
|
13
|
+
* a diff. A reviewer must never convert its own tooling limitation into a code
|
|
14
|
+
* verdict.
|
|
15
|
+
*
|
|
16
|
+
* This module is the pure half of the fix. It provides:
|
|
17
|
+
*
|
|
18
|
+
* 1. `planReviewChunks` — split an over-cap diff into whole-file chunks that
|
|
19
|
+
* each fit under the cap, so EVERY file is actually read by some pass. The
|
|
20
|
+
* split is BYTE-EXACT: `chunks.map(c => c.text).join("") === diff`, which is
|
|
21
|
+
* what makes "nothing was withheld" a provable property rather than a claim.
|
|
22
|
+
* 2. The ABSENCE-CLAIM guard — patterns + partitioner that recognise a reason
|
|
23
|
+
* asserting content is missing/invisible/unverifiable. The runner had no such
|
|
24
|
+
* guard (the server path has had one since the #1665/#1679/#1690 wave); that
|
|
25
|
+
* absence is why #1815's two rejects stood.
|
|
26
|
+
*
|
|
27
|
+
* The absence-claim half is a MIRROR of `api/_lib/reviewer/absence-claims.ts` —
|
|
28
|
+
* the runner is a standalone published package and cannot import from `api/_lib`.
|
|
29
|
+
* // keep in sync with api/_lib/reviewer/absence-claims.ts
|
|
30
|
+
*
|
|
31
|
+
* PURE. No I/O, no clock, no client. The wiring lives in `reviewer.ts`.
|
|
32
|
+
*/
|
|
33
|
+
/** One reviewable slice of an over-cap diff. `text` is a verbatim byte range. */
|
|
34
|
+
export interface ReviewChunk {
|
|
35
|
+
/** 1-based position in the chunk sequence. */
|
|
36
|
+
index: number;
|
|
37
|
+
/** Total chunks in the sequence (same value on every chunk). */
|
|
38
|
+
total: number;
|
|
39
|
+
/** File paths whose content this chunk carries (whole or partial). */
|
|
40
|
+
paths: string[];
|
|
41
|
+
/** The verbatim diff bytes this chunk carries. */
|
|
42
|
+
text: string;
|
|
43
|
+
/**
|
|
44
|
+
* True when this chunk carries only PART of a single file that exceeded the
|
|
45
|
+
* per-chunk cap on its own. The remaining parts ride the adjacent chunks, so
|
|
46
|
+
* the file is still fully covered ACROSS the sequence — never withheld.
|
|
47
|
+
*/
|
|
48
|
+
partial: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Hard ceiling on chunk count. A diff needing more passes than this is not a
|
|
52
|
+
* review problem the runner can solve by spending more subscription budget — it
|
|
53
|
+
* is reported as an INFRA outcome by the caller (never a reject), so the
|
|
54
|
+
* escalation path owns it. 8 chunks × 60,000 chars ≈ 480 KB of diff.
|
|
55
|
+
*/
|
|
56
|
+
export declare const MAX_REVIEW_CHUNKS = 8;
|
|
57
|
+
/**
|
|
58
|
+
* Split `diff` into chunks that each fit within `maxChars`, cutting at whole-file
|
|
59
|
+
* boundaries wherever possible.
|
|
60
|
+
*
|
|
61
|
+
* INVARIANTS (all asserted by the wave's tests):
|
|
62
|
+
* - byte-exact: `chunks.map(c => c.text).join("") === diff`;
|
|
63
|
+
* - every chunk's `text.length <= maxChars` (except the degenerate `maxChars <= 0`);
|
|
64
|
+
* - a diff at or under the cap yields exactly ONE chunk holding the whole diff,
|
|
65
|
+
* so the caller's single-pass path stays byte-identical to before.
|
|
66
|
+
*
|
|
67
|
+
* A file larger than `maxChars` on its own is sliced into contiguous parts rather
|
|
68
|
+
* than dropped — a partly-shown file across two passes still gets fully read,
|
|
69
|
+
* which a truncating cap never achieved.
|
|
70
|
+
*/
|
|
71
|
+
export declare function planReviewChunks(diff: string, maxChars: number): ReviewChunk[];
|
|
72
|
+
export declare const ABSENCE_CLAIM_PATTERNS: RegExp[];
|
|
73
|
+
/**
|
|
74
|
+
* True when one reviewer reason asserts that content is ABSENT from — or
|
|
75
|
+
* unverifiable within — what the reviewer was shown, rather than describing a
|
|
76
|
+
* defect in what it read. Only meaningful when coverage was incomplete; callers
|
|
77
|
+
* MUST gate on that before acting on it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isAbsenceClaimReason(reason: string | null | undefined): boolean;
|
|
80
|
+
/** Sub-marker identifying this class inside the escalation headline. */
|
|
81
|
+
export declare const TRUNCATED_ABSENCE_MARKER = "truncated-diff absence claim";
|
|
82
|
+
/**
|
|
83
|
+
* Headline stamped on a verdict the absence guard escalates. Opens with RR-3's
|
|
84
|
+
* `reviewer tooling failure:` marker so every existing consumer
|
|
85
|
+
* (`isToolingFailureReviewerOutcome`, the budget exemption in
|
|
86
|
+
* `countReviewerErrors`, the neutral `acc/review` publish) routes it as INFRA.
|
|
87
|
+
*
|
|
88
|
+
* Phrased to match none of the patterns above (asserted by the wave's test), so
|
|
89
|
+
* a re-scan of a stored row can never re-classify our own headline as a claim.
|
|
90
|
+
*/
|
|
91
|
+
export declare const REVIEWER_ABSENCE_ESCALATION_REASON: string;
|
|
92
|
+
/** Prefix marking a discarded claim in the audit trail (never re-emitted as a finding). */
|
|
93
|
+
export declare const DISCARDED_CLAIM_PREFIX = "discarded (unsound \u2014 a read-coverage claim, not a defect): ";
|
|
94
|
+
/** True when a completed review row is an absence-guard escalation. */
|
|
95
|
+
export declare function isAbsenceEscalatedOutcome(decision: string | null | undefined, reasons: string[] | null | undefined): boolean;
|
|
96
|
+
/** Split a reason list into the substantive findings and the absence claims. */
|
|
97
|
+
export declare function partitionAbsenceClaims(reasons: string[] | null | undefined): {
|
|
98
|
+
substantive: string[];
|
|
99
|
+
absence: string[];
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=review-chunking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-chunking.d.ts","sourceRoot":"","sources":["../../src/runtime/review-chunking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,iFAAiF;AACjF,MAAM,WAAW,WAA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