cursordoctrine 0.4.0 → 0.4.1
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/INSTALL.md +16 -6
- package/README.md +70 -17
- package/bin/cli.mjs +1 -0
- package/linux/hooks/subagent-stop-review.sh +1 -1
- package/package.json +1 -1
- package/skills/anti-slop/SKILL.md +2 -2
- package/windows/hooks/subagent-stop-review.ps1 +1 -1
package/INSTALL.md
CHANGED
|
@@ -26,7 +26,7 @@ Do not guess from the shell you happen to be running in — a Windows machine dr
|
|
|
26
26
|
|
|
27
27
|
Check the prerequisites first:
|
|
28
28
|
|
|
29
|
-
- Windows: PowerShell 7 (`pwsh`) on PATH
|
|
29
|
+
- Windows: **PowerShell 7 (`pwsh`) on PATH**, plus `git`. Python 3.9+ if you want the anti-slop scanner (the hooks work without it). Confirm with `pwsh -Version` — Windows PowerShell 5.1 (`powershell.exe`) is NOT supported; install PowerShell 7 via `winget install --id Microsoft.PowerShell --source winget` if missing.
|
|
30
30
|
- Linux: `bash`, `git`, and either `jq` or `python3` (the hooks prefer `jq` and fall back to `python3`; install `jq` if neither is present). Python 3.9+ for the anti-slop scanner.
|
|
31
31
|
|
|
32
32
|
## 2. Copy the files
|
|
@@ -36,7 +36,7 @@ Windows (from the repo root, in pwsh):
|
|
|
36
36
|
```powershell
|
|
37
37
|
New-Item -ItemType Directory -Force "$HOME\.agents\hooks", "$HOME\.cursor" | Out-Null
|
|
38
38
|
Copy-Item windows\hooks\* "$HOME\.agents\hooks\" -Force
|
|
39
|
-
Copy-Item windows\inject-doctrine.ps1, windows\doctrine.md, windows\USER-RULES.md "$HOME\.cursor\" -Force
|
|
39
|
+
Copy-Item windows\inject-doctrine.ps1, windows\doctrine.md, windows\USER-RULES.md, windows\declared-editing.md, windows\pre-compile.md "$HOME\.cursor\" -Force
|
|
40
40
|
# hooks.json ships with ~/ placeholders; pwsh -File does NOT expand ~, so
|
|
41
41
|
# substitute the real profile path (forward slashes) at install time:
|
|
42
42
|
$h = $HOME -replace '\\', '/'
|
|
@@ -51,7 +51,7 @@ Linux (from the repo root, in bash):
|
|
|
51
51
|
```bash
|
|
52
52
|
mkdir -p ~/.agents/hooks ~/.cursor
|
|
53
53
|
cp linux/hooks/* ~/.agents/hooks/
|
|
54
|
-
cp linux/inject-doctrine.sh linux/doctrine.md linux/USER-RULES.md ~/.cursor/
|
|
54
|
+
cp linux/inject-doctrine.sh linux/doctrine.md linux/USER-RULES.md linux/declared-editing.md linux/pre-compile.md ~/.cursor/
|
|
55
55
|
cp linux/hooks.json ~/.cursor/hooks.json
|
|
56
56
|
chmod +x ~/.agents/hooks/*.sh ~/.cursor/inject-doctrine.sh
|
|
57
57
|
# anti-slop skill (SKILL.md + the scanner the final-review hook runs):
|
|
@@ -76,6 +76,11 @@ echo '{"conversation_id":"t1","status":"completed"}' | bash ~/.agents/hooks/fina
|
|
|
76
76
|
echo '{"conversation_id":"t2","file_path":"/tmp/x.py"}' | bash ~/.agents/hooks/self-review-trigger.sh
|
|
77
77
|
echo '{"conversation_id":"t2","status":"completed"}' | bash ~/.agents/hooks/subagent-stop-review.sh # expect {"followup_message": "SUBAGENT FINAL REVIEW ..."} once, then {}
|
|
78
78
|
echo '{"conversation_id":"t2"}' | bash ~/.agents/hooks/post-tool-use.sh # drain t2's leftover feedback file
|
|
79
|
+
# anchor-set nudge: fires PRE-COMPILE NUDGE on the first edit, silent on the second
|
|
80
|
+
echo '{"conversation_id":"t3","file_path":"/tmp/x.py"}' | bash ~/.agents/hooks/anchor-set-nudge.sh
|
|
81
|
+
echo '{"conversation_id":"t3"}' | bash ~/.agents/hooks/post-tool-use.sh # expect additional_context containing "PRE-COMPILE NUDGE"
|
|
82
|
+
echo '{"conversation_id":"t3","file_path":"/tmp/y.py"}' | bash ~/.agents/hooks/anchor-set-nudge.sh # second edit -> flag armed -> silent
|
|
83
|
+
echo '{"conversation_id":"t3"}' | bash ~/.agents/hooks/post-tool-use.sh # expect {} (nothing new stashed)
|
|
79
84
|
echo '{}' | bash ~/.cursor/inject-doctrine.sh # expect {"additional_context": ...}
|
|
80
85
|
python3 ~/.cursor/skills/anti-slop/scripts/scan_slop.py --help # expect usage text (final review's scanner)
|
|
81
86
|
```
|
|
@@ -91,6 +96,10 @@ Windows (same payloads, swap `bash ~/...sh` for `pwsh.exe -NoProfile -File $HOME
|
|
|
91
96
|
echo '{"command":"git push --force"}' | pwsh.exe -NoProfile -File $HOME\.agents\hooks\permission-gate.ps1
|
|
92
97
|
echo '{"conversation_id":"t2","file_path":"C:\tmp\x.py"}' | pwsh.exe -NoProfile -File $HOME\.agents\hooks\self-review-trigger.ps1
|
|
93
98
|
echo '{"conversation_id":"t2","status":"completed"}' | pwsh.exe -NoProfile -File $HOME\.agents\hooks\subagent-stop-review.ps1 # SUBAGENT FINAL REVIEW once, then {}
|
|
99
|
+
# anchor-set nudge: fires PRE-COMPILE NUDGE on the first edit, silent on the second
|
|
100
|
+
echo '{"conversation_id":"t3","file_path":"C:\tmp\x.py"}' | pwsh.exe -NoProfile -File $HOME\.agents\hooks\anchor-set-nudge.ps1
|
|
101
|
+
echo '{"conversation_id":"t3"}' | pwsh.exe -NoProfile -File $HOME\.agents\hooks\post-tool-use.ps1 # additional_context with "PRE-COMPILE NUDGE"
|
|
102
|
+
echo '{"conversation_id":"t3","file_path":"C:\tmp\y.py"}' | pwsh.exe -NoProfile -File $HOME\.agents\hooks\anchor-set-nudge.ps1 # second edit -> silent
|
|
94
103
|
python $HOME\.cursor\skills\anti-slop\scripts\scan_slop.py --help
|
|
95
104
|
```
|
|
96
105
|
|
|
@@ -99,15 +108,16 @@ Also validate the config: `~/.cursor/hooks.json` must parse as JSON.
|
|
|
99
108
|
## 4. Verify inside Cursor
|
|
100
109
|
|
|
101
110
|
1. Restart Cursor (hooks.json is read at startup).
|
|
102
|
-
2. Open any project and start a new agent chat. The doctrine should be in context — ask the agent "what does your doctrine say about diffs?" and it should answer from §2.
|
|
103
|
-
3. Have the agent make a small edit to a tracked file. On the next turn it should receive a `SELF-REVIEW TRIGGER` message.
|
|
111
|
+
2. Open any project and start a new agent chat. The doctrine should be in context — ask the agent "what does your doctrine say about diffs?" and it should answer from §2; ask "what is the Anchor Set?" and it should answer from `pre-compile.md` (Objective / Constraints / Scope / Deterministic success).
|
|
112
|
+
3. Have the agent make a small edit to a tracked file. On the next turn it should receive a `SELF-REVIEW TRIGGER` message, and (if it's the first edit of the implementation) a `PRE-COMPILE NUDGE` reminder to write its Anchor Set to `.scope.json`.
|
|
104
113
|
4. Ask the agent to run `git push --force` (in a throwaway repo). The permission gate must block it.
|
|
105
114
|
5. Finish a small implementation and stop. A single `FINAL REVIEW` follow-up should fire — exactly once.
|
|
106
115
|
6. Delegate a small edit to a subagent (e.g. ask the agent to "use a generalPurpose subagent to add a comment to <file>"). The subagent should receive one `SUBAGENT FINAL REVIEW` follow-up before returning, and the parent should see `SUBAGENT WORK DETECTED` at its next tool boundary. (`subagentStop` is only read at startup — if nothing fires, restart Cursor again.)
|
|
107
116
|
7. Type `/anti-slop` in a chat (or say "remove the AI slop") — the anti-slop skill should load and run the scanner as its first step.
|
|
117
|
+
8. (Optional, opt-in scope gate) Have the agent write a `.scope.json` in the repo root (`intent` + `files[]` + `acceptance`), then edit a file outside `files[]`. The next turn should carry a `[SCOPE VIOLATION]` advisory quoting the declared `intent` and `acceptance`. Delete the file to disable the gate.
|
|
108
118
|
|
|
109
119
|
## 5. Report
|
|
110
120
|
|
|
111
121
|
Tell the user what was installed, which checks passed, and anything that failed with the exact error. Do not silently work around a failing check.
|
|
112
122
|
|
|
113
|
-
Kill switches if something misbehaves: `HOOKS_ENFORCE=0` (everything advisory off), `PERM_GATE_ENFORCE=0`, `MINIMAL_EDITING_ENFORCE=0` (deprecated in 0.3.0), `SEMANTIC_DENSITY_ENFORCE=0`, `SCOPE_GATE_ENFORCE=0`, `ANTI_SLOP_ENFORCE=0`, `FINAL_REVIEW_ENFORCE=0`, `SUBAGENT_REVIEW_ENFORCE=0`.
|
|
123
|
+
Kill switches if something misbehaves: `HOOKS_ENFORCE=0` (everything advisory off), `PERM_GATE_ENFORCE=0`, `ANCHOR_NUDGE_ENFORCE=0` (pre-compile nudge off), `MINIMAL_EDITING_ENFORCE=0` (deprecated in 0.3.0), `SEMANTIC_DENSITY_ENFORCE=0`, `SCOPE_GATE_ENFORCE=0`, `ANTI_SLOP_ENFORCE=0`, `FINAL_REVIEW_ENFORCE=0`, `SUBAGENT_REVIEW_ENFORCE=0`.
|
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
<div align="center">
|
|
11
11
|
<h1>cursordoctrine</h1>
|
|
12
|
-
<p><strong>
|
|
13
|
-
<p>Five hook events, one message bus.<br />The model audits its own work. Cursor carries context and gates blast radius.</p>
|
|
12
|
+
<p><strong>Self-review hooks for Cursor — proactive and reactive.</strong></p>
|
|
13
|
+
<p>Five hook events, one message bus.<br />The model compiles its intent, audits its own work, and stays on the rails. Cursor carries context and gates blast radius.</p>
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
<br />
|
|
@@ -19,18 +19,35 @@
|
|
|
19
19
|
|
|
20
20
|
## What this is
|
|
21
21
|
|
|
22
|
-
Cursor hooks that make the agent review its own edits without bolting a static-analysis pipeline onto every keystroke. No regex army, no scoring engine.
|
|
22
|
+
Cursor hooks that make the agent review its own edits without bolting a static-analysis pipeline onto every keystroke. No regex army, no scoring engine. Four jobs:
|
|
23
23
|
|
|
24
|
-
1. **
|
|
25
|
-
2. **
|
|
26
|
-
3. **
|
|
24
|
+
1. **Compile intent before coding** (proactive) — at session start the agent gets the doctrine plus the **Anchor Set** discipline (`pre-compile.md`): before writing code it must emit *Objective / Constraints / Scope / Deterministic success*, and write that contract to `.scope.json`. On the first edit of each implementation a `anchor-set-nudge` advisory fires to catch intent dilution at token ~50 instead of waiting for the stop-hook review at token ~5000.
|
|
25
|
+
2. **Inject the doctrine** at session start — every chat starts with the same short governing text (`doctrine.md`, `USER-RULES.md`, `declared-editing.md` the YAGNI ultra ladder, and `pre-compile.md` the thin intent-compilation phase).
|
|
26
|
+
3. **Hand the model its own edits back** (reactive) — after each agent edit, a self-review prompt goes into a pending file (plus semantic-density, scope-gate, anti-slop, and the pre-compile nudge advisories when they trip). Next turn the model reads its diff, fixes real bugs, stays quiet otherwise.
|
|
27
|
+
4. **Gate blast radius** — one permission gate denies a short explicit list of dangerous commands (`rm -rf /`, `curl | sh`, force-push, `npm publish`, ...). Everything else passes.
|
|
27
28
|
|
|
28
|
-
When an implementation finishes, the stop hook runs one final review over everything that changed, then stops.
|
|
29
|
+
When an implementation finishes, the stop hook runs one final review over everything that changed, then stops. Six axes. The first is **intent trace**: the hook pulls your last user message from the transcript and prepends it to the review so the model has to tie every diff hunk to a concrete request. Anything it can't trace is a hallucinated requirement and gets reverted. That's the only check that catches "clean code, wrong feature" — linters and later axes miss it.
|
|
29
30
|
|
|
30
31
|
Subagents get the same treatment. If a delegated run edited files, it reviews its own work before the result goes back to the parent. Those edits fold into the parent's final review. Every bound is enforced twice: in the script and in `hooks.json`.
|
|
31
32
|
|
|
32
33
|
Cursor only. Installs into `~/.cursor` and `~/.agents/hooks`. Doesn't touch your projects.
|
|
33
34
|
|
|
35
|
+
## Prerequisites
|
|
36
|
+
|
|
37
|
+
> **PowerShell 7 (`pwsh`) is required on Windows.** The hooks run via `pwsh.exe -NoProfile -File ...`. Windows PowerShell 5.1 (`powershell.exe`) is not supported — install PowerShell 7 separately.
|
|
38
|
+
|
|
39
|
+
| Platform | Required | Optional (recommended) |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| **Windows** | `git`, **PowerShell 7 (`pwsh`) on PATH** | Python 3.9+ (powers the anti-slop scanner; hooks work without it) |
|
|
42
|
+
| **Linux / SSH remotes** | `bash`, `git`, and `jq` **or** `python3` | Python 3.9+ (anti-slop scanner) |
|
|
43
|
+
|
|
44
|
+
Install PowerShell 7:
|
|
45
|
+
|
|
46
|
+
- **Windows**: `winget install --id Microsoft.PowerShell --source winget` (or grab the MSI from the [PowerShell GitHub releases](https://github.com/PowerShell/PowerShell/releases)). Confirm with `pwsh -Version`.
|
|
47
|
+
- **Linux**: follow the [official package instructions](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux) — only needed if you run the `windows/` pack on a Linux box (unusual); normal Linux installs use the `linux/` bash pack.
|
|
48
|
+
|
|
49
|
+
`npx cursordoctrine install` warns at the end if `pwsh` (Windows) or `bash`+`jq`/`python3` (Linux) or Python are missing, so you'll know up front.
|
|
50
|
+
|
|
34
51
|
## Install
|
|
35
52
|
|
|
36
53
|
Node 18+:
|
|
@@ -44,38 +61,72 @@ Restart Cursor after install — `hooks.json` is read at startup. `install` is i
|
|
|
44
61
|
|
|
45
62
|
No Node? Open `INSTALL.md`, paste it into a Cursor agent chat on the target machine, and let the agent copy files and run the checklist. Copy commands are in the same file if you prefer doing it by hand.
|
|
46
63
|
|
|
47
|
-
Prerequisites: `git` everywhere; `pwsh` on Windows; `bash` plus `jq` or `python3` on Linux.
|
|
48
|
-
|
|
49
64
|
The anti-slop skill (`skills/anti-slop/` — SKILL.md and the duplication scanner) installs to `~/.cursor/skills/anti-slop/`. The hook checklist (`~/.agents/hooks/anti-slop.md`, 13 items) is the canonical slop detector for per-edit advisories and final-review axis 4. Final review runs the scanner from the skill path first when it's there.
|
|
50
65
|
|
|
66
|
+
## The proactive phase: the Anchor Set
|
|
67
|
+
|
|
68
|
+
The reactive stack (self-review, anti-slop, final-review) only fires *after* code exists. If the agent drifted from the request on its first token, a clean final review of the wrong feature is still the wrong feature. The pre-compile phase puts the right feature on the rails first.
|
|
69
|
+
|
|
70
|
+
`pre-compile.md` (injected at session start alongside the doctrine) asks the agent to emit, terse, before any code:
|
|
71
|
+
|
|
72
|
+
1. **OBJECTIVE** — one operational sentence. Not "improve X" but "make X return Y when Z".
|
|
73
|
+
2. **CONSTRAINTS** — local negations: what it will NOT do (no schema migration, no new dep, no refactor of the surrounding function).
|
|
74
|
+
3. **SCOPE** — files to touch (exact, derived from the objective) and files untouchable.
|
|
75
|
+
4. **DETERMINISTIC SUCCESS** — the one command, test, or observable check that decides done.
|
|
76
|
+
|
|
77
|
+
It then writes that contract to `.scope.json` in the repo root:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"intent": "make /api/login return 401 instead of 500 on a bad password",
|
|
82
|
+
"files": ["src/api/login.ts", "tests/login.test.ts"],
|
|
83
|
+
"acceptance": "tests/login.test.ts passes; curl /api/login with wrong password returns 401",
|
|
84
|
+
"allow_growth": false
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Two machine-checkable consequences:
|
|
89
|
+
|
|
90
|
+
- **`scope-gate-audit`** (afterFileEdit, opt-in via `.scope.json` existing) audits every edit against `files[]` and quotes `intent` + `acceptance` back on a violation. Editing outside the declared set is the textbook scope-creep signal.
|
|
91
|
+
- **final-review axis 0** (intent trace) traces every diff hunk back to `intent`. Anything untraceable is a hallucinated requirement.
|
|
92
|
+
|
|
93
|
+
On the **first edit of each implementation**, `anchor-set-nudge` drops a reminder into the feedback bus: *did you write your Anchor Set to `.scope.json`?* One nudge per body of work — the flag is cleared at the same per-implementation boundary where the final-review one-shot brake fires, so a long chat with N implementations gets N nudges.
|
|
94
|
+
|
|
95
|
+
The Anchor Set is skipped for trivial one-liners (typo, literal) — the `declared-editing.md` ladder's rung 1 governs when it's overkill.
|
|
96
|
+
|
|
51
97
|
## The five flows
|
|
52
98
|
|
|
53
99
|
| Flow | Event | What happens |
|
|
54
100
|
|---|---|---|
|
|
55
|
-
| Session | `sessionStart` | `inject-doctrine` reads doctrine + user rules + declared-editing and emits them as `additional_context`. |
|
|
101
|
+
| Session | `sessionStart` | `inject-doctrine` reads doctrine + user rules + declared-editing + **pre-compile** and emits them as `additional_context`. |
|
|
56
102
|
| Every turn | `postToolUse` | Folds completed subagents' edit markers into this conversation's marker, then drains the conversation's pending feedback file into `additional_context`. One-shot, keyed by conversation id. |
|
|
57
103
|
| Shell | `beforeShellExecution` | `permission-gate` checks the command against a deny list. Allow by default, deny by list, fail open. |
|
|
58
|
-
| Edit | `afterFileEdit` + `stop` | `self-review-trigger` stashes the review prompt per edit; `minimal-edit-audit` (deprecated
|
|
104
|
+
| Edit | `afterFileEdit` + `stop` | **Proactive:** `anchor-set-nudge` fires once per implementation to push the Anchor Set. **Reactive:** `self-review-trigger` stashes the review prompt per edit; `minimal-edit-audit` (deprecated), `semantic-density-audit`, `scope-gate-audit` (opt-in, audits `.scope.json`), and `anti-slop-audit` append advisories when they trip; `final-review` fires one end-of-implementation six-axis pass. |
|
|
59
105
|
| Subagent | `subagentStop` | `subagent-stop-review` fires one in-subagent final review when a delegated run edited files, before the result returns to the parent. Marker-gated and flag-braked like `final-review`. |
|
|
60
106
|
|
|
61
107
|
## Layout
|
|
62
108
|
|
|
63
109
|
```
|
|
64
|
-
windows/ PowerShell hooks (pwsh) — install on Windows machines
|
|
110
|
+
windows/ PowerShell 7 hooks (pwsh) — install on Windows machines
|
|
65
111
|
hooks.json hook wiring for ~/.cursor/hooks.json
|
|
66
|
-
inject-doctrine.ps1, doctrine.md, USER-RULES.md,
|
|
67
|
-
|
|
112
|
+
inject-doctrine.ps1, doctrine.md, USER-RULES.md,
|
|
113
|
+
declared-editing.md, pre-compile.md
|
|
114
|
+
hooks/ the ten hook scripts + hook-common.ps1 (shared) + 3 prompt files
|
|
115
|
+
(anti-slop.md, self-review.md, final-review.md)
|
|
68
116
|
linux/ bash hooks — install on Linux machines and SSH remotes
|
|
69
|
-
hooks.json, inject-doctrine.sh, doctrine.md, USER-RULES.md,
|
|
117
|
+
hooks.json, inject-doctrine.sh, doctrine.md, USER-RULES.md,
|
|
118
|
+
declared-editing.md, pre-compile.md
|
|
70
119
|
hooks/ same hooks, ported to bash (jq preferred, python3 fallback)
|
|
71
120
|
skills/ Cursor agent skills shipped with the package
|
|
72
121
|
anti-slop/ SKILL.md + the duplication scanner (final review runs it)
|
|
122
|
+
scripts/scope_match.py — the .scope.json matcher shared by
|
|
123
|
+
scope-gate-audit and final-review (returns intent + acceptance)
|
|
73
124
|
bin/ the npm CLI (npx cursordoctrine install / verify / uninstall)
|
|
74
125
|
INSTALL.md ready-to-paste prompt that tells a Cursor agent to
|
|
75
126
|
install the right folder and verify every hook
|
|
76
127
|
```
|
|
77
128
|
|
|
78
|
-
Both folders do the same thing. Windows runs everything through `pwsh.exe
|
|
129
|
+
Both folders do the same thing. Windows runs everything through `pwsh.exe` (PowerShell 7 — Windows PowerShell 5.1 is not supported). Linux runs bash, which is what you want on a remote over SSH (check your `~/.ssh/config` host — hooks live on the remote's `$HOME`, not your laptop).
|
|
79
130
|
|
|
80
131
|
## Tuning and kill switches
|
|
81
132
|
|
|
@@ -85,6 +136,7 @@ All hooks fail open and always exit 0. Nothing here can block your session.
|
|
|
85
136
|
|---|---|---|
|
|
86
137
|
| `HOOKS_ENFORCE=0` | on | turns off all advisory hooks at once |
|
|
87
138
|
| `PERM_GATE_ENFORCE=0` | on | disables the permission gate |
|
|
139
|
+
| `ANCHOR_NUDGE_ENFORCE=0` | on | disables the pre-compile nudge (first-edit Anchor Set reminder) |
|
|
88
140
|
| `MINIMAL_EDITING_ENFORCE=0` | on | disables the over-edit advisory (deprecated in 0.3.0) |
|
|
89
141
|
| `SCOPE_GATE_ENFORCE=0` | on | disables the declared-scope advisory (opt-in: only fires when `.scope.json` exists) |
|
|
90
142
|
| `SEMANTIC_DENSITY_ENFORCE=0` | on | disables the semantic-opacity advisory |
|
|
@@ -98,7 +150,8 @@ All hooks fail open and always exit 0. Nothing here can block your session.
|
|
|
98
150
|
|
|
99
151
|
- **State lives under `$HOME`**, in `~/.cursor/.hooks-pending/`, keyed by conversation id. No repo litter. Concurrent sessions can't drain each other's prompts. Stale state older than 7 days gets swept on every stop.
|
|
100
152
|
- **`afterFileEdit` output isn't consumed by Cursor**, so edit hooks write to a pending file and `post-tool-use` re-emits it at the next tool boundary. That's the whole message bus.
|
|
101
|
-
- **One review per implementation.** The stop hook arms a per-conversation flag before emitting its follow-up, so a crash can't re-fire it and a long chat still gets a review after each implementation.
|
|
153
|
+
- **One review per implementation.** The stop hook arms a per-conversation flag before emitting its follow-up, so a crash can't re-fire it and a long chat still gets a review after each implementation. The `anchor-set-nudge` flag and the review flag clear together at that boundary — one nudge + one review per body of work.
|
|
154
|
+
- **The `.scope.json` contract is opt-in.** No `.scope.json` in the repo root → `scope-gate-audit` stays silent and the system falls back to the `declared-editing` ladder plus the final-review footprint check. Writing the file is how the agent opts into a machine-checked scope.
|
|
102
155
|
- **Subagents are first-class.** `afterFileEdit` fires inside subagents keyed by the subagent's conversation id. The harness normalizes agent edits (incl. `StrReplace`) to tool type `Write`, and `postToolUse` never fires for the `Task` tool — verified by payload capture. Matchers cover `Write|StrReplace|EditNotebook` defensively. `subagentStop` reviews the subagent in its own context. The parent folds orphaned subagent markers (from the `subagents/` transcript directory) into its own at every tool boundary and at stop.
|
|
103
156
|
|
|
104
157
|
Self-contained. No build. Open `hooks.json` and read it — that's the whole system in one file.
|
package/bin/cli.mjs
CHANGED
|
@@ -388,6 +388,7 @@ Examples
|
|
|
388
388
|
Kill switches (environment variables, all hooks fail open)
|
|
389
389
|
HOOKS_ENFORCE=0 everything advisory off
|
|
390
390
|
PERM_GATE_ENFORCE=0 permission gate off
|
|
391
|
+
ANCHOR_NUDGE_ENFORCE=0 pre-compile nudge off (first-edit Anchor Set reminder)
|
|
391
392
|
MINIMAL_EDITING_ENFORCE=0 over-edit advisory off (deprecated in 0.3.0)
|
|
392
393
|
SEMANTIC_DENSITY_ENFORCE=0 semantic-opacity advisory off
|
|
393
394
|
SCOPE_GATE_ENFORCE=0 declared-scope advisory off
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Counterpart of final-review.sh for delegated work. afterFileEdit DOES fire
|
|
5
5
|
# inside subagents (verified: a subagent run left its edits in
|
|
6
6
|
# session-edits-<subagent-cid>.txt), but subagents get no `stop` event, so
|
|
7
|
-
# that marker is never drained and the
|
|
7
|
+
# that marker is never drained and the six-axis review never fires for
|
|
8
8
|
# delegated implementations. This hook closes the loop: when a subagent
|
|
9
9
|
# finishes and ITS conversation has a session-edits marker, return ONE
|
|
10
10
|
# followup_message so the subagent audits its own implementation before the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursordoctrine",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Thin self-review hooks for Cursor — the model is the auditor. Pre-compile Anchor Set phase (proactive intent compilation), intent-trace final review (Tier 0), unified 13-item anti-slop checklist, operational slop detection.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"cursordoctrine": "bin/cli.mjs"
|
|
@@ -228,8 +228,8 @@ The `stop` hook (`~/.agents/hooks/final-review.ps1` on Windows,
|
|
|
228
228
|
`~/.agents/hooks/final-review.sh` on Linux) fires after the agent finishes an
|
|
229
229
|
implementation that edited files. It extracts the last `<user_query>` from the
|
|
230
230
|
session transcript (Tier 0 intent trace), reports session footprint (Tier 5),
|
|
231
|
-
and auto-submits a `followup_message` so the model audits
|
|
232
|
-
correctness, reliability, coverage, anti-slop. Axis 4 delegates to this skill's
|
|
231
|
+
and auto-submits a `followup_message` so the model audits six axes: intent,
|
|
232
|
+
correctness, reliability, coverage, anti-slop, wiring completeness. Axis 4 delegates to this skill's
|
|
233
233
|
scanner (`scan_slop.py --all`) and the canonical checklist at
|
|
234
234
|
`~/.agents/hooks/anti-slop.md` (13 items, including semantic contracts,
|
|
235
235
|
operational slop, and change surface). One bounded pass per implementation.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Counterpart of final-review.ps1 for delegated work. afterFileEdit DOES fire
|
|
4
4
|
# inside subagents (verified: a poteto subagent run left ~58 entries in
|
|
5
5
|
# session-edits-<subagent-cid>.txt), but subagents get no `stop` event, so
|
|
6
|
-
# that marker is never drained and the
|
|
6
|
+
# that marker is never drained and the six-axis review never fires for
|
|
7
7
|
# delegated implementations. This hook closes the loop: when a subagent
|
|
8
8
|
# finishes and ITS conversation has a session-edits marker, return ONE
|
|
9
9
|
# followup_message so the subagent audits its own implementation before the
|