Files
claude-code/spec/feature_20260510_F001_multi-encoding-file-tools/spec-plan-task-0.md
claude-code-best 0ce8f7a1cb feat: 添加 GBK 编码自动检测支持,文件读写工具透明处理非 UTF-8 文件
新增 encoding.ts 核心模块实现三层编码检测(BOM → UTF-8 fatal → GBK 回退),
改造同步/异步读取路径和写入路径,使 FileReadTool/FileEditTool/FileWriteTool
能正确处理 GBK 编码文件。包含完整单元测试和 spec 文档。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 20:50:12 +08:00

35 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### Task 0: 环境准备
**背景:**
确保构建和测试工具链在当前开发环境中可用,验证 Bun 运行时对 GBK 编码的 TextDecoder 支持情况。
**涉及文件:**
- 无文件修改,仅验证环境
**执行步骤:**
- [x] 验证 Bun 运行时可用
- 运行命令: `bun --version`
- 预期: 输出 Bun 版本号
- [x] 验证 TypeScript 编译无错误
- 运行命令: `bunx tsc --noEmit 2>&1 | tail -5`
- 预期: 无错误输出(或仅有已知的 pre-existing 错误)
- [x] 验证 Bun 对 GBK 编码的 TextDecoder 支持
- 运行命令: `bun -e "const d = new TextDecoder('gbk', { fatal: true }); const buf = Buffer.from([0xC4, 0xE3, 0xBA, 0xC3]); console.log(d.decode(buf))"`
- 预期: 输出 "你好"GBK 编码的中文字符)
- [x] 验证测试框架可用
- 运行命令: `bun test src/utils/__tests__/hash.test.ts 2>&1 | tail -3`
- 预期: 测试运行成功,无框架错误
**检查步骤:**
- [x] Bun 版本确认
- `bun --version`
- 预期: 输出有效版本号
- [x] GBK 编码支持确认
- `bun -e "console.log(new TextDecoder('gbk').decode(Buffer.from([0xC4, 0xE3, 0xBA, 0xC3])))"`
- 预期: 输出 "你好"
- [x] 现有测试通过
- `bun test src/utils/__tests__/file.test.ts 2>&1 | tail -3`
- 预期: 所有测试通过
---