codexport 0.1.7 → 0.1.8
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 +19 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { homedir, platform } from "node:os";
|
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { spawn } from "node:child_process";
|
|
13
13
|
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
14
|
-
const VERSION = "0.1.
|
|
14
|
+
const VERSION = "0.1.8";
|
|
15
15
|
const DEFAULT_PORT = 17342;
|
|
16
16
|
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
17
17
|
const CODEXPORT_DIR = ".codexport";
|
|
@@ -417,7 +417,7 @@ function rewritePortableMcpServer(_name, server, sourceRoot, sourceHome) {
|
|
|
417
417
|
return;
|
|
418
418
|
const command = typeof server.command === "string" ? server.command : undefined;
|
|
419
419
|
const args = Array.isArray(server.args) ? server.args : [];
|
|
420
|
-
const launcher = command ? portableMcpLauncher(_name, command, args, sourceHome) : undefined;
|
|
420
|
+
const launcher = command && mcpHasRequiredPortableEnv(_name, command, server) ? portableMcpLauncher(_name, command, args, sourceHome) : undefined;
|
|
421
421
|
if (launcher) {
|
|
422
422
|
server.command = launcher.command;
|
|
423
423
|
server.args = launcher.args.map((arg) => rewritePortablePath(arg, sourceRoot, sourceHome));
|
|
@@ -438,6 +438,9 @@ function rewritePortableMcpServer(_name, server, sourceRoot, sourceHome) {
|
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
+
if (typeof server.command === "string" && !server.url) {
|
|
442
|
+
ensurePortablePathEnv(server);
|
|
443
|
+
}
|
|
441
444
|
}
|
|
442
445
|
function portableMcpLauncher(name, command, args, sourceHome) {
|
|
443
446
|
const commandName = basenameAnyPlatform(command);
|
|
@@ -455,9 +458,22 @@ function portableMcpLauncher(name, command, args, sourceHome) {
|
|
|
455
458
|
}
|
|
456
459
|
return undefined;
|
|
457
460
|
}
|
|
461
|
+
function mcpHasRequiredPortableEnv(name, command, server) {
|
|
462
|
+
if (name !== "kagi-mcp" && basenameAnyPlatform(command) !== "kagi-mcp")
|
|
463
|
+
return true;
|
|
464
|
+
const env = server.env && typeof server.env === "object" && !Array.isArray(server.env) ? server.env : undefined;
|
|
465
|
+
return typeof env?.KAGI_API_KEY === "string" && env.KAGI_API_KEY.length > 0;
|
|
466
|
+
}
|
|
467
|
+
function ensurePortablePathEnv(server) {
|
|
468
|
+
const env = server.env && typeof server.env === "object" && !Array.isArray(server.env) ? server.env : {};
|
|
469
|
+
const existingPath = typeof env.PATH === "string" ? env.PATH : undefined;
|
|
470
|
+
const portableBins = ["${home}/.bun/bin", "${home}/.local/bin", "${home}/.cargo/bin", "${home}/go/bin"];
|
|
471
|
+
env.PATH = [...portableBins, existingPath ?? process.env.PATH ?? ""].filter(Boolean).join(path.delimiter);
|
|
472
|
+
server.env = env;
|
|
473
|
+
}
|
|
458
474
|
function npmPackageForPortableMcp(name, commandName) {
|
|
459
475
|
const knownPackages = {
|
|
460
|
-
"dora": "dora",
|
|
476
|
+
"dora": "@butttons/dora",
|
|
461
477
|
"kagi-mcp": "kagi-mcp",
|
|
462
478
|
"opensrc-mcp": "opensrc-mcp",
|
|
463
479
|
"opensrc-mcp-stdio": "opensrc-mcp",
|