@webpieces/rules-config 0.4.815 → 0.4.817
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/package.json +1 -1
- package/src/checklist-instructions.d.ts +3 -3
- package/src/checklist-instructions.js +6 -6
- package/src/checklist-instructions.js.map +1 -1
- package/src/checklist-override.d.ts +4 -4
- package/src/checklist-override.js +16 -16
- package/src/checklist-override.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +4 -4
- package/src/index.js.map +1 -1
- package/src/review-json-data.d.ts +2 -2
- package/src/review-json-data.js +6 -6
- package/src/review-json-data.js.map +1 -1
- package/src/review-json.d.ts +33 -32
- package/src/review-json.js +91 -82
- package/src/review-json.js.map +1 -1
- package/src/review-provenance.d.ts +2 -2
- package/src/review-provenance.js +7 -7
- package/src/review-provenance.js.map +1 -1
- package/src/reviewer-instructions.d.ts +1 -1
- package/src/reviewer-instructions.js +1 -1
- package/src/reviewer-instructions.js.map +1 -1
- package/src/state-dir.d.ts +1 -1
- package/src/state-dir.js +1 -1
- package/src/state-dir.js.map +1 -1
- package/src/summary-json-schema-renderer.d.ts +4 -0
- package/src/{review-json-schema-renderer.js → summary-json-schema-renderer.js} +7 -7
- package/src/summary-json-schema-renderer.js.map +1 -0
- package/templates/webpieces.git-workflow.md +6 -6
- package/templates/webpieces.location-matrix.md +1 -1
- package/templates/webpieces.mergeprocess.md +1 -1
- package/templates/webpieces.review-checklists.md +5 -5
- package/src/review-json-schema-renderer.d.ts +0 -4
- package/src/review-json-schema-renderer.js.map +0 -1
package/src/review-json.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReviewJsonService = exports.PrContext = exports.ChecklistVerdict = exports.CK_BAD_FORMAT = exports.CK_MISSING = exports.CK_FAIL = exports.CK_OVERRIDDEN = exports.CK_WARN = exports.CK_PASS = exports.
|
|
3
|
+
exports.ReviewJsonService = exports.PrContext = exports.ChecklistVerdict = exports.CK_BAD_FORMAT = exports.CK_MISSING = exports.CK_FAIL = exports.CK_OVERRIDDEN = exports.CK_WARN = exports.CK_PASS = exports.PrSummary = exports.ChecklistReviewContext = exports.RequiredChecklist = exports.ChecklistResult = exports.SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS = exports.VERDICT_STATUSES = exports.VERDICT_RED = exports.VERDICT_YELLOW = exports.VERDICT_GREEN = exports.checklistOverrideService = exports.ChecklistOverrideService = exports.ChecklistOverride = void 0;
|
|
4
4
|
exports.prDirFor = prDirFor;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
5
|
+
exports.summaryJsonPath = summaryJsonPath;
|
|
6
|
+
exports.summaryJsonSchemaHint = summaryJsonSchemaHint;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
8
|
const fs = tslib_1.__importStar(require("fs"));
|
|
9
9
|
const path = tslib_1.__importStar(require("path"));
|
|
@@ -12,7 +12,7 @@ const constants_1 = require("./constants");
|
|
|
12
12
|
const state_dir_1 = require("./state-dir");
|
|
13
13
|
const inform_ai_error_1 = require("./inform-ai-error");
|
|
14
14
|
const to_error_1 = require("./to-error");
|
|
15
|
-
const
|
|
15
|
+
const summary_json_schema_renderer_1 = require("./summary-json-schema-renderer");
|
|
16
16
|
const verdict_schema_renderer_1 = require("./verdict-schema-renderer");
|
|
17
17
|
const checklist_override_1 = require("./checklist-override");
|
|
18
18
|
Object.defineProperty(exports, "ChecklistOverride", { enumerable: true, get: function () { return checklist_override_1.ChecklistOverride; } });
|
|
@@ -27,7 +27,7 @@ Object.defineProperty(exports, "SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS", { enumera
|
|
|
27
27
|
Object.defineProperty(exports, "ChecklistResult", { enumerable: true, get: function () { return review_json_data_1.ChecklistResult; } });
|
|
28
28
|
Object.defineProperty(exports, "RequiredChecklist", { enumerable: true, get: function () { return review_json_data_1.RequiredChecklist; } });
|
|
29
29
|
Object.defineProperty(exports, "ChecklistReviewContext", { enumerable: true, get: function () { return review_json_data_1.ChecklistReviewContext; } });
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "PrSummary", { enumerable: true, get: function () { return review_json_data_1.PrSummary; } });
|
|
31
31
|
Object.defineProperty(exports, "CK_PASS", { enumerable: true, get: function () { return review_json_data_1.CK_PASS; } });
|
|
32
32
|
Object.defineProperty(exports, "CK_WARN", { enumerable: true, get: function () { return review_json_data_1.CK_WARN; } });
|
|
33
33
|
Object.defineProperty(exports, "CK_OVERRIDDEN", { enumerable: true, get: function () { return review_json_data_1.CK_OVERRIDDEN; } });
|
|
@@ -38,18 +38,18 @@ Object.defineProperty(exports, "ChecklistVerdict", { enumerable: true, get: func
|
|
|
38
38
|
Object.defineProperty(exports, "PrContext", { enumerable: true, get: function () { return review_json_data_1.PrContext; } });
|
|
39
39
|
const RISK_LEVELS = ['green', 'yellow', 'red'];
|
|
40
40
|
const EMOJI_FOR_LEVEL = { green: '🟢', yellow: '🟡', red: '🔴' };
|
|
41
|
-
// Where `wp-finish-upsert-pr` retires the
|
|
41
|
+
// Where `wp-finish-upsert-pr` retires the summary.json it just consumed, and the note it stamps on the way.
|
|
42
42
|
// The key sorts first in the written JSON because it is written first — an AI that opens the file to see
|
|
43
|
-
// whether it can reuse the
|
|
44
|
-
const
|
|
43
|
+
// whether it can reuse the summary reads what the file IS before it reads a title it might be tempted to keep.
|
|
44
|
+
const OLD_SUMMARY_FILE = 'old-summary.json';
|
|
45
45
|
const ARCHIVE_NOTE_KEY = '_ARCHIVED_AUDIT_ONLY';
|
|
46
|
-
const ARCHIVE_NOTE = 'ARCHIVE — this is the
|
|
47
|
-
'purposes only. It is NOT the
|
|
48
|
-
'update, which has since moved. If you are
|
|
46
|
+
const ARCHIVE_NOTE = 'ARCHIVE — this is the PR summary from the PREVIOUS wp-finish-upsert-pr run on this branch, kept for audit ' +
|
|
47
|
+
'purposes only. It is NOT the summary for a new round: it describes the code as of the last PR ' +
|
|
48
|
+
'update, which has since moved. If you are updating the PR again, write a FRESH summary.json at the path ' +
|
|
49
49
|
'pnpm wp-review-upsert-pr prints; do not copy this file\'s title, summary or risk level forward without ' +
|
|
50
|
-
're-deciding each one. Overwritten by every finish, so only the most recent
|
|
50
|
+
're-deciding each one. Overwritten by every finish, so only the most recent summary is ever here.';
|
|
51
51
|
// The same stamp, for a retired per-checklist verdict. Verdict files get their OWN wording because the two
|
|
52
|
-
// archives answer different questions: old-
|
|
52
|
+
// archives answer different questions: old-summary.json holds a description of the code, this holds a
|
|
53
53
|
// REVIEWER'S DECISION. The one thing that must not happen is a reader treating an archived red as the live
|
|
54
54
|
// verdict — the whole reason the file was moved rather than copied — so the note says that outright.
|
|
55
55
|
const CHECKLIST_ARCHIVE_NOTE = 'ARCHIVE — this is a checklist verdict from a PREVIOUS reviewer run on this branch, kept for audit ' +
|
|
@@ -57,7 +57,7 @@ const CHECKLIST_ARCHIVE_NOTE = 'ARCHIVE — this is a checklist verdict from a P
|
|
|
57
57
|
'refused the PR, and the gate moved it here so the only way forward is a FRESH review-<id>.json written ' +
|
|
58
58
|
'by a real reviewer run. Do not copy its status back onto the live path to get past the gate. ' +
|
|
59
59
|
'Overwritten by every retirement, so only the most recently retired verdict is ever here.';
|
|
60
|
-
/** Locates + loads/validates the AI-authored
|
|
60
|
+
/** Locates + loads/validates the AI-authored summary.json. `@injectable(bindingScopeValues.Singleton)` so it's drawn in the design. */
|
|
61
61
|
let ReviewJsonService = class ReviewJsonService {
|
|
62
62
|
dotDir;
|
|
63
63
|
overrides;
|
|
@@ -66,59 +66,59 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
66
66
|
this.overrides = overrides;
|
|
67
67
|
}
|
|
68
68
|
// The per-feature PR working dir: `<worktree>/.webpieces/pr-review/<feature>`. AI-WRITABLE scope,
|
|
69
|
-
// not local() — an agent AUTHORS
|
|
69
|
+
// not local() — an agent AUTHORS summary.json here, and each reviewer subagent authors its own
|
|
70
70
|
// review-<id>.json beside it. A worktree-isolated agent's Write is refused for any path under the
|
|
71
71
|
// shared checkout, which is where local() puts this, so local() made both files unwritable by the
|
|
72
72
|
// very agents the flow instructs to write them. See DotWebpieces.aiWritable() for the full account.
|
|
73
73
|
prDirFor(repoRoot, featureName) {
|
|
74
74
|
return this.dotDir.aiWritableFile(repoRoot, constants_1.PR_REVIEW_DIR, featureName);
|
|
75
75
|
}
|
|
76
|
-
// Absolute path of the
|
|
77
|
-
|
|
78
|
-
return path.join(this.prDirFor(repoRoot, featureName), '
|
|
76
|
+
// Absolute path of the summary.json for a feature — beside pr-body.md, keyed by branch name.
|
|
77
|
+
summaryJsonPath(repoRoot, featureName) {
|
|
78
|
+
return path.join(this.prDirFor(repoRoot, featureName), 'summary.json');
|
|
79
79
|
}
|
|
80
80
|
// Absolute path of the pr-context.json for a feature (the diff base/head + changed files).
|
|
81
81
|
prContextPath(repoRoot, featureName) {
|
|
82
82
|
return path.join(this.prDirFor(repoRoot, featureName), 'pr-context.json');
|
|
83
83
|
}
|
|
84
|
-
// Where a consumed
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
return path.join(path.dirname(
|
|
84
|
+
// Where a consumed summary.json is archived to, beside it. Always the SAME path — it holds the last
|
|
85
|
+
// summary and only the last one, so it can never be mistaken for a series that means something.
|
|
86
|
+
oldSummaryJsonPath(summaryJsonFilePath) {
|
|
87
|
+
return path.join(path.dirname(summaryJsonFilePath), OLD_SUMMARY_FILE);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* Retire the
|
|
91
|
-
* note saying what it is. Returns the archive path, or '' when there was nothing to archive.
|
|
90
|
+
* Retire the PR summary `wp-finish-upsert-pr` just used: move summary.json to old-summary.json, stamped
|
|
91
|
+
* with a note saying what it is. Returns the archive path, or '' when there was nothing to archive.
|
|
92
92
|
*
|
|
93
|
-
* The point is the MOVE, not the copy.
|
|
94
|
-
* file describing a
|
|
93
|
+
* The point is the MOVE, not the copy. summary.json left in place after a PR is posted is a live-looking
|
|
94
|
+
* file describing a PR update that already happened, and the next run of stage ② on this branch finds it
|
|
95
95
|
* sitting there — so a reviewer subagent that judges the PR's stated intent (its title, summary or risk
|
|
96
|
-
* level) can read the previous run's
|
|
96
|
+
* level) can read the previous run's summary and return GREEN against a title that no longer exists.
|
|
97
97
|
* Nothing in the verdict distinguishes that from a real pass. Moving it means the only way to reach
|
|
98
|
-
* finish again is to write a fresh one, and {@link
|
|
98
|
+
* finish again is to write a fresh one, and {@link loadSummaryJson} points at the archive when it is
|
|
99
99
|
* missing so the archive reads as an audit trail rather than as a lost file.
|
|
100
100
|
*
|
|
101
101
|
* Called only after the PR is actually up: a finish that failed before publishing must stay re-runnable.
|
|
102
102
|
*/
|
|
103
|
-
|
|
104
|
-
if (!fs.existsSync(
|
|
103
|
+
archiveSummaryJson(summaryJsonFilePath) {
|
|
104
|
+
if (!fs.existsSync(summaryJsonFilePath))
|
|
105
105
|
return '';
|
|
106
|
-
const archivePath = this.
|
|
107
|
-
const raw = fs.readFileSync(
|
|
106
|
+
const archivePath = this.oldSummaryJsonPath(summaryJsonFilePath);
|
|
107
|
+
const raw = fs.readFileSync(summaryJsonFilePath, 'utf8');
|
|
108
108
|
fs.writeFileSync(archivePath, this.archivedBody(raw, ARCHIVE_NOTE));
|
|
109
|
-
fs.rmSync(
|
|
109
|
+
fs.rmSync(summaryJsonFilePath);
|
|
110
110
|
return archivePath;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* The archived bytes: the original JSON with an AUDIT-ONLY note as its FIRST key, so anything that opens
|
|
114
114
|
* the file — human or AI — reads what it is before it reads any of its content.
|
|
115
115
|
*
|
|
116
|
-
* `note` is a parameter rather than a constant because two different files are archived here (
|
|
116
|
+
* `note` is a parameter rather than a constant because two different files are archived here (summary.json
|
|
117
117
|
* and review-<id>.json) and they need to say different things, while the stamping MECHANICS — parse,
|
|
118
118
|
* note first, original keys in order, fall back to raw — are identical. One implementation, two texts;
|
|
119
119
|
* a second copy of this method would be the thing that drifts.
|
|
120
120
|
*
|
|
121
|
-
* Falls back to the raw bytes when they do not parse. For
|
|
121
|
+
* Falls back to the raw bytes when they do not parse. For summary.json `loadSummaryJson` has already
|
|
122
122
|
* accepted the file so that is close to impossible, but a verdict file is written by a subagent and may
|
|
123
123
|
* be half-written or not an object at all — and preserving the original always beats losing it to a
|
|
124
124
|
* stamping failure, since the archive exists precisely to be the record.
|
|
@@ -204,42 +204,51 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
204
204
|
return new review_json_data_1.ChecklistReviewContext('', p);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
// Copy-paste
|
|
208
|
-
|
|
209
|
-
return new
|
|
207
|
+
// Copy-paste summary.json schema shared by every command that asks the coordinating AI to write it.
|
|
208
|
+
summaryJsonSchemaHint(filePath, mainAgentInstructions = '') {
|
|
209
|
+
return new summary_json_schema_renderer_1.SummaryJsonSchemaRenderer().render(filePath, mainAgentInstructions);
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
|
-
* The extra line the "no
|
|
212
|
+
* The extra line the "no summary.json" complaint carries when a PREVIOUS summary was archived here. It
|
|
213
213
|
* turns a bare "not found" — which reads as data loss, and invites hunting for the file — into the fact:
|
|
214
|
-
* the last finish consumed it, and the archive is audit material, not a
|
|
214
|
+
* the last finish consumed it, and the archive is audit material, not a summary to reuse.
|
|
215
215
|
*/
|
|
216
|
-
|
|
217
|
-
const archive = this.
|
|
216
|
+
archivedSummaryHint(filePath) {
|
|
217
|
+
const archive = this.oldSummaryJsonPath(filePath);
|
|
218
218
|
if (!fs.existsSync(archive))
|
|
219
219
|
return '';
|
|
220
|
-
return `\nA PREVIOUS
|
|
221
|
-
`That file is for AUDIT ONLY — it
|
|
220
|
+
return `\nA PREVIOUS PR summary was archived to ${archive} when the last pnpm wp-finish-upsert-pr consumed it.\n` +
|
|
221
|
+
`That file is for AUDIT ONLY — it describes code this branch has since moved past. Write a fresh one:`;
|
|
222
|
+
}
|
|
223
|
+
// Names summary.json when the author wrote its OLD name (review.json until #1033 — refused by Claude
|
|
224
|
+
// auto-mode as Self-Approval beside the review-<id>.json verdicts). HARD CUT: the stale file is never read.
|
|
225
|
+
renamedFileHint(filePath) {
|
|
226
|
+
const stale = path.join(path.dirname(filePath), 'review.json');
|
|
227
|
+
if (!fs.existsSync(stale))
|
|
228
|
+
return '';
|
|
229
|
+
return `\n${stale} is IGNORED — the author's file was renamed to summary.json. ` +
|
|
230
|
+
`Write the same JSON to ${filePath} instead.`;
|
|
222
231
|
}
|
|
223
|
-
// The per-checklist review file path that sits beside
|
|
224
|
-
checklistResultPath(
|
|
225
|
-
return path.join(path.dirname(
|
|
232
|
+
// The per-checklist review file path that sits beside summary.json: review-<id>.json.
|
|
233
|
+
checklistResultPath(summaryJsonFilePath, checklistId) {
|
|
234
|
+
return path.join(path.dirname(summaryJsonFilePath), `review-${checklistId}.json`);
|
|
226
235
|
}
|
|
227
236
|
/**
|
|
228
237
|
* Where a RETIRED verdict for one checklist goes: `review-<id>.json.old`, beside the live path.
|
|
229
238
|
*
|
|
230
|
-
* Mirrors {@link
|
|
239
|
+
* Mirrors {@link oldSummaryJsonPath} deliberately, including its single-slot rule: ALWAYS the same path,
|
|
231
240
|
* so it holds the last retired verdict and only the last one. A series (`.old.old`, `.old.1`) would read
|
|
232
241
|
* as though the number of retirements meant something, and nothing downstream can interpret that — the
|
|
233
242
|
* one fact worth keeping is "this checklist refused before, here is what it said".
|
|
234
243
|
*/
|
|
235
|
-
oldChecklistResultPath(
|
|
236
|
-
return `${this.checklistResultPath(
|
|
244
|
+
oldChecklistResultPath(summaryJsonFilePath, checklistId) {
|
|
245
|
+
return `${this.checklistResultPath(summaryJsonFilePath, checklistId)}.old`;
|
|
237
246
|
}
|
|
238
247
|
/**
|
|
239
248
|
* Retire one checklist's verdict: MOVE review-<id>.json to review-<id>.json.old, stamped with a note
|
|
240
249
|
* saying what it is. Returns the archive path, or '' when there was nothing to archive.
|
|
241
250
|
*
|
|
242
|
-
* The point is the MOVE, exactly as in {@link
|
|
251
|
+
* The point is the MOVE, exactly as in {@link archiveSummaryJson}. A red verdict left on the live path is
|
|
243
252
|
* re-read by the next run and re-reported as the CURRENT state of the branch, so the branch keeps being
|
|
244
253
|
* refused for a finding that may already be fixed — and the fix, when it comes, silently overwrites the
|
|
245
254
|
* only record that the gate ever refused anything. Moving it makes the refusal durable and makes a fresh
|
|
@@ -251,32 +260,32 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
251
260
|
* verdicts ARE deliberately reused across finish attempts, and retiring one would force a needless (and
|
|
252
261
|
* expensive) subagent re-run.
|
|
253
262
|
*/
|
|
254
|
-
archiveChecklistResult(
|
|
255
|
-
const livePath = this.checklistResultPath(
|
|
263
|
+
archiveChecklistResult(summaryJsonFilePath, checklistId) {
|
|
264
|
+
const livePath = this.checklistResultPath(summaryJsonFilePath, checklistId);
|
|
256
265
|
if (!fs.existsSync(livePath))
|
|
257
266
|
return '';
|
|
258
|
-
const archivePath = this.oldChecklistResultPath(
|
|
267
|
+
const archivePath = this.oldChecklistResultPath(summaryJsonFilePath, checklistId);
|
|
259
268
|
const raw = fs.readFileSync(livePath, 'utf8');
|
|
260
269
|
fs.writeFileSync(archivePath, this.archivedBody(raw, CHECKLIST_ARCHIVE_NOTE));
|
|
261
270
|
fs.rmSync(livePath);
|
|
262
271
|
return archivePath;
|
|
263
272
|
}
|
|
264
273
|
/**
|
|
265
|
-
* Load + validate the AI-authored
|
|
274
|
+
* Load + validate the AI-authored summary.json. Throws InformAiError (with the schema) when missing,
|
|
266
275
|
* unparseable, or structurally wrong. `required` is the set of checklists the diff matched: every one
|
|
267
276
|
* must have a well-formed, passing (or overridden) review-<id>.json or a validation error is raised
|
|
268
277
|
* alongside the usual ones so the AI gets ONE message.
|
|
269
278
|
*/
|
|
270
279
|
// webpieces-disable max-lines-new-methods -- one cohesive load+validate pass over the review fields
|
|
271
|
-
|
|
280
|
+
loadSummaryJson(filePath, required = [], expectedMainAgentInstructions = '') {
|
|
272
281
|
if (!fs.existsSync(filePath)) {
|
|
273
|
-
throw new inform_ai_error_1.InformAiError(`Required
|
|
274
|
-
`${this.
|
|
282
|
+
throw new inform_ai_error_1.InformAiError(`Required summary.json not found.${this.renamedFileHint(filePath)}${this.archivedSummaryHint(filePath)}\n\n` +
|
|
283
|
+
`${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}\n\n` +
|
|
275
284
|
`Then re-run: pnpm wp-finish-upsert-pr`);
|
|
276
285
|
}
|
|
277
|
-
const raw = this.
|
|
286
|
+
const raw = this.parseSummaryJson(fs.readFileSync(filePath, 'utf8'), filePath, expectedMainAgentInstructions);
|
|
278
287
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
279
|
-
throw new inform_ai_error_1.InformAiError(`
|
|
288
|
+
throw new inform_ai_error_1.InformAiError(`summary.json must be a JSON object.\n\n${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}`);
|
|
280
289
|
}
|
|
281
290
|
const errors = [];
|
|
282
291
|
for (const field of ['agent', 'model']) {
|
|
@@ -301,16 +310,16 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
301
310
|
for (const err of this.requiredChecklistErrors(required, results, filePath))
|
|
302
311
|
errors.push(err);
|
|
303
312
|
if (errors.length > 0) {
|
|
304
|
-
throw new inform_ai_error_1.InformAiError(`
|
|
313
|
+
throw new inform_ai_error_1.InformAiError(`summary.json has ${errors.length} error(s) — fix ALL, then re-run pnpm wp-finish-upsert-pr:\n\n` +
|
|
305
314
|
errors.map((e) => ` • ${e}`).join('\n') +
|
|
306
|
-
`\n\n${this.
|
|
315
|
+
`\n\n${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}`);
|
|
307
316
|
}
|
|
308
317
|
const level = riskLevel;
|
|
309
318
|
const emoji = typeof raw['riskEmoji'] === 'string' && raw['riskEmoji'] !== ''
|
|
310
319
|
? raw['riskEmoji']
|
|
311
320
|
: (EMOJI_FOR_LEVEL[level] ?? '🟡');
|
|
312
321
|
const summary = typeof raw['summary'] === 'string' ? raw['summary'] : '';
|
|
313
|
-
return new review_json_data_1.
|
|
322
|
+
return new review_json_data_1.PrSummary(raw['agent'].trim(), raw['model'].trim(), title, riskScore, level, emoji, summary, this.asStringArray(raw['violations']), this.asStringArray(raw['risks']), this.asStringArray(raw['filesToReview']), results, mainAgentInstructions);
|
|
314
323
|
}
|
|
315
324
|
// webpieces-disable no-any-unknown -- AI-authored JSON boundary is validated before use
|
|
316
325
|
validateMainAgentInstructions(raw, expected, errors) {
|
|
@@ -367,7 +376,7 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
367
376
|
/**
|
|
368
377
|
* THE renderer for "this reviewer refused" — one wording, wherever the refusal surfaces. It exists as a
|
|
369
378
|
* method because the text was previously inlined in {@link requiredChecklistErrors}, reachable only
|
|
370
|
-
* through
|
|
379
|
+
* through summary.json validation, while the command layer refused earlier with its own generic message.
|
|
371
380
|
* Two messages for one event is how the useful one became unreachable; there is now exactly one.
|
|
372
381
|
*
|
|
373
382
|
* It always quotes the reviewer's own `output` verbatim: the finding is the whole point, and an error
|
|
@@ -385,7 +394,7 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
385
394
|
* retirement, and a human who already decided to accept this checklist is never asked again.
|
|
386
395
|
*/
|
|
387
396
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
388
|
-
refusalError(req, verdict,
|
|
397
|
+
refusalError(req, verdict, summaryJsonFilePath, archivedPath = '') {
|
|
389
398
|
const finding = `${verdict.detail.split('\n').join('\n ')}\n`;
|
|
390
399
|
const head = `Checklist "${req.id}" FAILED review (status:"${review_json_data_1.VERDICT_RED}"). The reviewer (${req.reviewer.agentName}) wrote:\n ` + finding;
|
|
391
400
|
const retired = archivedPath === ''
|
|
@@ -395,7 +404,7 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
395
404
|
: ` That verdict has been RETIRED to ${archivedPath} (audit only — it is not a live verdict).\n` +
|
|
396
405
|
` A FRESH ${this.checklistFileName(req.id)} is now required. Fix the finding first, then have the ` +
|
|
397
406
|
`"${req.reviewer.agentName}" subagent review again and write a new verdict.\n`;
|
|
398
|
-
return head + retired + this.overrideRoute(req,
|
|
407
|
+
return head + retired + this.overrideRoute(req, summaryJsonFilePath);
|
|
399
408
|
}
|
|
400
409
|
/**
|
|
401
410
|
* The ship-anyway paragraph: who may authorize, and the exact command that records it.
|
|
@@ -404,14 +413,14 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
404
413
|
* override. A second copy of this paragraph is precisely how the previous one drifted into naming a
|
|
405
414
|
* command that had since been deleted.
|
|
406
415
|
*/
|
|
407
|
-
overrideRoute(req,
|
|
416
|
+
overrideRoute(req, summaryJsonFilePath) {
|
|
408
417
|
return ` To SHIP ANYWAY a human must decide it, and the decision is recorded in its own file — `
|
|
409
418
|
+ `${this.overrides.overrideFileName(req.id)}, never inside the reviewer's verdict.\n`
|
|
410
419
|
+ ` ${this.overrides.writerRule()}\n`
|
|
411
420
|
+ ' Run exactly this, replacing only the "reason" with what the human actually said:\n\n'
|
|
412
|
-
+ `${this.overrides.writeCommand(
|
|
421
|
+
+ `${this.overrides.writeCommand(summaryJsonFilePath, req.id)}\n`;
|
|
413
422
|
}
|
|
414
|
-
// Read the per-checklist verdict files `review-<id>.json` beside
|
|
423
|
+
// Read the per-checklist verdict files `review-<id>.json` beside summary.json — one per matched checklist.
|
|
415
424
|
// A missing file is simply absent from the result (→ counts as MISSING for that checklist); a malformed
|
|
416
425
|
// one is skipped (a stale review-<id>.json never wedges the branch).
|
|
417
426
|
//
|
|
@@ -420,21 +429,21 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
420
429
|
// the retired file sits right beside the live path, and a scan that swept the directory would hand a
|
|
421
430
|
// RETIRED refusal (or worse, a retired pass) back as the current state, undoing the whole point of the
|
|
422
431
|
// move in {@link archiveChecklistResult}.
|
|
423
|
-
loadChecklistResults(
|
|
432
|
+
loadChecklistResults(summaryJsonFilePath, required) {
|
|
424
433
|
const results = [];
|
|
425
434
|
for (const req of required) {
|
|
426
|
-
const p = this.checklistResultPath(
|
|
435
|
+
const p = this.checklistResultPath(summaryJsonFilePath, req.id);
|
|
427
436
|
if (!fs.existsSync(p))
|
|
428
437
|
continue;
|
|
429
438
|
// The human's authorization is read from its OWN file beside the verdict, in the same pass, so
|
|
430
439
|
// resolveVerdict never touches disk and every command resolves one outcome from one read.
|
|
431
|
-
const parsed = this.parseChecklistResult(p, req.id, this.overrides.load(
|
|
440
|
+
const parsed = this.parseChecklistResult(p, req.id, this.overrides.load(summaryJsonFilePath, req.id));
|
|
432
441
|
if (parsed)
|
|
433
442
|
results.push(parsed);
|
|
434
443
|
}
|
|
435
444
|
return results;
|
|
436
445
|
}
|
|
437
|
-
// Resolve ONE checklist's verdict from its review-<id>.json. Central so
|
|
446
|
+
// Resolve ONE checklist's verdict from its review-<id>.json. Central so summary.json enforcement AND the
|
|
438
447
|
// finish-command dashboard agree on the outcome. `problem` is checked FIRST: a file whose verdict cannot
|
|
439
448
|
// be read must not fall through to any shipping outcome.
|
|
440
449
|
resolveVerdict(req, results) {
|
|
@@ -461,7 +470,7 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
461
470
|
* One loud complaint per checklist whose verdict file EXISTS but cannot be read as a verdict — almost
|
|
462
471
|
* always one still using the removed `success` field. Public and separate from
|
|
463
472
|
* {@link requiredChecklistErrors} because `wp-finish-upsert-pr` refuses on missing reviewers BEFORE it
|
|
464
|
-
* parses
|
|
473
|
+
* parses summary.json: without this, a legacy file would surface as the generic "no verdict yet" block
|
|
465
474
|
* and the AI would re-run a reviewer that already ran instead of fixing four characters of JSON.
|
|
466
475
|
*/
|
|
467
476
|
checklistFormatErrors(required, results) {
|
|
@@ -588,8 +597,8 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
588
597
|
return value.filter((v) => typeof v === 'string');
|
|
589
598
|
}
|
|
590
599
|
// Parse opaque AI-authored JSON, converting a SyntaxError into a readable InformAiError.
|
|
591
|
-
// webpieces-disable no-any-unknown -- returns the opaque parsed object;
|
|
592
|
-
|
|
600
|
+
// webpieces-disable no-any-unknown -- returns the opaque parsed object; loadSummaryJson narrows each field
|
|
601
|
+
parseSummaryJson(raw, filePath, expectedMainAgentInstructions = '') {
|
|
593
602
|
// webpieces-disable no-unmanaged-exceptions -- chokepoint: convert JSON.parse SyntaxError to an InformAiError for the AI
|
|
594
603
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
595
604
|
try {
|
|
@@ -598,8 +607,8 @@ let ReviewJsonService = class ReviewJsonService {
|
|
|
598
607
|
}
|
|
599
608
|
catch (err) {
|
|
600
609
|
const error = (0, to_error_1.toError)(err);
|
|
601
|
-
throw new inform_ai_error_1.InformAiError(`
|
|
602
|
-
`${this.
|
|
610
|
+
throw new inform_ai_error_1.InformAiError(`summary.json is not valid JSON (${error.message}).\n\n` +
|
|
611
|
+
`${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}\n\n` +
|
|
603
612
|
`Then re-run: pnpm wp-finish-upsert-pr`);
|
|
604
613
|
}
|
|
605
614
|
}
|
|
@@ -617,11 +626,11 @@ function prDirFor(repoRoot, featureName) {
|
|
|
617
626
|
return reviewJsonSvc.prDirFor(repoRoot, featureName);
|
|
618
627
|
}
|
|
619
628
|
// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it
|
|
620
|
-
function
|
|
621
|
-
return reviewJsonSvc.
|
|
629
|
+
function summaryJsonPath(repoRoot, featureName) {
|
|
630
|
+
return reviewJsonSvc.summaryJsonPath(repoRoot, featureName);
|
|
622
631
|
}
|
|
623
632
|
// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it
|
|
624
|
-
function
|
|
625
|
-
return reviewJsonSvc.
|
|
633
|
+
function summaryJsonSchemaHint(filePath, mainAgentInstructions = '') {
|
|
634
|
+
return reviewJsonSvc.summaryJsonSchemaHint(filePath, mainAgentInstructions);
|
|
626
635
|
}
|
|
627
636
|
//# sourceMappingURL=review-json.js.map
|