@ruso-0/nreki 8.6.1 → 9.0.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 +52 -38
- package/package.json +1 -1
- package/templates/CLAUDE.md +55 -21
package/README.md
CHANGED
|
@@ -47,11 +47,27 @@ npx @ruso-0/nreki init
|
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
+
## ⚡ The "Zero-Config" Promise (80% of the value instantly)
|
|
51
|
+
|
|
52
|
+
NREKI is designed to be plug-and-play. You don't need a PhD in graph theory to use it.
|
|
53
|
+
|
|
54
|
+
Out of the box, NREKI automatically provides:
|
|
55
|
+
|
|
56
|
+
1. **Tree-sitter AST Shield (Layer 1):** Instantly catches missing commas, unclosed brackets, and hallucinated syntax in TS, JS, Python, and Go *before* they hit your disk. Zero native dependencies.
|
|
57
|
+
2. **TypeScript VFS (Layer 2):** Full cross-file type checking and CodeFix Auto-Healing in RAM using your existing `tsconfig.json`.
|
|
58
|
+
3. **TFC-Ultra Compression:** Bounding parafoveal overhead to O(1), saving 85-98% of tokens on file reads while keeping the LLM laser-focused on the exact method it needs to edit.
|
|
59
|
+
|
|
60
|
+
**What about Go and Python LSPs? (Graceful Degradation)**
|
|
61
|
+
|
|
62
|
+
If you happen to have `gopls` or `pyright` in your PATH, NREKI will silently detect them and upgrade Go/Python to Layer 2 (Cross-file semantics & LSP Auto-Healing). **If you don't have them, NREKI gracefully degrades to Layer 1.** Your agent never breaks. You get the core value with zero installation friction.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
50
66
|
## What It Actually Does
|
|
51
67
|
|
|
52
68
|
| Without NREKI | With NREKI | Result |
|
|
53
69
|
|---------------|-----------|--------|
|
|
54
|
-
| `cat
|
|
70
|
+
| `cat huge_file.ts` (burns 20k tokens) | `compress focus:"<method>"` (TFC-Ultra) | **82% to 98.2% Token Savings** |
|
|
55
71
|
| Agent writes broken code to disk | Edit validated in RAM before write | Zero broken files on disk |
|
|
56
72
|
| Error -> read output -> guess fix -> retry -> repeat | Auto-Healing fixes structural errors in RAM | Zero doom loop tokens |
|
|
57
73
|
| Agent manages 16+ tool calls | 3 tools, 20 actions | 85% less tool overhead |
|
|
@@ -62,6 +78,13 @@ npx @ruso-0/nreki init
|
|
|
62
78
|
|
|
63
79
|
---
|
|
64
80
|
|
|
81
|
+
## 🔬 Pro Features: Architecture Intelligence
|
|
82
|
+
*(For Staff Engineers, Tech Leads, and complex refactors)*
|
|
83
|
+
|
|
84
|
+
Under the hood, NREKI doesn't just read text; it builds a mathematical graph of your repository. It computes the combinatorial Laplacian of the file-level dependency graph to unlock advanced architectural insights that act as a passive radar for your team. **You don't need to understand any of this to get the Zero-Config benefits above** — these features kick in when you opt-in to them for complex refactors.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
65
88
|
## What's New in v8 (Antigravity)
|
|
66
89
|
|
|
67
90
|
### Spectral Clustering
|
|
@@ -149,61 +172,50 @@ True topological circuit rank via Union-Find on the type constraint graph. `beta
|
|
|
149
172
|
|
|
150
173
|
## What's New in v8.6 (TFC-Ultra)
|
|
151
174
|
|
|
152
|
-
**Topological Foveal Compression** — Hyper-causal context sculpting for frontier LLMs. Point TFC-Ultra at a specific method or function inside a
|
|
175
|
+
**Topological Foveal Compression (TFC-Ultra)** — Hyper-causal context sculpting for frontier LLMs (Opus 4.6 / Gemini 3.1 Pro). Point TFC-Ultra at a specific method or function inside a monolith, and it extracts the target symbol at 100% resolution plus its causal dependencies (upstream callers, downstream deps, resolved external imports, blast radius), while annihilating orthogonal "dark matter" code.
|
|
153
176
|
|
|
154
177
|
```bash
|
|
155
178
|
nreki_code action:"compress" path:"src/huge-file.ts" focus:"criticalMethod"
|
|
156
179
|
```
|
|
157
180
|
|
|
158
|
-
###
|
|
181
|
+
### The Physics of TFC-Ultra (Empirically Benchmarked)
|
|
159
182
|
|
|
160
|
-
|
|
183
|
+
We benchmarked TFC against NREKI's own `src/` directory (15 focus probes on operational methods, plus 15 boundary probes on minimal getters). No marketing fluff. Just math.
|
|
161
184
|
|
|
162
|
-
|
|
163
|
-
|--------|-------|
|
|
164
|
-
| **Avg compression** | **82.2%** (~5.6x) |
|
|
165
|
-
| **p50 compression** | **84.8%** |
|
|
166
|
-
| **p95 compression** | **89.9%** (~10x) |
|
|
167
|
-
| **Advantage vs legacy tier-3** | **+9.8pp** (consistent) |
|
|
168
|
-
| **Fovea fidelity** | **100%** — target symbol preserved verbatim for zero-loss reasoning |
|
|
169
|
-
| **True LRU AST cache** | **34x avg speedup**, **137x in extreme cases** (1,819ms → 13.3ms on 82 KB file) |
|
|
170
|
-
| **Fallback rate (Density Shield)** | **13.3%** — when TFC can't beat 15% compression, falls through to legacy aggressive |
|
|
185
|
+
**The Asymptotic Boundary (Theoretical Ceiling):**
|
|
171
186
|
|
|
172
|
-
|
|
187
|
+
- **Max Compression Observed: 98.2% (55x)**
|
|
188
|
+
- **Context:** Focus on a 3-line getter (`isBooted`) inside an 82 KB, 1,640-line monolith (`nreki-kernel.ts`). 1,605 orthogonal lines annihilated.
|
|
189
|
+
- **The Amdahl Law of Context:** The compression ratio scales inversely with the focus-to-file size ratio. The larger the monolith and the smaller the target, the more devastating the compression.
|
|
173
190
|
|
|
174
|
-
|
|
175
|
-
|--------|-------|
|
|
176
|
-
| **Max compression observed** | **98.2%** (**55x**) |
|
|
177
|
-
| **Context** | focus `isBooted` (3-line getter) inside `nreki-kernel.ts` (82 KB, 1,640 lines) |
|
|
178
|
-
| **Boundary probes** | 15 (top-3 smallest symbols per file), **0 fallbacks**, compression range: **30x–55x** |
|
|
191
|
+
**The Operational Case (Medium-to-large methods):**
|
|
179
192
|
|
|
180
|
-
|
|
193
|
+
- **Avg Compression: 82.2%** (~5.6x smaller)
|
|
194
|
+
- **p95 Compression: 89.9%** (~10x smaller)
|
|
195
|
+
- **Fovea Fidelity: 100%** — Target symbol preserved verbatim for zero-loss reasoning.
|
|
196
|
+
- **LRU Cache Speedup: 33x faster on average** (1,819ms → 11.7ms) via True LRU AST Cache. **142x in extreme cases.**
|
|
181
197
|
|
|
182
|
-
|
|
198
|
+
### Zero-Regression Density Shield
|
|
183
199
|
|
|
184
|
-
|
|
185
|
-
Ratio ≈ 1 − (Preamble + Fovea + Markov_Mantle_O(1)) / TotalFileSize
|
|
186
|
-
```
|
|
200
|
+
What happens if the LLM gets lazy and aims TFC at a 1,500-line "God Class"? The parafoveal overhead (callers, deps, metadata) would make the output larger than reading the file raw.
|
|
187
201
|
|
|
188
|
-
-
|
|
189
|
-
- When the Fovea is a large operational method (500 lines), the numerator grows. **Ratio drops to 70-80%.** Still preserves 100% of the causal information the agent needs.
|
|
190
|
-
- When the Fovea is a God Class (entire file), the numerator **exceeds** the denominator due to parafovea overhead. **The Density Shield detects this and falls through to legacy aggressive**, guaranteeing the output is never worse than baseline.
|
|
202
|
+
TFC-Ultra prevents this. If it cannot mathematically guarantee at least **15% real compression** (ratio < 0.85), it aborts silently in RAM and gracefully degrades to the Legacy Aggressive compressor. **The user never receives an output worse than the baseline.**
|
|
191
203
|
|
|
192
|
-
|
|
204
|
+
### Prompt Cache Inversion
|
|
205
|
+
|
|
206
|
+
TFC-Ultra forces a topological inversion of the output:
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
[Static Preamble] -> [Dark Matter Tombstones] -> [External Contracts] -> [Upstream/Downstream] -> [VOLATILE FOVEA]
|
|
210
|
+
```
|
|
193
211
|
|
|
194
|
-
|
|
212
|
+
By placing the volatile target code at the absolute bottom of the payload, the top 90% of the prompt remains static across subsequent iterative edits. This guarantees **Anthropic Prefix Cache hits**, saving users up to **90% in API costs**.
|
|
195
213
|
|
|
196
|
-
|
|
197
|
-
- **Upstream vectorial collapse** (O(1)): N local callers condensed to a single line of names
|
|
198
|
-
- **Downstream event horizon** (O(1)): top-10 local dependencies + `cleanSignature` to strip JSDoc waste
|
|
199
|
-
- **External parafovea**: BM25-resolved signatures of imported symbols used inside the fovea
|
|
200
|
-
- **Blast radius**: dependents from the project-wide import graph
|
|
201
|
-
- **Dark matter**: everything else in the file is omitted as a single annotation line
|
|
202
|
-
- **Density Shield 0.85**: if TFC can't achieve ≥15% real compression (e.g. when the agent aims at a God Class and pulls the entire file into the fovea), the compressor returns `null` and the system falls through to the legacy aggressive compressor — **mathematically guarantees you never perform worse than baseline**
|
|
214
|
+
### TFC-Pro Enforcer (Cognitive Bouncer)
|
|
203
215
|
|
|
204
|
-
|
|
216
|
+
When a file exceeds 3,000 tokens and the agent tries to read it raw, NREKI's `PreToolUseHook` intercepts the call, blocking context-window suicide. It forces the agent to use outline + focus-driven compression instead.
|
|
205
217
|
|
|
206
|
-
|
|
218
|
+
**This is not marketing. This is physics.** See [BENCH-TFC.md](BENCH-TFC.md) for the raw dogfooding benchmark with per-file breakdowns.
|
|
207
219
|
|
|
208
220
|
---
|
|
209
221
|
|
|
@@ -440,6 +452,8 @@ Re-injects 4-layer session state every ~15 tool calls to survive context compact
|
|
|
440
452
|
|--------|-------|
|
|
441
453
|
| Tests | 713 (44 suites) |
|
|
442
454
|
| Architecture Health Index | 9.7/10 (self-scored) |
|
|
455
|
+
| **Max TFC-Ultra Compression** | **98.2% (55x)** |
|
|
456
|
+
| **TFC LRU Cache Speedup** | **34x avg (11.7ms latency)** |
|
|
443
457
|
| Languages | 4 (TypeScript, JavaScript, Go, Python) |
|
|
444
458
|
| Failure modes sealed | 32 (P1-P32) |
|
|
445
459
|
| Audit findings resolved | 30/30 + 22 additional |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruso-0/nreki",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "MCP plugin that validates AI agent edits in RAM before they touch disk. Spectral clustering, architecture diffs, bridge detection, dead code oracle, and cross-file semantic checks for TypeScript, Go (gopls), and Python (pyright). Zero cloud dependencies.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
package/templates/CLAUDE.md
CHANGED
|
@@ -1,21 +1,55 @@
|
|
|
1
|
-
# NREKI
|
|
2
|
-
|
|
3
|
-
This workspace
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
1. **
|
|
8
|
-
2. **
|
|
9
|
-
3.
|
|
10
|
-
4.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
# 🛡️ NREKI SYSTEM ACTIVE: AI DIRECTIVES
|
|
2
|
+
|
|
3
|
+
This workspace is protected by NREKI, an AST-aware context firewall.
|
|
4
|
+
|
|
5
|
+
## 0. 🚨 EMERGENCY FALLBACK (MCP FAILURE)
|
|
6
|
+
If the `nreki_*` tools fail to load, timeout, or return connection errors:
|
|
7
|
+
1. **DO NOT PANIC or freeze.**
|
|
8
|
+
2. **TEMPORARILY SUSPEND** the "NEVER use Native Read/Write" rules below.
|
|
9
|
+
3. Fall back to your native `Read File`, `Write`, and `Replace` tools to complete the task.
|
|
10
|
+
4. Inform the user: *"NREKI connection lost. Proceeding with native tools (AST safety disabled)."*
|
|
11
|
+
|
|
12
|
+
*(Assuming NREKI is online, strictly obey the following laws):*
|
|
13
|
+
|
|
14
|
+
## 1. 📖 READING & DISCOVERY (The TFC-Ultra Protocol)
|
|
15
|
+
* **NEVER use Native `Read File` for existing files** (unless in Emergency Fallback). It dumps raw text, triggers "Attention Sinks", and burns context.
|
|
16
|
+
* **MANDATORY TFC-ULTRA FOR EDITS:** To understand or edit a specific logic block in a large file (>3000 tokens):
|
|
17
|
+
1. Run `nreki_navigate action:"outline" path:"<file>"` to map the structure.
|
|
18
|
+
2. Identify the exact **METHOD or FUNCTION** you need (DO NOT target entire classes).
|
|
19
|
+
3. Run `nreki_code action:"compress" path:"<file>" focus:"<method_name>"`.
|
|
20
|
+
*NREKI will isolate your target at 100% resolution, resolve causal dependencies, and annihilate up to 98% of orthogonal noise.*
|
|
21
|
+
* **GENERAL EXPLORATION:** If skimming a smaller file, use `nreki_code action:"read"`.
|
|
22
|
+
* **NAVIGATION:** Do not use grep/glob. Use `nreki_navigate` (`search`, `definition`, `references`, `outline`, `map`) for zero-noise discovery.
|
|
23
|
+
|
|
24
|
+
## 2. ✍️ SURGICAL EDITING & REFACTORING
|
|
25
|
+
* **NEVER use Native `Write` or `Replace` to modify existing files.** It bypasses the RAM safety shield.
|
|
26
|
+
* **SINGLE EDITS:** ALWAYS use `nreki_code action:"edit" symbol:"<Name>"`.
|
|
27
|
+
* **MULTI-FILE EDITS:** ALWAYS use `nreki_code action:"batch_edit"`. It is a strict ACID transaction.
|
|
28
|
+
* **PATCH MODE (Minimum Output Tokens):** For ANY edit that changes less than 30% of a symbol's body,
|
|
29
|
+
you **MUST** use `mode:"patch"` with `search_text` and `replace_text`.
|
|
30
|
+
**NEVER** rewrite an entire function to change a single line. Output tokens are 5x more expensive than input.
|
|
31
|
+
* **CRITICAL FOR PATCH:** Your `search_text` must be an EXACT substring of the existing AST node,
|
|
32
|
+
including exact whitespace and indentation. If patch fails, NREKI returns a preview of the actual AST content.
|
|
33
|
+
* **SCAFFOLDING EXCEPTION:** When creating BRAND NEW files from scratch, use Native `Write`.
|
|
34
|
+
New files have nothing pre-existing to break. NREKI `edit`/`batch_edit` is for modifying existing code only.
|
|
35
|
+
* **NEW FILES:** Use Native `Write` ONLY for creating brand-new files.
|
|
36
|
+
* **RENAMING:** Run `nreki_navigate action:"prepare_refactor"` before renaming.
|
|
37
|
+
|
|
38
|
+
## 3. 🏗️ BLAST RADIUS & ARCHITECTURE
|
|
39
|
+
* **RESPECT THE BLAST RADIUS:** When changing a signature, NREKI warns you of downstream dependent files. You **MUST** fix them in the SAME `batch_edit` transaction.
|
|
40
|
+
* **AUTO-HEALER:** If NREKI injects an import or fixes syntax, it will notify you: `[Auto-Heal applied]`. **DO NOT PANIC.** Do not manually revert it.
|
|
41
|
+
|
|
42
|
+
## 4. 🧠 CONTEXT SURVIVAL
|
|
43
|
+
* **ANCHOR PLANS:** Start complex tasks with `nreki_guard action:"set_plan" text:"PLAN.md"`. NREKI silently re-injects this plan every ~15,000 tokens so you never forget it.
|
|
44
|
+
* **BREADCRUMBS:** Use `nreki_guard action:"memorize" text:"<notes>"` to save your progress state.
|
|
45
|
+
|
|
46
|
+
## 5. 🚨 TERMINAL & SYSTEM ALERTS
|
|
47
|
+
* Run `npm test`, builds, and `git` normally via Bash. If logs are massive, use `nreki_code action:"filter_output"`.
|
|
48
|
+
* **CIRCUIT BREAKER:** If NREKI triggers the Circuit Breaker, you are in a token-burning doom loop. **STOP IMMEDIATELY.** Read the instructions.
|
|
49
|
+
|
|
50
|
+
## 6. 🔍 ARCHITECTURAL HEALTH (Passive Radar)
|
|
51
|
+
* **THE RULE:** NREKI monitors the codebase for "God Files" (Bus Factor) and "Spaghetti Code" (Coupling). If your refactor triggers a CRITICAL alert in an audit, treat it as a strong architectural hint to decouple, but **prioritize fixing syntax/logic first**.
|
|
52
|
+
|
|
53
|
+
## 7. 🐍🐹 MULTI-LANGUAGE & LSP SIDECARS
|
|
54
|
+
* **NATIVE SHIELD:** NREKI natively shields TS/JS. For Go/Python, it attempts to spawn `gopls`/`pyright` for Layer 2 Semantic validation.
|
|
55
|
+
* **MISSING BINARY?** If an LSP is not installed, NREKI gracefully degrades to Layer 1 (Syntax-Only AST Validation). **DO NOT PANIC.** Do NOT ask the user to install them. Acknowledge the downgrade silently and proceed with syntax-level confidence.
|