Skip to content

fix(core): preserve UTF-8 BOM in filesystem writes#11947

Draft
noobezlol wants to merge 1 commit into
Kilo-Org:mainfrom
noobezlol:fix/11901-preserve-utf8-bom
Draft

fix(core): preserve UTF-8 BOM in filesystem writes#11947
noobezlol wants to merge 1 commit into
Kilo-Org:mainfrom
noobezlol:fix/11901-preserve-utf8-bom

Conversation

@noobezlol

Copy link
Copy Markdown
Contributor

Fixes #11901

Summary

  • Wrap AppFileSystem.readFileString so UTF-8 BOM-prefixed files return the BOM marker that Effect's TextDecoder strips by default.
  • Wrap AppFileSystem.writeFileString so overwriting an existing BOM-prefixed file preserves the marker unless the write is an append-style operation.
  • Route readJson, writeJson, and string writeWithDirs through the BOM-aware helpers while keeping JSON parsing free of the marker.
  • Add focused regression coverage for reading, direct overwrites, edit-style writeWithDirs, and JSON read/write behavior.

Tests run

  • bunx prettier --check packages/core/src/filesystem.ts packages/core/test/filesystem/filesystem-bom.test.ts (from repo root) - passed.
  • bun run lint packages/core/src/filesystem.ts packages/core/test/filesystem/filesystem-bom.test.ts (from repo root) - passed: 0 warnings, 0 errors.
  • bun test test/filesystem/filesystem-bom.test.ts (from packages/core) - passed: 4 pass, 0 fail.
  • bun test test/filesystem/filesystem.test.ts (from packages/core) - passed: 26 pass, 0 fail.
  • bun run typecheck (from packages/core) - passed.
  • git diff --check - passed.

Notes

  • The issue referenced the older packages/shared/src/filesystem.ts path; on current main, this shared filesystem service lives at packages/core/src/filesystem.ts.
  • To run the checks in this sparse D-drive checkout, I populated missing workspace packages with git sparse-checkout add packages/kilo-sandbox, git sparse-checkout add packages/kilo-gateway, and git sparse-checkout add packages/sdk/js. Git emitted Windows long-path warnings while scanning nested node_modules, but the commands completed.

Risk / compatibility

  • Low risk for normal UTF-8 files: files without an existing BOM continue to write without one.
  • Existing BOM-prefixed files keep their marker across string overwrites and JSON writes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: preserve UTF-8 BOM when reading/writing files

1 participant