@nxuss/lemma 1.7.2 โ 1.8.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 +146 -179
- package/bin/brain-ingest.js +56 -0
- package/dist/cjs/mcp/tools.d.ts.map +1 -1
- package/dist/cjs/mcp/tools.js +145 -37
- package/dist/cjs/mcp/tools.js.map +1 -1
- package/dist/cjs/pr-review/bridge/BrainBridge.d.ts +11 -1
- package/dist/cjs/pr-review/bridge/BrainBridge.d.ts.map +1 -1
- package/dist/cjs/pr-review/bridge/BrainBridge.js +18 -23
- package/dist/cjs/pr-review/bridge/BrainBridge.js.map +1 -1
- package/dist/cjs/protocol/utils.d.ts.map +1 -1
- package/dist/cjs/protocol/utils.js +6 -5
- package/dist/cjs/protocol/utils.js.map +1 -1
- package/dist/cjs/security/SemanticScrubber.d.ts +2 -0
- package/dist/cjs/security/SemanticScrubber.d.ts.map +1 -1
- package/dist/cjs/security/SemanticScrubber.js +53 -13
- package/dist/cjs/security/SemanticScrubber.js.map +1 -1
- package/dist/cjs/subconscious/GitIngest.d.ts +48 -0
- package/dist/cjs/subconscious/GitIngest.d.ts.map +1 -0
- package/dist/cjs/subconscious/GitIngest.js +175 -0
- package/dist/cjs/subconscious/GitIngest.js.map +1 -0
- package/dist/cjs/subconscious/TheBrainV2.d.ts +23 -1
- package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.js +124 -17
- package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
- package/dist/cjs/utils/ConversationCheckpoint.d.ts +2 -0
- package/dist/cjs/utils/ConversationCheckpoint.d.ts.map +1 -1
- package/dist/cjs/utils/ConversationCheckpoint.js +38 -0
- package/dist/cjs/utils/ConversationCheckpoint.js.map +1 -1
- package/dist/cjs/utils/PatchMatcher.d.ts +2 -0
- package/dist/cjs/utils/PatchMatcher.d.ts.map +1 -1
- package/dist/cjs/utils/PatchMatcher.js +9 -1
- package/dist/cjs/utils/PatchMatcher.js.map +1 -1
- package/dist/esm/mcp/tools.d.ts.map +1 -1
- package/dist/esm/mcp/tools.js +147 -39
- package/dist/esm/mcp/tools.js.map +1 -1
- package/dist/esm/pr-review/bridge/BrainBridge.d.ts +11 -1
- package/dist/esm/pr-review/bridge/BrainBridge.d.ts.map +1 -1
- package/dist/esm/pr-review/bridge/BrainBridge.js +18 -20
- package/dist/esm/pr-review/bridge/BrainBridge.js.map +1 -1
- package/dist/esm/protocol/utils.d.ts.map +1 -1
- package/dist/esm/protocol/utils.js +6 -5
- package/dist/esm/protocol/utils.js.map +1 -1
- package/dist/esm/security/SemanticScrubber.d.ts +2 -0
- package/dist/esm/security/SemanticScrubber.d.ts.map +1 -1
- package/dist/esm/security/SemanticScrubber.js +53 -13
- package/dist/esm/security/SemanticScrubber.js.map +1 -1
- package/dist/esm/subconscious/GitIngest.d.ts +48 -0
- package/dist/esm/subconscious/GitIngest.d.ts.map +1 -0
- package/dist/esm/subconscious/GitIngest.js +166 -0
- package/dist/esm/subconscious/GitIngest.js.map +1 -0
- package/dist/esm/subconscious/TheBrainV2.d.ts +23 -1
- package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/esm/subconscious/TheBrainV2.js +124 -17
- package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
- package/dist/esm/utils/ConversationCheckpoint.d.ts +2 -0
- package/dist/esm/utils/ConversationCheckpoint.d.ts.map +1 -1
- package/dist/esm/utils/ConversationCheckpoint.js +37 -0
- package/dist/esm/utils/ConversationCheckpoint.js.map +1 -1
- package/dist/esm/utils/PatchMatcher.d.ts +2 -0
- package/dist/esm/utils/PatchMatcher.d.ts.map +1 -1
- package/dist/esm/utils/PatchMatcher.js +9 -1
- package/dist/esm/utils/PatchMatcher.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# ๐ง Lemma v1.
|
|
1
|
+
# ๐ง Lemma v1.8.1
|
|
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,9 +17,9 @@
|
|
|
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 **95 MCP tools** โ including zero-token static code intelligence that runs entirely on your machine with no LLM calls required.
|
|
21
21
|
|
|
22
|
-
Since v1.7.0 those
|
|
22
|
+
Since v1.7.0 those 95 tools are all registered, but only the ones your project can actually use
|
|
23
23
|
are advertised to the model each turn. The rest stay one `lemma_toolbox` call away. See
|
|
24
24
|
[Tool profiles](#-tool-profiles).
|
|
25
25
|
|
|
@@ -27,7 +27,61 @@ are advertised to the model each turn. The rest stay one `lemma_toolbox` call aw
|
|
|
27
27
|
|
|
28
28
|
## ๐ Changelog
|
|
29
29
|
|
|
30
|
-
### v1.
|
|
30
|
+
### v1.8.1 โ Two correctness fixes: secret scrubbing and patch data loss *(NEW)*
|
|
31
|
+
|
|
32
|
+
An audit of the tools with no test coverage turned up two bugs where the tool looked done but
|
|
33
|
+
silently produced wrong output.
|
|
34
|
+
|
|
35
|
+
- **`apply_workspace_patch` could corrupt a line.** The exact-match strategy computed
|
|
36
|
+
`startLine`/`endLine` from a raw substring `indexOf`, but the handler always spliced by whole
|
|
37
|
+
line. A search block that was a *fragment* of a line (not the entire line) collapsed
|
|
38
|
+
`startLine === endLine`, and the splice replaced the entire line with just the replacement โ
|
|
39
|
+
discarding everything else on it. Exact matches now splice by character offset;
|
|
40
|
+
whitespace-normalized/indent-anchored/fuzzy matches (already full-line windows) are unaffected.
|
|
41
|
+
- **The privacy scrubber only recognized 3 generic patterns.** Default patterns covered
|
|
42
|
+
`API_KEY`/`EMAIL`/`Bearer ...` shapes only โ vendor-specific secrets (Stripe, AWS, GitHub,
|
|
43
|
+
Google, Slack, JWTs, PEM private-key blocks) and custom-named secrets (e.g. a project's own
|
|
44
|
+
`_SALT` or `_WEBHOOK_SECRET` env var) passed through unmasked. Also, a project's custom
|
|
45
|
+
`lemma.config.json` patterns silently *replaced* the defaults instead of adding to them, so
|
|
46
|
+
defining one narrow pattern dropped coverage for everything else. Added vendor-specific
|
|
47
|
+
patterns plus a generic `ENV_SECRET` catch-all keyed on variable-name conventions, and custom
|
|
48
|
+
patterns now augment the defaults by default (`replaceDefaults: true` opts into full override).
|
|
49
|
+
|
|
50
|
+
### v1.8.0 โ The Brain learns from project history, not just what it's told *(NEW)*
|
|
51
|
+
|
|
52
|
+
Every memory in The Brain used to depend on the assistant remembering to call `store_memory`. If
|
|
53
|
+
nobody called it, the Brain knew nothing about work that already happened.
|
|
54
|
+
|
|
55
|
+
| Change | What it does | Why it matters |
|
|
56
|
+
| :--- | :--- | :--- |
|
|
57
|
+
| **`lemma-brain-ingest`** *(new CLI)* | Feeds The Brain from git commits and `CHANGELOG.md` โ no assistant call needed. Incremental via a marker file, safe to wire to `post-commit`. | The Brain stops depending on the model remembering to save anything. |
|
|
58
|
+
| **Checkpoints now feed The Brain** | `saveCheckpoint()` indexes any checkpoint with real content into the same Brain `search_memory` reads. | Decisions and bugs recorded in a checkpoint used to be invisible to search. |
|
|
59
|
+
| **`get_project_history`** *(new tool)* | Merges recent commits, checkpoints, and Brain memories for the current project into one call. | Answers "what have we done here" without three separate lookups. |
|
|
60
|
+
| **Outcome tagging** | `store_memory` accepts `outcome: 'failed'`; search surfaces it as a warning, not a suggestion. | A dead end is now as memorable as a fix. |
|
|
61
|
+
| **Symbol-level freshness** | `store_memory` accepts `symbols: [{filePath, symbolName}]` โ freshness is judged by that function's own source, not the whole file. | An unrelated edit elsewhere in the file no longer stales the memory out. |
|
|
62
|
+
|
|
63
|
+
**PR review memory was silently going nowhere.** `BrainBridge` talked to the proxy's
|
|
64
|
+
`/api/search`/`/api/memory/store`, both backed by ChromaDB + a local Ollama server on `:11434` โ
|
|
65
|
+
the exact stack TheBrainV2 replaced in 1.0.0. Whenever Ollama wasn't running (the common case
|
|
66
|
+
now), every call failed inside a `try/catch` and returned empty. It now reads/writes `TheBrainV2`
|
|
67
|
+
directly, so PR review and interactive coding share one memory instead of two disconnected ones.
|
|
68
|
+
|
|
69
|
+
**Two projects could quietly share โ or split โ memories.** `deriveProjectId` hashed the
|
|
70
|
+
project path without resolving symlinks; on macOS `process.cwd()` and an `os.tmpdir()`-built path
|
|
71
|
+
can report different strings for the same directory, hashing to two different project scopes. It
|
|
72
|
+
now resolves via `fs.realpathSync` first.
|
|
73
|
+
|
|
74
|
+
**Spanish text was mangled before it reached the index.** `tokenize()` used `\w` to strip
|
|
75
|
+
punctuation, which doesn't match accented letters โ "Cรณmo" became "mo", "diseรฑo" became "dise",
|
|
76
|
+
and the same word typed without its accent tokenized completely differently. `tokenize()` now
|
|
77
|
+
normalizes diacritics first, and gained an additive English/Spanish stemmer and Spanish stopwords.
|
|
78
|
+
|
|
79
|
+
**`token_budget` reported a multiplier no ledger backed.** It fetched a proxy route that doesn't
|
|
80
|
+
exist, silently fell back to an uncosted estimate, and reported a bigger number than the
|
|
81
|
+
session's own auditable ledger would support. It now reads the real `SavingsLedger` net position
|
|
82
|
+
(`/api/savings-breakdown`) or says plainly there's nothing to report if the proxy isn't running.
|
|
83
|
+
|
|
84
|
+
### v1.7.0 โ The cost of being connected
|
|
31
85
|
|
|
32
86
|
Every tool schema Lemma advertises goes into the model's system prompt and is **re-sent on every
|
|
33
87
|
request of the session** โ including schemas for tools the project can never use. On this repo that
|
|
@@ -288,7 +342,7 @@ Or use environment variables: `JENKINS_URL`, `JENKINS_USERNAME`, `JENKINS_API_TO
|
|
|
288
342
|
## ๐๏ธ Tool profiles
|
|
289
343
|
|
|
290
344
|
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
|
|
345
|
+
on **every request** of the session. Advertising all 95 tools costs ~11,600 tokens per turn โ much
|
|
292
346
|
of it schemas for tools a given project can never use.
|
|
293
347
|
|
|
294
348
|
Lemma advertises a scoped surface instead. Nothing is removed: every tool stays registered and
|
|
@@ -349,14 +403,57 @@ the richer record when one exists.
|
|
|
349
403
|
|
|
350
404
|
---
|
|
351
405
|
|
|
406
|
+
## ๐ง Feeding The Brain from project history
|
|
407
|
+
|
|
408
|
+
`store_memory` also depends on the assistant remembering to call it. `lemma-brain-ingest` pulls
|
|
409
|
+
memories from sources that already exist and don't need an assistant in the loop:
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
lemma-brain-ingest [projectRoot] [--max N] [--changelog] [--no-commits]
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
- Every git commit (message + files touched) becomes one Brain entry, so `search_memory` and
|
|
416
|
+
`get_telepathic_hints` can recall *why* a change happened, not just what the code looks like now.
|
|
417
|
+
- `--changelog` also ingests `CHANGELOG.md` (falls back to `docs/CHANGELOG.md`) โ one entry per release, parsed
|
|
418
|
+
directly, no LLM involved.
|
|
419
|
+
|
|
420
|
+
A marker file under `<project>/.lemma/session/` tracks the last commit and changelog version
|
|
421
|
+
ingested, so this is safe to run after every commit and safe to run by hand for a one-time
|
|
422
|
+
backfill of existing history โ both take the same incremental path and never double-store.
|
|
423
|
+
Wire it to a post-commit hook to keep it current automatically:
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
echo 'lemma-brain-ingest "$(git rev-parse --show-toplevel)" &' >> .git/hooks/post-commit
|
|
427
|
+
chmod +x .git/hooks/post-commit
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
352
432
|
## ๐ Free vs Pro
|
|
353
433
|
|
|
354
|
-
|
|
434
|
+
Of the 95 registered tools, 46 work with no license and 49 require Pro. This split is enforced by
|
|
435
|
+
one allowlist in code (`FREE_TOOLS` in `src/mcp/tools.ts`), not by narrative โ if a tool isn't in
|
|
436
|
+
that list, it's Pro, regardless of what a description elsewhere implies.
|
|
437
|
+
|
|
438
|
+
### ๐ Free (46 Tools)
|
|
355
439
|
|
|
356
440
|
These tools work **without a Pro license**. Activate them with just `lemma init`:
|
|
357
441
|
|
|
358
442
|
| Tool | What It Does |
|
|
359
443
|
| :--- | :--- |
|
|
444
|
+
| `smarter_cache` | Semantic cache lookup before reasoning from scratch |
|
|
445
|
+
| `state_hash_cache` | Reasoning cache keyed to file content hashes โ exact invalidation |
|
|
446
|
+
| `token_receipt` | Auditable per-session ledger of how each answer was produced |
|
|
447
|
+
| `search_memory` | Semantic search across The Brain, all projects |
|
|
448
|
+
| `store_memory` | Persist verified solutions/fixes/decisions into The Brain |
|
|
449
|
+
| `get_project_history` | Git log + checkpoints + Brain memories in one call |
|
|
450
|
+
| `token_budget` | Session token/cost dashboard, including Lemma's own overhead |
|
|
451
|
+
| `squeeze_prompt` | Compress code blocks before they enter your own context |
|
|
452
|
+
| `turbosqueeze` | Extreme internal-context compression (never shown to the user) |
|
|
453
|
+
| `read_workspace_file` | Read a file with auto-compression and privacy scrubbing |
|
|
454
|
+
| `scrub_privacy` | Mask PII, API keys, and secrets from any text block |
|
|
455
|
+
| `summarize_long_text` | Summarize via local Ollama, falls back to truncation |
|
|
456
|
+
| `lemma_toolbox` | List, inspect, and call tools whose schemas were withheld |
|
|
360
457
|
| `file_fingerprint` | File hash cache โ avoid re-reads |
|
|
361
458
|
| `git_blame_heat` | Git blame + risk scoring |
|
|
362
459
|
| `type_coverage_report` | TypeScript type safety score |
|
|
@@ -391,25 +488,27 @@ These tools work **without a Pro license**. Activate them with just `lemma init`
|
|
|
391
488
|
| `terraform_state_list` | List Terraform state resources |
|
|
392
489
|
| `terraform_drift` | Detect Terraform drift |
|
|
393
490
|
|
|
394
|
-
### ๐ Pro (
|
|
491
|
+
### ๐ Pro (49 Tools)
|
|
395
492
|
|
|
396
493
|
All remaining tools require a Pro license. Activate with `lemma activate <key>` โ [Get Pro](https://lemma.nxus.studio/upgrade)
|
|
397
494
|
|
|
398
495
|
| Category | Tools |
|
|
399
496
|
| :--- | :--- |
|
|
400
|
-
| **AI Proxy** | OpenAI/Anthropic/Gemini proxy, exact-match cache,
|
|
401
|
-
| **
|
|
402
|
-
| **
|
|
403
|
-
| **
|
|
404
|
-
| **
|
|
405
|
-
| **
|
|
406
|
-
| **
|
|
407
|
-
| **
|
|
408
|
-
| **
|
|
409
|
-
| **
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
>
|
|
497
|
+
| **AI Proxy** | OpenAI/Anthropic/Gemini proxy, exact-match cache, complexity router |
|
|
498
|
+
| **The Brain (advanced)** | `get_telepathic_hints`, `query_hybrid_consensus`, `semantic_dedup_guard`, `local_semantic_autofix` โ basic search/store/smarter_cache are Free |
|
|
499
|
+
| **Zero-Token Static** | `entropy_score`, `coupling_radar`, `pattern_fossil`, `git_heatmap_risk`, `precrime_static`, `dead_export_necromancer` |
|
|
500
|
+
| **Architecture** | `depgraph`, `refactor`, `ast_flow_visualizer`, `imports_skeleton_resolver`, `cognitive_map`, `file_intent_index` |
|
|
501
|
+
| **Code Intelligence** | `get_ast_hologram`, `validate_patch_sandbox`, `surgical_ast_insert`, `get_symbol_surgical_context`, `smart_file_slice`, `diff_only` |
|
|
502
|
+
| **Workspace writes** | `write_workspace_file`, `create_workspace_file`, `apply_workspace_patch`, `multi_file_patch`, `search_workspace`, `list_workspace_dir`, `run_workspace_command`, `output_region` |
|
|
503
|
+
| **Optimization (advanced)** | `wormhole_squeeze`, `compress_context`, `prune_conversation_history` โ `turbosqueeze`, `squeeze_prompt`, `token_budget` are Free |
|
|
504
|
+
| **PR Review** | `review_diff`, `review_pr`, `pr_status`, `generate_pr_workflow` |
|
|
505
|
+
| **Session & Automation** | `test_oracle`, `schema_extract`, `changelog_auto`, `env_snapshot`, `migration_tracer`, `spec_to_stub`, `batch_tool_calls`, `get_routing_advice`, `get_project_onboarding`, `auto_heal`, `semantic_grep` |
|
|
506
|
+
| **Automation (background)** | AutoPilot, Auto-Heal, Silent Patch Watcher |
|
|
507
|
+
|
|
508
|
+
> **The MCP server itself is Pro.** All 49 Pro tools โ the advanced Brain layer, PreCrime, AST
|
|
509
|
+
> Hologram, `depgraph`, `refactor`, every workspace-write tool, and every PR review tool โ require a
|
|
510
|
+
> Pro license. The 46 Free tools above (including all 22 Infrastructure tools and `read_workspace_file`
|
|
511
|
+
> with its automatic privacy scrubbing) are accessible without activation.
|
|
413
512
|
|
|
414
513
|
---
|
|
415
514
|
|
|
@@ -626,6 +725,8 @@ lemma start
|
|
|
626
725
|
| `lemma apply <id>` | Apply a pending fix patch. |
|
|
627
726
|
| `lemma discard <id>` | Discard a pending fix patch. |
|
|
628
727
|
| `lemma activate <key>` | Activate Pro license for full MCP access. |
|
|
728
|
+
| `lemma-checkpoint [projectRoot]` | Standalone bin: derive a session checkpoint from repo state (branch, changed files, recent commits) without an assistant call. See [Session checkpoints](#-session-checkpoints). |
|
|
729
|
+
| `lemma-brain-ingest [projectRoot]` | Standalone bin: feed The Brain from git commits and `CHANGELOG.md`, incrementally. See [Feeding The Brain from project history](#-feeding-the-brain-from-project-history). |
|
|
629
730
|
|
|
630
731
|
### Customizing via `lemma.config.json`
|
|
631
732
|
|
|
@@ -665,157 +766,32 @@ Just run `lemma init`. Lemma automatically registers its MCP server in your `~/.
|
|
|
665
766
|
}
|
|
666
767
|
```
|
|
667
768
|
|
|
668
|
-
Once connected, your IDE gains access to **
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
### ๐ Free Tools (11)
|
|
675
|
-
|
|
676
|
-
> These tools work without a Pro license. All are zero-dependency and run locally.
|
|
677
|
-
|
|
678
|
-
| Tool | Category | Description |
|
|
679
|
-
| :--- | :--- | :--- |
|
|
680
|
-
| `file_fingerprint` | Smart Read | SHA256 hash cache. Returns 'unchanged' when hash matches, avoiding re-reads. |
|
|
681
|
-
| `git_blame_heat` | Analysis | Git blame + risk scoring per line. Identifies hotspots and high-risk authors. |
|
|
682
|
-
| `type_coverage_report` | Analysis | TypeScript type safety score via AST. Reports typed vs untyped, `any` count. |
|
|
683
|
-
| `import_tree_context` | Architecture | Bidirectional import graph with reverse dependencies. |
|
|
684
|
-
| `read_token_budgeted` | Smart Read | Read file with hard token limit. Returns only relevant sections. |
|
|
685
|
-
| `bulk_file_digest` | Smart Read | Read N files in one call. Returns compressed digest. |
|
|
686
|
-
| `auto_context_bundle` | Smart Read | One-call bundle: content + imports + types + Brain hints. |
|
|
687
|
-
| `repeat_guard` | Optimization | Detects duplicate outputs using Jaccard similarity. |
|
|
688
|
-
| `conversation_checkpoint` | Session | Save/load session state to prevent re-explaining context. |
|
|
689
|
-
| `test_autofix_interceptor` | Automation | Run tests + Brain search for matching fixes. |
|
|
690
|
-
| `prompt_pattern_cache` | Optimization | Find/store optimized prompt templates. |
|
|
691
|
-
|
|
692
|
-
### ๐๏ธ Workspace Tools
|
|
693
|
-
|
|
694
|
-
| Tool | Description |
|
|
695
|
-
| :--- | :--- |
|
|
696
|
-
| `read_workspace_file` | Read a file with automatic token compression and privacy scrubbing. |
|
|
697
|
-
| `write_workspace_file` | Write content to a file, creating parent directories as needed. |
|
|
698
|
-
| `create_workspace_file` | Create a new file (fails if exists). Returns minimal ACK. |
|
|
699
|
-
| `apply_workspace_patch` | Smart search-and-replace patch โ safe against duplicate matches. |
|
|
700
|
-
| `multi_file_patch` | Apply patches to multiple files in a single call. |
|
|
701
|
-
| `list_workspace_dir` | Recursively list the project structure up to a configurable depth. |
|
|
702
|
-
| `search_workspace` | Fast text search (grep) across all project files. |
|
|
703
|
-
| `semantic_grep` | Natural language concept search using BM25. |
|
|
704
|
-
| `run_workspace_command` | Execute bash commands in the workspace root. Secured by allowlist. Distills long jest/vitest/tsc/eslint output down to the failures and their locations; full output kept retrievable. |
|
|
705
|
-
| `output_region` | Retrieve any part of a stored command output verbatim (whole thing, one failing test, or a line range). |
|
|
706
|
-
| `file_intent_index` | Group files by domain intent (auth, routing, config). |
|
|
707
|
-
|
|
708
|
-
### ๐ฌ Code Intelligence Tools
|
|
709
|
-
|
|
710
|
-
| Tool | Description |
|
|
711
|
-
| :--- | :--- |
|
|
712
|
-
| `get_ast_hologram` | Holographic AST Map of all exported symbols. 90% token savings. |
|
|
713
|
-
| `validate_patch_sandbox` | Pre-flight validator: runs tsc + syntax check before applying. |
|
|
714
|
-
| `diff_only` | Compact line-by-line diff between known states. Session-scoped. |
|
|
715
|
-
| `surgical_ast_insert` | Insert code at AST anchor point. 95% output token savings. |
|
|
716
|
-
| `get_symbol_surgical_context` | Extract symbol + dependency signatures only. 90% savings. |
|
|
717
|
-
| `smart_file_slice` | Read only relevant lines around a query. 85% savings. |
|
|
718
|
-
| `schema_extract` | Extract interfaces/types/schemas via AST. 80% savings. |
|
|
719
|
-
| `spec_to_stub` | Generate mock stubs from TypeScript interfaces. |
|
|
720
|
-
| `ast_flow_visualizer` | Mermaid flowchart from function control flow. |
|
|
721
|
-
| `imports_skeleton_resolver` | Import signature mapper for quick reference. |
|
|
722
|
-
|
|
723
|
-
### ๐ง Brain & Memory Tools
|
|
724
|
-
|
|
725
|
-
| Tool | Description |
|
|
726
|
-
| :--- | :--- |
|
|
727
|
-
| `search_memory` | Semantic search across The Brain from all projects globally. |
|
|
728
|
-
| `store_memory` | Persist solutions, fixes, decisions into The Brain. |
|
|
729
|
-
| `query_hybrid_consensus` | Hybrid cache: 80% threshold โ instant answer, 0 cloud tokens. |
|
|
730
|
-
| `get_telepathic_hints` | Proactive hints from The Brain based on active file. |
|
|
731
|
-
| `smarter_cache` | Predictive cache at 75% threshold before any reasoning. |
|
|
732
|
-
| `semantic_dedup_guard` | Brain dedup firewall. Rejects โฅ92% similar entries. |
|
|
733
|
-
| `local_semantic_autofix` | Offline self-healing from Brain error index. |
|
|
734
|
-
|
|
735
|
-
### โ๏ธ Optimization & Privacy Tools
|
|
736
|
-
|
|
737
|
-
| Tool | Description |
|
|
738
|
-
| :--- | :--- |
|
|
739
|
-
| `scrub_privacy` | Mask PII, API keys, secrets from any text block. |
|
|
740
|
-
| `squeeze_prompt` | Compress code blocks. Up to 80% token reduction. |
|
|
741
|
-
| `turbosqueeze` | Extreme compression: strips comments, imports, whitespace. |
|
|
742
|
-
| `wormhole_squeeze` | Reversible unicode compression. 60-70% reduction. |
|
|
743
|
-
| `compress_context` | Summarize old conversation turns. Keeps last N intact. |
|
|
744
|
-
| `prune_conversation_history` | Intelligently decimate history preserving critical context. |
|
|
745
|
-
| `summarize_long_text` | Summarize via Ollama. Falls back to truncation. |
|
|
746
|
-
| `token_budget` | Dashboard: multiplier, savings, strategies, recommendations. |
|
|
747
|
-
| `get_routing_advice` | Optimal model recommendation from Complexity Router. |
|
|
748
|
-
| `get_project_onboarding` | One-shot architectural mental model. |
|
|
749
|
-
| `auto_heal` | Auto-diagnose and repair crashes from live context. |
|
|
750
|
-
| `batch_tool_calls` | Execute multiple tools in parallel via Promise.all. |
|
|
751
|
-
|
|
752
|
-
### ๐ฎ Zero-Token Static Intelligence Tools
|
|
753
|
-
|
|
754
|
-
> All tools in this section use **zero LLM tokens**. Pure local computation.
|
|
755
|
-
|
|
756
|
-
| Tool | Description |
|
|
757
|
-
| :--- | :--- |
|
|
758
|
-
| `entropy_score` | Mathematical chaos score (0-100) per file. |
|
|
759
|
-
| `coupling_radar` | Dependency graph: circular imports, god modules, dead islands. |
|
|
760
|
-
| `pattern_fossil` | Zombie code detector: var vs const, callbacks vs async/await. |
|
|
761
|
-
| `git_heatmap_risk` | Git churn analysis + co-edit pairs. |
|
|
762
|
-
| `precrime_static` | Composite risk predictor combining entropy + coupling + git. |
|
|
763
|
-
| `dead_export_necromancer` | Dead code auditor: exported but never imported. |
|
|
764
|
-
| `git_blame_heat` | Git blame + per-line risk scoring. |
|
|
765
|
-
| `type_coverage_report` | TypeScript type safety score. |
|
|
766
|
-
| `import_tree_context` | Bidirectional import graph. |
|
|
767
|
-
|
|
768
|
-
### ๐๏ธ Architecture & Refactoring Tools
|
|
769
|
-
|
|
770
|
-
| Tool | Description |
|
|
771
|
-
| :--- | :--- |
|
|
772
|
-
| `depgraph` | Real-time dependency graph with depth, format, circular detection. |
|
|
773
|
-
| `refactor` | Declarative codemod: rename symbols or move files. |
|
|
774
|
-
| `cognitive_map` | Auto-updating knowledge graph of domains and patterns. |
|
|
775
|
-
|
|
776
|
-
### ๐ PR Review Agent Tools
|
|
777
|
-
|
|
778
|
-
| Tool | Description |
|
|
779
|
-
| :--- | :--- |
|
|
780
|
-
| `review_diff` | Analyze raw diff for bugs, security, best practices. |
|
|
781
|
-
| `review_pr` | Full PR review against GitHub, Azure DevOps, GitLab. |
|
|
782
|
-
| `pr_status` | Query last review status for a PR. |
|
|
783
|
-
| `generate_pr_workflow` | Generate CI/CD workflow YAML for PR reviews. |
|
|
784
|
-
|
|
785
|
-
### ๐งช Testing & Quality Tools
|
|
786
|
-
|
|
787
|
-
| Tool | Description |
|
|
788
|
-
| :--- | :--- |
|
|
789
|
-
| `test_oracle` | Run tests, return only failures with compressed traces. |
|
|
790
|
-
| `test_autofix_interceptor` | Run tests + Brain search for matching fixes. |
|
|
791
|
-
| `changelog_auto` | Conventional commit changelog from git history. |
|
|
792
|
-
| `env_snapshot` | Node/npm versions, deps, .env keys (values hidden). |
|
|
793
|
-
| `migration_tracer` | Prisma migration schema diff analysis. |
|
|
794
|
-
|
|
795
|
-
### ๐ Session & Automation Tools
|
|
796
|
-
|
|
797
|
-
| Tool | Description |
|
|
798
|
-
| :--- | :--- |
|
|
799
|
-
| `conversation_checkpoint` | Save/load session state to `.lemma/session/`. |
|
|
800
|
-
| `prompt_pattern_cache` | Find/store optimized prompt templates. |
|
|
801
|
-
| `review_pr` | Full PR review with auto-approve option. |
|
|
769
|
+
Once connected, your IDE gains access to all **95 MCP tools** (46 Free + 49 Pro โ see
|
|
770
|
+
[Free vs Pro](#-free-vs-pro) for the full, current split) and Lemma auto-injects the TurboMode
|
|
771
|
+
system prompt on handshake. By default only the tools your project shows evidence of needing are
|
|
772
|
+
*advertised* each turn โ see [Tool profiles](#-tool-profiles) โ but every tool is registered and
|
|
773
|
+
reachable via `lemma_toolbox` regardless of profile.
|
|
802
774
|
|
|
803
775
|
### โก TurboMode Auto-Injection
|
|
804
776
|
|
|
805
|
-
When connected via `lemma mcp`, Lemma auto-injects
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
777
|
+
When connected via `lemma mcp`, Lemma auto-injects its system prompt on handshake. The real,
|
|
778
|
+
current prompt (`LEMMA_TURBOMODE_PROMPT` in `src/mcp/prompts.ts`) states the goal โ reduce what
|
|
779
|
+
enters context without ever costing a correct answer โ and enforces it with rules including:
|
|
780
|
+
|
|
781
|
+
- A tool call costs tokens too: expect a call to save more than its own round-trip, or skip it.
|
|
782
|
+
- `lemma_toolbox` reaches every tool whose schema was withheld from this session โ check it
|
|
783
|
+
before saying a capability is missing.
|
|
784
|
+
- Compression (`turbosqueeze`, `wormhole_squeeze`, `squeeze_prompt`) is for the model's own
|
|
785
|
+
context only; the user always gets the real, uncompressed file.
|
|
786
|
+
- `smarter_cache` hits must be disclosed as cached, never presented as freshly reasoned, and
|
|
787
|
+
re-verified before acting on them.
|
|
788
|
+
- `state_hash_cache` (exact file-hash invalidation) is preferred over `smarter_cache` (semantic
|
|
789
|
+
similarity) whenever the answer depends on specific files.
|
|
790
|
+
- `store_memory` only after a solution is actually verified โ an unverified fix stored here
|
|
791
|
+
becomes a false cache hit later.
|
|
792
|
+
- `get_routing_advice` before assuming a mechanical task needs the biggest available model.
|
|
793
|
+
- `surgical_ast_insert` by default for adding to an existing file, instead of rewriting it whole.
|
|
794
|
+
- `token_receipt` for "how much did we save," never an invented estimate.
|
|
819
795
|
|
|
820
796
|
---
|
|
821
797
|
|
|
@@ -860,15 +836,6 @@ See [`.env.security.example`](.env.security.example) for all security-related en
|
|
|
860
836
|
|
|
861
837
|
## ๐ฆ SDK Integrations
|
|
862
838
|
|
|
863
|
-
### LangChain
|
|
864
|
-
```typescript
|
|
865
|
-
import { LemmaLangChainProvider } from '@nxuss/lemma/langchain';
|
|
866
|
-
|
|
867
|
-
const model = new LemmaLangChainProvider({
|
|
868
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
869
|
-
});
|
|
870
|
-
```
|
|
871
|
-
|
|
872
839
|
### CrewAI
|
|
873
840
|
```typescript
|
|
874
841
|
import { LemmaCrewAIProvider } from '@nxuss/lemma/crewai';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Feeds The Brain from sources the model never has to remember to store manually.
|
|
6
|
+
*
|
|
7
|
+
* Meant to be wired to a git post-commit hook so every commit becomes a searchable memory
|
|
8
|
+
* without depending on the assistant calling `store_memory`:
|
|
9
|
+
*
|
|
10
|
+
* echo 'lemma-brain-ingest "$(git rev-parse --show-toplevel)" &' >> .git/hooks/post-commit
|
|
11
|
+
*
|
|
12
|
+
* With no flags it's an incremental catch-up: a marker file under .lemma/session/ tracks the
|
|
13
|
+
* last commit ingested, so running this after every commit or by hand both take the same path
|
|
14
|
+
* and never double-store. `--max N` only matters the first time there is no marker yet.
|
|
15
|
+
*
|
|
16
|
+
* Usage: lemma-brain-ingest [projectRoot] [--max N] [--changelog] [--no-commits]
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
function main() {
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const maxIndex = args.indexOf('--max');
|
|
24
|
+
const maxCommits = maxIndex >= 0 ? parseInt(args[maxIndex + 1], 10) : undefined;
|
|
25
|
+
const includeChangelog = args.includes('--changelog');
|
|
26
|
+
const includeCommits = !args.includes('--no-commits');
|
|
27
|
+
const positional = args.filter((a, i) => !a.startsWith('--') && i !== maxIndex + 1);
|
|
28
|
+
const projectRoot = path.resolve(positional[0] || process.cwd());
|
|
29
|
+
|
|
30
|
+
const distPath = path.join(__dirname, '..', 'dist', 'cjs', 'subconscious', 'GitIngest.js');
|
|
31
|
+
let ingestRecentCommits, ingestChangelog;
|
|
32
|
+
try {
|
|
33
|
+
({ ingestRecentCommits, ingestChangelog } = require(distPath));
|
|
34
|
+
} catch {
|
|
35
|
+
console.error('[lemma-brain-ingest] Build not found. Run "npm run build" first.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (includeCommits) {
|
|
40
|
+
const res = ingestRecentCommits(projectRoot, { maxCommits });
|
|
41
|
+
console.error(`[lemma-brain-ingest] commits: ${res.ingested} stored, ${res.skipped} skipped (up to ${res.lastSha ? res.lastSha.substring(0, 12) : 'none'})`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (includeChangelog) {
|
|
45
|
+
const res = ingestChangelog(projectRoot);
|
|
46
|
+
console.error(`[lemma-brain-ingest] changelog: ${res.ingested} stored, ${res.skipped} skipped (${res.versionsSeen} version(s) seen)`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
main();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
// A hook that fails must never be the reason a commit or session goes bad.
|
|
54
|
+
console.error('[lemma-brain-ingest] Skipped:', err && err.message);
|
|
55
|
+
}
|
|
56
|
+
process.exit(0);
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAwjCnE,oFAAoF;AACpF,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,IAAI;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAQA;AAqHD,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;AAqCD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAC1C,IAAI,CAwEN"}
|