@unerr-ai/unerr 0.0.0-beta.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/LICENSE ADDED
@@ -0,0 +1,47 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ ## Acceptance
4
+
5
+ By using the software, you agree to all of the terms and conditions below.
6
+
7
+ ## Copyright License
8
+
9
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below.
10
+
11
+ ## Limitations
12
+
13
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
14
+
15
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
16
+
17
+ ## Notices
18
+
19
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
20
+
21
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
22
+
23
+ ## No Other Rights
24
+
25
+ These terms do not imply any licenses other than those expressly granted in these terms.
26
+
27
+ ## Termination
28
+
29
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
30
+
31
+ ## No Liability
32
+
33
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
34
+
35
+ ## Definitions
36
+
37
+ The **licensor** is the entity offering these terms, and the **software** is the software the licensor makes available under these terms, including any portion of it.
38
+
39
+ **you** refers to the individual or entity agreeing to these terms.
40
+
41
+ **your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
42
+
43
+ **your licenses** are all the licenses granted to you for the software under these terms.
44
+
45
+ **use** means anything you do with the software requiring one of your licenses.
46
+
47
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,301 @@
1
+ <p align="center">
2
+ <img src="public/icon-wordmark.svg" alt="unerr" width="320" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>Lands your AI agent at the right code in fewer turns, tokens, & breakages.</strong>
7
+ </p>
8
+
9
+ <p align="center">
10
+ Local code intelligence that gives your AI agent a graph of your entire codebase.<br/>
11
+ It stops looping, stops re-reading, stops breaking things it can't see.
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="#get-started"><img src="https://img.shields.io/badge/install-npx_@unerr/unerr-8B5CF6?style=flat-square&logo=npm" alt="Install" /></a>
16
+ <img src="https://img.shields.io/badge/runtime-Node.js_≥20-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node.js" />
17
+ <img src="https://img.shields.io/badge/protocol-MCP-7C3AED?style=flat-square" alt="MCP" />
18
+ <img src="https://img.shields.io/badge/tests-1455_passing-34D399?style=flat-square" alt="Tests" />
19
+ <img src="https://img.shields.io/badge/license-ELv2-A1A1AA?style=flat-square" alt="License" />
20
+ </p>
21
+
22
+ <p align="center">
23
+ <code>npx @unerr/unerr</code>
24
+ </p>
25
+
26
+ ---
27
+
28
+ ## Your agent loops because it's blind
29
+
30
+ You've seen it. You ask Claude or Cursor to refactor a function. It reads 30 files to find the call graph. It misses 14 downstream callers. It re-discovers conventions you told it yesterday. It tries a broken approach, fails, tries again — burning tokens while you watch.
31
+
32
+ **The agent isn't stupid. It's blind.**
33
+
34
+ - It can't see that `processPayment()` has 40 callers across 3 services
35
+ - It doesn't know your team uses `fetch` prefixes, not `get`
36
+ - It forgot everything from yesterday's session
37
+
38
+ unerr gives it a graph. Every caller, every dependency, every convention. The agent lands at the right code instead of searching for it.
39
+
40
+ ---
41
+
42
+ ## What happens when you run it
43
+
44
+ ```bash
45
+ npx @unerr/unerr
46
+ ```
47
+
48
+ **5 seconds later**, your agent has:
49
+
50
+ | Before unerr | After unerr |
51
+ |:---|:---|
52
+ | Reads 30 files to understand a call graph | Queries the graph in 5ms |
53
+ | Misses downstream callers, breaks things | Sees full blast radius before editing |
54
+ | Re-derives conventions every session | Knows your patterns, enforces them |
55
+ | Session degrades at 70% context fill | Stays sharp — 93% shell compression, context lasts 3-5x longer |
56
+ | Starts from zero tomorrow | Resumes where it left off |
57
+
58
+ ```
59
+ unerr session (12 min)
60
+ Tool calls 47 (all local, <5ms each)
61
+ Tokens saved ~120K (93% shell compression + graph-targeted reads)
62
+ Turns saved ~8 (approaches that would have failed, prevented)
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Get Started
68
+
69
+ ```bash
70
+ npx @unerr/unerr
71
+ ```
72
+
73
+ That's it. Auto-detects your IDE, indexes your codebase (~30s), starts serving intelligence via MCP.
74
+
75
+ ### Add to more agents
76
+
77
+ ```bash
78
+ unerr install claude-code # .mcp.json + .claude/skills/ + PreToolUse hook
79
+ unerr install cursor # .cursor/mcp.json + .cursor/rules/
80
+ unerr install vscode # .vscode/mcp.json + .github/copilot/
81
+ unerr install windsurf # .windsurf/mcp.json + .windsurf/rules/
82
+ unerr install zed # .zed/mcp.json
83
+ unerr install codex # .codex/mcp.json
84
+ unerr install gemini-cli # .gemini/settings.json
85
+ unerr install kiro # .kiro/mcp.json
86
+ unerr install aider # .aider/mcp.json
87
+ unerr install continue # .continue/config.json
88
+ ```
89
+
90
+ Works with any MCP-compatible agent. 15 supported out of the box.
91
+
92
+ <details>
93
+ <summary>Manual MCP config (any agent)</summary>
94
+
95
+ ```json
96
+ {
97
+ "mcpServers": {
98
+ "unerr": {
99
+ "command": "npx",
100
+ "args": ["@unerr/unerr", "--mcp"]
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ </details>
107
+
108
+ ---
109
+
110
+ ## What you get
111
+
112
+ ### Instant (first session)
113
+
114
+ - **Graph navigation** — `get_callers` · `get_callees` · `get_imports` · `search_code` in <5ms. The agent stops reading 30 files to find one function.
115
+ - **Blast radius** — before editing, the agent sees every downstream dependency. No more confident wrong changes.
116
+ - **Smart file reads** — `file_read({entity: "functionName"})` returns just that function + context. Not 2000 lines.
117
+ - **Shell compression** — 10 strategies, 645 command classifiers. Diffs, errors, logs, test results, key-value, tabular — each compressed differently. **93% average compression** across real-world benchmarks (2MB → 138KB).
118
+ - **Full output recovery** — when compression is significant, raw output is saved to disk with a recovery path. The agent can always access the original.
119
+ - **Convention awareness** — auto-detected naming, structure, and import patterns injected into agent context.
120
+
121
+ ### Compounding (session 2+)
122
+
123
+ - **Session persistence** — the agent tomorrow knows what the agent learned today. No more starting from zero.
124
+ - **Convention enforcement** — patterns detected in session 1 are enforced in session 5. No manual `.cursorrules` maintenance.
125
+ - **Anti-pattern rules** — when you revert bad code, unerr learns. That mistake never happens again.
126
+ - **Durability scoring** — code that keeps getting rewritten gets flagged before the agent touches it.
127
+ - **Loop prevention** — circuit breaker fires after repeated failed attempts.
128
+
129
+ ### Shell compression benchmarks
130
+
131
+ Every shell command the agent runs is classified (645 command patterns + content heuristics) and compressed with the best-fit strategy:
132
+
133
+ | Strategy | What it compresses | Avg compression |
134
+ |----------|-------------------|:-:|
135
+ | **diff** | `git diff`, patch output | **99%** |
136
+ | **structured** | JSON APIs, `docker inspect` | **97%** |
137
+ | **progress** | `npm install`, `pip install` | **95%** |
138
+ | **log_text** | Build logs, server logs, `make`, `cargo build` | **89%** |
139
+ | **test_results** | `vitest`, `pytest`, `cargo test`, `playwright` | **80%** |
140
+ | **tabular** | `ps aux`, `docker ps`, `kubectl get` | **77%** |
141
+ | **error_diagnostic** | `tsc`, `eslint`, `rustc`, `shellcheck` | **72%** |
142
+ | **key_value** | `env`, `kubectl describe`, `systemctl status` | **48%** |
143
+ | **tree_paths** | `find`, `tree`, `ls -R` | **42%** |
144
+ | **omni** | Fallback for unrecognized output | adaptive |
145
+
146
+ **Overall: 93% compression** (2MB → 138KB across 40 real-world test cases). Low-confidence classifications use smart fallback — tries both the best-guess strategy and generic compression, picks whichever saves more tokens.
147
+
148
+ ### Language support
149
+
150
+ | Language | Entity Extraction | Edge Extraction | Tree-sitter AST | SCIP |
151
+ |----------|:-:|:-:|:-:|:-:|
152
+ | TypeScript | ✓ | ✓ | ✓ | ✓ |
153
+ | JavaScript | ✓ | ✓ | ✓ | ✓ |
154
+ | Python | ✓ | ✓ | ✓ | ✓ |
155
+ | Go | ✓ | ✓ | ✓ | ✓ |
156
+ | Java | ✓ | ✓ | ✓ | ✓ |
157
+ | Rust | ✓ | ✓ | ✓ | ✓ |
158
+ | C# | ✓ | ✓ | ✓ | — |
159
+ | C / C++ | ✓ | ✓ | ✓ | — |
160
+ | Ruby | ✓ | ✓ | ✓ | — |
161
+ | PHP | ✓ | ✓ | ✓ | — |
162
+ | Kotlin | ✓ | ✓ | ✓ | — |
163
+ | Swift | ✓ | ✓ | ✓ | — |
164
+
165
+ All 13 languages get full regex-based entity extraction (functions, classes, interfaces, methods with `parent_class` detection) and tree-sitter AST extraction when WASM grammars are available. SCIP integration provides compiler-verified call graphs for TypeScript, Python, Go, Java, and Rust.
166
+
167
+ ---
168
+
169
+ ## How it works
170
+
171
+ ```
172
+ AI Agent (Claude Code / Cursor / VS Code / Windsurf / any MCP client)
173
+
174
+ ├── MCP tools ──→ unerr ──→ CozoDB graph (in-process, <5ms)
175
+ │ │
176
+ │ ├── Convention engine (auto-detects patterns)
177
+ │ ├── Session ledger (cross-session memory)
178
+ │ ├── Token budgeter (prevents context rot)
179
+ │ └── Compression engine (10 strategies, 645 classifiers)
180
+
181
+ └── CLI hooks ──→ Output compression ──→ Graph-aware prioritization
182
+ ```
183
+
184
+ One process. Fully local. No API keys. No network calls. No cloud.
185
+
186
+ ---
187
+
188
+ ## MCP Tools (17)
189
+
190
+ | Tool | What the agent gets |
191
+ |------|-----|
192
+ | `get_function` | Function body + callers + blast radius + applicable conventions |
193
+ | `get_class` | Class with inheritance, methods, and dependents |
194
+ | `get_file` | All entities, imports, exports, risk summary |
195
+ | `get_callers` | Every caller with file location and risk level |
196
+ | `get_callees` | All downstream dependencies |
197
+ | `get_imports` | Import/dependency graph |
198
+ | `search_code` | Graph-ranked full-text search |
199
+ | `get_rules` | Active rules for a path |
200
+ | `check_rules` | Evaluate rules — returns violations |
201
+ | `get_conventions` | Naming, structure, import conventions |
202
+ | `get_god_nodes` | High fan-in chokepoints |
203
+ | `get_surprising_connections` | Unexpected cross-module dependencies |
204
+ | `file_read` | Entity-targeted reads (not full file dumps) |
205
+ | `file_outline` | File structure without content |
206
+
207
+ Every response includes `_meta` (latency, risk level, drift status) and contextual warnings.
208
+
209
+ ---
210
+
211
+ <details>
212
+ <summary><strong>Commands</strong></summary>
213
+
214
+ ```bash
215
+ unerr # Start MCP proxy (auto-started by IDE via MCP config)
216
+ unerr status # Graph stats, health grade, active rules
217
+ unerr stats # Session and weekly efficiency metrics
218
+ unerr install <agent> # Add unerr to a specific AI coding agent
219
+ unerr init # Initialize unerr in a new project
220
+ unerr timeline # What happened across sessions
221
+ unerr rewind # Restore to a previous working state
222
+ unerr learn # Teach unerr a convention or correction
223
+ unerr debug # Diagnostic dump
224
+ ```
225
+
226
+ </details>
227
+
228
+ <details>
229
+ <summary><strong>Architecture</strong></summary>
230
+
231
+ ```
232
+ src/
233
+ entrypoints/ CLI entry + state machine
234
+ intelligence/ CozoDB graph, AST, conventions, rules, search
235
+ proxy/ MCP server, compression, session stats, token tracking
236
+ tracking/ Prompt ledger, drift detection, git attribution
237
+ commands/ CLI commands
238
+ tools/ MCP tool implementations
239
+ behaviors/ Agent behavior modules (cascade guard, loop breaker)
240
+ config/ Agent registry, MCP config writer
241
+ schemas/ Zod schemas
242
+ utils/ Logging, detection, git helpers
243
+ ```
244
+
245
+ **Design principles:**
246
+ - Zero network calls — fully local, no API keys
247
+ - stdout is sacred — MCP JSON-RPC only, everything else to stderr
248
+ - <5ms query responses — CozoDB runs in-process (Rust via NAPI)
249
+ - 30s time-to-value — shallow index first, deep enrichment in background
250
+ - Enhancement, not dependency — agent falls back gracefully if unerr is unavailable
251
+
252
+ **Tech stack:** TypeScript (ESM) · CozoDB (Rust/NAPI) · web-tree-sitter (WASM) · MCP SDK · Ink (React CLI) · tsup · Vitest
253
+
254
+ </details>
255
+
256
+ <details>
257
+ <summary><strong>Development</strong></summary>
258
+
259
+ ```bash
260
+ pnpm install
261
+ pnpm run build # tsup → dist/ (ESM, node20)
262
+ pnpm run dev # tsx watch
263
+ pnpm run test:run # full suite (1455 tests)
264
+ pnpm run lint # biome check
265
+ pnpm run typecheck # tsc --noEmit
266
+ ```
267
+
268
+ ```bash
269
+ pnpm link --global # make `unerr` available globally
270
+ ```
271
+
272
+ </details>
273
+
274
+ <details>
275
+ <summary><strong>Contributing</strong></summary>
276
+
277
+ Contributions welcome. Please open an issue first.
278
+
279
+ **Before submitting a PR:**
280
+ - Run `pnpm run typecheck && pnpm run lint && pnpm run test:run`
281
+ - All output goes to stderr — never stdout (MCP JSON-RPC channel)
282
+ - All CozoDB interactions are async — always `await`
283
+ - Use `.js` extensions in imports (NodeNext resolution)
284
+
285
+ See [CLAUDE.md](./CLAUDE.md) for detailed conventions.
286
+
287
+ </details>
288
+
289
+ ---
290
+
291
+ ## License
292
+
293
+ [Elastic License 2.0 (ELv2)](./LICENSE) — free to use, modify, and distribute. Cannot be offered as a hosted service.
294
+
295
+ ---
296
+
297
+ <p align="center">
298
+ <code>npx @unerr/unerr</code>
299
+ <br /><br />
300
+ <sub>One command. No cloud. No account. Free.</sub>
301
+ </p>
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node