composto-ai 0.4.1 → 0.6.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 +118 -33
- package/dist/index.js +896 -84
- package/dist/mcp/server.js +54 -37
- package/dist/memory/api.js +53 -200
- package/dist/memory/worker.js +71 -55
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
# Composto
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Causal memory layer for coding agents. Catches the bug your agent is about to reintroduce.**
|
|
4
4
|
|
|
5
|
-
Composto
|
|
5
|
+
Composto is a repo-local graph of your git history that your AI coding agent consults before every edit. When a file was reverted recently, has a fix cluster in its history, or was last touched by someone who left the team, Composto surfaces that signal as in-context guidance before the agent writes the code. Hook-enforced on Claude Code, Cursor, and Gemini CLI. Local-first, MIT.
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
CASE:"L3" → RET options.code
|
|
8
|
+
$ composto impact src/memory/signals/hotspot.ts
|
|
9
|
+
|
|
10
|
+
verdict: medium
|
|
11
|
+
score: 0.52
|
|
12
|
+
confidence: 0.50
|
|
13
|
+
signals:
|
|
14
|
+
revert_match ■■■■■■■■■■ strength=1.00 precision=1.00
|
|
15
|
+
hotspot ■ strength=0.10 precision=0.54
|
|
16
|
+
fix_ratio ■ strength=0.07 precision=0.54
|
|
17
|
+
author_churn · strength=0.00 precision=0.16
|
|
18
|
+
|
|
19
|
+
# This file was touched by a Revert commit in history.
|
|
20
|
+
# blastradius remembers. Your LLM couldn't.
|
|
22
21
|
```
|
|
23
22
|
|
|
24
23
|
---
|
|
@@ -29,32 +28,115 @@ OUT FN:generateLayer(layer: IRLayer, options: {...})
|
|
|
29
28
|
# Install
|
|
30
29
|
npm install -g composto-ai
|
|
31
30
|
|
|
32
|
-
#
|
|
33
|
-
|
|
31
|
+
# One-command setup, wires MCP + PreToolUse hook into your AI client
|
|
32
|
+
cd your-project
|
|
33
|
+
composto init --client=claude-code # or cursor, or gemini-cli
|
|
34
34
|
|
|
35
|
-
#
|
|
36
|
-
|
|
35
|
+
# Restart your AI client. Hook fires on every Edit / Write / MultiEdit.
|
|
36
|
+
# On medium|high|unknown verdicts, the agent gets a composto_blastradius
|
|
37
|
+
# block in context before it acts. Passthrough on low.
|
|
37
38
|
|
|
38
|
-
#
|
|
39
|
-
composto
|
|
39
|
+
# Observe
|
|
40
|
+
composto stats # hook invocations, verdict distribution, latency
|
|
41
|
+
composto stats --disable # local-only opt-out (writes .composto/telemetry-disabled)
|
|
40
42
|
|
|
41
|
-
#
|
|
42
|
-
COMPOSTO_BLASTRADIUS=1 composto index
|
|
43
|
+
# Query on demand
|
|
43
44
|
composto impact src/auth/login.ts
|
|
44
|
-
composto index --status
|
|
45
|
+
composto index --status # diagnostics: schema, freshness, calibration
|
|
45
46
|
```
|
|
46
47
|
|
|
48
|
+
### Also in the box: AST compression tools
|
|
49
|
+
|
|
50
|
+
Composto also ships a tree-sitter based AST compressor (about 89% token savings) and a smart context packer for bug-fix tasks. These are separate from the causal layer but live in the same binary.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
composto ir src/app.ts # compress a file to IR (L0/L1/L2/L3)
|
|
54
|
+
composto context src/ --budget 2000 # smart context within a token budget
|
|
55
|
+
composto benchmark . # see compression stats
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
See the [IR Layers](#ir-layers), [Health-Aware IR](#health-aware-ir), and [Context Budget](#context-budget) sections below for details.
|
|
59
|
+
|
|
47
60
|
### MCP plugin (Claude Code, Cursor, Claude Desktop)
|
|
48
61
|
|
|
49
|
-
The MCP server is bundled inside `composto-ai`. Install the package globally first, then register the server:
|
|
62
|
+
The MCP server is bundled inside `composto-ai`. Install the package globally first, then register the server with your client:
|
|
50
63
|
|
|
51
64
|
```bash
|
|
52
65
|
npm install -g composto-ai
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Claude Code:**
|
|
69
|
+
|
|
70
|
+
```bash
|
|
53
71
|
claude mcp add composto -- composto-mcp
|
|
54
72
|
```
|
|
55
73
|
|
|
74
|
+
**Cursor** — add to `~/.cursor/mcp.json` (or project-local `.cursor/mcp.json`):
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"composto": {
|
|
80
|
+
"command": "composto-mcp"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Then restart Cursor and verify under Settings → MCP that `composto` is green.
|
|
87
|
+
|
|
88
|
+
**Claude Desktop** — add the same block to `~/Library/Application Support/Claude/claude_desktop_config.json`.
|
|
89
|
+
|
|
56
90
|
Composto adds 5 tools to your AI assistant: `composto_ir`, `composto_benchmark`, `composto_context`, `composto_scan`, and `composto_blastradius` (the last one gated by `COMPOSTO_BLASTRADIUS=1` during beta).
|
|
57
91
|
|
|
92
|
+
#### Cursor: one-command setup
|
|
93
|
+
|
|
94
|
+
Registering the MCP server only *exposes* the tools — Cursor's agent often defaults to its built-in `read_file` / `codebase_search`. To configure both the MCP server **and** a project rule that tells the agent when to call Composto, run:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
cd your-project
|
|
98
|
+
composto init
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This writes `.cursor/mcp.json` (project-local MCP registration) and `.cursor/rules/composto.mdc` (an `alwaysApply: true` rule that gets injected into every conversation). Existing files are merged, never overwritten. Restart Cursor and check Settings → MCP that `composto` is green.
|
|
102
|
+
|
|
103
|
+
Without the rule, hit rate is ~30-50%; with it, ~85-95%. The rule template is embedded in [`src/cli/init.ts`](src/cli/init.ts) (`CURSOR_RULES_MDC`) — open the generated `.cursor/rules/composto.mdc` to customize per-project.
|
|
104
|
+
|
|
105
|
+
#### Hook-enforced injection (v0.6.0+)
|
|
106
|
+
|
|
107
|
+
Instead of asking the agent to remember to call `composto_blastradius`, wire a hook so it gets consulted **automatically** before every Edit / Write / MultiEdit. The agent receives a `<composto_blastradius>` context block in-line when verdict is `medium` or `high` — you don't do anything, the warning just shows up where it's needed.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cd your-project
|
|
111
|
+
composto init --client=claude-code # or cursor, or gemini-cli
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
This writes:
|
|
115
|
+
- The platform's MCP config (same as before)
|
|
116
|
+
- A **`PreToolUse` hook** (Claude Code / Gemini CLI) that invokes `composto hook <platform> pretooluse` on every file-targeting tool call. The hook extracts the target file, runs `composto_blastradius`, and injects the verdict as `additionalContext`. Passthrough on `low` verdict — no noise.
|
|
117
|
+
- For Cursor: a `.cursor/hooks.json` entry that **denies** the tool call on `verdict: high` (Cursor's `additional_context` is dropped per [forum #155689](https://forum.cursor.com/t/...), so hybrid strategy — the existing `.cursor/rules/composto.mdc` rule carries `medium`/`low`, the hook only interrupts on `high`).
|
|
118
|
+
|
|
119
|
+
Existing settings are merged, never overwritten. Re-running `composto init` is idempotent — no duplicate hook entries.
|
|
120
|
+
|
|
121
|
+
**Observe what's happening:**
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
composto stats # hook invocations, verdict distribution, p50/p95 latency
|
|
125
|
+
composto stats --json # machine-readable
|
|
126
|
+
composto stats --disable # opt out (writes .composto/telemetry-disabled marker)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Telemetry is **local-only** — writes to `.composto/memory.db` in your repo, nothing leaves your machine. No user ID, no cloud sync, no account.
|
|
130
|
+
|
|
131
|
+
**Platform matrix:**
|
|
132
|
+
|
|
133
|
+
| Platform | MCP | Hook | Strategy |
|
|
134
|
+
|---|:---:|:---:|---|
|
|
135
|
+
| Claude Code | ✅ | ✅ `PreToolUse` | `additionalContext` on medium\|high\|unknown, passthrough on low |
|
|
136
|
+
| Cursor | ✅ | ✅ `preToolUse` | Deny-on-high via `permissionDecision`; medium/low via `.mdc` rule |
|
|
137
|
+
| Gemini CLI | ✅ | ✅ `BeforeTool` | `additionalContext` on medium\|high\|unknown |
|
|
138
|
+
| Claude Desktop | ✅ | — | MCP-only (no hook API yet) |
|
|
139
|
+
|
|
58
140
|
---
|
|
59
141
|
|
|
60
142
|
## How It Works
|
|
@@ -106,11 +188,11 @@ composto index --status # diagnostics: schema, freshness, calibration
|
|
|
106
188
|
|
|
107
189
|
---
|
|
108
190
|
|
|
109
|
-
## BlastRadius
|
|
191
|
+
## BlastRadius
|
|
110
192
|
|
|
111
|
-
Beyond compression, Composto indexes your repo's git history into a local SQLite graph and exposes it as a queryable risk surface. Before your agent edits a file, it can ask: *"has this region been reverted?
|
|
193
|
+
Beyond compression, Composto indexes your repo's git history into a local SQLite graph and exposes it as a queryable risk surface. Before your agent edits a file, it can ask: *"has this region been reverted? who fixed the last similar bug? is the last author still around?"* — signals no LLM can infer from current code alone.
|
|
112
194
|
|
|
113
|
-
|
|
195
|
+
Four signals per query: `revert_match`, `hotspot`, `fix_ratio`, `author_churn`. Verdict is `low` / `medium` / `high` / `unknown`; when confidence is low the tool returns `unknown` rather than guessing. Precision is repo-calibrated (self-validation over the repo's own fix history).
|
|
114
196
|
|
|
115
197
|
```
|
|
116
198
|
verdict: high
|
|
@@ -122,7 +204,9 @@ signals:
|
|
|
122
204
|
...
|
|
123
205
|
```
|
|
124
206
|
|
|
125
|
-
**
|
|
207
|
+
**Where we are, honestly.** The v2.1 time-travel backtest (rewinds the DB to each pre-fix snapshot) shows `revert_match` carrying most of the product's value — it clears the ship gate on picomatch (precision 0.65, recall 0.78 on the `medium|high` band). Signal-attributed precision (excluding `revert_match`) is weaker: the three non-revert signals are alive but need calibration work. See [docs/blastradius-proof-v2.md](docs/blastradius-proof-v2.md) for numbers on all four band combinations across two public repos + the per-signal diagnostic behind them.
|
|
208
|
+
|
|
209
|
+
The honest framing: **BlastRadius is a bug-history memory layer that agents query before editing.** "This file was reverted three weeks ago" is the primary promise v1 delivers. The other signals expand the query surface — calibration work on `hotspot` and `fix_ratio` is the open follow-on.
|
|
126
210
|
|
|
127
211
|
Feature-flagged via `COMPOSTO_BLASTRADIUS=1` during the beta. Available as both CLI (`composto impact`, `composto index`) and MCP tool (`composto_blastradius`).
|
|
128
212
|
|
|
@@ -227,9 +311,10 @@ Overall compression: 89.2%
|
|
|
227
311
|
L0 compression: 97.5%
|
|
228
312
|
AST engine: 51/51 files (0 regex fallback)
|
|
229
313
|
Languages: TypeScript, JavaScript, Python, Go, Rust
|
|
230
|
-
Tests:
|
|
231
|
-
BlastRadius
|
|
232
|
-
|
|
314
|
+
Tests: 251 passing
|
|
315
|
+
BlastRadius v2.1: precision 0.65, recall 0.78 (picomatch, time-travel,
|
|
316
|
+
medium|high band). Honest signal-attributed numbers
|
|
317
|
+
in docs/blastradius-proof-v2.md.
|
|
233
318
|
```
|
|
234
319
|
|
|
235
320
|
---
|