@morphllm/morph-setup 1.0.2 → 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 +12 -5
- 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);
|