composto-ai 0.4.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,15 +46,84 @@ composto index --status
46
46
 
47
47
  ### MCP plugin (Claude Code, Cursor, Claude Desktop)
48
48
 
49
- The MCP server is bundled inside `composto-ai`. Install the package globally first, then register the server:
49
+ The MCP server is bundled inside `composto-ai`. Install the package globally first, then register the server with your client:
50
50
 
51
51
  ```bash
52
52
  npm install -g composto-ai
53
+ ```
54
+
55
+ **Claude Code:**
56
+
57
+ ```bash
53
58
  claude mcp add composto -- composto-mcp
54
59
  ```
55
60
 
61
+ **Cursor** — add to `~/.cursor/mcp.json` (or project-local `.cursor/mcp.json`):
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "composto": {
67
+ "command": "composto-mcp"
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ Then restart Cursor and verify under Settings → MCP that `composto` is green.
74
+
75
+ **Claude Desktop** — add the same block to `~/Library/Application Support/Claude/claude_desktop_config.json`.
76
+
56
77
  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
78
 
79
+ #### Cursor: one-command setup
80
+
81
+ 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:
82
+
83
+ ```bash
84
+ cd your-project
85
+ composto init
86
+ ```
87
+
88
+ 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.
89
+
90
+ 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.
91
+
92
+ #### Hook-enforced injection (v0.6.0+)
93
+
94
+ 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.
95
+
96
+ ```bash
97
+ cd your-project
98
+ composto init --client=claude-code # or cursor, or gemini-cli
99
+ ```
100
+
101
+ This writes:
102
+ - The platform's MCP config (same as before)
103
+ - 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.
104
+ - 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`).
105
+
106
+ Existing settings are merged, never overwritten. Re-running `composto init` is idempotent — no duplicate hook entries.
107
+
108
+ **Observe what's happening:**
109
+
110
+ ```bash
111
+ composto stats # hook invocations, verdict distribution, p50/p95 latency
112
+ composto stats --json # machine-readable
113
+ composto stats --disable # opt out (writes .composto/telemetry-disabled marker)
114
+ ```
115
+
116
+ Telemetry is **local-only** — writes to `.composto/memory.db` in your repo, nothing leaves your machine. No user ID, no cloud sync, no account.
117
+
118
+ **Platform matrix:**
119
+
120
+ | Platform | MCP | Hook | Strategy |
121
+ |---|:---:|:---:|---|
122
+ | Claude Code | ✅ | ✅ `PreToolUse` | `additionalContext` on medium\|high\|unknown, passthrough on low |
123
+ | Cursor | ✅ | ✅ `preToolUse` | Deny-on-high via `permissionDecision`; medium/low via `.mdc` rule |
124
+ | Gemini CLI | ✅ | ✅ `BeforeTool` | `additionalContext` on medium\|high\|unknown |
125
+ | Claude Desktop | ✅ | — | MCP-only (no hook API yet) |
126
+
58
127
  ---
59
128
 
60
129
  ## How It Works
@@ -108,9 +177,9 @@ composto index --status # diagnostics: schema, freshness, calibration
108
177
 
109
178
  ## BlastRadius (beta)
110
179
 
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? does it have a fix cluster? is the last author still around?"* — signals no LLM can infer from current code alone.
180
+ 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
181
 
113
- Five signals per query: `revert_match`, `hotspot`, `fix_ratio`, `coverage_decline`, `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 on every N=500 commits).
182
+ 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
183
 
115
184
  ```
116
185
  verdict: high
@@ -122,7 +191,9 @@ signals:
122
191
  ...
123
192
  ```
124
193
 
125
- **v1 ship gate** on this repo: precision 93.9%, recall 100% on the `medium|high` band. Multi-repo validation pending. See [docs/blastradius-proof.md](docs/blastradius-proof.md) for the method + honest caveats.
194
+ **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.
195
+
196
+ 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
197
 
127
198
  Feature-flagged via `COMPOSTO_BLASTRADIUS=1` during the beta. Available as both CLI (`composto impact`, `composto index`) and MCP tool (`composto_blastradius`).
128
199
 
@@ -227,9 +298,10 @@ Overall compression: 89.2%
227
298
  L0 compression: 97.5%
228
299
  AST engine: 51/51 files (0 regex fallback)
229
300
  Languages: TypeScript, JavaScript, Python, Go, Rust
230
- Tests: 224 passing
231
- BlastRadius v1: precision 90-96%, recall 99-100% on 3 repos
232
- (composto, picomatch, zod; medium|high band)
301
+ Tests: 251 passing
302
+ BlastRadius v2.1: precision 0.65, recall 0.78 (picomatch, time-travel,
303
+ medium|high band). Honest signal-attributed numbers
304
+ in docs/blastradius-proof-v2.md.
233
305
  ```
234
306
 
235
307
  ---