@unifan/pi-review-zh 1.0.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/CHANGELOG.md +540 -0
- package/LICENSE +15 -0
- package/README.md +55 -0
- package/agents/bugbot.md +46 -0
- package/agents/claude-md-compliance.md +46 -0
- package/agents/code-comments.md +43 -0
- package/agents/conventions.md +41 -0
- package/agents/gate.md +70 -0
- package/agents/history-context.md +45 -0
- package/agents/lite-review.md +51 -0
- package/agents/security-review.md +45 -0
- package/index.ts +205 -0
- package/package.json +38 -0
- package/reference/README.md +20 -0
- package/reference/claude-code-review.md +133 -0
- package/reference/cursor-review-skills.md +72 -0
- package/reference/pi-review-roadmap.md +183 -0
- package/reference/structured-output.md +26 -0
- package/reference/v0.2-plan.md +268 -0
- package/src/cli-args.ts +105 -0
- package/src/config.ts +340 -0
- package/src/directive.ts +481 -0
- package/src/gate-enforce.ts +151 -0
- package/src/lean-agents.ts +105 -0
- package/src/pr-ref.ts +39 -0
- package/src/report-tool.ts +394 -0
- package/src/report.ts +399 -0
- package/src/review-report.ts +279 -0
- package/src/review-run.ts +568 -0
- package/src/target-workspace.ts +239 -0
- package/src/tool-wrapper.ts +75 -0
- package/src/tui-renderer.ts +92 -0
- package/src/types.ts +207 -0
- package/src/workflow-schemas.ts +172 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema fragments injected as `outputSchema` on each reviewer and the
|
|
3
|
+
* gate. Kept in sync with src/schema.ts (used by the legacy spawn pipeline).
|
|
4
|
+
*
|
|
5
|
+
* The plugin no longer reads reviewer Markdown text; the workflowScript
|
|
6
|
+
* receives validated `result.structuredOutput` from pi-subagents.
|
|
7
|
+
*/
|
|
8
|
+
import type { IssueSeverity, IssueCategory, Verdict } from "./types.js";
|
|
9
|
+
|
|
10
|
+
export type JsonSchema = Record<string, unknown>;
|
|
11
|
+
|
|
12
|
+
const SEVERITY: IssueSeverity[] = ["blocker", "major", "minor", "nit"];
|
|
13
|
+
const CATEGORY: IssueCategory[] = [
|
|
14
|
+
"compliance",
|
|
15
|
+
"bug",
|
|
16
|
+
"convention",
|
|
17
|
+
"history",
|
|
18
|
+
"security",
|
|
19
|
+
"performance",
|
|
20
|
+
"docs",
|
|
21
|
+
"other",
|
|
22
|
+
];
|
|
23
|
+
const VERDICT: Verdict[] = ["approve", "request_changes", "comment"];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Stable JSON Schema describing the structured output of every reviewer.
|
|
27
|
+
* `status` distinguishes runtime `ok` (tool succeeded) from business
|
|
28
|
+
* `limited/skipped` (no findings because of missing context, not silence).
|
|
29
|
+
*/
|
|
30
|
+
export const REVIEWER_OUTPUT_SCHEMA: JsonSchema = {
|
|
31
|
+
type: "object",
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
required: ["status", "issues", "summary", "coverage"],
|
|
34
|
+
properties: {
|
|
35
|
+
status: {
|
|
36
|
+
type: "string",
|
|
37
|
+
enum: ["ok", "limited", "skipped"],
|
|
38
|
+
description:
|
|
39
|
+
"ok = reviewer produced findings normally; limited = could not run some checks (still may have issues); skipped = lane does not apply.",
|
|
40
|
+
},
|
|
41
|
+
issues: {
|
|
42
|
+
type: "array",
|
|
43
|
+
maxItems: 200,
|
|
44
|
+
items: {
|
|
45
|
+
type: "object",
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
required: ["file", "category", "severity", "confidence", "evidence", "fingerprint"],
|
|
48
|
+
properties: {
|
|
49
|
+
file: { type: "string", minLength: 1, maxLength: 500 },
|
|
50
|
+
line: { type: "integer", minimum: 1 },
|
|
51
|
+
relatedChangedLine: { type: "integer", minimum: 1 },
|
|
52
|
+
category: { type: "string", enum: CATEGORY },
|
|
53
|
+
severity: { type: "string", enum: SEVERITY },
|
|
54
|
+
confidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
55
|
+
evidence: { type: "string", minLength: 1, maxLength: 280 },
|
|
56
|
+
fingerprint: {
|
|
57
|
+
type: "string",
|
|
58
|
+
minLength: 1,
|
|
59
|
+
maxLength: 80,
|
|
60
|
+
description:
|
|
61
|
+
"Stable id (file:line:category[:short-hash-of-evidence]) so the gate can dedupe across reviewers.",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
summary: { type: "string", minLength: 1, maxLength: 2000 },
|
|
67
|
+
coverage: {
|
|
68
|
+
type: "object",
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
required: ["filesChecked", "commandsRun", "limitations"],
|
|
71
|
+
properties: {
|
|
72
|
+
filesChecked: { type: "array", items: { type: "string" } },
|
|
73
|
+
commandsRun: { type: "array", items: { type: "string" } },
|
|
74
|
+
limitations: {
|
|
75
|
+
type: "array",
|
|
76
|
+
items: { type: "string" },
|
|
77
|
+
description: "Plain-language reasons for limited/skipped status.",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Stable JSON Schema describing the gate's structured output. Adds
|
|
86
|
+
* `dispositions` so every candidate (kept/dropped/merged) is auditable.
|
|
87
|
+
*/
|
|
88
|
+
export const GATE_OUTPUT_SCHEMA: JsonSchema = {
|
|
89
|
+
type: "object",
|
|
90
|
+
additionalProperties: false,
|
|
91
|
+
required: ["status", "verdict", "issues", "dispositions", "reason"],
|
|
92
|
+
properties: {
|
|
93
|
+
status: {
|
|
94
|
+
type: "string",
|
|
95
|
+
enum: ["ok", "limited", "skipped"],
|
|
96
|
+
},
|
|
97
|
+
verdict: { type: "string", enum: VERDICT },
|
|
98
|
+
issues: {
|
|
99
|
+
type: "array",
|
|
100
|
+
maxItems: 500,
|
|
101
|
+
items: {
|
|
102
|
+
type: "object",
|
|
103
|
+
additionalProperties: false,
|
|
104
|
+
required: ["file", "category", "severity", "confidence", "evidence", "fingerprint"],
|
|
105
|
+
properties: {
|
|
106
|
+
file: { type: "string", minLength: 1, maxLength: 500 },
|
|
107
|
+
line: { type: "integer", minimum: 1 },
|
|
108
|
+
relatedChangedLine: { type: "integer", minimum: 1 },
|
|
109
|
+
category: { type: "string", enum: CATEGORY },
|
|
110
|
+
severity: { type: "string", enum: SEVERITY },
|
|
111
|
+
confidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
112
|
+
evidence: { type: "string", minLength: 1, maxLength: 280 },
|
|
113
|
+
fingerprint: { type: "string", minLength: 1, maxLength: 80 },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
dispositions: {
|
|
118
|
+
type: "array",
|
|
119
|
+
description:
|
|
120
|
+
"Per-candidate disposition: kept | dropped | merged. Required for every reviewer candidate so reports can audit threshold/dedupe/verify decisions.",
|
|
121
|
+
items: {
|
|
122
|
+
type: "object",
|
|
123
|
+
additionalProperties: false,
|
|
124
|
+
required: ["fingerprint", "decision", "originalConfidence", "finalConfidence", "reason"],
|
|
125
|
+
properties: {
|
|
126
|
+
fingerprint: { type: "string", minLength: 1, maxLength: 80 },
|
|
127
|
+
decision: { type: "string", enum: ["kept", "dropped", "merged"] },
|
|
128
|
+
originalConfidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
129
|
+
finalConfidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
130
|
+
sourceReviewers: {
|
|
131
|
+
type: "array",
|
|
132
|
+
items: { type: "string" },
|
|
133
|
+
},
|
|
134
|
+
reason: { type: "string", minLength: 1, maxLength: 500 },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
reason: { type: "string", minLength: 1, maxLength: 500 },
|
|
139
|
+
coverage: {
|
|
140
|
+
type: "object",
|
|
141
|
+
additionalProperties: false,
|
|
142
|
+
properties: {
|
|
143
|
+
limitations: { type: "array", items: { type: "string" } },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Serialize a JSON Schema as a JS string literal safe to embed in the
|
|
151
|
+
* generated workflowScript. Avoids escaping mistakes from JSON.stringify +
|
|
152
|
+
* double-quoting gymnastics.
|
|
153
|
+
*/
|
|
154
|
+
export function serializeSchemaForJs(schema: JsonSchema): string {
|
|
155
|
+
return JSON.stringify(schema);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Serialize a JSON Schema as a multi-line JS object literal for embedding
|
|
160
|
+
* directly in the generated workflowScript (v0.7.3). The single-line form
|
|
161
|
+
* produced 1400+ character lines — the exact spot where the main agent's
|
|
162
|
+
* copy slipped a character (PR 19291 incident, `"maxLength":80",`).
|
|
163
|
+
* Multi-line keeps every line short enough to copy reliably.
|
|
164
|
+
*/
|
|
165
|
+
export function serializeSchemaAsObjectLiteral(schema: JsonSchema, indent = " "): string {
|
|
166
|
+
const json = JSON.stringify(schema, null, 2);
|
|
167
|
+
// Indent every line so the literal sits cleanly inside the script body.
|
|
168
|
+
return json
|
|
169
|
+
.split("\n")
|
|
170
|
+
.map((line, i) => (i === 0 ? line : indent + line))
|
|
171
|
+
.join("\n");
|
|
172
|
+
}
|