@papicandela/mcx-cli 0.1.1 → 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/dist/index.js +213 -8
- 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);
|
|
@@ -49621,14 +49621,211 @@ function getRelativeImportPath2(configPath, adapterPath) {
|
|
|
49621
49621
|
return relative3;
|
|
49622
49622
|
}
|
|
49623
49623
|
|
|
49624
|
+
// src/commands/update.ts
|
|
49625
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
49626
|
+
import { spawn as spawn2 } from "child_process";
|
|
49627
|
+
import { readFile as readFile3, access as access4 } from "fs/promises";
|
|
49628
|
+
import { join as join8 } from "path";
|
|
49629
|
+
var CLI_PACKAGE = "@papicandela/mcx-cli";
|
|
49630
|
+
var CORE_PACKAGE = "@papicandela/mcx-core";
|
|
49631
|
+
var ADAPTERS_PACKAGE = "@papicandela/mcx-adapters";
|
|
49632
|
+
async function getInstalledVersion(pkg) {
|
|
49633
|
+
try {
|
|
49634
|
+
const result = await runCommand2("npm", ["list", pkg, "--json", "-g"], true);
|
|
49635
|
+
const data = JSON.parse(result);
|
|
49636
|
+
return data.dependencies?.[pkg]?.version || null;
|
|
49637
|
+
} catch {
|
|
49638
|
+
return null;
|
|
49639
|
+
}
|
|
49640
|
+
}
|
|
49641
|
+
async function getLatestVersion(pkg) {
|
|
49642
|
+
try {
|
|
49643
|
+
const result = await runCommand2("npm", ["view", pkg, "version"], true);
|
|
49644
|
+
return result.trim();
|
|
49645
|
+
} catch {
|
|
49646
|
+
return null;
|
|
49647
|
+
}
|
|
49648
|
+
}
|
|
49649
|
+
async function getProjectVersion(pkg, cwd) {
|
|
49650
|
+
try {
|
|
49651
|
+
const pkgPath = join8(cwd, "package.json");
|
|
49652
|
+
const content = await readFile3(pkgPath, "utf-8");
|
|
49653
|
+
const data = JSON.parse(content);
|
|
49654
|
+
const version2 = data.dependencies?.[pkg] || data.devDependencies?.[pkg];
|
|
49655
|
+
return version2?.replace(/[\^~]/, "") || null;
|
|
49656
|
+
} catch {
|
|
49657
|
+
return null;
|
|
49658
|
+
}
|
|
49659
|
+
}
|
|
49660
|
+
function runCommand2(cmd, args, silent = false) {
|
|
49661
|
+
return new Promise((resolve2, reject) => {
|
|
49662
|
+
const proc = spawn2(cmd, args, {
|
|
49663
|
+
shell: true,
|
|
49664
|
+
stdio: silent ? "pipe" : "inherit"
|
|
49665
|
+
});
|
|
49666
|
+
let output = "";
|
|
49667
|
+
if (silent && proc.stdout) {
|
|
49668
|
+
proc.stdout.on("data", (data) => {
|
|
49669
|
+
output += data.toString();
|
|
49670
|
+
});
|
|
49671
|
+
}
|
|
49672
|
+
proc.on("close", (code) => {
|
|
49673
|
+
if (code === 0) {
|
|
49674
|
+
resolve2(output);
|
|
49675
|
+
} else {
|
|
49676
|
+
reject(new Error(`Command failed with code ${code}`));
|
|
49677
|
+
}
|
|
49678
|
+
});
|
|
49679
|
+
proc.on("error", reject);
|
|
49680
|
+
});
|
|
49681
|
+
}
|
|
49682
|
+
async function exists4(path4) {
|
|
49683
|
+
try {
|
|
49684
|
+
await access4(path4);
|
|
49685
|
+
return true;
|
|
49686
|
+
} catch {
|
|
49687
|
+
return false;
|
|
49688
|
+
}
|
|
49689
|
+
}
|
|
49690
|
+
async function updateCli() {
|
|
49691
|
+
console.log(import_picocolors6.default.cyan(`
|
|
49692
|
+
Updating MCX CLI...`));
|
|
49693
|
+
const installed = await getInstalledVersion(CLI_PACKAGE);
|
|
49694
|
+
const latest = await getLatestVersion(CLI_PACKAGE);
|
|
49695
|
+
if (!latest) {
|
|
49696
|
+
console.log(import_picocolors6.default.red(" Failed to fetch latest version from npm"));
|
|
49697
|
+
return false;
|
|
49698
|
+
}
|
|
49699
|
+
if (installed === latest) {
|
|
49700
|
+
console.log(import_picocolors6.default.green(` Already at latest version (${latest})`));
|
|
49701
|
+
return true;
|
|
49702
|
+
}
|
|
49703
|
+
console.log(import_picocolors6.default.dim(` ${installed || "not installed"} \u2192 ${latest}`));
|
|
49704
|
+
try {
|
|
49705
|
+
await runCommand2("npm", ["install", "-g", `${CLI_PACKAGE}@latest`]);
|
|
49706
|
+
console.log(import_picocolors6.default.green(` Updated to ${latest}`));
|
|
49707
|
+
return true;
|
|
49708
|
+
} catch (error2) {
|
|
49709
|
+
console.log(import_picocolors6.default.red(" Update failed. Try running with sudo or as admin."));
|
|
49710
|
+
return false;
|
|
49711
|
+
}
|
|
49712
|
+
}
|
|
49713
|
+
async function updateProject(cwd) {
|
|
49714
|
+
console.log(import_picocolors6.default.cyan(`
|
|
49715
|
+
Updating project dependencies...`));
|
|
49716
|
+
const pkgPath = join8(cwd, "package.json");
|
|
49717
|
+
if (!await exists4(pkgPath)) {
|
|
49718
|
+
console.log(import_picocolors6.default.yellow(" No package.json found in current directory"));
|
|
49719
|
+
return false;
|
|
49720
|
+
}
|
|
49721
|
+
const coreVersion = await getProjectVersion(CORE_PACKAGE, cwd);
|
|
49722
|
+
const adaptersVersion = await getProjectVersion(ADAPTERS_PACKAGE, cwd);
|
|
49723
|
+
if (!coreVersion && !adaptersVersion) {
|
|
49724
|
+
console.log(import_picocolors6.default.yellow(" No MCX dependencies found in package.json"));
|
|
49725
|
+
return false;
|
|
49726
|
+
}
|
|
49727
|
+
const latestCore = await getLatestVersion(CORE_PACKAGE);
|
|
49728
|
+
const latestAdapters = await getLatestVersion(ADAPTERS_PACKAGE);
|
|
49729
|
+
const updates = [];
|
|
49730
|
+
if (coreVersion && latestCore && coreVersion !== latestCore) {
|
|
49731
|
+
console.log(import_picocolors6.default.dim(` ${CORE_PACKAGE}: ${coreVersion} \u2192 ${latestCore}`));
|
|
49732
|
+
updates.push(`${CORE_PACKAGE}@latest`);
|
|
49733
|
+
} else if (coreVersion) {
|
|
49734
|
+
console.log(import_picocolors6.default.green(` ${CORE_PACKAGE}: ${coreVersion} (up to date)`));
|
|
49735
|
+
}
|
|
49736
|
+
if (adaptersVersion && latestAdapters && adaptersVersion !== latestAdapters) {
|
|
49737
|
+
console.log(import_picocolors6.default.dim(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} \u2192 ${latestAdapters}`));
|
|
49738
|
+
updates.push(`${ADAPTERS_PACKAGE}@latest`);
|
|
49739
|
+
} else if (adaptersVersion) {
|
|
49740
|
+
console.log(import_picocolors6.default.green(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} (up to date)`));
|
|
49741
|
+
}
|
|
49742
|
+
if (updates.length === 0) {
|
|
49743
|
+
console.log(import_picocolors6.default.green(" All dependencies up to date"));
|
|
49744
|
+
return true;
|
|
49745
|
+
}
|
|
49746
|
+
try {
|
|
49747
|
+
console.log(import_picocolors6.default.dim(`
|
|
49748
|
+
Running bun install...`));
|
|
49749
|
+
await runCommand2("bun", ["add", ...updates], false);
|
|
49750
|
+
console.log(import_picocolors6.default.green(" Dependencies updated"));
|
|
49751
|
+
return true;
|
|
49752
|
+
} catch (error2) {
|
|
49753
|
+
console.log(import_picocolors6.default.red(" Failed to update dependencies"));
|
|
49754
|
+
return false;
|
|
49755
|
+
}
|
|
49756
|
+
}
|
|
49757
|
+
async function checkVersions(cwd) {
|
|
49758
|
+
console.log(import_picocolors6.default.cyan(`
|
|
49759
|
+
Checking versions...
|
|
49760
|
+
`));
|
|
49761
|
+
const installedCli = await getInstalledVersion(CLI_PACKAGE);
|
|
49762
|
+
const latestCli = await getLatestVersion(CLI_PACKAGE);
|
|
49763
|
+
console.log(import_picocolors6.default.bold("CLI:"));
|
|
49764
|
+
if (installedCli && latestCli) {
|
|
49765
|
+
if (installedCli === latestCli) {
|
|
49766
|
+
console.log(import_picocolors6.default.green(` ${CLI_PACKAGE}: ${installedCli} (latest)`));
|
|
49767
|
+
} else {
|
|
49768
|
+
console.log(import_picocolors6.default.yellow(` ${CLI_PACKAGE}: ${installedCli} \u2192 ${latestCli} available`));
|
|
49769
|
+
}
|
|
49770
|
+
} else {
|
|
49771
|
+
console.log(import_picocolors6.default.dim(` ${CLI_PACKAGE}: ${installedCli || "not installed"}`));
|
|
49772
|
+
}
|
|
49773
|
+
const pkgPath = join8(cwd, "package.json");
|
|
49774
|
+
if (await exists4(pkgPath)) {
|
|
49775
|
+
console.log(import_picocolors6.default.bold(`
|
|
49776
|
+
Project:`));
|
|
49777
|
+
const coreVersion = await getProjectVersion(CORE_PACKAGE, cwd);
|
|
49778
|
+
const latestCore = await getLatestVersion(CORE_PACKAGE);
|
|
49779
|
+
if (coreVersion && latestCore) {
|
|
49780
|
+
if (coreVersion === latestCore) {
|
|
49781
|
+
console.log(import_picocolors6.default.green(` ${CORE_PACKAGE}: ${coreVersion} (latest)`));
|
|
49782
|
+
} else {
|
|
49783
|
+
console.log(import_picocolors6.default.yellow(` ${CORE_PACKAGE}: ${coreVersion} \u2192 ${latestCore} available`));
|
|
49784
|
+
}
|
|
49785
|
+
} else if (coreVersion) {
|
|
49786
|
+
console.log(import_picocolors6.default.dim(` ${CORE_PACKAGE}: ${coreVersion}`));
|
|
49787
|
+
}
|
|
49788
|
+
const adaptersVersion = await getProjectVersion(ADAPTERS_PACKAGE, cwd);
|
|
49789
|
+
const latestAdapters = await getLatestVersion(ADAPTERS_PACKAGE);
|
|
49790
|
+
if (adaptersVersion && latestAdapters) {
|
|
49791
|
+
if (adaptersVersion === latestAdapters) {
|
|
49792
|
+
console.log(import_picocolors6.default.green(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} (latest)`));
|
|
49793
|
+
} else {
|
|
49794
|
+
console.log(import_picocolors6.default.yellow(` ${ADAPTERS_PACKAGE}: ${adaptersVersion} \u2192 ${latestAdapters} available`));
|
|
49795
|
+
}
|
|
49796
|
+
} else if (adaptersVersion) {
|
|
49797
|
+
console.log(import_picocolors6.default.dim(` ${ADAPTERS_PACKAGE}: ${adaptersVersion}`));
|
|
49798
|
+
}
|
|
49799
|
+
if (!coreVersion && !adaptersVersion) {
|
|
49800
|
+
console.log(import_picocolors6.default.dim(" No MCX dependencies found"));
|
|
49801
|
+
}
|
|
49802
|
+
}
|
|
49803
|
+
console.log();
|
|
49804
|
+
}
|
|
49805
|
+
async function updateCommand(options) {
|
|
49806
|
+
const cwd = process.cwd();
|
|
49807
|
+
if (options.check) {
|
|
49808
|
+
await checkVersions(cwd);
|
|
49809
|
+
return;
|
|
49810
|
+
}
|
|
49811
|
+
const updateBoth = !options.cli && !options.project;
|
|
49812
|
+
if (options.cli || updateBoth) {
|
|
49813
|
+
await updateCli();
|
|
49814
|
+
}
|
|
49815
|
+
if (options.project || updateBoth) {
|
|
49816
|
+
await updateProject(cwd);
|
|
49817
|
+
}
|
|
49818
|
+
console.log();
|
|
49819
|
+
}
|
|
49820
|
+
|
|
49624
49821
|
// src/index.ts
|
|
49625
49822
|
var program2 = new Command;
|
|
49626
|
-
program2.name("mcx").description("MCX - Modular Code Execution framework for AI agents").version("0.1.
|
|
49823
|
+
program2.name("mcx").description("MCX - Modular Code Execution framework for AI agents").version("0.1.2");
|
|
49627
49824
|
program2.command("init").description("Initialize a new MCX project in the current directory").action(async () => {
|
|
49628
49825
|
try {
|
|
49629
49826
|
await initCommand();
|
|
49630
49827
|
} catch (error2) {
|
|
49631
|
-
console.error(
|
|
49828
|
+
console.error(import_picocolors7.default.red("Init failed:"), error2);
|
|
49632
49829
|
process.exit(1);
|
|
49633
49830
|
}
|
|
49634
49831
|
});
|
|
@@ -49636,7 +49833,7 @@ program2.command("run <target>").description("Run a script file or skill").argum
|
|
|
49636
49833
|
try {
|
|
49637
49834
|
await runCommand(target, args);
|
|
49638
49835
|
} catch (error2) {
|
|
49639
|
-
console.error(
|
|
49836
|
+
console.error(import_picocolors7.default.red("Run failed:"), error2);
|
|
49640
49837
|
process.exit(1);
|
|
49641
49838
|
}
|
|
49642
49839
|
});
|
|
@@ -49648,7 +49845,7 @@ program2.command("serve").description("Start the MCP server for Claude Code inte
|
|
|
49648
49845
|
cwd: options.cwd
|
|
49649
49846
|
});
|
|
49650
49847
|
} catch (error2) {
|
|
49651
|
-
console.error(
|
|
49848
|
+
console.error(import_picocolors7.default.red("Serve failed:"), error2);
|
|
49652
49849
|
process.exit(1);
|
|
49653
49850
|
}
|
|
49654
49851
|
});
|
|
@@ -49656,7 +49853,7 @@ program2.command("list").alias("ls").description("List available skills and adap
|
|
|
49656
49853
|
try {
|
|
49657
49854
|
await listCommand();
|
|
49658
49855
|
} catch (error2) {
|
|
49659
|
-
console.error(
|
|
49856
|
+
console.error(import_picocolors7.default.red("List failed:"), error2);
|
|
49660
49857
|
process.exit(1);
|
|
49661
49858
|
}
|
|
49662
49859
|
});
|
|
@@ -49674,13 +49871,21 @@ program2.command("gen").alias("generate-adapter").description("Generate adapter
|
|
|
49674
49871
|
interactive: !source
|
|
49675
49872
|
});
|
|
49676
49873
|
} catch (error2) {
|
|
49677
|
-
console.error(
|
|
49874
|
+
console.error(import_picocolors7.default.red("Gen failed:"), error2);
|
|
49875
|
+
process.exit(1);
|
|
49876
|
+
}
|
|
49877
|
+
});
|
|
49878
|
+
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) => {
|
|
49879
|
+
try {
|
|
49880
|
+
await updateCommand(options);
|
|
49881
|
+
} catch (error2) {
|
|
49882
|
+
console.error(import_picocolors7.default.red("Update failed:"), error2);
|
|
49678
49883
|
process.exit(1);
|
|
49679
49884
|
}
|
|
49680
49885
|
});
|
|
49681
49886
|
if (process.argv.length === 2) {
|
|
49682
49887
|
serveCommand({ transport: "stdio" }).catch((error2) => {
|
|
49683
|
-
console.error(
|
|
49888
|
+
console.error(import_picocolors7.default.red("Serve failed:"), error2);
|
|
49684
49889
|
process.exit(1);
|
|
49685
49890
|
});
|
|
49686
49891
|
} 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.2",
|
|
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
|
}
|