@mrclrchtr/supi-review 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-html-sql.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +5 -5
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/package.json +3 -3
- package/src/git.ts +23 -11
- package/src/review-input.ts +53 -6
- package/src/review-limits.ts +6 -0
- package/src/review-result.ts +24 -3
- package/src/review.ts +29 -2
- package/src/target/packet.ts +59 -21
- package/src/target/resolve.ts +75 -0
- package/src/target/snapshot-match.ts +37 -0
- package/src/tool/agent-review-schemas.ts +46 -4
- package/src/tool/agent-review-tools.ts +33 -12
- package/src/tool/child-session-runner.ts +4 -0
- package/src/tool/criteria-only-scope.ts +31 -0
- package/src/tool/output-page.ts +13 -0
- package/src/tool/planner-runner.ts +3 -2
- package/src/tool/review-audit-tool.ts +2 -12
- package/src/tool/review-debug-summary.ts +64 -0
- package/src/tool/review-execution.ts +22 -0
- package/src/tool/review-format.ts +19 -11
- package/src/tool/review-output-tool.ts +8 -15
- package/src/tool/review-runner.ts +9 -1
- package/src/tool/review-system-prompt.ts +7 -3
- package/src/tool/review-workflow.ts +35 -32
- package/src/tool/schemas.ts +52 -2
- package/src/tool/session-lifecycle.ts +1 -0
- package/src/tui/common.ts +22 -0
- package/src/tui/prepare.ts +31 -12
- package/src/tui/run.ts +39 -11
- package/src/types.ts +35 -6
- package/src/workspace/review-workspace.ts +36 -7
package/src/tui/run.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
} from "../tool/review-execution.ts";
|
|
13
13
|
import { formatReviewUsage } from "../tool/usage-format.ts";
|
|
14
14
|
import type {
|
|
15
|
-
|
|
15
|
+
EffectiveFindingScope,
|
|
16
16
|
ReviewBatchDetails,
|
|
17
17
|
ReviewProgress,
|
|
18
18
|
ReviewTaskResult,
|
|
@@ -28,12 +28,17 @@ import {
|
|
|
28
28
|
|
|
29
29
|
// ── Helpers ──────────────────────────────────────────────────────
|
|
30
30
|
|
|
31
|
-
function findingScope(details: ReviewBatchDetails, taskId: string):
|
|
31
|
+
function findingScope(details: ReviewBatchDetails, taskId: string): EffectiveFindingScope {
|
|
32
|
+
if (details.snapshot.target.kind === "current-state") return "criteria-only";
|
|
32
33
|
return details.review.tasks.find((task) => task.id === taskId)?.findingScope ?? "change-only";
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
/** Format one task without collapsing independent verdicts into a batch verdict. */
|
|
36
|
-
function formatTaskCollapsed(
|
|
37
|
+
function formatTaskCollapsed(
|
|
38
|
+
result: ReviewTaskResult,
|
|
39
|
+
scope: EffectiveFindingScope,
|
|
40
|
+
theme: Theme,
|
|
41
|
+
): string {
|
|
37
42
|
const warnings = result.capabilityWarnings?.length ?? 0;
|
|
38
43
|
const warningLabel =
|
|
39
44
|
warnings > 0 ? ` · ${warnings} capability warning${warnings === 1 ? "" : "s"}` : "";
|
|
@@ -54,7 +59,14 @@ function formatTaskCollapsed(result: ReviewTaskResult, scope: FindingScope, them
|
|
|
54
59
|
|
|
55
60
|
export function renderRunCall(args: unknown, theme: Theme): Text {
|
|
56
61
|
const params = (args ?? {}) as {
|
|
57
|
-
direct?: {
|
|
62
|
+
direct?: {
|
|
63
|
+
target?: {
|
|
64
|
+
workingTree?: unknown;
|
|
65
|
+
comparison?: unknown;
|
|
66
|
+
commit?: unknown;
|
|
67
|
+
currentState?: unknown;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
58
70
|
prepared?: unknown;
|
|
59
71
|
};
|
|
60
72
|
const target = params.direct?.target;
|
|
@@ -64,7 +76,9 @@ export function renderRunCall(args: unknown, theme: Theme): Text {
|
|
|
64
76
|
? "comparison"
|
|
65
77
|
: target?.commit
|
|
66
78
|
? "commit"
|
|
67
|
-
:
|
|
79
|
+
: target?.currentState
|
|
80
|
+
? "current-state"
|
|
81
|
+
: "working-tree";
|
|
68
82
|
|
|
69
83
|
return renderReviewToolCall(
|
|
70
84
|
"supi_review_run",
|
|
@@ -202,11 +216,17 @@ function buildCollapsed(details: ReviewBatchDetails, theme: Theme): Text {
|
|
|
202
216
|
const tasks = details.results
|
|
203
217
|
.map((result) => formatTaskCollapsed(result, findingScope(details, result.taskId), theme))
|
|
204
218
|
.join(` ${theme.fg("dim", "·")} `);
|
|
219
|
+
const currentStateTarget =
|
|
220
|
+
details.snapshot.requestedTarget.kind === "current-state"
|
|
221
|
+
? details.snapshot.requestedTarget
|
|
222
|
+
: undefined;
|
|
205
223
|
const { additions, deletions, files } = details.snapshot.stats;
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
224
|
+
const targetDetail = currentStateTarget
|
|
225
|
+
? currentStateTarget.paths?.length
|
|
226
|
+
? `${currentStateTarget.paths.length} focus path${currentStateTarget.paths.length === 1 ? "" : "s"}`
|
|
227
|
+
: "repository-wide"
|
|
228
|
+
: `${files} file${files !== 1 ? "s" : ""} · +${additions.toLocaleString("en-US")} / -${deletions.toLocaleString("en-US")}`;
|
|
229
|
+
const target = theme.fg("dim", `${details.snapshot.title} (${targetDetail})`);
|
|
210
230
|
return new Text(`${tasks}\n${target}`, 0, 0);
|
|
211
231
|
}
|
|
212
232
|
|
|
@@ -232,12 +252,18 @@ function buildExpanded(details: ReviewBatchDetails, theme: Theme): Container {
|
|
|
232
252
|
container.addChild(
|
|
233
253
|
new Text(`${theme.fg("dim", "target:")} ${theme.fg("muted", details.snapshot.title)}`, 1, 0),
|
|
234
254
|
);
|
|
255
|
+
const currentStateTarget =
|
|
256
|
+
details.snapshot.requestedTarget.kind === "current-state"
|
|
257
|
+
? details.snapshot.requestedTarget
|
|
258
|
+
: undefined;
|
|
235
259
|
const fileCount = details.snapshot.changes.length;
|
|
236
260
|
container.addChild(
|
|
237
261
|
new Text(
|
|
238
262
|
theme.fg(
|
|
239
263
|
"dim",
|
|
240
|
-
|
|
264
|
+
currentStateTarget
|
|
265
|
+
? `review scope: ${currentStateTarget.paths?.map((path) => JSON.stringify(path)).join(", ") ?? "repository-wide discovery"}`
|
|
266
|
+
: `${fileCount} file${fileCount !== 1 ? "s" : ""} changed · +${details.snapshot.stats.additions} / -${details.snapshot.stats.deletions}`,
|
|
241
267
|
),
|
|
242
268
|
1,
|
|
243
269
|
0,
|
|
@@ -247,7 +273,9 @@ function buildExpanded(details: ReviewBatchDetails, theme: Theme): Container {
|
|
|
247
273
|
new Text(
|
|
248
274
|
theme.fg(
|
|
249
275
|
"dim",
|
|
250
|
-
|
|
276
|
+
currentStateTarget
|
|
277
|
+
? `workspace: ${details.workspaceReceipt.status} · current-state · frozen filesystem`
|
|
278
|
+
: `workspace: ${details.workspaceReceipt.status} · ${details.workspaceReceipt.targetKind} · ${details.workspaceReceipt.changedPathCount} paths`,
|
|
251
279
|
),
|
|
252
280
|
1,
|
|
253
281
|
0,
|
package/src/types.ts
CHANGED
|
@@ -7,13 +7,17 @@ import type { ReviewWorkspaceCleanupWarning } from "./workspace/review-workspace
|
|
|
7
7
|
export type CommitId = string;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
10
|
+
* The item selected for review: a Git change, a single commit, or a one-state
|
|
11
|
+
* Current-State Audit of the complete filesystem. A working-tree target may
|
|
12
|
+
* use an optional base commit to include committed branch work and current
|
|
13
|
+
* filesystem changes; a current-state target may optionally focus inspection
|
|
14
|
+
* with advisory workspace-relative paths.
|
|
12
15
|
*/
|
|
13
16
|
export type ReviewTargetSpec =
|
|
14
17
|
| { kind: "working-tree"; baseCommit?: CommitId }
|
|
15
18
|
| { kind: "comparison"; baseCommit: CommitId }
|
|
16
|
-
| { kind: "commit"; commit: CommitId }
|
|
19
|
+
| { kind: "commit"; commit: CommitId }
|
|
20
|
+
| { kind: "current-state"; paths?: string[] };
|
|
17
21
|
|
|
18
22
|
/** Resolved identity of a selected review target. */
|
|
19
23
|
export type ResolvedReviewTarget =
|
|
@@ -29,7 +33,8 @@ export type ResolvedReviewTarget =
|
|
|
29
33
|
mergeBaseCommit: CommitId;
|
|
30
34
|
headCommit: CommitId;
|
|
31
35
|
}
|
|
32
|
-
| { kind: "commit"; commit: CommitId; parentCommit?: CommitId }
|
|
36
|
+
| { kind: "commit"; commit: CommitId; parentCommit?: CommitId }
|
|
37
|
+
| { kind: "current-state"; headCommit: CommitId };
|
|
33
38
|
|
|
34
39
|
export interface DiffStats {
|
|
35
40
|
files: number;
|
|
@@ -87,12 +92,27 @@ export interface ReviewAuditReference {
|
|
|
87
92
|
/** Eligibility policy for findings produced by one Review Task. */
|
|
88
93
|
export type FindingScope = "change-only" | "boy-scout";
|
|
89
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Effective finding scope rendered for one task. Current-State Audit fixes
|
|
97
|
+
* `criteria-only`; Git change reviews use the task's caller-selected scope.
|
|
98
|
+
*/
|
|
99
|
+
export type EffectiveFindingScope = FindingScope | "criteria-only";
|
|
100
|
+
|
|
101
|
+
/** Caller-identified authoritative issue or repository document for Review Criteria. */
|
|
102
|
+
export interface CriteriaSource {
|
|
103
|
+
/** Identifier such as an issue reference, URL, or repository-relative path. */
|
|
104
|
+
reference: string;
|
|
105
|
+
/** Caller summary used before the reviewer retrieves the source itself. */
|
|
106
|
+
summary: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
90
109
|
/** One independent caller-defined review objective. */
|
|
91
110
|
export interface ReviewTask {
|
|
92
111
|
id: string;
|
|
93
112
|
instructions: string;
|
|
94
|
-
/** Defaults to change-only when omitted. */
|
|
113
|
+
/** Defaults to change-only when omitted; fixed criteria-only for Current-State Audit. */
|
|
95
114
|
findingScope?: FindingScope;
|
|
115
|
+
criteriaSources?: CriteriaSource[];
|
|
96
116
|
}
|
|
97
117
|
|
|
98
118
|
/** Semantic input shared with the reviewer tasks in one run. */
|
|
@@ -106,7 +126,10 @@ export type PlannerDraft = ReviewInput;
|
|
|
106
126
|
|
|
107
127
|
export type FindingImpact = "low" | "medium" | "high";
|
|
108
128
|
export type FindingEffort = "small" | "medium" | "large";
|
|
109
|
-
export type TaskVerdict = "pass" | "pass_with_findings" | "issues";
|
|
129
|
+
export type TaskVerdict = "pass" | "pass_with_findings" | "issues" | "incomplete";
|
|
130
|
+
|
|
131
|
+
/** A reviewer's structured statement about Review Criteria Source coverage. */
|
|
132
|
+
export type CriteriaCoverage = { status: "complete" } | { status: "incomplete"; reason: string };
|
|
110
133
|
|
|
111
134
|
/** Machine-derived count of all findings, including their acceptance and impact split. */
|
|
112
135
|
export interface FindingCounts {
|
|
@@ -137,6 +160,7 @@ export interface ReviewFinding {
|
|
|
137
160
|
export interface ReviewSubmission {
|
|
138
161
|
summary: string;
|
|
139
162
|
findings: ReviewFinding[];
|
|
163
|
+
criteriaCoverage: CriteriaCoverage;
|
|
140
164
|
}
|
|
141
165
|
|
|
142
166
|
export interface NormalizedReviewSubmission extends ReviewSubmission {
|
|
@@ -198,6 +222,7 @@ export type ChildRunOutcome<T> =
|
|
|
198
222
|
export interface ReviewProgress {
|
|
199
223
|
turns: number;
|
|
200
224
|
toolUses: number;
|
|
225
|
+
toolErrors?: number;
|
|
201
226
|
tokens?: {
|
|
202
227
|
input: number;
|
|
203
228
|
output: number;
|
|
@@ -243,8 +268,11 @@ export interface ReviewerInvocation {
|
|
|
243
268
|
onProgress?: (progress: ReviewProgress) => void;
|
|
244
269
|
}
|
|
245
270
|
|
|
271
|
+
export type ReviewerExtensionSetStatus = "active" | "degraded" | "unobserved";
|
|
272
|
+
|
|
246
273
|
export type ReviewerRunResult = ChildRunOutcome<ReviewSubmission> & {
|
|
247
274
|
modelId: string;
|
|
275
|
+
reviewerExtensionSetStatus: ReviewerExtensionSetStatus;
|
|
248
276
|
capabilityWarnings?: ReviewerCapabilityWarning[];
|
|
249
277
|
audit?: ReviewAuditReference;
|
|
250
278
|
};
|
|
@@ -270,6 +298,7 @@ export type ReviewTaskResult = ReviewTaskResultIdentity &
|
|
|
270
298
|
findingCounts: FindingCounts;
|
|
271
299
|
summary: string;
|
|
272
300
|
findings: ReviewFinding[];
|
|
301
|
+
criteriaCoverage: CriteriaCoverage;
|
|
273
302
|
}
|
|
274
303
|
| {
|
|
275
304
|
status: "failed";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { lstat, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { readReviewDiff } from "../git.ts";
|
|
6
6
|
import { runGit, runGitAllowExit } from "../git-command.ts";
|
|
7
|
+
import { resolveReviewPath } from "../review-path.ts";
|
|
7
8
|
import type { ReviewSnapshot, ReviewWorkspaceReceipt } from "../types.ts";
|
|
8
9
|
|
|
9
10
|
const WORKSPACE_MARKER = "supi-review:";
|
|
@@ -30,6 +31,7 @@ function afterCommit(snapshot: ReviewSnapshot): string {
|
|
|
30
31
|
if (snapshot.target.kind === "working-tree") {
|
|
31
32
|
return snapshot.target.mergeBaseCommit ?? snapshot.target.headCommit;
|
|
32
33
|
}
|
|
34
|
+
if (snapshot.target.kind === "current-state") return snapshot.target.headCommit;
|
|
33
35
|
return snapshot.target.kind === "comparison"
|
|
34
36
|
? snapshot.target.headCommit
|
|
35
37
|
: snapshot.target.commit;
|
|
@@ -47,6 +49,7 @@ function baselineRevision(snapshot: ReviewSnapshot): string {
|
|
|
47
49
|
if (snapshot.target.kind === "working-tree") {
|
|
48
50
|
return snapshot.target.mergeBaseCommit ?? snapshot.target.headCommit;
|
|
49
51
|
}
|
|
52
|
+
if (snapshot.target.kind === "current-state") return snapshot.target.headCommit;
|
|
50
53
|
if (snapshot.target.kind === "comparison") return snapshot.target.mergeBaseCommit;
|
|
51
54
|
return snapshot.target.parentCommit ?? "empty-tree";
|
|
52
55
|
}
|
|
@@ -60,11 +63,34 @@ function workspaceSnapshot(snapshot: ReviewSnapshot, cwd: string): ReviewSnapsho
|
|
|
60
63
|
};
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
async function verifyReviewScope(snapshot: ReviewSnapshot, cwd: string): Promise<void> {
|
|
67
|
+
if (snapshot.requestedTarget.kind !== "current-state") return;
|
|
68
|
+
for (const path of snapshot.requestedTarget.paths ?? []) {
|
|
69
|
+
try {
|
|
70
|
+
await lstat(resolveReviewPath(cwd, path).absolute);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (
|
|
73
|
+
error &&
|
|
74
|
+
typeof error === "object" &&
|
|
75
|
+
"code" in error &&
|
|
76
|
+
((error as { code?: unknown }).code === "ENOENT" ||
|
|
77
|
+
(error as { code?: unknown }).code === "ENOTDIR")
|
|
78
|
+
) {
|
|
79
|
+
throw new Error(`Review Workspace does not contain Review Scope path: ${path}.`, {
|
|
80
|
+
cause: error,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
63
88
|
/** Re-read the frozen workspace through the canonical patch compiler before children can inspect it. */
|
|
64
89
|
async function verifyWorkspace(
|
|
65
90
|
snapshot: ReviewSnapshot,
|
|
66
91
|
cwd: string,
|
|
67
92
|
): Promise<ReviewWorkspaceReceipt> {
|
|
93
|
+
await verifyReviewScope(snapshot, cwd);
|
|
68
94
|
const expectedWorkspaceHead = afterCommit(snapshot);
|
|
69
95
|
const observedWorkspaceHead = (
|
|
70
96
|
await runGit(cwd, [
|
|
@@ -77,7 +103,7 @@ async function verifyWorkspace(
|
|
|
77
103
|
if (observedWorkspaceHead !== expectedWorkspaceHead) {
|
|
78
104
|
throw new Error("Review Workspace checked out an unexpected commit.");
|
|
79
105
|
}
|
|
80
|
-
if (snapshot.target.kind !== "working-tree") {
|
|
106
|
+
if (snapshot.target.kind !== "working-tree" && snapshot.target.kind !== "current-state") {
|
|
81
107
|
const status = await runGit(cwd, ["status", "--porcelain"]);
|
|
82
108
|
if (status) throw new Error("Review Workspace was not clean after checkout.");
|
|
83
109
|
}
|
|
@@ -123,14 +149,17 @@ export async function materializeReviewWorkspace(
|
|
|
123
149
|
cwd = await realpath(workspacePath);
|
|
124
150
|
await runGit(snapshot.repositoryRoot, ["worktree", "lock", "--reason", lockReason(), cwd]);
|
|
125
151
|
|
|
126
|
-
if (snapshot.target.kind === "working-tree") {
|
|
152
|
+
if (snapshot.target.kind === "working-tree" || snapshot.target.kind === "current-state") {
|
|
127
153
|
const patch = await readReviewDiff(snapshot.repositoryRoot, snapshot);
|
|
128
154
|
if (sha256(patch) !== snapshot.diffHash) {
|
|
129
|
-
throw new Error("The
|
|
155
|
+
throw new Error("The review target changed before its Review Workspace was frozen.");
|
|
156
|
+
}
|
|
157
|
+
// An unchanged current state freezes to its HEAD checkout without a patch.
|
|
158
|
+
if (patch) {
|
|
159
|
+
const patchPath = join(parent, "target.patch");
|
|
160
|
+
await writeFile(patchPath, patch, "utf8");
|
|
161
|
+
await runGit(cwd, ["apply", "--index", "--binary", "--whitespace=nowarn", patchPath]);
|
|
130
162
|
}
|
|
131
|
-
const patchPath = join(parent, "target.patch");
|
|
132
|
-
await writeFile(patchPath, patch, "utf8");
|
|
133
|
-
await runGit(cwd, ["apply", "--index", "--binary", "--whitespace=nowarn", patchPath]);
|
|
134
163
|
}
|
|
135
164
|
receipt = await verifyWorkspace(snapshot, cwd);
|
|
136
165
|
} catch (error) {
|