@nxuss/lemma 0.8.1 โ†’ 0.9.0

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 (58) hide show
  1. package/README.md +144 -236
  2. package/dist/cjs/cli/lemma-proxy.d.ts.map +1 -1
  3. package/dist/cjs/cli/lemma-proxy.js +57 -119
  4. package/dist/cjs/cli/lemma-proxy.js.map +1 -1
  5. package/dist/cjs/mcp/tools.d.ts.map +1 -1
  6. package/dist/cjs/mcp/tools.js +868 -0
  7. package/dist/cjs/mcp/tools.js.map +1 -1
  8. package/dist/cjs/observability/IdeContextSync.js +3 -3
  9. package/dist/cjs/observability/IdeContextSync.js.map +1 -1
  10. package/dist/cjs/proxy/ProjectStore.d.ts +2 -0
  11. package/dist/cjs/proxy/ProjectStore.d.ts.map +1 -1
  12. package/dist/cjs/proxy/ProjectStore.js +3 -1
  13. package/dist/cjs/proxy/ProjectStore.js.map +1 -1
  14. package/dist/cjs/proxy/SseRelay.d.ts +4 -25
  15. package/dist/cjs/proxy/SseRelay.d.ts.map +1 -1
  16. package/dist/cjs/proxy/SseRelay.js +60 -63
  17. package/dist/cjs/proxy/SseRelay.js.map +1 -1
  18. package/dist/esm/cli/lemma-proxy.d.ts.map +1 -1
  19. package/dist/esm/cli/lemma-proxy.js +29 -91
  20. package/dist/esm/cli/lemma-proxy.js.map +1 -1
  21. package/dist/esm/mcp/tools.d.ts.map +1 -1
  22. package/dist/esm/mcp/tools.js +868 -0
  23. package/dist/esm/mcp/tools.js.map +1 -1
  24. package/dist/esm/observability/IdeContextSync.js +1 -1
  25. package/dist/esm/observability/IdeContextSync.js.map +1 -1
  26. package/dist/esm/proxy/ProjectStore.d.ts +2 -0
  27. package/dist/esm/proxy/ProjectStore.d.ts.map +1 -1
  28. package/dist/esm/proxy/ProjectStore.js +2 -0
  29. package/dist/esm/proxy/ProjectStore.js.map +1 -1
  30. package/dist/esm/proxy/SseRelay.d.ts +4 -25
  31. package/dist/esm/proxy/SseRelay.d.ts.map +1 -1
  32. package/dist/esm/proxy/SseRelay.js +60 -60
  33. package/dist/esm/proxy/SseRelay.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/cjs/protocol/iap.d.ts +0 -54
  36. package/dist/cjs/protocol/iap.d.ts.map +0 -1
  37. package/dist/cjs/protocol/iap.js +0 -108
  38. package/dist/cjs/protocol/iap.js.map +0 -1
  39. package/dist/cjs/subconscious/cache.d.ts +0 -34
  40. package/dist/cjs/subconscious/cache.d.ts.map +0 -1
  41. package/dist/cjs/subconscious/cache.js +0 -156
  42. package/dist/cjs/subconscious/cache.js.map +0 -1
  43. package/dist/cjs/subconscious/embeddings.d.ts +0 -25
  44. package/dist/cjs/subconscious/embeddings.d.ts.map +0 -1
  45. package/dist/cjs/subconscious/embeddings.js +0 -65
  46. package/dist/cjs/subconscious/embeddings.js.map +0 -1
  47. package/dist/esm/protocol/iap.d.ts +0 -54
  48. package/dist/esm/protocol/iap.d.ts.map +0 -1
  49. package/dist/esm/protocol/iap.js +0 -104
  50. package/dist/esm/protocol/iap.js.map +0 -1
  51. package/dist/esm/subconscious/cache.d.ts +0 -34
  52. package/dist/esm/subconscious/cache.d.ts.map +0 -1
  53. package/dist/esm/subconscious/cache.js +0 -152
  54. package/dist/esm/subconscious/cache.js.map +0 -1
  55. package/dist/esm/subconscious/embeddings.d.ts +0 -25
  56. package/dist/esm/subconscious/embeddings.d.ts.map +0 -1
  57. package/dist/esm/subconscious/embeddings.js +0 -58
  58. package/dist/esm/subconscious/embeddings.js.map +0 -1
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
- # ๐Ÿง  Lemma v0.8.1
1
+ # ๐Ÿง  Lemma v0.9.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
- [![Build Status](https://img.shields.io/badge/tests-139%20passed-brightgreen.svg?style=flat-square)](https://github.com/Nxusbets/lemma)
5
+ [![MCP Tools](https://img.shields.io/badge/MCP%20tools-32-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
- [![MCP Tools](https://img.shields.io/badge/MCP%20tools-25-ff69b4?style=flat-square)](https://github.com/Nxusbets/lemma)
9
8
 
10
9
  ```text
11
10
  __
@@ -13,321 +12,217 @@
13
12
  / / / _ \/ __ `__ \/ __ `__ \/ __ `/
14
13
  / /___/ __/ / / / / / / / / / / /_/ /
15
14
  /_____/\___/_/ /_/ /_/_/ /_/ /_/\__,_/
16
-
17
15
  ```
18
- > **The Intelligent local-first AI Gateway โ€” Privacy, Performance, and Precision for the Agentic Era.**
19
16
 
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**, and **Privacy Guardrails**.
17
+ > **The Intelligent local-first AI Gateway โ€” Privacy, Performance, and Static Code Intelligence for the Agentic Era.**
18
+
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 **32 MCP tools** โ€” including zero-token static code intelligence that runs entirely on your machine with no LLM calls required.
21
20
 
22
21
  ---
23
22
 
24
23
  ## โšก Killer Features
25
24
 
26
- ### ๐Ÿ–ฅ๏ธ Real-Time Telemetry & Time-Travel Dashboard
27
- **Full Observability & Interactive Debugging.** Spin up a gorgeous React-based dashboard at `http://localhost:8081/dashboard/` to monitor your entire AI workflow. View real-time charts of cost savings, token compactions, and cache hits. Walk through complex multi-agent conversations step-by-step using a time-travel slider, select and inspect active agent states, and export detailed telemetry audits instantly.
28
-
29
- ### ๐Ÿ›ธ Kiro/Cursor Composer Bypass (Pro Option) ๐Ÿ’Ž
30
- **Autonomous Multi-File Editing For Free.** Exposes `write_workspace_file`, smart `apply_workspace_patch` (smart search-and-replace patching), and sandbox terminal tool `run_workspace_command` (compile/lint check) to Cursor's standard chat or Claude Desktop via MCP. Any standard free chat instantly acts as a fully-featured, unlimited autonomous multi-file Composer without needing a premium Kiro/Cursor Pro subscription.
31
-
32
- ### ๐ŸŒŒ AST Time-Travel Telemetry: El Multiverso de Cรณdigo (Pro Option) ๐Ÿ’Ž
33
- **Regressive Error Debugging & Time-Travel.** Spawns a background recursive file watcher that debounces filesystem edits and calculates incremental AST diffs on every save. Merges active compiler crash logs to package a chronologically ordered time-traveling timeline resource (`lemma://multiverse/timeline`) so your LLM agents can inspect past codebase states and regressions instantly when you say "It broke".
34
-
35
- ### ๐Ÿ—บ๏ธ Zero-Shot Project Onboarding (Pro Option) ๐Ÿ’Ž
36
- **One-Shot Architecture Map.** Exposes a dynamic onboard resource (`lemma://project/onboarding`) that scans package files, folders, and key directory markers to compile a beautiful, structured markdown guide of your codebase's stack, directory layouts, and design principles so the LLM gets fully onboarded in a single shot.
37
-
38
- ### ๐Ÿง  Cross-Project Bug Telepathy (Pro Option) ๐Ÿ’Ž
39
- **Global Developer Hive Mind.** Lemma dynamically scans and queries vector memory indexes of all other local projects on your computer. If you solved a compiler issue or technical blocker in a different workspace last week, Lemma will telepathically inject that high-confidence solution to the current project's chat without you typing a single word.
40
-
41
- ### โœ‚๏ธ Codebase Context Squeezer & Log Collapsing
42
- **Massive Speedups & Zero Token Waste.** Get instant model responses and make your context windows go up to 10x further. Lemma dynamically squeezes outgoing codebase payloads, strips comments/whitespaces, and collapses repetitive console logs or redundant compiler stack traces, saving up to 95% on token consumption automatically.
43
-
44
- ### ๐Ÿ›ธ Local Cache-Augmented Response Synthesis (CARS)
45
- **Zero-Cost Answer Synthesis.** Experience instantaneous responses for questions similar to what you've asked beforeโ€”without hitting the cloud or spending a single penny on API tokens. Lemma automatically refines past knowledge to answer your current questions in under a second, keeping your work completely private and free of charge.
46
-
47
- ### ๐Ÿ“‹ Clipboard Telepathic Watcher (Universal Squeezer)
48
- **Universal Token Optimization Anywhere.** Enjoy Lemma's massive token-saving compression even in locked enterprise IDEs, web browsers, or closed developer chats. It works silently in the background, making sure that any code you paste into any chat is already fully optimized and compressed. You get ultra-compact, high-speed prompts everywhere instantly.
25
+ ### ๐Ÿง  Shared Semantic Memory โ€” The Brain
26
+ Lemma maintains a persistent vector database (ChromaDB) that accumulates knowledge across all your projects. Every solution, bug fix, and architecture decision you work through gets stored and semantically indexed. Future sessions can retrieve this knowledge in milliseconds โ€” no cloud, no tokens, no re-explaining.
49
27
 
50
28
  ### ๐Ÿ›ก๏ธ Privacy Firewall (Semantic Scrubber)
51
- **Enterprise-Grade Privacy.** Code with absolute peace of mind. Lemma prevents your sensitive secrets, API keys, credentials, and personally identifiable information (PII) from ever escaping your machine or reaching cloud providers, while ensuring your development flows are completely uninterrupted.
52
-
53
- ### ๐Ÿšฆ Complexity Router (Cost-Optimizer)
54
- **Smart Budget Management.** Slash your AI bills by up to 90% without sacrificing quality. Lemma intelligently evaluates your tasks, automatically using the most cost-effective resources for simple queries while reserving premium models for complex reasoning problems, ensuring optimal efficiency.
55
-
56
- ### ๐Ÿง  Telepathic Context Injector & Real-Time MCP Sync
57
- **Live App Consciousness.** Say goodbye to manual debugging and copy-pasting runtime errors. Your AI assistant stays perfectly synchronized with your application's active state, automatically alerting you to errors and bugs the instant they happen so you can fix them immediately.
58
-
59
- ### โšก Zero-Cost Local Streaming Fallback
60
- **Uninterrupted Offline Coding.** Never get blocked by cloud outages, network drops, or missing API keys. Lemma provides a seamless fallback that keeps your AI chat streaming instantly and completely for free, even when you're fully offline.
29
+ **Enterprise-Grade Privacy.** Prevents API keys, credentials, and PII from ever leaving your machine. Applied automatically to every file read and workspace search via MCP.
61
30
 
62
- ### ๐Ÿ’พ Shared Semantic Cache
63
- **Sub-Millisecond Response Speeds.** Eliminate redundant costs and wait times. Lemma is smart enough to deliver instant responses to recurring or conceptually similar ideas, cutting your total API expenditure by 40-70% and saving you hours of waiting.
31
+ ### ๐Ÿ”ฎ PreCrime Static Analyzer โ€” Zero Tokens
32
+ **Minority Report for your code.** Combines cyclomatic complexity, git churn history, and module coupling into a composite risk score per file. Predicts which files are most likely to produce a bug before you touch them โ€” using only the TypeScript Compiler API and git log. No LLM. No Ollama. No tokens.
64
33
 
65
- ---
34
+ ### ๐Ÿ•ธ๏ธ Coupling Radar โ€” Zero Tokens
35
+ Builds a full import/export dependency graph of your codebase using the TypeScript Compiler. Detects circular dependencies, god modules (imported by everything), dead islands (no importers), and fan-in/fan-out per module. Essential before any large refactor.
66
36
 
67
- ## ๐Ÿ”Œ Native SDKs: LangChain & CrewAI Integration
37
+ ### ๐Ÿงฎ Entropy Score โ€” Zero Tokens
38
+ Mathematical chaos score (0-100) per file using the TS Compiler API. Measures cyclomatic complexity, nesting depth, `any` ratio, and average function size. Tells you exactly where refactor debt is accumulating.
68
39
 
69
- Lemma isn't just for IDE chats. Bring enterprise privacy and cost-savings to your codebases and agentic frameworks.
40
+ ### ๐Ÿ—บ๏ธ AST Hologram โ€” Zero Tokens
41
+ 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.
70
42
 
71
- ### ๐Ÿฆœ LangChain Integration
72
- Run secure, ultra-efficient chains with a single line of code. Lemma integrates natively as a first-class provider in LangChain, tree-shaking outgoing tool calls and caching complex semantic queries.
73
- ```typescript
74
- import { LemmaLangChainProvider } from '@nxuss/lemma/langchain';
43
+ ### ๐Ÿšฆ Complexity Router
44
+ Intelligently evaluates each prompt and routes it to the most cost-effective model. Reserves premium models for complex reasoning, uses smaller models for simple tasks. Slashes your AI bill without sacrificing quality.
75
45
 
76
- const model = new LemmaLangChainProvider({
77
- apiKey: process.env.OPENAI_API_KEY,
78
- });
79
- ```
46
+ ### โœ‚๏ธ Context Squeezer & TurboMode
47
+ Dynamically squeezes outgoing code payloads, strips comments, collapses whitespace, and compacts JSON. Saves up to 90% on token consumption. Automatically injected via the `lemma-turbomode` system prompt on MCP handshake.
80
48
 
81
- ### ๐Ÿ‘ฅ CrewAI Integration
82
- Coordinate heavy multi-agent swarms without breaking your bank. Lemma automatically handles agent-to-agent communication compression, prevents token bloat, and provides high-speed consensus caching.
83
- ```typescript
84
- import { LemmaCrewAIProvider } from '@nxuss/lemma/crewai';
49
+ ### ๐Ÿ›ธ Autonomous Workspace Control
50
+ Exposes `write_workspace_file`, smart `apply_workspace_patch` (collision-safe search-and-replace), and `run_workspace_command` (with allowlist security) to any IDE via MCP. Any standard chat instantly becomes a fully-featured autonomous multi-file editor.
85
51
 
86
- const crew = new LemmaCrewAIProvider({
87
- agents: [...],
88
- });
89
- ```
52
+ ### ๐Ÿฉบ AutoPilot & Auto-Heal
53
+ 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.
90
54
 
91
55
  ---
92
56
 
93
- ## ๐Ÿš€ Smart CLI (Zero-Config)
94
-
95
- Lemma introduces a powerful, unified command-line tool. Get started, monitor, and manage your local AI gateway effortlessly:
57
+ ## ๐Ÿš€ Quick Start (Zero Config)
96
58
 
97
59
  ```bash
98
- # 1. Install globally
60
+ # Install globally
99
61
  npm install -g @nxuss/lemma
100
62
 
101
- # 2. Initialize (Auto-configures local database and environment)
63
+ # Initialize (auto-configures local DB and MCP for your IDEs)
102
64
  lemma init
103
65
 
104
- # 3. Spin up the gateway and launch the gorgeous dashboard
66
+ # Start the gateway + dashboard
105
67
  lemma start
106
68
  ```
107
69
 
108
- ### ๐Ÿ› ๏ธ CLI Reference
70
+ ---
71
+
72
+ ## ๐Ÿ› ๏ธ CLI Reference
109
73
 
110
74
  | Command | Action |
111
75
  | :--- | :--- |
112
- | `lemma init` | Bootstraps configuration files and auto-discovers project stack. |
113
- | `lemma start` | Launches the proxy, cache engine, and dashboard. |
76
+ | `lemma init` | Bootstraps config and auto-configures MCP for Claude Desktop, Cursor, Windsurf, Kiro, VS Code. |
77
+ | `lemma start` | Launches proxy, cache engine, and dashboard at `http://localhost:8081`. |
114
78
  | `lemma stop` | Gracefully shuts down the background proxy. |
115
- | `lemma status` | Displays health of all optimization modules and active connections. |
116
- | `lemma stats` | High-density metrics showing real-time token and cost savings. |
117
- | `lemma mcp` | Starts stdin/stdout MCP server for IDE integration (Cursor, Claude, VS Code, etc.). |
79
+ | `lemma status` | Health of all modules and active connections. |
80
+ | `lemma stats` | Real-time token and cost savings metrics. |
81
+ | `lemma mcp` | Starts the stdin/stdout MCP server for IDE integration. |
118
82
  | `lemma heal` | Auto-diagnose and repair the latest server crash from live context logs. |
119
- | `lemma upgrade` | See Pro features and get a license key. |
120
- | `lemma activate <key>` | Activate a Pro license key. |
121
- | `lemma autopilot` | Toggle autonomous mode for unattended cost optimization. |
122
- | `lemma clipboard` | Toggle the Clipboard Telepathic Watcher daemon. |
83
+ | `lemma autopilot` | Toggle autonomous background watcher mode. |
123
84
 
124
- ### โš™๏ธ Customization & System Options
85
+ ### Customizing via `lemma.config.json`
125
86
 
126
- By default, Lemma works seamlessly with zero configuration. However, if you are running in a sensitive enterprise environment or want absolute control over filesystem modifications, you can customize Lemma's behavior.
87
+ ```json
88
+ {
89
+ "system": {
90
+ "clipboardWatcher": { "disabled": false }
91
+ },
92
+ "mcp": {
93
+ "allowedCommandPrefixes": ["npm", "git", "tsc", "your-custom-tool"]
94
+ }
95
+ }
96
+ ```
127
97
 
128
- #### CLI Command Options
98
+ ---
129
99
 
130
- * **`lemma init`**: Initializes project, auto-discovers stack, and prompts before editing IDE configs.
131
- * **`lemma init --no-configure`**: Initialize without MCP server configuration for any IDE.
132
- * **`lemma init --yes`**: Skip all prompts and accept defaults (auto-configures all IDEs).
133
- * **`lemma start --no-clipboard`**: Start the proxy without spawning the background Clipboard watcher daemon.
100
+ ## ๐Ÿ”Œ MCP Integration
134
101
 
135
- #### Customizing via `lemma.config.json`
102
+ Add Lemma to any MCP-compatible IDE in seconds:
136
103
 
137
- Create or edit `lemma.config.json` in your project root to disable or fine-tune specific background daemons:
104
+ ### Cursor / Windsurf / Kiro / Antigravity
105
+ 1. Go to **Settings โ†’ MCP**
106
+ 2. Add new server: **Command** = `lemma mcp`
138
107
 
108
+ ### Claude Desktop
139
109
  ```json
140
110
  {
141
- "system": {
142
- "autoConfigure": {
143
- "disabled": false,
144
- "editor": true,
145
- "shell": true,
146
- "claude": true
147
- },
148
- "clipboardWatcher": {
149
- "disabled": false
111
+ "mcpServers": {
112
+ "lemma": {
113
+ "command": "npx",
114
+ "args": ["-y", "@nxuss/lemma", "mcp"]
150
115
  }
151
116
  }
152
117
  }
153
118
  ```
154
119
 
155
- ---
120
+ Once connected, your IDE gains access to all **32 MCP tools** and Lemma auto-injects the TurboMode system prompt on handshake.
156
121
 
157
- ## ๐Ÿ› ๏ธ MCP Tools Reference (v0.8.0 โ€” 25 Tools)
122
+ ---
158
123
 
159
- When connected via `lemma mcp`, your Chat IDE gains access to **25 native tools** covering workspace navigation, code safety, semantic memory, AI cost optimization, autonomous project context injection, and TurboMode optimization.
124
+ ## ๐Ÿ› ๏ธ MCP Tools Reference (v0.9.0 โ€” 32 Tools)
160
125
 
161
126
  ### ๐Ÿ—‚๏ธ Workspace Tools
162
127
 
163
128
  | Tool | Description |
164
129
  | :--- | :--- |
165
- | `read_workspace_file` | Read a file with automatic token compression (up to 80% savings) and privacy scrubbing. |
166
- | `write_workspace_file` | Write content to a file, creating directories as needed. |
167
- | `apply_workspace_patch` | Smart search-and-replace patch โ€” safe against duplicate matches. |
130
+ | `read_workspace_file` | Read a file with automatic token compression and privacy scrubbing. |
131
+ | `write_workspace_file` | Write content to a file, creating parent directories as needed. |
132
+ | `apply_workspace_patch` | Smart search-and-replace patch โ€” safe against duplicate matches. Returns clear errors if search block is ambiguous. |
168
133
  | `list_workspace_dir` | Recursively list the project structure up to a configurable depth. |
169
- | `search_workspace` | Fast text search (grep) across all project files with optional extension filter. |
170
- | `run_workspace_command` | Execute bash commands (tests, linters, git) in the workspace root. Returns stdout/stderr. |
134
+ | `search_workspace` | Fast text search (grep) across all project files with optional extension filter. Results are privacy-scrubbed. |
135
+ | `run_workspace_command` | Execute bash commands in the workspace root. Secured by an allowlist. 15s timeout. |
171
136
 
172
- ### ๐Ÿ”ฌ Code Intelligence Tools โœจ NEW in v0.7.0
137
+ ### ๐Ÿ”ฌ Code Intelligence Tools
173
138
 
174
139
  | Tool | Description |
175
140
  | :--- | :--- |
176
- | `get_ast_hologram` | **Holographic AST Map.** Scans the workspace and returns a dense JSON index of all exported symbols (classes, functions, interfaces, types, consts) with their file paths and line numbers. Use this **instead of reading individual files** โ€” saves up to 90% tokens when navigating large codebases. |
177
- | `validate_patch_sandbox` | **AST Multiverse Auto-Debugger.** Validates a proposed patch in an isolated sandbox (`/tmp`) **before** applying it to the workspace. Runs `tsc --noEmit` and bracket-balance checks. Returns a clear `โœ… SAFE TO APPLY` or `โŒ DO NOT APPLY` verdict with full diagnostics. |
141
+ | `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. |
142
+ | `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. |
143
+ | `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. |
178
144
 
179
145
  ### ๐Ÿง  Brain & Memory Tools
180
146
 
181
147
  | Tool | Description |
182
148
  | :--- | :--- |
183
- | `search_memory` | Semantic search across The Brain โ€” retrieves past solutions and context from all your projects. |
184
- | `store_memory` | Explicitly save a key technical decision, code snippet, or architecture note into The Brain for future sessions. |
185
- | `query_hybrid_consensus` | **Hybrid Consensus Engine.** Checks The Brain for a cached answer at a configurable similarity threshold (default 80%). Brain **HIT** โ†’ instant response, zero cloud tokens spent. Brain **MISS** โ†’ instructs the IDE to proceed with cloud and auto-stores the result afterward. |
186
- | `get_telepathic_hints` | **Proactive Telepathy.** Given the path of the file being edited, automatically surfaces the top N most relevant memories and past solutions from The Brain โ€” no explicit query needed. Front-loads context before you write a single line. |
149
+ | `search_memory` | Semantic search across The Brain โ€” retrieves past solutions and context from all your projects globally. |
150
+ | `store_memory` | Persist a technical solution, bug fix, or architecture decision into The Brain for future sessions. |
151
+ | `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. |
152
+ | `get_telepathic_hints` | **Proactive Telepathy.** Given the active file path, surfaces the top N most relevant past solutions from The Brain โ€” no query needed. |
187
153
 
188
154
  ### โš™๏ธ Optimization & Privacy Tools
189
155
 
190
156
  | Tool | Description |
191
157
  | :--- | :--- |
192
158
  | `scrub_privacy` | Mask PII, API keys, and secrets from any text block using the Privacy Firewall. |
193
- | `squeeze_prompt` | Compress code blocks and boilerplate in any prompt โ€” up to 80% token reduction. |
194
- | `summarize_long_text` | Automatically summarize lengthy content to stay within context window limits. |
195
- | `prune_conversation_history` | Intelligently trim conversation history while preserving critical context. |
196
- | `diff_only` | Extract only the changed lines between two code blocks โ€” minimal token diff. |
197
- | `batch_tool_calls` | Execute multiple tool calls in parallel for high-throughput operations. |
198
- | `get_routing_advice` | Analyze a prompt and get the optimal model recommendation from the Complexity Router. |
199
- | `auto_heal` | Diagnose and auto-heal the latest local server crash from Lemma's live context logs. |
200
- | `get_project_onboarding` | Download a one-shot architectural mental model of the current project codebase. |
201
- | `turbosqueeze` | Extreme prompt compression โ€” strips comments, imports, whitespace, compacts JSON. |
202
- | `compress_context` | Summarize old conversation turns via Ollama (fallback: truncation). |
203
- | `smarter_cache` | Predictive cache โ€” queries The Brain at 75% threshold before reasoning. |
204
- | `token_budget` | Optimization dashboard with multiplier, savings, and recommendations. |
205
-
206
- ### ๐Ÿš€ TurboMode Tools (NEW in v0.8.0)
159
+ | `squeeze_prompt` | Compress code blocks and boilerplate in any prompt. Up to 80% token reduction. |
160
+ | `turbosqueeze` | **Extreme compression.** Strips comments, imports, whitespace, and compacts JSON. Returns reduction stats. |
161
+ | `compress_context` | Summarizes old conversation turns, keeps last N turns intact. Falls back to truncation if no Ollama. |
162
+ | `prune_conversation_history` | Intelligently decimate conversation history while preserving critical recent context. |
163
+ | `summarize_long_text` | Summarize lengthy content via Ollama to save context window space. Falls back gracefully. |
164
+ | `smarter_cache` | **Predictive cache.** Queries The Brain at 75% threshold before any reasoning. Auto-suggests `store_memory` on MISS. |
165
+ | `token_budget` | Optimization dashboard: multiplier, total tokens saved, active strategies, and recommendations. |
166
+ | `get_routing_advice` | Analyze a prompt and get optimal model recommendation from the Complexity Router. |
167
+ | `get_project_onboarding` | Download a one-shot architectural mental model of the current codebase. |
168
+ | `auto_heal` | Diagnose and auto-heal the latest crash from Lemma's live context logs. |
169
+ | `batch_tool_calls` | Execute multiple tool calls in parallel via `Promise.all`. High-throughput operations in a single MCP round-trip. |
170
+
171
+ ### ๐Ÿ”ฎ Zero-Token Static Intelligence Tools (NEW in v0.9.0)
172
+
173
+ > All tools in this section use **zero LLM tokens, zero Ollama, zero cloud**. Pure local computation via TypeScript Compiler API, git, and math.
207
174
 
208
175
  | Tool | Description |
209
176
  | :--- | :--- |
210
- | `turbosqueeze` | **Extreme prompt compression.** Strips comments, imports, whitespace, and compacts JSON. Returns reduction stats and reports savings to proxy ledger. |
211
- | `compress_context` | **Conversation summarization.** Summarizes old turns via Ollama (falls back to truncation), keeps last N turns intact, reports token savings. |
212
- | `smarter_cache` | **Predictive cache.** Queries The Brain at 75% threshold before any reasoning, auto-suggests `store_memory` on MISS. |
213
- | `token_budget` | **Optimization dashboard.** Displays current multiplier, tokens saved, tool calls, and optimization recommendations. |
177
+ | `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. |
178
+ | `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. |
179
+ | `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. |
180
+ | `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. |
181
+ | `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. |
182
+ | `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. |
183
+ | `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. |
214
184
 
215
185
  ### โšก TurboMode Auto-Injection
216
- When connected via `lemma mcp`, Lemma automatically injects 7 TurboMode rules into the agent's system prompt during handshake โ€” no manual prompt loading required:
217
- 1. `turbosqueeze` before writing code
186
+
187
+ When connected via `lemma mcp`, Lemma auto-injects 7 rules into the agent's system prompt on handshake:
188
+
189
+ 1. `turbosqueeze` before writing large code blocks
218
190
  2. `smarter_cache` before any reasoning
219
- 3. `compress_context` every turn
220
- 4. `store_memory` after every solution
221
- 5. `get_ast_hologram` before reading files
222
- 6. `batch_tool_calls` for parallel operations
223
- 7. No fluff or chit-chat
191
+ 3. `store_memory` after every resolved solution
192
+ 4. `get_ast_hologram` before reading files
193
+ 5. `batch_tool_calls` for parallel operations
194
+ 6. `semantic_dedup_guard` before every `store_memory`
195
+ 7. No fluff, no chit-chat โ€” maximum density
224
196
 
225
- ### ๐Ÿ“ก Dashboard MCP Toggle
226
- The Dashboard Header now shows a **clickable MCP status badge** โ€” click to enable/disable MCP integration instantly. The badge cycles through `active` (cyan), `idle` (gray), and `offline` (red) states.
197
+ ---
227
198
 
228
- ### ๐Ÿ“ก MCP Resources
199
+ ## ๐Ÿ“ก MCP Resources
229
200
 
230
201
  | Resource URI | Description |
231
202
  | :--- | :--- |
232
- | `lemma://runtime/context` | Live application errors, stack traces, and runtime state. Subscribable โ€” your IDE gets notified the instant a crash happens. |
203
+ | `lemma://runtime/context` | Live application errors, stack traces, and runtime state. Subscribable โ€” IDE notified instantly on crash. |
233
204
  | `lemma://stats/usage` | Current token savings, cost report, and cache hit metrics in JSON. |
234
- | `lemma://project/context` | Active project metadata, tech stack, memory count, and token savings โ€” used for automatic context injection on cache misses. |
205
+ | `lemma://project/context` | Active project metadata, tech stack, memory count, and token savings. |
235
206
  | `lemma://project/onboarding` | Dynamic project architecture guide compiled on demand. |
236
- | `lemma://multiverse/timeline` | Chronological AST diff timeline of the last 10 code micro-snapshots. |
207
+ | `lemma://multiverse/timeline` | Chronological AST diff timeline of recent code snapshots. |
237
208
 
238
209
  ---
239
210
 
240
- ## ๐Ÿ’Ž Tier Comparison
241
-
242
- | Feature | ๐Ÿ†“ Free (Standard) | ๐Ÿ’Ž Pro ($12/mo) |
243
- | :--- | :--- | :--- |
244
- | **Privacy Firewall** | โœ… Included | โœ… Advanced Masking |
245
- | **Complexity Router** | โœ… Included | โœ… Custom Routing Policies |
246
- | **Caching** | Exact Match | **Semantic Memory** |
247
- | **Hive Mind** | Local Only | **Cloud Sync (Team Memory) + Cross-Project Telepathy ๐Ÿ’Ž** |
248
- | **AST Time-Travel Telemetry** | โŒ None | **Codebase Multiverse (Cap 10 AST Snapshots) ๐Ÿ’Ž** |
249
- | **Kiro/Cursor Composer Bypass** | โŒ None | **Smart Patches & Sandbox Terminal MCP ๐Ÿ’Ž** |
250
- | **Zero-Shot Onboarding Guide** | โŒ None | **Codebase Architecture Map MCP ๐Ÿ’Ž** |
251
- | **AST Hologram** | โŒ None | **Symbol Map โ€” 90% token savings ๐Ÿ’Ž** |
252
- | **Sandbox Patch Validator** | โŒ None | **Pre-flight code safety checks ๐Ÿ’Ž** |
253
- | **Hybrid Consensus Engine** | โŒ None | **Brain-first query routing ๐Ÿ’Ž** |
254
- | **Proactive Telepathy** | โŒ None | **Auto-surfaced context hints ๐Ÿ’Ž** |
255
- | **Telemetry Dashboard** | Basic Stats | **Time-Travel Debugger & 60fps Graph** |
256
- | **Limits** | 300 requests/mo | **Unlimited Agentic Power** |
257
-
258
- ---
259
-
260
- ## ๐Ÿ› ๏ธ Integration: Power Up Your Favorite Tools
261
-
262
- Lemma is compatible with **any** tool that allows you to configure a custom OpenAI Base URL. This means you can add Lemma's intelligence to your existing workflow in seconds.
263
-
264
- ### ๐Ÿ’ฌ Use it with AI Chats & IDEs
265
- You don't need to change your habits. Just point your tool's "Base URL" to Lemma:
266
- * **Cursor:** Go to `Settings > Models > OpenAI API > Override Base URL` and set it to `http://localhost:8081/v1`.
267
- * **VS Code (Continue):** Update your `config.json` to use `http://localhost:8081/v1` as the `apiBase`.
268
- * **AutoGPT / BabyAGI:** Set the `OPENAI_API_BASE` environment variable.
269
- * **Custom Apps:** Replace `https://api.openai.com/v1` with `http://localhost:8081/v1` in your SDK initialization.
270
-
271
- ### ๐Ÿ’Ž Pro Integration (Model Context Protocol - MCP)
272
- For **Lemma Pro** users, expose Lemma's entire intelligence layer โ€” Privacy Firewall, Semantic Brain, AST Hologram, Sandbox Validator, Hybrid Consensus, and Proactive Telepathy โ€” directly as native tools using the **Model Context Protocol (MCP)**. This lets the LLM read, search, write, patch, validate, and compile files autonomously.
273
-
274
- #### ๐ŸŸข Cursor / Antigravity / Windsurf:
275
- 1. Go to **Settings > Features > MCP**.
276
- 2. Click **+ Add New MCP Server**.
277
- 3. Configure the server:
278
- * **Name**: `Lemma`
279
- * **Type**: `command`
280
- * **Command**: `lemma mcp`
281
- 4. Click **Save**. A green **"Connected"** dot will appear, confirming that the IDE has loaded all 25 of Lemma's tools.
282
-
283
- #### ๐ŸŸข Claude Desktop:
284
- Add the following to your `claude_desktop_config.json` configuration file:
285
- ```json
286
- {
287
- "mcpServers": {
288
- "lemma": {
289
- "command": "npx",
290
- "args": ["-y", "@nxuss/lemma", "mcp"]
291
- }
292
- }
293
- }
294
- ```
295
-
296
- ### โšก Why use Lemma for Chat?
297
- 1. **Privacy:** Your IDE won't leak your secrets to the cloud.
298
- 2. **Context:** Lemma syncs your runtime crashes directly to your chat window.
299
- 3. **Speed:** Instant responses for similar questions via Semantic Cache.
300
- 4. **Intelligence:** AST Hologram + Hybrid Consensus = dramatically fewer tokens spent per session.
301
- 5. **Observability:** Gorgeous dashboard showing you exactly how much cash and tokens you are saving.
302
-
303
- ---
304
-
305
- ## ๐Ÿ”’ Security & Privacy
211
+ ## ๐Ÿ”’ Security
306
212
 
307
213
  ### Network Binding
308
- By default, Lemma binds only to `127.0.0.1` (localhost). It is **not accessible from the network** unless you explicitly set:
214
+ By default, Lemma binds only to `127.0.0.1` (localhost). Not network-accessible unless explicitly configured:
309
215
  ```env
310
216
  LEMMA_BIND_HOST=0.0.0.0
217
+ AUTH_ENABLED=true
218
+ AUTH_REQUIRE_API_KEY=true
219
+ AUTH_ALLOWED_ORIGINS=https://yourdomain.com
311
220
  ```
312
- > โš ๏ธ If you do expose Lemma to the network, always enable authentication first:
313
- > ```env
314
- > AUTH_ENABLED=true
315
- > AUTH_REQUIRE_API_KEY=true
316
- > AUTH_ALLOWED_ORIGINS=https://yourdomain.com
317
- > ```
318
-
319
- ### ๐Ÿ“‹ Clipboard Watcher Disclosure
320
- The **Clipboard Telepathic Watcher** polls your system clipboard every 1 second to automatically compress code you copy. This is disclosed in the startup banner. To disable it:
321
- ```env
322
- # In your .env
323
- LEMMA_DISABLE_CLIPBOARD=true
324
- ```
325
- Or via CLI flag: `lemma start --no-clipboard`
326
221
 
327
222
  ### MCP Command Allowlist
328
- The `run_workspace_command` MCP tool only executes commands from an allowlist. Default safe prefixes include `npm`, `npx`, `git`, `tsc`, `node`, `jest`, `eslint`, `ls`, `grep`, and more.
223
+ `run_workspace_command` only executes commands from an allowlist. Default safe prefixes: `npm`, `npx`, `git`, `tsc`, `node`, `jest`, `eslint`, `ls`, `grep`, and more.
329
224
 
330
- To extend the allowlist for your project, add to `lemma.config.json`:
225
+ Extend for your project in `lemma.config.json`:
331
226
  ```json
332
227
  {
333
228
  "mcp": {
@@ -336,24 +231,37 @@ To extend the allowlist for your project, add to `lemma.config.json`:
336
231
  }
337
232
  ```
338
233
 
339
- ### License Security (Cloud Server)
340
- When running the cloud server in production, set a private license salt:
341
- ```env
342
- # Generate with: openssl rand -hex 32
343
- LEMMA_LICENSE_SALT=your-random-64-char-hex-string
234
+ See [`.env.security.example`](.env.security.example) for all security-related environment variables.
235
+
236
+ ---
237
+
238
+ ## ๐Ÿฆœ SDK Integrations
239
+
240
+ ### LangChain
241
+ ```typescript
242
+ import { LemmaLangChainProvider } from '@nxuss/lemma/langchain';
243
+
244
+ const model = new LemmaLangChainProvider({
245
+ apiKey: process.env.OPENAI_API_KEY,
246
+ });
344
247
  ```
345
248
 
346
- ### Stripe Webhooks (Cloud Server)
347
- The Stripe webhook endpoint requires a webhook signing secret in production:
348
- ```env
349
- STRIPE_WEBHOOK_SECRET=whsec_...
249
+ ### CrewAI
250
+ ```typescript
251
+ import { LemmaCrewAIProvider } from '@nxuss/lemma/crewai';
252
+
253
+ const crew = new LemmaCrewAIProvider({ agents: [...] });
350
254
  ```
351
- Get this from **Stripe Dashboard โ†’ Developers โ†’ Webhooks โ†’ Signing Secret**. Without it, the endpoint is disabled in `NODE_ENV=production`.
352
255
 
353
- For local testing: `STRIPE_SKIP_SIGNATURE_VERIFY=true`
256
+ ---
354
257
 
355
- ### Full Security Template
356
- See [`.env.security.example`](.env.security.example) for all security-related environment variables.
258
+ ## ๐Ÿ”„ Using as a Proxy
259
+
260
+ Point any OpenAI-compatible tool to Lemma's local proxy for transparent caching and privacy:
261
+
262
+ - **Cursor:** `Settings > Models > OpenAI API > Override Base URL` โ†’ `http://localhost:8081/v1`
263
+ - **VS Code (Continue):** Set `apiBase` to `http://localhost:8081/v1`
264
+ - **Custom apps:** Replace `https://api.openai.com/v1` with `http://localhost:8081/v1`
357
265
 
358
266
  ---
359
267
 
@@ -1 +1 @@
1
- {"version":3,"file":"lemma-proxy.d.ts","sourceRoot":"","sources":["../../../src/cli/lemma-proxy.ts"],"names":[],"mappings":";AA0bA,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CA4DvF;AA2jED,wBAAsB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6KhL"}
1
+ {"version":3,"file":"lemma-proxy.d.ts","sourceRoot":"","sources":["../../../src/cli/lemma-proxy.ts"],"names":[],"mappings":";AAsbA,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CA4DvF;AAmgED,wBAAsB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6KhL"}