@webpieces/ai-hook-rules 0.4.825 → 0.4.826
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/ai-hook-rules",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.826",
|
|
4
4
|
"description": "Pluggable write-time validation framework for AI coding agents (@webpieces/ai-hook-rules). Claude Code PreToolUse + openclaw before_tool_call adapters share one rule engine.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"directory": "packages/tooling/ai-hook-rules"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@webpieces/rules-config": "0.4.
|
|
28
|
+
"@webpieces/rules-config": "0.4.826",
|
|
29
29
|
"inversify": "7.10.4",
|
|
30
30
|
"reflect-metadata": "0.2.2"
|
|
31
31
|
},
|
|
@@ -67,6 +67,14 @@ holds, for its checklist:
|
|
|
67
67
|
|
|
68
68
|
Work only from those files. Nothing about any checklist is restated here, so nothing here can drift.
|
|
69
69
|
|
|
70
|
+
## Before you review: the round budget
|
|
71
|
+
|
|
72
|
+
For EACH checklist you were handed, run \`pnpm wp-write-review --checklist <id> --check\` first. It counts
|
|
73
|
+
how many times that checklist has already been reviewed on this branch against the repository's
|
|
74
|
+
\`maxReviewerRounds\`. When it REFUSES, do not review that checklist and submit nothing for it: report its
|
|
75
|
+
refusal verbatim to your caller ("I am not allowed to review <id>: …"). \`wp-write-review\` refuses an
|
|
76
|
+
over-budget verdict anyway, so a review past the budget is wasted work that cannot be recorded.
|
|
77
|
+
|
|
70
78
|
## How to review
|
|
71
79
|
|
|
72
80
|
1. Handle each checklist SEPARATELY. Read its doc, then its in-scope diffs, then the full source of every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewer-agent.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/reviewer-agent.ts"],"names":[],"mappings":";;;AAqCA,8CAEC;AAGD,
|
|
1
|
+
{"version":3,"file":"reviewer-agent.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/reviewer-agent.ts"],"names":[],"mappings":";;;AAqCA,8CAEC;AAGD,kDAwDC;AAQD,gDAKC;AAOD,gDAOC;;AA7HD,+CAAyB;AACzB,mDAA6B;AAE7B,iCAAkC;AAElC,8EAA8E;AAC9E,yGAAyG;AACzG,gBAAgB;AAChB,EAAE;AACF,yGAAyG;AACzG,sGAAsG;AACtG,wGAAwG;AACxG,wGAAwG;AACxG,qJAAqJ;AACrJ,sGAAsG;AACtG,EAAE;AACF,uFAAuF;AACvF,wGAAwG;AACxG,0GAA0G;AAC1G,qGAAqG;AACrG,6GAA6G;AAC7G,+BAA+B;AAC/B,EAAE;AACF,sGAAsG;AACtG,wBAAwB;AACxB,8EAA8E;AAE9E,gHAAgH;AACnG,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAExD,0FAA0F;AAC7E,QAAA,qBAAqB,GAAG,kBAAkB,2BAAmB,KAAK,CAAC;AAEhF,2GAA2G;AAC9F,QAAA,uBAAuB,GAAG,GAAG,2BAAmB,KAAK,CAAC;AAEnE,wHAAwH;AACxH,SAAgB,iBAAiB,CAAC,WAAmB;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,6BAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,oHAAoH;AACpH,SAAgB,mBAAmB;IAC/B,OAAO;QACH,2BAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqD1B,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,kIAAkI;AAClI,SAAgB,kBAAkB,CAAC,IAAmB;IAClD,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,mBAAmB,EAAE,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,yHAAyH;AACzH,SAAgB,kBAAkB,CAAC,IAAY;IAC3C,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IACtC,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IACvF,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport { shimPath } from './shim';\n\n// ---------------------------------------------------------------------------\n// THE GENERIC REVIEWER AGENT — `.claude/agents/webpieces-reviewer.md`, a webpieces-owned, committed file\n// (issue #938).\n//\n// Every PR-gate checklist used to name its OWN agent type, one `.claude/agents/<name>-reviewer.md` each.\n// Those files added almost nothing over the checklist doc — a tool restriction and a paragraph saying\n// \"read your instructions file\" — were annoying to author per checklist, and drifted (#863: Codex never\n// read them at all). They also forced one subagent per checklist. So a repo now names ONE agent type in\n// `commands.pr-gate` (`webpieces-reviewer` unless `overrideReviewerAgent` is true), and this is the one webpieces ships: checklist-agnostic, because\n// everything checklist-specific is in the per-run instructions files `wp-review-upsert-pr` generates.\n//\n// It is a MANAGED SURFACE, exactly like `.claude/webpieces/ai-hook.sh`: GENERATED from\n// renderReviewerAgent(), byte-STABLE across releases (no version stamp, so it changes only when its own\n// words do), written by `wp-install-ai-hooks` and `wp-upgrade-shim`, and checked by managedSurfaceDrift()\n// so a missing, stale or hand-edited copy is flagged with `pnpm wp-upgrade-shim` as the cure. A repo\n// that wants different words sets `\"overrideReviewerAgent\": true` and `reviewerAgentName` to an agent of its\n// own instead of editing this.\n//\n// fs + path + ./shim only, like the rest of this directory: the cure must run on a tree too broken to\n// load the rule engine.\n// ---------------------------------------------------------------------------\n\n/** The agent type this file registers — the reviewer every repo gets unless it sets `overrideReviewerAgent`. */\nexport const REVIEWER_AGENT_NAME = 'webpieces-reviewer';\n\n/** The committed file, repo-relative — also the name the drift check reports it under. */\nexport const REVIEWER_AGENT_MARKER = `.claude/agents/${REVIEWER_AGENT_NAME}.md`;\n\n/** The copy that ships in the package, byte-identical to renderReviewerAgent() (locked by a unit test). */\nexport const REVIEWER_AGENT_TEMPLATE = `${REVIEWER_AGENT_NAME}.md`;\n\n// webpieces-disable no-function-outside-class -- pure fs+path helper beside shimPath, in the dependency-free bin module\nexport function reviewerAgentPath(projectRoot: string): string {\n return path.join(projectRoot, ...REVIEWER_AGENT_MARKER.split('/'));\n}\n\n// webpieces-disable no-function-outside-class -- pure renderer beside renderShim, in the dependency-free bin module\nexport function renderReviewerAgent(): string {\n return `---\nname: ${REVIEWER_AGENT_NAME}\ndescription: Generic PR-gate reviewer. Reviews a diff against one or more checklist docs, each over its own in-scope files, and submits exactly one verdict per checklist through pnpm wp-write-review. Spawned by \\`pnpm wp-review-upsert-pr\\`, which names the instructions files to read. Never edits code.\ntools: Read, Grep, Glob, Bash, Write\n---\n\n<!-- Generated by webpieces (@webpieces/ai-hook-rules) — do not edit; regenerate with pnpm wp-upgrade-shim.\n To change how reviews are done, set commands.pr-gate \"overrideReviewerAgent\": true and \"reviewerAgentName\" to an agent of your own. -->\n\nYou are a PR-gate reviewer. You did not write this change, and your job is to judge it against the\nchecklist(s) you are handed — nothing else.\n\n## What you are given\n\nYour caller names ONE OR MORE instructions files by absolute path, one per checklist\n(\\`<checklist-id>.instructions.md\\`). Read every one of them FIRST. Each is regenerated on every run and\nholds, for its checklist:\n\n- the checklist doc to review against — the substance of that review;\n- the files in scope, each with its extracted diff and the absolute path of the full source;\n- the diff manifest, the diff basis, and any pre-resolved context for this repo;\n- the exact verdict format, and the exact command that submits it.\n\nWork only from those files. Nothing about any checklist is restated here, so nothing here can drift.\n\n## Before you review: the round budget\n\nFor EACH checklist you were handed, run \\`pnpm wp-write-review --checklist <id> --check\\` first. It counts\nhow many times that checklist has already been reviewed on this branch against the repository's\n\\`maxReviewerRounds\\`. When it REFUSES, do not review that checklist and submit nothing for it: report its\nrefusal verbatim to your caller (\"I am not allowed to review <id>: …\"). \\`wp-write-review\\` refuses an\nover-budget verdict anyway, so a review past the budget is wasted work that cannot be recorded.\n\n## How to review\n\n1. Handle each checklist SEPARATELY. Read its doc, then its in-scope diffs, then the full source of every\n in-scope file — a hunk shows what changed, only the whole file shows what it changed into.\n2. Judge each checklist ONLY against its own in-scope files. A finding that belongs to another checklist\n is not a finding for this one; a matched file that turns out to be irrelevant gets one sentence.\n3. Read other files for context when a judgement needs it, but do not go hunting: no searches through\n \\`node_modules\\`, no re-deriving the dependency graph. If something you need is missing, say so in\n \\`output\\` and judge what you could see.\n\n## What you submit\n\nExactly ONE verdict per checklist you were handed — and nothing for a checklist you were not handed —\nin the format its instructions file gives, submitted through \\`pnpm wp-write-review --checklist <id>\\`\nwith the verdict JSON on stdin (a heredoc is simplest), or \\`--file <path>\\` naming a scratch file. It validates\nit, writes the verdict file, and records that YOU wrote it. A verdict file written any other way —\nby you, or by the coordinating agent on your behalf — is rejected by the gate, so there is no other route.\n\nYou NEVER edit code, config, docs, or any other file in the repo. You never write \\`summary.json\\` or an\n\\`override-<id>.json\\`. If a finding needs a human's decision, say so in \\`output\\`; the coordinating\nagent is the one with the human.\n`;\n}\n\n/**\n * True when this tree is webpieces-hooked (its committed shim exists) and the reviewer agent is MISSING or\n * differs from renderReviewerAgent(). Gated on the shim for the same reason `committedShimStale` is gated\n * on its own file: a tree webpieces never installed into has no managed surface to police.\n */\n// webpieces-disable no-function-outside-class -- pure fs+path helper beside committedShimStale, in the dependency-free bin module\nexport function reviewerAgentStale(root: string | null): boolean {\n if (root === null || !fs.existsSync(shimPath(root))) return false;\n const target = reviewerAgentPath(root);\n if (!fs.existsSync(target)) return true;\n return fs.readFileSync(target, 'utf8') !== renderReviewerAgent();\n}\n\n/**\n * Write the reviewer agent under `root`, returning true when the file changed. Creates `.claude/agents/`\n * when it is absent — that directory is what a Claude Code session scans for agent types.\n */\n// webpieces-disable no-function-outside-class -- pure fs+path writer beside writeShim, in the dependency-free bin module\nexport function writeReviewerAgent(root: string): boolean {\n const target = reviewerAgentPath(root);\n const desired = renderReviewerAgent();\n if (fs.existsSync(target) && fs.readFileSync(target, 'utf8') === desired) return false;\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, desired);\n return true;\n}\n"]}
|
|
@@ -23,6 +23,14 @@ holds, for its checklist:
|
|
|
23
23
|
|
|
24
24
|
Work only from those files. Nothing about any checklist is restated here, so nothing here can drift.
|
|
25
25
|
|
|
26
|
+
## Before you review: the round budget
|
|
27
|
+
|
|
28
|
+
For EACH checklist you were handed, run `pnpm wp-write-review --checklist <id> --check` first. It counts
|
|
29
|
+
how many times that checklist has already been reviewed on this branch against the repository's
|
|
30
|
+
`maxReviewerRounds`. When it REFUSES, do not review that checklist and submit nothing for it: report its
|
|
31
|
+
refusal verbatim to your caller ("I am not allowed to review <id>: …"). `wp-write-review` refuses an
|
|
32
|
+
over-budget verdict anyway, so a review past the budget is wasted work that cannot be recorded.
|
|
33
|
+
|
|
26
34
|
## How to review
|
|
27
35
|
|
|
28
36
|
1. Handle each checklist SEPARATELY. Read its doc, then its in-scope diffs, then the full source of every
|