pantheon-cli 0.2.15 → 0.2.17
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/pantheon.mjs +190 -32
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -23706,12 +23706,12 @@ import { hostname as hostname3 } from "node:os";
|
|
|
23706
23706
|
|
|
23707
23707
|
// src/connect.ts
|
|
23708
23708
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
23709
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync6, renameSync } from "node:fs";
|
|
23709
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, renameSync as renameSync2 } from "node:fs";
|
|
23710
23710
|
import { hostname as hostname2 } from "node:os";
|
|
23711
23711
|
import { join as join7 } from "node:path";
|
|
23712
23712
|
|
|
23713
23713
|
// src/mcp-install.ts
|
|
23714
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
23714
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
23715
23715
|
import { homedir as homedir5 } from "node:os";
|
|
23716
23716
|
import { dirname as dirname2, join as join6 } from "node:path";
|
|
23717
23717
|
import { fileURLToPath } from "node:url";
|
|
@@ -23740,17 +23740,109 @@ function mcpServer(home, withType = false) {
|
|
|
23740
23740
|
if (withType) server.type = "stdio";
|
|
23741
23741
|
return server;
|
|
23742
23742
|
}
|
|
23743
|
+
function stripComments(text2) {
|
|
23744
|
+
let out = "";
|
|
23745
|
+
let inString = false;
|
|
23746
|
+
let escaped = false;
|
|
23747
|
+
for (let i = 0; i < text2.length; i += 1) {
|
|
23748
|
+
const ch = text2[i];
|
|
23749
|
+
if (inString) {
|
|
23750
|
+
out += ch;
|
|
23751
|
+
if (escaped) escaped = false;
|
|
23752
|
+
else if (ch === "\\") escaped = true;
|
|
23753
|
+
else if (ch === '"') inString = false;
|
|
23754
|
+
continue;
|
|
23755
|
+
}
|
|
23756
|
+
if (ch === '"') {
|
|
23757
|
+
inString = true;
|
|
23758
|
+
out += ch;
|
|
23759
|
+
continue;
|
|
23760
|
+
}
|
|
23761
|
+
if (ch === "/" && text2[i + 1] === "/") {
|
|
23762
|
+
while (i < text2.length && text2[i] !== "\n") i += 1;
|
|
23763
|
+
out += "\n";
|
|
23764
|
+
continue;
|
|
23765
|
+
}
|
|
23766
|
+
if (ch === "/" && text2[i + 1] === "*") {
|
|
23767
|
+
i += 2;
|
|
23768
|
+
while (i < text2.length && !(text2[i] === "*" && text2[i + 1] === "/")) i += 1;
|
|
23769
|
+
i += 1;
|
|
23770
|
+
continue;
|
|
23771
|
+
}
|
|
23772
|
+
out += ch;
|
|
23773
|
+
}
|
|
23774
|
+
return out;
|
|
23775
|
+
}
|
|
23776
|
+
function stripTrailingCommas(text2) {
|
|
23777
|
+
const out = [];
|
|
23778
|
+
let inString = false;
|
|
23779
|
+
let escaped = false;
|
|
23780
|
+
let comma = -1;
|
|
23781
|
+
for (const ch of text2) {
|
|
23782
|
+
if (inString) {
|
|
23783
|
+
out.push(ch);
|
|
23784
|
+
if (escaped) escaped = false;
|
|
23785
|
+
else if (ch === "\\") escaped = true;
|
|
23786
|
+
else if (ch === '"') inString = false;
|
|
23787
|
+
continue;
|
|
23788
|
+
}
|
|
23789
|
+
if (ch === '"') {
|
|
23790
|
+
inString = true;
|
|
23791
|
+
comma = -1;
|
|
23792
|
+
out.push(ch);
|
|
23793
|
+
continue;
|
|
23794
|
+
}
|
|
23795
|
+
if (/\s/.test(ch)) {
|
|
23796
|
+
out.push(ch);
|
|
23797
|
+
continue;
|
|
23798
|
+
}
|
|
23799
|
+
if (ch === ",") {
|
|
23800
|
+
comma = out.length;
|
|
23801
|
+
out.push(ch);
|
|
23802
|
+
continue;
|
|
23803
|
+
}
|
|
23804
|
+
if ((ch === "}" || ch === "]") && comma >= 0) out[comma] = "";
|
|
23805
|
+
comma = -1;
|
|
23806
|
+
out.push(ch);
|
|
23807
|
+
}
|
|
23808
|
+
return out.join("");
|
|
23809
|
+
}
|
|
23810
|
+
function isPlainObject3(value) {
|
|
23811
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23812
|
+
}
|
|
23743
23813
|
function readJson(path) {
|
|
23744
23814
|
if (!existsSync6(path)) return {};
|
|
23815
|
+
const text2 = readFileSync5(path, "utf8").replace(/^\uFEFF/, "");
|
|
23816
|
+
if (!text2.trim()) return {};
|
|
23817
|
+
let value;
|
|
23745
23818
|
try {
|
|
23746
|
-
|
|
23747
|
-
} catch {
|
|
23748
|
-
|
|
23819
|
+
value = JSON.parse(text2);
|
|
23820
|
+
} catch (strict) {
|
|
23821
|
+
try {
|
|
23822
|
+
value = JSON.parse(stripTrailingCommas(stripComments(text2)));
|
|
23823
|
+
} catch {
|
|
23824
|
+
const why = strict instanceof Error ? strict.message : String(strict);
|
|
23825
|
+
throw new Error(`${path} is not valid JSON \u2014 ${why}`);
|
|
23826
|
+
}
|
|
23749
23827
|
}
|
|
23828
|
+
if (!isPlainObject3(value)) {
|
|
23829
|
+
throw new Error(`${path} is not valid JSON \u2014 the top level must be an object`);
|
|
23830
|
+
}
|
|
23831
|
+
return value;
|
|
23750
23832
|
}
|
|
23751
|
-
function
|
|
23833
|
+
function writeAtomic(path, text2) {
|
|
23752
23834
|
mkdirSync5(dirname2(path), { recursive: true });
|
|
23753
|
-
|
|
23835
|
+
const temp = `${path}.pantheon-${process.pid}.tmp`;
|
|
23836
|
+
try {
|
|
23837
|
+
writeFileSync5(temp, text2);
|
|
23838
|
+
renameSync(temp, path);
|
|
23839
|
+
} catch (error2) {
|
|
23840
|
+
if (existsSync6(temp)) unlinkSync2(temp);
|
|
23841
|
+
throw error2;
|
|
23842
|
+
}
|
|
23843
|
+
}
|
|
23844
|
+
function writeJson(path, data) {
|
|
23845
|
+
writeAtomic(path, `${JSON.stringify(data, null, 2)}
|
|
23754
23846
|
`);
|
|
23755
23847
|
}
|
|
23756
23848
|
function mergeMcpJson(path, home, server, key = "mcpServers") {
|
|
@@ -23791,7 +23883,7 @@ function upsertCodex(home) {
|
|
|
23791
23883
|
""
|
|
23792
23884
|
].join("\n");
|
|
23793
23885
|
if (!existsSync6(path)) {
|
|
23794
|
-
|
|
23886
|
+
writeAtomic(path, block2);
|
|
23795
23887
|
return;
|
|
23796
23888
|
}
|
|
23797
23889
|
const existing = readFileSync5(path, "utf8");
|
|
@@ -23800,11 +23892,11 @@ function upsertCodex(home) {
|
|
|
23800
23892
|
/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/,
|
|
23801
23893
|
block2.trim()
|
|
23802
23894
|
);
|
|
23803
|
-
|
|
23895
|
+
writeAtomic(path, next.endsWith("\n") ? next : `${next}
|
|
23804
23896
|
`);
|
|
23805
23897
|
return;
|
|
23806
23898
|
}
|
|
23807
|
-
|
|
23899
|
+
writeAtomic(path, `${existing.trimEnd()}
|
|
23808
23900
|
|
|
23809
23901
|
${block2}`);
|
|
23810
23902
|
}
|
|
@@ -23944,39 +24036,94 @@ function tilde(path) {
|
|
|
23944
24036
|
const home = homedir5();
|
|
23945
24037
|
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
23946
24038
|
}
|
|
24039
|
+
function detectApps() {
|
|
24040
|
+
const home = homedir5();
|
|
24041
|
+
const mac = process.platform === "darwin";
|
|
24042
|
+
const win = process.platform === "win32";
|
|
24043
|
+
const local = process.env.LOCALAPPDATA || join6(home, "AppData", "Local");
|
|
24044
|
+
const roaming = process.env.APPDATA || join6(home, "AppData", "Roaming");
|
|
24045
|
+
const evidence = {
|
|
24046
|
+
Cursor: [
|
|
24047
|
+
join6(home, ".cursor", "extensions"),
|
|
24048
|
+
join6(home, ".cursor", "argv.json"),
|
|
24049
|
+
join6(home, ".cursor", "cli"),
|
|
24050
|
+
...mac ? ["/Applications/Cursor.app", join6(home, "Applications", "Cursor.app")] : [],
|
|
24051
|
+
...win ? [join6(local, "Programs", "cursor")] : []
|
|
24052
|
+
],
|
|
24053
|
+
"Claude Code": [
|
|
24054
|
+
join6(home, ".claude", "projects"),
|
|
24055
|
+
join6(home, ".claude", "settings.json"),
|
|
24056
|
+
join6(home, ".claude", "history.jsonl"),
|
|
24057
|
+
join6(home, ".claude", "statsig")
|
|
24058
|
+
],
|
|
24059
|
+
"Claude Desktop": [
|
|
24060
|
+
...mac ? ["/Applications/Claude.app", join6(home, "Applications", "Claude.app")] : [],
|
|
24061
|
+
...win ? [join6(local, "AnthropicClaude"), join6(roaming, "Claude", "window-state.json")] : [],
|
|
24062
|
+
...!mac && !win ? [join6(home, ".config", "Claude", "window-state.json")] : []
|
|
24063
|
+
],
|
|
24064
|
+
"ChatGPT.app": mac ? ["/Applications/ChatGPT.app", join6(home, "Applications", "ChatGPT.app")] : [],
|
|
24065
|
+
Codex: [
|
|
24066
|
+
join6(home, ".codex", "sessions"),
|
|
24067
|
+
join6(home, ".codex", "auth.json"),
|
|
24068
|
+
join6(home, ".codex", "history.jsonl"),
|
|
24069
|
+
join6(home, ".codex", "log")
|
|
24070
|
+
],
|
|
24071
|
+
Windsurf: [
|
|
24072
|
+
join6(home, ".codeium", "windsurf"),
|
|
24073
|
+
...mac ? ["/Applications/Windsurf.app", join6(home, "Applications", "Windsurf.app")] : []
|
|
24074
|
+
]
|
|
24075
|
+
};
|
|
24076
|
+
const found = /* @__PURE__ */ new Set();
|
|
24077
|
+
for (const [name, paths] of Object.entries(evidence)) {
|
|
24078
|
+
if (paths.some((path) => existsSync6(path))) found.add(name);
|
|
24079
|
+
}
|
|
24080
|
+
return found;
|
|
24081
|
+
}
|
|
24082
|
+
var AHEAD = "Written ahead \u2014 app not detected, ready if you install it";
|
|
24083
|
+
function nextSteps(found, apiUrl) {
|
|
24084
|
+
if (found.length) return " Reload MCP in each app, then type /pantheon-handoff <space>";
|
|
24085
|
+
return [
|
|
24086
|
+
" No desktop agent detected. The configs above are in place if you install one.",
|
|
24087
|
+
"",
|
|
24088
|
+
" Using Claude.ai or ChatGPT in a browser instead? Connect it from",
|
|
24089
|
+
` ${apiUrl}/app/settings/connect`
|
|
24090
|
+
].join("\n");
|
|
24091
|
+
}
|
|
23947
24092
|
function installMcpClients(home) {
|
|
23948
24093
|
const written = [];
|
|
24094
|
+
const ahead = [];
|
|
23949
24095
|
const skipped = [];
|
|
23950
24096
|
const server = mcpServer(home);
|
|
23951
|
-
const
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
|
|
23955
|
-
|
|
23956
|
-
|
|
24097
|
+
const found = detectApps();
|
|
24098
|
+
const install = (name, path, entry) => {
|
|
24099
|
+
try {
|
|
24100
|
+
mergeMcpJson(path, home, entry);
|
|
24101
|
+
(found.has(name) ? written : ahead).push({ name, detail: tilde(path) });
|
|
24102
|
+
} catch (error2) {
|
|
24103
|
+
const why = error2 instanceof Error ? error2.message : String(error2);
|
|
24104
|
+
skipped.push({ name, detail: why.replace(homedir5(), "~") });
|
|
24105
|
+
}
|
|
24106
|
+
};
|
|
24107
|
+
install("Cursor", join6(homedir5(), ".cursor", "mcp.json"), server);
|
|
24108
|
+
install("Claude Code", join6(homedir5(), ".claude.json"), mcpServer(home, true));
|
|
23957
24109
|
const desktop = claudeDesktopPath();
|
|
23958
24110
|
if (existsSync6(dirname2(desktop)) || process.platform === "darwin" || process.platform === "win32") {
|
|
23959
|
-
|
|
23960
|
-
written.push({ name: "Claude Desktop", detail: tilde(desktop) });
|
|
24111
|
+
install("Claude Desktop", desktop, server);
|
|
23961
24112
|
} else {
|
|
23962
24113
|
skipped.push({ name: "Claude Desktop", detail: "app not found" });
|
|
23963
24114
|
}
|
|
23964
24115
|
const chatgpt = chatgptDesktopPath();
|
|
23965
|
-
if (chatgpt && existsSync6(dirname2(chatgpt)))
|
|
23966
|
-
mergeMcpJson(chatgpt, home, server);
|
|
23967
|
-
written.push({ name: "ChatGPT.app", detail: tilde(chatgpt) });
|
|
23968
|
-
}
|
|
24116
|
+
if (chatgpt && existsSync6(dirname2(chatgpt))) install("ChatGPT.app", chatgpt, server);
|
|
23969
24117
|
const codex = join6(homedir5(), ".codex", "config.toml");
|
|
23970
24118
|
try {
|
|
23971
24119
|
upsertCodex(home);
|
|
23972
|
-
written.push({ name: "Codex", detail: tilde(codex) });
|
|
24120
|
+
(found.has("Codex") ? written : ahead).push({ name: "Codex", detail: tilde(codex) });
|
|
23973
24121
|
} catch {
|
|
23974
24122
|
skipped.push({ name: "Codex", detail: `could not write ${tilde(codex)}` });
|
|
23975
24123
|
}
|
|
23976
24124
|
const windsurf = join6(homedir5(), ".codeium", "windsurf", "mcp_config.json");
|
|
23977
24125
|
if (existsSync6(dirname2(windsurf))) {
|
|
23978
|
-
|
|
23979
|
-
written.push({ name: "Windsurf", detail: tilde(windsurf) });
|
|
24126
|
+
install("Windsurf", windsurf, server);
|
|
23980
24127
|
} else {
|
|
23981
24128
|
skipped.push({ name: "Windsurf", detail: "app not found" });
|
|
23982
24129
|
}
|
|
@@ -23989,11 +24136,16 @@ function installMcpClients(home) {
|
|
|
23989
24136
|
name: "Replit Desktop",
|
|
23990
24137
|
detail: "add the HTTPS URL from Settings \u2192 Connect an agent"
|
|
23991
24138
|
});
|
|
23992
|
-
return { written, skipped };
|
|
24139
|
+
return { written, ahead, skipped, found: [...found] };
|
|
23993
24140
|
}
|
|
23994
24141
|
function removeServerFromJson(path, key = "mcpServers") {
|
|
23995
24142
|
if (!existsSync6(path)) return false;
|
|
23996
|
-
|
|
24143
|
+
let current;
|
|
24144
|
+
try {
|
|
24145
|
+
current = readJson(path);
|
|
24146
|
+
} catch {
|
|
24147
|
+
return false;
|
|
24148
|
+
}
|
|
23997
24149
|
const servers = current[key] ?? {};
|
|
23998
24150
|
if (!servers.pantheon) return false;
|
|
23999
24151
|
delete servers.pantheon;
|
|
@@ -24007,7 +24159,7 @@ function removeCodex() {
|
|
|
24007
24159
|
const existing = readFileSync5(path, "utf8");
|
|
24008
24160
|
if (!existing.includes("[mcp_servers.pantheon]")) return false;
|
|
24009
24161
|
const next = existing.replace(/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/, "").replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
24010
|
-
|
|
24162
|
+
writeAtomic(path, next ? `${next}
|
|
24011
24163
|
` : "");
|
|
24012
24164
|
return true;
|
|
24013
24165
|
}
|
|
@@ -24060,7 +24212,7 @@ function uninstallMcpClients() {
|
|
|
24060
24212
|
function installMcpFromConfig() {
|
|
24061
24213
|
const stored = loadMachineConfig();
|
|
24062
24214
|
if (!stored) throw new Error("Not connected. Run pantheon connect <code> first.");
|
|
24063
|
-
return installMcpClients(stored.config.home);
|
|
24215
|
+
return { ...installMcpClients(stored.config.home), apiUrl: stored.config.apiUrl };
|
|
24064
24216
|
}
|
|
24065
24217
|
|
|
24066
24218
|
// src/report.ts
|
|
@@ -24149,12 +24301,16 @@ async function connect(opts) {
|
|
|
24149
24301
|
execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
|
|
24150
24302
|
execFileSync3("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
|
|
24151
24303
|
let written = [];
|
|
24304
|
+
let ahead = [];
|
|
24152
24305
|
let skipped = [];
|
|
24306
|
+
let found = [];
|
|
24153
24307
|
let failure = "";
|
|
24154
24308
|
try {
|
|
24155
24309
|
const result = installMcpClients(home);
|
|
24156
24310
|
written = result.written;
|
|
24311
|
+
ahead = result.ahead;
|
|
24157
24312
|
skipped = result.skipped;
|
|
24313
|
+
found = result.found;
|
|
24158
24314
|
} catch (error2) {
|
|
24159
24315
|
failure = error2 instanceof Error ? error2.message : String(error2);
|
|
24160
24316
|
}
|
|
@@ -24168,8 +24324,9 @@ async function connect(opts) {
|
|
|
24168
24324
|
...archived ? [field("Set aside", `${archived} \u2014 spaces from the old repo`)] : []
|
|
24169
24325
|
].join("\n"),
|
|
24170
24326
|
failure ? field("MCP", `failed \u2014 ${failure}`) : block("Configured", written),
|
|
24327
|
+
block(AHEAD, ahead),
|
|
24171
24328
|
block("Skipped", skipped),
|
|
24172
|
-
|
|
24329
|
+
nextSteps(found, body.apiUrl)
|
|
24173
24330
|
)
|
|
24174
24331
|
);
|
|
24175
24332
|
}
|
|
@@ -24189,7 +24346,7 @@ function syncVault2(home, cloneUrl, helper, quiet) {
|
|
|
24189
24346
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
24190
24347
|
const archive = `${home}-${stamp2}`;
|
|
24191
24348
|
process.stdout.write(" Vault belongs to a deleted repo; setting it aside\u2026\n");
|
|
24192
|
-
|
|
24349
|
+
renameSync2(home, archive);
|
|
24193
24350
|
execFileSync3("git", ["-c", `credential.helper=${helper}`, "clone", cloneUrl, home], quiet);
|
|
24194
24351
|
return archive;
|
|
24195
24352
|
}
|
|
@@ -24492,8 +24649,9 @@ async function main() {
|
|
|
24492
24649
|
console.log(
|
|
24493
24650
|
report(
|
|
24494
24651
|
block("Configured", result.written),
|
|
24652
|
+
block(AHEAD, result.ahead),
|
|
24495
24653
|
block("Skipped", result.skipped),
|
|
24496
|
-
|
|
24654
|
+
nextSteps(result.found, result.apiUrl)
|
|
24497
24655
|
)
|
|
24498
24656
|
);
|
|
24499
24657
|
return;
|
package/package.json
CHANGED