pantheon-cli 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pantheon.mjs +523 -165
- package/package.json +3 -3
package/dist/pantheon.mjs
CHANGED
|
@@ -3640,7 +3640,7 @@ var require_fast_uri = __commonJS({
|
|
|
3640
3640
|
normalizeString(uri, options);
|
|
3641
3641
|
} else if (typeof uri === "object") {
|
|
3642
3642
|
uri = /** @type {T} */
|
|
3643
|
-
parse3(
|
|
3643
|
+
parse3(serialize2(uri, options), options);
|
|
3644
3644
|
}
|
|
3645
3645
|
return uri;
|
|
3646
3646
|
}
|
|
@@ -3653,13 +3653,13 @@ var require_fast_uri = __commonJS({
|
|
|
3653
3653
|
}
|
|
3654
3654
|
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
3655
3655
|
schemelessOptions.skipEscape = true;
|
|
3656
|
-
return
|
|
3656
|
+
return serialize2(resolved, schemelessOptions);
|
|
3657
3657
|
}
|
|
3658
3658
|
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
3659
3659
|
const target = {};
|
|
3660
3660
|
if (!skipNormalization) {
|
|
3661
|
-
base = parse3(
|
|
3662
|
-
relative2 = parse3(
|
|
3661
|
+
base = parse3(serialize2(base, options), options);
|
|
3662
|
+
relative2 = parse3(serialize2(relative2, options), options);
|
|
3663
3663
|
}
|
|
3664
3664
|
options = options || {};
|
|
3665
3665
|
if (!options.tolerant && relative2.scheme) {
|
|
@@ -3713,7 +3713,7 @@ var require_fast_uri = __commonJS({
|
|
|
3713
3713
|
const normalizedB = normalizeComparableURI(uriB, options);
|
|
3714
3714
|
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
|
|
3715
3715
|
}
|
|
3716
|
-
function
|
|
3716
|
+
function serialize2(cmpts, opts) {
|
|
3717
3717
|
const component = {
|
|
3718
3718
|
host: cmpts.host,
|
|
3719
3719
|
scheme: cmpts.scheme,
|
|
@@ -3912,7 +3912,7 @@ var require_fast_uri = __commonJS({
|
|
|
3912
3912
|
function normalizeStringWithStatus(uri, opts) {
|
|
3913
3913
|
const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
|
|
3914
3914
|
return {
|
|
3915
|
-
normalized: malformedAuthorityOrPort ? uri :
|
|
3915
|
+
normalized: malformedAuthorityOrPort ? uri : serialize2(parsed, opts),
|
|
3916
3916
|
malformedAuthorityOrPort
|
|
3917
3917
|
};
|
|
3918
3918
|
}
|
|
@@ -3922,7 +3922,7 @@ var require_fast_uri = __commonJS({
|
|
|
3922
3922
|
return malformedAuthorityOrPort ? void 0 : normalized;
|
|
3923
3923
|
}
|
|
3924
3924
|
if (typeof uri === "object") {
|
|
3925
|
-
return
|
|
3925
|
+
return serialize2(uri, opts);
|
|
3926
3926
|
}
|
|
3927
3927
|
}
|
|
3928
3928
|
var fastUri = {
|
|
@@ -3931,7 +3931,7 @@ var require_fast_uri = __commonJS({
|
|
|
3931
3931
|
resolve: resolve2,
|
|
3932
3932
|
resolveComponent,
|
|
3933
3933
|
equal,
|
|
3934
|
-
serialize,
|
|
3934
|
+
serialize: serialize2,
|
|
3935
3935
|
parse: parse3
|
|
3936
3936
|
};
|
|
3937
3937
|
module.exports = fastUri;
|
|
@@ -21263,16 +21263,16 @@ var MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
|
|
|
21263
21263
|
|
|
21264
21264
|
// ../core/src/spaces.ts
|
|
21265
21265
|
import {
|
|
21266
|
-
existsSync as
|
|
21267
|
-
mkdirSync,
|
|
21268
|
-
readFileSync as
|
|
21269
|
-
readdirSync as
|
|
21266
|
+
existsSync as existsSync3,
|
|
21267
|
+
mkdirSync as mkdirSync2,
|
|
21268
|
+
readFileSync as readFileSync3,
|
|
21269
|
+
readdirSync as readdirSync3,
|
|
21270
21270
|
statSync as statSync2,
|
|
21271
|
-
writeFileSync,
|
|
21271
|
+
writeFileSync as writeFileSync2,
|
|
21272
21272
|
appendFileSync
|
|
21273
21273
|
} from "node:fs";
|
|
21274
21274
|
import { homedir as homedir2 } from "node:os";
|
|
21275
|
-
import { basename as basename2, isAbsolute, join as
|
|
21275
|
+
import { basename as basename2, isAbsolute, join as join3, relative, resolve } from "node:path";
|
|
21276
21276
|
|
|
21277
21277
|
// ../core/src/transcripts.ts
|
|
21278
21278
|
import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
|
|
@@ -21650,9 +21650,282 @@ function captureLocalTranscript(opts = {}) {
|
|
|
21650
21650
|
return null;
|
|
21651
21651
|
}
|
|
21652
21652
|
|
|
21653
|
+
// ../core/src/skills.ts
|
|
21654
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, readdirSync as readdirSync2, rmSync, writeFileSync } from "node:fs";
|
|
21655
|
+
import { join as join2 } from "node:path";
|
|
21656
|
+
var SKILL_DIR = "skills";
|
|
21657
|
+
var DRAFT_DIR = "draft";
|
|
21658
|
+
var MAX_LIVE_SKILLS = 12;
|
|
21659
|
+
function skillsDir(root, status = "live") {
|
|
21660
|
+
return status === "live" ? join2(root, SKILL_DIR) : join2(root, SKILL_DIR, DRAFT_DIR);
|
|
21661
|
+
}
|
|
21662
|
+
function skillName(value) {
|
|
21663
|
+
const name = value.toLowerCase().trim().replace(/\.md$/, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
|
|
21664
|
+
return name || "skill";
|
|
21665
|
+
}
|
|
21666
|
+
function parseFrontmatter(raw) {
|
|
21667
|
+
const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
21668
|
+
if (!match) return { fields: {}, body: raw.trim() };
|
|
21669
|
+
const fields = {};
|
|
21670
|
+
for (const line of match[1].split("\n")) {
|
|
21671
|
+
const pair = line.match(/^([a-z_]+):\s*(.*)$/i);
|
|
21672
|
+
if (pair) fields[pair[1].toLowerCase()] = pair[2].trim();
|
|
21673
|
+
}
|
|
21674
|
+
return { fields, body: match[2].trim() };
|
|
21675
|
+
}
|
|
21676
|
+
function serialize(skill) {
|
|
21677
|
+
const head = [
|
|
21678
|
+
"---",
|
|
21679
|
+
`name: ${skill.name}`,
|
|
21680
|
+
`description: ${skill.when.replace(/\n/g, " ")}`,
|
|
21681
|
+
skill.key ? `key: ${skill.key}` : null,
|
|
21682
|
+
`sessions: ${skill.sessions}`,
|
|
21683
|
+
`updated_at: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
21684
|
+
"---",
|
|
21685
|
+
""
|
|
21686
|
+
].filter((line) => line !== null);
|
|
21687
|
+
return `${head.join("\n")}
|
|
21688
|
+
${skill.body.trim()}
|
|
21689
|
+
`;
|
|
21690
|
+
}
|
|
21691
|
+
function readSkillFile(dir, file, status) {
|
|
21692
|
+
const raw = (() => {
|
|
21693
|
+
try {
|
|
21694
|
+
return readFileSync2(join2(dir, file), "utf8");
|
|
21695
|
+
} catch {
|
|
21696
|
+
return "";
|
|
21697
|
+
}
|
|
21698
|
+
})();
|
|
21699
|
+
if (!raw.trim()) return null;
|
|
21700
|
+
const { fields, body } = parseFrontmatter(raw);
|
|
21701
|
+
const name = fields.name || file.replace(/\.md$/, "");
|
|
21702
|
+
return {
|
|
21703
|
+
name,
|
|
21704
|
+
when: fields.description || `Guidance recorded as ${name}.`,
|
|
21705
|
+
sessions: Number(fields.sessions) || 0,
|
|
21706
|
+
key: fields.key,
|
|
21707
|
+
updatedAt: fields.updated_at,
|
|
21708
|
+
status,
|
|
21709
|
+
body
|
|
21710
|
+
};
|
|
21711
|
+
}
|
|
21712
|
+
function listSkills(root, status = "live") {
|
|
21713
|
+
const dir = skillsDir(root, status);
|
|
21714
|
+
if (!existsSync2(dir)) return [];
|
|
21715
|
+
return readdirSync2(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => readSkillFile(dir, entry.name, status)).filter((skill) => skill !== null).sort((a, b) => b.sessions - a.sessions || a.name.localeCompare(b.name));
|
|
21716
|
+
}
|
|
21717
|
+
function skillRefs(root) {
|
|
21718
|
+
return listSkills(root, "live").slice(0, MAX_LIVE_SKILLS).map((skill) => ({ name: skill.name, when: skill.when, sessions: skill.sessions }));
|
|
21719
|
+
}
|
|
21720
|
+
function readSkill(root, name) {
|
|
21721
|
+
const file = `${skillName(name)}.md`;
|
|
21722
|
+
for (const status of ["live", "draft"]) {
|
|
21723
|
+
const dir = skillsDir(root, status);
|
|
21724
|
+
if (!existsSync2(join2(dir, file))) continue;
|
|
21725
|
+
const skill = readSkillFile(dir, file, status);
|
|
21726
|
+
if (skill) return skill;
|
|
21727
|
+
}
|
|
21728
|
+
throw new Error(
|
|
21729
|
+
`No skill named "${name}" in this space. Resume lists the ones that exist; do not guess a name.`
|
|
21730
|
+
);
|
|
21731
|
+
}
|
|
21732
|
+
function saveSkill(root, input, status = "draft") {
|
|
21733
|
+
const name = skillName(input.name);
|
|
21734
|
+
if (!input.body.trim()) throw new Error("A skill needs a body. Write the guidance, not a title.");
|
|
21735
|
+
if (!input.when.trim()) {
|
|
21736
|
+
throw new Error(
|
|
21737
|
+
"A skill needs a description saying when to use it. That line is all an agent sees before deciding to open it."
|
|
21738
|
+
);
|
|
21739
|
+
}
|
|
21740
|
+
const dir = skillsDir(root, status);
|
|
21741
|
+
mkdirSync(dir, { recursive: true });
|
|
21742
|
+
writeFileSync(
|
|
21743
|
+
join2(dir, `${name}.md`),
|
|
21744
|
+
serialize({
|
|
21745
|
+
name,
|
|
21746
|
+
when: input.when.trim(),
|
|
21747
|
+
body: input.body,
|
|
21748
|
+
key: input.key,
|
|
21749
|
+
sessions: input.sessions ?? 0
|
|
21750
|
+
})
|
|
21751
|
+
);
|
|
21752
|
+
return { name, status };
|
|
21753
|
+
}
|
|
21754
|
+
var SHELL_TOOL = /(shell|bash|terminal|command|run_|exec)/i;
|
|
21755
|
+
var MULTIPLEXER = /* @__PURE__ */ new Set([
|
|
21756
|
+
"git",
|
|
21757
|
+
"npm",
|
|
21758
|
+
"pnpm",
|
|
21759
|
+
"yarn",
|
|
21760
|
+
"npx",
|
|
21761
|
+
"docker",
|
|
21762
|
+
"cargo",
|
|
21763
|
+
"gh",
|
|
21764
|
+
"supabase",
|
|
21765
|
+
"vercel",
|
|
21766
|
+
"python",
|
|
21767
|
+
"python3",
|
|
21768
|
+
"node",
|
|
21769
|
+
"go",
|
|
21770
|
+
"kubectl",
|
|
21771
|
+
"brew",
|
|
21772
|
+
"pip",
|
|
21773
|
+
"pip3"
|
|
21774
|
+
]);
|
|
21775
|
+
var NOISE = /* @__PURE__ */ new Set(["cd", "ls", "cat", "echo", "pwd", "which", "true", "false", "clear"]);
|
|
21776
|
+
var ERROR_LINE = /^.*?\b(?:error|fatal|failed|failure|cannot|could not|not found|denied|refused|unsupported|invalid|ERR_[A-Z_]+|Traceback|panic)\b.*$/im;
|
|
21777
|
+
function errorLine(output) {
|
|
21778
|
+
if (!output) return null;
|
|
21779
|
+
const text2 = output.slice(0, 4e3);
|
|
21780
|
+
if (/\b(0 errors|no errors|error: 0|warning)\b/i.test(text2) && !/\berror\b:/i.test(text2)) {
|
|
21781
|
+
return null;
|
|
21782
|
+
}
|
|
21783
|
+
const hit = text2.match(ERROR_LINE)?.[0];
|
|
21784
|
+
if (!hit) return null;
|
|
21785
|
+
const line = hit.replace(/\s+/g, " ").trim();
|
|
21786
|
+
return line.length > 6 ? line.slice(0, 200) : null;
|
|
21787
|
+
}
|
|
21788
|
+
function errorKey(line) {
|
|
21789
|
+
return line.toLowerCase().replace(/(?:[a-z]:)?[\\/][\w.\\/-]+/g, " ").replace(/0x[0-9a-f]+|\b\d+\b/g, " ").replace(/["'`].*?["'`]/g, " ").replace(/[^a-z_ ]+/g, " ").replace(/\s+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
21790
|
+
}
|
|
21791
|
+
function commandText(input) {
|
|
21792
|
+
if (typeof input === "string") return input;
|
|
21793
|
+
if (!input || typeof input !== "object") return "";
|
|
21794
|
+
const record2 = input;
|
|
21795
|
+
for (const key of ["command", "cmd", "script", "input", "text"]) {
|
|
21796
|
+
const value = record2[key];
|
|
21797
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
21798
|
+
}
|
|
21799
|
+
return "";
|
|
21800
|
+
}
|
|
21801
|
+
function commandHead(command) {
|
|
21802
|
+
const words = command.replace(/^[\s(]*/, "").split(/\s+/).filter(Boolean);
|
|
21803
|
+
let index = 0;
|
|
21804
|
+
while (index < words.length && (/^[A-Z_][A-Z0-9_]*=/.test(words[index]) || words[index] === "sudo")) {
|
|
21805
|
+
index += 1;
|
|
21806
|
+
}
|
|
21807
|
+
const head = (words[index] || "").replace(/^.*[\\/]/, "").toLowerCase();
|
|
21808
|
+
if (!head || NOISE.has(head)) return null;
|
|
21809
|
+
if (!MULTIPLEXER.has(head)) return head;
|
|
21810
|
+
const sub = (words[index + 1] || "").toLowerCase();
|
|
21811
|
+
return /^[a-z][a-z0-9-]*$/.test(sub) ? `${head} ${sub}` : head;
|
|
21812
|
+
}
|
|
21813
|
+
var LOOKAHEAD = 8;
|
|
21814
|
+
var MAX_FRICTION = 24;
|
|
21815
|
+
function extractFrictions(turns) {
|
|
21816
|
+
const calls = [];
|
|
21817
|
+
for (const turn of turns) {
|
|
21818
|
+
for (const call of turn.toolCalls || []) {
|
|
21819
|
+
const command = SHELL_TOOL.test(call.name) ? commandText(call.input) : "";
|
|
21820
|
+
const head = command ? commandHead(command) : call.name.toLowerCase();
|
|
21821
|
+
if (!head) continue;
|
|
21822
|
+
calls.push({
|
|
21823
|
+
name: call.name,
|
|
21824
|
+
command: command.replace(/\s+/g, " ").trim().slice(0, 200) || call.name,
|
|
21825
|
+
head,
|
|
21826
|
+
output: call.output,
|
|
21827
|
+
turnId: turn.id
|
|
21828
|
+
});
|
|
21829
|
+
}
|
|
21830
|
+
}
|
|
21831
|
+
const out = [];
|
|
21832
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21833
|
+
for (let index = 0; index < calls.length && out.length < MAX_FRICTION; index += 1) {
|
|
21834
|
+
const call = calls[index];
|
|
21835
|
+
const error2 = errorLine(call.output);
|
|
21836
|
+
if (!error2) continue;
|
|
21837
|
+
const later = calls.slice(index + 1, index + 1 + LOOKAHEAD);
|
|
21838
|
+
const resolved = later.some((next) => next.head === call.head && !errorLine(next.output));
|
|
21839
|
+
if (!resolved) continue;
|
|
21840
|
+
const key = `${call.head}::${errorKey(error2)}`;
|
|
21841
|
+
if (!key.endsWith("::") && !seen.has(key)) {
|
|
21842
|
+
seen.add(key);
|
|
21843
|
+
out.push({ key, command: call.command, head: call.head, error: error2, turnId: call.turnId, resolved });
|
|
21844
|
+
}
|
|
21845
|
+
}
|
|
21846
|
+
return out;
|
|
21847
|
+
}
|
|
21848
|
+
var MIN_SESSIONS = 2;
|
|
21849
|
+
function titleFor(head, error2) {
|
|
21850
|
+
const subject = error2.replace(/^[^a-z]*/i, "").replace(/\s+/g, " ").trim().slice(0, 70);
|
|
21851
|
+
return `${head}: ${subject}`;
|
|
21852
|
+
}
|
|
21853
|
+
function documented(docs, error2) {
|
|
21854
|
+
if (!docs) return false;
|
|
21855
|
+
const haystack = docs.toLowerCase();
|
|
21856
|
+
const words = error2.toLowerCase().split(/[^a-z_]+/).filter((word) => word.length >= 7);
|
|
21857
|
+
if (!words.length) return false;
|
|
21858
|
+
const hits = words.filter((word) => haystack.includes(word)).length;
|
|
21859
|
+
return hits / words.length > 0.6;
|
|
21860
|
+
}
|
|
21861
|
+
function detectCandidates(sessions, options = {}) {
|
|
21862
|
+
const known = options.known ?? /* @__PURE__ */ new Set();
|
|
21863
|
+
const docs = options.docs ?? "";
|
|
21864
|
+
const groups = /* @__PURE__ */ new Map();
|
|
21865
|
+
for (const session of sessions) {
|
|
21866
|
+
for (const friction of extractFrictions(session.turns)) {
|
|
21867
|
+
if (known.has(friction.key)) continue;
|
|
21868
|
+
const group = groups.get(friction.key) ?? {
|
|
21869
|
+
evidence: [],
|
|
21870
|
+
sessions: /* @__PURE__ */ new Set(),
|
|
21871
|
+
head: friction.head,
|
|
21872
|
+
error: friction.error
|
|
21873
|
+
};
|
|
21874
|
+
group.sessions.add(session.id);
|
|
21875
|
+
group.evidence.push({
|
|
21876
|
+
sessionId: session.id,
|
|
21877
|
+
turnId: friction.turnId,
|
|
21878
|
+
command: friction.command,
|
|
21879
|
+
error: friction.error
|
|
21880
|
+
});
|
|
21881
|
+
groups.set(friction.key, group);
|
|
21882
|
+
}
|
|
21883
|
+
}
|
|
21884
|
+
const out = [];
|
|
21885
|
+
for (const [key, group] of groups) {
|
|
21886
|
+
if (group.sessions.size < MIN_SESSIONS) continue;
|
|
21887
|
+
if (documented(docs, group.error)) continue;
|
|
21888
|
+
const count = group.sessions.size;
|
|
21889
|
+
out.push({
|
|
21890
|
+
key,
|
|
21891
|
+
suggestedName: skillName(`${group.head}-${errorKey(group.error).split("-").slice(0, 3).join("-")}`),
|
|
21892
|
+
title: titleFor(group.head, group.error),
|
|
21893
|
+
why: `\`${group.head}\` failed this way in ${count} separate conversations and was worked through each time. Nothing in the repo's own docs covers it.`,
|
|
21894
|
+
sessions: [...group.sessions],
|
|
21895
|
+
evidence: group.evidence.slice(0, 6)
|
|
21896
|
+
});
|
|
21897
|
+
}
|
|
21898
|
+
return out.sort((a, b) => b.sessions.length - a.sessions.length || b.evidence.length - a.evidence.length).slice(0, options.limit ?? 3);
|
|
21899
|
+
}
|
|
21900
|
+
function knownSkillKeys(root) {
|
|
21901
|
+
const keys = /* @__PURE__ */ new Set();
|
|
21902
|
+
for (const status of ["live", "draft"]) {
|
|
21903
|
+
for (const skill of listSkills(root, status)) {
|
|
21904
|
+
if (skill.key) keys.add(skill.key);
|
|
21905
|
+
}
|
|
21906
|
+
}
|
|
21907
|
+
for (const key of readDismissed(root)) keys.add(key);
|
|
21908
|
+
return keys;
|
|
21909
|
+
}
|
|
21910
|
+
var DISMISSED = "dismissed.txt";
|
|
21911
|
+
function readDismissed(root) {
|
|
21912
|
+
const file = join2(skillsDir(root, "live"), DISMISSED);
|
|
21913
|
+
if (!existsSync2(file)) return [];
|
|
21914
|
+
return readFileSync2(file, "utf8").split("\n").map((line) => line.trim()).filter(Boolean);
|
|
21915
|
+
}
|
|
21916
|
+
function dismissCandidate(root, key) {
|
|
21917
|
+
const dir = skillsDir(root, "live");
|
|
21918
|
+
mkdirSync(dir, { recursive: true });
|
|
21919
|
+
const existing = new Set(readDismissed(root));
|
|
21920
|
+
existing.add(key.trim());
|
|
21921
|
+
writeFileSync(join2(dir, DISMISSED), `${[...existing].join("\n")}
|
|
21922
|
+
`);
|
|
21923
|
+
return { key };
|
|
21924
|
+
}
|
|
21925
|
+
|
|
21653
21926
|
// ../core/src/spaces.ts
|
|
21654
21927
|
function defaultHome() {
|
|
21655
|
-
return process.env.PANTHEON_HOME ||
|
|
21928
|
+
return process.env.PANTHEON_HOME || join3(homedir2(), "pantheon");
|
|
21656
21929
|
}
|
|
21657
21930
|
function missingSpaceName(value) {
|
|
21658
21931
|
const space = (value || "").trim();
|
|
@@ -21677,7 +21950,7 @@ function slugify(value) {
|
|
|
21677
21950
|
return slug || "space";
|
|
21678
21951
|
}
|
|
21679
21952
|
function spaceDir(home, slug) {
|
|
21680
|
-
return
|
|
21953
|
+
return join3(resolve(home), "spaces", slugify(slug));
|
|
21681
21954
|
}
|
|
21682
21955
|
function nowIso() {
|
|
21683
21956
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -21686,10 +21959,10 @@ function stamp() {
|
|
|
21686
21959
|
return nowIso().replace(/[:.]/g, "-");
|
|
21687
21960
|
}
|
|
21688
21961
|
function ensureDir(path) {
|
|
21689
|
-
|
|
21962
|
+
mkdirSync2(path, { recursive: true });
|
|
21690
21963
|
}
|
|
21691
21964
|
function readText(path) {
|
|
21692
|
-
return
|
|
21965
|
+
return existsSync3(path) ? readFileSync3(path, "utf8") : "";
|
|
21693
21966
|
}
|
|
21694
21967
|
function parseTurns(transcript) {
|
|
21695
21968
|
if (Array.isArray(transcript)) {
|
|
@@ -21778,9 +22051,9 @@ function mentionedDocuments(turns) {
|
|
|
21778
22051
|
}
|
|
21779
22052
|
function searchRoots() {
|
|
21780
22053
|
return [
|
|
21781
|
-
|
|
21782
|
-
|
|
21783
|
-
|
|
22054
|
+
join3(homedir2(), "Downloads"),
|
|
22055
|
+
join3(homedir2(), "Desktop"),
|
|
22056
|
+
join3(homedir2(), "Documents"),
|
|
21784
22057
|
"/mnt/user-data/outputs",
|
|
21785
22058
|
"/mnt/user-data/uploads",
|
|
21786
22059
|
process.cwd()
|
|
@@ -21789,17 +22062,17 @@ function searchRoots() {
|
|
|
21789
22062
|
function collectDiskArtifacts(turns) {
|
|
21790
22063
|
const found = [];
|
|
21791
22064
|
for (const doc of mentionedDocuments(turns)) {
|
|
21792
|
-
const candidates = [doc.path, ...searchRoots().map((root) =>
|
|
22065
|
+
const candidates = [doc.path, ...searchRoots().map((root) => join3(root, doc.name))].filter(
|
|
21793
22066
|
(path) => Boolean(path)
|
|
21794
22067
|
);
|
|
21795
22068
|
for (const path of candidates) {
|
|
21796
22069
|
try {
|
|
21797
|
-
if (!
|
|
22070
|
+
if (!existsSync3(path)) continue;
|
|
21798
22071
|
const stat = statSync2(path);
|
|
21799
22072
|
if (!stat.isFile() || stat.size === 0 || stat.size > MAX_DISK_ARTIFACT) continue;
|
|
21800
22073
|
found.push({
|
|
21801
22074
|
name: doc.name,
|
|
21802
|
-
content:
|
|
22075
|
+
content: readFileSync3(path).toString("base64"),
|
|
21803
22076
|
encoding: "base64"
|
|
21804
22077
|
});
|
|
21805
22078
|
break;
|
|
@@ -21831,7 +22104,7 @@ function pathsFromPatch(input) {
|
|
|
21831
22104
|
}
|
|
21832
22105
|
var slash = (path) => path.replace(/\\/g, "/");
|
|
21833
22106
|
function toFull(path, from) {
|
|
21834
|
-
const expanded = /^~[\\/]/.test(path) ?
|
|
22107
|
+
const expanded = /^~[\\/]/.test(path) ? join3(homedir2(), path.slice(2)) : path;
|
|
21835
22108
|
return slash(isAbsolute(expanded) ? resolve(expanded) : resolve(from, expanded));
|
|
21836
22109
|
}
|
|
21837
22110
|
function inside(base, full) {
|
|
@@ -21893,7 +22166,7 @@ function flatName(path, base) {
|
|
|
21893
22166
|
function readArtifactFile(path, base) {
|
|
21894
22167
|
const stat = statSync2(path);
|
|
21895
22168
|
if (!stat.isFile() || stat.size === 0 || stat.size > MAX_WRITTEN_FILE) return null;
|
|
21896
|
-
const buf =
|
|
22169
|
+
const buf = readFileSync3(path);
|
|
21897
22170
|
const binary = buf.includes(0);
|
|
21898
22171
|
return {
|
|
21899
22172
|
name: flatName(path, base),
|
|
@@ -21936,7 +22209,7 @@ function collectWrittenArtifacts(turns, cwd = process.cwd(), opts = {}) {
|
|
|
21936
22209
|
if (skipped.length < MAX_SKIP_REPORT) skipped.push({ name: flatName(path, base), reason });
|
|
21937
22210
|
};
|
|
21938
22211
|
const store = (path, gate) => {
|
|
21939
|
-
if (!
|
|
22212
|
+
if (!existsSync3(path)) return;
|
|
21940
22213
|
const stat = statSync2(path);
|
|
21941
22214
|
if (!stat.isFile() || stat.size === 0) return;
|
|
21942
22215
|
if (gate && since !== null && stat.mtimeMs < since) return;
|
|
@@ -21988,7 +22261,7 @@ function collectAttachedArtifacts(turns, cwd = process.cwd()) {
|
|
|
21988
22261
|
for (const path of paths) {
|
|
21989
22262
|
if (found.length >= 40 || total >= MAX_WRITTEN_TOTAL) break;
|
|
21990
22263
|
try {
|
|
21991
|
-
if (!
|
|
22264
|
+
if (!existsSync3(path)) continue;
|
|
21992
22265
|
const file = readArtifactFile(path, base);
|
|
21993
22266
|
if (!file) continue;
|
|
21994
22267
|
total += file.bytes;
|
|
@@ -22065,28 +22338,39 @@ function distill(input) {
|
|
|
22065
22338
|
function ensureSpace(home, name) {
|
|
22066
22339
|
const slug = slugify(name);
|
|
22067
22340
|
const root = spaceDir(home, slug);
|
|
22068
|
-
ensureDir(
|
|
22069
|
-
ensureDir(
|
|
22070
|
-
ensureDir(
|
|
22071
|
-
const metaPath =
|
|
22072
|
-
if (!
|
|
22073
|
-
|
|
22341
|
+
ensureDir(join3(root, "sessions"));
|
|
22342
|
+
ensureDir(join3(root, "handoffs"));
|
|
22343
|
+
ensureDir(join3(root, "artifacts"));
|
|
22344
|
+
const metaPath = join3(root, "space.yaml");
|
|
22345
|
+
if (!existsSync3(metaPath)) {
|
|
22346
|
+
writeFileSync2(
|
|
22074
22347
|
metaPath,
|
|
22075
22348
|
[`id: ${slug}`, `title: ${name}`, `created_at: ${nowIso()}`, ""].join("\n")
|
|
22076
22349
|
);
|
|
22077
22350
|
}
|
|
22078
|
-
if (!
|
|
22079
|
-
if (!
|
|
22351
|
+
if (!existsSync3(join3(root, "handoff.md"))) writeFileSync2(join3(root, "handoff.md"), "");
|
|
22352
|
+
if (!existsSync3(join3(root, "memory.md"))) writeFileSync2(join3(root, "memory.md"), "");
|
|
22353
|
+
return { slug, root };
|
|
22354
|
+
}
|
|
22355
|
+
function resolveSpace(home, name) {
|
|
22356
|
+
requireSpaceName(name);
|
|
22357
|
+
const slug = slugify(name);
|
|
22358
|
+
const root = spaceDir(home, slug);
|
|
22359
|
+
if (!existsSync3(root)) {
|
|
22360
|
+
throw new Error(
|
|
22361
|
+
`"${name}" is not a space in this vault. Call pantheon_list_spaces and use one of those names. Do not invent a substitute.`
|
|
22362
|
+
);
|
|
22363
|
+
}
|
|
22080
22364
|
return { slug, root };
|
|
22081
22365
|
}
|
|
22082
22366
|
function writeArtifacts(sessionDir, artifacts = []) {
|
|
22083
22367
|
const names = [];
|
|
22084
|
-
const dir =
|
|
22368
|
+
const dir = join3(sessionDir, "artifacts");
|
|
22085
22369
|
ensureDir(dir);
|
|
22086
22370
|
for (const artifact of artifacts) {
|
|
22087
22371
|
const safe2 = basename2(artifact.name).replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
22088
22372
|
const buf = artifact.encoding === "base64" ? Buffer.from(artifact.content, "base64") : Buffer.from(artifact.content, "utf8");
|
|
22089
|
-
|
|
22373
|
+
writeFileSync2(join3(dir, safe2), buf);
|
|
22090
22374
|
names.push(safe2);
|
|
22091
22375
|
}
|
|
22092
22376
|
return names;
|
|
@@ -22095,7 +22379,7 @@ function sanitizeSessionId(value) {
|
|
|
22095
22379
|
return value.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 120) || "session";
|
|
22096
22380
|
}
|
|
22097
22381
|
function readSessionTurns(sessionDir) {
|
|
22098
|
-
const raw = readText(
|
|
22382
|
+
const raw = readText(join3(sessionDir, "transcript.jsonl"));
|
|
22099
22383
|
if (!raw.trim()) return [];
|
|
22100
22384
|
const turns = [];
|
|
22101
22385
|
for (const line of raw.split("\n")) {
|
|
@@ -22127,16 +22411,16 @@ function writeSession(root, source, turns, artifacts, sessionId) {
|
|
|
22127
22411
|
const id = sanitizeSessionId(
|
|
22128
22412
|
sessionId || `${(source || "session").replace(/[^a-z0-9-]/gi, "").toLowerCase() || "session"}-${stamp()}`
|
|
22129
22413
|
);
|
|
22130
|
-
const sessionDir =
|
|
22414
|
+
const sessionDir = join3(root, "sessions", id);
|
|
22131
22415
|
ensureDir(sessionDir);
|
|
22132
22416
|
const existing = readSessionTurns(sessionDir);
|
|
22133
22417
|
const { merged, added } = mergeTurns(existing, turns);
|
|
22134
22418
|
const lines = merged.map((turn) => JSON.stringify(turn));
|
|
22135
|
-
|
|
22419
|
+
writeFileSync2(join3(sessionDir, "transcript.jsonl"), `${lines.join("\n")}
|
|
22136
22420
|
`);
|
|
22137
|
-
const created = readText(
|
|
22138
|
-
|
|
22139
|
-
|
|
22421
|
+
const created = readText(join3(sessionDir, "meta.yaml")).match(/^created_at: (.+)$/m)?.[1];
|
|
22422
|
+
writeFileSync2(
|
|
22423
|
+
join3(sessionDir, "meta.yaml"),
|
|
22140
22424
|
[
|
|
22141
22425
|
`id: ${id}`,
|
|
22142
22426
|
`source: ${source || "unknown"}`,
|
|
@@ -22256,11 +22540,11 @@ function writeHandoff(home, input) {
|
|
|
22256
22540
|
sessionId: session.sessionId,
|
|
22257
22541
|
sessions: sessionSummaries(root)
|
|
22258
22542
|
});
|
|
22259
|
-
|
|
22260
|
-
|
|
22543
|
+
writeFileSync2(join3(root, "handoff.md"), packet);
|
|
22544
|
+
writeFileSync2(join3(root, "handoffs", `${stamp()}.md`), packet);
|
|
22261
22545
|
if (input.facts?.length) {
|
|
22262
22546
|
const extra = input.facts.map((fact) => `- ${fact.trim()}`).join("\n");
|
|
22263
|
-
appendFileSync(
|
|
22547
|
+
appendFileSync(join3(root, "memory.md"), `${extra}
|
|
22264
22548
|
`);
|
|
22265
22549
|
}
|
|
22266
22550
|
return {
|
|
@@ -22276,6 +22560,9 @@ function writeHandoff(home, input) {
|
|
|
22276
22560
|
// Files this session made that the archive would not take. Silence here is
|
|
22277
22561
|
// how a handoff comes to promise more than it holds.
|
|
22278
22562
|
skipped: sweep?.skipped ?? [],
|
|
22563
|
+
// Usually empty. Only a failure that recurred across separate conversations
|
|
22564
|
+
// and is not already documented gets this far.
|
|
22565
|
+
skillCandidates: spaceSkillCandidates(root, cwd),
|
|
22279
22566
|
truncated: Boolean(input.truncated),
|
|
22280
22567
|
append: Boolean(input.append)
|
|
22281
22568
|
};
|
|
@@ -22297,9 +22584,9 @@ function writePark(home, input) {
|
|
|
22297
22584
|
const missing = missingGeneratedFiles(turns, artifacts);
|
|
22298
22585
|
if (missing) throw new Error(missing);
|
|
22299
22586
|
}
|
|
22300
|
-
const session = turns.length ? writeSession(root, input.source, turns, artifacts) : { sessionId: null, artifacts: writeArtifacts(
|
|
22587
|
+
const session = turns.length ? writeSession(root, input.source, turns, artifacts) : { sessionId: null, artifacts: writeArtifacts(join3(root, "sessions", "inbox"), artifacts) };
|
|
22301
22588
|
if (input.note) {
|
|
22302
|
-
appendFileSync(
|
|
22589
|
+
appendFileSync(join3(root, "memory.md"), `- park: ${input.note.trim()}
|
|
22303
22590
|
`);
|
|
22304
22591
|
}
|
|
22305
22592
|
return { slug, sessionId: session.sessionId, turns: turns.length, artifacts: session.artifacts };
|
|
@@ -22307,20 +22594,20 @@ function writePark(home, input) {
|
|
|
22307
22594
|
function writeRemember(home, space, fact) {
|
|
22308
22595
|
requireSpaceName(space);
|
|
22309
22596
|
const { slug, root } = ensureSpace(home, space);
|
|
22310
|
-
appendFileSync(
|
|
22597
|
+
appendFileSync(join3(root, "memory.md"), `- ${fact.trim()}
|
|
22311
22598
|
`);
|
|
22312
22599
|
return { slug };
|
|
22313
22600
|
}
|
|
22314
22601
|
function sessionDirs(root) {
|
|
22315
|
-
const sessions =
|
|
22316
|
-
if (!
|
|
22317
|
-
return
|
|
22318
|
-
const dir =
|
|
22319
|
-
const transcript =
|
|
22602
|
+
const sessions = join3(root, "sessions");
|
|
22603
|
+
if (!existsSync3(sessions)) return [];
|
|
22604
|
+
return readdirSync3(sessions, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== "inbox").map((entry) => {
|
|
22605
|
+
const dir = join3(sessions, entry.name);
|
|
22606
|
+
const transcript = join3(dir, "transcript.jsonl");
|
|
22320
22607
|
return {
|
|
22321
22608
|
id: entry.name,
|
|
22322
22609
|
dir,
|
|
22323
|
-
mtime:
|
|
22610
|
+
mtime: existsSync3(transcript) ? statSync2(transcript).mtimeMs : statSync2(dir).mtimeMs
|
|
22324
22611
|
};
|
|
22325
22612
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
22326
22613
|
}
|
|
@@ -22333,19 +22620,31 @@ function countLines(path) {
|
|
|
22333
22620
|
}
|
|
22334
22621
|
function sessionSummaries(root) {
|
|
22335
22622
|
return sessionDirs(root).map((session) => {
|
|
22336
|
-
const meta = readText(
|
|
22623
|
+
const meta = readText(join3(session.dir, "meta.yaml"));
|
|
22337
22624
|
const source = metaField(meta, "source");
|
|
22338
22625
|
return {
|
|
22339
22626
|
id: session.id,
|
|
22340
22627
|
source: source && source !== "unknown" ? source : void 0,
|
|
22341
22628
|
// meta.yaml is rewritten on every handoff, but a half-written or
|
|
22342
22629
|
// hand-edited archive should still report an honest count.
|
|
22343
|
-
turns: Number(metaField(meta, "turns")) || countLines(
|
|
22630
|
+
turns: Number(metaField(meta, "turns")) || countLines(join3(session.dir, "transcript.jsonl")),
|
|
22344
22631
|
createdAt: metaField(meta, "created_at"),
|
|
22345
22632
|
updatedAt: metaField(meta, "updated_at")
|
|
22346
22633
|
};
|
|
22347
22634
|
});
|
|
22348
22635
|
}
|
|
22636
|
+
var SKILL_SCAN_SESSIONS = 20;
|
|
22637
|
+
function projectDocs(cwd) {
|
|
22638
|
+
return ["AGENTS.md", "README.md", "CONTRIBUTING.md"].map((name) => readText(join3(cwd, name))).join("\n").slice(0, 4e4);
|
|
22639
|
+
}
|
|
22640
|
+
function spaceSkillCandidates(root, cwd) {
|
|
22641
|
+
const sessions = sessionDirs(root).slice(0, SKILL_SCAN_SESSIONS).map((session) => ({ id: session.id, turns: readSessionTurns(session.dir) }));
|
|
22642
|
+
if (sessions.length < 2) return [];
|
|
22643
|
+
return detectCandidates(sessions, {
|
|
22644
|
+
known: knownSkillKeys(root),
|
|
22645
|
+
docs: cwd ? projectDocs(cwd) : ""
|
|
22646
|
+
});
|
|
22647
|
+
}
|
|
22349
22648
|
var STORY_PACKETS = 8;
|
|
22350
22649
|
var STORY_CHARS = 6e3;
|
|
22351
22650
|
function packetBody(markdown) {
|
|
@@ -22356,15 +22655,15 @@ function unstamp(name) {
|
|
|
22356
22655
|
return name.replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z$/, "T$1:$2:$3.$4Z");
|
|
22357
22656
|
}
|
|
22358
22657
|
function readStory(root) {
|
|
22359
|
-
const dir =
|
|
22360
|
-
if (!
|
|
22361
|
-
const files2 =
|
|
22658
|
+
const dir = join3(root, "handoffs");
|
|
22659
|
+
if (!existsSync3(dir)) return [];
|
|
22660
|
+
const files2 = readdirSync3(dir).filter((name) => name.endsWith(".md")).sort();
|
|
22362
22661
|
const prior = files2.slice(0, -1).slice(-STORY_PACKETS);
|
|
22363
22662
|
const out = [];
|
|
22364
22663
|
let budget = STORY_CHARS;
|
|
22365
22664
|
for (const name of [...prior].reverse()) {
|
|
22366
22665
|
if (budget <= 0) break;
|
|
22367
|
-
const packet = packetBody(readText(
|
|
22666
|
+
const packet = packetBody(readText(join3(dir, name)));
|
|
22368
22667
|
if (!packet) continue;
|
|
22369
22668
|
out.push({ at: unstamp(name.replace(/\.md$/, "")), packet: packet.slice(0, budget) });
|
|
22370
22669
|
budget -= packet.length;
|
|
@@ -22374,9 +22673,9 @@ function readStory(root) {
|
|
|
22374
22673
|
function listSpaceArtifacts(root) {
|
|
22375
22674
|
const out = [];
|
|
22376
22675
|
for (const session of sessionDirs(root)) {
|
|
22377
|
-
const dir =
|
|
22378
|
-
if (!
|
|
22379
|
-
for (const name of
|
|
22676
|
+
const dir = join3(session.dir, "artifacts");
|
|
22677
|
+
if (!existsSync3(dir)) continue;
|
|
22678
|
+
for (const name of readdirSync3(dir)) {
|
|
22380
22679
|
if (name.startsWith(".")) continue;
|
|
22381
22680
|
out.push({ sessionId: session.id, name });
|
|
22382
22681
|
if (out.length >= 50) return out;
|
|
@@ -22384,7 +22683,7 @@ function listSpaceArtifacts(root) {
|
|
|
22384
22683
|
}
|
|
22385
22684
|
return out;
|
|
22386
22685
|
}
|
|
22387
|
-
function resumeNote(sessions, turns, story) {
|
|
22686
|
+
function resumeNote(sessions, turns, story, skills) {
|
|
22388
22687
|
if (!sessions.length) {
|
|
22389
22688
|
return "Nothing archived in this space yet. Ask the human what they were working on rather than guessing.";
|
|
22390
22689
|
}
|
|
@@ -22402,6 +22701,11 @@ function resumeNote(sessions, turns, story) {
|
|
|
22402
22701
|
parts.push(
|
|
22403
22702
|
'Before telling the human you lack context, run pantheon_search (query: "<topic>", context: 2) \u2014 it searches tool calls as well as messages, across every session.'
|
|
22404
22703
|
);
|
|
22704
|
+
if (skills.length) {
|
|
22705
|
+
parts.push(
|
|
22706
|
+
`This space has ${skills.length} skill${skills.length === 1 ? "" : "s"} \u2014 guidance written from failures that already happened here. Before working in an area one of them covers, read it with pantheon_get_skill. Following it is cheaper than rediscovering why it exists.`
|
|
22707
|
+
);
|
|
22708
|
+
}
|
|
22405
22709
|
return parts.join(" ");
|
|
22406
22710
|
}
|
|
22407
22711
|
function readResume(home, space) {
|
|
@@ -22410,16 +22714,19 @@ function readResume(home, space) {
|
|
|
22410
22714
|
const sessions = sessionSummaries(root);
|
|
22411
22715
|
const turns = sessions.reduce((sum, session) => sum + session.turns, 0);
|
|
22412
22716
|
const story = readStory(root);
|
|
22717
|
+
const skills = skillRefs(root);
|
|
22413
22718
|
return {
|
|
22414
22719
|
space: slug,
|
|
22415
|
-
handoff: readText(
|
|
22416
|
-
memory: readText(
|
|
22720
|
+
handoff: readText(join3(root, "handoff.md")).trim() || "(empty handoff)",
|
|
22721
|
+
memory: readText(join3(root, "memory.md")).trim() || "(no durable memory yet)",
|
|
22417
22722
|
sessionId: sessions[0]?.id ?? null,
|
|
22418
22723
|
sessions,
|
|
22419
22724
|
turns,
|
|
22420
22725
|
story,
|
|
22421
22726
|
artifacts: listSpaceArtifacts(root),
|
|
22422
|
-
|
|
22727
|
+
skills,
|
|
22728
|
+
pendingSkills: listSkills(root, "draft").length,
|
|
22729
|
+
note: resumeNote(sessions, turns, story.length, skills)
|
|
22423
22730
|
};
|
|
22424
22731
|
}
|
|
22425
22732
|
function packetPreview(markdown) {
|
|
@@ -22427,20 +22734,20 @@ function packetPreview(markdown) {
|
|
|
22427
22734
|
return packet.replace(/^#.+\n/gm, "").replace(/\s+/g, " ").trim().slice(0, 220);
|
|
22428
22735
|
}
|
|
22429
22736
|
function spaceTitle(root, slug) {
|
|
22430
|
-
const meta = readText(
|
|
22737
|
+
const meta = readText(join3(root, "space.yaml"));
|
|
22431
22738
|
return meta.match(/^title:\s*(.+)$/m)?.[1]?.trim() || slug;
|
|
22432
22739
|
}
|
|
22433
22740
|
function listSpaces(home) {
|
|
22434
|
-
const root =
|
|
22435
|
-
if (!
|
|
22436
|
-
return
|
|
22437
|
-
const dir =
|
|
22438
|
-
const handoff =
|
|
22741
|
+
const root = join3(resolve(home), "spaces");
|
|
22742
|
+
if (!existsSync3(root)) return [];
|
|
22743
|
+
return readdirSync3(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
|
|
22744
|
+
const dir = join3(root, entry.name);
|
|
22745
|
+
const handoff = join3(dir, "handoff.md");
|
|
22439
22746
|
const body = readText(handoff);
|
|
22440
22747
|
return {
|
|
22441
22748
|
slug: entry.name,
|
|
22442
22749
|
title: spaceTitle(dir, entry.name),
|
|
22443
|
-
updatedAt:
|
|
22750
|
+
updatedAt: existsSync3(handoff) ? statSync2(handoff).mtime.toISOString() : void 0,
|
|
22444
22751
|
preview: body ? packetPreview(body) : void 0
|
|
22445
22752
|
};
|
|
22446
22753
|
}).sort((a, b) => (b.updatedAt || "").localeCompare(a.updatedAt || ""));
|
|
@@ -22519,22 +22826,22 @@ function getTurns(home, space, sessionId, from, to) {
|
|
|
22519
22826
|
}
|
|
22520
22827
|
function getSession(home, space, sessionId) {
|
|
22521
22828
|
const { root } = ensureSpace(home, space);
|
|
22522
|
-
const file =
|
|
22523
|
-
if (!
|
|
22524
|
-
const turns =
|
|
22829
|
+
const file = join3(root, "sessions", sessionId, "transcript.jsonl");
|
|
22830
|
+
if (!existsSync3(file)) throw new Error(`Session not found: ${sessionId}`);
|
|
22831
|
+
const turns = readFileSync3(file, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
22525
22832
|
return { sessionId, turns, artifacts: listArtifacts(home, space, sessionId) };
|
|
22526
22833
|
}
|
|
22527
22834
|
function listArtifacts(home, space, sessionId) {
|
|
22528
22835
|
const { root } = ensureSpace(home, space);
|
|
22529
|
-
const dir =
|
|
22530
|
-
if (!
|
|
22531
|
-
return
|
|
22836
|
+
const dir = join3(root, "sessions", sessionId, "artifacts");
|
|
22837
|
+
if (!existsSync3(dir)) return [];
|
|
22838
|
+
return readdirSync3(dir);
|
|
22532
22839
|
}
|
|
22533
22840
|
function getArtifact(home, space, sessionId, name) {
|
|
22534
22841
|
const { root } = ensureSpace(home, space);
|
|
22535
|
-
const file =
|
|
22536
|
-
if (!
|
|
22537
|
-
const buf =
|
|
22842
|
+
const file = join3(root, "sessions", sessionId, "artifacts", basename2(name));
|
|
22843
|
+
if (!existsSync3(file)) throw new Error(`Artifact not found: ${name}`);
|
|
22844
|
+
const buf = readFileSync3(file);
|
|
22538
22845
|
const text2 = buf.toString("utf8");
|
|
22539
22846
|
const looksBinary = text2.includes("\0");
|
|
22540
22847
|
return looksBinary ? { name: basename2(name), encoding: "base64", content: buf.toString("base64") } : { name: basename2(name), encoding: "utf8", content: text2 };
|
|
@@ -22626,39 +22933,39 @@ Chat shortcuts (namespaced \u2014 use these, not /resume)
|
|
|
22626
22933
|
`;
|
|
22627
22934
|
|
|
22628
22935
|
// ../core/src/config.ts
|
|
22629
|
-
import { chmodSync, existsSync as
|
|
22936
|
+
import { chmodSync, existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
22630
22937
|
import { homedir as homedir3 } from "node:os";
|
|
22631
|
-
import { join as
|
|
22938
|
+
import { join as join4 } from "node:path";
|
|
22632
22939
|
function configDir() {
|
|
22633
|
-
return process.env.PANTHEON_CONFIG_DIR ||
|
|
22940
|
+
return process.env.PANTHEON_CONFIG_DIR || join4(homedir3(), ".config", "pantheon");
|
|
22634
22941
|
}
|
|
22635
22942
|
function loadMachineConfig() {
|
|
22636
22943
|
const dir = configDir();
|
|
22637
|
-
const configPath =
|
|
22638
|
-
const credPath =
|
|
22639
|
-
if (!
|
|
22944
|
+
const configPath = join4(dir, "config.json");
|
|
22945
|
+
const credPath = join4(dir, "credentials.json");
|
|
22946
|
+
if (!existsSync4(configPath) || !existsSync4(credPath)) return null;
|
|
22640
22947
|
return {
|
|
22641
|
-
config: JSON.parse(
|
|
22642
|
-
credentials: JSON.parse(
|
|
22948
|
+
config: JSON.parse(readFileSync4(configPath, "utf8")),
|
|
22949
|
+
credentials: JSON.parse(readFileSync4(credPath, "utf8"))
|
|
22643
22950
|
};
|
|
22644
22951
|
}
|
|
22645
22952
|
function saveMachineConfig(config2, credentials) {
|
|
22646
22953
|
const dir = configDir();
|
|
22647
|
-
|
|
22648
|
-
const configPath =
|
|
22649
|
-
const credPath =
|
|
22650
|
-
|
|
22954
|
+
mkdirSync3(dir, { recursive: true });
|
|
22955
|
+
const configPath = join4(dir, "config.json");
|
|
22956
|
+
const credPath = join4(dir, "credentials.json");
|
|
22957
|
+
writeFileSync3(configPath, `${JSON.stringify(config2, null, 2)}
|
|
22651
22958
|
`);
|
|
22652
|
-
|
|
22959
|
+
writeFileSync3(credPath, `${JSON.stringify(credentials, null, 2)}
|
|
22653
22960
|
`);
|
|
22654
22961
|
chmodSync(credPath, 384);
|
|
22655
22962
|
}
|
|
22656
22963
|
|
|
22657
22964
|
// ../core/src/vault.ts
|
|
22658
22965
|
import { execFileSync } from "node:child_process";
|
|
22659
|
-
import { existsSync as
|
|
22966
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, unlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
22660
22967
|
import { homedir as homedir4, tmpdir } from "node:os";
|
|
22661
|
-
import { dirname, join as
|
|
22968
|
+
import { dirname, join as join5 } from "node:path";
|
|
22662
22969
|
function gitEnv(extra = {}) {
|
|
22663
22970
|
return {
|
|
22664
22971
|
...process.env,
|
|
@@ -22666,7 +22973,7 @@ function gitEnv(extra = {}) {
|
|
|
22666
22973
|
PATH: [
|
|
22667
22974
|
extra.PATH,
|
|
22668
22975
|
process.env.PATH,
|
|
22669
|
-
|
|
22976
|
+
join5(homedir4(), ".local", "bin"),
|
|
22670
22977
|
"/opt/homebrew/bin",
|
|
22671
22978
|
"/usr/local/bin",
|
|
22672
22979
|
"/usr/bin",
|
|
@@ -22705,8 +23012,8 @@ async function mintToken() {
|
|
|
22705
23012
|
return body.token;
|
|
22706
23013
|
}
|
|
22707
23014
|
function withGitAuth(token, run) {
|
|
22708
|
-
const dest = process.platform === "win32" ?
|
|
22709
|
-
|
|
23015
|
+
const dest = process.platform === "win32" ? join5(tmpdir(), `pantheon-askpass-${process.pid}-${Date.now()}.cmd`) : join5(tmpdir(), `pantheon-askpass-${process.pid}-${Date.now()}`);
|
|
23016
|
+
writeFileSync4(
|
|
22710
23017
|
dest,
|
|
22711
23018
|
process.platform === "win32" ? `@echo off\r
|
|
22712
23019
|
echo(%~1| findstr /i "Username username" >nul\r
|
|
@@ -22736,7 +23043,7 @@ esac
|
|
|
22736
23043
|
}
|
|
22737
23044
|
function syncVaultWithToken(home, token, opts = {}) {
|
|
22738
23045
|
const result = { ok: false, committed: false, pulled: false, pushed: false };
|
|
22739
|
-
if (!
|
|
23046
|
+
if (!existsSync5(join5(home, ".git"))) {
|
|
22740
23047
|
result.error = "Vault is not a git repo.";
|
|
22741
23048
|
return result;
|
|
22742
23049
|
}
|
|
@@ -22775,11 +23082,11 @@ function syncVaultWithToken(home, token, opts = {}) {
|
|
|
22775
23082
|
}
|
|
22776
23083
|
}
|
|
22777
23084
|
function ensureVaultClone(home, cloneUrl, token) {
|
|
22778
|
-
if (
|
|
23085
|
+
if (existsSync5(join5(home, ".git"))) {
|
|
22779
23086
|
return syncVaultWithToken(home, token, { push: false });
|
|
22780
23087
|
}
|
|
22781
23088
|
try {
|
|
22782
|
-
|
|
23089
|
+
mkdirSync4(dirname(home), { recursive: true });
|
|
22783
23090
|
withGitAuth(token, (env) => {
|
|
22784
23091
|
execFileSync("git", ["clone", "--depth", "50", cloneUrl, home], {
|
|
22785
23092
|
encoding: "utf8",
|
|
@@ -22797,7 +23104,7 @@ function ensureVaultClone(home, cloneUrl, token) {
|
|
|
22797
23104
|
}
|
|
22798
23105
|
}
|
|
22799
23106
|
async function syncVault(home, opts = {}) {
|
|
22800
|
-
if (!
|
|
23107
|
+
if (!existsSync5(join5(home, ".git"))) {
|
|
22801
23108
|
return { ok: false, committed: false, pulled: false, pushed: false, error: "Vault is not a git repo. Run pantheon connect first." };
|
|
22802
23109
|
}
|
|
22803
23110
|
try {
|
|
@@ -22808,6 +23115,9 @@ async function syncVault(home, opts = {}) {
|
|
|
22808
23115
|
}
|
|
22809
23116
|
|
|
22810
23117
|
// ../mcp/src/index.ts
|
|
23118
|
+
function spaceRoot(home, space) {
|
|
23119
|
+
return resolveSpace(home, space).root;
|
|
23120
|
+
}
|
|
22811
23121
|
function defaultHooks() {
|
|
22812
23122
|
return {
|
|
22813
23123
|
pull: (home) => syncVault(home, { push: false }),
|
|
@@ -23019,7 +23329,10 @@ ${GUIDE}` }]
|
|
|
23019
23329
|
written.lastMessage ? `Last human message in the captured chat: "${written.lastMessage}" \u2014 if that is not this conversation, re-run with sessionKey from pantheon_local_sessions.` : null,
|
|
23020
23330
|
// A file the session made and the archive would not take is
|
|
23021
23331
|
// the one thing the human cannot see for themselves.
|
|
23022
|
-
written.skipped?.length ? `Not stored: ${written.skipped.map((file) => `${file.name} (${file.reason})`).join(", ")}. Tell the human, so they know the space does not hold these.` : null
|
|
23332
|
+
written.skipped?.length ? `Not stored: ${written.skipped.map((file) => `${file.name} (${file.reason})`).join(", ")}. Tell the human, so they know the space does not hold these.` : null,
|
|
23333
|
+
// Rare by design. Offer it, do not act on it: a skill nobody
|
|
23334
|
+
// asked for is context every future agent pays for.
|
|
23335
|
+
written.skillCandidates?.length ? `This space has hit the same problem in more than one conversation: ${written.skillCandidates.map((item) => `"${item.title}" (${item.sessions.length} sessions, key ${item.key})`).join("; ")}. Ask the human whether to write a skill for it. Only if they say yes, call pantheon_save_skill using the cited evidence \u2014 read the turns first with pantheon_get_turns rather than writing from memory. If they say no, call pantheon_dismiss_skill with that key so it stops being offered.` : null
|
|
23023
23336
|
].filter(Boolean).join(" ")
|
|
23024
23337
|
};
|
|
23025
23338
|
})
|
|
@@ -23123,6 +23436,51 @@ ${GUIDE}` }]
|
|
|
23123
23436
|
},
|
|
23124
23437
|
async ({ space, session_id, name }) => safe(() => getArtifact(home, space, session_id, name))
|
|
23125
23438
|
);
|
|
23439
|
+
registerTool(
|
|
23440
|
+
server,
|
|
23441
|
+
"pantheon_get_skill",
|
|
23442
|
+
"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.",
|
|
23443
|
+
{ space: external_exports.string(), name: external_exports.string() },
|
|
23444
|
+
async ({ space, name }) => safe(() => readSkill(spaceRoot(home, space), name))
|
|
23445
|
+
);
|
|
23446
|
+
registerTool(
|
|
23447
|
+
server,
|
|
23448
|
+
"pantheon_save_skill",
|
|
23449
|
+
"Write a skill into a Pantheon space as a DRAFT for the human to review. Only call this when pantheon_handoff returned a skillCandidate and the human agreed, or when the human explicitly asks for a skill \u2014 never speculatively, because an unread skill costs every future agent context for nothing. Ground every instruction in the cited evidence: say what failed, what fixed it, and cite session and turn. Do not restate anything already in AGENTS.md or the README.",
|
|
23450
|
+
{
|
|
23451
|
+
space: external_exports.string(),
|
|
23452
|
+
name: external_exports.string().describe("Short slug, e.g. nextjs-og-images."),
|
|
23453
|
+
when: external_exports.string().describe(
|
|
23454
|
+
"One sentence starting 'Use when\u2026' describing the trigger. This is all a future agent sees before deciding to open it, so name the situation, not the topic."
|
|
23455
|
+
),
|
|
23456
|
+
body: external_exports.string().describe(
|
|
23457
|
+
"Markdown. Lead each section with the failure, then the fix. End with the session ids and turn numbers this came from."
|
|
23458
|
+
),
|
|
23459
|
+
key: external_exports.string().optional().describe("The candidate key from pantheon_handoff, so it is not proposed again."),
|
|
23460
|
+
sessions: external_exports.number().optional().describe("How many conversations back this up.")
|
|
23461
|
+
},
|
|
23462
|
+
async ({ space, name, when, body, key, sessions }) => safe(async () => {
|
|
23463
|
+
const saved = saveSkill(spaceRoot(home, space), { name, when, body, key, sessions }, "draft");
|
|
23464
|
+
const sync2 = await vault.push(home, `skill draft ${saved.name}`);
|
|
23465
|
+
return {
|
|
23466
|
+
ok: sync2.ok !== false,
|
|
23467
|
+
...saved,
|
|
23468
|
+
sync: sync2,
|
|
23469
|
+
note: sync2.ok === false ? `Draft saved locally but the push failed: ${sync2.error || "unknown error"}. Tell the human it is not yet in GitHub.` : `Saved as a draft. It is NOT active \u2014 no agent will be given it until the human promotes it from the space page. Tell them it is waiting for review.`
|
|
23470
|
+
};
|
|
23471
|
+
})
|
|
23472
|
+
);
|
|
23473
|
+
registerTool(
|
|
23474
|
+
server,
|
|
23475
|
+
"pantheon_dismiss_skill",
|
|
23476
|
+
"Record that the human does not want a skill written for a candidate pantheon_handoff proposed. Stops it being offered again.",
|
|
23477
|
+
{ space: external_exports.string(), key: external_exports.string() },
|
|
23478
|
+
async ({ space, key }) => safe(async () => {
|
|
23479
|
+
const done = dismissCandidate(spaceRoot(home, space), key);
|
|
23480
|
+
const sync2 = await vault.push(home, "dismiss skill candidate");
|
|
23481
|
+
return { ok: sync2.ok !== false, ...done, sync: sync2 };
|
|
23482
|
+
})
|
|
23483
|
+
);
|
|
23126
23484
|
server.registerPrompt(
|
|
23127
23485
|
"resume",
|
|
23128
23486
|
{
|
|
@@ -23166,18 +23524,18 @@ import { hostname as hostname2 } from "node:os";
|
|
|
23166
23524
|
|
|
23167
23525
|
// src/connect.ts
|
|
23168
23526
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
23169
|
-
import { existsSync as
|
|
23170
|
-
import { join as
|
|
23527
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, renameSync } from "node:fs";
|
|
23528
|
+
import { join as join7 } from "node:path";
|
|
23171
23529
|
|
|
23172
23530
|
// src/mcp-install.ts
|
|
23173
|
-
import { existsSync as
|
|
23531
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
23174
23532
|
import { homedir as homedir5 } from "node:os";
|
|
23175
|
-
import { dirname as dirname2, join as
|
|
23533
|
+
import { dirname as dirname2, join as join6 } from "node:path";
|
|
23176
23534
|
import { fileURLToPath } from "node:url";
|
|
23177
23535
|
var here = dirname2(fileURLToPath(import.meta.url));
|
|
23178
23536
|
function pantheonBin() {
|
|
23179
23537
|
const self = fileURLToPath(import.meta.url);
|
|
23180
|
-
if (self.endsWith(".ts")) return
|
|
23538
|
+
if (self.endsWith(".ts")) return join6(here, "../bin/pantheon.mjs");
|
|
23181
23539
|
return self;
|
|
23182
23540
|
}
|
|
23183
23541
|
function launchEnv(home) {
|
|
@@ -23200,16 +23558,16 @@ function mcpServer(home, withType = false) {
|
|
|
23200
23558
|
return server;
|
|
23201
23559
|
}
|
|
23202
23560
|
function readJson(path) {
|
|
23203
|
-
if (!
|
|
23561
|
+
if (!existsSync6(path)) return {};
|
|
23204
23562
|
try {
|
|
23205
|
-
return JSON.parse(
|
|
23563
|
+
return JSON.parse(readFileSync5(path, "utf8"));
|
|
23206
23564
|
} catch {
|
|
23207
23565
|
throw new Error(`Could not parse ${path}. Fix the JSON, then retry.`);
|
|
23208
23566
|
}
|
|
23209
23567
|
}
|
|
23210
23568
|
function writeJson(path, data) {
|
|
23211
|
-
|
|
23212
|
-
|
|
23569
|
+
mkdirSync5(dirname2(path), { recursive: true });
|
|
23570
|
+
writeFileSync5(path, `${JSON.stringify(data, null, 2)}
|
|
23213
23571
|
`);
|
|
23214
23572
|
}
|
|
23215
23573
|
function mergeMcpJson(path, home, server, key = "mcpServers") {
|
|
@@ -23223,20 +23581,20 @@ function tomlString(value) {
|
|
|
23223
23581
|
}
|
|
23224
23582
|
function chatgptDesktopPath() {
|
|
23225
23583
|
if (process.platform !== "darwin") return null;
|
|
23226
|
-
return
|
|
23584
|
+
return join6(homedir5(), "Library", "Application Support", "ChatGPT", "chatgpt_mcp_config.json");
|
|
23227
23585
|
}
|
|
23228
23586
|
function claudeDesktopPath() {
|
|
23229
23587
|
if (process.platform === "darwin") {
|
|
23230
|
-
return
|
|
23588
|
+
return join6(homedir5(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
23231
23589
|
}
|
|
23232
23590
|
if (process.platform === "win32") {
|
|
23233
|
-
return
|
|
23591
|
+
return join6(process.env.APPDATA || homedir5(), "Claude", "claude_desktop_config.json");
|
|
23234
23592
|
}
|
|
23235
|
-
return
|
|
23593
|
+
return join6(homedir5(), ".config", "Claude", "claude_desktop_config.json");
|
|
23236
23594
|
}
|
|
23237
23595
|
function upsertCodex(home) {
|
|
23238
|
-
const path =
|
|
23239
|
-
|
|
23596
|
+
const path = join6(homedir5(), ".codex", "config.toml");
|
|
23597
|
+
mkdirSync5(dirname2(path), { recursive: true });
|
|
23240
23598
|
const server = mcpServer(home);
|
|
23241
23599
|
const args = server.args.map(tomlString).join(", ");
|
|
23242
23600
|
const block2 = [
|
|
@@ -23249,21 +23607,21 @@ function upsertCodex(home) {
|
|
|
23249
23607
|
`PANTHEON_HOME = ${tomlString(home)}`,
|
|
23250
23608
|
""
|
|
23251
23609
|
].join("\n");
|
|
23252
|
-
if (!
|
|
23253
|
-
|
|
23610
|
+
if (!existsSync6(path)) {
|
|
23611
|
+
writeFileSync5(path, block2);
|
|
23254
23612
|
return;
|
|
23255
23613
|
}
|
|
23256
|
-
const existing =
|
|
23614
|
+
const existing = readFileSync5(path, "utf8");
|
|
23257
23615
|
if (existing.includes("[mcp_servers.pantheon]")) {
|
|
23258
23616
|
const next = existing.replace(
|
|
23259
23617
|
/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/,
|
|
23260
23618
|
block2.trim()
|
|
23261
23619
|
);
|
|
23262
|
-
|
|
23620
|
+
writeFileSync5(path, next.endsWith("\n") ? next : `${next}
|
|
23263
23621
|
`);
|
|
23264
23622
|
return;
|
|
23265
23623
|
}
|
|
23266
|
-
|
|
23624
|
+
writeFileSync5(path, `${existing.trimEnd()}
|
|
23267
23625
|
|
|
23268
23626
|
${block2}`);
|
|
23269
23627
|
}
|
|
@@ -23309,7 +23667,7 @@ Parse the rest of the argument as the fact. Only then call pantheon_remember, ev
|
|
|
23309
23667
|
}
|
|
23310
23668
|
];
|
|
23311
23669
|
function writeCodexSkill() {
|
|
23312
|
-
const dirs2 = [
|
|
23670
|
+
const dirs2 = [join6(homedir5(), ".agents", "skills", "pantheon"), join6(homedir5(), ".codex", "skills", "pantheon")];
|
|
23313
23671
|
const skill = `---
|
|
23314
23672
|
name: pantheon
|
|
23315
23673
|
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.
|
|
@@ -23333,17 +23691,17 @@ A **space** is the short name the human chose for a conscience. For handoff, par
|
|
|
23333
23691
|
For handoff, send the real thread: role user = what the human typed, role assistant = what you replied. Copy the words. Never write a third-person recap. Never label your replies as user. Attach every file you generated (PDFs, letters, CVs) as base64 artifacts \u2014 not just code fences. On resume, fetch listed artifacts with \`pantheon_get_artifact\`. Handoff commits and pushes; resume pulls. Do not run \`pantheon sync\` or \`pantheon handoff\` in a shell.
|
|
23334
23692
|
`;
|
|
23335
23693
|
for (const dir of dirs2) {
|
|
23336
|
-
|
|
23337
|
-
|
|
23694
|
+
mkdirSync5(dir, { recursive: true });
|
|
23695
|
+
writeFileSync5(join6(dir, "SKILL.md"), skill);
|
|
23338
23696
|
}
|
|
23339
23697
|
}
|
|
23340
23698
|
function writeSlashCommands() {
|
|
23341
|
-
const dirs2 = [
|
|
23699
|
+
const dirs2 = [join6(homedir5(), ".cursor", "commands"), join6(homedir5(), ".claude", "commands")];
|
|
23342
23700
|
for (const dir of dirs2) {
|
|
23343
|
-
|
|
23701
|
+
mkdirSync5(dir, { recursive: true });
|
|
23344
23702
|
for (const command of slashCommands) {
|
|
23345
|
-
|
|
23346
|
-
|
|
23703
|
+
writeFileSync5(
|
|
23704
|
+
join6(dir, `${command.name}.md`),
|
|
23347
23705
|
`---
|
|
23348
23706
|
description: ${command.description}
|
|
23349
23707
|
---
|
|
@@ -23366,33 +23724,33 @@ function installMcpClients(home) {
|
|
|
23366
23724
|
const written = [];
|
|
23367
23725
|
const skipped = [];
|
|
23368
23726
|
const server = mcpServer(home);
|
|
23369
|
-
const cursor =
|
|
23727
|
+
const cursor = join6(homedir5(), ".cursor", "mcp.json");
|
|
23370
23728
|
mergeMcpJson(cursor, home, server);
|
|
23371
23729
|
written.push({ name: "Cursor", detail: tilde(cursor) });
|
|
23372
|
-
const claudeCode =
|
|
23730
|
+
const claudeCode = join6(homedir5(), ".claude.json");
|
|
23373
23731
|
mergeMcpJson(claudeCode, home, mcpServer(home, true));
|
|
23374
23732
|
written.push({ name: "Claude Code", detail: tilde(claudeCode) });
|
|
23375
23733
|
const desktop = claudeDesktopPath();
|
|
23376
|
-
if (
|
|
23734
|
+
if (existsSync6(dirname2(desktop)) || process.platform === "darwin" || process.platform === "win32") {
|
|
23377
23735
|
mergeMcpJson(desktop, home, server);
|
|
23378
23736
|
written.push({ name: "Claude Desktop", detail: tilde(desktop) });
|
|
23379
23737
|
} else {
|
|
23380
23738
|
skipped.push({ name: "Claude Desktop", detail: "app not found" });
|
|
23381
23739
|
}
|
|
23382
23740
|
const chatgpt = chatgptDesktopPath();
|
|
23383
|
-
if (chatgpt &&
|
|
23741
|
+
if (chatgpt && existsSync6(dirname2(chatgpt))) {
|
|
23384
23742
|
mergeMcpJson(chatgpt, home, server);
|
|
23385
23743
|
written.push({ name: "ChatGPT.app", detail: tilde(chatgpt) });
|
|
23386
23744
|
}
|
|
23387
|
-
const codex =
|
|
23745
|
+
const codex = join6(homedir5(), ".codex", "config.toml");
|
|
23388
23746
|
try {
|
|
23389
23747
|
upsertCodex(home);
|
|
23390
23748
|
written.push({ name: "Codex", detail: tilde(codex) });
|
|
23391
23749
|
} catch {
|
|
23392
23750
|
skipped.push({ name: "Codex", detail: `could not write ${tilde(codex)}` });
|
|
23393
23751
|
}
|
|
23394
|
-
const windsurf =
|
|
23395
|
-
if (
|
|
23752
|
+
const windsurf = join6(homedir5(), ".codeium", "windsurf", "mcp_config.json");
|
|
23753
|
+
if (existsSync6(dirname2(windsurf))) {
|
|
23396
23754
|
mergeMcpJson(windsurf, home, server);
|
|
23397
23755
|
written.push({ name: "Windsurf", detail: tilde(windsurf) });
|
|
23398
23756
|
} else {
|
|
@@ -23410,7 +23768,7 @@ function installMcpClients(home) {
|
|
|
23410
23768
|
return { written, skipped };
|
|
23411
23769
|
}
|
|
23412
23770
|
function removeServerFromJson(path, key = "mcpServers") {
|
|
23413
|
-
if (!
|
|
23771
|
+
if (!existsSync6(path)) return false;
|
|
23414
23772
|
const current = readJson(path);
|
|
23415
23773
|
const servers = current[key] ?? {};
|
|
23416
23774
|
if (!servers.pantheon) return false;
|
|
@@ -23420,22 +23778,22 @@ function removeServerFromJson(path, key = "mcpServers") {
|
|
|
23420
23778
|
return true;
|
|
23421
23779
|
}
|
|
23422
23780
|
function removeCodex() {
|
|
23423
|
-
const path =
|
|
23424
|
-
if (!
|
|
23425
|
-
const existing =
|
|
23781
|
+
const path = join6(homedir5(), ".codex", "config.toml");
|
|
23782
|
+
if (!existsSync6(path)) return false;
|
|
23783
|
+
const existing = readFileSync5(path, "utf8");
|
|
23426
23784
|
if (!existing.includes("[mcp_servers.pantheon]")) return false;
|
|
23427
23785
|
const next = existing.replace(/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/, "").replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
23428
|
-
|
|
23786
|
+
writeFileSync5(path, next ? `${next}
|
|
23429
23787
|
` : "");
|
|
23430
23788
|
return true;
|
|
23431
23789
|
}
|
|
23432
23790
|
function removeSlashCommands() {
|
|
23433
|
-
const dirs2 = [
|
|
23791
|
+
const dirs2 = [join6(homedir5(), ".cursor", "commands"), join6(homedir5(), ".claude", "commands")];
|
|
23434
23792
|
let removed = 0;
|
|
23435
23793
|
for (const dir of dirs2) {
|
|
23436
23794
|
for (const command of slashCommands) {
|
|
23437
|
-
const file =
|
|
23438
|
-
if (!
|
|
23795
|
+
const file = join6(dir, `${command.name}.md`);
|
|
23796
|
+
if (!existsSync6(file)) continue;
|
|
23439
23797
|
unlinkSync2(file);
|
|
23440
23798
|
removed += 1;
|
|
23441
23799
|
}
|
|
@@ -23444,32 +23802,32 @@ function removeSlashCommands() {
|
|
|
23444
23802
|
}
|
|
23445
23803
|
function uninstallMcpClients() {
|
|
23446
23804
|
const removed = [];
|
|
23447
|
-
if (removeServerFromJson(
|
|
23448
|
-
if (removeServerFromJson(
|
|
23805
|
+
if (removeServerFromJson(join6(homedir5(), ".cursor", "mcp.json"))) removed.push("Cursor");
|
|
23806
|
+
if (removeServerFromJson(join6(homedir5(), ".claude.json"))) removed.push("Claude Code");
|
|
23449
23807
|
if (removeServerFromJson(claudeDesktopPath())) removed.push("Claude Desktop");
|
|
23450
23808
|
const chatgpt = chatgptDesktopPath();
|
|
23451
23809
|
if (chatgpt && removeServerFromJson(chatgpt)) removed.push("ChatGPT.app (shared MCP file)");
|
|
23452
23810
|
if (removeCodex()) removed.push("ChatGPT.app / Codex");
|
|
23453
|
-
if (removeServerFromJson(
|
|
23811
|
+
if (removeServerFromJson(join6(homedir5(), ".codeium", "windsurf", "mcp_config.json"))) {
|
|
23454
23812
|
removed.push("Windsurf");
|
|
23455
23813
|
}
|
|
23456
23814
|
const slash2 = removeSlashCommands();
|
|
23457
23815
|
if (slash2) removed.push("/pantheon-* commands");
|
|
23458
23816
|
for (const dir of [
|
|
23459
|
-
|
|
23460
|
-
|
|
23817
|
+
join6(homedir5(), ".agents", "skills", "pantheon"),
|
|
23818
|
+
join6(homedir5(), ".codex", "skills", "pantheon")
|
|
23461
23819
|
]) {
|
|
23462
|
-
const file =
|
|
23463
|
-
if (!
|
|
23820
|
+
const file = join6(dir, "SKILL.md");
|
|
23821
|
+
if (!existsSync6(file)) continue;
|
|
23464
23822
|
unlinkSync2(file);
|
|
23465
23823
|
removed.push("ChatGPT / Codex skill");
|
|
23466
23824
|
break;
|
|
23467
23825
|
}
|
|
23468
23826
|
for (const launcher of [
|
|
23469
|
-
|
|
23470
|
-
|
|
23827
|
+
join6(homedir5(), ".local", "bin", "pantheon-mcp"),
|
|
23828
|
+
join6(homedir5(), ".local", "bin", "pantheon-mcp.cmd")
|
|
23471
23829
|
]) {
|
|
23472
|
-
if (!
|
|
23830
|
+
if (!existsSync6(launcher)) continue;
|
|
23473
23831
|
unlinkSync2(launcher);
|
|
23474
23832
|
removed.push("pantheon-mcp launcher");
|
|
23475
23833
|
}
|
|
@@ -23548,10 +23906,10 @@ async function connect(opts) {
|
|
|
23548
23906
|
},
|
|
23549
23907
|
{ machineSecret: body.machineSecret }
|
|
23550
23908
|
);
|
|
23551
|
-
|
|
23909
|
+
mkdirSync6(home, { recursive: true });
|
|
23552
23910
|
const helper = credentialHelperCommand();
|
|
23553
23911
|
const quiet = { stdio: ["ignore", "pipe", "pipe"] };
|
|
23554
|
-
const fresh = !
|
|
23912
|
+
const fresh = !existsSync7(join7(home, ".git"));
|
|
23555
23913
|
let archived = "";
|
|
23556
23914
|
if (fresh) {
|
|
23557
23915
|
process.stdout.write(" Cloning the vault\u2026\n");
|
|
@@ -23593,7 +23951,7 @@ function syncVault2(home, cloneUrl, helper, quiet) {
|
|
|
23593
23951
|
git2("pull", "--ff-only");
|
|
23594
23952
|
return "";
|
|
23595
23953
|
} catch (error2) {
|
|
23596
|
-
if (!
|
|
23954
|
+
if (!existsSync7(join7(home, ".git"))) throw error2;
|
|
23597
23955
|
}
|
|
23598
23956
|
if (sharesHistory(home)) {
|
|
23599
23957
|
process.stdout.write(" Merging work from another machine\u2026\n");
|
|
@@ -23782,7 +24140,7 @@ function printSpaces() {
|
|
|
23782
24140
|
}
|
|
23783
24141
|
|
|
23784
24142
|
// src/status.ts
|
|
23785
|
-
import { existsSync as
|
|
24143
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
23786
24144
|
function printStatus() {
|
|
23787
24145
|
const stored = loadMachineConfig();
|
|
23788
24146
|
if (!stored) {
|
|
@@ -23796,7 +24154,7 @@ function printStatus() {
|
|
|
23796
24154
|
field("GitHub", config2.account),
|
|
23797
24155
|
field("Install", String(config2.installationId)),
|
|
23798
24156
|
field("Repo", `${config2.repo} (private)`),
|
|
23799
|
-
field("Vault", `${config2.home}${
|
|
24157
|
+
field("Vault", `${config2.home}${existsSync8(config2.home) ? "" : " (missing)"}`),
|
|
23800
24158
|
field("API", config2.apiUrl),
|
|
23801
24159
|
field("Machine", config2.machineId)
|
|
23802
24160
|
].join("\n")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Carry agent conscience between AI coding agents. Hand off a conversation in one agent, resume it in another.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"tsx": "^4.20.3",
|
|
31
31
|
"typescript": "^5",
|
|
32
32
|
"zod": "^3.25.67",
|
|
33
|
-
"@pantheon/
|
|
34
|
-
"@pantheon/
|
|
33
|
+
"@pantheon/mcp": "0.1.0",
|
|
34
|
+
"@pantheon/core": "0.1.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"start": "tsx src/index.ts",
|