encoding-aware-fs 0.1.0 → 0.1.2
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/.encoding-converter.json +5 -0
- package/.mcp.json +15 -0
- package/dist/index.js +103 -26
- package/opencode.jsonc +15 -0
- package/package.json +1 -1
package/.mcp.json
ADDED
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((
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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(
|
|
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 =
|
|
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
|
|
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
|
|
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((
|
|
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((
|
|
21716
|
+
return new Promise((resolve2) => {
|
|
21717
21717
|
const json = serializeMessage(message);
|
|
21718
21718
|
if (this._stdout.write(json)) {
|
|
21719
|
-
|
|
21719
|
+
resolve2();
|
|
21720
21720
|
} else {
|
|
21721
|
-
this._stdout.once("drain",
|
|
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((
|
|
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
|
-
|
|
22008
|
+
resolve2({ encoding: null, confidence: 0 });
|
|
22009
22009
|
return;
|
|
22010
22010
|
}
|
|
22011
22011
|
try {
|
|
22012
22012
|
const result = JSON.parse(output.trim());
|
|
22013
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26555
|
-
|
|
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
|
-
|
|
26560
|
-
|
|
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);
|
|
@@ -26670,9 +26725,10 @@ async function writeClaudeCodeConfig(cwd) {
|
|
|
26670
26725
|
if (!merged.mcpServers) {
|
|
26671
26726
|
merged.mcpServers = {};
|
|
26672
26727
|
}
|
|
26728
|
+
const isWindows = process.platform === "win32";
|
|
26673
26729
|
merged.mcpServers["encoding-aware-fs"] = {
|
|
26674
|
-
command: "npx",
|
|
26675
|
-
args: ["-y", "encoding-aware-fs", "serve"],
|
|
26730
|
+
command: isWindows ? "cmd" : "npx",
|
|
26731
|
+
args: isWindows ? ["/c", "npx", "-y", "encoding-aware-fs", "serve"] : ["-y", "encoding-aware-fs", "serve"],
|
|
26676
26732
|
env: {}
|
|
26677
26733
|
};
|
|
26678
26734
|
await writeJsonFile(configPath, merged);
|
|
@@ -26685,15 +26741,30 @@ async function writeOpenCodeConfig(cwd) {
|
|
|
26685
26741
|
if (!merged.mcp) {
|
|
26686
26742
|
merged.mcp = {};
|
|
26687
26743
|
}
|
|
26744
|
+
const isWindows = process.platform === "win32";
|
|
26688
26745
|
merged.mcp["encoding-aware-fs"] = {
|
|
26689
26746
|
type: "local",
|
|
26690
|
-
command: ["npx", "-y", "encoding-aware-fs", "serve"],
|
|
26747
|
+
command: isWindows ? ["cmd", "/c", "npx", "-y", "encoding-aware-fs", "serve"] : ["npx", "-y", "encoding-aware-fs", "serve"],
|
|
26691
26748
|
enabled: true,
|
|
26692
26749
|
timeout: 3e4
|
|
26693
26750
|
};
|
|
26694
26751
|
await writeJsonFile(configPath, merged);
|
|
26695
26752
|
console.log(` \u2713 Wrote ${configPath}`);
|
|
26696
26753
|
}
|
|
26754
|
+
async function copySkillFile(cwd, platform) {
|
|
26755
|
+
const sourcePath = path6.join(path6.resolve(__dirname, ".."), "skills", platform, "SKILL.md");
|
|
26756
|
+
try {
|
|
26757
|
+
await fs10.access(sourcePath);
|
|
26758
|
+
} catch {
|
|
26759
|
+
console.log(` \u26A0 Skill file not found, skipping`);
|
|
26760
|
+
return;
|
|
26761
|
+
}
|
|
26762
|
+
const targetDir = platform === "claude-code" ? path6.join(cwd, ".claude", "skills", "encoding-aware-fs") : path6.join(cwd, ".agents", "skills", "encoding-aware-fs");
|
|
26763
|
+
const targetPath = path6.join(targetDir, "SKILL.md");
|
|
26764
|
+
await fs10.mkdir(targetDir, { recursive: true });
|
|
26765
|
+
await fs10.copyFile(sourcePath, targetPath);
|
|
26766
|
+
console.log(` \u2713 Installed skill \u2192 ${targetPath}`);
|
|
26767
|
+
}
|
|
26697
26768
|
async function ensureEncodingConfig(cwd) {
|
|
26698
26769
|
const configPath = path6.join(cwd, ".encoding-converter.json");
|
|
26699
26770
|
try {
|
|
@@ -26752,6 +26823,11 @@ async function runInstaller() {
|
|
|
26752
26823
|
await writeOpenCodeConfig(cwd);
|
|
26753
26824
|
}
|
|
26754
26825
|
}
|
|
26826
|
+
console.log();
|
|
26827
|
+
console.log("Skill files:");
|
|
26828
|
+
for (const platform of platforms) {
|
|
26829
|
+
await copySkillFile(cwd, platform);
|
|
26830
|
+
}
|
|
26755
26831
|
await ensureEncodingConfig(cwd);
|
|
26756
26832
|
console.log();
|
|
26757
26833
|
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 +26840,7 @@ async function runInstaller() {
|
|
|
26764
26840
|
console.log("\u2502 OpenCode: restart opencode \u2502");
|
|
26765
26841
|
}
|
|
26766
26842
|
console.log("\u2502 \u2502");
|
|
26843
|
+
console.log("\u2502 Skill files installed for AI discovery. \u2502");
|
|
26767
26844
|
console.log("\u2502 The MCP server will start automatically \u2502");
|
|
26768
26845
|
console.log("\u2502 when your AI tool connects. \u2502");
|
|
26769
26846
|
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