pantheon-cli 0.2.15 → 0.2.18
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 +307 -76
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -21970,6 +21970,12 @@ function missingSpaceName(value) {
|
|
|
21970
21970
|
const space = (value || "").trim();
|
|
21971
21971
|
return !space || space === "$ARGUMENTS" || space === "<space>" || /^space$/i.test(space);
|
|
21972
21972
|
}
|
|
21973
|
+
function splitSpaceName(value) {
|
|
21974
|
+
const trimmed = (value || "").trim();
|
|
21975
|
+
const slash2 = trimmed.indexOf("/");
|
|
21976
|
+
if (slash2 < 0) return { owner: null, name: trimmed };
|
|
21977
|
+
return { owner: trimmed.slice(0, slash2).trim(), name: trimmed.slice(slash2 + 1).trim() };
|
|
21978
|
+
}
|
|
21973
21979
|
function requireSpaceName(value) {
|
|
21974
21980
|
const space = value.trim();
|
|
21975
21981
|
if (missingSpaceName(space)) {
|
|
@@ -21977,10 +21983,14 @@ function requireSpaceName(value) {
|
|
|
21977
21983
|
"No conscience name. Ask the human what to call this space \u2014 one short name like preorders \u2014 then retry. Do not invent a name."
|
|
21978
21984
|
);
|
|
21979
21985
|
}
|
|
21980
|
-
|
|
21981
|
-
|
|
21982
|
-
|
|
21983
|
-
)
|
|
21986
|
+
const { owner, name } = splitSpaceName(space);
|
|
21987
|
+
const parts = owner === null ? [name] : [owner, name];
|
|
21988
|
+
for (const part of parts) {
|
|
21989
|
+
if (/\s/.test(part) || part.length > 64 || !/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(part)) {
|
|
21990
|
+
throw new Error(
|
|
21991
|
+
`"${space.slice(0, 80)}" is not a space name. Ask for one short name (letters, numbers, hyphens), then retry.`
|
|
21992
|
+
);
|
|
21993
|
+
}
|
|
21984
21994
|
}
|
|
21985
21995
|
return space;
|
|
21986
21996
|
}
|
|
@@ -21991,6 +22001,67 @@ function slugify(value) {
|
|
|
21991
22001
|
function spaceDir(home, slug) {
|
|
21992
22002
|
return join3(resolve(home), "spaces", slugify(slug));
|
|
21993
22003
|
}
|
|
22004
|
+
function sharedHome(home) {
|
|
22005
|
+
return `${resolve(home)}-shared`;
|
|
22006
|
+
}
|
|
22007
|
+
function sharedDir(home, owner, slug) {
|
|
22008
|
+
return join3(sharedHome(home), slugify(owner), slugify(slug));
|
|
22009
|
+
}
|
|
22010
|
+
function dirsIn(root) {
|
|
22011
|
+
if (!existsSync3(root)) return [];
|
|
22012
|
+
return readdirSync3(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => ({ name: entry.name, dir: join3(root, entry.name) }));
|
|
22013
|
+
}
|
|
22014
|
+
function sharedMatches(home, slug) {
|
|
22015
|
+
return dirsIn(sharedHome(home)).map((owner) => ({ owner: owner.name, root: join3(owner.dir, slug) })).filter((match) => existsSync3(match.root));
|
|
22016
|
+
}
|
|
22017
|
+
function sharedWriteRefusal(name) {
|
|
22018
|
+
return `"${name}" was shared with you read-only, so nothing can be written to it. Hand off to one of your own spaces instead \u2014 pantheon_list_spaces marks which are yours.`;
|
|
22019
|
+
}
|
|
22020
|
+
function resolveForRead(home, name, options = {}) {
|
|
22021
|
+
requireSpaceName(name);
|
|
22022
|
+
const { owner, name: bare } = splitSpaceName(name);
|
|
22023
|
+
const slug = slugify(bare);
|
|
22024
|
+
if (owner) {
|
|
22025
|
+
const root = sharedDir(home, owner, slug);
|
|
22026
|
+
if (!existsSync3(root)) {
|
|
22027
|
+
throw new Error(
|
|
22028
|
+
`"${owner}/${bare}" is not shared with this vault. Call pantheon_list_spaces to see what is.`
|
|
22029
|
+
);
|
|
22030
|
+
}
|
|
22031
|
+
return { slug: `${slugify(owner)}/${slug}`, root, shared: true, owner: slugify(owner) };
|
|
22032
|
+
}
|
|
22033
|
+
if (existsSync3(spaceDir(home, slug))) {
|
|
22034
|
+
return { slug, root: spaceDir(home, slug), shared: false };
|
|
22035
|
+
}
|
|
22036
|
+
const matches = sharedMatches(home, slug);
|
|
22037
|
+
if (matches.length === 1) {
|
|
22038
|
+
const [match] = matches;
|
|
22039
|
+
return { slug: `${match.owner}/${slug}`, root: match.root, shared: true, owner: match.owner };
|
|
22040
|
+
}
|
|
22041
|
+
if (matches.length > 1) {
|
|
22042
|
+
const names = matches.map((match) => `${match.owner}/${slug}`).join(", ");
|
|
22043
|
+
throw new Error(
|
|
22044
|
+
`"${bare}" has been shared by more than one person: ${names}. Use the full name to say which one.`
|
|
22045
|
+
);
|
|
22046
|
+
}
|
|
22047
|
+
if (options.create === false) {
|
|
22048
|
+
throw new Error(
|
|
22049
|
+
`"${name}" is not a space in this vault. Call pantheon_list_spaces and use one of those names. Do not invent a substitute.`
|
|
22050
|
+
);
|
|
22051
|
+
}
|
|
22052
|
+
return { slug, root: ensureSpace(home, bare).root, shared: false };
|
|
22053
|
+
}
|
|
22054
|
+
function resolveForWrite(home, name) {
|
|
22055
|
+
requireSpaceName(name);
|
|
22056
|
+
const { owner, name: bare } = splitSpaceName(name);
|
|
22057
|
+
if (owner) throw new Error(sharedWriteRefusal(`${owner}/${bare}`));
|
|
22058
|
+
const slug = slugify(bare);
|
|
22059
|
+
if (!existsSync3(spaceDir(home, slug))) {
|
|
22060
|
+
const [match] = sharedMatches(home, slug);
|
|
22061
|
+
if (match) throw new Error(sharedWriteRefusal(`${match.owner}/${slug}`));
|
|
22062
|
+
}
|
|
22063
|
+
return { slug, root: ensureSpace(home, bare).root, shared: false };
|
|
22064
|
+
}
|
|
21994
22065
|
function nowIso() {
|
|
21995
22066
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
21996
22067
|
}
|
|
@@ -22435,14 +22506,7 @@ function ensureSpace(home, name) {
|
|
|
22435
22506
|
return { slug, root };
|
|
22436
22507
|
}
|
|
22437
22508
|
function resolveSpace(home, name) {
|
|
22438
|
-
|
|
22439
|
-
const slug = slugify(name);
|
|
22440
|
-
const root = spaceDir(home, slug);
|
|
22441
|
-
if (!existsSync3(root)) {
|
|
22442
|
-
throw new Error(
|
|
22443
|
-
`"${name}" is not a space in this vault. Call pantheon_list_spaces and use one of those names. Do not invent a substitute.`
|
|
22444
|
-
);
|
|
22445
|
-
}
|
|
22509
|
+
const { slug, root } = resolveForRead(home, name, { create: false });
|
|
22446
22510
|
return { slug, root };
|
|
22447
22511
|
}
|
|
22448
22512
|
function writeArtifacts(sessionDir, artifacts = []) {
|
|
@@ -22615,8 +22679,7 @@ function sessionStart(path) {
|
|
|
22615
22679
|
}
|
|
22616
22680
|
}
|
|
22617
22681
|
function writeHandoff(home, input) {
|
|
22618
|
-
|
|
22619
|
-
const { slug, root } = ensureSpace(home, input.space);
|
|
22682
|
+
const { slug, root } = resolveForWrite(home, input.space);
|
|
22620
22683
|
const { turns, captured } = resolveTranscript(input);
|
|
22621
22684
|
if (!captured) {
|
|
22622
22685
|
const thin = transcriptLooksThin(turns);
|
|
@@ -22678,8 +22741,7 @@ function writeHandoff(home, input) {
|
|
|
22678
22741
|
};
|
|
22679
22742
|
}
|
|
22680
22743
|
function writePark(home, input) {
|
|
22681
|
-
|
|
22682
|
-
const { slug, root } = ensureSpace(home, input.space);
|
|
22744
|
+
const { slug, root } = resolveForWrite(home, input.space);
|
|
22683
22745
|
const turns = input.transcript ? parseTurns(input.transcript) : [];
|
|
22684
22746
|
if (turns.length) {
|
|
22685
22747
|
const thin = transcriptLooksThin(turns);
|
|
@@ -22702,8 +22764,7 @@ function writePark(home, input) {
|
|
|
22702
22764
|
return { slug, sessionId: session.sessionId, turns: turns.length, artifacts: session.artifacts };
|
|
22703
22765
|
}
|
|
22704
22766
|
function writeRemember(home, space, fact) {
|
|
22705
|
-
|
|
22706
|
-
const { slug, root } = ensureSpace(home, space);
|
|
22767
|
+
const { slug, root } = resolveForWrite(home, space);
|
|
22707
22768
|
appendFileSync(join3(root, "memory.md"), `- ${fact.trim()}
|
|
22708
22769
|
`);
|
|
22709
22770
|
return { slug };
|
|
@@ -22831,8 +22892,7 @@ function resumeNote(sessions, turns, story, skills) {
|
|
|
22831
22892
|
return parts.join(" ");
|
|
22832
22893
|
}
|
|
22833
22894
|
function readResume(home, space) {
|
|
22834
|
-
|
|
22835
|
-
const { slug, root } = ensureSpace(home, space);
|
|
22895
|
+
const { slug, root } = resolveForRead(home, space);
|
|
22836
22896
|
const sessions = sessionSummaries(root);
|
|
22837
22897
|
const turns = sessions.reduce((sum, session) => sum + session.turns, 0);
|
|
22838
22898
|
const story = readStory(root);
|
|
@@ -22859,20 +22919,32 @@ function spaceTitle(root, slug) {
|
|
|
22859
22919
|
const meta = readText(join3(root, "space.yaml"));
|
|
22860
22920
|
return meta.match(/^title:\s*(.+)$/m)?.[1]?.trim() || slug;
|
|
22861
22921
|
}
|
|
22922
|
+
function summarise(dir, slug, name, extra = {}) {
|
|
22923
|
+
const handoff = join3(dir, "handoff.md");
|
|
22924
|
+
const body = readText(handoff);
|
|
22925
|
+
return {
|
|
22926
|
+
slug,
|
|
22927
|
+
title: spaceTitle(dir, name),
|
|
22928
|
+
updatedAt: existsSync3(handoff) ? statSync2(handoff).mtime.toISOString() : void 0,
|
|
22929
|
+
preview: body ? packetPreview(body) : void 0,
|
|
22930
|
+
...extra
|
|
22931
|
+
};
|
|
22932
|
+
}
|
|
22862
22933
|
function listSpaces(home) {
|
|
22863
|
-
const
|
|
22864
|
-
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
|
|
22871
|
-
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
|
|
22875
|
-
|
|
22934
|
+
const own = dirsIn(join3(resolve(home), "spaces")).map(
|
|
22935
|
+
(entry) => summarise(entry.dir, entry.name, entry.name)
|
|
22936
|
+
);
|
|
22937
|
+
const shared = dirsIn(sharedHome(home)).flatMap(
|
|
22938
|
+
(owner) => dirsIn(owner.dir).map(
|
|
22939
|
+
(space) => summarise(space.dir, `${owner.name}/${space.name}`, space.name, {
|
|
22940
|
+
owner: owner.name,
|
|
22941
|
+
shared: true
|
|
22942
|
+
})
|
|
22943
|
+
)
|
|
22944
|
+
);
|
|
22945
|
+
return [...own, ...shared].sort(
|
|
22946
|
+
(a, b) => (b.updatedAt || "").localeCompare(a.updatedAt || "")
|
|
22947
|
+
);
|
|
22876
22948
|
}
|
|
22877
22949
|
var SEARCH_LIMIT = 20;
|
|
22878
22950
|
var SEARCH_MAX = 50;
|
|
@@ -22916,7 +22988,7 @@ function matchTurn(turn, needle) {
|
|
|
22916
22988
|
return null;
|
|
22917
22989
|
}
|
|
22918
22990
|
function searchSpace(home, space, query, options = {}) {
|
|
22919
|
-
const { root } =
|
|
22991
|
+
const { root } = resolveForRead(home, space);
|
|
22920
22992
|
const needle = query.trim().toLowerCase();
|
|
22921
22993
|
if (!needle) return [];
|
|
22922
22994
|
const limit = Math.min(Math.max(options.limit ?? SEARCH_LIMIT, 1), SEARCH_MAX);
|
|
@@ -22947,16 +23019,14 @@ function getTurns(home, space, sessionId, from, to) {
|
|
|
22947
23019
|
return session.turns.filter((turn) => turn.id >= from && turn.id <= to);
|
|
22948
23020
|
}
|
|
22949
23021
|
function getSession(home, space, sessionId) {
|
|
22950
|
-
const { root } =
|
|
23022
|
+
const { root } = resolveForRead(home, space);
|
|
22951
23023
|
const file = join3(root, "sessions", sessionId, "transcript.jsonl");
|
|
22952
23024
|
if (!existsSync3(file)) throw new Error(`Session not found: ${sessionId}`);
|
|
22953
23025
|
const turns = readFileSync3(file, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
22954
23026
|
return { sessionId, turns, artifacts: listArtifacts(home, space, sessionId) };
|
|
22955
23027
|
}
|
|
22956
23028
|
function forgetSession(home, space, sessionId) {
|
|
22957
|
-
|
|
22958
|
-
const slug = slugify(space);
|
|
22959
|
-
const root = spaceDir(home, slug);
|
|
23029
|
+
const { slug, root } = resolveForWrite(home, space);
|
|
22960
23030
|
const id = basename2(sessionId.trim());
|
|
22961
23031
|
if (!id || id.startsWith(".")) throw new Error(`Not a session id: "${sessionId}".`);
|
|
22962
23032
|
const dir = join3(root, "sessions", id);
|
|
@@ -22983,13 +23053,13 @@ function forgetSession(home, space, sessionId) {
|
|
|
22983
23053
|
};
|
|
22984
23054
|
}
|
|
22985
23055
|
function listArtifacts(home, space, sessionId) {
|
|
22986
|
-
const { root } =
|
|
23056
|
+
const { root } = resolveForRead(home, space);
|
|
22987
23057
|
const dir = join3(root, "sessions", sessionId, "artifacts");
|
|
22988
23058
|
if (!existsSync3(dir)) return [];
|
|
22989
23059
|
return readdirSync3(dir);
|
|
22990
23060
|
}
|
|
22991
23061
|
function getArtifact(home, space, sessionId, name) {
|
|
22992
|
-
const { root } =
|
|
23062
|
+
const { root } = resolveForRead(home, space);
|
|
22993
23063
|
const file = join3(root, "sessions", sessionId, "artifacts", basename2(name));
|
|
22994
23064
|
if (!existsSync3(file)) throw new Error(`Artifact not found: ${name}`);
|
|
22995
23065
|
const buf = readFileSync3(file);
|
|
@@ -23270,9 +23340,12 @@ async function syncVault(home, opts = {}) {
|
|
|
23270
23340
|
}
|
|
23271
23341
|
|
|
23272
23342
|
// ../mcp/src/index.ts
|
|
23273
|
-
function
|
|
23343
|
+
function readRoot(home, space) {
|
|
23274
23344
|
return resolveSpace(home, space).root;
|
|
23275
23345
|
}
|
|
23346
|
+
function writeRoot(home, space) {
|
|
23347
|
+
return resolveForWrite(home, space).root;
|
|
23348
|
+
}
|
|
23276
23349
|
function defaultHooks() {
|
|
23277
23350
|
return {
|
|
23278
23351
|
pull: (home) => syncVault(home, { push: false }),
|
|
@@ -23623,7 +23696,7 @@ ${GUIDE}` }]
|
|
|
23623
23696
|
"pantheon_get_skill",
|
|
23624
23697
|
"Read one skill from a Pantheon space: guidance written from failures that already happened in this project. Resume lists the names and when to use each; call this for the body before doing work in an area a skill covers. Every claim cites the session and turn it came from, so pantheon_get_turns will show the original moment if the guidance does not fit your situation.",
|
|
23625
23698
|
{ space: external_exports.string(), name: external_exports.string() },
|
|
23626
|
-
async ({ space, name }) => safe(() => readSkill(
|
|
23699
|
+
async ({ space, name }) => safe(() => readSkill(readRoot(home, space), name))
|
|
23627
23700
|
);
|
|
23628
23701
|
registerTool(
|
|
23629
23702
|
server,
|
|
@@ -23642,7 +23715,7 @@ ${GUIDE}` }]
|
|
|
23642
23715
|
sessions: external_exports.number().optional().describe("How many conversations back this up.")
|
|
23643
23716
|
},
|
|
23644
23717
|
async ({ space, name, when, body, key, sessions }) => safe(async () => {
|
|
23645
|
-
const saved = saveSkill(
|
|
23718
|
+
const saved = saveSkill(writeRoot(home, space), { name, when, body, key, sessions }, "draft");
|
|
23646
23719
|
const sync2 = await vault.push(home, `skill draft ${saved.name}`);
|
|
23647
23720
|
return {
|
|
23648
23721
|
ok: sync2.ok !== false,
|
|
@@ -23658,7 +23731,7 @@ ${GUIDE}` }]
|
|
|
23658
23731
|
"Record that the human does not want a skill written for a candidate pantheon_handoff proposed. Stops it being offered again.",
|
|
23659
23732
|
{ space: external_exports.string(), key: external_exports.string() },
|
|
23660
23733
|
async ({ space, key }) => safe(async () => {
|
|
23661
|
-
const done = dismissCandidate(
|
|
23734
|
+
const done = dismissCandidate(writeRoot(home, space), key);
|
|
23662
23735
|
const sync2 = await vault.push(home, "dismiss skill candidate");
|
|
23663
23736
|
return { ok: sync2.ok !== false, ...done, sync: sync2 };
|
|
23664
23737
|
})
|
|
@@ -23706,12 +23779,12 @@ import { hostname as hostname3 } from "node:os";
|
|
|
23706
23779
|
|
|
23707
23780
|
// src/connect.ts
|
|
23708
23781
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
23709
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync6, renameSync } from "node:fs";
|
|
23782
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, renameSync as renameSync2 } from "node:fs";
|
|
23710
23783
|
import { hostname as hostname2 } from "node:os";
|
|
23711
23784
|
import { join as join7 } from "node:path";
|
|
23712
23785
|
|
|
23713
23786
|
// src/mcp-install.ts
|
|
23714
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
23787
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
23715
23788
|
import { homedir as homedir5 } from "node:os";
|
|
23716
23789
|
import { dirname as dirname2, join as join6 } from "node:path";
|
|
23717
23790
|
import { fileURLToPath } from "node:url";
|
|
@@ -23740,17 +23813,109 @@ function mcpServer(home, withType = false) {
|
|
|
23740
23813
|
if (withType) server.type = "stdio";
|
|
23741
23814
|
return server;
|
|
23742
23815
|
}
|
|
23816
|
+
function stripComments(text2) {
|
|
23817
|
+
let out = "";
|
|
23818
|
+
let inString = false;
|
|
23819
|
+
let escaped = false;
|
|
23820
|
+
for (let i = 0; i < text2.length; i += 1) {
|
|
23821
|
+
const ch = text2[i];
|
|
23822
|
+
if (inString) {
|
|
23823
|
+
out += ch;
|
|
23824
|
+
if (escaped) escaped = false;
|
|
23825
|
+
else if (ch === "\\") escaped = true;
|
|
23826
|
+
else if (ch === '"') inString = false;
|
|
23827
|
+
continue;
|
|
23828
|
+
}
|
|
23829
|
+
if (ch === '"') {
|
|
23830
|
+
inString = true;
|
|
23831
|
+
out += ch;
|
|
23832
|
+
continue;
|
|
23833
|
+
}
|
|
23834
|
+
if (ch === "/" && text2[i + 1] === "/") {
|
|
23835
|
+
while (i < text2.length && text2[i] !== "\n") i += 1;
|
|
23836
|
+
out += "\n";
|
|
23837
|
+
continue;
|
|
23838
|
+
}
|
|
23839
|
+
if (ch === "/" && text2[i + 1] === "*") {
|
|
23840
|
+
i += 2;
|
|
23841
|
+
while (i < text2.length && !(text2[i] === "*" && text2[i + 1] === "/")) i += 1;
|
|
23842
|
+
i += 1;
|
|
23843
|
+
continue;
|
|
23844
|
+
}
|
|
23845
|
+
out += ch;
|
|
23846
|
+
}
|
|
23847
|
+
return out;
|
|
23848
|
+
}
|
|
23849
|
+
function stripTrailingCommas(text2) {
|
|
23850
|
+
const out = [];
|
|
23851
|
+
let inString = false;
|
|
23852
|
+
let escaped = false;
|
|
23853
|
+
let comma = -1;
|
|
23854
|
+
for (const ch of text2) {
|
|
23855
|
+
if (inString) {
|
|
23856
|
+
out.push(ch);
|
|
23857
|
+
if (escaped) escaped = false;
|
|
23858
|
+
else if (ch === "\\") escaped = true;
|
|
23859
|
+
else if (ch === '"') inString = false;
|
|
23860
|
+
continue;
|
|
23861
|
+
}
|
|
23862
|
+
if (ch === '"') {
|
|
23863
|
+
inString = true;
|
|
23864
|
+
comma = -1;
|
|
23865
|
+
out.push(ch);
|
|
23866
|
+
continue;
|
|
23867
|
+
}
|
|
23868
|
+
if (/\s/.test(ch)) {
|
|
23869
|
+
out.push(ch);
|
|
23870
|
+
continue;
|
|
23871
|
+
}
|
|
23872
|
+
if (ch === ",") {
|
|
23873
|
+
comma = out.length;
|
|
23874
|
+
out.push(ch);
|
|
23875
|
+
continue;
|
|
23876
|
+
}
|
|
23877
|
+
if ((ch === "}" || ch === "]") && comma >= 0) out[comma] = "";
|
|
23878
|
+
comma = -1;
|
|
23879
|
+
out.push(ch);
|
|
23880
|
+
}
|
|
23881
|
+
return out.join("");
|
|
23882
|
+
}
|
|
23883
|
+
function isPlainObject3(value) {
|
|
23884
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23885
|
+
}
|
|
23743
23886
|
function readJson(path) {
|
|
23744
23887
|
if (!existsSync6(path)) return {};
|
|
23888
|
+
const text2 = readFileSync5(path, "utf8").replace(/^\uFEFF/, "");
|
|
23889
|
+
if (!text2.trim()) return {};
|
|
23890
|
+
let value;
|
|
23745
23891
|
try {
|
|
23746
|
-
|
|
23747
|
-
} catch {
|
|
23748
|
-
|
|
23892
|
+
value = JSON.parse(text2);
|
|
23893
|
+
} catch (strict) {
|
|
23894
|
+
try {
|
|
23895
|
+
value = JSON.parse(stripTrailingCommas(stripComments(text2)));
|
|
23896
|
+
} catch {
|
|
23897
|
+
const why = strict instanceof Error ? strict.message : String(strict);
|
|
23898
|
+
throw new Error(`${path} is not valid JSON \u2014 ${why}`);
|
|
23899
|
+
}
|
|
23900
|
+
}
|
|
23901
|
+
if (!isPlainObject3(value)) {
|
|
23902
|
+
throw new Error(`${path} is not valid JSON \u2014 the top level must be an object`);
|
|
23749
23903
|
}
|
|
23904
|
+
return value;
|
|
23750
23905
|
}
|
|
23751
|
-
function
|
|
23906
|
+
function writeAtomic(path, text2) {
|
|
23752
23907
|
mkdirSync5(dirname2(path), { recursive: true });
|
|
23753
|
-
|
|
23908
|
+
const temp = `${path}.pantheon-${process.pid}.tmp`;
|
|
23909
|
+
try {
|
|
23910
|
+
writeFileSync5(temp, text2);
|
|
23911
|
+
renameSync(temp, path);
|
|
23912
|
+
} catch (error2) {
|
|
23913
|
+
if (existsSync6(temp)) unlinkSync2(temp);
|
|
23914
|
+
throw error2;
|
|
23915
|
+
}
|
|
23916
|
+
}
|
|
23917
|
+
function writeJson(path, data) {
|
|
23918
|
+
writeAtomic(path, `${JSON.stringify(data, null, 2)}
|
|
23754
23919
|
`);
|
|
23755
23920
|
}
|
|
23756
23921
|
function mergeMcpJson(path, home, server, key = "mcpServers") {
|
|
@@ -23791,7 +23956,7 @@ function upsertCodex(home) {
|
|
|
23791
23956
|
""
|
|
23792
23957
|
].join("\n");
|
|
23793
23958
|
if (!existsSync6(path)) {
|
|
23794
|
-
|
|
23959
|
+
writeAtomic(path, block2);
|
|
23795
23960
|
return;
|
|
23796
23961
|
}
|
|
23797
23962
|
const existing = readFileSync5(path, "utf8");
|
|
@@ -23800,11 +23965,11 @@ function upsertCodex(home) {
|
|
|
23800
23965
|
/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/,
|
|
23801
23966
|
block2.trim()
|
|
23802
23967
|
);
|
|
23803
|
-
|
|
23968
|
+
writeAtomic(path, next.endsWith("\n") ? next : `${next}
|
|
23804
23969
|
`);
|
|
23805
23970
|
return;
|
|
23806
23971
|
}
|
|
23807
|
-
|
|
23972
|
+
writeAtomic(path, `${existing.trimEnd()}
|
|
23808
23973
|
|
|
23809
23974
|
${block2}`);
|
|
23810
23975
|
}
|
|
@@ -23944,39 +24109,94 @@ function tilde(path) {
|
|
|
23944
24109
|
const home = homedir5();
|
|
23945
24110
|
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
23946
24111
|
}
|
|
24112
|
+
function detectApps() {
|
|
24113
|
+
const home = homedir5();
|
|
24114
|
+
const mac = process.platform === "darwin";
|
|
24115
|
+
const win = process.platform === "win32";
|
|
24116
|
+
const local = process.env.LOCALAPPDATA || join6(home, "AppData", "Local");
|
|
24117
|
+
const roaming = process.env.APPDATA || join6(home, "AppData", "Roaming");
|
|
24118
|
+
const evidence = {
|
|
24119
|
+
Cursor: [
|
|
24120
|
+
join6(home, ".cursor", "extensions"),
|
|
24121
|
+
join6(home, ".cursor", "argv.json"),
|
|
24122
|
+
join6(home, ".cursor", "cli"),
|
|
24123
|
+
...mac ? ["/Applications/Cursor.app", join6(home, "Applications", "Cursor.app")] : [],
|
|
24124
|
+
...win ? [join6(local, "Programs", "cursor")] : []
|
|
24125
|
+
],
|
|
24126
|
+
"Claude Code": [
|
|
24127
|
+
join6(home, ".claude", "projects"),
|
|
24128
|
+
join6(home, ".claude", "settings.json"),
|
|
24129
|
+
join6(home, ".claude", "history.jsonl"),
|
|
24130
|
+
join6(home, ".claude", "statsig")
|
|
24131
|
+
],
|
|
24132
|
+
"Claude Desktop": [
|
|
24133
|
+
...mac ? ["/Applications/Claude.app", join6(home, "Applications", "Claude.app")] : [],
|
|
24134
|
+
...win ? [join6(local, "AnthropicClaude"), join6(roaming, "Claude", "window-state.json")] : [],
|
|
24135
|
+
...!mac && !win ? [join6(home, ".config", "Claude", "window-state.json")] : []
|
|
24136
|
+
],
|
|
24137
|
+
"ChatGPT.app": mac ? ["/Applications/ChatGPT.app", join6(home, "Applications", "ChatGPT.app")] : [],
|
|
24138
|
+
Codex: [
|
|
24139
|
+
join6(home, ".codex", "sessions"),
|
|
24140
|
+
join6(home, ".codex", "auth.json"),
|
|
24141
|
+
join6(home, ".codex", "history.jsonl"),
|
|
24142
|
+
join6(home, ".codex", "log")
|
|
24143
|
+
],
|
|
24144
|
+
Windsurf: [
|
|
24145
|
+
join6(home, ".codeium", "windsurf"),
|
|
24146
|
+
...mac ? ["/Applications/Windsurf.app", join6(home, "Applications", "Windsurf.app")] : []
|
|
24147
|
+
]
|
|
24148
|
+
};
|
|
24149
|
+
const found = /* @__PURE__ */ new Set();
|
|
24150
|
+
for (const [name, paths] of Object.entries(evidence)) {
|
|
24151
|
+
if (paths.some((path) => existsSync6(path))) found.add(name);
|
|
24152
|
+
}
|
|
24153
|
+
return found;
|
|
24154
|
+
}
|
|
24155
|
+
var AHEAD = "Written ahead \u2014 app not detected, ready if you install it";
|
|
24156
|
+
function nextSteps(found, apiUrl) {
|
|
24157
|
+
if (found.length) return " Reload MCP in each app, then type /pantheon-handoff <space>";
|
|
24158
|
+
return [
|
|
24159
|
+
" No desktop agent detected. The configs above are in place if you install one.",
|
|
24160
|
+
"",
|
|
24161
|
+
" Using Claude.ai or ChatGPT in a browser instead? Connect it from",
|
|
24162
|
+
` ${apiUrl}/app/settings/connect`
|
|
24163
|
+
].join("\n");
|
|
24164
|
+
}
|
|
23947
24165
|
function installMcpClients(home) {
|
|
23948
24166
|
const written = [];
|
|
24167
|
+
const ahead = [];
|
|
23949
24168
|
const skipped = [];
|
|
23950
24169
|
const server = mcpServer(home);
|
|
23951
|
-
const
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
|
|
23955
|
-
|
|
23956
|
-
|
|
24170
|
+
const found = detectApps();
|
|
24171
|
+
const install = (name, path, entry) => {
|
|
24172
|
+
try {
|
|
24173
|
+
mergeMcpJson(path, home, entry);
|
|
24174
|
+
(found.has(name) ? written : ahead).push({ name, detail: tilde(path) });
|
|
24175
|
+
} catch (error2) {
|
|
24176
|
+
const why = error2 instanceof Error ? error2.message : String(error2);
|
|
24177
|
+
skipped.push({ name, detail: why.replace(homedir5(), "~") });
|
|
24178
|
+
}
|
|
24179
|
+
};
|
|
24180
|
+
install("Cursor", join6(homedir5(), ".cursor", "mcp.json"), server);
|
|
24181
|
+
install("Claude Code", join6(homedir5(), ".claude.json"), mcpServer(home, true));
|
|
23957
24182
|
const desktop = claudeDesktopPath();
|
|
23958
24183
|
if (existsSync6(dirname2(desktop)) || process.platform === "darwin" || process.platform === "win32") {
|
|
23959
|
-
|
|
23960
|
-
written.push({ name: "Claude Desktop", detail: tilde(desktop) });
|
|
24184
|
+
install("Claude Desktop", desktop, server);
|
|
23961
24185
|
} else {
|
|
23962
24186
|
skipped.push({ name: "Claude Desktop", detail: "app not found" });
|
|
23963
24187
|
}
|
|
23964
24188
|
const chatgpt = chatgptDesktopPath();
|
|
23965
|
-
if (chatgpt && existsSync6(dirname2(chatgpt)))
|
|
23966
|
-
mergeMcpJson(chatgpt, home, server);
|
|
23967
|
-
written.push({ name: "ChatGPT.app", detail: tilde(chatgpt) });
|
|
23968
|
-
}
|
|
24189
|
+
if (chatgpt && existsSync6(dirname2(chatgpt))) install("ChatGPT.app", chatgpt, server);
|
|
23969
24190
|
const codex = join6(homedir5(), ".codex", "config.toml");
|
|
23970
24191
|
try {
|
|
23971
24192
|
upsertCodex(home);
|
|
23972
|
-
written.push({ name: "Codex", detail: tilde(codex) });
|
|
24193
|
+
(found.has("Codex") ? written : ahead).push({ name: "Codex", detail: tilde(codex) });
|
|
23973
24194
|
} catch {
|
|
23974
24195
|
skipped.push({ name: "Codex", detail: `could not write ${tilde(codex)}` });
|
|
23975
24196
|
}
|
|
23976
24197
|
const windsurf = join6(homedir5(), ".codeium", "windsurf", "mcp_config.json");
|
|
23977
24198
|
if (existsSync6(dirname2(windsurf))) {
|
|
23978
|
-
|
|
23979
|
-
written.push({ name: "Windsurf", detail: tilde(windsurf) });
|
|
24199
|
+
install("Windsurf", windsurf, server);
|
|
23980
24200
|
} else {
|
|
23981
24201
|
skipped.push({ name: "Windsurf", detail: "app not found" });
|
|
23982
24202
|
}
|
|
@@ -23989,11 +24209,16 @@ function installMcpClients(home) {
|
|
|
23989
24209
|
name: "Replit Desktop",
|
|
23990
24210
|
detail: "add the HTTPS URL from Settings \u2192 Connect an agent"
|
|
23991
24211
|
});
|
|
23992
|
-
return { written, skipped };
|
|
24212
|
+
return { written, ahead, skipped, found: [...found] };
|
|
23993
24213
|
}
|
|
23994
24214
|
function removeServerFromJson(path, key = "mcpServers") {
|
|
23995
24215
|
if (!existsSync6(path)) return false;
|
|
23996
|
-
|
|
24216
|
+
let current;
|
|
24217
|
+
try {
|
|
24218
|
+
current = readJson(path);
|
|
24219
|
+
} catch {
|
|
24220
|
+
return false;
|
|
24221
|
+
}
|
|
23997
24222
|
const servers = current[key] ?? {};
|
|
23998
24223
|
if (!servers.pantheon) return false;
|
|
23999
24224
|
delete servers.pantheon;
|
|
@@ -24007,7 +24232,7 @@ function removeCodex() {
|
|
|
24007
24232
|
const existing = readFileSync5(path, "utf8");
|
|
24008
24233
|
if (!existing.includes("[mcp_servers.pantheon]")) return false;
|
|
24009
24234
|
const next = existing.replace(/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/, "").replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
24010
|
-
|
|
24235
|
+
writeAtomic(path, next ? `${next}
|
|
24011
24236
|
` : "");
|
|
24012
24237
|
return true;
|
|
24013
24238
|
}
|
|
@@ -24060,7 +24285,7 @@ function uninstallMcpClients() {
|
|
|
24060
24285
|
function installMcpFromConfig() {
|
|
24061
24286
|
const stored = loadMachineConfig();
|
|
24062
24287
|
if (!stored) throw new Error("Not connected. Run pantheon connect <code> first.");
|
|
24063
|
-
return installMcpClients(stored.config.home);
|
|
24288
|
+
return { ...installMcpClients(stored.config.home), apiUrl: stored.config.apiUrl };
|
|
24064
24289
|
}
|
|
24065
24290
|
|
|
24066
24291
|
// src/report.ts
|
|
@@ -24149,12 +24374,16 @@ async function connect(opts) {
|
|
|
24149
24374
|
execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
|
|
24150
24375
|
execFileSync3("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
|
|
24151
24376
|
let written = [];
|
|
24377
|
+
let ahead = [];
|
|
24152
24378
|
let skipped = [];
|
|
24379
|
+
let found = [];
|
|
24153
24380
|
let failure = "";
|
|
24154
24381
|
try {
|
|
24155
24382
|
const result = installMcpClients(home);
|
|
24156
24383
|
written = result.written;
|
|
24384
|
+
ahead = result.ahead;
|
|
24157
24385
|
skipped = result.skipped;
|
|
24386
|
+
found = result.found;
|
|
24158
24387
|
} catch (error2) {
|
|
24159
24388
|
failure = error2 instanceof Error ? error2.message : String(error2);
|
|
24160
24389
|
}
|
|
@@ -24168,8 +24397,9 @@ async function connect(opts) {
|
|
|
24168
24397
|
...archived ? [field("Set aside", `${archived} \u2014 spaces from the old repo`)] : []
|
|
24169
24398
|
].join("\n"),
|
|
24170
24399
|
failure ? field("MCP", `failed \u2014 ${failure}`) : block("Configured", written),
|
|
24400
|
+
block(AHEAD, ahead),
|
|
24171
24401
|
block("Skipped", skipped),
|
|
24172
|
-
|
|
24402
|
+
nextSteps(found, body.apiUrl)
|
|
24173
24403
|
)
|
|
24174
24404
|
);
|
|
24175
24405
|
}
|
|
@@ -24189,7 +24419,7 @@ function syncVault2(home, cloneUrl, helper, quiet) {
|
|
|
24189
24419
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
24190
24420
|
const archive = `${home}-${stamp2}`;
|
|
24191
24421
|
process.stdout.write(" Vault belongs to a deleted repo; setting it aside\u2026\n");
|
|
24192
|
-
|
|
24422
|
+
renameSync2(home, archive);
|
|
24193
24423
|
execFileSync3("git", ["-c", `credential.helper=${helper}`, "clone", cloneUrl, home], quiet);
|
|
24194
24424
|
return archive;
|
|
24195
24425
|
}
|
|
@@ -24492,8 +24722,9 @@ async function main() {
|
|
|
24492
24722
|
console.log(
|
|
24493
24723
|
report(
|
|
24494
24724
|
block("Configured", result.written),
|
|
24725
|
+
block(AHEAD, result.ahead),
|
|
24495
24726
|
block("Skipped", result.skipped),
|
|
24496
|
-
|
|
24727
|
+
nextSteps(result.found, result.apiUrl)
|
|
24497
24728
|
)
|
|
24498
24729
|
);
|
|
24499
24730
|
return;
|
package/package.json
CHANGED