vigiles 2.5.0 → 2.6.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/README.md CHANGED
@@ -9,8 +9,8 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <strong>Test &amp; verify your Claude Code harness.</strong><br />
13
- vigiles <strong>verifies the references</strong> your instruction files make — linter rules, file paths, scripts, code symbols — and <strong>evals</strong> whether your hooks, skills, and CLAUDE.md actually change what the agent does.
12
+ <strong>The missing linting + testing layer for agentic coding.</strong><br />
13
+ vigiles <strong>lints</strong> the references your instruction files make — linter rules, file paths, scripts, code symbols — and <strong>tests</strong> whether your hooks, skills, and CLAUDE.md actually change what the agent does.
14
14
  </p>
15
15
 
16
16
  <p align="center">
@@ -19,30 +19,39 @@
19
19
  <a href="https://github.com/zernie/vigiles/blob/main/LICENSE"><img src="https://img.shields.io/github/license/zernie/vigiles" alt="License" /></a>
20
20
  </p>
21
21
 
22
+ <p align="center">
23
+ <b>Two pillars →</b>
24
+ &nbsp;<a href="#verify-your-instruction-files">① Verify your instruction files</a>
25
+ &nbsp;·&nbsp;
26
+ <a href="#test-your-claude-code-harness">② Test your Claude Code harness</a>
27
+ </p>
28
+
22
29
  ---
23
30
 
24
31
  <details>
25
32
  <summary><b>Contents</b></summary>
26
33
 
27
- **Pillar 1verify your instruction files** · references your CLAUDE.md makes that a linter, the filesystem, and package.json can prove
34
+ - [**Two pillarspick one or both**](#two-pillars--pick-one-or-both)
35
+ - **Pillar 1** — [verify your instruction files](#verify-your-instruction-files) · full guide: [docs/verifying-instruction-files.md](docs/verifying-instruction-files.md)
36
+ - **Pillar 2** — [test your Claude Code harness](#test-your-claude-code-harness) · full guide: [docs/harness-testing.md](docs/harness-testing.md)
37
+ - [Quick start](#quick-start) · [CLI & CI](#cli--ci) · [Skills](#skills) · [Related tools](#related-tools)
38
+
39
+ </details>
28
40
 
29
- - Three adoption levels: [inline comments](#level-0--inline-comments-30-seconds-no-new-files) [YAML frontmatter](#level-1--yaml-frontmatter-editor-autocomplete-still-no-typescript) → [typed spec](#level-2--typed-spec-compiler-grade-guarantees)
30
- - [What changes with vigiles](#what-changes-with-vigiles)
31
- - [Quick start](#quick-start)
32
- - [Three rule types](#three-rule-types) — `enforce` / `guidance` / `guard`
33
- - [Verified references](#verified-references) — `file` / `cmd` / `symbol` / `ref`
41
+ ## Two pillars pick one or both
34
42
 
35
- **Pillar 2 [test your Claude Code harness](#test-your-claude-code-harness)** · eval whether your hooks, skills, and CLAUDE.md actually change what the agent does
43
+ An agent runs real commands in your repo it can delete the wrong files, leak a secret, or burn tokens looping on a stale instruction nobody checked. You'd never ship an app without a linter and a test suite. An AI agent steering your codebase is no different — so why is its harness trusted on vibes?
36
44
 
37
- - [Level 1 unit-test a hook (no AI)](#level-1--test-a-hook-by-itself-no-ai-milliseconds)
38
- - [Level 2 — does it fire in a real session?](#level-2--does-it-fire-in-a-real-session-free-scripted-ai)
39
- - [Level 3 — does it change behaviour?](#level-3--does-it-change-what-claude-does-real-ai-occasional)
40
- - [Test skills for real + assert on actions](#test-your-skills-for-real--and-assert-on-what-claude-did)
41
- - [Run them in CI](#run-them-in-ci)
45
+ `Agent = Model + Harness`. Your harness is everything that steers a run the **instructions** you write _and_ the **hooks, skills, and settings** that enforce them. vigiles is the **missing linting + testing layer for agentic coding**: it **lints** your instruction files and **tests** your harness. Two pillars of equal weight — adopt either on its own, or both:
42
46
 
43
- **More** [CLI & CI](#cli--ci) · [Skills](#skills) · [Maturity levels](#maturity-levels) · [Related tools](#related-tools)
47
+ | | Pillar | What it does |
48
+ | ----- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49
+ | **①** | [**Verify your instruction files**](#verify-your-instruction-files) | Every linter rule, file path, script, and code symbol your CLAUDE.md cites is checked against reality, so stale references can't silently mislead the agent. |
50
+ | **②** | [**Test your harness**](#test-your-claude-code-harness) | Your hooks and skills are code — vigiles tests that they actually fire, **deterministically and for free** (no model, no API key) before you ever pay for a real-model eval. |
44
51
 
45
- </details>
52
+ They share the thesis but not a dependency: verify your instructions without ever writing a harness test, or test your harness without a single `.spec.ts`. Pick the pillar that hurts today.
53
+
54
+ ## Verify your instruction files
46
55
 
47
56
  Your CLAUDE.md lies to your agent. Here's the fix.
48
57
 
@@ -70,13 +79,11 @@ Reads fine. Four things are wrong:
70
79
 
71
80
  The agent reads this, trusts it, and writes code based on stale claims nobody verified. vigiles **verifies the references in your instruction files** — that each linter rule exists and is enabled, that every file path and script is real, and that referenced **code symbols** (functions, classes, constants) actually exist in the files that define them — and meets you at whatever commitment level you want.
72
81
 
73
- > **See it in 60 seconds:** `npm run demo` runs `vigiles audit` against a deliberately-broken instruction file and catches a renamed symbol and a missing MCP tool (_"did you mean `purge`?"_), while the truthful references pass silently. [examples/demo →](examples/demo)
74
-
75
- Three levels. Each is independently useful; adopt as far up as you like.
82
+ > **Set it up paste this into Claude Code:**
83
+ >
84
+ > > Install vigiles and verify my instruction files. Scan my CLAUDE.md / AGENTS.md, turn its real claims into checked references (linter rules, file paths, scripts, symbols), run `vigiles audit`, and show me what's already stale. Use sensible defaults, but **ask me first** whether to stay in markdown mode or generate a typed `.spec.ts`, and whether to wire the audit into CI and install the edit-blocking hooks.
76
85
 
77
- ### Level 0inline comments (30 seconds, no new files)
78
-
79
- Add a comment to your existing CLAUDE.md and audit it:
86
+ Or do it by hand add a marker to your existing CLAUDE.md and audit it, no install, no new files:
80
87
 
81
88
  ```md
82
89
  <!-- vigiles:enforce eslint/no-console "Route output through logger.ts" -->
@@ -86,181 +93,46 @@ Add a comment to your existing CLAUDE.md and audit it:
86
93
  npx vigiles audit CLAUDE.md
87
94
  ```
88
95
 
89
- Each rule is checked against your real linter config typos get closest-match suggestions, disabled rules are flagged. Zero install commitment, zero new files.
90
-
91
- ### Level 1 — YAML frontmatter (editor autocomplete, still no TypeScript)
92
-
93
- Promote your rules into a `vigiles:` block at the top of the file:
94
-
95
- ```yaml
96
- ---
97
- # yaml-language-server: $schema=./.vigiles/schema.json
98
- vigiles:
99
- enforce:
100
- - rule: "@typescript-eslint/no-explicit-any"
101
- why: "Use unknown and narrow with type guards."
102
- - rule: eslint/no-console
103
- why: "Route output through logger.ts"
104
- ---
105
- ```
106
-
107
- `npx vigiles generate-schema` emits a JSON Schema from your project's _actual_ enabled rules, so your editor's built-in YAML language server (VS Code, JetBrains, neovim) autocompletes rule names and red-squiggles typos — at edit time, with no TypeScript in the project. `vigiles audit` enforces the same rules in CI. [Markdown mode →](docs/markdown-mode.md)
108
-
109
- ### Level 2 — typed spec (compiler-grade guarantees)
110
-
111
- When you want the strongest guarantees, compile a typed spec. Every linter rule reference is verified against your real config, every file path against the filesystem, every npm script against package.json. Stale references become compile errors — caught at edit time, not when the agent silently ignores you.
112
-
113
- ```typescript
114
- // CLAUDE.md.spec.ts
115
- import { claude, enforce, guidance } from "vigiles/spec";
116
-
117
- export default claude({
118
- commands: {
119
- "npm run build": "Compile TypeScript to dist/",
120
- "npm test": "Build and run all tests",
121
- // ✗ "npm run typecheck" → compile error: script not in package.json
122
- },
123
-
124
- keyFiles: {
125
- "src/utils/narrowing.ts": "Type guard utilities",
126
- // ✗ "src/utils/type-helpers.ts" → compile error: file not found
127
- },
128
-
129
- rules: {
130
- "no-explicit-any": enforce(
131
- "@typescript-eslint/no-explicit-any",
132
- "Use unknown and narrow with type guards.",
133
- ),
134
- // ✗ if rule is disabled in config → compile error
135
-
136
- "research-first": guidance("Google unfamiliar APIs first."),
137
- },
138
- });
139
- ```
140
-
141
- ```bash
142
- $ npx vigiles compile
143
-
144
- ✓ CLAUDE.md.spec.ts → CLAUDE.md
145
- 2 rules (1 linter-verified, 1 guidance)
146
- ~180 tokens
147
- ```
148
-
149
- At this level the spec is the source of truth and CLAUDE.md is a build artifact. The agent edits the spec — hooks auto-compile, types catch typos in the editor, CI catches drift.
150
-
151
- Companion repo for [Feedback Loop Is All You Need](https://zernie.com/blog/feedback-loop-is-all-you-need).
152
-
153
- ## What Changes With vigiles
154
-
155
- ### Claude Code
156
-
157
- | | Without vigiles | With vigiles |
158
- | ----------------------------------- | ---------------------------- | -------------------------------------------------------------- |
159
- | **Instructions** | Hand-written CLAUDE.md | Compiled from `.spec.ts` (build artifact) |
160
- | **Linter rule references** | Trust-based (nobody checks) | Verified at compile time against real config |
161
- | **File paths** | Rot silently when renamed | `file()` references checked against filesystem |
162
- | **Commands** | Stale scripts go unnoticed | `cmd()` references checked against package.json |
163
- | **Direct edits to CLAUDE.md** | Anyone can, nobody knows | PreToolUse hook blocks edits, redirects to spec |
164
- | **Spec edits** | N/A | PostToolUse hook auto-compiles to markdown |
165
- | **Linter config changes** | CLAUDE.md drifts out of sync | PostToolUse hook auto-regenerates types |
166
- | **guidance → enforce upgrades** | Manual guesswork | `/strengthen` reads per-linter docs, suggests upgrades |
167
- | **New lint rules from PR feedback** | Copy-paste from review | `/pr-to-lint-rule` generates rule + tests + spec entry |
168
- | **CI** | Nothing to verify | `vigiles audit` catches hand-edits, disabled rules, stale refs |
169
-
170
- <details>
171
- <summary><b>Codex</b> (same compile-time checks, no hooks)</summary>
172
-
173
- | | Without vigiles | With vigiles |
174
- | ----------------------------- | -------------------------------- | ------------------------------------------------------- |
175
- | **Instructions** | Hand-written AGENTS.md | Compiled from `.spec.ts` |
176
- | **Linter rule references** | Trust-based | Verified at compile time |
177
- | **File paths / commands** | Rot silently | Checked at compile time |
178
- | **Direct edits to AGENTS.md** | Undetected | CI catches hash mismatch |
179
- | **Hooks / auto-compile** | Not available (no plugin system) | Not available — run `vigiles compile` manually or in CI |
180
- | **CI** | Nothing to verify | Same `vigiles audit` pipeline as Claude |
181
-
182
- </details>
96
+ Each reference is checked against reality a typo gets a closest-match suggestion, a disabled rule is flagged. That's **markdown mode**; step up to a **typed spec** (`.spec.ts` → compiled CLAUDE.md, compiler-grade guarantees) when you want it.
183
97
 
184
- Everything vigiles compiles and audits is **deterministic**same input, same output, no LLM in the loop. The non-deterministic parts (authoring specs, suggesting upgrades, writing custom rules) are agent skills that run outside the compilation pipeline. [Determinism breakdown and flow diagram →](docs/comparison.md)
98
+ **Full guide: [docs/verifying-instruction-files.md](docs/verifying-instruction-files.md)** — the adoption ladder, the three rule types (`enforce` / `guidance` / `guard`), verified references (`file` / `cmd` / `symbol` / `ref`), and the before/after tables.
185
99
 
186
100
  ## Quick Start
187
101
 
188
- The fastest path is markdown mode — add a marker to your existing CLAUDE.md and audit it, no install or new files (see [Level 0 / Level 1](#level-0--inline-comments-30-seconds-no-new-files) above and [docs/markdown-mode.md](docs/markdown-mode.md)). When you want compiler-grade guarantees, scaffold a typed spec:
189
-
190
102
  ```bash
191
103
  npx vigiles init
192
104
  ```
193
105
 
194
- The wizard auto-detects your project, creates a spec, scans your linters, compiles to markdown, adds a CI step, and installs Claude Code hooks. After install: the agent edits the spec (hooks block direct CLAUDE.md edits), the spec auto-compiles on save, and `vigiles audit` catches drift in CI.
195
-
196
- Start with `guidance()` rules (zero config). When you're ready, run `/strengthen` to find rules that can be upgraded to compile-verified `enforce()`. Already have a hand-written CLAUDE.md? The wizard detects it and offers migration. Flags (`--strict`, `--target=AGENTS.md`, `--no-gha`) and non-interactive agent usage are in the [CLI reference](docs/cli.md) and [agent setup guide](docs/agent-setup.md).
197
-
198
- ## Three Rule Types
199
-
200
- **`enforce()`** — delegated to a linter. vigiles verifies the rule exists in the catalog AND is enabled in your project config. A disabled rule is a compile error.
201
-
202
- <!-- vigiles:ignore -->
203
-
204
- ```typescript
205
- "no-any": enforce("@typescript-eslint/no-explicit-any", "Use unknown and narrow."),
206
- "no-print": enforce("ruff/T201", "Use logging module."),
207
- "no-unwrap": enforce("clippy/unwrap_used", "Use expect() with context."),
208
- ```
209
-
210
- Supports ESLint, Stylelint, Ruff, Clippy, Pylint, RuboCop, and Cedar policies. [Full linter support details →](docs/linter-support.md)
211
-
212
- **`guidance()`** — prose advice. No mechanical enforcement, but not untracked: guidance rules participate in the monotonicity proof system. Once a rule exists, it can be strengthened ( `guidance` → `enforce` ) but never weakened or removed without an explicit allowlist. This prevents silent erosion of conventions over time.
213
-
214
- ```typescript
215
- "research-first": guidance("Google unfamiliar APIs first."),
216
- ```
217
-
218
- **`guard()`** — reactive: runs a command when watched files change (e.g. `*.spec.ts` → `npx vigiles compile`). One declaration emits hooks for every supported system (Claude Code PostToolUse, husky pre-commit, etc.) — no copy-pasting the same trigger across `.claude/settings.json`, `.husky/`, and CI. Same monotonicity guarantees as `enforce()`. [Full spec format →](docs/spec-format.md)
219
-
220
- ## Verified References
221
-
222
- `file()`, `cmd()`, `symbol()`, and `ref()` catch stale references at compile time:
223
-
224
- ```typescript
225
- import { claude, file, cmd, symbol, ref, instructions } from "vigiles/spec";
226
-
227
- export default claude({
228
- sections: {
229
- architecture: instructions`
230
- Core engine in ${file("src/compile.ts")}.
231
- Compile specs with ${symbol("src/compile.ts", "compileClaude")}.
232
- Run ${cmd("npm test")} to verify.
233
- See ${ref("skills/strengthen/SKILL.md")} for the strengthen skill.
234
- `,
235
- // If any path / script / symbol is stale → compile error
236
- },
237
- // ...
238
- });
239
- ```
240
-
241
- There's a small family of inline **marks** that `audit` checks, each binding a reference to its real source:
106
+ The wizard auto-detects your project, creates a spec, scans your linters, compiles to markdown, adds a CI step, and installs Claude Code hooks. After install: the agent edits the spec (hooks block direct CLAUDE.md edits), the spec auto-compiles on save, and `vigiles audit` catches drift in CI. Prefer no new files? Stay in [markdown mode](docs/markdown-mode.md). Start with `guidance()` rules and `/strengthen` them to `enforce()` later; flags and agent usage are in the [CLI reference](docs/cli.md).
242
107
 
243
- - `` `vigiles:symbol file#name` `` the named file actually **defines** that symbol (function, class, method, constant), parsed with [ast-grep](https://ast-grep.github.io) across **JS/TS, Python, Ruby, Rust, and CSS**. Rename it and `audit` fails; in markdown mode the `refs-hook` **forces the mark**, blocking edits that leave a code reference bare. [Details →](research/symbol-verification.md)
244
- - `` `vigiles:mcp server#tool` `` — the referenced **MCP tool exists** on its server. `audit` reads `.mcp.json`, starts the server, lists its tools, and flags a renamed/removed one with a "did you mean" — catching e.g. the GitHub MCP server renaming `create_issue` → `issue_write`, which otherwise fails silently.
245
-
246
- **Typo-safe at authoring time, too.** `vigiles generate-types` emits a `.vigiles/generated.d.ts` so `enforce("eslint/no-consolee")` red-squiggles in your editor; `generate-schema` gives Level 1 frontmatter the same via your YAML language server. Both have `--check` CI freshness modes. [How it works →](docs/linter-support.md#generate-types)
108
+ Companion repo for [Feedback Loop Is All You Need](https://zernie.com/blog/feedback-loop-is-all-you-need).
247
109
 
248
110
  ## Test your Claude Code harness
249
111
 
250
- You wrote hooks, a skill, a CLAUDE.md rule how do you know they work, beyond
251
- running Claude and eyeballing it? vigiles ships a library to **test the harness
252
- itself**, at three levels, cheapest first. It's plain async functions, so it
253
- drops into **node:test / vitest / jest**, or a zero-setup `vigiles test`.
112
+ Verifying references proves your instructions are _true_but the hooks and
113
+ skills that enforce them still have to **actually fire**. A hook can be wired
114
+ wrong, a skill's description can fail to trigger, injected context can never reach
115
+ the model all silently, all passing a naive "did it run?" check. So vigiles's
116
+ second pillar **tests the harness itself**, as the assembled machine it ships as.
254
117
 
255
- ### Level 1test a hook by itself (no AI, milliseconds)
118
+ > **Set it up paste this into Claude Code:**
119
+ >
120
+ > > Install vigiles and use its `test-harness` skill to write and run a harness test for this project. If I didn't say what to test, pick something real from my hooks / skills / settings, choose the cheapest tier (unit / deterministic / eval), write the test, and run it. Use good defaults, but **ask me** whether to gate it in CI and whether to add a real-model eval.
256
121
 
257
- A hook is just a process that's handed a "Claude is about to do X" event and
258
- answers block/allow. Hand it a fake event and check the answer no `claude`, no
259
- model, and **every** event type is reachable (incl. Edit/Write, PreCompact,
260
- SessionEnd):
122
+ It's a small library of plain async functions (drops into node:test / vitest /
123
+ jest, or a zero-setup `vigiles test`), with three tiers, cheapest first. The
124
+ design bet is **deterministic and cheap**: the first two tiers never call a model
125
+ or need an API key, so they run on every commit for free — the opposite of
126
+ eval-only frameworks like promptfoo, where every run hits a real model **by
127
+ design**. You only reach for the paid real-model tier when the question genuinely
128
+ needs it.
129
+
130
+ - **Unit-test a hook** — `runHook` hands a hook a fake event and checks block/allow. No `claude`, no model, milliseconds, reaches **every** event type.
131
+ - **Deterministic harness test** — `runHarnessTest` runs the **real** `claude` against a **scripted mock model**, so your hooks fire for real with no API key and the same result every time.
132
+ - **Eval** — `runEval` runs the real model A/B (change on vs off) and reports the gap as **mean ± se**, with a Welch-t-test [significance gate](docs/harness-testing.md#significance--is-the-gap-real), regression baselines, and cost/latency/token tracking.
261
133
 
262
134
  ```typescript
263
- import { runHook } from "vigiles/run-hook";
135
+ import { runHook } from "vigiles/testing";
264
136
 
265
137
  const r = runHook(guardCommand, {
266
138
  hook_event_name: "PreToolUse",
@@ -270,174 +142,10 @@ const r = runHook(guardCommand, {
270
142
  assert(r.blocked); // exit 2 / decision:"block" / permissionDecision:"deny"
271
143
  ```
272
144
 
273
- The same shape governs **MCP tools** — the dominant real MCP test — with no
274
- server running, because the hook only sees the tool _name_:
275
-
276
- ```typescript
277
- // block the destructive github-MCP tool; read-only ones pass
278
- runHook(guard, {
279
- hook_event_name: "PreToolUse",
280
- tool_name: "mcp__github__merge_pull_request",
281
- tool_input: { pull_number: 42 },
282
- }).blocked; // true
283
- ```
284
-
285
- ### Level 2 — does it fire in a real session? (free, scripted "AI")
286
-
287
- Right logic ≠ wired in correctly. `runHarnessTest` runs the **real** `claude`
288
- against a **scripted mock model** you control — your hooks fire for real, the
289
- agent's turns are fixed, no API key, same result every time. Covers the
290
- governance shapes: SessionStart, Stop, UserPromptSubmit, and Bash **and
291
- Edit/Write** Pre/PostToolUse.
292
-
293
- ```typescript
294
- import { runHarnessTest, scriptModel } from "vigiles/harness-test";
295
-
296
- const r = await runHarnessTest({
297
- settings: {
298
- hooks: {
299
- Stop: [
300
- { hooks: [{ type: "command", command: "test -f DONE || exit 2" }] },
301
- ],
302
- },
303
- },
304
- model: scriptModel([
305
- { text: "I'm done" }, // tries to stop → blocked (no DONE)
306
- { tool: "Bash", input: { command: "touch DONE" } },
307
- { text: "now done" },
308
- ]),
309
- });
310
- assert(JSON.parse(r.stdout).num_turns > 1); // the Stop hook forced more work
311
- ```
312
-
313
- ### Level 3 — does it change what Claude does? (real AI, occasional)
314
-
315
- `runEval` runs the **real** model N times with your change **on vs off** and
316
- reports the gap as **mean ± se** — so you can tell signal from noise instead of
317
- eyeballing two averages:
318
-
319
- ```typescript
320
- import { runEval, formatEvalReport } from "vigiles/eval";
321
-
322
- const report = await runEval({
323
- arms: { off: {}, on: { settings: { hooks: { PostToolUse: [refsHook] } } } },
324
- task: "Document chargeCard in SKILL.md, referencing it by name.",
325
- measure: (ctx) => ({
326
- marked: ctx.sh("grep -c vigiles:symbol SKILL.md") !== "0",
327
- }),
328
- trials: 6,
329
- cache: "readwrite", // replay past runs — editing `measure` re-scores for free
330
- });
331
- console.log(formatEvalReport(report));
332
- // off marked=0.00 on marked=0.50±0.20 pass^k=0 ($0.07 · 1.2s/run · 4.1k tok)
333
- ```
334
-
335
- `assertSignificant(report, { baseline: "off", arm: "on", metric: "marked" })`
336
- turns the gap into a CI gate — a Welch t-test decides whether it cleared the
337
- noise floor, **computed** from the arms' spread, not hand-fed. Runs go
338
- **concurrently**, track **cost / latency / tokens** (cap them with `maxCostUsd`),
339
- and the **record/replay cache** makes re-scoring after a `measure` edit free.
340
-
341
- Same tier, different question: **`measureTriggerRate`** measures how reliably a
342
- skill's _description fires_ across varied prompts — the #1 skill-authoring pain.
343
-
344
- ### Test your skills for real — and assert on what Claude _did_
345
-
346
- Install a plugin the way Claude actually does (`pluginDir` → `--plugin-dir`) so
347
- its **skills genuinely activate**, then assert on the agent's _actions_, not a
348
- stdout grep:
349
-
350
- ```typescript
351
- import { assertSkillResolved, assertToolNotUsed } from "vigiles/harness-assert";
352
-
353
- const r = await runHarnessTest({
354
- pluginDir: "./my-plugin",
355
- transcript: true, // populate r.toolCalls
356
- allowedTools: ["Read", "Write", "Bash", "Skill"],
357
- model: scriptModel([
358
- { tool: "Skill", input: { skill: "my-plugin:greet" } },
359
- { text: "ok" },
360
- ]),
361
- });
362
- assertSkillResolved(r, "my-plugin:greet"); // the skill fired, no error
363
- assertToolNotUsed(r, /^mcp__github__merge/); // the safety negative: the scary tool was never called
364
- ```
365
-
366
- `assertToolNotUsed` is how you test a safety rule **honestly** — _proving_ the
367
- dangerous tool was never used, which "the file looks unchanged" can't. It works
368
- on **real third-party plugins** too: the suite confirms real `obra/superpowers`
369
- and `wshobson/agents` skills resolve this way, with no markers injected.
370
-
371
- ### Did the injected context actually reach the model?
372
-
373
- A SessionStart hook or a slash command can _fire_ and still inject **nothing** —
374
- wrong output shape, wrong platform. `trace.modelRequests` records what the model
375
- actually received (system + messages), so you assert it landed, not just that the
376
- hook ran — **"fired ≠ landed"**:
377
-
378
- ```typescript
379
- import { assertRequestContains } from "vigiles/harness-assert";
380
-
381
- assertRequestContains(r, "You have superpowers"); // the additionalContext reached the model
382
- ```
383
-
384
- (Dogfood: this is exactly how vigiles found that real `obra/superpowers` emits a
385
- _top-level_ `additionalContext`, which Claude Code — reading the _nested_ form —
386
- never injects. The hook fired; the context never landed.)
387
-
388
- ### Running an untrusted plugin? It's confined by default
389
-
390
- Testing a third-party plugin means executing **its** hooks. `runHarnessTest` is
391
- safe by default: code you wrote (inline `settings`/`files`) runs directly, but an
392
- external `plugin` / `pluginDir` is **confined under bubblewrap** — a network
393
- namespace with **no egress** (a malicious hook can't phone home), a read-only
394
- filesystem, and a **cleared environment** (your `ANTHROPIC_API_KEY` and other
395
- secrets aren't even visible). If no sandbox is available the run **refuses**
396
- rather than executing unconfined:
397
-
398
- ```typescript
399
- runHarnessTest({ pluginDir: "./vendor/some-plugin", model }); // confined, or refuses
400
- runHarnessTest({ pluginDir: "./audited", model, sandbox: false }); // you vouch for it → direct
401
- ```
402
-
403
- Confinement is **Linux-only** (bubblewrap); on macOS / Windows an untrusted run
404
- refuses unless you pass `sandbox: false`. The suite dogfoods it on real
405
- `obra/superpowers` — its `SessionStart` hook runs in a no-egress sandbox, and the
406
- test proves egress is blocked while the scripted mock stays reachable.
407
-
408
- ### Run them in CI
409
-
410
- `vigiles test` runs `*.harness.mjs` files (free, no key); `vigiles eval` runs
411
- `*.eval.mjs` files (real model). Point a test at a whole plugin (or `"./"` for
412
- your repo) to load **what ships** — hooks (with `${CLAUDE_PLUGIN_ROOT}`
413
- resolved), CLAUDE.md, skills, subagents, commands — and `loadPlugin().warnings`
414
- flags anything only a real model can drive, so you never silently test an empty
415
- machine.
416
-
417
- ```bash
418
- npx vigiles test examples/harness/policy-gate.harness.mjs
419
- npx vigiles eval --trials=6 examples/harness/skill-outcome.eval.mjs
420
- ```
421
-
422
- ### What's covered today — surface × tier
423
-
424
- | Surface | Unit / static | Integration (no API key) | Eval (real model) |
425
- | ------------------------------------------------------------- | ---------------------------- | --------------------------- | ----------------- |
426
- | Hooks — Bash / SessionStart / Stop / UserPromptSubmit | ✅ logic | ✅ fires | ✅ |
427
- | Hooks — Edit / Write | ✅ logic | ✅ fires | ✅ |
428
- | Hooks — PreCompact / Notification / SessionEnd / SubagentStop | ✅ logic | — (mock can't trigger) | 🟡 |
429
- | CLAUDE.md / instructions | ✅ refs | 🟡 present, not behaviour | ✅ behaviour |
430
- | Skills | 🟡 refs | ✅ resolves via `pluginDir` | ✅ activation |
431
- | Subagents (`agents/`) | ✅ tool rail · 🟡 refs | 🟡 rail not live-armed | ✅ via Task |
432
- | Slash commands (`commands/`) | 🟡 refs | 🟡 needs prompt capture | ✅ via `/cmd` |
433
- | MCP servers | ✅ tool refs (`vigiles:mcp`) | 🔴 | 🔴 |
434
- | settings.json | 🟡 assert merged | ✅ applied | ✅ |
435
- | Hook context injection (does it _land_?) | — n/a | ✅ `trace.modelRequests` | ✅ |
436
- | Untrusted plugin execution | — n/a | ✅ confined (bwrap, Linux) | 🟡 outer sandbox |
437
-
438
- ✅ shipped · 🟡 partial · 🔴 gap · — n/a. Full detail + roadmap: [`research/harness-testing-coverage-matrix.md`](research/harness-testing-coverage-matrix.md).
439
-
440
- [Full guide → `docs/harness-testing.md`](docs/harness-testing.md) · [benchmarks](research/benchmarks-runtime-gates.md).
145
+ **[Full guide `docs/harness-testing.md`](docs/harness-testing.md)** — the tier
146
+ walkthrough, testing skills for real, "fired landed" (`trace.modelRequests`),
147
+ the safe-by-default sandbox for untrusted plugins, the surface × tier coverage
148
+ matrix, and how it compares to promptfoo. Also: [benchmarks](research/benchmarks-runtime-gates.md).
441
149
 
442
150
  ## CLI & CI
443
151
 
@@ -456,43 +164,29 @@ npx vigiles eval # Run *.eval.mjs real-model harness evals (--trials=N)
456
164
  Install with [Vercel Skills](https://github.com/vercel-labs/skills): `npx skills add zernie/vigiles`
457
165
 
458
166
  <details>
459
- <summary><b>The 7 skills</b></summary>
460
-
461
- | Skill | What it does |
462
- | ---------------------- | ----------------------------------------------------------------------- |
463
- | `strengthen` | Upgrade `guidance()` → `enforce()` using linter-specific reference docs |
464
- | `edit-spec` | Edit a spec file — guided workflow with compile step |
465
- | `migrate-to-spec` | Convert a hand-written CLAUDE.md to a typed `.spec.ts` |
466
- | `generate-rule` | Add a new `enforce()` / `guidance()` rule to a spec |
467
- | `pr-to-lint-rule` | Turn a recurring PR review comment into a lint rule + spec entry |
468
- | `enforce-rules-format` | Validate all rules have enforcement classification |
469
- | `audit-feedback-loop` | Score your repo's feedback loop maturity |
470
-
471
- </details>
472
-
473
- ## Maturity Levels
474
-
475
- From [Feedback Loop Is All You Need](https://zernie.com/blog/feedback-loop-is-all-you-need): **Vibes → Guardrails → Architecture as Code → The Organism**.
476
-
477
- <details>
478
- <summary>What each level means</summary>
479
-
480
- | Level | Name | What it means |
481
- | ----- | -------------------- | ------------------------------------------------------------------- |
482
- | 0 | Vibes | No CI, no linters, no CLAUDE.md |
483
- | 1 | Guardrails | CI + standard linters, no custom rules |
484
- | 2 | Architecture as Code | Custom lint rules + enforced CLAUDE.md |
485
- | 3 | The Organism | CI + custom rules + visual tests + observability + scheduled agents |
167
+ <summary><b>The 8 skills</b></summary>
168
+
169
+ | Skill | What it does |
170
+ | ---------------------- | ------------------------------------------------------------------------------------------------- |
171
+ | `strengthen` | Upgrade `guidance()` → `enforce()` using linter-specific reference docs |
172
+ | `edit-spec` | Edit a spec file — guided workflow with compile step |
173
+ | `migrate-to-spec` | Convert a hand-written CLAUDE.md to a typed `.spec.ts` |
174
+ | `generate-rule` | Add a new `enforce()` / `guidance()` rule to a spec |
175
+ | `pr-to-lint-rule` | Turn a recurring PR review comment into a lint rule + spec entry |
176
+ | `enforce-rules-format` | Validate all rules have enforcement classification |
177
+ | `audit-feedback-loop` | Score your repo's feedback loop maturity |
178
+ | `test-harness` | Test a Claude Code harness — pick the tier (unit / deterministic / eval) and write a passing test |
486
179
 
487
180
  </details>
488
181
 
489
182
  ## Related Tools
490
183
 
491
- vigiles owns one thing: compile-time verification of typed specs against real linter configs, filesystems, and package.json, plus testing the harness those specs describe. Everything else it composes with rather than replaces architectural linters ([ast-grep](https://ast-grep.github.io/), [Dependency Cruiser](https://github.com/sverweij/dependency-cruiser)) referenced via `enforce()`, file-sync tools ([Ruler](https://github.com/intellectronica/ruler), [rulesync](https://github.com/dyoshikawa/rulesync)) that distribute the compiled output, and markdown/prose linters that check a different layer. [How vigiles composes with each, and why runtime-LLM rule checkers are the opposite paradigm →](docs/related-tools.md)
184
+ vigiles composes with other tools rather than replacing them: architectural linters ([ast-grep](https://ast-grep.github.io/), [Dependency Cruiser](https://github.com/sverweij/dependency-cruiser)) referenced via `enforce()`, and file-sync tools ([Ruler](https://github.com/intellectronica/ruler), [rulesync](https://github.com/dyoshikawa/rulesync)) that distribute the compiled output. [How it fits with each, and why runtime-LLM rule checkers are the opposite paradigm →](docs/related-tools.md)
492
185
 
493
186
  ## Documentation
494
187
 
495
- - **[docs/](docs/README.md)** how-to & reference: the adoption ladder, CLI, linter support, the harness-testing guide, skills/agents.
188
+ - **The two pillar guides:** [verifying instruction files](docs/verifying-instruction-files.md) (Pillar 1) · [testing your harness](docs/harness-testing.md) (Pillar 2).
189
+ - **[docs/](docs/README.md)** — the full how-to & reference index: adoption ladder, CLI, linter support, skills/agents.
496
190
  - **[research/](research/README.md)** — the thinking behind it: design docs, the [harness-testing coverage roadmap](research/harness-testing-coverage-matrix.md), benchmark findings, landscape, and parked ideas.
497
191
 
498
192
  ## License
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `vigiles/claude-code` — the Claude Code-specific harness pieces a *different*
3
+ * harness would swap out: the plugin/repo loader (reads real Claude Code plugin
4
+ * layouts) and the scriptable Anthropic Messages mock. Split from
5
+ * `vigiles/testing` on purpose — the test API above is the stable surface; this
6
+ * is the adapter, so a future `vigiles/<other-harness>` can sit beside it.
7
+ */
8
+ export * from "./plugin-loader.js";
9
+ export * from "./mock-model.js";
10
+ //# sourceMappingURL=claude-code.d.ts.map
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * `vigiles/claude-code` — the Claude Code-specific harness pieces a *different*
19
+ * harness would swap out: the plugin/repo loader (reads real Claude Code plugin
20
+ * layouts) and the scriptable Anthropic Messages mock. Split from
21
+ * `vigiles/testing` on purpose — the test API above is the stable surface; this
22
+ * is the adapter, so a future `vigiles/<other-harness>` can sit beside it.
23
+ */
24
+ __exportStar(require("./plugin-loader.js"), exports);
25
+ __exportStar(require("./mock-model.js"), exports);
26
+ //# sourceMappingURL=claude-code.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=egress-proxy.d.ts.map
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Recording egress proxy — runs INSIDE the sandbox netns (on loopback), so a
5
+ * confined hook configured with `HTTP(S)_PROXY` routes its network attempts here.
6
+ * It RECORDS each target (`host:port`) to an ndjson log and BLOCKS it (responds
7
+ * 502 / closes) — the netns already has no external route, so nothing actually
8
+ * leaves; this just turns "silently blocked" into "blocked AND recorded", so a
9
+ * test can assert what a hook/skill tried to reach (phone-home / which registry
10
+ * an install would hit).
11
+ *
12
+ * Honest limit: this records what PROXY-honoring tools (npm, pip, curl, fetch)
13
+ * attempt. Raw-socket egress bypasses the proxy — but the netns still blocks it
14
+ * hard, so it can't get out; it just won't appear in the record. The block is the
15
+ * boundary; the record is best-effort observability over it.
16
+ *
17
+ * Run as: `node dist/egress-proxy.js <egress-log-path> <port-file-path>`.
18
+ */
19
+ /* v8 ignore start -- a standalone subprocess run only inside the sandbox netns;
20
+ exercised by the bwrap-gated end-to-end test, not the unit gate. The pure
21
+ parser (parseEgressLog) carries the testable logic. */
22
+ const node_http_1 = require("node:http");
23
+ const node_fs_1 = require("node:fs");
24
+ const [, , logPath, portPath] = process.argv;
25
+ function record(host, port) {
26
+ try {
27
+ (0, node_fs_1.appendFileSync)(logPath, JSON.stringify({ host, port, ts: Date.now() }) + "\n");
28
+ }
29
+ catch {
30
+ /* best-effort: a recording failure must not crash the hook under test */
31
+ }
32
+ }
33
+ const server = (0, node_http_1.createServer)((req, res) => {
34
+ // Plain HTTP via a proxy: req.url is absolute, e.g. http://host:port/path.
35
+ try {
36
+ const u = new URL(req.url ?? "");
37
+ record(u.hostname, Number(u.port) || 80);
38
+ }
39
+ catch {
40
+ /* unparseable target — skip */
41
+ }
42
+ res.writeHead(502, { "content-type": "text/plain" });
43
+ res.end("blocked by vigiles egress recorder\n");
44
+ });
45
+ // HTTPS via a proxy: the client sends `CONNECT host:port`. Record + refuse.
46
+ server.on("connect", (req, socket) => {
47
+ const [host, port] = (req.url ?? "").split(":");
48
+ record(host, Number(port) || 443);
49
+ socket.write("HTTP/1.1 502 Blocked\r\n\r\n");
50
+ socket.end();
51
+ });
52
+ server.on("clientError", (_e, socket) => socket.destroy());
53
+ server.listen(0, "127.0.0.1", () => {
54
+ const addr = server.address();
55
+ const port = typeof addr === "object" && addr ? addr.port : 0;
56
+ // Hand the chosen port back to the wrapper, which exports HTTP(S)_PROXY.
57
+ (0, node_fs_1.writeFileSync)(portPath, String(port));
58
+ });
59
+ /* v8 ignore stop */
60
+ //# sourceMappingURL=egress-proxy.js.map