ai-whisper 0.1.4 → 0.2.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/dist/bin/broker-daemon.js +182 -11
- package/dist/bin/companion-agent.js +190 -19
- package/dist/bin/relay-monitor.js +179 -8
- package/dist/bin/whisper.js +205 -34
- package/dist/skills/ai-whisper-bugfix/SKILL.md +136 -0
- package/package.json +3 -3
- package/skills/ai-whisper-bugfix/SKILL.md +136 -0
|
@@ -2025,6 +2025,36 @@ Findings: (omit this block entirely if none)
|
|
|
2025
2025
|
Non-blocking risks:
|
|
2026
2026
|
- <quality risk that does NOT block this gate, or "None.">
|
|
2027
2027
|
--- end protocol ---`;
|
|
2028
|
+
var WORKFLOW_DIAGNOSIS_PROTOCOL = `--- ai-whisper diagnosis review protocol ---
|
|
2029
|
+
You are the gatekeeper for an ai-whisper complex-bug-fixing DIAGNOSIS gate. No human is in the loop. Do NOT trust the implementer's diagnosis \u2014 verify it yourself. The gate stays shut until YOU independently agree on the root cause and that the fix is net-safe.
|
|
2030
|
+
|
|
2031
|
+
Required procedure:
|
|
2032
|
+
1. Independently reproduce: re-run the implementer's reproduction yourself; do not trust pasted output. If YOU cannot reproduce it, that is a blocking finding (the repro is not real/reliable). Speculation from reading code paths is not a valid reproduction.
|
|
2033
|
+
2. Attack the causal claim: is the cause PROVEN by the evidence chain, or merely asserted? Could the named cause be a correlate, or a symptom of something deeper? Demand any missing link.
|
|
2034
|
+
3. Attack the fix (anti-whack-a-mole): does the proposed fix remove the root cause, or just this symptom's surface? Could the bug resurface through another path? Name it if so.
|
|
2035
|
+
4. Attack the blast radius: is every affected area/module/contract listed? Add what is missing.
|
|
2036
|
+
5. Attack residual risks: are the real foreseeable risks named, or hand-waved?
|
|
2037
|
+
6. Mutual-agreement gate: approve ONLY when you have independently confirmed the reproduction and agree the cause is proven and the fix is net-safe (fixes more than it risks). "Plausible" is not approval.
|
|
2038
|
+
|
|
2039
|
+
Severity: a blocking finding must tie to a concrete diagnosis-contract item (unreproducible repro, unproven cause, symptom-masking fix, incomplete blast radius, un-named risk). Suppress style/taste. Do NOT gag valuable non-contract risk signals \u2014 surface them under "Non-blocking risks:" (always last) so they reach the human at escalation/completion.
|
|
2040
|
+
|
|
2041
|
+
Findings vs escalation: a fixable defect in the diagnosis is a FINDING (loops back for revision) \u2014 do NOT say you "cannot proceed" for a defect you can describe. ESCALATE only when you genuinely cannot review (a required reproduction input is absent and is not the implementer's to supply).
|
|
2042
|
+
|
|
2043
|
+
Never reply with only a bare verdict; your full reply must be well over 100 characters.
|
|
2044
|
+
|
|
2045
|
+
Output format \u2014 the verdict line MUST come before the Non-blocking risks section, which is always LAST:
|
|
2046
|
+
Diagnosis review matrix:
|
|
2047
|
+
| Claim | Required evidence | Implementer evidence | Independently verified? | Result |
|
|
2048
|
+
| ... |
|
|
2049
|
+
|
|
2050
|
+
Findings: (omit this block entirely if none)
|
|
2051
|
+
- <blocking finding tied to an exact diagnosis-contract item, with evidence>
|
|
2052
|
+
|
|
2053
|
+
<verdict line: "Approved. <one or two sentences>" OR, when blocked/cannot-proceed, state you cannot proceed and why>
|
|
2054
|
+
|
|
2055
|
+
Non-blocking risks:
|
|
2056
|
+
- <risk that does NOT block this gate, or "None.">
|
|
2057
|
+
--- end protocol ---`;
|
|
2028
2058
|
var SDD_SPEC_REVIEW = "Review the spec at {specPath}. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2029
2059
|
var SDD_CODE_REVIEW = "Review the implementer's changes for this phase \u2014 the commits in {commitRange}. The upper bound is a LIVE `HEAD`: resolve it against the current repository at review time and INCLUDE any commits added during this review round (e.g. fixes for your prior findings); do not pin the review to an earlier tip. Verify against the spec's acceptance criteria and run the project's verification/tests. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2030
2060
|
var SPEC_DRIVEN_DEVELOPMENT = {
|
|
@@ -2145,13 +2175,113 @@ var RALPH_LOOP = {
|
|
|
2145
2175
|
}
|
|
2146
2176
|
]
|
|
2147
2177
|
};
|
|
2178
|
+
var BUGFIX_DIAGNOSIS_KICKOFF = `You are the implementer in an autonomous complex-bug-fixing workflow. No human is in the loop \u2014 never ask for confirmation, permission, or clarification; do the work yourself.
|
|
2179
|
+
|
|
2180
|
+
Read the bug report at {specPath}. A human (dev or QA) already observed this bug, so you must reproduce it too \u2014 do NOT theorize from reading code paths.
|
|
2181
|
+
|
|
2182
|
+
Write a diagnosis artifact to {diagnosisPath} (create the file) with these sections:
|
|
2183
|
+
1. Reproduction \u2014 an ACTUALLY OBSERVED reproduction you ran yourself. Strongly prefer a failing test (RED) failing for the right reason; commit that test in THIS phase. If the project supports e2e/real-browser (e.g. Playwright), use it. Only if no automated test can capture it, give command/log output WITH an explicit justification.
|
|
2184
|
+
2. Root cause \u2014 the causal chain symptom\u2192cause, each link backed by concrete evidence (stack trace, log line, failing assertion, bisect), not assertion.
|
|
2185
|
+
3. Proposed fix approach \u2014 what changes and WHY that removes the root cause rather than masking the symptom.
|
|
2186
|
+
4. Blast radius \u2014 every area/module/contract the fix could affect.
|
|
2187
|
+
5. Residual risks \u2014 foreseeable risks remaining after the fix.
|
|
2188
|
+
|
|
2189
|
+
Commit the RED reproduction test (do NOT commit {bugfixDir}; it is gitignored). End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters \u2014 never hand back only a single word.`;
|
|
2190
|
+
var BUGFIX_DIAGNOSIS_REVIEW = "Review the diagnosis artifact at {diagnosisPath} for the bug reported at {specPath}. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_DIAGNOSIS_PROTOCOL;
|
|
2191
|
+
var BUGFIX_DIAGNOSIS_FIX = "Apply the reviewer's findings to the diagnosis at {diagnosisPath} now. This is an autonomous workflow \u2014 no human will respond. Make the edits yourself (re-reproduce if needed) and hand back the corrected diagnosis; never ask for confirmation, permission, or clarification. If you added or changed the RED reproduction test while addressing the findings, COMMIT it in this round (do NOT commit {bugfixDir}; it is gitignored) \u2014 the next phase reviews the committed change set, so an uncommitted repro update would be invisible to it. End your handback with a 1-2 sentence summary of what you changed; your reply must be at least two sentences, well over 100 characters \u2014 never hand back only a single word.";
|
|
2192
|
+
var BUGFIX_FIX_KICKOFF = `The diagnosis at {diagnosisPath} is APPROVED \u2014 treat it as ground truth (re-orient from it, not prior conversation). This is an autonomous workflow \u2014 no human will respond; do the work yourself.
|
|
2193
|
+
|
|
2194
|
+
1. Implement the fix per the APPROVED approach.
|
|
2195
|
+
2. Turn the reproduction GREEN \u2014 the failing test now passes for the right reason; if the repro was a non-test demonstration, re-run it and show the symptom is gone.
|
|
2196
|
+
3. Run the project's verification/test command PLUS targeted checks across the declared blast radius, including the full suite, to catch regressions.
|
|
2197
|
+
4. Commit the fix and any added happy-path/edge-case coverage tests (the RED test was committed in diagnosis). Do NOT commit {bugfixDir} (gitignored).
|
|
2198
|
+
|
|
2199
|
+
If you discover the approved cause was WRONG, do NOT silently switch to a different fix \u2014 the cause was the agreed premise of this run. Stop and hand back that you CANNOT PROCEED because the approved cause is wrong, explaining what the evidence now shows; do not deliver a fix built on a second, unreviewed theory. This halts the run and returns control to a human, who re-opens the diagnosis (a new run, or a resume after they adjust the report) \u2014 the workflow does not loop back to the diagnosis phase on its own. Otherwise, hand back the commit SHAs + verification output + a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.`;
|
|
2200
|
+
var BUGFIX_FIX_REVIEW = "The implementer claims the fix for the bug at {specPath} is complete \u2014 the changes are commits {commitRange}; resolve the upper bound against LIVE HEAD and include fix-round commits. Verify against the APPROVED diagnosis at {diagnosisPath}. Independently re-run the reproduction (it must be GREEN) and the verification suite \u2014 do not trust pasted output. Confirm: the root cause is actually removed (not just relocated \u2014 anti-whack-a-mole); every declared blast-radius area is regression-free; residual risks are handled or explicitly accepted; and COVERAGE is adequate \u2014 every happy path has at least one covering test and edge cases are covered. A case that genuinely cannot be covered must be explicitly noted (not silently passed); thin coverage is a blocking finding. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2201
|
+
var BUGFIX_FIX_FIX = "Apply the reviewer's findings to commits {commitRange} now (amend or add commits). This is an autonomous workflow \u2014 no human will respond. Do the work yourself and hand back the updated commit SHAs and verification output; never ask for confirmation, permission, or clarification. End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.";
|
|
2202
|
+
var BUGFIX_POSTMORTEM_KICKOFF = "Write a post-mortem report to {postmortemPath} (create the file) for the bug fixed in this run. This is an autonomous workflow \u2014 no human will respond; do the work yourself. Recap: confirmed root cause; the fix applied; reproduction\u2192GREEN evidence; blast radius touched; coverage gaps explicitly listed (carried from the fix review); residual risks; and lessons learned. Do NOT commit {bugfixDir} (gitignored). End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.";
|
|
2203
|
+
var BUGFIX_POSTMORTEM_REVIEW = "Review the post-mortem report at {postmortemPath}. Confirm it faithfully reflects what actually happened in this run \u2014 confirmed cause, the fix, the noted coverage gaps, and residual risks are all present and honest. This is not a rubber stamp; gloss-overs or omissions are findings. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2204
|
+
var BUGFIX_POSTMORTEM_FIX = "Apply the reviewer's findings to the post-mortem at {postmortemPath} now. This is an autonomous workflow \u2014 no human will respond. Make the edits yourself and hand back the corrected report; never ask for confirmation, permission, or clarification. End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.";
|
|
2205
|
+
var COMPLEX_BUG_FIXING = {
|
|
2206
|
+
type: "complex-bug-fixing",
|
|
2207
|
+
displayName: "Complex Bug Fixing",
|
|
2208
|
+
description: "Reproduce \u2192 adversarially-gated diagnosis \u2192 fix & verify \u2192 post-mortem, for a reported bug whose root cause is unknown",
|
|
2209
|
+
defaultImplementer: "claude",
|
|
2210
|
+
defaultReviewer: "codex",
|
|
2211
|
+
phases: [
|
|
2212
|
+
{
|
|
2213
|
+
name: "diagnosis",
|
|
2214
|
+
implementerRole: "implementer",
|
|
2215
|
+
reviewerRole: "reviewer",
|
|
2216
|
+
maxRounds: 5,
|
|
2217
|
+
initialHandoffStep: "implement",
|
|
2218
|
+
kickoffTemplate: BUGFIX_DIAGNOSIS_KICKOFF,
|
|
2219
|
+
stepTemplates: {
|
|
2220
|
+
implement: BUGFIX_DIAGNOSIS_KICKOFF,
|
|
2221
|
+
review: BUGFIX_DIAGNOSIS_REVIEW,
|
|
2222
|
+
fix: BUGFIX_DIAGNOSIS_FIX
|
|
2223
|
+
},
|
|
2224
|
+
reviewMode: "phase-review",
|
|
2225
|
+
evaluatorPromptKey: "review-loop",
|
|
2226
|
+
artifactOut: { kind: "spec", pathTemplate: "{diagnosisPath}" },
|
|
2227
|
+
anchorCommitBaseOnEntry: true,
|
|
2228
|
+
renderFixTemplateOnFindings: true
|
|
2229
|
+
},
|
|
2230
|
+
{
|
|
2231
|
+
name: "fix-and-verify",
|
|
2232
|
+
implementerRole: "implementer",
|
|
2233
|
+
reviewerRole: "reviewer",
|
|
2234
|
+
maxRounds: 5,
|
|
2235
|
+
initialHandoffStep: "implement",
|
|
2236
|
+
kickoffTemplate: BUGFIX_FIX_KICKOFF,
|
|
2237
|
+
stepTemplates: {
|
|
2238
|
+
implement: BUGFIX_FIX_KICKOFF,
|
|
2239
|
+
review: BUGFIX_FIX_REVIEW,
|
|
2240
|
+
fix: BUGFIX_FIX_FIX
|
|
2241
|
+
},
|
|
2242
|
+
reviewMode: "acceptance-review",
|
|
2243
|
+
evaluatorPromptKey: "review-loop",
|
|
2244
|
+
artifactOut: { kind: "commit-range" },
|
|
2245
|
+
renderFixTemplateOnFindings: true
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
name: "post-mortem",
|
|
2249
|
+
implementerRole: "implementer",
|
|
2250
|
+
reviewerRole: "reviewer",
|
|
2251
|
+
maxRounds: 3,
|
|
2252
|
+
initialHandoffStep: "implement",
|
|
2253
|
+
kickoffTemplate: BUGFIX_POSTMORTEM_KICKOFF,
|
|
2254
|
+
stepTemplates: {
|
|
2255
|
+
implement: BUGFIX_POSTMORTEM_KICKOFF,
|
|
2256
|
+
review: BUGFIX_POSTMORTEM_REVIEW,
|
|
2257
|
+
fix: BUGFIX_POSTMORTEM_FIX
|
|
2258
|
+
},
|
|
2259
|
+
reviewMode: "phase-review",
|
|
2260
|
+
evaluatorPromptKey: "review-loop",
|
|
2261
|
+
artifactOut: { kind: "spec", pathTemplate: "{postmortemPath}" },
|
|
2262
|
+
renderFixTemplateOnFindings: true
|
|
2263
|
+
}
|
|
2264
|
+
]
|
|
2265
|
+
};
|
|
2148
2266
|
var REGISTRY = {
|
|
2149
2267
|
[SPEC_DRIVEN_DEVELOPMENT.type]: SPEC_DRIVEN_DEVELOPMENT,
|
|
2150
|
-
[RALPH_LOOP.type]: RALPH_LOOP
|
|
2268
|
+
[RALPH_LOOP.type]: RALPH_LOOP,
|
|
2269
|
+
[COMPLEX_BUG_FIXING.type]: COMPLEX_BUG_FIXING
|
|
2151
2270
|
};
|
|
2152
2271
|
function ralphRunDir(workspaceRoot, workflowId) {
|
|
2153
2272
|
return join(workspaceRoot, ".ai-whisper", "ralph", workflowId);
|
|
2154
2273
|
}
|
|
2274
|
+
function bugfixRunDir(workspaceRoot, workflowId) {
|
|
2275
|
+
return join(workspaceRoot, ".ai-whisper", "bugfix", workflowId);
|
|
2276
|
+
}
|
|
2277
|
+
function bugfixPaths(workspaceRoot, workflowId) {
|
|
2278
|
+
const bugfixDir = bugfixRunDir(workspaceRoot, workflowId);
|
|
2279
|
+
return {
|
|
2280
|
+
bugfixDir,
|
|
2281
|
+
diagnosisPath: join(bugfixDir, "diagnosis.md"),
|
|
2282
|
+
postmortemPath: join(bugfixDir, "postmortem.md")
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2155
2285
|
function getWorkflowDefinition(type) {
|
|
2156
2286
|
return REGISTRY[type];
|
|
2157
2287
|
}
|
|
@@ -2371,12 +2501,16 @@ function createWorkflowControl(deps) {
|
|
|
2371
2501
|
const collab2 = getCollab(db, input.workflow.collabId);
|
|
2372
2502
|
const ralphDir = collab2 ? ralphRunDir(collab2.workspaceRoot, input.workflow.workflowId) : "";
|
|
2373
2503
|
const reviewMode = useAcceptance ? "acceptance-review" : input.phase.reviewMode ?? "phase-review";
|
|
2504
|
+
const bf = collab2 ? bugfixPaths(collab2.workspaceRoot, input.workflow.workflowId) : { bugfixDir: "", diagnosisPath: "", postmortemPath: "" };
|
|
2374
2505
|
return renderTemplate(tmpl, {
|
|
2375
2506
|
specPath: input.workflow.specPath,
|
|
2376
2507
|
planPath: safeDerivePlanPath(input.workflow.specPath, input.workflow.createdAt),
|
|
2377
2508
|
commitRange: liveReviewCommitRange(ctx),
|
|
2378
2509
|
ralphDir,
|
|
2379
|
-
reviewMode
|
|
2510
|
+
reviewMode,
|
|
2511
|
+
bugfixDir: bf.bugfixDir,
|
|
2512
|
+
diagnosisPath: bf.diagnosisPath,
|
|
2513
|
+
postmortemPath: bf.postmortemPath
|
|
2380
2514
|
});
|
|
2381
2515
|
}
|
|
2382
2516
|
function createContinuationHandoff(input) {
|
|
@@ -2413,12 +2547,16 @@ function createWorkflowControl(deps) {
|
|
|
2413
2547
|
const ctx = input.workflow.workflowContext;
|
|
2414
2548
|
const collab2 = getCollab(db, input.workflow.collabId);
|
|
2415
2549
|
const ralphDir = collab2 ? ralphRunDir(collab2.workspaceRoot, input.workflow.workflowId) : "";
|
|
2550
|
+
const bf = collab2 ? bugfixPaths(collab2.workspaceRoot, input.workflow.workflowId) : { bugfixDir: "", diagnosisPath: "", postmortemPath: "" };
|
|
2416
2551
|
const kickoffText = renderTemplate(phase.kickoffTemplate, {
|
|
2417
2552
|
specPath: input.workflow.specPath,
|
|
2418
2553
|
planPath: safeDerivePlanPath(input.workflow.specPath, input.workflow.createdAt),
|
|
2419
2554
|
commitRange: liveReviewCommitRange(ctx),
|
|
2420
2555
|
ralphDir,
|
|
2421
|
-
reviewMode: phase.reviewMode ?? "phase-review"
|
|
2556
|
+
reviewMode: phase.reviewMode ?? "phase-review",
|
|
2557
|
+
bugfixDir: bf.bugfixDir,
|
|
2558
|
+
diagnosisPath: bf.diagnosisPath,
|
|
2559
|
+
postmortemPath: bf.postmortemPath
|
|
2422
2560
|
});
|
|
2423
2561
|
const chainId = `relay_ch_${randomUUID().replace(/-/g, "").slice(0, 16)}`;
|
|
2424
2562
|
const phaseRunId = `wfp_${randomUUID().replace(/-/g, "").slice(0, 16)}`;
|
|
@@ -2676,15 +2814,19 @@ function createWorkflowControl(deps) {
|
|
|
2676
2814
|
} else if (normalized.verdict === "findings") {
|
|
2677
2815
|
const findingsText = input.followUpMessage ?? "Address the reviewer's findings.";
|
|
2678
2816
|
let fixRequestText;
|
|
2679
|
-
if (phase.repeatUntilComplete && phase.stepTemplates.fix) {
|
|
2817
|
+
if ((phase.repeatUntilComplete || phase.renderFixTemplateOnFindings) && phase.stepTemplates.fix) {
|
|
2680
2818
|
const ctx = workflow.workflowContext;
|
|
2681
2819
|
const collab2 = getCollab(db, workflow.collabId);
|
|
2682
2820
|
const ralphDir = collab2 ? ralphRunDir(collab2.workspaceRoot, workflow.workflowId) : "";
|
|
2821
|
+
const bf = collab2 ? bugfixPaths(collab2.workspaceRoot, workflow.workflowId) : { bugfixDir: "", diagnosisPath: "", postmortemPath: "" };
|
|
2683
2822
|
const fixTmpl = renderTemplate(phase.stepTemplates.fix, {
|
|
2684
2823
|
specPath: workflow.specPath,
|
|
2685
2824
|
planPath: safeDerivePlanPath(workflow.specPath, workflow.createdAt),
|
|
2686
2825
|
commitRange: liveReviewCommitRange(ctx),
|
|
2687
|
-
ralphDir
|
|
2826
|
+
ralphDir,
|
|
2827
|
+
bugfixDir: bf.bugfixDir,
|
|
2828
|
+
diagnosisPath: bf.diagnosisPath,
|
|
2829
|
+
postmortemPath: bf.postmortemPath
|
|
2688
2830
|
});
|
|
2689
2831
|
fixRequestText = `${fixTmpl}
|
|
2690
2832
|
|
|
@@ -4512,6 +4654,23 @@ function ensureRalphWorkspace(workspaceRoot, workflowId) {
|
|
|
4512
4654
|
return dir;
|
|
4513
4655
|
}
|
|
4514
4656
|
|
|
4657
|
+
// ../broker/dist/runtime/bugfix-setup.js
|
|
4658
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, existsSync as existsSync3 } from "node:fs";
|
|
4659
|
+
import { join as join3 } from "node:path";
|
|
4660
|
+
function ensureBugfixWorkspace(workspaceRoot, workflowId) {
|
|
4661
|
+
const dir = bugfixRunDir(workspaceRoot, workflowId);
|
|
4662
|
+
mkdirSync2(dir, { recursive: true });
|
|
4663
|
+
const ignorePath = join3(workspaceRoot, ".ai-whisper", ".gitignore");
|
|
4664
|
+
if (!existsSync3(ignorePath)) {
|
|
4665
|
+
writeFileSync2(ignorePath, "*\n");
|
|
4666
|
+
}
|
|
4667
|
+
const bugfixIgnorePath = join3(workspaceRoot, ".ai-whisper", "bugfix", ".gitignore");
|
|
4668
|
+
if (!existsSync3(bugfixIgnorePath)) {
|
|
4669
|
+
writeFileSync2(bugfixIgnorePath, "*\n");
|
|
4670
|
+
}
|
|
4671
|
+
return dir;
|
|
4672
|
+
}
|
|
4673
|
+
|
|
4515
4674
|
// ../broker/dist/runtime/workflow-driver.js
|
|
4516
4675
|
function createWorkflowDriver(deps) {
|
|
4517
4676
|
const { broker: broker2, headReader } = deps;
|
|
@@ -4582,7 +4741,7 @@ function createWorkflowDriver(deps) {
|
|
|
4582
4741
|
const sender = phase.initialHandoffStep === "review" ? implementerAgent : reviewerAgent;
|
|
4583
4742
|
const target = phase.initialHandoffStep === "review" ? reviewerAgent : implementerAgent;
|
|
4584
4743
|
let executionBaseHeadSha;
|
|
4585
|
-
if (phase.initialHandoffStep === "execute") {
|
|
4744
|
+
if (phase.initialHandoffStep === "execute" || phase.anchorCommitBaseOnEntry === true) {
|
|
4586
4745
|
try {
|
|
4587
4746
|
executionBaseHeadSha = await headReader.readHead(collab2.workspaceRoot);
|
|
4588
4747
|
} catch (err) {
|
|
@@ -4605,6 +4764,15 @@ function createWorkflowDriver(deps) {
|
|
|
4605
4764
|
} else {
|
|
4606
4765
|
ralphDir = ralphRunDir(collab2.workspaceRoot, workflowId);
|
|
4607
4766
|
}
|
|
4767
|
+
if (workflow.workflowType === "complex-bug-fixing") {
|
|
4768
|
+
try {
|
|
4769
|
+
ensureBugfixWorkspace(collab2.workspaceRoot, workflowId);
|
|
4770
|
+
} catch (err) {
|
|
4771
|
+
broker2.control.haltWorkflow({ workflowId, reason: `bugfix setup failed: ${String(err)}`, now });
|
|
4772
|
+
return;
|
|
4773
|
+
}
|
|
4774
|
+
}
|
|
4775
|
+
const bugfix = bugfixPaths(collab2.workspaceRoot, workflowId);
|
|
4608
4776
|
const ctx = workflow.workflowContext;
|
|
4609
4777
|
let planPath = workflow.specPath;
|
|
4610
4778
|
try {
|
|
@@ -4616,7 +4784,10 @@ function createWorkflowDriver(deps) {
|
|
|
4616
4784
|
planPath,
|
|
4617
4785
|
commitRange: ctx.commitRange ?? "HEAD",
|
|
4618
4786
|
ralphDir,
|
|
4619
|
-
reviewMode: phase.reviewMode ?? "phase-review"
|
|
4787
|
+
reviewMode: phase.reviewMode ?? "phase-review",
|
|
4788
|
+
bugfixDir: bugfix.bugfixDir,
|
|
4789
|
+
diagnosisPath: bugfix.diagnosisPath,
|
|
4790
|
+
postmortemPath: bugfix.postmortemPath
|
|
4620
4791
|
});
|
|
4621
4792
|
try {
|
|
4622
4793
|
broker2.control.beginPhaseRun({
|
|
@@ -5548,7 +5719,7 @@ function writeOwnPidToBrokerDaemon(db, input) {
|
|
|
5548
5719
|
|
|
5549
5720
|
// src/runtime/evaluator-config.ts
|
|
5550
5721
|
import { readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
|
|
5551
|
-
import { join as
|
|
5722
|
+
import { join as join4 } from "node:path";
|
|
5552
5723
|
|
|
5553
5724
|
// src/runtime/state-root.ts
|
|
5554
5725
|
import os from "node:os";
|
|
@@ -5607,15 +5778,15 @@ function loadEvaluatorConfig() {
|
|
|
5607
5778
|
const root = getStateRoot();
|
|
5608
5779
|
let dotenv = {};
|
|
5609
5780
|
try {
|
|
5610
|
-
dotenv = parseDotEnv(readFileSync2(
|
|
5781
|
+
dotenv = parseDotEnv(readFileSync2(join4(root, ".env"), "utf8"));
|
|
5611
5782
|
} catch (err) {
|
|
5612
5783
|
if (err.code !== "ENOENT") throw err;
|
|
5613
5784
|
}
|
|
5614
5785
|
const envGet = (k) => process.env[k] ?? dotenv[k];
|
|
5615
|
-
const authPath =
|
|
5786
|
+
const authPath = join4(root, "auth.json");
|
|
5616
5787
|
warnIfLoosePerms(authPath);
|
|
5617
5788
|
const auth = readJsonFile(authPath, "auth.json");
|
|
5618
|
-
const config = readJsonFile(
|
|
5789
|
+
const config = readJsonFile(join4(root, "config.json"), "config.json");
|
|
5619
5790
|
const evalCfg = config?.evaluator ?? {};
|
|
5620
5791
|
const evalOllama = evalCfg.ollama ?? {};
|
|
5621
5792
|
const provider = (envGet("AI_WHISPER_EVALUATOR_PROVIDER") ?? evalCfg.provider) === "ollama" ? "ollama" : "anthropic";
|
|
@@ -2058,6 +2058,36 @@ Findings: (omit this block entirely if none)
|
|
|
2058
2058
|
Non-blocking risks:
|
|
2059
2059
|
- <quality risk that does NOT block this gate, or "None.">
|
|
2060
2060
|
--- end protocol ---`;
|
|
2061
|
+
var WORKFLOW_DIAGNOSIS_PROTOCOL = `--- ai-whisper diagnosis review protocol ---
|
|
2062
|
+
You are the gatekeeper for an ai-whisper complex-bug-fixing DIAGNOSIS gate. No human is in the loop. Do NOT trust the implementer's diagnosis \u2014 verify it yourself. The gate stays shut until YOU independently agree on the root cause and that the fix is net-safe.
|
|
2063
|
+
|
|
2064
|
+
Required procedure:
|
|
2065
|
+
1. Independently reproduce: re-run the implementer's reproduction yourself; do not trust pasted output. If YOU cannot reproduce it, that is a blocking finding (the repro is not real/reliable). Speculation from reading code paths is not a valid reproduction.
|
|
2066
|
+
2. Attack the causal claim: is the cause PROVEN by the evidence chain, or merely asserted? Could the named cause be a correlate, or a symptom of something deeper? Demand any missing link.
|
|
2067
|
+
3. Attack the fix (anti-whack-a-mole): does the proposed fix remove the root cause, or just this symptom's surface? Could the bug resurface through another path? Name it if so.
|
|
2068
|
+
4. Attack the blast radius: is every affected area/module/contract listed? Add what is missing.
|
|
2069
|
+
5. Attack residual risks: are the real foreseeable risks named, or hand-waved?
|
|
2070
|
+
6. Mutual-agreement gate: approve ONLY when you have independently confirmed the reproduction and agree the cause is proven and the fix is net-safe (fixes more than it risks). "Plausible" is not approval.
|
|
2071
|
+
|
|
2072
|
+
Severity: a blocking finding must tie to a concrete diagnosis-contract item (unreproducible repro, unproven cause, symptom-masking fix, incomplete blast radius, un-named risk). Suppress style/taste. Do NOT gag valuable non-contract risk signals \u2014 surface them under "Non-blocking risks:" (always last) so they reach the human at escalation/completion.
|
|
2073
|
+
|
|
2074
|
+
Findings vs escalation: a fixable defect in the diagnosis is a FINDING (loops back for revision) \u2014 do NOT say you "cannot proceed" for a defect you can describe. ESCALATE only when you genuinely cannot review (a required reproduction input is absent and is not the implementer's to supply).
|
|
2075
|
+
|
|
2076
|
+
Never reply with only a bare verdict; your full reply must be well over 100 characters.
|
|
2077
|
+
|
|
2078
|
+
Output format \u2014 the verdict line MUST come before the Non-blocking risks section, which is always LAST:
|
|
2079
|
+
Diagnosis review matrix:
|
|
2080
|
+
| Claim | Required evidence | Implementer evidence | Independently verified? | Result |
|
|
2081
|
+
| ... |
|
|
2082
|
+
|
|
2083
|
+
Findings: (omit this block entirely if none)
|
|
2084
|
+
- <blocking finding tied to an exact diagnosis-contract item, with evidence>
|
|
2085
|
+
|
|
2086
|
+
<verdict line: "Approved. <one or two sentences>" OR, when blocked/cannot-proceed, state you cannot proceed and why>
|
|
2087
|
+
|
|
2088
|
+
Non-blocking risks:
|
|
2089
|
+
- <risk that does NOT block this gate, or "None.">
|
|
2090
|
+
--- end protocol ---`;
|
|
2061
2091
|
var SDD_SPEC_REVIEW = "Review the spec at {specPath}. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2062
2092
|
var SDD_CODE_REVIEW = "Review the implementer's changes for this phase \u2014 the commits in {commitRange}. The upper bound is a LIVE `HEAD`: resolve it against the current repository at review time and INCLUDE any commits added during this review round (e.g. fixes for your prior findings); do not pin the review to an earlier tip. Verify against the spec's acceptance criteria and run the project's verification/tests. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2063
2093
|
var SPEC_DRIVEN_DEVELOPMENT = {
|
|
@@ -2178,13 +2208,113 @@ var RALPH_LOOP = {
|
|
|
2178
2208
|
}
|
|
2179
2209
|
]
|
|
2180
2210
|
};
|
|
2211
|
+
var BUGFIX_DIAGNOSIS_KICKOFF = `You are the implementer in an autonomous complex-bug-fixing workflow. No human is in the loop \u2014 never ask for confirmation, permission, or clarification; do the work yourself.
|
|
2212
|
+
|
|
2213
|
+
Read the bug report at {specPath}. A human (dev or QA) already observed this bug, so you must reproduce it too \u2014 do NOT theorize from reading code paths.
|
|
2214
|
+
|
|
2215
|
+
Write a diagnosis artifact to {diagnosisPath} (create the file) with these sections:
|
|
2216
|
+
1. Reproduction \u2014 an ACTUALLY OBSERVED reproduction you ran yourself. Strongly prefer a failing test (RED) failing for the right reason; commit that test in THIS phase. If the project supports e2e/real-browser (e.g. Playwright), use it. Only if no automated test can capture it, give command/log output WITH an explicit justification.
|
|
2217
|
+
2. Root cause \u2014 the causal chain symptom\u2192cause, each link backed by concrete evidence (stack trace, log line, failing assertion, bisect), not assertion.
|
|
2218
|
+
3. Proposed fix approach \u2014 what changes and WHY that removes the root cause rather than masking the symptom.
|
|
2219
|
+
4. Blast radius \u2014 every area/module/contract the fix could affect.
|
|
2220
|
+
5. Residual risks \u2014 foreseeable risks remaining after the fix.
|
|
2221
|
+
|
|
2222
|
+
Commit the RED reproduction test (do NOT commit {bugfixDir}; it is gitignored). End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters \u2014 never hand back only a single word.`;
|
|
2223
|
+
var BUGFIX_DIAGNOSIS_REVIEW = "Review the diagnosis artifact at {diagnosisPath} for the bug reported at {specPath}. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_DIAGNOSIS_PROTOCOL;
|
|
2224
|
+
var BUGFIX_DIAGNOSIS_FIX = "Apply the reviewer's findings to the diagnosis at {diagnosisPath} now. This is an autonomous workflow \u2014 no human will respond. Make the edits yourself (re-reproduce if needed) and hand back the corrected diagnosis; never ask for confirmation, permission, or clarification. If you added or changed the RED reproduction test while addressing the findings, COMMIT it in this round (do NOT commit {bugfixDir}; it is gitignored) \u2014 the next phase reviews the committed change set, so an uncommitted repro update would be invisible to it. End your handback with a 1-2 sentence summary of what you changed; your reply must be at least two sentences, well over 100 characters \u2014 never hand back only a single word.";
|
|
2225
|
+
var BUGFIX_FIX_KICKOFF = `The diagnosis at {diagnosisPath} is APPROVED \u2014 treat it as ground truth (re-orient from it, not prior conversation). This is an autonomous workflow \u2014 no human will respond; do the work yourself.
|
|
2226
|
+
|
|
2227
|
+
1. Implement the fix per the APPROVED approach.
|
|
2228
|
+
2. Turn the reproduction GREEN \u2014 the failing test now passes for the right reason; if the repro was a non-test demonstration, re-run it and show the symptom is gone.
|
|
2229
|
+
3. Run the project's verification/test command PLUS targeted checks across the declared blast radius, including the full suite, to catch regressions.
|
|
2230
|
+
4. Commit the fix and any added happy-path/edge-case coverage tests (the RED test was committed in diagnosis). Do NOT commit {bugfixDir} (gitignored).
|
|
2231
|
+
|
|
2232
|
+
If you discover the approved cause was WRONG, do NOT silently switch to a different fix \u2014 the cause was the agreed premise of this run. Stop and hand back that you CANNOT PROCEED because the approved cause is wrong, explaining what the evidence now shows; do not deliver a fix built on a second, unreviewed theory. This halts the run and returns control to a human, who re-opens the diagnosis (a new run, or a resume after they adjust the report) \u2014 the workflow does not loop back to the diagnosis phase on its own. Otherwise, hand back the commit SHAs + verification output + a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.`;
|
|
2233
|
+
var BUGFIX_FIX_REVIEW = "The implementer claims the fix for the bug at {specPath} is complete \u2014 the changes are commits {commitRange}; resolve the upper bound against LIVE HEAD and include fix-round commits. Verify against the APPROVED diagnosis at {diagnosisPath}. Independently re-run the reproduction (it must be GREEN) and the verification suite \u2014 do not trust pasted output. Confirm: the root cause is actually removed (not just relocated \u2014 anti-whack-a-mole); every declared blast-radius area is regression-free; residual risks are handled or explicitly accepted; and COVERAGE is adequate \u2014 every happy path has at least one covering test and edge cases are covered. A case that genuinely cannot be covered must be explicitly noted (not silently passed); thin coverage is a blocking finding. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2234
|
+
var BUGFIX_FIX_FIX = "Apply the reviewer's findings to commits {commitRange} now (amend or add commits). This is an autonomous workflow \u2014 no human will respond. Do the work yourself and hand back the updated commit SHAs and verification output; never ask for confirmation, permission, or clarification. End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.";
|
|
2235
|
+
var BUGFIX_POSTMORTEM_KICKOFF = "Write a post-mortem report to {postmortemPath} (create the file) for the bug fixed in this run. This is an autonomous workflow \u2014 no human will respond; do the work yourself. Recap: confirmed root cause; the fix applied; reproduction\u2192GREEN evidence; blast radius touched; coverage gaps explicitly listed (carried from the fix review); residual risks; and lessons learned. Do NOT commit {bugfixDir} (gitignored). End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.";
|
|
2236
|
+
var BUGFIX_POSTMORTEM_REVIEW = "Review the post-mortem report at {postmortemPath}. Confirm it faithfully reflects what actually happened in this run \u2014 confirmed cause, the fix, the noted coverage gaps, and residual risks are all present and honest. This is not a rubber stamp; gloss-overs or omissions are findings. This is an autonomous workflow with no human in the loop.\n\n" + WORKFLOW_REVIEW_PROTOCOL;
|
|
2237
|
+
var BUGFIX_POSTMORTEM_FIX = "Apply the reviewer's findings to the post-mortem at {postmortemPath} now. This is an autonomous workflow \u2014 no human will respond. Make the edits yourself and hand back the corrected report; never ask for confirmation, permission, or clarification. End your handback with a 1-2 sentence summary; your reply must be at least two sentences, well over 100 characters.";
|
|
2238
|
+
var COMPLEX_BUG_FIXING = {
|
|
2239
|
+
type: "complex-bug-fixing",
|
|
2240
|
+
displayName: "Complex Bug Fixing",
|
|
2241
|
+
description: "Reproduce \u2192 adversarially-gated diagnosis \u2192 fix & verify \u2192 post-mortem, for a reported bug whose root cause is unknown",
|
|
2242
|
+
defaultImplementer: "claude",
|
|
2243
|
+
defaultReviewer: "codex",
|
|
2244
|
+
phases: [
|
|
2245
|
+
{
|
|
2246
|
+
name: "diagnosis",
|
|
2247
|
+
implementerRole: "implementer",
|
|
2248
|
+
reviewerRole: "reviewer",
|
|
2249
|
+
maxRounds: 5,
|
|
2250
|
+
initialHandoffStep: "implement",
|
|
2251
|
+
kickoffTemplate: BUGFIX_DIAGNOSIS_KICKOFF,
|
|
2252
|
+
stepTemplates: {
|
|
2253
|
+
implement: BUGFIX_DIAGNOSIS_KICKOFF,
|
|
2254
|
+
review: BUGFIX_DIAGNOSIS_REVIEW,
|
|
2255
|
+
fix: BUGFIX_DIAGNOSIS_FIX
|
|
2256
|
+
},
|
|
2257
|
+
reviewMode: "phase-review",
|
|
2258
|
+
evaluatorPromptKey: "review-loop",
|
|
2259
|
+
artifactOut: { kind: "spec", pathTemplate: "{diagnosisPath}" },
|
|
2260
|
+
anchorCommitBaseOnEntry: true,
|
|
2261
|
+
renderFixTemplateOnFindings: true
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
name: "fix-and-verify",
|
|
2265
|
+
implementerRole: "implementer",
|
|
2266
|
+
reviewerRole: "reviewer",
|
|
2267
|
+
maxRounds: 5,
|
|
2268
|
+
initialHandoffStep: "implement",
|
|
2269
|
+
kickoffTemplate: BUGFIX_FIX_KICKOFF,
|
|
2270
|
+
stepTemplates: {
|
|
2271
|
+
implement: BUGFIX_FIX_KICKOFF,
|
|
2272
|
+
review: BUGFIX_FIX_REVIEW,
|
|
2273
|
+
fix: BUGFIX_FIX_FIX
|
|
2274
|
+
},
|
|
2275
|
+
reviewMode: "acceptance-review",
|
|
2276
|
+
evaluatorPromptKey: "review-loop",
|
|
2277
|
+
artifactOut: { kind: "commit-range" },
|
|
2278
|
+
renderFixTemplateOnFindings: true
|
|
2279
|
+
},
|
|
2280
|
+
{
|
|
2281
|
+
name: "post-mortem",
|
|
2282
|
+
implementerRole: "implementer",
|
|
2283
|
+
reviewerRole: "reviewer",
|
|
2284
|
+
maxRounds: 3,
|
|
2285
|
+
initialHandoffStep: "implement",
|
|
2286
|
+
kickoffTemplate: BUGFIX_POSTMORTEM_KICKOFF,
|
|
2287
|
+
stepTemplates: {
|
|
2288
|
+
implement: BUGFIX_POSTMORTEM_KICKOFF,
|
|
2289
|
+
review: BUGFIX_POSTMORTEM_REVIEW,
|
|
2290
|
+
fix: BUGFIX_POSTMORTEM_FIX
|
|
2291
|
+
},
|
|
2292
|
+
reviewMode: "phase-review",
|
|
2293
|
+
evaluatorPromptKey: "review-loop",
|
|
2294
|
+
artifactOut: { kind: "spec", pathTemplate: "{postmortemPath}" },
|
|
2295
|
+
renderFixTemplateOnFindings: true
|
|
2296
|
+
}
|
|
2297
|
+
]
|
|
2298
|
+
};
|
|
2181
2299
|
var REGISTRY = {
|
|
2182
2300
|
[SPEC_DRIVEN_DEVELOPMENT.type]: SPEC_DRIVEN_DEVELOPMENT,
|
|
2183
|
-
[RALPH_LOOP.type]: RALPH_LOOP
|
|
2301
|
+
[RALPH_LOOP.type]: RALPH_LOOP,
|
|
2302
|
+
[COMPLEX_BUG_FIXING.type]: COMPLEX_BUG_FIXING
|
|
2184
2303
|
};
|
|
2185
2304
|
function ralphRunDir(workspaceRoot, workflowId) {
|
|
2186
2305
|
return join(workspaceRoot, ".ai-whisper", "ralph", workflowId);
|
|
2187
2306
|
}
|
|
2307
|
+
function bugfixRunDir(workspaceRoot, workflowId) {
|
|
2308
|
+
return join(workspaceRoot, ".ai-whisper", "bugfix", workflowId);
|
|
2309
|
+
}
|
|
2310
|
+
function bugfixPaths(workspaceRoot, workflowId) {
|
|
2311
|
+
const bugfixDir = bugfixRunDir(workspaceRoot, workflowId);
|
|
2312
|
+
return {
|
|
2313
|
+
bugfixDir,
|
|
2314
|
+
diagnosisPath: join(bugfixDir, "diagnosis.md"),
|
|
2315
|
+
postmortemPath: join(bugfixDir, "postmortem.md")
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2188
2318
|
function getWorkflowDefinition(type) {
|
|
2189
2319
|
return REGISTRY[type];
|
|
2190
2320
|
}
|
|
@@ -2404,12 +2534,16 @@ function createWorkflowControl(deps) {
|
|
|
2404
2534
|
const collab = getCollab(db, input.workflow.collabId);
|
|
2405
2535
|
const ralphDir = collab ? ralphRunDir(collab.workspaceRoot, input.workflow.workflowId) : "";
|
|
2406
2536
|
const reviewMode = useAcceptance ? "acceptance-review" : input.phase.reviewMode ?? "phase-review";
|
|
2537
|
+
const bf = collab ? bugfixPaths(collab.workspaceRoot, input.workflow.workflowId) : { bugfixDir: "", diagnosisPath: "", postmortemPath: "" };
|
|
2407
2538
|
return renderTemplate(tmpl, {
|
|
2408
2539
|
specPath: input.workflow.specPath,
|
|
2409
2540
|
planPath: safeDerivePlanPath(input.workflow.specPath, input.workflow.createdAt),
|
|
2410
2541
|
commitRange: liveReviewCommitRange(ctx),
|
|
2411
2542
|
ralphDir,
|
|
2412
|
-
reviewMode
|
|
2543
|
+
reviewMode,
|
|
2544
|
+
bugfixDir: bf.bugfixDir,
|
|
2545
|
+
diagnosisPath: bf.diagnosisPath,
|
|
2546
|
+
postmortemPath: bf.postmortemPath
|
|
2413
2547
|
});
|
|
2414
2548
|
}
|
|
2415
2549
|
function createContinuationHandoff(input) {
|
|
@@ -2446,12 +2580,16 @@ function createWorkflowControl(deps) {
|
|
|
2446
2580
|
const ctx = input.workflow.workflowContext;
|
|
2447
2581
|
const collab = getCollab(db, input.workflow.collabId);
|
|
2448
2582
|
const ralphDir = collab ? ralphRunDir(collab.workspaceRoot, input.workflow.workflowId) : "";
|
|
2583
|
+
const bf = collab ? bugfixPaths(collab.workspaceRoot, input.workflow.workflowId) : { bugfixDir: "", diagnosisPath: "", postmortemPath: "" };
|
|
2449
2584
|
const kickoffText = renderTemplate(phase.kickoffTemplate, {
|
|
2450
2585
|
specPath: input.workflow.specPath,
|
|
2451
2586
|
planPath: safeDerivePlanPath(input.workflow.specPath, input.workflow.createdAt),
|
|
2452
2587
|
commitRange: liveReviewCommitRange(ctx),
|
|
2453
2588
|
ralphDir,
|
|
2454
|
-
reviewMode: phase.reviewMode ?? "phase-review"
|
|
2589
|
+
reviewMode: phase.reviewMode ?? "phase-review",
|
|
2590
|
+
bugfixDir: bf.bugfixDir,
|
|
2591
|
+
diagnosisPath: bf.diagnosisPath,
|
|
2592
|
+
postmortemPath: bf.postmortemPath
|
|
2455
2593
|
});
|
|
2456
2594
|
const chainId = `relay_ch_${randomUUID().replace(/-/g, "").slice(0, 16)}`;
|
|
2457
2595
|
const phaseRunId = `wfp_${randomUUID().replace(/-/g, "").slice(0, 16)}`;
|
|
@@ -2709,15 +2847,19 @@ function createWorkflowControl(deps) {
|
|
|
2709
2847
|
} else if (normalized.verdict === "findings") {
|
|
2710
2848
|
const findingsText = input.followUpMessage ?? "Address the reviewer's findings.";
|
|
2711
2849
|
let fixRequestText;
|
|
2712
|
-
if (phase.repeatUntilComplete && phase.stepTemplates.fix) {
|
|
2850
|
+
if ((phase.repeatUntilComplete || phase.renderFixTemplateOnFindings) && phase.stepTemplates.fix) {
|
|
2713
2851
|
const ctx = workflow.workflowContext;
|
|
2714
2852
|
const collab = getCollab(db, workflow.collabId);
|
|
2715
2853
|
const ralphDir = collab ? ralphRunDir(collab.workspaceRoot, workflow.workflowId) : "";
|
|
2854
|
+
const bf = collab ? bugfixPaths(collab.workspaceRoot, workflow.workflowId) : { bugfixDir: "", diagnosisPath: "", postmortemPath: "" };
|
|
2716
2855
|
const fixTmpl = renderTemplate(phase.stepTemplates.fix, {
|
|
2717
2856
|
specPath: workflow.specPath,
|
|
2718
2857
|
planPath: safeDerivePlanPath(workflow.specPath, workflow.createdAt),
|
|
2719
2858
|
commitRange: liveReviewCommitRange(ctx),
|
|
2720
|
-
ralphDir
|
|
2859
|
+
ralphDir,
|
|
2860
|
+
bugfixDir: bf.bugfixDir,
|
|
2861
|
+
diagnosisPath: bf.diagnosisPath,
|
|
2862
|
+
postmortemPath: bf.postmortemPath
|
|
2721
2863
|
});
|
|
2722
2864
|
fixRequestText = `${fixTmpl}
|
|
2723
2865
|
|
|
@@ -4535,6 +4677,23 @@ function ensureRalphWorkspace(workspaceRoot, workflowId) {
|
|
|
4535
4677
|
return dir;
|
|
4536
4678
|
}
|
|
4537
4679
|
|
|
4680
|
+
// ../broker/dist/runtime/bugfix-setup.js
|
|
4681
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, existsSync as existsSync3 } from "node:fs";
|
|
4682
|
+
import { join as join3 } from "node:path";
|
|
4683
|
+
function ensureBugfixWorkspace(workspaceRoot, workflowId) {
|
|
4684
|
+
const dir = bugfixRunDir(workspaceRoot, workflowId);
|
|
4685
|
+
mkdirSync2(dir, { recursive: true });
|
|
4686
|
+
const ignorePath = join3(workspaceRoot, ".ai-whisper", ".gitignore");
|
|
4687
|
+
if (!existsSync3(ignorePath)) {
|
|
4688
|
+
writeFileSync2(ignorePath, "*\n");
|
|
4689
|
+
}
|
|
4690
|
+
const bugfixIgnorePath = join3(workspaceRoot, ".ai-whisper", "bugfix", ".gitignore");
|
|
4691
|
+
if (!existsSync3(bugfixIgnorePath)) {
|
|
4692
|
+
writeFileSync2(bugfixIgnorePath, "*\n");
|
|
4693
|
+
}
|
|
4694
|
+
return dir;
|
|
4695
|
+
}
|
|
4696
|
+
|
|
4538
4697
|
// ../broker/dist/runtime/workflow-driver.js
|
|
4539
4698
|
function createWorkflowDriver(deps) {
|
|
4540
4699
|
const { broker, headReader } = deps;
|
|
@@ -4605,7 +4764,7 @@ function createWorkflowDriver(deps) {
|
|
|
4605
4764
|
const sender = phase.initialHandoffStep === "review" ? implementerAgent : reviewerAgent;
|
|
4606
4765
|
const target = phase.initialHandoffStep === "review" ? reviewerAgent : implementerAgent;
|
|
4607
4766
|
let executionBaseHeadSha;
|
|
4608
|
-
if (phase.initialHandoffStep === "execute") {
|
|
4767
|
+
if (phase.initialHandoffStep === "execute" || phase.anchorCommitBaseOnEntry === true) {
|
|
4609
4768
|
try {
|
|
4610
4769
|
executionBaseHeadSha = await headReader.readHead(collab.workspaceRoot);
|
|
4611
4770
|
} catch (err) {
|
|
@@ -4628,6 +4787,15 @@ function createWorkflowDriver(deps) {
|
|
|
4628
4787
|
} else {
|
|
4629
4788
|
ralphDir = ralphRunDir(collab.workspaceRoot, workflowId);
|
|
4630
4789
|
}
|
|
4790
|
+
if (workflow.workflowType === "complex-bug-fixing") {
|
|
4791
|
+
try {
|
|
4792
|
+
ensureBugfixWorkspace(collab.workspaceRoot, workflowId);
|
|
4793
|
+
} catch (err) {
|
|
4794
|
+
broker.control.haltWorkflow({ workflowId, reason: `bugfix setup failed: ${String(err)}`, now });
|
|
4795
|
+
return;
|
|
4796
|
+
}
|
|
4797
|
+
}
|
|
4798
|
+
const bugfix = bugfixPaths(collab.workspaceRoot, workflowId);
|
|
4631
4799
|
const ctx = workflow.workflowContext;
|
|
4632
4800
|
let planPath = workflow.specPath;
|
|
4633
4801
|
try {
|
|
@@ -4639,7 +4807,10 @@ function createWorkflowDriver(deps) {
|
|
|
4639
4807
|
planPath,
|
|
4640
4808
|
commitRange: ctx.commitRange ?? "HEAD",
|
|
4641
4809
|
ralphDir,
|
|
4642
|
-
reviewMode: phase.reviewMode ?? "phase-review"
|
|
4810
|
+
reviewMode: phase.reviewMode ?? "phase-review",
|
|
4811
|
+
bugfixDir: bugfix.bugfixDir,
|
|
4812
|
+
diagnosisPath: bugfix.diagnosisPath,
|
|
4813
|
+
postmortemPath: bugfix.postmortemPath
|
|
4643
4814
|
});
|
|
4644
4815
|
try {
|
|
4645
4816
|
broker.control.beginPhaseRun({
|
|
@@ -5429,14 +5600,14 @@ function createCompanionRuntime(input) {
|
|
|
5429
5600
|
|
|
5430
5601
|
// src/runtime/broker-artifact-service.ts
|
|
5431
5602
|
import fs from "node:fs";
|
|
5432
|
-
import { join as
|
|
5603
|
+
import { join as join5 } from "node:path";
|
|
5433
5604
|
|
|
5434
5605
|
// src/runtime/paths.ts
|
|
5435
5606
|
import os from "node:os";
|
|
5436
|
-
import { join as
|
|
5607
|
+
import { join as join4 } from "node:path";
|
|
5437
5608
|
function getLiveSessionBrokerTempRoot() {
|
|
5438
5609
|
const username = process.env["USER"] ?? process.env["USERNAME"] ?? "unknown";
|
|
5439
|
-
return
|
|
5610
|
+
return join4(os.tmpdir(), "ai-whisper", username, "live-session-broker");
|
|
5440
5611
|
}
|
|
5441
5612
|
|
|
5442
5613
|
// src/runtime/broker-artifact-service.ts
|
|
@@ -5479,9 +5650,9 @@ var BrokerArtifactService = class {
|
|
|
5479
5650
|
}
|
|
5480
5651
|
createArtifact(input) {
|
|
5481
5652
|
const dirName = buildDirName(input.now, input.workItemId);
|
|
5482
|
-
const artifactDirPath =
|
|
5483
|
-
const requestFilePath =
|
|
5484
|
-
const statusFilePath =
|
|
5653
|
+
const artifactDirPath = join5(this.tempRoot, dirName);
|
|
5654
|
+
const requestFilePath = join5(artifactDirPath, "request.json");
|
|
5655
|
+
const statusFilePath = join5(artifactDirPath, "status.json");
|
|
5485
5656
|
fs.mkdirSync(artifactDirPath, { recursive: true });
|
|
5486
5657
|
const requestData = {
|
|
5487
5658
|
schemaVersion: 1,
|
|
@@ -5560,9 +5731,9 @@ var BrokerArtifactService = class {
|
|
|
5560
5731
|
const entries = fs.readdirSync(this.tempRoot);
|
|
5561
5732
|
const now = Date.now();
|
|
5562
5733
|
for (const entry of entries) {
|
|
5563
|
-
const dirPath =
|
|
5734
|
+
const dirPath = join5(this.tempRoot, entry);
|
|
5564
5735
|
try {
|
|
5565
|
-
const statusPath =
|
|
5736
|
+
const statusPath = join5(dirPath, "status.json");
|
|
5566
5737
|
if (!fs.existsSync(statusPath)) continue;
|
|
5567
5738
|
const raw = fs.readFileSync(statusPath, "utf8");
|
|
5568
5739
|
const status = JSON.parse(raw);
|
|
@@ -5973,8 +6144,8 @@ function createClaudeLiveSession(input) {
|
|
|
5973
6144
|
|
|
5974
6145
|
// ../adapter-codex/dist/create-codex-provider.js
|
|
5975
6146
|
import { spawn as spawn3 } from "node:child_process";
|
|
5976
|
-
import { existsSync as
|
|
5977
|
-
import { join as
|
|
6147
|
+
import { existsSync as existsSync4, readFileSync, rmSync } from "node:fs";
|
|
6148
|
+
import { join as join6 } from "node:path";
|
|
5978
6149
|
|
|
5979
6150
|
// ../adapter-codex/dist/codex-prompt.js
|
|
5980
6151
|
function buildCodexPrompt(request) {
|
|
@@ -6109,7 +6280,7 @@ function createCodexProvider(config) {
|
|
|
6109
6280
|
},
|
|
6110
6281
|
handleWork(request, context) {
|
|
6111
6282
|
const prompt = context?.artifactHandle ? buildCodexFileBackedBrokerPrompt(context.artifactHandle.requestFilePath) : buildCodexPrompt(request);
|
|
6112
|
-
const outputLastMessagePath = context?.artifactHandle ?
|
|
6283
|
+
const outputLastMessagePath = context?.artifactHandle ? join6(context.artifactHandle.artifactDirPath, ".codex-last-message.json") : null;
|
|
6113
6284
|
const spawnArgs = outputLastMessagePath ? [...config.execArgs, "--output-last-message", outputLastMessagePath, prompt] : [...config.execArgs, prompt];
|
|
6114
6285
|
return new Promise((resolve2) => {
|
|
6115
6286
|
const child = spawn3(config.executable, spawnArgs, {
|
|
@@ -6146,7 +6317,7 @@ function createCodexProvider(config) {
|
|
|
6146
6317
|
});
|
|
6147
6318
|
return;
|
|
6148
6319
|
}
|
|
6149
|
-
if (outputLastMessagePath &&
|
|
6320
|
+
if (outputLastMessagePath && existsSync4(outputLastMessagePath)) {
|
|
6150
6321
|
try {
|
|
6151
6322
|
const fileReply = parseCodexOutput(readFileSync(outputLastMessagePath, "utf8"));
|
|
6152
6323
|
if (fileReply.kind !== "failure") {
|