nreki 12.3.0 → 12.5.1
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 +51 -0
- package/README.md +225 -217
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +453 -227
- package/dist/index.js.map +1 -1
- package/dist/init/agent-detect.d.ts.map +1 -1
- package/dist/init/agent-detect.js +3 -1
- package/dist/init/agent-detect.js.map +1 -1
- package/dist/init/global-register.d.ts +61 -0
- package/dist/init/global-register.d.ts.map +1 -0
- package/dist/init/global-register.js +822 -0
- package/dist/init/global-register.js.map +1 -0
- package/dist/init/init-runner.d.ts +8 -0
- package/dist/init/init-runner.d.ts.map +1 -1
- package/dist/init/init-runner.js +87 -6
- package/dist/init/init-runner.js.map +1 -1
- package/dist/init/setup-ui.d.ts +70 -0
- package/dist/init/setup-ui.d.ts.map +1 -0
- package/dist/init/setup-ui.js +533 -0
- package/dist/init/setup-ui.js.map +1 -0
- package/dist/init/voyage-prompt.d.ts +85 -0
- package/dist/init/voyage-prompt.d.ts.map +1 -0
- package/dist/init/voyage-prompt.js +263 -0
- package/dist/init/voyage-prompt.js.map +1 -0
- package/dist/project-root.d.ts +41 -0
- package/dist/project-root.d.ts.map +1 -1
- package/dist/project-root.js +176 -0
- package/dist/project-root.js.map +1 -1
- package/dist/search/voyage.d.ts +2 -1
- package/dist/search/voyage.d.ts.map +1 -1
- package/dist/search/voyage.js +5 -2
- package/dist/search/voyage.js.map +1 -1
- package/dist/utils/voyage-key.d.ts +32 -0
- package/dist/utils/voyage-key.d.ts.map +1 -0
- package/dist/utils/voyage-key.js +89 -0
- package/dist/utils/voyage-key.js.map +1 -0
- package/package.json +2 -9
- package/scripts/download-wasm.js +5 -1
- package/src/index.ts +458 -226
- package/src/init/agent-detect.ts +5 -1
- package/src/init/global-register.ts +862 -0
- package/src/init/init-runner.ts +93 -6
- package/src/init/setup-ui.ts +588 -0
- package/src/init/voyage-prompt.ts +316 -0
- package/src/project-root.ts +245 -60
- package/src/search/voyage.ts +5 -2
- package/src/utils/voyage-key.ts +89 -0
- package/templates/voyage-key-dialog.ps1 +83 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [12.5.1] - 2026-11-27
|
|
4
|
+
|
|
5
|
+
12.5.0 was tagged on GitHub but never published to npm: CI failed on all 9 jobs (the full suite had not been run). Found by reviewing it:
|
|
6
|
+
|
|
7
|
+
- **The file watcher starts after the MCP handshake again.** 12.5.0's per-workspace runtime started it before `server.connect`, which the v11.2.1 guard test caught on every OS. `bootLive` now writes the session marker and upgrades the hook; the new `startBackground` starts the watcher and the WASM preload once the transport is connected.
|
|
8
|
+
- **A global server recognizes host folders reached through a link.** On macOS the temp folder is `/var/…` for `HOME` and `/private/var/…` for `process.cwd()`, so 12.5.0 took the Antigravity plugin folder for a project and wrote `.nreki/` into it (macOS CI). Folders are now compared with their links resolved.
|
|
9
|
+
- **`project_root` can no longer point NREKI at any folder.** The workspace folder bounds every read and write NREKI makes (safePath), and in 12.5.0 any tool call could rebind it to any existing folder: the home folder (NREKI then watched all of it), `~/.claude` (its hooks run code), `~/.ssh`, or a drive root. Now a folder inside the current workspace keeps it; with MCP roots it must be inside one of them; a server pinned by `NREKI_PROJECT_ROOT` or started in a project (a folder with `.git`, `package.json`, `tsconfig.json`…) cannot leave it; only a host that gave no folder (Antigravity's global plugin) lets `project_root` choose, and never the home folder, a folder above it, a hidden folder in it, a drive root or a system folder. The same list keeps a server started in `/`, `C:\` or `Program Files` from binding there.
|
|
10
|
+
- **`deinit --global` keeps your own hooks.** `init` adds NREKI's command to a PreToolUse matcher you already had in `~/.claude/settings.json` (your own `Edit` hook, say); 12.5.0's `deinit --global` deleted that whole matcher, your hook included. It now removes NREKI's command only.
|
|
11
|
+
- **`--no-prompt` no longer changes the install scope.** In 12.5.0 it also turned the user-scope install into a project install; `--prompt`/`--no-prompt` now only decide whether the Voyage box opens.
|
|
12
|
+
- **`npx nreki key` leaves the folder it runs in alone** (it migrated that folder's `.mcp.json` entry).
|
|
13
|
+
- **Switching workspace stops the old one's gopls/pyright** (they kept running until the process exited), and a tool call waits for a `roots/list_changed` switch in flight instead of running in the workspace being closed.
|
|
14
|
+
- Note: Cursor does not load `~/.cursor/rules/*.mdc` as global rules (forum reports; its global rules live in Settings › Rules), so in Cursor the first NREKI call may answer with the `project_root` hint.
|
|
15
|
+
|
|
16
|
+
## [12.5.0] - 2026-11-27
|
|
17
|
+
|
|
18
|
+
- **Zero-approval global install (`npx nreki init`).** In an interactive terminal (including Git Bash on Windows), `npx nreki init` now registers NREKI at **user scope** across Claude Code (`~/.claude.json` + `~/.claude/`), Antigravity (`~/.gemini/config/plugins/nreki/`), Cursor (`~/.cursor/mcp.json` + `~/.cursor/rules/nreki.mdc`), Codex (`~/.codex/config.toml` + `~/.codex/AGENTS.md`), and VS Code (`Code/User/mcp.json` when installed), migrating away stale NREKI `.mcp.json` project entries while preserving other servers. `--project` keeps repo-scoped installs, and `npx nreki deinit --global` removes user-scoped registrations cleanly.
|
|
19
|
+
- **Local browser Voyage setup card (`127.0.0.1`) + `npx nreki key`.** `init` opens a token-protected local setup card in the user's browser on Windows, macOS, and Linux with inline Voyage API key verification (`~/.nreki/voyage.key`), falling back automatically to the Windows dialog or hidden terminal prompt when no browser opens.
|
|
20
|
+
- **Dynamic workspace binding for global MCP servers.** Global servers stay idle when started in a host config directory (`~/.gemini/config/plugins/nreki`, `~`, etc.) without polluting it, and bind to the open project via MCP `roots/list` (`notifications/roots/list_changed`), `project_root`, or absolute file paths.
|
|
21
|
+
- **Standalone `npm install nreki`.** `typescript` is now bundled in `dependencies` instead of a strict `peerDependencies` constraint so `npm i nreki` and `npm i -g nreki` succeed across Python, Go, C++, JS, and global installs.
|
|
22
|
+
|
|
23
|
+
## [12.4.1] - 2026-11-26
|
|
24
|
+
|
|
25
|
+
- **The Voyage box opens visibly on Windows.** In 12.4.0 (tagged, never published to npm) it opened invisible: `spawnSync`'s `windowsHide` sets `SW_HIDE` in the child's startup info, and Windows applies it to the first window the child shows, here the box itself. UI Automation found no window for the dialog process, so `init` waited for an answer nobody could give.
|
|
26
|
+
- The box now starts without `windowsHide`. Run from a terminal, PowerShell shares the terminal's console.
|
|
27
|
+
- The script spends the first `ShowWindow` call on an invisible throwaway form, so a launcher's `SW_HIDE` can never hide the box.
|
|
28
|
+
- Checked end to end with UI Automation and `BM_CLICK` / `WM_SETTEXT`, with no keyboard input: a visible window in Spanish; "Sin Voyage" returns `local`; a typed key comes back whole.
|
|
29
|
+
|
|
30
|
+
## [12.4.0] - 2026-11-26
|
|
31
|
+
|
|
32
|
+
`npx nreki init` asks for the Voyage API key in a box, and CI is green again on every OS and Node version.
|
|
33
|
+
|
|
34
|
+
- **The Voyage box.** In an interactive terminal, `init` shows a box for the Voyage API key: on Windows a small window with a masked field, elsewhere a hidden prompt in the terminal.
|
|
35
|
+
- Before saving a typed key, `init` checks it with one tiny Voyage request. A rejected key asks again, up to three times.
|
|
36
|
+
- The key is saved outside every project in `~/.nreki/voyage.key`, next to the trust key: mode 0600, written to a fresh temp file and renamed, never through a link.
|
|
37
|
+
- Accepting turns Voyage on in this project's registrations (`NREKI_SEMANTIC=voyage`). "No Voyage" turns it off. Closing the box changes nothing.
|
|
38
|
+
- With a key already set, an empty field uses it.
|
|
39
|
+
- On Windows, an existing user variable `NREKI_VOYAGE_API_KEY` is updated to the new key, so it cannot shadow it. Elsewhere `init` warns when an environment variable holds a different key.
|
|
40
|
+
- The box speaks Spanish on a Spanish system.
|
|
41
|
+
- It never appears when `init` runs without a terminal (as an agent runs it), under `CI`, with `--dry-run`, `--no-mcp`, `--no-voyage`, or the new `--no-prompt`.
|
|
42
|
+
- **NREKI reads the saved key** when no environment variable holds one: `NREKI_VOYAGE_API_KEY`, then `VOYAGE_API_KEY`, then `~/.nreki/voyage.key`. A host that forwards only some variables (Codex) still gets the key. A key alone never turns Voyage on: the project still opts in with `NREKI_SEMANTIC=voyage`.
|
|
43
|
+
- **Session marker removed before the native-edit endpoint closes.** A reader never finds a marker pointing at a closed endpoint. This also fixes a race in the built-server test, which failed on slow Linux CI runners.
|
|
44
|
+
- **CI:**
|
|
45
|
+
- Each failed test becomes a GitHub annotation (`scripts/ci-test-report.mjs`); annotations are readable without signing in, unlike job logs. That is how the two failures of 12.3.0 were found:
|
|
46
|
+
- On Windows, the `NREKI_PROJECT_ROOT` server test started the server through `tsx`. A child process outlived the client and kept the project folder locked (`EBUSY`). The test now starts the built server, waits for it to exit, and retries removing the folder while Windows still holds it: on Node 20/22 the synchronous `fs.rmSync` does not retry `EBUSY` at all, whatever `maxRetries` says; Node 24 does.
|
|
47
|
+
- On Linux, the race above.
|
|
48
|
+
- `actions/checkout@v5` and `actions/setup-node@v5`.
|
|
49
|
+
- Node 24 no longer runs as `continue-on-error`, which reported its failures as green.
|
|
50
|
+
- `npm run typecheck:tests` runs in CI.
|
|
51
|
+
|
|
52
|
+
Tests: `tests/voyage-key-prompt.test.ts`. One test checks that `init` run without a terminal never shows the box.
|
|
53
|
+
|
|
3
54
|
## [12.3.0] - 2026-11-26
|
|
4
55
|
|
|
5
56
|
`npx nreki init` now installs NREKI in one command: it writes each agent's instructions and registers NREKI as that agent's MCP server, with the project folder pinned.
|
package/README.md
CHANGED
|
@@ -1,217 +1,225 @@
|
|
|
1
|
-
# NREKI - Bulletproof Shield for AI Coding Agents
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img src="https://img.shields.io/npm/v/nreki?style=for-the-badge&color=blue" alt="npm version">
|
|
5
|
-
<img src="https://img.shields.io/badge/Tests-
|
|
6
|
-
<img src="https://img.shields.io/badge/AHI-9.7%2F10-brightgreen?style=for-the-badge" alt="AHI 9.7/10">
|
|
7
|
-
<img src="https://img.shields.io/badge/Languages-TS%20%7C%20JS%20%7C%20Go%20%7C%20Python%20%7C%20Kotlin%20%7C%20Java%20%7C%20C%2B%2B-blue?style=for-the-badge" alt="Multi-language">
|
|
8
|
-
<img src="https://img.shields.io/badge/Cloud-Zero-orange?style=for-the-badge" alt="Zero Cloud by default">
|
|
9
|
-
<img src="https://img.shields.io/badge/License-Apache_2.0-yellow?style=for-the-badge" alt="Apache 2.0">
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
**MCP plugin that validates AI agent edits in RAM before they touch disk.** When Claude Code, Cursor, or Copilot changes a function signature in one file and breaks 30 others, NREKI catches it in milliseconds - the file is never written. If the error is structural (missing import, forgotten `await`), NREKI auto-fixes it in RAM. Zero tokens wasted on fix-retry doom loops.
|
|
13
|
-
|
|
14
|
-
**v12.
|
|
15
|
-
|
|
16
|
-
**v12.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
**v12.
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
npx nreki init
|
|
53
|
-
npx nreki
|
|
54
|
-
npx nreki
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
|
121
|
-
|
|
122
|
-
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
in the
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
|
147
|
-
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
1
|
+
# NREKI - Bulletproof Shield for AI Coding Agents
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/npm/v/nreki?style=for-the-badge&color=blue" alt="npm version">
|
|
5
|
+
<img src="https://img.shields.io/badge/Tests-1873-brightgreen?style=for-the-badge" alt="1873 Tests">
|
|
6
|
+
<img src="https://img.shields.io/badge/AHI-9.7%2F10-brightgreen?style=for-the-badge" alt="AHI 9.7/10">
|
|
7
|
+
<img src="https://img.shields.io/badge/Languages-TS%20%7C%20JS%20%7C%20Go%20%7C%20Python%20%7C%20Kotlin%20%7C%20Java%20%7C%20C%2B%2B-blue?style=for-the-badge" alt="Multi-language">
|
|
8
|
+
<img src="https://img.shields.io/badge/Cloud-Zero-orange?style=for-the-badge" alt="Zero Cloud by default">
|
|
9
|
+
<img src="https://img.shields.io/badge/License-Apache_2.0-yellow?style=for-the-badge" alt="Apache 2.0">
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
**MCP plugin that validates AI agent edits in RAM before they touch disk.** When Claude Code, Cursor, or Copilot changes a function signature in one file and breaks 30 others, NREKI catches it in milliseconds - the file is never written. If the error is structural (missing import, forgotten `await`), NREKI auto-fixes it in RAM. Zero tokens wasted on fix-retry doom loops.
|
|
13
|
+
|
|
14
|
+
**v12.5 — one install per user + a Voyage setup card.** Run `npx nreki init` in a terminal: a local setup card opens in your browser (`127.0.0.1`, falling back to the Windows dialog or a hidden terminal prompt) so you can paste and verify your Voyage API key (`~/.nreki/voyage.key`), and NREKI registers once at **user scope** for Claude Code (`~/.claude.json`), Antigravity (`~/.gemini/config/plugins/nreki/`), Cursor (`~/.cursor/mcp.json`), Codex (`~/.codex/config.toml`), and VS Code (`Code/User/mcp.json`), with no per-project `.mcp.json` approval. NREKI works in the project the agent opens: the folder it was started in, the editor's MCP roots, or, for hosts that give neither (Antigravity's global plugin; Cursor may too), the `project_root` the agent passes on its first call. A tool call can never move it outside that workspace, nor onto your home folder, a hidden folder in it, or a system folder.
|
|
15
|
+
|
|
16
|
+
**v12.4.1 — a box for the Voyage key.** `npx nreki init` asks for your Voyage API key (a small window on Windows, a hidden prompt elsewhere), checks it with Voyage, saves it outside every project (`~/.nreki/voyage.key`) and turns semantic search on for the project. It never asks when an agent runs `init`.
|
|
17
|
+
|
|
18
|
+
**v12.3.0 — one command installs NREKI.** Run `npx nreki init` in a project: it writes each agent's instructions and registers NREKI as that agent's MCP server (Claude Code, Codex, Antigravity, Cursor, VS Code/Copilot), with the project folder pinned so NREKI indexes the right code. Without agent files in the project it installs for the agents found on your computer. `--voyage` turns on semantic search. `NREKI_PROJECT_ROOT` names the project for hosts that start servers in another folder (measured: Antigravity starts a global plugin's server in the plugin folder). `npx nreki deinit` removes the registrations too.
|
|
19
|
+
|
|
20
|
+
**v12.2.0 — Spanish/hybrid recall, symbol deletion, and opt-in native edit preflight.** By default, NREKI writes its session marker without opening any local IPC socket or pipe: the Claude hook keeps large-file `Read` steering active and lets native `Edit`, `MultiEdit` and `Write` pass silently. Claude instructions (`CLAUDE.md`, `SKILL.md`, and MCP initialization) use native `Edit` for single-file changes and reserve `nreki_code action:"batch_edit"` for cross-file signature changes and renames (`AGENTS.md` keeps the `batch_edit` + checker workflow for Codex). `edit` and `batch_edit` also accept `mode:"replace"` with `new_code:""` to delete a symbol under full AST and compiler validation, and `context` / hybrid search bridges Spanish software/business terms into English on the lexical side while keeping exact names, paths and Voyage queries unchanged.
|
|
21
|
+
|
|
22
|
+
Opting in with `NREKI_NATIVE_PREFLIGHT=1` enables the Claude hook v5 authenticated local IPC preview for native `Edit`, `MultiEdit` and `Write`: accepted edits add no hook output, and rejected edits return diagnostics before the native tool writes. That opt-in preview never writes proposed code or auto-heals, restores the kernel under the same lock, enforces comment-only Anti-Sweep checks plus an opt-in-only differential TypeScript AST zero-`any` check (`batch_edit` does not enforce zero-`any` by default), and batches external watcher refreshes without redundant compiler baseline rebuilds. Declaration surface checks strip JSDoc/comments (preserving triple-slash directives) so comment-only edits report an unchanged exported API in both `batch_edit` footers and preflight, while modules containing `export *` or `export =` are never treated as purely additive so new exports cannot silently shadow re-exported names in consumers outside the active `tsconfig`. This preflight cannot make the later native write atomic with validation: use `batch_edit` for transactional multi-file writes. The hook does not intercept shell writes.
|
|
23
|
+
|
|
24
|
+
**v12.1.2 — fixes from an external audit of 12.1.1.**
|
|
25
|
+
- Secrets are blanked across a typed or commented initializer before code is sent to the optional Voyage index.
|
|
26
|
+
- NREKI never writes its own files (`.nreki/…`) through a link; the installed hook is v4.
|
|
27
|
+
- `context` shows an imported helper only from the file that declares it.
|
|
28
|
+
- The footer reports importers compiled by another tsconfig, in project mode too.
|
|
29
|
+
- Sibling anonymous callbacks keep their own errors in the error baseline.
|
|
30
|
+
- See [CHANGELOG.md](CHANGELOG.md#1212---2026-11-14).
|
|
31
|
+
|
|
32
|
+
**v12.1.1 — context finds every issue, safer by default.**
|
|
33
|
+
- `context` searches every issue that names no code: a named type or a capitalized word no longer cancels that search. `path` scopes it.
|
|
34
|
+
- Importers are resolved the way the compiler resolves them, tsconfig aliases included, so the footer no longer calls an unchecked importer "no importers".
|
|
35
|
+
- Fixes from an external audit:
|
|
36
|
+
- no writes through symbolic links;
|
|
37
|
+
- more sensitive files blocked;
|
|
38
|
+
- secrets blanked before code is sent to the optional Voyage index;
|
|
39
|
+
- auto-heal no longer reports fixes it did not make.
|
|
40
|
+
- See [CHANGELOG.md](CHANGELOG.md#1211---2026-11-14).
|
|
41
|
+
|
|
42
|
+
**v12.1.0 — fewer turns, honest footers.** `nreki_navigate action:"context"` returns, in one call, the code a task names; for a task that names no code it returns the best hits of each issue. The `[Validated]` footer says when re-running tsc is redundant. `Class.method` names work everywhere, and an optional Voyage index adds semantic search. Measured with Codex on two new projects, three pairs each: 33 % fewer tokens, then 1.8 % more (see [Token cost](#token-cost)). Also included are the fixes from two external security and integrity audits. See [CHANGELOG.md](CHANGELOG.md#1210---2026-11-13).
|
|
43
|
+
|
|
44
|
+
**v12.0.0 — Edit-Safety MCP (BREAKING).** NREKI is an edit-safety layer: it validates and atomically commits agent edits, and provides local code navigation. Host agents bring their own semantic retrieval. **`hybrid_search` (NREKI + BM25 RRF fusion) was removed** — its +10pp recall did not justify the ~4.3× token cost for a use case that does not exist when the agent already has grep. `search` (BM25 keywords + dependency topology, with an optional Voyage semantic index) and `fast_grep` (RAM-resident exact substring) cover local navigation; `nreki_code` batch-edits with in-RAM compiler/LSP validation. See [CHANGELOG.md](CHANGELOG.md#1200) for the migration path. (v11.0.0 removed ONNX embeddings; v12.0.0 removed the hybrid_search fusion — same precedent.)
|
|
45
|
+
|
|
46
|
+
<p align="center"><img src="docs/demo.gif" alt="NREKI outline with defect + ghost tags"></p>
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm i -g nreki # installs NREKI, TypeScript compiler API, and Tree-sitter WASM grammars
|
|
52
|
+
npx nreki init # opens the Voyage API key setup box + installs globally for Claude, Antigravity, Cursor, Codex & VS Code
|
|
53
|
+
npx nreki key # re-open the Voyage API key setup box anytime
|
|
54
|
+
npx nreki init --project # install inside the current project folder only (.mcp.json, .codex/config.toml, etc.)
|
|
55
|
+
npx nreki init --voyage # turn Voyage semantic search on explicitly
|
|
56
|
+
npx nreki init --no-prompt # never show the Voyage key box
|
|
57
|
+
npx nreki init --agent codex,antigravity # choose specific agents (claude, codex, antigravity, cursor, cline, copilot, generic)
|
|
58
|
+
npx nreki init --dry-run # preview the plan, write nothing
|
|
59
|
+
npx nreki init --no-mcp # instructions only
|
|
60
|
+
npx nreki deinit --global # remove NREKI's global + local hooks, instructions and MCP registrations
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
In a terminal, `init` first opens a card for your Voyage API key (optional) in your browser; without a browser it falls back to a small window on Windows, a hidden prompt elsewhere. A typed key is checked with Voyage and saved in `~/.nreki/voyage.key` (outside every project, readable only by you), and Voyage is turned on in the registrations; "No Voyage" keeps local search only. With a key already set, leave the field empty to use it. NREKI reads `NREKI_VOYAGE_API_KEY`, then `VOYAGE_API_KEY`, then that file. `--no-prompt` skips the card; it does not change where NREKI is installed.
|
|
64
|
+
|
|
65
|
+
In a terminal `init` installs at user scope, as above. With `--project` (and when an agent runs `init`), it installs for every agent configured in the project. If there is none, it installs for the agents found on this computer (`~/.claude`, `~/.codex`, `~/.gemini/antigravity`, `~/.cursor`); if there is none either, it writes `AGENTS.md`. Then it prints what is left to do in each agent, such as approving the server in Claude Code or trusting the folder in Codex. Re-running it after an upgrade updates NREKI's own entries to the new version and keeps fields you added; an entry named `nreki` that NREKI did not write is left alone unless `--force`.
|
|
66
|
+
|
|
67
|
+
| Agent | Detected in the project via | Instructions | MCP registration (project folder pinned by) |
|
|
68
|
+
|---------------|-----------------------------------------------------|------------------------------------------------|-------------------------------------------------------------|
|
|
69
|
+
| `claude` | `.claude/` or `CLAUDE.md` | `CLAUDE.md` block, skill, enforcer hook, `.claude/settings.json` | `.mcp.json` (Claude Code starts it in the project) |
|
|
70
|
+
| `codex` | `.codex/` | `AGENTS.md` block | `.codex/config.toml` (`cwd`; Codex reads it only for trusted projects) |
|
|
71
|
+
| `antigravity` | `.agents/mcp_config.json`, `.agents/rules/`, `GEMINI.md` | `AGENTS.md` block (always-on rule) | `.agents/mcp_config.json` (Antigravity starts it in the project) |
|
|
72
|
+
| `cursor` | `.cursor/` or `.cursorrules` | `.cursor/rules/nreki.mdc` | `.cursor/mcp.json` (`NREKI_PROJECT_ROOT`) |
|
|
73
|
+
| `copilot` | `.github/copilot-instructions.md` | `.github/copilot-instructions.md` block | `.vscode/mcp.json` (`NREKI_PROJECT_ROOT=${workspaceFolder}`) |
|
|
74
|
+
| `cline` | `.clinerules` | `.clinerules/nreki.md` | by hand: Cline keeps MCP servers in its global settings |
|
|
75
|
+
| `generic` | none of the above | `AGENTS.md` block | by hand |
|
|
76
|
+
|
|
77
|
+
The Codex and Cursor entries hold this computer's path to the project: keep `.codex/` and `.cursor/mcp.json` out of git. On Windows every entry launches `cmd /c npx -y nreki@<version>`, because `npx` is a `.cmd` shim there.
|
|
78
|
+
|
|
79
|
+
Registering by hand works too, from the project folder: `claude mcp add nreki -- npx -y nreki` (Windows: `claude mcp add nreki -- cmd /c npx -y nreki`), or `{ "mcpServers": { "nreki": { "command": "npx", "args": ["-y", "nreki"] } } }` in an MCP client's config. If the client starts servers in another folder, add `"env": { "NREKI_PROJECT_ROOT": "<absolute project path>" }`.
|
|
80
|
+
|
|
81
|
+
Since 12.2.0 the npm package is **`nreki`**. Releases up to 12.0.0 were published as `@ruso-0/nreki`; if you configured that name, run `npx nreki init` or replace it with `nreki` in your MCP config.
|
|
82
|
+
|
|
83
|
+
First MCP run indexes the project automatically in the background — `fast_grep` returns RAM-resident substring matches immediately while NREKI's semantic index warms (v11.2.1+). Zero config for TS/JS; point a `tsconfig.json` at your code and NREKI detects the right validation mode.
|
|
84
|
+
|
|
85
|
+
## How it works
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
AI proposes edit -> NREKI intercepts in RAM -> Compiler/LSP validates
|
|
89
|
+
| |
|
|
90
|
+
| No errors ----------------------> Two-Phase Atomic Commit to disk
|
|
91
|
+
| Errors found --> Auto-Heal (TS CodeFix + LSP codeAction, atomic)
|
|
92
|
+
| |
|
|
93
|
+
| Fixed all? ---> Commit to disk
|
|
94
|
+
| Some remain? -> Full rollback. Disk untouched. Errors returned to agent.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Three tools (`nreki_navigate`, `nreki_code`, `nreki_guard`), 26 actions (11 navigate + 6 code + 9 guard), 4 languages (TS/JS, Go via gopls, Python via pyright). Works with any MCP-compatible agent. Apache 2.0.
|
|
98
|
+
|
|
99
|
+
### Token cost
|
|
100
|
+
|
|
101
|
+
Depending on the client, an agent pays NREKI's three tool definitions (~700 tokens) on every request of a session or once when it looks them up, and every tool result again on each later request. NREKI saves tokens only when it saves more than that: fewer turns and smaller results than the agent's own tools.
|
|
102
|
+
|
|
103
|
+
- `nreki_navigate action:"context" query:"<the task>"` returns, in one call, the code the task names: symbols verbatim with their line ranges, where the fields it mentions occur, and who imports each file. Exploring with `map`/grep/reads usually takes two or three turns.
|
|
104
|
+
- `read`/`compress` with `focus:"a,b"` return only those symbols; edits return one line plus the `[Validated: …]` footer.
|
|
105
|
+
- Measured with Codex (2026-11-13) on synthetic TypeScript projects of 30–40 files, three pairs per run. The first run cost 25 % more tokens with NREKI: `read` ignored `focus`, agents re-read what `context` returned, and took extra turns. After those fixes, a pre-registered run was a tie (+0.02 %) and a run on a new project cost +4.97 %: `context` saved the reading turns, but agents sent `batch_edit` alone and ran the checker on the next turn. With `context` now asking for the checker in the same cell, a run on another new project used **33 % fewer tokens**: 225,391 vs 336,643, 12 vs 18 turns, NREKI ahead in all 3 pairs, all 6 solutions correct. Every NREKI session took the minimum 4 turns: checker, `context`, `batch_edit` plus checker, answer. That is one project and three pairs: a measurement, not a guarantee. On a third new project (42 files) the published 12.1.0 cost 1.8 % more. In two of its three sessions `context` let one capitalized word ("Station", a type) stand for the whole task and returned none of the files to fix. 12.1.1 searches every issue that names no code. One pair on yet another new project, run on the 12.1.1 code before release, used 40.85 % fewer tokens: 449,645 vs 760,190, 21 vs 36 turns, both solutions correct. That is one session per arm, and the agents delegated differently. All runs after the fixes had the optional Voyage index on (see Privacy). In that last pair it made no query, so the default, `context` with BM25 alone, has not been measured on its own.
|
|
106
|
+
|
|
107
|
+
## Highlights
|
|
108
|
+
|
|
109
|
+
- **Atomic multi-TextEdit healing.** When gopls or pyright proposes a quickfix with coupled edits (import + usage), NREKI applies every TextEdit of the chosen action together with per-file savepoints and bottom-up offset ordering. No more doom-loop retries where only the import lands and the usage stays broken.
|
|
110
|
+
- **Tolerant Patch mode.** `nreki_code action:"edit" mode:"patch"` now retries with indent-flexible matching when the exact-indent search fails and the content is unique. The literal-`$` guarantee is preserved end-to-end (no V8 `$&` / `$$` substitution surprises).
|
|
111
|
+
- **Cognitive Enforcer.** Agents can't `batch_edit` blindly - every edit in a batch is validated against a per-file passport (outline seen? symbol focused?). The v10.5.7 fix closed a bypass where 2+ edits could smuggle blind mutations through.
|
|
112
|
+
- **TTRD Bounties.** Successful strict-type restoration reports the exact CFI (Cognitive Friction Index) discount to the agent. Pavlovian reinforcement that actually quantifies what improved.
|
|
113
|
+
- **Defect radar + ghost oracle.** Four inline detectors and a 0-ext-refs tagger run during `outline` - free signals, no extra tool call.
|
|
114
|
+
- **Executable engrams.** Pin insights to symbols. Engrams prefixed `ASSERT` survive AST mutation; everything else invalidates on body change so memory can't go stale.
|
|
115
|
+
|
|
116
|
+
## Language support (Validation + Auto-heal)
|
|
117
|
+
|
|
118
|
+
| Language | Validation | Auto-heal |
|
|
119
|
+
|----------|------------|-----------|
|
|
120
|
+
| TypeScript / JavaScript | Full (TS Compiler API) | TS CodeFix API |
|
|
121
|
+
| Go | gopls LSP sidecar | codeAction (atomic) |
|
|
122
|
+
| Python | pyright / basedpyright LSP sidecar | codeAction (atomic; basedpyright only — plain pyright validates without healing) |
|
|
123
|
+
|
|
124
|
+
### What an accepted edit was checked against
|
|
125
|
+
|
|
126
|
+
Semantic checking is on whenever the project root has a `tsconfig.json`/`jsconfig.json`, a Python marker (`pyproject.toml`, `requirements.txt`, `setup.py`, `Pipfile`) or a `go.mod`; without one, edits get the syntax check only. The `[Validated: …]` footer of every edit states what ran for that edit.
|
|
127
|
+
|
|
128
|
+
| Project | Checked together with the edit |
|
|
129
|
+
|---------|--------------------------------|
|
|
130
|
+
| TypeScript, up to 200 files | the edited files and their direct importers (up to 50) |
|
|
131
|
+
| TypeScript, 201–1000 files | the whole program |
|
|
132
|
+
| TypeScript, over 1000 files | the edited files and their direct importers (up to 50) |
|
|
133
|
+
| Go | the edited files, the other files of their package and the files that import them (up to 50) |
|
|
134
|
+
| Python | the edited files and the files that import them (up to 50) |
|
|
135
|
+
|
|
136
|
+
For Go and Python only the errors an edit adds are fatal: an error that was already there does not block it. Transitive importers are not checked in any row but the second; run the compiler or the tests when the footer says so.
|
|
137
|
+
|
|
138
|
+
## AST parser coverage
|
|
139
|
+
|
|
140
|
+
NREKI's tree-sitter parser layer indexes additional languages for
|
|
141
|
+
foveal compression + symbol retrieval + semantic-edit syntactic
|
|
142
|
+
validation. These languages do **not** have LSP sidecars and
|
|
143
|
+
therefore receive no auto-heal; otherwise their files participate
|
|
144
|
+
in the retrieval index identically to TypeScript files.
|
|
145
|
+
|
|
146
|
+
| Language | Extensions | Parser | Foveal | Syntax check | LSP auto-heal | Type Ledger |
|
|
147
|
+
|-------------|-----------------------------------------|--------|--------|--------------|---------------|-------------|
|
|
148
|
+
| TypeScript | .ts .tsx .mts .cts | ✓ | ✓ | ✓ | ✓ (tsc) | ✓ |
|
|
149
|
+
| JavaScript | .js .jsx .mjs .cjs | ✓ | ✓ | ✓ | ✓ (tsc) | ✓ |
|
|
150
|
+
| Python | .py | ✓ | ✓ | ✓ | ✓ (pyright) | — |
|
|
151
|
+
| Go | .go | ✓ | ✓ | ✓ | ✓ (gopls) | — |
|
|
152
|
+
| CSS | .css | ✓ | ✓ | ✓ | — | — |
|
|
153
|
+
| JSON | .json | ✓ | ✓ | ✓ | — | — |
|
|
154
|
+
| HTML | .html | ✓ | ✓ | ✓ | — | — |
|
|
155
|
+
| **Kotlin** | .kt .kts | ✓ | ✓ | ✓ | — | — |
|
|
156
|
+
| **Java** | .java | ✓ | ✓ | ✓ | — | — |
|
|
157
|
+
| **C++** | .cpp .cc .cxx .hpp .hh .hxx .h* | ✓ | ✓ | ✓ | — | — |
|
|
158
|
+
| **C** | .c .h* | ✓ | ✓ | ✓ | — | — |
|
|
159
|
+
|
|
160
|
+
Kotlin / Java / C++ / C activation in v11.0.x covers Android development
|
|
161
|
+
(Kotlin app layer + Java legacy + C++ NDK native layer + C NDK code) and the
|
|
162
|
+
broader JVM / native cross-platform ecosystem.
|
|
163
|
+
|
|
164
|
+
> *`.h` headers are routed at parse time: headers containing
|
|
165
|
+
> C++ markers (template, namespace, class, `#ifdef __cplusplus`)
|
|
166
|
+
> use the C++ grammar; pure C headers use the C grammar. Default
|
|
167
|
+
> to C grammar for ambiguous cases.
|
|
168
|
+
|
|
169
|
+
**Known limitation (v11.0.x):** cross-file import detection for
|
|
170
|
+
Kotlin / Java / C++ / C is not yet implemented. Repo-map dependency edges
|
|
171
|
+
for files in these languages are intra-file only until v11.0.x.1.
|
|
172
|
+
|
|
173
|
+
### Known limitations (v11.0.1)
|
|
174
|
+
|
|
175
|
+
**Android XML manifests and Gradle build files are NOT yet indexed.**
|
|
176
|
+
AndroidManifest.xml, resource XMLs (`res/layout/`, `res/values/`, etc.),
|
|
177
|
+
and Gradle build scripts (`build.gradle` Groovy DSL) coverage is tracked
|
|
178
|
+
for v11.0.2 (see issue #4).
|
|
179
|
+
|
|
180
|
+
**WASM checksum verification deferred.** Upstream grammar upgrades may not
|
|
181
|
+
propagate to vendor `wasm/` directory due to skip-if-exists logic in
|
|
182
|
+
`scripts/download-wasm.js`. SHA-256 checksum verification tracked as issue #5.
|
|
183
|
+
|
|
184
|
+
**chunks table lacks language column.** Retrieval language-aware scoring
|
|
185
|
+
requires runtime path extension filtering. Breaking migration tracked as
|
|
186
|
+
issue #6 (coordinated with v11.0.2 XML activation due to noise risk
|
|
187
|
+
amplification).
|
|
188
|
+
|
|
189
|
+
**Type Ledger (cross-file architectural dependency mapping) remains
|
|
190
|
+
TypeScript-specific by design** - it relies on TypeScript compiler-
|
|
191
|
+
derived type information. Multi-language Type Ledger expansion is
|
|
192
|
+
tracked under the Phase 8 roadmap.
|
|
193
|
+
|
|
194
|
+
## Privacy: everything is local unless you opt in
|
|
195
|
+
|
|
196
|
+
By default no code leaves the machine. `search` can optionally add semantic recall (find code by meaning, even when it shares no words with the question) with your own [Voyage AI](https://www.voyageai.com/) key:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
NREKI_SEMANTIC=voyage # explicit opt-in (required)
|
|
200
|
+
NREKI_VOYAGE_API_KEY=pa-... # or VOYAGE_API_KEY
|
|
201
|
+
NREKI_VOYAGE_MODEL=voyage-code-4 # optional, default shown
|
|
202
|
+
NREKI_VOYAGE_MAX_TOKENS=20000000 # optional per-process embedding budget
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
- A `VOYAGE_API_KEY` exported for another tool does **not** enable it; `NREKI_SEMANTIC=voyage` does.
|
|
206
|
+
- **What is sent:** every indexed code chunk (project-relative path, its comments, up to 6,000 characters of code) is embedded **once**, in the background, and the vector is stored locally in `.nreki.db`. Unchanged chunks are never re-sent, also after a restart; an edited file re-sends only its changed chunks. Each `search` sends only the query. Sensitive paths (`.env`, keys, `.ssh`, …) are never sent; secrets hard-coded in ordinary source files would be.
|
|
207
|
+
- **Cost:** about one token per 3.5 characters of code, once. A 1M-token repository is roughly $0.12 at voyage-code-4's list price, inside the free tier Voyage gives each account.
|
|
208
|
+
- **How results change:** the dense ranking is fused with BM25 (reciprocal-rank fusion), so a chunk BM25 never retrieved can surface. Until indexing finishes, and whenever Voyage is unreachable (2.5 s timeout) or the key is rejected, search answers from BM25 alone and logs the reason once.
|
|
209
|
+
- Check Voyage's terms for data retention/training; on self-serve accounts, opting out of training requires a payment method on file.
|
|
210
|
+
|
|
211
|
+
### Memory files are signed
|
|
212
|
+
|
|
213
|
+
NREKI's memory lives in the project folder: engrams, `memorize` notes and the plan pointer (`.nreki.db`), pinned rules (`.nreki/pins.json`), file history and the map cache (`.nreki/`). The agent reads parts of it as its own notes, and a repository could ship such files, so each one is signed with a key kept in your user folder (`~/.nreki/trust.key`, never in a project). A file without a valid signature is never loaded: it is moved to `.nreki/quarantine/` and the index is rebuilt.
|
|
214
|
+
|
|
215
|
+
Upgrading from 12.0.0 or earlier quarantines your old memory once. To restore it, run `npx nreki trust-db` in a terminal with the agent session closed: it lists the engrams, notes and pins it found and restores them only after you type `yes`. Without an interactive terminal it refuses, so an agent cannot run it on its own.
|
|
216
|
+
|
|
217
|
+
## Docs & links
|
|
218
|
+
|
|
219
|
+
- **[CHANGELOG.md](CHANGELOG.md)** - full version history (every patch, every release, every test count).
|
|
220
|
+
- **[templates/CLAUDE.md](templates/CLAUDE.md)** - optimized instructions auto-installed by `npx nreki init`.
|
|
221
|
+
- **Issues / ideas** - GitHub Issues on this repo.
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
Apache 2.0. Zero cloud dependencies. Everything runs locally in the agent's process (the opt-in Voyage reranker above is the only exception).
|