@morphllm/morph-setup 1.0.1 → 1.0.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 +35 -36
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -621,11 +621,18 @@ async function writeJson(filePath, data) {
|
|
|
621
621
|
function tomlEscapeString(value) {
|
|
622
622
|
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n");
|
|
623
623
|
}
|
|
624
|
+
function buildMorphArgs(input) {
|
|
625
|
+
const args = ["-y", "@morphllm/morphmcp"];
|
|
626
|
+
if (input.apiKey) args.push("--api-key", input.apiKey);
|
|
627
|
+
return args;
|
|
628
|
+
}
|
|
624
629
|
function buildCodexMorphBlock(input) {
|
|
625
630
|
const lines = [];
|
|
626
631
|
lines.push("[mcp_servers.morph-mcp]");
|
|
627
632
|
lines.push('command = "npx"');
|
|
628
|
-
|
|
633
|
+
const morphArgs = buildMorphArgs(input);
|
|
634
|
+
const argsToml = morphArgs.map((a) => `"${tomlEscapeString(a)}"`).join(", ");
|
|
635
|
+
lines.push(`args = [${argsToml}]`);
|
|
629
636
|
lines.push("enabled = true");
|
|
630
637
|
const env = [];
|
|
631
638
|
if (input.apiKey) env.push(`MORPH_API_KEY = "${tomlEscapeString(input.apiKey)}"`);
|
|
@@ -700,7 +707,7 @@ async function installToMcpServersJson(configPath, input, options) {
|
|
|
700
707
|
servers[key] = {
|
|
701
708
|
...existing ?? {},
|
|
702
709
|
command: "npx",
|
|
703
|
-
args:
|
|
710
|
+
args: buildMorphArgs(input),
|
|
704
711
|
...env ? { env } : {}
|
|
705
712
|
};
|
|
706
713
|
await writeJson(configPath, obj);
|
|
@@ -727,7 +734,7 @@ async function installToClaudeCodeUserConfig(configPath, input) {
|
|
|
727
734
|
...existing ?? {},
|
|
728
735
|
type: "stdio",
|
|
729
736
|
command: "npx",
|
|
730
|
-
args:
|
|
737
|
+
args: buildMorphArgs(input),
|
|
731
738
|
...env ? { env } : {}
|
|
732
739
|
};
|
|
733
740
|
await writeJson(configPath, obj);
|
|
@@ -761,7 +768,7 @@ async function installToOpenCodeConfig(configPath, input) {
|
|
|
761
768
|
mcp[key] = {
|
|
762
769
|
...existing ?? {},
|
|
763
770
|
type: "local",
|
|
764
|
-
command: ["npx",
|
|
771
|
+
command: ["npx", ...buildMorphArgs(input)],
|
|
765
772
|
enabled: true,
|
|
766
773
|
...Object.keys(environment).length > 0 ? { environment } : {}
|
|
767
774
|
};
|
|
@@ -798,7 +805,7 @@ async function installToAmpSettings(configPath, input) {
|
|
|
798
805
|
servers[serverKey] = {
|
|
799
806
|
...existing ?? {},
|
|
800
807
|
command: "npx",
|
|
801
|
-
args:
|
|
808
|
+
args: buildMorphArgs(input),
|
|
802
809
|
...env ? { env } : {}
|
|
803
810
|
};
|
|
804
811
|
await writeJson(configPath, obj);
|
|
@@ -930,18 +937,28 @@ function getBundledSkillsDir() {
|
|
|
930
937
|
function getAllAgentTypes() {
|
|
931
938
|
return Object.keys(agents);
|
|
932
939
|
}
|
|
933
|
-
async function
|
|
934
|
-
const
|
|
940
|
+
async function selectPlatforms(opts) {
|
|
941
|
+
const supportedMcpIds = new Set(listSupportedMcpClients().map((c) => c.id));
|
|
942
|
+
const allPlatforms = getAllAgentTypes().filter((id) => supportedMcpIds.has(id));
|
|
935
943
|
if (opts.cliAgents.length > 0) return opts.cliAgents;
|
|
936
|
-
if (opts.yes)
|
|
937
|
-
|
|
938
|
-
|
|
944
|
+
if (opts.yes) {
|
|
945
|
+
const detectedAgents2 = await detectInstalledAgents();
|
|
946
|
+
const detectedMcp2 = detectMcpClients();
|
|
947
|
+
const detected2 = [.../* @__PURE__ */ new Set([...detectedAgents2, ...detectedMcp2])].filter(
|
|
948
|
+
(id) => supportedMcpIds.has(id)
|
|
949
|
+
);
|
|
950
|
+
return detected2.length > 0 ? detected2 : allPlatforms;
|
|
951
|
+
}
|
|
952
|
+
const detectedAgents = await detectInstalledAgents();
|
|
953
|
+
const detectedMcp = detectMcpClients();
|
|
954
|
+
const detected = /* @__PURE__ */ new Set([...detectedAgents, ...detectedMcp]);
|
|
955
|
+
const initial = detected.size > 0 ? [...detected] : allPlatforms;
|
|
939
956
|
const res = await p.multiselect({
|
|
940
|
-
message: "Choose which
|
|
941
|
-
options:
|
|
957
|
+
message: "Choose which platforms you want to install into:",
|
|
958
|
+
options: allPlatforms.map((id) => ({
|
|
942
959
|
value: id,
|
|
943
960
|
label: agents[id].displayName,
|
|
944
|
-
hint: detected.
|
|
961
|
+
hint: detected.has(id) ? "detected" : void 0
|
|
945
962
|
})),
|
|
946
963
|
initialValues: initial,
|
|
947
964
|
required: true
|
|
@@ -949,25 +966,6 @@ async function selectAgents(opts) {
|
|
|
949
966
|
if (p.isCancel(res)) process.exit(0);
|
|
950
967
|
return res;
|
|
951
968
|
}
|
|
952
|
-
async function selectMcpClients(opts) {
|
|
953
|
-
const supported = listSupportedMcpClients();
|
|
954
|
-
const detected = detectMcpClients();
|
|
955
|
-
if (opts.yes) {
|
|
956
|
-
return detected.length > 0 ? detected : supported.map((c) => c.id);
|
|
957
|
-
}
|
|
958
|
-
const res = await p.multiselect({
|
|
959
|
-
message: "Choose which apps to install the MCP into",
|
|
960
|
-
options: supported.map((c) => ({
|
|
961
|
-
value: c.id,
|
|
962
|
-
label: c.label,
|
|
963
|
-
hint: detected.includes(c.id) ? "detected" : void 0
|
|
964
|
-
})),
|
|
965
|
-
initialValues: detected.length > 0 ? detected : supported.map((c) => c.id),
|
|
966
|
-
required: true
|
|
967
|
-
});
|
|
968
|
-
if (p.isCancel(res)) process.exit(0);
|
|
969
|
-
return res;
|
|
970
|
-
}
|
|
971
969
|
async function getMorphMcpInput(opts) {
|
|
972
970
|
const envApiKey = process.env.MORPH_API_KEY;
|
|
973
971
|
const effectiveApiKey = opts.cliApiKey ?? envApiKey;
|
|
@@ -1037,22 +1035,23 @@ async function main() {
|
|
|
1037
1035
|
const pkg = require2("../package.json");
|
|
1038
1036
|
setVersion(pkg.version);
|
|
1039
1037
|
await showMorphSplash();
|
|
1040
|
-
const program = new Command().name("morph-setup").description("Install Morph MCP and bundled skills onto coding agents").argument("[source]", "Optional skills source (repo/path). Bundled skills are always installed.").option("--morph-api-key <key>", "MORPH_API_KEY to write into MCP config (overrides env)").option("-g, --global", "Install skills globally (default)").option("
|
|
1038
|
+
const program = new Command().name("morph-setup").description("Install Morph MCP and bundled skills onto coding agents").argument("[source]", "Optional skills source (repo/path). Bundled skills are always installed.").option("--morph-api-key <key>", "MORPH_API_KEY to write into MCP config (overrides env)").option("-g, --global", "Install skills globally (default)").option("-a, --agent <agents...>", "Target specific agents (repeatable)").option("-s, --skill <skills...>", "Install specific skills by name (only affects <source> skills)").option("-l, --list", "List available skills without installing").option("-y, --yes", "Skip all confirmation prompts").version(pkg.version);
|
|
1041
1039
|
const argv = process.argv.slice();
|
|
1042
1040
|
if (argv[2] === "--") argv.splice(2, 1);
|
|
1043
1041
|
program.parse(argv);
|
|
1044
1042
|
const opts = program.opts();
|
|
1045
1043
|
const source = program.args[0];
|
|
1046
1044
|
const yes = !!opts.yes;
|
|
1047
|
-
const global =
|
|
1045
|
+
const global = true;
|
|
1048
1046
|
p.intro(chalk.greenBright(" Morph MCP Install "));
|
|
1049
|
-
const mcpClients = await selectMcpClients({ yes });
|
|
1050
1047
|
const mcpInput = await getMorphMcpInput({
|
|
1051
1048
|
yes,
|
|
1052
1049
|
cliApiKey: opts.morphApiKey
|
|
1053
1050
|
});
|
|
1054
1051
|
const cliAgents = (opts.agent ?? []).map((a) => a);
|
|
1055
|
-
const
|
|
1052
|
+
const selectedPlatforms = await selectPlatforms({ yes, cliAgents });
|
|
1053
|
+
const mcpClients = selectedPlatforms;
|
|
1054
|
+
const targetAgents = selectedPlatforms;
|
|
1056
1055
|
if (opts.list) {
|
|
1057
1056
|
const bundled = await discoverSkills(getBundledSkillsDir());
|
|
1058
1057
|
p.log.info(chalk.greenBright("Bundled skills:"));
|