milens 0.7.2 → 0.7.3

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 (52) hide show
  1. package/.agents/skills/adapters/SKILL.md +59 -59
  2. package/.agents/skills/analyzer/SKILL.md +83 -83
  3. package/.agents/skills/apps/SKILL.md +65 -65
  4. package/.agents/skills/docs/SKILL.md +63 -63
  5. package/.agents/skills/milens/SKILL.md +322 -322
  6. package/.agents/skills/milens-security-review/SKILL.md +224 -224
  7. package/.agents/skills/orchestrator/SKILL.md +64 -64
  8. package/.agents/skills/parser/SKILL.md +86 -86
  9. package/.agents/skills/root/SKILL.md +89 -89
  10. package/.agents/skills/scripts/SKILL.md +56 -56
  11. package/.agents/skills/security/SKILL.md +67 -67
  12. package/.agents/skills/server/SKILL.md +84 -84
  13. package/.agents/skills/store/SKILL.md +77 -77
  14. package/.agents/skills/test/SKILL.md +155 -155
  15. package/.agents/skills/ui/SKILL.md +56 -56
  16. package/README.md +577 -577
  17. package/adapters/README.md +144 -144
  18. package/adapters/claude-code/.claude/mcp.json +9 -9
  19. package/adapters/claude-code/.claude/settings.json.hooks-snippet.json +26 -26
  20. package/adapters/claude-code/.claude-plugin/plugin.json +11 -11
  21. package/adapters/claude-code/.mcp.json +9 -9
  22. package/adapters/claude-code/CLAUDE.md +81 -81
  23. package/adapters/claude-code/hooks/hooks.json +27 -27
  24. package/adapters/codex/.codex/config.toml +3 -3
  25. package/adapters/copilot/.vscode/mcp.json +10 -10
  26. package/adapters/cursor/.cursor/mcp.json +9 -9
  27. package/adapters/cursor/.cursorrules +69 -69
  28. package/adapters/gemini/.gemini/context.md +81 -81
  29. package/adapters/gemini/.gemini/settings.json +9 -9
  30. package/adapters/opencode/.opencode/config.json +8 -8
  31. package/adapters/zed/.zed/settings.json +8 -8
  32. package/dist/build-info.d.ts +2 -2
  33. package/dist/build-info.js +2 -2
  34. package/dist/cli.js +482 -482
  35. package/dist/parser/lang-css.js +9 -9
  36. package/dist/parser/lang-go.js +58 -58
  37. package/dist/parser/lang-html.js +3 -3
  38. package/dist/parser/lang-java.js +37 -37
  39. package/dist/parser/lang-js.js +105 -105
  40. package/dist/parser/lang-php.js +45 -45
  41. package/dist/parser/lang-py.js +43 -43
  42. package/dist/parser/lang-ruby.js +28 -28
  43. package/dist/parser/lang-rust.js +48 -48
  44. package/dist/parser/lang-ts.js +210 -210
  45. package/dist/server/mcp-prompts.js +502 -502
  46. package/dist/server/mcp.js +56 -56
  47. package/dist/skills.js +296 -296
  48. package/dist/store/annotations.js +1 -1
  49. package/dist/store/db.js +224 -224
  50. package/dist/store/schema.sql +144 -144
  51. package/dist/store/vectors.js +2 -2
  52. package/package.json +85 -85
package/README.md CHANGED
@@ -1,577 +1,577 @@
1
- <p align="center">
2
- <strong>Milens</strong><br>
3
- <em>Your AI butler</em>
4
- </p>
5
-
6
- <p align="center">
7
- <a href="https://www.npmjs.com/package/milens"><img src="https://img.shields.io/npm/v/milens" alt="npm"></a>
8
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node"></a>
9
- <a href="https://github.com/fuze210699/milens/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license"></a>
10
- <img src="https://img.shields.io/badge/tools-43-purple" alt="43 tools">
11
- <img src="https://img.shields.io/badge/languages-12-blue" alt="12 languages">
12
- <img src="https://img.shields.io/badge/prompts-6-orange" alt="6 prompts">
13
- <img src="https://img.shields.io/badge/security-190%2B-red" alt="190+ rules">
14
- <img src="https://img.shields.io/badge/harnesses-7-lightgrey" alt="7 harnesses">
15
- <a href="https://github.com/fuze210699/milens/actions/workflows/milens-ci-test.yml"><img src="https://github.com/fuze210699/milens/actions/workflows/milens-ci-test.yml/badge.svg" alt="CI"></a>
16
- <img src="https://img.shields.io/npm/dm/milens" alt="npm downloads">
17
- <img src="https://img.shields.io/npm/dt/milens" alt="npm total">
18
-
19
- </p>
20
-
21
- <p align="center">
22
- <a href="https://github.com/fuze210699/milens">⭐ Star</a> ·
23
- <a href="https://github.com/sponsors/fuze210699">💖 Sponsor</a> ·
24
- <a href="https://github.com/fuze210699/milens/discussions">💬 Discussions</a> ·
25
- </p>
26
-
27
- ## The Problem
28
-
29
- **Burning cash** on AI with **digital amnesia**? Every **blind edit** is a **production bomb** you pay to defuse.
30
- **Milens** — *Your AI Butler*. Full codebase **memory**, instant **context**, **zero** repeated questions. It knows what's **fragile** before your agent **breaks** it.
31
-
32
- > **Stop burning cash. Stop burning prod.**
33
-
34
- ---
35
-
36
- ## What is Milens?
37
-
38
- A **free**, self-hosted **knowledge graph** for your codebase — and the **MCP toolkit** that lets your AI agent query it instantly.
39
-
40
- Instead of reading files blindly, your agent asks the graph.
41
- Instead of guessing side effects, it sees **exact blast radius** before editing.
42
- Instead of starting from zero, it **remembers** what you taught it last session.
43
-
44
- **12 languages.** One SQLite file. **43 MCP tools.** Zero API costs.
45
-
46
- > Parse locally. Query locally. Learn locally. **Forever free.**
47
-
48
- ---
49
-
50
- ## Supported Languages
51
-
52
- <p align="center">
53
- <img src="https://img.shields.io/badge/TypeScript-.ts%20.tsx-3178C6?logo=typescript&logoColor=white" alt="TS">
54
- <img src="https://img.shields.io/badge/JavaScript-.js%20.jsx-F7DF1E?logo=javascript&logoColor=black" alt="JS">
55
- <img src="https://img.shields.io/badge/Python-.py-3776AB?logo=python&logoColor=white" alt="PY">
56
- <img src="https://img.shields.io/badge/Java-.java-ED8B00?logo=openjdk&logoColor=white" alt="Java">
57
- <img src="https://img.shields.io/badge/Go-.go-00ADD8?logo=go&logoColor=white" alt="Go">
58
- <img src="https://img.shields.io/badge/Rust-.rs-000000?logo=rust&logoColor=white" alt="Rust">
59
- <img src="https://img.shields.io/badge/PHP-.php-777BB4?logo=php&logoColor=white" alt="PHP">
60
- <img src="https://img.shields.io/badge/Ruby-.rb%20.rake-CC342D?logo=ruby&logoColor=white" alt="Ruby">
61
- <img src="https://img.shields.io/badge/Vue-.vue-4FC08D?logo=vuedotjs&logoColor=white" alt="Vue">
62
- <img src="https://img.shields.io/badge/HTML-.html%20.htm-E34F26?logo=html5&logoColor=white" alt="HTML">
63
- <img src="https://img.shields.io/badge/CSS-.css-1572B6?logo=css3&logoColor=white" alt="CSS">
64
- <img src="https://img.shields.io/badge/Markdown-.md%20.mdx-000000?logo=markdown&logoColor=white" alt="MD">
65
- </p>
66
-
67
- ---
68
-
69
- ## Quick Start
70
-
71
- ```bash
72
- npm install -g milens
73
- cd your-project
74
- milens init --profile full --interactive
75
- ```
76
- One command. Your codebase becomes a queryable graph. AGENTS.md, skills, and hooks ready.
77
-
78
- Then connect your editor:
79
-
80
- ##### Visual Studio Code
81
-
82
- ```json
83
- .vscode/mcp.json
84
- {
85
- "servers": {
86
- "milens": {
87
- "type": "stdio",
88
- "command": "milens",
89
- "args": ["serve", "-p", "${workspaceFolder}"]
90
- }
91
- }
92
- }
93
- ```
94
-
95
- ##### Claude Code
96
-
97
- ```bash
98
- claude mcp add milens -- milens serve -p .
99
- ```
100
-
101
- Or drop this in `.mcp.json` at your project root (equivalent, works the same in the CLI, VS Code extension, and desktop app):
102
-
103
- ```json
104
- {
105
- "mcpServers": {
106
- "milens": {
107
- "type": "stdio",
108
- "command": "milens",
109
- "args": ["serve", "-p", "."]
110
- }
111
- }
112
- }
113
- ```
114
-
115
- Or install as a plugin from the marketplace:
116
-
117
- ```bash
118
- /plugin marketplace add fuze210699/milens
119
- /plugin install milens
120
- ```
121
-
122
- See [adapters/README.md](adapters/README.md#claude-code--via-plugin-install-marketplace) for how this avoids the workspace-root pitfall that broke earlier plugin builds.
123
-
124
- <details>
125
- <summary><b>More editors</b> — Cursor, OpenCode, Codex, Gemini, Zed</summary>
126
-
127
- ```bash
128
- # Cursor — .cursor/mcp.json
129
- { "mcpServers": { "milens": { "command": "milens", "args": ["serve", "-p", "${workspaceFolder}"] } } }
130
-
131
- # OpenCode — opencode.json
132
- { "mcp": { "milens": { "type": "local", "command": ["milens", "serve", "-p", "."] } } }
133
-
134
- # Codex — .codex/config.toml
135
- [mcp_servers.milens]
136
- command = "milens"
137
- args = ["serve", "-p", "."]
138
-
139
- # Gemini — .gemini/settings.json
140
- { "mcpServers": { "milens": { "command": "milens", "args": ["serve", "-p", "${workspaceFolder}"] } } }
141
-
142
- # Zed — .zed/settings.json
143
- { "context_servers": { "milens": { "command": "milens serve -p ." } } }
144
- ```
145
-
146
- </details>
147
-
148
-
149
- > Verify Milens appears in your IDE's MCP server list. Then ask your agent: milens status. Green light means your codebase is indexed. You're live.
150
-
151
- ---
152
-
153
- ## Why Milens
154
-
155
- | Capability | Without Milens | With Milens |
156
- |---|---|---|
157
- | **Understand a codebase** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
158
- | **Edit safely** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
159
- | **Find references** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
160
- | **Review PRs** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
161
- | **Uninstall cleanly** | ⭐ | ⭐⭐⭐⭐⭐ |
162
- | **Security audit** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
163
- | **Session memory** | ⭐ | ⭐⭐⭐⭐⭐ |
164
- | **Write tests** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
165
- | **Find dead code** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
166
-
167
- *And many more — see [real-world scenarios →](https://milens.vercel.app/scenarios.html)*
168
-
169
- ---
170
-
171
- ## Architecture
172
-
173
- | Layer | Technology | Output |
174
- |---|---|---|
175
- | **Ingestion** | Tree-sitter WASM | CST from 12 languages |
176
- | **Analysis** | Dual-path resolver | Symbols + verified links |
177
- | **Storage** | SQLite + FTS5 | Queryable knowledge graph |
178
- | **Interface** | MCP stdio / HTTP | 43 tools |
179
- | **Clients** | AI agents, CLI, editors | Context-aware actions |
180
- ---
181
-
182
- ## Key Features
183
-
184
- | Feature | Description |
185
- |---|---|
186
- | **Code Intelligence** | 43 MCP tools — search, impact, context, trace, routes |
187
- | **Security Scanner** | 190 rules across 9 categories + dependency audit |
188
- | **Sub-Agent Prompts** | 6 prompts — plan, review, tdd, security, architect, debugger |
189
- | **CLI Workflows** | 7 commands — tdd, review, plan, onboard, security-scan, refactor, handoff |
190
- | **Uninstall** | Full cleanup — 11 trace categories, interactive or auto |
191
- | **Metrics** | 7 metrics — TER, LR, CQI, BRR, TCGR, DCER, CTR |
192
- | **Learning Engine** | Annotate → Recall → Evolve — confidence-based annotations |
193
- | **12 Languages** | TS, JS, Python, Java, Go, Rust, PHP, Ruby, Vue, HTML, CSS, Markdown |
194
- | **Cross-Language Linking** | HTML class → CSS selectors, Vue template → script symbols |
195
- | **Type Bindings & MRO** | Infer types from constructors. C3, first-wins, ruby-mixin strategies |
196
- | **Accuracy Validation** | 8 test projects with expected.json for precision/recall |
197
- | **Symbol-Level PR Diff** | `review_pr` diffs actual symbols between commits, not entire files |
198
- | **7 Editor Adapters** | Claude Code, Cursor, Copilot, OpenCode, Codex, Gemini, Zed |
199
-
200
- ---
201
-
202
- ## Security & Privacy
203
-
204
- **Zero trust. Zero network. Zero leaks.**
205
-
206
- | | |
207
- |:---|:---|
208
- | 🔒 **Air-gapped** | Runs entirely offline. No outbound connections. No telemetry. |
209
- | 🏠 **Your code, your disk** | Index lives in `.milens/` per repo. Gitignored by default. Zero source code in registry. |
210
- | 🛡️ **Localhost-only** | MCP server binds `127.0.0.1` exclusively. External requests blocked. |
211
- | ⚡ **Safe execution** | `execFileSync` with argument arrays. No shell string interpolation. No path traversal. |
212
- | 🔍 **Offline audits** | Optional CVE check against local database. No API calls. |
213
- | 🔐 **Private embeddings** | Optional. Generated locally via Xenova transformers. No data leaves your machine. |
214
- | 🧱 **Input hardening** | ReDoS-safe regex. FTS5 tokens bound as SQLite literals. |
215
-
216
- Everything that touches your code stays on your filesystem. **Built for production. Trust nothing.**
217
-
218
-
219
- ---
220
-
221
- ## Pricing
222
-
223
- | | Free | Pro |
224
- |---|---|---|
225
- | **Cost** | $0 | $5/seat/month |
226
- | **43 MCP tools** | ✓ | ✓ |
227
- | **CLI + workflows** | ✓ | ✓ |
228
- | **Security scanner** | 190 rules | 190 rules + advanced |
229
- | **Private repos** | — | ✓ |
230
- | **PR auto-review** | — | ✓ Every PR |
231
- | **Push auto-index** | — | ✓ On push to main |
232
- | **Analyses/month** | 10 (public repos) | 50/seat (pooled) |
233
- | **Custom skill packs** | — | ✓ |
234
- | **Priority support** | — | ✓ Email + Slack |
235
-
236
- For solo devs: all 43 tools are free forever. For teams: the GitHub App automates review and security on every PR, saving ~$300/month in AI tokens for a team of 5. [Full pricing →](docs/pricing.md)
237
-
238
- ---
239
-
240
- ## CLI Commands
241
-
242
- ### Core
243
-
244
- | Command | Description |
245
- |---|---|
246
- | `init` | Bootstrap milens: index + AGENTS.md + skills + hooks |
247
- | `analyze` | Index a codebase: parse symbols, resolve dependencies, build search index |
248
- | `serve` | Start MCP server (stdio/HTTP) |
249
- | `watch` | Watch files for changes and auto re-index |
250
- | `status` | Show index status |
251
-
252
- ### Search & Inspect
253
-
254
- | Command | Description |
255
- |---|---|
256
- | `search <query>` | Search symbols by name |
257
- | `inspect <symbol>` | 360° view: refs, deps, hierarchy |
258
- | `impact <symbol>` | Blast radius: what breaks if this symbol changes? |
259
-
260
- ### Maintenance
261
-
262
- | Command | Description |
263
- |---|---|
264
- | `clean` | Remove index for a repository |
265
- | `uninstall` | Remove all milens traces: injected blocks, generated files, hooks, cron, database, registry, MCP configs, deps, env vars |
266
- | `upgrade` | Upgrade milens: clear npx cache, rebuild index while keeping annotations/sessions |
267
- | `list` | List all indexed repositories |
268
-
269
- ### Security
270
-
271
- | Command | Description |
272
- |---|---|
273
- | `security scan` | Scan project for vulnerabilities (190 rules, scope/severity filterable) |
274
- | `security deps` | Audit dependencies for known vulnerabilities |
275
-
276
- ### Quality & Evolution
277
-
278
- | Command | Description |
279
- |---|---|
280
- | `metrics` | Compute code quality and efficiency metrics |
281
- | `evolve` | Promote high-confidence annotations to rules/skills |
282
- | `orchestrate` | Full review cycle: detect changes → risk → coverage gaps → dead code |
283
-
284
- ### Workflows
285
-
286
- | Command | Description |
287
- |---|---|
288
- | `workflow tdd` | Test coverage gaps + risk-prioritized untested symbols |
289
- | `workflow review` | PR risk analysis — git diff + heat scoring |
290
- | `workflow plan` | Codebase summary — domains, top hubs |
291
- | `workflow onboard` | Onboarding report — structure, entry points |
292
- | `workflow security-scan` | Full security audit |
293
- | `workflow refactor` | Dead code detection + candidates |
294
- | `workflow handoff` | Session knowledge summary |
295
-
296
- ### Hooks
297
-
298
- | Command | Description |
299
- |---|---|
300
- | `hooks enable` | Turn on all hooks |
301
- | `hooks disable` | Turn off hooks |
302
- | `hooks profile <name>` | Apply hook presets (minimal, standard, full) |
303
-
304
- ### Dashboard
305
-
306
- | Command | Description |
307
- |---|---|
308
- | `dashboard` | Open usage analytics dashboard in browser |
309
-
310
- ---
311
-
312
- ## MCP Tools
313
-
314
- ### Search & Navigation
315
-
316
- | Tool | Description |
317
- |---|---|
318
- | `query` | Find symbol definitions by name (FTS5) |
319
- | `grep` | Text search across all files — code, templates, configs, docs |
320
- | `context` | 360° view: incoming refs + outgoing deps |
321
- | `get_file_symbols` | All symbols in a file |
322
- | `get_type_hierarchy` | Inheritance/implementation tree |
323
- | `semantic_search` | Hybrid FTS5 + vector search (requires `--embeddings`) |
324
- | `find_similar` | Find symbols topologically similar |
325
-
326
- ### Impact & Safety
327
-
328
- | Tool | Description |
329
- |---|---|
330
- | `impact` | Blast radius — what breaks if this symbol changes? |
331
- | `edit_check` | Pre-edit safety: callers, export status, re-export chains, warnings |
332
- | `overview` | Combined context + impact + grep in one call |
333
- | `detect_changes` | Git diff → affected symbols + dependents |
334
- | `find_dead_code` | Exported symbols with zero incoming references |
335
- | `pre_commit_check` | Pre-commit risk: review_pr + dead code + coverage gaps |
336
- | `compare_impact` | Compare impact graph before/after edit |
337
-
338
- ### Review & Testing
339
-
340
- | Tool | Description |
341
- |---|---|
342
- | `review_pr` | PR risk assessment: symbol-level diff via git show, cross-file impact |
343
- | `review_symbol` | Single symbol deep-dive: role, heat, dependents, test status, risk |
344
- | `codebase_summary` | Compact codebase overview: domains, top hubs, coverage |
345
- | `test_plan` | Dependency-aware test strategy: mocks, scenarios |
346
- | `test_generate` | Auto-generate test file with framework detection |
347
- | `test_coverage_gaps` | Untested exported symbols sorted by risk |
348
- | `test_impact` | Map code changes to which test files to run |
349
-
350
- ### Orchestration
351
-
352
- | Tool | Description |
353
- |---|---|
354
- | `orchestrate` | detect_changes → review_pr → impact → coverage gaps → dead code → action plan |
355
-
356
- ### Understanding
357
-
358
- | Tool | Description |
359
- |---|---|
360
- | `smart_context` | Intent-aware: understand/edit/debug/test |
361
- | `trace` | Execution flow: call chains from entrypoints to target |
362
- | `routes` | Detect framework routes/endpoints (Express, FastAPI, NestJS, etc.) |
363
- | `explain_relationship` | Shortest dependency path between two symbols |
364
- | `domains` | Domain clusters: files forming logical modules |
365
-
366
- ### Memory & Sessions
367
-
368
- | Tool | Description |
369
- |---|---|
370
- | `annotate` | Record a note about a symbol (persists across sessions) |
371
- | `recall` | Retrieve annotations from past sessions |
372
- | `session_start` | Register agent session for multi-agent coordination |
373
- | `session_end` | End session and record stats |
374
- | `session_context` | Get session metadata + annotations |
375
- | `handoff` | Transfer context between agent sessions |
376
-
377
- ### Security
378
-
379
- | Tool | Description |
380
- |---|---|
381
- | `security_scan` | Scan for vulnerabilities — 190 rules, 9 categories |
382
- | `fix_apply` | Apply security fix to a file (creates backup) |
383
-
384
- ### Hooks
385
-
386
- | Tool | Description |
387
- |---|---|
388
- | `hook_onFileChange` | Trigger when files are modified → impact summary |
389
- | `hook_preCompact` | Save metrics snapshot before context compaction |
390
- | `hook_postCompact` | Restore context by recalling annotations after compaction |
391
-
392
- ### Codebase Overview
393
-
394
- | Tool | Description |
395
- |---|---|
396
- | `status` | Index stats: symbols, links, files, coverage, staleness |
397
- | `repos` | List all indexed repositories with summary stats |
398
-
399
- ### Developer
400
-
401
- | Tool | Description |
402
- |---|---|
403
- | `ast_explore` | Parse code snippet to S-expression AST tree |
404
- | `test_query` | Run tree-sitter query against code snippet |
405
-
406
- ---
407
-
408
- ## Editor Adapters
409
-
410
- Milens works with any MCP-compatible agent:
411
-
412
- | Harness | Config File | Recommended Profile |
413
- |---|---|---|
414
- | **Claude Code** | `.claude/mcp.json` | standard |
415
- | **OpenCode** | `.opencode/config.json` | standard |
416
- | **VS Code / Copilot** | `.vscode/mcp.json` | standard |
417
- | **Cursor** | `.cursorrules` | standard |
418
- | **Codex** | `.codex/codex.md` | standard |
419
- | **Gemini** | `.gemini/context.md` | minimal (10 tools) |
420
- | **Zed** | `.zed/settings.json` | minimal |
421
-
422
- Each adapter is in the `adapters/` directory with ready-to-copy config files and agent instructions.
423
-
424
- ### Profile Selection
425
-
426
- ```bash
427
- MILENS_PROFILE=minimal milens serve # 10 tools — lighter footprint
428
- MILENS_PROFILE=standard milens serve # 25 tools — full daily coding
429
- milens serve --profile full # 43 tools — everything
430
- ```
431
-
432
- ---
433
-
434
- ## 🔒 Security Scanner
435
-
436
- > **190+ rules. 25 categories. One call.**
437
-
438
- Replace ten manual greps with a single `security_scan()`. OWASP Top 10 mapped. Offline. Zero API calls.
439
-
440
- | Category | Rules | Detects |
441
- |:---:|:---:|:---|
442
- | 🔑 **Secrets** | 70+ | AWS keys, GitHub tokens, JWT secrets, private keys, cloud credentials |
443
- | 💉 **Injection** | 26 | SQLi, NoSQLi, XSS, SSTI, LDAP, XPath, CRLF, GraphQL |
444
- | 🧨 **RCE** | 6 | `eval()`, `exec()`, `child_process`, PowerShell, dynamic class loading |
445
- | 🧬 **Deserialization** | 9 | `pickle`, `yaml.load`, Java `readObject`, PHP `unserialize` |
446
- | 🌐 **SSRF** | 4 | User-controlled URL fetch, file/gopher protocols, cloud metadata |
447
- | 📁 **File Access** | 6 | Path traversal, `fs.readFile` with user input, unrestricted upload |
448
- | 🔐 **Auth** | 12 | Missing middleware, JWT none alg, IDOR, mass assignment, session fixation |
449
- | 🛡️ **Crypto** | 15 | MD5, SHA1, DES, ECB, weak RSA, custom crypto, `Math.random()` for tokens |
450
- | ⚙️ **Config** | 5 | CORS wildcard, insecure cookies, debug mode in production |
451
- | 📤 **Data Leaks** | 5 | `console.log(password)`, hardcoded URLs with credentials |
452
- | 🔤 **Unicode** | 4 | Bidi override, zero-width chars, homoglyph attacks |
453
- | 🐳 **IaC** | 3+ | Dockerfile secrets, K8s hardcoded creds, Terraform exposed keys |
454
-
455
- **Dependency audit included:**
456
- ```bash
457
- milens security scan # Full audit, 190+ rules
458
- milens security scan --scope secrets --severity HIGH
459
- milens security deps # Offline CVE check: npm, Python, Rust, Go, Java
460
- ```
461
-
462
- From an AI agent: `security_scan({scope: "all", severity: "HIGH"})`
463
-
464
- ---
465
-
466
- ## Sub-Agent Prompts
467
-
468
- | Prompt | Purpose |
469
- |---|---|
470
- | `milens-planner` | Implementation planning with blast radius + test strategy |
471
- | `milens-reviewer` | PR review — risk scan → deep dive → dead code → security |
472
- | `milens-tester` | TDD — coverage gaps → test plans → implement → verify |
473
- | `milens-security` | Security audit — secrets, injection, unicode, crypto, config |
474
- | `milens-architect` | Architecture analysis — domains, routes, coupling, hierarchy |
475
- | `milens-debugger` | Root cause analysis — trace → blast radius → hypotheses → fixes |
476
- | `dead_code_remove` | Safe dead code removal with impact verification |
477
-
478
- ---
479
-
480
- ## Metrics
481
-
482
- Seven quantified metrics for AI-driven development:
483
-
484
- | Metric | Full Name | What It Tracks |
485
- |---|---|---|
486
- | **TER** | Token Efficiency Ratio | Useful tokens ÷ total tokens |
487
- | **LR** | Learning Rate | Savings gained ÷ savings possible |
488
- | **CQI** | Code Quality Index | Coverage + security + coupling + docs |
489
- | **BRR** | Bug Recurrence Rate | Bugs repeated ÷ total fixed |
490
- | **TCGR** | Test Coverage Growth Rate | Weekly coverage improvement |
491
- | **DCER** | Dead Code Elimination Rate | Dead symbols ÷ total exported |
492
- | **CTR** | Cycle Time Reduction | Time saved vs manual approach |
493
-
494
- ```bash
495
- milens metrics
496
- ```
497
-
498
- ---
499
-
500
- ## Learning & Evolution
501
-
502
- The system gets smarter every session:
503
-
504
- ```
505
- SESSION 1: Agent finds bug in createUser()
506
- → annotate({symbol: "createUser", key: "bug", value: "Call createUser() before normalizeEmail()"})
507
- → confidence: 0.5
508
-
509
- SESSION 2: Agent auto-recalls the annotation
510
- → "I know createUser() has a known issue. I'll handle the order correctly."
511
- → Bug avoided. confidence ↑ 0.7
512
-
513
- SESSION 5: Confidence reaches 0.9
514
- → milens evolve promotes it to .agents/skills/milens-bug/SKILL.md
515
- → Now enforced as a rule for every future session
516
- ```
517
-
518
- ---
519
-
520
- ## Hook System (6 Triggers)
521
-
522
- | Hook | When | Default Action |
523
- |---|---|---|
524
- | `onSessionStart` | Agent begins work | Refresh index + codebase_summary + recall past warnings |
525
- | `onSessionEnd` | Agent finishes | detect_changes + review_pr + auto-annotate changed symbols |
526
- | `onPreCommit` | Before `git commit` | detect_changes + review_pr + find_dead_code |
527
- | `onFileChange` | Files modified | Re-analyze changed files + impact on affected symbols |
528
- | `onPreCompact` | Before context window compaction | Save codebase_summary snapshot |
529
- | `onPostCompact` | After compaction | recall annotations to restore lost context |
530
-
531
- ```bash
532
- milens hooks enable # Turn on all hooks
533
- milens hooks profile standard # Preset: SessionStart, SessionEnd, PreCommit
534
- milens hooks disable --hook preCommit # Turn off one hook
535
- ```
536
-
537
- ---
538
-
539
- ## Contributing
540
-
541
- | Type | How | Where |
542
- |---|---|---|
543
- | **Skill files** | Create reusable agent workflows | `.agents/skills/` |
544
- | **Security rules** | Add new vulnerability patterns | `src/security/rules.ts` |
545
- | **Adapter packs** | Connect milens to new harnesses | `adapters/` |
546
- | **Core features** | Improve tools, parser, analyzer | `src/` |
547
- | **Documentation** | Fix docs, add examples | `docs/` |
548
- | **Bug reports** | Report issues with reproduction | [Issues](https://github.com/fuze210699/milens/issues) |
549
-
550
- ```bash
551
- git clone https://github.com/fuze210699/milens.git
552
- cd milens
553
- npm install && npm run build && npm test
554
- ```
555
-
556
- See [CONTRIBUTING.md](CONTRIBUTING.md) for full details — skill format, security rule format, PR process, and code of conduct.
557
-
558
- ---
559
-
560
- ## License
561
-
562
- Core (analyzer, parser, store, CLI, MCP tools): **MIT License**
563
- See [LICENSE](LICENSE) for details.
564
-
565
- ---
566
-
567
- <p align="center">
568
- <a href="https://github.com/fuze210699/milens">GitHub</a> ·
569
- <a href="https://github.com/fuze210699/milens/tree/main/docs">Docs</a> ·
570
- <a href="https://github.com/fuze210699/milens/blob/main/docs/cli.md">CLI</a> ·
571
- <a href="https://github.com/fuze210699/milens/blob/main/docs/accuracy.md">Accuracy</a> ·
572
- <a href="https://github.com/fuze210699/milens/blob/main/docs/languages.md">Languages</a> ·
573
- <a href="https://github.com/fuze210699/milens/blob/main/docs/pricing.md">Pricing</a> ·
574
- <a href="https://github.com/fuze210699/milens/blob/main/CONTRIBUTING.md">Contribute</a> ·
575
- <a href="https://github.com/fuze210699/milens/blob/main/CHANGELOG.md">Changelog</a> ·
576
- <a href="https://github.com/fuze210699/milens/blob/main/SECURITY.md">Security</a>
577
- </p>
1
+ <p align="center">
2
+ <strong>Milens</strong><br>
3
+ <em>Your AI butler</em>
4
+ </p>
5
+
6
+ <p align="center">
7
+ <a href="https://www.npmjs.com/package/milens"><img src="https://img.shields.io/npm/v/milens" alt="npm"></a>
8
+ <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node"></a>
9
+ <a href="https://github.com/fuze210699/milens/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license"></a>
10
+ <img src="https://img.shields.io/badge/tools-43-purple" alt="43 tools">
11
+ <img src="https://img.shields.io/badge/languages-12-blue" alt="12 languages">
12
+ <img src="https://img.shields.io/badge/prompts-6-orange" alt="6 prompts">
13
+ <img src="https://img.shields.io/badge/security-190%2B-red" alt="190+ rules">
14
+ <img src="https://img.shields.io/badge/harnesses-7-lightgrey" alt="7 harnesses">
15
+ <a href="https://github.com/fuze210699/milens/actions/workflows/milens-ci-test.yml"><img src="https://github.com/fuze210699/milens/actions/workflows/milens-ci-test.yml/badge.svg" alt="CI"></a>
16
+ <img src="https://img.shields.io/npm/dm/milens" alt="npm downloads">
17
+ <img src="https://img.shields.io/npm/dt/milens" alt="npm total">
18
+
19
+ </p>
20
+
21
+ <p align="center">
22
+ <a href="https://github.com/fuze210699/milens">⭐ Star</a> ·
23
+ <a href="https://github.com/sponsors/fuze210699">💖 Sponsor</a> ·
24
+ <a href="https://github.com/fuze210699/milens/discussions">💬 Discussions</a> ·
25
+ </p>
26
+
27
+ ## The Problem
28
+
29
+ **Burning cash** on AI with **digital amnesia**? Every **blind edit** is a **production bomb** you pay to defuse.
30
+ **Milens** — *Your AI Butler*. Full codebase **memory**, instant **context**, **zero** repeated questions. It knows what's **fragile** before your agent **breaks** it.
31
+
32
+ > **Stop burning cash. Stop burning prod.**
33
+
34
+ ---
35
+
36
+ ## What is Milens?
37
+
38
+ A **free**, self-hosted **knowledge graph** for your codebase — and the **MCP toolkit** that lets your AI agent query it instantly.
39
+
40
+ Instead of reading files blindly, your agent asks the graph.
41
+ Instead of guessing side effects, it sees **exact blast radius** before editing.
42
+ Instead of starting from zero, it **remembers** what you taught it last session.
43
+
44
+ **12 languages.** One SQLite file. **43 MCP tools.** Zero API costs.
45
+
46
+ > Parse locally. Query locally. Learn locally. **Forever free.**
47
+
48
+ ---
49
+
50
+ ## Supported Languages
51
+
52
+ <p align="center">
53
+ <img src="https://img.shields.io/badge/TypeScript-.ts%20.tsx-3178C6?logo=typescript&logoColor=white" alt="TS">
54
+ <img src="https://img.shields.io/badge/JavaScript-.js%20.jsx-F7DF1E?logo=javascript&logoColor=black" alt="JS">
55
+ <img src="https://img.shields.io/badge/Python-.py-3776AB?logo=python&logoColor=white" alt="PY">
56
+ <img src="https://img.shields.io/badge/Java-.java-ED8B00?logo=openjdk&logoColor=white" alt="Java">
57
+ <img src="https://img.shields.io/badge/Go-.go-00ADD8?logo=go&logoColor=white" alt="Go">
58
+ <img src="https://img.shields.io/badge/Rust-.rs-000000?logo=rust&logoColor=white" alt="Rust">
59
+ <img src="https://img.shields.io/badge/PHP-.php-777BB4?logo=php&logoColor=white" alt="PHP">
60
+ <img src="https://img.shields.io/badge/Ruby-.rb%20.rake-CC342D?logo=ruby&logoColor=white" alt="Ruby">
61
+ <img src="https://img.shields.io/badge/Vue-.vue-4FC08D?logo=vuedotjs&logoColor=white" alt="Vue">
62
+ <img src="https://img.shields.io/badge/HTML-.html%20.htm-E34F26?logo=html5&logoColor=white" alt="HTML">
63
+ <img src="https://img.shields.io/badge/CSS-.css-1572B6?logo=css3&logoColor=white" alt="CSS">
64
+ <img src="https://img.shields.io/badge/Markdown-.md%20.mdx-000000?logo=markdown&logoColor=white" alt="MD">
65
+ </p>
66
+
67
+ ---
68
+
69
+ ## Quick Start
70
+
71
+ ```bash
72
+ npm install -g milens
73
+ cd your-project
74
+ milens init --profile full --interactive
75
+ ```
76
+ One command. Your codebase becomes a queryable graph. AGENTS.md, skills, and hooks ready.
77
+
78
+ Then connect your editor:
79
+
80
+ ##### Visual Studio Code
81
+
82
+ ```json
83
+ .vscode/mcp.json
84
+ {
85
+ "servers": {
86
+ "milens": {
87
+ "type": "stdio",
88
+ "command": "milens",
89
+ "args": ["serve", "-p", "${workspaceFolder}"]
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ##### Claude Code
96
+
97
+ ```bash
98
+ claude mcp add milens -- milens serve -p .
99
+ ```
100
+
101
+ Or drop this in `.mcp.json` at your project root (equivalent, works the same in the CLI, VS Code extension, and desktop app):
102
+
103
+ ```json
104
+ {
105
+ "mcpServers": {
106
+ "milens": {
107
+ "type": "stdio",
108
+ "command": "milens",
109
+ "args": ["serve", "-p", "."]
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ Or install as a plugin from the marketplace:
116
+
117
+ ```bash
118
+ /plugin marketplace add fuze210699/milens
119
+ /plugin install milens
120
+ ```
121
+
122
+ See [adapters/README.md](adapters/README.md#claude-code--via-plugin-install-marketplace) for how this avoids the workspace-root pitfall that broke earlier plugin builds.
123
+
124
+ <details>
125
+ <summary><b>More editors</b> — Cursor, OpenCode, Codex, Gemini, Zed</summary>
126
+
127
+ ```bash
128
+ # Cursor — .cursor/mcp.json
129
+ { "mcpServers": { "milens": { "command": "milens", "args": ["serve", "-p", "${workspaceFolder}"] } } }
130
+
131
+ # OpenCode — opencode.json
132
+ { "mcp": { "milens": { "type": "local", "command": ["milens", "serve", "-p", "."] } } }
133
+
134
+ # Codex — .codex/config.toml
135
+ [mcp_servers.milens]
136
+ command = "milens"
137
+ args = ["serve", "-p", "."]
138
+
139
+ # Gemini — .gemini/settings.json
140
+ { "mcpServers": { "milens": { "command": "milens", "args": ["serve", "-p", "${workspaceFolder}"] } } }
141
+
142
+ # Zed — .zed/settings.json
143
+ { "context_servers": { "milens": { "command": "milens serve -p ." } } }
144
+ ```
145
+
146
+ </details>
147
+
148
+
149
+ > Verify Milens appears in your IDE's MCP server list. Then ask your agent: milens status. Green light means your codebase is indexed. You're live.
150
+
151
+ ---
152
+
153
+ ## Why Milens
154
+
155
+ | Capability | Without Milens | With Milens |
156
+ |---|---|---|
157
+ | **Understand a codebase** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
158
+ | **Edit safely** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
159
+ | **Find references** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
160
+ | **Review PRs** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
161
+ | **Uninstall cleanly** | ⭐ | ⭐⭐⭐⭐⭐ |
162
+ | **Security audit** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
163
+ | **Session memory** | ⭐ | ⭐⭐⭐⭐⭐ |
164
+ | **Write tests** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
165
+ | **Find dead code** | ⭐⭐ | ⭐⭐⭐⭐⭐ |
166
+
167
+ *And many more — see [real-world scenarios →](https://milens.vercel.app/scenarios.html)*
168
+
169
+ ---
170
+
171
+ ## Architecture
172
+
173
+ | Layer | Technology | Output |
174
+ |---|---|---|
175
+ | **Ingestion** | Tree-sitter WASM | CST from 12 languages |
176
+ | **Analysis** | Dual-path resolver | Symbols + verified links |
177
+ | **Storage** | SQLite + FTS5 | Queryable knowledge graph |
178
+ | **Interface** | MCP stdio / HTTP | 43 tools |
179
+ | **Clients** | AI agents, CLI, editors | Context-aware actions |
180
+ ---
181
+
182
+ ## Key Features
183
+
184
+ | Feature | Description |
185
+ |---|---|
186
+ | **Code Intelligence** | 43 MCP tools — search, impact, context, trace, routes |
187
+ | **Security Scanner** | 190 rules across 9 categories + dependency audit |
188
+ | **Sub-Agent Prompts** | 6 prompts — plan, review, tdd, security, architect, debugger |
189
+ | **CLI Workflows** | 7 commands — tdd, review, plan, onboard, security-scan, refactor, handoff |
190
+ | **Uninstall** | Full cleanup — 11 trace categories, interactive or auto |
191
+ | **Metrics** | 7 metrics — TER, LR, CQI, BRR, TCGR, DCER, CTR |
192
+ | **Learning Engine** | Annotate → Recall → Evolve — confidence-based annotations |
193
+ | **12 Languages** | TS, JS, Python, Java, Go, Rust, PHP, Ruby, Vue, HTML, CSS, Markdown |
194
+ | **Cross-Language Linking** | HTML class → CSS selectors, Vue template → script symbols |
195
+ | **Type Bindings & MRO** | Infer types from constructors. C3, first-wins, ruby-mixin strategies |
196
+ | **Accuracy Validation** | 8 test projects with expected.json for precision/recall |
197
+ | **Symbol-Level PR Diff** | `review_pr` diffs actual symbols between commits, not entire files |
198
+ | **7 Editor Adapters** | Claude Code, Cursor, Copilot, OpenCode, Codex, Gemini, Zed |
199
+
200
+ ---
201
+
202
+ ## Security & Privacy
203
+
204
+ **Zero trust. Zero network. Zero leaks.**
205
+
206
+ | | |
207
+ |:---|:---|
208
+ | 🔒 **Air-gapped** | Runs entirely offline. No outbound connections. No telemetry. |
209
+ | 🏠 **Your code, your disk** | Index lives in `.milens/` per repo. Gitignored by default. Zero source code in registry. |
210
+ | 🛡️ **Localhost-only** | MCP server binds `127.0.0.1` exclusively. External requests blocked. |
211
+ | ⚡ **Safe execution** | `execFileSync` with argument arrays. No shell string interpolation. No path traversal. |
212
+ | 🔍 **Offline audits** | Optional CVE check against local database. No API calls. |
213
+ | 🔐 **Private embeddings** | Optional. Generated locally via Xenova transformers. No data leaves your machine. |
214
+ | 🧱 **Input hardening** | ReDoS-safe regex. FTS5 tokens bound as SQLite literals. |
215
+
216
+ Everything that touches your code stays on your filesystem. **Built for production. Trust nothing.**
217
+
218
+
219
+ ---
220
+
221
+ ## Pricing
222
+
223
+ | | Free | Pro |
224
+ |---|---|---|
225
+ | **Cost** | $0 | $5/seat/month |
226
+ | **43 MCP tools** | ✓ | ✓ |
227
+ | **CLI + workflows** | ✓ | ✓ |
228
+ | **Security scanner** | 190 rules | 190 rules + advanced |
229
+ | **Private repos** | — | ✓ |
230
+ | **PR auto-review** | — | ✓ Every PR |
231
+ | **Push auto-index** | — | ✓ On push to main |
232
+ | **Analyses/month** | 10 (public repos) | 50/seat (pooled) |
233
+ | **Custom skill packs** | — | ✓ |
234
+ | **Priority support** | — | ✓ Email + Slack |
235
+
236
+ For solo devs: all 43 tools are free forever. For teams: the GitHub App automates review and security on every PR, saving ~$300/month in AI tokens for a team of 5. [Full pricing →](docs/pricing.md)
237
+
238
+ ---
239
+
240
+ ## CLI Commands
241
+
242
+ ### Core
243
+
244
+ | Command | Description |
245
+ |---|---|
246
+ | `init` | Bootstrap milens: index + AGENTS.md + skills + hooks |
247
+ | `analyze` | Index a codebase: parse symbols, resolve dependencies, build search index |
248
+ | `serve` | Start MCP server (stdio/HTTP) |
249
+ | `watch` | Watch files for changes and auto re-index |
250
+ | `status` | Show index status |
251
+
252
+ ### Search & Inspect
253
+
254
+ | Command | Description |
255
+ |---|---|
256
+ | `search <query>` | Search symbols by name |
257
+ | `inspect <symbol>` | 360° view: refs, deps, hierarchy |
258
+ | `impact <symbol>` | Blast radius: what breaks if this symbol changes? |
259
+
260
+ ### Maintenance
261
+
262
+ | Command | Description |
263
+ |---|---|
264
+ | `clean` | Remove index for a repository |
265
+ | `uninstall` | Remove all milens traces: injected blocks, generated files, hooks, cron, database, registry, MCP configs, deps, env vars |
266
+ | `upgrade` | Upgrade milens: clear npx cache, rebuild index while keeping annotations/sessions |
267
+ | `list` | List all indexed repositories |
268
+
269
+ ### Security
270
+
271
+ | Command | Description |
272
+ |---|---|
273
+ | `security scan` | Scan project for vulnerabilities (190 rules, scope/severity filterable) |
274
+ | `security deps` | Audit dependencies for known vulnerabilities |
275
+
276
+ ### Quality & Evolution
277
+
278
+ | Command | Description |
279
+ |---|---|
280
+ | `metrics` | Compute code quality and efficiency metrics |
281
+ | `evolve` | Promote high-confidence annotations to rules/skills |
282
+ | `orchestrate` | Full review cycle: detect changes → risk → coverage gaps → dead code |
283
+
284
+ ### Workflows
285
+
286
+ | Command | Description |
287
+ |---|---|
288
+ | `workflow tdd` | Test coverage gaps + risk-prioritized untested symbols |
289
+ | `workflow review` | PR risk analysis — git diff + heat scoring |
290
+ | `workflow plan` | Codebase summary — domains, top hubs |
291
+ | `workflow onboard` | Onboarding report — structure, entry points |
292
+ | `workflow security-scan` | Full security audit |
293
+ | `workflow refactor` | Dead code detection + candidates |
294
+ | `workflow handoff` | Session knowledge summary |
295
+
296
+ ### Hooks
297
+
298
+ | Command | Description |
299
+ |---|---|
300
+ | `hooks enable` | Turn on all hooks |
301
+ | `hooks disable` | Turn off hooks |
302
+ | `hooks profile <name>` | Apply hook presets (minimal, standard, full) |
303
+
304
+ ### Dashboard
305
+
306
+ | Command | Description |
307
+ |---|---|
308
+ | `dashboard` | Open usage analytics dashboard in browser |
309
+
310
+ ---
311
+
312
+ ## MCP Tools
313
+
314
+ ### Search & Navigation
315
+
316
+ | Tool | Description |
317
+ |---|---|
318
+ | `query` | Find symbol definitions by name (FTS5) |
319
+ | `grep` | Text search across all files — code, templates, configs, docs |
320
+ | `context` | 360° view: incoming refs + outgoing deps |
321
+ | `get_file_symbols` | All symbols in a file |
322
+ | `get_type_hierarchy` | Inheritance/implementation tree |
323
+ | `semantic_search` | Hybrid FTS5 + vector search (requires `--embeddings`) |
324
+ | `find_similar` | Find symbols topologically similar |
325
+
326
+ ### Impact & Safety
327
+
328
+ | Tool | Description |
329
+ |---|---|
330
+ | `impact` | Blast radius — what breaks if this symbol changes? |
331
+ | `edit_check` | Pre-edit safety: callers, export status, re-export chains, warnings |
332
+ | `overview` | Combined context + impact + grep in one call |
333
+ | `detect_changes` | Git diff → affected symbols + dependents |
334
+ | `find_dead_code` | Exported symbols with zero incoming references |
335
+ | `pre_commit_check` | Pre-commit risk: review_pr + dead code + coverage gaps |
336
+ | `compare_impact` | Compare impact graph before/after edit |
337
+
338
+ ### Review & Testing
339
+
340
+ | Tool | Description |
341
+ |---|---|
342
+ | `review_pr` | PR risk assessment: symbol-level diff via git show, cross-file impact |
343
+ | `review_symbol` | Single symbol deep-dive: role, heat, dependents, test status, risk |
344
+ | `codebase_summary` | Compact codebase overview: domains, top hubs, coverage |
345
+ | `test_plan` | Dependency-aware test strategy: mocks, scenarios |
346
+ | `test_generate` | Auto-generate test file with framework detection |
347
+ | `test_coverage_gaps` | Untested exported symbols sorted by risk |
348
+ | `test_impact` | Map code changes to which test files to run |
349
+
350
+ ### Orchestration
351
+
352
+ | Tool | Description |
353
+ |---|---|
354
+ | `orchestrate` | detect_changes → review_pr → impact → coverage gaps → dead code → action plan |
355
+
356
+ ### Understanding
357
+
358
+ | Tool | Description |
359
+ |---|---|
360
+ | `smart_context` | Intent-aware: understand/edit/debug/test |
361
+ | `trace` | Execution flow: call chains from entrypoints to target |
362
+ | `routes` | Detect framework routes/endpoints (Express, FastAPI, NestJS, etc.) |
363
+ | `explain_relationship` | Shortest dependency path between two symbols |
364
+ | `domains` | Domain clusters: files forming logical modules |
365
+
366
+ ### Memory & Sessions
367
+
368
+ | Tool | Description |
369
+ |---|---|
370
+ | `annotate` | Record a note about a symbol (persists across sessions) |
371
+ | `recall` | Retrieve annotations from past sessions |
372
+ | `session_start` | Register agent session for multi-agent coordination |
373
+ | `session_end` | End session and record stats |
374
+ | `session_context` | Get session metadata + annotations |
375
+ | `handoff` | Transfer context between agent sessions |
376
+
377
+ ### Security
378
+
379
+ | Tool | Description |
380
+ |---|---|
381
+ | `security_scan` | Scan for vulnerabilities — 190 rules, 9 categories |
382
+ | `fix_apply` | Apply security fix to a file (creates backup) |
383
+
384
+ ### Hooks
385
+
386
+ | Tool | Description |
387
+ |---|---|
388
+ | `hook_onFileChange` | Trigger when files are modified → impact summary |
389
+ | `hook_preCompact` | Save metrics snapshot before context compaction |
390
+ | `hook_postCompact` | Restore context by recalling annotations after compaction |
391
+
392
+ ### Codebase Overview
393
+
394
+ | Tool | Description |
395
+ |---|---|
396
+ | `status` | Index stats: symbols, links, files, coverage, staleness |
397
+ | `repos` | List all indexed repositories with summary stats |
398
+
399
+ ### Developer
400
+
401
+ | Tool | Description |
402
+ |---|---|
403
+ | `ast_explore` | Parse code snippet to S-expression AST tree |
404
+ | `test_query` | Run tree-sitter query against code snippet |
405
+
406
+ ---
407
+
408
+ ## Editor Adapters
409
+
410
+ Milens works with any MCP-compatible agent:
411
+
412
+ | Harness | Config File | Recommended Profile |
413
+ |---|---|---|
414
+ | **Claude Code** | `.claude/mcp.json` | standard |
415
+ | **OpenCode** | `.opencode/config.json` | standard |
416
+ | **VS Code / Copilot** | `.vscode/mcp.json` | standard |
417
+ | **Cursor** | `.cursorrules` | standard |
418
+ | **Codex** | `.codex/codex.md` | standard |
419
+ | **Gemini** | `.gemini/context.md` | minimal (10 tools) |
420
+ | **Zed** | `.zed/settings.json` | minimal |
421
+
422
+ Each adapter is in the `adapters/` directory with ready-to-copy config files and agent instructions.
423
+
424
+ ### Profile Selection
425
+
426
+ ```bash
427
+ MILENS_PROFILE=minimal milens serve # 10 tools — lighter footprint
428
+ MILENS_PROFILE=standard milens serve # 25 tools — full daily coding
429
+ milens serve --profile full # 43 tools — everything
430
+ ```
431
+
432
+ ---
433
+
434
+ ## 🔒 Security Scanner
435
+
436
+ > **190+ rules. 25 categories. One call.**
437
+
438
+ Replace ten manual greps with a single `security_scan()`. OWASP Top 10 mapped. Offline. Zero API calls.
439
+
440
+ | Category | Rules | Detects |
441
+ |:---:|:---:|:---|
442
+ | 🔑 **Secrets** | 70+ | AWS keys, GitHub tokens, JWT secrets, private keys, cloud credentials |
443
+ | 💉 **Injection** | 26 | SQLi, NoSQLi, XSS, SSTI, LDAP, XPath, CRLF, GraphQL |
444
+ | 🧨 **RCE** | 6 | `eval()`, `exec()`, `child_process`, PowerShell, dynamic class loading |
445
+ | 🧬 **Deserialization** | 9 | `pickle`, `yaml.load`, Java `readObject`, PHP `unserialize` |
446
+ | 🌐 **SSRF** | 4 | User-controlled URL fetch, file/gopher protocols, cloud metadata |
447
+ | 📁 **File Access** | 6 | Path traversal, `fs.readFile` with user input, unrestricted upload |
448
+ | 🔐 **Auth** | 12 | Missing middleware, JWT none alg, IDOR, mass assignment, session fixation |
449
+ | 🛡️ **Crypto** | 15 | MD5, SHA1, DES, ECB, weak RSA, custom crypto, `Math.random()` for tokens |
450
+ | ⚙️ **Config** | 5 | CORS wildcard, insecure cookies, debug mode in production |
451
+ | 📤 **Data Leaks** | 5 | `console.log(password)`, hardcoded URLs with credentials |
452
+ | 🔤 **Unicode** | 4 | Bidi override, zero-width chars, homoglyph attacks |
453
+ | 🐳 **IaC** | 3+ | Dockerfile secrets, K8s hardcoded creds, Terraform exposed keys |
454
+
455
+ **Dependency audit included:**
456
+ ```bash
457
+ milens security scan # Full audit, 190+ rules
458
+ milens security scan --scope secrets --severity HIGH
459
+ milens security deps # Offline CVE check: npm, Python, Rust, Go, Java
460
+ ```
461
+
462
+ From an AI agent: `security_scan({scope: "all", severity: "HIGH"})`
463
+
464
+ ---
465
+
466
+ ## Sub-Agent Prompts
467
+
468
+ | Prompt | Purpose |
469
+ |---|---|
470
+ | `milens-planner` | Implementation planning with blast radius + test strategy |
471
+ | `milens-reviewer` | PR review — risk scan → deep dive → dead code → security |
472
+ | `milens-tester` | TDD — coverage gaps → test plans → implement → verify |
473
+ | `milens-security` | Security audit — secrets, injection, unicode, crypto, config |
474
+ | `milens-architect` | Architecture analysis — domains, routes, coupling, hierarchy |
475
+ | `milens-debugger` | Root cause analysis — trace → blast radius → hypotheses → fixes |
476
+ | `dead_code_remove` | Safe dead code removal with impact verification |
477
+
478
+ ---
479
+
480
+ ## Metrics
481
+
482
+ Seven quantified metrics for AI-driven development:
483
+
484
+ | Metric | Full Name | What It Tracks |
485
+ |---|---|---|
486
+ | **TER** | Token Efficiency Ratio | Useful tokens ÷ total tokens |
487
+ | **LR** | Learning Rate | Savings gained ÷ savings possible |
488
+ | **CQI** | Code Quality Index | Coverage + security + coupling + docs |
489
+ | **BRR** | Bug Recurrence Rate | Bugs repeated ÷ total fixed |
490
+ | **TCGR** | Test Coverage Growth Rate | Weekly coverage improvement |
491
+ | **DCER** | Dead Code Elimination Rate | Dead symbols ÷ total exported |
492
+ | **CTR** | Cycle Time Reduction | Time saved vs manual approach |
493
+
494
+ ```bash
495
+ milens metrics
496
+ ```
497
+
498
+ ---
499
+
500
+ ## Learning & Evolution
501
+
502
+ The system gets smarter every session:
503
+
504
+ ```
505
+ SESSION 1: Agent finds bug in createUser()
506
+ → annotate({symbol: "createUser", key: "bug", value: "Call createUser() before normalizeEmail()"})
507
+ → confidence: 0.5
508
+
509
+ SESSION 2: Agent auto-recalls the annotation
510
+ → "I know createUser() has a known issue. I'll handle the order correctly."
511
+ → Bug avoided. confidence ↑ 0.7
512
+
513
+ SESSION 5: Confidence reaches 0.9
514
+ → milens evolve promotes it to .agents/skills/milens-bug/SKILL.md
515
+ → Now enforced as a rule for every future session
516
+ ```
517
+
518
+ ---
519
+
520
+ ## Hook System (6 Triggers)
521
+
522
+ | Hook | When | Default Action |
523
+ |---|---|---|
524
+ | `onSessionStart` | Agent begins work | Refresh index + codebase_summary + recall past warnings |
525
+ | `onSessionEnd` | Agent finishes | detect_changes + review_pr + auto-annotate changed symbols |
526
+ | `onPreCommit` | Before `git commit` | detect_changes + review_pr + find_dead_code |
527
+ | `onFileChange` | Files modified | Re-analyze changed files + impact on affected symbols |
528
+ | `onPreCompact` | Before context window compaction | Save codebase_summary snapshot |
529
+ | `onPostCompact` | After compaction | recall annotations to restore lost context |
530
+
531
+ ```bash
532
+ milens hooks enable # Turn on all hooks
533
+ milens hooks profile standard # Preset: SessionStart, SessionEnd, PreCommit
534
+ milens hooks disable --hook preCommit # Turn off one hook
535
+ ```
536
+
537
+ ---
538
+
539
+ ## Contributing
540
+
541
+ | Type | How | Where |
542
+ |---|---|---|
543
+ | **Skill files** | Create reusable agent workflows | `.agents/skills/` |
544
+ | **Security rules** | Add new vulnerability patterns | `src/security/rules.ts` |
545
+ | **Adapter packs** | Connect milens to new harnesses | `adapters/` |
546
+ | **Core features** | Improve tools, parser, analyzer | `src/` |
547
+ | **Documentation** | Fix docs, add examples | `docs/` |
548
+ | **Bug reports** | Report issues with reproduction | [Issues](https://github.com/fuze210699/milens/issues) |
549
+
550
+ ```bash
551
+ git clone https://github.com/fuze210699/milens.git
552
+ cd milens
553
+ npm install && npm run build && npm test
554
+ ```
555
+
556
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for full details — skill format, security rule format, PR process, and code of conduct.
557
+
558
+ ---
559
+
560
+ ## License
561
+
562
+ Core (analyzer, parser, store, CLI, MCP tools): **MIT License**
563
+ See [LICENSE](LICENSE) for details.
564
+
565
+ ---
566
+
567
+ <p align="center">
568
+ <a href="https://github.com/fuze210699/milens">GitHub</a> ·
569
+ <a href="https://github.com/fuze210699/milens/tree/main/docs">Docs</a> ·
570
+ <a href="https://github.com/fuze210699/milens/blob/main/docs/cli.md">CLI</a> ·
571
+ <a href="https://github.com/fuze210699/milens/blob/main/docs/accuracy.md">Accuracy</a> ·
572
+ <a href="https://github.com/fuze210699/milens/blob/main/docs/languages.md">Languages</a> ·
573
+ <a href="https://github.com/fuze210699/milens/blob/main/docs/pricing.md">Pricing</a> ·
574
+ <a href="https://github.com/fuze210699/milens/blob/main/CONTRIBUTING.md">Contribute</a> ·
575
+ <a href="https://github.com/fuze210699/milens/blob/main/CHANGELOG.md">Changelog</a> ·
576
+ <a href="https://github.com/fuze210699/milens/blob/main/SECURITY.md">Security</a>
577
+ </p>