@ruso-0/nreki 8.6.1 → 8.6.2

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
@@ -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 file.ts` dumps entire file | `nreki_code action:"read"` compresses to signatures | 60-80% fewer tokens |
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 file, and it extracts the target symbol at 100% resolution plus its causal dependencies (upstream callers, downstream deps, resolved imports, blast radius), while annihilating orthogonal "dark matter" code.
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
- ### Empirical results (benchmarked against NREKI src/ — 5 files, 15 focus probes + 15 boundary probes)
181
+ ### The Physics of TFC-Ultra (Empirically Benchmarked)
159
182
 
160
- **Operational case** (methods of medium-to-large size):
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
- | Metric | Value |
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
- **Best case boundary** (theoretical ceiling small focus inside large file):
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
- | Metric | Value |
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
- ### The Amdahl law of focused compression
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
- TFC compression ratio follows an asymptotic limit:
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
- - When the Fovea is a small getter (3 lines) inside a 1,640-line file, the numerator is minuscule vs. the denominator. **Ratio approaches 100%. Empirical ceiling: 98.2% (55x).**
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
- **This is not marketing. This is physics.** See [BENCH-TFC.md](BENCH-TFC.md) for the raw dogfooding benchmark with per-file breakdowns.
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
- ### How it works
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
- - **Fovea**: the target symbol is preserved byte-for-byte at 100% resolution
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
- ### TFC-Pro Enforcer (auto-guard on `read`)
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
- When a file exceeds 3,000 tokens and the agent tries to read it raw, NREKI's hook intercepts the call and instructs the agent to use outline + focus-driven compression instead. This eliminates context-window suicide before it happens.
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": "8.6.1",
3
+ "version": "8.6.2",
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",
@@ -1,21 +1,48 @@
1
- # NREKI Active
2
-
3
- This workspace has the NREKI MCP plugin installed. It extends your capabilities with AST-aware tools that protect your context window and prevent syntax errors before they reach disk.
4
-
5
- ## Optimal Workflow
6
-
7
- 1. **Run tests & commands freely.** Use Bash for npm test, builds, git - NREKI doesn't interfere with your terminal.
8
- 2. **Navigate with AST precision.** Prefer `nreki_navigate` over grep/glob. It returns exact structural matches (functions, classes, references) without flooding your context with noise.
9
- 3. **Read files efficiently.** ALWAYS prefer `nreki_code action:"read"` over native Read. Native Read dumps the entire file into your context - a 2,000-line file burns ~5,000 tokens in one call. `nreki_code read` auto-compresses to ~1,200 tokens while keeping all structural context. This is the single biggest token saver available to you.
10
- 4. **Debugging? Read uncompressed.** If you need to understand a function's internal logic (not just its signature), use `nreki_code action:"read" compress:false`. Compression hides function bodies to save tokens - great for navigation, but not for debugging.
11
- 5. **Edit surgically.** Prefer `nreki_code action:"edit"` for modifying existing functions/classes. It validates the AST before writing to disk - if your code has a syntax error, the file stays untouched and you get the exact line/column to fix.
12
- 6. **Multi-file refactors? Use batch_edit.** `nreki_code action:"batch_edit" edits:[...]` edits multiple files atomically. If ANY file has a syntax error, NOTHING is written to disk. All-or-nothing safety.
13
- 7. **Renaming a symbol? Use prepare_refactor first.** `nreki_navigate action:"prepare_refactor" symbol:"OldName"` analyzes every occurrence and classifies it as "high confidence" (safe to rename) or "review" (might be a string, comment, or object key). Then use batch_edit to apply the renames.
14
- 8. **Watch for blast radius warnings.** When you change a function's signature, NREKI automatically warns you which files import it. Fix those files before running tests.
15
- 9. **The repo map shows architecture tiers.** `nreki_navigate action:"map"` now classifies files as CORE (high import count - modify with caution), BUSINESS LOGIC (medium), or LEAF (safe to experiment).
16
- 10. **Create new files normally.** Use native Write for brand new files that don't exist yet.
17
- 11. **Pin rules that matter.** Use `nreki_guard action:"pin"` to persist instructions across messages (e.g., "always use fetch, not axios").
18
- 12. **Anchor your plan.** If you're working on a complex task with strict schemas or architectural constraints, use `nreki_guard action:"set_plan" text:"PLAN.md"` at the start. NREKI will silently re-inject your plan every ~15 tool calls to survive context compaction. Use `nreki_guard action:"memorize" text:"your progress notes"` to leave notes for yourself.
19
- 13. **If the circuit breaker triggers, follow its instructions.** It detected a doom loop and is protecting your session from burning tokens on repeated failures.
20
-
21
- NREKI handles the context heavy-lifting so you can focus on writing correct code on the first try.
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
+ * **NEW FILES:** Use Native `Write` ONLY for creating brand-new files.
29
+ * **RENAMING:** Run `nreki_navigate action:"prepare_refactor"` before renaming.
30
+
31
+ ## 3. 🏗️ BLAST RADIUS & ARCHITECTURE
32
+ * **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.
33
+ * **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.
34
+
35
+ ## 4. 🧠 CONTEXT SURVIVAL
36
+ * **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.
37
+ * **BREADCRUMBS:** Use `nreki_guard action:"memorize" text:"<notes>"` to save your progress state.
38
+
39
+ ## 5. 🚨 TERMINAL & SYSTEM ALERTS
40
+ * Run `npm test`, builds, and `git` normally via Bash. If logs are massive, use `nreki_code action:"filter_output"`.
41
+ * **CIRCUIT BREAKER:** If NREKI triggers the Circuit Breaker, you are in a token-burning doom loop. **STOP IMMEDIATELY.** Read the instructions.
42
+
43
+ ## 6. 🔍 ARCHITECTURAL HEALTH (Passive Radar)
44
+ * **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**.
45
+
46
+ ## 7. 🐍🐹 MULTI-LANGUAGE & LSP SIDECARS
47
+ * **NATIVE SHIELD:** NREKI natively shields TS/JS. For Go/Python, it attempts to spawn `gopls`/`pyright` for Layer 2 Semantic validation.
48
+ * **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.