* fix: catch EEXIST from recursive mkdir on Windows
fs.mkdir with { recursive: true } can still throw EEXIST on Windows
when the target directory is backed by an NTFS reparse point (OneDrive),
a directory junction, or a WSL-served path. libuv's recursive walk
doesn't treat these as regular directories, so mkdir with recursive:true
attempts to create an already-existing path segment and fails.
This adds a defensive EEXIST catch at both directory-creation origins:
- AppFileSystem.ensureDir / writeWithDirs (snapshots, config, plans)
- Encoding.write (all tool writes and edits)
No functional change on Linux/macOS where EEXIST is never thrown from
recursive mkdir.
Fixes#9618, #9755
* fix: remove extra arg from mkdirSafe call, add unit tests
* docs(kilo-docs): update auto-generated source links
Add 2 new GitHub issue references (9618, 9755) from encoding.ts
and update URL count from 84 to 86.
---------
Co-authored-by: nimgrim <nimgrim@users.noreply.github.com>
Co-authored-by: Imanol Maiztegui <imanol.mzd@gmail.com>
jschardet produced labels like "ascii", "gb2312", "MacCyrillic", "IBM855/866",
and "TIS-620". chardet's supported encoding set does not include any of
these (ASCII folds into UTF-8; Chinese is emitted as GB18030), so the
mappings were dead code.
chardet is less aggressive than jschardet on short CJK samples; a
12-byte Shift_JIS phrase now collides with the windows-1252 profile.
Reuse the longer Shift_JIS sample the rest of the suite relies on.
Swap jschardet for the actively-maintained chardet library for text
encoding detection. chardet ships with TypeScript definitions, so the
local jschardet module shim is no longer needed.
Replace `export namespace Encoding`/`EncodedIO` wrappers with top-level
exports and switch consumers to `import * as Encoding`/`EncodedIO`.
The module itself acts as the namespace, avoiding the TS-namespace
wrapper that tree-shakers and some module resolvers handle awkwardly.
Users that hand us BOM-less UTF-16/32 are violating the documented
contract; trust jschardet + iconv.encodingExists and let the result
be whatever it is.
Add unit tests for the Encoding namespace and extend the tool integration
suite with ApplyPatch delete and EditTool replaceAll paths for non-UTF-8
files.