@nxuss/lemma 1.6.0 → 1.7.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 +114 -5
- package/bin/checkpoint.js +49 -0
- package/bin/init.js +21 -2
- package/dist/cjs/mcp/prompts.d.ts +1 -2
- package/dist/cjs/mcp/prompts.d.ts.map +1 -1
- package/dist/cjs/mcp/prompts.js +29 -126
- package/dist/cjs/mcp/prompts.js.map +1 -1
- package/dist/cjs/mcp/resources.d.ts.map +1 -1
- package/dist/cjs/mcp/resources.js +4 -4
- package/dist/cjs/mcp/resources.js.map +1 -1
- package/dist/cjs/mcp/tool-profiles.d.ts +55 -0
- package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -0
- package/dist/cjs/mcp/tool-profiles.js +204 -0
- package/dist/cjs/mcp/tool-profiles.js.map +1 -0
- package/dist/cjs/mcp/tools.d.ts +12 -0
- package/dist/cjs/mcp/tools.d.ts.map +1 -1
- package/dist/cjs/mcp/tools.js +175 -26
- package/dist/cjs/mcp/tools.js.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.d.ts +36 -2
- package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.js +104 -23
- package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
- package/dist/cjs/utils/AutoContextBundle.d.ts.map +1 -1
- package/dist/cjs/utils/AutoContextBundle.js +17 -20
- package/dist/cjs/utils/AutoContextBundle.js.map +1 -1
- package/dist/cjs/utils/ConversationCheckpoint.d.ts +13 -0
- package/dist/cjs/utils/ConversationCheckpoint.d.ts.map +1 -1
- package/dist/cjs/utils/ConversationCheckpoint.js +58 -0
- package/dist/cjs/utils/ConversationCheckpoint.js.map +1 -1
- package/dist/cjs/utils/TestAutofixInterceptor.d.ts.map +1 -1
- package/dist/cjs/utils/TestAutofixInterceptor.js +15 -26
- package/dist/cjs/utils/TestAutofixInterceptor.js.map +1 -1
- package/dist/esm/api/dashboardRoutes.d.ts +3 -3
- package/dist/esm/api/dashboardRoutes.js +1 -1
- package/dist/esm/api/server.d.ts +4 -4
- package/dist/esm/api/server.js +3 -3
- package/dist/esm/autopilot/AutopilotWatcher.js +3 -3
- package/dist/esm/autopilot/Notifier.d.ts +1 -1
- package/dist/esm/cli/lemma-proxy.js +14 -14
- package/dist/esm/cli/stack.d.ts +4 -4
- package/dist/esm/cli/stack.js +5 -5
- package/dist/esm/cloud/KeyManager.d.ts +1 -1
- package/dist/esm/cloud/KeyManager.js +1 -1
- package/dist/esm/cloud/TenantCache.d.ts +1 -1
- package/dist/esm/cloud/TenantCache.js +1 -1
- package/dist/esm/cloud/index.d.ts +3 -3
- package/dist/esm/cloud/index.js +3 -3
- package/dist/esm/cloud/server.d.ts +3 -3
- package/dist/esm/cloud/server.js +5 -5
- package/dist/esm/config/index.d.ts +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/consensus/index.d.ts +2 -2
- package/dist/esm/consensus/index.js +2 -2
- package/dist/esm/core/AgentRegistry.d.ts +1 -1
- package/dist/esm/core/AgentRegistry.js +1 -1
- package/dist/esm/core/DashboardBroadcaster.d.ts +3 -3
- package/dist/esm/core/DashboardBroadcaster.js +2 -2
- package/dist/esm/core/DashboardWebSocketServer.d.ts +1 -1
- package/dist/esm/core/DashboardWebSocketServer.js +1 -1
- package/dist/esm/core/GhostAlchemist.js +1 -1
- package/dist/esm/core/GhostListener.js +2 -2
- package/dist/esm/core/OrchestrationEngine.d.ts +3 -3
- package/dist/esm/core/OrchestrationEngine.js +2 -2
- package/dist/esm/core/SubconsciousEngine.d.ts +1 -1
- package/dist/esm/core/SubconsciousEngine.js +2 -2
- package/dist/esm/core/WebSocketServer.d.ts +2 -2
- package/dist/esm/core/WebSocketServer.js +1 -1
- package/dist/esm/core/index.d.ts +6 -6
- package/dist/esm/core/index.js +6 -6
- package/dist/esm/core/router.d.ts +3 -3
- package/dist/esm/core/router.js +1 -1
- package/dist/esm/db/database.js +1 -1
- package/dist/esm/embed.d.ts +2 -2
- package/dist/esm/embed.js +2 -2
- package/dist/esm/examples/basic-usage.js +1 -1
- package/dist/esm/index.d.ts +14 -14
- package/dist/esm/index.js +14 -14
- package/dist/esm/infra/analyzers/DriftDetector.d.ts +1 -1
- package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts +1 -1
- package/dist/esm/infra/analyzers/MonolithAnalyzer.d.ts +1 -1
- package/dist/esm/infra/analyzers/index.d.ts +3 -3
- package/dist/esm/infra/analyzers/index.js +3 -3
- package/dist/esm/infra/cli.js +2 -2
- package/dist/esm/infra/config.d.ts +1 -1
- package/dist/esm/infra/index.d.ts +5 -5
- package/dist/esm/infra/index.js +5 -5
- package/dist/esm/infra/mcp-tools.js +5 -5
- package/dist/esm/infra/providers/InfraProvider.d.ts +1 -1
- package/dist/esm/infra/providers/JenkinsProvider.d.ts +2 -2
- package/dist/esm/infra/providers/OKDProvider.d.ts +2 -2
- package/dist/esm/infra/providers/TerraformProvider.d.ts +2 -2
- package/dist/esm/infra/providers/index.d.ts +5 -5
- package/dist/esm/infra/providers/index.js +3 -3
- package/dist/esm/mcp/index.js +5 -5
- package/dist/esm/mcp/prompts.d.ts +1 -2
- package/dist/esm/mcp/prompts.d.ts.map +1 -1
- package/dist/esm/mcp/prompts.js +28 -125
- package/dist/esm/mcp/prompts.js.map +1 -1
- package/dist/esm/mcp/resources.d.ts.map +1 -1
- package/dist/esm/mcp/resources.js +5 -5
- package/dist/esm/mcp/resources.js.map +1 -1
- package/dist/esm/mcp/tool-profiles.d.ts +55 -0
- package/dist/esm/mcp/tool-profiles.d.ts.map +1 -0
- package/dist/esm/mcp/tool-profiles.js +196 -0
- package/dist/esm/mcp/tool-profiles.js.map +1 -0
- package/dist/esm/mcp/tools.d.ts +12 -0
- package/dist/esm/mcp/tools.d.ts.map +1 -1
- package/dist/esm/mcp/tools.js +209 -63
- package/dist/esm/mcp/tools.js.map +1 -1
- package/dist/esm/observability/IdeContextSync.d.ts +1 -1
- package/dist/esm/observability/IdeContextSync.js +5 -5
- package/dist/esm/pr-review/PRReviewEngine.d.ts +1 -1
- package/dist/esm/pr-review/PRReviewEngine.js +4 -4
- package/dist/esm/pr-review/ReviewStore.d.ts +1 -1
- package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitHubAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/GitHubAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitLabAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/GitLabAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitPlatformAdapter.d.ts +1 -1
- package/dist/esm/pr-review/adapters/index.d.ts +4 -4
- package/dist/esm/pr-review/adapters/index.js +3 -3
- package/dist/esm/pr-review/analyzers/QualityGrader.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/RegressionDetector.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/SecurityScanner.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/StaticAnalyzer.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/index.d.ts +8 -8
- package/dist/esm/pr-review/analyzers/index.js +4 -4
- package/dist/esm/pr-review/bridge/BrainBridge.d.ts +1 -1
- package/dist/esm/pr-review/bridge/BrainBridge.js +1 -1
- package/dist/esm/pr-review/bridge/index.d.ts +1 -1
- package/dist/esm/pr-review/bridge/index.js +1 -1
- package/dist/esm/pr-review/index.d.ts +4 -4
- package/dist/esm/pr-review/index.js +2 -2
- package/dist/esm/pr-review/reviewRunner.d.ts +2 -2
- package/dist/esm/pr-review/reviewRunner.js +6 -6
- package/dist/esm/pr-review/webhook/WebhookServer.js +1 -1
- package/dist/esm/pr-review/webhook/index.d.ts +1 -1
- package/dist/esm/pr-review/webhook/index.js +1 -1
- package/dist/esm/protocol/flows.d.ts +1 -1
- package/dist/esm/protocol/flows.js +1 -1
- package/dist/esm/protocol/index.d.ts +4 -4
- package/dist/esm/protocol/index.js +4 -4
- package/dist/esm/protocol/utils.d.ts +1 -1
- package/dist/esm/protocol/utils.js +2 -2
- package/dist/esm/protocol/validators.d.ts +1 -1
- package/dist/esm/protocol/validators.js +1 -1
- package/dist/esm/proxy/ContextInjector.d.ts +1 -1
- package/dist/esm/proxy/Gatekeeper.d.ts +1 -1
- package/dist/esm/security/SecurityMiddleware.d.ts +1 -1
- package/dist/esm/security/SecurityMiddleware.js +3 -3
- package/dist/esm/security/index.d.ts +4 -4
- package/dist/esm/security/index.js +4 -4
- package/dist/esm/speculative/SpeculativeCache.d.ts +2 -2
- package/dist/esm/speculative/SpeculativeEngine.d.ts +2 -2
- package/dist/esm/speculative/SpeculativeEngine.js +3 -3
- package/dist/esm/speculative/WorkerPool.d.ts +1 -1
- package/dist/esm/speculative/index.d.ts +4 -4
- package/dist/esm/speculative/index.js +4 -4
- package/dist/esm/subconscious/SemanticCache.d.ts +2 -2
- package/dist/esm/subconscious/SemanticCache.js +2 -2
- package/dist/esm/subconscious/SubconsciousEngine.d.ts +1 -1
- package/dist/esm/subconscious/SubconsciousEngine.js +3 -3
- package/dist/esm/subconscious/TheBrainV2.d.ts +36 -2
- package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/esm/subconscious/TheBrainV2.js +103 -23
- package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
- package/dist/esm/subconscious/index.d.ts +4 -4
- package/dist/esm/subconscious/index.js +4 -4
- package/dist/esm/utils/AutoContextBundle.d.ts +1 -1
- package/dist/esm/utils/AutoContextBundle.d.ts.map +1 -1
- package/dist/esm/utils/AutoContextBundle.js +20 -23
- package/dist/esm/utils/AutoContextBundle.js.map +1 -1
- package/dist/esm/utils/BulkFileDigest.js +2 -2
- package/dist/esm/utils/ClipboardWatcher.js +2 -2
- package/dist/esm/utils/ContextCollapser.js +1 -1
- package/dist/esm/utils/ConversationCheckpoint.d.ts +13 -0
- package/dist/esm/utils/ConversationCheckpoint.d.ts.map +1 -1
- package/dist/esm/utils/ConversationCheckpoint.js +57 -0
- package/dist/esm/utils/ConversationCheckpoint.js.map +1 -1
- package/dist/esm/utils/ExecutiveReport.js +1 -1
- package/dist/esm/utils/StructuralSearch.d.ts +1 -1
- package/dist/esm/utils/SurgicalASTInsert.js +1 -1
- package/dist/esm/utils/SymbolSurgicalContext.js +1 -1
- package/dist/esm/utils/TestAutofixInterceptor.d.ts.map +1 -1
- package/dist/esm/utils/TestAutofixInterceptor.js +15 -26
- package/dist/esm/utils/TestAutofixInterceptor.js.map +1 -1
- package/dist/esm/utils/WorkspaceSearch.js +0 -0
- package/dist/esm/utils/logger.js +1 -1
- package/package.json +9 -10
- package/sdks/crewai/README.md +178 -0
- package/sdks/crewai/dist/index.d.ts +130 -0
- package/sdks/crewai/dist/index.js +308 -0
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# 🧠 Lemma v1.
|
|
1
|
+
# 🧠 Lemma v1.7.0
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@nxuss/lemma)
|
|
4
4
|
[](https://github.com/Nxusbets/lemma/blob/main/LICENSE)
|
|
5
|
-
[](https://github.com/Nxusbets/lemma)
|
|
6
6
|
[](https://github.com/Nxusbets/lemma)
|
|
7
7
|
[](https://github.com/Nxusbets/lemma)
|
|
8
|
-
[](https://github.com/Nxusbets/lemma)
|
|
9
9
|
|
|
10
10
|
```text
|
|
11
11
|
__
|
|
@@ -17,13 +17,58 @@
|
|
|
17
17
|
|
|
18
18
|
> **The Intelligent local-first AI Gateway — Privacy, Performance, Static Code Intelligence, and Infrastructure Command Center for the Agentic Era.**
|
|
19
19
|
|
|
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**, **22 Infrastructure Management Tools**, and a suite of **
|
|
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**, **22 Infrastructure Management Tools**, and a suite of **94 MCP tools** — including zero-token static code intelligence that runs entirely on your machine with no LLM calls required.
|
|
21
|
+
|
|
22
|
+
Since v1.7.0 those 94 tools are all registered, but only the ones your project can actually use
|
|
23
|
+
are advertised to the model each turn. The rest stay one `lemma_toolbox` call away. See
|
|
24
|
+
[Tool profiles](#-tool-profiles).
|
|
21
25
|
|
|
22
26
|
---
|
|
23
27
|
|
|
24
28
|
## 📋 Changelog
|
|
25
29
|
|
|
26
|
-
### v1.
|
|
30
|
+
### v1.7.0 — The cost of being connected *(NEW)*
|
|
31
|
+
|
|
32
|
+
Every tool schema Lemma advertises goes into the model's system prompt and is **re-sent on every
|
|
33
|
+
request of the session** — including schemas for tools the project can never use. On this repo that
|
|
34
|
+
was ~13,950 tokens per turn before Lemma saved anything.
|
|
35
|
+
|
|
36
|
+
| Change | What it does | Why it matters |
|
|
37
|
+
| :--- | :--- | :--- |
|
|
38
|
+
| **Project-scoped tool surface** | Core tools are always advertised; situational groups (infrastructure, review) only when the repo shows evidence they apply. `mcp.toolProfile` accepts `auto`, `core`, or `full`. | ~3,420 tokens of schemas per turn instead of ~11,600. |
|
|
39
|
+
| **`lemma_toolbox`** *(new)* | Lists tools whose schemas were withheld, returns any tool's schema, and invokes it. | A withheld schema is a deferred cost, never a lost capability. |
|
|
40
|
+
| **Leaner TURBOMODE prompt** | ~2,340 → ~1,700 tokens. Instructions for tools the session doesn't advertise are gone; every correctness rule stays, enforced by tests. | The prompt stops paying for advice the model can't act on directly. |
|
|
41
|
+
| **Overhead in `token_budget`** | Reports profile, advertised vs. hidden counts, active groups, and the real schema token cost. | The fixed cost is visible instead of assumed. |
|
|
42
|
+
|
|
43
|
+
**Total fixed cost per turn on this repo: ~5,120 tokens, down from ~13,950.**
|
|
44
|
+
|
|
45
|
+
**The Brain reported cache hits that never happened.** Duplicate detection runs an internal search
|
|
46
|
+
before storing a memory, and that search shared the counters behind the reported hit rate — while
|
|
47
|
+
searching with a minimum similarity of 0, so it matched nearly every time. Every store inflated the
|
|
48
|
+
session hit rate and bumped an unrelated entry's hit counter. Internal lookups no longer count.
|
|
49
|
+
**Reported hit rates will be lower after upgrading; the lower number is the correct one.**
|
|
50
|
+
|
|
51
|
+
**Three features silently did nothing.** `get_telepathic_hints`, `auto_context_bundle`, and
|
|
52
|
+
`test_autofix_interceptor` read prior knowledge from `<project>/.lemma/memory/` — a directory no
|
|
53
|
+
code path writes. They returned empty in every project while the Brain held the answers. All three
|
|
54
|
+
now query the Brain directly.
|
|
55
|
+
|
|
56
|
+
**Also in this release:**
|
|
57
|
+
|
|
58
|
+
- **Memories are scoped by project** via a `projectId` derived from the git remote. Entries stored
|
|
59
|
+
before this release stay visible everywhere rather than disappearing.
|
|
60
|
+
- **Brain entries are ~38% smaller** — `terms` duplicated `Object.keys(termFreq)` and is now
|
|
61
|
+
rebuilt on load instead of stored. Existing files are read unchanged.
|
|
62
|
+
- **`get_project_onboarding` works without the proxy**, falling back to a locally derived map
|
|
63
|
+
instead of returning an error on the first call of the session.
|
|
64
|
+
- **`lemma-checkpoint`** *(new CLI)* captures a checkpoint from repository state, so it no longer
|
|
65
|
+
depends on the assistant remembering to call the tool. See [Session checkpoints](#-session-checkpoints).
|
|
66
|
+
- **Removed the `lemma-autopilot` prompt** — it told the model to call tools unconditionally, the
|
|
67
|
+
opposite of the net-savings accounting added in v1.6.0. `lemma-turbomode` is the supported prompt.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### v1.6.0 — The savings ledger can now report a loss
|
|
27
72
|
|
|
28
73
|
Every release up to this one measured only what Lemma **saved**. That is single-entry bookkeeping:
|
|
29
74
|
a number that can only go up is not evidence of anything, because the ledger had no way to express
|
|
@@ -240,6 +285,70 @@ Or use environment variables: `JENKINS_URL`, `JENKINS_USERNAME`, `JENKINS_API_TO
|
|
|
240
285
|
|
|
241
286
|
---
|
|
242
287
|
|
|
288
|
+
## 🎚️ Tool profiles
|
|
289
|
+
|
|
290
|
+
Every tool schema an MCP server advertises is injected into the model's system prompt and re-sent
|
|
291
|
+
on **every request** of the session. Advertising all 94 tools costs ~11,600 tokens per turn — much
|
|
292
|
+
of it schemas for tools a given project can never use.
|
|
293
|
+
|
|
294
|
+
Lemma advertises a scoped surface instead. Nothing is removed: every tool stays registered and
|
|
295
|
+
callable, and `lemma_toolbox` reaches the ones whose schemas were withheld.
|
|
296
|
+
|
|
297
|
+
| Profile | Advertises |
|
|
298
|
+
| :--- | :--- |
|
|
299
|
+
| `auto` *(default)* | Core tools, plus situational groups the repo shows evidence for |
|
|
300
|
+
| `core` | Core tools only |
|
|
301
|
+
| `full` | Everything, as before v1.7.0 |
|
|
302
|
+
|
|
303
|
+
```jsonc
|
|
304
|
+
// lemma.config.json
|
|
305
|
+
{ "mcp": { "toolProfile": "full" } } // or set LEMMA_TOOL_PROFILE=full
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Core** covers workspace reading and navigation, the patch/validate write path, AST context,
|
|
309
|
+
caching (`state_hash_cache`, `smarter_cache`, `search_memory`, `store_memory`), routing advice, and
|
|
310
|
+
the ledger. **Situational groups** are advertised on evidence — the infrastructure group when a
|
|
311
|
+
`Jenkinsfile`, `kustomization.yaml`, `.openshift/`, or a `.tf` file is present, or a provider is
|
|
312
|
+
already connected.
|
|
313
|
+
|
|
314
|
+
Reaching anything else:
|
|
315
|
+
|
|
316
|
+
```jsonc
|
|
317
|
+
lemma_toolbox { "action": "list", "query": "terraform drift" } // what exists
|
|
318
|
+
lemma_toolbox { "action": "schema", "tool": "terraform_drift" } // its inputs
|
|
319
|
+
lemma_toolbox { "action": "call", "tool": "terraform_drift", "args": {} }
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
`token_budget` reports the profile in use, advertised vs. hidden counts, and what the advertised
|
|
323
|
+
schemas actually cost this session.
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## 💾 Session checkpoints
|
|
328
|
+
|
|
329
|
+
`conversation_checkpoint` saves what a session established so the next one doesn't re-derive it —
|
|
330
|
+
but it only runs if the assistant remembers to call it at the end, which is not something to build
|
|
331
|
+
on. `lemma-checkpoint` derives a checkpoint from repository state instead:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
lemma-checkpoint [projectRoot] [--summary "text"]
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
It records the branch, changed files, and recent commits to `<project>/.lemma/session/`, exits 0
|
|
338
|
+
even outside a git repository, and is meant to be wired to your host's session-end event:
|
|
339
|
+
|
|
340
|
+
```jsonc
|
|
341
|
+
// ~/.claude/settings.json
|
|
342
|
+
{ "hooks": { "SessionEnd": [{ "hooks": [{ "type": "command",
|
|
343
|
+
"command": "lemma-checkpoint \"${CLAUDE_PROJECT_DIR:-$PWD}\"" }] }] } }
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Decisions made and tasks left pending exist only in the conversation, so an automatic capture
|
|
347
|
+
leaves those fields empty rather than inventing them — a checkpoint saved by the assistant stays
|
|
348
|
+
the richer record when one exists.
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
243
352
|
## 💎 Free vs Pro
|
|
244
353
|
|
|
245
354
|
### 🆓 Free (33 Tools)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Session-end checkpoint capture.
|
|
6
|
+
*
|
|
7
|
+
* Meant to be wired to a host's session-end event (e.g. a Claude Code Stop/SessionEnd hook)
|
|
8
|
+
* so a checkpoint gets written even when the assistant never calls the MCP tool. Writes to
|
|
9
|
+
* <project>/.lemma/session/ and exits 0 no matter what — a hook that fails must never be the
|
|
10
|
+
* reason a session ends badly.
|
|
11
|
+
*
|
|
12
|
+
* Usage: lemma-checkpoint [projectRoot] [--summary "text"]
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const path = require('path');
|
|
16
|
+
|
|
17
|
+
function main() {
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
const summaryIndex = args.indexOf('--summary');
|
|
20
|
+
const summary = summaryIndex >= 0 ? args[summaryIndex + 1] : undefined;
|
|
21
|
+
const positional = args.filter((a, i) => !a.startsWith('--') && i !== summaryIndex + 1);
|
|
22
|
+
const projectRoot = path.resolve(positional[0] || process.cwd());
|
|
23
|
+
|
|
24
|
+
const distPath = path.join(__dirname, '..', 'dist', 'cjs', 'utils', 'ConversationCheckpoint.js');
|
|
25
|
+
let captureAutoCheckpoint;
|
|
26
|
+
try {
|
|
27
|
+
({ captureAutoCheckpoint } = require(distPath));
|
|
28
|
+
} catch {
|
|
29
|
+
console.error('[lemma-checkpoint] Build not found. Run "npm run build" first.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const result = captureAutoCheckpoint(projectRoot, summary);
|
|
34
|
+
if (!result) {
|
|
35
|
+
console.error('[lemma-checkpoint] Not a git repository — nothing to capture.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
console.error(
|
|
39
|
+
`[lemma-checkpoint] Saved: ${result.filesModified.length} file(s) changed → ${path.join(projectRoot, '.lemma/session')}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
main();
|
|
45
|
+
} catch (err) {
|
|
46
|
+
// A checkpoint is best-effort context, never a reason to fail the host's shutdown.
|
|
47
|
+
console.error('[lemma-checkpoint] Skipped:', err && err.message);
|
|
48
|
+
}
|
|
49
|
+
process.exit(0);
|
package/bin/init.js
CHANGED
|
@@ -278,6 +278,25 @@ tokens sale más cara que los tokens que ahorra.
|
|
|
278
278
|
| "¿Cuánto ahorramos de verdad?" | \`mcp__lemma__token_receipt\` | Bitácora auditable real, no una cifra inventada |
|
|
279
279
|
| Guardar una solución para el futuro | \`mcp__lemma__store_memory\` | Solo después de verificarla (tests pasaron, el usuario confirmó) — una solución mala guardada se vuelve un cache hit falso más adelante |
|
|
280
280
|
|
|
281
|
+
## No todas las tools de Lemma están en tu lista
|
|
282
|
+
|
|
283
|
+
Cada schema que Lemma anuncia se re-envía en **cada** request de la sesión, así que solo se
|
|
284
|
+
anuncian las que este proyecto puede usar de verdad. El resto sigue registrado y disponible:
|
|
285
|
+
|
|
286
|
+
- \`mcp__lemma__lemma_toolbox\` con \`action="list"\` (y un \`query\`) para ver qué existe.
|
|
287
|
+
- \`action="schema"\` para leer los inputs de una tool antes de llamarla.
|
|
288
|
+
- \`action="call"\` para ejecutarla.
|
|
289
|
+
|
|
290
|
+
Antes de decirle al usuario que Lemma no puede hacer algo, revisa el toolbox. Si el proyecto
|
|
291
|
+
necesita todas las tools anunciadas de forma permanente, pon \`mcp.toolProfile: "full"\` en
|
|
292
|
+
\`lemma.config.json\`.
|
|
293
|
+
|
|
294
|
+
## Antes de pedirle código al usuario
|
|
295
|
+
|
|
296
|
+
No le pidas que pegue archivos, logs o documentación que puedes obtener tú: agota primero
|
|
297
|
+
\`search_workspace\`, \`get_ast_hologram\` (estructura: da nombres y líneas, no firmas) y
|
|
298
|
+
\`read_workspace_file\`. Cada ida y vuelta con el usuario cuesta más que la lectura.
|
|
299
|
+
|
|
281
300
|
## Al iniciar en este proyecto
|
|
282
301
|
|
|
283
302
|
1. Llama \`mcp__lemma__get_project_onboarding\` para orientarte con el contexto ya indexado.
|
|
@@ -286,8 +305,8 @@ tokens sale más cara que los tokens que ahorra.
|
|
|
286
305
|
|
|
287
306
|
## Al reportar o investigar un bug
|
|
288
307
|
|
|
289
|
-
1. \`
|
|
290
|
-
2. \`
|
|
308
|
+
1. \`mcp__lemma__search_memory\` con el mensaje de error, por si ya se resolvió algo parecido.
|
|
309
|
+
2. \`lemma_toolbox\` → \`get_telepathic_hints\` con el archivo relevante para contexto de runtime.
|
|
291
310
|
|
|
292
311
|
## Una sola regla dura
|
|
293
312
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const LEMMA_TURBOMODE_PROMPT = "You are operating in LEMMA TURBOMODE. Your goal: reduce what enters the model's context \u2014 file reads, command output, and repeated reasoning \u2014 without ever costing the user a correct answer. Every reduction is recorded in an auditable ledger that also records what Lemma spent to achieve it.\n\nThere is no fixed multiplier to hit. Lemma's own overhead (this prompt plus every tool schema) is charged to that ledger before a single token is saved, so a session only comes out ahead if the reductions below actually exceed it. Optimize for real net savings, not for a number.\n\n## MANDATORY TURBOMODE RULES \u2014 VIOLATE THESE AND YOU WASTE THE USER'S MONEY\n\n### 0. Every tool call costs tokens too\nA tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs \u2014 on a small file or a short command, reading it directly is cheaper. Do not call `token_budget` on a schedule; it produces a report, not work. Call it only when the user asks how the session is going.\n\n### 1. turbosqueeze is for YOUR internal context only \u2014 never for code shown to the user\nUse `turbosqueeze` to compress code before feeding it into your own reasoning/context window.\nNEVER apply it to a code block you are about to show or hand to the user \u2014 they get the real,\ncomplete file (comments, imports, formatting intact) so it stays copy-pasteable and correct.\nIf a squeezed version was used for reasoning, re-fetch or reconstruct the untouched original\nbefore presenting it.\n\n### 2. smarter_cache (threshold 0.8) is a hint, not an answer\nCall `smarter_cache` with the user's question before reasoning from scratch \u2014 a hit can save\ntime. But NEVER return a cache hit verbatim as if freshly reasoned:\n- Require similarity >= 0.8 (raised from 0.75 \u2014 0.75 was matching questions that weren't\n actually the same question).\n- Always tell the user the answer came from cache (e.g. \"from a cached earlier answer:\").\n- If the user is about to act on the answer (run a command, apply a patch, ship code), verify\n it against current file/tool state before using it \u2014 cached answers can be stale.\n- On a MISS, or on any doubt, reason normally.\n\n### 3. Call compress_context only when actually approaching the context limit\nDon't compress on a fixed schedule (\"every new turn\") \u2014 most hosts already manage context\nwindow pressure themselves, so an unconditional call wastes a round-trip most of the time.\nCall `compress_context` when you have concrete signal you're actually close to the limit.\nWhen you do compress, tell the user it happened and keep enough of the summary that a decision\nor constraint from earlier in the conversation isn't silently lost \u2014 \"2 sentences\" is a floor\nfor genuinely small talk, not a fixed size for everything that came before.\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 VERIFIED solution \u2192 call store_memory automatically\nStore via `store_memory` once you've confirmed the fix/answer actually worked (tests pass,\nthe user confirmed, the build succeeded) \u2014 not the first thing you tried. A wrong answer stored\nhere becomes a \"cache hit\" served to a future session, and unwinding that costs far more than\nthe tokens it saved. Verified answers are still free to cache aggressively.\n\n### 6. Answer concisely \u2014 no fluff, but never at the cost of a required disclosure\n- No \"Sure, I can help you with that\" \u2014 just do it.\n- No unnecessary 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- Exception: disclosures required elsewhere in these rules (cache-hit source per rule 2,\n a context-compression event per rule 3, a risky/irreversible action) are never fluff \u2014 say\n them in one short line. Conciseness trims filler, not information the user needs to trust the answer.\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### 9b. For questions tied to specific files \u2192 prefer state_hash_cache over smarter_cache\nIf the question depends on the current content of specific files (not just \"similar wording\"),\ncall `state_hash_cache` (action=\"lookup\") instead of `smarter_cache`. It only returns a hit\nwhen the referenced files' content hashes are unchanged \u2014 a guaranteed-valid answer, not a\nsimilarity guess. After answering, call it again with action=\"store\" to cache it. Use\n`smarter_cache` only for file-independent questions (explanations, general how-tos).\n\n### 9c. Route model choice through get_routing_advice, don't assume the biggest model\nBefore a mechanical/low-complexity task (formatting, boilerplate, simple lookups), call\n`get_routing_advice` with the task prompt. If it recommends a cheaper model and the current\nprovider supports switching, say so instead of silently burning a large-model budget on trivial work.\n\n### 9d. Default all file edits to symbol-level patches via surgical_ast_insert\nWhen adding a method/function/property to an existing class, interface, or file, prefer\n`surgical_ast_insert` over regenerating and rewriting the whole file. Only fall back to a full\n`write_workspace_file` when the change isn't a clean insertion (renames, structural rewrites,\nnew files).\n\n### 9e. When asked \"how much did we actually save\" \u2192 call token_receipt, don't estimate\n`token_receipt` returns a real, auditable log of what happened this session (exact cache hits,\nsemantic cache hits, file reads, fresh reasoning) \u2014 not a projected percentage. Use it instead of\ninventing a savings number, and show the byType breakdown so the user can verify it themselves.\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, but verify the suggested fix before applying it\nCall `test_autofix_interceptor` to get failures + Brain-suggested fixes in one call \u2014 that part\nsaves real tokens. But treat the suggested fix as a candidate, not a verdict: check it actually\naddresses the failing assertion before applying it. Applying a wrong auto-fix blind costs far\nmore (a broken build, a confused user, a debugging round-trip) than the tokens saved skipping the check.\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\nCorrectness first, then cost \u2014 a fast wrong answer is more expensive than a slow right one once\nyou count the round-trip to find and fix it.\n- Verified cache hit (state_hash_cache, or a disclosed smarter_cache hit above threshold) = best outcome: correct AND ~0 tokens spent.\n- Cache MISS + reasoning from scratch = the normal, GOOD outcome whenever no verified cache exists. Reasoning is not a failure mode \u2014 it's what you do when you don't already have a trustworthy answer.\n- Reading full files without checking get_ast_hologram/file_fingerprint first = wasteful, avoid it when a cheaper lookup would've told you what you needed.\n- Any answer delivered without required disclosure (rule 6's exception), or a cached/auto-fixed result used without verification = FAIL, regardless of tokens saved \u2014 it can cost the user far more than tokens once it's wrong.\n\nRemember: the goal is spending fewer tokens on the SAME quality of answer, not a lower-quality answer for fewer tokens.";
|
|
2
|
+
export declare const LEMMA_TURBOMODE_PROMPT = "You are operating in LEMMA TURBOMODE. Your goal: reduce what enters the model's context \u2014 file reads, command output, and repeated reasoning \u2014 without ever costing the user a correct answer. Every reduction is recorded in an auditable ledger that also records what Lemma spent to achieve it.\n\nThere is no fixed multiplier to hit. Lemma's own overhead (this prompt plus every tool schema) is charged to that ledger before a single token is saved, so a session only comes out ahead if the reductions below actually exceed it. Optimize for real net savings, not for a number.\n\n## MANDATORY TURBOMODE RULES \u2014 VIOLATE THESE AND YOU WASTE THE USER'S MONEY\n\n### 0. Every tool call costs tokens too\nA tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs \u2014 on a small file or a short command, reading it directly is cheaper. Never call a reporting tool on a schedule: a report is not work. Call one only when the user asks how the session is going.\n\n### 0b. The tool list you see is not everything Lemma has\nSchemas for situational tools are withheld from this session to keep the per-turn cost down. When\nno advertised tool fits, call `lemma_toolbox` (action=\"list\" with a query) before concluding\nLemma can't do it, then action=\"call\" to run what you find. Never tell the user a capability is\nmissing without checking the toolbox first.\n\n### 1. Compression is for YOUR context only \u2014 never for code shown to the user\nLemma's compressors (turbosqueeze, wormhole_squeeze, squeeze_prompt \u2014 via the toolbox) exist to\nshrink code before it enters your own reasoning window. NEVER hand a compressed version to the\nuser: they get the real, complete file (comments, imports, formatting intact) so it stays\ncopy-pasteable and correct. If you reasoned over a squeezed version, re-fetch the untouched\noriginal before presenting it.\n\n### 2. smarter_cache (threshold 0.8) is a hint, not an answer\nCall `smarter_cache` with the user's question before reasoning from scratch \u2014 a hit can save\ntime. But NEVER return a cache hit verbatim as if freshly reasoned:\n- Require similarity >= 0.8 (raised from 0.75 \u2014 0.75 was matching questions that weren't\n actually the same question).\n- Always tell the user the answer came from cache (e.g. \"from a cached earlier answer:\").\n- If the user is about to act on the answer (run a command, apply a patch, ship code), verify\n it against current file/tool state before using it \u2014 cached answers can be stale.\n- On a MISS, or on any doubt, reason normally.\n\n### 3. 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### 4. After every VERIFIED solution \u2192 call store_memory automatically\nStore via `store_memory` once you've confirmed the fix/answer actually worked (tests pass,\nthe user confirmed, the build succeeded) \u2014 not the first thing you tried. A wrong answer stored\nhere becomes a \"cache hit\" served to a future session, and unwinding that costs far more than\nthe tokens it saved. Verified answers are still free to cache aggressively.\n\n### 5. Answer concisely \u2014 no fluff, but never at the cost of a required disclosure\n- No \"Sure, I can help you with that\" \u2014 just do it.\n- No unnecessary explanation of what you did \u2014 unless asked.\n- No repeating the user's question back to them.\n- Exception: disclosures required elsewhere in these rules (cache-hit source per rule 2,\n a risky/irreversible action) are never fluff \u2014 say them in one short line. Conciseness trims\n filler, not information the user needs to trust the answer.\n\n### 6. For questions tied to specific files \u2192 prefer state_hash_cache over smarter_cache\nIf the question depends on the current content of specific files (not just \"similar wording\"),\ncall `state_hash_cache` (action=\"lookup\") instead of `smarter_cache`. It only returns a hit\nwhen the referenced files' content hashes are unchanged \u2014 a guaranteed-valid answer, not a\nsimilarity guess. After answering, call it again with action=\"store\" to cache it. Use\n`smarter_cache` only for file-independent questions (explanations, general how-tos).\n\n### 7. Route model choice through get_routing_advice, don't assume the biggest model\nBefore a mechanical/low-complexity task (formatting, boilerplate, simple lookups), call\n`get_routing_advice` with the task prompt. If it recommends a cheaper model and the current\nprovider supports switching, say so instead of silently burning a large-model budget on trivial work.\n\n### 8. Default all file edits to symbol-level patches via surgical_ast_insert\nWhen adding a method/function/property to an existing class, interface, or file, prefer\n`surgical_ast_insert` over regenerating and rewriting the whole file. Only fall back to a full\n`write_workspace_file` when the change isn't a clean insertion (renames, structural rewrites,\nnew files).\n\n### 9. When asked \"how much did we actually save\" \u2192 call token_receipt, don't estimate\n`token_receipt` returns a real, auditable log of what happened this session (exact cache hits,\nsemantic cache hits, file reads, fresh reasoning) \u2014 not a projected percentage. Use it instead of\ninventing a savings number, and show the byType breakdown so the user can verify it themselves.\n\n### 10. Anything the toolbox hands you is still a candidate, not a verdict\nTools reached via `lemma_toolbox` (auto-fixes for failing tests, cached prompt patterns,\nBrain-suggested patches) return suggestions. Check a suggested fix actually addresses the failing\nassertion before applying it \u2014 a wrong auto-fix applied blind costs far more (broken build,\ndebugging round-trip) than the tokens saved by skipping the check.\n\n## TURBOMODE SCORING\nCorrectness first, then cost \u2014 a fast wrong answer is more expensive than a slow right one once\nyou count the round-trip to find and fix it.\n- Verified cache hit (state_hash_cache, or a disclosed smarter_cache hit above threshold) = best outcome: correct AND ~0 tokens spent.\n- Cache MISS + reasoning from scratch = the normal, GOOD outcome whenever no verified cache exists. Reasoning is not a failure mode \u2014 it's what you do when you don't already have a trustworthy answer.\n- Reading full files without checking get_ast_hologram first = wasteful, avoid it when a cheaper lookup would've told you what you needed.\n- Any answer delivered without required disclosure (rule 6's exception), or a cached/auto-fixed result used without verification = FAIL, regardless of tokens saved \u2014 it can cost the user far more than tokens once it's wrong.\n\nRemember: the goal is spending fewer tokens on the SAME quality of answer, not a lower-quality answer for fewer tokens.";
|
|
4
3
|
export declare function setupPromptsHandlers(server: Server): void;
|
|
5
4
|
//# 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,
|
|
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,sBAAsB,23NAsFqF,CAAC;AAEzH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA8BzD"}
|
package/dist/cjs/mcp/prompts.js
CHANGED
|
@@ -1,59 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LEMMA_TURBOMODE_PROMPT =
|
|
3
|
+
exports.LEMMA_TURBOMODE_PROMPT = void 0;
|
|
4
4
|
exports.setupPromptsHandlers = setupPromptsHandlers;
|
|
5
5
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
6
|
-
exports.LEMMA_SYSTEM_PROMPT = `You are connected to Lemma — an intelligent local-first AI gateway.
|
|
7
|
-
Lemma gives you a set of tools you MUST use proactively and automatically. NEVER ask the user
|
|
8
|
-
to call a tool manually. YOU invoke the tools. The user should experience zero friction.
|
|
9
|
-
|
|
10
|
-
## MANDATORY AUTOMATIC BEHAVIORS
|
|
11
|
-
|
|
12
|
-
### 1. Before reading ANY file → call get_ast_hologram first
|
|
13
|
-
When you need to understand the structure of a codebase or navigate files, ALWAYS call
|
|
14
|
-
\`get_ast_hologram\` first (with the relevant dirPath, e.g. "src"). Use the returned symbol
|
|
15
|
-
map to pinpoint exactly which files to read. NEVER blindly read every file one by one.
|
|
16
|
-
|
|
17
|
-
### 2. Before answering ANY technical question → call query_hybrid_consensus first
|
|
18
|
-
BEFORE making any reasoning or cloud LLM call, ALWAYS call \`query_hybrid_consensus\` with
|
|
19
|
-
the user's question. If similarity ≥ 80%, return the cached answer immediately — no cloud
|
|
20
|
-
call needed. Only proceed with your own reasoning if the Brain returns a MISS.
|
|
21
|
-
|
|
22
|
-
### 3. When you start working on ANY file → call get_telepathic_hints automatically
|
|
23
|
-
Whenever the user mentions a file or you are about to read/edit a file, IMMEDIATELY call
|
|
24
|
-
\`get_telepathic_hints\` with that file's path. Surface the results to the user as relevant
|
|
25
|
-
context BEFORE doing any work. Do not ask permission — just do it.
|
|
26
|
-
|
|
27
|
-
### 4. Before applying ANY code patch → call validate_patch_sandbox first
|
|
28
|
-
NEVER call \`write_workspace_file\` or \`apply_workspace_patch\` without FIRST calling
|
|
29
|
-
\`validate_patch_sandbox\` with the proposed content. Only proceed with the write if the
|
|
30
|
-
verdict is "✅ SAFE TO APPLY". If it fails, fix the issues and re-validate.
|
|
31
|
-
|
|
32
|
-
### 5. After solving any technical problem → call store_memory automatically
|
|
33
|
-
After resolving a bug, implementing a feature, or answering a significant technical question,
|
|
34
|
-
ALWAYS call \`store_memory\` to persist the solution. Use a descriptive query key so it can
|
|
35
|
-
be retrieved in future sessions across ALL projects.
|
|
36
|
-
|
|
37
|
-
### 6. Workspace navigation → always use Lemma tools, NEVER guess file contents
|
|
38
|
-
- Use \`list_workspace_dir\` to navigate structure
|
|
39
|
-
- Use \`read_workspace_file\` (auto-compresses + scrubs secrets) instead of asking the user
|
|
40
|
-
- Use \`search_workspace\` for text search across files
|
|
41
|
-
- Use \`run_workspace_command\` for builds, tests, linters — long output comes back distilled
|
|
42
|
-
(failing tests / diagnostics with locations). It is a real view of the run, not a guess, but it
|
|
43
|
-
is not the whole output: call \`output_region\` with the reported handle whenever you need the
|
|
44
|
-
rest, and never tell the user a run was clean based on a distilled view you didn't read.
|
|
45
|
-
|
|
46
|
-
### 7. Privacy is automatic
|
|
47
|
-
\`read_workspace_file\` and \`search_workspace\` automatically scrub API keys and PII.
|
|
48
|
-
You never need to manually sanitize file content.
|
|
49
|
-
|
|
50
|
-
## LEMMA RESOURCES (auto-subscribe when available)
|
|
51
|
-
- \`lemma://runtime/context\` — live crash logs. Read this FIRST when the user reports a bug.
|
|
52
|
-
- \`lemma://multiverse/timeline\` — AST history. Use when the user says "it was working before".
|
|
53
|
-
- \`lemma://project/onboarding\` — architecture map. Read at session start in new repos.
|
|
54
|
-
- \`lemma://stats/usage\` — token savings report.
|
|
55
|
-
|
|
56
|
-
Remember: the user hired YOU to be autonomous. Act like it.`;
|
|
57
6
|
exports.LEMMA_TURBOMODE_PROMPT = `You are operating in LEMMA TURBOMODE. Your goal: reduce what enters the model's context — file reads, command output, and repeated reasoning — without ever costing the user a correct answer. Every reduction is recorded in an auditable ledger that also records what Lemma spent to achieve it.
|
|
58
7
|
|
|
59
8
|
There is no fixed multiplier to hit. Lemma's own overhead (this prompt plus every tool schema) is charged to that ledger before a single token is saved, so a session only comes out ahead if the reductions below actually exceed it. Optimize for real net savings, not for a number.
|
|
@@ -61,14 +10,20 @@ There is no fixed multiplier to hit. Lemma's own overhead (this prompt plus ever
|
|
|
61
10
|
## MANDATORY TURBOMODE RULES — VIOLATE THESE AND YOU WASTE THE USER'S MONEY
|
|
62
11
|
|
|
63
12
|
### 0. Every tool call costs tokens too
|
|
64
|
-
A tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs — on a small file or a short command, reading it directly is cheaper.
|
|
13
|
+
A tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs — on a small file or a short command, reading it directly is cheaper. Never call a reporting tool on a schedule: a report is not work. Call one only when the user asks how the session is going.
|
|
65
14
|
|
|
66
|
-
###
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
15
|
+
### 0b. The tool list you see is not everything Lemma has
|
|
16
|
+
Schemas for situational tools are withheld from this session to keep the per-turn cost down. When
|
|
17
|
+
no advertised tool fits, call \`lemma_toolbox\` (action="list" with a query) before concluding
|
|
18
|
+
Lemma can't do it, then action="call" to run what you find. Never tell the user a capability is
|
|
19
|
+
missing without checking the toolbox first.
|
|
20
|
+
|
|
21
|
+
### 1. Compression is for YOUR context only — never for code shown to the user
|
|
22
|
+
Lemma's compressors (turbosqueeze, wormhole_squeeze, squeeze_prompt — via the toolbox) exist to
|
|
23
|
+
shrink code before it enters your own reasoning window. NEVER hand a compressed version to the
|
|
24
|
+
user: they get the real, complete file (comments, imports, formatting intact) so it stays
|
|
25
|
+
copy-pasteable and correct. If you reasoned over a squeezed version, re-fetch the untouched
|
|
26
|
+
original before presenting it.
|
|
72
27
|
|
|
73
28
|
### 2. smarter_cache (threshold 0.8) is a hint, not an answer
|
|
74
29
|
Call \`smarter_cache\` with the user's question before reasoning from scratch — a hit can save
|
|
@@ -80,91 +35,58 @@ time. But NEVER return a cache hit verbatim as if freshly reasoned:
|
|
|
80
35
|
it against current file/tool state before using it — cached answers can be stale.
|
|
81
36
|
- On a MISS, or on any doubt, reason normally.
|
|
82
37
|
|
|
83
|
-
### 3.
|
|
84
|
-
Don't compress on a fixed schedule ("every new turn") — most hosts already manage context
|
|
85
|
-
window pressure themselves, so an unconditional call wastes a round-trip most of the time.
|
|
86
|
-
Call \`compress_context\` when you have concrete signal you're actually close to the limit.
|
|
87
|
-
When you do compress, tell the user it happened and keep enough of the summary that a decision
|
|
88
|
-
or constraint from earlier in the conversation isn't silently lost — "2 sentences" is a floor
|
|
89
|
-
for genuinely small talk, not a fixed size for everything that came before.
|
|
90
|
-
|
|
91
|
-
### 4. Before reading files → call get_ast_hologram
|
|
38
|
+
### 3. Before reading files → call get_ast_hologram
|
|
92
39
|
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.
|
|
93
40
|
|
|
94
|
-
###
|
|
95
|
-
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.
|
|
96
|
-
|
|
97
|
-
### 4c. Before deep file analysis → use import_tree_context + type_coverage_report
|
|
98
|
-
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.
|
|
99
|
-
|
|
100
|
-
### 4d. Before investigating code ownership → call git_blame_heat
|
|
101
|
-
For questions about who wrote code, why it's risky, or change history, call git_blame_heat instead of reasoning. Zero LLM cost.
|
|
102
|
-
|
|
103
|
-
### 5. After every VERIFIED solution → call store_memory automatically
|
|
41
|
+
### 4. After every VERIFIED solution → call store_memory automatically
|
|
104
42
|
Store via \`store_memory\` once you've confirmed the fix/answer actually worked (tests pass,
|
|
105
43
|
the user confirmed, the build succeeded) — not the first thing you tried. A wrong answer stored
|
|
106
44
|
here becomes a "cache hit" served to a future session, and unwinding that costs far more than
|
|
107
45
|
the tokens it saved. Verified answers are still free to cache aggressively.
|
|
108
46
|
|
|
109
|
-
###
|
|
47
|
+
### 5. Answer concisely — no fluff, but never at the cost of a required disclosure
|
|
110
48
|
- No "Sure, I can help you with that" — just do it.
|
|
111
49
|
- No unnecessary explanation of what you did — unless asked.
|
|
112
|
-
- No markdown formatting in internal responses.
|
|
113
50
|
- No repeating the user's question back to them.
|
|
114
51
|
- Exception: disclosures required elsewhere in these rules (cache-hit source per rule 2,
|
|
115
|
-
a
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
### 7. Use batch_tool_calls aggressively
|
|
119
|
-
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.
|
|
52
|
+
a risky/irreversible action) are never fluff — say them in one short line. Conciseness trims
|
|
53
|
+
filler, not information the user needs to trust the answer.
|
|
120
54
|
|
|
121
|
-
###
|
|
122
|
-
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.
|
|
123
|
-
|
|
124
|
-
### 9. Before outputting long responses → check repeat_guard
|
|
125
|
-
Call \`repeat_guard\` with your draft output to avoid repeating yourself. Saves 10-15% of output tokens.
|
|
126
|
-
|
|
127
|
-
### 9b. For questions tied to specific files → prefer state_hash_cache over smarter_cache
|
|
55
|
+
### 6. For questions tied to specific files → prefer state_hash_cache over smarter_cache
|
|
128
56
|
If the question depends on the current content of specific files (not just "similar wording"),
|
|
129
57
|
call \`state_hash_cache\` (action="lookup") instead of \`smarter_cache\`. It only returns a hit
|
|
130
58
|
when the referenced files' content hashes are unchanged — a guaranteed-valid answer, not a
|
|
131
59
|
similarity guess. After answering, call it again with action="store" to cache it. Use
|
|
132
60
|
\`smarter_cache\` only for file-independent questions (explanations, general how-tos).
|
|
133
61
|
|
|
134
|
-
###
|
|
62
|
+
### 7. Route model choice through get_routing_advice, don't assume the biggest model
|
|
135
63
|
Before a mechanical/low-complexity task (formatting, boilerplate, simple lookups), call
|
|
136
64
|
\`get_routing_advice\` with the task prompt. If it recommends a cheaper model and the current
|
|
137
65
|
provider supports switching, say so instead of silently burning a large-model budget on trivial work.
|
|
138
66
|
|
|
139
|
-
###
|
|
67
|
+
### 8. Default all file edits to symbol-level patches via surgical_ast_insert
|
|
140
68
|
When adding a method/function/property to an existing class, interface, or file, prefer
|
|
141
69
|
\`surgical_ast_insert\` over regenerating and rewriting the whole file. Only fall back to a full
|
|
142
70
|
\`write_workspace_file\` when the change isn't a clean insertion (renames, structural rewrites,
|
|
143
71
|
new files).
|
|
144
72
|
|
|
145
|
-
###
|
|
73
|
+
### 9. When asked "how much did we actually save" → call token_receipt, don't estimate
|
|
146
74
|
\`token_receipt\` returns a real, auditable log of what happened this session (exact cache hits,
|
|
147
75
|
semantic cache hits, file reads, fresh reasoning) — not a projected percentage. Use it instead of
|
|
148
76
|
inventing a savings number, and show the byType breakdown so the user can verify it themselves.
|
|
149
77
|
|
|
150
|
-
### 10.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
saves real tokens. But treat the suggested fix as a candidate, not a verdict: check it actually
|
|
156
|
-
addresses the failing assertion before applying it. Applying a wrong auto-fix blind costs far
|
|
157
|
-
more (a broken build, a confused user, a debugging round-trip) than the tokens saved skipping the check.
|
|
158
|
-
|
|
159
|
-
### 12. For common prompt patterns → use prompt_pattern_cache
|
|
160
|
-
Before generating repetitive prompts ("explain this", "review this", "write tests"), check \`prompt_pattern_cache\` action "find" for cached templates.
|
|
78
|
+
### 10. Anything the toolbox hands you is still a candidate, not a verdict
|
|
79
|
+
Tools reached via \`lemma_toolbox\` (auto-fixes for failing tests, cached prompt patterns,
|
|
80
|
+
Brain-suggested patches) return suggestions. Check a suggested fix actually addresses the failing
|
|
81
|
+
assertion before applying it — a wrong auto-fix applied blind costs far more (broken build,
|
|
82
|
+
debugging round-trip) than the tokens saved by skipping the check.
|
|
161
83
|
|
|
162
84
|
## TURBOMODE SCORING
|
|
163
85
|
Correctness first, then cost — a fast wrong answer is more expensive than a slow right one once
|
|
164
86
|
you count the round-trip to find and fix it.
|
|
165
87
|
- Verified cache hit (state_hash_cache, or a disclosed smarter_cache hit above threshold) = best outcome: correct AND ~0 tokens spent.
|
|
166
88
|
- Cache MISS + reasoning from scratch = the normal, GOOD outcome whenever no verified cache exists. Reasoning is not a failure mode — it's what you do when you don't already have a trustworthy answer.
|
|
167
|
-
- Reading full files without checking get_ast_hologram
|
|
89
|
+
- Reading full files without checking get_ast_hologram first = wasteful, avoid it when a cheaper lookup would've told you what you needed.
|
|
168
90
|
- Any answer delivered without required disclosure (rule 6's exception), or a cached/auto-fixed result used without verification = FAIL, regardless of tokens saved — it can cost the user far more than tokens once it's wrong.
|
|
169
91
|
|
|
170
92
|
Remember: the goal is spending fewer tokens on the SAME quality of answer, not a lower-quality answer for fewer tokens.`;
|
|
@@ -172,11 +94,6 @@ function setupPromptsHandlers(server) {
|
|
|
172
94
|
server.setRequestHandler(types_js_1.ListPromptsRequestSchema, async () => {
|
|
173
95
|
return {
|
|
174
96
|
prompts: [
|
|
175
|
-
{
|
|
176
|
-
name: "lemma-autopilot",
|
|
177
|
-
description: "Lemma Autopilot: mandatory behavioral instructions for the AI assistant. Load this prompt to make all Lemma tools fire automatically with zero user friction.",
|
|
178
|
-
arguments: [],
|
|
179
|
-
},
|
|
180
97
|
{
|
|
181
98
|
name: "lemma-turbomode",
|
|
182
99
|
description: "LEMMA TURBOMODE: reduce context spend on file reads, command output, and repeated reasoning. Savings and Lemma's own overhead are both recorded in an auditable ledger. Use for long sessions on large repos.",
|
|
@@ -186,20 +103,6 @@ function setupPromptsHandlers(server) {
|
|
|
186
103
|
};
|
|
187
104
|
});
|
|
188
105
|
server.setRequestHandler(types_js_1.GetPromptRequestSchema, async (request) => {
|
|
189
|
-
if (request.params.name === "lemma-autopilot") {
|
|
190
|
-
return {
|
|
191
|
-
description: "Lemma Autopilot System Instructions",
|
|
192
|
-
messages: [
|
|
193
|
-
{
|
|
194
|
-
role: "user",
|
|
195
|
-
content: {
|
|
196
|
-
type: "text",
|
|
197
|
-
text: exports.LEMMA_SYSTEM_PROMPT,
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
],
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
106
|
if (request.params.name === "lemma-turbomode") {
|
|
204
107
|
return {
|
|
205
108
|
description: "Lemma TurboMode — Extreme Token Optimization",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":";;;AA2FA,oDA8BC;AAxHD,iEAAsG;AAEzF,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wHAsFkF,CAAC;AAEzH,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,+MAA+M;oBAC5N,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,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":"resources.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AASnE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA2D3D"}
|
|
@@ -10,6 +10,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const os_1 = __importDefault(require("os"));
|
|
11
11
|
const axios_1 = __importDefault(require("axios"));
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
|
+
const TheBrainV2_1 = require("../subconscious/TheBrainV2");
|
|
13
14
|
function setupResourcesHandlers(server) {
|
|
14
15
|
server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => {
|
|
15
16
|
return {
|
|
@@ -134,10 +135,9 @@ async function handleProjectContext(uri) {
|
|
|
134
135
|
}
|
|
135
136
|
catch { }
|
|
136
137
|
try {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
138
|
+
// Counted files in <project>/.lemma/memory, which nothing writes — so this resource
|
|
139
|
+
// always advertised 0 memories regardless of what the Brain actually held.
|
|
140
|
+
memoryCount = (0, TheBrainV2_1.getBrain)().getEntriesForProject((0, TheBrainV2_1.deriveProjectId)(projectPath)).length;
|
|
141
141
|
}
|
|
142
142
|
catch { }
|
|
143
143
|
const markdown = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/mcp/resources.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/mcp/resources.ts"],"names":[],"mappings":";;;;;AASA,wDA2DC;AAnED,iEAA2G;AAC3G,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AACpB,kDAA0B;AAC1B,mCAAiD;AACjD,2DAAuE;AAEvE,SAAgB,sBAAsB,CAAC,MAAc;IACnD,MAAM,CAAC,iBAAiB,CAAC,qCAA0B,EAAE,KAAK,IAAI,EAAE;QAC9D,OAAO;YACL,SAAS,EAAE;gBACT;oBACE,GAAG,EAAE,yBAAyB;oBAC9B,IAAI,EAAE,oBAAoB;oBAC1B,WAAW,EAAE,kFAAkF;oBAC/F,QAAQ,EAAE,eAAe;iBAC1B;gBACD;oBACE,GAAG,EAAE,qBAAqB;oBAC1B,IAAI,EAAE,0BAA0B;oBAChC,WAAW,EAA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