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