@webpieces/rules-config 0.4.498 → 0.4.499
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/branch-mutation-log.d.ts +1 -1
- package/src/branch-mutation-log.js.map +1 -1
- package/src/checklist-config.js +1 -1
- package/src/checklist-config.js.map +1 -1
- package/src/checklist-instructions.d.ts +1 -1
- package/src/checklist-instructions.js +28 -13
- package/src/checklist-instructions.js.map +1 -1
- package/src/diff-scope.d.ts +10 -0
- package/src/diff-scope.js +14 -1
- package/src/diff-scope.js.map +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +11 -3
- package/src/index.js.map +1 -1
- package/src/pr-gate-config.d.ts +53 -0
- package/src/pr-gate-config.js +66 -4
- package/src/pr-gate-config.js.map +1 -1
- package/src/review-json.d.ts +35 -2
- package/src/review-json.js +73 -14
- package/src/review-json.js.map +1 -1
- package/src/reviewer-instructions.d.ts +86 -0
- package/src/reviewer-instructions.js +236 -0
- package/src/reviewer-instructions.js.map +1 -0
- package/src/subagent-provenance.d.ts +55 -1
- package/src/subagent-provenance.js +143 -5
- package/src/subagent-provenance.js.map +1 -1
- package/templates/webpieces.git-workflow.md +13 -7
- package/templates/webpieces.review-checklists.md +19 -8
package/src/review-json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-json.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/review-json.ts"],"names":[],"mappings":";;;AA6dA,4BAEC;AAGD,wCAEC;AAGD,oDAEC;AAGD,wCAEC;;AA9eD,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,2CAA+D;AAC/D,uDAAkD;AAClD,yCAAqC;AAErC,qGAAqG;AACrG,yGAAyG;AACzG,0GAA0G;AAC1G,4EAA4E;AAC/D,QAAA,aAAa,GAAG,OAAO,CAAC;AACxB,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,WAAW,G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MAAM,IAAI,+BAAa,CACnB,kCAAkC,KAAK,CAAC,OAAO,SAAS,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,MAAM;gBACjG,uCAAuC,CAC1C,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAlTY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,iBAAiB,CAkT7B;AAED,0FAA0F;AAC1F,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE9C,wIAAwI;AACxI,SAAgB,QAAQ,CAAC,QAAgB,EAAE,WAAmB;IAC1D,OAAO,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;AAED,wIAAwI;AACxI,SAAgB,cAAc,CAAC,QAAgB,EAAE,WAAmB;IAChE,OAAO,aAAa,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC/D,CAAC;AAED,wIAAwI;AACxI,SAAgB,oBAAoB,CAAC,QAAgB;IACjD,OAAO,aAAa,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,wIAAwI;AACxI,SAAgB,cAAc,CAAC,QAAgB,EAAE,WAAyC,EAAE;IACxF,OAAO,aAAa,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { WEBPIECES_TMP_DIR, PR_REVIEW_DIR } from './constants';\nimport { InformAiError } from './inform-ai-error';\nimport { toError } from './to-error';\n\n// The three colors a reviewer subagent may report in `review-<id>.json`. A TRI-state, not a boolean,\n// because the boolean it replaced gave a reviewer no way to say \"this passes, but a human should look at\n// X\" — the only way to raise a concern was to FAIL the PR and then override your own failure, which reads\n// on the dashboard as a deliberately-accepted defect rather than as a note.\nexport const VERDICT_GREEN = 'green';\nexport const VERDICT_YELLOW = 'yellow';\nexport const VERDICT_RED = 'red';\nexport const VERDICT_STATUSES = [VERDICT_GREEN, VERDICT_YELLOW, VERDICT_RED] as const;\n\n// The verdict a reviewer SUBAGENT writes into `.webpieces/pr-review/<branch>/review-<id>.json`, one per\n// matched checklist. One file per checklist so N concurrent reviewer subagents never clobber a shared\n// file. It records the OUTCOME:\n// status:'green' → PASS\n// status:'yellow' → WARN (passes; the concern is published on the PR, nothing is blocked)\n// status:'red' + override non-empty → OVERRIDDEN (pass; the free-text justification reaches the PR)\n// status:'red' + no override → FAIL (refuse; `output` is printed verbatim)\n// `override` is deliberately free text, not a boolean — it forces the ship-anyway decision to be stated\n// in words and surfaces it on the dashboard, where a human sees it. Data-only (per CLAUDE.md).\nexport class ChecklistResult {\n id: string;\n status: string; // one of VERDICT_STATUSES; anything else is reported via `problem`\n output: string; // what the reviewer found; printed verbatim when the checklist fails\n override: string; // '' = no override; non-empty = ship-anyway justification (renders 🟠 overridden)\n // '' = a well-formed verdict. Non-empty = the file exists and parses but its verdict cannot be READ\n // (most often: it still uses the removed `success` field). Carried as data rather than thrown so the\n // complaint can be reported by BOTH wp-checklist and wp-finish-upsert-pr in identical words, and so a\n // legacy file is never silently mistaken for a missing one.\n problem: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(id: string, status: string, output: string, override: string, problem = '') {\n this.id = id;\n this.status = status;\n this.output = output;\n this.override = override;\n this.problem = problem;\n }\n}\n\n// What the pr-gate command computed from the diff: a checklist this branch MATCHED (its patterns hit the\n// diff, so its reviewer subagent must run). Drives review-<id>.json enforcement, provenance, the schema\n// hint, and the dashboard. Data-only.\nexport class RequiredChecklist {\n id: string; // = subagent name; keys review-<id>.json\n subagent: string; // reviewer agent that must run (agentType the harness stamps)\n doc: string; // REPO-RELATIVE guidance doc the reviewer reads ('' → it just reads the diff)\n matchedFiles: string[]; // the changed files that matched it (for the dashboard + hint)\n // Which of the checklist's OWN globs actually fired. Printed so a reviewer can judge how coarse the\n // match was — a precise `db/migrations/**` hit means something different from a blanket `**` — and the\n // template tells reviewers that matching IS deliberately coarse. [] = no patterns (matches every PR).\n matchedPatterns: string[];\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(id: string, subagent: string, doc: string, matchedFiles: string[], matchedPatterns: string[] = []) {\n this.id = id;\n this.subagent = subagent;\n this.doc = doc;\n this.matchedFiles = matchedFiles;\n this.matchedPatterns = matchedPatterns;\n }\n}\n\n/**\n * The per-PR facts every reviewer subagent needs GIVEN to it, alongside its own checklist: the exact base\n * sha the gate diffs against and the file holding the complete changed-file set. Both used to live only in\n * a doc the printed instruction told the AI to go read, one indirection away from the instruction to hand\n * them over — so the printed block could not stand on its own. Data-only; empty = omit those lines.\n */\nexport class ChecklistReviewContext {\n baseSha: string; // the 3-point merge-base sha; `git diff <baseSha> HEAD -- <file>`\n prContextPath: string; // path of pr-context.json — the AUTHORITATIVE full changed-file set\n\n constructor(baseSha = '', prContextPath = '') {\n this.baseSha = baseSha;\n this.prContextPath = prContextPath;\n }\n}\n\n// The AI-authored review for a PR. The AI writes review.json itself between `wp-start-upsert-pr` (which\n// prints the schema) and `wp-finish-upsert-pr` (which reads it); reviewer subagents write the per-checklist\n// review-<id>.json files. Data-only (per CLAUDE.md).\nexport class ReviewJson {\n title: string; // human PR title describing the change; used as the `gh pr` title (empty → caller falls back)\n riskScore: number; // 0–100, drives the risk bar\n riskLevel: string; // 'green' | 'yellow' | 'red'\n riskEmoji: string; // '🟢' | '🟡' | '🔴' — derived from riskLevel when omitted\n summary: string; // rendered in the dashboard Summary section\n violations: string[]; // pattern/architecture violations; length = the Pattern Violations count\n risks: string[];\n filesToReview: string[];\n results: ChecklistResult[]; // resolved per-checklist verdicts (from review-<id>.json); [] when none\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n title: string,\n riskScore: number,\n riskLevel: string,\n riskEmoji: string,\n summary: string,\n violations: string[],\n risks: string[],\n filesToReview: string[],\n results: ChecklistResult[] = [],\n ) {\n this.title = title;\n this.riskScore = riskScore;\n this.riskLevel = riskLevel;\n this.riskEmoji = riskEmoji;\n this.summary = summary;\n this.violations = violations;\n this.risks = risks;\n this.filesToReview = filesToReview;\n this.results = results;\n }\n}\n\n// A checklist's resolved outcome, shared by review.json enforcement and the dashboard so both agree.\n// PASS, WARN and OVERRIDDEN all ship; FAIL, MISSING and BAD_FORMAT all refuse the PR.\nexport const CK_PASS = 'pass'; // review-<id>.json status:'green'\nexport const CK_WARN = 'warn'; // review-<id>.json status:'yellow' → 🟡 passes WITH concerns\nexport const CK_OVERRIDDEN = 'overridden'; // review-<id>.json status:'red' + non-empty override → 🟠\nexport const CK_FAIL = 'fail'; // review-<id>.json status:'red' + no override → refuse\nexport const CK_MISSING = 'missing'; // no review-<id>.json written → refuse\nexport const CK_BAD_FORMAT = 'bad-format'; // written, but its verdict is unreadable (e.g. legacy `success`)\n\nexport class ChecklistVerdict {\n id: string;\n status: string; // one of CK_PASS | CK_WARN | CK_OVERRIDDEN | CK_FAIL | CK_MISSING | CK_BAD_FORMAT\n detail: string; // reviewer output / override justification / format complaint (dashboard + errors)\n\n constructor(id: string, status: string, detail: string) {\n this.id = id;\n this.status = status;\n this.detail = detail;\n }\n}\n\n// The PR's diff context, written by wp-start-upsert-pr into `.webpieces/pr-review/<branch>/pr-context.json`\n// so a reviewer subagent knows the exact 3-point base the gate used and the full changed-file set — then\n// reads any file's actual diff with `git diff <base> HEAD -- <file>`. This is what lets a checklist match\n// coarsely by path (in the config) while the subagent makes the fine, content-level judgment. Data-only.\nexport class PrContext {\n base: string; // the 3-point merge-base sha the gate diffs against\n head: string; // HEAD sha\n changedFiles: string[]; // every file changed base..head (NOT tsOnly — includes .sql/.gql/Dockerfile/…)\n\n constructor(base: string, head: string, changedFiles: string[]) {\n this.base = base;\n this.head = head;\n this.changedFiles = changedFiles;\n }\n}\n\nconst RISK_LEVELS = ['green', 'yellow', 'red'] as const;\nconst EMOJI_FOR_LEVEL: Record<string, string> = { green: '🟢', yellow: '🟡', red: '🔴' };\n\n/** Locates + loads/validates the AI-authored review.json. `@injectable(bindingScopeValues.Singleton)` so it's drawn in the design. */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewJsonService {\n // The per-feature PR working dir: `.webpieces/pr-review/<feature>`.\n prDirFor(repoRoot: string, featureName: string): string {\n return path.join(repoRoot, WEBPIECES_TMP_DIR, PR_REVIEW_DIR, featureName);\n }\n\n // Absolute path of the review.json for a feature — beside pr-body.md, keyed by branch name.\n reviewJsonPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'review.json');\n }\n\n // Absolute path of the pr-context.json for a feature (the diff base/head + changed files).\n prContextPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'pr-context.json');\n }\n\n // Persist the PR's diff context so reviewer subagents can read the changed-file set + the exact base\n // sha (then `git diff <base> HEAD -- <file>` for content). Returns the file path written.\n writePrContext(repoRoot: string, featureName: string, context: PrContext): string {\n const dir = this.prDirFor(repoRoot, featureName);\n fs.mkdirSync(dir, { recursive: true });\n const p = this.prContextPath(repoRoot, featureName);\n fs.writeFileSync(p, JSON.stringify(context, null, 2) + '\\n');\n return p;\n }\n\n /**\n * The review context for a feature, recovered from the pr-context.json wp-start-upsert-pr already wrote.\n * Lets wp-finish-upsert-pr's \"you still owe me review-<id>.json\" message inline the SAME self-sufficient\n * per-reviewer block start printed, instead of a checklist name and an indirection. Empty when the file\n * is absent or unreadable — the block then just omits those lines.\n */\n reviewContextFor(repoRoot: string, featureName: string): ChecklistReviewContext {\n const p = this.prContextPath(repoRoot, featureName);\n if (!fs.existsSync(p)) return new ChecklistReviewContext();\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable context file degrades to fewer printed lines, never a crash\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(p, 'utf8')) as Record<string, unknown>;\n const base = typeof raw['base'] === 'string' ? (raw['base'] as string) : '';\n return new ChecklistReviewContext(base, p);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return new ChecklistReviewContext('', p);\n }\n }\n\n // Copy-paste schema both commands print. `required` is the set of checklists the diff MATCHED; empty\n // ⇒ output identical to a repo with no checklists. Non-empty ⇒ appends per-checklist instructions\n // naming the reviewer subagent + doc + the review-<id>.json to write.\n reviewJsonSchemaHint(filePath: string): string {\n return (\n `Write your PR review to:\\n ${filePath}\\n\\n` +\n `with this exact JSON shape (riskEmoji optional — derived from riskLevel):\\n\\n` +\n `{\\n` +\n ` \"title\": \"concise PR title describing the change (imperative, no branch names)\",\\n` +\n ` \"riskScore\": 0, // integer 0–100 (higher = riskier)\\n` +\n ` \"riskLevel\": \"green | yellow | red\",\\n` +\n ` \"summary\": \"5–10 sentence review summary\",\\n` +\n ` \"violations\": [\"pattern/architecture violations you found (empty array if none)\"],\\n` +\n ` \"risks\": [\"notable risks (empty array if none)\"],\\n` +\n ` \"filesToReview\": [\"paths a human should look at (empty array if none)\"]\\n` +\n `}`\n );\n }\n\n // The per-checklist review file path that sits beside review.json: review-<id>.json.\n checklistResultPath(reviewJsonFilePath: string, checklistId: string): string {\n return path.join(path.dirname(reviewJsonFilePath), `review-${checklistId}.json`);\n }\n\n /**\n * Load + validate the AI-authored review.json. Throws InformAiError (with the schema) when missing,\n * unparseable, or structurally wrong. `required` is the set of checklists the diff matched: every one\n * must have a well-formed, passing (or overridden) review-<id>.json or a validation error is raised\n * alongside the usual ones so the AI gets ONE message.\n */\n // webpieces-disable max-lines-new-methods -- one cohesive load+validate pass over the review fields\n loadReviewJson(filePath: string, required: readonly RequiredChecklist[] = []): ReviewJson {\n if (!fs.existsSync(filePath)) {\n throw new InformAiError(\n `Required review.json not found.\\n\\n${this.reviewJsonSchemaHint(filePath)}\\n\\n` +\n `Then re-run: pnpm wp-finish-upsert-pr`,\n );\n }\n\n const raw = this.parseReviewJson(fs.readFileSync(filePath, 'utf8'), filePath);\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n throw new InformAiError(`review.json must be a JSON object.\\n\\n${this.reviewJsonSchemaHint(filePath)}`);\n }\n\n const errors: string[] = [];\n\n const riskScore = raw['riskScore'];\n if (typeof riskScore !== 'number' || !Number.isFinite(riskScore) || riskScore < 0 || riskScore > 100) {\n errors.push(`\"riskScore\" must be a number 0–100, got ${JSON.stringify(riskScore)}.`);\n }\n\n const riskLevel = raw['riskLevel'];\n if (typeof riskLevel !== 'string' || !RISK_LEVELS.includes(riskLevel as typeof RISK_LEVELS[number])) {\n errors.push(`\"riskLevel\" must be one of: ${RISK_LEVELS.join(', ')}.`);\n }\n\n const title = typeof raw['title'] === 'string' ? (raw['title'] as string).trim() : '';\n if (title === '') {\n errors.push('\"title\" must be a non-empty, imperative PR title describing the change (no branch names).');\n }\n\n const results = this.loadChecklistResults(filePath, required);\n for (const err of this.requiredChecklistErrors(required, results)) errors.push(err);\n\n if (errors.length > 0) {\n throw new InformAiError(\n `review.json has ${errors.length} error(s) — fix ALL, then re-run pnpm wp-finish-upsert-pr:\\n\\n` +\n errors.map((e: string): string => ` • ${e}`).join('\\n') +\n `\\n\\n${this.reviewJsonSchemaHint(filePath)}`,\n );\n }\n\n const level = riskLevel as string;\n const emoji = typeof raw['riskEmoji'] === 'string' && raw['riskEmoji'] !== ''\n ? (raw['riskEmoji'] as string)\n : (EMOJI_FOR_LEVEL[level] ?? '🟡');\n const summary = typeof raw['summary'] === 'string' ? (raw['summary'] as string) : '';\n\n return new ReviewJson(\n title,\n riskScore as number,\n level,\n emoji,\n summary,\n this.asStringArray(raw['violations']),\n this.asStringArray(raw['risks']),\n this.asStringArray(raw['filesToReview']),\n results,\n );\n }\n\n /**\n * The checklists that still OWE a verdict: no review-<id>.json at all, a malformed one, or one whose\n * verdict is an un-overridden FAIL. This is the set every message lists — a checklist already PASSed or\n * OVERRIDDEN on this branch is deliberately NOT re-listed, because re-instructing it invites a redundant\n * second run and reads as though the earlier verdict did not count.\n */\n pendingChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => {\n const status = this.resolveVerdict(req, results).status;\n // CK_WARN must be listed here beside PASS/OVERRIDDEN. A yellow verdict SHIPS — leaving it out\n // would mark the checklist owed forever, so `outstanding` never empties and the PR is refused\n // permanently no matter how many times the reviewer runs.\n return status !== CK_PASS && status !== CK_WARN && status !== CK_OVERRIDDEN;\n });\n }\n\n // Read the per-checklist verdict files `review-<id>.json` beside review.json — one per matched checklist.\n // A missing file is simply absent from the result (→ counts as MISSING for that checklist); a malformed\n // one is skipped (a stale review-<id>.json never wedges the branch).\n loadChecklistResults(reviewJsonFilePath: string, required: readonly RequiredChecklist[]): ChecklistResult[] {\n const results: ChecklistResult[] = [];\n for (const req of required) {\n const p = this.checklistResultPath(reviewJsonFilePath, req.id);\n if (!fs.existsSync(p)) continue;\n const parsed = this.parseChecklistResult(p, req.id);\n if (parsed) results.push(parsed);\n }\n return results;\n }\n\n // Resolve ONE checklist's verdict from its review-<id>.json. Central so review.json enforcement AND the\n // finish-command dashboard agree on the outcome. `problem` is checked FIRST: a file whose verdict cannot\n // be read must not fall through to any shipping outcome.\n resolveVerdict(req: RequiredChecklist, results: readonly ChecklistResult[]): ChecklistVerdict {\n const result = results.find((r: ChecklistResult): boolean => r.id === req.id);\n if (!result) return new ChecklistVerdict(req.id, CK_MISSING, '');\n if (result.problem !== '') return new ChecklistVerdict(req.id, CK_BAD_FORMAT, result.problem);\n if (result.status === VERDICT_GREEN) return new ChecklistVerdict(req.id, CK_PASS, result.output);\n if (result.status === VERDICT_YELLOW) return new ChecklistVerdict(req.id, CK_WARN, result.output);\n if (result.override.trim() !== '') return new ChecklistVerdict(req.id, CK_OVERRIDDEN, result.override.trim());\n return new ChecklistVerdict(req.id, CK_FAIL, result.output);\n }\n\n /**\n * One loud complaint per checklist whose verdict file EXISTS but cannot be read as a verdict — almost\n * always one still using the removed `success` field. Public and separate from\n * {@link requiredChecklistErrors} because `wp-finish-upsert-pr` refuses on missing reviewers BEFORE it\n * parses review.json: without this, a legacy file would surface as the generic \"no verdict yet\" block\n * and the AI would re-run a reviewer that already ran instead of fixing four characters of JSON.\n */\n checklistFormatErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): string[] {\n const errors: string[] = [];\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n if (verdict.status === CK_BAD_FORMAT) errors.push(verdict.detail);\n }\n return errors;\n }\n\n // Every matched checklist whose verdict is FAIL (reviewed, found a problem, no override) or MISSING (no\n // review-<id>.json written) → one error each, printing the reviewer's `output` verbatim.\n private requiredChecklistErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): string[] {\n // Format complaints come from the ONE renderer, so wp-checklist and wp-finish word them identically.\n const errors: string[] = this.checklistFormatErrors(required, results);\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n // CK_WARN ('yellow' — passed with concerns) is deliberately absent from this chain: it SHIPS.\n // The concern still reaches the PR, published in the checklist comment. Do not \"fix\" this.\n if (verdict.status === CK_FAIL) {\n errors.push(\n `Checklist \"${req.id}\" FAILED review (status:\"${VERDICT_RED}\"). The reviewer (${req.subagent}) wrote:\\n ` +\n `${verdict.detail.split('\\n').join('\\n ')}\\n` +\n ` Fix it, then re-run; or set a non-empty \"override\" in ${this.checklistFileName(req.id)} to ship anyway with a stated justification.`,\n );\n } else if (verdict.status === CK_MISSING) {\n const doc = req.doc.trim() !== '' ? ` Read: ${req.doc}.` : '';\n errors.push(\n `Checklist \"${req.id}\" MATCHED this diff but has no verdict. Spawn the \"${req.subagent}\" subagent to review it, ` +\n `then write ${this.checklistFileName(req.id)} with ` +\n `{\"id\":\"${req.id}\",\"status\":\"${VERDICT_GREEN}\",\"output\":\"…\",\"override\":\"\"}.${doc}`,\n );\n }\n }\n return errors;\n }\n\n private checklistFileName(checklistId: string): string {\n return `review-${checklistId}.json`;\n }\n\n /**\n * Parse one review-<id>.json into a ChecklistResult. `null` ONLY when the bytes do not parse as a JSON\n * object at all — that tolerance is why a half-written file never wedges a branch, and it degrades to\n * the same \"no verdict yet\" message as an absent file, which is honest (nothing readable is there).\n *\n * A file that DOES parse always yields a result, even when its verdict is unreadable, carrying the\n * complaint in `problem`. Returning `null` for those instead would collapse \"wrote a verdict in the old\n * format\" into \"never wrote a verdict\" and send the AI off to re-run a reviewer that already ran.\n */\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field\n private parseChecklistResult(filePath: string, id: string): ChecklistResult | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unparseable per-checklist file is skipped, not fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed below\n const raw = JSON.parse(fs.readFileSync(filePath, 'utf8')) as Record<string, unknown>;\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return null;\n const output = typeof raw['output'] === 'string' ? (raw['output'] as string) : '';\n const override = typeof raw['override'] === 'string' ? (raw['override'] as string) : '';\n const status = typeof raw['status'] === 'string' ? (raw['status'] as string).trim().toLowerCase() : '';\n return new ChecklistResult(id, status, output, override, this.statusProblem(filePath, id, status, raw));\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * '' when `status` is one of the three colors. Otherwise the complaint to show the AI verbatim. The\n * legacy-`success` case gets its OWN message: `success` was removed outright (no compatibility mode),\n * and a reviewer told only \"status must be green|yellow|red\" cannot tell whether it wrote the wrong\n * value or is using a field that no longer exists.\n */\n // webpieces-disable no-any-unknown -- opaque parsed JSON; only tested for key presence here\n private statusProblem(filePath: string, id: string, status: string, raw: Record<string, unknown>): string {\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if ((VERDICT_STATUSES as readonly string[]).includes(status)) return '';\n const shape =\n ` { \"id\": \"${id}\", \"status\": \"${VERDICT_GREEN} | ${VERDICT_YELLOW} | ${VERDICT_RED}\", ` +\n `\"output\": \"what you checked / found\", \"override\": \"\" }\\n` +\n ` ${VERDICT_GREEN} → passes\\n` +\n ` ${VERDICT_YELLOW} → passes WITH CONCERNS; nothing is blocked and the concern is published on the PR\\n` +\n ` ${VERDICT_RED} → REFUSES the PR (set a non-empty \"override\" to ship anyway with a stated justification)\\n` +\n ` File: ${filePath}`;\n if ('success' in raw) {\n return `Checklist \"${id}\" wrote its verdict with the REMOVED \"success\" field. It is now a tri-state ` +\n `\"status\" — there is no compatibility mode. Rewrite the file as:\\n${shape}`;\n }\n return `Checklist \"${id}\" wrote a verdict with no valid \"status\" (got ${JSON.stringify(status)}). ` +\n `It must be exactly one of ${VERDICT_STATUSES.join(', ')}:\\n${shape}`;\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON value, narrowed to string[] here\n private asStringArray(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n // webpieces-disable no-any-unknown -- element of an opaque JSON array, narrowed by the type guard\n return value.filter((v: unknown): v is string => typeof v === 'string');\n }\n\n // Parse opaque AI-authored JSON, converting a SyntaxError into a readable InformAiError.\n // webpieces-disable no-any-unknown -- returns the opaque parsed object; loadReviewJson narrows each field\n private parseReviewJson(raw: string, filePath: string): Record<string, unknown> {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: convert JSON.parse SyntaxError to an InformAiError for the AI\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed by the caller\n return JSON.parse(raw) as Record<string, unknown>;\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(\n `review.json is not valid JSON (${error.message}).\\n\\n${this.reviewJsonSchemaHint(filePath)}\\n\\n` +\n `Then re-run: pnpm wp-finish-upsert-pr`,\n );\n }\n }\n}\n\n// Temporary migration delegators to ReviewJsonService — removed once consumers inject it.\nconst reviewJsonSvc = new ReviewJsonService();\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function prDirFor(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.prDirFor(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function reviewJsonPath(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.reviewJsonPath(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function reviewJsonSchemaHint(filePath: string): string {\n return reviewJsonSvc.reviewJsonSchemaHint(filePath);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function loadReviewJson(filePath: string, required: readonly RequiredChecklist[] = []): ReviewJson {\n return reviewJsonSvc.loadReviewJson(filePath, required);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"review-json.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/review-json.ts"],"names":[],"mappings":";;;AA0hBA,4BAEC;AAGD,wCAEC;AAGD,oDAEC;AAGD,wCAEC;;AA3iBD,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,2CAA+D;AAC/D,uDAAkD;AAClD,yCAAqC;AAErC,qGAAqG;AACrG,yGAAyG;AACzG,0GAA0G;AAC1G,4EAA4E;AAC/D,QAAA,aAAa,GAAG,OAAO,CAAC;AACxB,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,WAAW,GAAG,KAAK,CAAC;AACpB,QAAA,gBAAgB,GAAG,CAAC,qBAAa,EAAE,sBAAc,EAAE,mBAAW,CAAU,CAAC;AAEtF,wGAAwG;AACxG,sGAAsG;AACtG,gCAAgC;AAChC,2CAA2C;AAC3C,4GAA4G;AAC5G,sGAAsG;AACtG,kFAAkF;AAClF,wGAAwG;AACxG,+FAA+F;AAC/F,MAAa,eAAe;IACxB,EAAE,CAAS;IACX,MAAM,CAAS,CAAI,mEAAmE;IACt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nimport { WEBPIECES_TMP_DIR, PR_REVIEW_DIR } from './constants';\nimport { InformAiError } from './inform-ai-error';\nimport { toError } from './to-error';\n\n// The three colors a reviewer subagent may report in `review-<id>.json`. A TRI-state, not a boolean,\n// because the boolean it replaced gave a reviewer no way to say \"this passes, but a human should look at\n// X\" — the only way to raise a concern was to FAIL the PR and then override your own failure, which reads\n// on the dashboard as a deliberately-accepted defect rather than as a note.\nexport const VERDICT_GREEN = 'green';\nexport const VERDICT_YELLOW = 'yellow';\nexport const VERDICT_RED = 'red';\nexport const VERDICT_STATUSES = [VERDICT_GREEN, VERDICT_YELLOW, VERDICT_RED] as const;\n\n// The verdict a reviewer SUBAGENT writes into `.webpieces/pr-review/<branch>/review-<id>.json`, one per\n// matched checklist. One file per checklist so N concurrent reviewer subagents never clobber a shared\n// file. It records the OUTCOME:\n// status:'green' → PASS\n// status:'yellow' → WARN (passes; the concern is published on the PR, nothing is blocked)\n// status:'red' + override non-empty → OVERRIDDEN (pass; the free-text justification reaches the PR)\n// status:'red' + no override → FAIL (refuse; `output` is printed verbatim)\n// `override` is deliberately free text, not a boolean — it forces the ship-anyway decision to be stated\n// in words and surfaces it on the dashboard, where a human sees it. Data-only (per CLAUDE.md).\nexport class ChecklistResult {\n id: string;\n status: string; // one of VERDICT_STATUSES; anything else is reported via `problem`\n output: string; // what the reviewer found; printed verbatim when the checklist fails\n override: string; // '' = no override; non-empty = ship-anyway justification (renders 🟠 overridden)\n // '' = a well-formed verdict. Non-empty = the file exists and parses but its verdict cannot be READ\n // (most often: it still uses the removed `success` field). Carried as data rather than thrown so the\n // complaint can be reported by BOTH wp-review-upsert-pr and wp-finish-upsert-pr in identical words, and so a\n // legacy file is never silently mistaken for a missing one.\n problem: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(id: string, status: string, output: string, override: string, problem = '') {\n this.id = id;\n this.status = status;\n this.output = output;\n this.override = override;\n this.problem = problem;\n }\n}\n\n// What the pr-gate command computed from the diff: a checklist this branch MATCHED (its patterns hit the\n// diff, so its reviewer subagent must run). Drives review-<id>.json enforcement, provenance, the schema\n// hint, and the dashboard. Data-only.\nexport class RequiredChecklist {\n id: string; // = subagent name; keys review-<id>.json\n subagent: string; // reviewer agent that must run (agentType the harness stamps)\n doc: string; // REPO-RELATIVE guidance doc the reviewer reads ('' → it just reads the diff)\n matchedFiles: string[]; // the changed files that matched it (for the dashboard + hint)\n // Which of the checklist's OWN globs actually fired. Printed so a reviewer can judge how coarse the\n // match was — a precise `db/migrations/**` hit means something different from a blanket `**` — and the\n // template tells reviewers that matching IS deliberately coarse. [] = no patterns (matches every PR).\n matchedPatterns: string[];\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(id: string, subagent: string, doc: string, matchedFiles: string[], matchedPatterns: string[] = []) {\n this.id = id;\n this.subagent = subagent;\n this.doc = doc;\n this.matchedFiles = matchedFiles;\n this.matchedPatterns = matchedPatterns;\n }\n}\n\n/**\n * The per-PR facts every reviewer subagent needs GIVEN to it, alongside its own checklist: the exact base\n * sha the gate diffs against and the file holding the complete changed-file set. Both used to live only in\n * a doc the printed instruction told the AI to go read, one indirection away from the instruction to hand\n * them over — so the printed block could not stand on its own. Data-only; empty = omit those lines.\n */\nexport class ChecklistReviewContext {\n baseSha: string; // the 3-point merge-base sha\n prContextPath: string; // path of pr-context.json — the AUTHORITATIVE full changed-file set\n /**\n * The exact command that reproduces ONE file's diff, with a `-- <file>` tail — NOT assembled by the\n * caller. This used to be hardcoded as `git diff <baseSha> HEAD -- <file>`, which returns NOTHING on a\n * dirty tree because the changed-file set is computed base→working-tree. See DiffBasis, which derives\n * this string from the same range the file set came from.\n */\n fileDiffCommand: string;\n diffDir: string; // dir of the MATERIALIZED diff (diff/ALL.diff + diff/files/…); '' when not written\n dirty: boolean; // true ⇒ the range includes uncommitted + untracked work, and must be said out loud\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(baseSha = '', prContextPath = '', fileDiffCommand = '', diffDir = '', dirty = false) {\n this.baseSha = baseSha;\n this.prContextPath = prContextPath;\n this.fileDiffCommand = fileDiffCommand;\n this.diffDir = diffDir;\n this.dirty = dirty;\n }\n}\n\n// The AI-authored review for a PR. The AI writes review.json itself between `wp-start-upsert-pr` (which\n// prints the schema) and `wp-finish-upsert-pr` (which reads it); reviewer subagents write the per-checklist\n// review-<id>.json files. Data-only (per CLAUDE.md).\nexport class ReviewJson {\n title: string; // human PR title describing the change; used as the `gh pr` title (empty → caller falls back)\n riskScore: number; // 0–100, drives the risk bar\n riskLevel: string; // 'green' | 'yellow' | 'red'\n riskEmoji: string; // '🟢' | '🟡' | '🔴' — derived from riskLevel when omitted\n summary: string; // rendered in the dashboard Summary section\n violations: string[]; // pattern/architecture violations; length = the Pattern Violations count\n risks: string[];\n filesToReview: string[];\n results: ChecklistResult[]; // resolved per-checklist verdicts (from review-<id>.json); [] when none\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n title: string,\n riskScore: number,\n riskLevel: string,\n riskEmoji: string,\n summary: string,\n violations: string[],\n risks: string[],\n filesToReview: string[],\n results: ChecklistResult[] = [],\n ) {\n this.title = title;\n this.riskScore = riskScore;\n this.riskLevel = riskLevel;\n this.riskEmoji = riskEmoji;\n this.summary = summary;\n this.violations = violations;\n this.risks = risks;\n this.filesToReview = filesToReview;\n this.results = results;\n }\n}\n\n// A checklist's resolved outcome, shared by review.json enforcement and the dashboard so both agree.\n// PASS, WARN and OVERRIDDEN all ship; FAIL, MISSING and BAD_FORMAT all refuse the PR.\nexport const CK_PASS = 'pass'; // review-<id>.json status:'green'\nexport const CK_WARN = 'warn'; // review-<id>.json status:'yellow' → 🟡 passes WITH concerns\nexport const CK_OVERRIDDEN = 'overridden'; // review-<id>.json status:'red' + non-empty override → 🟠\nexport const CK_FAIL = 'fail'; // review-<id>.json status:'red' + no override → refuse\nexport const CK_MISSING = 'missing'; // no review-<id>.json written → refuse\nexport const CK_BAD_FORMAT = 'bad-format'; // written, but its verdict is unreadable (e.g. legacy `success`)\n\nexport class ChecklistVerdict {\n id: string;\n status: string; // one of CK_PASS | CK_WARN | CK_OVERRIDDEN | CK_FAIL | CK_MISSING | CK_BAD_FORMAT\n detail: string; // reviewer output / override justification / format complaint (dashboard + errors)\n\n constructor(id: string, status: string, detail: string) {\n this.id = id;\n this.status = status;\n this.detail = detail;\n }\n}\n\n// The PR's diff context, written by wp-start-upsert-pr into `.webpieces/pr-review/<branch>/pr-context.json`\n// so a reviewer subagent knows the exact 3-point base the gate used and the full changed-file set — then\n// reads any file's actual diff with `git diff <base> HEAD -- <file>`. This is what lets a checklist match\n// coarsely by path (in the config) while the subagent makes the fine, content-level judgment. Data-only.\nexport class PrContext {\n base: string; // the 3-point merge-base sha the gate diffs against\n /**\n * The real HEAD sha. This was once the literal string 'HEAD', which is not a fact — it cannot be\n * compared later to detect that the tree moved under a review, and it reads as a range that was never\n * actually diffed. Its only reader (reviewContextFor) takes `base`, so recording the sha is free.\n */\n head: string;\n changedFiles: string[]; // every file changed in the range (NOT tsOnly — includes .sql/.gql/Dockerfile/…)\n dirty: boolean; // true ⇒ changedFiles includes uncommitted + untracked work\n dirtyFiles: string[]; // exactly which paths are uncommitted/untracked — why `dirty` is true\n diffCommand: string; // the command that reproduces the WHOLE diff (see DiffBasis; correct when dirty)\n diffDir: string; // dir holding the materialized per-file diffs + ALL.diff; '' when not materialized\n generatedAt: string; // ISO timestamp, so a stale context is detectable rather than silently trusted\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n base: string, head: string, changedFiles: string[],\n dirty = false, dirtyFiles: string[] = [], diffCommand = '', diffDir = '', generatedAt = '',\n ) {\n this.base = base;\n this.head = head;\n this.changedFiles = changedFiles;\n this.dirty = dirty;\n this.dirtyFiles = dirtyFiles;\n this.diffCommand = diffCommand;\n this.diffDir = diffDir;\n this.generatedAt = generatedAt;\n }\n}\n\nconst RISK_LEVELS = ['green', 'yellow', 'red'] as const;\nconst EMOJI_FOR_LEVEL: Record<string, string> = { green: '🟢', yellow: '🟡', red: '🔴' };\n\n/** Locates + loads/validates the AI-authored review.json. `@injectable(bindingScopeValues.Singleton)` so it's drawn in the design. */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewJsonService {\n // The per-feature PR working dir: `.webpieces/pr-review/<feature>`.\n prDirFor(repoRoot: string, featureName: string): string {\n return path.join(repoRoot, WEBPIECES_TMP_DIR, PR_REVIEW_DIR, featureName);\n }\n\n // Absolute path of the review.json for a feature — beside pr-body.md, keyed by branch name.\n reviewJsonPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'review.json');\n }\n\n // Absolute path of the pr-context.json for a feature (the diff base/head + changed files).\n prContextPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'pr-context.json');\n }\n\n // Persist the PR's diff context so reviewer subagents can read the changed-file set + the exact base\n // sha (then `git diff <base> HEAD -- <file>` for content). Returns the file path written.\n writePrContext(repoRoot: string, featureName: string, context: PrContext): string {\n const dir = this.prDirFor(repoRoot, featureName);\n fs.mkdirSync(dir, { recursive: true });\n const p = this.prContextPath(repoRoot, featureName);\n fs.writeFileSync(p, JSON.stringify(context, null, 2) + '\\n');\n return p;\n }\n\n /**\n * The review context for a feature, recovered from the pr-context.json wp-start-upsert-pr already wrote.\n * Lets wp-finish-upsert-pr's \"you still owe me review-<id>.json\" message inline the SAME self-sufficient\n * per-reviewer block start printed, instead of a checklist name and an indirection. Empty when the file\n * is absent or unreadable — the block then just omits those lines.\n */\n reviewContextFor(repoRoot: string, featureName: string): ChecklistReviewContext {\n const p = this.prContextPath(repoRoot, featureName);\n if (!fs.existsSync(p)) return new ChecklistReviewContext();\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable context file degrades to fewer printed lines, never a crash\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(p, 'utf8')) as Record<string, unknown>;\n const base = typeof raw['base'] === 'string' ? (raw['base'] as string) : '';\n // Recover the REPRODUCE command rather than re-deriving it: a context written by an older\n // pr-gate has no diffCommand, and guessing `<base> HEAD` there would resurrect the exact\n // empty-on-a-dirty-tree bug this field exists to kill. Absent ⇒ omit the line entirely.\n const cmd = typeof raw['diffCommand'] === 'string' ? (raw['diffCommand'] as string) : '';\n const diffDir = typeof raw['diffDir'] === 'string' ? (raw['diffDir'] as string) : '';\n const dirty = raw['dirty'] === true;\n return new ChecklistReviewContext(base, p, cmd === '' ? '' : `${cmd} -- <file>`, diffDir, dirty);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return new ChecklistReviewContext('', p);\n }\n }\n\n // Copy-paste schema both commands print. `required` is the set of checklists the diff MATCHED; empty\n // ⇒ output identical to a repo with no checklists. Non-empty ⇒ appends per-checklist instructions\n // naming the reviewer subagent + doc + the review-<id>.json to write.\n reviewJsonSchemaHint(filePath: string): string {\n return (\n `Write your PR review to:\\n ${filePath}\\n\\n` +\n `with this exact JSON shape (riskEmoji optional — derived from riskLevel):\\n\\n` +\n `{\\n` +\n ` \"title\": \"concise PR title describing the change (imperative, no branch names)\",\\n` +\n ` \"riskScore\": 0, // integer 0–100 (higher = riskier)\\n` +\n ` \"riskLevel\": \"green | yellow | red\",\\n` +\n ` \"summary\": \"5–10 sentence review summary\",\\n` +\n ` \"violations\": [\"pattern/architecture violations you found (empty array if none)\"],\\n` +\n ` \"risks\": [\"notable risks (empty array if none)\"],\\n` +\n ` \"filesToReview\": [\"paths a human should look at (empty array if none)\"]\\n` +\n `}`\n );\n }\n\n // The per-checklist review file path that sits beside review.json: review-<id>.json.\n checklistResultPath(reviewJsonFilePath: string, checklistId: string): string {\n return path.join(path.dirname(reviewJsonFilePath), `review-${checklistId}.json`);\n }\n\n /**\n * Load + validate the AI-authored review.json. Throws InformAiError (with the schema) when missing,\n * unparseable, or structurally wrong. `required` is the set of checklists the diff matched: every one\n * must have a well-formed, passing (or overridden) review-<id>.json or a validation error is raised\n * alongside the usual ones so the AI gets ONE message.\n */\n // webpieces-disable max-lines-new-methods -- one cohesive load+validate pass over the review fields\n loadReviewJson(filePath: string, required: readonly RequiredChecklist[] = []): ReviewJson {\n if (!fs.existsSync(filePath)) {\n throw new InformAiError(\n `Required review.json not found.\\n\\n${this.reviewJsonSchemaHint(filePath)}\\n\\n` +\n `Then re-run: pnpm wp-finish-upsert-pr`,\n );\n }\n\n const raw = this.parseReviewJson(fs.readFileSync(filePath, 'utf8'), filePath);\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n throw new InformAiError(`review.json must be a JSON object.\\n\\n${this.reviewJsonSchemaHint(filePath)}`);\n }\n\n const errors: string[] = [];\n\n const riskScore = raw['riskScore'];\n if (typeof riskScore !== 'number' || !Number.isFinite(riskScore) || riskScore < 0 || riskScore > 100) {\n errors.push(`\"riskScore\" must be a number 0–100, got ${JSON.stringify(riskScore)}.`);\n }\n\n const riskLevel = raw['riskLevel'];\n if (typeof riskLevel !== 'string' || !RISK_LEVELS.includes(riskLevel as typeof RISK_LEVELS[number])) {\n errors.push(`\"riskLevel\" must be one of: ${RISK_LEVELS.join(', ')}.`);\n }\n\n const title = typeof raw['title'] === 'string' ? (raw['title'] as string).trim() : '';\n if (title === '') {\n errors.push('\"title\" must be a non-empty, imperative PR title describing the change (no branch names).');\n }\n\n const results = this.loadChecklistResults(filePath, required);\n for (const err of this.requiredChecklistErrors(required, results)) errors.push(err);\n\n if (errors.length > 0) {\n throw new InformAiError(\n `review.json has ${errors.length} error(s) — fix ALL, then re-run pnpm wp-finish-upsert-pr:\\n\\n` +\n errors.map((e: string): string => ` • ${e}`).join('\\n') +\n `\\n\\n${this.reviewJsonSchemaHint(filePath)}`,\n );\n }\n\n const level = riskLevel as string;\n const emoji = typeof raw['riskEmoji'] === 'string' && raw['riskEmoji'] !== ''\n ? (raw['riskEmoji'] as string)\n : (EMOJI_FOR_LEVEL[level] ?? '🟡');\n const summary = typeof raw['summary'] === 'string' ? (raw['summary'] as string) : '';\n\n return new ReviewJson(\n title,\n riskScore as number,\n level,\n emoji,\n summary,\n this.asStringArray(raw['violations']),\n this.asStringArray(raw['risks']),\n this.asStringArray(raw['filesToReview']),\n results,\n );\n }\n\n /**\n * The checklists that still OWE a verdict: no review-<id>.json at all, a malformed one, or one whose\n * verdict is an un-overridden FAIL. This is the set every message lists — a checklist already PASSed or\n * OVERRIDDEN on this branch is deliberately NOT re-listed, because re-instructing it invites a redundant\n * second run and reads as though the earlier verdict did not count.\n */\n pendingChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => {\n const status = this.resolveVerdict(req, results).status;\n // CK_WARN must be listed here beside PASS/OVERRIDDEN. A yellow verdict SHIPS — leaving it out\n // would mark the checklist owed forever, so `outstanding` never empties and the PR is refused\n // permanently no matter how many times the reviewer runs.\n return status !== CK_PASS && status !== CK_WARN && status !== CK_OVERRIDDEN;\n });\n }\n\n // Read the per-checklist verdict files `review-<id>.json` beside review.json — one per matched checklist.\n // A missing file is simply absent from the result (→ counts as MISSING for that checklist); a malformed\n // one is skipped (a stale review-<id>.json never wedges the branch).\n loadChecklistResults(reviewJsonFilePath: string, required: readonly RequiredChecklist[]): ChecklistResult[] {\n const results: ChecklistResult[] = [];\n for (const req of required) {\n const p = this.checklistResultPath(reviewJsonFilePath, req.id);\n if (!fs.existsSync(p)) continue;\n const parsed = this.parseChecklistResult(p, req.id);\n if (parsed) results.push(parsed);\n }\n return results;\n }\n\n // Resolve ONE checklist's verdict from its review-<id>.json. Central so review.json enforcement AND the\n // finish-command dashboard agree on the outcome. `problem` is checked FIRST: a file whose verdict cannot\n // be read must not fall through to any shipping outcome.\n resolveVerdict(req: RequiredChecklist, results: readonly ChecklistResult[]): ChecklistVerdict {\n const result = results.find((r: ChecklistResult): boolean => r.id === req.id);\n if (!result) return new ChecklistVerdict(req.id, CK_MISSING, '');\n if (result.problem !== '') return new ChecklistVerdict(req.id, CK_BAD_FORMAT, result.problem);\n if (result.status === VERDICT_GREEN) return new ChecklistVerdict(req.id, CK_PASS, result.output);\n if (result.status === VERDICT_YELLOW) return new ChecklistVerdict(req.id, CK_WARN, result.output);\n if (result.override.trim() !== '') return new ChecklistVerdict(req.id, CK_OVERRIDDEN, result.override.trim());\n return new ChecklistVerdict(req.id, CK_FAIL, result.output);\n }\n\n /**\n * One loud complaint per checklist whose verdict file EXISTS but cannot be read as a verdict — almost\n * always one still using the removed `success` field. Public and separate from\n * {@link requiredChecklistErrors} because `wp-finish-upsert-pr` refuses on missing reviewers BEFORE it\n * parses review.json: without this, a legacy file would surface as the generic \"no verdict yet\" block\n * and the AI would re-run a reviewer that already ran instead of fixing four characters of JSON.\n */\n checklistFormatErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): string[] {\n const errors: string[] = [];\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n if (verdict.status === CK_BAD_FORMAT) errors.push(verdict.detail);\n }\n return errors;\n }\n\n // Every matched checklist whose verdict is FAIL (reviewed, found a problem, no override) or MISSING (no\n // review-<id>.json written) → one error each, printing the reviewer's `output` verbatim.\n private requiredChecklistErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): string[] {\n // Format complaints come from the ONE renderer, so wp-review-upsert-pr and wp-finish word them identically.\n const errors: string[] = this.checklistFormatErrors(required, results);\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n // CK_WARN ('yellow' — passed with concerns) is deliberately absent from this chain: it SHIPS.\n // The concern still reaches the PR, published in the checklist comment. Do not \"fix\" this.\n if (verdict.status === CK_FAIL) {\n errors.push(\n `Checklist \"${req.id}\" FAILED review (status:\"${VERDICT_RED}\"). The reviewer (${req.subagent}) wrote:\\n ` +\n `${verdict.detail.split('\\n').join('\\n ')}\\n` +\n ` Fix it, then re-run; or set a non-empty \"override\" in ${this.checklistFileName(req.id)} to ship anyway with a stated justification.`,\n );\n } else if (verdict.status === CK_MISSING) {\n const doc = req.doc.trim() !== '' ? ` Read: ${req.doc}.` : '';\n errors.push(\n `Checklist \"${req.id}\" MATCHED this diff but has no verdict. Spawn the \"${req.subagent}\" subagent to review it, ` +\n `then write ${this.checklistFileName(req.id)} with ` +\n `{\"id\":\"${req.id}\",\"status\":\"${VERDICT_GREEN}\",\"output\":\"…\",\"override\":\"\"}.${doc}`,\n );\n }\n }\n return errors;\n }\n\n private checklistFileName(checklistId: string): string {\n return `review-${checklistId}.json`;\n }\n\n /**\n * THE renderer for a reviewer's verdict schema — with the reviewer's own `id` already filled in and,\n * when known, the exact file it must write.\n *\n * There is one because a verdict schema that lives anywhere a human maintains it goes stale, and a\n * reviewer follows the stale copy. That is not a hypothetical: when `success` was replaced by the\n * tri-state `status`, hand-written `.claude/agents/*.md` files kept documenting `success`, and a real\n * PR had to carry \"the verdict format in your own agent .md file is OUT OF DATE\" in the spawn prompt to\n * work around it. Every printed copy — the stage-② roster, the generated per-reviewer instructions\n * file, and the complaint raised against a malformed verdict — now comes from here.\n *\n * `verdictPath` may be '' when the caller is describing the shape rather than a specific file.\n */\n verdictSchemaFor(id: string, verdictPath = '', indent = ' '): string {\n const lines = [\n `${indent}{ \"id\": \"${id}\", \"status\": \"${VERDICT_GREEN} | ${VERDICT_YELLOW} | ${VERDICT_RED}\", ` +\n `\"output\": \"what you checked / found\", \"override\": \"\" }`,\n `${indent} ${VERDICT_GREEN} → passes, nothing to flag`,\n `${indent} ${VERDICT_YELLOW} → passes WITH CONCERNS; nothing is blocked and the concern is published on the PR`,\n `${indent} ${VERDICT_RED} → REFUSES the PR (set a non-empty \"override\" to ship anyway with a stated justification)`,\n `${indent}Prefer \"${VERDICT_YELLOW}\" over red-plus-override when the change is acceptable but worth a human's`,\n `${indent}attention — an override reads as a deliberately-accepted defect, a yellow reads as a note.`,\n ];\n if (verdictPath !== '') lines.push(`${indent}File: ${verdictPath}`);\n return lines.join('\\n');\n }\n\n /**\n * Parse one review-<id>.json into a ChecklistResult. `null` ONLY when the bytes do not parse as a JSON\n * object at all — that tolerance is why a half-written file never wedges a branch, and it degrades to\n * the same \"no verdict yet\" message as an absent file, which is honest (nothing readable is there).\n *\n * A file that DOES parse always yields a result, even when its verdict is unreadable, carrying the\n * complaint in `problem`. Returning `null` for those instead would collapse \"wrote a verdict in the old\n * format\" into \"never wrote a verdict\" and send the AI off to re-run a reviewer that already ran.\n */\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field\n private parseChecklistResult(filePath: string, id: string): ChecklistResult | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unparseable per-checklist file is skipped, not fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed below\n const raw = JSON.parse(fs.readFileSync(filePath, 'utf8')) as Record<string, unknown>;\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return null;\n const output = typeof raw['output'] === 'string' ? (raw['output'] as string) : '';\n const override = typeof raw['override'] === 'string' ? (raw['override'] as string) : '';\n const status = typeof raw['status'] === 'string' ? (raw['status'] as string).trim().toLowerCase() : '';\n return new ChecklistResult(id, status, output, override, this.statusProblem(filePath, id, status, raw));\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * '' when `status` is one of the three colors. Otherwise the complaint to show the AI verbatim. The\n * legacy-`success` case gets its OWN message: `success` was removed outright (no compatibility mode),\n * and a reviewer told only \"status must be green|yellow|red\" cannot tell whether it wrote the wrong\n * value or is using a field that no longer exists.\n */\n // webpieces-disable no-any-unknown -- opaque parsed JSON; only tested for key presence here\n private statusProblem(filePath: string, id: string, status: string, raw: Record<string, unknown>): string {\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if ((VERDICT_STATUSES as readonly string[]).includes(status)) return '';\n // The ONE renderer — see verdictSchemaFor. A second copy here is what let the old `success` shape\n // survive in print after it was removed from the parser.\n const shape = this.verdictSchemaFor(id, filePath);\n if ('success' in raw) {\n return `Checklist \"${id}\" wrote its verdict with the REMOVED \"success\" field. It is now a tri-state ` +\n `\"status\" — there is no compatibility mode. Rewrite the file as:\\n${shape}`;\n }\n return `Checklist \"${id}\" wrote a verdict with no valid \"status\" (got ${JSON.stringify(status)}). ` +\n `It must be exactly one of ${VERDICT_STATUSES.join(', ')}:\\n${shape}`;\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON value, narrowed to string[] here\n private asStringArray(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n // webpieces-disable no-any-unknown -- element of an opaque JSON array, narrowed by the type guard\n return value.filter((v: unknown): v is string => typeof v === 'string');\n }\n\n // Parse opaque AI-authored JSON, converting a SyntaxError into a readable InformAiError.\n // webpieces-disable no-any-unknown -- returns the opaque parsed object; loadReviewJson narrows each field\n private parseReviewJson(raw: string, filePath: string): Record<string, unknown> {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: convert JSON.parse SyntaxError to an InformAiError for the AI\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed by the caller\n return JSON.parse(raw) as Record<string, unknown>;\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(\n `review.json is not valid JSON (${error.message}).\\n\\n${this.reviewJsonSchemaHint(filePath)}\\n\\n` +\n `Then re-run: pnpm wp-finish-upsert-pr`,\n );\n }\n }\n}\n\n// Temporary migration delegators to ReviewJsonService — removed once consumers inject it.\nconst reviewJsonSvc = new ReviewJsonService();\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function prDirFor(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.prDirFor(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function reviewJsonPath(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.reviewJsonPath(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function reviewJsonSchemaHint(filePath: string): string {\n return reviewJsonSvc.reviewJsonSchemaHint(filePath);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function loadReviewJson(filePath: string, required: readonly RequiredChecklist[] = []): ReviewJson {\n return reviewJsonSvc.loadReviewJson(filePath, required);\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ReviewJsonService } from './review-json';
|
|
2
|
+
/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */
|
|
3
|
+
export declare class ContextEntry {
|
|
4
|
+
label: string;
|
|
5
|
+
path: string;
|
|
6
|
+
note: string;
|
|
7
|
+
constructor(label: string, entryPath: string, note?: string);
|
|
8
|
+
}
|
|
9
|
+
/** One reviewer's matched file and the extracted diff for it. Data-only. */
|
|
10
|
+
export declare class BriefedFile {
|
|
11
|
+
file: string;
|
|
12
|
+
diffPath: string;
|
|
13
|
+
constructor(file: string, diffPath: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.
|
|
17
|
+
*
|
|
18
|
+
* Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a
|
|
19
|
+
* relative path that fails to resolve turns into a search, which is the cost this whole class exists to
|
|
20
|
+
* remove. Data-only.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ReviewerBriefing {
|
|
23
|
+
subagent: string;
|
|
24
|
+
docPath: string;
|
|
25
|
+
repoRoot: string;
|
|
26
|
+
diffDir: string;
|
|
27
|
+
allDiffPath: string;
|
|
28
|
+
manifestPath: string;
|
|
29
|
+
myFiles: BriefedFile[];
|
|
30
|
+
matchedPatterns: string[];
|
|
31
|
+
sourceDirs: string[];
|
|
32
|
+
contextEntries: ContextEntry[];
|
|
33
|
+
verdictPath: string;
|
|
34
|
+
checklistId: string;
|
|
35
|
+
fileDiffCommand: string;
|
|
36
|
+
dirty: boolean;
|
|
37
|
+
constructor(subagent: string, checklistId: string, repoRoot: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to
|
|
41
|
+
* `.webpieces/pr-review/<feature>/instructions/<subagent>.instructions.md`.
|
|
42
|
+
*
|
|
43
|
+
* WHY this file exists, measured rather than assumed: a reviewer subagent on monorepo-nx2 spent **14 of its
|
|
44
|
+
* 26 tool calls** rediscovering context the tooling already had — three separate greps into
|
|
45
|
+
* `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a
|
|
46
|
+
* re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is
|
|
47
|
+
* chosen to delete a specific one of those calls.
|
|
48
|
+
*
|
|
49
|
+
* It is GENERATED per run, and the registered `.claude/agents/<subagent>.md` is a thin stub that points
|
|
50
|
+
* here, because content a human maintains goes stale and a reviewer follows the stale copy. The verdict
|
|
51
|
+
* schema in particular comes from {@link ReviewJsonService.verdictSchemaFor}.
|
|
52
|
+
*
|
|
53
|
+
* `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
|
|
54
|
+
*/
|
|
55
|
+
export declare class ReviewerInstructionsService {
|
|
56
|
+
private readonly reviewJsonService;
|
|
57
|
+
constructor(reviewJsonService: ReviewJsonService);
|
|
58
|
+
/** The dir holding this branch's generated instructions, beside its review.json. */
|
|
59
|
+
instructionsDirFor(repoRoot: string, featureName: string): string;
|
|
60
|
+
/** The file name for a reviewer's generated instructions. */
|
|
61
|
+
fileNameFor(subagent: string): string;
|
|
62
|
+
/** Absolute path of one reviewer's generated instructions file. */
|
|
63
|
+
pathFor(repoRoot: string, featureName: string, subagent: string): string;
|
|
64
|
+
render(briefing: ReviewerBriefing): string;
|
|
65
|
+
private identity;
|
|
66
|
+
private checklistSection;
|
|
67
|
+
/**
|
|
68
|
+
* The change itself. The materialized diff leads because it is ONE Read instead of a shell-out per file,
|
|
69
|
+
* and because a hand-assembled range can come back empty (it did — see DiffBasis).
|
|
70
|
+
*/
|
|
71
|
+
private diffSection;
|
|
72
|
+
private myFilesTable;
|
|
73
|
+
private sourceSection;
|
|
74
|
+
/**
|
|
75
|
+
* The section that deletes the `node_modules` greps. Entries come from config, because the tooling
|
|
76
|
+
* cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package
|
|
77
|
+
* installed to, and it must never drop an entry silently: a missing path is stated as missing.
|
|
78
|
+
*/
|
|
79
|
+
private contextSection;
|
|
80
|
+
/**
|
|
81
|
+
* The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this
|
|
82
|
+
* reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.
|
|
83
|
+
*/
|
|
84
|
+
private verdictSection;
|
|
85
|
+
private budgetSection;
|
|
86
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReviewerInstructionsService = exports.ReviewerBriefing = exports.BriefedFile = exports.ContextEntry = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const inversify_1 = require("inversify");
|
|
7
|
+
const review_json_1 = require("./review-json");
|
|
8
|
+
/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */
|
|
9
|
+
class ContextEntry {
|
|
10
|
+
label;
|
|
11
|
+
path; // ABSOLUTE, or '' when it could not be resolved
|
|
12
|
+
note; // '(not installed)' / '(configured but missing)' — never silently dropped
|
|
13
|
+
constructor(label, entryPath, note = '') {
|
|
14
|
+
this.label = label;
|
|
15
|
+
this.path = entryPath;
|
|
16
|
+
this.note = note;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ContextEntry = ContextEntry;
|
|
20
|
+
/** One reviewer's matched file and the extracted diff for it. Data-only. */
|
|
21
|
+
class BriefedFile {
|
|
22
|
+
file; // repo-relative source path
|
|
23
|
+
diffPath; // ABSOLUTE path of the extracted .diff
|
|
24
|
+
constructor(file, diffPath) {
|
|
25
|
+
this.file = file;
|
|
26
|
+
this.diffPath = diffPath;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.BriefedFile = BriefedFile;
|
|
30
|
+
/**
|
|
31
|
+
* Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.
|
|
32
|
+
*
|
|
33
|
+
* Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a
|
|
34
|
+
* relative path that fails to resolve turns into a search, which is the cost this whole class exists to
|
|
35
|
+
* remove. Data-only.
|
|
36
|
+
*/
|
|
37
|
+
class ReviewerBriefing {
|
|
38
|
+
subagent;
|
|
39
|
+
docPath; // the checklist's guidance doc ('' when the checklist has none)
|
|
40
|
+
repoRoot;
|
|
41
|
+
diffDir; // '' when nothing was materialized
|
|
42
|
+
allDiffPath;
|
|
43
|
+
manifestPath;
|
|
44
|
+
myFiles; // ONLY this reviewer's matched files
|
|
45
|
+
matchedPatterns; // [] ⇒ patternless: the whole diff is in scope
|
|
46
|
+
sourceDirs; // deduped ABSOLUTE parent dirs of myFiles
|
|
47
|
+
contextEntries;
|
|
48
|
+
verdictPath; // ABSOLUTE review-<id>.json
|
|
49
|
+
checklistId;
|
|
50
|
+
fileDiffCommand;
|
|
51
|
+
dirty;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
53
|
+
constructor(subagent, checklistId, repoRoot) {
|
|
54
|
+
this.subagent = subagent;
|
|
55
|
+
this.checklistId = checklistId;
|
|
56
|
+
this.repoRoot = repoRoot;
|
|
57
|
+
this.docPath = '';
|
|
58
|
+
this.diffDir = '';
|
|
59
|
+
this.allDiffPath = '';
|
|
60
|
+
this.manifestPath = '';
|
|
61
|
+
this.myFiles = [];
|
|
62
|
+
this.matchedPatterns = [];
|
|
63
|
+
this.sourceDirs = [];
|
|
64
|
+
this.contextEntries = [];
|
|
65
|
+
this.verdictPath = '';
|
|
66
|
+
this.fileDiffCommand = '';
|
|
67
|
+
this.dirty = false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ReviewerBriefing = ReviewerBriefing;
|
|
71
|
+
/**
|
|
72
|
+
* Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to
|
|
73
|
+
* `.webpieces/pr-review/<feature>/instructions/<subagent>.instructions.md`.
|
|
74
|
+
*
|
|
75
|
+
* WHY this file exists, measured rather than assumed: a reviewer subagent on monorepo-nx2 spent **14 of its
|
|
76
|
+
* 26 tool calls** rediscovering context the tooling already had — three separate greps into
|
|
77
|
+
* `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a
|
|
78
|
+
* re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is
|
|
79
|
+
* chosen to delete a specific one of those calls.
|
|
80
|
+
*
|
|
81
|
+
* It is GENERATED per run, and the registered `.claude/agents/<subagent>.md` is a thin stub that points
|
|
82
|
+
* here, because content a human maintains goes stale and a reviewer follows the stale copy. The verdict
|
|
83
|
+
* schema in particular comes from {@link ReviewJsonService.verdictSchemaFor}.
|
|
84
|
+
*
|
|
85
|
+
* `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
|
|
86
|
+
*/
|
|
87
|
+
let ReviewerInstructionsService = class ReviewerInstructionsService {
|
|
88
|
+
reviewJsonService;
|
|
89
|
+
constructor(reviewJsonService) {
|
|
90
|
+
this.reviewJsonService = reviewJsonService;
|
|
91
|
+
}
|
|
92
|
+
/** The dir holding this branch's generated instructions, beside its review.json. */
|
|
93
|
+
instructionsDirFor(repoRoot, featureName) {
|
|
94
|
+
return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');
|
|
95
|
+
}
|
|
96
|
+
/** The file name for a reviewer's generated instructions. */
|
|
97
|
+
fileNameFor(subagent) {
|
|
98
|
+
return `${subagent}.instructions.md`;
|
|
99
|
+
}
|
|
100
|
+
/** Absolute path of one reviewer's generated instructions file. */
|
|
101
|
+
pathFor(repoRoot, featureName, subagent) {
|
|
102
|
+
return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(subagent));
|
|
103
|
+
}
|
|
104
|
+
render(briefing) {
|
|
105
|
+
return [
|
|
106
|
+
...this.identity(briefing),
|
|
107
|
+
...this.checklistSection(briefing),
|
|
108
|
+
...this.diffSection(briefing),
|
|
109
|
+
...this.sourceSection(briefing),
|
|
110
|
+
...this.contextSection(briefing),
|
|
111
|
+
...this.verdictSection(briefing),
|
|
112
|
+
...this.budgetSection(),
|
|
113
|
+
].join('\n') + '\n';
|
|
114
|
+
}
|
|
115
|
+
identity(b) {
|
|
116
|
+
return [
|
|
117
|
+
`# You are \`${b.subagent}\``,
|
|
118
|
+
'',
|
|
119
|
+
'Review as YOURSELF, against your own checklist — not as a general code reviewer.',
|
|
120
|
+
'You may not review your own authorship, and you may not write another reviewer\'s verdict file.',
|
|
121
|
+
'',
|
|
122
|
+
'_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',
|
|
123
|
+
'paths are absolute because your working directory is not guaranteed to be the repo root._',
|
|
124
|
+
'',
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
checklistSection(b) {
|
|
128
|
+
if (b.docPath === '') {
|
|
129
|
+
return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];
|
|
130
|
+
}
|
|
131
|
+
return ['## Your checklist', '', `Read this FIRST: \`${b.docPath}\``, ''];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The change itself. The materialized diff leads because it is ONE Read instead of a shell-out per file,
|
|
135
|
+
* and because a hand-assembled range can come back empty (it did — see DiffBasis).
|
|
136
|
+
*/
|
|
137
|
+
diffSection(b) {
|
|
138
|
+
const lines = ['## The change you are reviewing', ''];
|
|
139
|
+
if (b.dirty) {
|
|
140
|
+
lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');
|
|
141
|
+
lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');
|
|
142
|
+
lines.push('');
|
|
143
|
+
}
|
|
144
|
+
if (b.allDiffPath !== '') {
|
|
145
|
+
lines.push(`**Everything on this branch, already extracted:** \`${b.allDiffPath}\``);
|
|
146
|
+
lines.push('');
|
|
147
|
+
}
|
|
148
|
+
lines.push(...this.myFilesTable(b));
|
|
149
|
+
if (b.manifestPath !== '') {
|
|
150
|
+
lines.push(`Path map (authoritative; records truncated + excluded files): \`${b.manifestPath}\``);
|
|
151
|
+
lines.push('');
|
|
152
|
+
}
|
|
153
|
+
if (b.fileDiffCommand !== '') {
|
|
154
|
+
lines.push(`Reproduce any single file: \`${b.fileDiffCommand}\``);
|
|
155
|
+
lines.push('');
|
|
156
|
+
}
|
|
157
|
+
lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');
|
|
158
|
+
lines.push('irrelevant to your checklist, say so in one sentence and move on.');
|
|
159
|
+
lines.push('');
|
|
160
|
+
return lines;
|
|
161
|
+
}
|
|
162
|
+
myFilesTable(b) {
|
|
163
|
+
if (b.myFiles.length === 0)
|
|
164
|
+
return ['_No files matched your patterns._', ''];
|
|
165
|
+
const why = b.matchedPatterns.length === 0
|
|
166
|
+
? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \`patterns\`, so the whole diff is yours.`
|
|
167
|
+
: `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p) => `\`${p}\``).join(', ')}:`;
|
|
168
|
+
const rows = b.myFiles.map((f) => `| \`${f.file}\` | \`${f.diffPath}\` |`);
|
|
169
|
+
return [why, '', '| file | its diff |', '|---|---|', ...rows, ''];
|
|
170
|
+
}
|
|
171
|
+
sourceSection(b) {
|
|
172
|
+
const lines = ['## Where the source lives', '', `Repo root: \`${b.repoRoot}\``, ''];
|
|
173
|
+
if (b.sourceDirs.length > 0) {
|
|
174
|
+
lines.push('Your matched files live under:');
|
|
175
|
+
for (const dir of b.sourceDirs)
|
|
176
|
+
lines.push(`- \`${dir}\``);
|
|
177
|
+
lines.push('');
|
|
178
|
+
}
|
|
179
|
+
lines.push('Read whole files around the diff when you need to. The diff is the SUBJECT; the surrounding');
|
|
180
|
+
lines.push('code is the CONTEXT — a change that looks fine in isolation can still be wrong in place.');
|
|
181
|
+
lines.push('');
|
|
182
|
+
return lines;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The section that deletes the `node_modules` greps. Entries come from config, because the tooling
|
|
186
|
+
* cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package
|
|
187
|
+
* installed to, and it must never drop an entry silently: a missing path is stated as missing.
|
|
188
|
+
*/
|
|
189
|
+
contextSection(b) {
|
|
190
|
+
if (b.contextEntries.length === 0)
|
|
191
|
+
return [];
|
|
192
|
+
const lines = ['## Pre-resolved context (do not go hunting for these)', ''];
|
|
193
|
+
for (const entry of b.contextEntries) {
|
|
194
|
+
const suffix = entry.note === '' ? '' : ` ${entry.note}`;
|
|
195
|
+
lines.push(`- **${entry.label}** — \`${entry.path === '' ? entry.note : entry.path}\`${entry.path === '' ? '' : suffix}`);
|
|
196
|
+
}
|
|
197
|
+
lines.push('');
|
|
198
|
+
return lines;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this
|
|
202
|
+
* reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.
|
|
203
|
+
*/
|
|
204
|
+
verdictSection(b) {
|
|
205
|
+
return [
|
|
206
|
+
'## Write your verdict',
|
|
207
|
+
'',
|
|
208
|
+
`Write EXACTLY this shape, to EXACTLY this file: \`${b.verdictPath}\``,
|
|
209
|
+
'',
|
|
210
|
+
'```',
|
|
211
|
+
this.reviewJsonService.verdictSchemaFor(b.checklistId, '', ''),
|
|
212
|
+
'```',
|
|
213
|
+
'',
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
budgetSection() {
|
|
217
|
+
return [
|
|
218
|
+
'## Budget',
|
|
219
|
+
'',
|
|
220
|
+
'Everything you need is listed above. Do NOT search `node_modules`, do NOT re-derive the dependency',
|
|
221
|
+
'graph, and do NOT hunt the repo for infrastructure config — those paths are either given above or',
|
|
222
|
+
'were not configured. If something you genuinely need is missing, name it in `output` and give your',
|
|
223
|
+
'verdict on what you could actually see. A reviewer that spends its budget searching produces a',
|
|
224
|
+
'thinner review than one that spends it reading.',
|
|
225
|
+
'',
|
|
226
|
+
'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',
|
|
227
|
+
'reports a verdict written without opening the diff.',
|
|
228
|
+
];
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
exports.ReviewerInstructionsService = ReviewerInstructionsService;
|
|
232
|
+
exports.ReviewerInstructionsService = ReviewerInstructionsService = tslib_1.__decorate([
|
|
233
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
234
|
+
tslib_1.__metadata("design:paramtypes", [review_json_1.ReviewJsonService])
|
|
235
|
+
], ReviewerInstructionsService);
|
|
236
|
+
//# sourceMappingURL=reviewer-instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reviewer-instructions.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/reviewer-instructions.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,+CAAkD;AAElD,2GAA2G;AAC3G,MAAa,YAAY;IACrB,KAAK,CAAS;IACd,IAAI,CAAS,CAAK,gDAAgD;IAClE,IAAI,CAAS,CAAK,0EAA0E;IAE5F,YAAY,KAAa,EAAE,SAAiB,EAAE,IAAI,GAAG,EAAE;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AAVD,oCAUC;AAED,4EAA4E;AAC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;YACvB,EAAE;YACF,qDAAqD,CAAC,CAAC,WAAW,IAAI;YACtE,EAAE;YACF,KAAK;YACL,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC;YAC9D,KAAK;YACL,EAAE;SACL,CAAC;IACN,CAAC;IAEO,aAAa;QACjB,OAAO;YACH,WAAW;YACX,EAAE;YACF,oGAAoG;YACpG,mGAAmG;YACnG,oGAAoG;YACpG,gGAAgG;YAChG,iDAAiD;YACjD,EAAE;YACF,oGAAoG;YACpG,qDAAqD;SACxD,CAAC;IACN,CAAC;CACJ,CAAA;AArJY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,+BAAiB;GADxD,2BAA2B,CAqJvC","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewJsonService } from './review-json';\n\n/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */\nexport class ContextEntry {\n label: string;\n path: string; // ABSOLUTE, or '' when it could not be resolved\n note: string; // '(not installed)' / '(configured but missing)' — never silently dropped\n\n constructor(label: string, entryPath: string, note = '') {\n this.label = label;\n this.path = entryPath;\n this.note = note;\n }\n}\n\n/** One reviewer's matched file and the extracted diff for it. Data-only. */\nexport class BriefedFile {\n file: string; // repo-relative source path\n diffPath: string; // ABSOLUTE path of the extracted .diff\n\n constructor(file: string, diffPath: string) {\n this.file = file;\n this.diffPath = diffPath;\n }\n}\n\n/**\n * Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.\n *\n * Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a\n * relative path that fails to resolve turns into a search, which is the cost this whole class exists to\n * remove. Data-only.\n */\nexport class ReviewerBriefing {\n subagent: string;\n docPath: string; // the checklist's guidance doc ('' when the checklist has none)\n repoRoot: string;\n diffDir: string; // '' when nothing was materialized\n allDiffPath: string;\n manifestPath: string;\n myFiles: BriefedFile[]; // ONLY this reviewer's matched files\n matchedPatterns: string[]; // [] ⇒ patternless: the whole diff is in scope\n sourceDirs: string[]; // deduped ABSOLUTE parent dirs of myFiles\n contextEntries: ContextEntry[];\n verdictPath: string; // ABSOLUTE review-<id>.json\n checklistId: string;\n fileDiffCommand: string;\n dirty: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(subagent: string, checklistId: string, repoRoot: string) {\n this.subagent = subagent;\n this.checklistId = checklistId;\n this.repoRoot = repoRoot;\n this.docPath = '';\n this.diffDir = '';\n this.allDiffPath = '';\n this.manifestPath = '';\n this.myFiles = [];\n this.matchedPatterns = [];\n this.sourceDirs = [];\n this.contextEntries = [];\n this.verdictPath = '';\n this.fileDiffCommand = '';\n this.dirty = false;\n }\n}\n\n/**\n * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to\n * `.webpieces/pr-review/<feature>/instructions/<subagent>.instructions.md`.\n *\n * WHY this file exists, measured rather than assumed: a reviewer subagent on monorepo-nx2 spent **14 of its\n * 26 tool calls** rediscovering context the tooling already had — three separate greps into\n * `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a\n * re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is\n * chosen to delete a specific one of those calls.\n *\n * It is GENERATED per run, and the registered `.claude/agents/<subagent>.md` is a thin stub that points\n * here, because content a human maintains goes stale and a reviewer follows the stale copy. The verdict\n * schema in particular comes from {@link ReviewJsonService.verdictSchemaFor}.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerInstructionsService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** The dir holding this branch's generated instructions, beside its review.json. */\n instructionsDirFor(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');\n }\n\n /** The file name for a reviewer's generated instructions. */\n fileNameFor(subagent: string): string {\n return `${subagent}.instructions.md`;\n }\n\n /** Absolute path of one reviewer's generated instructions file. */\n pathFor(repoRoot: string, featureName: string, subagent: string): string {\n return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(subagent));\n }\n\n render(briefing: ReviewerBriefing): string {\n return [\n ...this.identity(briefing),\n ...this.checklistSection(briefing),\n ...this.diffSection(briefing),\n ...this.sourceSection(briefing),\n ...this.contextSection(briefing),\n ...this.verdictSection(briefing),\n ...this.budgetSection(),\n ].join('\\n') + '\\n';\n }\n\n private identity(b: ReviewerBriefing): string[] {\n return [\n `# You are \\`${b.subagent}\\``,\n '',\n 'Review as YOURSELF, against your own checklist — not as a general code reviewer.',\n 'You may not review your own authorship, and you may not write another reviewer\\'s verdict file.',\n '',\n '_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',\n 'paths are absolute because your working directory is not guaranteed to be the repo root._',\n '',\n ];\n }\n\n private checklistSection(b: ReviewerBriefing): string[] {\n if (b.docPath === '') {\n return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];\n }\n return ['## Your checklist', '', `Read this FIRST: \\`${b.docPath}\\``, ''];\n }\n\n /**\n * The change itself. The materialized diff leads because it is ONE Read instead of a shell-out per file,\n * and because a hand-assembled range can come back empty (it did — see DiffBasis).\n */\n private diffSection(b: ReviewerBriefing): string[] {\n const lines = ['## The change you are reviewing', ''];\n if (b.dirty) {\n lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');\n lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');\n lines.push('');\n }\n if (b.allDiffPath !== '') {\n lines.push(`**Everything on this branch, already extracted:** \\`${b.allDiffPath}\\``);\n lines.push('');\n }\n lines.push(...this.myFilesTable(b));\n if (b.manifestPath !== '') {\n lines.push(`Path map (authoritative; records truncated + excluded files): \\`${b.manifestPath}\\``);\n lines.push('');\n }\n if (b.fileDiffCommand !== '') {\n lines.push(`Reproduce any single file: \\`${b.fileDiffCommand}\\``);\n lines.push('');\n }\n lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');\n lines.push('irrelevant to your checklist, say so in one sentence and move on.');\n lines.push('');\n return lines;\n }\n\n private myFilesTable(b: ReviewerBriefing): string[] {\n if (b.myFiles.length === 0) return ['_No files matched your patterns._', ''];\n const why = b.matchedPatterns.length === 0\n ? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \\`patterns\\`, so the whole diff is yours.`\n : `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p: string): string => `\\`${p}\\``).join(', ')}:`;\n const rows = b.myFiles.map((f: BriefedFile): string => `| \\`${f.file}\\` | \\`${f.diffPath}\\` |`);\n return [why, '', '| file | its diff |', '|---|---|', ...rows, ''];\n }\n\n private sourceSection(b: ReviewerBriefing): string[] {\n const lines = ['## Where the source lives', '', `Repo root: \\`${b.repoRoot}\\``, ''];\n if (b.sourceDirs.length > 0) {\n lines.push('Your matched files live under:');\n for (const dir of b.sourceDirs) lines.push(`- \\`${dir}\\``);\n lines.push('');\n }\n lines.push('Read whole files around the diff when you need to. The diff is the SUBJECT; the surrounding');\n lines.push('code is the CONTEXT — a change that looks fine in isolation can still be wrong in place.');\n lines.push('');\n return lines;\n }\n\n /**\n * The section that deletes the `node_modules` greps. Entries come from config, because the tooling\n * cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package\n * installed to, and it must never drop an entry silently: a missing path is stated as missing.\n */\n private contextSection(b: ReviewerBriefing): string[] {\n if (b.contextEntries.length === 0) return [];\n const lines = ['## Pre-resolved context (do not go hunting for these)', ''];\n for (const entry of b.contextEntries) {\n const suffix = entry.note === '' ? '' : ` ${entry.note}`;\n lines.push(`- **${entry.label}** — \\`${entry.path === '' ? entry.note : entry.path}\\`${entry.path === '' ? '' : suffix}`);\n }\n lines.push('');\n return lines;\n }\n\n /**\n * The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this\n * reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.\n */\n private verdictSection(b: ReviewerBriefing): string[] {\n return [\n '## Write your verdict',\n '',\n `Write EXACTLY this shape, to EXACTLY this file: \\`${b.verdictPath}\\``,\n '',\n '```',\n this.reviewJsonService.verdictSchemaFor(b.checklistId, '', ''),\n '```',\n '',\n ];\n }\n\n private budgetSection(): string[] {\n return [\n '## Budget',\n '',\n 'Everything you need is listed above. Do NOT search `node_modules`, do NOT re-derive the dependency',\n 'graph, and do NOT hunt the repo for infrastructure config — those paths are either given above or',\n 'were not configured. If something you genuinely need is missing, name it in `output` and give your',\n 'verdict on what you could actually see. A reviewer that spends its budget searching produces a',\n 'thinner review than one that spends it reading.',\n '',\n 'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',\n 'reports a verdict written without opening the diff.',\n ];\n }\n}\n"]}
|