@mrclrchtr/supi-review 4.5.1 → 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/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/README.md +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +49 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +49 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +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/README.md +1 -3
- 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 +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +49 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +49 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +4 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +1 -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 +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +49 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +49 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +4 -4
- 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 +6 -6
- package/node_modules/@mrclrchtr/supi-core/README.md +1 -3
- package/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +49 -12
- package/package.json +4 -4
- 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
|
@@ -3,6 +3,7 @@ import { resolveReviewSnapshot, summarizeReviewSnapshot } from "../git.ts";
|
|
|
3
3
|
import { normalizeReviewInput } from "../review-input.ts";
|
|
4
4
|
import type { ReviewPlanLease, ReviewPlanStore } from "../session/review-plan-store.ts";
|
|
5
5
|
import { buildFileManifest } from "../target/file-manifest.ts";
|
|
6
|
+
import { snapshotsMatch } from "../target/snapshot-match.ts";
|
|
6
7
|
import type {
|
|
7
8
|
PlannerDraft,
|
|
8
9
|
PlannerRunResult,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
createUnobservedChildFailureDiagnostics,
|
|
22
23
|
} from "./child-failure-diagnostics.ts";
|
|
23
24
|
import { combineUsage } from "./child-usage.ts";
|
|
25
|
+
import { enforceCriteriaOnlyScope } from "./criteria-only-scope.ts";
|
|
24
26
|
import { PLANNER_PROMPT_VERSION, runPlanner } from "./planner-runner.ts";
|
|
25
27
|
import { executeReviewTasks, type ReviewExecutionUpdate } from "./review-execution.ts";
|
|
26
28
|
|
|
@@ -76,6 +78,29 @@ export interface PreparedRunInput {
|
|
|
76
78
|
export type RunReviewInput = DirectRunInput | PreparedRunInput;
|
|
77
79
|
|
|
78
80
|
function plannerPrompt(snapshot: ReviewSnapshot, context: string): string {
|
|
81
|
+
const conversation = [
|
|
82
|
+
"",
|
|
83
|
+
"## Bounded session conversation",
|
|
84
|
+
context || "No session conversation was available.",
|
|
85
|
+
];
|
|
86
|
+
if (snapshot.requestedTarget.kind === "current-state") {
|
|
87
|
+
return [
|
|
88
|
+
"# Review Planning Input",
|
|
89
|
+
"",
|
|
90
|
+
`Target: ${snapshot.title}`,
|
|
91
|
+
"Finding Scope: criteria-only",
|
|
92
|
+
"This is a one-state audit without Git-change attribution.",
|
|
93
|
+
"",
|
|
94
|
+
"## Review scope",
|
|
95
|
+
...(snapshot.requestedTarget.paths?.length
|
|
96
|
+
? [
|
|
97
|
+
"Advisory focus paths; they do not restrict inspection or finding eligibility.",
|
|
98
|
+
...snapshot.requestedTarget.paths.map((path) => `- ${JSON.stringify(path)}`),
|
|
99
|
+
]
|
|
100
|
+
: ["Repository-wide discovery; no advisory focus paths were supplied."]),
|
|
101
|
+
...conversation,
|
|
102
|
+
].join("\n");
|
|
103
|
+
}
|
|
79
104
|
return [
|
|
80
105
|
"# Review Planning Input",
|
|
81
106
|
"",
|
|
@@ -85,9 +110,7 @@ function plannerPrompt(snapshot: ReviewSnapshot, context: string): string {
|
|
|
85
110
|
"",
|
|
86
111
|
"## Changed-path inventory",
|
|
87
112
|
...buildFileManifest(snapshot.changes),
|
|
88
|
-
|
|
89
|
-
"## Bounded session conversation",
|
|
90
|
-
context || "No session conversation was available.",
|
|
113
|
+
...conversation,
|
|
91
114
|
].join("\n");
|
|
92
115
|
}
|
|
93
116
|
|
|
@@ -185,34 +208,6 @@ export async function prepareReview(input: PrepareReviewInput) {
|
|
|
185
208
|
return { kind: "prepared" as const, plan, ...(planning.usage ? { usage: planning.usage } : {}) };
|
|
186
209
|
}
|
|
187
210
|
|
|
188
|
-
function targetsMatch(left: ReviewSnapshot["target"], right: ReviewSnapshot["target"]): boolean {
|
|
189
|
-
if (left.kind !== right.kind) return false;
|
|
190
|
-
if (left.kind === "working-tree" && right.kind === "working-tree") {
|
|
191
|
-
return (
|
|
192
|
-
left.headCommit === right.headCommit &&
|
|
193
|
-
left.requestedBaseCommit === right.requestedBaseCommit &&
|
|
194
|
-
left.mergeBaseCommit === right.mergeBaseCommit
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
if (left.kind === "comparison" && right.kind === "comparison") {
|
|
198
|
-
return (
|
|
199
|
-
left.requestedBaseCommit === right.requestedBaseCommit &&
|
|
200
|
-
left.mergeBaseCommit === right.mergeBaseCommit &&
|
|
201
|
-
left.headCommit === right.headCommit
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
return (
|
|
205
|
-
left.kind === "commit" &&
|
|
206
|
-
right.kind === "commit" &&
|
|
207
|
-
left.commit === right.commit &&
|
|
208
|
-
left.parentCommit === right.parentCommit
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function snapshotsMatch(left: ReviewSnapshot, right: ReviewSnapshot): boolean {
|
|
213
|
-
return left.diffHash === right.diffHash && targetsMatch(left.target, right.target);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
211
|
function workspaceFailureReason(error: unknown): string {
|
|
217
212
|
if (error instanceof Error && error.message.startsWith("Review Workspace ")) {
|
|
218
213
|
return error.message;
|
|
@@ -262,6 +257,9 @@ export async function runReview(input: RunReviewInput) {
|
|
|
262
257
|
snapshot = resolved;
|
|
263
258
|
review = normalizeReviewInput(input.review);
|
|
264
259
|
model = input.reviewerModel;
|
|
260
|
+
const scoped = enforceCriteriaOnlyScope(review, snapshot.target.kind, "caller-supplied");
|
|
261
|
+
if ("reason" in scoped) return { kind: "invalid" as const, reason: scoped.reason };
|
|
262
|
+
review = scoped.review;
|
|
265
263
|
} else {
|
|
266
264
|
const plan = input.planStore.peek(input.planId);
|
|
267
265
|
if (!plan) {
|
|
@@ -306,9 +304,14 @@ export async function runReview(input: RunReviewInput) {
|
|
|
306
304
|
};
|
|
307
305
|
}
|
|
308
306
|
snapshot = refreshed;
|
|
309
|
-
review = selectedReview;
|
|
310
307
|
model = lease.plan.reviewerModel;
|
|
311
308
|
provenance = input.decision.kind === "accept-draft" ? "planner-assisted" : "caller-supplied";
|
|
309
|
+
const scoped = enforceCriteriaOnlyScope(selectedReview, refreshed.target.kind, provenance);
|
|
310
|
+
if ("reason" in scoped) {
|
|
311
|
+
input.planStore.release(lease);
|
|
312
|
+
return { kind: "invalid" as const, reason: scoped.reason };
|
|
313
|
+
}
|
|
314
|
+
review = scoped.review;
|
|
312
315
|
if (lease.plan.plannerDraft && lease.plan.plannerModelId && lease.plan.plannerPromptVersion) {
|
|
313
316
|
planning = {
|
|
314
317
|
promptVersion: lease.plan.plannerPromptVersion,
|
package/src/tool/schemas.ts
CHANGED
|
@@ -22,9 +22,37 @@ export const reviewTaskSchema = Type.Object(
|
|
|
22
22
|
StringEnum(["change-only", "boy-scout"] as const, {
|
|
23
23
|
default: "change-only",
|
|
24
24
|
description:
|
|
25
|
-
"change-only reports issues attributable to the target. boy-scout may also report directly related pre-existing issues, which stay advisory unless the target worsens or newly exposes them.",
|
|
25
|
+
"change-only reports issues attributable to the target. boy-scout may also report directly related pre-existing issues, which stay advisory unless the target worsens or newly exposes them. Current-State Audit fixes criteria-only; omit this field for currentState targets.",
|
|
26
26
|
}),
|
|
27
27
|
),
|
|
28
|
+
criteriaSources: Type.Optional(
|
|
29
|
+
Type.Array(
|
|
30
|
+
Type.Object(
|
|
31
|
+
{
|
|
32
|
+
reference: Type.String({
|
|
33
|
+
minLength: 1,
|
|
34
|
+
maxLength: REVIEW_LIMITS.criteriaReferenceCharacters,
|
|
35
|
+
pattern: "\\S",
|
|
36
|
+
description:
|
|
37
|
+
"Authoritative source identifier, such as an issue reference, URL, or repository-relative document path.",
|
|
38
|
+
}),
|
|
39
|
+
summary: Type.String({
|
|
40
|
+
minLength: 1,
|
|
41
|
+
maxLength: REVIEW_LIMITS.criteriaSummaryCharacters,
|
|
42
|
+
pattern: "\\S",
|
|
43
|
+
description:
|
|
44
|
+
"Caller summary of the source used before the reviewer retrieves the source itself.",
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
{ additionalProperties: false },
|
|
48
|
+
),
|
|
49
|
+
{
|
|
50
|
+
minItems: 1,
|
|
51
|
+
maxItems: REVIEW_LIMITS.criteriaSourcesPerTask,
|
|
52
|
+
description: "Authoritative issues or documents this task's Review Criteria derive from.",
|
|
53
|
+
},
|
|
54
|
+
),
|
|
55
|
+
),
|
|
28
56
|
},
|
|
29
57
|
{ additionalProperties: false },
|
|
30
58
|
);
|
|
@@ -68,7 +96,8 @@ export const reviewFindingSchema = Type.Object(
|
|
|
68
96
|
description: "Concrete evidence, consequence, and needed correction.",
|
|
69
97
|
}),
|
|
70
98
|
blocksAcceptance: Type.Boolean({
|
|
71
|
-
description:
|
|
99
|
+
description:
|
|
100
|
+
"True only when the reviewed target should not be accepted as satisfying the Review Task until this is corrected.",
|
|
72
101
|
}),
|
|
73
102
|
impact: StringEnum(["low", "medium", "high"] as const, {
|
|
74
103
|
description: "Downside if unfixed, not the size of the correction.",
|
|
@@ -121,6 +150,27 @@ export const reviewSubmissionSchema = Type.Object(
|
|
|
121
150
|
maxItems: REVIEW_LIMITS.findingsPerTask,
|
|
122
151
|
description: "Findings in intended order; use [] after a clean review (at most 20 findings).",
|
|
123
152
|
}),
|
|
153
|
+
criteriaCoverage: Type.Object(
|
|
154
|
+
{
|
|
155
|
+
status: StringEnum(["complete", "incomplete"] as const, {
|
|
156
|
+
description:
|
|
157
|
+
"complete when the supplied Review Criteria were sufficient; incomplete when unavailable source detail limited the audit.",
|
|
158
|
+
}),
|
|
159
|
+
reason: Type.Optional(
|
|
160
|
+
Type.String({
|
|
161
|
+
minLength: 1,
|
|
162
|
+
maxLength: REVIEW_LIMITS.criteriaCoverageReasonCharacters,
|
|
163
|
+
pattern: "\\S",
|
|
164
|
+
description: "Required only when status is incomplete; names the unavailable detail.",
|
|
165
|
+
}),
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
additionalProperties: false,
|
|
170
|
+
description:
|
|
171
|
+
"Required structured criteria coverage statement; incomplete coverage cannot support a definitive pass.",
|
|
172
|
+
},
|
|
173
|
+
),
|
|
124
174
|
},
|
|
125
175
|
{ additionalProperties: false },
|
|
126
176
|
);
|
package/src/tui/common.ts
CHANGED
|
@@ -39,6 +39,7 @@ export function formatVerdictBadge(verdict: TaskVerdict, theme: Theme): string {
|
|
|
39
39
|
if (verdict === "pass_with_findings") {
|
|
40
40
|
return theme.fg("warning", theme.bold("PASS WITH FINDINGS"));
|
|
41
41
|
}
|
|
42
|
+
if (verdict === "incomplete") return theme.fg("warning", theme.bold("INCOMPLETE"));
|
|
42
43
|
return theme.fg("error", theme.bold("ISSUES"));
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -183,6 +184,25 @@ function appendCapabilityWarnings(
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
function appendCriteriaCoverage(
|
|
188
|
+
container: Container,
|
|
189
|
+
result: ReviewTaskResult & { status: "completed" },
|
|
190
|
+
theme: Theme,
|
|
191
|
+
): void {
|
|
192
|
+
if (result.criteriaCoverage?.status !== "incomplete") return;
|
|
193
|
+
container.addChild(new Spacer(1));
|
|
194
|
+
container.addChild(
|
|
195
|
+
new Text(
|
|
196
|
+
theme.fg(
|
|
197
|
+
"warning",
|
|
198
|
+
`criteria coverage: incomplete — ${result.criteriaCoverage.reason ?? "unspecified"}`,
|
|
199
|
+
),
|
|
200
|
+
1,
|
|
201
|
+
0,
|
|
202
|
+
),
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
186
206
|
/** Build an expanded-view section for a single review task result. */
|
|
187
207
|
export function buildTaskSection(
|
|
188
208
|
container: Container,
|
|
@@ -234,6 +254,8 @@ export function buildTaskSection(
|
|
|
234
254
|
return;
|
|
235
255
|
}
|
|
236
256
|
|
|
257
|
+
appendCriteriaCoverage(container, result, theme);
|
|
258
|
+
|
|
237
259
|
if (result.summary) {
|
|
238
260
|
container.addChild(new Spacer(1));
|
|
239
261
|
container.addChild(new Text(theme.fg("muted", result.summary), 1, 0));
|
package/src/tui/prepare.ts
CHANGED
|
@@ -7,29 +7,31 @@
|
|
|
7
7
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
8
8
|
import { Container, Spacer, Text } from "@earendil-works/pi-tui";
|
|
9
9
|
import { formatReviewUsage } from "../tool/usage-format.ts";
|
|
10
|
-
import type {
|
|
10
|
+
import type { PreparedReviewDetails } from "../types.ts";
|
|
11
11
|
import { renderError, renderPartial, renderReviewToolCall } from "./common.ts";
|
|
12
12
|
|
|
13
13
|
/** Plan details shape extracted from execute's details return. */
|
|
14
|
-
|
|
15
|
-
plannerDraft?: {
|
|
16
|
-
sharedContext?: string;
|
|
17
|
-
tasks: Array<{ id: string; instructions: string; findingScope?: FindingScope }>;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
14
|
+
type PrepareDetails = PreparedReviewDetails;
|
|
20
15
|
|
|
21
16
|
// ── renderCall ───────────────────────────────────────────────────
|
|
22
17
|
|
|
23
18
|
export function renderPrepareCall(args: unknown, theme: Theme): Text {
|
|
24
19
|
const params = (args ?? {}) as {
|
|
25
20
|
planning?: string;
|
|
26
|
-
target?: {
|
|
21
|
+
target?: {
|
|
22
|
+
workingTree?: unknown;
|
|
23
|
+
comparison?: unknown;
|
|
24
|
+
commit?: unknown;
|
|
25
|
+
currentState?: unknown;
|
|
26
|
+
};
|
|
27
27
|
};
|
|
28
28
|
const targetKind = params.target?.comparison
|
|
29
29
|
? "comparison"
|
|
30
30
|
: params.target?.commit
|
|
31
31
|
? "commit"
|
|
32
|
-
:
|
|
32
|
+
: params.target?.currentState
|
|
33
|
+
? "current-state"
|
|
34
|
+
: "working-tree";
|
|
33
35
|
|
|
34
36
|
return renderReviewToolCall("supi_review_prepare", params.planning ?? "none", theme, targetKind);
|
|
35
37
|
}
|
|
@@ -70,7 +72,16 @@ function buildCollapsed(details: PrepareDetails, theme: Theme): Text {
|
|
|
70
72
|
const segments: string[] = [];
|
|
71
73
|
segments.push(theme.fg("accent", "Plan ready"));
|
|
72
74
|
segments.push(theme.fg("muted", targetKind));
|
|
73
|
-
segments.push(
|
|
75
|
+
segments.push(
|
|
76
|
+
theme.fg(
|
|
77
|
+
"dim",
|
|
78
|
+
targetKind === "current-state"
|
|
79
|
+
? details.snapshot.requestedTarget.paths?.length
|
|
80
|
+
? `${details.snapshot.requestedTarget.paths.length} focus paths`
|
|
81
|
+
: "repository-wide"
|
|
82
|
+
: `${fileCount} file${fileCount !== 1 ? "s" : ""} changed`,
|
|
83
|
+
),
|
|
84
|
+
);
|
|
74
85
|
if (hasPlanner) segments.push(theme.fg("muted", "with draft"));
|
|
75
86
|
else if (details.plannerFailure) segments.push(theme.fg("warning", "planner unavailable"));
|
|
76
87
|
|
|
@@ -116,6 +127,7 @@ function addPlannerMetadata(container: Container, details: PrepareDetails, theme
|
|
|
116
127
|
function addPlannerDraft(container: Container, details: PrepareDetails, theme: Theme): void {
|
|
117
128
|
const draft = details.plannerDraft;
|
|
118
129
|
if (!draft) return;
|
|
130
|
+
const currentState = details.snapshot.requestedTarget.kind === "current-state";
|
|
119
131
|
container.addChild(new Spacer(1));
|
|
120
132
|
container.addChild(new Text(theme.fg("accent", theme.bold("Planner Draft")), 1, 0));
|
|
121
133
|
if (draft.sharedContext) {
|
|
@@ -127,11 +139,16 @@ function addPlannerDraft(container: Container, details: PrepareDetails, theme: T
|
|
|
127
139
|
for (const task of draft.tasks) {
|
|
128
140
|
container.addChild(
|
|
129
141
|
new Text(
|
|
130
|
-
`${theme.fg("accent", task.id)} ${theme.fg("dim", `(${task.findingScope ?? "change-only"})`)}: ${theme.fg("muted", task.instructions)}`,
|
|
142
|
+
`${theme.fg("accent", task.id)} ${theme.fg("dim", `(${currentState ? "criteria-only" : (task.findingScope ?? "change-only")})`)}: ${theme.fg("muted", task.instructions)}`,
|
|
131
143
|
1,
|
|
132
144
|
0,
|
|
133
145
|
),
|
|
134
146
|
);
|
|
147
|
+
for (const source of task.criteriaSources ?? []) {
|
|
148
|
+
container.addChild(
|
|
149
|
+
new Text(theme.fg("dim", `criteria: ${source.reference} — ${source.summary}`), 1, 0),
|
|
150
|
+
);
|
|
151
|
+
}
|
|
135
152
|
container.addChild(new Text(theme.fg("dim", "─".repeat(40)), 1, 0));
|
|
136
153
|
}
|
|
137
154
|
}
|
|
@@ -155,7 +172,9 @@ function buildExpanded(details: PrepareDetails, theme: Theme): Container {
|
|
|
155
172
|
new Text(
|
|
156
173
|
theme.fg(
|
|
157
174
|
"dim",
|
|
158
|
-
|
|
175
|
+
snapshot.requestedTarget.kind === "current-state"
|
|
176
|
+
? `review scope: ${snapshot.requestedTarget.paths?.map((path) => JSON.stringify(path)).join(", ") ?? "repository-wide discovery"}`
|
|
177
|
+
: `${snapshot.changes.length} file${snapshot.changes.length !== 1 ? "s" : ""} changed · +${snapshot.stats.additions} / -${snapshot.stats.deletions}`,
|
|
159
178
|
),
|
|
160
179
|
1,
|
|
161
180
|
0,
|
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) {
|