milens 0.6.2 → 0.6.4

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 (123) hide show
  1. package/.agents/skills/adapters/SKILL.md +31 -0
  2. package/.agents/skills/analyzer/SKILL.md +55 -0
  3. package/.agents/skills/apps/SKILL.md +42 -0
  4. package/.agents/skills/docs/SKILL.md +46 -0
  5. package/.agents/skills/milens/SKILL.md +168 -0
  6. package/.agents/skills/milens-code-review/SKILL.md +186 -0
  7. package/.agents/skills/milens-eval/SKILL.md +221 -0
  8. package/.agents/skills/milens-plan/SKILL.md +227 -0
  9. package/.agents/skills/milens-refactor-clean/SKILL.md +209 -0
  10. package/.agents/skills/milens-security-review/SKILL.md +224 -0
  11. package/.agents/skills/milens-tdd/SKILL.md +156 -0
  12. package/.agents/skills/parser/SKILL.md +60 -0
  13. package/.agents/skills/root/SKILL.md +64 -0
  14. package/.agents/skills/scripts/SKILL.md +27 -0
  15. package/.agents/skills/security/SKILL.md +44 -0
  16. package/.agents/skills/server/SKILL.md +46 -0
  17. package/.agents/skills/store/SKILL.md +53 -0
  18. package/.agents/skills/test/SKILL.md +73 -0
  19. package/LICENSE +75 -75
  20. package/README.md +524 -305
  21. package/adapters/README.md +107 -0
  22. package/adapters/claude-code/.claude/mcp.json +9 -0
  23. package/adapters/claude-code/CLAUDE.md +58 -0
  24. package/adapters/codex/.codex/codex.md +52 -0
  25. package/adapters/copilot/.github/copilot-instructions.md +62 -0
  26. package/adapters/cursor/.cursorrules +9 -0
  27. package/adapters/gemini/.gemini/context.md +58 -0
  28. package/adapters/opencode/.opencode/config.json +9 -0
  29. package/adapters/opencode/AGENTS.md +58 -0
  30. package/adapters/zed/.zed/settings.json +8 -0
  31. package/dist/agents-md.d.ts +3 -0
  32. package/dist/agents-md.d.ts.map +1 -0
  33. package/dist/agents-md.js +112 -0
  34. package/dist/agents-md.js.map +1 -0
  35. package/dist/analyzer/engine.d.ts +1 -0
  36. package/dist/analyzer/engine.d.ts.map +1 -1
  37. package/dist/analyzer/engine.js +27 -8
  38. package/dist/analyzer/engine.js.map +1 -1
  39. package/dist/analyzer/review.d.ts +23 -0
  40. package/dist/analyzer/review.d.ts.map +1 -0
  41. package/dist/analyzer/review.js +143 -0
  42. package/dist/analyzer/review.js.map +1 -0
  43. package/dist/analyzer/testplan.d.ts +59 -0
  44. package/dist/analyzer/testplan.d.ts.map +1 -0
  45. package/dist/analyzer/testplan.js +218 -0
  46. package/dist/analyzer/testplan.js.map +1 -0
  47. package/dist/cli.js +1192 -401
  48. package/dist/cli.js.map +1 -1
  49. package/dist/metrics.d.ts +51 -0
  50. package/dist/metrics.d.ts.map +1 -0
  51. package/dist/metrics.js +64 -0
  52. package/dist/metrics.js.map +1 -0
  53. package/dist/parser/extract.d.ts +1 -0
  54. package/dist/parser/extract.d.ts.map +1 -1
  55. package/dist/parser/extract.js +8 -0
  56. package/dist/parser/extract.js.map +1 -1
  57. package/dist/parser/lang-go.d.ts.map +1 -1
  58. package/dist/parser/lang-go.js +75 -39
  59. package/dist/parser/lang-go.js.map +1 -1
  60. package/dist/parser/lang-java.d.ts.map +1 -1
  61. package/dist/parser/lang-java.js +30 -29
  62. package/dist/parser/lang-java.js.map +1 -1
  63. package/dist/parser/lang-js.js +105 -105
  64. package/dist/parser/lang-php.js +38 -38
  65. package/dist/parser/lang-py.d.ts.map +1 -1
  66. package/dist/parser/lang-py.js +53 -31
  67. package/dist/parser/lang-py.js.map +1 -1
  68. package/dist/parser/lang-ruby.d.ts.map +1 -1
  69. package/dist/parser/lang-ruby.js +15 -14
  70. package/dist/parser/lang-ruby.js.map +1 -1
  71. package/dist/parser/lang-rust.js +30 -30
  72. package/dist/parser/lang-ts.js +191 -191
  73. package/dist/security/deps.d.ts +38 -0
  74. package/dist/security/deps.d.ts.map +1 -0
  75. package/dist/security/deps.js +685 -0
  76. package/dist/security/deps.js.map +1 -0
  77. package/dist/security/rules.d.ts +42 -0
  78. package/dist/security/rules.d.ts.map +1 -0
  79. package/dist/security/rules.js +940 -0
  80. package/dist/security/rules.js.map +1 -0
  81. package/dist/server/hooks.d.ts +26 -0
  82. package/dist/server/hooks.d.ts.map +1 -0
  83. package/dist/server/hooks.js +253 -0
  84. package/dist/server/hooks.js.map +1 -0
  85. package/dist/server/mcp-prompts.d.ts +277 -0
  86. package/dist/server/mcp-prompts.d.ts.map +1 -0
  87. package/dist/server/mcp-prompts.js +627 -0
  88. package/dist/server/mcp-prompts.js.map +1 -0
  89. package/dist/server/mcp.d.ts.map +1 -1
  90. package/dist/server/mcp.js +520 -36
  91. package/dist/server/mcp.js.map +1 -1
  92. package/dist/server/test-plan.d.ts +20 -0
  93. package/dist/server/test-plan.d.ts.map +1 -0
  94. package/dist/server/test-plan.js +100 -0
  95. package/dist/server/test-plan.js.map +1 -0
  96. package/dist/skills.js +152 -120
  97. package/dist/skills.js.map +1 -1
  98. package/dist/store/annotations.d.ts +41 -0
  99. package/dist/store/annotations.d.ts.map +1 -0
  100. package/dist/store/annotations.js +192 -0
  101. package/dist/store/annotations.js.map +1 -0
  102. package/dist/store/confidence.d.ts +18 -0
  103. package/dist/store/confidence.d.ts.map +1 -0
  104. package/dist/store/confidence.js +82 -0
  105. package/dist/store/confidence.js.map +1 -0
  106. package/dist/store/db.d.ts +68 -1
  107. package/dist/store/db.d.ts.map +1 -1
  108. package/dist/store/db.js +349 -139
  109. package/dist/store/db.js.map +1 -1
  110. package/dist/store/schema.sql +128 -83
  111. package/dist/store/vectors.d.ts +65 -0
  112. package/dist/store/vectors.d.ts.map +1 -0
  113. package/dist/store/vectors.js +212 -0
  114. package/dist/store/vectors.js.map +1 -0
  115. package/dist/types.d.ts +101 -0
  116. package/dist/types.d.ts.map +1 -1
  117. package/dist/utils.d.ts +3 -0
  118. package/dist/utils.d.ts.map +1 -0
  119. package/dist/utils.js +9 -0
  120. package/dist/utils.js.map +1 -0
  121. package/docs/README.md +24 -0
  122. package/docs/diagram2.svg +1 -1
  123. package/package.json +80 -65
package/README.md CHANGED
@@ -1,477 +1,696 @@
1
1
  <p align="center">
2
- <strong>milens</strong><br>
3
- <em>Code Intelligence Engine for AI Agents</em>
2
+ <strong>Milens</strong><br>
3
+ <em>AI-DOS The Operating System for AI-Driven Development</em>
4
4
  </p>
5
5
 
6
6
  <p align="center">
7
- <a href="https://www.npmjs.com/package/milens"><img src="https://img.shields.io/npm/v/milens" alt="npm version"></a>
8
- <a href="https://github.com/fuze210699/milens/blob/develop/LICENSE"><img src="https://img.shields.io/badge/license-PolyForm--Noncommercial-blue" alt="License: PolyForm Noncommercial"></a>
9
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="Node.js >= 20"></a>
10
- <img src="https://img.shields.io/badge/languages-12-orange" alt="12 Languages">
11
- <img src="https://img.shields.io/badge/MCP_tools-21-purple" alt="21 MCP Tools">
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-33-purple" alt="33 tools">
11
+ <img src="https://img.shields.io/badge/prompts-6-orange" alt="6 prompts">
12
+ <img src="https://img.shields.io/badge/security-50%2B-red" alt="50+ rules">
13
+ <img src="https://img.shields.io/badge/harnesses-7-lightgrey" alt="7 harnesses">
12
14
  </p>
13
15
 
14
- <p align="center">
15
- <strong>Index any codebase → Knowledge graph → AI agents that never miss code</strong>
16
- </p>
16
+ ---
17
17
 
18
18
  <p align="center">
19
- <a href="#the-problem">Why?</a>
20
- <a href="#quick-start">Quick Start</a>
21
- <a href="#cli-commands">CLI Commands</a>
22
- <a href="#mcp-tools">MCP Tools</a>
23
- <a href="#editor-setup">Editors</a> •
24
- <a href="#supported-languages">Languages</a>
19
+ <a href="https://github.com/fuze210699/milens">⭐ Star</a> ·
20
+ <a href="https://github.com/sponsors/fuze210699">💖 Sponsor</a> ·
21
+ <a href="https://github.com/fuze210699/milens/discussions">💬 Discussions</a> ·
22
+ <a href="https://github.com/fuze210699/milens/blob/main/docs/pricing.md">Pro $19/seat</a>
25
23
  </p>
26
24
 
27
25
  ---
28
26
 
29
27
  ## The Problem
30
28
 
31
- You're burning tokens and premium requests on tasks that milens can handle at a fraction of the cost. Every time your agent explores a codebase — reading files one by one, searching for references, tracing call chains — you're paying for what a pre-built knowledge graph delivers instantly.
29
+ AI coding agents are powerful but they don't truly know your codebase.
32
30
 
33
- **Why not let milens save your wallet?**
31
+ **What happens every session:**
34
32
 
35
- One `milens analyze` replaces dozens of agent tool calls. Instead of the agent spending 10+ steps to map out a function's dependencies, `impact()` returns the full blast radius in a single call.
33
+ 1. Agent edits `UserService.validate()`
34
+ 2. Doesn't know 47 functions depend on its return type
35
+ 3. **Breaking changes ship to production**
36
36
 
37
- If you're concerned about security, read our [Security & Privacy](#security--privacy) guarantees milens is fully offline, zero telemetry, localhost-only.
37
+ The deeper issue: agents waste **70% of their context window** just trying to understand the codebase. Reading files one by one. Grep'ing for references. Tracing call chains manually. Every session starts from zero last session's discoveries are gone.
38
38
 
39
- ### How milens Solves This
39
+ After 10-20 AI sessions, the codebase accumulates dead code, untested hubs, and forgotten security gaps. The agent gets slower, more confused, and more expensive — while the developer burns tokens and patience.
40
40
 
41
- <p align="center">
42
- <img src="docs/diagram1.svg" alt="Without milens vs With milens comparison" width="700">
43
- </p>
41
+ ---
44
42
 
45
- milens builds a **pre-indexed knowledge graph** at analysis time — resolving every import, call, and inheritance chain — so that any tool query returns the full dependency picture instantly, without multi-step exploration.
43
+ ## Without Milens vs With Milens
44
+
45
+ | Situation | Without Milens | With Milens |
46
+ |---|---|---|
47
+ | **Understand a new codebase** | Agent reads 15 files blind (~30,000 tokens) | `codebase_summary()` — 500 tokens, complete overview |
48
+ | **Edit a function safely** | No idea what depends on it. Hope it doesn't break. | `impact({target, depth: 3})` — exact blast radius before every edit |
49
+ | **Find all references** | Grep 5 times, read 8 files, miss template usages | `context({name})` — incoming + outgoing, one call |
50
+ | **Review a PR** | Read diff, guess risk, miss hidden dependencies | `review_pr()` — every symbol scored CRITICAL/HIGH/MEDIUM/LOW |
51
+ | **Security audit** | 10 manual greps for secrets, injections, unicode | `security_scan()` — 50 rules, one tool call |
52
+ | **Start a new session** | Zero context. Re-learn everything from scratch. | `recall()` — agent remembers every past bug, caveat, and pattern |
53
+ | **Write tests** | Guess what needs testing. Guess how to mock. | `test_plan()` — mock strategy + 3 scenarios + coverage gaps sorted by risk |
54
+ | **Find dead code** | Manual search. "Is this still used? I'm not sure." | `find_dead_code()` — every exported symbol with zero references |
55
+
56
+ **Average savings: ~70% fewer tokens per session. ~50% faster task completion.**
57
+
58
+ ---
59
+
60
+ ## What is Milens?
61
+
62
+ Milens gives AI coding agents **instant code intelligence**. Instead of reading 15 files to understand a codebase, your agent calls one tool and gets the full picture in 500 tokens.
63
+
64
+ It builds a **knowledge graph** of your entire project — every function, class, import, call, and inheritance chain — then exposes it through 33 MCP tools. Agents query the graph instead of searching files. The result: **70% fewer tokens** per session, **zero broken dependencies**, and a system that **learns from every session**.
65
+
66
+ - **Analyze once.** Tree-sitter parses 12 languages into a SQLite knowledge graph.
67
+ - **Query instantly.** FTS5 search, recursive CTE traversal, vector similarity — all in-database.
68
+ - **Edit safely.** Every tool returns a blast radius before you change anything.
69
+ - **Scan automatically.** 50+ security rules run in one call, not ten greps.
70
+ - **Learn continuously.** Annotations persist across sessions. Patterns auto-promote to rules.
71
+
72
+ Fully offline. Zero telemetry. Localhost-only MCP server. One command to bootstrap.
73
+
74
+ ```
75
+ npx milens init --profile full
76
+ ```
46
77
 
47
78
  ---
48
79
 
49
80
  ## Quick Start
50
81
 
51
82
  ```bash
52
- npx milens analyze # index your codebase
83
+ npm install -g milens # install globally
84
+ cd your-project
85
+ milens init --profile full --interactive # bootstrap everything
53
86
  ```
54
87
 
55
- Then add the MCP server to your editor ([setup below](#editor-setup)) and your agent immediately gets 19 code intelligence tools.
88
+ 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.
56
89
 
57
- ---
90
+ Then connect your editor:
58
91
 
59
- ## CLI Commands
92
+ ```json
93
+ // .vscode/mcp.json — VS Code / Copilot
94
+ {
95
+ "servers": {
96
+ "milens": {
97
+ "type": "stdio",
98
+ "command": "npx",
99
+ "args": ["-y", "milens", "serve", "-p", "${workspaceFolder}"]
100
+ }
101
+ }
102
+ }
103
+ ```
60
104
 
61
- ### `milens analyze` — Index a codebase
105
+ ```bash
106
+ # Claude Code
107
+ claude mcp add milens -- npx -y milens serve -p .
62
108
 
63
- Parse all source files, resolve cross-file dependencies, and build a searchable knowledge graph.
109
+ # Cursor .cursor/mcp.json
110
+ { "mcpServers": { "milens": { "command": "npx", "args": ["-y", "milens", "serve", "-p", "."] } } }
64
111
 
65
- ```bash
66
- milens analyze # index current directory
67
- milens analyze -p /path/to/repo # index a specific repo
68
- milens analyze -p . --force # full re-index (ignore cache)
69
- milens analyze -p . --force --verbose # full re-index with detailed progress
112
+ # OpenCode — .opencode/config.json
113
+ { "mcp": { "milens": { "command": "npx", "args": ["-y", "milens", "serve"] } } }
70
114
  ```
71
115
 
72
- **Output:** A `.milens/milens.db` SQLite database containing every symbol, relationship, and search index.
116
+ Open your AI agent. It auto-loads `AGENTS.md` with codebase context. You're ready.
73
117
 
74
- **Incremental mode:** By default, only re-parses files whose SHA-256 hash has changed since the last run.
118
+ ---
119
+
120
+ ## Architecture
75
121
 
76
- #### Generating AI skill files
122
+ ```
123
+ npx milens init
124
+
125
+ ┌────────────────┼────────────────┐
126
+ ▼ ▼ ▼
127
+ ANALYZE GENERATE CONFIGURE
128
+ tree-sitter parse AGENTS.md security rules
129
+ resolve imports skill files pre-commit hooks
130
+ build graph adapter packs CI templates
131
+ │ │ │
132
+ └────────────────┼────────────────┘
133
+
134
+ milens serve
135
+
136
+ ┌────────────────┼────────────────┐
137
+ ▼ ▼ ▼
138
+ 33 MCP TOOLS 6 SUB-AGENT 50+ SECURITY
139
+ query, impact, PROMPTS RULES
140
+ context, trace, planner, secrets, injection,
141
+ review_pr, ... reviewer, ... unicode, crypto, ...
142
+
143
+
144
+ AI CODING AGENT
145
+ ┌────────────────┼────────────────┐
146
+ ▼ ▼ ▼
147
+ CODE SAFELY REVIEW AUTO LEARN CONTINUOUSLY
148
+ edit_check() review_pr() annotate → recall
149
+ impact() security_scan() evolve → promote
150
+ ```
77
151
 
78
- Skill files teach your AI agent the codebase structure — key symbols, entry points, cross-area dependencies — without reading every file.
152
+ ### Four-Layer Stack
79
153
 
80
- ```bash
81
- milens analyze -p . --skills # generate for all editors
82
- milens analyze -p . --skills-copilot # GitHub Copilot only
83
- milens analyze -p . --skills-cursor # Cursor only
84
- milens analyze -p . --skills-claude # Claude Code only
85
- milens analyze -p . --skills-agents # AGENTS.md only
86
- milens analyze -p . --skills-windsurf # Windsurf only
87
154
  ```
155
+ ┌─────────────────────────────────────────────────────────┐
156
+ │ PLATFORM LAYER │
157
+ │ GitHub App · npm · 7 adapter packs · Desktop Dashboard │
158
+ │ Pricing: Free / Pro ($19/seat) / Enterprise │
159
+ ├─────────────────────────────────────────────────────────┤
160
+ │ AUTOMATION LAYER │
161
+ │ 6 Hooks (SessionStart, SessionEnd, PreCommit, ...) │
162
+ │ Auto-annotate · Auto-recall · Watch mode │
163
+ │ Scheduled evolve (cron/schtasks) · Pre-commit hooks │
164
+ ├─────────────────────────────────────────────────────────┤
165
+ │ WORKFLOW LAYER │
166
+ │ 6 Sub-agent Prompts (planner, reviewer, tester, ...) │
167
+ │ 6 Skill files · AGENTS.md auto-generator │
168
+ │ Selective profiles (minimal/standard/full) │
169
+ ├─────────────────────────────────────────────────────────┤
170
+ │ INTELLIGENCE LAYER │
171
+ │ Knowledge Graph (SQLite+FTS5) · 33 MCP Tools │
172
+ │ Memory (annotations+sessions) · Learning (confidence) │
173
+ │ 50+ Security Rules (OWASP) · 7 Metrics (TER, CQI, ...) │
174
+ └─────────────────────────────────────────────────────────┘
175
+ ```
176
+
177
+ ### Pipeline
88
178
 
89
- | Flag | Output files |
179
+ | Stage | What Happens | Technology |
180
+ |---|---|---|
181
+ | **Scan** | Discover source files by extension | Node.js `fs` |
182
+ | **Parse** | Extract symbols, imports, calls, heritage | tree-sitter WASM (12 languages) |
183
+ | **Resolve** | Match imports to files, calls to definitions | Cross-file linker |
184
+ | **Enrich** | Compute roles, heat scores, domain clusters | Union-find + PageRank-like |
185
+ | **Persist** | Store everything in SQLite | better-sqlite3 + FTS5 |
186
+ | **Serve** | Expose via MCP protocol | stdio + StreamableHTTP |
187
+ | **Learn** | Annotate → confidence score → promote → skill | SQLite + evolution log |
188
+ | **Scan** | 50+ regex rules across all files | Built-in security engine |
189
+
190
+ ### Design Principles
191
+
192
+ | Principle | Implementation |
90
193
  |---|---|
91
- | `--skills-copilot` | `.github/instructions/*.instructions.md` + `.github/copilot-instructions.md` |
92
- | `--skills-cursor` | `.cursor/rules/*.mdc` + `.cursor/index.mdc` |
93
- | `--skills-claude` | `.claude/skills/generated/*/SKILL.md` + `.claude/rules/*.md` + `CLAUDE.md` |
94
- | `--skills-agents` | `.agents/skills/*/SKILL.md` + `AGENTS.md` |
95
- | `--skills-windsurf` | `.windsurfrules` |
194
+ | **One parse, infinite queries** | Knowledge graph pre-computed at analyze time |
195
+ | **Zero network** | Everything offline. No API calls. No telemetry. |
196
+ | **Token-compact** | `name [kind] file:line` format saves 40-60% tokens |
197
+ | **Incremental** | SHA-256 file hashing. Only changed files re-parsed. |
198
+ | **In-database traversal** | Recursive CTEs for graph queries. No full graph in memory. |
199
+ | **Localhost only** | HTTP binds 127.0.0.1. No network exposure. |
200
+ | **MCP standard** | Works with any MCP-compatible agent. No vendor lock-in. |
96
201
 
97
- > Root config files use `<!-- milens:start/end -->` markers for **idempotent injection** — re-running replaces the milens section without overwriting your custom content.
202
+ ---
98
203
 
99
- **Team Collaboration Notes:**
204
+ ## MCP Tools (33)
100
205
 
101
- - **Instruction files are safe to commit** - They use `<workspaceRoot>` placeholder instead of absolute paths
102
- - ✅ **No merge conflicts** - No machine-specific information (username, absolute paths, etc.)
103
- - ✅ **Consistent AI assistance** - All team members get the same codebase intelligence
104
- - ⚠️ **Database is gitignored** - `.milens/*.db` files are local; each developer runs `npx milens analyze` after clone
206
+ ### Search & Navigation
105
207
 
106
- See [`.milens/README.md`](.milens/README.md) for more details on the index directory.
208
+ | Tool | Does |
209
+ |---|---|
210
+ | `query` | FTS5 full-text search for symbol definitions |
211
+ | `grep` | Regex search across ALL project files (code, configs, docs, templates) |
212
+ | `context` | 360° view: who calls this + what this depends on |
213
+ | `get_file_symbols` | Every symbol in a file with ref/dep counts |
214
+ | `get_type_hierarchy` | Full inheritance tree — ancestors + descendants |
107
215
 
108
- ---
216
+ ### Safety & Impact
109
217
 
110
- ### `milens search` Find symbols by name
218
+ | Tool | Does |
219
+ |---|---|
220
+ | `impact` | Blast radius: depth 1-3 traversal showing what breaks |
221
+ | `edit_check` | Pre-edit safety: callers, re-exports, test coverage, warnings |
222
+ | `detect_changes` | Git diff → which symbols changed + their dependents |
223
+ | `find_dead_code` | Exported symbols with zero incoming references |
224
+ | `overview` | context + impact + grep combined in one call |
111
225
 
112
- Full-text search (BM25) across all indexed symbol names and file paths.
226
+ ### Understanding Code
113
227
 
114
- ```bash
115
- milens search "UserService" # search for symbols
116
- milens search "auth" --limit 50 # increase result limit (default: 20)
117
- milens search "handler" -p /path/to/repo # search in a specific repo
118
- ```
228
+ | Tool | Does |
229
+ |---|---|
230
+ | `smart_context` | Intent-aware context: `edit` / `debug` / `test` / `understand` |
231
+ | `trace` | Full execution path from entrypoints to target (or reverse) |
232
+ | `routes` | Auto-detect API endpoints across 11 frameworks |
233
+ | `explain_relationship` | Shortest dependency chain between any two symbols |
234
+ | `domains` | Module clusters based on cross-file dependency graph |
119
235
 
120
- **Output format:** `name [kind] file:line (exported)`
236
+ ### Review & Testing
121
237
 
122
- ```
123
- AuthService [class] src/auth.ts:15 (exported)
124
- hashPassword [function] src/auth.ts:3 (exported)
125
- ```
238
+ | Tool | Does |
239
+ |---|---|
240
+ | `review_pr` | Scores every changed symbol CRITICAL/HIGH/MEDIUM/LOW |
241
+ | `review_symbol` | Deep-dive: role, heat, dependents, test status, recommendation |
242
+ | `codebase_summary` | ~500 token overview for session bootstrap |
243
+ | `test_plan` | Mock strategy + 3+ test scenarios based on dependencies |
244
+ | `test_coverage_gaps` | Untested symbols sorted by risk |
245
+ | `test_impact` | Maps changed code → which test files to run |
126
246
 
127
- ---
247
+ ### Memory & Sessions
128
248
 
129
- ### `milens inspect` 360° symbol view
249
+ | Tool | Does |
250
+ |---|---|
251
+ | `annotate` | Save observation about a symbol (persists forever) |
252
+ | `recall` | Retrieve past annotations by symbol, key, agent, or session |
253
+ | `session_start` | Begin new session with agent identity |
254
+ | `session_context` | Session metadata + tool calls + annotations |
255
+ | `session_end` | Close session, record stats |
256
+ | `handoff` | Transfer all context from one agent session to another |
130
257
 
131
- Show everything about a symbol: who calls it (incoming) and what it depends on (outgoing).
258
+ ### Security
132
259
 
133
- ```bash
134
- milens inspect "AuthService"
135
- milens inspect "resolveLinks" -p .
136
- ```
260
+ | Tool | Does |
261
+ |---|---|
262
+ | `security_scan` | **50+ rules in one call.** Scopes: secrets, injection, unicode, dangerous, config, data-leak, crypto, auth, file-access |
137
263
 
138
- **Output:**
264
+ ### Overview & Similarity
139
265
 
140
- ```
141
- AuthService [class] src/auth.ts:15
142
- incoming:
143
- calls: handleLogin (src/routes.ts)
144
- calls: UserController (src/controllers/user.ts)
145
- outgoing:
146
- imports: User (src/models.ts)
147
- calls: hashPassword (src/auth.ts)
148
- calls: createUser (src/models.ts)
149
- ```
266
+ | Tool | Does |
267
+ |---|---|
268
+ | `status` | Index stats, test coverage %, link accuracy |
269
+ | `repos` | List all indexed repositories |
270
+ | `semantic_search` | Meaning-based symbol search (FTS5 + vector hybrid) |
271
+ | `find_similar` | Symbols with shared callers/callees (topological similarity) |
272
+
273
+ ### Developer
274
+
275
+ | Tool | Does |
276
+ |---|---|
277
+ | `ast_explore` | Parse code snippet → S-expression AST tree |
278
+ | `test_query` | Test a tree-sitter query against code |
150
279
 
151
280
  ---
152
281
 
153
- ### `milens impact` — Blast radius analysis
282
+ ## Tool Output Examples
154
283
 
155
- Recursively trace what depends on a symbol (upstream) or what a symbol depends on (downstream).
284
+ ### Context 360° Symbol View
156
285
 
157
- ```bash
158
- milens impact "createUser" # upstream: what breaks if this changes?
159
- milens impact "UserModel" -d downstream # downstream: what does this depend on?
160
- milens impact "searchSymbols" --depth 2 # limit traversal depth (default: 3)
161
286
  ```
287
+ context({name: "AuthService"})
288
+
289
+ AuthService [class] src/auth.ts:15 (exported)
290
+ role: hub | heat: 0.85
162
291
 
163
- **Output:**
292
+ incoming (3):
293
+ calls: handleLogin [function] src/routes.ts:23
294
+ calls: UserController [class] src/controllers/user.ts:8
295
+ imports: authRouter [variable] src/routes.ts:1
164
296
 
297
+ outgoing (3):
298
+ imports: User [class] src/models.ts:5
299
+ calls: hashPassword [function] src/auth.ts:3
300
+ calls: createUser [function] src/models.ts:42
165
301
  ```
166
- TARGET: createUser [function] src/models.ts:42
167
- [depth 1] AuthService [class] src/auth.ts:15 (calls)
168
- [depth 1] UserController [class] src/controllers/user.ts:8 (calls)
169
- [depth 2] handleLogin [function] src/routes.ts:23 (calls)
302
+
303
+ ### Impact Blast Radius
304
+
170
305
  ```
306
+ impact({target: "createUser", direction: "upstream", depth: 3})
171
307
 
172
- **Depth meaning:**
173
- - Depth 1 = **WILL BREAK** — direct callers/dependents
174
- - Depth 2 = **LIKELY AFFECTED** — indirect dependents
175
- - Depth 3 = **MAY NEED TESTING** — transitive dependents
308
+ TARGET: createUser [function] src/models.ts:42
176
309
 
177
- ---
310
+ [depth 1] WILL BREAK:
311
+ AuthService [class] src/auth.ts:15 (calls)
312
+ UserController [class] src/controllers/user.ts:8 (calls)
178
313
 
179
- ### `milens serve` — Start MCP server
314
+ [depth 2] LIKELY AFFECTED:
315
+ handleLogin [function] src/routes.ts:23 (calls)
316
+ handleRegister [function] src/routes.ts:45 (calls)
180
317
 
181
- Expose the knowledge graph to AI agents via the Model Context Protocol.
318
+ [depth 3] MAY NEED TESTING:
319
+ authRouter [variable] src/routes.ts:1 (imports)
320
+ adminDashboard [function] src/admin.ts:10 (calls)
182
321
 
183
- ```bash
184
- milens serve # stdio transport (for editors)
185
- milens serve -p /path/to/repo # serve a specific repo
186
- milens serve --http # HTTP transport on port 3100
187
- milens serve --http --port 8080 # HTTP on custom port
322
+ 5 dependents across 3 depths
188
323
  ```
189
324
 
190
- **stdio mode** (default): Used by editors like VS Code, Cursor, and Claude Code. The agent communicates through stdin/stdout.
325
+ ### Review PR Risk Assessment
191
326
 
192
- **HTTP mode**: Used by remote agents or custom integrations. Binds to `127.0.0.1` only — no network exposure.
193
-
194
- Endpoint: `POST http://localhost:3100/mcp`
327
+ ```
328
+ review_pr({})
195
329
 
196
- ---
330
+ PR Risk Assessment (vs HEAD):
331
+ 6 changed files, 12 affected symbols
197
332
 
198
- ### `milens status`Show index stats
333
+ handlePayment [function] src/payment.ts:30heat:92 deps:15 test:no → CRITICAL(85)
334
+ checkoutRoute [function] src/routes/checkout.ts:5 — heat:78 deps:8 test:yes → HIGH(58)
335
+ UserModel [class] src/models.ts:20 — heat:65 deps:3 test:yes → MEDIUM(35)
336
+ formatCurrency [function] src/utils.ts:45 — heat:10 deps:0 test:no → LOW(15)
199
337
 
200
- ```bash
201
- milens status # current directory
202
- milens status -p /path/to/repo # specific repo
338
+ Summary: CRITICAL=1 HIGH=2 MEDIUM=4 LOW=5
203
339
  ```
204
340
 
205
- **Output:**
341
+ ### Security Scan — 50 Rules at Once
206
342
 
207
343
  ```
208
- Repository: /home/user/my-project
209
- Database: /home/user/my-project/.milens/milens.db
210
- Indexed: 2026-04-11T10:30:00Z
211
- Symbols: 210
212
- Links: 348
213
- Files: 30
344
+ security_scan({scope: "all", severity: "HIGH"})
345
+
346
+ {
347
+ "summary": {
348
+ "totalScanned": 1240,
349
+ "findings": 8,
350
+ "bySeverity": { "CRITICAL": 1, "HIGH": 3, "MEDIUM": 4 },
351
+ "score": 78
352
+ },
353
+ "findings": [
354
+ {
355
+ "ruleId": "SEC-001",
356
+ "category": "secrets",
357
+ "severity": "CRITICAL",
358
+ "owasp": "A02:2021",
359
+ "file": "src/config.ts",
360
+ "line": 15,
361
+ "match": "password = 'admin123'",
362
+ "fix": "Move to environment variable: process.env.DB_PASSWORD"
363
+ },
364
+ {
365
+ "ruleId": "SEC-011",
366
+ "category": "injection",
367
+ "severity": "HIGH",
368
+ "owasp": "A03:2021",
369
+ "file": "src/routes/admin.ts",
370
+ "line": 42,
371
+ "match": "eval(userInput)",
372
+ "fix": "Replace eval() with a safe parser or validator"
373
+ }
374
+ ]
375
+ }
214
376
  ```
215
377
 
216
378
  ---
217
379
 
218
- ### `milens list` — List all indexed repositories
380
+ ## Sub-agent Prompts (6)
219
381
 
220
- ```bash
221
- milens list
222
- ```
382
+ Instead of chaining 5-10 tools manually, your agent calls one prompt:
223
383
 
224
- **Output:**
384
+ | Prompt | Input | Workflow |
385
+ |---|---|---|
386
+ | `milens-planner` | Feature description | Research → Analyze Target → Predict Impact → Plan Tests → **Implementation Plan** |
387
+ | `milens-reviewer` | Change description | Scan PR → Deep-dive Symbols → Find Dead Code → Text Search → **Review Report** |
388
+ | `milens-tester` | Symbol name | Find Gaps → Generate Plan → Implement → Verify → **Coverage Report** |
389
+ | `milens-architect` | (none) | Overview → Domains → Routes → Hierarchy → Connections → **Architecture Analysis** |
390
+ | `milens-security` | (none) | Scan PR → Secrets → Unicode → Dangerous → Data Leak → **Security Audit** |
391
+ | `milens-debugger` | Target + error | Context → Trace Execution → Impact → Find Relationship → **Root Cause Analysis** |
225
392
 
226
- ```
227
- 3 indexed repositories:
393
+ ---
228
394
 
229
- /home/user/project-a
230
- DB: /home/user/project-a/.milens/milens.db
231
- Indexed: 2026-04-11T10:30:00Z
395
+ ## CLI Commands
232
396
 
233
- /home/user/project-b
234
- DB: /home/user/project-b/.milens/milens.db
235
- Indexed: 2026-04-10T15:22:00Z
397
+ ```
398
+ milens init [--profile minimal|standard|full] [--interactive] Bootstrap a project
399
+ milens analyze [-p .] [--force] [--skills] [--embeddings] Index a codebase
400
+ milens serve [-p .] [--http] [--port 3100] [--profile minimal] Start MCP server
401
+ milens workflow <name> Run predefined pipeline
402
+ milens security scan [--scope secrets] [--severity HIGH] Security audit
403
+ milens security deps Dependency CVE check
404
+ milens hooks enable|disable|list|profile Manage automation
405
+ milens watch [--debounce 2000] Auto re-index on change
406
+ milens evolve [--schedule install|uninstall|status] Promote learned patterns
407
+ milens metrics TER, CQI, BRR, CTR...
408
+ milens search <query> [--limit 50] Find symbols
409
+ milens inspect <symbol> Incoming + outgoing deps
410
+ milens impact <symbol> [-d downstream] [--depth 2] Blast radius
411
+ milens status [-p .] Index health
412
+ milens list All indexed repos
413
+ milens clean [-p .] [--all] Remove index
414
+ milens dashboard [--port 8080] Usage analytics
236
415
  ```
237
416
 
238
- ---
239
-
240
- ### `milens clean` — Remove index
417
+ ### Workflow Examples
241
418
 
242
419
  ```bash
243
- milens clean # remove index for current directory
244
- milens clean -p /path/to/repo # remove index for specific repo
245
- milens clean --all # remove ALL indexes
420
+ milens workflow tdd # Find test gaps plan → verify
421
+ milens workflow review # PR review risk scores → dead code
422
+ milens workflow plan "Add Stripe billing" # Full implementation plan
423
+ milens workflow onboard # Session startup checklist
424
+ milens workflow security-scan # All 50 rules at once
246
425
  ```
247
426
 
248
- ---
249
-
250
- ### `milens dashboard` — Usage analytics
427
+ ### Profile Selection
251
428
 
252
- Open a browser-based dashboard showing tool usage statistics, token savings, and response times.
429
+ Control how many tools are active to optimize token overhead:
253
430
 
254
431
  ```bash
255
- milens dashboard # open on port 3200
256
- milens dashboard --port 8080 # custom port
432
+ MILENS_PROFILE=minimal milens serve # 10 tools ~500 token overhead
433
+ MILENS_PROFILE=standard milens serve # 25 tools full daily coding
434
+ milens serve --profile full # 33 tools — everything
257
435
  ```
258
436
 
259
437
  ---
260
438
 
261
- ## MCP Tools
439
+ ## Security (50+ Rules)
262
440
 
263
- When the MCP server is running, your AI agent gets these 21 tools:
441
+ All 50 rules map to **OWASP Top 10 (2021)**. One tool call covers what used to take 10 manual greps.
264
442
 
265
- ### Search & Navigate
266
-
267
- | Tool | What It Does | Example |
443
+ | Category | Rules | Detects |
268
444
  |---|---|---|
269
- | `query` | Symbol search (FTS5 full-text) | `query({query: "UserService"})` |
270
- | `grep` | Text search ALL files — code, templates, configs, docs | `grep({pattern: "TODO", scope: "all"})` |
271
- | `context` | 360° symbol view incoming refs + outgoing deps | `context({name: "AuthService"})` |
272
- | `get_file_symbols` | All symbols in a file with ref/dep counts | `get_file_symbols({file: "src/auth.ts"})` |
273
- | `get_type_hierarchy` | Inheritance/implementation tree | `get_type_hierarchy({name: "BaseController"})` |
445
+ | **secrets** | 10 | AWS keys, GitHub tokens, OpenAI keys, private keys, hardcoded passwords |
446
+ | **injection** | 9 | SQL injection, XSS, command injection, `eval()`, `exec()`, dangerous DOM |
447
+ | **unicode** | 4 | Zero-width chars, bidi override, homoglyph attacks |
448
+ | **dangerous** | 7 | `os.system`, `subprocess shell`, unsafe deserialization, `spawn shell` |
449
+ | **config** | 5 | CORS wildcards, insecure cookies, debug mode, `--dangerously-skip-permissions` |
450
+ | **data-leak** | 5 | `console.log` of secrets, hardcoded URLs |
451
+ | **crypto** | 4 | MD5, SHA1, `Math.random()` for crypto, hardcoded salt/IV |
452
+ | **auth** | 4 | String comparison, missing middleware, JWT without expiry, session in URL |
453
+ | **file-access** | 2 | Path traversal, unsafe file reads |
274
454
 
275
- ### Impact & Safety
455
+ ```bash
456
+ milens security scan --scope secrets --severity HIGH --format json
457
+ milens security deps # Offline CVE check (34 known vulns, 5 ecosystems)
458
+ ```
276
459
 
277
- | Tool | What It Does | Example |
278
- |---|---|---|
279
- | `impact` | Blast radius: what breaks if this changes? | `impact({target: "createUser"})` |
280
- | `edit_check` | Pre-edit safety: callers + exports + test coverage + ⚠ warnings | `edit_check({name: "resolveLinks"})` |
281
- | `detect_changes` | Git diff → affected symbols + direct dependents | `detect_changes({})` |
282
- | `find_dead_code` | Exported symbols with zero references | `find_dead_code({})` |
460
+ From an AI agent: `security_scan({scope: "all", severity: "HIGH"})`
283
461
 
284
- ### Understanding
462
+ ---
285
463
 
286
- | Tool | What It Does | Example |
287
- |---|---|---|
288
- | `smart_context` | Intent-aware context: `understand`/`edit`/`debug`/`test` | `smart_context({name: "analyze", intent: "edit"})` |
289
- | `trace` | Execution flow: call chains to/from entrypoints | `trace({to: "searchSymbols"})` |
290
- | `routes` | Detect framework routes/endpoints | `routes({})` |
291
- | `explain_relationship` | Shortest path between two symbols | `explain_relationship({from: "A", to: "B"})` |
292
- | `overview` | Combined context + impact + grep in ONE call | `overview({name: "Database"})` |
464
+ ## Hook System (6 Triggers)
293
465
 
294
- ### Codebase Overview
466
+ Automation so your agent never forgets:
295
467
 
296
- | Tool | What It Does | Example |
468
+ | Hook | When | Default Action |
297
469
  |---|---|---|
298
- | `domains` | Domain clusters groups of files forming logical modules | `domains({})` |
299
- | `repos` | List all indexed repositories | `repos({})` |
300
- | `status` | Index stats, domains, test coverage, accuracy report | `status({})` |
470
+ | `onSessionStart` | Agent begins work | Refresh index + codebase_summary + recall past warnings |
471
+ | `onSessionEnd` | Agent finishes | detect_changes + review_pr + auto-annotate changed symbols |
472
+ | `onPreCommit` | Before `git commit` | detect_changes + review_pr + find_dead_code |
473
+ | `onFileChange` | Files modified | Re-analyze changed files + impact on affected symbols |
474
+ | `onPreCompact` | Before context window compaction | Save codebase_summary snapshot |
475
+ | `onPostCompact` | After compaction | recall annotations to restore lost context |
301
476
 
302
- ### Developer Tools
303
-
304
- | Tool | What It Does | Example |
305
- |---|---|---|
306
- | `ast_explore` | Parse code snippet → S-expression AST tree | `ast_explore({code: "const x = 1", language: "typescript"})` |
307
- | `test_query` | Test tree-sitter query against code snippet | `test_query({query: "(identifier) @name", code: "const x = 1", language: "typescript"})` |
477
+ ```bash
478
+ milens hooks enable # Turn on all hooks
479
+ milens hooks profile standard # Preset: SessionStart, SessionEnd, PreCommit
480
+ milens hooks disable --hook preCommit # Turn off one hook
481
+ ```
308
482
 
309
- ### Resources & Prompts
483
+ ---
310
484
 
311
- **4 Resources:** `milens://overview`, `milens://symbol/{name}`, `milens://file/{path}`, `milens://domain/{name}`
485
+ ## Learning & Evolution
312
486
 
313
- **3 Guided Prompts:** `delete-feature`, `refactor-symbol`, `explore-symbol` — each triggers a multi-step workflow using the tools above.
487
+ The system gets smarter every session:
314
488
 
315
- ---
489
+ ```
490
+ SESSION 1: Agent finds bug in createUser()
491
+ → annotate({symbol: "createUser", key: "bug", value: "Call createUser() before normalizeEmail()"})
492
+ → confidence: 0.5
316
493
 
317
- ## Editor Setup
494
+ SESSION 2: Agent auto-recalls the annotation
495
+ → "I know createUser() has a known issue. I'll handle the order correctly."
496
+ → Bug avoided. confidence ↑ 0.7
318
497
 
319
- ### VS Code / GitHub Copilot
498
+ SESSION 5: Confidence reaches 0.9
499
+ → milens evolve promotes it to .agents/skills/milens-bug/SKILL.md
500
+ → Now enforced as a rule for every future session
501
+ ```
320
502
 
321
503
  ```bash
322
- npx milens analyze -p . # index your repo (run once)
504
+ milens evolve # Promote high-confidence patterns now
505
+ milens evolve --schedule install # Auto-run weekly (cron/schtasks)
323
506
  ```
324
507
 
325
- Add to `.vscode/mcp.json`:
508
+ ---
326
509
 
327
- ```json
328
- {
329
- "servers": {
330
- "milens": {
331
- "type": "stdio",
332
- "command": "npx",
333
- "args": ["-y", "milens", "serve", "-p", "${workspaceFolder}"]
334
- }
335
- }
336
- }
337
- ```
510
+ ## Supported Languages
338
511
 
339
- <details>
340
- <summary><strong>Other Editors</strong></summary>
512
+ 12 languages through tree-sitter:
513
+
514
+ | Language | Files | Imports | Calls | Heritage |
515
+ |---|---|---|---|---|
516
+ | TypeScript | `.ts` `.tsx` | ESM + CJS + decorators | ✓ + decorators | extends / implements |
517
+ | JavaScript | `.js` `.jsx` `.mjs` `.cjs` | ESM + CJS | ✓ | extends |
518
+ | Python | `.py` | import + relative | ✓ + decorators | extends |
519
+ | Java | `.java` | import + static | ✓ + annotations | extends / implements |
520
+ | Go | `.go` | import + go.mod | ✓ | embedding |
521
+ | Rust | `.rs` | use | ✓ + macros | trait impl |
522
+ | PHP | `.php` | use + include | ✓ + static, new | extends + traits |
523
+ | Ruby | `.rb` | require | ✓ | extends |
524
+ | Vue | `.vue` | ESM | ✓ template refs | extends |
525
+ | HTML | `.html` `.htm` | `<script src>` `<link>` | ✓ inline | — |
526
+ | CSS | `.css` | `@import` | — | — |
527
+ | Markdown | `.md` `.mdx` | local `[links]()` | — | headings as sections |
528
+
529
+ **Framework detection** (via `routes()`)**: Express, FastAPI, NestJS, Flask, Django, Go net/http, Gin, PHP Laravel, Rails, Sinatra, Spring.
341
530
 
342
- #### Cursor
531
+ ---
343
532
 
344
- Add to `.cursor/mcp.json`:
533
+ ## Editor & Harness Support
345
534
 
346
- ```json
347
- {
348
- "mcpServers": {
349
- "milens": {
350
- "command": "npx",
351
- "args": ["-y", "milens", "serve", "-p", "."]
352
- }
353
- }
354
- }
355
- ```
535
+ Milens works with any MCP-compatible agent. Two ways to use:
356
536
 
357
- #### Claude Code
537
+ | | MCP Server | CLI |
538
+ |---|---|---|
539
+ | **What** | Real-time tools for AI agents during coding | Direct commands from terminal |
540
+ | **For** | Daily development with AI agents | Scripts, CI/CD, one-off analysis |
541
+ | **Setup** | Add MCP config to editor | `npm install -g milens` |
542
+ | **Tools** | All 33 tools + 6 prompts | Full CLI command set |
543
+ | **Example** | Agent calls `impact()` before editing | `milens security scan --scope secrets` |
358
544
 
359
- ```bash
360
- claude mcp add milens -- npx -y milens serve -p .
361
- ```
545
+ **Harness adapters available for 7 editors:**
362
546
 
363
- #### Windsurf
547
+ | Harness | Config File | Recommended Profile |
548
+ |---|---|---|
549
+ | **Claude Code** | `.claude/mcp.json` | standard (25 tools) |
550
+ | **OpenCode** | `.opencode/config.json` | standard |
551
+ | **VS Code / Copilot** | `.vscode/mcp.json` | standard |
552
+ | **Cursor** | `.cursorrules` | standard |
553
+ | **Codex** | `.codex/codex.md` | standard |
554
+ | **Gemini** | `.gemini/context.md` | minimal (10 tools) |
555
+ | **Zed** | `.zed/settings.json` | minimal |
364
556
 
365
- Add to `~/.codeium/windsurf/mcp_config.json`:
557
+ Each adapter is in the `adapters/` directory with ready-to-copy config files and agent instructions.
366
558
 
367
- ```json
368
- {
369
- "mcpServers": {
370
- "milens": {
371
- "command": "npx",
372
- "args": ["-y", "milens", "serve", "-p", "."]
373
- }
374
- }
375
- }
376
- ```
559
+ ---
377
560
 
378
- #### Codex
561
+ ## Metrics
379
562
 
380
- Add to `.codex/config.toml`:
563
+ Seven quantified metrics for AI-driven development:
381
564
 
382
- ```toml
383
- [mcp_servers.milens]
384
- command = "npx"
385
- args = ["-y", "milens", "serve", "-p", "."]
565
+ ```
566
+ $ milens metrics
567
+
568
+ ╔══════════════════════════════════════════════╗
569
+ ║ Milens Metrics Report ║
570
+ ╠══════════════════════════════════════════════╣
571
+ ║ TER: Token Efficiency Ratio 0.85 ║
572
+ ║ LR: Learning Rate 0.59 ║
573
+ ║ CQI: Code Quality Index 7.2/10 ║
574
+ ║ BRR: Bug Recurrence Rate 8% ║
575
+ ║ TCGR: Test Coverage Growth Rate 5.2%/wk ║
576
+ ║ DCER: Dead Code Elimination Rate 3% ║
577
+ ║ CTR: Cycle Time Reduction 67% ║
578
+ ╚══════════════════════════════════════════════╝
386
579
  ```
387
580
 
388
- </details>
581
+ | Metric | Full Name | What It Tracks |
582
+ |---|---|---|
583
+ | **TER** | Token Efficiency Ratio | Useful tokens ÷ total tokens |
584
+ | **LR** | Learning Rate | Savings gained ÷ savings possible |
585
+ | **CQI** | Code Quality Index | Coverage + security + coupling + docs |
586
+ | **BRR** | Bug Recurrence Rate | Bugs repeated ÷ total fixed |
587
+ | **TCGR** | Test Coverage Growth Rate | Weekly coverage improvement |
588
+ | **DCER** | Dead Code Elimination Rate | Dead symbols ÷ total exported |
589
+ | **CTR** | Cycle Time Reduction | Time saved vs manual approach |
389
590
 
390
591
  ---
391
592
 
392
- ## Supported Languages
593
+ ## Security & Privacy
594
+
595
+ **Zero network. Zero telemetry. Zero data leaving your machine.**
393
596
 
394
- | Language | Extensions | Imports | Calls | Heritage | Frameworks |
395
- |---|---|---|---|---|---|
396
- | TypeScript | `.ts` `.tsx` | ESM + require | + decorators | ✓ extends/implements | NestJS, React JSX |
397
- | JavaScript | `.js` `.jsx` `.mjs` `.cjs` | ESM + require | ✓ | ✓ | React JSX, Express |
398
- | Python | `.py` | | + decorators | | FastAPI, Flask |
399
- | Java | `.java` | + static | + annotations, new | | Spring |
400
- | Go | `.go` | | | | net/http |
401
- | Rust | `.rs` | | + macros | | — |
402
- | PHP | `.php` | ✓ + include | ✓ + static, new | ✓ + traits | Laravel |
403
- | Ruby | `.rb` | ✓ | ✓ | ✓ | Rails |
404
- | Vue | `.vue` | ✓ | ✓ template refs | ✓ | Vue 3 SFC |
405
- | HTML | `.html` `.htm` | ✓ `<script src>` `<link>` | ✓ inline `<script>` | — | — |
406
- | CSS | `.css` | ✓ `@import` | — | — | Custom properties |
407
- | Markdown | `.md` `.mdx` | ✓ local `[links]()` | — | — | Headings → section symbols, parent-child hierarchy |
597
+ | Layer | Guarantee |
598
+ |---|---|
599
+ | **Data** | Index stored in `.milens/` per repo (gitignored). No source code in registry. |
600
+ | **Network** | HTTP binds `127.0.0.1` only. No outbound connections. |
601
+ | **Input** | User regex validated against ReDoS. FTS5 tokens quoted as literals. |
602
+ | **File access** | All paths bounded to repo root. No traversal possible. |
603
+ | **Git** | `execFileSync` with arg arrays. No shell interpolation. |
604
+ | **Embeddings** | Optional. Generated locally via Xenova transformers. No API calls. |
408
605
 
409
606
  ---
410
607
 
411
- ## Architecture
608
+ ## Pricing
412
609
 
413
- <p align="center">
414
- <img src="docs/diagram2.svg" alt="milens architecture: Indexing Pipeline → MCP Server → AI Agent" width="700">
415
- </p>
416
-
417
- ### How it works
610
+ | Tier | Price | Key Features |
611
+ |---|---|---|
612
+ | **Free** | $0 | All 33 tools, public repos, 50+ security rules, CLI, community support. MIT core. |
613
+ | **Pro** | $19/seat/mo | Private repos, GitHub App, advanced scanning, priority support, custom skills |
614
+ | **Enterprise** | Contact | SSO/SAML, audit logging, on-prem, custom rules, SLAs, rollout consulting |
418
615
 
419
- 1. **Scan** find all source files matching supported extensions
420
- 2. **Parse** — tree-sitter extracts symbols (functions, classes, methods, etc.) and raw references (imports, calls, extends)
421
- 3. **Resolve** — cross-file link resolution: match import paths to files, match call names to symbol definitions
422
- 4. **Enrich** — compute roles (entrypoint/hub/utility/leaf), heat scores, domain clusters
423
- 5. **Persist** — store everything in SQLite with FTS5 search and recursive CTEs for graph traversal
616
+ OSS stays free forever. [Full pricing details →](docs/pricing.md)
424
617
 
425
- ### Multi-Repo
618
+ ---
426
619
 
427
- milens uses a global registry (`~/.milens/`) — one MCP server serves all indexed repos. Pass `repo` to target a specific one when multiple are registered.
620
+ ## What's New in v0.7.0
428
621
 
429
- <p align="center">
430
- <img src="docs/diagram3.svg" alt="Multi-repo architecture" width="500">
431
- </p>
622
+ - **6 Sub-agent MCP Prompts** — planner, reviewer, tester, architect, security-auditor, debugger. One prompt replaces 5-10 chained tool calls.
623
+ - **50+ Built-in Security Rules** — OWASP Top 10 mapped. `security_scan()` replaces 10 manual greps. Dependency audit for 5 ecosystems.
624
+ - **Hook System** — 6 event triggers (SessionStart, SessionEnd, PreCommit, FileChange, PreCompact, PostCompact). Auto-annotate, auto-recall.
625
+ - **`milens init`** — One-command bootstrap: analyze + AGENTS.md + skill files + security rules + pre-commit hooks.
626
+ - **`milens workflow`** — 7 predefined pipelines: tdd, review, plan, security-scan, refactor, onboard, handoff.
627
+ - **Selective Profiles** — `minimal` (10 tools), `standard` (25), `full` (33). Control token overhead.
628
+ - **Watch Mode** — Auto re-index on file changes. `milens watch`.
629
+ - **Scheduled Evolve** — Auto-promote high-confidence patterns to skills. `milens evolve --schedule install`.
630
+ - **7 Harness Adapters** — Claude Code, OpenCode, Codex, Cursor, Copilot, Gemini, Zed.
631
+ - **GitHub App** — Probot-based app for automated PR review and `/milens analyze` on repos.
632
+ - **Desktop Dashboard** — Electron-based desktop app with 6 tabs (Overview, Domains, Learning, Metrics, Security, Settings).
633
+ - **Interactive Installer** — `milens init --interactive` walks through every option step by step.
432
634
 
433
- ### Design Decisions
434
-
435
- | Decision | Rationale |
436
- |---|---|
437
- | **Declarative LangSpec** | Each language = 1 config object with tree-sitter queries. One universal extractor for all 12 languages |
438
- | **SQLite + recursive CTE** | Impact analysis runs entirely in the database — no full graph in memory |
439
- | **Token-compact output** | `name [kind] file:line` format — saves 40-60% tokens for AI |
440
- | **Incremental by hash** | SHA-256 file hashing — only changed files get re-parsed |
441
- | **Localhost-only HTTP** | Binds `127.0.0.1` — no network exposure without explicit intent |
635
+ [Full changelog →](https://github.com/fuze210699/milens/releases)
442
636
 
443
637
  ---
444
638
 
445
- ## Security & Privacy
639
+ ## Environment Variables
446
640
 
447
- milens is **offline by design** zero network calls, zero telemetry.
641
+ | Variable | Default | Effect |
642
+ |---|---|---|
643
+ | `MILENS_PROFILE` | (unset = full) | Tool set: `minimal` (10 tools), `standard` (25), `full` (33) |
644
+ | `MILENS_VERSION` | (from package.json) | Override version reported in MCP server metadata |
448
645
 
449
- | Layer | Protection |
450
- |---|---|
451
- | **Data locality** | Index lives in `.milens/` per repo (gitignored). No source code stored in registry |
452
- | **HTTP transport** | Binds to `127.0.0.1` only — requires explicit `--http` flag |
453
- | **User-supplied regex** | Validated against ReDoS patterns |
454
- | **FTS5 queries** | Each token quoted as a literal — no query injection |
455
- | **File access** | All reads bounded to the repo root — no path traversal |
456
- | **Git integration** | `execFileSync` with argument arrays — no shell interpolation |
646
+ Use in MCP config:
647
+ ```json
648
+ {
649
+ "mcpServers": {
650
+ "milens": {
651
+ "command": "npx",
652
+ "args": ["-y", "milens", "serve"],
653
+ "env": { "MILENS_PROFILE": "standard" }
654
+ }
655
+ }
656
+ }
657
+ ```
658
+
659
+ Or from CLI:
660
+ ```bash
661
+ MILENS_PROFILE=minimal milens serve
662
+ ```
457
663
 
458
664
  ---
459
665
 
460
666
  ## Development
461
667
 
462
668
  ```bash
463
- npm install # install dependencies
464
- npm run build # tsc → dist/
465
- npm test # vitest (65 tests)
466
- npm run lint # tsc --noEmit
467
- npm run self-analyze # index this repo
468
- npm run self-serve # start MCP server on port 3100
669
+ git clone https://github.com/fuze210699/milens.git
670
+ cd milens
671
+ npm install
672
+ npm run build # tsc → dist/
673
+ npm test # vitest (136 tests)
674
+ npm run lint # tsc --noEmit
675
+ npm run self-analyze # Index milens with milens
676
+ npm run self-serve # Start MCP on port 3100
469
677
  ```
470
678
 
679
+ **Tech Stack:** TypeScript (ESM) · tree-sitter (WASM) · SQLite (better-sqlite3 + FTS5) · MCP SDK · Vitest · Commander
680
+
471
681
  ---
472
682
 
473
683
  ## License
474
684
 
475
- [PolyForm Noncommercial 1.0.0](LICENSE)
685
+ Core (analyzer, parser, store, CLI, MCP tools): **MIT License**
686
+ Advanced features (GitHub App, enterprise): Commercial license
687
+ See [LICENSE](LICENSE) for details.
688
+
689
+ ---
476
690
 
477
- Architectural inspiration from [GitNexus](https://github.com/abhigyanpatwari/GitNexus) by Abhigyan Patwari.
691
+ <p align="center">
692
+ <a href="https://github.com/fuze210699/milens">GitHub</a> ·
693
+ <a href="https://github.com/fuze210699/milens/tree/main/docs">Docs</a> ·
694
+ <a href="https://github.com/fuze210699/milens/blob/main/docs/pricing.md">Pricing</a> ·
695
+ <a href="https://github.com/fuze210699/milens/blob/main/CONTRIBUTING.md">Contribute</a>
696
+ </p>