@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/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# @mrclrchtr/supi-review — Code Review for Pi
|
|
8
8
|
|
|
9
|
-
Code review extension for the [Pi coding agent](https://github.com/earendil-works/pi) that runs parallel, isolated review tasks against a working tree, branch, or
|
|
9
|
+
Code review extension for the [Pi coding agent](https://github.com/earendil-works/pi) that runs parallel, isolated review tasks against a working tree, branch, commit, or the complete current filesystem state.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -53,6 +53,28 @@ Preparation is optional. Skills and agents that already know how to review shoul
|
|
|
53
53
|
|
|
54
54
|
One to four tasks share a reviewer model and one frozen Review Workspace. Direct and Prepared adapters use the same canonical packet compiler; every task result includes the SHA-256 of the exact packet bytes and nested-model usage when reported.
|
|
55
55
|
|
|
56
|
+
Tasks may identify authoritative Review Criteria Sources whose summaries travel in the packet:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"direct": {
|
|
61
|
+
"target": { "currentState": { "paths": ["packages/supi-review"] } },
|
|
62
|
+
"tasks": [
|
|
63
|
+
{
|
|
64
|
+
"id": "spec",
|
|
65
|
+
"instructions": "Review the current state against issue #123.",
|
|
66
|
+
"criteriaSources": [
|
|
67
|
+
{ "reference": "#123", "summary": "Acceptance criteria: A, B, C." },
|
|
68
|
+
{ "reference": "docs/adr/0012.md", "summary": "Current-State Audit semantics." }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`currentState` audits one frozen filesystem state without Git-change attribution, so tasks must omit `findingScope`; the engine fixes `criteria-only`. `paths` is an optional advisory focus whose entries must exist in the frozen state.
|
|
77
|
+
|
|
56
78
|
## Prepared Review
|
|
57
79
|
|
|
58
80
|
Preparation returns a session-scoped `planId` and optional Planner Draft. Planner failure returns a usable no-draft plan. Before a Prepared Review runs, the engine re-resolves the target and compares its exact Review Snapshot; drift invalidates the plan. A batch with at least one completed task consumes its plan, while an all-non-completed batch releases it for retry.
|
|
@@ -75,6 +97,7 @@ The Review Engine resolves the Git worktree root once and pins commit identities
|
|
|
75
97
|
- `working-tree` — net current filesystem plus non-ignored untracked files against `HEAD`, or `merge-base(baseCommit, HEAD)`; the caller index is not evidence
|
|
76
98
|
- `comparison` — merge base of `baseCommit` and captured `HEAD` to captured `HEAD`
|
|
77
99
|
- `commit` — first parent (or empty tree) to `commit`
|
|
100
|
+
- `currentState` — the complete current filesystem, including uncommitted and untracked work, reviewed as one state against Review Criteria
|
|
78
101
|
|
|
79
102
|
A Working-Tree Review Workspace checks out its pinned baseline and stages the exact canonical patch, so `git diff HEAD` shows the complete target. Comparison and Commit workspaces check out their pinned after commit. Before Reviewer Sessions start, the engine re-compiles the target patch from the linked workspace and verifies its hash, expected checkout commit, and changed-path count. Every completed batch includes that compact Workspace receipt, so later caller edits cannot change the in-flight target.
|
|
80
103
|
|
|
@@ -90,7 +113,9 @@ Reviewers receive:
|
|
|
90
113
|
|
|
91
114
|
They use ordinary Git and direct reads in the frozen Review Workspace. Before-side content remains available through the packet's pinned Git revision. Code Intelligence runs in a headless inspection profile; an unavailable profile produces a Reviewer Capability Warning, while the built-in inspection tools remain available.
|
|
92
115
|
|
|
93
|
-
Each Review Task may set `findingScope` to `change-only` (the default) or `boy-scout`. Change-only findings must be attributable to the selected change, including omitted or partial required behavior and acceptance-relevant scope creep. Boy Scout scope may additionally report pre-existing issues in changed files or symbols the reviewer judges directly affected; purely pre-existing findings are advisory unless the change worsens or newly exposes them. Repository standards and specifications requested by a task are Review Criteria, but repository content can never override the fixed Reviewer Protocol or task.
|
|
116
|
+
Each Git-change Review Task may set `findingScope` to `change-only` (the default) or `boy-scout`. Change-only findings must be attributable to the selected change, including omitted or partial required behavior and acceptance-relevant scope creep. Boy Scout scope may additionally report pre-existing issues in changed files or symbols the reviewer judges directly affected; purely pre-existing findings are advisory unless the change worsens or newly exposes them. Current-State Audit uses fixed `criteria-only` scope: any finding relevant to the Review Criteria may block acceptance, regardless of when it was introduced. Repository standards and specifications requested by a task are Review Criteria, but repository content can never override the fixed Reviewer Protocol or task.
|
|
117
|
+
|
|
118
|
+
Before alleging a documented-rule breach, reviewers check that rule's documented exceptions; covered candidates are omitted and submitted breach findings state why no exception applies. Test verification means inspecting test source, coverage, and requirement mapping; runtime checks stay with the containing Agent. When a task lists `criteriaSources`, reviewers use the supplied summaries first and may retrieve an identified source read-only when its summary is insufficient; unavailable required detail produces an incomplete Criteria Coverage statement rather than a false pass.
|
|
94
119
|
|
|
95
120
|
Inspection-only is behavioral protocol, not access control. The surrounding Sandboxed Pi Environment is the security boundary and must contain only files and credentials acceptable for reviewer-model access. When `review.bootstrapCommand` is configured, the Review Engine runs its shell command once after workspace verification and before reviewer fan-out; reviewers then receive no Dependency Bootstrap instruction. When it is empty, reviewers may choose a Dependency Bootstrap command when local dependencies limit Code Intelligence. They must not intentionally mutate Target Evidence or Git history, and must not run tests, builds, linters, runtime experiments, services, nested Pi sessions, or nested reviews.
|
|
96
121
|
|
|
@@ -98,7 +123,9 @@ Reviewer Sessions replace Pi's generic coding prompt with the package-owned Revi
|
|
|
98
123
|
|
|
99
124
|
## Results and continuation
|
|
100
125
|
|
|
101
|
-
Each successful task returns a summary, ordered findings, and structured counts by blocking status and impact. Parent-facing task output identifies the effective Finding Scope. Findings contain `blocksAcceptance`, `impact`, `effort`, `confidence`, and an optional target-relative location. The Review Engine derives `
|
|
126
|
+
Each successful task returns a summary, ordered findings, required Criteria Coverage, and structured counts by blocking status and impact. Parent-facing task output identifies the effective Finding Scope. Findings contain `blocksAcceptance`, `impact`, `effort`, `confidence`, and an optional target-relative location. The Review Engine derives `issues` when any finding blocks acceptance, otherwise `incomplete` when Criteria Coverage is incomplete, otherwise `pass_with_findings` for advisory-only findings and `pass` for none; it never aggregates or reranks tasks.
|
|
127
|
+
|
|
128
|
+
When SuPi debugging is enabled, every finished task records a compact `review-task` Debug Event with trustworthy lifecycle, usage, outcome, and capability metrics (packet bytes, duration, turns, tool calls/errors, cache hit rate, verdict, and Reviewer Extension Set status).
|
|
102
129
|
|
|
103
130
|
Capability and cleanup warnings are execution provenance, not findings. By default, non-success diagnostics retain only bounded lifecycle metadata and redacted provider-owned error summaries; reviewer conversation, shell commands, tool arguments/results, and repository evidence are never retained.
|
|
104
131
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Shared workspace context and capability contracts for code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!__tests__"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mrclrchtr/supi-core": "4.
|
|
32
|
+
"@mrclrchtr/supi-core": "4.7.0"
|
|
33
33
|
},
|
|
34
34
|
"bundledDependencies": [
|
|
35
35
|
"@mrclrchtr/supi-core"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Shared workspace context and capability contracts for code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!__tests__"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mrclrchtr/supi-core": "4.
|
|
32
|
+
"@mrclrchtr/supi-core": "4.7.0"
|
|
33
33
|
},
|
|
34
34
|
"bundledDependencies": [
|
|
35
35
|
"@mrclrchtr/supi-core"
|
package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-lsp",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Language Server Protocol runtime for SuPi code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"vscode-jsonrpc": "^9.0.0",
|
|
38
38
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
39
39
|
"vscode-languageserver-types": "^3.17.5",
|
|
40
|
-
"@mrclrchtr/supi-code-runtime": "4.
|
|
41
|
-
"@mrclrchtr/supi-core": "4.
|
|
40
|
+
"@mrclrchtr/supi-code-runtime": "4.7.0",
|
|
41
|
+
"@mrclrchtr/supi-core": "4.7.0"
|
|
42
42
|
},
|
|
43
43
|
"bundledDependencies": [
|
|
44
44
|
"@mrclrchtr/supi-code-runtime",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Shared workspace context and capability contracts for code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!__tests__"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mrclrchtr/supi-core": "4.
|
|
32
|
+
"@mrclrchtr/supi-core": "4.7.0"
|
|
33
33
|
},
|
|
34
34
|
"bundledDependencies": [
|
|
35
35
|
"@mrclrchtr/supi-core"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-tree-sitter",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Structural AST analysis for SuPi code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"web-tree-sitter": "^0.26.8",
|
|
37
|
-
"@mrclrchtr/supi-code-runtime": "4.
|
|
38
|
-
"@mrclrchtr/supi-core": "4.
|
|
37
|
+
"@mrclrchtr/supi-code-runtime": "4.7.0",
|
|
38
|
+
"@mrclrchtr/supi-core": "4.7.0"
|
|
39
39
|
},
|
|
40
40
|
"bundledDependencies": [
|
|
41
41
|
"@mrclrchtr/supi-code-runtime",
|
|
@@ -60,7 +60,7 @@ function htmlId(tag: SyntaxNodeLike): string | null {
|
|
|
60
60
|
if (attribute.type !== "attribute") continue;
|
|
61
61
|
const name = directChild(attribute, "attribute_name");
|
|
62
62
|
if (name?.text.toLowerCase() !== "id") continue;
|
|
63
|
-
return firstDescendant(attribute, "attribute_value")?.text
|
|
63
|
+
return firstDescendant(attribute, "attribute_value")?.text ?? null;
|
|
64
64
|
}
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-intelligence",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "LSP and AST navigation, search, diagnostics, and refactoring",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"yaml": "^2.9.0",
|
|
38
|
-
"@mrclrchtr/supi-code-runtime": "4.
|
|
39
|
-
"@mrclrchtr/supi-core": "4.
|
|
40
|
-
"@mrclrchtr/supi-lsp": "4.
|
|
41
|
-
"@mrclrchtr/supi-tree-sitter": "4.
|
|
38
|
+
"@mrclrchtr/supi-code-runtime": "4.7.0",
|
|
39
|
+
"@mrclrchtr/supi-core": "4.7.0",
|
|
40
|
+
"@mrclrchtr/supi-lsp": "4.7.0",
|
|
41
|
+
"@mrclrchtr/supi-tree-sitter": "4.7.0"
|
|
42
42
|
},
|
|
43
43
|
"bundledDependencies": [
|
|
44
44
|
"@mrclrchtr/supi-code-runtime",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-review",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Parallel isolated reviews of trees, comparisons, and commits",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mrclrchtr/supi-
|
|
35
|
-
"@mrclrchtr/supi-
|
|
34
|
+
"@mrclrchtr/supi-core": "4.7.0",
|
|
35
|
+
"@mrclrchtr/supi-code-intelligence": "4.7.0"
|
|
36
36
|
},
|
|
37
37
|
"bundledDependencies": [
|
|
38
38
|
"@mrclrchtr/supi-code-intelligence",
|
package/src/git.ts
CHANGED
|
@@ -11,26 +11,33 @@ import type { ResolvedReviewTarget, ReviewSnapshot } from "./types.ts";
|
|
|
11
11
|
|
|
12
12
|
export { resolveReviewSnapshot, summarizeReviewSnapshot } from "./target/resolve.ts";
|
|
13
13
|
|
|
14
|
+
type FilesystemDiffTarget = Extract<
|
|
15
|
+
ResolvedReviewTarget,
|
|
16
|
+
{ kind: "working-tree" | "current-state" }
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
/** Pinned diff baseline for a filesystem target; current-state audits diff against HEAD. */
|
|
20
|
+
function baselineFor(target: FilesystemDiffTarget): string {
|
|
21
|
+
return "mergeBaseCommit" in target
|
|
22
|
+
? (target.mergeBaseCommit ?? target.headCommit)
|
|
23
|
+
: target.headCommit;
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
function withWorkingTreeIndex<T>(
|
|
15
27
|
cwd: string,
|
|
16
|
-
target:
|
|
28
|
+
target: FilesystemDiffTarget,
|
|
17
29
|
operation: (indexFile: string) => Promise<T>,
|
|
18
30
|
): Promise<T> {
|
|
19
|
-
return withReviewIndex(
|
|
20
|
-
cwd,
|
|
21
|
-
target.headCommit,
|
|
22
|
-
target.mergeBaseCommit ?? target.headCommit,
|
|
23
|
-
operation,
|
|
24
|
-
);
|
|
31
|
+
return withReviewIndex(cwd, target.headCommit, baselineFor(target), operation);
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
async function readWorkingTreeDiff(
|
|
28
35
|
root: string,
|
|
29
|
-
target:
|
|
36
|
+
target: FilesystemDiffTarget,
|
|
30
37
|
path?: string,
|
|
31
38
|
): Promise<string> {
|
|
32
39
|
return withWorkingTreeIndex(root, target, async (indexFile) => {
|
|
33
|
-
const baseline = target
|
|
40
|
+
const baseline = baselineFor(target);
|
|
34
41
|
const pathArgs = path ? ["--", path] : [];
|
|
35
42
|
const [tracked, untrackedText] = await Promise.all([
|
|
36
43
|
git(root, literalPathspec(["diff", ...DIFF_FLAGS, baseline, ...pathArgs]), indexFile),
|
|
@@ -60,11 +67,16 @@ export async function readReviewDiff(
|
|
|
60
67
|
): Promise<string> {
|
|
61
68
|
const root = snapshot.repositoryRoot;
|
|
62
69
|
const safe = path ? resolveReviewPath(root, path) : undefined;
|
|
63
|
-
|
|
70
|
+
// Current-State Audit has no change attribution; every state path is evidence.
|
|
71
|
+
if (
|
|
72
|
+
safe &&
|
|
73
|
+
snapshot.target.kind !== "current-state" &&
|
|
74
|
+
!snapshot.changes.some((change) => change.path === safe.path)
|
|
75
|
+
) {
|
|
64
76
|
throw new Error(`${safe.path} is not changed by this target.`);
|
|
65
77
|
}
|
|
66
78
|
const target = snapshot.target;
|
|
67
|
-
if (target.kind === "working-tree") {
|
|
79
|
+
if (target.kind === "working-tree" || target.kind === "current-state") {
|
|
68
80
|
return readWorkingTreeDiff(root, target, safe?.path);
|
|
69
81
|
}
|
|
70
82
|
const pathArgs = safe ? ["--", safe.path] : [];
|
package/src/review-input.ts
CHANGED
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
import { REVIEW_LIMITS } from "./review-limits.ts";
|
|
2
|
-
import type { ReviewInput } from "./types.ts";
|
|
2
|
+
import type { CriteriaSource, ReviewInput } from "./types.ts";
|
|
3
|
+
|
|
4
|
+
function normalizeCriteriaSources(
|
|
5
|
+
taskId: string,
|
|
6
|
+
sources?: CriteriaSource[],
|
|
7
|
+
): CriteriaSource[] | undefined {
|
|
8
|
+
if (sources === undefined) return undefined;
|
|
9
|
+
if (sources.length > REVIEW_LIMITS.criteriaSourcesPerTask) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Review task ${taskId} may list at most ${REVIEW_LIMITS.criteriaSourcesPerTask} criteria sources.`,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
const normalized: CriteriaSource[] = [];
|
|
15
|
+
const summaries = new Map<string, string>();
|
|
16
|
+
for (const source of sources) {
|
|
17
|
+
const reference = source.reference.trim();
|
|
18
|
+
const summary = source.summary.trim();
|
|
19
|
+
if (!reference || !summary) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Review task ${taskId} criteria source references and summaries must not be blank.`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (reference.length > REVIEW_LIMITS.criteriaReferenceCharacters) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Review task ${taskId} criteria source reference must not exceed ${REVIEW_LIMITS.criteriaReferenceCharacters} characters.`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (summary.length > REVIEW_LIMITS.criteriaSummaryCharacters) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Review task ${taskId} criteria source summary must not exceed ${REVIEW_LIMITS.criteriaSummaryCharacters.toLocaleString("en-US")} characters.`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const previous = summaries.get(reference);
|
|
35
|
+
if (previous !== undefined) {
|
|
36
|
+
if (previous !== summary) {
|
|
37
|
+
throw new Error(`Review task ${taskId} repeats criteria source ${reference}.`);
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
summaries.set(reference, summary);
|
|
42
|
+
normalized.push({ reference, summary });
|
|
43
|
+
}
|
|
44
|
+
return normalized;
|
|
45
|
+
}
|
|
3
46
|
|
|
4
47
|
/** Canonicalize and semantically validate review input for every adapter. */
|
|
5
48
|
export function normalizeReviewInput(review: ReviewInput): ReviewInput {
|
|
6
49
|
const sharedContext = review.sharedContext?.trim();
|
|
7
|
-
const tasks = review.tasks.map((task) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
50
|
+
const tasks = review.tasks.map((task) => {
|
|
51
|
+
const criteriaSources = normalizeCriteriaSources(task.id.trim(), task.criteriaSources);
|
|
52
|
+
return {
|
|
53
|
+
id: task.id.trim(),
|
|
54
|
+
instructions: task.instructions.trim(),
|
|
55
|
+
...(task.findingScope !== undefined ? { findingScope: task.findingScope } : {}),
|
|
56
|
+
...(criteriaSources ? { criteriaSources } : {}),
|
|
57
|
+
};
|
|
58
|
+
});
|
|
12
59
|
if (tasks.length < 1 || tasks.length > 4) {
|
|
13
60
|
throw new Error("Provide between one and four review tasks.");
|
|
14
61
|
}
|
package/src/review-limits.ts
CHANGED
|
@@ -8,4 +8,10 @@ export const REVIEW_LIMITS = {
|
|
|
8
8
|
findingTitleCharacters: 200,
|
|
9
9
|
findingDescriptionCharacters: 8_000,
|
|
10
10
|
locationPathCharacters: 4_096,
|
|
11
|
+
criteriaSourcesPerTask: 5,
|
|
12
|
+
criteriaReferenceCharacters: 256,
|
|
13
|
+
criteriaSummaryCharacters: 2_000,
|
|
14
|
+
criteriaCoverageReasonCharacters: 500,
|
|
15
|
+
reviewScopePathsPerTarget: 16,
|
|
16
|
+
reviewScopePathCharacters: 4_096,
|
|
11
17
|
} as const;
|
package/src/review-result.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { REVIEW_LIMITS } from "./review-limits.ts";
|
|
2
2
|
import { normalizeRepositoryRelativePath } from "./review-path.ts";
|
|
3
3
|
import type {
|
|
4
|
+
CriteriaCoverage,
|
|
4
5
|
FindingCounts,
|
|
5
6
|
NormalizedReviewSubmission,
|
|
6
7
|
ReviewFinding,
|
|
@@ -44,6 +45,22 @@ function countFindings(
|
|
|
44
45
|
return counts;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
function normalizeCriteriaCoverage(coverage: CriteriaCoverage): CriteriaCoverage {
|
|
49
|
+
if (!coverage) throw new Error("Review submissions must include criteria coverage.");
|
|
50
|
+
const reason = ("reason" in coverage ? coverage.reason : undefined)?.trim();
|
|
51
|
+
if (coverage.status === "complete") {
|
|
52
|
+
if (reason) throw new Error("Complete criteria coverage must not include a reason.");
|
|
53
|
+
return { status: "complete" };
|
|
54
|
+
}
|
|
55
|
+
if (!reason) throw new Error("Incomplete criteria coverage needs a criteria coverage reason.");
|
|
56
|
+
if (reason.length > REVIEW_LIMITS.criteriaCoverageReasonCharacters) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Criteria coverage reason must not exceed ${REVIEW_LIMITS.criteriaCoverageReasonCharacters} characters.`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return { status: "incomplete", reason };
|
|
62
|
+
}
|
|
63
|
+
|
|
47
64
|
/** Derive an acceptance verdict and structured finding counts without reordering findings. */
|
|
48
65
|
export function normalizeReviewSubmission(
|
|
49
66
|
submission: ReviewSubmissionInput,
|
|
@@ -52,8 +69,10 @@ export function normalizeReviewSubmission(
|
|
|
52
69
|
throw new Error(`A review task may submit at most ${REVIEW_LIMITS.findingsPerTask} findings.`);
|
|
53
70
|
}
|
|
54
71
|
const findingCounts = countFindings(submission.findings);
|
|
72
|
+
const criteriaCoverage = normalizeCriteriaCoverage(submission.criteriaCoverage);
|
|
55
73
|
return {
|
|
56
74
|
summary: requireText(submission.summary, "Review summary", REVIEW_LIMITS.summaryCharacters),
|
|
75
|
+
criteriaCoverage,
|
|
57
76
|
findings: submission.findings.map((finding, index) => {
|
|
58
77
|
if (
|
|
59
78
|
!Number.isFinite(finding.confidence) ||
|
|
@@ -104,8 +123,10 @@ export function normalizeReviewSubmission(
|
|
|
104
123
|
verdict:
|
|
105
124
|
findingCounts.blocking > 0
|
|
106
125
|
? "issues"
|
|
107
|
-
:
|
|
108
|
-
? "
|
|
109
|
-
:
|
|
126
|
+
: criteriaCoverage?.status === "incomplete"
|
|
127
|
+
? "incomplete"
|
|
128
|
+
: findingCounts.total > 0
|
|
129
|
+
? "pass_with_findings"
|
|
130
|
+
: "pass",
|
|
110
131
|
};
|
|
111
132
|
}
|
package/src/review.ts
CHANGED
|
@@ -32,15 +32,30 @@ const DEFAULT_REVIEW: ReviewInput = {
|
|
|
32
32
|
],
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
const CURRENT_STATE_DEFAULT_REVIEW: ReviewInput = {
|
|
36
|
+
tasks: [
|
|
37
|
+
{
|
|
38
|
+
id: "general",
|
|
39
|
+
instructions: "Review the current state against the requested criteria.",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function defaultReviewFor(target: ReviewTargetSpec): ReviewInput {
|
|
45
|
+
return target.kind === "current-state" ? CURRENT_STATE_DEFAULT_REVIEW : DEFAULT_REVIEW;
|
|
46
|
+
}
|
|
47
|
+
|
|
35
48
|
async function selectTarget(ctx: CommandContext): Promise<ReviewTargetSpec | undefined> {
|
|
36
49
|
const kind = await ctx.ui.select("Review target", [
|
|
37
50
|
"Uncommitted changes against HEAD",
|
|
38
51
|
"Current work against a base branch",
|
|
39
52
|
"Committed changes against a base branch",
|
|
40
53
|
"Single commit",
|
|
54
|
+
"Current state audit",
|
|
41
55
|
]);
|
|
42
56
|
if (!kind) return undefined;
|
|
43
57
|
if (kind === "Uncommitted changes against HEAD") return { kind: "working-tree" };
|
|
58
|
+
if (kind === "Current state audit") return { kind: "current-state" };
|
|
44
59
|
const choices =
|
|
45
60
|
kind === "Single commit" ? await listRecentCommits(ctx.cwd) : await listLocalBranches(ctx.cwd);
|
|
46
61
|
const label = await ctx.ui.select(
|
|
@@ -116,6 +131,7 @@ async function editReviewInteractive(
|
|
|
116
131
|
id,
|
|
117
132
|
instructions,
|
|
118
133
|
...(existing?.findingScope ? { findingScope: existing.findingScope } : {}),
|
|
134
|
+
...(existing?.criteriaSources?.length ? { criteriaSources: existing.criteriaSources } : {}),
|
|
119
135
|
});
|
|
120
136
|
}
|
|
121
137
|
|
|
@@ -197,7 +213,7 @@ async function prepareInteractiveReview(
|
|
|
197
213
|
ctx.ui.notify("Planner unavailable; edit replacement tasks to continue.", "warning");
|
|
198
214
|
}
|
|
199
215
|
return {
|
|
200
|
-
review: outcome.plan.plannerDraft ??
|
|
216
|
+
review: outcome.plan.plannerDraft ?? defaultReviewFor(target),
|
|
201
217
|
planId: outcome.plan.id,
|
|
202
218
|
};
|
|
203
219
|
}
|
|
@@ -268,9 +284,20 @@ async function runCommand(ctx: CommandContext, services: ReviewCommandServices):
|
|
|
268
284
|
? await prepareInteractiveReview(ctx, target, reviewerModel, planStore)
|
|
269
285
|
: undefined;
|
|
270
286
|
if (planning === "AI suggests tasks" && !prepared) return;
|
|
271
|
-
const
|
|
287
|
+
const baseReview = prepared?.review ?? defaultReviewFor(target);
|
|
272
288
|
const planId = prepared?.planId;
|
|
273
289
|
|
|
290
|
+
// Current-State Audit fixes criteria-only scope; strip planner-default findingScope
|
|
291
|
+
// before the editor copies it into user-facing tasks. Copy rather than mutate so the
|
|
292
|
+
// plan store's planner draft is never edited in place.
|
|
293
|
+
const review =
|
|
294
|
+
target.kind === "current-state"
|
|
295
|
+
? {
|
|
296
|
+
...baseReview,
|
|
297
|
+
tasks: baseReview.tasks.map(({ findingScope: _stripped, ...rest }) => rest),
|
|
298
|
+
}
|
|
299
|
+
: baseReview;
|
|
300
|
+
|
|
274
301
|
const edited = await editReviewInteractive(ctx, review, {
|
|
275
302
|
allowResize: planning === "Write my own tasks",
|
|
276
303
|
});
|