@tokenfactory/acc-runner 0.25.0 → 0.27.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 +77 -4
- package/package.json +1 -1
- package/dist/anthropic-auth.d.ts +0 -53
- package/dist/anthropic-auth.d.ts.map +0 -1
- package/dist/anthropic-auth.js +0 -89
- package/dist/anthropic-auth.js.map +0 -1
- package/dist/bin-resolve.d.ts +0 -16
- package/dist/bin-resolve.d.ts.map +0 -1
- package/dist/bin-resolve.js +0 -35
- package/dist/bin-resolve.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -128
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts +0 -121
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -396
- package/dist/config.js.map +0 -1
- package/dist/cost-pricing.d.ts +0 -130
- package/dist/cost-pricing.d.ts.map +0 -1
- package/dist/cost-pricing.js +0 -191
- package/dist/cost-pricing.js.map +0 -1
- package/dist/doctor.d.ts +0 -37
- package/dist/doctor.d.ts.map +0 -1
- package/dist/doctor.js +0 -658
- package/dist/doctor.js.map +0 -1
- package/dist/failure-classifier.d.ts +0 -112
- package/dist/failure-classifier.d.ts.map +0 -1
- package/dist/failure-classifier.js +0 -353
- package/dist/failure-classifier.js.map +0 -1
- package/dist/gh.d.ts +0 -22
- package/dist/gh.d.ts.map +0 -1
- package/dist/gh.js +0 -48
- package/dist/gh.js.map +0 -1
- package/dist/git.d.ts +0 -50
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js +0 -127
- package/dist/git.js.map +0 -1
- package/dist/github-client.d.ts +0 -133
- package/dist/github-client.d.ts.map +0 -1
- package/dist/github-client.js +0 -234
- package/dist/github-client.js.map +0 -1
- package/dist/keychain.d.ts +0 -21
- package/dist/keychain.d.ts.map +0 -1
- package/dist/keychain.js +0 -45
- package/dist/keychain.js.map +0 -1
- package/dist/login.d.ts +0 -12
- package/dist/login.d.ts.map +0 -1
- package/dist/login.js +0 -133
- package/dist/login.js.map +0 -1
- package/dist/logout.d.ts +0 -2
- package/dist/logout.d.ts.map +0 -1
- package/dist/logout.js +0 -31
- package/dist/logout.js.map +0 -1
- package/dist/mcp-spawn.d.ts +0 -30
- package/dist/mcp-spawn.d.ts.map +0 -1
- package/dist/mcp-spawn.js +0 -145
- package/dist/mcp-spawn.js.map +0 -1
- package/dist/messaging.d.ts +0 -49
- package/dist/messaging.d.ts.map +0 -1
- package/dist/messaging.js +0 -36
- package/dist/messaging.js.map +0 -1
- package/dist/pkg-version.d.ts +0 -3
- package/dist/pkg-version.d.ts.map +0 -1
- package/dist/pkg-version.js +0 -20
- package/dist/pkg-version.js.map +0 -1
- package/dist/profiles/designer-prompt.d.ts +0 -18
- package/dist/profiles/designer-prompt.d.ts.map +0 -1
- package/dist/profiles/designer-prompt.js +0 -172
- package/dist/profiles/designer-prompt.js.map +0 -1
- package/dist/profiles/developer-prompt.d.ts +0 -24
- package/dist/profiles/developer-prompt.d.ts.map +0 -1
- package/dist/profiles/developer-prompt.js +0 -24
- package/dist/profiles/developer-prompt.js.map +0 -1
- package/dist/profiles/manager-prompt.d.ts +0 -34
- package/dist/profiles/manager-prompt.d.ts.map +0 -1
- package/dist/profiles/manager-prompt.js +0 -93
- package/dist/profiles/manager-prompt.js.map +0 -1
- package/dist/profiles/tester-prompt.d.ts +0 -28
- package/dist/profiles/tester-prompt.d.ts.map +0 -1
- package/dist/profiles/tester-prompt.js +0 -165
- package/dist/profiles/tester-prompt.js.map +0 -1
- package/dist/prompt.d.ts +0 -38
- package/dist/prompt.d.ts.map +0 -1
- package/dist/prompt.js +0 -78
- package/dist/prompt.js.map +0 -1
- package/dist/runtime/cache-dir.d.ts +0 -2
- package/dist/runtime/cache-dir.d.ts.map +0 -1
- package/dist/runtime/cache-dir.js +0 -15
- package/dist/runtime/cache-dir.js.map +0 -1
- package/dist/runtime/conflict-resolver.d.ts +0 -65
- package/dist/runtime/conflict-resolver.d.ts.map +0 -1
- package/dist/runtime/conflict-resolver.js +0 -477
- package/dist/runtime/conflict-resolver.js.map +0 -1
- package/dist/runtime/expand-args.d.ts +0 -28
- package/dist/runtime/expand-args.d.ts.map +0 -1
- package/dist/runtime/expand-args.js +0 -50
- package/dist/runtime/expand-args.js.map +0 -1
- package/dist/runtime/locks.d.ts +0 -21
- package/dist/runtime/locks.d.ts.map +0 -1
- package/dist/runtime/locks.js +0 -97
- package/dist/runtime/locks.js.map +0 -1
- package/dist/runtime/provision-mutex.d.ts +0 -37
- package/dist/runtime/provision-mutex.d.ts.map +0 -1
- package/dist/runtime/provision-mutex.js +0 -67
- package/dist/runtime/provision-mutex.js.map +0 -1
- package/dist/runtime/quarantine.d.ts +0 -26
- package/dist/runtime/quarantine.d.ts.map +0 -1
- package/dist/runtime/quarantine.js +0 -50
- package/dist/runtime/quarantine.js.map +0 -1
- package/dist/runtime/resolution-integrity.d.ts +0 -86
- package/dist/runtime/resolution-integrity.d.ts.map +0 -1
- package/dist/runtime/resolution-integrity.js +0 -248
- package/dist/runtime/resolution-integrity.js.map +0 -1
- package/dist/runtime/reviewer.d.ts +0 -81
- package/dist/runtime/reviewer.d.ts.map +0 -1
- package/dist/runtime/reviewer.js +0 -374
- package/dist/runtime/reviewer.js.map +0 -1
- package/dist/runtime/rework.d.ts +0 -48
- package/dist/runtime/rework.d.ts.map +0 -1
- package/dist/runtime/rework.js +0 -136
- package/dist/runtime/rework.js.map +0 -1
- package/dist/runtime/singleton.d.ts +0 -47
- package/dist/runtime/singleton.d.ts.map +0 -1
- package/dist/runtime/singleton.js +0 -200
- package/dist/runtime/singleton.js.map +0 -1
- package/dist/runtime/version-drift.d.ts +0 -31
- package/dist/runtime/version-drift.d.ts.map +0 -1
- package/dist/runtime/version-drift.js +0 -114
- package/dist/runtime/version-drift.js.map +0 -1
- package/dist/runtime/worktree.d.ts +0 -74
- package/dist/runtime/worktree.d.ts.map +0 -1
- package/dist/runtime/worktree.js +0 -206
- package/dist/runtime/worktree.js.map +0 -1
- package/dist/secrets/inject.d.ts +0 -70
- package/dist/secrets/inject.d.ts.map +0 -1
- package/dist/secrets/inject.js +0 -102
- package/dist/secrets/inject.js.map +0 -1
- package/dist/supabase.d.ts +0 -4
- package/dist/supabase.d.ts.map +0 -1
- package/dist/supabase.js +0 -36
- package/dist/supabase.js.map +0 -1
- package/dist/task-runner.d.ts +0 -313
- package/dist/task-runner.d.ts.map +0 -1
- package/dist/task-runner.js +0 -1766
- package/dist/task-runner.js.map +0 -1
- package/dist/token-provider.d.ts +0 -50
- package/dist/token-provider.d.ts.map +0 -1
- package/dist/token-provider.js +0 -177
- package/dist/token-provider.js.map +0 -1
- package/dist/types.d.ts +0 -120
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -16
- package/dist/types.js.map +0 -1
- package/dist/version-check.d.ts +0 -17
- package/dist/version-check.d.ts.map +0 -1
- package/dist/version-check.js +0 -56
- package/dist/version-check.js.map +0 -1
- package/dist/watch.d.ts +0 -295
- package/dist/watch.d.ts.map +0 -1
- package/dist/watch.js +0 -1532
- package/dist/watch.js.map +0 -1
package/dist/runtime/reviewer.js
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* v0.12-REVIEW-LOCAL — Runner-side reviewer-agent runtime.
|
|
3
|
-
*
|
|
4
|
-
* Triggered by a `review_assigned` realtime broadcast on
|
|
5
|
-
* `runner:<id>`. Spawns `claude --print` with the reviewer prompt
|
|
6
|
-
* (mirrors v0.11-B's spawnClaude for task-runner.ts) against the
|
|
7
|
-
* operator's CLI subscription, parses the JSON decision, and posts
|
|
8
|
-
* it back via acc.submit_review. Cost-cap enforcement is identical
|
|
9
|
-
* to api/_lib/reviewer-agent.ts so the cron's downstream merge
|
|
10
|
-
* gate sees consistent ReviewerOutcome shape across the queue and
|
|
11
|
-
* fallback paths.
|
|
12
|
-
*
|
|
13
|
-
* Never throws. Every failure surfaces through acc.submit_review
|
|
14
|
-
* with decision='reviewer_error' so the queue row settles and the
|
|
15
|
-
* cron's poll-merge loop can advance.
|
|
16
|
-
*/
|
|
17
|
-
import { execa } from "execa";
|
|
18
|
-
import { parseClaudeJson, priceUsdCents, normalizeUsage, } from "../cost-pricing.js";
|
|
19
|
-
import { classifyClaudeExit, extractResetTime } from "../failure-classifier.js";
|
|
20
|
-
import { withAnthropicAuth } from "../anthropic-auth.js";
|
|
21
|
-
import { buildEnv } from "../bin-resolve.js";
|
|
22
|
-
// Same template as prompts/reviewer-agent.md. The runner does not have
|
|
23
|
-
// the markdown file at runtime (the package ships without prompts/) so
|
|
24
|
-
// the prompt is embedded. Keep this string in sync with the markdown
|
|
25
|
-
// version on every prompt edit; tests/integration/v0.12-REVIEW-LOCAL
|
|
26
|
-
// asserts both render the same outline.
|
|
27
|
-
const REVIEWER_PROMPT_TEMPLATE = [
|
|
28
|
-
"You are reviewing a pull request opened by another Claude (an ACC",
|
|
29
|
-
"task runner). Be skeptical. Bias toward rejecting when in doubt.",
|
|
30
|
-
"",
|
|
31
|
-
"Task spec:",
|
|
32
|
-
"{{task_description}}",
|
|
33
|
-
"",
|
|
34
|
-
"Acceptance criteria:",
|
|
35
|
-
"{{acceptance_criteria}}",
|
|
36
|
-
"",
|
|
37
|
-
"PR title: {{pr_title}}",
|
|
38
|
-
"PR body:",
|
|
39
|
-
"{{pr_body}}",
|
|
40
|
-
"",
|
|
41
|
-
"PR diff:",
|
|
42
|
-
"{{pr_diff}}",
|
|
43
|
-
"",
|
|
44
|
-
"Answer in this exact JSON shape, no surrounding prose:",
|
|
45
|
-
'{"decision":"approve"|"reject","reasons":["..."],"confidence":0.0}',
|
|
46
|
-
].join("\n");
|
|
47
|
-
const MAX_DIFF_CHARS = 60_000;
|
|
48
|
-
const RETRY_DELAYS_MS = [2000, 4000, 8000];
|
|
49
|
-
/** Returns true when a claude stderr string indicates a transient API error that is safe to retry. */
|
|
50
|
-
export function isRetriableError(stderr) {
|
|
51
|
-
if (!stderr)
|
|
52
|
-
return false;
|
|
53
|
-
const lower = stderr.toLowerCase();
|
|
54
|
-
return /5\d{2}/.test(stderr) || lower.includes("overloaded") || lower.includes("timeout");
|
|
55
|
-
}
|
|
56
|
-
function defaultSleep(ms) {
|
|
57
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
58
|
-
}
|
|
59
|
-
export function renderReviewerPrompt(args) {
|
|
60
|
-
const diff = args.pr_diff.length > MAX_DIFF_CHARS
|
|
61
|
-
? args.pr_diff.slice(0, MAX_DIFF_CHARS) +
|
|
62
|
-
`\n\n... [diff truncated at ${MAX_DIFF_CHARS} chars; full length ${args.pr_diff.length}] ...\n`
|
|
63
|
-
: args.pr_diff;
|
|
64
|
-
const acceptance = (args.acceptance_criteria ?? [])
|
|
65
|
-
.map((a, i) => `${i + 1}. ${a}`)
|
|
66
|
-
.join("\n");
|
|
67
|
-
return REVIEWER_PROMPT_TEMPLATE
|
|
68
|
-
.replace("{{task_description}}", args.task_description ?? "")
|
|
69
|
-
.replace("{{acceptance_criteria}}", acceptance)
|
|
70
|
-
.replace("{{pr_title}}", args.pr_title ?? "")
|
|
71
|
-
.replace("{{pr_body}}", args.pr_body ?? "")
|
|
72
|
-
.replace("{{pr_diff}}", diff);
|
|
73
|
-
}
|
|
74
|
-
export function extractReviewerDecision(text) {
|
|
75
|
-
if (!text)
|
|
76
|
-
return null;
|
|
77
|
-
// Path 1: strict JSON (preserved fast path).
|
|
78
|
-
const first = text.indexOf("{");
|
|
79
|
-
const last = text.lastIndexOf("}");
|
|
80
|
-
if (first !== -1 && last > first) {
|
|
81
|
-
const candidates = [text.slice(first, last + 1), text.trim()];
|
|
82
|
-
for (const candidate of candidates) {
|
|
83
|
-
try {
|
|
84
|
-
const obj = JSON.parse(candidate);
|
|
85
|
-
if (obj.decision !== "approve" && obj.decision !== "reject")
|
|
86
|
-
continue;
|
|
87
|
-
const reasons = Array.isArray(obj.reasons)
|
|
88
|
-
? obj.reasons.filter((r) => typeof r === "string")
|
|
89
|
-
: [];
|
|
90
|
-
const confidence = typeof obj.confidence === "number" &&
|
|
91
|
-
obj.confidence >= 0 && obj.confidence <= 1
|
|
92
|
-
? obj.confidence
|
|
93
|
-
: 0;
|
|
94
|
-
return { decision: obj.decision, reasons, confidence };
|
|
95
|
-
}
|
|
96
|
-
catch { /* try next candidate */ }
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// Path 2 (v0.45-FIX, mirrors api/_lib/reviewer-agent.ts v0.44 patch):
|
|
100
|
-
// prose fallback. Sonnet sometimes returns markdown analysis instead of
|
|
101
|
-
// strict JSON; without this the runner-side reviewer flips every PR to
|
|
102
|
-
// reviewer_error and the cron's auto-retry only burns through max_retries.
|
|
103
|
-
// We bias toward `reject` when the keyword is ambiguous so a parse-recovered
|
|
104
|
-
// approve still has to clear the configured confidence_threshold (0.7)
|
|
105
|
-
// before merging.
|
|
106
|
-
const decisionMatch = /\b(approve|reject)\b/i.exec(text);
|
|
107
|
-
if (!decisionMatch)
|
|
108
|
-
return null;
|
|
109
|
-
const decision = decisionMatch[1].toLowerCase();
|
|
110
|
-
const confidenceMatch = /confidence[^0-9]{0,20}(0?\.\d+|1(?:\.0+)?)/i.exec(text);
|
|
111
|
-
const confidence = confidenceMatch
|
|
112
|
-
? Math.min(1, Math.max(0, Number.parseFloat(confidenceMatch[1])))
|
|
113
|
-
: decision === "reject"
|
|
114
|
-
? 0.6 // prose reject without confidence: assume meaningful but not overwhelming
|
|
115
|
-
: 0.3; // prose approve without confidence: assume tentative, below default 0.7 threshold
|
|
116
|
-
// Best-effort reason extraction: pull bullet / numbered lines.
|
|
117
|
-
const reasonLines = text
|
|
118
|
-
.split(/\r?\n/)
|
|
119
|
-
.map((line) => line.trim())
|
|
120
|
-
.filter((line) => /^(?:[-*•]\s|\d+[.)]\s)/.test(line))
|
|
121
|
-
.map((line) => line.replace(/^(?:[-*•]\s|\d+[.)]\s)/, "").trim())
|
|
122
|
-
.filter((line) => line.length > 0)
|
|
123
|
-
.slice(0, 10);
|
|
124
|
-
const reasons = reasonLines.length > 0
|
|
125
|
-
? reasonLines
|
|
126
|
-
: [
|
|
127
|
-
"parsed from prose reviewer output (no JSON found)",
|
|
128
|
-
`decision_keyword: ${decision}`,
|
|
129
|
-
];
|
|
130
|
-
return { decision, reasons, confidence };
|
|
131
|
-
}
|
|
132
|
-
async function defaultFetchPRMeta(repo, prNumber) {
|
|
133
|
-
const { stdout } = await execa("gh", ["pr", "view", String(prNumber), "-R", repo, "--json", "title,body"], { env: buildEnv() });
|
|
134
|
-
const parsed = JSON.parse(stdout);
|
|
135
|
-
return { title: parsed.title ?? "", body: parsed.body ?? "" };
|
|
136
|
-
}
|
|
137
|
-
async function defaultFetchPRDiff(repo, prNumber) {
|
|
138
|
-
const { stdout } = await execa("gh", ["pr", "diff", String(prNumber), "-R", repo], { env: buildEnv() });
|
|
139
|
-
return stdout;
|
|
140
|
-
}
|
|
141
|
-
function defaultSpawnClaude(modelId) {
|
|
142
|
-
const args = ["--print", "--dangerously-skip-permissions", "--output-format=json"];
|
|
143
|
-
const trimmed = (modelId ?? "").trim();
|
|
144
|
-
if (trimmed)
|
|
145
|
-
args.push("--model", trimmed);
|
|
146
|
-
// v0.74-B: forward ANTHROPIC_API_KEY (trimmed) when set so the reviewer
|
|
147
|
-
// claude authenticates via the API account (no per-session cap) rather than
|
|
148
|
-
// the interactive OAuth session. claude has no --api-key flag; the env var
|
|
149
|
-
// is the only auth channel. See src/anthropic-auth.ts.
|
|
150
|
-
return execa("claude", args, {
|
|
151
|
-
stdin: "pipe",
|
|
152
|
-
stdout: "pipe",
|
|
153
|
-
stderr: "pipe",
|
|
154
|
-
reject: false,
|
|
155
|
-
env: withAnthropicAuth(buildEnv()),
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function parseEnvelope(stdout, fallbackModel) {
|
|
159
|
-
const parsed = parseClaudeJson(stdout);
|
|
160
|
-
if (!parsed) {
|
|
161
|
-
return { result: stdout.trim(), session_id: null, cost_usd: 0, model: fallbackModel };
|
|
162
|
-
}
|
|
163
|
-
const model = parsed.model ?? fallbackModel;
|
|
164
|
-
const usage = normalizeUsage(parsed.usage);
|
|
165
|
-
const cents = priceUsdCents(model, usage);
|
|
166
|
-
return {
|
|
167
|
-
result: parsed.result ?? "",
|
|
168
|
-
// any-allowed: parseClaudeJson keeps additional fields on the
|
|
169
|
-
// record; session_id isn't on the typed shape but appears in
|
|
170
|
-
// every observed `--output-format=json` envelope from Claude CLI.
|
|
171
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
|
-
session_id: parsed.session_id ?? null,
|
|
173
|
-
cost_usd: cents / 100,
|
|
174
|
-
model,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Drive one review end-to-end: fetch task spec + PR meta + diff →
|
|
179
|
-
* render prompt → spawn claude → parse decision → submit_review.
|
|
180
|
-
* Always submits a row even on internal failure (reviewer_error) so
|
|
181
|
-
* the cron's poll-merge loop can advance.
|
|
182
|
-
*/
|
|
183
|
-
export async function runReview(assignment, deps) {
|
|
184
|
-
const fetchMeta = deps.fetchPRMeta ?? defaultFetchPRMeta;
|
|
185
|
-
const fetchDiff = deps.fetchPRDiff ?? defaultFetchPRDiff;
|
|
186
|
-
const spawnFn = deps.spawnClaude ?? defaultSpawnClaude;
|
|
187
|
-
let outcome;
|
|
188
|
-
try {
|
|
189
|
-
outcome = await driveReview(assignment, deps, fetchMeta, fetchDiff, spawnFn);
|
|
190
|
-
}
|
|
191
|
-
catch (err) {
|
|
192
|
-
outcome = {
|
|
193
|
-
decision: "reviewer_error",
|
|
194
|
-
reasons: [`runtime_threw: ${err.message?.slice(0, 200)}`],
|
|
195
|
-
confidence: 0,
|
|
196
|
-
session_id: null,
|
|
197
|
-
cost_usd: 0,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
const { error } = await deps.supabase.rpc("submit_review", {
|
|
201
|
-
p_review_id: assignment.review_id,
|
|
202
|
-
p_decision: outcome.decision,
|
|
203
|
-
p_reasons: outcome.reasons,
|
|
204
|
-
p_confidence: outcome.confidence,
|
|
205
|
-
p_session_id: outcome.session_id,
|
|
206
|
-
p_cost_usd: outcome.cost_usd,
|
|
207
|
-
});
|
|
208
|
-
if (error) {
|
|
209
|
-
process.stderr.write(`[acc-runner] submit_review(${assignment.review_id}) failed: ${error.message}\n`);
|
|
210
|
-
}
|
|
211
|
-
return outcome;
|
|
212
|
-
}
|
|
213
|
-
async function invokeClaude(spawnFn, modelId, prompt) {
|
|
214
|
-
const child = spawnFn(modelId);
|
|
215
|
-
if (child.stdin) {
|
|
216
|
-
child.stdin.write(prompt);
|
|
217
|
-
child.stdin.end();
|
|
218
|
-
}
|
|
219
|
-
const [stdout, stderr, exit] = await Promise.all([
|
|
220
|
-
collectStream(child.stdout),
|
|
221
|
-
collectStream(child.stderr),
|
|
222
|
-
child,
|
|
223
|
-
]);
|
|
224
|
-
return { stdout, stderr, exitCode: exit.exitCode ?? 1 };
|
|
225
|
-
}
|
|
226
|
-
async function driveReview(assignment, deps, fetchMeta, fetchDiff, spawnFn) {
|
|
227
|
-
const { data, error } = await deps.supabase.rpc("fetch_task_for_runner", {
|
|
228
|
-
p_task_id: assignment.task_id,
|
|
229
|
-
});
|
|
230
|
-
if (error || !data) {
|
|
231
|
-
return {
|
|
232
|
-
decision: "reviewer_error",
|
|
233
|
-
reasons: [`fetch_task_failed: ${error?.message ?? "no data"}`],
|
|
234
|
-
confidence: 0,
|
|
235
|
-
session_id: null,
|
|
236
|
-
cost_usd: 0,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
const result = data;
|
|
240
|
-
const task = result.task;
|
|
241
|
-
const repo = task.repo?.trim();
|
|
242
|
-
if (!repo) {
|
|
243
|
-
return {
|
|
244
|
-
decision: "reviewer_error",
|
|
245
|
-
reasons: ["task has no repo to target gh against"],
|
|
246
|
-
confidence: 0,
|
|
247
|
-
session_id: null,
|
|
248
|
-
cost_usd: 0,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
// Look up the org's reviewer policy. The runner-side reviewer needs
|
|
252
|
-
// confidence_threshold + max_cost_usd_per_review to stay consistent
|
|
253
|
-
// with the cron-side gate, since the cron now just lifts the decision
|
|
254
|
-
// out of the queue row without re-checking the cap.
|
|
255
|
-
const policy = deps.loadPolicy
|
|
256
|
-
? await deps.loadPolicy("")
|
|
257
|
-
: await loadReviewerPolicy(deps.supabase);
|
|
258
|
-
const [meta, diff] = await Promise.all([
|
|
259
|
-
fetchMeta(repo, assignment.pr_number),
|
|
260
|
-
fetchDiff(repo, assignment.pr_number),
|
|
261
|
-
]);
|
|
262
|
-
const prompt = renderReviewerPrompt({
|
|
263
|
-
task_description: task.description ?? "",
|
|
264
|
-
acceptance_criteria: task.acceptance ?? [],
|
|
265
|
-
pr_title: meta.title,
|
|
266
|
-
pr_body: meta.body,
|
|
267
|
-
pr_diff: diff,
|
|
268
|
-
});
|
|
269
|
-
const sleepFn = deps.sleep ?? defaultSleep;
|
|
270
|
-
const modelId = policy?.model_id ?? "claude-sonnet-4-6";
|
|
271
|
-
let invokeResult = null;
|
|
272
|
-
for (let attempt = 0; attempt <= RETRY_DELAYS_MS.length; attempt++) {
|
|
273
|
-
invokeResult = await invokeClaude(spawnFn, modelId, prompt);
|
|
274
|
-
if (invokeResult.exitCode === 0)
|
|
275
|
-
break;
|
|
276
|
-
const canRetry = attempt < RETRY_DELAYS_MS.length &&
|
|
277
|
-
invokeResult.exitCode === 1 &&
|
|
278
|
-
isRetriableError(invokeResult.stderr);
|
|
279
|
-
if (!canRetry)
|
|
280
|
-
break;
|
|
281
|
-
const delayMs = RETRY_DELAYS_MS[attempt];
|
|
282
|
-
process.stderr.write(`[reviewer] retry attempt ${attempt + 1}/${RETRY_DELAYS_MS.length} after ${delayMs}ms\n`);
|
|
283
|
-
await sleepFn(delayMs);
|
|
284
|
-
}
|
|
285
|
-
// invokeResult is always set — the loop runs at least once
|
|
286
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
287
|
-
const { stdout, exitCode, stderr: claudeStderr } = invokeResult;
|
|
288
|
-
if (exitCode !== 0) {
|
|
289
|
-
// v0.56 (T-56-1): a session/usage limit (429) is NOT a reviewer error —
|
|
290
|
-
// report reviewer_capacity so the api side excludes it from retry caps
|
|
291
|
-
// and the runner pauses until the window reopens. Checked only on a
|
|
292
|
-
// non-zero exit so a normal review whose prose happens to mention a
|
|
293
|
-
// "limit" can never be mis-flagged.
|
|
294
|
-
const classified = classifyClaudeExit(exitCode, claudeStderr, stdout);
|
|
295
|
-
if (classified.class === "capacity_exhausted") {
|
|
296
|
-
const resumeMs = extractResetTime(`${claudeStderr}\n${stdout}`);
|
|
297
|
-
return {
|
|
298
|
-
decision: "reviewer_capacity",
|
|
299
|
-
reasons: [classified.detail],
|
|
300
|
-
confidence: 0,
|
|
301
|
-
session_id: null,
|
|
302
|
-
cost_usd: 0,
|
|
303
|
-
resume_at: resumeMs !== null ? new Date(resumeMs).toISOString() : null,
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
return {
|
|
307
|
-
decision: "reviewer_error",
|
|
308
|
-
reasons: [
|
|
309
|
-
`claude exited ${exitCode}`,
|
|
310
|
-
...(claudeStderr ? [`stderr: ${claudeStderr.slice(0, 200)}`] : []),
|
|
311
|
-
],
|
|
312
|
-
confidence: 0,
|
|
313
|
-
session_id: null,
|
|
314
|
-
cost_usd: 0,
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
const envelope = parseEnvelope(stdout, modelId);
|
|
318
|
-
// Cost cap parity with api/_lib/reviewer-agent.ts. A cap of 0
|
|
319
|
-
// disables the gate.
|
|
320
|
-
if (policy &&
|
|
321
|
-
policy.max_cost_usd_per_review > 0 &&
|
|
322
|
-
envelope.cost_usd > policy.max_cost_usd_per_review) {
|
|
323
|
-
return {
|
|
324
|
-
decision: "cost_cap_exceeded",
|
|
325
|
-
reasons: [
|
|
326
|
-
`reviewer cost $${envelope.cost_usd.toFixed(4)} exceeded cap $${policy.max_cost_usd_per_review.toFixed(2)}`,
|
|
327
|
-
],
|
|
328
|
-
confidence: 0,
|
|
329
|
-
session_id: envelope.session_id,
|
|
330
|
-
cost_usd: envelope.cost_usd,
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
const decision = extractReviewerDecision(envelope.result);
|
|
334
|
-
if (!decision) {
|
|
335
|
-
return {
|
|
336
|
-
decision: "reviewer_error",
|
|
337
|
-
reasons: [
|
|
338
|
-
"could not parse reviewer JSON from claude output",
|
|
339
|
-
`output_head: ${envelope.result.slice(0, 200)}`,
|
|
340
|
-
],
|
|
341
|
-
confidence: 0,
|
|
342
|
-
session_id: envelope.session_id,
|
|
343
|
-
cost_usd: envelope.cost_usd,
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
return {
|
|
347
|
-
decision: decision.decision,
|
|
348
|
-
reasons: decision.reasons,
|
|
349
|
-
confidence: decision.confidence,
|
|
350
|
-
session_id: envelope.session_id,
|
|
351
|
-
cost_usd: envelope.cost_usd,
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
async function loadReviewerPolicy(supabase) {
|
|
355
|
-
// any-allowed: org_settings rows aren't in the runner's generated
|
|
356
|
-
// Database type yet — same pattern as task-runner.ts cost-event sink.
|
|
357
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
358
|
-
const { data } = await supabase.from("org_settings")
|
|
359
|
-
.select("automerge_policy")
|
|
360
|
-
.limit(1)
|
|
361
|
-
.maybeSingle();
|
|
362
|
-
const row = data;
|
|
363
|
-
return row?.automerge_policy?.reviewer ?? null;
|
|
364
|
-
}
|
|
365
|
-
async function collectStream(stream) {
|
|
366
|
-
if (!stream)
|
|
367
|
-
return "";
|
|
368
|
-
let captured = "";
|
|
369
|
-
for await (const raw of stream) {
|
|
370
|
-
captured += typeof raw === "string" ? raw : raw.toString("utf8");
|
|
371
|
-
}
|
|
372
|
-
return captured;
|
|
373
|
-
}
|
|
374
|
-
//# sourceMappingURL=reviewer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reviewer.js","sourceRoot":"","sources":["../../src/runtime/reviewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAA0B,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAqD7C,uEAAuE;AACvE,uEAAuE;AACvE,qEAAqE;AACrE,qEAAqE;AACrE,wCAAwC;AACxC,MAAM,wBAAwB,GAAG;IAC/B,mEAAmE;IACnE,kEAAkE;IAClE,EAAE;IACF,YAAY;IACZ,sBAAsB;IACtB,EAAE;IACF,sBAAsB;IACtB,yBAAyB;IACzB,EAAE;IACF,wBAAwB;IACxB,UAAU;IACV,aAAa;IACb,EAAE;IACF,UAAU;IACV,aAAa;IACb,EAAE;IACF,wDAAwD;IACxD,oEAAoE;CACrE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE3C,sGAAsG;AACtG,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;A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C,cAAc,CAAS;SAC1D,MAAM,CAAC,kBAAkB,CAAC;SAC1B,KAAK,CAAC,CAAC,CAAC;SACR,WAAW,EAAE,CAAC;IACjB,MAAM,GAAG,GAAG,IAAmE,CAAC;IAChF,OAAO,GAAG,EAAE,gBAAgB,EAAE,QAAQ,IAAI,IAAI,CAAC;AACjD,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,MAAoC;IAC/D,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAwC,EAAE,CAAC;QACjE,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/runtime/rework.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export interface ReworkMeta {
|
|
2
|
-
pr_number: number;
|
|
3
|
-
repo: string;
|
|
4
|
-
/** PR head branch. May be empty — resolve via fetchPrHeadRef then. */
|
|
5
|
-
branch: string;
|
|
6
|
-
/** The rejected task; re-review + needs-review flip target. Empty when
|
|
7
|
-
* the meta was reconstructed from task-row fallback fields. */
|
|
8
|
-
origin_task_id: string;
|
|
9
|
-
verdict: string;
|
|
10
|
-
confidence: number;
|
|
11
|
-
comments: string[];
|
|
12
|
-
cycle: number;
|
|
13
|
-
}
|
|
14
|
-
/** Mirrors the bound enforced inside acc.create_rework_task. */
|
|
15
|
-
export declare const MAX_REWORK_CYCLES = 3;
|
|
16
|
-
/**
|
|
17
|
-
* Extract rework metadata from the task description. Falls back to the
|
|
18
|
-
* task row's own pr_number/repo/branch when the sentinel is absent or
|
|
19
|
-
* malformed (same degradation path as parseConflictMeta).
|
|
20
|
-
*/
|
|
21
|
-
export declare function parseReworkMeta(description: string | null | undefined, fallback?: {
|
|
22
|
-
pr_number?: number | null;
|
|
23
|
-
repo?: string | null;
|
|
24
|
-
branch?: string | null;
|
|
25
|
-
}): ReworkMeta | null;
|
|
26
|
-
/**
|
|
27
|
-
* Resolve the PR's head branch via gh when the sentinel carried an empty
|
|
28
|
-
* branch (e.g. the origin task row had no branch back-written yet).
|
|
29
|
-
*/
|
|
30
|
-
export declare function fetchPrHeadRef(repo: string, prNumber: number): Promise<string>;
|
|
31
|
-
/**
|
|
32
|
-
* Rework prompt. Replaces renderTaskPrompt for rework tasks: the protocol
|
|
33
|
-
* header changes from "open a PR" to "update the existing PR's branch",
|
|
34
|
-
* and the reviewer's verdict + comments become the work spec. The runner
|
|
35
|
-
* pushes after Claude exits, so the session only needs to commit.
|
|
36
|
-
*/
|
|
37
|
-
export declare function renderReworkPrompt(args: {
|
|
38
|
-
task: {
|
|
39
|
-
id: string;
|
|
40
|
-
title: string;
|
|
41
|
-
description?: string | null;
|
|
42
|
-
typecheck_cmd?: string | null;
|
|
43
|
-
forbidden: string[];
|
|
44
|
-
};
|
|
45
|
-
meta: ReworkMeta;
|
|
46
|
-
branch: string;
|
|
47
|
-
}): string;
|
|
48
|
-
//# sourceMappingURL=rework.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rework.d.ts","sourceRoot":"","sources":["../../src/runtime/rework.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf;oEACgE;IAChE,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,IAAI,CAAC;AA+BnC;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,QAAQ,CAAC,EAAE;IACT,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,GACA,UAAU,GAAG,IAAI,CA6BnB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CAqDT"}
|
package/dist/runtime/rework.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* v0.51 T-51-1 (G2): rework task support — sentinel parsing + prompt.
|
|
3
|
-
*
|
|
4
|
-
* A `rework` task is created by acc.create_rework_task (migration 0172)
|
|
5
|
-
* when a reviewer rejects a PR with confidence < 0.9. Unlike
|
|
6
|
-
* conflict_resolution tasks (resolved via the GitHub API, no Claude),
|
|
7
|
-
* rework tasks run the normal Claude session — but against the PR's
|
|
8
|
-
* EXISTING head branch: task-runner.ts provisions the worktree from
|
|
9
|
-
* `origin/<branch>` instead of forking from the integration branch,
|
|
10
|
-
* pushes back to the same branch (same PR), and never opens a new PR.
|
|
11
|
-
*
|
|
12
|
-
* The task description carries the reviewer's verdict in a sentinel the
|
|
13
|
-
* server embeds (mirrors the acc-conflict sentinel from T-48-5):
|
|
14
|
-
* <!-- acc-rework: {"pr_number":N,"repo":"o/r","branch":"...",
|
|
15
|
-
* "origin_task_id":"T-...","verdict":"reject","confidence":0.72,
|
|
16
|
-
* "comments":["..."],"cycle":1} -->
|
|
17
|
-
*/
|
|
18
|
-
import { execa } from "execa";
|
|
19
|
-
import { buildEnv } from "../bin-resolve.js";
|
|
20
|
-
/** Mirrors the bound enforced inside acc.create_rework_task. */
|
|
21
|
-
export const MAX_REWORK_CYCLES = 3;
|
|
22
|
-
// Lazy body match so reviewer comments containing "}" don't truncate the
|
|
23
|
-
// JSON (the acc-conflict regex's [^}]* would). Comments never contain
|
|
24
|
-
// "-->" — the RPC builds them from reviewer reasons.
|
|
25
|
-
const REWORK_META_RE = /<!--\s*acc-rework:\s*(\{[\s\S]*?\})\s*-->/;
|
|
26
|
-
function coerce(parsed) {
|
|
27
|
-
if (typeof parsed.pr_number !== "number" ||
|
|
28
|
-
typeof parsed.repo !== "string" ||
|
|
29
|
-
!parsed.repo.includes("/")) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
pr_number: parsed.pr_number,
|
|
34
|
-
repo: parsed.repo,
|
|
35
|
-
branch: typeof parsed.branch === "string" ? parsed.branch : "",
|
|
36
|
-
origin_task_id: typeof parsed.origin_task_id === "string" ? parsed.origin_task_id : "",
|
|
37
|
-
verdict: typeof parsed.verdict === "string" ? parsed.verdict : "reject",
|
|
38
|
-
confidence: typeof parsed.confidence === "number" ? parsed.confidence : 0,
|
|
39
|
-
comments: Array.isArray(parsed.comments)
|
|
40
|
-
? parsed.comments.filter((c) => typeof c === "string")
|
|
41
|
-
: [],
|
|
42
|
-
cycle: typeof parsed.cycle === "number" ? parsed.cycle : 1,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Extract rework metadata from the task description. Falls back to the
|
|
47
|
-
* task row's own pr_number/repo/branch when the sentinel is absent or
|
|
48
|
-
* malformed (same degradation path as parseConflictMeta).
|
|
49
|
-
*/
|
|
50
|
-
export function parseReworkMeta(description, fallback) {
|
|
51
|
-
if (description) {
|
|
52
|
-
const match = REWORK_META_RE.exec(description);
|
|
53
|
-
if (match) {
|
|
54
|
-
try {
|
|
55
|
-
const meta = coerce(JSON.parse(match[1]));
|
|
56
|
-
if (meta)
|
|
57
|
-
return meta;
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
// fall through to task-row fallback
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const prNumber = fallback?.pr_number;
|
|
65
|
-
const repo = fallback?.repo;
|
|
66
|
-
if (typeof prNumber === "number" && typeof repo === "string" && repo.includes("/")) {
|
|
67
|
-
return {
|
|
68
|
-
pr_number: prNumber,
|
|
69
|
-
repo,
|
|
70
|
-
branch: fallback?.branch ?? "",
|
|
71
|
-
origin_task_id: "",
|
|
72
|
-
verdict: "reject",
|
|
73
|
-
confidence: 0,
|
|
74
|
-
comments: [],
|
|
75
|
-
cycle: 1,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Resolve the PR's head branch via gh when the sentinel carried an empty
|
|
82
|
-
* branch (e.g. the origin task row had no branch back-written yet).
|
|
83
|
-
*/
|
|
84
|
-
export async function fetchPrHeadRef(repo, prNumber) {
|
|
85
|
-
const { stdout } = await execa("gh", ["pr", "view", String(prNumber), "-R", repo, "--json", "headRefName", "--jq", ".headRefName"], { env: buildEnv() });
|
|
86
|
-
return stdout.trim();
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Rework prompt. Replaces renderTaskPrompt for rework tasks: the protocol
|
|
90
|
-
* header changes from "open a PR" to "update the existing PR's branch",
|
|
91
|
-
* and the reviewer's verdict + comments become the work spec. The runner
|
|
92
|
-
* pushes after Claude exits, so the session only needs to commit.
|
|
93
|
-
*/
|
|
94
|
-
export function renderReworkPrompt(args) {
|
|
95
|
-
const { task, meta, branch } = args;
|
|
96
|
-
const lines = [];
|
|
97
|
-
lines.push(`**Branch:** ${branch} (EXISTING — already checked out; do NOT create a new branch)`);
|
|
98
|
-
lines.push(`**PR:** #${meta.pr_number} on ${meta.repo} (EXISTING — do NOT open a new PR)`);
|
|
99
|
-
lines.push("");
|
|
100
|
-
lines.push(`# Task ${task.id}: ${task.title}`);
|
|
101
|
-
lines.push("");
|
|
102
|
-
lines.push("A reviewer rejected this PR. You are on the PR's existing branch with " +
|
|
103
|
-
"its current contents. Address every reviewer comment below with " +
|
|
104
|
-
"minimal, focused changes, then COMMIT your work. The runner pushes " +
|
|
105
|
-
"the branch after you exit — do not push and do not open a PR.");
|
|
106
|
-
lines.push("");
|
|
107
|
-
lines.push(`## Reviewer verdict (rework cycle ${meta.cycle}/${MAX_REWORK_CYCLES})`);
|
|
108
|
-
lines.push(`${meta.verdict} (confidence ${meta.confidence})`);
|
|
109
|
-
lines.push("");
|
|
110
|
-
lines.push("## Reviewer comments");
|
|
111
|
-
lines.push(...(meta.comments.length
|
|
112
|
-
? meta.comments.map((c) => `- ${c}`)
|
|
113
|
-
: ["- (none provided — re-read the task description and PR diff for context)"]));
|
|
114
|
-
lines.push("");
|
|
115
|
-
if (task.description) {
|
|
116
|
-
lines.push("## Task description");
|
|
117
|
-
lines.push(task.description);
|
|
118
|
-
lines.push("");
|
|
119
|
-
}
|
|
120
|
-
lines.push("## Forbidden files (DO NOT TOUCH)");
|
|
121
|
-
lines.push(...(task.forbidden.length ? task.forbidden.map((f) => `- ${f}`) : ["- (none)"]));
|
|
122
|
-
lines.push("");
|
|
123
|
-
lines.push("## Gates");
|
|
124
|
-
lines.push(`Run \`${task.typecheck_cmd?.trim() || "pnpm typecheck && pnpm lint && pnpm build"}\` ` +
|
|
125
|
-
"after your edits. All gates must pass before you commit. If a gate " +
|
|
126
|
-
"fails and you cannot fix it, say so explicitly in your final output " +
|
|
127
|
-
"and do not commit broken code.");
|
|
128
|
-
lines.push("");
|
|
129
|
-
lines.push("## Required output");
|
|
130
|
-
lines.push("- Summary of what you changed per reviewer comment");
|
|
131
|
-
lines.push("- Any comments you could NOT address, and why");
|
|
132
|
-
lines.push("- Gate results (typecheck/lint/build)");
|
|
133
|
-
lines.push("");
|
|
134
|
-
return lines.join("\n");
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=rework.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rework.js","sourceRoot":"","sources":["../../src/runtime/rework.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAgB7C,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC,yEAAyE;AACzE,sEAAsE;AACtE,qDAAqD;AACrD,MAAM,cAAc,GAAG,2CAA2C,CAAC;AAEnE,SAAS,MAAM,CAAC,MAA2B;IACzC,IACE,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACpC,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC/B,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAC1B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QAC9D,cAAc,EACZ,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAA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IAAI,CAAC,UAAU,CAAC,CAAC;IACvB,KAAK,CAAC,IAAI,CACR,SAAS,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,2CAA2C,KAAK;QACvF,qEAAqE;QACrE,sEAAsE;QACtE,gCAAgC,CACjC,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACjC,KAAK,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IACjE,KAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC5D,KAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export interface SingletonLockInfo {
|
|
2
|
-
pid: number;
|
|
3
|
-
/** Canonical (realpath-resolved where possible) repo path this runner serves. */
|
|
4
|
-
repoPath: string;
|
|
5
|
-
acquiredAt: string;
|
|
6
|
-
version: string;
|
|
7
|
-
}
|
|
8
|
-
export interface SingletonLock {
|
|
9
|
-
lockFile: string;
|
|
10
|
-
repoPath: string;
|
|
11
|
-
/** Remove the lock iff we still own it. Safe to call more than once. */
|
|
12
|
-
release(): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export declare class SingletonLockHeldError extends Error {
|
|
15
|
-
readonly holder: SingletonLockInfo;
|
|
16
|
-
readonly lockFile: string;
|
|
17
|
-
constructor(holder: SingletonLockInfo, lockFile: string);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Resolve a repo path to a stable canonical form so two spellings of the
|
|
21
|
-
* same directory (trailing slash, symlink, `./`) map to one lock file.
|
|
22
|
-
* realpath fails if the path does not exist yet — fall back to resolve().
|
|
23
|
-
*/
|
|
24
|
-
export declare function canonicalRepoPath(repoPath: string): string;
|
|
25
|
-
/** `<cache>/runner.<hash>.lock`, hash derived from the canonical repo path. */
|
|
26
|
-
export declare function singletonLockPath(repoPath: string): string;
|
|
27
|
-
/**
|
|
28
|
-
* Acquire the single-instance lock for `repoPath`. Throws
|
|
29
|
-
* SingletonLockHeldError when a *live* process already holds the lock for
|
|
30
|
-
* the same canonical repo path. A stale lock (dead pid, our own pid, or a
|
|
31
|
-
* corrupt file) is reclaimed with a stderr breadcrumb and then re-acquired.
|
|
32
|
-
*/
|
|
33
|
-
export declare function acquireSingletonLock(repoPath: string, pid?: number): Promise<SingletonLock>;
|
|
34
|
-
/**
|
|
35
|
-
* Inspect the lock file for `repoPath` and return its holder iff a *live*
|
|
36
|
-
* process other than `selfPid` owns it. Used by `acc-runner doctor` to
|
|
37
|
-
* report a duplicate runner without trying to acquire the lock.
|
|
38
|
-
*/
|
|
39
|
-
export declare function findLiveLockHolder(repoPath: string, selfPid?: number): Promise<SingletonLockInfo | null>;
|
|
40
|
-
/**
|
|
41
|
-
* pgrep-style scan for other `acc-runner watch` processes. Best-effort and
|
|
42
|
-
* offline of the lock file — used by doctor to catch a runner that predates
|
|
43
|
-
* the singleton lock (no lock file) or one whose lock was hand-deleted.
|
|
44
|
-
* Returns foreign pids; never throws (returns [] on any failure).
|
|
45
|
-
*/
|
|
46
|
-
export declare function listForeignRunnerPids(selfPid?: number): Promise<number[]>;
|
|
47
|
-
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/runtime/singleton.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;aAE7B,MAAM,EAAE,iBAAiB;aACzB,QAAQ,EAAE,MAAM;gBADhB,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,MAAM;CAOnC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO1D;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO1D;AA0CD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,GAAG,GAAE,MAAoB,GACxB,OAAO,CAAC,aAAa,CAAC,CA8CxB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAoB,GAC5B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAMnC;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,GAAE,MAAoB,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBnB"}
|