code-warden 3.1.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONFIGURE.md +39 -39
- package/DECISIONS.md +107 -107
- package/README.md +199 -137
- package/SKILL.md +169 -169
- package/bin/code-warden.js +82 -0
- package/codewarden.json +14 -14
- package/examples/governed-session.md +132 -132
- package/install.js +399 -399
- package/install.ps1 +32 -32
- package/install.sh +33 -33
- package/package.json +45 -2
- package/references/anti-drift.md +55 -55
- package/references/architecture.md +26 -26
- package/references/cleanup.md +30 -30
- package/references/cognition.md +36 -36
- package/references/operations.md +45 -45
- package/references/planning-gates.md +83 -83
- package/references/research-and-fit.md +51 -51
- package/references/safety.md +31 -31
- package/templates/ci/github-actions.yml +83 -66
- package/tools/auto-detect.js +91 -91
- package/tools/auto-targets.js +104 -104
- package/tools/auto-windsurf-adapter.js +75 -75
- package/tools/get-context.js +50 -50
- package/tools/governance-report.js +302 -0
- package/tools/hooks/claude/install-hooks.js +112 -112
- package/tools/hooks/claude/uninstall-hooks.js +75 -75
- package/tools/hooks/claude/warden-lint-hook.js +106 -106
- package/tools/hooks/claude/warden-secrets-hook.js +73 -73
- package/tools/hooks/codex/install-hooks.js +100 -100
- package/tools/hooks/codex/uninstall-hooks.js +53 -53
- package/tools/hooks/codex/warden-apply-patch-hook.js +113 -113
- package/tools/hooks/codex/warden-bash-hook.js +51 -51
- package/tools/lib/config.js +49 -49
- package/tools/lib/file-collection.js +72 -72
- package/tools/lib/line-count.js +28 -28
- package/tools/lib/secret-patterns.js +57 -57
- package/tools/tests/fixtures/clean.js +9 -9
- package/tools/tests/run-tests.js +210 -210
- package/tools/verify-secrets.js +26 -26
- package/tools/warden-lint.js +27 -27
package/README.md
CHANGED
|
@@ -1,137 +1,199 @@
|
|
|
1
|
-
# code-warden
|
|
2
|
-
|
|
3
|
-
> Portable AI Coding Governance Layer
|
|
4
|
-
|
|
5
|
-
Code-Warden
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
|
17
|
-
|
|
18
|
-
| **
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
node install.js
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
1
|
+
# code-warden
|
|
2
|
+
|
|
3
|
+
> Portable AI Coding Governance Layer
|
|
4
|
+
|
|
5
|
+
Code-Warden provides verifiable governance for AI-assisted development.
|
|
6
|
+
It does not just ask agents to follow rules — it adds Scope Gates, Plan Gates,
|
|
7
|
+
local checks, CI enforcement, runtime hooks where supported, and governance
|
|
8
|
+
artifacts that show what was checked before code was accepted.
|
|
9
|
+
|
|
10
|
+
## Four Layers
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<img src="../logo/layers-diagram.png" alt="Code-Warden Four Layers" width="100%" />
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
| Layer | What it does |
|
|
17
|
+
|-------|-------------|
|
|
18
|
+
| **Skill governance** | Scope Gate, Plan Gate, blast-radius checks, patch-first editing, research gates, drift signals, verification evidence |
|
|
19
|
+
| **Local verification** | `warden-lint`, `verify-secrets`, `get-context` — directory-aware, no external deps |
|
|
20
|
+
| **Installer and health** | Cross-app auto-installer, manifest-backed installs, `--doctor`, `--verify-target`, Windsurf adapter |
|
|
21
|
+
| **Hard enforcement** | Claude Code `PreToolUse` hooks — block oversized writes and hardcoded secrets before the file system is touched |
|
|
22
|
+
|
|
23
|
+
## Governance Evidence
|
|
24
|
+
|
|
25
|
+
Generate a machine-readable governance report that can be stored in CI, attached to PRs, or used as audit evidence:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
node tools/governance-report.js . # write .code-warden-report.json + summary
|
|
29
|
+
node tools/governance-report.js . --format=json # JSON to stdout
|
|
30
|
+
node tools/governance-report.js . --format=md # Markdown to stdout
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The report runs all checks in a single pass (file length, secrets, behavioral tests, source integrity) and produces a structured artifact:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"tool": "code-warden",
|
|
38
|
+
"version": "3.2.0",
|
|
39
|
+
"checks": {
|
|
40
|
+
"fileLength": { "status": "pass", "filesScanned": 34, "violations": 0 },
|
|
41
|
+
"secrets": { "status": "pass", "filesScanned": 34, "violations": 0 },
|
|
42
|
+
"behavioralTests": { "status": "pass", "tests": 8, "failures": 0 },
|
|
43
|
+
"installHealth": { "status": "pass" }
|
|
44
|
+
},
|
|
45
|
+
"result": "pass"
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
In CI, the Markdown format pipes directly into `$GITHUB_STEP_SUMMARY` for PR-visible evidence:
|
|
50
|
+
|
|
51
|
+
| Check | Result | Details |
|
|
52
|
+
|-------|--------|---------|
|
|
53
|
+
| File length | PASS | 34 files scanned, 0 violations |
|
|
54
|
+
| Hardcoded credentials | PASS | 34 files scanned, 0 violations |
|
|
55
|
+
| Behavioral tests | PASS | 8 tests, 0 failures |
|
|
56
|
+
| Install health | PASS | All source files present |
|
|
57
|
+
|
|
58
|
+
See [`templates/ci/github-actions.yml`](templates/ci/github-actions.yml) for the full CI template with artifact upload.
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx code-warden init
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or install globally:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install -g code-warden
|
|
70
|
+
code-warden init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### CLI commands
|
|
74
|
+
|
|
75
|
+
| Command | Purpose |
|
|
76
|
+
|---------|---------|
|
|
77
|
+
| `code-warden init` | Install to all detected AI runtimes |
|
|
78
|
+
| `code-warden report` | Generate governance report |
|
|
79
|
+
| `code-warden report --format=md` | Markdown output for PR summaries |
|
|
80
|
+
| `code-warden doctor` | Verify source integrity + install health |
|
|
81
|
+
| `code-warden list` | Show detected runtimes |
|
|
82
|
+
| `code-warden hooks claude` | Install Claude Code PreToolUse hooks |
|
|
83
|
+
| `code-warden hooks codex` | Install Codex PreToolUse hooks (partial) |
|
|
84
|
+
| `code-warden uninstall-hooks claude` | Remove Claude Code hooks |
|
|
85
|
+
| `code-warden uninstall-hooks codex` | Remove Codex hooks |
|
|
86
|
+
|
|
87
|
+
### Direct installer commands
|
|
88
|
+
|
|
89
|
+
| Command | Purpose |
|
|
90
|
+
|---------|---------|
|
|
91
|
+
| `node install.js` | Scan, prompt, install to detected apps |
|
|
92
|
+
| `node install.js --all` | Install without prompt |
|
|
93
|
+
| `node install.js --dry-run` | Preview installs, write nothing |
|
|
94
|
+
| `node install.js --list` | Show detected apps and detection method |
|
|
95
|
+
| `node install.js --doctor` | Verify source integrity + per-target install health |
|
|
96
|
+
| `node install.js --target=claude,cursor` | Force specific targets (warns if not detected) |
|
|
97
|
+
| `node install.js --verify-target=claude` | Strict health check — exits nonzero if not installed |
|
|
98
|
+
| `node install.js --hooks=claude` | Install PreToolUse hooks into `~/.claude/settings.json` |
|
|
99
|
+
| `node install.js --uninstall-hooks=claude` | Remove code-warden hook entries from settings |
|
|
100
|
+
|
|
101
|
+
Supported targets: **Claude Code**, **Cursor**, **Warp**, **OpenAI Codex**, **Windsurf**, **Generic Agents**.
|
|
102
|
+
|
|
103
|
+
Each install writes a `.code-warden-install.json` manifest (version, target, format, timestamp).
|
|
104
|
+
|
|
105
|
+
### npm scripts
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm run lint # warden-lint on full project tree
|
|
109
|
+
npm run check-secrets # verify-secrets on full project tree
|
|
110
|
+
npm run report # governance report, writes .code-warden-report.json
|
|
111
|
+
npm run report:json # governance report as JSON to stdout
|
|
112
|
+
npm run report:md # governance report as Markdown to stdout
|
|
113
|
+
npm run install-auto # node install.js
|
|
114
|
+
npm run install-dry-run # node install.js --dry-run
|
|
115
|
+
npm run install-list # node install.js --list
|
|
116
|
+
npm run install-doctor # node install.js --doctor
|
|
117
|
+
npm run test # behavioral tests (8 scanner/hook pass/fail cases)
|
|
118
|
+
npm run ci # lint + secrets + test + doctor
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
Load at the start of any coding session. Trigger phrases:
|
|
124
|
+
|
|
125
|
+
- `"load code-warden"` / `"load protocol"`
|
|
126
|
+
- `"begin coding"` / `"new session"` / `"governance check"`
|
|
127
|
+
- `"start a new module"` / `"review this before we write"`
|
|
128
|
+
|
|
129
|
+
The session sequence is enforced before any implementation:
|
|
130
|
+
|
|
131
|
+
<p align="center">
|
|
132
|
+
<img src="../logo/session-flow.png" alt="Code-Warden Session Start Sequence" width="100%" />
|
|
133
|
+
</p>
|
|
134
|
+
|
|
135
|
+
1. Architecture State (Re-injection Rule)
|
|
136
|
+
2. Session Scope (Session Scoping Rule)
|
|
137
|
+
3. Reference Files (Blueprint Rule)
|
|
138
|
+
4. **Scope Gate** — goal, non-goals, files in/out, verify commands, rollback
|
|
139
|
+
5. **Plan Gate** — patch order, blast radius class, post-patch checks
|
|
140
|
+
|
|
141
|
+
See [`examples/governed-session.md`](examples/governed-session.md) for an annotated example.
|
|
142
|
+
|
|
143
|
+
## Optional Claude Code Hooks
|
|
144
|
+
|
|
145
|
+
<p align="center">
|
|
146
|
+
<img src="../logo/hook-flow.png" alt="Code-Warden Hook Enforcement Flow" width="100%" />
|
|
147
|
+
</p>
|
|
148
|
+
|
|
149
|
+
Install hard enforcement that runs at the `PreToolUse` level — before writes happen:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Requires Claude Code target to be installed first
|
|
153
|
+
node install.js --hooks=claude
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| Hook | Trigger | Policy |
|
|
157
|
+
|------|---------|--------|
|
|
158
|
+
| `warden-lint-hook.js` | `Write` or `Edit` | Blocks if resulting file exceeds line limit |
|
|
159
|
+
| `warden-secrets-hook.js` | `Write` or `Edit` | Hardcoded credential scanner — blocks if content matches any secret pattern |
|
|
160
|
+
|
|
161
|
+
Both hooks use exec form (`node /path/to/hook.js`) — no shell differences across platforms.
|
|
162
|
+
|
|
163
|
+
Thresholds are read from `codewarden.json` in the installed skill directory.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
node install.js --uninstall-hooks=claude # remove hook entries from settings.json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Doctor and `--verify-target=claude` validate hook script paths when hooks are registered.
|
|
170
|
+
|
|
171
|
+
## Configuration
|
|
172
|
+
|
|
173
|
+
All thresholds in [`codewarden.json`](codewarden.json):
|
|
174
|
+
|
|
175
|
+
| Setting | Default | What it controls |
|
|
176
|
+
|---------|---------|-----------------|
|
|
177
|
+
| `thresholds.max_file_length` | 400 | Lines before `warden-lint.js` flags a file |
|
|
178
|
+
| `thresholds.pre_flight_trigger_lines` | 150 | Lines before a pre-flight manifest is required |
|
|
179
|
+
| `thresholds.human_checkpoint_files` | 2 | Files touched before `[AWAITING CONFIRMATION]` is required |
|
|
180
|
+
| `safety.exempt_from_blast_radius` | `tests/`, `docs/`, `scripts/` | Paths excluded from rollback-plan rule |
|
|
181
|
+
|
|
182
|
+
See [`CONFIGURE.md`](CONFIGURE.md) for team-size profiles and tuning rationale.
|
|
183
|
+
|
|
184
|
+
## Reference Files
|
|
185
|
+
|
|
186
|
+
| File | Domain |
|
|
187
|
+
|------|--------|
|
|
188
|
+
| `references/planning-gates.md` | Scope Gate and Plan Gate contracts |
|
|
189
|
+
| `references/architecture.md` | Blueprint Rule, Re-injection, State Update |
|
|
190
|
+
| `references/safety.md` | Blast Radius, Patch-First, Zero-Trust, Dependency Freeze |
|
|
191
|
+
| `references/cognition.md` | Think Before Coding, Don't Guess Syntax, Human Checkpoint |
|
|
192
|
+
| `references/cleanup.md` | Tech Debt format, Test Contract, Decision Log |
|
|
193
|
+
| `references/anti-drift.md` | Anchor Check, Session Scoping, Drift Trigger Protocol |
|
|
194
|
+
| `references/operations.md` | Verification, source-control hygiene, dependency control |
|
|
195
|
+
| `references/research-and-fit.md` | Live research gate, stack fit, product-shape guardrails |
|
|
196
|
+
|
|
197
|
+
## Author
|
|
198
|
+
|
|
199
|
+
Justin Davis — MIT License
|