@staff0rd/assist 0.841.0 → 0.843.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/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.843.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -36748,65 +36748,11 @@ function writeJobSummary(synthesisPath, prInfo, summaryPath) {
|
|
|
36748
36748
|
`);
|
|
36749
36749
|
}
|
|
36750
36750
|
|
|
36751
|
-
// src/commands/review/
|
|
36752
|
-
|
|
36753
|
-
|
|
36754
|
-
// src/commands/review/chainAddressComments.ts
|
|
36755
|
-
function chainAddressComments(prNumber, announce) {
|
|
36756
|
-
const args = ["review-pr-comments", String(prNumber)];
|
|
36757
|
-
if (announce) args.push("--announce");
|
|
36758
|
-
return startChainedSession(
|
|
36759
|
-
`an Address Comments session for PR #${prNumber}`,
|
|
36760
|
-
() => requestAssistSession(args, process.cwd(), { inPlace: true })
|
|
36761
|
-
);
|
|
36762
|
-
}
|
|
36763
|
-
|
|
36764
|
-
// src/commands/review/chainAfterReview.ts
|
|
36765
|
-
async function chainAfterReview(prNumber, outcome, options2) {
|
|
36766
|
-
const raisedComments = outcome.posted > 0 && outcome.submitted;
|
|
36767
|
-
if (options2.addressComments && raisedComments) {
|
|
36768
|
-
await chainAddressComments(prNumber, options2.announce);
|
|
36769
|
-
return;
|
|
36770
|
-
}
|
|
36771
|
-
if (options2.announce) await announcePr(prNumber);
|
|
36772
|
-
}
|
|
36773
|
-
|
|
36774
|
-
// src/commands/review/sanitiseReviewerNames.ts
|
|
36775
|
-
var REVIEWER_LABEL = "the reviewer";
|
|
36776
|
-
function sanitiseReviewerNames(value) {
|
|
36777
|
-
return value.replace(/\bclaude\b/gi, REVIEWER_LABEL).replace(/\bopus\b/gi, REVIEWER_LABEL);
|
|
36778
|
-
}
|
|
36751
|
+
// src/commands/review/appendCiFooter.ts
|
|
36752
|
+
function appendCiFooter(body, ciFooter) {
|
|
36753
|
+
return ciFooter ? `${body}
|
|
36779
36754
|
|
|
36780
|
-
|
|
36781
|
-
function buildCommentBody(finding) {
|
|
36782
|
-
const lines2 = [];
|
|
36783
|
-
const severityLabel = finding.severity ?? "finding";
|
|
36784
|
-
lines2.push(`**${severityLabel}: ${finding.title}**`);
|
|
36785
|
-
if (finding.impact) lines2.push("", `Impact: ${finding.impact}`);
|
|
36786
|
-
if (finding.recommendation)
|
|
36787
|
-
lines2.push("", `Recommendation: ${finding.recommendation}`);
|
|
36788
|
-
return sanitiseReviewerNames(lines2.join("\n"));
|
|
36789
|
-
}
|
|
36790
|
-
async function postFindings(findings) {
|
|
36791
|
-
let posted = 0;
|
|
36792
|
-
let failed3 = 0;
|
|
36793
|
-
for (const finding of findings) {
|
|
36794
|
-
const body = buildCommentBody(finding);
|
|
36795
|
-
try {
|
|
36796
|
-
await comment2(finding.file, finding.line, body, {
|
|
36797
|
-
startLine: finding.startLine,
|
|
36798
|
-
skipPreview: true
|
|
36799
|
-
});
|
|
36800
|
-
posted++;
|
|
36801
|
-
} catch (error) {
|
|
36802
|
-
failed3++;
|
|
36803
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
36804
|
-
console.error(
|
|
36805
|
-
`Failed to post comment on ${finding.file}:${finding.line}: ${message3}`
|
|
36806
|
-
);
|
|
36807
|
-
}
|
|
36808
|
-
}
|
|
36809
|
-
return { posted, failed: failed3 };
|
|
36755
|
+
${ciFooter}` : body;
|
|
36810
36756
|
}
|
|
36811
36757
|
|
|
36812
36758
|
// src/commands/review/runReviewSubmission.ts
|
|
@@ -36831,243 +36777,27 @@ function submitBodyOnlyReview(body) {
|
|
|
36831
36777
|
runReviewSubmission(MUTATION6, body);
|
|
36832
36778
|
}
|
|
36833
36779
|
|
|
36834
|
-
// src/commands/review/
|
|
36835
|
-
|
|
36836
|
-
|
|
36837
|
-
|
|
36838
|
-
}
|
|
36839
|
-
|
|
36840
|
-
// src/commands/review/appendCiFooter.ts
|
|
36841
|
-
function appendCiFooter(body, ciFooter) {
|
|
36842
|
-
return ciFooter ? `${body}
|
|
36843
|
-
|
|
36844
|
-
${ciFooter}` : body;
|
|
36845
|
-
}
|
|
36846
|
-
|
|
36847
|
-
// src/commands/review/buildReviewBody.ts
|
|
36848
|
-
function buildReviewBody(markdown, unanchored, ciFooter) {
|
|
36849
|
-
return appendCiFooter(
|
|
36850
|
-
sanitiseReviewerNames(buildReviewSummary(markdown, unanchored)),
|
|
36851
|
-
ciFooter
|
|
36852
|
-
);
|
|
36853
|
-
}
|
|
36854
|
-
|
|
36855
|
-
// src/commands/review/postAndMaybeSubmit.ts
|
|
36856
|
-
function submitReview(body, posted) {
|
|
36857
|
-
if (posted > 0) submitPendingReview(body);
|
|
36858
|
-
else submitBodyOnlyReview(body);
|
|
36859
|
-
}
|
|
36860
|
-
async function decideSubmit(options2) {
|
|
36861
|
-
if (!options2.prompt) return options2.submit;
|
|
36862
|
-
await setSessionStatus("waiting");
|
|
36863
|
-
try {
|
|
36864
|
-
return await promptConfirm("Submit the pending review?", options2.submit);
|
|
36865
|
-
} finally {
|
|
36866
|
-
await setSessionStatus("running");
|
|
36867
|
-
}
|
|
36868
|
-
}
|
|
36869
|
-
async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
|
|
36870
|
-
const result = await postFindings(lineBound);
|
|
36871
|
-
const failedSuffix = result.failed > 0 ? `, ${result.failed} failed` : "";
|
|
36872
|
-
console.log(`Posted ${result.posted} comment(s)${failedSuffix}.`);
|
|
36873
|
-
const carried = carriedUnanchoredFindings(unanchored);
|
|
36874
|
-
if (result.posted === 0 && carried.length === 0 && !options2.ciFooter)
|
|
36875
|
-
return { posted: 0, submitted: false };
|
|
36876
|
-
const shouldSubmit = await decideSubmit(options2);
|
|
36877
|
-
if (shouldSubmit) {
|
|
36878
|
-
submitReview(
|
|
36879
|
-
buildReviewBody(markdown, unanchored, options2.ciFooter),
|
|
36880
|
-
result.posted
|
|
36881
|
-
);
|
|
36882
|
-
return { posted: result.posted, submitted: true };
|
|
36883
|
-
}
|
|
36884
|
-
console.log("Leaving the review unsubmitted.");
|
|
36885
|
-
return { posted: result.posted, submitted: false };
|
|
36886
|
-
}
|
|
36887
|
-
|
|
36888
|
-
// src/commands/review/stillOnReviewedPr.ts
|
|
36889
|
-
function currentPrNumber() {
|
|
36890
|
-
try {
|
|
36891
|
-
return findCurrentPrNumber();
|
|
36892
|
-
} catch (error) {
|
|
36893
|
-
console.error(
|
|
36894
|
-
`Error: could not confirm which PR this tree is on: ${error instanceof Error ? error.message : String(error)}`
|
|
36895
|
-
);
|
|
36896
|
-
return null;
|
|
36897
|
-
}
|
|
36898
|
-
}
|
|
36899
|
-
function stillOnReviewedPr(prNumber) {
|
|
36900
|
-
const current = currentPrNumber();
|
|
36901
|
-
if (current === prNumber) return true;
|
|
36902
|
-
console.error(
|
|
36903
|
-
`Error: this tree is now on ${current === null ? "a branch with no open PR" : `PR #${current}`}, not the reviewed PR #${prNumber}; skipping the post and any chained sessions.`
|
|
36904
|
-
);
|
|
36905
|
-
return false;
|
|
36906
|
-
}
|
|
36907
|
-
|
|
36908
|
-
// src/commands/review/submitNoFindingsReview.ts
|
|
36909
|
-
function submitNoFindingsReview(markdown, ciFooter) {
|
|
36910
|
-
const body = sanitiseReviewerNames(
|
|
36911
|
-
`${buildReviewSummary(markdown)}
|
|
36912
|
-
|
|
36913
|
-
No findings were raised.`
|
|
36914
|
-
);
|
|
36915
|
-
submitBodyOnlyReview(appendCiFooter(body, ciFooter));
|
|
36916
|
-
}
|
|
36917
|
-
|
|
36918
|
-
// src/commands/review/describeWork.ts
|
|
36919
|
-
function describeWork(comments3, carried) {
|
|
36920
|
-
const parts = [];
|
|
36921
|
-
if (comments3 > 0) parts.push(`${comments3} line comment(s)`);
|
|
36922
|
-
if (carried > 0) parts.push(`${carried} finding(s) in the review body`);
|
|
36923
|
-
return parts.join(" and ");
|
|
36924
|
-
}
|
|
36925
|
-
|
|
36926
|
-
// src/commands/review/postReviewToPr.ts
|
|
36927
|
-
var NOTHING_POSTED = { posted: 0, submitted: false };
|
|
36928
|
-
async function confirmPost(prNumber, work, options2) {
|
|
36929
|
-
if (!options2.prompt) return true;
|
|
36930
|
-
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
36931
|
-
}
|
|
36932
|
-
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
36933
|
-
const markdown = readFileSync52(synthesisPath, "utf8");
|
|
36934
|
-
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
36935
|
-
const carried = carriedUnanchoredFindings(unanchored);
|
|
36936
|
-
if (inDiff.length === 0 && carried.length === 0) {
|
|
36937
|
-
if (!options2.ciFooter) return NOTHING_POSTED;
|
|
36938
|
-
submitNoFindingsReview(markdown, options2.ciFooter);
|
|
36939
|
-
return { posted: 0, submitted: true };
|
|
36940
|
-
}
|
|
36941
|
-
const work = describeWork(inDiff.length, carried.length);
|
|
36942
|
-
console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
|
|
36943
|
-
const confirmed = await confirmPost(prInfo.prNumber, work, options2);
|
|
36944
|
-
if (!confirmed) {
|
|
36945
|
-
console.log("Skipped posting.");
|
|
36946
|
-
return NOTHING_POSTED;
|
|
36947
|
-
}
|
|
36948
|
-
return postAndMaybeSubmit(inDiff, unanchored, markdown, options2);
|
|
36949
|
-
}
|
|
36950
|
-
async function postReviewToPr(synthesisPath, prInfo, options2) {
|
|
36951
|
-
if (!stillOnReviewedPr(prInfo.prNumber)) return;
|
|
36952
|
-
const outcome = await postFindingsToPr(prInfo, synthesisPath, options2);
|
|
36953
|
-
await chainAfterReview(prInfo.prNumber, outcome, options2);
|
|
36780
|
+
// src/commands/review/submitFailedReview.ts
|
|
36781
|
+
function describeFailures(failures) {
|
|
36782
|
+
if (failures.length === 0) return "The review did not complete.";
|
|
36783
|
+
const steps = failures.map((f) => f.name.replace("-", " ")).join(" and ");
|
|
36784
|
+
return `The review did not complete: ${steps} failed.`;
|
|
36954
36785
|
}
|
|
36955
|
-
|
|
36956
|
-
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
|
|
36960
|
-
|
|
36961
|
-
|
|
36962
|
-
|
|
36963
|
-
- Severity: blocker | major | minor | nit
|
|
36964
|
-
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
36965
|
-
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
36966
|
-
- Impact: one sentence on what could go wrong
|
|
36967
|
-
- Recommendation: one or two sentences with a concrete change
|
|
36968
|
-
|
|
36969
|
-
For every finding whose Source is NOT \`already-raised\`, walk through it with the user one at a time:
|
|
36970
|
-
1. Read the referenced file/lines (use the Location field) and any nearby code needed to understand the impact.
|
|
36971
|
-
2. Present a short assessment (one or two sentences) of whether the finding is real and what the right fix is.
|
|
36972
|
-
3. Ask the user: apply or skip?
|
|
36973
|
-
- On 'apply': edit the relevant file(s) in place to fix the issue, then remove that finding's entire \`### Finding:\` block from ${synthesisPath} (including any blank line that separated it from the next block).
|
|
36974
|
-
- On 'skip': leave the finding block in ${synthesisPath} unchanged and move on.
|
|
36975
|
-
|
|
36976
|
-
Skip findings whose Source is \`already-raised\` entirely \u2014 do not present them and do not remove them from ${synthesisPath}.
|
|
36977
|
-
|
|
36978
|
-
Important constraints:
|
|
36979
|
-
- Do not stage, commit, or push any changes. Leave all code edits unstaged in the working tree.
|
|
36980
|
-
- Do not post anything to a PR.
|
|
36981
|
-
- Only modify ${synthesisPath} by removing the blocks for findings the user chose to apply. Do not edit the wording of any remaining finding block.
|
|
36982
|
-
- When every non-already-raised finding has been decided, briefly summarise what was applied vs skipped and exit.`;
|
|
36983
|
-
}
|
|
36984
|
-
async function runApplySession(synthesisPath) {
|
|
36985
|
-
const { done: done2 } = spawnClaude(buildApplyPrompt(synthesisPath), {
|
|
36986
|
-
allowEdits: true
|
|
36987
|
-
});
|
|
36988
|
-
await done2;
|
|
36989
|
-
}
|
|
36990
|
-
|
|
36991
|
-
// src/commands/review/runBacklogSession.ts
|
|
36992
|
-
function buildBacklogPrompt(synthesisPath) {
|
|
36993
|
-
return `/bug add each finding in ${synthesisPath} as a phase
|
|
36994
|
-
|
|
36995
|
-
Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading, each in a \`### Finding:\` block with Severity, Source, Location, Impact, and Recommendation fields.
|
|
36996
|
-
|
|
36997
|
-
File ONE bug backlog item covering the review findings:
|
|
36998
|
-
- Include EVERY finding in the file as a phase on that single item \u2014 including findings whose Source is \`already-raised\`.
|
|
36999
|
-
- Each phase should be named after its finding's title and its tasks should capture the finding's Location, Impact, and Recommendation.
|
|
37000
|
-
- File the item with \`assist backlog propose\`, then apply the whole plan with a single \`assist backlog update-plan <id> --json -\` call whose payload lists every finding as a phase. Do not run \`assist backlog add-phase\` per finding \u2014 the plan lands in one preview, or not at all.
|
|
37001
|
-
|
|
37002
|
-
Important constraints:
|
|
37003
|
-
- Do not edit ${synthesisPath} \u2014 leave it untouched.
|
|
37004
|
-
- Do not post anything to a PR.
|
|
37005
|
-
- Do not stage, commit, or push any changes.`;
|
|
37006
|
-
}
|
|
37007
|
-
async function runBacklogSession(synthesisPath) {
|
|
37008
|
-
const { done: done2 } = spawnClaude(buildBacklogPrompt(synthesisPath), {
|
|
37009
|
-
allowEdits: true
|
|
37010
|
-
});
|
|
37011
|
-
await done2;
|
|
37012
|
-
}
|
|
37013
|
-
|
|
37014
|
-
// src/commands/review/runRefineSession.ts
|
|
37015
|
-
function buildRefinePrompt(synthesisPath) {
|
|
37016
|
-
return `You are refining a code review synthesis with the user.
|
|
37017
|
-
|
|
37018
|
-
Read ${synthesisPath} and walk the user through each finding one at a time. Before asking the user what to do with a finding, do some investigation so you can give an informed opinion:
|
|
37019
|
-
- Read the referenced file/lines (use the Location field) to confirm the issue is real and current.
|
|
37020
|
-
- Check nearby code, callers, or related files when the impact depends on context.
|
|
37021
|
-
- Form a view on whether the finding is applicable, whether the stated severity is right, and whether the recommendation actually fixes the problem.
|
|
37022
|
-
|
|
37023
|
-
Then present your assessment briefly (one or two sentences) and ask the user whether to keep it as-is, edit it (e.g. adjust severity, sharpen the recommendation), or drop it. After all existing findings are reviewed, ask whether to add any new findings.
|
|
37024
|
-
|
|
37025
|
-
Edit ${synthesisPath} in place so the resulting file is the user's final list:
|
|
37026
|
-
- To drop a finding, remove its entire \`### Finding:\` block.
|
|
37027
|
-
- To edit a finding, modify only the fields the user wants changed.
|
|
37028
|
-
- To add a new finding, append a block in the exact format below under the \`## Findings\` heading.
|
|
37029
|
-
|
|
37030
|
-
Each finding block must use this exact format so it parses correctly:
|
|
37031
|
-
|
|
37032
|
-
### Finding: <short title>
|
|
37033
|
-
- Severity: blocker | major | minor | nit
|
|
37034
|
-
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
37035
|
-
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
37036
|
-
- Impact: one sentence on what could go wrong
|
|
37037
|
-
- Recommendation: one or two sentences with a concrete change
|
|
37038
|
-
|
|
37039
|
-
User-supplied findings should use Source: \`confirmed\`. Use Location \`n/a\` only when the finding is not tied to a specific line.
|
|
37040
|
-
|
|
37041
|
-
Do not post anything to a PR; only edit ${synthesisPath}. When the user is done, exit.`;
|
|
37042
|
-
}
|
|
37043
|
-
async function runRefineSession(synthesisPath) {
|
|
37044
|
-
const { done: done2 } = spawnClaude(buildRefinePrompt(synthesisPath), {
|
|
37045
|
-
allowEdits: true
|
|
37046
|
-
});
|
|
37047
|
-
await done2;
|
|
36786
|
+
function submitFailedReview(failures, ciFooter, runUrl) {
|
|
36787
|
+
const lines2 = [
|
|
36788
|
+
"## Code review failed",
|
|
36789
|
+
"",
|
|
36790
|
+
`${describeFailures(failures)} No findings were posted.`
|
|
36791
|
+
];
|
|
36792
|
+
if (runUrl) lines2.push("", `See the [workflow run](${runUrl}) for details.`);
|
|
36793
|
+
submitBodyOnlyReview(appendCiFooter(lines2.join("\n"), ciFooter));
|
|
37048
36794
|
}
|
|
37049
36795
|
|
|
37050
|
-
// src/commands/review/
|
|
37051
|
-
function
|
|
37052
|
-
|
|
37053
|
-
|
|
37054
|
-
|
|
37055
|
-
return null;
|
|
37056
|
-
}
|
|
37057
|
-
async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
37058
|
-
const session = nonPostingSession(options2);
|
|
37059
|
-
if (!session) {
|
|
37060
|
-
await postReviewToPr(synthesisPath, prInfo, {
|
|
37061
|
-
prompt: options2.prompt,
|
|
37062
|
-
submit: options2.submit,
|
|
37063
|
-
addressComments: options2.addressComments,
|
|
37064
|
-
announce: options2.announce,
|
|
37065
|
-
ciFooter: options2.ciFooter
|
|
37066
|
-
});
|
|
37067
|
-
return;
|
|
37068
|
-
}
|
|
37069
|
-
await session(synthesisPath);
|
|
37070
|
-
if (options2.announce) await announcePr(prInfo.prNumber);
|
|
36796
|
+
// src/commands/review/exitFailedCiReview.ts
|
|
36797
|
+
function exitFailedCiReview(failures, ci) {
|
|
36798
|
+
console.error("Review failed; no findings were posted.");
|
|
36799
|
+
submitFailedReview(failures, ci.footer, ci.runUrl);
|
|
36800
|
+
process.exit(1);
|
|
37071
36801
|
}
|
|
37072
36802
|
|
|
37073
36803
|
// src/commands/review/cachedReviewerResult.ts
|
|
@@ -37294,66 +37024,6 @@ function skippedCodexResult(outputPath) {
|
|
|
37294
37024
|
return { name: "codex", outputPath, exitCode: 0, stderr: "" };
|
|
37295
37025
|
}
|
|
37296
37026
|
|
|
37297
|
-
// src/commands/review/reviewerLabel.ts
|
|
37298
|
-
function reviewerLabel(name, model) {
|
|
37299
|
-
return model ? `${name} (${model})` : name;
|
|
37300
|
-
}
|
|
37301
|
-
|
|
37302
|
-
// src/commands/review/formatReviewerFailure.ts
|
|
37303
|
-
var FAST_FAIL_MS = 1e3;
|
|
37304
|
-
var STDOUT_TAIL_LINES = 20;
|
|
37305
|
-
function indent2(text18) {
|
|
37306
|
-
return text18.split(/\r?\n/).map((line) => ` ${line}`);
|
|
37307
|
-
}
|
|
37308
|
-
function tailLines(text18, maxLines) {
|
|
37309
|
-
const lines2 = text18.split(/\r?\n/);
|
|
37310
|
-
return lines2.length <= maxLines ? text18 : lines2.slice(-maxLines).join("\n");
|
|
37311
|
-
}
|
|
37312
|
-
function isFastFail(input) {
|
|
37313
|
-
return input.exitCode !== 0 && input.elapsedMs !== void 0 && input.elapsedMs < FAST_FAIL_MS;
|
|
37314
|
-
}
|
|
37315
|
-
function fastFailHint(command) {
|
|
37316
|
-
return [
|
|
37317
|
-
`${command} exited almost immediately \u2014 it likely failed to start.`,
|
|
37318
|
-
`Common causes: not installed on PATH, not authenticated, or misconfigured.`,
|
|
37319
|
-
`Try \`${command} --version\` to confirm install, then \`${command} login\` if authentication may be missing.`
|
|
37320
|
-
];
|
|
37321
|
-
}
|
|
37322
|
-
function outputDetail(input) {
|
|
37323
|
-
const stderr = input.stderr.trim();
|
|
37324
|
-
if (stderr) return ["stderr:", ...indent2(stderr)];
|
|
37325
|
-
const stdout = (input.stdout ?? "").trim();
|
|
37326
|
-
if (stdout) {
|
|
37327
|
-
return [
|
|
37328
|
-
`stdout (no stderr was captured \u2014 showing last ${STDOUT_TAIL_LINES} lines):`,
|
|
37329
|
-
...indent2(tailLines(stdout, STDOUT_TAIL_LINES))
|
|
37330
|
-
];
|
|
37331
|
-
}
|
|
37332
|
-
return [
|
|
37333
|
-
"No stderr or stdout was captured. Check the review folder for partial output, or rerun with --verbose for full streaming output."
|
|
37334
|
-
];
|
|
37335
|
-
}
|
|
37336
|
-
function formatReviewerFailure(input) {
|
|
37337
|
-
const command = input.command ?? input.name;
|
|
37338
|
-
const seconds = Math.round((input.elapsedMs ?? 0) / 1e3);
|
|
37339
|
-
const headerLine = `${reviewerLabel(command, input.model)} CLI exited with code ${input.exitCode} after ${seconds}s`;
|
|
37340
|
-
const detailLines = [];
|
|
37341
|
-
if (isFastFail(input)) detailLines.push(...fastFailHint(command));
|
|
37342
|
-
detailLines.push(...outputDetail(input));
|
|
37343
|
-
return { headerLine, detailLines };
|
|
37344
|
-
}
|
|
37345
|
-
function printReviewerFailure(input) {
|
|
37346
|
-
if (input.exitCode === 0) return;
|
|
37347
|
-
const diagnostic = formatReviewerFailure(input);
|
|
37348
|
-
console.error(`[${input.name}] ${diagnostic.headerLine}`);
|
|
37349
|
-
for (const line of diagnostic.detailLines) console.error(line);
|
|
37350
|
-
}
|
|
37351
|
-
|
|
37352
|
-
// src/commands/review/printReviewerFailures.ts
|
|
37353
|
-
function printReviewerFailures(results) {
|
|
37354
|
-
for (const r of results) printReviewerFailure(r);
|
|
37355
|
-
}
|
|
37356
|
-
|
|
37357
37027
|
// src/commands/review/runAndSynthesise.ts
|
|
37358
37028
|
import { existsSync as existsSync68, unlinkSync as unlinkSync19 } from "fs";
|
|
37359
37029
|
|
|
@@ -37442,6 +37112,11 @@ The review request is at: ${requestPath}
|
|
|
37442
37112
|
`;
|
|
37443
37113
|
}
|
|
37444
37114
|
|
|
37115
|
+
// src/commands/review/reviewerLabel.ts
|
|
37116
|
+
function reviewerLabel(name, model) {
|
|
37117
|
+
return model ? `${name} (${model})` : name;
|
|
37118
|
+
}
|
|
37119
|
+
|
|
37445
37120
|
// src/commands/review/buildCodexModelArgs.ts
|
|
37446
37121
|
function buildCodexModelArgs() {
|
|
37447
37122
|
return buildLitellmCodexArgs(loadConfig().review?.codexModel);
|
|
@@ -37628,6 +37303,56 @@ function attachStdoutTail(child, maxBytes = 8192) {
|
|
|
37628
37303
|
return state;
|
|
37629
37304
|
}
|
|
37630
37305
|
|
|
37306
|
+
// src/commands/review/formatReviewerFailure.ts
|
|
37307
|
+
var FAST_FAIL_MS = 1e3;
|
|
37308
|
+
var STDOUT_TAIL_LINES = 20;
|
|
37309
|
+
function indent2(text18) {
|
|
37310
|
+
return text18.split(/\r?\n/).map((line) => ` ${line}`);
|
|
37311
|
+
}
|
|
37312
|
+
function tailLines(text18, maxLines) {
|
|
37313
|
+
const lines2 = text18.split(/\r?\n/);
|
|
37314
|
+
return lines2.length <= maxLines ? text18 : lines2.slice(-maxLines).join("\n");
|
|
37315
|
+
}
|
|
37316
|
+
function isFastFail(input) {
|
|
37317
|
+
return input.exitCode !== 0 && input.elapsedMs !== void 0 && input.elapsedMs < FAST_FAIL_MS;
|
|
37318
|
+
}
|
|
37319
|
+
function fastFailHint(command) {
|
|
37320
|
+
return [
|
|
37321
|
+
`${command} exited almost immediately \u2014 it likely failed to start.`,
|
|
37322
|
+
`Common causes: not installed on PATH, not authenticated, or misconfigured.`,
|
|
37323
|
+
`Try \`${command} --version\` to confirm install, then \`${command} login\` if authentication may be missing.`
|
|
37324
|
+
];
|
|
37325
|
+
}
|
|
37326
|
+
function outputDetail(input) {
|
|
37327
|
+
const stderr = input.stderr.trim();
|
|
37328
|
+
if (stderr) return ["stderr:", ...indent2(stderr)];
|
|
37329
|
+
const stdout = (input.stdout ?? "").trim();
|
|
37330
|
+
if (stdout) {
|
|
37331
|
+
return [
|
|
37332
|
+
`stdout (no stderr was captured \u2014 showing last ${STDOUT_TAIL_LINES} lines):`,
|
|
37333
|
+
...indent2(tailLines(stdout, STDOUT_TAIL_LINES))
|
|
37334
|
+
];
|
|
37335
|
+
}
|
|
37336
|
+
return [
|
|
37337
|
+
"No stderr or stdout was captured. Check the review folder for partial output, or rerun with --verbose for full streaming output."
|
|
37338
|
+
];
|
|
37339
|
+
}
|
|
37340
|
+
function formatReviewerFailure(input) {
|
|
37341
|
+
const command = input.command ?? input.name;
|
|
37342
|
+
const seconds = Math.round((input.elapsedMs ?? 0) / 1e3);
|
|
37343
|
+
const headerLine = `${reviewerLabel(command, input.model)} CLI exited with code ${input.exitCode} after ${seconds}s`;
|
|
37344
|
+
const detailLines = [];
|
|
37345
|
+
if (isFastFail(input)) detailLines.push(...fastFailHint(command));
|
|
37346
|
+
detailLines.push(...outputDetail(input));
|
|
37347
|
+
return { headerLine, detailLines };
|
|
37348
|
+
}
|
|
37349
|
+
function printReviewerFailure(input) {
|
|
37350
|
+
if (input.exitCode === 0) return;
|
|
37351
|
+
const diagnostic = formatReviewerFailure(input);
|
|
37352
|
+
console.error(`[${input.name}] ${diagnostic.headerLine}`);
|
|
37353
|
+
for (const line of diagnostic.detailLines) console.error(line);
|
|
37354
|
+
}
|
|
37355
|
+
|
|
37631
37356
|
// src/commands/review/logChildClose.ts
|
|
37632
37357
|
function logChildClose(args) {
|
|
37633
37358
|
const elapsedSeconds = Math.round(args.elapsedMs / 1e3);
|
|
@@ -37952,7 +37677,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
37952
37677
|
}
|
|
37953
37678
|
|
|
37954
37679
|
// src/commands/review/synthesise.ts
|
|
37955
|
-
import { readFileSync as
|
|
37680
|
+
import { readFileSync as readFileSync52 } from "fs";
|
|
37956
37681
|
|
|
37957
37682
|
// src/commands/review/buildSynthesisStdin.ts
|
|
37958
37683
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -38021,7 +37746,7 @@ Files:
|
|
|
38021
37746
|
|
|
38022
37747
|
// src/commands/review/synthesise.ts
|
|
38023
37748
|
function printSummary2(synthesisPath) {
|
|
38024
|
-
const markdown =
|
|
37749
|
+
const markdown = readFileSync52(synthesisPath, "utf8");
|
|
38025
37750
|
console.log("");
|
|
38026
37751
|
console.log(buildReviewSummary(markdown));
|
|
38027
37752
|
console.log("");
|
|
@@ -38103,6 +37828,18 @@ function useSpinnerUi(verbose) {
|
|
|
38103
37828
|
return Boolean(process.stdout.isTTY);
|
|
38104
37829
|
}
|
|
38105
37830
|
|
|
37831
|
+
// src/commands/review/printReviewerFailures.ts
|
|
37832
|
+
function printReviewerFailures(results) {
|
|
37833
|
+
for (const r of results) printReviewerFailure(r);
|
|
37834
|
+
}
|
|
37835
|
+
|
|
37836
|
+
// src/commands/review/reportFailures.ts
|
|
37837
|
+
function reportFailures(failures, usingSpinner) {
|
|
37838
|
+
if (failures.length === 0) return;
|
|
37839
|
+
if (!usingSpinner) return;
|
|
37840
|
+
printReviewerFailures(failures);
|
|
37841
|
+
}
|
|
37842
|
+
|
|
38106
37843
|
// src/commands/review/runReviewPipeline.ts
|
|
38107
37844
|
function createUi(spinnerUi) {
|
|
38108
37845
|
const startedAt = Date.now();
|
|
@@ -38117,11 +37854,6 @@ function finishUi(ui, ok) {
|
|
|
38117
37854
|
if (ok) ui.elapsed.succeed(label2);
|
|
38118
37855
|
else ui.elapsed.fail(label2);
|
|
38119
37856
|
}
|
|
38120
|
-
function reportFailures(failures, usingSpinner) {
|
|
38121
|
-
if (failures.length === 0) return;
|
|
38122
|
-
if (!usingSpinner) return;
|
|
38123
|
-
printReviewerFailures(failures);
|
|
38124
|
-
}
|
|
38125
37857
|
async function runReviewPipeline(paths, options2) {
|
|
38126
37858
|
const cachedClaude = cachedReviewerResult("claude", paths.claudePath);
|
|
38127
37859
|
const codexPlan = await planCodexReviewer(
|
|
@@ -38140,7 +37872,7 @@ async function runReviewPipeline(paths, options2) {
|
|
|
38140
37872
|
});
|
|
38141
37873
|
finishUi(ui, outcome.ok);
|
|
38142
37874
|
reportFailures(outcome.failures, ui.multi !== void 0);
|
|
38143
|
-
return outcome
|
|
37875
|
+
return outcome;
|
|
38144
37876
|
} catch (error) {
|
|
38145
37877
|
ui.multi?.failRemaining();
|
|
38146
37878
|
throw error;
|
|
@@ -38438,7 +38170,300 @@ function gatherChangedContext() {
|
|
|
38438
38170
|
process.exit(1);
|
|
38439
38171
|
}
|
|
38440
38172
|
|
|
38441
|
-
// src/commands/review/
|
|
38173
|
+
// src/commands/review/postReviewToPr.ts
|
|
38174
|
+
import { readFileSync as readFileSync53 } from "fs";
|
|
38175
|
+
|
|
38176
|
+
// src/commands/review/chainAddressComments.ts
|
|
38177
|
+
function chainAddressComments(prNumber, announce) {
|
|
38178
|
+
const args = ["review-pr-comments", String(prNumber)];
|
|
38179
|
+
if (announce) args.push("--announce");
|
|
38180
|
+
return startChainedSession(
|
|
38181
|
+
`an Address Comments session for PR #${prNumber}`,
|
|
38182
|
+
() => requestAssistSession(args, process.cwd(), { inPlace: true })
|
|
38183
|
+
);
|
|
38184
|
+
}
|
|
38185
|
+
|
|
38186
|
+
// src/commands/review/chainAfterReview.ts
|
|
38187
|
+
async function chainAfterReview(prNumber, outcome, options2) {
|
|
38188
|
+
const raisedComments = outcome.posted > 0 && outcome.submitted;
|
|
38189
|
+
if (options2.addressComments && raisedComments) {
|
|
38190
|
+
await chainAddressComments(prNumber, options2.announce);
|
|
38191
|
+
return;
|
|
38192
|
+
}
|
|
38193
|
+
if (options2.announce) await announcePr(prNumber);
|
|
38194
|
+
}
|
|
38195
|
+
|
|
38196
|
+
// src/commands/review/sanitiseReviewerNames.ts
|
|
38197
|
+
var REVIEWER_LABEL = "the reviewer";
|
|
38198
|
+
function sanitiseReviewerNames(value) {
|
|
38199
|
+
return value.replace(/\bclaude\b/gi, REVIEWER_LABEL).replace(/\bopus\b/gi, REVIEWER_LABEL);
|
|
38200
|
+
}
|
|
38201
|
+
|
|
38202
|
+
// src/commands/review/postFindings.ts
|
|
38203
|
+
function buildCommentBody(finding) {
|
|
38204
|
+
const lines2 = [];
|
|
38205
|
+
const severityLabel = finding.severity ?? "finding";
|
|
38206
|
+
lines2.push(`**${severityLabel}: ${finding.title}**`);
|
|
38207
|
+
if (finding.impact) lines2.push("", `Impact: ${finding.impact}`);
|
|
38208
|
+
if (finding.recommendation)
|
|
38209
|
+
lines2.push("", `Recommendation: ${finding.recommendation}`);
|
|
38210
|
+
return sanitiseReviewerNames(lines2.join("\n"));
|
|
38211
|
+
}
|
|
38212
|
+
async function postFindings(findings) {
|
|
38213
|
+
let posted = 0;
|
|
38214
|
+
let failed3 = 0;
|
|
38215
|
+
for (const finding of findings) {
|
|
38216
|
+
const body = buildCommentBody(finding);
|
|
38217
|
+
try {
|
|
38218
|
+
await comment2(finding.file, finding.line, body, {
|
|
38219
|
+
startLine: finding.startLine,
|
|
38220
|
+
skipPreview: true
|
|
38221
|
+
});
|
|
38222
|
+
posted++;
|
|
38223
|
+
} catch (error) {
|
|
38224
|
+
failed3++;
|
|
38225
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
38226
|
+
console.error(
|
|
38227
|
+
`Failed to post comment on ${finding.file}:${finding.line}: ${message3}`
|
|
38228
|
+
);
|
|
38229
|
+
}
|
|
38230
|
+
}
|
|
38231
|
+
return { posted, failed: failed3 };
|
|
38232
|
+
}
|
|
38233
|
+
|
|
38234
|
+
// src/commands/review/submitPendingReview.ts
|
|
38235
|
+
var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
|
|
38236
|
+
function submitPendingReview(body) {
|
|
38237
|
+
runReviewSubmission(MUTATION7, body);
|
|
38238
|
+
}
|
|
38239
|
+
|
|
38240
|
+
// src/commands/review/buildReviewBody.ts
|
|
38241
|
+
function buildReviewBody(markdown, unanchored, ciFooter) {
|
|
38242
|
+
return appendCiFooter(
|
|
38243
|
+
sanitiseReviewerNames(buildReviewSummary(markdown, unanchored)),
|
|
38244
|
+
ciFooter
|
|
38245
|
+
);
|
|
38246
|
+
}
|
|
38247
|
+
|
|
38248
|
+
// src/commands/review/postAndMaybeSubmit.ts
|
|
38249
|
+
function submitReview(body, posted) {
|
|
38250
|
+
if (posted > 0) submitPendingReview(body);
|
|
38251
|
+
else submitBodyOnlyReview(body);
|
|
38252
|
+
}
|
|
38253
|
+
async function decideSubmit(options2) {
|
|
38254
|
+
if (!options2.prompt) return options2.submit;
|
|
38255
|
+
await setSessionStatus("waiting");
|
|
38256
|
+
try {
|
|
38257
|
+
return await promptConfirm("Submit the pending review?", options2.submit);
|
|
38258
|
+
} finally {
|
|
38259
|
+
await setSessionStatus("running");
|
|
38260
|
+
}
|
|
38261
|
+
}
|
|
38262
|
+
async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
|
|
38263
|
+
const result = await postFindings(lineBound);
|
|
38264
|
+
const failedSuffix = result.failed > 0 ? `, ${result.failed} failed` : "";
|
|
38265
|
+
console.log(`Posted ${result.posted} comment(s)${failedSuffix}.`);
|
|
38266
|
+
const carried = carriedUnanchoredFindings(unanchored);
|
|
38267
|
+
if (result.posted === 0 && carried.length === 0 && !options2.ciFooter)
|
|
38268
|
+
return { posted: 0, submitted: false };
|
|
38269
|
+
const shouldSubmit = await decideSubmit(options2);
|
|
38270
|
+
if (shouldSubmit) {
|
|
38271
|
+
submitReview(
|
|
38272
|
+
buildReviewBody(markdown, unanchored, options2.ciFooter),
|
|
38273
|
+
result.posted
|
|
38274
|
+
);
|
|
38275
|
+
return { posted: result.posted, submitted: true };
|
|
38276
|
+
}
|
|
38277
|
+
console.log("Leaving the review unsubmitted.");
|
|
38278
|
+
return { posted: result.posted, submitted: false };
|
|
38279
|
+
}
|
|
38280
|
+
|
|
38281
|
+
// src/commands/review/stillOnReviewedPr.ts
|
|
38282
|
+
function currentPrNumber() {
|
|
38283
|
+
try {
|
|
38284
|
+
return findCurrentPrNumber();
|
|
38285
|
+
} catch (error) {
|
|
38286
|
+
console.error(
|
|
38287
|
+
`Error: could not confirm which PR this tree is on: ${error instanceof Error ? error.message : String(error)}`
|
|
38288
|
+
);
|
|
38289
|
+
return null;
|
|
38290
|
+
}
|
|
38291
|
+
}
|
|
38292
|
+
function stillOnReviewedPr(prNumber) {
|
|
38293
|
+
const current = currentPrNumber();
|
|
38294
|
+
if (current === prNumber) return true;
|
|
38295
|
+
console.error(
|
|
38296
|
+
`Error: this tree is now on ${current === null ? "a branch with no open PR" : `PR #${current}`}, not the reviewed PR #${prNumber}; skipping the post and any chained sessions.`
|
|
38297
|
+
);
|
|
38298
|
+
return false;
|
|
38299
|
+
}
|
|
38300
|
+
|
|
38301
|
+
// src/commands/review/submitNoFindingsReview.ts
|
|
38302
|
+
function submitNoFindingsReview(markdown, ciFooter) {
|
|
38303
|
+
const body = sanitiseReviewerNames(
|
|
38304
|
+
`${buildReviewSummary(markdown)}
|
|
38305
|
+
|
|
38306
|
+
No findings were raised.`
|
|
38307
|
+
);
|
|
38308
|
+
submitBodyOnlyReview(appendCiFooter(body, ciFooter));
|
|
38309
|
+
}
|
|
38310
|
+
|
|
38311
|
+
// src/commands/review/describeWork.ts
|
|
38312
|
+
function describeWork(comments3, carried) {
|
|
38313
|
+
const parts = [];
|
|
38314
|
+
if (comments3 > 0) parts.push(`${comments3} line comment(s)`);
|
|
38315
|
+
if (carried > 0) parts.push(`${carried} finding(s) in the review body`);
|
|
38316
|
+
return parts.join(" and ");
|
|
38317
|
+
}
|
|
38318
|
+
|
|
38319
|
+
// src/commands/review/postReviewToPr.ts
|
|
38320
|
+
var NOTHING_POSTED = { posted: 0, submitted: false };
|
|
38321
|
+
async function confirmPost(prNumber, work, options2) {
|
|
38322
|
+
if (!options2.prompt) return true;
|
|
38323
|
+
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
38324
|
+
}
|
|
38325
|
+
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
38326
|
+
const markdown = readFileSync53(synthesisPath, "utf8");
|
|
38327
|
+
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
38328
|
+
const carried = carriedUnanchoredFindings(unanchored);
|
|
38329
|
+
if (inDiff.length === 0 && carried.length === 0) {
|
|
38330
|
+
if (!options2.ciFooter) return NOTHING_POSTED;
|
|
38331
|
+
submitNoFindingsReview(markdown, options2.ciFooter);
|
|
38332
|
+
return { posted: 0, submitted: true };
|
|
38333
|
+
}
|
|
38334
|
+
const work = describeWork(inDiff.length, carried.length);
|
|
38335
|
+
console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
|
|
38336
|
+
const confirmed = await confirmPost(prInfo.prNumber, work, options2);
|
|
38337
|
+
if (!confirmed) {
|
|
38338
|
+
console.log("Skipped posting.");
|
|
38339
|
+
return NOTHING_POSTED;
|
|
38340
|
+
}
|
|
38341
|
+
return postAndMaybeSubmit(inDiff, unanchored, markdown, options2);
|
|
38342
|
+
}
|
|
38343
|
+
async function postReviewToPr(synthesisPath, prInfo, options2) {
|
|
38344
|
+
if (!stillOnReviewedPr(prInfo.prNumber)) return;
|
|
38345
|
+
const outcome = await postFindingsToPr(prInfo, synthesisPath, options2);
|
|
38346
|
+
await chainAfterReview(prInfo.prNumber, outcome, options2);
|
|
38347
|
+
}
|
|
38348
|
+
|
|
38349
|
+
// src/commands/review/runApplySession.ts
|
|
38350
|
+
function buildApplyPrompt(synthesisPath) {
|
|
38351
|
+
return `You are helping the user apply fixes for a code review with each finding decided one at a time.
|
|
38352
|
+
|
|
38353
|
+
Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading. Each finding is a block in this exact format:
|
|
38354
|
+
|
|
38355
|
+
### Finding: <short title>
|
|
38356
|
+
- Severity: blocker | major | minor | nit
|
|
38357
|
+
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
38358
|
+
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
38359
|
+
- Impact: one sentence on what could go wrong
|
|
38360
|
+
- Recommendation: one or two sentences with a concrete change
|
|
38361
|
+
|
|
38362
|
+
For every finding whose Source is NOT \`already-raised\`, walk through it with the user one at a time:
|
|
38363
|
+
1. Read the referenced file/lines (use the Location field) and any nearby code needed to understand the impact.
|
|
38364
|
+
2. Present a short assessment (one or two sentences) of whether the finding is real and what the right fix is.
|
|
38365
|
+
3. Ask the user: apply or skip?
|
|
38366
|
+
- On 'apply': edit the relevant file(s) in place to fix the issue, then remove that finding's entire \`### Finding:\` block from ${synthesisPath} (including any blank line that separated it from the next block).
|
|
38367
|
+
- On 'skip': leave the finding block in ${synthesisPath} unchanged and move on.
|
|
38368
|
+
|
|
38369
|
+
Skip findings whose Source is \`already-raised\` entirely \u2014 do not present them and do not remove them from ${synthesisPath}.
|
|
38370
|
+
|
|
38371
|
+
Important constraints:
|
|
38372
|
+
- Do not stage, commit, or push any changes. Leave all code edits unstaged in the working tree.
|
|
38373
|
+
- Do not post anything to a PR.
|
|
38374
|
+
- Only modify ${synthesisPath} by removing the blocks for findings the user chose to apply. Do not edit the wording of any remaining finding block.
|
|
38375
|
+
- When every non-already-raised finding has been decided, briefly summarise what was applied vs skipped and exit.`;
|
|
38376
|
+
}
|
|
38377
|
+
async function runApplySession(synthesisPath) {
|
|
38378
|
+
const { done: done2 } = spawnClaude(buildApplyPrompt(synthesisPath), {
|
|
38379
|
+
allowEdits: true
|
|
38380
|
+
});
|
|
38381
|
+
await done2;
|
|
38382
|
+
}
|
|
38383
|
+
|
|
38384
|
+
// src/commands/review/runBacklogSession.ts
|
|
38385
|
+
function buildBacklogPrompt(synthesisPath) {
|
|
38386
|
+
return `/bug add each finding in ${synthesisPath} as a phase
|
|
38387
|
+
|
|
38388
|
+
Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading, each in a \`### Finding:\` block with Severity, Source, Location, Impact, and Recommendation fields.
|
|
38389
|
+
|
|
38390
|
+
File ONE bug backlog item covering the review findings:
|
|
38391
|
+
- Include EVERY finding in the file as a phase on that single item \u2014 including findings whose Source is \`already-raised\`.
|
|
38392
|
+
- Each phase should be named after its finding's title and its tasks should capture the finding's Location, Impact, and Recommendation.
|
|
38393
|
+
- File the item with \`assist backlog propose\`, then apply the whole plan with a single \`assist backlog update-plan <id> --json -\` call whose payload lists every finding as a phase. Do not run \`assist backlog add-phase\` per finding \u2014 the plan lands in one preview, or not at all.
|
|
38394
|
+
|
|
38395
|
+
Important constraints:
|
|
38396
|
+
- Do not edit ${synthesisPath} \u2014 leave it untouched.
|
|
38397
|
+
- Do not post anything to a PR.
|
|
38398
|
+
- Do not stage, commit, or push any changes.`;
|
|
38399
|
+
}
|
|
38400
|
+
async function runBacklogSession(synthesisPath) {
|
|
38401
|
+
const { done: done2 } = spawnClaude(buildBacklogPrompt(synthesisPath), {
|
|
38402
|
+
allowEdits: true
|
|
38403
|
+
});
|
|
38404
|
+
await done2;
|
|
38405
|
+
}
|
|
38406
|
+
|
|
38407
|
+
// src/commands/review/runRefineSession.ts
|
|
38408
|
+
function buildRefinePrompt(synthesisPath) {
|
|
38409
|
+
return `You are refining a code review synthesis with the user.
|
|
38410
|
+
|
|
38411
|
+
Read ${synthesisPath} and walk the user through each finding one at a time. Before asking the user what to do with a finding, do some investigation so you can give an informed opinion:
|
|
38412
|
+
- Read the referenced file/lines (use the Location field) to confirm the issue is real and current.
|
|
38413
|
+
- Check nearby code, callers, or related files when the impact depends on context.
|
|
38414
|
+
- Form a view on whether the finding is applicable, whether the stated severity is right, and whether the recommendation actually fixes the problem.
|
|
38415
|
+
|
|
38416
|
+
Then present your assessment briefly (one or two sentences) and ask the user whether to keep it as-is, edit it (e.g. adjust severity, sharpen the recommendation), or drop it. After all existing findings are reviewed, ask whether to add any new findings.
|
|
38417
|
+
|
|
38418
|
+
Edit ${synthesisPath} in place so the resulting file is the user's final list:
|
|
38419
|
+
- To drop a finding, remove its entire \`### Finding:\` block.
|
|
38420
|
+
- To edit a finding, modify only the fields the user wants changed.
|
|
38421
|
+
- To add a new finding, append a block in the exact format below under the \`## Findings\` heading.
|
|
38422
|
+
|
|
38423
|
+
Each finding block must use this exact format so it parses correctly:
|
|
38424
|
+
|
|
38425
|
+
### Finding: <short title>
|
|
38426
|
+
- Severity: blocker | major | minor | nit
|
|
38427
|
+
- Source: confirmed | disputed | claude-only | codex-only | already-raised
|
|
38428
|
+
- Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
|
|
38429
|
+
- Impact: one sentence on what could go wrong
|
|
38430
|
+
- Recommendation: one or two sentences with a concrete change
|
|
38431
|
+
|
|
38432
|
+
User-supplied findings should use Source: \`confirmed\`. Use Location \`n/a\` only when the finding is not tied to a specific line.
|
|
38433
|
+
|
|
38434
|
+
Do not post anything to a PR; only edit ${synthesisPath}. When the user is done, exit.`;
|
|
38435
|
+
}
|
|
38436
|
+
async function runRefineSession(synthesisPath) {
|
|
38437
|
+
const { done: done2 } = spawnClaude(buildRefinePrompt(synthesisPath), {
|
|
38438
|
+
allowEdits: true
|
|
38439
|
+
});
|
|
38440
|
+
await done2;
|
|
38441
|
+
}
|
|
38442
|
+
|
|
38443
|
+
// src/commands/review/handlePostSynthesis.ts
|
|
38444
|
+
function nonPostingSession(options2) {
|
|
38445
|
+
if (options2.backlog) return runBacklogSession;
|
|
38446
|
+
if (options2.apply) return runApplySession;
|
|
38447
|
+
if (options2.refine) return runRefineSession;
|
|
38448
|
+
return null;
|
|
38449
|
+
}
|
|
38450
|
+
async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
38451
|
+
const session = nonPostingSession(options2);
|
|
38452
|
+
if (!session) {
|
|
38453
|
+
await postReviewToPr(synthesisPath, prInfo, {
|
|
38454
|
+
prompt: options2.prompt,
|
|
38455
|
+
submit: options2.submit,
|
|
38456
|
+
addressComments: options2.addressComments,
|
|
38457
|
+
announce: options2.announce,
|
|
38458
|
+
ciFooter: options2.ciFooter
|
|
38459
|
+
});
|
|
38460
|
+
return;
|
|
38461
|
+
}
|
|
38462
|
+
await session(synthesisPath);
|
|
38463
|
+
if (options2.announce) await announcePr(prInfo.prNumber);
|
|
38464
|
+
}
|
|
38465
|
+
|
|
38466
|
+
// src/commands/review/runPostSynthesis.ts
|
|
38442
38467
|
function runPostSynthesis(synthesisPath, prInfo, options2) {
|
|
38443
38468
|
return handlePostSynthesis(synthesisPath, prInfo, {
|
|
38444
38469
|
refine: options2.refine ?? false,
|
|
@@ -38451,19 +38476,20 @@ function runPostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
38451
38476
|
ciFooter: options2.ci?.footer
|
|
38452
38477
|
});
|
|
38453
38478
|
}
|
|
38479
|
+
|
|
38480
|
+
// src/commands/review/reviewPr.ts
|
|
38454
38481
|
async function reviewPr(repoRoot2, options2) {
|
|
38455
38482
|
const context = gatherChangedContext();
|
|
38456
38483
|
const paths = setupReviewDir(repoRoot2, context, options2.force ?? false);
|
|
38457
38484
|
attachReviewLog(paths.reviewDir);
|
|
38458
|
-
const
|
|
38485
|
+
const outcome = await runReviewPipeline(paths, {
|
|
38459
38486
|
verbose: options2.verbose ?? false,
|
|
38460
38487
|
models: options2.ci?.models,
|
|
38461
38488
|
strict: options2.ci !== void 0
|
|
38462
38489
|
});
|
|
38463
|
-
|
|
38464
|
-
|
|
38465
|
-
|
|
38466
|
-
}
|
|
38490
|
+
const synthesisOk = outcome.ok;
|
|
38491
|
+
if (!synthesisOk && options2.ci)
|
|
38492
|
+
exitFailedCiReview(outcome.failures, options2.ci);
|
|
38467
38493
|
if (synthesisOk && options2.ci)
|
|
38468
38494
|
writeJobSummary(paths.synthesisPath, context, options2.ci.summaryPath);
|
|
38469
38495
|
if (synthesisOk)
|