@nxuss/lemma 1.0.5 → 1.1.1

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 (104) hide show
  1. package/README.md +203 -95
  2. package/dist/cjs/mcp/prompts.d.ts +1 -1
  3. package/dist/cjs/mcp/prompts.d.ts.map +1 -1
  4. package/dist/cjs/mcp/prompts.js +24 -0
  5. package/dist/cjs/mcp/prompts.js.map +1 -1
  6. package/dist/cjs/mcp/tools.d.ts.map +1 -1
  7. package/dist/cjs/mcp/tools.js +497 -0
  8. package/dist/cjs/mcp/tools.js.map +1 -1
  9. package/dist/cjs/utils/AutoContextBundle.d.ts +17 -0
  10. package/dist/cjs/utils/AutoContextBundle.d.ts.map +1 -0
  11. package/dist/cjs/utils/AutoContextBundle.js +125 -0
  12. package/dist/cjs/utils/AutoContextBundle.js.map +1 -0
  13. package/dist/cjs/utils/BulkFileDigest.d.ts +13 -0
  14. package/dist/cjs/utils/BulkFileDigest.d.ts.map +1 -0
  15. package/dist/cjs/utils/BulkFileDigest.js +64 -0
  16. package/dist/cjs/utils/BulkFileDigest.js.map +1 -0
  17. package/dist/cjs/utils/ConversationCheckpoint.d.ts +14 -0
  18. package/dist/cjs/utils/ConversationCheckpoint.d.ts.map +1 -0
  19. package/dist/cjs/utils/ConversationCheckpoint.js +77 -0
  20. package/dist/cjs/utils/ConversationCheckpoint.js.map +1 -0
  21. package/dist/cjs/utils/FileFingerprint.d.ts +11 -0
  22. package/dist/cjs/utils/FileFingerprint.d.ts.map +1 -0
  23. package/dist/cjs/utils/FileFingerprint.js +64 -0
  24. package/dist/cjs/utils/FileFingerprint.js.map +1 -0
  25. package/dist/cjs/utils/GitBlameHeat.d.ts +20 -0
  26. package/dist/cjs/utils/GitBlameHeat.d.ts.map +1 -0
  27. package/dist/cjs/utils/GitBlameHeat.js +91 -0
  28. package/dist/cjs/utils/GitBlameHeat.js.map +1 -0
  29. package/dist/cjs/utils/ImportTreeContext.d.ts +17 -0
  30. package/dist/cjs/utils/ImportTreeContext.d.ts.map +1 -0
  31. package/dist/cjs/utils/ImportTreeContext.js +159 -0
  32. package/dist/cjs/utils/ImportTreeContext.js.map +1 -0
  33. package/dist/cjs/utils/PromptPatternCache.d.ts +14 -0
  34. package/dist/cjs/utils/PromptPatternCache.d.ts.map +1 -0
  35. package/dist/cjs/utils/PromptPatternCache.js +104 -0
  36. package/dist/cjs/utils/PromptPatternCache.js.map +1 -0
  37. package/dist/cjs/utils/RepeatGuard.d.ts +9 -0
  38. package/dist/cjs/utils/RepeatGuard.d.ts.map +1 -0
  39. package/dist/cjs/utils/RepeatGuard.js +90 -0
  40. package/dist/cjs/utils/RepeatGuard.js.map +1 -0
  41. package/dist/cjs/utils/TestAutofixInterceptor.d.ts +17 -0
  42. package/dist/cjs/utils/TestAutofixInterceptor.d.ts.map +1 -0
  43. package/dist/cjs/utils/TestAutofixInterceptor.js +125 -0
  44. package/dist/cjs/utils/TestAutofixInterceptor.js.map +1 -0
  45. package/dist/cjs/utils/TokenBudgetedReader.d.ts +14 -0
  46. package/dist/cjs/utils/TokenBudgetedReader.d.ts.map +1 -0
  47. package/dist/cjs/utils/TokenBudgetedReader.js +157 -0
  48. package/dist/cjs/utils/TokenBudgetedReader.js.map +1 -0
  49. package/dist/cjs/utils/TypeCoverage.d.ts +15 -0
  50. package/dist/cjs/utils/TypeCoverage.d.ts.map +1 -0
  51. package/dist/cjs/utils/TypeCoverage.js +141 -0
  52. package/dist/cjs/utils/TypeCoverage.js.map +1 -0
  53. package/dist/esm/mcp/prompts.d.ts +1 -1
  54. package/dist/esm/mcp/prompts.d.ts.map +1 -1
  55. package/dist/esm/mcp/prompts.js +24 -0
  56. package/dist/esm/mcp/prompts.js.map +1 -1
  57. package/dist/esm/mcp/tools.d.ts.map +1 -1
  58. package/dist/esm/mcp/tools.js +497 -0
  59. package/dist/esm/mcp/tools.js.map +1 -1
  60. package/dist/esm/utils/AutoContextBundle.d.ts +17 -0
  61. package/dist/esm/utils/AutoContextBundle.d.ts.map +1 -0
  62. package/dist/esm/utils/AutoContextBundle.js +86 -0
  63. package/dist/esm/utils/AutoContextBundle.js.map +1 -0
  64. package/dist/esm/utils/BulkFileDigest.d.ts +13 -0
  65. package/dist/esm/utils/BulkFileDigest.d.ts.map +1 -0
  66. package/dist/esm/utils/BulkFileDigest.js +58 -0
  67. package/dist/esm/utils/BulkFileDigest.js.map +1 -0
  68. package/dist/esm/utils/ConversationCheckpoint.d.ts +14 -0
  69. package/dist/esm/utils/ConversationCheckpoint.d.ts.map +1 -0
  70. package/dist/esm/utils/ConversationCheckpoint.js +69 -0
  71. package/dist/esm/utils/ConversationCheckpoint.js.map +1 -0
  72. package/dist/esm/utils/FileFingerprint.d.ts +11 -0
  73. package/dist/esm/utils/FileFingerprint.d.ts.map +1 -0
  74. package/dist/esm/utils/FileFingerprint.js +56 -0
  75. package/dist/esm/utils/FileFingerprint.js.map +1 -0
  76. package/dist/esm/utils/GitBlameHeat.d.ts +20 -0
  77. package/dist/esm/utils/GitBlameHeat.d.ts.map +1 -0
  78. package/dist/esm/utils/GitBlameHeat.js +85 -0
  79. package/dist/esm/utils/GitBlameHeat.js.map +1 -0
  80. package/dist/esm/utils/ImportTreeContext.d.ts +17 -0
  81. package/dist/esm/utils/ImportTreeContext.d.ts.map +1 -0
  82. package/dist/esm/utils/ImportTreeContext.js +153 -0
  83. package/dist/esm/utils/ImportTreeContext.js.map +1 -0
  84. package/dist/esm/utils/PromptPatternCache.d.ts +14 -0
  85. package/dist/esm/utils/PromptPatternCache.d.ts.map +1 -0
  86. package/dist/esm/utils/PromptPatternCache.js +96 -0
  87. package/dist/esm/utils/PromptPatternCache.js.map +1 -0
  88. package/dist/esm/utils/RepeatGuard.d.ts +9 -0
  89. package/dist/esm/utils/RepeatGuard.d.ts.map +1 -0
  90. package/dist/esm/utils/RepeatGuard.js +83 -0
  91. package/dist/esm/utils/RepeatGuard.js.map +1 -0
  92. package/dist/esm/utils/TestAutofixInterceptor.d.ts +17 -0
  93. package/dist/esm/utils/TestAutofixInterceptor.d.ts.map +1 -0
  94. package/dist/esm/utils/TestAutofixInterceptor.js +122 -0
  95. package/dist/esm/utils/TestAutofixInterceptor.js.map +1 -0
  96. package/dist/esm/utils/TokenBudgetedReader.d.ts +14 -0
  97. package/dist/esm/utils/TokenBudgetedReader.d.ts.map +1 -0
  98. package/dist/esm/utils/TokenBudgetedReader.js +118 -0
  99. package/dist/esm/utils/TokenBudgetedReader.js.map +1 -0
  100. package/dist/esm/utils/TypeCoverage.d.ts +15 -0
  101. package/dist/esm/utils/TypeCoverage.d.ts.map +1 -0
  102. package/dist/esm/utils/TypeCoverage.js +102 -0
  103. package/dist/esm/utils/TypeCoverage.js.map +1 -0
  104. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,11 @@
1
- # 🧠 Lemma v1.0.3
1
+ # 🧠 Lemma v1.1.0
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@nxuss/lemma.svg?color=orange&style=flat-square)](https://www.npmjs.com/package/@nxuss/lemma)
4
4
  [![License](https://img.shields.io/npm/l/@nxuss/lemma.svg?color=blue&style=flat-square)](https://github.com/Nxusbets/lemma/blob/main/LICENSE)
5
- [![MCP Tools](https://img.shields.io/badge/MCP%20tools-51-ff69b4?style=flat-square)](https://github.com/Nxusbets/lemma)
5
+ [![MCP Tools](https://img.shields.io/badge/MCP%20tools-62-ff69b4?style=flat-square)](https://github.com/Nxusbets/lemma)
6
6
  [![Security](https://img.shields.io/badge/privacy-firewall%20active-blueviolet?style=flat-square)](https://github.com/Nxusbets/lemma)
7
7
  [![Caching](https://img.shields.io/badge/semantic%20memory-enabled-success?style=flat-square)](https://github.com/Nxusbets/lemma)
8
+ [![Tests](https://img.shields.io/badge/tests-199%20passing-00c853?style=flat-square)](https://github.com/Nxusbets/lemma)
8
9
 
9
10
  ```text
10
11
  __
@@ -16,30 +17,80 @@
16
17
 
17
18
  > **The Intelligent local-first AI Gateway — Privacy, Performance, and Static Code Intelligence for the Agentic Era.**
18
19
 
19
- Lemma is a high-performance orchestration layer that sits between your development environment and LLM providers. It transforms the way you build with AI by providing **Shared Semantic Memory**, **Autonomous Cost Optimization**, **Privacy Guardrails**, and a suite of **51 MCP tools** — including zero-token static code intelligence that runs entirely on your machine with no LLM calls required.
20
+ Lemma is a high-performance orchestration layer that sits between your development environment and LLM providers. It transforms the way you build with AI by providing **Shared Semantic Memory**, **Autonomous Cost Optimization**, **Privacy Guardrails**, and a suite of **62 MCP tools** — including zero-token static code intelligence that runs entirely on your machine with no LLM calls required.
21
+
22
+ ---
23
+
24
+ ## 📋 Changelog
25
+
26
+ ### v1.1.0 — Token Avalanche *(NEW)*
27
+
28
+ **11 new tools, all FREE**, focused on maximizing token savings without requiring Pro:
29
+
30
+ #### 🆓 Free Tools Added in v1.1.0
31
+
32
+ | Tool | Token Savings | Description |
33
+ | :--- | :--- | :--- |
34
+ | `file_fingerprint` | -60-70% re-reads | SHA256 hash cache per file. Returns 'unchanged' when hash matches, skipping full re-reads. |
35
+ | `git_blame_heat` | -1000-2000 tok/session | Git blame + risk scoring per line. Identifies hotspots and high-risk authors. Zero LLM cost. |
36
+ | `type_coverage_report` | -1000 tok/review | TypeScript type safety score via AST. Reports typed vs untyped declarations, `any` count, score 0-100. |
37
+ | `import_tree_context` | -3000 tok/exploration | Bidirectional import graph. Shows what imports what, external deps, reverse dependencies. |
38
+ | `read_token_budgeted` | -70-90% file reads | Read file with hard token limit. Returns only most relevant sections via AST-based scoring. |
39
+ | `bulk_file_digest` | -80% round-trips | Read N files in one call, return compressed digest. Saves round-trip overhead. |
40
+ | `auto_context_bundle` | -75% round-trips | One-call context: content + imports + schema types + Brain hints. Replaces 4-5 separate tool calls. |
41
+ | `repeat_guard` | -10-15% output | Jaccard similarity check against recent outputs. Prevents duplicate explanations. |
42
+ | `conversation_checkpoint` | -3000-5000 tok/session | Save/load session state to `.lemma/session/`. Prevents re-explaining context across turns. |
43
+ | `test_autofix_interceptor` | -5000 tok/debugging | Run tests + search Brain for matching fixes. Returns failures with suggested fixes from past sessions. |
44
+ | `prompt_pattern_cache` | -20-30% prompts | Find/store optimized prompt templates. Auto-merges similar patterns. Tracks hit counts. |
45
+
46
+ **Updated TURBOMODE prompt** with 6 new automatic behaviors (rules 4b-4d, 8-12).
47
+
48
+ #### Other v1.1.0 Changes
49
+ - 199 tests passing (28 new test files)
50
+ - Zero new npm dependencies
51
+ - All new tools are FREE (no Pro license required)
20
52
 
21
53
  ---
22
54
 
23
55
  ## 💎 Free vs Pro
24
56
 
25
- | Feature | 🆓 Free | 💎 Pro |
26
- | :--- | :---: | :---: |
27
- | **AI Proxy (OpenAI/Anthropic/Gemini)** | | |
28
- | **Exact-match cache** | ✅ | ✅ |
29
- | **Context Squeezer (auto-compression)** | | |
30
- | **Privacy Firewall (proxy layer)** | | ✅ |
31
- | **Complexity Router** | | |
32
- | **Dashboard** | Basic stats | Full time-travel |
33
- | **Proxy requests/month** | 300 | Unlimited |
34
- | **MCP Server (all 51 tools)** | | |
35
- | **The Brain — Semantic Memory** | | |
36
- | **Zero-Token Static Analysis** | | |
37
- | **Cross-Project Telepathy** | | |
38
- | **AutoPilot & Auto-Heal** | | |
39
- | **`depgraph` — Dependency Graph** | | |
40
- | **`refactor` Codemod Engine** | | |
41
-
42
- > **The MCP is Pro.** All 51 tools — The Brain, PreCrime predictor, AST Hologram, Entropy Score, Coupling Radar, `depgraph`, `refactor`, and every optimization tool — require a Pro license. Activate with `lemma activate <key>` → [Get Pro](https://lemma.nxus.studio/upgrade)
57
+ ### 🆓 Free (11 Tools)
58
+
59
+ These tools work **without a Pro license**. Activate them with just `lemma init`:
60
+
61
+ | Tool | What It Does |
62
+ | :--- | :--- |
63
+ | `file_fingerprint` | File hash cache — avoid re-reads |
64
+ | `git_blame_heat` | Git blame + risk scoring |
65
+ | `type_coverage_report` | TypeScript type safety score |
66
+ | `import_tree_context` | Bidirectional import graph |
67
+ | `read_token_budgeted` | Token-budgeted file reader |
68
+ | `bulk_file_digest` | Multi-file digest in one call |
69
+ | `auto_context_bundle` | Full context bundle per file |
70
+ | `repeat_guard` | Duplicate output detector |
71
+ | `conversation_checkpoint` | Session state save/load |
72
+ | `test_autofix_interceptor` | Test failure Brain auto-fix |
73
+ | `prompt_pattern_cache` | Reusable prompt templates |
74
+
75
+ ### 💎 Pro (51 Tools)
76
+
77
+ All remaining tools require a Pro license. Activate with `lemma activate <key>` → [Get Pro](https://lemma.nxus.studio/upgrade)
78
+
79
+ | Category | Tools |
80
+ | :--- | :--- |
81
+ | **AI Proxy** | OpenAI/Anthropic/Gemini proxy, exact-match cache, context squeezer, complexity router |
82
+ | **Privacy** | Privacy firewall (semantic scrubber), PII masking |
83
+ | **The Brain** | Semantic memory, telepathic hints, hybrid consensus, smarter cache, dedup guard |
84
+ | **Zero-Token Static** | entropy_score, coupling_radar, pattern_fossil, git_heatmap_risk, precrime_static, dead_export_necromancer |
85
+ | **Architecture** | depgraph, refactor, ast_flow_visualizer, imports_skeleton_resolver |
86
+ | **Code Intelligence** | get_ast_hologram, validate_patch_sandbox, surgical_ast_insert, get_symbol_surgical_context |
87
+ | **Workspace** | read/write/create files, apply patches, search, list dirs, run commands |
88
+ | **Optimization** | turbosqueeze, squeeze_prompt, wormhole_squeeze, compress_context, token_budget |
89
+ | **PR Review** | review_diff, review_pr, pr_status, generate_pr_workflow |
90
+ | **Session** | test_oracle, schema_extract, changelog_auto, env_snapshot, migration_tracer |
91
+ | **Automation** | AutoPilot, Auto-Heal, Silent Patch Watcher |
92
+
93
+ > **The MCP server is Pro.** All 51 Pro tools — The Brain, PreCrime, AST Hologram, `depgraph`, `refactor`, and every optimization tool — require a Pro license. The 11 Free tools listed above are accessible without activation.
43
94
 
44
95
  ---
45
96
 
@@ -63,7 +114,7 @@ Mathematical chaos score (0-100) per file using the TS Compiler API. Measures cy
63
114
  ### 🗺️ AST Hologram — Zero Tokens
64
115
  Scans the entire workspace and returns a dense JSON index of all exported symbols (classes, functions, interfaces, types, consts) with file paths and line numbers. Use this instead of reading individual files — saves up to 90% tokens when navigating large codebases.
65
116
 
66
- ### 📡 `depgraph` — Real-Time Dependency Graph *(NEW in v0.9.3)*
117
+ ### 📡 `depgraph` — Real-Time Dependency Graph
67
118
  **Architecture-aware blast radius analysis.** Builds a real-time, bidirectional dependency graph for any file in the workspace using the TypeScript Compiler API — zero LLM calls, zero tokens. Shows exactly what a file imports, what imports it (reverse dependencies), and what symbols it exports.
68
119
 
69
120
  ```
@@ -81,7 +132,7 @@ Scans the entire workspace and returns a dense JSON index of all exported symbol
81
132
 
82
133
  Supports `--depth` (1-5), `--format text|mermaid|json`, `--reverse`, `--circular` (cycle detection), and `--external` (include node_modules).
83
134
 
84
- ### 🔧 `refactor` — Declarative Codemod Engine *(NEW in v0.9.3)*
135
+ ### 🔧 `refactor` — Declarative Codemod Engine
85
136
  **Multi-file refactoring with surgical precision.** Rename any symbol across the entire workspace or move files updating all importers — using the TypeScript Compiler API for accurate AST-based reference detection. Zero LLM calls.
86
137
 
87
138
  **`rename`** — Finds every reference to a symbol (via AST, not text search) and renames it everywhere:
@@ -117,70 +168,70 @@ Exposes `write_workspace_file`, smart `apply_workspace_patch` (collision-safe se
117
168
  ### 🩺 AutoPilot & Auto-Heal
118
169
  Lemma's background file watcher detects TypeScript compilation errors on every save, parses the error, and calls the auto-heal agent to apply a fix — automatically. When Autopilot succeeds, the fix is stored in The Brain for future sessions.
119
170
 
120
- ### 🕵️ Silent Patch Watcher *(NEW in v1.0.1)*
171
+ ### 🕵️ Silent Patch Watcher
121
172
  **Magia negra, no invasiva.** Like Autopilot, but **never touches your code**. Lemma watches your project silently, detects TypeScript errors on save, generates fixes, and stores them as patches in `.lemma/patches/`. You review with `lemma patches` and apply with `lemma apply <id>`.
122
173
 
123
174
  ```
124
175
  lemma watch ← starts silently watching src/
125
- [you save a file with a bug]
176
+ [youse save a file with a bug]
126
177
  📬 macOS notification ← "Lemma: TS2322 in route.ts:42"
127
178
  lemma patches ← shows 1 pending fix
128
179
  lemma apply ts2322-... ← applies the fix
129
180
  npm run build ← ✅ passes
130
181
  ```
131
182
 
132
- ### 🧬 `get_symbol_surgical_context` — Surgical Symbol Context *(NEW in v1.0.0)*
133
- **Saves up to 90% input tokens.** Instead of reading complete dependency source files, this tool parses your workspace via TS Compiler AST and extracts ONLY the targeted symbol implementation along with the precise function/class signatures of all its direct workspace imports.
183
+ ### 🧬 `get_symbol_surgical_context` — Surgical Symbol Context
184
+ **Saves up to 90% input tokens.** Instead of reading complete dependency source files, this tool parses your workspace via TS Compiler AST and extracts ONLY the targeted symbol implementation along with the precise function/class signatures of all its direct workspace imports.
134
185
 
135
- ### ⚙️ `surgical_ast_insert` — AST Surgical Code Injector *(NEW in v1.0.0)*
186
+ ### ⚙️ `surgical_ast_insert` — AST Surgical Code Injector
136
187
  **Saves up to 95% output tokens.** Removes the need for the LLM to output massive file diffs or rewrite entire files. The LLM only outputs the exact function snippet, and Lemma compiles it surgically into the class/scope AST at the specified anchor point.
137
188
 
138
- ### 🩹 `local_semantic_autofix` — Offline Self-Healing *(NEW in v1.0.0)*
189
+ ### 🩹 `local_semantic_autofix` — Offline Self-Healing
139
190
  **Resolves compilation/runtime crashes in <15ms with 0 tokens.** When your tests or compilers crash, Lemma queries the global error index in `TheBrainV2`. If a matching traceback fix is found in memory (solved in this or any other repo on your machine), it applies the resolution instantly.
140
191
 
141
- ### 💰 `generate_executive_roi_report` — Corporate ROI Ledger *(NEW in v1.0.0)*
192
+ ### 💰 `generate_executive_roi_report` — Corporate ROI Ledger
142
193
  Generates a complete executive Markdown/PDF-ready report of total direct API dollars saved, developer hours reclaimed from caching, security masking events, and scalability financial projections for engineering managers.
143
194
 
144
- ### 🌀 `wormhole_squeeze` — Reversible Code Compression *(NEW in v1.0.0)*
195
+ ### 🌀 `wormhole_squeeze` — Reversible Code Compression
145
196
  Compresses your source code using non-colliding mathematical unicode symbols (like `⨃`, `⨂`, `⨁`) and temporary aliases to shrink file sizes by up to 70% while keeping it 100% reversible.
146
197
 
147
- ### 📐 `smart_file_slice` — Context Slicing *(NEW in v1.0.3)*
198
+ ### 📐 `smart_file_slice` — Context Slicing
148
199
  Reads only the relevant lines of a file around a keyword or query, avoiding sending the entire file to the LLM. Saves ~85% of input tokens.
149
200
 
150
- ### 🧪 `test_oracle` — Smart Test Failure Filter *(NEW in v1.0.3)*
201
+ ### 🧪 `test_oracle` — Smart Test Failure Filter
151
202
  Executes unit tests locally and returns ONLY the failing test cases with compressed stack traces, keeping successful test logs out of the prompt. Saves ~90% tokens.
152
203
 
153
- ### 📄 `schema_extract` — High-Level Type Extractor *(NEW in v1.0.3)*
204
+ ### 📄 `schema_extract` — High-Level Type Extractor
154
205
  Extracts TS interfaces, types, Zod schemas, or Prisma schemas via AST, stripping out all execution and implementation code. Saves ~80% tokens.
155
206
 
156
- ### 📜 `changelog_auto` — Zero-Token conventional changelogs *(NEW in v1.0.3)*
207
+ ### 📜 `changelog_auto` — Zero-Token conventional changelogs
157
208
  Generates a conventional commit changelog directly from git history logs with 0 LLM queries.
158
209
 
159
- ### 🪚 `spec_to_stub` — Spec Mock Stub Creator *(NEW in v1.0.3)*
210
+ ### 🪚 `spec_to_stub` — Spec Mock Stub Creator
160
211
  Parses interfaces and types to output a mock stub template object configuration using pure AST.
161
212
 
162
- ### 📋 `env_snapshot` — Env Dependency Capture *(NEW in v1.0.3)*
213
+ ### 📋 `env_snapshot` — Env Dependency Capture
163
214
  Captures node/npm versions, package.json dependencies, and present `.env` keys (hiding private values/credentials) for instant environment onboarding.
164
215
 
165
- ### 🧭 `migration_tracer` — Prisma Migration Analyst *(NEW in v1.0.3)*
216
+ ### 🧭 `migration_tracer` — Prisma Migration Analyst
166
217
  Traces recent schema modifications (creates, alters, drops) from local Prisma migration files without reading the full SQL code.
167
218
 
168
- ### 🩹 `multi_file_patch` — Multi-File Search-and-Replace *(NEW in v1.0.3)* ⭐
219
+ ### 🩹 `multi_file_patch` — Multi-File Search-and-Replace
169
220
  Applies search-and-replace patches to multiple files in a single call. Eliminates round-trips for multi-file refactoring.
170
221
 
171
- ### 📁 `file_intent_index` — Codebase Categorizer *(NEW in v1.0.3)*
222
+ ### 📁 `file_intent_index` — Codebase Categorizer
172
223
  Automatically groups workspace files by domain intent (auth, routing, config, schemas) for lightning fast navigation.
173
224
 
174
- ### 🧠 `cognitive_map` — Auto-Cognitive Knowledge Graph *(NEW in v1.0.3)*
225
+ ### 🧠 `cognitive_map` — Auto-Cognitive Knowledge Graph
175
226
  A persistent, auto-updating structural knowledge graph representing codebase domains, patterns, decisions, and known bugs at `~/.lemma-cache/cog_map.json`.
176
227
 
177
- ### 🔍 `semantic_grep` — BM25 Concept Search *(NEW in v1.0.3)*
228
+ ### 🔍 `semantic_grep` — BM25 Concept Search
178
229
  Token relevance concept searching across your codebase, allowing natural language queries instead of strict substring matches.
179
230
 
180
- ### 📦 `imports_skeleton_resolver` — Import Signature Mapper *(NEW in v1.0.3)*
231
+ ### 📦 `imports_skeleton_resolver` — Import Signature Mapper
181
232
  Scans imports inside a file and retrieves exported TypeScript signatures from local dependencies in a unified reference sheet. Saves ~85% reading tokens.
182
233
 
183
- ### 🎨 `ast_flow_visualizer` — Flowchart Generator *(NEW in v1.0.3)*
234
+ ### 🎨 `ast_flow_visualizer` — Flowchart Generator
184
235
  Compiles any TS function's control flow statements (loops, ifs, try-catches) into an interactive visual Mermaid diagram rendered directly in markdown.
185
236
 
186
237
  ---
@@ -212,10 +263,11 @@ lemma start
212
263
  | `lemma mcp` | Starts the stdin/stdout MCP server for IDE integration. |
213
264
  | `lemma heal` | Auto-diagnose and repair the latest server crash from live context logs. |
214
265
  | `lemma autopilot` | Toggle autonomous background watcher mode (auto-applies fixes). |
215
- | `lemma watch` | **NEW** Silent background watcher — saves patches without touching code. |
216
- | `lemma patches` | **NEW** List available patches (`--all`, `--pending`). |
217
- | `lemma apply <id>` | **NEW** Apply a pending fix patch. |
218
- | `lemma discard <id>` | **NEW** Discard a pending fix patch. |
266
+ | `lemma watch` | Silent background watcher — saves patches without touching code. |
267
+ | `lemma patches` | List available patches (`--all`, `--pending`). |
268
+ | `lemma apply <id>` | Apply a pending fix patch. |
269
+ | `lemma discard <id>` | Discard a pending fix patch. |
270
+ | `lemma activate <key>` | Activate Pro license for full MCP access. |
219
271
 
220
272
  ### Customizing via `lemma.config.json`
221
273
 
@@ -255,11 +307,29 @@ Just run `lemma init`. Lemma automatically registers its MCP server in your `~/.
255
307
  }
256
308
  ```
257
309
 
258
- Once connected, your IDE gains access to all **38 MCP tools** and Lemma auto-injects the TurboMode system prompt on handshake.
310
+ Once connected, your IDE gains access to **62 MCP tools** 11 free + 51 Pro. Lemma auto-injects the TurboMode system prompt on handshake.
259
311
 
260
312
  ---
261
313
 
262
- ## 🛠️ MCP Tools Reference (v0.9.338 Tools)
314
+ ## 🛠️ MCP Tools Reference (v1.1.062 Tools)
315
+
316
+ ### 🆓 Free Tools (11)
317
+
318
+ > These tools work without a Pro license. All are zero-dependency and run locally.
319
+
320
+ | Tool | Category | Description |
321
+ | :--- | :--- | :--- |
322
+ | `file_fingerprint` | Smart Read | SHA256 hash cache. Returns 'unchanged' when hash matches, avoiding re-reads. |
323
+ | `git_blame_heat` | Analysis | Git blame + risk scoring per line. Identifies hotspots and high-risk authors. |
324
+ | `type_coverage_report` | Analysis | TypeScript type safety score via AST. Reports typed vs untyped, `any` count. |
325
+ | `import_tree_context` | Architecture | Bidirectional import graph with reverse dependencies. |
326
+ | `read_token_budgeted` | Smart Read | Read file with hard token limit. Returns only relevant sections. |
327
+ | `bulk_file_digest` | Smart Read | Read N files in one call. Returns compressed digest. |
328
+ | `auto_context_bundle` | Smart Read | One-call bundle: content + imports + types + Brain hints. |
329
+ | `repeat_guard` | Optimization | Detects duplicate outputs using Jaccard similarity. |
330
+ | `conversation_checkpoint` | Session | Save/load session state to prevent re-explaining context. |
331
+ | `test_autofix_interceptor` | Automation | Run tests + Brain search for matching fixes. |
332
+ | `prompt_pattern_cache` | Optimization | Find/store optimized prompt templates. |
263
333
 
264
334
  ### 🗂️ Workspace Tools
265
335
 
@@ -267,80 +337,113 @@ Once connected, your IDE gains access to all **38 MCP tools** and Lemma auto-inj
267
337
  | :--- | :--- |
268
338
  | `read_workspace_file` | Read a file with automatic token compression and privacy scrubbing. |
269
339
  | `write_workspace_file` | Write content to a file, creating parent directories as needed. |
270
- | `apply_workspace_patch` | Smart search-and-replace patch safe against duplicate matches. Returns clear errors if search block is ambiguous. |
340
+ | `create_workspace_file` | Create a new file (fails if exists). Returns minimal ACK. |
341
+ | `apply_workspace_patch` | Smart search-and-replace patch — safe against duplicate matches. |
342
+ | `multi_file_patch` | Apply patches to multiple files in a single call. |
271
343
  | `list_workspace_dir` | Recursively list the project structure up to a configurable depth. |
272
- | `search_workspace` | Fast text search (grep) across all project files with optional extension filter. Results are privacy-scrubbed. |
273
- | `run_workspace_command` | Execute bash commands in the workspace root. Secured by an allowlist. 15s timeout. |
344
+ | `search_workspace` | Fast text search (grep) across all project files. |
345
+ | `semantic_grep` | Natural language concept search using BM25. |
346
+ | `run_workspace_command` | Execute bash commands in the workspace root. Secured by allowlist. |
347
+ | `file_intent_index` | Group files by domain intent (auth, routing, config). |
274
348
 
275
349
  ### 🔬 Code Intelligence Tools
276
350
 
277
351
  | Tool | Description |
278
352
  | :--- | :--- |
279
- | `get_ast_hologram` | **Holographic AST Map.** Scans the workspace via TS Compiler API and returns a dense JSON index of all exported symbols with file paths and line numbers. Use instead of reading individual files — 90% token savings. Zero LLM calls. |
280
- | `validate_patch_sandbox` | **Pre-flight Validator.** Validates a proposed patch in an isolated sandbox before applying it. Runs `tsc --noEmit` and bracket-balance checks. Returns `SAFE TO APPLY` or `DO NOT APPLY` verdict. |
281
- | `diff_only` | Compute a compact line-by-line diff between the last known state of a file and its current content. Session-scoped state tracking. |
353
+ | `get_ast_hologram` | Holographic AST Map of all exported symbols. 90% token savings. |
354
+ | `validate_patch_sandbox` | Pre-flight validator: runs tsc + syntax check before applying. |
355
+ | `diff_only` | Compact line-by-line diff between known states. Session-scoped. |
356
+ | `surgical_ast_insert` | Insert code at AST anchor point. 95% output token savings. |
357
+ | `get_symbol_surgical_context` | Extract symbol + dependency signatures only. 90% savings. |
358
+ | `smart_file_slice` | Read only relevant lines around a query. 85% savings. |
359
+ | `schema_extract` | Extract interfaces/types/schemas via AST. 80% savings. |
360
+ | `spec_to_stub` | Generate mock stubs from TypeScript interfaces. |
361
+ | `ast_flow_visualizer` | Mermaid flowchart from function control flow. |
362
+ | `imports_skeleton_resolver` | Import signature mapper for quick reference. |
282
363
 
283
364
  ### 🧠 Brain & Memory Tools
284
365
 
285
366
  | Tool | Description |
286
367
  | :--- | :--- |
287
- | `search_memory` | Semantic search across The Brain — retrieves past solutions and context from all your projects globally. |
288
- | `store_memory` | Persist a technical solution, bug fix, or architecture decision into The Brain for future sessions. |
289
- | `query_hybrid_consensus` | **Hybrid Consensus Engine.** Checks The Brain at configurable threshold (default 80%). HIT → instant answer, zero cloud tokens. MISS → proceed with cloud and cache afterward. |
290
- | `get_telepathic_hints` | **Proactive Telepathy.** Given the active file path, surfaces the top N most relevant past solutions from The Brain no query needed. |
368
+ | `search_memory` | Semantic search across The Brain from all projects globally. |
369
+ | `store_memory` | Persist solutions, fixes, decisions into The Brain. |
370
+ | `query_hybrid_consensus` | Hybrid cache: 80% threshold → instant answer, 0 cloud tokens. |
371
+ | `get_telepathic_hints` | Proactive hints from The Brain based on active file. |
372
+ | `smarter_cache` | Predictive cache at 75% threshold before any reasoning. |
373
+ | `semantic_dedup_guard` | Brain dedup firewall. Rejects ≥92% similar entries. |
374
+ | `local_semantic_autofix` | Offline self-healing from Brain error index. |
291
375
 
292
376
  ### ⚙️ Optimization & Privacy Tools
293
377
 
294
378
  | Tool | Description |
295
379
  | :--- | :--- |
296
- | `scrub_privacy` | Mask PII, API keys, and secrets from any text block using the Privacy Firewall. |
297
- | `squeeze_prompt` | Compress code blocks and boilerplate in any prompt. Up to 80% token reduction. |
298
- | `turbosqueeze` | **Extreme compression.** Strips comments, imports, whitespace, and compacts JSON. Returns reduction stats. |
299
- | `compress_context` | Summarizes old conversation turns, keeps last N turns intact. Falls back to truncation if no Ollama. |
300
- | `prune_conversation_history` | Intelligently decimate conversation history while preserving critical recent context. |
301
- | `summarize_long_text` | Summarize lengthy content via Ollama to save context window space. Falls back gracefully. |
302
- | `smarter_cache` | **Predictive cache.** Queries The Brain at 75% threshold before any reasoning. Auto-suggests `store_memory` on MISS. |
303
- | `token_budget` | Optimization dashboard: multiplier, total tokens saved, active strategies, and recommendations. |
304
- | `get_routing_advice` | Analyze a prompt and get optimal model recommendation from the Complexity Router. |
305
- | `get_project_onboarding` | Download a one-shot architectural mental model of the current codebase. |
306
- | `auto_heal` | Diagnose and auto-heal the latest crash from Lemma's live context logs. |
307
- | `batch_tool_calls` | Execute multiple tool calls in parallel via `Promise.all`. High-throughput operations in a single MCP round-trip. |
380
+ | `scrub_privacy` | Mask PII, API keys, secrets from any text block. |
381
+ | `squeeze_prompt` | Compress code blocks. Up to 80% token reduction. |
382
+ | `turbosqueeze` | Extreme compression: strips comments, imports, whitespace. |
383
+ | `wormhole_squeeze` | Reversible unicode compression. 60-70% reduction. |
384
+ | `compress_context` | Summarize old conversation turns. Keeps last N intact. |
385
+ | `prune_conversation_history` | Intelligently decimate history preserving critical context. |
386
+ | `summarize_long_text` | Summarize via Ollama. Falls back to truncation. |
387
+ | `token_budget` | Dashboard: multiplier, savings, strategies, recommendations. |
388
+ | `get_routing_advice` | Optimal model recommendation from Complexity Router. |
389
+ | `get_project_onboarding` | One-shot architectural mental model. |
390
+ | `auto_heal` | Auto-diagnose and repair crashes from live context. |
391
+ | `batch_tool_calls` | Execute multiple tools in parallel via Promise.all. |
308
392
 
309
393
  ### 🔮 Zero-Token Static Intelligence Tools
310
394
 
311
- > All tools in this section use **zero LLM tokens, zero Ollama, zero cloud**. Pure local computation via TypeScript Compiler API, git, and math.
395
+ > All tools in this section use **zero LLM tokens**. Pure local computation.
396
+
397
+ | Tool | Description |
398
+ | :--- | :--- |
399
+ | `entropy_score` | Mathematical chaos score (0-100) per file. |
400
+ | `coupling_radar` | Dependency graph: circular imports, god modules, dead islands. |
401
+ | `pattern_fossil` | Zombie code detector: var vs const, callbacks vs async/await. |
402
+ | `git_heatmap_risk` | Git churn analysis + co-edit pairs. |
403
+ | `precrime_static` | Composite risk predictor combining entropy + coupling + git. |
404
+ | `dead_export_necromancer` | Dead code auditor: exported but never imported. |
405
+ | `git_blame_heat` | Git blame + per-line risk scoring. |
406
+ | `type_coverage_report` | TypeScript type safety score. |
407
+ | `import_tree_context` | Bidirectional import graph. |
408
+
409
+ ### 🏗️ Architecture & Refactoring Tools
312
410
 
313
411
  | Tool | Description |
314
412
  | :--- | :--- |
315
- | `entropy_score` | **Mathematical chaos score** (0-100) per file. Measures cyclomatic complexity, max nesting depth, `any` type ratio, and average function size. Identifies which files need refactoring before you touch them. |
316
- | `coupling_radar` | **Dependency graph analysis.** Detects circular imports, god modules (high fan-in), dead islands (no importers), and fan-in/fan-out per module. Essential before large refactors. |
317
- | `pattern_fossil` | **Zombie code detector.** Finds patterns that were replaced in most of the codebase but survive in old files: `var` vs `const/let`, callbacks vs `async/await`, `require()` vs `import`, `: any` vs generics. Reports adoption percentage. |
318
- | `git_heatmap_risk` | **Git churn analysis.** Calculates change frequency per file and co-edit pairs (files that always change together = hidden coupling). Returns a risk score for each file based on historical git behavior. |
319
- | `precrime_static` | **Minority Report predictor.** Combines `entropy_score` (40%) + `git_heatmap_risk` (40%) + `coupling_radar` (20%) into a composite PreCrime Score per file. Ranks files by bug probability with per-factor breakdown and names the riskiest functions. |
320
- | `semantic_dedup_guard` | **Brain dedup firewall.** Before calling `store_memory`, pass content through here. If similarity ≥ 92% → rejects as duplicate. If 75–91% → warns and shows the similar entry. Keeps The Brain lean and dense. |
321
- | `dead_export_necromancer` | **Dead code auditor.** Maps every `export` in the workspace against every `import`. Symbols exported but never imported anywhere = zombie code inflating your context. Reports dead exports by file with estimated token waste. |
413
+ | `depgraph` | Real-time dependency graph with depth, format, circular detection. |
414
+ | `refactor` | Declarative codemod: rename symbols or move files. |
415
+ | `cognitive_map` | Auto-updating knowledge graph of domains and patterns. |
416
+
417
+ ### 🔍 PR Review Agent Tools
322
418
 
323
- ### 🏗️ Architecture & Refactoring Tools *(NEW in v0.9.3)*
419
+ | Tool | Description |
420
+ | :--- | :--- |
421
+ | `review_diff` | Analyze raw diff for bugs, security, best practices. |
422
+ | `review_pr` | Full PR review against GitHub, Azure DevOps, GitLab. |
423
+ | `pr_status` | Query last review status for a PR. |
424
+ | `generate_pr_workflow` | Generate CI/CD workflow YAML for PR reviews. |
324
425
 
325
- > Architecture-aware tools that combine dependency analysis with surgical code transformation. **Zero LLM calls.**
426
+ ### 🧪 Testing & Quality Tools
326
427
 
327
428
  | Tool | Description |
328
429
  | :--- | :--- |
329
- | `depgraph` | **Real-time dependency graph.** Builds a bidirectional import/export map for any file. Shows what a file imports, what imports it (reverse deps with `--reverse`), and what symbols it exports. Supports `--depth` 1-5, `--format text\|mermaid\|json`, `--circular` (cycle detection), and `--external` (include node_modules). Use before any refactor to measure blast radius. |
330
- | `refactor` | **Declarative codemod engine.** `rename` renames a symbol across all files using AST-based reference detection (no false positives from string search). `move` relocates a file and rewires every import path in the workspace. Both support `--dryRun` (unified diff preview), `--tscCheck` (post-apply type verification), and `--backup` (`.bak` files). |
430
+ | `test_oracle` | Run tests, return only failures with compressed traces. |
431
+ | `test_autofix_interceptor` | Run tests + Brain search for matching fixes. |
432
+ | `changelog_auto` | Conventional commit changelog from git history. |
433
+ | `env_snapshot` | Node/npm versions, deps, .env keys (values hidden). |
434
+ | `migration_tracer` | Prisma migration schema diff analysis. |
331
435
 
332
- ### 🔍 PR Review Agent Tools
436
+ ### 📋 Session & Automation Tools
333
437
 
334
438
  | Tool | Description |
335
439
  | :--- | :--- |
336
- | `review_diff` | Analyze a raw diff for bugs, security issues, and best practices before committing. |
337
- | `review_pr` | Full PR review against a Git platform (GitHub, Azure DevOps, GitLab). Runs all 4 analyzers (Static, Security, Regression, Quality) and stores results in The Brain. |
338
- | `pr_status` | Query the last review status and report for a given PR number and platform. |
339
- | `generate_pr_workflow` | Generate a CI/CD workflow YAML (GitHub Actions or Azure Pipelines) that runs `lemma pr-review` as a step. |
440
+ | `conversation_checkpoint` | Save/load session state to `.lemma/session/`. |
441
+ | `prompt_pattern_cache` | Find/store optimized prompt templates. |
442
+ | `review_pr` | Full PR review with auto-approve option. |
340
443
 
341
444
  ### ⚡ TurboMode Auto-Injection
342
445
 
343
- When connected via `lemma mcp`, Lemma auto-injects 7 rules into the agent's system prompt on handshake:
446
+ When connected via `lemma mcp`, Lemma auto-injects 12 rules into the agent's system prompt on handshake:
344
447
 
345
448
  1. `turbosqueeze` before writing large code blocks
346
449
  2. `smarter_cache` before any reasoning
@@ -349,6 +452,11 @@ When connected via `lemma mcp`, Lemma auto-injects 7 rules into the agent's syst
349
452
  5. `batch_tool_calls` for parallel operations
350
453
  6. `semantic_dedup_guard` before every `store_memory`
351
454
  7. No fluff, no chit-chat — maximum density
455
+ 8. `auto_context_bundle` or `bulk_file_digest` for multi-file ops
456
+ 9. `repeat_guard` before long outputs
457
+ 10. `conversation_checkpoint` to restore session context
458
+ 11. `test_autofix_interceptor` when tests fail
459
+ 12. `prompt_pattern_cache` for repetitive prompts
352
460
 
353
461
  ---
354
462
 
@@ -356,11 +464,11 @@ When connected via `lemma mcp`, Lemma auto-injects 7 rules into the agent's syst
356
464
 
357
465
  | Resource URI | Description |
358
466
  | :--- | :--- |
359
- | `lemma://runtime/context` | Live application errors, stack traces, and runtime state. Subscribable — IDE notified instantly on crash. |
360
- | `lemma://stats/usage` | Current token savings, cost report, and cache hit metrics in JSON. |
361
- | `lemma://project/context` | Active project metadata, tech stack, memory count, and token savings. |
362
- | `lemma://project/onboarding` | Dynamic project architecture guide compiled on demand. |
363
- | `lemma://multiverse/timeline` | Chronological AST diff timeline of recent code snapshots. |
467
+ | `lemma://runtime/context` | Live application errors, stack traces, and runtime state. |
468
+ | `lemma://stats/usage` | Current token savings, cost report, and cache hit metrics. |
469
+ | `lemma://project/context` | Active project metadata, tech stack, memory count. |
470
+ | `lemma://project/onboarding` | Dynamic project architecture guide. |
471
+ | `lemma://multiverse/timeline` | Chronological AST diff timeline of recent snapshots. |
364
472
 
365
473
  ---
366
474
 
@@ -1,5 +1,5 @@
1
1
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
2
  export declare const LEMMA_SYSTEM_PROMPT = "You are connected to Lemma \u2014 an intelligent local-first AI gateway.\nLemma gives you a set of tools you MUST use proactively and automatically. NEVER ask the user\nto call a tool manually. YOU invoke the tools. The user should experience zero friction.\n\n## MANDATORY AUTOMATIC BEHAVIORS\n\n### 1. Before reading ANY file \u2192 call get_ast_hologram first\nWhen you need to understand the structure of a codebase or navigate files, ALWAYS call\n`get_ast_hologram` first (with the relevant dirPath, e.g. \"src\"). Use the returned symbol\nmap to pinpoint exactly which files to read. NEVER blindly read every file one by one.\n\n### 2. Before answering ANY technical question \u2192 call query_hybrid_consensus first\nBEFORE making any reasoning or cloud LLM call, ALWAYS call `query_hybrid_consensus` with\nthe user's question. If similarity \u2265 80%, return the cached answer immediately \u2014 no cloud\ncall needed. Only proceed with your own reasoning if the Brain returns a MISS.\n\n### 3. When you start working on ANY file \u2192 call get_telepathic_hints automatically\nWhenever the user mentions a file or you are about to read/edit a file, IMMEDIATELY call\n`get_telepathic_hints` with that file's path. Surface the results to the user as relevant\ncontext BEFORE doing any work. Do not ask permission \u2014 just do it.\n\n### 4. Before applying ANY code patch \u2192 call validate_patch_sandbox first\nNEVER call `write_workspace_file` or `apply_workspace_patch` without FIRST calling\n`validate_patch_sandbox` with the proposed content. Only proceed with the write if the\nverdict is \"\u2705 SAFE TO APPLY\". If it fails, fix the issues and re-validate.\n\n### 5. After solving any technical problem \u2192 call store_memory automatically\nAfter resolving a bug, implementing a feature, or answering a significant technical question,\nALWAYS call `store_memory` to persist the solution. Use a descriptive query key so it can\nbe retrieved in future sessions across ALL projects.\n\n### 6. Workspace navigation \u2192 always use Lemma tools, NEVER guess file contents\n- Use `list_workspace_dir` to navigate structure\n- Use `read_workspace_file` (auto-compresses + scrubs secrets) instead of asking the user\n- Use `search_workspace` for text search across files\n- Use `run_workspace_command` for builds, tests, linters\n\n### 7. Privacy is automatic\n`read_workspace_file` and `search_workspace` automatically scrub API keys and PII.\nYou never need to manually sanitize file content.\n\n## LEMMA RESOURCES (auto-subscribe when available)\n- `lemma://runtime/context` \u2014 live crash logs. Read this FIRST when the user reports a bug.\n- `lemma://multiverse/timeline` \u2014 AST history. Use when the user says \"it was working before\".\n- `lemma://project/onboarding` \u2014 architecture map. Read at session start in new repos.\n- `lemma://stats/usage` \u2014 token savings report.\n\nRemember: the user hired YOU to be autonomous. Act like it.";
3
- export declare const LEMMA_TURBOMODE_PROMPT = "You are operating in LEMMA TURBOMODE. Your goal: multiply the user's LLM membership 50x by spending 50x fewer tokens per task. Every token counts. Every cache hit is a membership extension.\n\n## MANDATORY TURBOMODE RULES \u2014 VIOLATE THESE AND YOU WASTE THE USER'S MONEY\n\n### 0. Before ANYTHING \u2192 check token_budget\nEvery 5 turns, call `token_budget` to check your consumption. If multiplier drops below 10x, optimize harder.\n\n### 1. Before sending ANY code \u2192 call turbosqueeze\nBEFORE including ANY code block in your response, run it through `turbosqueeze` first. Strip comments, collapse whitespace, remove imports. A 500-line file becomes 50 lines. This is your #1 token saver.\n\n### 2. Before reasoning \u2192 call smarter_cache (threshold 0.75)\nNEVER reason from scratch. Call `smarter_cache` with the user's exact question. If similarity >= 75%, return the cached answer INSTANTLY. Zero cloud tokens spent. Only reason if you get a MISS.\n\n### 3. Before every new turn \u2192 call compress_context\nAt the start of any extended interaction, call `compress_context` on the full message history. Keep only the last 3 turns intact. Summarize everything before that into 2 sentences. This keeps your context window lean.\n\n### 4. Before reading files \u2192 call get_ast_hologram\nNEVER read files blindly. Always call `get_ast_hologram` first to locate the exact symbols you need. Then read only those specific files. Each unnecessary file read wastes 1000+ tokens.\n\n### 5. After every solution \u2192 call store_memory automatically\nEvery bug fix, feature, or answer MUST be stored via `store_memory`. This creates a permanent cache hit for future sessions. The first time costs tokens; every time after is FREE.\n\n### 6. Answer concisely \u2014 no fluff\n- No \"Sure, I can help you with that\" \u2014 just do it.\n- No explanation of what you did \u2014 unless asked.\n- No markdown formatting in internal responses.\n- No repeating the user's question back to them.\n\n### 7. Use batch_tool_calls aggressively\nAny set of independent operations (read 3 files, search 2 patterns, check cache for 2 questions) \u2014 use `batch_tool_calls` to run them in parallel. Single round-trip > multiple sequential calls.\n\n## TURBOMODE SCORING\n- Cache HIT = perfect score (0 tokens spent)\n- Cache MISS + compress = good score (< 100 tokens spent on overhead)\n- Reasoning from scratch = bad score (only when absolutely necessary)\n- Reading full files without hologram = FAIL (wasteful)\n\nRemember: this user has a deadline. Every token you save is time and money. Make every token count.";
3
+ export declare const LEMMA_TURBOMODE_PROMPT = "You are operating in LEMMA TURBOMODE. Your goal: multiply the user's LLM membership 50x by spending 50x fewer tokens per task. Every token counts. Every cache hit is a membership extension.\n\n## MANDATORY TURBOMODE RULES \u2014 VIOLATE THESE AND YOU WASTE THE USER'S MONEY\n\n### 0. Before ANYTHING \u2192 check token_budget\nEvery 5 turns, call `token_budget` to check your consumption. If multiplier drops below 10x, optimize harder.\n\n### 1. Before sending ANY code \u2192 call turbosqueeze\nBEFORE including ANY code block in your response, run it through `turbosqueeze` first. Strip comments, collapse whitespace, remove imports. A 500-line file becomes 50 lines. This is your #1 token saver.\n\n### 2. Before reasoning \u2192 call smarter_cache (threshold 0.75)\nNEVER reason from scratch. Call `smarter_cache` with the user's exact question. If similarity >= 75%, return the cached answer INSTANTLY. Zero cloud tokens spent. Only reason if you get a MISS.\n\n### 3. Before every new turn \u2192 call compress_context\nAt the start of any extended interaction, call `compress_context` on the full message history. Keep only the last 3 turns intact. Summarize everything before that into 2 sentences. This keeps your context window lean.\n\n### 4. Before reading files \u2192 call get_ast_hologram\nNEVER read files blindly. Always call `get_ast_hologram` first to locate the exact symbols you need. Then read only those specific files. Each unnecessary file read wastes 1000+ tokens.\n\n### 4b. Before re-reading a file \u2192 call file_fingerprint\nBefore calling read_workspace_file, check if the file hash has changed since last read. If status is 'unchanged', skip the read entirely. Only read when hash differs.\n\n### 4c. Before deep file analysis \u2192 use import_tree_context + type_coverage_report\nInstead of reading full files to understand architecture, call import_tree_context (import graph) and type_coverage_report (type safety). Both are zero-token tools.\n\n### 4d. Before investigating code ownership \u2192 call git_blame_heat\nFor questions about who wrote code, why it's risky, or change history, call git_blame_heat instead of reasoning. Zero LLM cost.\n\n### 5. After every solution \u2192 call store_memory automatically\nEvery bug fix, feature, or answer MUST be stored via `store_memory`. This creates a permanent cache hit for future sessions. The first time costs tokens; every time after is FREE.\n\n### 6. Answer concisely \u2014 no fluff\n- No \"Sure, I can help you with that\" \u2014 just do it.\n- No explanation of what you did \u2014 unless asked.\n- No markdown formatting in internal responses.\n- No repeating the user's question back to them.\n\n### 7. Use batch_tool_calls aggressively\nAny set of independent operations (read 3 files, search 2 patterns, check cache for 2 questions) \u2014 use `batch_tool_calls` to run them in parallel. Single round-trip > multiple sequential calls.\n\n### 8. Before multi-file operations \u2192 use auto_context_bundle or bulk_file_digest\nInstead of reading files one by one, use `auto_context_bundle` (one file, everything included) or `bulk_file_digest` (multiple files, one call). Both save 75-80% round-trips.\n\n### 9. Before outputting long responses \u2192 check repeat_guard\nCall `repeat_guard` with your draft output to avoid repeating yourself. Saves 10-15% of output tokens.\n\n### 10. When resuming work \u2192 load conversation_checkpoint\nAt session start or when user says \"continuemos\", call `conversation_checkpoint` with action \"load\" to restore context without re-explaining.\n\n### 11. When tests fail \u2192 use test_autofix_interceptor\nInstead of manually reading errors and reasoning, call `test_autofix_interceptor` to get failures + Brain-suggested fixes in one call.\n\n### 12. For common prompt patterns \u2192 use prompt_pattern_cache\nBefore generating repetitive prompts (\"explain this\", \"review this\", \"write tests\"), check `prompt_pattern_cache` action \"find\" for cached templates.\n\n## TURBOMODE SCORING\n- Cache HIT = perfect score (0 tokens spent)\n- Cache MISS + compress = good score (< 100 tokens spent on overhead)\n- Reasoning from scratch = bad score (only when absolutely necessary)\n- Reading full files without hologram = FAIL (wasteful)\n\nRemember: this user has a deadline. Every token you save is time and money. Make every token count.";
4
4
  export declare function setupPromptsHandlers(server: Server): void;
5
5
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,eAAO,MAAM,mBAAmB,m6FA+C4B,CAAC;AAE7D,eAAO,MAAM,sBAAsB,4jFAqCiE,CAAC;AAErG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiDzD"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,eAAO,MAAM,mBAAmB,m6FA+C4B,CAAC;AAE7D,eAAO,MAAM,sBAAsB,yyIA6DiE,CAAC;AAErG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiDzD"}
@@ -70,6 +70,15 @@ At the start of any extended interaction, call \`compress_context\` on the full
70
70
  ### 4. Before reading files → call get_ast_hologram
71
71
  NEVER read files blindly. Always call \`get_ast_hologram\` first to locate the exact symbols you need. Then read only those specific files. Each unnecessary file read wastes 1000+ tokens.
72
72
 
73
+ ### 4b. Before re-reading a file → call file_fingerprint
74
+ Before calling read_workspace_file, check if the file hash has changed since last read. If status is 'unchanged', skip the read entirely. Only read when hash differs.
75
+
76
+ ### 4c. Before deep file analysis → use import_tree_context + type_coverage_report
77
+ Instead of reading full files to understand architecture, call import_tree_context (import graph) and type_coverage_report (type safety). Both are zero-token tools.
78
+
79
+ ### 4d. Before investigating code ownership → call git_blame_heat
80
+ For questions about who wrote code, why it's risky, or change history, call git_blame_heat instead of reasoning. Zero LLM cost.
81
+
73
82
  ### 5. After every solution → call store_memory automatically
74
83
  Every bug fix, feature, or answer MUST be stored via \`store_memory\`. This creates a permanent cache hit for future sessions. The first time costs tokens; every time after is FREE.
75
84
 
@@ -82,6 +91,21 @@ Every bug fix, feature, or answer MUST be stored via \`store_memory\`. This crea
82
91
  ### 7. Use batch_tool_calls aggressively
83
92
  Any set of independent operations (read 3 files, search 2 patterns, check cache for 2 questions) — use \`batch_tool_calls\` to run them in parallel. Single round-trip > multiple sequential calls.
84
93
 
94
+ ### 8. Before multi-file operations → use auto_context_bundle or bulk_file_digest
95
+ Instead of reading files one by one, use \`auto_context_bundle\` (one file, everything included) or \`bulk_file_digest\` (multiple files, one call). Both save 75-80% round-trips.
96
+
97
+ ### 9. Before outputting long responses → check repeat_guard
98
+ Call \`repeat_guard\` with your draft output to avoid repeating yourself. Saves 10-15% of output tokens.
99
+
100
+ ### 10. When resuming work → load conversation_checkpoint
101
+ At session start or when user says "continuemos", call \`conversation_checkpoint\` with action "load" to restore context without re-explaining.
102
+
103
+ ### 11. When tests fail → use test_autofix_interceptor
104
+ Instead of manually reading errors and reasoning, call \`test_autofix_interceptor\` to get failures + Brain-suggested fixes in one call.
105
+
106
+ ### 12. For common prompt patterns → use prompt_pattern_cache
107
+ Before generating repetitive prompts ("explain this", "review this", "write tests"), check \`prompt_pattern_cache\` action "find" for cached templates.
108
+
85
109
  ## TURBOMODE SCORING
86
110
  - Cache HIT = perfect score (0 tokens spent)
87
111
  - Cache MISS + compress = good score (< 100 tokens spent on overhead)
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":";;;AA2FA,oDAiDC;AA3ID,iEAAsG;AAEzF,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DA+CyB,CAAC;AAEhD,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oGAqC8D,CAAC;AAErG,SAAgB,oBAAoB,CAAC,MAAc;IACjD,MAAM,CAAC,iBAAiB,CAAC,mCAAwB,EAAE,KAAK,IAAI,EAAE;QAC5D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,+JAA+J;oBAC5K,SAAS,EAAE,EAAE;iBACd;gBACD;oBACE,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,wOAAwO;oBACrP,SAAS,EAAE,EAAE;iBACd;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,iBAAiB,CAAC,iCAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACjE,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,OAAO;gBACL,WAAW,EAAE,qCAAqC;gBAClD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,2BAAmB;yBAC1B;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,OAAO;gBACL,WAAW,EAAE,8CAA8C;gBAC3D,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,8BAAsB;yBAC7B;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":";;;AAmHA,oDAiDC;AAnKD,iEAAsG;AAEzF,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DA+CyB,CAAC;AAEhD,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oGA6D8D,CAAC;AAErG,SAAgB,oBAAoB,CAAC,MAAc;IACjD,MAAM,CAAC,iBAAiB,CAAC,mCAAwB,EAAE,KAAK,IAAI,EAAE;QAC5D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,+JAA+J;oBAC5K,SAAS,EAAE,EAAE;iBACd;gBACD;oBACE,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,wOAAwO;oBACrP,SAAS,EAAE,EAAE;iBACd;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,iBAAiB,CAAC,iCAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACjE,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,OAAO;gBACL,WAAW,EAAE,qCAAqC;gBAClD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,2BAAmB;yBAC1B;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,OAAO;gBACL,WAAW,EAAE,8CAA8C;gBAC3D,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,8BAAsB;yBAC7B;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AA41BnE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,IAAI,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAC1C,IAAI,CA2DN"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAkgCnE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,IAAI,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAC1C,IAAI,CA2DN"}