milens 0.6.4 → 0.6.5

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 (67) hide show
  1. package/.agents/skills/adapters/SKILL.md +20 -0
  2. package/.agents/skills/analyzer/SKILL.md +35 -13
  3. package/.agents/skills/apps/SKILL.md +25 -1
  4. package/.agents/skills/docs/SKILL.md +32 -5
  5. package/.agents/skills/milens/SKILL.md +36 -6
  6. package/.agents/skills/milens-architect/SKILL.md +128 -0
  7. package/.agents/skills/milens-debugger/SKILL.md +141 -0
  8. package/.agents/skills/orchestrator/SKILL.md +59 -0
  9. package/.agents/skills/parser/SKILL.md +35 -14
  10. package/.agents/skills/root/SKILL.md +39 -17
  11. package/.agents/skills/scripts/SKILL.md +21 -3
  12. package/.agents/skills/security/SKILL.md +32 -11
  13. package/.agents/skills/server/SKILL.md +45 -19
  14. package/.agents/skills/store/SKILL.md +40 -18
  15. package/.agents/skills/test/SKILL.md +57 -9
  16. package/LICENSE +21 -75
  17. package/README.md +260 -433
  18. package/dist/agents-md.d.ts.map +1 -1
  19. package/dist/agents-md.js +5 -3
  20. package/dist/agents-md.js.map +1 -1
  21. package/dist/analyzer/engine.d.ts +1 -0
  22. package/dist/analyzer/engine.d.ts.map +1 -1
  23. package/dist/analyzer/engine.js +36 -6
  24. package/dist/analyzer/engine.js.map +1 -1
  25. package/dist/cli.js +296 -19
  26. package/dist/cli.js.map +1 -1
  27. package/dist/orchestrator/orchestrator.d.ts +65 -0
  28. package/dist/orchestrator/orchestrator.d.ts.map +1 -0
  29. package/dist/orchestrator/orchestrator.js +178 -0
  30. package/dist/orchestrator/orchestrator.js.map +1 -0
  31. package/dist/orchestrator/reporter.d.ts +15 -0
  32. package/dist/orchestrator/reporter.d.ts.map +1 -0
  33. package/dist/orchestrator/reporter.js +38 -0
  34. package/dist/orchestrator/reporter.js.map +1 -0
  35. package/dist/security/rules.d.ts.map +1 -1
  36. package/dist/security/rules.js +4 -1
  37. package/dist/security/rules.js.map +1 -1
  38. package/dist/server/hooks.d.ts +3 -0
  39. package/dist/server/hooks.d.ts.map +1 -1
  40. package/dist/server/hooks.js +79 -0
  41. package/dist/server/hooks.js.map +1 -1
  42. package/dist/server/mcp-prompts.d.ts.map +1 -1
  43. package/dist/server/mcp-prompts.js +1 -1
  44. package/dist/server/mcp-prompts.js.map +1 -1
  45. package/dist/server/mcp.d.ts.map +1 -1
  46. package/dist/server/mcp.js +418 -15
  47. package/dist/server/mcp.js.map +1 -1
  48. package/dist/server/watcher.d.ts +39 -0
  49. package/dist/server/watcher.d.ts.map +1 -0
  50. package/dist/server/watcher.js +134 -0
  51. package/dist/server/watcher.js.map +1 -0
  52. package/dist/skills.js +51 -7
  53. package/dist/skills.js.map +1 -1
  54. package/dist/store/annotations.d.ts.map +1 -1
  55. package/dist/store/annotations.js +18 -15
  56. package/dist/store/annotations.js.map +1 -1
  57. package/dist/store/confidence.d.ts +10 -0
  58. package/dist/store/confidence.d.ts.map +1 -1
  59. package/dist/store/confidence.js +28 -1
  60. package/dist/store/confidence.js.map +1 -1
  61. package/dist/store/db.d.ts +16 -0
  62. package/dist/store/db.d.ts.map +1 -1
  63. package/dist/store/db.js +121 -7
  64. package/dist/store/db.js.map +1 -1
  65. package/dist/store/schema.sql +24 -9
  66. package/docs/README.md +3 -5
  67. package/package.json +4 -3
package/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  <a href="https://www.npmjs.com/package/milens"><img src="https://img.shields.io/npm/v/milens" alt="npm"></a>
8
8
  <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node"></a>
9
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">
10
+ <img src="https://img.shields.io/badge/tools-41-purple" alt="41 tools">
11
+ <img src="https://img.shields.io/badge/prompts-7-orange" alt="7 prompts">
12
12
  <img src="https://img.shields.io/badge/security-50%2B-red" alt="50+ rules">
13
13
  <img src="https://img.shields.io/badge/harnesses-7-lightgrey" alt="7 harnesses">
14
14
  </p>
@@ -19,60 +19,56 @@
19
19
  <a href="https://github.com/fuze210699/milens">⭐ Star</a> ·
20
20
  <a href="https://github.com/sponsors/fuze210699">💖 Sponsor</a> ·
21
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>
22
+ <a href="https://github.com/fuze210699/milens/blob/main/docs/pricing.md">Pro $1/seat</a>
23
23
  </p>
24
24
 
25
25
  ---
26
26
 
27
- ## The Problem
27
+ ## Quick Install
28
28
 
29
- AI coding agents are powerful — but they don't truly know your codebase.
30
-
31
- **What happens every session:**
32
-
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
-
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
-
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
-
41
- ---
42
-
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.**
29
+ ```bash
30
+ npx milens init --profile full
31
+ npx milens analyze -p . --force
32
+ ```
57
33
 
58
34
  ---
59
35
 
60
36
  ## What is Milens?
61
37
 
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**.
38
+ Milens is a code intelligence platform that gives AI coding agents instant understanding of your codebase. 41 MCP tools, 7 sub-agent prompts, 7 CLI workflows, and 50 security rules. It builds a knowledge graph of your entire project every function, class, import, call, and inheritance chain — then exposes it through MCP tools. Agents query the graph instead of searching files. **70% fewer tokens** per session, **zero broken dependencies**, and a system that **learns from every session**.
65
39
 
66
40
  - **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.
41
+ - **Query instantly.** FTS5 search, recursive CTE traversal — all in-database.
68
42
  - **Edit safely.** Every tool returns a blast radius before you change anything.
69
43
  - **Scan automatically.** 50+ security rules run in one call, not ten greps.
70
44
  - **Learn continuously.** Annotations persist across sessions. Patterns auto-promote to rules.
71
45
 
72
46
  Fully offline. Zero telemetry. Localhost-only MCP server. One command to bootstrap.
73
47
 
48
+ ---
49
+
50
+ ## Architecture
51
+
74
52
  ```
75
- npx milens init --profile full
53
+ npx milens init
54
+
55
+ ┌─────▼──────┐
56
+ │ Analyzer │ ── Parse 12 langs
57
+ └─────┬──────┘ (tree-sitter WASM)
58
+
59
+ ┌─────▼──────┐
60
+ │ Store │ ── SQLite + FTS5
61
+ └─────┬──────┘ (symbols, links, metadata)
62
+
63
+ ┌─────▼──────┐
64
+ │ Server │ ── MCP stdio/HTTP
65
+ └─────┬──────┘ 41 tools
66
+
67
+ ┌──────────┴──────────┐
68
+ ▼ ▼
69
+ AI Agent (MCP) CLI (terminal)
70
+
71
+ Pipeline stages: Parser (tree-sitter CST) → Analyzer (symbol extraction + dependency resolution) → Store (SQLite insert + index) → Server (MCP tool dispatch)
76
72
  ```
77
73
 
78
74
  ---
@@ -111,328 +107,204 @@ claude mcp add milens -- npx -y milens serve -p .
111
107
 
112
108
  # OpenCode — .opencode/config.json
113
109
  { "mcp": { "milens": { "command": "npx", "args": ["-y", "milens", "serve"] } } }
114
- ```
115
110
 
116
- Open your AI agent. It auto-loads `AGENTS.md` with codebase context. You're ready.
111
+ # Codex .codex/config.toml
112
+ [mcp_servers.milens]
113
+ command = "npx"
114
+ args = ["-y", "milens", "serve", "-p", "."]
117
115
 
118
- ---
119
-
120
- ## Architecture
116
+ # Gemini — .gemini/settings.json
117
+ { "mcpServers": { "milens": { "command": "npx", "args": ["-y", "milens", "serve", "-p", "."] } } }
121
118
 
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
119
+ # Zed — .zed/settings.json
120
+ { "mcp_servers": { "milens": { "command": "npx", "args": ["-y", "milens", "serve", "-p", "."] } } }
150
121
  ```
151
122
 
152
- ### Four-Layer Stack
123
+ Open your AI agent. It auto-loads `AGENTS.md` with codebase context. You're ready.
153
124
 
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
- ```
125
+ ---
176
126
 
177
- ### Pipeline
127
+ ## Without Milens vs With Milens
178
128
 
179
- | Stage | What Happens | Technology |
129
+ | Situation | Without Milens | With Milens |
180
130
  |---|---|---|
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. |
131
+ | **Understand a new codebase** | Agent reads 15 files blind (~30,000 tokens) | `codebase_summary()` — 500 tokens |
132
+ | **Edit a function safely** | No idea what depends on it | `impact({target, depth: 3})` — exact blast radius |
133
+ | **Find all references** | Grep 5 times, read 8 files | `context({name})` incoming + outgoing, one call |
134
+ | **Review a PR** | Read diff, guess risk | `review_pr()` every symbol scored CRITICAL/HIGH/MEDIUM/LOW |
135
+ | **Security audit** | 10 manual greps | `security_scan()` 50 rules, one tool call |
136
+ | **Start a new session** | Zero context | `recall()` agent remembers every past lesson |
137
+ | **Write tests** | Guess what needs testing | `test_plan()` mock strategy + 3 scenarios |
138
+ | **Find dead code** | Manual search | `find_dead_code()` every symbol with zero references |
201
139
 
202
- ---
203
-
204
- ## MCP Tools (33)
205
-
206
- ### Search & Navigation
140
+ **Average savings: ~70% fewer tokens per session. ~50% faster task completion.**
207
141
 
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 |
142
+ ---
215
143
 
216
- ### Safety & Impact
144
+ ## Features at a Glance
217
145
 
218
- | Tool | Does |
146
+ | Feature | Description |
219
147
  |---|---|
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 |
148
+ | 🔍 Code Intelligence | 41 MCP tools query, impact, context, trace, routes |
149
+ | 🛡️ Security Scanner | 50 rules, 9 categories, OWASP-mapped, dependency audit |
150
+ | 🤖 Sub-Agent Prompts | 7 prompts plan, review, tdd, security, architect, debug, dead_code_remove |
151
+ | 🔄 CLI Workflows | 7 commands tdd, review, plan, onboard, security-scan, refactor, handoff |
152
+ | 📊 Metrics | 7 quantified metrics TER, LR, CQI, BRR, TCGR, DCER, CTR |
153
+ | 🧠 Learning Engine | Annotate → Recall → Evolve — confidence-based knowledge base |
154
+ | 🔌 12 Languages | TS, JS, Python, Java, Go, Rust, PHP, Ruby, Vue, HTML, CSS, Markdown |
155
+ | 🖥️ 7 Editors | Claude Code, Cursor, Copilot, OpenCode, Codex, Gemini CLI, Zed |
225
156
 
226
- ### Understanding Code
157
+ ---
227
158
 
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 |
159
+ ## CLI Commands
235
160
 
236
- ### Review & Testing
161
+ ### Core
237
162
 
238
- | Tool | Does |
163
+ | Command | Description |
239
164
  |---|---|
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 |
165
+ | `analyze` | Index codebase into knowledge graph |
166
+ | `serve` | Start MCP server (stdio/HTTP) |
167
+ | `search` | FTS5 search across symbols |
168
+ | `status` | Index health check |
169
+ | `metrics` | 7-metric quality report |
170
+ | `init` | Bootstrap project with profile presets |
171
+ | `watch` | Auto-reindex on file changes |
246
172
 
247
- ### Memory & Sessions
173
+ ### Workflows
248
174
 
249
- | Tool | Does |
175
+ | Command | Description |
250
176
  |---|---|
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 |
177
+ | `milens workflow tdd` | Test coverage gaps + risk-prioritized untested symbols |
178
+ | `milens workflow review` | PR risk analysis git diff + heat scoring |
179
+ | `milens workflow plan` | Codebase summary domains, top hubs |
180
+ | `milens workflow onboard` | Onboarding report structure, entry points, next steps |
181
+ | `milens workflow security-scan` | Full security audit with all 50 rules |
182
+ | `milens workflow refactor` | Dead code detection + candidates |
183
+ | `milens workflow handoff` | Session knowledge summary + promotable annotations |
257
184
 
258
185
  ### Security
259
186
 
260
- | Tool | Does |
261
- |---|---|
262
- | `security_scan` | **50+ rules in one call.** Scopes: secrets, injection, unicode, dangerous, config, data-leak, crypto, auth, file-access |
263
-
264
- ### Overview & Similarity
265
-
266
- | Tool | Does |
187
+ | Command | Description |
267
188
  |---|---|
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) |
189
+ | `security scan` | Scan for vulnerabilities (scope, severity filterable) |
190
+ | `security deps` | Audit dependencies against offline CVE database |
272
191
 
273
- ### Developer
192
+ ### Maintenance
274
193
 
275
- | Tool | Does |
194
+ | Command | Description |
276
195
  |---|---|
277
- | `ast_explore` | Parse code snippet S-expression AST tree |
278
- | `test_query` | Test a tree-sitter query against code |
196
+ | `evolve` | Promote high-confidence annotations to rules/skills |
197
+ | `hooks` | Session lifecycle hook management |
279
198
 
280
199
  ---
281
200
 
282
- ## Tool Output Examples
283
-
284
- ### Context — 360° Symbol View
285
-
286
- ```
287
- context({name: "AuthService"})
288
-
289
- AuthService [class] src/auth.ts:15 (exported)
290
- role: hub | heat: 0.85
291
-
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
201
+ ## MCP Tools
296
202
 
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
301
- ```
203
+ ### Search & Navigation
302
204
 
303
- ### Impact Blast Radius
205
+ | Tool | Description |
206
+ |---|---|
207
+ | `query` | Find symbol definitions by name (FTS5) |
208
+ | `grep` | Text search ALL files (templates, styles, configs, docs) |
209
+ | `context` | 360° view: incoming refs + outgoing deps |
210
+ | `get_file_symbols` | All symbols in a file |
211
+ | `get_type_hierarchy` | Inheritance/implementation tree |
212
+ | `semantic_search` | Hybrid FTS5 + vector search |
213
+ | `find_similar` | Find symbols similar by topology |
304
214
 
305
- ```
306
- impact({target: "createUser", direction: "upstream", depth: 3})
215
+ ### Impact & Safety
307
216
 
308
- TARGET: createUser [function] src/models.ts:42
217
+ | Tool | Description |
218
+ |---|---|
219
+ | `impact` | Blast radius: what breaks if target changes |
220
+ | `edit_check` | Pre-edit safety: callers + export status + re-export chains |
221
+ | `overview` | Combined context + impact + grep in one call |
222
+ | `detect_changes` | Git diff → affected symbols + dependents |
223
+ | `find_dead_code` | Exported symbols with zero incoming references |
224
+ | `pre_commit_check` | Pre-commit risk: review_pr + dead code + coverage gaps |
225
+ | `compare_impact` | Compare impact graph before/after edit — detects regressions |
309
226
 
310
- [depth 1] WILL BREAK:
311
- AuthService [class] src/auth.ts:15 (calls)
312
- UserController [class] src/controllers/user.ts:8 (calls)
227
+ ### Review & Testing
313
228
 
314
- [depth 2] LIKELY AFFECTED:
315
- handleLogin [function] src/routes.ts:23 (calls)
316
- handleRegister [function] src/routes.ts:45 (calls)
229
+ | Tool | Description |
230
+ |---|---|
231
+ | `review_pr` | PR risk assessment: scored by blast radius + test coverage |
232
+ | `review_symbol` | Single symbol deep-dive: role, heat, dependents, risk |
233
+ | `codebase_summary` | Compact ~500 token overview |
234
+ | `test_plan` | Dependency-aware test plan: mocks, strategies, scenarios |
235
+ | `test_generate` | Auto-generate test file with framework detection |
236
+ | `test_coverage_gaps` | Untested exported symbols sorted by risk |
237
+ | `test_impact` | Which tests to run for current changes |
317
238
 
318
- [depth 3] MAY NEED TESTING:
319
- authRouter [variable] src/routes.ts:1 (imports)
320
- adminDashboard [function] src/admin.ts:10 (calls)
239
+ ### Orchestration
321
240
 
322
- 5 dependents across 3 depths
323
- ```
241
+ | Tool | Description |
242
+ |---|---|
243
+ | `orchestrate` | Full cycle: changes → risk → gaps → dead code → action plan |
324
244
 
325
- ### Review PR — Risk Assessment
245
+ ### Understanding
326
246
 
327
- ```
328
- review_pr({})
247
+ | Tool | Description |
248
+ |---|---|
249
+ | `smart_context` | Intent-aware context: understand/edit/debug/test |
250
+ | `trace` | Execution flow: call chains from entrypoints to target |
251
+ | `routes` | Detect framework routes/endpoints |
252
+ | `explain_relationship` | Shortest dependency path between two symbols |
253
+ | `domains` | Domain clusters: files forming logical modules |
329
254
 
330
- PR Risk Assessment (vs HEAD):
331
- 6 changed files, 12 affected symbols
255
+ ### Memory & Sessions
332
256
 
333
- handlePayment [function] src/payment.ts:30 heat: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)
257
+ | Tool | Description |
258
+ |---|---|
259
+ | `annotate` | Record a note about a symbol (persists across sessions) |
260
+ | `recall` | Retrieve annotations from past sessions |
261
+ | `session_start` | Register agent session |
262
+ | `session_end` | End session and record stats |
263
+ | `session_context` | Get session metadata + annotations |
264
+ | `handoff` | Transfer context between agent sessions |
337
265
 
338
- Summary: CRITICAL=1 HIGH=2 MEDIUM=4 LOW=5
339
- ```
266
+ ### Security
340
267
 
341
- ### Security Scan 50 Rules at Once
268
+ | Tool | Description |
269
+ |---|---|
270
+ | `security_scan` | Scan for vulnerabilities (50+ rules, 9 categories) |
271
+ | `fix_apply` | Apply security fix to a file (creates backup) |
342
272
 
343
- ```
344
- security_scan({scope: "all", severity: "HIGH"})
273
+ ### Hooks
345
274
 
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
- }
376
- ```
275
+ | Tool | Description |
276
+ |---|---|
277
+ | `hook_onFileChange` | Re-analyze changed files + impact summary |
278
+ | `hook_preCompact` | Save metrics snapshot before context compaction |
279
+ | `hook_postCompact` | Restore context by recalling annotations |
377
280
 
378
- ---
281
+ ### Developer
379
282
 
380
- ## Sub-agent Prompts (6)
283
+ | Tool | Description |
284
+ |---|---|
285
+ | `ast_explore` | Parse code snippet to S-expression AST tree |
286
+ | `test_query` | Run tree-sitter query against code snippet |
381
287
 
382
- Instead of chaining 5-10 tools manually, your agent calls one prompt:
288
+ ### Overview
383
289
 
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** |
290
+ | Tool | Description |
291
+ |---|---|
292
+ | `status` | Index stats: symbols, links, files, coverage |
293
+ | `repos` | List all indexed repositories |
392
294
 
393
295
  ---
394
296
 
395
- ## CLI Commands
396
-
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
- ```
416
-
417
- ### Workflow Examples
418
-
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
- ```
426
-
427
- ### Profile Selection
428
-
429
- Control how many tools are active to optimize token overhead:
297
+ ## Sub-Agent Prompts
430
298
 
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
- ```
299
+ | Prompt | Purpose |
300
+ |---|---|
301
+ | `milens-planner` | 5-step implementation planning with blast radius |
302
+ | `milens-reviewer` | PR review risk scan → deep dive → dead code → security |
303
+ | `milens-tester` | TDD — coverage gaps → test plans → implement → verify |
304
+ | `milens-security` | Security audit — secrets, injection, unicode, crypto, config |
305
+ | `milens-architect` | Architecture analysis — domains, routes, coupling, hierarchy |
306
+ | `milens-debugger` | Root cause analysis — trace → blast radius → hypotheses → fixes |
307
+ | `dead_code_remove` | Safe dead code removal with impact verification |
436
308
 
437
309
  ---
438
310
 
@@ -446,74 +318,28 @@ All 50 rules map to **OWASP Top 10 (2021)**. One tool call covers what used to t
446
318
  | **injection** | 9 | SQL injection, XSS, command injection, `eval()`, `exec()`, dangerous DOM |
447
319
  | **unicode** | 4 | Zero-width chars, bidi override, homoglyph attacks |
448
320
  | **dangerous** | 7 | `os.system`, `subprocess shell`, unsafe deserialization, `spawn shell` |
449
- | **config** | 5 | CORS wildcards, insecure cookies, debug mode, `--dangerously-skip-permissions` |
321
+ | **config** | 5 | CORS wildcards, insecure cookies, debug mode |
450
322
  | **data-leak** | 5 | `console.log` of secrets, hardcoded URLs |
451
323
  | **crypto** | 4 | MD5, SHA1, `Math.random()` for crypto, hardcoded salt/IV |
452
- | **auth** | 4 | String comparison, missing middleware, JWT without expiry, session in URL |
324
+ | **auth** | 4 | String comparison, missing middleware, JWT without expiry |
453
325
  | **file-access** | 2 | Path traversal, unsafe file reads |
454
326
 
455
327
  ```bash
456
328
  milens security scan --scope secrets --severity HIGH --format json
457
- milens security deps # Offline CVE check (34 known vulns, 5 ecosystems)
329
+ milens security deps # Offline CVE check (35 CVEs, 5 ecosystems)
458
330
  ```
459
331
 
460
332
  From an AI agent: `security_scan({scope: "all", severity: "HIGH"})`
461
333
 
462
334
  ---
463
335
 
464
- ## Hook System (6 Triggers)
465
-
466
- Automation so your agent never forgets:
467
-
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 |
476
-
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
- ```
482
-
483
- ---
484
-
485
- ## Learning & Evolution
486
-
487
- The system gets smarter every session:
488
-
489
- ```
490
- SESSION 1: Agent finds bug in createUser()
491
- → annotate({symbol: "createUser", key: "bug", value: "Call createUser() before normalizeEmail()"})
492
- → confidence: 0.5
493
-
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
497
-
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
- ```
502
-
503
- ```bash
504
- milens evolve # Promote high-confidence patterns now
505
- milens evolve --schedule install # Auto-run weekly (cron/schtasks)
506
- ```
507
-
508
- ---
509
-
510
336
  ## Supported Languages
511
337
 
512
338
  12 languages through tree-sitter:
513
339
 
514
340
  | Language | Files | Imports | Calls | Heritage |
515
341
  |---|---|---|---|---|
516
- | TypeScript | `.ts` `.tsx` | ESM + CJS + decorators | ✓ + decorators | extends / implements |
342
+ | TypeScript | `.ts` `.tsx` | ESM + CJS + decorators | ✓ | extends / implements |
517
343
  | JavaScript | `.js` `.jsx` `.mjs` `.cjs` | ESM + CJS | ✓ | extends |
518
344
  | Python | `.py` | import + relative | ✓ + decorators | extends |
519
345
  | Java | `.java` | import + static | ✓ + annotations | extends / implements |
@@ -530,23 +356,13 @@ milens evolve --schedule install # Auto-run weekly (cron/schtasks)
530
356
 
531
357
  ---
532
358
 
533
- ## Editor & Harness Support
359
+ ## Editor Adapters
534
360
 
535
- Milens works with any MCP-compatible agent. Two ways to use:
536
-
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:**
361
+ Milens works with any MCP-compatible agent:
546
362
 
547
363
  | Harness | Config File | Recommended Profile |
548
364
  |---|---|---|
549
- | **Claude Code** | `.claude/mcp.json` | standard (25 tools) |
365
+ | **Claude Code** | `.claude/mcp.json` | standard |
550
366
  | **OpenCode** | `.opencode/config.json` | standard |
551
367
  | **VS Code / Copilot** | `.vscode/mcp.json` | standard |
552
368
  | **Cursor** | `.cursorrules` | standard |
@@ -556,28 +372,20 @@ Milens works with any MCP-compatible agent. Two ways to use:
556
372
 
557
373
  Each adapter is in the `adapters/` directory with ready-to-copy config files and agent instructions.
558
374
 
375
+ ### Profile Selection
376
+
377
+ ```bash
378
+ MILENS_PROFILE=minimal milens serve # 10 tools — ~500 token overhead
379
+ MILENS_PROFILE=standard milens serve # 25 tools — full daily coding
380
+ milens serve --profile full # 41 tools — everything
381
+ ```
382
+
559
383
  ---
560
384
 
561
385
  ## Metrics
562
386
 
563
387
  Seven quantified metrics for AI-driven development:
564
388
 
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
- ╚══════════════════════════════════════════════╝
579
- ```
580
-
581
389
  | Metric | Full Name | What It Tracks |
582
390
  |---|---|---|
583
391
  | **TER** | Token Efficiency Ratio | Useful tokens ÷ total tokens |
@@ -588,20 +396,48 @@ $ milens metrics
588
396
  | **DCER** | Dead Code Elimination Rate | Dead symbols ÷ total exported |
589
397
  | **CTR** | Cycle Time Reduction | Time saved vs manual approach |
590
398
 
399
+ ```bash
400
+ milens metrics
401
+ ```
402
+
591
403
  ---
592
404
 
593
- ## Security & Privacy
405
+ ## Learning & Evolution
594
406
 
595
- **Zero network. Zero telemetry. Zero data leaving your machine.**
407
+ The system gets smarter every session:
596
408
 
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. |
409
+ ```
410
+ SESSION 1: Agent finds bug in createUser()
411
+ annotate({symbol: "createUser", key: "bug", value: "Call createUser() before normalizeEmail()"})
412
+ confidence: 0.5
413
+
414
+ SESSION 2: Agent auto-recalls the annotation
415
+ "I know createUser() has a known issue. I'll handle the order correctly."
416
+ Bug avoided. confidence 0.7
417
+
418
+ SESSION 5: Confidence reaches 0.9
419
+ → milens evolve promotes it to .agents/skills/milens-bug/SKILL.md
420
+ → Now enforced as a rule for every future session
421
+ ```
422
+
423
+ ---
424
+
425
+ ## Hook System (6 Triggers)
426
+
427
+ | Hook | When | Default Action |
428
+ |---|---|---|
429
+ | `onSessionStart` | Agent begins work | Refresh index + codebase_summary + recall past warnings |
430
+ | `onSessionEnd` | Agent finishes | detect_changes + review_pr + auto-annotate changed symbols |
431
+ | `onPreCommit` | Before `git commit` | detect_changes + review_pr + find_dead_code |
432
+ | `onFileChange` | Files modified | Re-analyze changed files + impact on affected symbols |
433
+ | `onPreCompact` | Before context window compaction | Save codebase_summary snapshot |
434
+ | `onPostCompact` | After compaction | recall annotations to restore lost context |
435
+
436
+ ```bash
437
+ milens hooks enable # Turn on all hooks
438
+ milens hooks profile standard # Preset: SessionStart, SessionEnd, PreCommit
439
+ milens hooks disable --hook preCommit # Turn off one hook
440
+ ```
605
441
 
606
442
  ---
607
443
 
@@ -609,57 +445,48 @@ $ milens metrics
609
445
 
610
446
  | Tier | Price | Key Features |
611
447
  |---|---|---|
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 |
448
+ | **Free** | $0 | All 41 tools, 7 prompts, 7 workflows, 50+ security rules, CLI, community support. MIT core. |
615
449
 
616
- OSS stays free forever. [Full pricing details →](docs/pricing.md)
450
+ [Full pricing details →](docs/pricing.md)
617
451
 
618
452
  ---
619
453
 
620
- ## What's New in v0.7.0
621
-
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.
454
+ ## Changelog
455
+
456
+ ### v0.6.5 (May 2026)
457
+
458
+ - 14 new test files (168 554 tests, 23% 58% coverage)
459
+ - 7 CLI workflow commands: tdd, review, plan, onboard, security-scan, refactor, handoff
460
+ - Enhanced orchestrator with snapshot persistence
461
+ - Compare impact for regression detection
462
+ - Coverage thresholds in vitest.config.ts
463
+ - CI/CD: milens-ci-test.yml workflow
464
+ - 41 MCP tools in full profile (up from 33)
465
+
466
+ ### v0.6.0 (March 2026)
467
+
468
+ - 41 MCP tools, 7 sub-agent prompts
469
+ - Learning engine: annotate → recall → evolve
470
+ - Offline CVE database with 35+ CVEs across 5 ecosystems
471
+ - 7 editor harness adapters
472
+ - Hook system with 6 event triggers
634
473
 
635
474
  [Full changelog →](https://github.com/fuze210699/milens/releases)
636
475
 
637
476
  ---
638
477
 
639
- ## Environment Variables
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 |
478
+ ## Security & Privacy
645
479
 
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
- ```
480
+ **Zero network. Zero telemetry. Zero data leaving your machine.**
658
481
 
659
- Or from CLI:
660
- ```bash
661
- MILENS_PROFILE=minimal milens serve
662
- ```
482
+ | Layer | Guarantee |
483
+ |---|---|
484
+ | **Data** | Index stored in `.milens/` per repo (gitignored). No source code in registry. |
485
+ | **Network** | HTTP binds `127.0.0.1` only. No outbound connections. |
486
+ | **Input** | User regex validated against ReDoS. FTS5 tokens quoted as literals. |
487
+ | **File access** | All paths bounded to repo root. No traversal possible. |
488
+ | **Git** | `execFileSync` with arg arrays. No shell interpolation. |
489
+ | **Embeddings** | Optional. Generated locally via Xenova transformers. No API calls. |
663
490
 
664
491
  ---
665
492
 
@@ -670,7 +497,7 @@ git clone https://github.com/fuze210699/milens.git
670
497
  cd milens
671
498
  npm install
672
499
  npm run build # tsc → dist/
673
- npm test # vitest (136 tests)
500
+ npm test # vitest (554 tests, 30 test files)
674
501
  npm run lint # tsc --noEmit
675
502
  npm run self-analyze # Index milens with milens
676
503
  npm run self-serve # Start MCP on port 3100