encoding-aware-fs 0.1.0 → 0.1.1

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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "sourceEncoding": "GB18030",
3
+ "targetEncoding": "UTF-8",
4
+ "confidenceThreshold": 0.8
5
+ }
package/.mcp.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "mcpServers": {
3
+ "encoding-aware-fs": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "encoding-aware-fs",
8
+ "serve"
9
+ ],
10
+ "env": {}
11
+ }
12
+ }
13
+ }
package/dist/index.js CHANGED
@@ -12769,7 +12769,7 @@ var init_protocol = __esm({
12769
12769
  return;
12770
12770
  }
12771
12771
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
12772
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
12772
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
12773
12773
  options?.signal?.throwIfAborted();
12774
12774
  }
12775
12775
  } catch (error2) {
@@ -12786,7 +12786,7 @@ var init_protocol = __esm({
12786
12786
  */
12787
12787
  request(request, resultSchema, options) {
12788
12788
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
12789
- return new Promise((resolve, reject) => {
12789
+ return new Promise((resolve2, reject) => {
12790
12790
  const earlyReject = (error2) => {
12791
12791
  reject(error2);
12792
12792
  };
@@ -12864,7 +12864,7 @@ var init_protocol = __esm({
12864
12864
  if (!parseResult.success) {
12865
12865
  reject(parseResult.error);
12866
12866
  } else {
12867
- resolve(parseResult.data);
12867
+ resolve2(parseResult.data);
12868
12868
  }
12869
12869
  } catch (error2) {
12870
12870
  reject(error2);
@@ -13125,12 +13125,12 @@ var init_protocol = __esm({
13125
13125
  }
13126
13126
  } catch {
13127
13127
  }
13128
- return new Promise((resolve, reject) => {
13128
+ return new Promise((resolve2, reject) => {
13129
13129
  if (signal.aborted) {
13130
13130
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
13131
13131
  return;
13132
13132
  }
13133
- const timeoutId = setTimeout(resolve, interval);
13133
+ const timeoutId = setTimeout(resolve2, interval);
13134
13134
  signal.addEventListener("abort", () => {
13135
13135
  clearTimeout(timeoutId);
13136
13136
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -16167,7 +16167,7 @@ var require_compile = __commonJS({
16167
16167
  const schOrFunc = root.refs[ref];
16168
16168
  if (schOrFunc)
16169
16169
  return schOrFunc;
16170
- let _sch = resolve.call(this, root, ref);
16170
+ let _sch = resolve2.call(this, root, ref);
16171
16171
  if (_sch === void 0) {
16172
16172
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
16173
16173
  const { schemaId } = this.opts;
@@ -16194,7 +16194,7 @@ var require_compile = __commonJS({
16194
16194
  function sameSchemaEnv(s1, s2) {
16195
16195
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
16196
16196
  }
16197
- function resolve(root, ref) {
16197
+ function resolve2(root, ref) {
16198
16198
  let sch;
16199
16199
  while (typeof (sch = this.refs[ref]) == "string")
16200
16200
  ref = sch;
@@ -16770,7 +16770,7 @@ var require_fast_uri = __commonJS({
16770
16770
  }
16771
16771
  return uri;
16772
16772
  }
16773
- function resolve(baseURI, relativeURI, options) {
16773
+ function resolve2(baseURI, relativeURI, options) {
16774
16774
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
16775
16775
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
16776
16776
  schemelessOptions.skipEscape = true;
@@ -16998,7 +16998,7 @@ var require_fast_uri = __commonJS({
16998
16998
  var fastUri = {
16999
16999
  SCHEMES,
17000
17000
  normalize,
17001
- resolve,
17001
+ resolve: resolve2,
17002
17002
  resolveComponent,
17003
17003
  equal,
17004
17004
  serialize,
@@ -21122,7 +21122,7 @@ var init_mcp = __esm({
21122
21122
  let task = createTaskResult.task;
21123
21123
  const pollInterval = task.pollInterval ?? 5e3;
21124
21124
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
21125
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
21125
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
21126
21126
  const updatedTask = await extra.taskStore.getTask(taskId);
21127
21127
  if (!updatedTask) {
21128
21128
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -21713,12 +21713,12 @@ var init_stdio2 = __esm({
21713
21713
  this.onclose?.();
21714
21714
  }
21715
21715
  send(message) {
21716
- return new Promise((resolve) => {
21716
+ return new Promise((resolve2) => {
21717
21717
  const json = serializeMessage(message);
21718
21718
  if (this._stdout.write(json)) {
21719
- resolve();
21719
+ resolve2();
21720
21720
  } else {
21721
- this._stdout.once("drain", resolve);
21721
+ this._stdout.once("drain", resolve2);
21722
21722
  }
21723
21723
  });
21724
21724
  }
@@ -21973,7 +21973,7 @@ async function detectEncoding(filePath) {
21973
21973
  log("error", "Python not found for encoding detection", { error: String(err) });
21974
21974
  return { encoding: null, confidence: 0 };
21975
21975
  }
21976
- return new Promise((resolve) => {
21976
+ return new Promise((resolve2) => {
21977
21977
  const proc = (0, import_child_process.spawn)(pythonCmd, [
21978
21978
  "-c",
21979
21979
  `
@@ -22005,23 +22005,23 @@ except Exception as e:
22005
22005
  proc.on("close", (code) => {
22006
22006
  if (code !== 0) {
22007
22007
  log("debug", "Python chardet process failed", { code, stderr });
22008
- resolve({ encoding: null, confidence: 0 });
22008
+ resolve2({ encoding: null, confidence: 0 });
22009
22009
  return;
22010
22010
  }
22011
22011
  try {
22012
22012
  const result = JSON.parse(output.trim());
22013
- resolve({
22013
+ resolve2({
22014
22014
  encoding: result.encoding || null,
22015
22015
  confidence: result.confidence || 0
22016
22016
  });
22017
22017
  } catch {
22018
22018
  log("error", "Failed to parse chardet output", { output });
22019
- resolve({ encoding: null, confidence: 0 });
22019
+ resolve2({ encoding: null, confidence: 0 });
22020
22020
  }
22021
22021
  });
22022
22022
  proc.on("error", (err) => {
22023
22023
  log("error", "Failed to spawn Python process", { error: err.message });
22024
- resolve({ encoding: null, confidence: 0 });
22024
+ resolve2({ encoding: null, confidence: 0 });
22025
22025
  });
22026
22026
  });
22027
22027
  }
@@ -26541,6 +26541,23 @@ var uninstaller_exports = {};
26541
26541
  __export(uninstaller_exports, {
26542
26542
  runUninstaller: () => runUninstaller
26543
26543
  });
26544
+ async function fileExists(filePath) {
26545
+ try {
26546
+ await fs9.access(filePath);
26547
+ return true;
26548
+ } catch {
26549
+ return false;
26550
+ }
26551
+ }
26552
+ async function removeDirIfEmpty(dirPath) {
26553
+ try {
26554
+ const entries = await fs9.readdir(dirPath);
26555
+ if (entries.length === 0) {
26556
+ await fs9.rmdir(dirPath);
26557
+ }
26558
+ } catch {
26559
+ }
26560
+ }
26544
26561
  function isEmptyMcpJson(data) {
26545
26562
  return data && typeof data === "object" && data.mcpServers && typeof data.mcpServers === "object" && Object.keys(data.mcpServers).length === 0 && Object.keys(data).length === 1;
26546
26563
  }
@@ -26551,13 +26568,27 @@ async function detectInstalled(cwd) {
26551
26568
  const found = [];
26552
26569
  const mcpJsonPath = path5.join(cwd, ".mcp.json");
26553
26570
  const mcpJson = await readJsonFile(mcpJsonPath);
26554
- if (mcpJson?.mcpServers?.["encoding-aware-fs"]) {
26555
- found.push({ type: "claude-code", name: "Claude Code (.mcp.json)", configPath: mcpJsonPath });
26571
+ const claudeSkillPath = path5.join(cwd, ".claude", "skills", "encoding-aware-fs", "SKILL.md");
26572
+ const hasClaudeSkill = await fileExists(claudeSkillPath);
26573
+ if (mcpJson?.mcpServers?.["encoding-aware-fs"] || hasClaudeSkill) {
26574
+ found.push({
26575
+ type: "claude-code",
26576
+ name: "Claude Code (.mcp.json)",
26577
+ configPath: mcpJsonPath,
26578
+ skillPath: hasClaudeSkill ? claudeSkillPath : void 0
26579
+ });
26556
26580
  }
26557
26581
  const openCodePath = path5.join(cwd, "opencode.jsonc");
26558
26582
  const openCode = await readJsonFile(openCodePath);
26559
- if (openCode?.mcp?.["encoding-aware-fs"]) {
26560
- found.push({ type: "opencode", name: "OpenCode (opencode.jsonc)", configPath: openCodePath });
26583
+ const openCodeSkillPath = path5.join(cwd, ".agents", "skills", "encoding-aware-fs", "SKILL.md");
26584
+ const hasOpenCodeSkill = await fileExists(openCodeSkillPath);
26585
+ if (openCode?.mcp?.["encoding-aware-fs"] || hasOpenCodeSkill) {
26586
+ found.push({
26587
+ type: "opencode",
26588
+ name: "OpenCode (opencode.jsonc)",
26589
+ configPath: openCodePath,
26590
+ skillPath: hasOpenCodeSkill ? openCodeSkillPath : void 0
26591
+ });
26561
26592
  }
26562
26593
  return found;
26563
26594
  }
@@ -26587,6 +26618,24 @@ async function removeOpenCodeEntry(configPath) {
26587
26618
  console.log(` \u2713 Removed encoding-aware-fs entry from ${configPath}`);
26588
26619
  }
26589
26620
  }
26621
+ async function removeSkillFiles(platform) {
26622
+ if (!platform.skillPath)
26623
+ return;
26624
+ try {
26625
+ await fs9.unlink(platform.skillPath);
26626
+ console.log(` \u2713 Removed ${platform.skillPath}`);
26627
+ } catch (err) {
26628
+ if (err.code !== "ENOENT")
26629
+ throw err;
26630
+ return;
26631
+ }
26632
+ const skillDir = path5.dirname(platform.skillPath);
26633
+ await removeDirIfEmpty(skillDir);
26634
+ const skillsDir = path5.dirname(skillDir);
26635
+ await removeDirIfEmpty(skillsDir);
26636
+ const parentDir = path5.dirname(skillsDir);
26637
+ await removeDirIfEmpty(parentDir);
26638
+ }
26590
26639
  async function runUninstaller() {
26591
26640
  const cwd = process.cwd();
26592
26641
  console.log();
@@ -26603,10 +26652,13 @@ async function runUninstaller() {
26603
26652
  console.log("Found configurations:");
26604
26653
  for (const p of installed) {
26605
26654
  console.log(` \u2022 ${p.name}`);
26655
+ if (p.skillPath) {
26656
+ console.log(` + Skill file: ${p.skillPath}`);
26657
+ }
26606
26658
  }
26607
26659
  console.log();
26608
26660
  const proceed = await (0, import_prompts.confirm)({
26609
- message: "Remove encoding-aware-fs MCP config entries?",
26661
+ message: "Remove encoding-aware-fs MCP config entries and skill files?",
26610
26662
  default: false
26611
26663
  });
26612
26664
  if (!proceed) {
@@ -26621,6 +26673,9 @@ async function runUninstaller() {
26621
26673
  await removeOpenCodeEntry(p.configPath);
26622
26674
  }
26623
26675
  }
26676
+ for (const p of installed) {
26677
+ await removeSkillFiles(p);
26678
+ }
26624
26679
  const encodingConfigPath = path5.join(cwd, ".encoding-converter.json");
26625
26680
  try {
26626
26681
  await fs9.access(encodingConfigPath);
@@ -26694,6 +26749,20 @@ async function writeOpenCodeConfig(cwd) {
26694
26749
  await writeJsonFile(configPath, merged);
26695
26750
  console.log(` \u2713 Wrote ${configPath}`);
26696
26751
  }
26752
+ async function copySkillFile(cwd, platform) {
26753
+ const sourcePath = path6.join(path6.resolve(__dirname, ".."), "skills", platform, "SKILL.md");
26754
+ try {
26755
+ await fs10.access(sourcePath);
26756
+ } catch {
26757
+ console.log(` \u26A0 Skill file not found, skipping`);
26758
+ return;
26759
+ }
26760
+ const targetDir = platform === "claude-code" ? path6.join(cwd, ".claude", "skills", "encoding-aware-fs") : path6.join(cwd, ".agents", "skills", "encoding-aware-fs");
26761
+ const targetPath = path6.join(targetDir, "SKILL.md");
26762
+ await fs10.mkdir(targetDir, { recursive: true });
26763
+ await fs10.copyFile(sourcePath, targetPath);
26764
+ console.log(` \u2713 Installed skill \u2192 ${targetPath}`);
26765
+ }
26697
26766
  async function ensureEncodingConfig(cwd) {
26698
26767
  const configPath = path6.join(cwd, ".encoding-converter.json");
26699
26768
  try {
@@ -26752,6 +26821,11 @@ async function runInstaller() {
26752
26821
  await writeOpenCodeConfig(cwd);
26753
26822
  }
26754
26823
  }
26824
+ console.log();
26825
+ console.log("Skill files:");
26826
+ for (const platform of platforms) {
26827
+ await copySkillFile(cwd, platform);
26828
+ }
26755
26829
  await ensureEncodingConfig(cwd);
26756
26830
  console.log();
26757
26831
  console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
@@ -26764,6 +26838,7 @@ async function runInstaller() {
26764
26838
  console.log("\u2502 OpenCode: restart opencode \u2502");
26765
26839
  }
26766
26840
  console.log("\u2502 \u2502");
26841
+ console.log("\u2502 Skill files installed for AI discovery. \u2502");
26767
26842
  console.log("\u2502 The MCP server will start automatically \u2502");
26768
26843
  console.log("\u2502 when your AI tool connects. \u2502");
26769
26844
  console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
package/opencode.jsonc ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "mcp": {
3
+ "encoding-aware-fs": {
4
+ "type": "local",
5
+ "command": [
6
+ "npx",
7
+ "-y",
8
+ "encoding-aware-fs",
9
+ "serve"
10
+ ],
11
+ "enabled": true,
12
+ "timeout": 30000
13
+ }
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "encoding-aware-fs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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": {