encoding-aware-fs 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/dist/index.js CHANGED
@@ -29555,7 +29555,21 @@ function registerEditFile(server2, config3, allowedDirectories) {
29555
29555
  originalEncoding = resolvedSourceEncoding;
29556
29556
  }
29557
29557
  const utf8Content = isGBEncoding(originalEncoding) ? decodeToUtf8(buffer, originalEncoding) : buffer.toString("utf-8");
29558
- const modifiedContent = applyEditsToContent(utf8Content, args.edits);
29558
+ let modifiedContent;
29559
+ try {
29560
+ modifiedContent = applyEditsToContent(utf8Content, args.edits);
29561
+ } catch (editError) {
29562
+ const message = editError instanceof Error ? editError.message : String(editError);
29563
+ return {
29564
+ content: [{
29565
+ type: "text",
29566
+ text: `Error: ${message}
29567
+
29568
+ To fix this: call read_file with path "${args.path}" to get the current file content, then retry the edit with the exact text from the file. Do NOT use the built-in Edit tool \u2014 always use encoding-aware-fs MCP tools.`
29569
+ }],
29570
+ isError: true
29571
+ };
29572
+ }
29559
29573
  const diff = createUnifiedDiff(utf8Content, modifiedContent, args.path);
29560
29574
  if (!args.dryRun) {
29561
29575
  const finalContent = restoreLineEndings(modifiedContent, originalLineEnding);
package/dist/server.js CHANGED
@@ -28746,7 +28746,21 @@ function registerEditFile(server2, config3, allowedDirectories) {
28746
28746
  originalEncoding = resolvedSourceEncoding;
28747
28747
  }
28748
28748
  const utf8Content = isGBEncoding(originalEncoding) ? decodeToUtf8(buffer, originalEncoding) : buffer.toString("utf-8");
28749
- const modifiedContent = applyEditsToContent(utf8Content, args.edits);
28749
+ let modifiedContent;
28750
+ try {
28751
+ modifiedContent = applyEditsToContent(utf8Content, args.edits);
28752
+ } catch (editError) {
28753
+ const message = editError instanceof Error ? editError.message : String(editError);
28754
+ return {
28755
+ content: [{
28756
+ type: "text",
28757
+ text: `Error: ${message}
28758
+
28759
+ To fix this: call read_file with path "${args.path}" to get the current file content, then retry the edit with the exact text from the file. Do NOT use the built-in Edit tool \u2014 always use encoding-aware-fs MCP tools.`
28760
+ }],
28761
+ isError: true
28762
+ };
28763
+ }
28750
28764
  const diff = createUnifiedDiff(utf8Content, modifiedContent, args.path);
28751
28765
  if (!args.dryRun) {
28752
28766
  const finalContent = restoreLineEndings(modifiedContent, originalLineEnding);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "encoding-aware-fs",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Encoding-aware file operations MCP Server for AI tools working with GB18030 projects",
5
5
  "main": "dist/server.js",
6
6
  "bin": {