pi-charset 0.1.6 → 0.1.7
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 +18 -0
- package/CHANGELOG.zh-CN.md +18 -0
- package/dist/config.js +943 -0
- package/dist/edit/apply-patch-core.js +274 -0
- package/dist/edit/diagnostics.js +46 -0
- package/dist/edit/hashline.js +400 -0
- package/dist/edit/patch.js +634 -0
- package/dist/edit/paths.js +48 -0
- package/dist/edit/plan.js +90 -0
- package/dist/encoding/classify.js +430 -0
- package/dist/encoding/common-scripts.js +58 -0
- package/dist/encoding/converter.js +311 -0
- package/dist/encoding/fast-codec.js +476 -0
- package/dist/encoding/file-stamp.js +32 -0
- package/dist/encoding/line-endings.js +118 -0
- package/dist/encoding/mime.js +88 -0
- package/dist/encoding/stream-transcode.js +287 -0
- package/dist/grep-core.js +730 -0
- package/dist/journal.js +494 -0
- package/dist/maintenance.js +333 -0
- package/dist/mcp/server.js +866 -0
- package/dist/notify.js +60 -0
- package/dist/operations.js +1021 -0
- package/dist/path-key.js +10 -0
- package/dist/read-view.js +927 -0
- package/dist/resolve.js +325 -0
- package/dist/version.js +2 -0
- package/docs/MCP-AND-MULTI-AGENT.md +27 -19
- package/docs/zh-CN/MCP-AND-MULTI-AGENT.md +27 -19
- package/package.json +14 -2
- package/src/edit/apply-patch-core.ts +32 -3
- package/src/grep-core.ts +50 -8
- package/src/grep.ts +9 -1
- package/src/index.ts +8 -5
- package/src/journal.ts +167 -42
- package/src/mcp/server.ts +435 -163
- package/src/operations.ts +197 -68
- package/src/read-view.ts +111 -8
- package/src/shell-guard.ts +38 -1
- package/src/version.ts +1 -1
- package/tools/pi-charset-cli.mjs +453 -167
- package/tools/pi-charset-mcp.mjs +78 -41
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.1.7] - 2026-12-06
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **P0 — Compiled ESM delivery (`dist/`) for installed `node_modules/` packages**: Compile all Pi-independent core + MCP + CLI modules into standard Node ESM under `dist/` (`tsconfig.build.json`, `tools/build.mjs`) and mark Pi peer dependencies as optional in `peerDependenciesMeta`, eliminating `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING` after `npm install pi-charset` / `npx -p pi-charset pi-charset-mcp` and cutting standalone install footprint from ~131 packages to direct runtime dependencies only. Added an automated isolated `node_modules/pi-charset/` tarball install + stdio MCP handshake + GBK read/edit/write smoke gate to `tools/check-release.mjs`.
|
|
17
|
+
- **P1 — Zero-side-effect `dryRun: true` undo & strict boolean validation**: `undoWrite(..., { dryRun: true })` and `charset_fix(action="undo", dryRun=true)` now perform read-only verification without modifying disk, consuming journal entries, or mutating baselines; non-boolean safety flags (e.g. `dryRun: "true"`) are rejected with `[INVALID_INPUT; not_applied]`.
|
|
18
|
+
- **P1 — Pre-write NUL guard & Gate 2 before `autoCommit`**: `encodeForWrite` now rejects NUL-bearing content before touching disk (shared across `write` and `apply_patch add`), and `writeEncodedLocked` / `apply_patch add` now verify Gate 2 BEFORE calling `autoCommit` so unverified or tampered writes never enter Git history.
|
|
19
|
+
- **P1 — Safe Git `autoCommit` pathspecs & index preservation**: All Git mutations in `src/journal.ts` now pass `--literal-pathspecs` (preventing bracket filenames like `motor[1].c` from glob-matching `motor1.c`), skip `autoCommit` safely when a target file already has user-staged changes (preserving partial staging), and snapshot/restore exact index stage entries on commit/hook failure without affecting other staged work.
|
|
20
|
+
- **P1 — True Git staged-blob checking, Chinese/special paths & `core.hooksPath`**: Rebuilt `tools/pi-charset-cli.mjs` directly on the compiled shared core (`dist/`, eliminating CLI/core classifier drift). `pi-charset check --staged` now reads actual index stage-0 blobs via `git diff --cached --raw -z` + `git cat-file blob` (honoring `.gitattributes` `text`/`eol`/`working-tree-encoding` and non-ASCII/Chinese filenames without quoting or trimming bugs), and `pi-charset install-hook` now resolves active `core.hooksPath` before falling back to `--git-common-dir`.
|
|
21
|
+
- **P1 — Shell guard infinite-loop fix**: Handled single `<` input redirections, here-strings (`<<<`), fd redirections (`0<`), and process substitutions (`<(...)` / `>(...)`, inspecting nested commands) with an unbreakable loop-progress invariant in `src/shell-guard.ts`, and short-circuited `shellGuard: "off"` before parsing.
|
|
22
|
+
- **P1 — `apply_patch` Move source re-verification before unlink**: Re-checks source file `lstat` identity and exact bytes immediately prior to unlinking so external modifications landing during the move window are preserved rather than deleted.
|
|
23
|
+
- **P2 — Gate 2 known-encoding verification, strict output budgets, Pi `read` `outputSchema`, `grep` error propagation & EUC-KR coverage, MCP JSON-RPC hardening**: Stopped `verifyWritten` from re-guessing UTF-8 against known GBK targets (eliminating false failures on GBK `"漏"` `c2 a9`); enforced strict byte budgets even on 1 MiB single-line files across MCP `charset_read` and Pi/MCP `ranges`; aligned Pi `read` `structuredContent` with Pi 1.4.0's `readOutputSchema`; propagated ripgrep syntax/execution failures explicitly (`status: "failed"` / `isError: true` / thrown error) and fixed zero-config ASCII/regex search across `EUC-KR`/`Big5`/`Shift_JIS`/`EUC-JP`; added JSON-RPC 2.0 envelope validation, per-request error isolation, `notifications/cancelled` aborts, bounded request queue, and clean stdout backpressure drain on EOF.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Add request-level `expectedVersion` optimistic concurrency on `charset_write` / `charset_edit` (safe across multiple logical agents sharing one MCP instance) and machine-readable `structuredContent` (`applied`, `verified`, `committed`, `undoId`, `version`, `encoding`, `bom`, `eol`, `bytesOnDisk`) across MCP tools.
|
|
28
|
+
- Add `pi-charset --version`, `pi-charset doctor`, `pi-charset explain <file>`, `mcp-config --help` / `--client cursor|windsurf` / `--local`, and strict CLI option validation.
|
|
29
|
+
|
|
12
30
|
## [0.1.6] - 2026-12-06
|
|
13
31
|
|
|
14
32
|
### Added
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -8,6 +8,24 @@
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.1.7] - 2026-12-06
|
|
12
|
+
|
|
13
|
+
### 修复
|
|
14
|
+
|
|
15
|
+
- **P0 — 发布编译后纯标准 ESM 核心产物(`dist/`)解决 `node_modules` 安装后 MCP 启动阻断**:新增 `tsconfig.build.json` 与 `tools/build.mjs` 将全部 Pi 无关核心、MCP 与 CLI 依赖编译为标准 Node ESM(`dist/`),并在 `package.json` 的 `peerDependenciesMeta` 中将 Pi peer 依赖标记为可选,彻底消除标准 npm 安装后的 `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING` 并将独立安装体积由 ~131 包缩减为仅含直接运行依赖;同时在 `tools/check-release.mjs` 新增「真实 `.tgz` 解包至隔离 `node_modules/pi-charset/`(零 Pi 依赖)→ 真实 stdio MCP 握手 → GBK/CRLF 读写改逐字节断言」发布门禁。
|
|
16
|
+
- **P1 — 修复 `dryRun: true` 撤销实际改盘与布尔参数容错隐患**:为 `undoWrite` 与 `charset_fix(action="undo", dryRun=true)` 补齐只读预览路径,保证零磁盘改动、不消费 journal 且不修改基线;对 `dryRun`/`bom`/`outline`/`hashlines` 等布尔参数改为严格类型校验,拒绝把 `"true"` 静默当作 `false`。
|
|
17
|
+
- **P1 — 修复 `write` 写前 NUL 预检缺失与 `autoCommit` 先于 Gate 2 执行**:在 `encodeForWrite` 中统一前置拦截会产生二进制 NUL 的写入(覆盖 `write` 与 `apply_patch add`),并将 `writeEncodedLocked` 与 `apply_patch add` 改为 Gate 2 验证通过后才允许执行 `autoCommit`,彻底杜绝未校验或遭篡改字节进入 Git 历史。
|
|
18
|
+
- **P1 — 修复 `autoCommit` 方括号路径通配误提交与失败时破坏部分暂存**:`src/journal.ts` 全部涉及路径的 Git 命令统一使用 `--literal-pathspecs`(修复 `motor[1].c` 误带入 `motor1.c`);写前检测目标文件若已有用户部分暂存改动则跳过自动提交以保护原暂存区,并在提交或钩子失败时按 `ls-files --stage` 快照精确恢复暂存条目而不影响其它已暂存文件。
|
|
19
|
+
- **P1 — 修复 CLI `--staged` 读工作树、中文路径漏检、`core.hooksPath` 忽略与分类器漂移**:重构 `tools/pi-charset-cli.mjs` 直接复用 `dist/` 同源核心;`check --staged` 改为 `git diff --cached --raw -z` + `git cat-file blob` 校验真实暂存区 stage-0 快照(完整支持中文及特殊文件名,并感知 `.gitattributes` 的 `text`/`eol`/`working-tree-encoding`);`install-hook` 优先解析 `core.hooksPath` 再回退 `--git-common-dir`。
|
|
20
|
+
- **P1 — 修复 `shell-guard.ts` 遇到单 `<` 输入重定向死循环**:补齐 `<`、`0<`、`<>`、`<<<` 与 `<(...)`/`>(...)` 进程替换解析(并递归检查进程替换内的命令)与不可破坏的循环推进不变量,`shellGuard: "off"` 提前短路返回。
|
|
21
|
+
- **P1 — 修复 `apply_patch` Move 删源前并发窗口**:在删除源文件前再次复核 `lstat` 文件身份与精确字节,若移动窗口内源文件遭外部修改则保留外部版本并报告部分完成状态与可撤回批次号。
|
|
22
|
+
- **P2 — 全面修复已知目标编码 Gate 2 误报、超长首行预算绕过、Pi `read` `outputSchema` 不匹配、`grep` 失败掩盖与 EUC-KR 漏搜、MCP JSON-RPC 韧性与 EOF 排空**:`verifyWritten` 在目标编码已知时不再重猜 UTF-8(消除 GBK `"漏"` `c2 a9` 误报);统一 `sliceLinesBounded` 与 `formatLineRanges` 严格预算使 1 MiB 单行不再突破 50 KB 上限;对齐 Pi 1.4.0 `readOutputSchema`;显式传播 ripgrep 语法/执行错误并补齐零配置对 `EUC-KR`/`Big5`/`Shift_JIS`/`EUC-JP` 的正则与词搜索;为 MCP 补齐 JSON-RPC 2.0 信封校验、单请求异常隔离、`notifications/cancelled` 取消、有界请求队列与 EOF 输出排空。
|
|
23
|
+
|
|
24
|
+
### 新增
|
|
25
|
+
|
|
26
|
+
- 为 `charset_write` 与 `charset_edit` 增加请求级 `expectedVersion` 乐观并发版本锁(多 Agent 共享单 MCP 实例时防过期覆盖),并为 MCP 工具补齐机器可读 `structuredContent`(`applied`、`verified`、`committed`、`undoId`、`version`、`encoding`、`bom`、`eol`、`bytesOnDisk`)。
|
|
27
|
+
- 新增 `pi-charset --version`、`pi-charset doctor`、`pi-charset explain <file>`、`mcp-config --help` / `--client cursor|windsurf` / `--local` 与严格的 CLI 参数校验。
|
|
28
|
+
|
|
11
29
|
## [0.1.6] - 2026-12-06
|
|
12
30
|
|
|
13
31
|
### 新增
|