vigiles 2.0.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.
Files changed (156) hide show
  1. package/.claude/settings.json +46 -0
  2. package/.claude/settings.local.json +8 -0
  3. package/.claude-plugin/hooks/post-edit.sh +34 -0
  4. package/.claude-plugin/hooks/pre-edit.sh +40 -0
  5. package/.claude-plugin/hooks/session-start.sh +38 -0
  6. package/.claude-plugin/marketplace.json +14 -0
  7. package/.claude-plugin/plugin.json +47 -0
  8. package/.github/workflows/ci.yml +81 -0
  9. package/.prettierignore +1 -0
  10. package/.vigiles/generated.d.ts +205 -0
  11. package/CLAUDE.md +95 -0
  12. package/CLAUDE.md.spec.ts +142 -0
  13. package/CONTRIBUTING.md +121 -0
  14. package/LICENSE +21 -0
  15. package/README.md +377 -0
  16. package/action.yml +25 -0
  17. package/dist/action.d.ts +7 -0
  18. package/dist/action.d.ts.map +1 -0
  19. package/dist/action.js +180 -0
  20. package/dist/action.js.map +1 -0
  21. package/dist/cli.d.ts +12 -0
  22. package/dist/cli.d.ts.map +1 -0
  23. package/dist/cli.js +1267 -0
  24. package/dist/cli.js.map +1 -0
  25. package/dist/cli.test.d.ts +2 -0
  26. package/dist/cli.test.d.ts.map +1 -0
  27. package/dist/cli.test.js +650 -0
  28. package/dist/cli.test.js.map +1 -0
  29. package/dist/compile.d.ts +101 -0
  30. package/dist/compile.d.ts.map +1 -0
  31. package/dist/compile.js +503 -0
  32. package/dist/compile.js.map +1 -0
  33. package/dist/evolve.d.ts +132 -0
  34. package/dist/evolve.d.ts.map +1 -0
  35. package/dist/evolve.js +599 -0
  36. package/dist/evolve.js.map +1 -0
  37. package/dist/freshness.d.ts +67 -0
  38. package/dist/freshness.d.ts.map +1 -0
  39. package/dist/freshness.js +244 -0
  40. package/dist/freshness.js.map +1 -0
  41. package/dist/freshness.test.d.ts +2 -0
  42. package/dist/freshness.test.d.ts.map +1 -0
  43. package/dist/freshness.test.js +356 -0
  44. package/dist/freshness.test.js.map +1 -0
  45. package/dist/generate-types.d.ts +34 -0
  46. package/dist/generate-types.d.ts.map +1 -0
  47. package/dist/generate-types.js +381 -0
  48. package/dist/generate-types.js.map +1 -0
  49. package/dist/inline.d.ts +58 -0
  50. package/dist/inline.d.ts.map +1 -0
  51. package/dist/inline.js +142 -0
  52. package/dist/inline.js.map +1 -0
  53. package/dist/inline.test.d.ts +5 -0
  54. package/dist/inline.test.d.ts.map +1 -0
  55. package/dist/inline.test.js +152 -0
  56. package/dist/inline.test.js.map +1 -0
  57. package/dist/linters.d.ts +38 -0
  58. package/dist/linters.d.ts.map +1 -0
  59. package/dist/linters.js +588 -0
  60. package/dist/linters.js.map +1 -0
  61. package/dist/proofs.d.ts +272 -0
  62. package/dist/proofs.d.ts.map +1 -0
  63. package/dist/proofs.js +622 -0
  64. package/dist/proofs.js.map +1 -0
  65. package/dist/proofs.test.d.ts +9 -0
  66. package/dist/proofs.test.d.ts.map +1 -0
  67. package/dist/proofs.test.js +952 -0
  68. package/dist/proofs.test.js.map +1 -0
  69. package/dist/spec.d.ts +258 -0
  70. package/dist/spec.d.ts.map +1 -0
  71. package/dist/spec.js +113 -0
  72. package/dist/spec.js.map +1 -0
  73. package/dist/spec.test.d.ts +2 -0
  74. package/dist/spec.test.d.ts.map +1 -0
  75. package/dist/spec.test.js +1222 -0
  76. package/dist/spec.test.js.map +1 -0
  77. package/dist/types.d.ts +101 -0
  78. package/dist/types.d.ts.map +1 -0
  79. package/dist/types.js +3 -0
  80. package/dist/types.js.map +1 -0
  81. package/dist/validate.d.ts +10 -0
  82. package/dist/validate.d.ts.map +1 -0
  83. package/dist/validate.js +286 -0
  84. package/dist/validate.js.map +1 -0
  85. package/dist/validate.test.d.ts +2 -0
  86. package/dist/validate.test.d.ts.map +1 -0
  87. package/dist/validate.test.js +531 -0
  88. package/dist/validate.test.js.map +1 -0
  89. package/docs/agent-setup.md +85 -0
  90. package/docs/agent-workflows.md +103 -0
  91. package/docs/comparison.md +71 -0
  92. package/docs/freshness.md +124 -0
  93. package/docs/inline-mode.md +119 -0
  94. package/docs/linter-support.md +166 -0
  95. package/docs/spec-format.md +194 -0
  96. package/eslint.config.mjs +79 -0
  97. package/examples/CLAUDE.md +54 -0
  98. package/examples/CLAUDE.md.spec.ts +65 -0
  99. package/examples/SKILL.md +50 -0
  100. package/examples/SKILL.md.spec.ts +57 -0
  101. package/fixtures/example-project/CLAUDE.md +11 -0
  102. package/fixtures/example-project/package.json +9 -0
  103. package/fixtures/example-project/src/index.ts +3 -0
  104. package/fixtures/example-project/src/utils.test.ts +2 -0
  105. package/fixtures/example-project/src/utils.ts +3 -0
  106. package/logo.png +0 -0
  107. package/package.json +42 -0
  108. package/research/adoption-strategy.md +111 -0
  109. package/research/agent-integration.md +145 -0
  110. package/research/ai-code-quality.md +197 -0
  111. package/research/code-search-for-agents.md +313 -0
  112. package/research/competitive-landscape.md +163 -0
  113. package/research/doc-freshness.md +516 -0
  114. package/research/executable-specs.md +368 -0
  115. package/research/feature-ideas.md +464 -0
  116. package/research/formal-proofs-for-agents.md +338 -0
  117. package/research/fp-for-agent-harness.md +150 -0
  118. package/research/fp-for-deterministic-ai.md +131 -0
  119. package/research/self-evolving-specs.md +298 -0
  120. package/schemas/claude-md-strict.yml +18 -0
  121. package/schemas/claude-md.yml +6 -0
  122. package/schemas/skill-strict.yml +12 -0
  123. package/schemas/skill.yml +5 -0
  124. package/skills/audit-feedback-loop/SKILL.md +76 -0
  125. package/skills/edit-spec/SKILL.md +131 -0
  126. package/skills/enforce-rules-format/SKILL.md +71 -0
  127. package/skills/generate-logo/SKILL.md +102 -0
  128. package/skills/generate-rule/SKILL.md +90 -0
  129. package/skills/linter-docs/clippy.md +241 -0
  130. package/skills/linter-docs/eslint.md +384 -0
  131. package/skills/linter-docs/pylint.md +288 -0
  132. package/skills/linter-docs/rubocop.md +277 -0
  133. package/skills/linter-docs/ruff.md +187 -0
  134. package/skills/linter-docs/stylelint.md +247 -0
  135. package/skills/migrate-to-spec/SKILL.md +124 -0
  136. package/skills/pr-to-lint-rule/SKILL.md +97 -0
  137. package/skills/strengthen/SKILL.md +168 -0
  138. package/src/action.ts +214 -0
  139. package/src/cli.test.ts +914 -0
  140. package/src/cli.ts +1631 -0
  141. package/src/compile.ts +691 -0
  142. package/src/evolve.ts +781 -0
  143. package/src/freshness.test.ts +449 -0
  144. package/src/freshness.ts +299 -0
  145. package/src/generate-types.ts +448 -0
  146. package/src/inline.test.ts +206 -0
  147. package/src/inline.ts +164 -0
  148. package/src/linters.ts +739 -0
  149. package/src/proofs.test.ts +1314 -0
  150. package/src/proofs.ts +849 -0
  151. package/src/spec.test.ts +1471 -0
  152. package/src/spec.ts +427 -0
  153. package/src/types.ts +117 -0
  154. package/src/validate.test.ts +701 -0
  155. package/src/validate.ts +381 -0
  156. package/tsconfig.json +23 -0
@@ -0,0 +1,313 @@
1
+ # Code Search for AI Coding Agents
2
+
3
+ Research on how AI coding agents find and read code. Agents spend ~99% of their time reading. This document compares approaches: grep, AST-based search, embeddings, LSP, and graph databases.
4
+
5
+ ---
6
+
7
+ ## The Problem
8
+
9
+ AI coding agents (Claude Code, Codex, Cursor, Aider) spend most of their time _finding_ code, not _writing_ it. The search strategy determines both cost (tokens burned) and quality (did the agent find the right context?).
10
+
11
+ The fundamental tension: **exact matching** (fast, deterministic, requires knowing what to search for) vs. **semantic matching** (slower, approximate, works when you don't know the symbol name).
12
+
13
+ ---
14
+
15
+ ## 1. Ripgrep — The Current Baseline
16
+
17
+ ### How it works
18
+
19
+ Ripgrep (`rg`) is a Rust text search tool. Performance comes from:
20
+
21
+ - **SIMD-accelerated literal matching**: Uses the `memchr` crate and Intel's Teddy algorithm. When a regex contains literal substrings, ripgrep extracts them and uses SIMD to skip through files without entering the regex engine.
22
+ - **Lock-free parallel directory walking**: Built on `crossbeam` and the `ignore` crate. Traverses directories in parallel across all CPU cores.
23
+ - **Smart filtering**: Respects `.gitignore` natively, skips binary files.
24
+ - **Lazy line isolation**: When a candidate match is found via literal scan, only that line's boundaries are located and the full regex runs on that line alone.
25
+
26
+ ### Performance
27
+
28
+ | Benchmark | Ripgrep | GNU grep | Speedup |
29
+ | --------------------------------- | ------- | -------- | ------------------------- |
30
+ | Linux kernel full search | ~0.06s | ~0.67s | 10x |
31
+ | Node.js project (with .gitignore) | — | — | 302x (skips node_modules) |
32
+ | Common identifier search | — | — | 9.2x |
33
+
34
+ Typical AI agent usage: 10-30 searches per task, each completing in 20-50ms.
35
+
36
+ ### How Claude Code uses it
37
+
38
+ Three-tool hierarchy in cost-ascending order:
39
+
40
+ 1. **Glob** — pattern-matching file discovery, returns only paths (near-zero token cost)
41
+ 2. **Grep** — ripgrep content search, returns matching lines with context (low cost)
42
+ 3. **Read** — full file loading (500-5,000 tokens per file)
43
+
44
+ For heavy exploration, Claude Code spawns an **Explore sub-agent** on Haiku (15x cheaper per token). This sub-agent searches, summarizes, and returns results — preventing exploration costs from consuming the main context.
45
+
46
+ **Key finding from Anthropic**: Early Claude Code versions used RAG + a local vector DB. They abandoned it because agentic search "outperformed everything by a lot, and this was surprising" (Boris Cherny, Latent Space podcast, May 2025). Reasons: exact symbol matching beats fuzzy similarity for code, no index staleness, no privacy concerns from stored embeddings.
47
+
48
+ ### Strengths
49
+
50
+ - Deterministic — same query always returns same results
51
+ - Zero setup, zero indexing
52
+ - Never stale — always searches current filesystem state
53
+ - Low token cost per search (returns just matching lines)
54
+
55
+ ### Weaknesses
56
+
57
+ - **No concept search**: Can't find code by concept when you don't know the symbol name. If `createD1HttpClient` was renamed to `buildGatewayClient`, grep finds nothing.
58
+ - **Structurally blind**: `useState` in a comment matches the same as `useState` in code.
59
+ - **Noisy on common terms**: Searching `useState` in a React codebase returns hundreds of matches.
60
+ - **No cross-reference understanding**: Can't follow type hierarchies, call chains, or data flow.
61
+
62
+ ### Is it actually inefficient?
63
+
64
+ Amazon Science (Feb 2026): keyword search via agentic tool use achieves **over 90% of RAG-level performance** without a vector database. One developer reduced Claude Code's input tokens by 83% with optimized ripgrep patterns via an MCP server. The Milvus team argued the grep-only approach "burns too many tokens" on large codebases. But Claude Code compensates with prompt caching (92% prefix reuse rate, cache reads at 0.1x price).
65
+
66
+ **Verdict**: Efficient enough for most repos. Token cost is real but manageable with caching. The simplicity advantage (zero infrastructure) is underrated.
67
+
68
+ ---
69
+
70
+ ## 2. ast-grep — Structural Code Search
71
+
72
+ ### How it works
73
+
74
+ ast-grep parses source code into an AST using tree-sitter, then matches patterns against tree structure rather than text. Written in Rust.
75
+
76
+ Pattern syntax uses **metavariables**: `$VAR` captures a single AST node, `$$$` captures zero or more sequential nodes.
77
+
78
+ ```
79
+ # Find all console.log calls regardless of arguments
80
+ console.log($$$)
81
+
82
+ # Find async functions without try/catch
83
+ async function $FN($$$ARGS) { $$$ }
84
+
85
+ # Find React components using a specific hook
86
+ function $COMPONENT($$$) { const $VAR = useState($$$); $$$ }
87
+ ```
88
+
89
+ Queries impossible with text grep become natural: "find all async functions without error handling", "find functions with more than 3 parameters."
90
+
91
+ ### Performance
92
+
93
+ | Benchmark | ast-grep | Ripgrep |
94
+ | ---------------------------- | --------------------------- | ------- |
95
+ | Single pattern on TypeScript | ~0.5s | ~0.02s |
96
+ | Six rules on same codebase | 0.975s (after optimization) | — |
97
+
98
+ Optimization history on six-rule benchmark:
99
+
100
+ - Original: 10.8s
101
+ - Avoid expensive regex cloning: 5.3s
102
+ - BitSet-based `potential_kinds` (skip non-matching AST node types): 3.6s
103
+ - Eliminate duplicate tree traversal (combine rules): 0.975s (11x total improvement)
104
+
105
+ ### Advantages
106
+
107
+ - **Structural precision**: Distinguishes function definitions from calls from comments
108
+ - **Refactoring-safe**: Pattern captures actual function invocations, not string mentions
109
+ - **Language-aware**: 26+ languages via tree-sitter grammars
110
+ - **Composable rules**: Can combine with relational rules ("find X inside Y")
111
+ - **Deterministic**: Yes
112
+
113
+ ### Limitations
114
+
115
+ - **5-25x slower than ripgrep** for simple text searches (must parse full AST)
116
+ - **Pattern authoring complexity**: Agents struggle to write correct ast-grep patterns without explicit training
117
+ - **Not a grep replacement**: Best as a complement — grep to narrow, ast-grep to verify structurally
118
+
119
+ ### AI agent integration
120
+
121
+ ast-grep provides an MCP server (`ast-grep-mcp`) and a Claude Code skill. As of late 2025, Claude Code "cannot automatically detect when to use ast-grep for all appropriate use cases" — requires explicit system instructions.
122
+
123
+ **Vigiles relevance**: ast-grep is the natural backend for `check()` assertions that go beyond file pairing. `no("src/**/*.ts").matches("console.log($$$)")` could be powered by ast-grep.
124
+
125
+ ---
126
+
127
+ ## 3. Embeddings-Based Search
128
+
129
+ ### Cursor's approach
130
+
131
+ 1. **AST-based chunking**: Tree-sitter parses code into AST, depth-first traversal splits into sub-trees within token limits, merging sibling nodes to avoid over-fragmentation.
132
+ 2. **Custom embedding model**: Trained using a novel feedback loop — during agent sessions, analyze which files the agent eventually needed, have an LLM rank optimal retrieval at each step, train the embedding model to align.
133
+ 3. **Turbopuffer vector database**: Remote vector store for nearest-neighbor search.
134
+ 4. **Merkle tree synchronization**: Hierarchical hash for efficient change detection. Root hash compared every 10 minutes; only changed files re-embedded.
135
+ 5. **Privacy**: File paths obfuscated with client-side encryption. Only embeddings stored remotely.
136
+
137
+ **Cursor's own benchmark results**:
138
+
139
+ - 12.5% higher accuracy vs. grep alone
140
+ - 2.6% code retention improvement on large codebases (1,000+ files)
141
+ - 2.2% fewer dissatisfied follow-up requests
142
+
143
+ The gains are real but modest. Cursor concludes: "the combination of grep and semantic search leads to the best outcomes."
144
+
145
+ ### Aider's repo-map (NOT embeddings)
146
+
147
+ Aider's approach is graph-based, not embedding-based:
148
+
149
+ 1. **Tree-sitter parsing**: Extracts definitions and references across 40+ languages.
150
+ 2. **Dependency graph**: Each source file is a node; edges connect files with cross-references.
151
+ 3. **Personalized PageRank**: Files in active chat get high weight; ranks files by structural importance relative to current context.
152
+ 4. **Token budget**: Configurable (`--map-tokens`, default 1K). Shows function signatures and class definitions — enough for the LLM to understand APIs without full source.
153
+
154
+ No GPU, no embedding model, no vector database, works offline. Achieves **4.3-6.5% token utilization efficiency** — highest among comparable approaches.
155
+
156
+ **Deterministic**: Yes (given same input state).
157
+
158
+ ### Augment Code's Context Engine
159
+
160
+ The most ambitious approach:
161
+
162
+ - Hybrid analysis: AST + dataflow + control flow + semantic embeddings + graph neural networks
163
+ - Processes 400,000+ files, indexes commit history, PR history, external docs
164
+ - Custom embedding and retrieval models trained in pairs
165
+ - Millisecond sync with code changes
166
+
167
+ **Claimed results** (blind study, 500 PRs on Elasticsearch's 3.6M-line Java codebase):
168
+
169
+ - +12.8 overall quality vs. competitors at -13.9/-11.8
170
+ - Claude Code + Opus 4.5 saw 80% quality improvement with Context Engine MCP vs. without
171
+
172
+ Self-reported numbers. Treat with appropriate skepticism.
173
+
174
+ ### Are embeddings actually better?
175
+
176
+ **The evidence is mixed**:
177
+
178
+ - **Jason Liu** (from Augment's SWE-bench work): "We explored adding various embedding-based retrieval tools, but found that for SWE-bench tasks this was not the bottleneck — grep and find were sufficient."
179
+ - **DeepMind study**: State-of-the-art embedding models achieve **less than 20% recall** on complex retrieval tasks, while BM25 (lexical search) performs "exceptionally well" on the same tasks.
180
+ - **Theoretical ceiling**: For each embedding dimension, there exists a document count beyond which the embedding cannot encode all relevant result combinations. Single-vector approaches have a built-in mathematical limit.
181
+
182
+ **When embeddings win**: Millions of files, unknown terminology, concept search across unfamiliar codebases.
183
+ **When grep wins**: Known symbols, structured code, small-to-medium repos, exact matching, deterministic requirements.
184
+ **Deterministic**: No. Results vary with model updates, quantization, floating-point precision.
185
+
186
+ ---
187
+
188
+ ## 4. Tree-sitter — The Parsing Backbone
189
+
190
+ ### What it is
191
+
192
+ Incremental parsing library (C) that generates concrete syntax trees:
193
+
194
+ - **Incremental**: O(log n) for edits vs. O(n) for full reparse
195
+ - **Error-recovering**: Produces usable trees from syntactically invalid code
196
+ - **100+ languages**: Via grammar files
197
+ - **Query language**: S-expression patterns against tree nodes
198
+
199
+ ### What builds on tree-sitter
200
+
201
+ | Tool | Use |
202
+ | ------------------- | --------------------------------------------- |
203
+ | **Aider repo-map** | Definition/reference extraction (40+ langs) |
204
+ | **ast-grep** | Full AST pattern matching + rewriting |
205
+ | **Cursor** | AST-based code chunking for embeddings |
206
+ | **Kiro** | Built-in code intelligence (18 languages) |
207
+ | **Probe** | AST-aware search returning complete functions |
208
+ | **Codebase-Memory** | Knowledge graph construction (66 languages) |
209
+ | **GitHub** | Code navigation, semantic search |
210
+
211
+ ### Performance (Codebase-Memory benchmarks)
212
+
213
+ - Django (49K nodes): indexes in ~6s
214
+ - Linux kernel (2.1M nodes): indexes in ~3 minutes
215
+ - Individual queries: graph traversal <<1ms, BFS call-path tracing ~0.3ms
216
+
217
+ ### The cAST paper (EMNLP 2025)
218
+
219
+ AST-based chunking improves retrieval significantly:
220
+
221
+ - Recall@5 up 4.3 points on RepoEval
222
+ - Pass@1 up 2.67 points on SWE-bench generation
223
+ - StarCoder2-7B: average 5.5 point gain on RepoEval
224
+
225
+ ---
226
+
227
+ ## 5. Other Approaches
228
+
229
+ ### LSP (Language Server Protocol)
230
+
231
+ Live semantic model: go-to-definition, find-references, hover info, diagnostics via JSON-RPC.
232
+
233
+ - **50ms** to find all call sites vs. **45 seconds** with text search on large codebases (900x improvement)
234
+ - Returns exact matches consuming ~500 tokens vs. 2000+ for grep-based scanning
235
+ - Claude Code shipped native LSP support December 2025 (v2.0.74)
236
+ - Requires language server installation + initialization (seconds to minutes)
237
+ - Deterministic: yes
238
+
239
+ ### Code Graph Databases (Sourcegraph / SCIP)
240
+
241
+ SCIP indexes are 4x smaller than equivalent LSIF payloads. Sourcegraph's philosophy: code intelligence should use parsers and search indexes, not agent hype. Achieved 30% completion acceptance rate in Cody by optimizing context as a "bin packing problem."
242
+
243
+ ### Call Graph / Data Flow
244
+
245
+ - **Codebase-Memory**: Six-strategy cascading call resolution with confidence scores (0.30-0.95)
246
+ - **CodeQL**: Interprocedural data flow tracking across method boundaries
247
+ - Powerful but heavy — full call graph construction requires type resolution
248
+
249
+ ---
250
+
251
+ ## 6. SWE-bench Evidence
252
+
253
+ | Agent | Search Strategy | SWE-bench Lite | Cost/Issue |
254
+ | ------------------ | -------------------------------------------- | ---------------------- | ---------- |
255
+ | **Agentless** | LLM + embeddings (hierarchical localization) | 32% | $0.70 |
256
+ | **Moatless Tools** | FAISS + Voyage AI embeddings + MCTS | 39% | $0.14 |
257
+ | **SweRank** | Custom embedding model (retrieve-and-rerank) | Beats Claude-3.5 agent | — |
258
+
259
+ **Key insight**: The relationship between search sophistication and end-to-end performance is weak on current benchmarks. For SWE-bench-scale repositories, grep is sufficient because repos are small and code is structured. Agent persistence compensates for unsophisticated search.
260
+
261
+ **Contamination warning**: Models are 3-6x more accurate on SWE-bench-Verified than on decontaminated sets. Top models score ~23% on SWE-bench Pro vs. 70%+ on Verified.
262
+
263
+ ---
264
+
265
+ ## 7. The Emerging Consensus: Layered Search
266
+
267
+ The 2025-2026 industry direction converges on **layered search**:
268
+
269
+ ```
270
+ Layer 1: Ripgrep — fast text search (20ms, zero setup)
271
+ Layer 2: Tree-sitter/LSP — structural understanding (50ms, light setup)
272
+ Layer 3: ast-grep — pattern matching on AST (500ms, no setup)
273
+ Layer 4: Embeddings — concept search (200ms query, hours to index)
274
+ Layer 5: Graph databases — full code intelligence (ms query, minutes to index)
275
+ ```
276
+
277
+ Each layer adds capability at the cost of complexity. Hybrid retrieval combining BM25 + dense embeddings achieves **15-30% better recall** than either alone.
278
+
279
+ **Probe** (probelabs/probe) represents the "third path": ripgrep speed + tree-sitter AST parsing. Returns complete functions/classes rather than text fragments. Zero setup, fully local.
280
+
281
+ **Codebase-Memory**: Tree-sitter knowledge graph in a single C binary with SQLite. Achieves 83% answer quality vs. 92% for file-exploration agents at **10x fewer tokens** and **2.1x fewer tool calls**.
282
+
283
+ ---
284
+
285
+ ## Summary
286
+
287
+ | Approach | Latency | Indexing | Deterministic | Best For | Worst For |
288
+ | --------------------- | -------------- | ---------- | ------------- | ------------------------------ | ------------------ |
289
+ | **Ripgrep** | 20-50ms | None | Yes | Known symbols, exact match | Concept search |
290
+ | **ast-grep** | 0.5-1s | None | Yes | Structural patterns | Simple text search |
291
+ | **Embeddings** | 50-200ms query | Hours | No | Concept search, huge codebases | Exact symbols |
292
+ | **Tree-sitter graph** | <<1ms query | Seconds | Yes | Dependencies, call chains | Full text search |
293
+ | **LSP** | ~50ms | Background | Yes | Go-to-def, find-refs | Setup overhead |
294
+ | **Code graph DB** | ms query | Minutes | Yes | Enterprise navigation | Small repos |
295
+
296
+ The biggest opportunity for vigiles: tree-sitter-based structural understanding powers both `check()` assertions (ast-grep) and smarter type generation (dependency-aware). It's deterministic, fast, and requires no external services.
297
+
298
+ ---
299
+
300
+ ## Sources
301
+
302
+ - Boris Cherny, Latent Space podcast (May 2025) — Claude Code abandoned RAG for agentic grep
303
+ - Amazon Science (Feb 2026) — keyword search achieves 90%+ of RAG performance
304
+ - Cursor blog: "Improving Agent with Semantic Search" — 12.5% accuracy gain
305
+ - Aider blog: "Building a Better Repository Map with Tree-sitter" — PageRank approach
306
+ - Jason Liu: "Why Grep Beat Embeddings in Our SWE-bench Agent"
307
+ - cAST paper (EMNLP 2025) — AST chunking improves retrieval 4.3 points
308
+ - Codebase-Memory (arXiv 2603.27277) — 83% quality at 10x fewer tokens
309
+ - ast-grep blog: "Optimize ast-grep to Get 10X Faster"
310
+ - DeepMind — embedding models achieve <20% recall on complex retrieval
311
+ - SWE-Search (ICLR 2025) — MCTS enhancement for code agents
312
+ - SweRank — retrieve-and-rerank beats agent-based systems
313
+ - SWE-bench contamination (arXiv 2506.12286) — 3-6x accuracy inflation
@@ -0,0 +1,163 @@
1
+ # Competitive Landscape: AI Agent Instruction File Tooling
2
+
3
+ Collected April 2026. 15+ tools exist in this space across four categories.
4
+
5
+ ---
6
+
7
+ ## Category 1: Linters / Validators (Direct Competitors)
8
+
9
+ | Tool | Focus | Key Differentiator |
10
+ | ------------------------------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | **[AgentLinter](https://github.com/seojoonkim/agentlinter)** | Content quality scoring for CLAUDE.md/AGENTS.md | A-F grading, security checks, token efficiency, vagueness detection. 30+ rules. Exports to Cursor/Copilot/Gemini formats |
12
+ | **[cclint (carlrannaberg)](https://github.com/carlrannaberg/cclint)** | Claude Code project structure | Validates entire `.claude/` directory: agent definitions, slash commands, settings.json hooks. Zod-based custom schemas |
13
+ | **[cclint (felixgeelhaar)](https://github.com/felixgeelhaar/cclint)** | CLAUDE.md best-practice validation | Independent tool with same name. TypeScript-based |
14
+ | **[claudelint](https://github.com/pdugan20/claudelint)** | Full Claude Code ecosystem | Broadest scope: CLAUDE.md + skills + settings + hooks + MCP servers + plugins. Circular reference detection. Auto-fix. Available as Claude Code plugin |
15
+ | **[cursor-doctor](https://github.com/nedcodes-ok/cursor-doctor)** | Cursor `.mdc` rule files | 100+ checks, 34 auto-fixers. A-F grading. 48 conflict-pattern checks across files. Glob pattern validation. Team drift detection. "82% of 50 real projects had broken rules" |
16
+ | **[claude-rules-doctor](https://github.com/nulone/claude-rules-doctor)** | `.claude/rules/` glob validity | Narrow: detects dead rules where `paths:` globs match no files |
17
+
18
+ ## Category 2: Staleness / Drift Detection
19
+
20
+ | Tool | Focus | Key Differentiator |
21
+ | --------------------------------------------------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
22
+ | **[agents-lint](https://github.com/giacomo/agents-lint)** | Stale references in AGENTS.md | Most novel competitor. Verifies file paths exist, `npm run` scripts exist in package.json (with monorepo support), packages in manifests, flags deprecated packages (moment, request, tslint). Zero deps |
23
+
24
+ ## Category 3: Rule Sync / Portability
25
+
26
+ | Tool | Focus |
27
+ | ------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
28
+ | **[Ruler](https://github.com/intellectronica/ruler)** | Single source of truth → auto-distributes to agent configs |
29
+ | **[rulesync](https://github.com/dyoshikawa/rulesync)** | Unified rule management CLI, 10+ AI tools |
30
+ | **[rule-porter](https://github.com/nedcodes-ok/rule-porter)** | Bidirectional format conversion between Cursor/Windsurf/CLAUDE.md/AGENTS.md/Copilot |
31
+ | **[block/ai-rules](https://github.com/block/ai-rules)** | Enterprise multi-agent rule management (by Block/Square) |
32
+ | **[vibe-cli](https://github.com/jinjos/vibe-cli)** | Unifies rules across Claude/Cursor/Copilot/Gemini |
33
+
34
+ ## Category 4: Runtime Policy Engines (Adjacent)
35
+
36
+ | Tool | Focus |
37
+ | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
38
+ | **[Agent RuleZ](https://github.com/SpillwaveSolutions/agent_rulez)** | YAML policy engine for Claude Code hooks. Rust binary, sub-10ms, blocks dangerous ops |
39
+ | **[Vectimus](https://github.com/vectimus/vectimus)** | Cedar-based policy engine. 78 policies, sub-5ms, signed audit receipts, maps to OWASP/SOC2/NIST |
40
+ | **[Microsoft Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit)** | Runtime governance infra. Sub-0.1ms per action. Framework-agnostic |
41
+
42
+ ---
43
+
44
+ ## vigiles Moat Analysis (Updated April 2026 — v2)
45
+
46
+ **What we have that nobody else does:**
47
+
48
+ 1. **Spec compilation** — `.spec.ts` files compile to CLAUDE.md/SKILL.md. The spec is TypeScript (type-checked at authoring time). The markdown is a build artifact. Nobody else does this — other tools lint markdown after the fact.
49
+ 2. **Linter cross-referencing** — `enforce("eslint/no-console")` verifies the rule exists AND is enabled in your ESLint config. Same for Ruff, Clippy, Pylint, RuboCop, Stylelint. 6 linter APIs. No other tool does this.
50
+ 3. **Type generation** — `vigiles generate-types` scans all 6 linter APIs + package.json + filesystem → emits `.d.ts` with type unions. The TS compiler PROVES references are valid at authoring time. Like Prisma for databases, but for linter rules.
51
+ 4. **Branded reference types** — `file()` returns `VerifiedPath`, `cmd()` returns `VerifiedCmd`. Distinguishes verified from unverified at the type level.
52
+ 5. **SHA-256 integrity hash** on compiled output — detects manual edits to generated files.
53
+
54
+ **What we explicitly DON'T do (and why):**
55
+
56
+ - **Architectural linting** — use ast-grep, Dependency Cruiser, Steiger, eslint-plugin-boundaries. vigiles references their rules via `enforce()`.
57
+ - **Per-file code linting** — use ESLint, Ruff, Clippy. vigiles verifies they're configured, doesn't reimplement them.
58
+ - **Markdown formatting** — use markdownlint. vigiles generates the markdown, structure is correct by construction.
59
+ - **File sync** — use Ruler, rulesync, block/ai-rules. vigiles compiles the source, sync tools handle distribution.
60
+
61
+ **Gaps relative to competitors:**
62
+
63
+ | Gap | Who has it |
64
+ | --------------------------------------------------- | --------------------------------------------- |
65
+ | Staleness detection (file paths, scripts, packages) | **agents-lint** |
66
+ | Auto-fix | **cursor-doctor** (34 fixers), **claudelint** |
67
+ | Conflict detection across files | **cursor-doctor** (48 patterns) |
68
+ | `.claude/rules/` glob validation | **claude-rules-doctor** |
69
+ | Hook/MCP/plugin validation | **claudelint**, **cclint** |
70
+ | Scoring/grading (A-F) | **AgentLinter**, **cursor-doctor** |
71
+ | Security anti-pattern detection | **AgentLinter** |
72
+ | Token budget analysis | **cursor-doctor** |
73
+
74
+ **Strategic filter for new rules:** Only build rules that require knowing something mdschema can't know (filesystem state, linter configs, content semantics). Structural checks (heading hierarchy, required sections, max depth) belong in mdschema schemas, not vigiles rules.
75
+
76
+ ---
77
+
78
+ ## Real-World Pain Points
79
+
80
+ Problems people actually report with AI instruction files, with citations:
81
+
82
+ ### 1. File Too Long / Rules Ignored (HIGH FREQUENCY)
83
+
84
+ CLAUDE.md over ~200-300 lines → compliance drops sharply. ETH Zurich study: LLM-generated instruction files caused -3% task success, +20% cost. Over 50% of rules were noise.
85
+
86
+ - Sources: [HumanLayer](https://www.humanlayer.dev/blog/stop-claude-from-ignoring-your-claude-md), [DEV.to](https://dev.to/minatoplanb/i-wrote-200-lines-of-rules-for-claude-code-it-ignored-them-all-4639), [DEV.to](https://dev.to/alexefimenko/i-analyzed-a-lot-of-ai-agent-rules-files-most-are-making-your-agent-worse-2fl)
87
+
88
+ ### 2. Vague / Unenforceable Directives (HIGH FREQUENCY)
89
+
90
+ "Write clean code," "Follow best practices" — infinite interpretations, zero behavioral change.
91
+
92
+ - Sources: [HumanLayer](https://www.humanlayer.dev/blog/writing-a-good-claude-md), [UX Planet](https://uxplanet.org/claude-md-best-practices-1ef4f861ce7c)
93
+
94
+ ### 3. Stale / Broken File References (HIGH FREQUENCY)
95
+
96
+ Instruction files reference paths moved, renamed, or deleted. One audit found 59 broken references.
97
+
98
+ - Sources: [Packmind](https://packmind.com/evaluate-context-ai-coding-agent/), [agents-lint](https://giacomo.github.io/agents-lint/)
99
+
100
+ ### 4. Contradictory Rules Across Files (MEDIUM FREQUENCY)
101
+
102
+ Root CLAUDE.md says "Use Prettier," subdirectory says "Use Biome." Agent picks one at random.
103
+
104
+ - Sources: [Cursor Forum](https://forum.cursor.com/t/issues-with-cursorrules-not-being-consistently-followed/59264)
105
+
106
+ ### 5. Rules That Belong in Tooling (MEDIUM FREQUENCY)
107
+
108
+ "Don't use var" should be an ESLint rule, not a CLAUDE.md instruction. ~80% compliance via instruction vs 100% via linter.
109
+
110
+ - Sources: [Spotify Engineering](https://engineering.atspotify.com/2025/12/feedback-loops-background-coding-agents-part-3), [Anthropic](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)
111
+
112
+ ### 6. "Lost in the Middle" Effect (RESEARCH-BACKED)
113
+
114
+ LLMs exhibit primacy/recency bias — rules buried in the middle of long files get deprioritized.
115
+
116
+ - Sources: [Context Windows - Goose Blog](https://block.github.io/goose/blog/2025/08/18/understanding-context-windows/), [Martin Fowler](https://martinfowler.com/articles/exploring-gen-ai/context-engineering-coding-agents.html)
117
+
118
+ ### 7. Missing Essential Sections (MEDIUM FREQUENCY)
119
+
120
+ GitHub analysis of 2,500+ AGENTS.md files: common omissions = executable commands, testing instructions, project structure, code style, git workflow.
121
+
122
+ - Sources: [GitHub Blog](https://github.blog/ai-and-ml/github-copilot/how-to-write-a-great-agents-md-lessons-from-over-2500-repositories/), [AGENTS.md](https://agents.md/)
123
+
124
+ ---
125
+
126
+ ## Transferable Concepts from Other Linters
127
+
128
+ | Source Tool | Concept | vigiles Application |
129
+ | ------------------------------- | ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
130
+ | **hadolint** (Dockerfile) | Version pinning — flag vague refs that rot | `no-vague-enforcement`: flag `**Enforced by:** linter` without specific rule name |
131
+ | **actionlint** (GitHub Actions) | Reference validation — actions/jobs must exist | Already have `require-rule-file`. Extend to script/package refs |
132
+ | **commitlint** | Structural template enforcement | `require-why` (rationale), `rule-title-format` (consistent imperative titles) |
133
+ | **ShellCheck** | Portability warnings — bash-isms in sh scripts | `no-tool-specific-rules`: flag rules using tools only one agent has when project uses multiple agents |
134
+ | **Clippy** (Rust) | Severity tiers (correctness/suspicious/style/pedantic) | Could tier vigiles rules by impact, but current pass/fail model is simpler |
135
+ | **Pylint** (`R0801`) | Duplicate code detection | `no-duplicate-rules` across instruction files |
136
+ | **ESLint** (`no-shadow`) | Scope shadowing — inner var hides outer | `no-shadow-rules`: subdirectory CLAUDE.md redefines root rule with different enforcement |
137
+ | **Danger.js** | PR meta-checks — is it too big? changelog updated? | `instruction-file-hygiene`: was CLAUDE.md updated when architecture changed? |
138
+
139
+ ---
140
+
141
+ ## Decisions Log
142
+
143
+ ### markdownlint integration — NO (April 2026)
144
+
145
+ Decided not to integrate markdownlint. Reasons:
146
+
147
+ - **Not our job.** vigiles validates content semantics (are enforcement claims real?). markdownlint validates formatting (trailing spaces, list markers). Different concerns.
148
+ - **Already solved.** CodeRabbit runs it on PRs by default. Teams that want CI blocking already run `npx markdownlint CLAUDE.md`.
149
+ - **Noise.** Formatting issues in instruction files have zero impact on whether the agent follows the rules. Dilutes signal from our actual rules.
150
+ - **Dependency weight.** Against the zero-config principle. Would own the config surface ("why is vigiles flagging MD013?").
151
+
152
+ Listed as complementary tool in README instead.
153
+
154
+ ### Agent detection refactor — SIMPLIFIED (April 2026)
155
+
156
+ Removed indicator-based agent detection (scanning `.claude/`, `.cursor/`, etc. and nagging about missing files). Replaced with simple `"files": ["CLAUDE.md"]` config.
157
+
158
+ Reasons:
159
+
160
+ - Having a `.cursor/` directory doesn't mean you owe the world a `.cursorrules` file
161
+ - File distribution across agents is the sync tools' job (Ruler, rulesync, block/ai-rules), not ours
162
+ - The "missing file" check was a half-baked sync tool inside a content validator
163
+ - Simpler: validate what exists, don't nag about what doesn't