pantheon-cli 0.2.27 → 0.2.29

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.
Files changed (2) hide show
  1. package/dist/pantheon.mjs +487 -39
  2. package/package.json +3 -3
package/dist/pantheon.mjs CHANGED
@@ -8585,12 +8585,12 @@ ZodString.create = (params) => {
8585
8585
  ...processCreateParams(params)
8586
8586
  });
8587
8587
  };
8588
- function floatSafeRemainder(val, step) {
8588
+ function floatSafeRemainder(val, step2) {
8589
8589
  const valDecCount = (val.toString().split(".")[1] || "").length;
8590
- const stepDecCount = (step.toString().split(".")[1] || "").length;
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(step.toFixed(decCount).replace(".", ""));
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, step) {
11224
+ function floatSafeRemainder2(val, step2) {
11225
11225
  const valDecCount = (val.toString().split(".")[1] || "").length;
11226
- const stepDecCount = (step.toString().split(".")[1] || "").length;
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(step.toFixed(decCount).replace(".", ""));
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(["cd", "ls", "cat", "echo", "pwd", "which", "true", "false", "clear"]);
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 (!head || NOISE.has(head)) return null;
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 mentioned = mentionedDocuments(turns).map((doc) => doc.name);
22438
- if (!mentioned.length) return null;
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 = mentioned.filter((name) => !attached.has(artifactKey(name).toLowerCase()));
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
 
@@ -23397,7 +23660,7 @@ async function fetchShares(apiUrl, auth) {
23397
23660
  if (!Array.isArray(body.shares)) throw new Error("Could not read the share list.");
23398
23661
  return body.shares;
23399
23662
  }
23400
- async function pullShares(home) {
23663
+ async function pullShares(home, options = {}) {
23401
23664
  const stored = loadMachineConfig();
23402
23665
  if (!stored) return { ok: false, spaces: 0, fetched: 0, error: "Not connected." };
23403
23666
  const auth = `Bearer ${stored.config.machineId}.${stored.credentials.machineSecret}`;
@@ -23442,16 +23705,20 @@ async function pullShares(home) {
23442
23705
  prune(spaceDir2, spaceDir2, wanted);
23443
23706
  }
23444
23707
  let fetched = 0;
23708
+ let finished = 0;
23709
+ options.onProgress?.(0, jobs.length);
23445
23710
  await pool(jobs, async (job) => {
23446
23711
  const url = `${stored.config.apiUrl}/api/cli/shares/${encodeURIComponent(job.owner)}/${encodeURIComponent(job.slug)}?path=${encodeURIComponent(job.relative)}`;
23447
23712
  const res = await fetch(url, { headers: { authorization: auth } }).catch(() => null);
23448
23713
  if (!res?.ok) {
23449
23714
  delete next[job.key];
23715
+ options.onProgress?.(finished += 1, jobs.length);
23450
23716
  return;
23451
23717
  }
23452
23718
  mkdirSync5(dirname2(job.dest), { recursive: true });
23453
23719
  writeFileSync5(job.dest, Buffer.from(await res.arrayBuffer()));
23454
23720
  fetched += 1;
23721
+ options.onProgress?.(finished += 1, jobs.length);
23455
23722
  });
23456
23723
  for (const owner of dirNames(root)) {
23457
23724
  for (const slug of dirNames(join6(root, owner))) {
@@ -23886,10 +24153,15 @@ ${GUIDE}` }]
23886
24153
  "Markdown. Lead each section with the failure, then the fix. End with the session ids and turn numbers this came from."
23887
24154
  ),
23888
24155
  key: external_exports.string().optional().describe("The candidate key from pantheon_handoff, so it is not proposed again."),
23889
- 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
+ )
23890
24160
  },
23891
- async ({ space, name, when, body, key, sessions }) => safe(async () => {
23892
- const saved = saveSkill(writeRoot(home, space), { name, when, body, key, sessions }, "draft");
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");
23893
24165
  const sync2 = await vault.push(home, `skill draft ${saved.name}`);
23894
24166
  return {
23895
24167
  ok: sync2.ok !== false,
@@ -23899,6 +24171,13 @@ ${GUIDE}` }]
23899
24171
  };
23900
24172
  })
23901
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
+ );
23902
24181
  registerTool(
23903
24182
  server,
23904
24183
  "pantheon_dismiss_skill",
@@ -24176,6 +24455,19 @@ Only then call pantheon_park, even if the slug is new. If you send a transcript,
24176
24455
  body: `${spaceGate}
24177
24456
 
24178
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.`
24179
24471
  },
24180
24472
  {
24181
24473
  name: "pantheon-spaces",
@@ -24192,7 +24484,7 @@ function writeCodexSkill() {
24192
24484
  const dirs2 = [join7(homedir5(), ".agents", "skills", "pantheon"), join7(homedir5(), ".codex", "skills", "pantheon")];
24193
24485
  const skill = `---
24194
24486
  name: pantheon
24195
- 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.
24196
24488
  ---
24197
24489
 
24198
24490
  # Pantheon
@@ -24206,6 +24498,7 @@ Grounding: the only space list is the \`pantheon_list_spaces\` tool result. Neve
24206
24498
  - \`/pantheon-park <space>\` \u2192 MCP tool \`pantheon_park\`
24207
24499
  - \`/pantheon-remember <space> <fact>\` \u2192 MCP tool \`pantheon_remember\`
24208
24500
  - \`/pantheon-spaces\` \u2192 MCP tool \`pantheon_list_spaces\`
24501
+ - \`/pantheon-skills <space>\` \u2192 MCP tool \`pantheon_skill_review\`
24209
24502
  - \`/pantheon-help\` \u2192 MCP tool \`pantheon_help\`
24210
24503
 
24211
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.
@@ -24252,6 +24545,13 @@ sentences drawn from the packet; any open threads; and the available skills by
24252
24545
  name and trigger. The table only proves the load worked. It says nothing about
24253
24546
  where the work was, which is the part the human asked for, so never fold that
24254
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\`.
24255
24555
  `;
24256
24556
  for (const dir of dirs2) {
24257
24557
  mkdirSync6(dir, { recursive: true });
@@ -24462,6 +24762,109 @@ function installMcpFromConfig() {
24462
24762
  return { ...installMcpClients(stored.config.home), apiUrl: stored.config.apiUrl };
24463
24763
  }
24464
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
+
24465
24868
  // src/report.ts
24466
24869
  var LABEL = 12;
24467
24870
  var NAME = 22;
@@ -24495,7 +24898,7 @@ function candidateHosts(explicit) {
24495
24898
  async function connect(opts) {
24496
24899
  const home = opts.home || defaultHome();
24497
24900
  const code = opts.code.replace(/\s/g, "").toUpperCase();
24498
- process.stdout.write(" Verifying pairing code\u2026\n");
24901
+ const pairing = step("Verifying pairing code");
24499
24902
  let body = null;
24500
24903
  let apiUrl = "";
24501
24904
  let lastError = "Pair failed";
@@ -24520,7 +24923,11 @@ async function connect(opts) {
24520
24923
  lastError = `Could not reach ${host}`;
24521
24924
  }
24522
24925
  }
24523
- if (!body) throw new Error(lastError);
24926
+ if (!body) {
24927
+ pairing.fail();
24928
+ throw new Error(lastError);
24929
+ }
24930
+ pairing.done(body.account);
24524
24931
  saveMachineConfig(
24525
24932
  {
24526
24933
  home,
@@ -24539,10 +24946,9 @@ async function connect(opts) {
24539
24946
  const fresh = !existsSync8(join8(home, ".git"));
24540
24947
  let archived = "";
24541
24948
  if (fresh) {
24542
- process.stdout.write(" Cloning the vault\u2026\n");
24543
- execFileSync3("git", [...auth, "clone", body.cloneUrl, home], quiet);
24949
+ await clone2(body.cloneUrl, home, auth, "Cloning the vault");
24544
24950
  } else {
24545
- archived = syncVault2(home, body.cloneUrl, auth, quiet);
24951
+ archived = await syncVault2(home, body.cloneUrl, auth, quiet);
24546
24952
  }
24547
24953
  claimCredentials(home, quiet);
24548
24954
  execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
@@ -24577,27 +24983,55 @@ async function connect(opts) {
24577
24983
  )
24578
24984
  );
24579
24985
  }
24580
- function syncVault2(home, cloneUrl, auth, quiet) {
24581
- const git2 = (...args) => execFileSync3("git", [...auth, "-C", home, ...args], quiet);
24986
+ async function syncVault2(home, cloneUrl, auth, quiet) {
24582
24987
  retarget(home, cloneUrl, quiet);
24988
+ const updating = step("Updating the vault");
24583
24989
  try {
24584
- git2("pull", "--ff-only");
24990
+ execFileSync3("git", [...auth, "-C", home, "pull", "--ff-only"], quiet);
24991
+ updating.done();
24585
24992
  return "";
24586
24993
  } catch (error2) {
24587
- if (!existsSync8(join8(home, ".git"))) throw error2;
24994
+ if (!existsSync8(join8(home, ".git"))) {
24995
+ updating.fail();
24996
+ throw error2;
24997
+ }
24588
24998
  }
24589
24999
  if (sharesHistory(home)) {
24590
- process.stdout.write(" Merging work from another machine\u2026\n");
24591
- git2("pull", "--no-rebase", "--no-edit");
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");
24592
25011
  return "";
24593
25012
  }
24594
25013
  const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
24595
25014
  const archive = `${home}-${stamp2}`;
24596
- process.stdout.write(" Vault belongs to a different repo; setting it aside\u2026\n");
25015
+ updating.done("belongs to a different account");
24597
25016
  renameSync2(home, archive);
24598
- execFileSync3("git", [...auth, "clone", cloneUrl, home], quiet);
25017
+ const aside = step("Setting the old vault aside");
25018
+ aside.done(archive);
25019
+ await clone2(cloneUrl, home, auth, "Cloning the new vault");
24599
25020
  return archive;
24600
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
+ }
24601
25035
  function retarget(home, cloneUrl, quiet) {
24602
25036
  try {
24603
25037
  execFileSync3("git", ["-C", home, "remote", "set-url", "origin", cloneUrl], quiet);
@@ -24693,8 +25127,8 @@ async function bootstrapFromToken(token, opts = {}) {
24693
25127
  { machineSecret: body.machineSecret }
24694
25128
  );
24695
25129
  const vaultToken = await mintVaultToken(apiUrl, body.machineId, body.machineSecret);
24696
- const clone2 = ensureVaultClone(home, body.cloneUrl, vaultToken);
24697
- if (!clone2.ok) throw new Error(clone2.error || "Could not clone the vault.");
25130
+ const clone3 = ensureVaultClone(home, body.cloneUrl, vaultToken);
25131
+ if (!clone3.ok) throw new Error(clone3.error || "Could not clone the vault.");
24698
25132
  try {
24699
25133
  installAgentAssets();
24700
25134
  } catch {
@@ -24826,21 +25260,35 @@ function printStatus() {
24826
25260
  async function sync() {
24827
25261
  const stored = loadMachineConfig();
24828
25262
  if (!stored) throw new Error("Not connected. Run pantheon connect <code> first.");
25263
+ const vault = step("Syncing the vault");
24829
25264
  const result = await syncVault(stored.config.home, { push: true, message: "pantheon sync" });
24830
- if (!result.ok) throw new Error(result.error || "Sync failed");
25265
+ if (!result.ok) {
25266
+ vault.fail();
25267
+ throw new Error(result.error || "Sync failed");
25268
+ }
24831
25269
  const bits = [
24832
25270
  result.committed ? "committed" : "clean",
24833
25271
  result.pulled ? "pulled" : null,
24834
25272
  result.pushed ? "pushed" : null
24835
25273
  ].filter(Boolean);
24836
- console.log(` Vault ${bits.join(", ")}`);
24837
- const shared = await pullShares(stored.config.home);
24838
- if (shared.ok && shared.spaces) {
24839
- const detail = shared.fetched ? `${shared.fetched} files fetched` : "up to date";
24840
- console.log(` Shared ${shared.spaces} ${shared.spaces === 1 ? "space" : "spaces"}, ${detail}`);
24841
- } else if (!shared.ok) {
24842
- console.log(` Shared could not refresh \u2014 ${shared.error}`);
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;
24843
25289
  }
25290
+ const detail = pull.fetched ? `${pull.fetched} files fetched` : "up to date";
25291
+ shared.done(`${pull.spaces} ${pull.spaces === 1 ? "space" : "spaces"}, ${detail}`);
24844
25292
  }
24845
25293
 
24846
25294
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
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/core": "0.1.0",
34
- "@pantheon/mcp": "0.1.0"
33
+ "@pantheon/mcp": "0.1.0",
34
+ "@pantheon/core": "0.1.0"
35
35
  },
36
36
  "scripts": {
37
37
  "start": "tsx src/index.ts",