@ruso-0/nreki 6.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/CHANGELOG.md +648 -0
- package/LICENSE +21 -0
- package/README.md +425 -0
- package/dist/ast-navigator.d.ts +29 -0
- package/dist/ast-navigator.d.ts.map +1 -0
- package/dist/ast-navigator.js +279 -0
- package/dist/ast-navigator.js.map +1 -0
- package/dist/ast-sandbox.d.ts +74 -0
- package/dist/ast-sandbox.d.ts.map +1 -0
- package/dist/ast-sandbox.js +242 -0
- package/dist/ast-sandbox.js.map +1 -0
- package/dist/chronos-memory.d.ts +69 -0
- package/dist/chronos-memory.d.ts.map +1 -0
- package/dist/chronos-memory.js +247 -0
- package/dist/chronos-memory.js.map +1 -0
- package/dist/circuit-breaker.d.ts +107 -0
- package/dist/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker.js +330 -0
- package/dist/circuit-breaker.js.map +1 -0
- package/dist/compressor-advanced.d.ts +80 -0
- package/dist/compressor-advanced.d.ts.map +1 -0
- package/dist/compressor-advanced.js +555 -0
- package/dist/compressor-advanced.js.map +1 -0
- package/dist/compressor.d.ts +81 -0
- package/dist/compressor.d.ts.map +1 -0
- package/dist/compressor.js +227 -0
- package/dist/compressor.js.map +1 -0
- package/dist/database.d.ts +169 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +1029 -0
- package/dist/database.js.map +1 -0
- package/dist/embedder.d.ts +73 -0
- package/dist/embedder.d.ts.map +1 -0
- package/dist/embedder.js +165 -0
- package/dist/embedder.js.map +1 -0
- package/dist/engine.d.ts +224 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +582 -0
- package/dist/engine.js.map +1 -0
- package/dist/hologram/harvester.d.ts +41 -0
- package/dist/hologram/harvester.d.ts.map +1 -0
- package/dist/hologram/harvester.js +129 -0
- package/dist/hologram/harvester.js.map +1 -0
- package/dist/hologram/shadow-cache.d.ts +49 -0
- package/dist/hologram/shadow-cache.d.ts.map +1 -0
- package/dist/hologram/shadow-cache.js +165 -0
- package/dist/hologram/shadow-cache.js.map +1 -0
- package/dist/hologram/shadow-generator.d.ts +32 -0
- package/dist/hologram/shadow-generator.d.ts.map +1 -0
- package/dist/hologram/shadow-generator.js +828 -0
- package/dist/hologram/shadow-generator.js.map +1 -0
- package/dist/hooks/preToolUse.d.ts +63 -0
- package/dist/hooks/preToolUse.d.ts.map +1 -0
- package/dist/hooks/preToolUse.js +103 -0
- package/dist/hooks/preToolUse.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +367 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/kernel-manager.d.ts +52 -0
- package/dist/kernel/kernel-manager.d.ts.map +1 -0
- package/dist/kernel/kernel-manager.js +197 -0
- package/dist/kernel/kernel-manager.js.map +1 -0
- package/dist/kernel/kernel-worker.d.ts +9 -0
- package/dist/kernel/kernel-worker.d.ts.map +1 -0
- package/dist/kernel/kernel-worker.js +76 -0
- package/dist/kernel/kernel-worker.js.map +1 -0
- package/dist/kernel/nreki-kernel.d.ts +244 -0
- package/dist/kernel/nreki-kernel.d.ts.map +1 -0
- package/dist/kernel/nreki-kernel.js +1656 -0
- package/dist/kernel/nreki-kernel.js.map +1 -0
- package/dist/middleware/circuit-breaker.d.ts +32 -0
- package/dist/middleware/circuit-breaker.d.ts.map +1 -0
- package/dist/middleware/circuit-breaker.js +160 -0
- package/dist/middleware/circuit-breaker.js.map +1 -0
- package/dist/middleware/file-lock.d.ts +33 -0
- package/dist/middleware/file-lock.d.ts.map +1 -0
- package/dist/middleware/file-lock.js +55 -0
- package/dist/middleware/file-lock.js.map +1 -0
- package/dist/middleware/validator.d.ts +26 -0
- package/dist/middleware/validator.d.ts.map +1 -0
- package/dist/middleware/validator.js +39 -0
- package/dist/middleware/validator.js.map +1 -0
- package/dist/monitor.d.ts +94 -0
- package/dist/monitor.d.ts.map +1 -0
- package/dist/monitor.js +221 -0
- package/dist/monitor.js.map +1 -0
- package/dist/parser-pool.d.ts +28 -0
- package/dist/parser-pool.d.ts.map +1 -0
- package/dist/parser-pool.js +81 -0
- package/dist/parser-pool.js.map +1 -0
- package/dist/parser.d.ts +91 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +311 -0
- package/dist/parser.js.map +1 -0
- package/dist/pin-memory.d.ts +35 -0
- package/dist/pin-memory.d.ts.map +1 -0
- package/dist/pin-memory.js +161 -0
- package/dist/pin-memory.js.map +1 -0
- package/dist/repo-map.d.ts +81 -0
- package/dist/repo-map.d.ts.map +1 -0
- package/dist/repo-map.js +550 -0
- package/dist/repo-map.js.map +1 -0
- package/dist/router.d.ts +102 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +1989 -0
- package/dist/router.js.map +1 -0
- package/dist/semantic-edit.d.ts +82 -0
- package/dist/semantic-edit.d.ts.map +1 -0
- package/dist/semantic-edit.js +529 -0
- package/dist/semantic-edit.js.map +1 -0
- package/dist/terminal-filter.d.ts +27 -0
- package/dist/terminal-filter.d.ts.map +1 -0
- package/dist/terminal-filter.js +257 -0
- package/dist/terminal-filter.js.map +1 -0
- package/dist/undo.d.ts +21 -0
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +55 -0
- package/dist/undo.js.map +1 -0
- package/dist/utils/code-tokenizer.d.ts +25 -0
- package/dist/utils/code-tokenizer.d.ts.map +1 -0
- package/dist/utils/code-tokenizer.js +52 -0
- package/dist/utils/code-tokenizer.js.map +1 -0
- package/dist/utils/file-filter.d.ts +23 -0
- package/dist/utils/file-filter.d.ts.map +1 -0
- package/dist/utils/file-filter.js +48 -0
- package/dist/utils/file-filter.js.map +1 -0
- package/dist/utils/imports.d.ts +32 -0
- package/dist/utils/imports.d.ts.map +1 -0
- package/dist/utils/imports.js +155 -0
- package/dist/utils/imports.js.map +1 -0
- package/dist/utils/path-jail.d.ts +27 -0
- package/dist/utils/path-jail.d.ts.map +1 -0
- package/dist/utils/path-jail.js +95 -0
- package/dist/utils/path-jail.js.map +1 -0
- package/dist/utils/read-source.d.ts +18 -0
- package/dist/utils/read-source.d.ts.map +1 -0
- package/dist/utils/read-source.js +22 -0
- package/dist/utils/read-source.js.map +1 -0
- package/dist/utils/safe-parse.d.ts +20 -0
- package/dist/utils/safe-parse.d.ts.map +1 -0
- package/dist/utils/safe-parse.js +25 -0
- package/dist/utils/safe-parse.js.map +1 -0
- package/package.json +75 -0
- package/scripts/download-wasm.js +46 -0
- package/wasm/.gitkeep +0 -0
- package/wasm/tree-sitter-go.wasm +0 -0
- package/wasm/tree-sitter-javascript.wasm +0 -0
- package/wasm/tree-sitter-python.wasm +0 -0
- package/wasm/tree-sitter-typescript.wasm +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to NREKI will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [6.0.0] - 2026-03-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Holographic Pruning**: New performance mode for large projects (>1000 files).
|
|
9
|
+
Replaces full `.ts` source files with lightweight `.d.ts` shadow stubs in the
|
|
10
|
+
TypeScript compiler's VFS, dramatically reducing boot time and memory usage.
|
|
11
|
+
- Shadow Generator (`src/hologram/shadow-generator.ts`): Tree-sitter based file
|
|
12
|
+
classifier and `.d.ts` generator. Classifies exports as prunable (explicit types)
|
|
13
|
+
or unprunable (inferred types). Uses AST walking, not regex.
|
|
14
|
+
- Shadow Cache (`src/hologram/shadow-cache.ts`): Disk persistence for shadows
|
|
15
|
+
with mtime/hash staleness detection and version guard invalidation.
|
|
16
|
+
- Symbiotic Harvester (`src/hologram/harvester.ts`): Extracts real `.d.ts` from
|
|
17
|
+
the TypeScript compiler during idle time, replacing heuristic shadows with
|
|
18
|
+
compiler-grade ones. Cooperative scheduler with epoch-aware abort.
|
|
19
|
+
- Lazy Subgraph Loading: Kernel boots with only ambient files in rootNames.
|
|
20
|
+
Target files are added dynamically during `interceptAtomicBatch()`.
|
|
21
|
+
- Pre-warming: Background shadow scan starts after MCP handshake, before first edit.
|
|
22
|
+
- Domain Separation: `predictBlastRadius` disabled in hologram mode (use Layer 1
|
|
23
|
+
AST navigator for reference queries).
|
|
24
|
+
- **JIT Holography**: Eliminates upfront `scanProject()`. Shadows generated
|
|
25
|
+
on-demand when TypeScript's module resolver requests files. Cold boot
|
|
26
|
+
drops from 22.96s to 1.94s on VSCode (5,584 files). Only 642 of 5,584
|
|
27
|
+
files are ever classified — the rest are never touched.
|
|
28
|
+
- `NrekiKernel.setShadows()` - receive shadow scan results before boot
|
|
29
|
+
- `NrekiKernel.hasShadows()` - check if shadows are loaded
|
|
30
|
+
- `NrekiKernel.setJitParser()` - inject Tree-sitter parser for on-demand use
|
|
31
|
+
- `NrekiKernel.setJitClassifier()` - inject classification function
|
|
32
|
+
- `NrekiKernel.hasJitHologram()` - check if JIT mode is available
|
|
33
|
+
- `NrekiKernel.getJitCacheSize()` - report on-demand classification count
|
|
34
|
+
- `NrekiKernel.getLogicalTime()` - monotonic clock for harvester epoch detection
|
|
35
|
+
- `NrekiKernel.getProgram()` - access TypeScript Program for harvester .d.ts emission
|
|
36
|
+
- `NrekiMode` type extended with `"hologram"`
|
|
37
|
+
- `detectMode()` returns `"hologram"` for projects with >1000 source files
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
- VFS hooks in `NrekiKernel.boot()` now include hologram intercepts (BEFORE existing
|
|
41
|
+
VFS checks) for `fileExists`, `readFile`, and `getScriptSnapshot`
|
|
42
|
+
- `getFatalErrors()` semantic cascade evaluation now runs for both `project` and
|
|
43
|
+
`hologram` modes
|
|
44
|
+
- `RouterDependencies.nrekiMode` type includes `"hologram"`
|
|
45
|
+
- Deferred boot in router handles hologram mode (scan before boot if pre-warm incomplete)
|
|
46
|
+
|
|
47
|
+
### Tests
|
|
48
|
+
- 60 new tests across 7 test files:
|
|
49
|
+
- `tests/hologram-shadow-generator.test.ts` (19 tests)
|
|
50
|
+
- `tests/hologram-vfs.test.ts` (8 tests)
|
|
51
|
+
- `tests/hologram-lazy-subgraph.test.ts` (5 tests)
|
|
52
|
+
- `tests/hologram-domain-separation.test.ts` (3 tests)
|
|
53
|
+
- `tests/hologram-harvester.test.ts` (6 tests)
|
|
54
|
+
- `tests/hologram-integration.test.ts` (4 tests)
|
|
55
|
+
- `tests/jit-holography.test.ts` (15 tests)
|
|
56
|
+
|
|
57
|
+
## [5.3.0] - 2026-03-18
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
- **Temporal Type Regression Detection (TTRD)**: Detects when an AI agent weakens
|
|
61
|
+
type contracts to bypass the TypeScript compiler.
|
|
62
|
+
- Uses TypeChecker API to read compiler-resolved types, not AST text. Catches
|
|
63
|
+
inferred type escape (`as any` in expressions) and alias weakening
|
|
64
|
+
(`type X = any` where function signatures stay identical).
|
|
65
|
+
- Pre/Post comparison within the same ACID transaction. No global baseline needed.
|
|
66
|
+
- Barrel file guard: skips re-exported symbols, processes local declarations only.
|
|
67
|
+
- Type string safety: default truncation (no NoTruncation flag), 500-char hard limit.
|
|
68
|
+
- Submodular penalty: log2 scaling prevents cascading errors from blocking files.
|
|
69
|
+
- Debt ledger: stores original strict types for future restoration guidance.
|
|
70
|
+
- Debt payment: restoring strict types clears debt records and reduces friction.
|
|
71
|
+
- Ghost debt cleanup: deleted symbols cancel their debt automatically.
|
|
72
|
+
- Per-file regression tracking in batch edits (no friendly fire).
|
|
73
|
+
- `NrekiKernel.extractCanonicalTypes()` - TypeChecker-based export type extraction
|
|
74
|
+
- `NrekiKernel.computeTypeRegressions()` - Pre/Post contract comparison
|
|
75
|
+
- `NrekiKernel.resolvePosixPath()` - public path normalization
|
|
76
|
+
- `ChronosMemory.recordRegressions()` - submodular penalty with debt ledger
|
|
77
|
+
- `ChronosMemory.assessDebtPayments()` - debt forgiveness on type restoration or deletion
|
|
78
|
+
- `NrekiInterceptResult.regressions` - regression evidence per intercept
|
|
79
|
+
- `NrekiInterceptResult.postContracts` - post-edit type contracts for debt assessment
|
|
80
|
+
- `TypeRegression.filePath` - per-file attribution for batch edit accuracy
|
|
81
|
+
|
|
82
|
+
### Tests
|
|
83
|
+
- 19 new tests in `tests/ttrd.test.ts`
|
|
84
|
+
- extractCanonicalTypes, regression detection, false positive guards, barrel file guard,
|
|
85
|
+
type string limits, submodular penalty, debt ledger persistence, debt payment,
|
|
86
|
+
ghost debt, JIT warnings, happy path detection, pre/post baseline, healed path,
|
|
87
|
+
batch edit attribution, batch debt payment, no-success-on-regression
|
|
88
|
+
- **Performance Modes**: Auto-detection of validation depth based on project size.
|
|
89
|
+
- `syntax` mode (< 50 files): Kernel disabled. Tree-sitter only.
|
|
90
|
+
- `project` mode (50-1000 files): Full cross-file semantic validation with early exit.
|
|
91
|
+
- `file` mode (> 1000 files): Semantic checks on edited files only. No cascade.
|
|
92
|
+
- Mode auto-detected via bounded DFS file counter in ~85ms.
|
|
93
|
+
- Deferred boot: kernel boots on first edit, not at startup. MCP server starts in 0ms.
|
|
94
|
+
- Early exit in project mode: stops evaluating after threshold errors (50 + 20 per edited file).
|
|
95
|
+
- Corrupted builder recovery via warm rebuild (~2-5s) after early exit.
|
|
96
|
+
- Global noise filter: ignores diagnostic noise from missing @types when editing source files.
|
|
97
|
+
- Toxicity scoring for TTRD: detects parameter-level regressions (RetryConfig to any).
|
|
98
|
+
- Structural collapse detection: catches Promise<any> to any.
|
|
99
|
+
- **VSCode Benchmark (file mode)**: 5,584 files, 91.6s boot, 4.5GB RAM, 0 OOM crashes.
|
|
100
|
+
- Test A (safe edit): PASS, 23s
|
|
101
|
+
- Test B (local type break): CAUGHT, 25 errors in event.ts, 55s
|
|
102
|
+
- Test C (TTRD): CAUGHT via compilation, 1 error, 41s
|
|
103
|
+
- Test D (IDisposable): CAUGHT, 29 local errors in lifecycle.ts, 98s
|
|
104
|
+
- Previous project mode: 644s latency, 35,704 errors, OOM crashes
|
|
105
|
+
|
|
106
|
+
### Tests
|
|
107
|
+
- 20 new tests in `tests/mode-modes.test.ts` (mode detection, syntax/file/project behavior, early exit, recovery, elastic threshold, global noise, TTRD toxicity)
|
|
108
|
+
- 1 new test in `tests/ttrd-silent-crime.test.ts` (silent type degradation)
|
|
109
|
+
- Total: 590 tests across 29 suites, 0 failures
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## [5.2.0] - 2026-03-18
|
|
114
|
+
|
|
115
|
+
### Added
|
|
116
|
+
- **Chronos Memory**: Cross-session file error tracking with Cognitive Friction Index (CFI)
|
|
117
|
+
- Exponential decay (λ=0.85) - file friction reduces 15% per clean session
|
|
118
|
+
- Success discount - successful edits on high-friction files halve their CFI score
|
|
119
|
+
- JIT warnings - error history appears only when reading/editing affected files
|
|
120
|
+
- Edit gating - high-friction files require uncompressed read before editing
|
|
121
|
+
- Blast radius tracking - error penalties go to files where errors occur, not the edited file
|
|
122
|
+
- Dead file cleanup - deleted files are removed from tracking on session start
|
|
123
|
+
- Baseline cache reuse - O(1) error counting without compiler invocation
|
|
124
|
+
- Crash-safe persistence with debounced atomic writes
|
|
125
|
+
- `NrekiKernel.getInitialErrorCount()` - immutable boot-time error snapshot
|
|
126
|
+
- `NrekiKernel.getCurrentErrorCount()` - O(1) via baseline cache
|
|
127
|
+
- Global Health Delta tracking (ΔH = current errors - boot errors)
|
|
128
|
+
- **Chronos Health Score** in `nreki_guard action:"report"` output
|
|
129
|
+
- Circuit breaker trips now feed Chronos CFI automatically
|
|
130
|
+
|
|
131
|
+
### Tests
|
|
132
|
+
|
|
133
|
+
- 16 new tests in `tests/chronos-memory.test.ts`
|
|
134
|
+
- Constructor, recordTrip/Error/Heal/Success, isHighFriction, passive decay, GC, dead file cleanup, persistence, health report, blast radius tracking
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## v5.1.0 - Zero-Token Error Correction (2026-03-17)
|
|
139
|
+
|
|
140
|
+
### New: NREKI L3.3 Auto-Healing Engine
|
|
141
|
+
|
|
142
|
+
When the LLM's edit introduces structural errors (missing imports, forgotten `async` keyword, incomplete interface implementations), NREKI now **auto-corrects them in RAM** using TypeScript's CodeFix API - the same engine that powers VS Code's "Quick Fix" lightbulb. The LLM never sees the error. Zero tokens wasted.
|
|
143
|
+
|
|
144
|
+
- **`attemptAutoHealing()`**: Iterative fix-recompile loop inside `interceptAtomicBatch()`. Applies one CodeFix at a time, recompiles the universe (~20ms), checks if errors decreased, and either accepts or micro-rollbacks.
|
|
145
|
+
- **Error reduction rule**: Every fix must reduce total error count. If a fix leaves the same errors or more, it is reverted and blacklisted.
|
|
146
|
+
- **SAFE_FIXES whitelist**: Only deterministic structural fixes are applied - never type mutations or business logic changes:
|
|
147
|
+
- `import` / `fixMissingImport` - adds forgotten imports
|
|
148
|
+
- `fixAwaitInSyncFunction` - adds `async` when LLM wrote `await` without it
|
|
149
|
+
- `fixPromiseResolve` - wraps returns in `Promise.resolve()`
|
|
150
|
+
- `fixMissingProperties` - auto-implements required interface properties
|
|
151
|
+
- `fixClassDoesntImplementInheritedAbstractMember` - implements abstract methods
|
|
152
|
+
- `fixAddMissingMember` - declares missing class properties
|
|
153
|
+
- `fixAddOverrideModifier` - adds `override` keyword
|
|
154
|
+
- **Micro-rollback per fix**: Each fix has its own undo-log. Failed fixes revert without affecting successful ones.
|
|
155
|
+
- **Macro-rollback on partial failure**: If not ALL errors are resolved, the entire healing attempt is undone and the original errors are returned to the LLM intact.
|
|
156
|
+
- **Patch protection**: On successful healing, the response tells the agent not to overwrite the auto-applied fixes in the next edit.
|
|
157
|
+
- **`healedFiles` in response**: Router creates `nreki_undo` backups for collateral files the healer touched.
|
|
158
|
+
- **`healingStats`**: Public counter tracking `applied` and `failed` healing attempts.
|
|
159
|
+
|
|
160
|
+
### New: `getFatalErrors()` - Centralized Triple Shield
|
|
161
|
+
|
|
162
|
+
Extracted the 3-shield evaluation logic (Global → Syntactic → Semantic) into a reusable private method. Both `interceptAtomicBatch()` and `attemptAutoHealing()` use it, eliminating code duplication.
|
|
163
|
+
|
|
164
|
+
### Bug Fixes
|
|
165
|
+
|
|
166
|
+
- **`ts.emptyOptions` doesn't exist in TS 5.9**: Replaced with `{} as ts.UserPreferences`.
|
|
167
|
+
|
|
168
|
+
### Tests
|
|
169
|
+
|
|
170
|
+
- **526 tests**, 25 suites, zero failures, zero regressions
|
|
171
|
+
- New: `tests/auto-healing.test.ts` -6 tests covering:
|
|
172
|
+
- Missing import → auto-healed → `safe: true` → disk has import
|
|
173
|
+
- `await` without `async`, callers healthy → auto-healed → `safe: true`
|
|
174
|
+
- `await` without `async`, callers break → cascade detected → micro-rollback → `safe: false`
|
|
175
|
+
- Business logic error (no CodeFix) → healing skipped → `safe: false`
|
|
176
|
+
- `healingStats` counter verification
|
|
177
|
+
- Clean code → healing not triggered → `safe: true` without heal text
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## v5.0.0 - The NREKI Kernel (2026-03-16)
|
|
182
|
+
|
|
183
|
+
### New: NREKI Kernel (Layer 2 - Cross-File Semantic Verification)
|
|
184
|
+
|
|
185
|
+
- **VFS-LSP Kernel**: Hijacks TypeScript Compiler API with a Virtual File System in RAM. Edits are validated against the entire project's type system before reaching disk.
|
|
186
|
+
- **True ACID Transactions**: `interceptAtomicBatch()` validates in RAM; `commitToDisk()` writes via two-phase atomic commit (backup → temp+rename → cleanup) with physical rollback on OS failure.
|
|
187
|
+
- **Zero Disk Touch**: When the kernel is active, `semanticEdit()` operates in `dryRun` mode. The disk is immutable until semantic validation passes.
|
|
188
|
+
- **Triple Shield**: Global diagnostics → Syntactic diagnostics → Semantic diagnostics. Catches broken syntax AND cross-file type errors.
|
|
189
|
+
- **Predictive Blast Radius**: `predictBlastRadius()` uses `ts.LanguageService.findReferences()` to show what will break and WHY before the agent edits. ~20ms per query.
|
|
190
|
+
- **PageRank Architecture Scoring**: Files classified by recursive importance via Markov Chain Power Iteration (damping factor 0.85, 20 iterations, <8ms convergence for 1,000 files). Replaces naive inDegree classification.
|
|
191
|
+
- **Warm-Path Optimization**: Failed intercepts advance the monotonic clock instead of destroying the builder program. Rollback drops from ~10s to ~50ms.
|
|
192
|
+
- **Path Jail at Kernel Level**: `interceptAtomicBatch()` rejects paths that resolve outside the project root.
|
|
193
|
+
- **O(1) Virtual Directory Resolution**: `vfsDirectories` Set replaces O(n) VFS scan in `directoryExists`.
|
|
194
|
+
- **LanguageService Integration**: VS Code's reference engine connected to the VFS for JIT lazy evaluation.
|
|
195
|
+
|
|
196
|
+
### Renamed: TokenGuard → NREKI
|
|
197
|
+
|
|
198
|
+
- npm package: `@ruso-0/tokenguard` → `@ruso-0/nreki`
|
|
199
|
+
- Tool names: `tg_navigate` → `nreki_navigate`, `tg_code` → `nreki_code`, `tg_guard` → `nreki_guard`
|
|
200
|
+
- Database: `.tokenguard.db` → `.nreki.db`
|
|
201
|
+
- Pins: `.tokenguard-pins.json` → `.nreki-pins.json`
|
|
202
|
+
- Backups: `.tokenguard-backup/` → `.nreki-backup/`
|
|
203
|
+
- Server name: `TokenGuard` → `NREKI`
|
|
204
|
+
|
|
205
|
+
### Security Hardening (30/30 Audit Findings Resolved)
|
|
206
|
+
|
|
207
|
+
- **A1**: Kernel path jail blocks traversal attempts (`../../etc/passwd`)
|
|
208
|
+
- **A2**: Write-Then-Validate eliminated - now Validate-Then-Write via dryRun
|
|
209
|
+
- **A3**: Zombie mutex (`withTimeout`/`Promise.race`) deleted entirely
|
|
210
|
+
- **A4**: Sensitive file blocklist expanded (+8 patterns: docker, kube, netrc, htpasswd, etc.)
|
|
211
|
+
- **A5**: `node_modules` filter uses path segment regex, not substring match
|
|
212
|
+
- **A6**: Kernel returns relative paths in error messages, not absolute
|
|
213
|
+
- **A8**: Pin sanitization adds Unicode normalization (NFKC) + null byte rejection
|
|
214
|
+
- **A9**: Prototype pollution guard on pin JSON.parse
|
|
215
|
+
- **A10**: Kernel readFile blocks sensitive files (.env, .pem, .key) in disk fallback
|
|
216
|
+
- **B1**: `commitToDisk()` resurrected as the only write path when kernel is active
|
|
217
|
+
- **B2**: `isTypeScriptFile` regex expanded to `.mts`, `.cts`, `.mjs`, `.cjs`, `.d.mts`, `.d.cts`
|
|
218
|
+
- **B4**: Double-boot guard added to `boot()`
|
|
219
|
+
- **B5**: Pre-boot guard added to `interceptAtomicBatch()`
|
|
220
|
+
- **B6**: `logicalTime` saved and restored on rollback
|
|
221
|
+
- **B7**: Fingerprint hash upgraded from MD5 to SHA-256
|
|
222
|
+
- **B8**: GC threshold made configurable (`gcThreshold` property)
|
|
223
|
+
- **C4**: Heartbeat skipped during circuit breaker escalation ≥ 2
|
|
224
|
+
- **C5**: Version read from `package.json` at runtime (no hardcoded string)
|
|
225
|
+
- **D1**: Pin file writes use atomic temp+rename pattern
|
|
226
|
+
- **D2**: Orphaned `.nreki-bak-*` files cleaned on kernel boot
|
|
227
|
+
- **D4**: Token estimation margin documented (20-40% variance)
|
|
228
|
+
- **E1**: `directoryExists` uses O(1) Set lookup instead of O(n) VFS scan
|
|
229
|
+
|
|
230
|
+
### Tests
|
|
231
|
+
|
|
232
|
+
- **520 tests**, 24 suites, zero failures
|
|
233
|
+
- New: `tests/nreki-kernel.test.ts` -22 kernel unit tests (boot, semantic validation, syntactic shield, baseline tolerance, file operations, ACID, concurrency, edge cases)
|
|
234
|
+
- New: `tests/nreki-integration.test.ts` -8 integration tests (dryRun, full commit path, type-break blocked, batch VFS, path traversal rejection)
|
|
235
|
+
- New: PageRank tests (recursive importance, convergence <50ms for 1,000 files)
|
|
236
|
+
- New: Precision tests (VFS staging leak, node_modules filtering, restore failure handling)
|
|
237
|
+
|
|
238
|
+
### Benchmark: OpenDota (148 files, 1,600+ stars)
|
|
239
|
+
|
|
240
|
+
- 6/6 correct verdicts (valid edit, type break, syntax break, file delete, non-TS file)
|
|
241
|
+
- Zero false positives, zero false negatives
|
|
242
|
+
- Boot: 10.68s | Type break detection: 12.6s | Syntax detection: 11.4s
|
|
243
|
+
|
|
244
|
+
### 32 Sealed Failure Modes (P1-P32)
|
|
245
|
+
|
|
246
|
+
P2 (atomic commit), P4 (dynamic rootNames), P5 (tombstone), P8 (monotonic clock), P9 (topological cardinality), P10 (FIFO mutex), P11 (periodic GC), P15 (path sanitization), P17 (zombie AST), P18 (destruction & resurrection), P19 (counter reset), P21 (multi-file deadlock), P25 (idempotent undo-log), P26 (POSIX normalization), P27 (recursive mkdir), P28 (syntactic blindness), P29 (TS6053 ghost), P30 (non-TS filter), P31 (virtual directories), P32 (physical rollback).
|
|
247
|
+
|
|
248
|
+
## [4.0.2] - 2026-03-13
|
|
249
|
+
|
|
250
|
+
### Fixed (Logic)
|
|
251
|
+
- **Blind Sniper**: `prepare_refactor` only searched function signatures (BM25 shorthand index), missing symbols used inside function bodies. Now uses exhaustive `raw_code` SQL scan for 100% coverage. Also added `property_identifier` and `shorthand_property_identifier` to the AST node type filter.
|
|
252
|
+
- **Batch Edit Race Condition**: `batch_edit` had no file locks. Concurrent `edit` + `batch_edit` on the same file could corrupt it. Added two-phase locking (acquire all or rollback all, release in finally).
|
|
253
|
+
- **indexOf Wrong Function**: `applySemanticSplice` fallback searched from byte 0, could edit the wrong function when duplicates exist. Now searches in a ±500 byte local window around the AST-reported position first.
|
|
254
|
+
- **extractSignature String Confusion**: `{` inside string literals (e.g., `msg = "{"`) was mistaken for function body start, truncating signatures. Added string-state tracking to skip characters inside quotes.
|
|
255
|
+
- **Silent Plan Amnesia**: Plans exceeding 15,000 characters were silently dropped. Now injects a visible WARNING telling Claude to summarize the plan.
|
|
256
|
+
|
|
257
|
+
### Fixed (Documentation)
|
|
258
|
+
- Updated `index.ts` docstring from v3.3.0 to v4.0.2.
|
|
259
|
+
- Rewrote `skills/SKILL.md` with v4 tool names and features (batch_edit, prepare_refactor, blast radius, architecture tiers).
|
|
260
|
+
- Updated `getClaudeMdContent()` (CLAUDE.md init) with v4 features.
|
|
261
|
+
- Changed "vs full file rewrite" to "vs native read+edit" in response messages.
|
|
262
|
+
- Changed "Saves 98%" claim to "60-80%" in semantic-edit docstring.
|
|
263
|
+
- Eliminated double file read in handleEdit by returning oldRawCode from semanticEdit.
|
|
264
|
+
- Updated preToolUse.ts docstring to use v4 tool names.
|
|
265
|
+
|
|
266
|
+
## [4.0.1] - 2026-03-13
|
|
267
|
+
|
|
268
|
+
### Fixed
|
|
269
|
+
- **Inflated `tokensAvoided` metric**: `semanticEdit()` was computing savings as `fullFile × 2 - newCode`, which double-counted the file read. Corrected to `fullFile + oldSymbol - newCode` (read file + old symbol code that Claude would have sent).
|
|
270
|
+
- **Router docstring version**: Updated from v3.3.0 to v4.0.0 and added `batch_edit` and `prepare_refactor` to the tool action listings.
|
|
271
|
+
- **Batch edit blast radius missing dependents**: `handleBatchEdit()` now queries the dependency graph to list files that import edited modules, matching the behavior of single-file `handleEdit()`.
|
|
272
|
+
|
|
273
|
+
## [4.0.0] - 2026-03-12
|
|
274
|
+
|
|
275
|
+
### BREAKING CHANGES
|
|
276
|
+
- **`symbolName` extracted from AST**: Parser now uses tree-sitter `@_name` captures instead of ~10 fragile regexes. `ParsedChunk` interface adds `symbolName: string`. Database schema adds `symbol_name`, `start_index`, `end_index` columns (auto-migrated for existing DBs).
|
|
277
|
+
|
|
278
|
+
### Added
|
|
279
|
+
- **`nreki_code action:"batch_edit"`**: Atomically edit multiple symbols across multiple files. Uses Virtual File System in RAM with reverse splice ordering (descending startIndex) to avoid byte offset corruption. All-or-nothing: if ANY file fails AST validation, NOTHING is written to disk.
|
|
280
|
+
- **Architecture Map**: `nreki_navigate action:"map"` now includes dependency graph with import centrality classification. Files are tiered by in-degree percentile: P75+ = "core", P50-P75 = "logic", <P50 = "leaf". Uses O(1) FastLookup index for import resolution (relative paths, `@/` aliases, extensionless, index.ts implicit).
|
|
281
|
+
- **Blast Radius Detection**: When `nreki_code action:"edit"` changes a function's signature (parameters, return type), NREKI warns which files import that symbol. Suggests `batch_edit` to update dependents. Also applies to `batch_edit`.
|
|
282
|
+
- **`nreki_navigate action:"prepare_refactor"`**: AST-based confidence classification for safe renaming. Walks tree-sitter syntax nodes and classifies each occurrence as "high" confidence (safe to rename) or "review" (inside strings, comments, object keys, JSX text). Returns a formatted report with two sections.
|
|
283
|
+
- **`parseRaw<T>()`**: Public method on `ASTParser` for raw tree-sitter tree access via callback pattern with guaranteed WASM memory cleanup.
|
|
284
|
+
- **`DependencyGraph` interface**: `importedBy`, `inDegree`, and `tiers` maps exported from `repo-map.ts`.
|
|
285
|
+
- **`buildFastLookup()`**: O(1) import resolution mapping extensionless, src/-stripped, and index-collapsed variants to actual file paths.
|
|
286
|
+
- **`detectSignatureChange()`**: Pure function comparing old/new signatures to detect parameter and return type changes.
|
|
287
|
+
- **`findChunkBySymbol()`**: Extracted pure function preferring `chunk.symbolName` (AST) with `extractName()` regex fallback.
|
|
288
|
+
- **`applySemanticSplice()`**: Extracted pure splice function for reuse in both single and batch edits.
|
|
289
|
+
|
|
290
|
+
### Fixed
|
|
291
|
+
- **Bug A - Stale docstring**: `engine.ts` header incorrectly referenced "sqlite-vec + FTS5". Updated to reflect actual implementation (pure-JS VectorIndex + BM25 KeywordIndex).
|
|
292
|
+
- **Bug B - Multi-line console.log stripping**: Regex-based `console.log()` removal failed on multi-line calls. Replaced with `stripCallStatements()` using balanced parenthesis tracking. Same fix applied to Python `print()`.
|
|
293
|
+
- **Bug C - Python `#` in strings**: Comment stripping destroyed `#` inside string literals (e.g., `color = "#FF0000"`). Fixed by reordering (triple-quotes first) and protecting single/double-quoted strings with placeholders before stripping comments.
|
|
294
|
+
- **Bug D - Simplistic glob matching**: `walkDirectory` converted `**/node_modules/**` to `node_modules` via string replace, failing for patterns like `**/*.min.js`. Replaced with `picomatch` for proper glob matching.
|
|
295
|
+
|
|
296
|
+
### Changed
|
|
297
|
+
- `semantic-edit.ts` refactored: extracted `applySemanticSplice()`, `findChunkBySymbol()`, `detectSignatureChange()` as pure functions.
|
|
298
|
+
- `repo-map.ts` extended: `generateRepoMap()` now builds and caches dependency graph alongside repo map. `repoMapToText()` appends architecture tier summary.
|
|
299
|
+
- Database schema: `chunks` table now stores `start_index`, `end_index`, `symbol_name` with migration for existing DBs.
|
|
300
|
+
- Test count: 464 → 473 tests across 21 test suites.
|
|
301
|
+
|
|
302
|
+
### Dependencies
|
|
303
|
+
- Added `picomatch` (runtime) and `@types/picomatch` (dev) for proper glob matching.
|
|
304
|
+
|
|
305
|
+
## [3.3.0] - 2026-03-13
|
|
306
|
+
|
|
307
|
+
### Added
|
|
308
|
+
- **Context Heartbeat**: Silently re-injects critical session state
|
|
309
|
+
every ~15 tool calls to survive Claude Code's context compaction. Uses 4-layer
|
|
310
|
+
state re-injection:
|
|
311
|
+
- Layer 1 (Plan File): Anchored plan document via `set_plan`
|
|
312
|
+
- Layer 2 (Scratchpad): Claude's progress notes via `memorize` + pinned rules
|
|
313
|
+
- Layer 3 (Recent Edits): Files modified in this session
|
|
314
|
+
- Layer 4 (Circuit Breaker): Active escalation alerts if in Break & Build
|
|
315
|
+
- **`nreki_guard action:"set_plan"`**: Anchor a master plan file (PLAN.md, schemas).
|
|
316
|
+
Includes Bankruptcy Shield rejecting plans >4000 tokens to prevent context bloat.
|
|
317
|
+
- **`nreki_guard action:"memorize"`**: Claude writes progress notes to persistent scratchpad.
|
|
318
|
+
Notes survive context compaction and are re-injected during heartbeat.
|
|
319
|
+
- **Top-injection pattern**: Heartbeat injects state ABOVE the tool response, keeping the
|
|
320
|
+
immediate result at the bottom to respect the LLM's U-shaped attention curve.
|
|
321
|
+
- **Read-only filter**: Heartbeat only fires during context-gathering actions
|
|
322
|
+
(read, search, map, status, definition, references, outline). Never during
|
|
323
|
+
edit, undo, or filter_output to avoid distracting Claude during critical operations.
|
|
324
|
+
- **Restart Detection**: Heartbeat detects MCP server restarts (currentCalls < lastInjectCalls)
|
|
325
|
+
and resets the injection counter to prevent permanent heartbeat death.
|
|
326
|
+
|
|
327
|
+
## [3.2.0] - 2026-03-13
|
|
328
|
+
|
|
329
|
+
### Added
|
|
330
|
+
- **Auto-Context Inlining**: When Claude requests a definition or reads a file, NREKI
|
|
331
|
+
automatically resolves signatures of imported dependencies and injects them in the response.
|
|
332
|
+
Reduces follow-up tool calls by providing "X-ray vision" in a single turn.
|
|
333
|
+
- Import extraction supports ESM (named + default), CommonJS require, Python from-import,
|
|
334
|
+
and Go namespace inference.
|
|
335
|
+
- "Gold Filter": only injects dependencies actually used in the function body, using the
|
|
336
|
+
local alias name (not the original export name) for accurate matching.
|
|
337
|
+
- Security filter: signatures containing passwords, API keys, auth tokens, or encryption
|
|
338
|
+
keys are automatically excluded from injection.
|
|
339
|
+
- Anti-prompt-injection: JSDoc comments and NREKI stubs are stripped from signatures
|
|
340
|
+
before injection, preventing malicious content from entering Claude's context.
|
|
341
|
+
- Homonym disambiguation: BM25 searches combine symbol name + import path hint to find
|
|
342
|
+
the correct signature even when multiple files export the same name.
|
|
343
|
+
- 150ms hard timeout prevents event loop blocking on large codebases.
|
|
344
|
+
- `auto_context: false` parameter available on both `nreki_navigate` and `nreki_code` to disable.
|
|
345
|
+
- Session report tracks `autoContextInjections` count.
|
|
346
|
+
- **Go import support**: Auto-Context infers exported symbols from Go namespace usage patterns
|
|
347
|
+
(e.g., `utils.HashPassword()` resolves to `HashPassword` in the `utils` package).
|
|
348
|
+
- **Preloaded content in compressFileAdvanced**: Eliminates double file I/O when both
|
|
349
|
+
auto-context and compression are active on the same read.
|
|
350
|
+
|
|
351
|
+
### Changed
|
|
352
|
+
- `CompressionLevel` type is now used explicitly instead of `as any` for level casting.
|
|
353
|
+
- `handleRead` reads the file exactly once and reuses the content for both auto-context
|
|
354
|
+
extraction and compression.
|
|
355
|
+
|
|
356
|
+
## [3.1.3] - 2026-03-12
|
|
357
|
+
|
|
358
|
+
### Fixed
|
|
359
|
+
- **Path normalization in Circuit Breaker**: All file paths are now resolved to absolute + forward slashes before recording. Prevents split counters where `"src/app.ts"` and `"/abs/path/src/app.ts"` were tracked as different files, causing Pattern 4 to never trigger.
|
|
360
|
+
- **Ghost data after file deletion**: `db.save()` is now called after the watcher's `unlink` event, ensuring deleted files don't reappear from disk on next session.
|
|
361
|
+
- **Plaintext fallback for unsupported languages**: Files with unsupported extensions (.rs, .java, .cpp, etc.) are now indexed as single plaintext chunks. BM25 keyword search works on all file types as documented in the README. AST features (validation, structural compression, semantic edit) still require TS/JS/Python/Go.
|
|
362
|
+
|
|
363
|
+
## [3.1.2] - 2026-03-12
|
|
364
|
+
|
|
365
|
+
### Fixed
|
|
366
|
+
- **Duplicate JSDoc on softReset**: Removed stale v3.0 comment that contradicted actual behavior.
|
|
367
|
+
- **Inflated grepEstimate**: Replaced arbitrary `× 3` multiplier with per-unique-file estimation. Added "(estimated)" to savings output.
|
|
368
|
+
- **@xenova/transformers moved to optionalDependencies**: `npm install` no longer downloads ~200MB of ONNX runtime for Lite mode users. Pro mode users can install it separately with `npm install @xenova/transformers`.
|
|
369
|
+
|
|
370
|
+
## [3.1.1] - 2026-03-12
|
|
371
|
+
|
|
372
|
+
### Fixed
|
|
373
|
+
- **Circuit breaker `redirectsIssued`**: No longer counts Level 3 hard stops as redirects.
|
|
374
|
+
- **Circuit breaker `softReset` amnesia total**: Purges all history entries for the tripped file, giving Claude 3 clean attempts with the new strategy instead of 1.
|
|
375
|
+
- **Breaker payloads instruct `compress:false`**: Level 1 and Level 2 redirects now tell Claude to read uncompressed code so it can understand the logic before rewriting.
|
|
376
|
+
- **Smart rebase for Python/Go**: Auto-indentation now strips Claude's indent and rebases to the target context, fixing IndentationError in Python and tab corruption in Go.
|
|
377
|
+
- **CRLF support**: Line start detection skips `\r` on Windows files.
|
|
378
|
+
- **Cross-platform byte indices**: Verifies tree-sitter byte offsets against actual content, falls back to indexOf if they differ across platforms.
|
|
379
|
+
|
|
380
|
+
### Added
|
|
381
|
+
- **Behavioral Advisor (PreToolUseHook)**: Connected to `handleRead` - when Claude reads a file raw (compress:false), it gets a suggestion showing how many tokens it wasted and the exact command to compress next time.
|
|
382
|
+
- **Danger Zones in status**: `nreki_guard action:"status"` now shows the 5 heaviest unread files with estimated token counts. Files already read (raw or compressed) are filtered out dynamically.
|
|
383
|
+
- **CLI `--help` and `--version`**: Standard CLI hygiene. Version sourced from single `VERSION` constant.
|
|
384
|
+
- **Telemetry via social sharing**: Session report footer invites users to share their receipt on GitHub Discussions.
|
|
385
|
+
- **E2E breaker test**: Full integration test simulating 3 failures → Level 1 redirect → grace period → recovery with insert_after.
|
|
386
|
+
- **5 topological edit tests**: insert_after, insert_before, auto-indent nested, syntax rejection, last-symbol edge case.
|
|
387
|
+
|
|
388
|
+
### Removed
|
|
389
|
+
- `evaluateGrepOperation` and `countFiles` from PreToolUseHook (unreachable via MCP).
|
|
390
|
+
- `src/schemas.ts` (dead v2 code, zero imports).
|
|
391
|
+
- All "BOMBA" comments replaced with professional descriptions.
|
|
392
|
+
|
|
393
|
+
### Changed
|
|
394
|
+
- CLAUDE.md point 3 now includes quantitative advice (5,000 tokens vs 1,200 tokens).
|
|
395
|
+
- `RouterDependencies.hook` is optional for backward compatibility.
|
|
396
|
+
- `engine.markFileRead()` called in both compress and raw read branches.
|
|
397
|
+
|
|
398
|
+
## [3.1.0] - 2026-03-11
|
|
399
|
+
|
|
400
|
+
### Added
|
|
401
|
+
- **Creative Circuit Breaker ("Break & Build")**: 3-level escalation system that redirects Claude with increasingly specific strategies instead of just blocking. Level 1: rewrite from scratch. Level 2: decompose into helpers. Level 3: hard stop, ask the human.
|
|
402
|
+
- **`nreki_guard action:"reset"`**: Escape hatch for humans to clear the circuit breaker and let Claude retry with a new approach.
|
|
403
|
+
- **`npx nreki init`**: CLI subcommand that generates a `CLAUDE.md` file with collaborative-tone instructions for Claude Code to prefer NREKI tools.
|
|
404
|
+
- **Redirect statistics**: Session report now tracks `redirectsIssued` and `redirectsSuccessful` to measure creative breaker effectiveness.
|
|
405
|
+
|
|
406
|
+
### Performance
|
|
407
|
+
- **Batch SQL queries**: `searchHybrid`, `searchKeywordOnly`, and `searchVector` now use `WHERE id IN (...)` batch queries instead of N+1 individual queries per chunk ID.
|
|
408
|
+
- **BM25 TF precompute**: Term frequencies are precomputed at index time for O(1) lookup during search, replacing O(n) `filter()` scans.
|
|
409
|
+
|
|
410
|
+
### Changed
|
|
411
|
+
- Circuit breaker `ToolCallRecord` now includes `symbolName` for contextual redirect payloads.
|
|
412
|
+
- Circuit breaker `trip()` now escalates `escalationLevel` (0→3) instead of just setting a boolean.
|
|
413
|
+
- `softReset()` preserves escalation level across retries, enabling progressive escalation.
|
|
414
|
+
- All version strings aligned to 3.1.0.
|
|
415
|
+
|
|
416
|
+
### Tests
|
|
417
|
+
- 438 tests (was 423). Added 15 new tests for escalation levels, redirect payloads, symbolName tracking, and soft/hard reset behavior.
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## [3.0.3] - 2026-03-11
|
|
422
|
+
|
|
423
|
+
### Fixed
|
|
424
|
+
- **CI macOS/Windows**: `safePath` now calls `realpathSync` on the workspace root as well as the resolved path, fixing false-positive "Symlink escape blocked" errors on macOS where `/tmp` is a symlink to `/private/tmp`. All 423 tests pass on all platforms.
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## [3.0.2] - 2026-03-10
|
|
429
|
+
|
|
430
|
+
### Headline
|
|
431
|
+
docs: fix README Quick Start syntax, update test count to 423, update keywords, add security documentation.
|
|
432
|
+
|
|
433
|
+
### Fixed
|
|
434
|
+
- **README Quick Start**: Replaced v2 `options:{}` syntax with v3 flat params (`text:`, `symbol:`, `new_code:`, `output:`).
|
|
435
|
+
- **README Quick Start**: Replaced `target:` with correct param names (`query:`, `symbol:`).
|
|
436
|
+
- **README**: Renamed `terminal` → `filter_output` in nreki_code actions table, comparison table, architecture diagram, and Quick Start.
|
|
437
|
+
- **README**: Updated test count from 361 → 423 in title, badges, stress test section, and real-world validation.
|
|
438
|
+
- **README**: Updated test suites from 14 → 16.
|
|
439
|
+
|
|
440
|
+
### Added
|
|
441
|
+
- **README Security section**: Documented symlink resolution, sensitive file blocklist, pin sanitization, and file-level mutex.
|
|
442
|
+
|
|
443
|
+
### Changed
|
|
444
|
+
- **package.json**: Updated keywords to reflect v3 security focus (`code-safety`, `ast-validation`, `circuit-breaker`, `defensive-coding`, `ai-safety`, `surgical-edit`).
|
|
445
|
+
- **package.json**: Set author to `Ruso-0 (https://github.com/Ruso-0)`.
|
|
446
|
+
- **package.json**: Version bumped to 3.0.2.
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## [3.0.0] - 2026-03-10
|
|
451
|
+
|
|
452
|
+
### Headline
|
|
453
|
+
NREKI v3.0 - Architecture overhaul. 16 tools collapsed to 3 routers. Invisible middleware. Lite/Pro mode. 81% reduction in tool definition overhead.
|
|
454
|
+
|
|
455
|
+
### BREAKING CHANGES
|
|
456
|
+
- **16 tools → 3 router tools**: All MCP tool names have changed. LLMs must use the new `nreki_navigate`, `nreki_code`, `nreki_guard` tool names with `action` parameters.
|
|
457
|
+
- **`nreki_validate` removed from MCP**: Now runs automatically as invisible middleware inside `nreki_code action:"edit"`. No manual calls needed.
|
|
458
|
+
- **`nreki_circuit_breaker` removed from MCP**: Now runs as passive middleware monitoring all tool calls. Auto-resets after 60s inactivity or when a different action is called.
|
|
459
|
+
- **`nreki_audit` removed from MCP**: Moved to CLI only. Use `npx @ruso-0/nreki --audit`.
|
|
460
|
+
|
|
461
|
+
### Added - Router Pattern
|
|
462
|
+
- **`nreki_navigate`** - Unified navigation tool replacing `nreki_search`, `nreki_def`, `nreki_refs`, `nreki_outline`, `nreki_map`. Actions: `search`, `definition`, `references`, `outline`, `map`.
|
|
463
|
+
- **`nreki_code`** - Unified code tool replacing `nreki_read`, `nreki_compress`, `nreki_semantic_edit`, `nreki_undo`, `nreki_terminal`. Actions: `read`, `compress`, `edit`, `undo`, `terminal` (renamed to `filter_output` in v3.0.2).
|
|
464
|
+
- **`nreki_guard`** - Unified safety tool replacing `nreki_pin`, `nreki_status`, `nreki_session_report`. Actions: `pin`, `unpin`, `status`, `report`.
|
|
465
|
+
- `src/router.ts` - Central dispatcher mapping `{tool, action}` to handler functions (~700 lines).
|
|
466
|
+
|
|
467
|
+
### Added - Invisible Middleware
|
|
468
|
+
- `src/middleware/validator.ts` - AST validation wrapper. Validates code via tree-sitter before disk writes inside `nreki_code action:"edit"`.
|
|
469
|
+
- `src/middleware/circuit-breaker.ts` - Passive circuit breaker. Wraps all handlers, records tool call results, trips on destructive patterns, auto-resets on action diversity or 60s inactivity.
|
|
470
|
+
|
|
471
|
+
### Added - Lite / Pro Mode
|
|
472
|
+
- **Lite mode (default)**: Instant startup (~100ms). BM25 keyword-only search. No ONNX model dependency.
|
|
473
|
+
- **Pro mode (`--enable-embeddings`)**: Hybrid semantic + BM25 search with RRF fusion. Requires ONNX Runtime for jina-v2-small embeddings.
|
|
474
|
+
- `searchKeywordOnly()` method added to `NREKIDB` for Lite mode BM25 search.
|
|
475
|
+
- Engine methods (`indexFile`, `indexDirectory`, `search`, `getRepoMap`) now branch based on `enableEmbeddings` config.
|
|
476
|
+
|
|
477
|
+
### Changed
|
|
478
|
+
- **`src/index.ts`**: Rewritten from ~1,479 lines (16 tool registrations) to ~180 lines (3 router registrations).
|
|
479
|
+
- **Tool definition overhead**: ~3,520 tokens → ~660 tokens (81% reduction).
|
|
480
|
+
- **Test count**: 305 → 361 tests across 14 test suites.
|
|
481
|
+
- **`package.json`**: Version bumped to 3.0.0. Description updated.
|
|
482
|
+
- **`README.md`**: Complete rewrite for v3.0 architecture.
|
|
483
|
+
|
|
484
|
+
### Added - Tests
|
|
485
|
+
- `tests/router.test.ts` - 30 tests for router dispatch correctness across all 14 `{tool, action}` pairs.
|
|
486
|
+
- `tests/middleware.test.ts` - 13 tests for validator and circuit breaker middleware behavior.
|
|
487
|
+
- `tests/backward-compat.test.ts` - 13 tests verifying all 16 original tool behaviors work through the new 3-tool API.
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
## [2.1.2] - 2026-03-10
|
|
492
|
+
|
|
493
|
+
### Headline
|
|
494
|
+
NREKI v2.1.2 - Lazy ONNX loading fixes MCP handshake timeout for real-world users.
|
|
495
|
+
|
|
496
|
+
### Fixed
|
|
497
|
+
- **CRITICAL - MCP handshake timeout**: `engine.initialize()` was eagerly loading the ONNX embedding model (~5-10s) during startup, blocking ALL tool calls until the model was ready. Real users connecting via Claude Code would experience timeouts or slow first responses. Split initialization into two phases:
|
|
498
|
+
- **Fast path** (`initialize()`): SQLite + Tree-sitter only (~100ms). Used by 12/16 tools.
|
|
499
|
+
- **Embedder path** (`initializeEmbedder()`): Adds ONNX model load. Used only by `nreki_search`, `nreki_map`, and indexing operations.
|
|
500
|
+
- **`nreki_def` first-call latency**: Was 465ms because it waited for the embedder to load (which it doesn't use). Now completes in ~50ms on first call.
|
|
501
|
+
- Removed background `engine.initialize()` from `main()` - tools now self-initialize at the correct level when first called.
|
|
502
|
+
|
|
503
|
+
### Changed
|
|
504
|
+
- **package.json**: Version bumped to 2.1.2.
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## [2.1.1] - 2026-03-10
|
|
509
|
+
|
|
510
|
+
### Headline
|
|
511
|
+
NREKI v2.1.1 - Final audit fixes, nreki_undo, 16 tools, 305 tests.
|
|
512
|
+
|
|
513
|
+
### Added - New Tool
|
|
514
|
+
- **`nreki_undo`** - Undo the last `nreki_semantic_edit` on a file. Auto-restores from backup with one-shot semantics (backup is consumed after restore).
|
|
515
|
+
|
|
516
|
+
### Added - New Module
|
|
517
|
+
- `src/undo.ts` - Backup/restore engine using base64url-encoded file paths. Stores pre-edit snapshots in `.nreki/backups/`.
|
|
518
|
+
- `src/utils/read-source.ts` - Shared BOM-safe file reader. Strips U+FEFF byte order marks from Windows-created source files.
|
|
519
|
+
|
|
520
|
+
### Security
|
|
521
|
+
- **FIX 2 - XML injection prevention**: Pin content is now escaped (`&`, `<`, `>`, `"`, `'`) before storage to prevent prompt injection via pinned rules.
|
|
522
|
+
|
|
523
|
+
### Fixed
|
|
524
|
+
- **FIX 1 - BOM stripping**: All source file readers now use `readSource()` to strip U+FEFF BOM, fixing parse failures on Windows-created files.
|
|
525
|
+
- **FIX 3 - Code tokenizer**: Rewritten to correctly handle `$scope`, `__proto__`, `_privateVar`, and other edge-case identifiers with `$`/`_` prefixes.
|
|
526
|
+
- **FIX 4 - Fast dot product**: Replaced cosine similarity with direct dot product for L2-normalized vectors. Removes sqrt/division overhead; mathematically equivalent for unit vectors.
|
|
527
|
+
- **FIX 6 - Pin order**: Pinned rules now appear AFTER repo map text (was before). Preserves Anthropic prompt cache hits since the static map stays at the start of context.
|
|
528
|
+
- **FIX 7 - Circuit breaker normalization**: `hashError()` now normalizes ISO timestamps and improved memory address normalization. Added 5-minute TTL eviction to prevent stale errors from tripping the breaker.
|
|
529
|
+
- **FIX 8 - ASCII receipt**: Replaced all Unicode box-drawing characters and emojis in session receipt and reports with ASCII equivalents for terminal compatibility.
|
|
530
|
+
|
|
531
|
+
### Changed
|
|
532
|
+
- **Tool count**: 15 -> 16 MCP tools.
|
|
533
|
+
- **Test count**: 282 -> 305 tests across 11 test suites.
|
|
534
|
+
- **nreki_map**: Pinned rules now appended after repo map (was prepended before).
|
|
535
|
+
- **package.json**: Version bumped to 2.1.1.
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
## [2.1.0] - 2026-03-10
|
|
540
|
+
|
|
541
|
+
### Headline
|
|
542
|
+
NREKI v2.1 - 15 MCP tools, 282 tests, circuit breaker, surgical edit, pin memory, session receipt.
|
|
543
|
+
|
|
544
|
+
### Added - New Tools
|
|
545
|
+
- **`nreki_semantic_edit`** - Surgically edit a function/class/interface by name without reading or rewriting the entire file. Finds the exact AST node, replaces only those bytes, validates syntax before saving. Saves 98% of output tokens vs full file rewrites.
|
|
546
|
+
- **`nreki_circuit_breaker`** - Detects infinite failure loops (same error 3+ times, same file 5+ times, write-test-fail cycles). When tripped, forces Claude to stop and ask the human for guidance. Prevents doom loops that burn through remaining context.
|
|
547
|
+
- **`nreki_pin`** - Pin important rules Claude should never forget. Pinned items are injected into every `nreki_map` response, keeping project conventions permanently in Claude's attention window. Max 10 pins, 200 chars each, persisted to disk.
|
|
548
|
+
|
|
549
|
+
### Added - New Modules
|
|
550
|
+
- `src/semantic-edit.ts` - Zero-read surgical AST patching. Symbol name lookup, byte-level splice, syntax validation before write.
|
|
551
|
+
- `src/circuit-breaker.ts` - Loop detection engine with sliding window analysis, consecutive failure tracking, and automatic trip/reset.
|
|
552
|
+
- `src/pin-memory.ts` - Persistent pinned rules with deterministic output (sorted by id) for prompt cache compatibility.
|
|
553
|
+
|
|
554
|
+
### Added - Session Receipt
|
|
555
|
+
- `nreki_session_report` now generates an ASCII receipt showing input tokens saved, output tokens avoided, search queries, surgical edits, syntax errors blocked, doom loops prevented, pinned rules active, estimated USD savings, and model info.
|
|
556
|
+
|
|
557
|
+
### Changed
|
|
558
|
+
- **Tool count**: 12 -> 15 MCP tools.
|
|
559
|
+
- **Test count**: 194 -> 282 tests across 11 test suites.
|
|
560
|
+
- **nreki_map**: Now prepends pinned rules at the top of the repo map output.
|
|
561
|
+
- **README**: Complete rewrite for v2.1 with comparison table, 3 unique features highlight, receipt preview, and updated architecture diagram.
|
|
562
|
+
- **package.json**: Version bumped to 2.1.0.
|
|
563
|
+
|
|
564
|
+
### Architecture
|
|
565
|
+
- **Pin memory layer**: Pinned rules are stored in `.nreki/pins.json` and prepended to every `nreki_map` response. Deterministic output (sorted by id) preserves prompt cache compatibility.
|
|
566
|
+
- **Circuit breaker integration**: `nreki_terminal` automatically feeds errors to the circuit breaker for proactive loop detection.
|
|
567
|
+
|
|
568
|
+
## [2.0.0] - 2026-03-10
|
|
569
|
+
|
|
570
|
+
### Headline
|
|
571
|
+
NREKI v2.0 - 12 MCP tools, 194 tests, cache-aware two-layer architecture.
|
|
572
|
+
|
|
573
|
+
### Added - New Tools
|
|
574
|
+
- **`nreki_def`** - Go-to-definition by symbol name. AST-based, 100% precise, returns full source body with signature.
|
|
575
|
+
- **`nreki_refs`** - Find all references to a symbol across the project. Cross-file word-boundary matching with context.
|
|
576
|
+
- **`nreki_outline`** - List all symbols in a file with kind, signature, export status, and line ranges. Like VS Code Outline.
|
|
577
|
+
- **`nreki_validate`** - AST sandbox validator. Parses code with tree-sitter before disk write. Catches missing commas, unclosed braces, invalid syntax with exact line/column and fix suggestions. Prevents the "write broken code → see error → retry" token burn loop.
|
|
578
|
+
|
|
579
|
+
### Added - New Modules
|
|
580
|
+
- `src/ast-navigator.ts` - AST navigation engine for nreki_def, nreki_refs, nreki_outline. Walks project files, extracts symbols, signatures, export status.
|
|
581
|
+
- `src/ast-sandbox.ts` - AST sandbox validator with `validateCode()` and `validateDiff()`. Recursive tree walk with `hasError` subtree pruning for large-file performance.
|
|
582
|
+
- `src/terminal-filter.ts` - Terminal entropy filter. Strips ANSI codes, deduplicates stack traces, extracts unique errors and affected files. 89% token reduction on error output.
|
|
583
|
+
- `src/repo-map.ts` - Static deterministic repo map for Anthropic prompt cache optimization. Identical output for same repo state enables $0.30/M caching vs $3.00/M input.
|
|
584
|
+
|
|
585
|
+
### Changed
|
|
586
|
+
- **Embeddings**: Migrated from all-MiniLM-L6-v2 (384-dim) to jina-embeddings-v2-small-en (512-dim) for 3x better code search precision.
|
|
587
|
+
- **BM25 tuning**: Optimized k1=1.8, b=0.35 for code (vs default k1=1.2, b=0.75 for prose).
|
|
588
|
+
- **RRF tuning**: k=10 for sharper rank fusion (vs k=60 default).
|
|
589
|
+
- **Code tokenizer**: camelCase, snake_case, PascalCase identifiers split into sub-tokens for better BM25 matching.
|
|
590
|
+
- **Tool count**: 6 → 12 MCP tools.
|
|
591
|
+
- **Test count**: 90 → 194 tests across 8 test suites.
|
|
592
|
+
- **README**: Complete rewrite with self-benchmark results, two-layer architecture docs, and updated comparison table.
|
|
593
|
+
|
|
594
|
+
### Architecture
|
|
595
|
+
- **Two-layer design**: Layer 1 (static repo map, prompt-cacheable) + Layer 2 (dynamic context, per-query).
|
|
596
|
+
- **Cache-friendly**: nreki_map output is deterministic - same repo state produces identical text, enabling Anthropic prompt caching.
|
|
597
|
+
|
|
598
|
+
### Performance (Self-Benchmark)
|
|
599
|
+
- nreki_search: 10 results in 16ms (hybrid RRF fusion)
|
|
600
|
+
- nreki_def: Definition lookup in 128ms across 22 files
|
|
601
|
+
- nreki_refs: 20 references found in 11ms
|
|
602
|
+
- nreki_outline: 25 symbols extracted in 7ms
|
|
603
|
+
- nreki_compress: 5,502 → 1,753 tokens (68% reduction, medium level)
|
|
604
|
+
- nreki_terminal: 11,967 → 1,276 tokens (89% reduction)
|
|
605
|
+
- nreki_validate: Syntax error detection with line/column in <1ms
|
|
606
|
+
- nreki_map: 22 files mapped, 4,677 tokens, 169ms
|
|
607
|
+
|
|
608
|
+
## [1.2.0] - 2026-03-10
|
|
609
|
+
|
|
610
|
+
### Security
|
|
611
|
+
- **Path traversal protection**: All file operations now validate paths stay within workspace root (`safePath`)
|
|
612
|
+
- **Input validation**: All tool inputs validated with Zod schemas before processing
|
|
613
|
+
- **File size limits**: Files > 500KB and binary/minified files are automatically skipped
|
|
614
|
+
|
|
615
|
+
### Fixed
|
|
616
|
+
- **WASM memory leaks**: Tree-sitter parse trees now guaranteed cleanup via `safeParse` try/finally wrapper
|
|
617
|
+
- **Event loop blocking**: Large indexing operations now yield every 100 files via `setImmediate`
|
|
618
|
+
- **Aggressive compression stubs**: Functions now show line count, key references, and expand commands instead of empty bodies
|
|
619
|
+
- **Search tokenization**: Code identifiers (camelCase, snake_case, PascalCase) are now split into sub-tokens for better matching
|
|
620
|
+
- **Vector search accuracy**: Cosine similarity now uses proper norm computation instead of raw dot product
|
|
621
|
+
- **RRF scoring**: Verified correct rank-based fusion (was already using positions, not scores)
|
|
622
|
+
|
|
623
|
+
### Added
|
|
624
|
+
- `src/utils/path-jail.ts` - Path traversal protection
|
|
625
|
+
- `src/utils/safe-parse.ts` - WASM memory-safe parsing
|
|
626
|
+
- `src/utils/file-filter.ts` - File size and extension filtering
|
|
627
|
+
- `src/utils/code-tokenizer.ts` - Code-aware identifier tokenization
|
|
628
|
+
- `src/schemas.ts` - Zod validation schemas for all tools
|
|
629
|
+
- `.github/workflows/ci.yml` - CI/CD with matrix testing (3 OSes × 3 Node versions)
|
|
630
|
+
- `CONTRIBUTING.md` - Contributor guide
|
|
631
|
+
- `CHANGELOG.md` - This file
|
|
632
|
+
- `.github/ISSUE_TEMPLATE/bug_report.md`
|
|
633
|
+
- `.github/ISSUE_TEMPLATE/feature_request.md`
|
|
634
|
+
- Comprehensive test suite for all new utilities
|
|
635
|
+
|
|
636
|
+
### Performance
|
|
637
|
+
- Pre-computed vector norms at index time (avoids recalculation during search)
|
|
638
|
+
- Proper cosine similarity with normalized vectors
|
|
639
|
+
|
|
640
|
+
## [1.1.1] - 2026-03-09
|
|
641
|
+
|
|
642
|
+
### Initial Release
|
|
643
|
+
- MCP server with 6 tools: nreki_search, nreki_audit, nreki_compress, nreki_status, nreki_session_report, nreki_read
|
|
644
|
+
- Hybrid RRF search (BM25 + vector similarity)
|
|
645
|
+
- Three-tier classic compression + LLMLingua-2-inspired advanced compression
|
|
646
|
+
- Real-time file watching with chokidar
|
|
647
|
+
- Token consumption monitoring and burn rate prediction
|
|
648
|
+
- Pre-tool-use interception hook
|