scythe-context-mcp 0.1.1 → 0.1.3

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 CHANGED
@@ -6,6 +6,24 @@ This project follows semantic versioning before npm publication where practical.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.3] - 2026-06-14
10
+
11
+ ### Changed
12
+
13
+ - Clarify MCP server instructions so Codex prefers Scythe Context for unknown-location, semantic, and related-file lookup, while using `rg` or direct file reads for exact strings, known paths, and small targeted checks.
14
+ - Update Windows Codex App + WSL documentation to prefer a `wsl.exe` wrapper that starts WSL Node, avoiding Windows Node direct access to WSL repo-local SQLite indexes.
15
+
16
+ ### Fixed
17
+
18
+ - Avoid false binary detection when a UTF-8 scan prefix ends in the middle of a multibyte character.
19
+ - Overwrite stale sqlite-vec rows before inserting embeddings so incremental reindexing cannot fail when embedding ids are reused.
20
+
21
+ ## [0.1.2] - 2026-06-13
22
+
23
+ ### Fixed
24
+
25
+ - Ensure the npm bin entrypoint is executable so `npx -y scythe-context-mcp` works on Unix-like environments.
26
+
9
27
  ## [0.1.1] - 2026-06-13
10
28
 
11
29
  ### Added
package/README.en.md CHANGED
@@ -52,7 +52,7 @@ Codex MCP configuration uses fields such as `command`, `args`, `cwd`, `env`, and
52
52
  | --- | --- |
53
53
  | Codex and MCP both run on Windows | Use Windows `node.exe` plus Windows npm `npx-cli.js`. |
54
54
  | Codex CLI runs inside WSL/Linux/macOS | Use `npx` or `node dist/index.js` from the same environment. |
55
- | Codex App on Windows opens a WSL repo | The App's WSL MCP bridge may still be unreliable; run MCP on Windows Node and pass the current WSL workspace to the Windows process with `PWD` + `WSLENV`. |
55
+ | Codex App on Windows opens a WSL repo | Use Windows `wsl.exe` to start WSL Node, so the SQLite index stays on the WSL filesystem. Avoid Windows Node directly reading or writing `.scythe-context/` inside a WSL repo. |
56
56
 
57
57
  ### Native Windows
58
58
 
@@ -99,40 +99,42 @@ Here `args` points to the built Scythe Context MCP entrypoint; do not pin `cwd`
99
99
 
100
100
  ### Windows Codex App + WSL repo
101
101
 
102
- Codex App on Windows may not reliably start WSL-side stdio MCP servers while using WSL agent mode. If MCP tools do not appear in the App, MCP handshakes time out, or config paths cross Windows/WSL boundaries, run the MCP server on Windows Node and let Scythe Context index the WSL repo path.
102
+ Codex App on Windows may not reliably start WSL-side stdio MCP servers while using WSL agent mode. The most reliable tested workaround is to let Codex run Windows `wsl.exe`, then let `wsl.exe` start WSL Node and the WSL npm package.
103
103
 
104
- Minimum config:
104
+ Install inside WSL first:
105
105
 
106
- ```toml
107
- [mcp_servers.scythe_context]
108
- command = "/mnt/c/nvm4w/nodejs/node.exe"
109
- args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', "-y", "scythe-context-mcp"]
110
- cwd = "/mnt/c/Users/you"
111
- env_vars = ["GEMINI_API_KEY", "PWD"]
112
-
113
- [mcp_servers.scythe_context.env]
114
- WSLENV = "PWD/p"
106
+ ```bash
107
+ npm install -g scythe-context-mcp
108
+ command -v scythe-context-mcp
109
+ scythe-context-mcp --version
115
110
  ```
116
111
 
117
- Notes:
118
-
119
- - Keep `cwd` on a Windows-accessible directory such as `/mnt/c/Users/you`. Do not use the WSL repo's UNC directory as `cwd`, because npm/npx may go through CMD, and CMD does not support UNC current directories.
120
- - This `cwd` is not the repo to index; it is only a safe startup directory for the Windows process. The real WSL repo is passed through `PWD/p`.
121
- - `PWD/p` lets WSL convert the current workspace path into a UNC path readable by the Windows process, so you do not need to edit config for every repo.
122
- - If `GEMINI_API_KEY` already exists in the Windows user environment or is forwarded by Codex `env_vars`, you do not need to put the key in `WSLENV`.
123
- - Do not point Windows `node.exe` at `dist/index.js` inside a WSL checkout unless that checkout's dependencies were installed by Windows npm. `better-sqlite3` and `sqlite-vec` include native modules, and Windows Node cannot load native binaries installed by Linux npm.
124
-
125
- Proxy URL, model, and auth mode can be written directly in Codex config; they do not need to go through `WSLENV`:
112
+ Then use this Codex config:
126
113
 
127
114
  ```toml
115
+ [mcp_servers.scythe_context]
116
+ command = "/mnt/c/Windows/System32/wsl.exe"
117
+ args = ["-d", "Ubuntu", "--", "bash", "-lc", "PATH=/home/you/.nvm/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin exec /home/you/.nvm/current/bin/scythe-context-mcp"]
118
+ startup_timeout_sec = 40
119
+ tool_timeout_sec = 120
120
+ env_vars = ["PWD", "GEMINI_API_KEY"]
121
+
128
122
  [mcp_servers.scythe_context.env]
129
- WSLENV = "PWD/p"
123
+ WSLENV = "PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY"
130
124
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
131
125
  GEMINI_MODEL = "gemini-embedding-2"
132
126
  GEMINI_AUTH_MODE = "bearer"
133
127
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
134
128
  ```
135
129
 
130
+ Notes:
131
+
132
+ - Replace `Ubuntu` with your WSL distribution name; check it with `wsl.exe -l -v`.
133
+ - Replace `/home/you/.nvm/current/bin` with your WSL Node/npm path; check it inside WSL with `which node` and `which scythe-context-mcp`.
134
+ - Do not pin `cwd` or `SCYTHE_CONTEXT_DEFAULT_PROJECT` in global config. This setup follows the current Codex workspace, so you do not need to edit config for every repo.
135
+ - `WSLENV` lists variable names to preserve across WSL/Windows interop; it does not contain the key itself. Prefer keeping `GEMINI_API_KEY` in the environment that starts Codex, then forward it with `env_vars`; write it directly under `[mcp_servers.scythe_context.env]` only for local throwaway testing.
136
+ - Avoid using Windows Node to index `.scythe-context/` directly inside a WSL repo. SQLite can report `database is locked` across the UNC / WSL filesystem boundary, and native modules can also accidentally mix Windows and WSL binaries.
137
+
136
138
  ### Optional hardening
137
139
 
138
140
  These settings are not required for a minimal launch, but they help for large repos, first-time `npx` downloads, or a fixed tool surface:
@@ -186,17 +188,19 @@ Supported auth modes:
186
188
 
187
189
  Official Gemini usually uses `x-goog-api-key`; many third-party proxies use `bearer`. If a proxy requires a query-string key, use `query` and set `GEMINI_API_KEY_QUERY_PARAM` if needed.
188
190
 
189
- `WSLENV` is a WSL interop rule, not a Codex-specific field. You only need it when the Windows Codex App opens a WSL repo and the MCP server is launched through Windows Node. Add `GEMINI_API_KEY`, URL, or model variables to `WSLENV` only when they exist only in the WSL environment:
191
+ `WSLENV` is a WSL interop rule, not a Codex-specific field. You only need it when Windows Codex App opens a WSL repo and the server is launched through a `wsl.exe` wrapper or another cross-environment command. With the `wsl.exe` wrapper above, use the no-suffix form:
190
192
 
191
193
  ```toml
192
194
  [mcp_servers.scythe_context.env]
193
- WSLENV = "PWD/p:GEMINI_API_KEY/w:GEMINI_BASE_URL/w:GEMINI_MODEL/w:GEMINI_AUTH_MODE/w:GEMINI_OUTPUT_DIMENSIONALITY/w"
195
+ WSLENV = "PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY"
194
196
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
195
197
  GEMINI_MODEL = "gemini-embedding-2"
196
198
  GEMINI_AUTH_MODE = "bearer"
197
199
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
198
200
  ```
199
201
 
202
+ Use `PWD/p` only if you intentionally run a Windows Node process and need WSL to convert the workspace path to a Windows-readable UNC path. That mode is currently not recommended for directly reading or writing the repo-local SQLite index in WSL.
203
+
200
204
  ## Typical Workflow
201
205
 
202
206
  1. Check index status first:
package/README.md CHANGED
@@ -52,7 +52,7 @@ Codex MCP 設定使用 `command`、`args`、`cwd`、`env` 與 `env_vars` 等欄
52
52
  | --- | --- |
53
53
  | Codex 和 MCP 都在 Windows | 用 Windows `node.exe` + Windows npm `npx-cli.js`。 |
54
54
  | Codex CLI 在 WSL/Linux/macOS | 用同一個環境內的 `npx` 或 `node dist/index.js`。 |
55
- | Codex App on Windows 開 WSL repo | 目前 App WSL MCP bridge 仍可能不穩;建議 MCP Windows Node,再用 `PWD` + `WSLENV` 把目前 WSL workspace 傳給 Windows process。 |
55
+ | Codex App on Windows 開 WSL repo | 建議用 Windows `wsl.exe` 啟動 WSL Node,讓 SQLite index 留在 WSL filesystem。避免 Windows Node 直接讀寫 WSL repo 內的 `.scythe-context/`。 |
56
56
 
57
57
  ### Native Windows
58
58
 
@@ -99,40 +99,42 @@ env_vars = ["GEMINI_API_KEY"]
99
99
 
100
100
  ### Windows Codex App + WSL repo
101
101
 
102
- 目前 Codex App on Windows 的 WSL agent mode 可能無法可靠啟動 WSL-side stdio MCP server。若你遇到 App 裡看不到 MCP tools、MCP handshake timeout、或 config path 混到 Windows/WSL 的問題,建議使用 Windows Node 啟動 MCP,並讓 Scythe Context 透過 WSL path 索引 repo
102
+ 目前 Codex App on Windows 的 WSL agent mode 可能無法可靠直接啟動 WSL-side stdio MCP server。實測較穩的做法是讓 Codex 執行 Windows `wsl.exe`,再由 `wsl.exe` WSL 內啟動 WSL Node WSL npm package
103
103
 
104
- 最小設定:
104
+ 先在 WSL 內安裝:
105
105
 
106
- ```toml
107
- [mcp_servers.scythe_context]
108
- command = "/mnt/c/nvm4w/nodejs/node.exe"
109
- args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', "-y", "scythe-context-mcp"]
110
- cwd = "/mnt/c/Users/you"
111
- env_vars = ["GEMINI_API_KEY", "PWD"]
112
-
113
- [mcp_servers.scythe_context.env]
114
- WSLENV = "PWD/p"
106
+ ```bash
107
+ npm install -g scythe-context-mcp
108
+ command -v scythe-context-mcp
109
+ scythe-context-mcp --version
115
110
  ```
116
111
 
117
- 注意:
118
-
119
- - `cwd` 放 Windows 可用目錄,例如 `/mnt/c/Users/you`。不要把 `cwd` 設成 WSL repo 的 UNC 目錄,因為 npm/npx 可能經過 CMD,而 CMD 不支援 UNC current directory。
120
- - 這個 `cwd` 不是要索引的 repo,只是 Windows process 的安全啟動位置;真正的 WSL repo 由 `PWD/p` 傳入。
121
- - `PWD/p` 會讓 WSL 把目前 workspace 路徑轉成 Windows process 可讀的 UNC path;所以不需要每換一個 repo 就改設定。
122
- - 如果 `GEMINI_API_KEY` 已存在 Windows 使用者環境或由 Codex `env_vars` 直接轉發,就不需要把 key 放進 `WSLENV`。
123
- - 不要用 Windows `node.exe` 直接執行 WSL checkout 裡的 `dist/index.js`,除非該 checkout 的 dependencies 是用 Windows npm 安裝的。`better-sqlite3` 和 `sqlite-vec` 都包含 native module,Windows Node 不能載入 Linux npm 安裝出的 native binary。
124
-
125
- 中轉站 URL、model、auth mode 可以直接寫在 Codex config 裡,不需要透過 `WSLENV`:
112
+ 然後在 Codex config 使用:
126
113
 
127
114
  ```toml
115
+ [mcp_servers.scythe_context]
116
+ command = "/mnt/c/Windows/System32/wsl.exe"
117
+ args = ["-d", "Ubuntu", "--", "bash", "-lc", "PATH=/home/you/.nvm/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin exec /home/you/.nvm/current/bin/scythe-context-mcp"]
118
+ startup_timeout_sec = 40
119
+ tool_timeout_sec = 120
120
+ env_vars = ["PWD", "GEMINI_API_KEY"]
121
+
128
122
  [mcp_servers.scythe_context.env]
129
- WSLENV = "PWD/p"
123
+ WSLENV = "PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY"
130
124
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
131
125
  GEMINI_MODEL = "gemini-embedding-2"
132
126
  GEMINI_AUTH_MODE = "bearer"
133
127
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
134
128
  ```
135
129
 
130
+ 注意:
131
+
132
+ - `Ubuntu` 要換成你的 WSL distribution 名稱;可用 `wsl.exe -l -v` 查看。
133
+ - `/home/you/.nvm/current/bin` 要換成你的 WSL Node/npm 路徑;可在 WSL 內用 `which node`、`which scythe-context-mcp` 確認。
134
+ - 不要在全域 config 固定 `cwd` 或 `SCYTHE_CONTEXT_DEFAULT_PROJECT`。這個設定會跟著 Codex 目前 workspace 走,不需要每換 repo 就改一次。
135
+ - `WSLENV` 這裡列的是要跨 WSL/Windows interop 保留的變數名,不是 key 內容。建議把 `GEMINI_API_KEY` 放在 Codex 啟動環境或系統環境,並用 `env_vars` 轉發;本機臨時測試才考慮直接寫在 `[mcp_servers.scythe_context.env]`。
136
+ - 不建議用 Windows Node 直接索引 WSL repo 內的 `.scythe-context/`。SQLite 在 UNC / WSL filesystem 邊界可能出現 `database is locked`,而且 native modules 也容易混到 Windows/WSL 不同平台的 binary。
137
+
136
138
  ### 可選強化設定
137
139
 
138
140
  以下設定不是最小啟動必需,但在大型 repo、首次 `npx` 下載或想固定工具面時有用:
@@ -186,17 +188,19 @@ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
186
188
 
187
189
  官方 Gemini 通常使用 `x-goog-api-key`;很多第三方中轉站使用 `bearer`。如果中轉站要求 query string key,可以使用 `query`,必要時再設定 `GEMINI_API_KEY_QUERY_PARAM`。
188
190
 
189
- `WSLENV` 是 WSL interop 規則,不是 Codex 專用欄位。只有在 Windows Codex App + WSL repo 模式需要讓 WSL 把變數轉交給 Windows Node 時才需要。若 `GEMINI_API_KEY`、URL model 只存在 WSL 環境變數,才把它們加進 `WSLENV`:
191
+ `WSLENV` 是 WSL interop 規則,不是 Codex 專用欄位。只有在 Windows Codex App + WSL repo 並透過 `wsl.exe` wrapper Windows Node 跨環境啟動時才需要。若使用上面的 `wsl.exe` wrapper,通常使用無 suffix 形式:
190
192
 
191
193
  ```toml
192
194
  [mcp_servers.scythe_context.env]
193
- WSLENV = "PWD/p:GEMINI_API_KEY/w:GEMINI_BASE_URL/w:GEMINI_MODEL/w:GEMINI_AUTH_MODE/w:GEMINI_OUTPUT_DIMENSIONALITY/w"
195
+ WSLENV = "PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY"
194
196
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
195
197
  GEMINI_MODEL = "gemini-embedding-2"
196
198
  GEMINI_AUTH_MODE = "bearer"
197
199
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
198
200
  ```
199
201
 
202
+ 若你刻意採用 Windows Node 方案,才需要 `PWD/p` 把 WSL path 轉成 Windows 可讀 UNC path;但目前不建議用它直接讀寫 WSL repo 內的 SQLite index。
203
+
200
204
  ## 常用工作流
201
205
 
202
206
  1. 先檢查索引狀態:
package/README.zh-CN.md CHANGED
@@ -52,7 +52,7 @@ Codex MCP 配置使用 `command`、`args`、`cwd`、`env` 与 `env_vars` 等字
52
52
  | --- | --- |
53
53
  | Codex 和 MCP 都在 Windows | 用 Windows `node.exe` + Windows npm `npx-cli.js`。 |
54
54
  | Codex CLI 在 WSL/Linux/macOS | 用同一个环境内的 `npx` 或 `node dist/index.js`。 |
55
- | Codex App on Windows 打开 WSL repo | 目前 App WSL MCP bridge 仍可能不稳定;建议 MCP Windows Node,再用 `PWD` + `WSLENV` 把当前 WSL workspace 传给 Windows process。 |
55
+ | Codex App on Windows 打开 WSL repo | 建议用 Windows `wsl.exe` 启动 WSL Node,让 SQLite index 留在 WSL filesystem。避免 Windows Node 直接读写 WSL repo 内的 `.scythe-context/`。 |
56
56
 
57
57
  ### Native Windows
58
58
 
@@ -99,40 +99,42 @@ env_vars = ["GEMINI_API_KEY"]
99
99
 
100
100
  ### Windows Codex App + WSL repo
101
101
 
102
- 目前 Codex App on Windows 的 WSL agent mode 可能无法可靠启动 WSL-side stdio MCP server。如果你遇到 App 里看不到 MCP tools、MCP handshake timeout、或 config path 混到 Windows/WSL 的问题,建议使用 Windows Node 启动 MCP,并让 Scythe Context 通过 WSL path 索引 repo
102
+ 目前 Codex App on Windows 的 WSL agent mode 可能无法可靠直接启动 WSL-side stdio MCP server。实测较稳定的做法是让 Codex 执行 Windows `wsl.exe`,再由 `wsl.exe` WSL 内启动 WSL Node WSL npm package
103
103
 
104
- 最小配置:
104
+ 先在 WSL 内安装:
105
105
 
106
- ```toml
107
- [mcp_servers.scythe_context]
108
- command = "/mnt/c/nvm4w/nodejs/node.exe"
109
- args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', "-y", "scythe-context-mcp"]
110
- cwd = "/mnt/c/Users/you"
111
- env_vars = ["GEMINI_API_KEY", "PWD"]
112
-
113
- [mcp_servers.scythe_context.env]
114
- WSLENV = "PWD/p"
106
+ ```bash
107
+ npm install -g scythe-context-mcp
108
+ command -v scythe-context-mcp
109
+ scythe-context-mcp --version
115
110
  ```
116
111
 
117
- 注意:
118
-
119
- - `cwd` 放 Windows 可用目录,例如 `/mnt/c/Users/you`。不要把 `cwd` 设成 WSL repo 的 UNC 目录,因为 npm/npx 可能经过 CMD,而 CMD 不支持 UNC current directory。
120
- - 这个 `cwd` 不是要索引的 repo,只是 Windows process 的安全启动位置;真正的 WSL repo 由 `PWD/p` 传入。
121
- - `PWD/p` 会让 WSL 把当前 workspace 路径转成 Windows process 可读的 UNC path;所以不需要每换一个 repo 就改配置。
122
- - 如果 `GEMINI_API_KEY` 已存在 Windows 用户环境或由 Codex `env_vars` 直接转发,就不需要把 key 放进 `WSLENV`。
123
- - 不要用 Windows `node.exe` 直接执行 WSL checkout 里的 `dist/index.js`,除非该 checkout 的 dependencies 是用 Windows npm 安装的。`better-sqlite3` 和 `sqlite-vec` 都包含 native module,Windows Node 不能加载 Linux npm 安装出的 native binary。
124
-
125
- 中转站 URL、model、auth mode 可以直接写在 Codex config 里,不需要通过 `WSLENV`:
112
+ 然后在 Codex config 使用:
126
113
 
127
114
  ```toml
115
+ [mcp_servers.scythe_context]
116
+ command = "/mnt/c/Windows/System32/wsl.exe"
117
+ args = ["-d", "Ubuntu", "--", "bash", "-lc", "PATH=/home/you/.nvm/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin exec /home/you/.nvm/current/bin/scythe-context-mcp"]
118
+ startup_timeout_sec = 40
119
+ tool_timeout_sec = 120
120
+ env_vars = ["PWD", "GEMINI_API_KEY"]
121
+
128
122
  [mcp_servers.scythe_context.env]
129
- WSLENV = "PWD/p"
123
+ WSLENV = "PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY"
130
124
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
131
125
  GEMINI_MODEL = "gemini-embedding-2"
132
126
  GEMINI_AUTH_MODE = "bearer"
133
127
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
134
128
  ```
135
129
 
130
+ 注意:
131
+
132
+ - `Ubuntu` 要换成你的 WSL distribution 名称;可用 `wsl.exe -l -v` 查看。
133
+ - `/home/you/.nvm/current/bin` 要换成你的 WSL Node/npm 路径;可在 WSL 内用 `which node`、`which scythe-context-mcp` 确认。
134
+ - 不要在全局 config 固定 `cwd` 或 `SCYTHE_CONTEXT_DEFAULT_PROJECT`。这个设置会跟着 Codex 当前 workspace 走,不需要每换 repo 就改一次。
135
+ - `WSLENV` 这里列的是要跨 WSL/Windows interop 保留的变量名,不是 key 内容。建议把 `GEMINI_API_KEY` 放在 Codex 启动环境或系统环境,并用 `env_vars` 转发;只有本机临时测试才考虑直接写在 `[mcp_servers.scythe_context.env]`。
136
+ - 不建议用 Windows Node 直接索引 WSL repo 内的 `.scythe-context/`。SQLite 在 UNC / WSL filesystem 边界可能出现 `database is locked`,而且 native modules 也容易混到 Windows/WSL 不同平台的 binary。
137
+
136
138
  ### 可选强化配置
137
139
 
138
140
  以下配置不是最小启动必需,但在大型 repo、首次 `npx` 下载或想固定工具面时有用:
@@ -186,17 +188,19 @@ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
186
188
 
187
189
  官方 Gemini 通常使用 `x-goog-api-key`;很多第三方中转站使用 `bearer`。如果中转站要求 query string key,可以使用 `query`,必要时再设置 `GEMINI_API_KEY_QUERY_PARAM`。
188
190
 
189
- `WSLENV` 是 WSL interop 规则,不是 Codex 专用字段。只有在 Windows Codex App + WSL repo 模式需要让 WSL 把变量转交给 Windows Node 时才需要。若 `GEMINI_API_KEY`、URL model 只存在 WSL 环境变量,才把它们加进 `WSLENV`:
191
+ `WSLENV` 是 WSL interop 规则,不是 Codex 专用字段。只有在 Windows Codex App + WSL repo 并通过 `wsl.exe` wrapper Windows Node 跨环境启动时才需要。若使用上面的 `wsl.exe` wrapper,通常使用无 suffix 形式:
190
192
 
191
193
  ```toml
192
194
  [mcp_servers.scythe_context.env]
193
- WSLENV = "PWD/p:GEMINI_API_KEY/w:GEMINI_BASE_URL/w:GEMINI_MODEL/w:GEMINI_AUTH_MODE/w:GEMINI_OUTPUT_DIMENSIONALITY/w"
195
+ WSLENV = "PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY"
194
196
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
195
197
  GEMINI_MODEL = "gemini-embedding-2"
196
198
  GEMINI_AUTH_MODE = "bearer"
197
199
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
198
200
  ```
199
201
 
202
+ 若你刻意采用 Windows Node 方案,才需要 `PWD/p` 把 WSL path 转成 Windows 可读 UNC path;但目前不建议用它直接读写 WSL repo 内的 SQLite index。
203
+
200
204
  ## 常用工作流
201
205
 
202
206
  1. 先检查索引状态:
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- export const PACKAGE_VERSION = "0.1.1";
1
+ export const PACKAGE_VERSION = "0.1.3";
2
2
  export function parseCliArgs(args) {
3
3
  if (args.length === 0)
4
4
  return { kind: "serve" };
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ const server = new McpServer({
24
24
  name: "scythe-context-mcp",
25
25
  version: PACKAGE_VERSION,
26
26
  }, {
27
- instructions: "Scythe Context is a local code-context MCP server for Codex. Use repo_index_status first, repo_reindex(dry_run=false) when metadata is missing or stale, and repo_context_pack for task lookup. Only set index_embeddings=true when semantic vectors are needed because chunk text is sent to the configured embedding endpoint. Keep max_context_chars and max_related_context_chars bounded. Use repo_semantic_search for ranking/debugging and repo_related_files for a focused file graph.",
27
+ instructions: "Scythe Context is a code-context MCP server for Codex. Use it for unknown file locations, semantic/code-intent search, or related files/imports/snippets. Use rg/direct reads for exact strings, known paths, or small checks. Start with repo_index_status; repo_reindex(dry_run=false) only if metadata is missing/stale. Prefer repo_context_pack for task lookup. Set index_embeddings=true only when semantic vectors are needed; chunk text goes to the configured endpoint. Use repo_related_files for focused graphs.",
28
28
  });
29
29
  registerTools(server, config);
30
30
  const transport = new StdioServerTransport();
@@ -1,12 +1,11 @@
1
1
  import { TextDecoder } from "node:util";
2
- const utf8Decoder = new TextDecoder("utf-8", { fatal: true });
3
2
  export function isProbablyBinary(buffer) {
4
3
  if (buffer.length === 0)
5
4
  return false;
6
5
  if (buffer.includes(0))
7
6
  return true;
8
7
  try {
9
- utf8Decoder.decode(buffer);
8
+ new TextDecoder("utf-8", { fatal: true }).decode(buffer, { stream: true });
10
9
  return false;
11
10
  }
12
11
  catch {
@@ -62,9 +62,12 @@ export async function indexMissingEmbeddings(options) {
62
62
  ${limitSql}
63
63
  `)
64
64
  .all({ embeddingSetId, maxChunks: options.maxChunks });
65
- const insertVector = db.prepare(`insert or replace into ${vectorTableName(options.dimensions)}(rowid, embedding) values (?, ?)`);
65
+ const vectorTable = vectorTableName(options.dimensions);
66
+ const deleteVector = db.prepare(`delete from ${vectorTable} where rowid = ?`);
67
+ const insertVector = db.prepare(`insert into ${vectorTable}(rowid, embedding) values (?, ?)`);
66
68
  const writeEmbedding = db.transaction((chunkId, vector) => {
67
69
  const embeddingId = getOrCreateEmbeddingRecord(db, { chunkId, embeddingSetId });
70
+ deleteVector.run(BigInt(embeddingId));
68
71
  insertVector.run(BigInt(embeddingId), vectorToFloat32Buffer(vector, options.dimensions));
69
72
  });
70
73
  for (const batch of chunkArray(pendingChunks, options.batchSize)) {
@@ -42,22 +42,23 @@ Codex's official MCP configuration model is platform-neutral: a stdio server has
42
42
 
43
43
  - Native Windows: use Windows `node.exe` and npm's `npx-cli.js`, or the short binary command only when Codex can reliably see the npm global binary on PATH.
44
44
  - WSL/Linux/macOS: use `npx -y scythe-context-mcp` or `node dist/index.js` from a build produced in that same environment.
45
- - Windows Codex App with WSL workspaces: use Windows `node.exe` and Windows npm package dependencies, but pass the current WSL workspace through `PWD` and `WSLENV`. Use `SCYTHE_CONTEXT_DEFAULT_PROJECT` only when intentionally pinning one fixed default project.
45
+ - Windows Codex App with WSL workspaces: prefer Windows `wsl.exe` as a wrapper that starts WSL Node and WSL npm package dependencies. This keeps the repo-local SQLite index on the WSL filesystem. Use `SCYTHE_CONTEXT_DEFAULT_PROJECT` only when intentionally pinning one fixed default project.
46
46
 
47
47
  Do not mix a Node runtime from one OS with `node_modules` installed by another OS. This matters because Scythe Context depends on native SQLite modules.
48
48
 
49
49
  ### Windows App with WSL workspaces
50
50
 
51
- When Codex App runs a WSL project but MCP servers need to use Windows Node, prefer launching Scythe Context through Windows `node.exe` and npm's `npx-cli.js`:
51
+ When Codex App runs a WSL project, prefer launching Scythe Context through Windows `wsl.exe` and a WSL-installed `scythe-context-mcp` binary:
52
52
 
53
- - Current Codex App on Windows may not reliably start WSL-side stdio MCP servers while using WSL agent mode. If MCP tools are missing, handshakes time out, or config paths cross Windows/WSL boundaries, use the Windows Node workaround.
54
- - Use `command = "/mnt/c/.../node.exe"` with the Windows npm `npx-cli.js` path as the first arg.
55
- - Keep `cwd` on a Windows-accessible directory such as `/mnt/c/Users/you`; do not use a WSL repo UNC path as `cwd` because npm/npx may invoke CMD and CMD does not support UNC current directories.
56
- - Forward `PWD` with `PWD/p` in `WSLENV` so WSL converts the current workspace to a UNC path for the Windows process.
57
- - Include provider variables in `WSLENV` with `/w` only when those values exist in WSL and must be forwarded to Windows Node.
53
+ - Current Codex App on Windows may not reliably start WSL-side stdio MCP servers directly while using WSL agent mode. If MCP tools are missing, handshakes time out, or config paths cross Windows/WSL boundaries, use `wsl.exe` as a wrapper.
54
+ - Install the package inside WSL, then point the wrapper command at the WSL global binary, for example `/home/you/.nvm/current/bin/scythe-context-mcp`.
55
+ - Keep the WSL Node path at the front of `PATH` inside the wrapper command. This avoids accidentally resolving a Windows npm global shim from the inherited Windows PATH.
56
+ - Do not pin `cwd` in global config. Let Codex's current workspace and `PWD` decide the target repo.
57
+ - Use `WSLENV = "PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY"` when config env variables must survive the WSL -> Windows `wsl.exe` -> WSL round trip.
58
+ - Do not use Windows Node to directly read or write `.scythe-context/index.sqlite` inside a WSL repo. In live testing this can fail with `database is locked` across the UNC / WSL filesystem boundary.
58
59
  - Do not point Windows `node.exe` at a WSL checkout's `dist/index.js` unless dependencies were installed by Windows npm in that checkout.
59
60
 
60
- The reason is native dependency compatibility. `better-sqlite3` and `sqlite-vec` load platform-specific binaries. Windows Node should load Windows-installed package dependencies, while WSL Node should load WSL-installed package dependencies.
61
+ The reason is both filesystem and native dependency compatibility. `better-sqlite3` and `sqlite-vec` load platform-specific binaries, and SQLite locking is more predictable when the Node process and index database live in the same OS filesystem.
61
62
 
62
63
  ### AGENTS.md
63
64
 
@@ -90,7 +91,7 @@ Recommended config should expose all tools by default during development, but `e
90
91
  - Valid Codex TOML examples using `[mcp_servers.scythe_context.env]`.
91
92
  - Secret-safe config examples using `env_vars` for `GEMINI_API_KEY`.
92
93
  - `cwd` in MCP config so relative `.env` loading is predictable.
93
- - Windows App + WSL setup guidance using Windows `node.exe`, npm `npx-cli.js`, `PWD`, and `WSLENV`.
94
+ - Windows App + WSL setup guidance using Windows `wsl.exe`, WSL Node, npm package dependencies installed in WSL, `PWD`, and `WSLENV`.
94
95
  - `startup_timeout_sec` and `tool_timeout_sec` tuned above defaults.
95
96
  - Bounded context output for primary and related snippets.
96
97
  - Explicit opt-in embedding and opt-in related snippet packing.
@@ -114,12 +115,13 @@ Recommended config should expose all tools by default during development, but `e
114
115
 
115
116
  ### Windows App starts but WSL repo indexing fails
116
117
 
117
- 1. Prefer the npm package path through Windows `node.exe` plus npm `npx-cli.js`.
118
- 2. Keep `cwd` on `/mnt/c/...`, not the WSL repo.
119
- 3. Forward the current workspace with `env_vars = ["PWD", ...]` and `WSLENV = "PWD/p:..."`.
120
- 4. Forward provider environment variables with `WSLENV` only when they exist in WSL but the MCP server runs through Windows Node.
121
- 5. Avoid mixing Windows Node with Linux-installed `node_modules`.
122
- 6. Run the same Windows Node + `npx-cli.js` command from a WSL shell with `cwd` under `/mnt/c/Users/...` to verify the launch path before configuring Codex.
118
+ 1. Prefer the `wsl.exe` wrapper that starts WSL Node and a WSL-installed `scythe-context-mcp` binary.
119
+ 2. Confirm WSL has its own install: `npm install -g scythe-context-mcp`, then `command -v scythe-context-mcp`.
120
+ 3. Keep WSL Node's bin directory before Windows paths in the wrapper command's `PATH`.
121
+ 4. Do not set global `cwd` or `SCYTHE_CONTEXT_DEFAULT_PROJECT` unless you intentionally want one fixed repo.
122
+ 5. Use `WSLENV` without suffixes for the wrapper mode, for example `PWD:GEMINI_API_KEY:GEMINI_BASE_URL:GEMINI_MODEL:GEMINI_AUTH_MODE:GEMINI_OUTPUT_DIMENSIONALITY`.
123
+ 6. If you see `invalid ELF header`, the process probably loaded a Windows npm package or shim from WSL; fix `PATH` or reinstall inside WSL.
124
+ 7. If you see `database is locked` while using Windows Node against a WSL repo, switch to the `wsl.exe` wrapper so SQLite is opened by WSL Node on the WSL filesystem.
123
125
 
124
126
  ### Tool starts but embedding fails
125
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scythe-context-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Local MCP context engine for Codex with Gemini Embedding 2 support.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -34,13 +34,13 @@
34
34
  ".env.example"
35
35
  ],
36
36
  "scripts": {
37
- "build": "tsc -p tsconfig.json",
37
+ "build": "tsc -p tsconfig.json && node scripts/bin-mode.mjs ensure",
38
38
  "dev": "tsx src/index.ts",
39
39
  "prepack": "npm run build",
40
40
  "smoke": "node dist/index.js --version && node dist/index.js --help",
41
41
  "test": "vitest run",
42
42
  "typecheck": "tsc -p tsconfig.json --noEmit",
43
- "verify": "npm test && npm run build && npm run smoke && npm audit --omit=dev && npm pack --dry-run"
43
+ "verify": "npm test && npm run build && node scripts/bin-mode.mjs check && npm run smoke && npm audit --omit=dev && npm pack --dry-run"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=24.11.0 <27"