@nxuss/lemma 0.8.2 โ†’ 0.9.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.
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
- # ๐Ÿง  Lemma v0.8.1
1
+ # ๐Ÿง  Lemma v0.9.1
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,239 @@
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.**
21
18
 
22
- ---
23
-
24
- ## โšก Killer Features
25
-
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.
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.
28
20
 
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".
21
+ ---
34
22
 
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.
23
+ ## ๐Ÿ’Ž Free vs Pro
24
+
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 32 tools)** | โŒ | โœ… |
35
+ | **The Brain โ€” Semantic Memory** | โŒ | โœ… |
36
+ | **Zero-Token Static Analysis** | โŒ | โœ… |
37
+ | **Cross-Project Telepathy** | โŒ | โœ… |
38
+ | **AutoPilot & Auto-Heal** | โŒ | โœ… |
39
+
40
+ > **The MCP is Pro.** All 32 tools โ€” The Brain, PreCrime predictor, AST Hologram, Entropy Score, Coupling Radar, workspace control, and every optimization tool โ€” require a Pro license. Activate with `lemma activate <key>` โ†’ [Get Pro](https://lemma.nxus.studio/upgrade)
37
41
 
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.
42
+ ---
40
43
 
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.
44
+ ## โšก What's in the Pro MCP
43
45
 
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
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.
47
+ ### ๐Ÿง  Shared Semantic Memory โ€” The Brain
48
+ 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
49
 
50
50
  ### ๐Ÿ›ก๏ธ 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.
51
+ **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.
52
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.
53
+ ### ๐Ÿ”ฎ PreCrime Static Analyzer โ€” Zero Tokens
54
+ **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.
55
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.
56
+ ### ๐Ÿ•ธ๏ธ Coupling Radar โ€” Zero Tokens
57
+ 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.
58
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.
59
+ ### ๐Ÿงฎ Entropy Score โ€” Zero Tokens
60
+ 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.
61
61
 
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.
62
+ ### ๐Ÿ—บ๏ธ AST Hologram โ€” Zero Tokens
63
+ 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.
64
64
 
65
- ---
66
-
67
- ## ๐Ÿ”Œ Native SDKs: LangChain & CrewAI Integration
68
-
69
- Lemma isn't just for IDE chats. Bring enterprise privacy and cost-savings to your codebases and agentic frameworks.
70
-
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';
65
+ ### ๐Ÿšฆ Complexity Router
66
+ 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
67
 
76
- const model = new LemmaLangChainProvider({
77
- apiKey: process.env.OPENAI_API_KEY,
78
- });
79
- ```
68
+ ### โœ‚๏ธ Context Squeezer & TurboMode
69
+ 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
70
 
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';
71
+ ### ๐Ÿ›ธ Autonomous Workspace Control
72
+ 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
73
 
86
- const crew = new LemmaCrewAIProvider({
87
- agents: [...],
88
- });
89
- ```
74
+ ### ๐Ÿฉบ AutoPilot & Auto-Heal
75
+ 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
76
 
91
77
  ---
92
78
 
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:
79
+ ## ๐Ÿš€ Quick Start (Zero Config)
96
80
 
97
81
  ```bash
98
- # 1. Install globally
82
+ # Install globally
99
83
  npm install -g @nxuss/lemma
100
84
 
101
- # 2. Initialize (Auto-configures local database and environment)
85
+ # Initialize (auto-configures local DB and MCP for your IDEs)
102
86
  lemma init
103
87
 
104
- # 3. Spin up the gateway and launch the gorgeous dashboard
88
+ # Start the gateway + dashboard
105
89
  lemma start
106
90
  ```
107
91
 
108
- ### ๐Ÿ› ๏ธ CLI Reference
92
+ ---
93
+
94
+ ## ๐Ÿ› ๏ธ CLI Reference
109
95
 
110
96
  | Command | Action |
111
97
  | :--- | :--- |
112
- | `lemma init` | Bootstraps configuration files and auto-discovers project stack. |
113
- | `lemma start` | Launches the proxy, cache engine, and dashboard. |
98
+ | `lemma init` | Bootstraps config and auto-configures MCP for Claude Desktop, Cursor, Windsurf, Kiro, VS Code. |
99
+ | `lemma start` | Launches proxy, cache engine, and dashboard at `http://localhost:8081`. |
114
100
  | `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.). |
101
+ | `lemma status` | Health of all modules and active connections. |
102
+ | `lemma stats` | Real-time token and cost savings metrics. |
103
+ | `lemma mcp` | Starts the stdin/stdout MCP server for IDE integration. |
118
104
  | `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. |
105
+ | `lemma autopilot` | Toggle autonomous background watcher mode. |
123
106
 
124
- ### โš™๏ธ Customization & System Options
107
+ ### Customizing via `lemma.config.json`
125
108
 
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.
109
+ ```json
110
+ {
111
+ "system": {
112
+ "clipboardWatcher": { "disabled": false }
113
+ },
114
+ "mcp": {
115
+ "allowedCommandPrefixes": ["npm", "git", "tsc", "your-custom-tool"]
116
+ }
117
+ }
118
+ ```
127
119
 
128
- #### CLI Command Options
120
+ ---
129
121
 
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.
122
+ ## ๐Ÿ”Œ MCP Integration
134
123
 
135
- #### Customizing via `lemma.config.json`
124
+ Add Lemma to any MCP-compatible IDE in seconds:
136
125
 
137
- Create or edit `lemma.config.json` in your project root to disable or fine-tune specific background daemons:
126
+ ### Cursor / Windsurf / Kiro / Antigravity
127
+ 1. Go to **Settings โ†’ MCP**
128
+ 2. Add new server: **Command** = `lemma mcp`
138
129
 
130
+ ### Claude Desktop
139
131
  ```json
140
132
  {
141
- "system": {
142
- "autoConfigure": {
143
- "disabled": false,
144
- "editor": true,
145
- "shell": true,
146
- "claude": true
147
- },
148
- "clipboardWatcher": {
149
- "disabled": false
133
+ "mcpServers": {
134
+ "lemma": {
135
+ "command": "npx",
136
+ "args": ["-y", "@nxuss/lemma", "mcp"]
150
137
  }
151
138
  }
152
139
  }
153
140
  ```
154
141
 
155
- ---
142
+ Once connected, your IDE gains access to all **32 MCP tools** and Lemma auto-injects the TurboMode system prompt on handshake.
156
143
 
157
- ## ๐Ÿ› ๏ธ MCP Tools Reference (v0.8.0 โ€” 25 Tools)
144
+ ---
158
145
 
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.
146
+ ## ๐Ÿ› ๏ธ MCP Tools Reference (v0.9.0 โ€” 32 Tools)
160
147
 
161
148
  ### ๐Ÿ—‚๏ธ Workspace Tools
162
149
 
163
150
  | Tool | Description |
164
151
  | :--- | :--- |
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. |
152
+ | `read_workspace_file` | Read a file with automatic token compression and privacy scrubbing. |
153
+ | `write_workspace_file` | Write content to a file, creating parent directories as needed. |
154
+ | `apply_workspace_patch` | Smart search-and-replace patch โ€” safe against duplicate matches. Returns clear errors if search block is ambiguous. |
168
155
  | `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. |
156
+ | `search_workspace` | Fast text search (grep) across all project files with optional extension filter. Results are privacy-scrubbed. |
157
+ | `run_workspace_command` | Execute bash commands in the workspace root. Secured by an allowlist. 15s timeout. |
171
158
 
172
- ### ๐Ÿ”ฌ Code Intelligence Tools โœจ NEW in v0.7.0
159
+ ### ๐Ÿ”ฌ Code Intelligence Tools
173
160
 
174
161
  | Tool | Description |
175
162
  | :--- | :--- |
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. |
163
+ | `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. |
164
+ | `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. |
165
+ | `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
166
 
179
167
  ### ๐Ÿง  Brain & Memory Tools
180
168
 
181
169
  | Tool | Description |
182
170
  | :--- | :--- |
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. |
171
+ | `search_memory` | Semantic search across The Brain โ€” retrieves past solutions and context from all your projects globally. |
172
+ | `store_memory` | Persist a technical solution, bug fix, or architecture decision into The Brain for future sessions. |
173
+ | `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. |
174
+ | `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
175
 
188
176
  ### โš™๏ธ Optimization & Privacy Tools
189
177
 
190
178
  | Tool | Description |
191
179
  | :--- | :--- |
192
180
  | `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)
181
+ | `squeeze_prompt` | Compress code blocks and boilerplate in any prompt. Up to 80% token reduction. |
182
+ | `turbosqueeze` | **Extreme compression.** Strips comments, imports, whitespace, and compacts JSON. Returns reduction stats. |
183
+ | `compress_context` | Summarizes old conversation turns, keeps last N turns intact. Falls back to truncation if no Ollama. |
184
+ | `prune_conversation_history` | Intelligently decimate conversation history while preserving critical recent context. |
185
+ | `summarize_long_text` | Summarize lengthy content via Ollama to save context window space. Falls back gracefully. |
186
+ | `smarter_cache` | **Predictive cache.** Queries The Brain at 75% threshold before any reasoning. Auto-suggests `store_memory` on MISS. |
187
+ | `token_budget` | Optimization dashboard: multiplier, total tokens saved, active strategies, and recommendations. |
188
+ | `get_routing_advice` | Analyze a prompt and get optimal model recommendation from the Complexity Router. |
189
+ | `get_project_onboarding` | Download a one-shot architectural mental model of the current codebase. |
190
+ | `auto_heal` | Diagnose and auto-heal the latest crash from Lemma's live context logs. |
191
+ | `batch_tool_calls` | Execute multiple tool calls in parallel via `Promise.all`. High-throughput operations in a single MCP round-trip. |
192
+
193
+ ### ๐Ÿ”ฎ Zero-Token Static Intelligence Tools (NEW in v0.9.0)
194
+
195
+ > All tools in this section use **zero LLM tokens, zero Ollama, zero cloud**. Pure local computation via TypeScript Compiler API, git, and math.
207
196
 
208
197
  | Tool | Description |
209
198
  | :--- | :--- |
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. |
199
+ | `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. |
200
+ | `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. |
201
+ | `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. |
202
+ | `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. |
203
+ | `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. |
204
+ | `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. |
205
+ | `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
206
 
215
207
  ### โšก 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
208
+
209
+ When connected via `lemma mcp`, Lemma auto-injects 7 rules into the agent's system prompt on handshake:
210
+
211
+ 1. `turbosqueeze` before writing large code blocks
218
212
  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
213
+ 3. `store_memory` after every resolved solution
214
+ 4. `get_ast_hologram` before reading files
215
+ 5. `batch_tool_calls` for parallel operations
216
+ 6. `semantic_dedup_guard` before every `store_memory`
217
+ 7. No fluff, no chit-chat โ€” maximum density
224
218
 
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.
219
+ ---
227
220
 
228
- ### ๐Ÿ“ก MCP Resources
221
+ ## ๐Ÿ“ก MCP Resources
229
222
 
230
223
  | Resource URI | Description |
231
224
  | :--- | :--- |
232
- | `lemma://runtime/context` | Live application errors, stack traces, and runtime state. Subscribable โ€” your IDE gets notified the instant a crash happens. |
225
+ | `lemma://runtime/context` | Live application errors, stack traces, and runtime state. Subscribable โ€” IDE notified instantly on crash. |
233
226
  | `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. |
227
+ | `lemma://project/context` | Active project metadata, tech stack, memory count, and token savings. |
235
228
  | `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. |
229
+ | `lemma://multiverse/timeline` | Chronological AST diff timeline of recent code snapshots. |
237
230
 
238
231
  ---
239
232
 
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
233
+ ## ๐Ÿ”’ Security
306
234
 
307
235
  ### 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:
236
+ By default, Lemma binds only to `127.0.0.1` (localhost). Not network-accessible unless explicitly configured:
309
237
  ```env
310
238
  LEMMA_BIND_HOST=0.0.0.0
239
+ AUTH_ENABLED=true
240
+ AUTH_REQUIRE_API_KEY=true
241
+ AUTH_ALLOWED_ORIGINS=https://yourdomain.com
311
242
  ```
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
243
 
327
244
  ### 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.
245
+ `run_workspace_command` only executes commands from an allowlist. Default safe prefixes: `npm`, `npx`, `git`, `tsc`, `node`, `jest`, `eslint`, `ls`, `grep`, and more.
329
246
 
330
- To extend the allowlist for your project, add to `lemma.config.json`:
247
+ Extend for your project in `lemma.config.json`:
331
248
  ```json
332
249
  {
333
250
  "mcp": {
@@ -336,24 +253,37 @@ To extend the allowlist for your project, add to `lemma.config.json`:
336
253
  }
337
254
  ```
338
255
 
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
256
+ See [`.env.security.example`](.env.security.example) for all security-related environment variables.
257
+
258
+ ---
259
+
260
+ ## ๐Ÿฆœ SDK Integrations
261
+
262
+ ### LangChain
263
+ ```typescript
264
+ import { LemmaLangChainProvider } from '@nxuss/lemma/langchain';
265
+
266
+ const model = new LemmaLangChainProvider({
267
+ apiKey: process.env.OPENAI_API_KEY,
268
+ });
344
269
  ```
345
270
 
346
- ### Stripe Webhooks (Cloud Server)
347
- The Stripe webhook endpoint requires a webhook signing secret in production:
348
- ```env
349
- STRIPE_WEBHOOK_SECRET=whsec_...
271
+ ### CrewAI
272
+ ```typescript
273
+ import { LemmaCrewAIProvider } from '@nxuss/lemma/crewai';
274
+
275
+ const crew = new LemmaCrewAIProvider({ agents: [...] });
350
276
  ```
351
- Get this from **Stripe Dashboard โ†’ Developers โ†’ Webhooks โ†’ Signing Secret**. Without it, the endpoint is disabled in `NODE_ENV=production`.
352
277
 
353
- For local testing: `STRIPE_SKIP_SIGNATURE_VERIFY=true`
278
+ ---
354
279
 
355
- ### Full Security Template
356
- See [`.env.security.example`](.env.security.example) for all security-related environment variables.
280
+ ## ๐Ÿ”„ Using as a Proxy
281
+
282
+ Point any OpenAI-compatible tool to Lemma's local proxy for transparent caching and privacy:
283
+
284
+ - **Cursor:** `Settings > Models > OpenAI API > Override Base URL` โ†’ `http://localhost:8081/v1`
285
+ - **VS Code (Continue):** Set `apiBase` to `http://localhost:8081/v1`
286
+ - **Custom apps:** Replace `https://api.openai.com/v1` with `http://localhost:8081/v1`
357
287
 
358
288
  ---
359
289
 
@@ -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;AAqXnE,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,CA2CN"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AA0enE,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"}