milens 0.6.3 → 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 (137) 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 +508 -432
  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.js +1 -1
  36. package/dist/analyzer/engine.js.map +1 -1
  37. package/dist/cli.js +1190 -401
  38. package/dist/cli.js.map +1 -1
  39. package/dist/metrics.d.ts +51 -0
  40. package/dist/metrics.d.ts.map +1 -0
  41. package/dist/metrics.js +64 -0
  42. package/dist/metrics.js.map +1 -0
  43. package/dist/parser/lang-go.js +47 -47
  44. package/dist/parser/lang-java.js +29 -29
  45. package/dist/parser/lang-js.js +105 -105
  46. package/dist/parser/lang-php.js +38 -38
  47. package/dist/parser/lang-py.js +34 -34
  48. package/dist/parser/lang-ruby.js +14 -14
  49. package/dist/parser/lang-rust.js +30 -30
  50. package/dist/parser/lang-ts.js +191 -191
  51. package/dist/security/deps.d.ts +38 -0
  52. package/dist/security/deps.d.ts.map +1 -0
  53. package/dist/security/deps.js +685 -0
  54. package/dist/security/deps.js.map +1 -0
  55. package/dist/security/rules.d.ts +42 -0
  56. package/dist/security/rules.d.ts.map +1 -0
  57. package/dist/security/rules.js +940 -0
  58. package/dist/security/rules.js.map +1 -0
  59. package/dist/server/hooks.d.ts +26 -0
  60. package/dist/server/hooks.d.ts.map +1 -0
  61. package/dist/server/hooks.js +253 -0
  62. package/dist/server/hooks.js.map +1 -0
  63. package/dist/server/mcp-prompts.d.ts +277 -0
  64. package/dist/server/mcp-prompts.d.ts.map +1 -0
  65. package/dist/server/mcp-prompts.js +627 -0
  66. package/dist/server/mcp-prompts.js.map +1 -0
  67. package/dist/server/mcp.d.ts.map +1 -1
  68. package/dist/server/mcp.js +618 -643
  69. package/dist/server/mcp.js.map +1 -1
  70. package/dist/server/test-plan.d.ts +20 -0
  71. package/dist/server/test-plan.d.ts.map +1 -0
  72. package/dist/server/test-plan.js +100 -0
  73. package/dist/server/test-plan.js.map +1 -0
  74. package/dist/skills.js +152 -152
  75. package/dist/store/annotations.d.ts +41 -0
  76. package/dist/store/annotations.d.ts.map +1 -0
  77. package/dist/store/annotations.js +192 -0
  78. package/dist/store/annotations.js.map +1 -0
  79. package/dist/store/confidence.d.ts +18 -0
  80. package/dist/store/confidence.d.ts.map +1 -0
  81. package/dist/store/confidence.js +82 -0
  82. package/dist/store/confidence.js.map +1 -0
  83. package/dist/store/db.d.ts +37 -14
  84. package/dist/store/db.d.ts.map +1 -1
  85. package/dist/store/db.js +332 -239
  86. package/dist/store/db.js.map +1 -1
  87. package/dist/store/schema.sql +128 -116
  88. package/dist/store/vectors.js +2 -2
  89. package/dist/types.d.ts +101 -0
  90. package/dist/types.d.ts.map +1 -1
  91. package/docs/README.md +24 -0
  92. package/package.json +80 -66
  93. package/dist/gateway/analyzer.d.ts +0 -6
  94. package/dist/gateway/analyzer.d.ts.map +0 -1
  95. package/dist/gateway/analyzer.js +0 -218
  96. package/dist/gateway/analyzer.js.map +0 -1
  97. package/dist/gateway/cache.d.ts +0 -35
  98. package/dist/gateway/cache.d.ts.map +0 -1
  99. package/dist/gateway/cache.js +0 -175
  100. package/dist/gateway/cache.js.map +0 -1
  101. package/dist/gateway/config.d.ts +0 -10
  102. package/dist/gateway/config.d.ts.map +0 -1
  103. package/dist/gateway/config.js +0 -167
  104. package/dist/gateway/config.js.map +0 -1
  105. package/dist/gateway/context-memory.d.ts +0 -68
  106. package/dist/gateway/context-memory.d.ts.map +0 -1
  107. package/dist/gateway/context-memory.js +0 -157
  108. package/dist/gateway/context-memory.js.map +0 -1
  109. package/dist/gateway/observability.d.ts +0 -83
  110. package/dist/gateway/observability.d.ts.map +0 -1
  111. package/dist/gateway/observability.js +0 -152
  112. package/dist/gateway/observability.js.map +0 -1
  113. package/dist/gateway/privacy.d.ts +0 -27
  114. package/dist/gateway/privacy.d.ts.map +0 -1
  115. package/dist/gateway/privacy.js +0 -139
  116. package/dist/gateway/privacy.js.map +0 -1
  117. package/dist/gateway/providers.d.ts +0 -66
  118. package/dist/gateway/providers.d.ts.map +0 -1
  119. package/dist/gateway/providers.js +0 -377
  120. package/dist/gateway/providers.js.map +0 -1
  121. package/dist/gateway/router.d.ts +0 -18
  122. package/dist/gateway/router.d.ts.map +0 -1
  123. package/dist/gateway/router.js +0 -102
  124. package/dist/gateway/router.js.map +0 -1
  125. package/dist/gateway/server.d.ts +0 -20
  126. package/dist/gateway/server.d.ts.map +0 -1
  127. package/dist/gateway/server.js +0 -387
  128. package/dist/gateway/server.js.map +0 -1
  129. package/dist/gateway/translator.d.ts +0 -19
  130. package/dist/gateway/translator.d.ts.map +0 -1
  131. package/dist/gateway/translator.js +0 -340
  132. package/dist/gateway/translator.js.map +0 -1
  133. package/dist/gateway/types.d.ts +0 -215
  134. package/dist/gateway/types.d.ts.map +0 -1
  135. package/dist/gateway/types.js +0 -3
  136. package/dist/gateway/types.js.map +0 -1
  137. package/dist/store/gateway-schema.sql +0 -53
package/README.md CHANGED
@@ -1,620 +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-32-purple" alt="32 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="#mcp-tools">MCP Tools</a>
22
- <a href="#tool-examples">Examples</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.
32
-
33
- **Why not let milens save your wallet?**
29
+ AI coding agents are powerful but they don't truly know your codebase.
34
30
 
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.
31
+ **What happens every session:**
36
32
 
37
- If you're concerned about security, read our [Security & Privacy](#security--privacy) guarantees — milens is fully offline, zero telemetry, localhost-only.
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**
38
36
 
39
- ### How milens Solves This
40
-
41
- <p align="center">
42
- <img src="https://raw.githubusercontent.com/fuze210699/milens/develop/docs/diagram1.svg" alt="Without milens vs With milens comparison" width="700">
43
- </p>
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.
44
38
 
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.
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.
46
40
 
47
41
  ---
48
42
 
49
- ## Quick Start
43
+ ## Without Milens vs With Milens
50
44
 
51
- ```bash
52
- npx milens analyze # index your codebase
53
- ```
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 |
54
55
 
55
- Then add the MCP server to your editor ([setup below](#editor-setup)) and your agent immediately gets 32 code intelligence tools.
56
+ **Average savings: ~70% fewer tokens per session. ~50% faster task completion.**
56
57
 
57
58
  ---
58
59
 
59
- ## CLI Commands
60
+ ## What is Milens?
60
61
 
61
- ### `milens analyze` Index a codebase
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.
62
63
 
63
- Parse all source files, resolve cross-file dependencies, and build a searchable knowledge graph.
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**.
64
65
 
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
70
- ```
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
71
 
72
- **Output:** A `.milens/milens.db` SQLite database containing every symbol, relationship, and search index.
72
+ Fully offline. Zero telemetry. Localhost-only MCP server. One command to bootstrap.
73
73
 
74
- **Incremental mode:** By default, only re-parses files whose SHA-256 hash has changed since the last run.
74
+ ```
75
+ npx milens init --profile full
76
+ ```
75
77
 
76
- #### Generating AI skill files
78
+ ---
77
79
 
78
- Skill files teach your AI agent the codebase structure — key symbols, entry points, cross-area dependencies — without reading every file.
80
+ ## Quick Start
79
81
 
80
82
  ```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
83
+ npm install -g milens # install globally
84
+ cd your-project
85
+ milens init --profile full --interactive # bootstrap everything
87
86
  ```
88
87
 
89
- | Flag | Output files |
90
- |---|---|
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` |
96
-
97
- > Root config files use `<!-- milens:start/end -->` markers for **idempotent injection** — re-running replaces the milens section without overwriting your custom content.
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.
98
89
 
99
- **Team Collaboration Notes:**
90
+ Then connect your editor:
100
91
 
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
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
+ ```
105
104
 
106
- See [`.milens/README.md`](https://github.com/fuze210699/milens/blob/develop/.milens/README.md) for more details on the index directory.
105
+ ```bash
106
+ # Claude Code
107
+ claude mcp add milens -- npx -y milens serve -p .
107
108
 
108
- ---
109
+ # Cursor — .cursor/mcp.json
110
+ { "mcpServers": { "milens": { "command": "npx", "args": ["-y", "milens", "serve", "-p", "."] } } }
109
111
 
110
- ### `milens search` Find symbols by name
112
+ # OpenCode.opencode/config.json
113
+ { "mcp": { "milens": { "command": "npx", "args": ["-y", "milens", "serve"] } } }
114
+ ```
111
115
 
112
- Full-text search (BM25) across all indexed symbol names and file paths.
116
+ Open your AI agent. It auto-loads `AGENTS.md` with codebase context. You're ready.
113
117
 
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
- ```
118
+ ---
119
119
 
120
- **Output format:** `name [kind] file:line (exported)`
120
+ ## Architecture
121
121
 
122
122
  ```
123
- AuthService [class] src/auth.ts:15 (exported)
124
- hashPassword [function] src/auth.ts:3 (exported)
125
- ```
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
+ ```
151
+
152
+ ### Four-Layer Stack
153
+
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
178
+
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 |
193
+ |---|---|
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. |
126
201
 
127
202
  ---
128
203
 
129
- ### `milens inspect` — 360° symbol view
130
-
131
- Show everything about a symbol: who calls it (incoming) and what it depends on (outgoing).
204
+ ## MCP Tools (33)
132
205
 
133
- ```bash
134
- milens inspect "AuthService"
135
- milens inspect "resolveLinks" -p .
136
- ```
206
+ ### Search & Navigation
137
207
 
138
- **Output:**
139
-
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
- ```
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 |
150
215
 
151
- ---
216
+ ### Safety & Impact
152
217
 
153
- ### `milens impact` Blast radius analysis
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 |
154
225
 
155
- Recursively trace what depends on a symbol (upstream) or what a symbol depends on (downstream).
226
+ ### Understanding Code
156
227
 
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
- ```
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 |
162
235
 
163
- **Output:**
236
+ ### Review & Testing
164
237
 
165
- ```
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)
170
- ```
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 |
171
246
 
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
247
+ ### Memory & Sessions
176
248
 
177
- ---
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 |
178
257
 
179
- ### `milens serve` — Start MCP server
258
+ ### Security
180
259
 
181
- Expose the knowledge graph to AI agents via the Model Context Protocol.
260
+ | Tool | Does |
261
+ |---|---|
262
+ | `security_scan` | **50+ rules in one call.** Scopes: secrets, injection, unicode, dangerous, config, data-leak, crypto, auth, file-access |
182
263
 
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
188
- ```
264
+ ### Overview & Similarity
189
265
 
190
- **stdio mode** (default): Used by editors like VS Code, Cursor, and Claude Code. The agent communicates through stdin/stdout.
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) |
191
272
 
192
- **HTTP mode**: Used by remote agents or custom integrations. Binds to `127.0.0.1` only — no network exposure.
273
+ ### Developer
193
274
 
194
- Endpoint: `POST http://localhost:3100/mcp`
275
+ | Tool | Does |
276
+ |---|---|
277
+ | `ast_explore` | Parse code snippet → S-expression AST tree |
278
+ | `test_query` | Test a tree-sitter query against code |
195
279
 
196
280
  ---
197
281
 
198
- ### `milens status` — Show index stats
282
+ ## Tool Output Examples
283
+
284
+ ### Context — 360° Symbol View
199
285
 
200
- ```bash
201
- milens status # current directory
202
- milens status -p /path/to/repo # specific repo
203
286
  ```
287
+ context({name: "AuthService"})
288
+
289
+ AuthService [class] src/auth.ts:15 (exported)
290
+ role: hub | heat: 0.85
204
291
 
205
- **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
206
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
207
301
  ```
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
302
+
303
+ ### Impact — Blast Radius
304
+
214
305
  ```
306
+ impact({target: "createUser", direction: "upstream", depth: 3})
215
307
 
216
- ---
308
+ TARGET: createUser [function] src/models.ts:42
217
309
 
218
- ### `milens list` — List all indexed repositories
310
+ [depth 1] WILL BREAK:
311
+ AuthService [class] src/auth.ts:15 (calls)
312
+ UserController [class] src/controllers/user.ts:8 (calls)
219
313
 
220
- ```bash
221
- milens list
222
- ```
314
+ [depth 2] LIKELY AFFECTED:
315
+ handleLogin [function] src/routes.ts:23 (calls)
316
+ handleRegister [function] src/routes.ts:45 (calls)
223
317
 
224
- **Output:**
318
+ [depth 3] MAY NEED TESTING:
319
+ authRouter [variable] src/routes.ts:1 (imports)
320
+ adminDashboard [function] src/admin.ts:10 (calls)
225
321
 
322
+ 5 dependents across 3 depths
226
323
  ```
227
- 3 indexed repositories:
228
324
 
229
- /home/user/project-a
230
- DB: /home/user/project-a/.milens/milens.db
231
- Indexed: 2026-04-11T10:30:00Z
325
+ ### Review PR — Risk Assessment
232
326
 
233
- /home/user/project-b
234
- DB: /home/user/project-b/.milens/milens.db
235
- Indexed: 2026-04-10T15:22:00Z
236
327
  ```
328
+ review_pr({})
237
329
 
238
- ---
330
+ PR Risk Assessment (vs HEAD):
331
+ 6 changed files, 12 affected symbols
239
332
 
240
- ### `milens clean`Remove index
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)
241
337
 
242
- ```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
338
+ Summary: CRITICAL=1 HIGH=2 MEDIUM=4 LOW=5
246
339
  ```
247
340
 
248
- ---
249
-
250
- ### `milens dashboard` — Usage analytics
341
+ ### Security Scan — 50 Rules at Once
251
342
 
252
- Open a browser-based dashboard showing tool usage statistics, token savings, and response times.
343
+ ```
344
+ security_scan({scope: "all", severity: "HIGH"})
253
345
 
254
- ```bash
255
- milens dashboard # open on port 3200
256
- milens dashboard --port 8080 # custom port
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
+ }
257
376
  ```
258
377
 
259
378
  ---
260
379
 
261
- ## MCP Tools
380
+ ## Sub-agent Prompts (6)
262
381
 
263
- When the MCP server is running, your AI agent gets these 32 tools:
382
+ Instead of chaining 5-10 tools manually, your agent calls one prompt:
264
383
 
265
- ### Search & Navigate
266
-
267
- | Tool | What It Does | Example |
384
+ | Prompt | Input | Workflow |
268
385
  |---|---|---|
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"})` |
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** |
274
392
 
275
- ### Impact & Safety
393
+ ---
276
394
 
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({})` |
395
+ ## CLI Commands
283
396
 
284
- ### Understanding
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
415
+ ```
285
416
 
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 (11 frameworks) | `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"})` |
417
+ ### Workflow Examples
293
418
 
294
- ### Codebase Overview
419
+ ```bash
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
425
+ ```
295
426
 
296
- | Tool | What It Does | Example |
297
- |---|---|---|
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({})` |
427
+ ### Profile Selection
301
428
 
302
- ### Developer Tools
429
+ Control how many tools are active to optimize token overhead:
303
430
 
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"})` |
431
+ ```bash
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
435
+ ```
308
436
 
309
- ### Review & Risk Assessment
437
+ ---
310
438
 
311
- | Tool | What It Does | Example |
312
- |---|---|---|
313
- | `review_pr` | PR risk assessment: scores changed symbols by blast radius + test coverage | `review_pr({})` |
314
- | `review_symbol` | Single symbol risk: role, heat, dependents, test status | `review_symbol({name: "AuthService"})` |
315
- | `codebase_summary` | High-level bootstrapping context: domains, key symbols, coverage | `codebase_summary({})` |
439
+ ## Security (50+ Rules)
316
440
 
317
- ### Testing
441
+ All 50 rules map to **OWASP Top 10 (2021)**. One tool call covers what used to take 10 manual greps.
318
442
 
319
- | Tool | What It Does | Example |
443
+ | Category | Rules | Detects |
320
444
  |---|---|---|
321
- | `test_plan` | Dependency-aware test plan: mocks, strategies, suggested tests | `test_plan({name: "createUser"})` |
322
- | `test_coverage_gaps` | Untested exported symbols sorted by risk | `test_coverage_gaps({})` |
323
- | `test_impact` | Maps git changes test files to run | `test_impact({})` |
324
-
325
- ### Annotations & Sessions
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 |
326
454
 
327
- | Tool | What It Does | Example |
328
- |---|---|---|
329
- | `annotate` | Store observation/note about a symbol (persists across sessions) | `annotate({symbol: "AuthService", key: "note", value: "needs refactor"})` |
330
- | `recall` | Retrieve annotations by symbol, key, agent, or session | `recall({symbol: "AuthService"})` |
331
- | `session_start` | Register agent session for multi-agent coordination | `session_start({agent: "copilot"})` |
332
- | `session_context` | Get session metadata + annotations | `session_context({})` |
333
- | `handoff` | Transfer context between agent sessions | `handoff({from_session: "abc", to_session: "def"})` |
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
+ ```
334
459
 
335
- ### Search & Similarity
460
+ From an AI agent: `security_scan({scope: "all", severity: "HIGH"})`
336
461
 
337
- | Tool | What It Does | Example |
338
- |---|---|---|
339
- | `semantic_search` | Hybrid FTS5 + vector cosine similarity search | `semantic_search({query: "authentication flow"})` |
340
- | `find_similar` | Find symbols similar by embedding proximity | `find_similar({name: "AuthService"})` |
462
+ ---
341
463
 
342
- > `semantic_search` and `find_similar` require `milens analyze --embeddings` to generate vector embeddings.
464
+ ## Hook System (6 Triggers)
343
465
 
344
- ### Resources & Prompts
466
+ Automation so your agent never forgets:
345
467
 
346
- **4 Resources:** `milens://overview`, `milens://symbol/{name}`, `milens://file/{path}`, `milens://domain/{name}`
468
+ | Hook | When | Default Action |
469
+ |---|---|---|
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 |
347
476
 
348
- **3 Guided Prompts:** `delete-feature`, `refactor-symbol`, `explore-symbol` — each triggers a multi-step workflow using the tools above.
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
+ ```
349
482
 
350
483
  ---
351
484
 
352
- ## Tool Examples
485
+ ## Learning & Evolution
353
486
 
354
- ### Impact Analysis
487
+ The system gets smarter every session:
355
488
 
356
489
  ```
357
- impact({target: "createUser"})
490
+ SESSION 1: Agent finds bug in createUser()
491
+ → annotate({symbol: "createUser", key: "bug", value: "Call createUser() before normalizeEmail()"})
492
+ → confidence: 0.5
358
493
 
359
- TARGET: createUser [function] src/models.ts:42
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
360
497
 
361
- [depth 1] AuthService [class] src/auth.ts:15 (calls)
362
- [depth 1] UserController [class] src/controllers/user.ts:8 (calls)
363
- [depth 2] handleLogin [function] src/routes.ts:23 (calls)
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
+ ```
364
502
 
365
- 3 dependents across 2 depths
503
+ ```bash
504
+ milens evolve # Promote high-confidence patterns now
505
+ milens evolve --schedule install # Auto-run weekly (cron/schtasks)
366
506
  ```
367
507
 
368
- ### Context (360° Symbol View)
508
+ ---
369
509
 
370
- ```
371
- context({name: "AuthService"})
510
+ ## Supported Languages
372
511
 
373
- AuthService [class] src/auth.ts:15 (exported)
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.
374
530
 
375
- incoming (3):
376
- calls: handleLogin [function] src/routes.ts:23
377
- calls: UserController [class] src/controllers/user.ts:8
378
- imports: authRouter [variable] src/routes.ts:1
531
+ ---
379
532
 
380
- outgoing (3):
381
- imports: User [class] src/models.ts:5
382
- calls: hashPassword [function] src/auth.ts:3
383
- calls: createUser [function] src/models.ts:42
384
- ```
533
+ ## Editor & Harness Support
385
534
 
386
- ### Edit Check (Pre-Edit Safety)
535
+ Milens works with any MCP-compatible agent. Two ways to use:
387
536
 
388
- ```
389
- edit_check({name: "resolveLinks"})
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` |
544
+
545
+ **Harness adapters available for 7 editors:**
390
546
 
391
- resolveLinks [function] src/analyzer/resolver.ts:45 (exported)
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 |
392
556
 
393
- callers (2):
394
- analyze [function] src/analyzer/engine.ts:89
395
- resolveLinksForFile [function] src/analyzer/resolver.ts:120
557
+ Each adapter is in the `adapters/` directory with ready-to-copy config files and agent instructions.
396
558
 
397
- re-exported via:
398
- src/analyzer/index.ts:3
559
+ ---
399
560
 
400
- has test coverage
401
- ⚠ 2 direct callers will be affected
402
- ```
561
+ ## Metrics
403
562
 
404
- ### Smart Context (Intent-Aware)
563
+ Seven quantified metrics for AI-driven development:
405
564
 
406
565
  ```
407
- smart_context({name: "UserService", intent: "edit"})
566
+ $ milens metrics
408
567
 
409
- UserService [class] src/services/user.ts:10 (exported)
410
- role: hub | heat: 0.85
411
-
412
- callers (5):
413
- handleLogin, handleRegister, UserController, AdminController, testUserService
414
- direct dependencies (3):
415
- User [class], hashPassword [function], db [variable]
416
- indirect dependents (depth 2): 8 symbols
417
- re-exported via: src/services/index.ts:2
418
- has test coverage
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
+ ╚══════════════════════════════════════════════╝
419
579
  ```
420
580
 
421
- ### Routes Detection
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 |
422
590
 
423
- ```
424
- routes({})
591
+ ---
425
592
 
426
- 11 routes detected:
593
+ ## Security & Privacy
427
594
 
428
- [express]
429
- GET /api/users (src/routes/users.ts:12) → getUsers [function]
430
- POST /api/users (src/routes/users.ts:25) → createUser [function]
595
+ **Zero network. Zero telemetry. Zero data leaving your machine.**
431
596
 
432
- [nestjs]
433
- GET /auth/login (src/auth/auth.controller.ts:15) → login [method]
434
- ```
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. |
435
605
 
436
606
  ---
437
607
 
438
- ## Editor Setup
608
+ ## Pricing
439
609
 
440
- ### Editor Support
441
-
442
- | Editor | MCP | Skills |
610
+ | Tier | Price | Key Features |
443
611
  |---|---|---|
444
- | **VS Code / Copilot** | | |
445
- | **Cursor** | | |
446
- | **Claude Code** | | |
447
- | **Windsurf** | ✓ | ✓ |
448
- | **Codex** | ✓ | — |
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 |
449
615
 
450
- ### VS Code / GitHub Copilot
616
+ OSS stays free forever. [Full pricing details →](docs/pricing.md)
451
617
 
452
- ```bash
453
- npx milens analyze -p . # index your repo (run once)
454
- ```
618
+ ---
455
619
 
456
- Add to `.vscode/mcp.json`:
620
+ ## What's New in v0.7.0
457
621
 
458
- ```json
459
- {
460
- "servers": {
461
- "milens": {
462
- "type": "stdio",
463
- "command": "npx",
464
- "args": ["-y", "milens", "serve", "-p", "${workspaceFolder}"]
465
- }
466
- }
467
- }
468
- ```
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.
469
634
 
470
- <details>
471
- <summary><strong>Other Editors</strong></summary>
635
+ [Full changelog →](https://github.com/fuze210699/milens/releases)
472
636
 
473
- #### Cursor
637
+ ---
474
638
 
475
- Add to `.cursor/mcp.json`:
639
+ ## Environment Variables
476
640
 
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 |
645
+
646
+ Use in MCP config:
477
647
  ```json
478
648
  {
479
649
  "mcpServers": {
480
650
  "milens": {
481
651
  "command": "npx",
482
- "args": ["-y", "milens", "serve", "-p", "."]
652
+ "args": ["-y", "milens", "serve"],
653
+ "env": { "MILENS_PROFILE": "standard" }
483
654
  }
484
655
  }
485
656
  }
486
657
  ```
487
658
 
488
- #### Claude Code
489
-
659
+ Or from CLI:
490
660
  ```bash
491
- claude mcp add milens -- npx -y milens serve -p .
492
- ```
493
-
494
- #### Windsurf
495
-
496
- Add to `~/.codeium/windsurf/mcp_config.json`:
497
-
498
- ```json
499
- {
500
- "mcpServers": {
501
- "milens": {
502
- "command": "npx",
503
- "args": ["-y", "milens", "serve", "-p", "."]
504
- }
505
- }
506
- }
661
+ MILENS_PROFILE=minimal milens serve
507
662
  ```
508
663
 
509
- #### Codex
664
+ ---
510
665
 
511
- Add to `.codex/config.toml`:
666
+ ## Development
512
667
 
513
- ```toml
514
- [mcp_servers.milens]
515
- command = "npx"
516
- args = ["-y", "milens", "serve", "-p", "."]
668
+ ```bash
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
517
677
  ```
518
678
 
519
- </details>
679
+ **Tech Stack:** TypeScript (ESM) · tree-sitter (WASM) · SQLite (better-sqlite3 + FTS5) · MCP SDK · Vitest · Commander
520
680
 
521
681
  ---
522
682
 
523
- ## Supported Languages
683
+ ## License
524
684
 
525
- | Language | Extensions | Imports | Calls | Heritage | Frameworks |
526
- |---|---|---|---|---|---|
527
- | TypeScript | `.ts` `.tsx` | ✓ ESM + require | ✓ + decorators | ✓ extends/implements | NestJS, React JSX |
528
- | JavaScript | `.js` `.jsx` `.mjs` `.cjs` | ✓ ESM + require | ✓ | ✓ | React JSX, Express |
529
- | Python | `.py` | ✓ + relative | ✓ + decorators | ✓ | FastAPI, Flask, Django |
530
- | Java | `.java` | ✓ + static | ✓ + annotations, new | ✓ | Spring |
531
- | Go | `.go` | ✓ + go.mod | ✓ | ✓ embedding | net/http, Gin |
532
- | Rust | `.rs` | ✓ | ✓ + macros | ✓ | — |
533
- | PHP | `.php` | ✓ + include | ✓ + static, new | ✓ + traits | Laravel |
534
- | Ruby | `.rb` | ✓ | ✓ | ✓ | Rails, Sinatra |
535
- | Vue | `.vue` | ✓ | ✓ template refs | ✓ | Vue 3 SFC |
536
- | HTML | `.html` `.htm` | ✓ `<script src>` `<link>` | ✓ inline `<script>` | — | — |
537
- | CSS | `.css` | ✓ `@import` | — | — | Custom properties |
538
- | Markdown | `.md` `.mdx` | ✓ local `[links]()` | — | — | Headings → section symbols, parent-child hierarchy |
685
+ Core (analyzer, parser, store, CLI, MCP tools): **MIT License**
686
+ Advanced features (GitHub App, enterprise): Commercial license
687
+ See [LICENSE](LICENSE) for details.
539
688
 
540
689
  ---
541
690
 
542
- ## Architecture
543
-
544
691
  <p align="center">
545
- <img src="https://raw.githubusercontent.com/fuze210699/milens/develop/docs/diagram2.svg" alt="milens architecture: Indexing Pipeline → MCP Server → AI Agent" width="700">
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>
546
696
  </p>
547
-
548
- ### How it works
549
-
550
- 1. **Scan** — find all source files matching supported extensions
551
- 2. **Parse** — tree-sitter extracts symbols (functions, classes, methods, etc.) and raw references (imports, calls, extends)
552
- 3. **Resolve** — cross-file link resolution: match import paths to files, match call names to symbol definitions
553
- 4. **Enrich** — compute roles (entrypoint/hub/utility/leaf), heat scores, domain clusters
554
- 5. **Persist** — store everything in SQLite with FTS5 search and recursive CTEs for graph traversal
555
-
556
- ### Multi-Repo
557
-
558
- milens uses a global registry (`~/.milens/`) — one MCP server serves all indexed repos. Pass `repo` to target a specific one when multiple are registered.
559
-
560
- <p align="center">
561
- <img src="https://raw.githubusercontent.com/fuze210699/milens/develop/docs/diagram3.svg" alt="Multi-repo architecture" width="500">
562
- </p>
563
-
564
- ### Design Decisions
565
-
566
- | Decision | Rationale |
567
- |---|---|
568
- | **Declarative LangSpec** | Each language = 1 config object with tree-sitter queries. One universal extractor for all 12 languages |
569
- | **SQLite + recursive CTE** | Impact analysis runs entirely in the database — no full graph in memory |
570
- | **Token-compact output** | `name [kind] file:line` format — saves 40-60% tokens for AI |
571
- | **Incremental by hash** | SHA-256 file hashing — only changed files get re-parsed |
572
- | **Localhost-only HTTP** | Binds `127.0.0.1` — no network exposure without explicit intent |
573
-
574
- ### Tech Stack
575
-
576
- | Layer | Technology |
577
- |---|---|
578
- | **Runtime** | Node.js ≥ 20 |
579
- | **Language** | TypeScript (ESM) |
580
- | **Parsing** | tree-sitter (WASM bindings) |
581
- | **Database** | SQLite (better-sqlite3) + FTS5 |
582
- | **Graph traversal** | Recursive CTEs |
583
- | **Agent protocol** | MCP (stdio + StreamableHTTP) |
584
- | **Testing** | Vitest (136 tests) |
585
-
586
- ---
587
-
588
- ## Security & Privacy
589
-
590
- milens is **offline by design** — zero network calls, zero telemetry.
591
-
592
- | Layer | Protection |
593
- |---|---|
594
- | **Data locality** | Index lives in `.milens/` per repo (gitignored). No source code stored in registry |
595
- | **HTTP transport** | Binds to `127.0.0.1` only — requires explicit `--http` flag |
596
- | **User-supplied regex** | Validated against ReDoS patterns |
597
- | **FTS5 queries** | Each token quoted as a literal — no query injection |
598
- | **File access** | All reads bounded to the repo root — no path traversal |
599
- | **Git integration** | `execFileSync` with argument arrays — no shell interpolation |
600
-
601
- ---
602
-
603
- ## Development
604
-
605
- ```bash
606
- npm install # install dependencies
607
- npm run build # tsc → dist/
608
- npm test # vitest (136 tests)
609
- npm run lint # tsc --noEmit
610
- npm run self-analyze # index this repo
611
- npm run self-serve # start MCP server on port 3100
612
- ```
613
-
614
- ---
615
-
616
- ## License
617
-
618
- [PolyForm Noncommercial 1.0.0](https://github.com/fuze210699/milens/blob/develop/LICENSE)
619
-
620
- Architectural inspiration from [GitNexus](https://github.com/abhigyanpatwari/GitNexus) by Abhigyan Patwari.