pantheon-cli 0.2.25 → 0.2.28
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 +701 -111
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -8585,12 +8585,12 @@ ZodString.create = (params) => {
|
|
|
8585
8585
|
...processCreateParams(params)
|
|
8586
8586
|
});
|
|
8587
8587
|
};
|
|
8588
|
-
function floatSafeRemainder(val,
|
|
8588
|
+
function floatSafeRemainder(val, step2) {
|
|
8589
8589
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
8590
|
-
const stepDecCount = (
|
|
8590
|
+
const stepDecCount = (step2.toString().split(".")[1] || "").length;
|
|
8591
8591
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
8592
8592
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
8593
|
-
const stepInt = Number.parseInt(
|
|
8593
|
+
const stepInt = Number.parseInt(step2.toFixed(decCount).replace(".", ""));
|
|
8594
8594
|
return valInt % stepInt / 10 ** decCount;
|
|
8595
8595
|
}
|
|
8596
8596
|
var ZodNumber = class _ZodNumber extends ZodType {
|
|
@@ -11221,12 +11221,12 @@ function cleanRegex(source) {
|
|
|
11221
11221
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
11222
11222
|
return source.slice(start, end);
|
|
11223
11223
|
}
|
|
11224
|
-
function floatSafeRemainder2(val,
|
|
11224
|
+
function floatSafeRemainder2(val, step2) {
|
|
11225
11225
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
11226
|
-
const stepDecCount = (
|
|
11226
|
+
const stepDecCount = (step2.toString().split(".")[1] || "").length;
|
|
11227
11227
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
11228
11228
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
11229
|
-
const stepInt = Number.parseInt(
|
|
11229
|
+
const stepInt = Number.parseInt(step2.toFixed(decCount).replace(".", ""));
|
|
11230
11230
|
return valInt % stepInt / 10 ** decCount;
|
|
11231
11231
|
}
|
|
11232
11232
|
function defineLazy(object3, key, getter) {
|
|
@@ -21712,12 +21712,28 @@ function parseFrontmatter(raw) {
|
|
|
21712
21712
|
}
|
|
21713
21713
|
return { fields, body: match[2].trim() };
|
|
21714
21714
|
}
|
|
21715
|
+
function formatCitations(evidence) {
|
|
21716
|
+
if (!evidence?.length) return "";
|
|
21717
|
+
return evidence.map((cite) => `${cite.sessionId}#${cite.turnId}`).join(", ");
|
|
21718
|
+
}
|
|
21719
|
+
function parseCitations(value) {
|
|
21720
|
+
if (!value) return [];
|
|
21721
|
+
return value.split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
|
|
21722
|
+
const hash = part.lastIndexOf("#");
|
|
21723
|
+
if (hash < 1) return null;
|
|
21724
|
+
const turnId = Number(part.slice(hash + 1));
|
|
21725
|
+
if (!Number.isFinite(turnId)) return null;
|
|
21726
|
+
return { sessionId: part.slice(0, hash), turnId };
|
|
21727
|
+
}).filter((cite) => cite !== null);
|
|
21728
|
+
}
|
|
21715
21729
|
function serialize(skill) {
|
|
21730
|
+
const citations = formatCitations(skill.evidence);
|
|
21716
21731
|
const head = [
|
|
21717
21732
|
"---",
|
|
21718
21733
|
`name: ${skill.name}`,
|
|
21719
21734
|
`description: ${skill.when.replace(/\n/g, " ")}`,
|
|
21720
21735
|
skill.key ? `key: ${skill.key}` : null,
|
|
21736
|
+
citations ? `evidence: ${citations}` : null,
|
|
21721
21737
|
`sessions: ${skill.sessions}`,
|
|
21722
21738
|
`updated_at: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
21723
21739
|
"---",
|
|
@@ -21743,6 +21759,7 @@ function readSkillFile(dir, file, status) {
|
|
|
21743
21759
|
when: fields.description || `Guidance recorded as ${name}.`,
|
|
21744
21760
|
sessions: Number(fields.sessions) || 0,
|
|
21745
21761
|
key: fields.key,
|
|
21762
|
+
evidence: parseCitations(fields.evidence),
|
|
21746
21763
|
updatedAt: fields.updated_at,
|
|
21747
21764
|
status,
|
|
21748
21765
|
body
|
|
@@ -21785,6 +21802,7 @@ function saveSkill(root, input, status = "draft") {
|
|
|
21785
21802
|
when: input.when.trim(),
|
|
21786
21803
|
body: input.body,
|
|
21787
21804
|
key: input.key,
|
|
21805
|
+
evidence: input.evidence,
|
|
21788
21806
|
sessions: input.sessions ?? 0
|
|
21789
21807
|
})
|
|
21790
21808
|
);
|
|
@@ -21811,7 +21829,95 @@ var MULTIPLEXER = /* @__PURE__ */ new Set([
|
|
|
21811
21829
|
"pip",
|
|
21812
21830
|
"pip3"
|
|
21813
21831
|
]);
|
|
21814
|
-
var NOISE = /* @__PURE__ */ new Set([
|
|
21832
|
+
var NOISE = /* @__PURE__ */ new Set([
|
|
21833
|
+
"cd",
|
|
21834
|
+
"ls",
|
|
21835
|
+
"cat",
|
|
21836
|
+
"echo",
|
|
21837
|
+
"pwd",
|
|
21838
|
+
"which",
|
|
21839
|
+
"true",
|
|
21840
|
+
"false",
|
|
21841
|
+
"clear",
|
|
21842
|
+
// Shell keywords, which are not commands at all.
|
|
21843
|
+
"for",
|
|
21844
|
+
"while",
|
|
21845
|
+
"until",
|
|
21846
|
+
"if",
|
|
21847
|
+
"then",
|
|
21848
|
+
"else",
|
|
21849
|
+
"fi",
|
|
21850
|
+
"do",
|
|
21851
|
+
"done",
|
|
21852
|
+
"case",
|
|
21853
|
+
"esac",
|
|
21854
|
+
"function",
|
|
21855
|
+
"select",
|
|
21856
|
+
"in",
|
|
21857
|
+
"eval",
|
|
21858
|
+
"exec",
|
|
21859
|
+
"exit",
|
|
21860
|
+
"return",
|
|
21861
|
+
"set",
|
|
21862
|
+
"unset",
|
|
21863
|
+
"export",
|
|
21864
|
+
"source",
|
|
21865
|
+
"shift",
|
|
21866
|
+
"local",
|
|
21867
|
+
"declare",
|
|
21868
|
+
"trap",
|
|
21869
|
+
"wait",
|
|
21870
|
+
// Core utilities: plumbing every session uses regardless of the project.
|
|
21871
|
+
"rm",
|
|
21872
|
+
"rmdir",
|
|
21873
|
+
"mkdir",
|
|
21874
|
+
"cp",
|
|
21875
|
+
"mv",
|
|
21876
|
+
"ln",
|
|
21877
|
+
"touch",
|
|
21878
|
+
"chmod",
|
|
21879
|
+
"chown",
|
|
21880
|
+
"find",
|
|
21881
|
+
"head",
|
|
21882
|
+
"tail",
|
|
21883
|
+
"grep",
|
|
21884
|
+
"egrep",
|
|
21885
|
+
"fgrep",
|
|
21886
|
+
"rg",
|
|
21887
|
+
"sed",
|
|
21888
|
+
"awk",
|
|
21889
|
+
"sort",
|
|
21890
|
+
"uniq",
|
|
21891
|
+
"wc",
|
|
21892
|
+
"cut",
|
|
21893
|
+
"tr",
|
|
21894
|
+
"tee",
|
|
21895
|
+
"xargs",
|
|
21896
|
+
"sleep",
|
|
21897
|
+
"printf",
|
|
21898
|
+
"read",
|
|
21899
|
+
"test",
|
|
21900
|
+
"kill",
|
|
21901
|
+
"ps",
|
|
21902
|
+
"top",
|
|
21903
|
+
"open",
|
|
21904
|
+
"date",
|
|
21905
|
+
"basename",
|
|
21906
|
+
"dirname",
|
|
21907
|
+
"mktemp",
|
|
21908
|
+
"diff",
|
|
21909
|
+
"less",
|
|
21910
|
+
"more",
|
|
21911
|
+
"seq",
|
|
21912
|
+
"env",
|
|
21913
|
+
"time",
|
|
21914
|
+
"jobs",
|
|
21915
|
+
"stat",
|
|
21916
|
+
"du",
|
|
21917
|
+
"df",
|
|
21918
|
+
"man",
|
|
21919
|
+
"sudo"
|
|
21920
|
+
]);
|
|
21815
21921
|
var ERROR_LINE = /^.*?\b(?:error|fatal|failed|failure|cannot|could not|not found|denied|refused|unsupported|invalid|ERR_[A-Z_]+|Traceback|panic)\b.*$/im;
|
|
21816
21922
|
function errorLine(output) {
|
|
21817
21923
|
if (!output) return null;
|
|
@@ -21844,11 +21950,58 @@ function commandHead(command) {
|
|
|
21844
21950
|
index += 1;
|
|
21845
21951
|
}
|
|
21846
21952
|
const head = (words[index] || "").replace(/^.*[\\/]/, "").toLowerCase();
|
|
21847
|
-
if (
|
|
21953
|
+
if (!/^[a-z_][a-z0-9._+-]*$/.test(head)) return null;
|
|
21954
|
+
if (NOISE.has(head)) return null;
|
|
21848
21955
|
if (!MULTIPLEXER.has(head)) return head;
|
|
21849
21956
|
const sub = (words[index + 1] || "").toLowerCase();
|
|
21850
21957
|
return /^[a-z][a-z0-9-]*$/.test(sub) ? `${head} ${sub}` : head;
|
|
21851
21958
|
}
|
|
21959
|
+
var CORRECTION_OPENS = /^\s*(?:no\b|nope\b|don'?t\b|stop\b|actually\b|wrong\b|that'?s not\b|not (?:what|quite|right)\b|instead\b|never\b|why (?:did|are|would) you\b|you (?:should|shouldn'?t|need to|keep)\b)/i;
|
|
21960
|
+
var CORRECTION_ANYWHERE = /\b(?:that'?s not what i (?:asked|meant|said)|not what i (?:asked|meant|wanted)|i (?:already )?(?:said|told you)|you (?:keep|again) )/i;
|
|
21961
|
+
var MAX_CORRECTIONS_PER_SESSION = 6;
|
|
21962
|
+
var WRAPPED = /<user_query>([\s\S]*?)<\/user_query>/i;
|
|
21963
|
+
var CONTEXT_BLOCK = /<(timestamp|system_reminder|system_notification|attached_files|external_links|open_and_recently_viewed_files|previous_conversation_summary|agent_transcripts|rules|user_info|git_status)>[\s\S]*?<\/\1>/gi;
|
|
21964
|
+
function humanText(raw) {
|
|
21965
|
+
const inner = raw.match(WRAPPED);
|
|
21966
|
+
return (inner ? inner[1] : raw).replace(CONTEXT_BLOCK, " ").replace(/<\/?[a-z_]+>/gi, " ").replace(/\s+/g, " ").trim();
|
|
21967
|
+
}
|
|
21968
|
+
function extractCorrections(turns) {
|
|
21969
|
+
const out = [];
|
|
21970
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21971
|
+
for (const turn of turns) {
|
|
21972
|
+
if (turn.role !== "user") continue;
|
|
21973
|
+
const text2 = humanText(turn.text || "");
|
|
21974
|
+
if (text2.length < 8) continue;
|
|
21975
|
+
if (!CORRECTION_OPENS.test(text2) && !CORRECTION_ANYWHERE.test(text2)) continue;
|
|
21976
|
+
const fingerprint2 = text2.slice(0, 80).toLowerCase();
|
|
21977
|
+
if (seen.has(fingerprint2)) continue;
|
|
21978
|
+
seen.add(fingerprint2);
|
|
21979
|
+
out.push({ turnId: turn.id, text: text2.slice(0, 240) });
|
|
21980
|
+
if (out.length >= MAX_CORRECTIONS_PER_SESSION) break;
|
|
21981
|
+
}
|
|
21982
|
+
return out;
|
|
21983
|
+
}
|
|
21984
|
+
function extractRoutines(turns) {
|
|
21985
|
+
const out = /* @__PURE__ */ new Map();
|
|
21986
|
+
for (const turn of turns) {
|
|
21987
|
+
for (const call of turn.toolCalls || []) {
|
|
21988
|
+
if (!SHELL_TOOL.test(call.name)) continue;
|
|
21989
|
+
const command = commandText(call.input);
|
|
21990
|
+
if (!command) continue;
|
|
21991
|
+
const head = commandHead(command);
|
|
21992
|
+
if (!head) continue;
|
|
21993
|
+
const seen = out.get(head);
|
|
21994
|
+
if (seen) seen.count += 1;
|
|
21995
|
+
else
|
|
21996
|
+
out.set(head, {
|
|
21997
|
+
count: 1,
|
|
21998
|
+
command: command.replace(/\s+/g, " ").trim().slice(0, 200),
|
|
21999
|
+
turnId: turn.id
|
|
22000
|
+
});
|
|
22001
|
+
}
|
|
22002
|
+
}
|
|
22003
|
+
return out;
|
|
22004
|
+
}
|
|
21852
22005
|
var LOOKAHEAD = 8;
|
|
21853
22006
|
var MAX_FRICTION = 24;
|
|
21854
22007
|
function extractFrictions(turns) {
|
|
@@ -22434,10 +22587,10 @@ function collectAttachedArtifacts(turns, cwd = process.cwd()) {
|
|
|
22434
22587
|
return found;
|
|
22435
22588
|
}
|
|
22436
22589
|
function missingGeneratedFiles(turns, artifacts = []) {
|
|
22437
|
-
const
|
|
22438
|
-
if (!
|
|
22590
|
+
const mentioned2 = mentionedDocuments(turns).map((doc) => doc.name);
|
|
22591
|
+
if (!mentioned2.length) return null;
|
|
22439
22592
|
const attached = new Set(artifacts.map((item) => artifactKey(item.name).toLowerCase()));
|
|
22440
|
-
const missing =
|
|
22593
|
+
const missing = mentioned2.filter((name) => !attached.has(artifactKey(name).toLowerCase()));
|
|
22441
22594
|
if (!missing.length) return null;
|
|
22442
22595
|
return `This chat created or named these files but they were not attached: ${missing.join(", ")}. Read each file (Claude: /mnt/user-data/outputs or the download you presented) and pass artifacts as { name, content: "<base64>", encoding: "base64" }. PDFs and other files you generated must be attached.`;
|
|
22443
22596
|
}
|
|
@@ -22862,6 +23015,109 @@ function readStory(root) {
|
|
|
22862
23015
|
}
|
|
22863
23016
|
return out.reverse();
|
|
22864
23017
|
}
|
|
23018
|
+
var REVIEW_CORRECTIONS = 24;
|
|
23019
|
+
var REVIEW_ROUTINES = 12;
|
|
23020
|
+
var ROUTINE_MIN_SESSIONS = 2;
|
|
23021
|
+
function skillReview(home, space, cwd) {
|
|
23022
|
+
const { slug, root } = resolveForRead(home, space, { create: false });
|
|
23023
|
+
const sessions = sessionDirs(root).slice(0, SKILL_SCAN_SESSIONS).map((session) => ({ id: session.id, turns: readSessionTurns(session.dir) }));
|
|
23024
|
+
const live = skillRefs(root);
|
|
23025
|
+
const drafts = listSkills(root, "draft").map((skill) => skill.name);
|
|
23026
|
+
const corrections = [];
|
|
23027
|
+
const routines = /* @__PURE__ */ new Map();
|
|
23028
|
+
let turns = 0;
|
|
23029
|
+
for (const session of sessions) {
|
|
23030
|
+
turns += session.turns.length;
|
|
23031
|
+
for (const hit of extractCorrections(session.turns)) {
|
|
23032
|
+
if (corrections.length < REVIEW_CORRECTIONS) {
|
|
23033
|
+
corrections.push({ sessionId: session.id, turnId: hit.turnId, text: hit.text });
|
|
23034
|
+
}
|
|
23035
|
+
}
|
|
23036
|
+
for (const [head, use] of extractRoutines(session.turns)) {
|
|
23037
|
+
const seen = routines.get(head) ?? {
|
|
23038
|
+
runs: 0,
|
|
23039
|
+
sessions: /* @__PURE__ */ new Set(),
|
|
23040
|
+
example: { sessionId: session.id, turnId: use.turnId, text: use.command }
|
|
23041
|
+
};
|
|
23042
|
+
seen.runs += use.count;
|
|
23043
|
+
seen.sessions.add(session.id);
|
|
23044
|
+
routines.set(head, seen);
|
|
23045
|
+
}
|
|
23046
|
+
}
|
|
23047
|
+
const docs = cwd ? projectDocs(cwd) : "";
|
|
23048
|
+
const shortlist = [...routines.entries()].filter(([, use]) => use.sessions.size >= ROUTINE_MIN_SESSIONS).sort((a, b) => b[1].sessions.size - a[1].sessions.size || b[1].runs - a[1].runs).slice(0, REVIEW_ROUTINES).map(([head, use]) => ({
|
|
23049
|
+
head,
|
|
23050
|
+
sessions: use.sessions.size,
|
|
23051
|
+
runs: use.runs,
|
|
23052
|
+
example: use.example
|
|
23053
|
+
}));
|
|
23054
|
+
const documented2 = docs ? shortlist.filter((item) => mentioned(docs, item.head)).map((item) => item.head) : [];
|
|
23055
|
+
const candidates = sessions.length < 2 ? [] : detectCandidates(sessions, { known: knownSkillKeys(root), docs });
|
|
23056
|
+
return {
|
|
23057
|
+
space: slug,
|
|
23058
|
+
slots: { used: live.length, cap: MAX_LIVE_SKILLS },
|
|
23059
|
+
live,
|
|
23060
|
+
drafts,
|
|
23061
|
+
scanned: { sessions: sessions.length, turns },
|
|
23062
|
+
candidates,
|
|
23063
|
+
corrections,
|
|
23064
|
+
routines: shortlist,
|
|
23065
|
+
documented: documented2,
|
|
23066
|
+
note: reviewNote({
|
|
23067
|
+
slug,
|
|
23068
|
+
slots: live.length,
|
|
23069
|
+
sessions: sessions.length,
|
|
23070
|
+
signals: corrections.length + shortlist.length + candidates.length
|
|
23071
|
+
})
|
|
23072
|
+
};
|
|
23073
|
+
}
|
|
23074
|
+
function mentioned(docs, head) {
|
|
23075
|
+
const escaped = head.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
23076
|
+
return new RegExp(`(?:^|[^a-z0-9-])${escaped}(?![a-z0-9-])`, "i").test(docs);
|
|
23077
|
+
}
|
|
23078
|
+
function reviewNote(input) {
|
|
23079
|
+
const parts = [];
|
|
23080
|
+
if (!input.sessions) {
|
|
23081
|
+
parts.push(
|
|
23082
|
+
`Nothing is archived in "${input.slug}" yet, so there is no history to review. Anything worth writing has to come from the conversation you are in right now.`
|
|
23083
|
+
);
|
|
23084
|
+
} else if (!input.signals) {
|
|
23085
|
+
parts.push(
|
|
23086
|
+
`Nothing recurring turned up across ${input.sessions} archived session${input.sessions === 1 ? "" : "s"}. That is a normal result and the correct answer is usually none.`
|
|
23087
|
+
);
|
|
23088
|
+
} else {
|
|
23089
|
+
parts.push(
|
|
23090
|
+
`These are signals, not findings. A repeated command is often just a habit, and a correction may have been a one-off \u2014 read the turns with pantheon_get_turns before treating any of it as a lesson.`
|
|
23091
|
+
);
|
|
23092
|
+
}
|
|
23093
|
+
parts.push(
|
|
23094
|
+
"Tool output is not archived from every client, so the strongest evidence \u2014 what a command actually printed when it failed \u2014 usually exists only in the conversation you are having now. Weigh that alongside these."
|
|
23095
|
+
);
|
|
23096
|
+
parts.push(
|
|
23097
|
+
`Propose at most two, and propose none if nothing here recurred: this space is using ${input.slots} of ${MAX_LIVE_SKILLS} live slots and every one of them costs context on every future resume. Ask the human before writing anything, then call pantheon_save_skill with evidence citing the session and turn each claim came from.`
|
|
23098
|
+
);
|
|
23099
|
+
return parts.join(" ");
|
|
23100
|
+
}
|
|
23101
|
+
function verifyCitations(root, evidence) {
|
|
23102
|
+
if (!evidence.length) return;
|
|
23103
|
+
const counts = /* @__PURE__ */ new Map();
|
|
23104
|
+
for (const session of sessionDirs(root)) {
|
|
23105
|
+
counts.set(session.id, readSessionTurns(session.dir).length);
|
|
23106
|
+
}
|
|
23107
|
+
for (const cite of evidence) {
|
|
23108
|
+
const turns = counts.get(cite.sessionId);
|
|
23109
|
+
if (turns === void 0) {
|
|
23110
|
+
throw new Error(
|
|
23111
|
+
`No session "${cite.sessionId}" in this space, so it cannot be cited. Use an id from the sessions list, or leave evidence empty if this came from the live conversation.`
|
|
23112
|
+
);
|
|
23113
|
+
}
|
|
23114
|
+
if (cite.turnId < 1 || cite.turnId > turns) {
|
|
23115
|
+
throw new Error(
|
|
23116
|
+
`Session "${cite.sessionId}" has ${turns} turns, so turn ${cite.turnId} does not exist. Cite the turn you actually read.`
|
|
23117
|
+
);
|
|
23118
|
+
}
|
|
23119
|
+
}
|
|
23120
|
+
}
|
|
22865
23121
|
function listSpaceArtifacts(root) {
|
|
22866
23122
|
const out = [];
|
|
22867
23123
|
for (const session of sessionDirs(root)) {
|
|
@@ -23156,6 +23412,12 @@ MCP tools \u2014 always the pantheon_ prefix
|
|
|
23156
23412
|
pantheon_get_artifact fetch a stored file
|
|
23157
23413
|
pantheon_forget_session delete one archived chat, when capture read the
|
|
23158
23414
|
wrong one. Not undoable \u2014 confirm the id first.
|
|
23415
|
+
pantheon_skill_review read a space for lessons worth writing down, then
|
|
23416
|
+
propose at most two \u2014 or none, which is usual
|
|
23417
|
+
pantheon_get_skill read one skill's guidance
|
|
23418
|
+
pantheon_save_skill write a skill as a draft, citing the turns it came
|
|
23419
|
+
from. A draft reaches no agent until promoted.
|
|
23420
|
+
pantheon_dismiss_skill stop a candidate being offered again
|
|
23159
23421
|
|
|
23160
23422
|
Chat shortcuts (namespaced \u2014 use these, not /resume)
|
|
23161
23423
|
/pantheon-handoff <space>
|
|
@@ -23163,6 +23425,7 @@ Chat shortcuts (namespaced \u2014 use these, not /resume)
|
|
|
23163
23425
|
/pantheon-park <space>
|
|
23164
23426
|
/pantheon-remember <space> <fact>
|
|
23165
23427
|
/pantheon-spaces
|
|
23428
|
+
/pantheon-skills <space>
|
|
23166
23429
|
/pantheon-help
|
|
23167
23430
|
`;
|
|
23168
23431
|
|
|
@@ -23365,6 +23628,140 @@ async function syncVault(home, opts = {}) {
|
|
|
23365
23628
|
}
|
|
23366
23629
|
}
|
|
23367
23630
|
|
|
23631
|
+
// ../core/src/shares.ts
|
|
23632
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync4, readFileSync as readFileSync5, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
23633
|
+
import { dirname as dirname2, join as join6 } from "node:path";
|
|
23634
|
+
function ledgerPath(root) {
|
|
23635
|
+
return join6(root, "manifest.json");
|
|
23636
|
+
}
|
|
23637
|
+
function readLedger(root) {
|
|
23638
|
+
try {
|
|
23639
|
+
return JSON.parse(readFileSync5(ledgerPath(root), "utf8"));
|
|
23640
|
+
} catch {
|
|
23641
|
+
return {};
|
|
23642
|
+
}
|
|
23643
|
+
}
|
|
23644
|
+
function safeSegment(value) {
|
|
23645
|
+
const clean = (value || "").trim();
|
|
23646
|
+
if (!clean || clean === "." || clean === "..") return null;
|
|
23647
|
+
if (clean.includes("/") || clean.includes("\\") || clean.includes("\0")) return null;
|
|
23648
|
+
return clean;
|
|
23649
|
+
}
|
|
23650
|
+
function safeRelative(value) {
|
|
23651
|
+
const parts = (value || "").split("/").filter(Boolean);
|
|
23652
|
+
if (!parts.length) return null;
|
|
23653
|
+
if (parts.some((part) => !safeSegment(part))) return null;
|
|
23654
|
+
return parts.join("/");
|
|
23655
|
+
}
|
|
23656
|
+
async function fetchShares(apiUrl, auth) {
|
|
23657
|
+
const res = await fetch(`${apiUrl}/api/cli/shares`, { headers: { authorization: auth } });
|
|
23658
|
+
if (!res.ok) throw new Error(`Could not list shares (${res.status}).`);
|
|
23659
|
+
const body = await res.json();
|
|
23660
|
+
if (!Array.isArray(body.shares)) throw new Error("Could not read the share list.");
|
|
23661
|
+
return body.shares;
|
|
23662
|
+
}
|
|
23663
|
+
async function pullShares(home, options = {}) {
|
|
23664
|
+
const stored = loadMachineConfig();
|
|
23665
|
+
if (!stored) return { ok: false, spaces: 0, fetched: 0, error: "Not connected." };
|
|
23666
|
+
const auth = `Bearer ${stored.config.machineId}.${stored.credentials.machineSecret}`;
|
|
23667
|
+
const root = sharedHome(home);
|
|
23668
|
+
let shares;
|
|
23669
|
+
try {
|
|
23670
|
+
shares = await fetchShares(stored.config.apiUrl, auth);
|
|
23671
|
+
} catch (error2) {
|
|
23672
|
+
return {
|
|
23673
|
+
ok: false,
|
|
23674
|
+
spaces: 0,
|
|
23675
|
+
fetched: 0,
|
|
23676
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
23677
|
+
};
|
|
23678
|
+
}
|
|
23679
|
+
if (!shares.length) {
|
|
23680
|
+
if (existsSync6(root)) rmSync3(root, { recursive: true, force: true });
|
|
23681
|
+
return { ok: true, spaces: 0, fetched: 0 };
|
|
23682
|
+
}
|
|
23683
|
+
mkdirSync5(root, { recursive: true });
|
|
23684
|
+
const ledger = readLedger(root);
|
|
23685
|
+
const next = {};
|
|
23686
|
+
const keep = /* @__PURE__ */ new Set();
|
|
23687
|
+
const jobs = [];
|
|
23688
|
+
for (const share of shares) {
|
|
23689
|
+
const owner = safeSegment(share.owner);
|
|
23690
|
+
const slug = safeSegment(share.slug);
|
|
23691
|
+
if (!owner || !slug) continue;
|
|
23692
|
+
keep.add(`${owner}/${slug}`);
|
|
23693
|
+
const spaceDir2 = join6(root, owner, slug);
|
|
23694
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
23695
|
+
for (const file of share.files || []) {
|
|
23696
|
+
const relative2 = safeRelative(file.path);
|
|
23697
|
+
if (!relative2) continue;
|
|
23698
|
+
wanted.add(relative2);
|
|
23699
|
+
const key = `${owner}/${slug}/${relative2}`;
|
|
23700
|
+
next[key] = file.sha;
|
|
23701
|
+
const dest = join6(spaceDir2, relative2);
|
|
23702
|
+
if (ledger[key] === file.sha && existsSync6(dest)) continue;
|
|
23703
|
+
jobs.push({ key, owner, slug, relative: relative2, dest });
|
|
23704
|
+
}
|
|
23705
|
+
prune(spaceDir2, spaceDir2, wanted);
|
|
23706
|
+
}
|
|
23707
|
+
let fetched = 0;
|
|
23708
|
+
let finished = 0;
|
|
23709
|
+
options.onProgress?.(0, jobs.length);
|
|
23710
|
+
await pool(jobs, async (job) => {
|
|
23711
|
+
const url = `${stored.config.apiUrl}/api/cli/shares/${encodeURIComponent(job.owner)}/${encodeURIComponent(job.slug)}?path=${encodeURIComponent(job.relative)}`;
|
|
23712
|
+
const res = await fetch(url, { headers: { authorization: auth } }).catch(() => null);
|
|
23713
|
+
if (!res?.ok) {
|
|
23714
|
+
delete next[job.key];
|
|
23715
|
+
options.onProgress?.(finished += 1, jobs.length);
|
|
23716
|
+
return;
|
|
23717
|
+
}
|
|
23718
|
+
mkdirSync5(dirname2(job.dest), { recursive: true });
|
|
23719
|
+
writeFileSync5(job.dest, Buffer.from(await res.arrayBuffer()));
|
|
23720
|
+
fetched += 1;
|
|
23721
|
+
options.onProgress?.(finished += 1, jobs.length);
|
|
23722
|
+
});
|
|
23723
|
+
for (const owner of dirNames(root)) {
|
|
23724
|
+
for (const slug of dirNames(join6(root, owner))) {
|
|
23725
|
+
if (keep.has(`${owner}/${slug}`)) continue;
|
|
23726
|
+
rmSync3(join6(root, owner, slug), { recursive: true, force: true });
|
|
23727
|
+
}
|
|
23728
|
+
if (!dirNames(join6(root, owner)).length) rmSync3(join6(root, owner), { recursive: true, force: true });
|
|
23729
|
+
}
|
|
23730
|
+
writeFileSync5(ledgerPath(root), `${JSON.stringify(next, null, 2)}
|
|
23731
|
+
`);
|
|
23732
|
+
return { ok: true, spaces: keep.size, fetched };
|
|
23733
|
+
}
|
|
23734
|
+
async function pool(items, run, limit = 12) {
|
|
23735
|
+
let cursor = 0;
|
|
23736
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
23737
|
+
while (cursor < items.length) {
|
|
23738
|
+
const item = items[cursor++];
|
|
23739
|
+
await run(item);
|
|
23740
|
+
}
|
|
23741
|
+
});
|
|
23742
|
+
await Promise.all(workers);
|
|
23743
|
+
}
|
|
23744
|
+
function prune(base, dir, wanted) {
|
|
23745
|
+
if (!existsSync6(dir)) return;
|
|
23746
|
+
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
23747
|
+
const full = join6(dir, entry.name);
|
|
23748
|
+
if (entry.isDirectory()) {
|
|
23749
|
+
prune(base, full, wanted);
|
|
23750
|
+
if (!readdirSync4(full).length) rmSync3(full, { recursive: true, force: true });
|
|
23751
|
+
continue;
|
|
23752
|
+
}
|
|
23753
|
+
const relative2 = full.slice(base.length + 1).split("\\").join("/");
|
|
23754
|
+
if (!wanted.has(relative2)) rmSync3(full, { force: true });
|
|
23755
|
+
}
|
|
23756
|
+
}
|
|
23757
|
+
function dirNames(root) {
|
|
23758
|
+
try {
|
|
23759
|
+
return readdirSync4(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
23760
|
+
} catch {
|
|
23761
|
+
return [];
|
|
23762
|
+
}
|
|
23763
|
+
}
|
|
23764
|
+
|
|
23368
23765
|
// ../mcp/src/index.ts
|
|
23369
23766
|
function readRoot(home, space) {
|
|
23370
23767
|
return resolveSpace(home, space).root;
|
|
@@ -23374,7 +23771,12 @@ function writeRoot(home, space) {
|
|
|
23374
23771
|
}
|
|
23375
23772
|
function defaultHooks() {
|
|
23376
23773
|
return {
|
|
23377
|
-
pull: (home) =>
|
|
23774
|
+
pull: async (home) => {
|
|
23775
|
+
const sync2 = await syncVault(home, { push: false });
|
|
23776
|
+
await pullShares(home).catch(() => {
|
|
23777
|
+
});
|
|
23778
|
+
return sync2;
|
|
23779
|
+
},
|
|
23378
23780
|
push: (home, message) => syncVault(home, { push: true, message })
|
|
23379
23781
|
};
|
|
23380
23782
|
}
|
|
@@ -23751,10 +24153,15 @@ ${GUIDE}` }]
|
|
|
23751
24153
|
"Markdown. Lead each section with the failure, then the fix. End with the session ids and turn numbers this came from."
|
|
23752
24154
|
),
|
|
23753
24155
|
key: external_exports.string().optional().describe("The candidate key from pantheon_handoff, so it is not proposed again."),
|
|
23754
|
-
sessions: external_exports.number().optional().describe("How many conversations back this up.")
|
|
24156
|
+
sessions: external_exports.number().optional().describe("How many conversations back this up."),
|
|
24157
|
+
evidence: external_exports.array(external_exports.object({ sessionId: external_exports.string(), turnId: external_exports.number() })).optional().describe(
|
|
24158
|
+
"The archived turns this came from. Every id is checked against the vault and the save is refused if one does not exist, so cite turns you actually read with pantheon_get_turns. Leave empty only when the lesson came from the live conversation, which is not archived yet."
|
|
24159
|
+
)
|
|
23755
24160
|
},
|
|
23756
|
-
async ({ space, name, when, body, key, sessions }) => safe(async () => {
|
|
23757
|
-
const
|
|
24161
|
+
async ({ space, name, when, body, key, sessions, evidence }) => safe(async () => {
|
|
24162
|
+
const root = writeRoot(home, space);
|
|
24163
|
+
verifyCitations(root, evidence ?? []);
|
|
24164
|
+
const saved = saveSkill(root, { name, when, body, key, sessions, evidence }, "draft");
|
|
23758
24165
|
const sync2 = await vault.push(home, `skill draft ${saved.name}`);
|
|
23759
24166
|
return {
|
|
23760
24167
|
ok: sync2.ok !== false,
|
|
@@ -23764,6 +24171,13 @@ ${GUIDE}` }]
|
|
|
23764
24171
|
};
|
|
23765
24172
|
})
|
|
23766
24173
|
);
|
|
24174
|
+
registerTool(
|
|
24175
|
+
server,
|
|
24176
|
+
"pantheon_skill_review",
|
|
24177
|
+
"Review a Pantheon space for lessons worth writing down as a skill. Trigger: /pantheon-skills <space>. Returns what this space already has, how many of its live slots are spent, and the recurring signals its archive still holds: times the human corrected an agent, commands run across several conversations, and any deterministic candidates. These are raw material, not findings \u2014 read the turns with pantheon_get_turns before believing any of them. Judge the conversation you are having now as well, and weigh it heavily: most clients never archive what a tool printed, so a failure you hit in this chat is evidence that exists nowhere else. Then propose AT MOST TWO, and propose none if nothing genuinely recurred \u2014 none is the ordinary answer and a space with no skills is healthier than one with skills nobody reads. Never write a skill for something AGENTS.md or the README already says. Put each proposal to the human in one line \u2014 what it would say and what it is drawn from \u2014 and write nothing until they choose. Only then call pantheon_save_skill, once per approved skill, with evidence citing the turns.",
|
|
24178
|
+
{ space: external_exports.string(), cwd: external_exports.string().optional() },
|
|
24179
|
+
async ({ space, cwd }) => safe(() => skillReview(home, space, cwd || process.cwd()))
|
|
24180
|
+
);
|
|
23767
24181
|
registerTool(
|
|
23768
24182
|
server,
|
|
23769
24183
|
"pantheon_dismiss_skill",
|
|
@@ -23818,24 +24232,24 @@ import { hostname as hostname3 } from "node:os";
|
|
|
23818
24232
|
|
|
23819
24233
|
// src/connect.ts
|
|
23820
24234
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
23821
|
-
import { existsSync as
|
|
24235
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync7, renameSync as renameSync2 } from "node:fs";
|
|
23822
24236
|
import { hostname as hostname2 } from "node:os";
|
|
23823
|
-
import { join as
|
|
24237
|
+
import { join as join8 } from "node:path";
|
|
23824
24238
|
|
|
23825
24239
|
// src/mcp-install.ts
|
|
23826
|
-
import { existsSync as
|
|
24240
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync6, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
23827
24241
|
import { homedir as homedir5 } from "node:os";
|
|
23828
|
-
import { dirname as
|
|
24242
|
+
import { dirname as dirname3, join as join7 } from "node:path";
|
|
23829
24243
|
import { fileURLToPath } from "node:url";
|
|
23830
|
-
var here =
|
|
24244
|
+
var here = dirname3(fileURLToPath(import.meta.url));
|
|
23831
24245
|
function pantheonBin() {
|
|
23832
24246
|
const self = fileURLToPath(import.meta.url);
|
|
23833
|
-
if (self.endsWith(".ts")) return
|
|
24247
|
+
if (self.endsWith(".ts")) return join7(here, "../bin/pantheon.mjs");
|
|
23834
24248
|
return self;
|
|
23835
24249
|
}
|
|
23836
24250
|
function launchEnv(home) {
|
|
23837
|
-
const nodeDir =
|
|
23838
|
-
const binDir =
|
|
24251
|
+
const nodeDir = dirname3(process.execPath);
|
|
24252
|
+
const binDir = dirname3(pantheonBin());
|
|
23839
24253
|
const sep = process.platform === "win32" ? ";" : ":";
|
|
23840
24254
|
const pathKey = process.platform === "win32" ? "Path" : "PATH";
|
|
23841
24255
|
return {
|
|
@@ -23923,8 +24337,8 @@ function isPlainObject3(value) {
|
|
|
23923
24337
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23924
24338
|
}
|
|
23925
24339
|
function readJson(path) {
|
|
23926
|
-
if (!
|
|
23927
|
-
const text2 =
|
|
24340
|
+
if (!existsSync7(path)) return {};
|
|
24341
|
+
const text2 = readFileSync6(path, "utf8").replace(/^\uFEFF/, "");
|
|
23928
24342
|
if (!text2.trim()) return {};
|
|
23929
24343
|
let value;
|
|
23930
24344
|
try {
|
|
@@ -23943,13 +24357,13 @@ function readJson(path) {
|
|
|
23943
24357
|
return value;
|
|
23944
24358
|
}
|
|
23945
24359
|
function writeAtomic(path, text2) {
|
|
23946
|
-
|
|
24360
|
+
mkdirSync6(dirname3(path), { recursive: true });
|
|
23947
24361
|
const temp = `${path}.pantheon-${process.pid}.tmp`;
|
|
23948
24362
|
try {
|
|
23949
|
-
|
|
24363
|
+
writeFileSync6(temp, text2);
|
|
23950
24364
|
renameSync(temp, path);
|
|
23951
24365
|
} catch (error2) {
|
|
23952
|
-
if (
|
|
24366
|
+
if (existsSync7(temp)) unlinkSync2(temp);
|
|
23953
24367
|
throw error2;
|
|
23954
24368
|
}
|
|
23955
24369
|
}
|
|
@@ -23968,20 +24382,20 @@ function tomlString(value) {
|
|
|
23968
24382
|
}
|
|
23969
24383
|
function chatgptDesktopPath() {
|
|
23970
24384
|
if (process.platform !== "darwin") return null;
|
|
23971
|
-
return
|
|
24385
|
+
return join7(homedir5(), "Library", "Application Support", "ChatGPT", "chatgpt_mcp_config.json");
|
|
23972
24386
|
}
|
|
23973
24387
|
function claudeDesktopPath() {
|
|
23974
24388
|
if (process.platform === "darwin") {
|
|
23975
|
-
return
|
|
24389
|
+
return join7(homedir5(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
23976
24390
|
}
|
|
23977
24391
|
if (process.platform === "win32") {
|
|
23978
|
-
return
|
|
24392
|
+
return join7(process.env.APPDATA || homedir5(), "Claude", "claude_desktop_config.json");
|
|
23979
24393
|
}
|
|
23980
|
-
return
|
|
24394
|
+
return join7(homedir5(), ".config", "Claude", "claude_desktop_config.json");
|
|
23981
24395
|
}
|
|
23982
24396
|
function upsertCodex(home) {
|
|
23983
|
-
const path =
|
|
23984
|
-
|
|
24397
|
+
const path = join7(homedir5(), ".codex", "config.toml");
|
|
24398
|
+
mkdirSync6(dirname3(path), { recursive: true });
|
|
23985
24399
|
const server = mcpServer(home);
|
|
23986
24400
|
const args = server.args.map(tomlString).join(", ");
|
|
23987
24401
|
const block2 = [
|
|
@@ -23994,11 +24408,11 @@ function upsertCodex(home) {
|
|
|
23994
24408
|
`PANTHEON_HOME = ${tomlString(home)}`,
|
|
23995
24409
|
""
|
|
23996
24410
|
].join("\n");
|
|
23997
|
-
if (!
|
|
24411
|
+
if (!existsSync7(path)) {
|
|
23998
24412
|
writeAtomic(path, block2);
|
|
23999
24413
|
return;
|
|
24000
24414
|
}
|
|
24001
|
-
const existing =
|
|
24415
|
+
const existing = readFileSync6(path, "utf8");
|
|
24002
24416
|
if (existing.includes("[mcp_servers.pantheon]")) {
|
|
24003
24417
|
const next = existing.replace(
|
|
24004
24418
|
/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/,
|
|
@@ -24041,6 +24455,19 @@ Only then call pantheon_park, even if the slug is new. If you send a transcript,
|
|
|
24041
24455
|
body: `${spaceGate}
|
|
24042
24456
|
|
|
24043
24457
|
Parse the rest of the argument as the fact. Only then call pantheon_remember, even if the slug is new. Do not dump the chat.`
|
|
24458
|
+
},
|
|
24459
|
+
{
|
|
24460
|
+
name: "pantheon-skills",
|
|
24461
|
+
description: "Review a Pantheon space for lessons worth writing down",
|
|
24462
|
+
body: `${spaceGate}
|
|
24463
|
+
|
|
24464
|
+
Only then call pantheon_skill_review with that space, passing cwd when the project folder is not the server's working directory. It returns signals, not conclusions: corrections the human made, commands run across several conversations, and any deterministic candidates. Read the turns it cites with pantheon_get_turns before you believe any of them.
|
|
24465
|
+
|
|
24466
|
+
Then judge THIS conversation too, and weigh it heavily. Most clients never write down what a tool printed, so a failure you hit in this chat is evidence that exists nowhere else \u2014 a command that failed until you found the flag, a correction the human had to repeat, an approach that turned out to be wrong. That is the material only you have.
|
|
24467
|
+
|
|
24468
|
+
Propose AT MOST TWO, and propose none if nothing genuinely recurred. None is the ordinary answer: a live skill is loaded into every future resume of this space, so an unread one is a permanent tax. Never propose something AGENTS.md or the README already says \u2014 the review tells you which commands are already documented. Never propose a restatement of what the code plainly does.
|
|
24469
|
+
|
|
24470
|
+
Put each proposal to the human as one line: what it would tell a future agent, and what it is drawn from. Wait. Write nothing until they choose. For each one they approve, call pantheon_save_skill with evidence citing the sessions and turns \u2014 the vault checks those ids and refuses the save if one does not exist, so cite what you read rather than what you remember. If they say no to a deterministic candidate, call pantheon_dismiss_skill with its key so it stops being offered. Then tell them a draft is not active until they promote it on the space page.`
|
|
24044
24471
|
},
|
|
24045
24472
|
{
|
|
24046
24473
|
name: "pantheon-spaces",
|
|
@@ -24054,10 +24481,10 @@ Parse the rest of the argument as the fact. Only then call pantheon_remember, ev
|
|
|
24054
24481
|
}
|
|
24055
24482
|
];
|
|
24056
24483
|
function writeCodexSkill() {
|
|
24057
|
-
const dirs2 = [
|
|
24484
|
+
const dirs2 = [join7(homedir5(), ".agents", "skills", "pantheon"), join7(homedir5(), ".codex", "skills", "pantheon")];
|
|
24058
24485
|
const skill = `---
|
|
24059
24486
|
name: pantheon
|
|
24060
|
-
description: Use when the user types /pantheon-handoff, /pantheon-resume, /pantheon-park, /pantheon-remember, /pantheon-spaces, /pantheon-help, mentions Pantheon, conscience, spaces, or wants to hand off or resume an agent conversation. Always call pantheon_* MCP tools first. Never invent Pantheon space names from memory.
|
|
24487
|
+
description: Use when the user types /pantheon-handoff, /pantheon-resume, /pantheon-park, /pantheon-remember, /pantheon-spaces, /pantheon-skills, /pantheon-help, mentions Pantheon, conscience, spaces, or wants to hand off or resume an agent conversation. Always call pantheon_* MCP tools first. Never invent Pantheon space names from memory.
|
|
24061
24488
|
---
|
|
24062
24489
|
|
|
24063
24490
|
# Pantheon
|
|
@@ -24071,6 +24498,7 @@ Grounding: the only space list is the \`pantheon_list_spaces\` tool result. Neve
|
|
|
24071
24498
|
- \`/pantheon-park <space>\` \u2192 MCP tool \`pantheon_park\`
|
|
24072
24499
|
- \`/pantheon-remember <space> <fact>\` \u2192 MCP tool \`pantheon_remember\`
|
|
24073
24500
|
- \`/pantheon-spaces\` \u2192 MCP tool \`pantheon_list_spaces\`
|
|
24501
|
+
- \`/pantheon-skills <space>\` \u2192 MCP tool \`pantheon_skill_review\`
|
|
24074
24502
|
- \`/pantheon-help\` \u2192 MCP tool \`pantheon_help\`
|
|
24075
24503
|
|
|
24076
24504
|
A **space** is the short name the human chose for a conscience. For handoff, park, or remember: if they did not give one, ask: "What should this conscience be named?" Do not invent a name. If they typed a new slug for handoff, call \`pantheon_handoff\` \u2014 that creates the space. For resume with no name, call \`pantheon_resume\` anyway \u2014 it lists live spaces. Show that list and ask which one.
|
|
@@ -24117,19 +24545,26 @@ sentences drawn from the packet; any open threads; and the available skills by
|
|
|
24117
24545
|
name and trigger. The table only proves the load worked. It says nothing about
|
|
24118
24546
|
where the work was, which is the part the human asked for, so never fold that
|
|
24119
24547
|
into cells.
|
|
24548
|
+
|
|
24549
|
+
Report \`pantheon_skill_review\` as prose, not a table \u2014 it is a judgement, and a
|
|
24550
|
+
table of raw signals just hands the work back to the human. Say what you found
|
|
24551
|
+
worth writing, at most two, each as one line naming what it would tell a future
|
|
24552
|
+
agent and which turns it came from. If nothing recurred, say so plainly and stop;
|
|
24553
|
+
that is the common case and not a failure. Wait for them to choose before calling
|
|
24554
|
+
\`pantheon_save_skill\`.
|
|
24120
24555
|
`;
|
|
24121
24556
|
for (const dir of dirs2) {
|
|
24122
|
-
|
|
24123
|
-
|
|
24557
|
+
mkdirSync6(dir, { recursive: true });
|
|
24558
|
+
writeFileSync6(join7(dir, "SKILL.md"), skill);
|
|
24124
24559
|
}
|
|
24125
24560
|
}
|
|
24126
24561
|
function writeSlashCommands() {
|
|
24127
|
-
const dirs2 = [
|
|
24562
|
+
const dirs2 = [join7(homedir5(), ".cursor", "commands"), join7(homedir5(), ".claude", "commands")];
|
|
24128
24563
|
for (const dir of dirs2) {
|
|
24129
|
-
|
|
24564
|
+
mkdirSync6(dir, { recursive: true });
|
|
24130
24565
|
for (const command of slashCommands) {
|
|
24131
|
-
|
|
24132
|
-
|
|
24566
|
+
writeFileSync6(
|
|
24567
|
+
join7(dir, `${command.name}.md`),
|
|
24133
24568
|
`---
|
|
24134
24569
|
description: ${command.description}
|
|
24135
24570
|
---
|
|
@@ -24152,42 +24587,42 @@ function detectApps() {
|
|
|
24152
24587
|
const home = homedir5();
|
|
24153
24588
|
const mac = process.platform === "darwin";
|
|
24154
24589
|
const win = process.platform === "win32";
|
|
24155
|
-
const local = process.env.LOCALAPPDATA ||
|
|
24156
|
-
const roaming = process.env.APPDATA ||
|
|
24590
|
+
const local = process.env.LOCALAPPDATA || join7(home, "AppData", "Local");
|
|
24591
|
+
const roaming = process.env.APPDATA || join7(home, "AppData", "Roaming");
|
|
24157
24592
|
const evidence = {
|
|
24158
24593
|
Cursor: [
|
|
24159
|
-
|
|
24160
|
-
|
|
24161
|
-
|
|
24162
|
-
...mac ? ["/Applications/Cursor.app",
|
|
24163
|
-
...win ? [
|
|
24594
|
+
join7(home, ".cursor", "extensions"),
|
|
24595
|
+
join7(home, ".cursor", "argv.json"),
|
|
24596
|
+
join7(home, ".cursor", "cli"),
|
|
24597
|
+
...mac ? ["/Applications/Cursor.app", join7(home, "Applications", "Cursor.app")] : [],
|
|
24598
|
+
...win ? [join7(local, "Programs", "cursor")] : []
|
|
24164
24599
|
],
|
|
24165
24600
|
"Claude Code": [
|
|
24166
|
-
|
|
24167
|
-
|
|
24168
|
-
|
|
24169
|
-
|
|
24601
|
+
join7(home, ".claude", "projects"),
|
|
24602
|
+
join7(home, ".claude", "settings.json"),
|
|
24603
|
+
join7(home, ".claude", "history.jsonl"),
|
|
24604
|
+
join7(home, ".claude", "statsig")
|
|
24170
24605
|
],
|
|
24171
24606
|
"Claude Desktop": [
|
|
24172
|
-
...mac ? ["/Applications/Claude.app",
|
|
24173
|
-
...win ? [
|
|
24174
|
-
...!mac && !win ? [
|
|
24607
|
+
...mac ? ["/Applications/Claude.app", join7(home, "Applications", "Claude.app")] : [],
|
|
24608
|
+
...win ? [join7(local, "AnthropicClaude"), join7(roaming, "Claude", "window-state.json")] : [],
|
|
24609
|
+
...!mac && !win ? [join7(home, ".config", "Claude", "window-state.json")] : []
|
|
24175
24610
|
],
|
|
24176
|
-
"ChatGPT.app": mac ? ["/Applications/ChatGPT.app",
|
|
24611
|
+
"ChatGPT.app": mac ? ["/Applications/ChatGPT.app", join7(home, "Applications", "ChatGPT.app")] : [],
|
|
24177
24612
|
Codex: [
|
|
24178
|
-
|
|
24179
|
-
|
|
24180
|
-
|
|
24181
|
-
|
|
24613
|
+
join7(home, ".codex", "sessions"),
|
|
24614
|
+
join7(home, ".codex", "auth.json"),
|
|
24615
|
+
join7(home, ".codex", "history.jsonl"),
|
|
24616
|
+
join7(home, ".codex", "log")
|
|
24182
24617
|
],
|
|
24183
24618
|
Windsurf: [
|
|
24184
|
-
|
|
24185
|
-
...mac ? ["/Applications/Windsurf.app",
|
|
24619
|
+
join7(home, ".codeium", "windsurf"),
|
|
24620
|
+
...mac ? ["/Applications/Windsurf.app", join7(home, "Applications", "Windsurf.app")] : []
|
|
24186
24621
|
]
|
|
24187
24622
|
};
|
|
24188
24623
|
const found = /* @__PURE__ */ new Set();
|
|
24189
24624
|
for (const [name, paths] of Object.entries(evidence)) {
|
|
24190
|
-
if (paths.some((path) =>
|
|
24625
|
+
if (paths.some((path) => existsSync7(path))) found.add(name);
|
|
24191
24626
|
}
|
|
24192
24627
|
return found;
|
|
24193
24628
|
}
|
|
@@ -24216,25 +24651,25 @@ function installMcpClients(home) {
|
|
|
24216
24651
|
skipped.push({ name, detail: why.replace(homedir5(), "~") });
|
|
24217
24652
|
}
|
|
24218
24653
|
};
|
|
24219
|
-
install("Cursor",
|
|
24220
|
-
install("Claude Code",
|
|
24654
|
+
install("Cursor", join7(homedir5(), ".cursor", "mcp.json"), server);
|
|
24655
|
+
install("Claude Code", join7(homedir5(), ".claude.json"), mcpServer(home, true));
|
|
24221
24656
|
const desktop = claudeDesktopPath();
|
|
24222
|
-
if (
|
|
24657
|
+
if (existsSync7(dirname3(desktop)) || process.platform === "darwin" || process.platform === "win32") {
|
|
24223
24658
|
install("Claude Desktop", desktop, server);
|
|
24224
24659
|
} else {
|
|
24225
24660
|
skipped.push({ name: "Claude Desktop", detail: "app not found" });
|
|
24226
24661
|
}
|
|
24227
24662
|
const chatgpt = chatgptDesktopPath();
|
|
24228
|
-
if (chatgpt &&
|
|
24229
|
-
const codex =
|
|
24663
|
+
if (chatgpt && existsSync7(dirname3(chatgpt))) install("ChatGPT.app", chatgpt, server);
|
|
24664
|
+
const codex = join7(homedir5(), ".codex", "config.toml");
|
|
24230
24665
|
try {
|
|
24231
24666
|
upsertCodex(home);
|
|
24232
24667
|
(found.has("Codex") ? written : ahead).push({ name: "Codex", detail: tilde(codex) });
|
|
24233
24668
|
} catch {
|
|
24234
24669
|
skipped.push({ name: "Codex", detail: `could not write ${tilde(codex)}` });
|
|
24235
24670
|
}
|
|
24236
|
-
const windsurf =
|
|
24237
|
-
if (
|
|
24671
|
+
const windsurf = join7(homedir5(), ".codeium", "windsurf", "mcp_config.json");
|
|
24672
|
+
if (existsSync7(dirname3(windsurf))) {
|
|
24238
24673
|
install("Windsurf", windsurf, server);
|
|
24239
24674
|
} else {
|
|
24240
24675
|
skipped.push({ name: "Windsurf", detail: "app not found" });
|
|
@@ -24251,7 +24686,7 @@ function installMcpClients(home) {
|
|
|
24251
24686
|
return { written, ahead, skipped, found: [...found] };
|
|
24252
24687
|
}
|
|
24253
24688
|
function removeServerFromJson(path, key = "mcpServers") {
|
|
24254
|
-
if (!
|
|
24689
|
+
if (!existsSync7(path)) return false;
|
|
24255
24690
|
let current;
|
|
24256
24691
|
try {
|
|
24257
24692
|
current = readJson(path);
|
|
@@ -24266,9 +24701,9 @@ function removeServerFromJson(path, key = "mcpServers") {
|
|
|
24266
24701
|
return true;
|
|
24267
24702
|
}
|
|
24268
24703
|
function removeCodex() {
|
|
24269
|
-
const path =
|
|
24270
|
-
if (!
|
|
24271
|
-
const existing =
|
|
24704
|
+
const path = join7(homedir5(), ".codex", "config.toml");
|
|
24705
|
+
if (!existsSync7(path)) return false;
|
|
24706
|
+
const existing = readFileSync6(path, "utf8");
|
|
24272
24707
|
if (!existing.includes("[mcp_servers.pantheon]")) return false;
|
|
24273
24708
|
const next = existing.replace(/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/, "").replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
24274
24709
|
writeAtomic(path, next ? `${next}
|
|
@@ -24276,12 +24711,12 @@ function removeCodex() {
|
|
|
24276
24711
|
return true;
|
|
24277
24712
|
}
|
|
24278
24713
|
function removeSlashCommands() {
|
|
24279
|
-
const dirs2 = [
|
|
24714
|
+
const dirs2 = [join7(homedir5(), ".cursor", "commands"), join7(homedir5(), ".claude", "commands")];
|
|
24280
24715
|
let removed = 0;
|
|
24281
24716
|
for (const dir of dirs2) {
|
|
24282
24717
|
for (const command of slashCommands) {
|
|
24283
|
-
const file =
|
|
24284
|
-
if (!
|
|
24718
|
+
const file = join7(dir, `${command.name}.md`);
|
|
24719
|
+
if (!existsSync7(file)) continue;
|
|
24285
24720
|
unlinkSync2(file);
|
|
24286
24721
|
removed += 1;
|
|
24287
24722
|
}
|
|
@@ -24290,32 +24725,32 @@ function removeSlashCommands() {
|
|
|
24290
24725
|
}
|
|
24291
24726
|
function uninstallMcpClients() {
|
|
24292
24727
|
const removed = [];
|
|
24293
|
-
if (removeServerFromJson(
|
|
24294
|
-
if (removeServerFromJson(
|
|
24728
|
+
if (removeServerFromJson(join7(homedir5(), ".cursor", "mcp.json"))) removed.push("Cursor");
|
|
24729
|
+
if (removeServerFromJson(join7(homedir5(), ".claude.json"))) removed.push("Claude Code");
|
|
24295
24730
|
if (removeServerFromJson(claudeDesktopPath())) removed.push("Claude Desktop");
|
|
24296
24731
|
const chatgpt = chatgptDesktopPath();
|
|
24297
24732
|
if (chatgpt && removeServerFromJson(chatgpt)) removed.push("ChatGPT.app (shared MCP file)");
|
|
24298
24733
|
if (removeCodex()) removed.push("ChatGPT.app / Codex");
|
|
24299
|
-
if (removeServerFromJson(
|
|
24734
|
+
if (removeServerFromJson(join7(homedir5(), ".codeium", "windsurf", "mcp_config.json"))) {
|
|
24300
24735
|
removed.push("Windsurf");
|
|
24301
24736
|
}
|
|
24302
24737
|
const slash2 = removeSlashCommands();
|
|
24303
24738
|
if (slash2) removed.push("/pantheon-* commands");
|
|
24304
24739
|
for (const dir of [
|
|
24305
|
-
|
|
24306
|
-
|
|
24740
|
+
join7(homedir5(), ".agents", "skills", "pantheon"),
|
|
24741
|
+
join7(homedir5(), ".codex", "skills", "pantheon")
|
|
24307
24742
|
]) {
|
|
24308
|
-
const file =
|
|
24309
|
-
if (!
|
|
24743
|
+
const file = join7(dir, "SKILL.md");
|
|
24744
|
+
if (!existsSync7(file)) continue;
|
|
24310
24745
|
unlinkSync2(file);
|
|
24311
24746
|
removed.push("ChatGPT / Codex skill");
|
|
24312
24747
|
break;
|
|
24313
24748
|
}
|
|
24314
24749
|
for (const launcher of [
|
|
24315
|
-
|
|
24316
|
-
|
|
24750
|
+
join7(homedir5(), ".local", "bin", "pantheon-mcp"),
|
|
24751
|
+
join7(homedir5(), ".local", "bin", "pantheon-mcp.cmd")
|
|
24317
24752
|
]) {
|
|
24318
|
-
if (!
|
|
24753
|
+
if (!existsSync7(launcher)) continue;
|
|
24319
24754
|
unlinkSync2(launcher);
|
|
24320
24755
|
removed.push("pantheon-mcp launcher");
|
|
24321
24756
|
}
|
|
@@ -24327,6 +24762,109 @@ function installMcpFromConfig() {
|
|
|
24327
24762
|
return { ...installMcpClients(stored.config.home), apiUrl: stored.config.apiUrl };
|
|
24328
24763
|
}
|
|
24329
24764
|
|
|
24765
|
+
// src/progress.ts
|
|
24766
|
+
import { spawn } from "node:child_process";
|
|
24767
|
+
var UNICODE = {
|
|
24768
|
+
frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
|
|
24769
|
+
full: "\u2588",
|
|
24770
|
+
empty: "\u2591",
|
|
24771
|
+
ok: "\u2713",
|
|
24772
|
+
bad: "\xD7"
|
|
24773
|
+
};
|
|
24774
|
+
var ASCII = {
|
|
24775
|
+
frames: ["-", "\\", "|", "/"],
|
|
24776
|
+
full: "#",
|
|
24777
|
+
empty: "-",
|
|
24778
|
+
ok: "+",
|
|
24779
|
+
bad: "x"
|
|
24780
|
+
};
|
|
24781
|
+
function glyphs() {
|
|
24782
|
+
const windows = process.platform === "win32";
|
|
24783
|
+
const modern = Boolean(process.env.WT_SESSION || process.env.TERM_PROGRAM);
|
|
24784
|
+
return windows && !modern ? ASCII : UNICODE;
|
|
24785
|
+
}
|
|
24786
|
+
var BAR_WIDTH = 16;
|
|
24787
|
+
function step(label) {
|
|
24788
|
+
const mark = glyphs();
|
|
24789
|
+
const started = Date.now();
|
|
24790
|
+
const live = Boolean(process.stdout.isTTY);
|
|
24791
|
+
let frame = 0;
|
|
24792
|
+
let suffix = "";
|
|
24793
|
+
let timer = null;
|
|
24794
|
+
const paint = () => {
|
|
24795
|
+
if (!live) return;
|
|
24796
|
+
frame = (frame + 1) % mark.frames.length;
|
|
24797
|
+
process.stdout.write(`\r\x1B[2K ${mark.frames[frame]} ${label}${suffix}`);
|
|
24798
|
+
};
|
|
24799
|
+
if (live) {
|
|
24800
|
+
paint();
|
|
24801
|
+
timer = setInterval(paint, 80);
|
|
24802
|
+
timer.unref?.();
|
|
24803
|
+
} else {
|
|
24804
|
+
process.stdout.write(` ${label}\u2026
|
|
24805
|
+
`);
|
|
24806
|
+
}
|
|
24807
|
+
const stop = (glyph, detail) => {
|
|
24808
|
+
if (timer) clearInterval(timer);
|
|
24809
|
+
timer = null;
|
|
24810
|
+
if (!live) return;
|
|
24811
|
+
const seconds = (Date.now() - started) / 1e3;
|
|
24812
|
+
const took = seconds >= 0.1 ? ` ${seconds.toFixed(1)}s` : "";
|
|
24813
|
+
process.stdout.write(
|
|
24814
|
+
`\r\x1B[2K ${glyph} ${label}${detail ? ` ${detail}` : ""}${took}
|
|
24815
|
+
`
|
|
24816
|
+
);
|
|
24817
|
+
};
|
|
24818
|
+
return {
|
|
24819
|
+
note(text2) {
|
|
24820
|
+
suffix = text2 ? ` ${text2}` : "";
|
|
24821
|
+
paint();
|
|
24822
|
+
},
|
|
24823
|
+
progress(percent, detail) {
|
|
24824
|
+
const clamped = Math.max(0, Math.min(100, Math.round(percent)));
|
|
24825
|
+
const filled = Math.round(BAR_WIDTH * clamped / 100);
|
|
24826
|
+
const bar = mark.full.repeat(filled) + mark.empty.repeat(BAR_WIDTH - filled);
|
|
24827
|
+
suffix = ` ${bar} ${String(clamped).padStart(3)}%${detail ? ` ${detail}` : ""}`;
|
|
24828
|
+
paint();
|
|
24829
|
+
},
|
|
24830
|
+
done(detail) {
|
|
24831
|
+
stop(mark.ok, detail);
|
|
24832
|
+
},
|
|
24833
|
+
fail() {
|
|
24834
|
+
stop(mark.bad);
|
|
24835
|
+
}
|
|
24836
|
+
};
|
|
24837
|
+
}
|
|
24838
|
+
var PHASES = {
|
|
24839
|
+
"Counting objects": "counting",
|
|
24840
|
+
"Compressing objects": "compressing",
|
|
24841
|
+
"Receiving objects": "downloading",
|
|
24842
|
+
"Resolving deltas": "unpacking",
|
|
24843
|
+
"Updating files": "checking out"
|
|
24844
|
+
};
|
|
24845
|
+
var PROGRESS_LINE = new RegExp(`(${Object.keys(PHASES).join("|")}):\\s+(\\d+)%`);
|
|
24846
|
+
function runGit(args, onProgress) {
|
|
24847
|
+
return new Promise((resolve3, reject) => {
|
|
24848
|
+
const child = spawn("git", args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
24849
|
+
let errors = "";
|
|
24850
|
+
child.stderr.setEncoding("utf8");
|
|
24851
|
+
child.stderr.on("data", (chunk) => {
|
|
24852
|
+
if (errors.length < 8e3) errors += chunk;
|
|
24853
|
+
if (!onProgress) return;
|
|
24854
|
+
for (const line of chunk.split(/[\r\n]/)) {
|
|
24855
|
+
const hit = line.match(PROGRESS_LINE);
|
|
24856
|
+
if (hit) onProgress(Number(hit[2]), PHASES[hit[1]] || "working");
|
|
24857
|
+
}
|
|
24858
|
+
});
|
|
24859
|
+
child.on("error", reject);
|
|
24860
|
+
child.on("close", (code) => {
|
|
24861
|
+
if (code === 0) return resolve3();
|
|
24862
|
+
const detail = errors.split("\n").filter(Boolean).slice(-3).join("\n").trim();
|
|
24863
|
+
reject(new Error(detail || `git ${args.find((arg) => !arg.startsWith("-")) || ""} failed`));
|
|
24864
|
+
});
|
|
24865
|
+
});
|
|
24866
|
+
}
|
|
24867
|
+
|
|
24330
24868
|
// src/report.ts
|
|
24331
24869
|
var LABEL = 12;
|
|
24332
24870
|
var NAME = 22;
|
|
@@ -24360,7 +24898,7 @@ function candidateHosts(explicit) {
|
|
|
24360
24898
|
async function connect(opts) {
|
|
24361
24899
|
const home = opts.home || defaultHome();
|
|
24362
24900
|
const code = opts.code.replace(/\s/g, "").toUpperCase();
|
|
24363
|
-
|
|
24901
|
+
const pairing = step("Verifying pairing code");
|
|
24364
24902
|
let body = null;
|
|
24365
24903
|
let apiUrl = "";
|
|
24366
24904
|
let lastError = "Pair failed";
|
|
@@ -24385,7 +24923,11 @@ async function connect(opts) {
|
|
|
24385
24923
|
lastError = `Could not reach ${host}`;
|
|
24386
24924
|
}
|
|
24387
24925
|
}
|
|
24388
|
-
if (!body)
|
|
24926
|
+
if (!body) {
|
|
24927
|
+
pairing.fail();
|
|
24928
|
+
throw new Error(lastError);
|
|
24929
|
+
}
|
|
24930
|
+
pairing.done(body.account);
|
|
24389
24931
|
saveMachineConfig(
|
|
24390
24932
|
{
|
|
24391
24933
|
home,
|
|
@@ -24398,16 +24940,15 @@ async function connect(opts) {
|
|
|
24398
24940
|
},
|
|
24399
24941
|
{ machineSecret: body.machineSecret }
|
|
24400
24942
|
);
|
|
24401
|
-
|
|
24943
|
+
mkdirSync7(home, { recursive: true });
|
|
24402
24944
|
const auth = authArgs();
|
|
24403
24945
|
const quiet = { stdio: ["ignore", "pipe", "pipe"] };
|
|
24404
|
-
const fresh = !
|
|
24946
|
+
const fresh = !existsSync8(join8(home, ".git"));
|
|
24405
24947
|
let archived = "";
|
|
24406
24948
|
if (fresh) {
|
|
24407
|
-
|
|
24408
|
-
execFileSync3("git", [...auth, "clone", body.cloneUrl, home], quiet);
|
|
24949
|
+
await clone2(body.cloneUrl, home, auth, "Cloning the vault");
|
|
24409
24950
|
} else {
|
|
24410
|
-
archived = syncVault2(home, body.cloneUrl, auth, quiet);
|
|
24951
|
+
archived = await syncVault2(home, body.cloneUrl, auth, quiet);
|
|
24411
24952
|
}
|
|
24412
24953
|
claimCredentials(home, quiet);
|
|
24413
24954
|
execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
|
|
@@ -24442,27 +24983,55 @@ async function connect(opts) {
|
|
|
24442
24983
|
)
|
|
24443
24984
|
);
|
|
24444
24985
|
}
|
|
24445
|
-
function syncVault2(home, cloneUrl, auth, quiet) {
|
|
24446
|
-
const git2 = (...args) => execFileSync3("git", [...auth, "-C", home, ...args], quiet);
|
|
24986
|
+
async function syncVault2(home, cloneUrl, auth, quiet) {
|
|
24447
24987
|
retarget(home, cloneUrl, quiet);
|
|
24988
|
+
const updating = step("Updating the vault");
|
|
24448
24989
|
try {
|
|
24449
|
-
|
|
24990
|
+
execFileSync3("git", [...auth, "-C", home, "pull", "--ff-only"], quiet);
|
|
24991
|
+
updating.done();
|
|
24450
24992
|
return "";
|
|
24451
24993
|
} catch (error2) {
|
|
24452
|
-
if (!
|
|
24994
|
+
if (!existsSync8(join8(home, ".git"))) {
|
|
24995
|
+
updating.fail();
|
|
24996
|
+
throw error2;
|
|
24997
|
+
}
|
|
24453
24998
|
}
|
|
24454
24999
|
if (sharesHistory(home)) {
|
|
24455
|
-
|
|
24456
|
-
|
|
25000
|
+
updating.note("merging work from another machine");
|
|
25001
|
+
try {
|
|
25002
|
+
await runGit(
|
|
25003
|
+
[...auth, "-C", home, "pull", "--no-rebase", "--no-edit", "--progress"],
|
|
25004
|
+
(percent, phase) => updating.progress(percent, phase)
|
|
25005
|
+
);
|
|
25006
|
+
} catch (error2) {
|
|
25007
|
+
updating.fail();
|
|
25008
|
+
throw error2;
|
|
25009
|
+
}
|
|
25010
|
+
updating.done("merged");
|
|
24457
25011
|
return "";
|
|
24458
25012
|
}
|
|
24459
25013
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
24460
25014
|
const archive = `${home}-${stamp2}`;
|
|
24461
|
-
|
|
25015
|
+
updating.done("belongs to a different account");
|
|
24462
25016
|
renameSync2(home, archive);
|
|
24463
|
-
|
|
25017
|
+
const aside = step("Setting the old vault aside");
|
|
25018
|
+
aside.done(archive);
|
|
25019
|
+
await clone2(cloneUrl, home, auth, "Cloning the new vault");
|
|
24464
25020
|
return archive;
|
|
24465
25021
|
}
|
|
25022
|
+
async function clone2(cloneUrl, home, auth, label) {
|
|
25023
|
+
const cloning = step(label);
|
|
25024
|
+
try {
|
|
25025
|
+
await runGit(
|
|
25026
|
+
[...auth, "clone", "--progress", cloneUrl, home],
|
|
25027
|
+
(percent, phase) => cloning.progress(percent, phase)
|
|
25028
|
+
);
|
|
25029
|
+
} catch (error2) {
|
|
25030
|
+
cloning.fail();
|
|
25031
|
+
throw error2;
|
|
25032
|
+
}
|
|
25033
|
+
cloning.done();
|
|
25034
|
+
}
|
|
24466
25035
|
function retarget(home, cloneUrl, quiet) {
|
|
24467
25036
|
try {
|
|
24468
25037
|
execFileSync3("git", ["-C", home, "remote", "set-url", "origin", cloneUrl], quiet);
|
|
@@ -24558,8 +25127,8 @@ async function bootstrapFromToken(token, opts = {}) {
|
|
|
24558
25127
|
{ machineSecret: body.machineSecret }
|
|
24559
25128
|
);
|
|
24560
25129
|
const vaultToken = await mintVaultToken(apiUrl, body.machineId, body.machineSecret);
|
|
24561
|
-
const
|
|
24562
|
-
if (!
|
|
25130
|
+
const clone3 = ensureVaultClone(home, body.cloneUrl, vaultToken);
|
|
25131
|
+
if (!clone3.ok) throw new Error(clone3.error || "Could not clone the vault.");
|
|
24563
25132
|
try {
|
|
24564
25133
|
installAgentAssets();
|
|
24565
25134
|
} catch {
|
|
@@ -24665,7 +25234,7 @@ function printSpaces() {
|
|
|
24665
25234
|
}
|
|
24666
25235
|
|
|
24667
25236
|
// src/status.ts
|
|
24668
|
-
import { existsSync as
|
|
25237
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
24669
25238
|
function printStatus() {
|
|
24670
25239
|
const stored = loadMachineConfig();
|
|
24671
25240
|
if (!stored) {
|
|
@@ -24679,7 +25248,7 @@ function printStatus() {
|
|
|
24679
25248
|
field("GitHub", config2.account),
|
|
24680
25249
|
field("Install", String(config2.installationId)),
|
|
24681
25250
|
field("Repo", `${config2.repo} (private)`),
|
|
24682
|
-
field("Vault", `${config2.home}${
|
|
25251
|
+
field("Vault", `${config2.home}${existsSync9(config2.home) ? "" : " (missing)"}`),
|
|
24683
25252
|
field("API", config2.apiUrl),
|
|
24684
25253
|
field("Machine", config2.machineId)
|
|
24685
25254
|
].join("\n")
|
|
@@ -24691,14 +25260,35 @@ function printStatus() {
|
|
|
24691
25260
|
async function sync() {
|
|
24692
25261
|
const stored = loadMachineConfig();
|
|
24693
25262
|
if (!stored) throw new Error("Not connected. Run pantheon connect <code> first.");
|
|
25263
|
+
const vault = step("Syncing the vault");
|
|
24694
25264
|
const result = await syncVault(stored.config.home, { push: true, message: "pantheon sync" });
|
|
24695
|
-
if (!result.ok)
|
|
25265
|
+
if (!result.ok) {
|
|
25266
|
+
vault.fail();
|
|
25267
|
+
throw new Error(result.error || "Sync failed");
|
|
25268
|
+
}
|
|
24696
25269
|
const bits = [
|
|
24697
25270
|
result.committed ? "committed" : "clean",
|
|
24698
25271
|
result.pulled ? "pulled" : null,
|
|
24699
25272
|
result.pushed ? "pushed" : null
|
|
24700
25273
|
].filter(Boolean);
|
|
24701
|
-
|
|
25274
|
+
vault.done(bits.join(", "));
|
|
25275
|
+
const shared = step("Refreshing shared consciences");
|
|
25276
|
+
const pull = await pullShares(stored.config.home, {
|
|
25277
|
+
onProgress: (done, total) => {
|
|
25278
|
+
if (total) shared.progress(done / total * 100, `${done}/${total} files`);
|
|
25279
|
+
}
|
|
25280
|
+
});
|
|
25281
|
+
if (!pull.ok) {
|
|
25282
|
+
shared.fail();
|
|
25283
|
+
console.log(` Shared could not refresh \u2014 ${pull.error}`);
|
|
25284
|
+
return;
|
|
25285
|
+
}
|
|
25286
|
+
if (!pull.spaces) {
|
|
25287
|
+
shared.done("none shared with you");
|
|
25288
|
+
return;
|
|
25289
|
+
}
|
|
25290
|
+
const detail = pull.fetched ? `${pull.fetched} files fetched` : "up to date";
|
|
25291
|
+
shared.done(`${pull.spaces} ${pull.spaces === 1 ? "space" : "spaces"}, ${detail}`);
|
|
24702
25292
|
}
|
|
24703
25293
|
|
|
24704
25294
|
// src/index.ts
|
package/package.json
CHANGED