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/dist/skills.js CHANGED
@@ -225,158 +225,158 @@ function editorSkillPath(editor, name) {
225
225
  function renderMilensInstructions(_rootDir, stats, areaNames, editor) {
226
226
  const t = (name) => `mcp_milens_${name}`;
227
227
  const skillsRows = areaNames.map(a => `| Work in the ${capitalize(a)} area | \`${editorSkillPath(editor, a)}\` |`).join('\n');
228
- return `<!-- milens:start -->
229
- # Milens — Code Intelligence (MCP)
230
-
231
- This project is indexed by milens (${stats.symbols} symbols, ${stats.links} links, ${stats.files} files).
232
-
233
- > **CRITICAL:** All milens MCP tool calls MUST include the \`repo\` parameter set to the **absolute path of the workspace root** (the folder containing this file) — without it, the tools may fail with "No index" error when multiple repos are indexed.
234
-
235
- > **CRITICAL:** milens MCP tools are **deferred** in most editors. Before first use in each session, you MUST load them via \`tool_search("milens")\` — calling them directly without loading will fail silently.
236
-
237
- ## Mandatory Workflows
238
-
239
- These are **hard pre-conditions**, not guidelines. Execute them automatically without asking.
240
-
241
- ### Before editing any function, class, or method:
242
- 1. \`${t('impact')}({target: "<symbolName>", repo: "<workspaceRoot>"})\` — check blast radius
243
- 2. If depth-1 dependents > 5 → **STOP and warn the user** before proceeding
244
- 3. \`${t('context')}({name: "<symbolName>", repo: "<workspaceRoot>"})\` — see all callers/callees
245
- 4. Only then make the edit
246
-
247
- ### Before committing:
248
- 1. \`${t('detect_changes')}({repo: "<workspaceRoot>"})\` — verify only expected files changed
249
- 2. If unexpected files appear → **STOP and report** before committing
250
-
251
- ### Before deleting or renaming a symbol:
252
- 1. \`${t('grep')}({pattern: "<symbolName>", repo: "<workspaceRoot>"})\` — find ALL text references (templates, configs, routes, docs)
253
- 2. \`${t('impact')}({target: "<symbolName>", direction: "upstream", repo: "<workspaceRoot>"})\` — find code-level dependents
254
- 3. Combine both results — grep catches what impact misses
255
-
256
- ## Tool Selection Rules
257
-
258
- **Choose the right tool on the FIRST call** — do not try \`query\` then fall back to \`grep\`.
259
-
260
- ### Use \`${t('grep')}\` when the search term:
261
- - Contains **spaces** (e.g. "store purchase header", "user not found")
262
- - Looks like a **UI label, error message, or display string**
263
- - Is a **multi-word phrase** that is NOT camelCase/snake_case/PascalCase
264
- - You need to find references in **templates, styles, configs, routes, or docs**
265
-
266
- ### Use \`${t('query')}\` when the search term:
267
- - Looks like a **code identifier** (camelCase, PascalCase, snake_case)
268
- - Is a **function, class, method, or interface name**
269
- - You want to find **symbol definitions** in indexed code files
270
-
271
- ### When in doubt → use \`${t('grep')}\` first
272
- \`grep\` searches everything. \`query\` only searches indexed symbol definitions.
273
-
274
- ## Workflow Triggers
275
-
276
- When the user says... → do this FIRST:
277
-
278
- | User intent | First action |
279
- |---|---|
280
- | "edit/change/modify/fix \`X\`" | \`${t('impact')}({target: "X", repo: "<workspaceRoot>"})\` |
281
- | "delete/remove \`X\`" | \`${t('grep')}({pattern: "X", repo: "<workspaceRoot>"})\` then \`${t('impact')}\` |
282
- | "rename \`X\`" | \`${t('grep')}({pattern: "X", repo: "<workspaceRoot>"})\` then \`${t('impact')}\` |
283
- | "find/search for \`X\`" | Choose \`query\` or \`grep\` per rules above |
284
- | "commit" / "push" | \`${t('detect_changes')}({repo: "<workspaceRoot>"})\` |
285
- | "what calls/uses \`X\`" | \`${t('context')}({name: "X", repo: "<workspaceRoot>"})\` |
286
- | "what happens if I change \`X\`" | \`${t('impact')}({target: "X", repo: "<workspaceRoot>"})\` |
287
- | "how are \`A\` and \`B\` connected" | \`${t('explain_relationship')}({from: "A", to: "B", repo: "<workspaceRoot>"})\` |
288
- | "explore/understand \`X\`" | \`${t('context')}({name: "X", repo: "<workspaceRoot>"})\` |
289
- | "update/write docs for \`X\`" | \`${t('grep')}({pattern: "X", include: "**/*.md"})\` — find existing docs mentioning X, then \`${t('context')}({name: "X"})\` for full symbol info |
290
- | "research/explore docs" | \`${t('get_file_symbols')}({file: "<doc.md>"})\` — see document outline (headings as sections) |
291
- | "what docs mention \`X\`" | \`${t('grep')}({pattern: "X", include: "**/*.md"})\` — find all markdown references |
292
- | "review this PR" | \`${t('review_pr')}({repo: "<workspaceRoot>"})\` — risk assessment for changed files |
293
- | "is \`X\` risky to change" | \`${t('review_symbol')}({name: "X", repo: "<workspaceRoot>"})\` |
294
- | "write tests for \`X\`" | \`${t('test_plan')}({name: "X", repo: "<workspaceRoot>"})\` — deps, mocks, suggested tests |
295
- | "what needs tests" | \`${t('test_coverage_gaps')}({repo: "<workspaceRoot>"})\` — untested symbols by risk |
296
- | "which tests to run" | \`${t('test_impact')}({repo: "<workspaceRoot>"})\` — maps changes → test files |
297
- | "remember/note that \`X\`..." | \`${t('annotate')}({symbol: "X", key: "note", value: "...", repo: "<workspaceRoot>"})\` |
298
- | "what do we know about \`X\`" | \`${t('recall')}({symbol: "X", repo: "<workspaceRoot>"})\` |
299
- | "start new session" | \`${t('session_start')}({agent: "...", repo: "<workspaceRoot>"})\` |
300
- | "find code like \`X\`" | \`${t('find_similar')}({name: "X", repo: "<workspaceRoot>"})\` |
301
- | "search for \`concept\`" | \`${t('semantic_search')}({query: "concept", repo: "<workspaceRoot>"})\` |
302
-
303
- ## Documentation Workflows
304
-
305
- Milens indexes **Markdown files** (.md, .mdx) — headings become \`section\` symbols with parent-child hierarchy, and local links become cross-file references.
306
-
307
- ### Researching or exploring documentation:
308
- 1. \`${t('get_file_symbols')}({file: "README.md", repo: "<workspaceRoot>"})\` — see the full heading outline (TOC) of any doc
309
- 2. \`${t('query')}({query: "<topic>"})\` — search section headings across all docs and code
310
- 3. \`${t('grep')}({pattern: "<keyword>", include: "**/*.md"})\` — text search within docs only
311
-
312
- ### Before updating documentation:
313
- 1. \`${t('get_file_symbols')}({file: "<doc.md>"})\` — understand document structure first
314
- 2. If documenting a code symbol: \`${t('context')}({name: "<symbolName>"})\` — get full symbol info (signature, callers, deps)
315
- 3. \`${t('grep')}({pattern: "<symbolName>", include: "**/*.md"})\` — check if other docs already reference it
316
-
317
- ### After renaming/deleting a code symbol:
318
- - \`${t('grep')}({pattern: "<oldName>", include: "**/*.md"})\` — find docs that need updating (milens indexes markdown links as cross-file references)
319
-
320
- ## Never Do
321
-
322
- - NEVER edit a symbol without first running \`${t('impact')}\` on it.
323
- - NEVER delete or rename without running both \`${t('grep')}\` and \`${t('impact')}\`.
324
- - NEVER commit without running \`${t('detect_changes')}()\`.
325
- - NEVER call milens MCP tools without the \`repo\` parameter.
326
- - NEVER use \`${t('query')}\` for multi-word display text or UI labels — use \`${t('grep')}\`.
327
-
328
- ---
329
-
330
- ## Reference
331
-
332
- ### Tools
333
-
334
- | Tool | Purpose |
335
- |---|---|
336
- | \`${t('query')}\` | Find symbol definitions by name (FTS5) |
337
- | \`${t('grep')}\` | Text search ALL files (templates, styles, configs, docs) |
338
- | \`${t('context')}\` | 360° view: incoming refs + outgoing deps |
339
- | \`${t('impact')}\` | Blast radius before editing |
340
- | \`${t('detect_changes')}\` | Pre-commit scope check |
341
- | \`${t('explain_relationship')}\` | Shortest path between two symbols |
342
- | \`${t('get_file_symbols')}\` | All symbols in a file |
343
- | \`${t('get_type_hierarchy')}\` | Class inheritance tree |
344
- | \`${t('find_dead_code')}\` | Unused exported symbols |
345
- | \`${t('status')}\` | Index health check |
346
- | \`${t('edit_check')}\` | Pre-edit safety: callers + export status + re-export chains + test coverage |
347
- | \`${t('trace')}\` | Execution flow: call chains from entrypoints to a symbol |
348
- | \`${t('routes')}\` | Detect framework routes/endpoints (Express, FastAPI, NestJS, etc.) |
349
- | \`${t('smart_context')}\` | Intent-aware context: understand/edit/debug/test |
350
- | \`${t('overview')}\` | Combined context + impact + grep in one call |
351
- | \`${t('domains')}\` | Domain clusters: groups of files forming logical modules |
352
- | \`${t('repos')}\` | List all indexed repositories with summary stats |
353
- | \`${t('ast_explore')}\` | Explore raw AST structure of a code file |
354
- | \`${t('test_query')}\` | Run raw SQL query against the milens index database |
355
- | \`${t('review_pr')}\` | PR risk assessment: scores changed symbols by blast radius + test coverage |
356
- | \`${t('review_symbol')}\` | Single symbol risk: role, heat, dependents, test status |
357
- | \`${t('test_plan')}\` | Dependency-aware test plan: mocks, strategies, suggested tests |
358
- | \`${t('test_coverage_gaps')}\` | Untested exported symbols sorted by risk |
359
- | \`${t('test_impact')}\` | Which tests to run for current changes |
360
- | \`${t('annotate')}\` | Store observation/note about a symbol (persists across sessions) |
361
- | \`${t('recall')}\` | Retrieve annotations (filter by symbol, key, agent, session) |
362
- | \`${t('session_start')}\` | Register agent session for multi-agent coordination |
363
- | \`${t('session_context')}\` | Get session metadata + annotations |
364
- | \`${t('handoff')}\` | Transfer context between agent sessions |
365
- | \`${t('codebase_summary')}\` | High-level bootstrapping context: domains, key symbols, coverage |
366
- | \`${t('semantic_search')}\` | Hybrid FTS5 + vector search (requires --embeddings) |
367
- | \`${t('find_similar')}\` | Find symbols similar by embedding proximity |
368
-
369
- ### Keeping the Index Fresh
370
-
371
- After significant code changes: \`npx milens analyze -p . --force\`
372
-
373
- ### Skills
374
-
375
- | Task | Read this skill file |
376
- |------|---------------------|
377
- | General milens tools reference | \`${editorSkillPath(editor, 'milens')}\` |
378
- ${skillsRows}
379
-
228
+ return `<!-- milens:start -->
229
+ # Milens — Code Intelligence (MCP)
230
+
231
+ This project is indexed by milens (${stats.symbols} symbols, ${stats.links} links, ${stats.files} files).
232
+
233
+ > **CRITICAL:** All milens MCP tool calls MUST include the \`repo\` parameter set to the **absolute path of the workspace root** (the folder containing this file) — without it, the tools may fail with "No index" error when multiple repos are indexed.
234
+
235
+ > **CRITICAL:** milens MCP tools are **deferred** in most editors. Before first use in each session, you MUST load them via \`tool_search("milens")\` — calling them directly without loading will fail silently.
236
+
237
+ ## Mandatory Workflows
238
+
239
+ These are **hard pre-conditions**, not guidelines. Execute them automatically without asking.
240
+
241
+ ### Before editing any function, class, or method:
242
+ 1. \`${t('impact')}({target: "<symbolName>", repo: "<workspaceRoot>"})\` — check blast radius
243
+ 2. If depth-1 dependents > 5 → **STOP and warn the user** before proceeding
244
+ 3. \`${t('context')}({name: "<symbolName>", repo: "<workspaceRoot>"})\` — see all callers/callees
245
+ 4. Only then make the edit
246
+
247
+ ### Before committing:
248
+ 1. \`${t('detect_changes')}({repo: "<workspaceRoot>"})\` — verify only expected files changed
249
+ 2. If unexpected files appear → **STOP and report** before committing
250
+
251
+ ### Before deleting or renaming a symbol:
252
+ 1. \`${t('grep')}({pattern: "<symbolName>", repo: "<workspaceRoot>"})\` — find ALL text references (templates, configs, routes, docs)
253
+ 2. \`${t('impact')}({target: "<symbolName>", direction: "upstream", repo: "<workspaceRoot>"})\` — find code-level dependents
254
+ 3. Combine both results — grep catches what impact misses
255
+
256
+ ## Tool Selection Rules
257
+
258
+ **Choose the right tool on the FIRST call** — do not try \`query\` then fall back to \`grep\`.
259
+
260
+ ### Use \`${t('grep')}\` when the search term:
261
+ - Contains **spaces** (e.g. "store purchase header", "user not found")
262
+ - Looks like a **UI label, error message, or display string**
263
+ - Is a **multi-word phrase** that is NOT camelCase/snake_case/PascalCase
264
+ - You need to find references in **templates, styles, configs, routes, or docs**
265
+
266
+ ### Use \`${t('query')}\` when the search term:
267
+ - Looks like a **code identifier** (camelCase, PascalCase, snake_case)
268
+ - Is a **function, class, method, or interface name**
269
+ - You want to find **symbol definitions** in indexed code files
270
+
271
+ ### When in doubt → use \`${t('grep')}\` first
272
+ \`grep\` searches everything. \`query\` only searches indexed symbol definitions.
273
+
274
+ ## Workflow Triggers
275
+
276
+ When the user says... → do this FIRST:
277
+
278
+ | User intent | First action |
279
+ |---|---|
280
+ | "edit/change/modify/fix \`X\`" | \`${t('impact')}({target: "X", repo: "<workspaceRoot>"})\` |
281
+ | "delete/remove \`X\`" | \`${t('grep')}({pattern: "X", repo: "<workspaceRoot>"})\` then \`${t('impact')}\` |
282
+ | "rename \`X\`" | \`${t('grep')}({pattern: "X", repo: "<workspaceRoot>"})\` then \`${t('impact')}\` |
283
+ | "find/search for \`X\`" | Choose \`query\` or \`grep\` per rules above |
284
+ | "commit" / "push" | \`${t('detect_changes')}({repo: "<workspaceRoot>"})\` |
285
+ | "what calls/uses \`X\`" | \`${t('context')}({name: "X", repo: "<workspaceRoot>"})\` |
286
+ | "what happens if I change \`X\`" | \`${t('impact')}({target: "X", repo: "<workspaceRoot>"})\` |
287
+ | "how are \`A\` and \`B\` connected" | \`${t('explain_relationship')}({from: "A", to: "B", repo: "<workspaceRoot>"})\` |
288
+ | "explore/understand \`X\`" | \`${t('context')}({name: "X", repo: "<workspaceRoot>"})\` |
289
+ | "update/write docs for \`X\`" | \`${t('grep')}({pattern: "X", include: "**/*.md"})\` — find existing docs mentioning X, then \`${t('context')}({name: "X"})\` for full symbol info |
290
+ | "research/explore docs" | \`${t('get_file_symbols')}({file: "<doc.md>"})\` — see document outline (headings as sections) |
291
+ | "what docs mention \`X\`" | \`${t('grep')}({pattern: "X", include: "**/*.md"})\` — find all markdown references |
292
+ | "review this PR" | \`${t('review_pr')}({repo: "<workspaceRoot>"})\` — risk assessment for changed files |
293
+ | "is \`X\` risky to change" | \`${t('review_symbol')}({name: "X", repo: "<workspaceRoot>"})\` |
294
+ | "write tests for \`X\`" | \`${t('test_plan')}({name: "X", repo: "<workspaceRoot>"})\` — deps, mocks, suggested tests |
295
+ | "what needs tests" | \`${t('test_coverage_gaps')}({repo: "<workspaceRoot>"})\` — untested symbols by risk |
296
+ | "which tests to run" | \`${t('test_impact')}({repo: "<workspaceRoot>"})\` — maps changes → test files |
297
+ | "remember/note that \`X\`..." | \`${t('annotate')}({symbol: "X", key: "note", value: "...", repo: "<workspaceRoot>"})\` |
298
+ | "what do we know about \`X\`" | \`${t('recall')}({symbol: "X", repo: "<workspaceRoot>"})\` |
299
+ | "start new session" | \`${t('session_start')}({agent: "...", repo: "<workspaceRoot>"})\` |
300
+ | "find code like \`X\`" | \`${t('find_similar')}({name: "X", repo: "<workspaceRoot>"})\` |
301
+ | "search for \`concept\`" | \`${t('semantic_search')}({query: "concept", repo: "<workspaceRoot>"})\` |
302
+
303
+ ## Documentation Workflows
304
+
305
+ Milens indexes **Markdown files** (.md, .mdx) — headings become \`section\` symbols with parent-child hierarchy, and local links become cross-file references.
306
+
307
+ ### Researching or exploring documentation:
308
+ 1. \`${t('get_file_symbols')}({file: "README.md", repo: "<workspaceRoot>"})\` — see the full heading outline (TOC) of any doc
309
+ 2. \`${t('query')}({query: "<topic>"})\` — search section headings across all docs and code
310
+ 3. \`${t('grep')}({pattern: "<keyword>", include: "**/*.md"})\` — text search within docs only
311
+
312
+ ### Before updating documentation:
313
+ 1. \`${t('get_file_symbols')}({file: "<doc.md>"})\` — understand document structure first
314
+ 2. If documenting a code symbol: \`${t('context')}({name: "<symbolName>"})\` — get full symbol info (signature, callers, deps)
315
+ 3. \`${t('grep')}({pattern: "<symbolName>", include: "**/*.md"})\` — check if other docs already reference it
316
+
317
+ ### After renaming/deleting a code symbol:
318
+ - \`${t('grep')}({pattern: "<oldName>", include: "**/*.md"})\` — find docs that need updating (milens indexes markdown links as cross-file references)
319
+
320
+ ## Never Do
321
+
322
+ - NEVER edit a symbol without first running \`${t('impact')}\` on it.
323
+ - NEVER delete or rename without running both \`${t('grep')}\` and \`${t('impact')}\`.
324
+ - NEVER commit without running \`${t('detect_changes')}()\`.
325
+ - NEVER call milens MCP tools without the \`repo\` parameter.
326
+ - NEVER use \`${t('query')}\` for multi-word display text or UI labels — use \`${t('grep')}\`.
327
+
328
+ ---
329
+
330
+ ## Reference
331
+
332
+ ### Tools
333
+
334
+ | Tool | Purpose |
335
+ |---|---|
336
+ | \`${t('query')}\` | Find symbol definitions by name (FTS5) |
337
+ | \`${t('grep')}\` | Text search ALL files (templates, styles, configs, docs) |
338
+ | \`${t('context')}\` | 360° view: incoming refs + outgoing deps |
339
+ | \`${t('impact')}\` | Blast radius before editing |
340
+ | \`${t('detect_changes')}\` | Pre-commit scope check |
341
+ | \`${t('explain_relationship')}\` | Shortest path between two symbols |
342
+ | \`${t('get_file_symbols')}\` | All symbols in a file |
343
+ | \`${t('get_type_hierarchy')}\` | Class inheritance tree |
344
+ | \`${t('find_dead_code')}\` | Unused exported symbols |
345
+ | \`${t('status')}\` | Index health check |
346
+ | \`${t('edit_check')}\` | Pre-edit safety: callers + export status + re-export chains + test coverage |
347
+ | \`${t('trace')}\` | Execution flow: call chains from entrypoints to a symbol |
348
+ | \`${t('routes')}\` | Detect framework routes/endpoints (Express, FastAPI, NestJS, etc.) |
349
+ | \`${t('smart_context')}\` | Intent-aware context: understand/edit/debug/test |
350
+ | \`${t('overview')}\` | Combined context + impact + grep in one call |
351
+ | \`${t('domains')}\` | Domain clusters: groups of files forming logical modules |
352
+ | \`${t('repos')}\` | List all indexed repositories with summary stats |
353
+ | \`${t('ast_explore')}\` | Explore raw AST structure of a code file |
354
+ | \`${t('test_query')}\` | Run raw SQL query against the milens index database |
355
+ | \`${t('review_pr')}\` | PR risk assessment: scores changed symbols by blast radius + test coverage |
356
+ | \`${t('review_symbol')}\` | Single symbol risk: role, heat, dependents, test status |
357
+ | \`${t('test_plan')}\` | Dependency-aware test plan: mocks, strategies, suggested tests |
358
+ | \`${t('test_coverage_gaps')}\` | Untested exported symbols sorted by risk |
359
+ | \`${t('test_impact')}\` | Which tests to run for current changes |
360
+ | \`${t('annotate')}\` | Store observation/note about a symbol (persists across sessions) |
361
+ | \`${t('recall')}\` | Retrieve annotations (filter by symbol, key, agent, session) |
362
+ | \`${t('session_start')}\` | Register agent session for multi-agent coordination |
363
+ | \`${t('session_context')}\` | Get session metadata + annotations |
364
+ | \`${t('handoff')}\` | Transfer context between agent sessions |
365
+ | \`${t('codebase_summary')}\` | High-level bootstrapping context: domains, key symbols, coverage |
366
+ | \`${t('semantic_search')}\` | Hybrid FTS5 + vector search (requires --embeddings) |
367
+ | \`${t('find_similar')}\` | Find symbols similar by embedding proximity |
368
+
369
+ ### Keeping the Index Fresh
370
+
371
+ After significant code changes: \`npx milens analyze -p . --force\`
372
+
373
+ ### Skills
374
+
375
+ | Task | Read this skill file |
376
+ |------|---------------------|
377
+ | General milens tools reference | \`${editorSkillPath(editor, 'milens')}\` |
378
+ ${skillsRows}
379
+
380
380
  <!-- milens:end -->`;
381
381
  }
382
382
  function generateToolInstructions(rootDir, copilotDir, cursorDir, claudeDir, _claudeRulesDir, agentsDir, stats, areaNames, has) {
@@ -0,0 +1,41 @@
1
+ import BetterSqlite3 from 'better-sqlite3';
2
+ import type { Annotation, AnnotationKey, Session, EvolutionEvent } from '../types.js';
3
+ export declare class AnnotationStore {
4
+ private db;
5
+ private stmts;
6
+ constructor(db: BetterSqlite3.Database);
7
+ private prepareStatements;
8
+ annotate(symbol: string, key: string, value: string, options?: {
9
+ agent?: string;
10
+ sessionId?: string;
11
+ }): Annotation;
12
+ recall(filters?: {
13
+ symbol?: string;
14
+ key?: AnnotationKey;
15
+ agent?: string;
16
+ sessionId?: string;
17
+ limit?: number;
18
+ }): Annotation[];
19
+ sessionStart(agent: string): string;
20
+ sessionEnd(sessionId: string, status?: string): {
21
+ sessionId: string;
22
+ status: string;
23
+ annotationCount: number;
24
+ };
25
+ sessionContext(sessionId: string): {
26
+ session: Session;
27
+ annotations: Annotation[];
28
+ annotationCount: number;
29
+ toolCallsCount: number;
30
+ };
31
+ handoff(fromSessionId: string, toAgent: string, context: string): {
32
+ newSessionId: string;
33
+ annotationsCopied: number;
34
+ };
35
+ getPromotableAnnotations(): Annotation[];
36
+ getStaleAnnotations(daysOld: number, confidenceThreshold: number): Annotation[];
37
+ archiveAnnotation(id: string): void;
38
+ logEvolutionEvent(annotationId: string, event: EvolutionEvent['event'], oldValue?: string, newValue?: string): void;
39
+ getAnnotationCount(): number;
40
+ }
41
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/store/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQtF,qBAAa,eAAe;IAC1B,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,KAAK,CAAmD;gBAEpD,EAAE,EAAE,aAAa,CAAC,QAAQ;IAKtC,OAAO,CAAC,iBAAiB;IAsDzB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU;IAkDlH,MAAM,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,aAAa,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU,EAAE;IA8B5H,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAMnC,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE;IAW9G,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,UAAU,EAAE,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE;IAenI,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAA;KAAE;IAiBrH,wBAAwB,IAAI,UAAU,EAAE;IAKxC,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,GAAG,UAAU,EAAE;IAM/E,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IASnC,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAMnH,kBAAkB,IAAI,MAAM;CAG7B"}
@@ -0,0 +1,192 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ const VALID_KEYS = [
3
+ 'note', 'bug', 'security', 'architecture',
4
+ 'workflow', 'test', 'dependency', 'refactor',
5
+ ];
6
+ export class AnnotationStore {
7
+ db;
8
+ stmts;
9
+ constructor(db) {
10
+ this.db = db;
11
+ this.stmts = this.prepareStatements();
12
+ }
13
+ prepareStatements() {
14
+ return {
15
+ insertAnnotation: this.db.prepare(`INSERT OR REPLACE INTO annotations (id, symbol, key, value, agent, session_id, confidence, created_at, updated_at)
16
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`),
17
+ findBySymbolKey: this.db.prepare('SELECT * FROM annotations WHERE symbol = ? AND key = ?'),
18
+ updateAnnotation: this.db.prepare('UPDATE annotations SET value = ?, confidence = ?, updated_at = datetime(\'now\') WHERE id = ?'),
19
+ queryBySymbol: this.db.prepare('SELECT * FROM annotations WHERE symbol = ? ORDER BY confidence DESC, updated_at DESC LIMIT ?'),
20
+ queryByKey: this.db.prepare('SELECT * FROM annotations WHERE key = ? ORDER BY confidence DESC LIMIT ?'),
21
+ queryByAgent: this.db.prepare('SELECT * FROM annotations WHERE agent = ? ORDER BY updated_at DESC LIMIT ?'),
22
+ queryAll: this.db.prepare('SELECT * FROM annotations ORDER BY confidence DESC, updated_at DESC LIMIT ?'),
23
+ queryBySession: this.db.prepare('SELECT * FROM annotations WHERE session_id = ? ORDER BY updated_at DESC'),
24
+ insertSession: this.db.prepare('INSERT INTO sessions (id, agent, status, started_at) VALUES (?, ?, ?, datetime(\'now\'))'),
25
+ endSession: this.db.prepare('UPDATE sessions SET ended_at = datetime(\'now\'), status = ?, tool_calls_count = ?, annotations_count = ? WHERE id = ?'),
26
+ getSession: this.db.prepare('SELECT * FROM sessions WHERE id = ?'),
27
+ countSessionAnns: this.db.prepare('SELECT COUNT(*) as c FROM annotations WHERE session_id = ?'),
28
+ countAll: this.db.prepare('SELECT COUNT(*) as c FROM annotations'),
29
+ insertEvent: this.db.prepare('INSERT INTO evolution_log (annotation_id, event, old_value, new_value) VALUES (?, ?, ?, ?)'),
30
+ getPromotable: this.db.prepare("SELECT * FROM annotations WHERE confidence >= 0.8 ORDER BY confidence DESC"),
31
+ getStale: this.db.prepare("SELECT * FROM annotations WHERE updated_at < datetime('now', ?) AND confidence < ? ORDER BY confidence ASC"),
32
+ archiveAnnotation: this.db.prepare("UPDATE annotations SET confidence = 0, updated_at = datetime('now') WHERE id = ?"),
33
+ deleteAnnotation: this.db.prepare('DELETE FROM annotations WHERE id = ?'),
34
+ };
35
+ }
36
+ // ── Annotation CRUD ──
37
+ annotate(symbol, key, value, options) {
38
+ if (!VALID_KEYS.includes(key)) {
39
+ throw new Error(`Invalid annotation key: "${key}". Valid: ${VALID_KEYS.join(', ')}`);
40
+ }
41
+ const annotationKey = key;
42
+ const existing = this.stmts.findBySymbolKey.get(symbol, annotationKey);
43
+ if (existing) {
44
+ if (existing.value === value) {
45
+ const newConfidence = Math.min(existing.confidence + 0.1, 1.0);
46
+ this.stmts.updateAnnotation.run(value, newConfidence, existing.id);
47
+ const eventType = newConfidence >= 0.8 && existing.confidence < 0.8 ? 'promoted' : 'confidence_up';
48
+ this.logEvolutionEvent(existing.id, eventType, existing.value, value);
49
+ return rowToAnnotation({
50
+ ...existing,
51
+ confidence: newConfidence,
52
+ updated_at: new Date().toISOString(),
53
+ });
54
+ }
55
+ this.stmts.updateAnnotation.run(value, 0.5, existing.id);
56
+ this.logEvolutionEvent(existing.id, 'created', existing.value, value);
57
+ return rowToAnnotation({
58
+ ...existing,
59
+ value,
60
+ confidence: 0.5,
61
+ updated_at: new Date().toISOString(),
62
+ });
63
+ }
64
+ const id = randomUUID();
65
+ const now = new Date().toISOString();
66
+ this.stmts.insertAnnotation.run(id, symbol, annotationKey, value, options?.agent ?? null, options?.sessionId ?? null, 0.5, now, now);
67
+ this.logEvolutionEvent(id, 'created', undefined, value);
68
+ return {
69
+ id, symbol, key: annotationKey, value,
70
+ agent: options?.agent,
71
+ sessionId: options?.sessionId,
72
+ confidence: 0.5,
73
+ createdAt: now,
74
+ updatedAt: now,
75
+ };
76
+ }
77
+ recall(filters) {
78
+ const limit = filters?.limit ?? 50;
79
+ if (filters?.symbol && filters?.key) {
80
+ const rows = this.stmts.findBySymbolKey.all(filters.symbol, filters.key);
81
+ return rows.map(rowToAnnotation);
82
+ }
83
+ if (filters?.symbol) {
84
+ const rows = this.stmts.queryBySymbol.all(filters.symbol, limit);
85
+ return rows.map(rowToAnnotation);
86
+ }
87
+ if (filters?.key) {
88
+ const rows = this.stmts.queryByKey.all(filters.key, limit);
89
+ return rows.map(rowToAnnotation);
90
+ }
91
+ if (filters?.agent) {
92
+ const rows = this.stmts.queryByAgent.all(filters.agent, limit);
93
+ return rows.map(rowToAnnotation);
94
+ }
95
+ if (filters?.sessionId) {
96
+ const rows = this.stmts.queryBySession.all(filters.sessionId);
97
+ return rows.map(rowToAnnotation);
98
+ }
99
+ const rows = this.stmts.queryAll.all(limit);
100
+ return rows.map(rowToAnnotation);
101
+ }
102
+ // ── Session management ──
103
+ sessionStart(agent) {
104
+ const id = randomUUID();
105
+ this.stmts.insertSession.run(id, agent, 'active');
106
+ return id;
107
+ }
108
+ sessionEnd(sessionId, status) {
109
+ const session = this.stmts.getSession.get(sessionId);
110
+ if (!session)
111
+ throw new Error(`Session not found: ${sessionId}`);
112
+ const annCount = this.stmts.countSessionAnns.get(sessionId).c;
113
+ const finalStatus = status ?? 'completed';
114
+ this.stmts.endSession.run(finalStatus, session.tool_calls_count ?? 0, annCount, sessionId);
115
+ return { sessionId, status: finalStatus, annotationCount: annCount };
116
+ }
117
+ sessionContext(sessionId) {
118
+ const sessionRow = this.stmts.getSession.get(sessionId);
119
+ if (!sessionRow)
120
+ throw new Error(`Session not found: ${sessionId}`);
121
+ const annotations = this.recall({ sessionId });
122
+ const annCount = this.stmts.countSessionAnns.get(sessionId).c;
123
+ return {
124
+ session: rowToSession(sessionRow),
125
+ annotations,
126
+ annotationCount: annCount,
127
+ toolCallsCount: sessionRow.tool_calls_count ?? 0,
128
+ };
129
+ }
130
+ handoff(fromSessionId, toAgent, context) {
131
+ const fromSession = this.stmts.getSession.get(fromSessionId);
132
+ if (!fromSession)
133
+ throw new Error(`Session not found: ${fromSessionId}`);
134
+ const fromAnnCount = this.stmts.countSessionAnns.get(fromSessionId).c;
135
+ this.stmts.endSession.run('completed', fromSession.tool_calls_count ?? 0, fromAnnCount, fromSessionId);
136
+ const newId = randomUUID();
137
+ this.db.prepare('INSERT INTO sessions (id, agent, status, started_at, context) VALUES (?, ?, ?, datetime(\'now\'), ?)').run(newId, toAgent, 'active', context);
138
+ return { newSessionId: newId, annotationsCopied: fromAnnCount };
139
+ }
140
+ // ── Maintenance ──
141
+ getPromotableAnnotations() {
142
+ const rows = this.stmts.getPromotable.all();
143
+ return rows.map(rowToAnnotation);
144
+ }
145
+ getStaleAnnotations(daysOld, confidenceThreshold) {
146
+ const modifier = `-${daysOld} days`;
147
+ const rows = this.stmts.getStale.all(modifier, confidenceThreshold);
148
+ return rows.map(rowToAnnotation);
149
+ }
150
+ archiveAnnotation(id) {
151
+ const row = this.db.prepare('SELECT * FROM annotations WHERE id = ?').get(id);
152
+ if (!row)
153
+ throw new Error(`Annotation not found: ${id}`);
154
+ this.stmts.archiveAnnotation.run(id);
155
+ this.logEvolutionEvent(id, 'archived', row.value, undefined);
156
+ }
157
+ // ── Evolution log ──
158
+ logEvolutionEvent(annotationId, event, oldValue, newValue) {
159
+ this.stmts.insertEvent.run(annotationId, event, oldValue ?? null, newValue ?? null);
160
+ }
161
+ // ── Stats ──
162
+ getAnnotationCount() {
163
+ return this.stmts.countAll.get().c;
164
+ }
165
+ }
166
+ // ── Row mappers ──
167
+ function rowToAnnotation(row) {
168
+ return {
169
+ id: row.id,
170
+ symbol: row.symbol,
171
+ key: row.key,
172
+ value: row.value,
173
+ agent: row.agent ?? undefined,
174
+ sessionId: row.session_id ?? undefined,
175
+ confidence: row.confidence,
176
+ createdAt: row.created_at,
177
+ updatedAt: row.updated_at,
178
+ };
179
+ }
180
+ function rowToSession(row) {
181
+ return {
182
+ id: row.id,
183
+ agent: row.agent,
184
+ status: row.status,
185
+ startedAt: row.started_at,
186
+ endedAt: row.ended_at ?? undefined,
187
+ toolCallsCount: row.tool_calls_count ?? 0,
188
+ annotationsCount: row.annotations_count ?? 0,
189
+ context: row.context ?? undefined,
190
+ };
191
+ }
192
+ //# sourceMappingURL=annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/store/annotations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,GAA6B;IAC3C,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc;IACzC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU;CACpC,CAAC;AAEX,MAAM,OAAO,eAAe;IAClB,EAAE,CAAyB;IAC3B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UAAU;QAC1B,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,SAAS,EAAE,GAAG,CAAC,UAAU;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,GAAQ;IAC5B,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,MAA2B;QACvC,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,OAAO,EAAE,GAAG,CAAC,QAAQ,IAAI,SAAS;QAClC,cAAc,EAAE,GAAG,CAAC,gBAAgB,IAAI,CAAC;QACzC,gBAAgB,EAAE,GAAG,CAAC,iBAAiB,IAAI,CAAC;QAC5C,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,SAAS;KAClC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { AnnotationStore } from './annotations.js';
2
+ /** Boost confidence for an annotation, logging the evolution event */
3
+ export declare function boostConfidence(store: AnnotationStore, annotationId: string, increment?: number): void;
4
+ /** Decay confidence for stale annotations */
5
+ export declare function decayConfidence(store: AnnotationStore, annotationId: string, decrement?: number): void;
6
+ /** Get stale annotations older than daysOld with confidence below threshold */
7
+ export declare function getStaleAnnotations(store: AnnotationStore, daysOld?: number, confidenceThreshold?: number): ReturnType<typeof store.recall>;
8
+ /** Promote high-confidence security annotations to SECURITY.md rules */
9
+ export declare function promoteSecurityAnnotations(store: AnnotationStore, rootPath: string): {
10
+ promoted: number;
11
+ content: string;
12
+ };
13
+ /** Run full decay pass on all annotations */
14
+ export declare function runDecayPass(store: AnnotationStore): {
15
+ decayed: number;
16
+ archived: number;
17
+ };
18
+ //# sourceMappingURL=confidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confidence.d.ts","sourceRoot":"","sources":["../../src/store/confidence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,sEAAsE;AACtE,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,MAAY,GACtB,IAAI,CAUN;AAED,6CAA6C;AAC7C,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,MAAY,GACtB,IAAI,CASN;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,MAAW,EACpB,mBAAmB,GAAE,MAAY,GAChC,UAAU,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,CAGjC;AAED,wEAAwE;AACxE,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,MAAM,GACf;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA+BvC;AAED,6CAA6C;AAC7C,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAkB1F"}