@papicandela/mcx-cli 0.1.1 → 0.1.3
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 +239 -12
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -16779,7 +16779,7 @@ var {
|
|
|
16779
16779
|
} = import__.default;
|
|
16780
16780
|
|
|
16781
16781
|
// src/index.ts
|
|
16782
|
-
var
|
|
16782
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
16783
16783
|
|
|
16784
16784
|
// src/commands/init.ts
|
|
16785
16785
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -49365,8 +49365,19 @@ function GeneratorWizard({ onComplete }) {
|
|
|
49365
49365
|
const adaptersRegex = /adapters:\s*\[([^\]]*)\]/s;
|
|
49366
49366
|
const match = newContent.match(adaptersRegex);
|
|
49367
49367
|
if (match) {
|
|
49368
|
-
|
|
49369
|
-
const
|
|
49368
|
+
let currentAdapters = match[1];
|
|
49369
|
+
const cleanedAdapters = currentAdapters.split(`
|
|
49370
|
+
`).map((line) => {
|
|
49371
|
+
const commentIndex = line.indexOf("//");
|
|
49372
|
+
if (commentIndex !== -1) {
|
|
49373
|
+
return line.slice(0, commentIndex);
|
|
49374
|
+
}
|
|
49375
|
+
return line;
|
|
49376
|
+
}).join(`
|
|
49377
|
+
`).trim();
|
|
49378
|
+
const adapterTokens = cleanedAdapters.split(/[,\s]+/).filter((token) => token.length > 0 && token !== ",");
|
|
49379
|
+
adapterTokens.push(adapterName);
|
|
49380
|
+
const newAdapters = adapterTokens.length > 0 ? adapterTokens.join(", ") : adapterName;
|
|
49370
49381
|
newContent = newContent.replace(adaptersRegex, `adapters: [${newAdapters}]`);
|
|
49371
49382
|
}
|
|
49372
49383
|
await Bun.write(configPath, newContent);
|
|
@@ -49601,8 +49612,19 @@ Adapter already imported in mcx.config.ts`));
|
|
|
49601
49612
|
const adaptersRegex = /adapters:\s*\[([^\]]*)\]/s;
|
|
49602
49613
|
const match = newContent.match(adaptersRegex);
|
|
49603
49614
|
if (match) {
|
|
49604
|
-
|
|
49605
|
-
const
|
|
49615
|
+
let currentAdapters = match[1];
|
|
49616
|
+
const cleanedAdapters = currentAdapters.split(`
|
|
49617
|
+
`).map((line) => {
|
|
49618
|
+
const commentIndex = line.indexOf("//");
|
|
49619
|
+
if (commentIndex !== -1) {
|
|
49620
|
+
return line.slice(0, commentIndex);
|
|
49621
|
+
}
|
|
49622
|
+
return line;
|
|
49623
|
+
}).join(`
|
|
49624
|
+
`).trim();
|
|
49625
|
+
const adapterTokens = cleanedAdapters.split(/[,\s]+/).filter((token) => token.length > 0 && token !== ",");
|
|
49626
|
+
adapterTokens.push(adapterName);
|
|
49627
|
+
const newAdapters = adapterTokens.length > 0 ? adapterTokens.join(", ") : adapterName;
|
|
49606
49628
|
newContent = newContent.replace(adaptersRegex, `adapters: [${newAdapters}]`);
|
|
49607
49629
|
}
|
|
49608
49630
|
await Bun.write(configPath, newContent);
|
|
@@ -49621,14 +49643,211 @@ function getRelativeImportPath2(configPath, adapterPath) {
|
|
|
49621
49643
|
return relative3;
|
|
49622
49644
|
}
|
|
49623
49645
|
|
|
49646
|
+
// src/commands/update.ts
|
|
49647
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
49648
|
+
import { spawn as spawn2 } from "child_process";
|
|
49649
|
+
import { readFile as readFile3, access as access4 } from "fs/promises";
|
|
49650
|
+
import { join as join8 } from "path";
|
|
49651
|
+
var CLI_PACKAGE = "@papicandela/mcx-cli";
|
|
49652
|
+
var CORE_PACKAGE = "@papicandela/mcx-core";
|
|
49653
|
+
var ADAPTERS_PACKAGE = "@papicandela/mcx-adapters";
|
|
49654
|
+
async function getInstalledVersion(pkg) {
|
|
49655
|
+
try {
|
|
49656
|
+
const result = await runCommand2("npm", ["list", pkg, "--json", "-g"], true);
|
|
49657
|
+
const data = JSON.parse(result);
|
|
49658
|
+
return data.dependencies?.[pkg]?.version || null;
|
|
49659
|
+
} catch {
|
|
49660
|
+
return null;
|
|
49661
|
+
}
|
|
49662
|
+
}
|
|
49663
|
+
async function getLatestVersion(pkg) {
|
|
49664
|
+
try {
|
|
49665
|
+
const result = await runCommand2("npm", ["view", pkg, "version"], true);
|
|
49666
|
+
return result.trim();
|
|
49667
|
+
} catch {
|
|
49668
|
+
return null;
|
|
49669
|
+
}
|
|
49670
|
+
}
|
|
49671
|
+
async function getProjectVersion(pkg, cwd) {
|
|
49672
|
+
try {
|
|
49673
|
+
const pkgPath = join8(cwd, "package.json");
|
|
49674
|
+
const content = await readFile3(pkgPath, "utf-8");
|
|
49675
|
+
const data = JSON.parse(content);
|
|
49676
|
+
const version2 = data.dependencies?.[pkg] || data.devDependencies?.[pkg];
|
|
49677
|
+
return version2?.replace(/[\^~]/, "") || null;
|
|
49678
|
+
} catch {
|
|
49679
|
+
return null;
|
|
49680
|
+
}
|
|
49681
|
+
}
|
|
49682
|
+
function runCommand2(cmd, args, silent = false) {
|
|
49683
|
+
return new Promise((resolve2, reject) => {
|
|
49684
|
+
const proc = spawn2(cmd, args, {
|
|
49685
|
+
shell: true,
|
|
49686
|
+
stdio: silent ? "pipe" : "inherit"
|
|
49687
|
+
});
|
|
49688
|
+
let output = "";
|
|
49689
|
+
if (silent && proc.stdout) {
|
|
49690
|
+
proc.stdout.on("data", (data) => {
|
|
49691
|
+
output += data.toString();
|
|
49692
|
+
});
|
|
49693
|
+
}
|
|
49694
|
+
proc.on("close", (code) => {
|
|
49695
|
+
if (code === 0) {
|
|
49696
|
+
resolve2(output);
|
|
49697
|
+
} else {
|
|
49698
|
+
reject(new Error(`Command failed with code ${code}`));
|
|
49699
|
+
}
|
|
49700
|
+
});
|
|
49701
|
+
proc.on("error", reject);
|
|
49702
|
+
});
|
|
49703
|
+
}
|
|
49704
|
+
async function exists4(path4) {
|
|
49705
|
+
try {
|
|
49706
|
+
await access4(path4);
|
|
49707
|
+
return true;
|
|
49708
|
+
} catch {
|
|
49709
|
+
return false;
|
|
49710
|
+
}
|
|
49711
|
+
}
|
|
49712
|
+
async function updateCli() {
|
|
49713
|
+
console.log(import_picocolors6.default.cyan(`
|
|
49714
|
+
Updating MCX CLI...`));
|
|
49715
|
+
const installed = await getInstalledVersion(CLI_PACKAGE);
|
|
49716
|
+
const latest = await getLatestVersion(CLI_PACKAGE);
|
|
49717
|
+
if (!latest) {
|
|
49718
|
+
console.log(import_picocolors6.default.red(" Failed to fetch latest version from npm"));
|
|
49719
|
+
return false;
|
|
49720
|
+
}
|
|
49721
|
+
if (installed === latest) {
|
|
49722
|
+
console.log(import_picocolors6.default.green(` Already at latest version (${latest})`));
|
|
49723
|
+
return true;
|
|
49724
|
+
}
|
|
49725
|
+
console.log(import_picocolors6.default.dim(` ${installed || "not installed"} \u2192 ${latest}`));
|
|
49726
|
+
try {
|
|
49727
|
+
await runCommand2("npm", ["install", "-g", `${CLI_PACKAGE}@latest`]);
|
|
49728
|
+
console.log(import_picocolors6.default.green(` Updated to ${latest}`));
|
|
49729
|
+
return true;
|
|
49730
|
+
} catch (error2) {
|
|
49731
|
+
console.log(import_picocolors6.default.red(" Update failed. Try running with sudo or as admin."));
|
|
49732
|
+
return false;
|
|
49733
|
+
}
|
|
49734
|
+
}
|
|
49735
|
+
async function updateProject(cwd) {
|
|
49736
|
+
console.log(import_picocolors6.default.cyan(`
|
|
49737
|
+
Updating project dependencies...`));
|
|
49738
|
+
const pkgPath = join8(cwd, "package.json");
|
|
49739
|
+
if (!await exists4(pkgPath)) {
|
|
49740
|
+
console.log(import_picocolors6.default.yellow(" No package.json found in current directory"));
|
|
49741
|
+
return false;
|
|
49742
|
+
}
|
|
49743
|
+
const coreVersion = await getProjectVersion(CORE_PACKAGE, cwd);
|
|
49744
|
+
const adaptersVersion = await getProjectVersion(ADAPTERS_PACKAGE, cwd);
|
|
49745
|
+
if (!coreVersion && !adaptersVersion) {
|
|
49746
|
+
console.log(import_picocolors6.default.yellow(" No MCX dependencies found in package.json"));
|
|
49747
|
+
return false;
|
|
49748
|
+
}
|
|
49749
|
+
const latestCore = await getLatestVersion(CORE_PACKAGE);
|
|
49750
|
+
const latestAdapters = await getLatestVersion(ADAPTERS_PACKAGE);
|
|
49751
|
+
const updates = [];
|
|
49752
|
+
if (coreVersion && latestCore && coreVersion !== latestCore) {
|
|
49753
|
+
console.log(import_picocolors6.default.dim(` ${CORE_PACKAGE}: ${coreVersion} \u2192 ${latestCore}`));
|
|
49754
|
+
updates.push(`${CORE_PACKAGE}@latest`);
|
|
49755
|
+
} else if (coreVersion) {
|
|
49756
|
+
console.log(import_picocolors6.default.green(` ${CORE_PACKAGE}: ${coreVersion} (up to date)`));
|
|
49757
|
+
}
|
|
49758
|
+
if (adaptersVersion && latestAdapters && adaptersVersion !== latestAdapters) {
|
|
49759
|
+
console.log(import_picocolors6.default.dim(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} \u2192 ${latestAdapters}`));
|
|
49760
|
+
updates.push(`${ADAPTERS_PACKAGE}@latest`);
|
|
49761
|
+
} else if (adaptersVersion) {
|
|
49762
|
+
console.log(import_picocolors6.default.green(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} (up to date)`));
|
|
49763
|
+
}
|
|
49764
|
+
if (updates.length === 0) {
|
|
49765
|
+
console.log(import_picocolors6.default.green(" All dependencies up to date"));
|
|
49766
|
+
return true;
|
|
49767
|
+
}
|
|
49768
|
+
try {
|
|
49769
|
+
console.log(import_picocolors6.default.dim(`
|
|
49770
|
+
Running bun install...`));
|
|
49771
|
+
await runCommand2("bun", ["add", ...updates], false);
|
|
49772
|
+
console.log(import_picocolors6.default.green(" Dependencies updated"));
|
|
49773
|
+
return true;
|
|
49774
|
+
} catch (error2) {
|
|
49775
|
+
console.log(import_picocolors6.default.red(" Failed to update dependencies"));
|
|
49776
|
+
return false;
|
|
49777
|
+
}
|
|
49778
|
+
}
|
|
49779
|
+
async function checkVersions(cwd) {
|
|
49780
|
+
console.log(import_picocolors6.default.cyan(`
|
|
49781
|
+
Checking versions...
|
|
49782
|
+
`));
|
|
49783
|
+
const installedCli = await getInstalledVersion(CLI_PACKAGE);
|
|
49784
|
+
const latestCli = await getLatestVersion(CLI_PACKAGE);
|
|
49785
|
+
console.log(import_picocolors6.default.bold("CLI:"));
|
|
49786
|
+
if (installedCli && latestCli) {
|
|
49787
|
+
if (installedCli === latestCli) {
|
|
49788
|
+
console.log(import_picocolors6.default.green(` ${CLI_PACKAGE}: ${installedCli} (latest)`));
|
|
49789
|
+
} else {
|
|
49790
|
+
console.log(import_picocolors6.default.yellow(` ${CLI_PACKAGE}: ${installedCli} \u2192 ${latestCli} available`));
|
|
49791
|
+
}
|
|
49792
|
+
} else {
|
|
49793
|
+
console.log(import_picocolors6.default.dim(` ${CLI_PACKAGE}: ${installedCli || "not installed"}`));
|
|
49794
|
+
}
|
|
49795
|
+
const pkgPath = join8(cwd, "package.json");
|
|
49796
|
+
if (await exists4(pkgPath)) {
|
|
49797
|
+
console.log(import_picocolors6.default.bold(`
|
|
49798
|
+
Project:`));
|
|
49799
|
+
const coreVersion = await getProjectVersion(CORE_PACKAGE, cwd);
|
|
49800
|
+
const latestCore = await getLatestVersion(CORE_PACKAGE);
|
|
49801
|
+
if (coreVersion && latestCore) {
|
|
49802
|
+
if (coreVersion === latestCore) {
|
|
49803
|
+
console.log(import_picocolors6.default.green(` ${CORE_PACKAGE}: ${coreVersion} (latest)`));
|
|
49804
|
+
} else {
|
|
49805
|
+
console.log(import_picocolors6.default.yellow(` ${CORE_PACKAGE}: ${coreVersion} \u2192 ${latestCore} available`));
|
|
49806
|
+
}
|
|
49807
|
+
} else if (coreVersion) {
|
|
49808
|
+
console.log(import_picocolors6.default.dim(` ${CORE_PACKAGE}: ${coreVersion}`));
|
|
49809
|
+
}
|
|
49810
|
+
const adaptersVersion = await getProjectVersion(ADAPTERS_PACKAGE, cwd);
|
|
49811
|
+
const latestAdapters = await getLatestVersion(ADAPTERS_PACKAGE);
|
|
49812
|
+
if (adaptersVersion && latestAdapters) {
|
|
49813
|
+
if (adaptersVersion === latestAdapters) {
|
|
49814
|
+
console.log(import_picocolors6.default.green(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} (latest)`));
|
|
49815
|
+
} else {
|
|
49816
|
+
console.log(import_picocolors6.default.yellow(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} \u2192 ${latestAdapters} available`));
|
|
49817
|
+
}
|
|
49818
|
+
} else if (adaptersVersion) {
|
|
49819
|
+
console.log(import_picocolors6.default.dim(` ${ADAPTERS_PACKAGE}: ${adaptersVersion}`));
|
|
49820
|
+
}
|
|
49821
|
+
if (!coreVersion && !adaptersVersion) {
|
|
49822
|
+
console.log(import_picocolors6.default.dim(" No MCX dependencies found"));
|
|
49823
|
+
}
|
|
49824
|
+
}
|
|
49825
|
+
console.log();
|
|
49826
|
+
}
|
|
49827
|
+
async function updateCommand(options) {
|
|
49828
|
+
const cwd = process.cwd();
|
|
49829
|
+
if (options.check) {
|
|
49830
|
+
await checkVersions(cwd);
|
|
49831
|
+
return;
|
|
49832
|
+
}
|
|
49833
|
+
const updateBoth = !options.cli && !options.project;
|
|
49834
|
+
if (options.cli || updateBoth) {
|
|
49835
|
+
await updateCli();
|
|
49836
|
+
}
|
|
49837
|
+
if (options.project || updateBoth) {
|
|
49838
|
+
await updateProject(cwd);
|
|
49839
|
+
}
|
|
49840
|
+
console.log();
|
|
49841
|
+
}
|
|
49842
|
+
|
|
49624
49843
|
// src/index.ts
|
|
49625
49844
|
var program2 = new Command;
|
|
49626
|
-
program2.name("mcx").description("MCX - Modular Code Execution framework for AI agents").version("0.1.
|
|
49845
|
+
program2.name("mcx").description("MCX - Modular Code Execution framework for AI agents").version("0.1.3");
|
|
49627
49846
|
program2.command("init").description("Initialize a new MCX project in the current directory").action(async () => {
|
|
49628
49847
|
try {
|
|
49629
49848
|
await initCommand();
|
|
49630
49849
|
} catch (error2) {
|
|
49631
|
-
console.error(
|
|
49850
|
+
console.error(import_picocolors7.default.red("Init failed:"), error2);
|
|
49632
49851
|
process.exit(1);
|
|
49633
49852
|
}
|
|
49634
49853
|
});
|
|
@@ -49636,7 +49855,7 @@ program2.command("run <target>").description("Run a script file or skill").argum
|
|
|
49636
49855
|
try {
|
|
49637
49856
|
await runCommand(target, args);
|
|
49638
49857
|
} catch (error2) {
|
|
49639
|
-
console.error(
|
|
49858
|
+
console.error(import_picocolors7.default.red("Run failed:"), error2);
|
|
49640
49859
|
process.exit(1);
|
|
49641
49860
|
}
|
|
49642
49861
|
});
|
|
@@ -49648,7 +49867,7 @@ program2.command("serve").description("Start the MCP server for Claude Code inte
|
|
|
49648
49867
|
cwd: options.cwd
|
|
49649
49868
|
});
|
|
49650
49869
|
} catch (error2) {
|
|
49651
|
-
console.error(
|
|
49870
|
+
console.error(import_picocolors7.default.red("Serve failed:"), error2);
|
|
49652
49871
|
process.exit(1);
|
|
49653
49872
|
}
|
|
49654
49873
|
});
|
|
@@ -49656,7 +49875,7 @@ program2.command("list").alias("ls").description("List available skills and adap
|
|
|
49656
49875
|
try {
|
|
49657
49876
|
await listCommand();
|
|
49658
49877
|
} catch (error2) {
|
|
49659
|
-
console.error(
|
|
49878
|
+
console.error(import_picocolors7.default.red("List failed:"), error2);
|
|
49660
49879
|
process.exit(1);
|
|
49661
49880
|
}
|
|
49662
49881
|
});
|
|
@@ -49674,13 +49893,21 @@ program2.command("gen").alias("generate-adapter").description("Generate adapter
|
|
|
49674
49893
|
interactive: !source
|
|
49675
49894
|
});
|
|
49676
49895
|
} catch (error2) {
|
|
49677
|
-
console.error(
|
|
49896
|
+
console.error(import_picocolors7.default.red("Gen failed:"), error2);
|
|
49897
|
+
process.exit(1);
|
|
49898
|
+
}
|
|
49899
|
+
});
|
|
49900
|
+
program2.command("update").alias("upgrade").description("Update MCX CLI and project dependencies").option("-c, --cli", "Update CLI only").option("-p, --project", "Update project dependencies only").option("--check", "Check versions without updating").action(async (options) => {
|
|
49901
|
+
try {
|
|
49902
|
+
await updateCommand(options);
|
|
49903
|
+
} catch (error2) {
|
|
49904
|
+
console.error(import_picocolors7.default.red("Update failed:"), error2);
|
|
49678
49905
|
process.exit(1);
|
|
49679
49906
|
}
|
|
49680
49907
|
});
|
|
49681
49908
|
if (process.argv.length === 2) {
|
|
49682
49909
|
serveCommand({ transport: "stdio" }).catch((error2) => {
|
|
49683
|
-
console.error(
|
|
49910
|
+
console.error(import_picocolors7.default.red("Serve failed:"), error2);
|
|
49684
49911
|
process.exit(1);
|
|
49685
49912
|
});
|
|
49686
49913
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papicandela/mcx-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "CLI for the MCX framework - MCP Code Execution",
|
|
5
5
|
"author": "papicandela",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,6 +52,5 @@
|
|
|
52
52
|
"cli",
|
|
53
53
|
"mcp",
|
|
54
54
|
"claude"
|
|
55
|
-
]
|
|
56
|
-
"license": "MIT"
|
|
55
|
+
]
|
|
57
56
|
}
|