codepage-bridge-mcp 0.1.5 → 0.1.6
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/.mcp.json +2 -10
- package/README.md +81 -764
- package/README_CN.md +161 -584
- package/dist/src/core.d.ts +3 -2
- package/dist/src/core.js +46 -18
- package/dist/src/core.js.map +1 -1
- package/dist/src/filesystem/cache.d.ts +1 -2
- package/dist/src/filesystem/cache.js +9 -17
- package/dist/src/filesystem/cache.js.map +1 -1
- package/dist/src/limits.d.ts +2 -0
- package/dist/src/limits.js +17 -0
- package/dist/src/limits.js.map +1 -0
- package/dist/src/tools/grep.js +81 -28
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/read.js +5 -0
- package/dist/src/tools/read.js.map +1 -1
- package/dist/src/tools/write.js +1 -1
- package/dist/src/tools/write.js.map +1 -1
- package/install/install-unix.sh +29 -0
- package/install/install-windows.ps1 +29 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,242 +8,69 @@ Codepage Bridge exposes `Read`, `Grep`, `Edit`, and `Write` over MCP while trans
|
|
|
8
8
|
|
|
9
9
|
It is designed for legacy codebases that still use GBK/GB2312/GB18030, Big5, Shift-JIS, EUC-KR, Windows codepages, UTF-16, and other non-UTF-8 encodings.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Recommended install
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
This is now the single recommended installation path for end users.
|
|
14
14
|
|
|
15
|
-
###
|
|
16
|
-
|
|
17
|
-
This is the intended long-term default path for ordinary users.
|
|
18
|
-
|
|
19
|
-
Current status:
|
|
20
|
-
|
|
21
|
-
- the repository now contains the minimum Claude Code plugin / marketplace structure;
|
|
22
|
-
- the plugin declares Codepage Bridge through a plugin-local `.mcp.json`;
|
|
23
|
-
- the plugin includes `/setup`, `/setup-project`, and `/doctor` commands.
|
|
24
|
-
|
|
25
|
-
What is still required before true marketplace one-click installation works end to end:
|
|
26
|
-
|
|
27
|
-
1. publish `codepage-bridge-mcp` to npm or another `npx`-reachable registry;
|
|
28
|
-
2. add this repository to a Claude Code marketplace source;
|
|
29
|
-
3. install the plugin from that marketplace.
|
|
30
|
-
|
|
31
|
-
Once those steps are completed, users will be able to install Codepage Bridge from marketplace without cloning the repository.
|
|
32
|
-
|
|
33
|
-
For now, use **GitHub Release installation** below.
|
|
34
|
-
|
|
35
|
-
### Option B — Install from GitHub Release (recommended for normal users right now)
|
|
36
|
-
|
|
37
|
-
This is the current recommended path for ordinary users.
|
|
38
|
-
|
|
39
|
-
You can choose one of two sub-paths:
|
|
40
|
-
|
|
41
|
-
1. **You already downloaded and extracted the release package**
|
|
42
|
-
2. **You want a script to download the release package for you**
|
|
43
|
-
|
|
44
|
-
Both paths avoid local `npm install` and local `npm run build`.
|
|
45
|
-
|
|
46
|
-
They still require local:
|
|
47
|
-
|
|
48
|
-
- `claude`
|
|
49
|
-
- `node`
|
|
50
|
-
|
|
51
|
-
### Option C — Install from source (contributors and local development only)
|
|
52
|
-
|
|
53
|
-
Use this path only if you want to:
|
|
54
|
-
|
|
55
|
-
- develop Codepage Bridge itself;
|
|
56
|
-
- inspect or modify the implementation;
|
|
57
|
-
- debug installation issues locally.
|
|
58
|
-
|
|
59
|
-
Typical flow:
|
|
60
|
-
|
|
61
|
-
1. clone the repository;
|
|
62
|
-
2. run `npm install`;
|
|
63
|
-
3. run `npm run build`;
|
|
64
|
-
4. register the MCP manually or via the source installer.
|
|
65
|
-
|
|
66
|
-
If you skip the built-in tool blocking and `CLAUDE.md` policy steps, Claude Code may continue using its built-in file tools and bypass `.encoding-rules`.
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## Marketplace / Plugin Publishing Plan
|
|
71
|
-
|
|
72
|
-
This repository now includes the minimum Claude Code marketplace/plugin structure:
|
|
73
|
-
|
|
74
|
-
- `.claude-plugin/plugin.json`
|
|
75
|
-
- `.claude-plugin/marketplace.json`
|
|
76
|
-
- plugin-local `.mcp.json`
|
|
77
|
-
- plugin commands in `commands/`
|
|
78
|
-
|
|
79
|
-
The plugin-local `.mcp.json` currently starts Codepage Bridge with:
|
|
80
|
-
|
|
81
|
-
```json
|
|
82
|
-
{
|
|
83
|
-
"mcpServers": {
|
|
84
|
-
"codepage-bridge": {
|
|
85
|
-
"command": "npx",
|
|
86
|
-
"args": ["-y", "codepage-bridge-mcp"]
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
That means marketplace installation depends on the package name `codepage-bridge-mcp` being publicly installable through `npx`.
|
|
93
|
-
|
|
94
|
-
### Publishing steps
|
|
95
|
-
|
|
96
|
-
1. publish `codepage-bridge-mcp` to npm;
|
|
97
|
-
2. keep `package.json`, `.claude-plugin/plugin.json`, and `.claude-plugin/marketplace.json` versions in sync;
|
|
98
|
-
3. add this repository to a Claude Code marketplace source;
|
|
99
|
-
6. validate the plugin with:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
claude plugin validate . --strict
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
7. install from marketplace and run `/setup`.
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## Install from GitHub Release
|
|
110
|
-
|
|
111
|
-
This is the easiest path for end users today.
|
|
112
|
-
|
|
113
|
-
There are **two valid ways** to use the Release installer flow.
|
|
114
|
-
|
|
115
|
-
### Path 1 — You already downloaded and extracted a release package
|
|
116
|
-
|
|
117
|
-
This is the preferred path if you are already inside an extracted release directory.
|
|
118
|
-
|
|
119
|
-
Use:
|
|
120
|
-
|
|
121
|
-
#### Windows
|
|
15
|
+
### Windows
|
|
122
16
|
|
|
123
17
|
```powershell
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
#### macOS / Linux
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
bash ./install/install-this-release-unix.sh
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
What it does:
|
|
18
|
+
# Remove an older install with the same name first, if one exists.
|
|
19
|
+
claude mcp remove codepage-bridge -s user
|
|
134
20
|
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
### Path 2 — You want the installer to download the release package for you
|
|
140
|
-
|
|
141
|
-
Use:
|
|
142
|
-
|
|
143
|
-
#### Windows
|
|
144
|
-
|
|
145
|
-
```powershell
|
|
146
|
-
powershell -ExecutionPolicy Bypass -File .\install\download-release-windows.ps1
|
|
21
|
+
# Register the npm package once, at user scope. `cmd` is required on Windows.
|
|
22
|
+
claude mcp add --scope user codepage-bridge -- cmd /d /s /c "npx -y codepage-bridge-mcp"
|
|
23
|
+
claude mcp get codepage-bridge
|
|
147
24
|
```
|
|
148
25
|
|
|
149
|
-
|
|
26
|
+
### macOS / Linux
|
|
150
27
|
|
|
151
28
|
```bash
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
What it does:
|
|
156
|
-
|
|
157
|
-
- fetches the latest release from GitHub;
|
|
158
|
-
- downloads the correct platform archive;
|
|
159
|
-
- extracts it under the user install directory;
|
|
160
|
-
- registers Claude Code MCP.
|
|
161
|
-
|
|
162
|
-
You can also install a specific version.
|
|
29
|
+
# Remove an older install with the same name first, if one exists.
|
|
30
|
+
claude mcp remove codepage-bridge -s user
|
|
163
31
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
powershell -ExecutionPolicy Bypass -File .\install\download-release-windows.ps1 -Version v0.1.0
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
#### macOS / Linux
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
bash ./install/download-release-unix.sh v0.1.0
|
|
32
|
+
# Register the npm package once, at user scope.
|
|
33
|
+
claude mcp add --scope user codepage-bridge -- npx -y codepage-bridge-mcp
|
|
34
|
+
claude mcp get codepage-bridge
|
|
174
35
|
```
|
|
175
36
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
The old `install-from-release-*` scripts are kept as compatibility wrappers:
|
|
179
|
-
|
|
180
|
-
- if run inside an extracted release package, they install from local files;
|
|
181
|
-
- otherwise they fall back to downloading the release package.
|
|
182
|
-
|
|
183
|
-
These are still valid, but the clearer scripts are:
|
|
184
|
-
|
|
185
|
-
- `install-this-release-*`
|
|
186
|
-
- `download-release-*`
|
|
187
|
-
|
|
188
|
-
### What Release installation still requires
|
|
189
|
-
|
|
190
|
-
The release installation path still expects these commands to already exist locally:
|
|
37
|
+
What this requires locally:
|
|
191
38
|
|
|
192
39
|
- `claude`
|
|
193
40
|
- `node`
|
|
194
41
|
|
|
195
|
-
|
|
42
|
+
What it does **not** require:
|
|
196
43
|
|
|
197
44
|
- `git clone`
|
|
198
45
|
- `npm install`
|
|
199
46
|
- `npm run build`
|
|
47
|
+
- downloading a GitHub Release package first
|
|
200
48
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
## Install from source
|
|
49
|
+
### Avoid duplicate MCP registrations
|
|
204
50
|
|
|
205
|
-
|
|
51
|
+
Register `codepage-bridge` in only one scope. Claude Code treats the same server name with different commands as a configuration conflict—for example, an older user-scoped local build and this repository's project-scoped `.mcp.json` npm command.
|
|
206
52
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
git clone git@github.com:skyispainted/codepage-bridge-mcp.git
|
|
211
|
-
cd codepage-bridge-mcp
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### 2. Install dependencies
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
npm install
|
|
218
|
-
```
|
|
53
|
+
Run `claude mcp list` to diagnose duplicates. Keep the endpoint you want, then remove the other registration:
|
|
219
54
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
npm run build
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
The server entry point is:
|
|
55
|
+
```powershell
|
|
56
|
+
# Keep the npm command from the user-scoped installation.
|
|
57
|
+
claude mcp remove codepage-bridge -s project
|
|
227
58
|
|
|
228
|
-
|
|
229
|
-
|
|
59
|
+
# Or keep a project-local configuration and remove a previous user installation.
|
|
60
|
+
claude mcp remove codepage-bridge -s user
|
|
230
61
|
```
|
|
231
62
|
|
|
232
|
-
|
|
63
|
+
After removing a registration, run `claude mcp get codepage-bridge` again. It must report one endpoint with status `Connected`.
|
|
233
64
|
|
|
234
|
-
|
|
65
|
+
### Large text files
|
|
235
66
|
|
|
236
|
-
|
|
67
|
+
`Read` and `Grep` allow individual text files up to `32 MiB` by default. To use a different limit, set `CODEPAGE_BRIDGE_MAX_TEXT_FILE_MIB` to a positive integer before starting Claude Code:
|
|
237
68
|
|
|
238
69
|
```powershell
|
|
239
|
-
|
|
70
|
+
setx CODEPAGE_BRIDGE_MAX_TEXT_FILE_MIB 64
|
|
240
71
|
```
|
|
241
72
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
bash ./install/install-from-source-unix.sh
|
|
246
|
-
```
|
|
73
|
+
Restart Claude Code after changing the variable. Larger files require proportionally more Node.js memory while decoding, splitting lines, and matching regular expressions.
|
|
247
74
|
|
|
248
75
|
---
|
|
249
76
|
|
|
@@ -267,120 +94,11 @@ If new text cannot be represented in the target encoding, the write fails instea
|
|
|
267
94
|
|
|
268
95
|
---
|
|
269
96
|
|
|
270
|
-
##
|
|
271
|
-
|
|
272
|
-
- Encoding-aware `Read`, `Grep`, `Edit`, and `Write` tools.
|
|
273
|
-
- Project-level `.encoding-rules` with gitignore-like glob behavior.
|
|
274
|
-
- The nearest `.encoding-rules` defines both the project root and active rules.
|
|
275
|
-
- Last matching rule wins; `!pattern` resets matching files to strict UTF-8.
|
|
276
|
-
- Basename patterns such as `*.cpp` match at every directory depth.
|
|
277
|
-
- Strict UTF-8 fallback for files not matched by a rule.
|
|
278
|
-
- GBK/GB2312/GB18030, Big5, Shift-JIS, EUC-KR, Windows codepages, UTF-8, and UTF-16 support.
|
|
279
|
-
- BOM and dominant line-ending preservation for edits.
|
|
280
|
-
- Read-before-write protection and stale-write detection using byte hashes.
|
|
281
|
-
- Atomic temporary-file writes and per-path write locks.
|
|
282
|
-
- Symlink and project-root boundary checks.
|
|
283
|
-
- Image, PDF, and Jupyter Notebook reading.
|
|
284
|
-
- Grep output modes, context lines, glob/type filters, regex flags, and pagination.
|
|
285
|
-
- Large-file partial edit authorization: the model only needs to read the target lines it wants to edit, not the entire file.
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## Requirements
|
|
290
|
-
|
|
291
|
-
- Node.js 20 or newer.
|
|
292
|
-
- Claude Code or another MCP client with stdio server support.
|
|
293
|
-
- Optional: Poppler commands `pdfinfo` and `pdftoppm` for PDF page rendering.
|
|
294
|
-
|
|
295
|
-
Check prerequisites:
|
|
296
|
-
|
|
297
|
-
### Windows
|
|
298
|
-
|
|
299
|
-
```powershell
|
|
300
|
-
node --version
|
|
301
|
-
npm --version
|
|
302
|
-
claude --version
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### macOS / Linux
|
|
306
|
-
|
|
307
|
-
```bash
|
|
308
|
-
node --version
|
|
309
|
-
npm --version
|
|
310
|
-
claude --version
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
---
|
|
314
|
-
|
|
315
|
-
## Claude Code Setup
|
|
316
|
-
|
|
317
|
-
You can install Codepage Bridge either:
|
|
318
|
-
|
|
319
|
-
- **user-level**: available in all your projects;
|
|
320
|
-
- **project-level**: committed as part of a single repository.
|
|
321
|
-
|
|
322
|
-
### Option A — User-level setup
|
|
323
|
-
|
|
324
|
-
Recommended if you use legacy-encoded projects regularly.
|
|
325
|
-
|
|
326
|
-
#### Windows
|
|
327
|
-
|
|
328
|
-
```powershell
|
|
329
|
-
claude mcp add --scope user codepage-bridge -- node C:\absolute\path\to\codepage-bridge-mcp\dist\src\server.js
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
#### macOS / Linux
|
|
333
|
-
|
|
334
|
-
```bash
|
|
335
|
-
claude mcp add --scope user codepage-bridge -- node /absolute/path/to/codepage-bridge-mcp/dist/src/server.js
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
Verify:
|
|
339
|
-
|
|
340
|
-
```bash
|
|
341
|
-
claude mcp get codepage-bridge
|
|
342
|
-
claude mcp list
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
Expected result:
|
|
346
|
-
|
|
347
|
-
- name: `codepage-bridge`
|
|
348
|
-
- status: `Connected`
|
|
349
|
-
|
|
350
|
-
### Option B — Project-level setup
|
|
351
|
-
|
|
352
|
-
Recommended if you want the repository itself to declare the MCP.
|
|
353
|
-
|
|
354
|
-
Create `.mcp.json` in the project root:
|
|
355
|
-
|
|
356
|
-
```json
|
|
357
|
-
{
|
|
358
|
-
"mcpServers": {
|
|
359
|
-
"codepage-bridge": {
|
|
360
|
-
"type": "stdio",
|
|
361
|
-
"command": "node",
|
|
362
|
-
"args": [
|
|
363
|
-
"/absolute/path/to/codepage-bridge-mcp/dist/src/server.js"
|
|
364
|
-
]
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
Shared project MCP configurations may require approval the first time Claude Code opens the project.
|
|
371
|
-
|
|
372
|
-
Minimal templates are included under:
|
|
373
|
-
|
|
374
|
-
- `examples/minimal-project/`
|
|
375
|
-
- `examples/claude-config/`
|
|
376
|
-
|
|
377
|
-
---
|
|
378
|
-
|
|
379
|
-
## Extremely Important: Disable the Built-in File Tools
|
|
97
|
+
## Required Claude Code configuration
|
|
380
98
|
|
|
381
99
|
Installing the MCP is **not sufficient by itself**.
|
|
382
100
|
|
|
383
|
-
Claude Code may
|
|
101
|
+
Claude Code may still choose its built-in:
|
|
384
102
|
|
|
385
103
|
- `Read`
|
|
386
104
|
- `Grep`
|
|
@@ -390,11 +108,9 @@ Claude Code may continue choosing its built-in:
|
|
|
390
108
|
|
|
391
109
|
Those tools bypass `.encoding-rules`.
|
|
392
110
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
### Edit `~/.claude/settings.json`
|
|
111
|
+
### Step 1 — merge `settings.fragment.json`
|
|
396
112
|
|
|
397
|
-
|
|
113
|
+
Merge this into your existing `~/.claude/settings.json`:
|
|
398
114
|
|
|
399
115
|
```json
|
|
400
116
|
{
|
|
@@ -416,40 +132,13 @@ Add the following entries to your existing settings file:
|
|
|
416
132
|
}
|
|
417
133
|
```
|
|
418
134
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
### If your settings file already has `permissions.allow`
|
|
422
|
-
|
|
423
|
-
Append these four entries:
|
|
424
|
-
|
|
425
|
-
```json
|
|
426
|
-
"mcp__codepage-bridge__Read"
|
|
427
|
-
"mcp__codepage-bridge__Grep"
|
|
428
|
-
"mcp__codepage-bridge__Edit"
|
|
429
|
-
"mcp__codepage-bridge__Write"
|
|
430
|
-
```
|
|
431
|
-
|
|
432
|
-
### If your settings file already has `permissions.deny`
|
|
433
|
-
|
|
434
|
-
Append these five entries:
|
|
435
|
-
|
|
436
|
-
```json
|
|
437
|
-
"Read"
|
|
438
|
-
"Grep"
|
|
439
|
-
"Edit"
|
|
440
|
-
"Write"
|
|
441
|
-
"NotebookEdit"
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
An example merge snippet is included in:
|
|
135
|
+
Template file:
|
|
445
136
|
|
|
446
137
|
- `examples/claude-config/settings.fragment.json`
|
|
447
138
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
## Add a `CLAUDE.md` Policy
|
|
139
|
+
**Do not replace your whole settings file unless it is empty.** Merge these arrays into your existing configuration.
|
|
451
140
|
|
|
452
|
-
|
|
141
|
+
### Step 2 — add a `CLAUDE.md` policy
|
|
453
142
|
|
|
454
143
|
Add this to the project `CLAUDE.md`, or to `~/.claude/CLAUDE.md` for a global policy:
|
|
455
144
|
|
|
@@ -471,18 +160,11 @@ Do not manually transcode files or normalize line endings. `.encoding-rules`
|
|
|
471
160
|
is the source of truth.
|
|
472
161
|
```
|
|
473
162
|
|
|
474
|
-
|
|
163
|
+
Template file:
|
|
475
164
|
|
|
476
165
|
- `examples/minimal-project/CLAUDE.md`
|
|
477
166
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
- `deny` removes unsafe built-in tools from the model's available tool list.
|
|
481
|
-
- `CLAUDE.md` prevents the model from bypassing the bridge using shell tools.
|
|
482
|
-
|
|
483
|
-
---
|
|
484
|
-
|
|
485
|
-
## Create `.encoding-rules`
|
|
167
|
+
### Step 3 — add `.encoding-rules`
|
|
486
168
|
|
|
487
169
|
Every project using Codepage Bridge must contain `.encoding-rules` at its root.
|
|
488
170
|
|
|
@@ -501,11 +183,9 @@ assets/**/*.csv shift_jis
|
|
|
501
183
|
!SourceCode/generated/**
|
|
502
184
|
```
|
|
503
185
|
|
|
504
|
-
|
|
186
|
+
Template file:
|
|
505
187
|
|
|
506
|
-
|
|
507
|
-
<glob-pattern> <encoding>
|
|
508
|
-
```
|
|
188
|
+
- `examples/minimal-project/.encoding-rules`
|
|
509
189
|
|
|
510
190
|
Rules:
|
|
511
191
|
|
|
@@ -518,28 +198,9 @@ Rules:
|
|
|
518
198
|
- Files with no matching rule use strict UTF-8.
|
|
519
199
|
- The nearest `.encoding-rules` is used; its directory is the allowed project root.
|
|
520
200
|
|
|
521
|
-
Supported examples:
|
|
522
|
-
|
|
523
|
-
```text
|
|
524
|
-
utf8
|
|
525
|
-
utf-16le
|
|
526
|
-
gbk
|
|
527
|
-
gb2312
|
|
528
|
-
gb18030
|
|
529
|
-
big5
|
|
530
|
-
shift_jis
|
|
531
|
-
euc-kr
|
|
532
|
-
windows-1251
|
|
533
|
-
windows-1252
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
A starter file is included in:
|
|
537
|
-
|
|
538
|
-
- `examples/minimal-project/.encoding-rules`
|
|
539
|
-
|
|
540
201
|
---
|
|
541
202
|
|
|
542
|
-
## Verify the
|
|
203
|
+
## Verify the setup
|
|
543
204
|
|
|
544
205
|
### 1. Check the MCP is connected
|
|
545
206
|
|
|
@@ -549,19 +210,23 @@ claude mcp get codepage-bridge
|
|
|
549
210
|
|
|
550
211
|
Expected:
|
|
551
212
|
|
|
552
|
-
- `
|
|
553
|
-
-
|
|
213
|
+
- name: `codepage-bridge`
|
|
214
|
+
- status: `Connected`
|
|
554
215
|
|
|
555
216
|
### 2. Start a fresh Claude Code session in a legacy project
|
|
556
217
|
|
|
557
|
-
### 3. Ask Claude to read a legacy-encoded file
|
|
218
|
+
### 3. Ask Claude to read or search a legacy-encoded file
|
|
558
219
|
|
|
559
|
-
|
|
220
|
+
Examples:
|
|
560
221
|
|
|
561
222
|
```text
|
|
562
223
|
Read SourceCode/Main.cpp and show the first 10 lines.
|
|
563
224
|
```
|
|
564
225
|
|
|
226
|
+
```text
|
|
227
|
+
Search SourceCode for the string 错误码.
|
|
228
|
+
```
|
|
229
|
+
|
|
565
230
|
### 4. Confirm the model uses Codepage Bridge tools
|
|
566
231
|
|
|
567
232
|
In a verbose / print-mode session, the tool call should be one of:
|
|
@@ -575,388 +240,55 @@ It should **not** call built-in `Read`, `Grep`, `Edit`, or `Write`.
|
|
|
575
240
|
|
|
576
241
|
---
|
|
577
242
|
|
|
578
|
-
##
|
|
579
|
-
|
|
580
|
-
### `Read`
|
|
581
|
-
|
|
582
|
-
```json
|
|
583
|
-
{
|
|
584
|
-
"file_path": "C:\\project\\SourceCode\\Main.cpp",
|
|
585
|
-
"offset": 1,
|
|
586
|
-
"limit": 200,
|
|
587
|
-
"pages": "1-5"
|
|
588
|
-
}
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
Behavior:
|
|
592
|
-
|
|
593
|
-
- Text is decoded according to `.encoding-rules` and returned as Unicode.
|
|
594
|
-
- Output uses numbered lines compatible with Claude Code workflows.
|
|
595
|
-
- Files larger than 256 KiB require `offset` and `limit`.
|
|
596
|
-
- Multiple ranged reads of the same unchanged file are merged by line coverage.
|
|
597
|
-
- Ranges may be sequential, overlapping, out of order, or concurrent within one MCP process.
|
|
598
|
-
- If the file changes, accumulated coverage is invalidated.
|
|
599
|
-
- Supports PNG, JPEG, GIF, WebP, PDF pages, and Notebook cells.
|
|
600
|
-
- Notebook reads do not accept text-line `offset` or `limit`.
|
|
601
|
-
|
|
602
|
-
### `Grep`
|
|
603
|
-
|
|
604
|
-
```json
|
|
605
|
-
{
|
|
606
|
-
"pattern": "error|failed",
|
|
607
|
-
"path": "C:\\project",
|
|
608
|
-
"glob": "**/*.log",
|
|
609
|
-
"output_mode": "content",
|
|
610
|
-
"-i": false,
|
|
611
|
-
"-n": true,
|
|
612
|
-
"-C": 2,
|
|
613
|
-
"head_limit": 250,
|
|
614
|
-
"offset": 0
|
|
615
|
-
}
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
Supported options:
|
|
619
|
-
|
|
620
|
-
- `output_mode`: `content`, `files_with_matches`, or `count`
|
|
621
|
-
- `glob`
|
|
622
|
-
- common `type` filters
|
|
623
|
-
- `-i`, `-n`, `-o`
|
|
624
|
-
- `-A`, `-B`, `-C`, `context`
|
|
625
|
-
- `multiline`
|
|
626
|
-
- `head_limit`, `offset`
|
|
627
|
-
|
|
628
|
-
Each candidate file is decoded using its own nearest `.encoding-rules`. Explicit single-file decode failures are reported as errors rather than being misreported as zero matches.
|
|
629
|
-
|
|
630
|
-
### `Edit`
|
|
631
|
-
|
|
632
|
-
```json
|
|
633
|
-
{
|
|
634
|
-
"file_path": "C:\\project\\SourceCode\\Main.cpp",
|
|
635
|
-
"old_string": "old text",
|
|
636
|
-
"new_string": "new text",
|
|
637
|
-
"replace_all": false
|
|
638
|
-
}
|
|
639
|
-
```
|
|
640
|
-
|
|
641
|
-
Behavior:
|
|
642
|
-
|
|
643
|
-
- Existing files do not require reading the whole file.
|
|
644
|
-
- An edit is authorized when every line covered by the selected `old_string` match was actually returned to the model.
|
|
645
|
-
- For unique targets in large files, the model only needs to read the relevant nearby lines.
|
|
646
|
-
- With `replace_all: true`, every matching range must have been read.
|
|
647
|
-
- If a target was not read, the error reports the exact missing line range(s).
|
|
648
|
-
- The file is re-read and hashed immediately before writing.
|
|
649
|
-
- Multiple matches are rejected unless `replace_all` is true.
|
|
650
|
-
- Straight/curly quote compatibility follows Claude Code edit behavior.
|
|
651
|
-
- The original encoding, BOM, and dominant line ending are preserved.
|
|
652
|
-
|
|
653
|
-
### `Write`
|
|
654
|
-
|
|
655
|
-
```json
|
|
656
|
-
{
|
|
657
|
-
"file_path": "C:\\project\\SourceCode\\NewFile.cpp",
|
|
658
|
-
"content": "full content"
|
|
659
|
-
}
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
Behavior:
|
|
243
|
+
## Features
|
|
663
244
|
|
|
664
|
-
-
|
|
665
|
-
-
|
|
666
|
-
-
|
|
667
|
-
-
|
|
245
|
+
- Encoding-aware `Read`, `Grep`, `Edit`, and `Write` tools.
|
|
246
|
+
- Project-level `.encoding-rules` with gitignore-like glob behavior.
|
|
247
|
+
- The nearest `.encoding-rules` defines both the project root and active rules.
|
|
248
|
+
- Last matching rule wins; `!pattern` resets matching files to strict UTF-8.
|
|
249
|
+
- Basename patterns such as `*.cpp` match at every directory depth.
|
|
250
|
+
- Strict UTF-8 fallback for files not matched by a rule.
|
|
251
|
+
- GBK/GB2312/GB18030, Big5, Shift-JIS, EUC-KR, Windows codepages, UTF-8, and UTF-16 support.
|
|
252
|
+
- BOM and dominant line-ending preservation for edits.
|
|
253
|
+
- Read-before-write protection and stale-write detection using byte hashes.
|
|
254
|
+
- Atomic temporary-file writes and per-path write locks.
|
|
255
|
+
- Symlink and project-root boundary checks.
|
|
256
|
+
- Image, PDF, and Jupyter Notebook reading.
|
|
257
|
+
- Grep output modes, context lines, glob/type filters, regex flags, and pagination.
|
|
258
|
+
- Large-file partial edit authorization: the model only needs to read the target lines it wants to edit, not the entire file.
|
|
668
259
|
|
|
669
260
|
---
|
|
670
261
|
|
|
671
|
-
##
|
|
262
|
+
## Maintainer notes
|
|
672
263
|
|
|
673
|
-
|
|
264
|
+
### npm package
|
|
674
265
|
|
|
675
|
-
|
|
676
|
-
- `examples/minimal-project/.mcp.json`
|
|
677
|
-
- `examples/minimal-project/CLAUDE.md`
|
|
678
|
-
- `examples/claude-config/settings.fragment.json`
|
|
679
|
-
|
|
680
|
-
Use them as copy-paste starting points.
|
|
681
|
-
|
|
682
|
-
---
|
|
683
|
-
|
|
684
|
-
## NPM_TOKEN automation note
|
|
685
|
-
|
|
686
|
-
The GitHub release workflow now publishes the npm package automatically using Trusted Publishing before packaging release assets.
|
|
687
|
-
|
|
688
|
-
Repository maintainers must configure a GitHub Actions secret named NPM_TOKEN.
|
|
689
|
-
|
|
690
|
-
Important: if a token was ever pasted into chat, terminal history, logs, or screenshots, revoke it in npm immediately and create a new publish token before storing it in GitHub Secrets.
|
|
691
|
-
|
|
692
|
-
Ensure the GitHub repository is allowed to publish this package in the npm Trusted Publishing settings.
|
|
693
|
-
|
|
694
|
-
## Maintainer Release Flow
|
|
695
|
-
|
|
696
|
-
To publish a new release:
|
|
697
|
-
|
|
698
|
-
```bash
|
|
699
|
-
git tag v0.1.0
|
|
700
|
-
git push origin v0.1.0
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
The GitHub Release workflow will:`r`n`r`n- publish the npm package using `NPM_TOKEN`;
|
|
704
|
-
|
|
705
|
-
- run type checks;
|
|
706
|
-
- run the full test suite;
|
|
707
|
-
- build the project;
|
|
708
|
-
- prune dev dependencies;
|
|
709
|
-
- package platform-specific release archives;
|
|
710
|
-
- generate per-asset SHA256 files;
|
|
711
|
-
- generate a combined `checksums.txt` file;
|
|
712
|
-
- publish the assets to GitHub Releases.
|
|
713
|
-
|
|
714
|
-
---
|
|
715
|
-
|
|
716
|
-
## npm Publish Readiness
|
|
717
|
-
|
|
718
|
-
The repository is now prepared for npm publishing.
|
|
719
|
-
|
|
720
|
-
### Package shape
|
|
721
|
-
|
|
722
|
-
The published tarball contains only:
|
|
723
|
-
|
|
724
|
-
- `dist/src/`
|
|
725
|
-
- `.claude-plugin/`
|
|
726
|
-
- `.mcp.json`
|
|
727
|
-
- `install/`
|
|
728
|
-
- `examples/`
|
|
729
|
-
- `README.md`
|
|
730
|
-
- `README_CN.md`
|
|
731
|
-
- `LICENSE`
|
|
732
|
-
|
|
733
|
-
It does **not** publish:
|
|
734
|
-
|
|
735
|
-
- `src/`
|
|
736
|
-
- `test/`
|
|
737
|
-
- `node_modules/`
|
|
738
|
-
- project-local `.claude/`
|
|
739
|
-
- release build caches
|
|
740
|
-
|
|
741
|
-
### Prepublish checks
|
|
742
|
-
|
|
743
|
-
`prepublishOnly` now runs:
|
|
744
|
-
|
|
745
|
-
```bash
|
|
746
|
-
npm run check
|
|
747
|
-
npm test
|
|
748
|
-
npm run build
|
|
749
|
-
```
|
|
750
|
-
|
|
751
|
-
### Dry-run verification
|
|
752
|
-
|
|
753
|
-
Before publishing, run:
|
|
754
|
-
|
|
755
|
-
```bash
|
|
756
|
-
npm pack --dry-run
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
This verifies the final npm tarball contents.
|
|
760
|
-
|
|
761
|
-
### Publish steps
|
|
762
|
-
|
|
763
|
-
1. log in to npm:
|
|
764
|
-
|
|
765
|
-
```bash
|
|
766
|
-
npm login
|
|
767
|
-
```
|
|
768
|
-
|
|
769
|
-
2. publish the package:
|
|
770
|
-
|
|
771
|
-
```bash
|
|
772
|
-
npm publish
|
|
773
|
-
```
|
|
774
|
-
|
|
775
|
-
3. verify that this works:
|
|
776
|
-
|
|
777
|
-
```bash
|
|
778
|
-
npx -y codepage-bridge-mcp
|
|
779
|
-
```
|
|
780
|
-
|
|
781
|
-
Once that succeeds, the plugin / marketplace path becomes fully installable because the plugin-local `.mcp.json` already points at:
|
|
782
|
-
|
|
783
|
-
```json
|
|
784
|
-
{
|
|
785
|
-
"mcpServers": {
|
|
786
|
-
"codepage-bridge": {
|
|
787
|
-
"command": "npx",
|
|
788
|
-
"args": ["-y", "codepage-bridge-mcp"]
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
```
|
|
793
|
-
## Final Marketplace Publish & Install Plan
|
|
794
|
-
|
|
795
|
-
Codepage Bridge is now **plugin-ready** and **npm-ready**.
|
|
796
|
-
|
|
797
|
-
### What is already done
|
|
798
|
-
|
|
799
|
-
- plugin manifests exist:
|
|
800
|
-
- `.claude-plugin/plugin.json`
|
|
801
|
-
- `.claude-plugin/marketplace.json`
|
|
802
|
-
- plugin-local MCP declaration exists:
|
|
803
|
-
- `.mcp.json`
|
|
804
|
-
- plugin commands exist:
|
|
805
|
-
- `/setup`
|
|
806
|
-
- `/setup-project`
|
|
807
|
-
- `/doctor`
|
|
808
|
-
- npm publish metadata is prepared in `package.json`
|
|
809
|
-
- `npm pack --dry-run` has been verified
|
|
810
|
-
- `claude plugin validate . --strict` passes
|
|
811
|
-
|
|
812
|
-
### What is still required before marketplace installation fully works
|
|
813
|
-
|
|
814
|
-
1. log in to npm
|
|
815
|
-
2. publish `codepage-bridge-mcp`
|
|
816
|
-
3. add this repository to a Claude Code marketplace source
|
|
817
|
-
4. install the plugin from marketplace
|
|
818
|
-
|
|
819
|
-
### Actual publish checklist
|
|
820
|
-
|
|
821
|
-
Run these commands locally:
|
|
822
|
-
|
|
823
|
-
```bash
|
|
824
|
-
npm login
|
|
825
|
-
npm whoami
|
|
826
|
-
npm pack --dry-run
|
|
827
|
-
npm publish
|
|
828
|
-
```
|
|
829
|
-
|
|
830
|
-
After publish, verify:
|
|
266
|
+
The package is published and installable via:
|
|
831
267
|
|
|
832
268
|
```bash
|
|
833
269
|
npx -y codepage-bridge-mcp
|
|
834
270
|
```
|
|
835
271
|
|
|
836
|
-
|
|
272
|
+
### Plugin / Marketplace status
|
|
837
273
|
|
|
838
|
-
|
|
274
|
+
This repository is plugin-ready and marketplace-ready.
|
|
839
275
|
|
|
840
|
-
|
|
276
|
+
Plugin files:
|
|
841
277
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
### Important limitation
|
|
850
|
-
|
|
851
|
-
Marketplace installation can install the plugin and declare the MCP, but safe usage still depends on project configuration:
|
|
852
|
-
|
|
853
|
-
- deny built-in `Read`, `Grep`, `Edit`, `Write`, `NotebookEdit`
|
|
854
|
-
- use Codepage Bridge for all file content operations
|
|
855
|
-
- add `.encoding-rules` to each legacy-encoded project
|
|
856
|
-
## Troubleshooting
|
|
857
|
-
|
|
858
|
-
### `No .encoding-rules found`
|
|
859
|
-
|
|
860
|
-
Cause:
|
|
861
|
-
|
|
862
|
-
- the project root does not contain `.encoding-rules`;
|
|
863
|
-
- you are pointing at a file outside the intended project root.
|
|
864
|
-
|
|
865
|
-
Fix:
|
|
866
|
-
|
|
867
|
-
- add `.encoding-rules` to the project root;
|
|
868
|
-
- ensure the target path is inside that project tree.
|
|
869
|
-
|
|
870
|
-
### `Invalid byte sequence for utf-8`
|
|
871
|
-
|
|
872
|
-
Cause:
|
|
873
|
-
|
|
874
|
-
- the file was decoded as UTF-8 but is actually in another encoding;
|
|
875
|
-
- your `.encoding-rules` did not match the file.
|
|
876
|
-
|
|
877
|
-
Fix:
|
|
878
|
-
|
|
879
|
-
- confirm the rule file exists;
|
|
880
|
-
- confirm the pattern matches nested paths;
|
|
881
|
-
- for language-wide rules, prefer patterns like `*.cpp gbk`.
|
|
882
|
-
|
|
883
|
-
### `Text contains characters not representable in ...`
|
|
884
|
-
|
|
885
|
-
Cause:
|
|
886
|
-
|
|
887
|
-
- the new text contains characters that the target encoding cannot represent.
|
|
888
|
-
|
|
889
|
-
Fix:
|
|
890
|
-
|
|
891
|
-
- change the text;
|
|
892
|
-
- or explicitly move the file to an encoding that can represent those characters.
|
|
893
|
-
|
|
894
|
-
### `The target text has not been read`
|
|
895
|
-
|
|
896
|
-
Cause:
|
|
897
|
-
|
|
898
|
-
- the model tried to edit a region it has not actually seen.
|
|
899
|
-
|
|
900
|
-
Fix:
|
|
901
|
-
|
|
902
|
-
- read the exact lines reported in the error;
|
|
903
|
-
- retry the edit.
|
|
904
|
-
|
|
905
|
-
### `Pending approval`
|
|
906
|
-
|
|
907
|
-
Cause:
|
|
908
|
-
|
|
909
|
-
- a project `.mcp.json` server has not been approved yet by Claude Code.
|
|
910
|
-
|
|
911
|
-
Fix:
|
|
912
|
-
|
|
913
|
-
- open Claude Code in the project and approve the server;
|
|
914
|
-
- or install Codepage Bridge at user scope.
|
|
915
|
-
|
|
916
|
-
### `Failed to connect`
|
|
917
|
-
|
|
918
|
-
Check:
|
|
919
|
-
|
|
920
|
-
- `node --version`
|
|
921
|
-
- `claude --version`
|
|
922
|
-
- `Test-Path dist/src/server.js` on Windows
|
|
923
|
-
- `test -f ./dist/src/server.js` on macOS/Linux
|
|
924
|
-
- `claude mcp get codepage-bridge`
|
|
925
|
-
|
|
926
|
-
Then rebuild:
|
|
927
|
-
|
|
928
|
-
```bash
|
|
929
|
-
npm install
|
|
930
|
-
npm run build
|
|
931
|
-
```
|
|
932
|
-
|
|
933
|
-
### Claude still uses built-in file tools
|
|
934
|
-
|
|
935
|
-
Cause:
|
|
936
|
-
|
|
937
|
-
- built-in tools were not denied;
|
|
938
|
-
- the model is bypassing through shell commands.
|
|
939
|
-
|
|
940
|
-
Fix:
|
|
278
|
+
- `.claude-plugin/plugin.json`
|
|
279
|
+
- `.claude-plugin/marketplace.json`
|
|
280
|
+
- `.mcp.json`
|
|
281
|
+
- `commands/setup.md`
|
|
282
|
+
- `commands/setup-project.md`
|
|
283
|
+
- `commands/doctor.md`
|
|
941
284
|
|
|
942
|
-
|
|
943
|
-
- add the `CLAUDE.md` policy;
|
|
944
|
-
- start a new Claude session.
|
|
285
|
+
### GitHub Release
|
|
945
286
|
|
|
946
|
-
|
|
287
|
+
GitHub Release packaging is still maintained for users who prefer downloadable archives, but it is no longer the primary installation path described in this README.
|
|
947
288
|
|
|
948
|
-
|
|
289
|
+
### Release workflow
|
|
949
290
|
|
|
950
|
-
|
|
951
|
-
2. Test rules on representative nested files before large edits.
|
|
952
|
-
3. Use basename globs for language-wide rules, for example `*.cpp gbk`.
|
|
953
|
-
4. Do not silently convert encodings.
|
|
954
|
-
5. Do not bypass the bridge with shell tools or scripts.
|
|
955
|
-
6. Keep the MCP process trusted; it has read/write access inside roots defined by `.encoding-rules`.
|
|
956
|
-
7. Review generated diffs; encoding preservation does not guarantee semantic correctness.
|
|
957
|
-
8. PDF support is optional; install Poppler or avoid PDF reads.
|
|
958
|
-
9. Notebook editing is intentionally unavailable. Notebook reading is supported, but there is no `NotebookEdit` tool.
|
|
959
|
-
10. Windows network/device paths are rejected before I/O to avoid unintended SMB access and credential leakage.
|
|
291
|
+
The GitHub release workflow uses npm Trusted Publishing with GitHub OIDC.
|
|
960
292
|
|
|
961
293
|
---
|
|
962
294
|
|
|
@@ -970,21 +302,6 @@ npm run build
|
|
|
970
302
|
npm start
|
|
971
303
|
```
|
|
972
304
|
|
|
973
|
-
Automated coverage currently includes:
|
|
974
|
-
|
|
975
|
-
- encoding rule precedence;
|
|
976
|
-
- nested basename matching;
|
|
977
|
-
- strict codecs;
|
|
978
|
-
- lossy-write rejection;
|
|
979
|
-
- stale-write protection;
|
|
980
|
-
- atomic writes;
|
|
981
|
-
- symlink boundaries;
|
|
982
|
-
- images, PDFs, and Notebook reads;
|
|
983
|
-
- GBK read/edit/write flows;
|
|
984
|
-
- Grep modes and error handling;
|
|
985
|
-
- full-file and target-range edit authorization;
|
|
986
|
-
- MCP protocol registration.
|
|
987
|
-
|
|
988
305
|
## License
|
|
989
306
|
|
|
990
307
|
MIT. See [LICENSE](LICENSE).
|