pantheon-cli 0.1.2 → 0.2.2

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 +485 -113
  2. package/package.json +1 -1
package/dist/pantheon.mjs CHANGED
@@ -3655,49 +3655,49 @@ var require_fast_uri = __commonJS({
3655
3655
  schemelessOptions.skipEscape = true;
3656
3656
  return serialize(resolved, schemelessOptions);
3657
3657
  }
3658
- function resolveComponent(base, relative, options, skipNormalization) {
3658
+ function resolveComponent(base, relative2, options, skipNormalization) {
3659
3659
  const target = {};
3660
3660
  if (!skipNormalization) {
3661
3661
  base = parse3(serialize(base, options), options);
3662
- relative = parse3(serialize(relative, options), options);
3662
+ relative2 = parse3(serialize(relative2, options), options);
3663
3663
  }
3664
3664
  options = options || {};
3665
- if (!options.tolerant && relative.scheme) {
3666
- target.scheme = relative.scheme;
3667
- target.userinfo = relative.userinfo;
3668
- target.host = relative.host;
3669
- target.port = relative.port;
3670
- target.path = removeDotSegments(relative.path || "");
3671
- target.query = relative.query;
3665
+ if (!options.tolerant && relative2.scheme) {
3666
+ target.scheme = relative2.scheme;
3667
+ target.userinfo = relative2.userinfo;
3668
+ target.host = relative2.host;
3669
+ target.port = relative2.port;
3670
+ target.path = removeDotSegments(relative2.path || "");
3671
+ target.query = relative2.query;
3672
3672
  } else {
3673
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
3674
- target.userinfo = relative.userinfo;
3675
- target.host = relative.host;
3676
- target.port = relative.port;
3677
- target.path = removeDotSegments(relative.path || "");
3678
- target.query = relative.query;
3673
+ if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
3674
+ target.userinfo = relative2.userinfo;
3675
+ target.host = relative2.host;
3676
+ target.port = relative2.port;
3677
+ target.path = removeDotSegments(relative2.path || "");
3678
+ target.query = relative2.query;
3679
3679
  } else {
3680
- if (!relative.path) {
3680
+ if (!relative2.path) {
3681
3681
  target.path = base.path;
3682
- if (relative.query !== void 0) {
3683
- target.query = relative.query;
3682
+ if (relative2.query !== void 0) {
3683
+ target.query = relative2.query;
3684
3684
  } else {
3685
3685
  target.query = base.query;
3686
3686
  }
3687
3687
  } else {
3688
- if (relative.path[0] === "/") {
3689
- target.path = removeDotSegments(relative.path);
3688
+ if (relative2.path[0] === "/") {
3689
+ target.path = removeDotSegments(relative2.path);
3690
3690
  } else {
3691
3691
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3692
- target.path = "/" + relative.path;
3692
+ target.path = "/" + relative2.path;
3693
3693
  } else if (!base.path) {
3694
- target.path = relative.path;
3694
+ target.path = relative2.path;
3695
3695
  } else {
3696
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3696
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
3697
3697
  }
3698
3698
  target.path = removeDotSegments(target.path);
3699
3699
  }
3700
- target.query = relative.query;
3700
+ target.query = relative2.query;
3701
3701
  }
3702
3702
  target.userinfo = base.userinfo;
3703
3703
  target.host = base.host;
@@ -3705,7 +3705,7 @@ var require_fast_uri = __commonJS({
3705
3705
  }
3706
3706
  target.scheme = base.scheme;
3707
3707
  }
3708
- target.fragment = relative.fragment;
3708
+ target.fragment = relative2.fragment;
3709
3709
  return target;
3710
3710
  }
3711
3711
  function equal(uriA, uriB, options) {
@@ -21272,10 +21272,10 @@ import {
21272
21272
  appendFileSync
21273
21273
  } from "node:fs";
21274
21274
  import { homedir as homedir2 } from "node:os";
21275
- import { basename as basename2, join as join2, resolve } from "node:path";
21275
+ import { basename as basename2, isAbsolute, join as join2, relative, resolve } from "node:path";
21276
21276
 
21277
21277
  // ../core/src/transcripts.ts
21278
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
21278
+ import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
21279
21279
  import { homedir } from "node:os";
21280
21280
  import { basename, join } from "node:path";
21281
21281
  var MAX_SCAN = 60;
@@ -21319,12 +21319,12 @@ function files(path) {
21319
21319
  return [];
21320
21320
  }
21321
21321
  }
21322
- function pathSlug(cwd) {
21323
- return cwd.replace(/^[/\\]+/, "").replace(/[/\\]/g, "-");
21322
+ function projectKey(value) {
21323
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
21324
21324
  }
21325
21325
  function sameWorkspace(a, b) {
21326
21326
  if (!a || !b) return false;
21327
- const norm = (value) => value.replace(/\/+$/, "").toLowerCase();
21327
+ const norm = (value) => value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
21328
21328
  return norm(a) === norm(b);
21329
21329
  }
21330
21330
  function textOf(value) {
@@ -21345,8 +21345,8 @@ function cursorRoot() {
21345
21345
  function cursorSessions(cwd) {
21346
21346
  const root = cursorRoot();
21347
21347
  if (!existsSync(root)) return [];
21348
- const wanted = cwd ? pathSlug(cwd) : "";
21349
- const projects = dirs(root).filter((name) => wanted ? name === wanted : true);
21348
+ const wanted = cwd ? projectKey(cwd) : "";
21349
+ const projects = dirs(root).filter((name) => wanted ? projectKey(name) === wanted : true);
21350
21350
  const found = [];
21351
21351
  for (const project of projects) {
21352
21352
  const base = join(root, project, "agent-transcripts");
@@ -21357,7 +21357,7 @@ function cursorSessions(cwd) {
21357
21357
  source: "cursor",
21358
21358
  key: `cursor-${id}`,
21359
21359
  path,
21360
- cwd: project === wanted ? cwd : void 0,
21360
+ cwd: wanted && projectKey(project) === wanted ? cwd : void 0,
21361
21361
  updatedAt: iso(mtime(path))
21362
21362
  });
21363
21363
  }
@@ -21517,11 +21517,10 @@ function claudeRoot() {
21517
21517
  function claudeSessions(cwd) {
21518
21518
  const root = claudeRoot();
21519
21519
  if (!existsSync(root)) return [];
21520
- const wanted = cwd ? pathSlug(cwd).toLowerCase() : "";
21520
+ const wanted = cwd ? projectKey(cwd) : "";
21521
21521
  const found = [];
21522
21522
  for (const project of dirs(root)) {
21523
- const normalized = project.replace(/^-+/, "").toLowerCase();
21524
- if (wanted && normalized !== wanted) continue;
21523
+ if (wanted && projectKey(project) !== wanted) continue;
21525
21524
  for (const name of files(join(root, project))) {
21526
21525
  if (!name.endsWith(".jsonl")) continue;
21527
21526
  const path = join(root, project, name);
@@ -21591,6 +21590,52 @@ function discoverLocalSessions(opts = {}) {
21591
21590
  function readLocalSession(session) {
21592
21591
  return readers[session.source](session.path);
21593
21592
  }
21593
+ var HINT_TAIL_BYTES = 256 * 1024;
21594
+ function tail(path, bytes = HINT_TAIL_BYTES) {
21595
+ try {
21596
+ const size = statSync(path).size;
21597
+ const length = Math.min(size, bytes);
21598
+ if (!length) return "";
21599
+ const fd = openSync(path, "r");
21600
+ try {
21601
+ const buf = Buffer.alloc(length);
21602
+ readSync(fd, buf, 0, length, size - length);
21603
+ return buf.toString("utf8");
21604
+ } finally {
21605
+ closeSync(fd);
21606
+ }
21607
+ } catch {
21608
+ return "";
21609
+ }
21610
+ }
21611
+ function describe(session, mentionsHint) {
21612
+ const turns = readLocalSession(session);
21613
+ const spoken = [...turns].reverse().find((turn) => turn.role === "user" && turn.text.trim());
21614
+ return {
21615
+ key: session.key,
21616
+ source: session.source,
21617
+ turns: turns.length,
21618
+ updatedAt: session.updatedAt,
21619
+ lastMessage: spoken ? spoken.text.replace(/\s+/g, " ").trim().slice(0, 140) : null,
21620
+ mentionsHint
21621
+ };
21622
+ }
21623
+ function ambiguousCapture(opts = {}) {
21624
+ const needle = opts.hint?.trim().toLowerCase();
21625
+ if (!needle || needle.length < 3) return null;
21626
+ const cwd = opts.cwd || process.cwd();
21627
+ const scoped = discoverLocalSessions({ cwd, source: opts.source });
21628
+ const candidates = (scoped.length ? scoped : discoverLocalSessions({ source: opts.source })).slice(
21629
+ 0,
21630
+ MAX_SCAN
21631
+ );
21632
+ if (candidates.length < 2) return null;
21633
+ const [newest, ...rest2] = candidates;
21634
+ if (tail(newest.path).toLowerCase().includes(needle)) return null;
21635
+ const named = rest2.filter((session) => tail(session.path).toLowerCase().includes(needle));
21636
+ if (!named.length) return null;
21637
+ return [...named.slice(0, 3).map((s) => describe(s, true)), describe(newest, false)];
21638
+ }
21594
21639
  function captureLocalTranscript(opts = {}) {
21595
21640
  const { sessionKey, minTurns = 2 } = opts;
21596
21641
  const cwd = opts.cwd || process.cwd();
@@ -21784,10 +21829,54 @@ function pathsFromPatch(input) {
21784
21829
  }
21785
21830
  return found;
21786
21831
  }
21787
- var SKIP_PATH = /(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|\.turbo)(\/|$)|\.(lock|log)$|lock\.(json|yaml)$/;
21788
- var MAX_WRITTEN_FILE = 512 * 1024;
21789
- var MAX_WRITTEN_TOTAL = 8 * 1024 * 1024;
21832
+ var slash = (path) => path.replace(/\\/g, "/");
21833
+ function toFull(path, from) {
21834
+ const expanded = /^~[\\/]/.test(path) ? join2(homedir2(), path.slice(2)) : path;
21835
+ return slash(isAbsolute(expanded) ? resolve(expanded) : resolve(from, expanded));
21836
+ }
21837
+ function inside(base, full) {
21838
+ const rel = relative(base, full);
21839
+ return Boolean(rel) && !rel.startsWith("..") && !isAbsolute(rel);
21840
+ }
21841
+ var SKIP_PATH = /(^|\/)(node_modules|\.git|\.next|coverage|\.turbo)(\/|$)|\.(lock|log|db|sqlite3?|map)$|lock\.(json|yaml)$/;
21842
+ var BUILD_DIR = /(^|\/)(dist|build|out)(\/|$)/;
21843
+ var DELIVERABLE = /\.(png|jpe?g|gif|webp|avif|svg|mp4|mov|webm|mp3|wav|pdf|csv|xlsx?|docx?|pptx?|zip)$/i;
21844
+ var SECRET_PATH = /(^|\/)(\.env(\.[\w-]+)*|\.npmrc|\.netrc|\.pgpass|id_(rsa|dsa|ecdsa|ed25519)|(credentials|secrets?)(\.[\w-]+)?)$|\.(pem|key|p12|pfx|keystore|jks)$/i;
21845
+ var MAX_WRITTEN_FILE = 8 * 1024 * 1024;
21846
+ var MAX_WRITTEN_TOTAL = 24 * 1024 * 1024;
21790
21847
  var MAX_WRITTEN_COUNT = 200;
21848
+ var MAX_SKIP_REPORT = 12;
21849
+ function pathsFromText(text2) {
21850
+ const found = [];
21851
+ const cleaned = text2.replace(/\b[a-z][a-z0-9+.-]*:\/\/\S+/gi, " ");
21852
+ for (const raw of cleaned.split(/[\s'"`;|&$(){}[\],]+/)) {
21853
+ const token = raw.replace(/^[-=@]+/, "").replace(/[.,:;]+$/, "");
21854
+ if (!token || token.length > 200) continue;
21855
+ if (!/^([a-zA-Z]:)?[\w./\\@~+-]+$/.test(token)) continue;
21856
+ if (!/\.[a-zA-Z][a-zA-Z0-9]{0,7}$/.test(token)) continue;
21857
+ found.push(token);
21858
+ }
21859
+ return found;
21860
+ }
21861
+ function inputText(input) {
21862
+ if (typeof input === "string") return input;
21863
+ if (!input || typeof input !== "object") return "";
21864
+ try {
21865
+ return JSON.stringify(input);
21866
+ } catch {
21867
+ return "";
21868
+ }
21869
+ }
21870
+ var CWD_KEYS = ["working_directory", "workdir", "work_dir", "cwd", "directory"];
21871
+ function callBase(input, base) {
21872
+ const record2 = input && typeof input === "object" ? input : null;
21873
+ const declared = record2 ? CWD_KEYS.map((key) => record2[key]).find(
21874
+ (value) => typeof value === "string" && value.trim().length > 0
21875
+ ) : void 0;
21876
+ const walked = inputText(input).match(/(?:^|[\s"'`;&|])cd\s+(([a-zA-Z]:)?[\w./\\@~-]+)\s*(?:&&|;)/);
21877
+ const dir = declared?.trim() || walked?.[1];
21878
+ return dir ? toFull(dir, base) : base;
21879
+ }
21791
21880
  function pathFromInput(input) {
21792
21881
  if (!input || typeof input !== "object") return null;
21793
21882
  const record2 = input;
@@ -21798,8 +21887,8 @@ function pathFromInput(input) {
21798
21887
  return null;
21799
21888
  }
21800
21889
  function flatName(path, base) {
21801
- const relative = path.startsWith(base) ? path.slice(base.length) : path;
21802
- return relative.replace(/^[./]+/, "").replace(/[^a-zA-Z0-9._/-]/g, "_").replace(/\//g, "_");
21890
+ const rel = inside(base, path) ? relative(base, path) : path;
21891
+ return slash(rel).replace(/^[a-zA-Z]:/, "").replace(/^[./]+/, "").replace(/[^a-zA-Z0-9._/-]/g, "_").replace(/\//g, "_");
21803
21892
  }
21804
21893
  function readArtifactFile(path, base) {
21805
21894
  const stat = statSync2(path);
@@ -21813,44 +21902,85 @@ function readArtifactFile(path, base) {
21813
21902
  bytes: stat.size
21814
21903
  };
21815
21904
  }
21816
- function collectWrittenArtifacts(turns, cwd = process.cwd()) {
21817
- const base = cwd.endsWith("/") ? cwd : `${cwd}/`;
21818
- const latest = /* @__PURE__ */ new Set();
21819
- const add = (path) => {
21820
- const full = path.startsWith("/") ? path : join2(base, path);
21821
- if (!SKIP_PATH.test(full)) latest.add(full);
21905
+ function collectWrittenArtifacts(turns, cwd = process.cwd(), opts = {}) {
21906
+ const base = slash(resolve(cwd));
21907
+ const since = opts.since ?? null;
21908
+ const vault = opts.home ? slash(resolve(opts.home)) : null;
21909
+ const written = /* @__PURE__ */ new Set();
21910
+ const touched = /* @__PURE__ */ new Set();
21911
+ const add = (into, path, from = base) => {
21912
+ const full = toFull(path, from);
21913
+ if (SKIP_PATH.test(full) || SECRET_PATH.test(full)) return;
21914
+ if (BUILD_DIR.test(full) && !DELIVERABLE.test(full)) return;
21915
+ if (vault && inside(vault, full)) return;
21916
+ if (into === touched && !inside(base, full)) return;
21917
+ into.add(full);
21822
21918
  };
21823
21919
  for (const turn of turns) {
21824
21920
  for (const call of turn.toolCalls ?? []) {
21825
- if (!WRITE_TOOL.test(call.name || "")) continue;
21826
- const path = pathFromInput(call.input);
21827
- if (path) add(path);
21828
- for (const patched of pathsFromPatch(call.input)) add(patched);
21921
+ if (WRITE_TOOL.test(call.name || "")) {
21922
+ const path = pathFromInput(call.input);
21923
+ if (path) add(written, path);
21924
+ for (const patched of pathsFromPatch(call.input)) add(written, patched);
21925
+ continue;
21926
+ }
21927
+ if (since === null) continue;
21928
+ const from = callBase(call.input, base);
21929
+ for (const named of pathsFromText(inputText(call.input))) add(touched, named, from);
21829
21930
  }
21830
21931
  }
21831
21932
  const found = [];
21933
+ const skipped = [];
21832
21934
  let total = 0;
21833
- for (const path of latest) {
21834
- if (found.length >= MAX_WRITTEN_COUNT || total >= MAX_WRITTEN_TOTAL) break;
21935
+ const note = (path, reason) => {
21936
+ if (skipped.length < MAX_SKIP_REPORT) skipped.push({ name: flatName(path, base), reason });
21937
+ };
21938
+ const store = (path, gate) => {
21939
+ if (!existsSync2(path)) return;
21940
+ const stat = statSync2(path);
21941
+ if (!stat.isFile() || stat.size === 0) return;
21942
+ if (gate && since !== null && stat.mtimeMs < since) return;
21943
+ if (stat.size > MAX_WRITTEN_FILE) {
21944
+ note(
21945
+ path,
21946
+ `${Math.round(stat.size / 1024)}KB, over the ${MAX_WRITTEN_FILE / 1024 / 1024}MB per-file limit`
21947
+ );
21948
+ return;
21949
+ }
21950
+ if (found.length >= MAX_WRITTEN_COUNT || total + stat.size > MAX_WRITTEN_TOTAL) {
21951
+ note(path, "this handoff's artifact budget was full");
21952
+ return;
21953
+ }
21954
+ const file = readArtifactFile(path, base);
21955
+ if (!file) return;
21956
+ total += file.bytes;
21957
+ found.push({ name: file.name, content: file.content, encoding: file.encoding });
21958
+ };
21959
+ for (const path of written) {
21835
21960
  try {
21836
- if (!existsSync2(path)) continue;
21837
- const file = readArtifactFile(path, base);
21838
- if (!file) continue;
21839
- total += file.bytes;
21840
- found.push({ name: file.name, content: file.content, encoding: file.encoding });
21961
+ store(path, false);
21841
21962
  } catch {
21842
21963
  }
21843
21964
  }
21844
- return found;
21965
+ for (const path of touched) {
21966
+ if (written.has(path)) continue;
21967
+ try {
21968
+ store(path, true);
21969
+ } catch {
21970
+ }
21971
+ }
21972
+ return { artifacts: found, skipped };
21845
21973
  }
21846
21974
  function collectAttachedArtifacts(turns, cwd = process.cwd()) {
21847
- const base = cwd.endsWith("/") ? cwd : `${cwd}/`;
21975
+ const base = slash(resolve(cwd));
21848
21976
  const paths = /* @__PURE__ */ new Set();
21849
21977
  for (const turn of turns) {
21850
21978
  if (turn.role !== "user") continue;
21851
- for (const match of (turn.text || "").matchAll(/(?:^|[\s"'`(@])(\/[\w./@ -]*\/[\w.@-]+\.[a-zA-Z0-9]{1,16})/g)) {
21852
- const path = match[1].trim();
21853
- if (!SKIP_PATH.test(path)) paths.add(path);
21979
+ for (const match of (turn.text || "").matchAll(
21980
+ /(?:^|[\s"'`(@])((?:[a-zA-Z]:[\\/]|\/)[\w.\\/@ -]*[\\/][\w.@-]+\.[a-zA-Z0-9]{1,16})/g
21981
+ )) {
21982
+ const full = slash(match[1].trim());
21983
+ if (!SKIP_PATH.test(full) && !SECRET_PATH.test(full)) paths.add(full);
21854
21984
  }
21855
21985
  }
21856
21986
  const found = [];
@@ -21878,12 +22008,38 @@ function missingGeneratedFiles(turns, artifacts = []) {
21878
22008
  }
21879
22009
  var PACKET_TURNS = 14;
21880
22010
  var PACKET_TURN_CHARS = 400;
21881
- function distill(space, source, turns, summary, artifacts, sessionId) {
22011
+ function sessionLine(session, current) {
22012
+ const detail = [session.source, session.updatedAt && `updated ${session.updatedAt}`].filter(Boolean).join(", ");
22013
+ return `- ${session.id} \u2014 ${session.turns} turns${detail ? ` (${detail})` : ""}${current ? " \u2190 this packet" : ""}`;
22014
+ }
22015
+ function fullHistory(slug, turns, sessionId, sessions) {
22016
+ const total = sessions.reduce((sum, session) => sum + session.turns, 0) || turns;
22017
+ const archive = `spaces/${slug}/sessions/${sessionId}/transcript.jsonl`;
22018
+ const lines = [
22019
+ "## Full history",
22020
+ `This session is archived verbatim \u2014 ${turns} turns including tool calls.`,
22021
+ `Archive: ${archive}`
22022
+ ];
22023
+ if (sessions.length > 1) {
22024
+ lines.push(
22025
+ "",
22026
+ `This space holds ${total} turns across ${sessions.length} sessions. This packet covers one of them, so it is not the whole story.`,
22027
+ ...sessions.map((session) => sessionLine(session, session.id === sessionId))
22028
+ );
22029
+ }
22030
+ lines.push(
22031
+ "",
22032
+ `Search the whole space before deciding something is missing: pantheon_search (space: ${slug}, query: "<topic>") \u2014 it reads tool calls as well as messages.`,
22033
+ `Then pantheon_get_turns (space, session_id, from, to) for a range, or pantheon_get_session for one session end to end.`
22034
+ );
22035
+ return lines;
22036
+ }
22037
+ function distill(input) {
22038
+ const { space, source, turns, summary, artifacts, sessionId, sessions } = input;
21882
22039
  const spoken = turns.filter((turn) => turn.text.trim());
21883
22040
  const last = spoken.slice(-PACKET_TURNS);
21884
22041
  const toolCalls = turns.reduce((total, turn) => total + (turn.toolCalls?.length || 0), 0);
21885
22042
  const span = [turns.find((turn) => turn.ts)?.ts, [...turns].reverse().find((turn) => turn.ts)?.ts].filter(Boolean).join(" \u2192 ");
21886
- const archive = sessionId ? `spaces/${slugify(space)}/sessions/${sessionId}/transcript.jsonl` : `spaces/${slugify(space)}/sessions/`;
21887
22043
  const lines = [
21888
22044
  `# Handoff: ${space}`,
21889
22045
  `Source: ${source || "unknown"} \xB7 ${turns.length} turns \xB7 ${toolCalls} tool calls \xB7 ${nowIso()}`,
@@ -21900,10 +22056,7 @@ function distill(space, source, turns, summary, artifacts, sessionId) {
21900
22056
  (turn) => `- [${turn.id}] ${turn.role}: ${turn.text.replace(/\s+/g, " ").slice(0, PACKET_TURN_CHARS)}`
21901
22057
  ),
21902
22058
  "",
21903
- "## Full history",
21904
- `The complete conversation is archived verbatim \u2014 ${turns.length} turns including tool calls.`,
21905
- `Archive: ${archive}`,
21906
- sessionId ? `Read it with pantheon_get_session (space: ${slugify(space)}, session_id: ${sessionId}), a range with pantheon_get_turns, or find a moment with pantheon_search.` : "Read it with pantheon_get_session, pantheon_get_turns, or pantheon_search.",
22059
+ ...fullHistory(slugify(space), turns.length, sessionId, sessions),
21907
22060
  ""
21908
22061
  ];
21909
22062
  return `${lines.filter((line) => line !== null).join("\n")}
@@ -22025,6 +22178,18 @@ function transcriptLooksThin(turns) {
22025
22178
  }
22026
22179
  return null;
22027
22180
  }
22181
+ function choiceLine(choice, space) {
22182
+ const why = choice.mentionsHint ? `mentions "${space}"` : "most recently written";
22183
+ const last = choice.lastMessage ? ` \xB7 last human message: "${choice.lastMessage}"` : "";
22184
+ return `- sessionKey: ${choice.key} \u2014 ${choice.turns} turns, ${why}${last}`;
22185
+ }
22186
+ function chooseSessionMessage(space, choices) {
22187
+ return [
22188
+ `More than one conversation in this workspace could be the one being handed off, and the most recently written is not the one that mentions "${space}". Do not guess.`,
22189
+ "Show the human this list, ask which conversation they are in, then call pantheon_handoff again with that sessionKey:",
22190
+ ...choices.map((choice) => choiceLine(choice, space))
22191
+ ].join("\n");
22192
+ }
22028
22193
  function resolveTranscript(input) {
22029
22194
  const supplied = input.transcript ? parseTurns(input.transcript) : [];
22030
22195
  if (supplied.length) return { turns: supplied, captured: null };
@@ -22033,6 +22198,10 @@ function resolveTranscript(input) {
22033
22198
  "Transcript is empty and capture is disabled. Send the real turns, or drop capture:false to archive this chat from local history."
22034
22199
  );
22035
22200
  }
22201
+ if (!input.sessionKey) {
22202
+ const choices = ambiguousCapture({ cwd: input.cwd, hint: input.space });
22203
+ if (choices) throw new Error(chooseSessionMessage(input.space, choices));
22204
+ }
22036
22205
  const captured = captureLocalTranscript({ cwd: input.cwd, sessionKey: input.sessionKey });
22037
22206
  if (!captured?.turns.length) {
22038
22207
  throw new Error(
@@ -22041,6 +22210,19 @@ function resolveTranscript(input) {
22041
22210
  }
22042
22211
  return { turns: captured.turns, captured };
22043
22212
  }
22213
+ function lastSpoken(turns) {
22214
+ const last = [...turns].reverse().find((turn) => turn.role === "user" && turn.text.trim());
22215
+ return last ? last.text.replace(/\s+/g, " ").trim().slice(0, 160) : null;
22216
+ }
22217
+ function sessionStart(path) {
22218
+ try {
22219
+ const stat = statSync2(path);
22220
+ if (stat.birthtimeMs > 0 && stat.birthtimeMs <= stat.mtimeMs) return stat.birthtimeMs;
22221
+ return stat.mtimeMs - 24 * 60 * 60 * 1e3;
22222
+ } catch {
22223
+ return null;
22224
+ }
22225
+ }
22044
22226
  function writeHandoff(home, input) {
22045
22227
  requireSpaceName(input.space);
22046
22228
  const { slug, root } = ensureSpace(home, input.space);
@@ -22050,11 +22232,12 @@ function writeHandoff(home, input) {
22050
22232
  if (thin) throw new Error(thin);
22051
22233
  }
22052
22234
  const cwd = input.cwd || process.cwd();
22235
+ const sweep = captured ? collectWrittenArtifacts(turns, cwd, { since: sessionStart(captured.session.path), home }) : null;
22053
22236
  const artifacts = mergeArtifacts(
22054
22237
  input.artifacts,
22055
22238
  extractFencedArtifacts(turns),
22056
22239
  collectDiskArtifacts(turns),
22057
- captured ? collectWrittenArtifacts(turns, cwd) : void 0,
22240
+ sweep?.artifacts,
22058
22241
  captured ? collectAttachedArtifacts(turns, cwd) : void 0
22059
22242
  );
22060
22243
  if (!captured) {
@@ -22064,14 +22247,15 @@ function writeHandoff(home, input) {
22064
22247
  const source = input.source || captured?.session.source;
22065
22248
  const sessionId = captured ? captured.session.key : input.append ? latestSessionId(root) || void 0 : void 0;
22066
22249
  const session = writeSession(root, source, turns, artifacts, sessionId);
22067
- const packet = distill(
22068
- input.space,
22250
+ const packet = distill({
22251
+ space: input.space,
22069
22252
  source,
22070
- session.turns,
22071
- input.summary,
22072
- session.artifacts,
22073
- session.sessionId
22074
- );
22253
+ turns: session.turns,
22254
+ summary: input.summary,
22255
+ artifacts: session.artifacts,
22256
+ sessionId: session.sessionId,
22257
+ sessions: sessionSummaries(root)
22258
+ });
22075
22259
  writeFileSync(join2(root, "handoff.md"), packet);
22076
22260
  writeFileSync(join2(root, "handoffs", `${stamp()}.md`), packet);
22077
22261
  if (input.facts?.length) {
@@ -22086,7 +22270,12 @@ function writeHandoff(home, input) {
22086
22270
  added: session.added,
22087
22271
  alreadyArchived: session.existing,
22088
22272
  capturedFrom: captured ? captured.session.source : null,
22273
+ // So a human can tell at a glance that the right conversation was read.
22274
+ lastMessage: lastSpoken(session.turns),
22089
22275
  artifacts: session.artifacts,
22276
+ // Files this session made that the archive would not take. Silence here is
22277
+ // how a handoff comes to promise more than it holds.
22278
+ skipped: sweep?.skipped ?? [],
22090
22279
  truncated: Boolean(input.truncated),
22091
22280
  append: Boolean(input.append)
22092
22281
  };
@@ -22135,6 +22324,53 @@ function sessionDirs(root) {
22135
22324
  };
22136
22325
  }).sort((a, b) => b.mtime - a.mtime);
22137
22326
  }
22327
+ function metaField(raw, key) {
22328
+ return raw.match(new RegExp(`^${key}:\\s*(.+)$`, "m"))?.[1]?.trim() || void 0;
22329
+ }
22330
+ function countLines(path) {
22331
+ const raw = readText(path);
22332
+ return raw.trim() ? raw.split("\n").filter((line) => line.trim()).length : 0;
22333
+ }
22334
+ function sessionSummaries(root) {
22335
+ return sessionDirs(root).map((session) => {
22336
+ const meta = readText(join2(session.dir, "meta.yaml"));
22337
+ const source = metaField(meta, "source");
22338
+ return {
22339
+ id: session.id,
22340
+ source: source && source !== "unknown" ? source : void 0,
22341
+ // meta.yaml is rewritten on every handoff, but a half-written or
22342
+ // hand-edited archive should still report an honest count.
22343
+ turns: Number(metaField(meta, "turns")) || countLines(join2(session.dir, "transcript.jsonl")),
22344
+ createdAt: metaField(meta, "created_at"),
22345
+ updatedAt: metaField(meta, "updated_at")
22346
+ };
22347
+ });
22348
+ }
22349
+ var STORY_PACKETS = 8;
22350
+ var STORY_CHARS = 6e3;
22351
+ function packetBody(markdown) {
22352
+ const after = markdown.split("## Packet")[1];
22353
+ return after ? after.split(/\n## /)[0].trim() : "";
22354
+ }
22355
+ function unstamp(name) {
22356
+ return name.replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z$/, "T$1:$2:$3.$4Z");
22357
+ }
22358
+ function readStory(root) {
22359
+ const dir = join2(root, "handoffs");
22360
+ if (!existsSync2(dir)) return [];
22361
+ const files2 = readdirSync2(dir).filter((name) => name.endsWith(".md")).sort();
22362
+ const prior = files2.slice(0, -1).slice(-STORY_PACKETS);
22363
+ const out = [];
22364
+ let budget = STORY_CHARS;
22365
+ for (const name of [...prior].reverse()) {
22366
+ if (budget <= 0) break;
22367
+ const packet = packetBody(readText(join2(dir, name)));
22368
+ if (!packet) continue;
22369
+ out.push({ at: unstamp(name.replace(/\.md$/, "")), packet: packet.slice(0, budget) });
22370
+ budget -= packet.length;
22371
+ }
22372
+ return out.reverse();
22373
+ }
22138
22374
  function listSpaceArtifacts(root) {
22139
22375
  const out = [];
22140
22376
  for (const session of sessionDirs(root)) {
@@ -22148,16 +22384,42 @@ function listSpaceArtifacts(root) {
22148
22384
  }
22149
22385
  return out;
22150
22386
  }
22387
+ function resumeNote(sessions, turns, story) {
22388
+ if (!sessions.length) {
22389
+ return "Nothing archived in this space yet. Ask the human what they were working on rather than guessing.";
22390
+ }
22391
+ const parts = [
22392
+ `handoff.md is a packet, not the conversation: this space holds ${turns} turns across ${sessions.length} session${sessions.length === 1 ? "" : "s"}, all archived verbatim with tool calls.`
22393
+ ];
22394
+ if (sessions.length > 1) {
22395
+ parts.push(
22396
+ "The packet was written by whichever session ended last, so it does not describe the others. Every id in sessions works with pantheon_get_session and pantheon_get_turns."
22397
+ );
22398
+ }
22399
+ if (story) {
22400
+ parts.push(`story holds ${story} earlier packet${story === 1 ? "" : "s"}, oldest first.`);
22401
+ }
22402
+ parts.push(
22403
+ '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
+ );
22405
+ return parts.join(" ");
22406
+ }
22151
22407
  function readResume(home, space) {
22152
22408
  requireSpaceName(space);
22153
22409
  const { slug, root } = ensureSpace(home, space);
22154
- const artifacts = listSpaceArtifacts(root);
22410
+ const sessions = sessionSummaries(root);
22411
+ const turns = sessions.reduce((sum, session) => sum + session.turns, 0);
22412
+ const story = readStory(root);
22155
22413
  return {
22156
22414
  space: slug,
22157
22415
  handoff: readText(join2(root, "handoff.md")).trim() || "(empty handoff)",
22158
22416
  memory: readText(join2(root, "memory.md")).trim() || "(no durable memory yet)",
22159
- sessionId: sessionDirs(root)[0]?.id ?? null,
22160
- artifacts
22417
+ sessionId: sessions[0]?.id ?? null,
22418
+ sessions,
22419
+ turns,
22420
+ story,
22421
+ artifacts: listSpaceArtifacts(root),
22422
+ note: resumeNote(sessions, turns, story.length)
22161
22423
  };
22162
22424
  }
22163
22425
  function packetPreview(markdown) {
@@ -22183,27 +22445,70 @@ function listSpaces(home) {
22183
22445
  };
22184
22446
  }).sort((a, b) => (b.updatedAt || "").localeCompare(a.updatedAt || ""));
22185
22447
  }
22186
- function searchSpace(home, space, query) {
22448
+ var SEARCH_LIMIT = 20;
22449
+ var SEARCH_MAX = 50;
22450
+ var CONTEXT_MAX = 5;
22451
+ var EXCERPT_CHARS = 280;
22452
+ var CONTEXT_CHARS = 400;
22453
+ function excerptAround(haystack, needle, width = EXCERPT_CHARS) {
22454
+ const flat = haystack.replace(/\s+/g, " ").trim();
22455
+ const at = flat.toLowerCase().indexOf(needle);
22456
+ if (at < 0) return flat.slice(0, width);
22457
+ const start = Math.max(0, at - Math.floor(width / 3));
22458
+ const end = Math.min(flat.length, start + width);
22459
+ return `${start > 0 ? "\u2026" : ""}${flat.slice(start, end)}${end < flat.length ? "\u2026" : ""}`;
22460
+ }
22461
+ function toolHaystack(call) {
22462
+ const input = typeof call.input === "string" ? call.input : JSON.stringify(call.input ?? "");
22463
+ return [call.name, input, call.output ?? ""].filter(Boolean).join(" ");
22464
+ }
22465
+ function slimTurn(turn) {
22466
+ return {
22467
+ id: turn.id,
22468
+ role: turn.role,
22469
+ text: (turn.text || "").replace(/\s+/g, " ").slice(0, CONTEXT_CHARS),
22470
+ ts: turn.ts,
22471
+ toolCalls: turn.toolCalls?.map((call) => ({ name: call.name }))
22472
+ };
22473
+ }
22474
+ function matchTurn(turn, needle) {
22475
+ if (turn.text?.toLowerCase().includes(needle)) {
22476
+ return { matchedIn: "text", excerpt: excerptAround(turn.text, needle) };
22477
+ }
22478
+ for (const call of turn.toolCalls ?? []) {
22479
+ const haystack = toolHaystack(call);
22480
+ if (!haystack.toLowerCase().includes(needle)) continue;
22481
+ return {
22482
+ matchedIn: "tool",
22483
+ tool: call.name,
22484
+ excerpt: excerptAround(haystack, needle)
22485
+ };
22486
+ }
22487
+ return null;
22488
+ }
22489
+ function searchSpace(home, space, query, options = {}) {
22187
22490
  const { root } = ensureSpace(home, space);
22188
- const sessions = join2(root, "sessions");
22189
- if (!existsSync2(sessions)) return [];
22190
- const needle = query.toLowerCase();
22491
+ const needle = query.trim().toLowerCase();
22492
+ if (!needle) return [];
22493
+ const limit = Math.min(Math.max(options.limit ?? SEARCH_LIMIT, 1), SEARCH_MAX);
22494
+ const context = Math.min(Math.max(options.context ?? 0, 0), CONTEXT_MAX);
22191
22495
  const hits = [];
22192
- for (const session of readdirSync2(sessions, { withFileTypes: true })) {
22193
- if (!session.isDirectory()) continue;
22194
- const file = join2(sessions, session.name, "transcript.jsonl");
22195
- if (!existsSync2(file)) continue;
22196
- for (const line of readFileSync2(file, "utf8").split("\n")) {
22197
- if (!line.trim()) continue;
22198
- const turn = JSON.parse(line);
22199
- if (!turn.text?.toLowerCase().includes(needle)) continue;
22496
+ for (const session of sessionDirs(root)) {
22497
+ const turns = readSessionTurns(session.dir);
22498
+ for (let index = 0; index < turns.length; index += 1) {
22499
+ const turn = turns[index];
22500
+ const match = matchTurn(turn, needle);
22501
+ if (!match) continue;
22200
22502
  hits.push({
22201
- sessionId: session.name,
22503
+ sessionId: session.id,
22202
22504
  turnId: turn.id,
22203
22505
  role: turn.role,
22204
- excerpt: turn.text.replace(/\s+/g, " ").slice(0, 280)
22506
+ ...match,
22507
+ ...context ? {
22508
+ context: turns.slice(Math.max(0, index - context), index + context + 1).map(slimTurn)
22509
+ } : {}
22205
22510
  });
22206
- if (hits.length >= 20) return hits;
22511
+ if (hits.length >= limit) return hits;
22207
22512
  }
22208
22513
  }
22209
22514
  return hits;
@@ -22246,6 +22551,7 @@ Grounding \u2014 never break these:
22246
22551
  - If pantheon_* tools are missing or fail, say "Pantheon MCP is not connected" and stop. Do not guess.
22247
22552
  - /pantheon-spaces \u2192 call pantheon_list_spaces, then show only those slugs.
22248
22553
  - Files you generated (PDFs, letters, CVs, spreadsheets) must go in artifacts as base64. Handoff is rejected if the chat names a .pdf and you omit it.
22554
+ - After resume, the packet is a summary of the session that ended last \u2014 not the space. Before you tell the human something was not carried over, call pantheon_search (it reads tool calls too) and pantheon_get_turns on any id from the sessions list.
22249
22555
  `;
22250
22556
  var GUIDE = `pantheon \u2014 agent conscience
22251
22557
 
@@ -22277,6 +22583,13 @@ Tutorial
22277
22583
  4. Continue later: /pantheon-resume <space> \u2192 pantheon_resume
22278
22584
  If they omit <space>, still call pantheon_resume. It lists the vault so they can pick.
22279
22585
  Handoff commits and pushes. Resume pulls first. Do not run pantheon sync.
22586
+ 5. Dig past the packet. Resume returns a summary of the last session plus
22587
+ sessions (every archived conversation and its turn count) and story
22588
+ (what earlier handoffs said). The detail is all still there:
22589
+ pantheon_search find a moment anywhere in the space, tool calls included
22590
+ pantheon_get_turns read around it
22591
+ pantheon_get_session read one conversation end to end
22592
+ Missing context is nearly always unsearched, not unsaved.
22280
22593
 
22281
22594
  Terminal (this CLI)
22282
22595
  connect <code> bind this machine to the private GitHub vault
@@ -22292,12 +22605,13 @@ Terminal (this CLI)
22292
22605
  MCP tools \u2014 always the pantheon_ prefix
22293
22606
  pantheon_help this same guide
22294
22607
  pantheon_list_spaces list consciences
22295
- pantheon_resume pull vault, then load latest handoff.md + memory.md
22608
+ pantheon_resume pull vault, then load the packet, memory, story,
22609
+ session list, and artifact names
22296
22610
  pantheon_handoff archive this chat from local history, commit and push
22297
22611
  pantheon_local_sessions list recorded chats capture can see (Cursor/Codex/Claude)
22298
22612
  pantheon_park archive without rewriting the packet, then push
22299
22613
  pantheon_remember add one durable fact, then push
22300
- pantheon_search search the full dump
22614
+ pantheon_search search every session \u2014 messages and tool calls
22301
22615
  pantheon_get_turns fetch a turn range
22302
22616
  pantheon_get_session fetch a stored transcript
22303
22617
  pantheon_get_artifact fetch a stored file
@@ -22544,6 +22858,9 @@ function fail(error2) {
22544
22858
  }
22545
22859
  function hint(message) {
22546
22860
  const text2 = message.toLowerCase();
22861
+ if (text2.includes("more than one conversation")) {
22862
+ return "Do not retry blindly \u2014 the same chat would be picked again. Show the human the listed conversations, ask which one they are in, then call pantheon_handoff with that sessionKey.";
22863
+ }
22547
22864
  if (text2.includes("not found") && text2.includes("session")) {
22548
22865
  return "Call pantheon_search first and use the session_id from a hit.";
22549
22866
  }
@@ -22634,7 +22951,7 @@ ${GUIDE}` }]
22634
22951
  registerTool(
22635
22952
  server,
22636
22953
  "pantheon_resume",
22637
- "Pull the vault, then load the latest Pantheon handoff packet, durable memory, and stored artifact names. Trigger: /pantheon-resume <space>. If the space name is missing or empty, this tool lists live spaces \u2014 show that list and ask which conscience. If artifacts are listed, fetch needed files with pantheon_get_artifact. Never call a generic resume tool for this. Do not run pantheon sync.",
22954
+ "Pull the vault, then load a Pantheon conscience: the latest handoff packet, durable memory, packets from earlier handoffs (story), every archived session with its turn count (sessions), and stored artifact names. Trigger: /pantheon-resume <space>. If the space name is missing or empty, this tool lists live spaces \u2014 show that list and ask which conscience. The packet is a summary of the session that ended last, not the space: when the human asks about anything it does not cover, call pantheon_search before saying you lack context, and read detail with pantheon_get_turns or pantheon_get_session using any id from sessions. Fetch files with pantheon_get_artifact. Never call a generic resume tool for this. Do not run pantheon sync.",
22638
22955
  { space: external_exports.string().optional() },
22639
22956
  async ({ space }) => safe(async () => {
22640
22957
  const sync2 = await vault.pull(home);
@@ -22695,7 +23012,15 @@ ${GUIDE}` }]
22695
23012
  ok: sync2.ok !== false,
22696
23013
  ...written,
22697
23014
  sync: sync2,
22698
- note: sync2.ok === false ? `Saved locally (${written.turns} turns) but the push failed: ${sync2.error || "unknown error"}. Tell the human it is not yet in GitHub.` : `Archived ${written.turns} turns${written.added !== written.turns ? ` (${written.added} new)` : ""} from ${written.capturedFrom || "the supplied transcript"}.`
23015
+ note: sync2.ok === false ? `Saved locally (${written.turns} turns) but the push failed: ${sync2.error || "unknown error"}. Tell the human it is not yet in GitHub.` : [
23016
+ `Archived ${written.turns} turns${written.added !== written.turns ? ` (${written.added} new)` : ""} from ${written.capturedFrom || "the supplied transcript"}.`,
23017
+ // Capture reads a chat off disk, so name what it read: if a
23018
+ // second conversation was open, this is where that shows.
23019
+ 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
+ // A file the session made and the archive would not take is
23021
+ // 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
23023
+ ].filter(Boolean).join(" ")
22699
23024
  };
22700
23025
  })
22701
23026
  );
@@ -22753,9 +23078,20 @@ ${GUIDE}` }]
22753
23078
  registerTool(
22754
23079
  server,
22755
23080
  "pantheon_search",
22756
- "Search the full Pantheon dump for a space. Returns session and turn pointers.",
22757
- { space: external_exports.string(), query: external_exports.string() },
22758
- async ({ space, query }) => safe(() => ({ hits: searchSpace(home, space, query) }))
23081
+ "Search every archived session in a Pantheon space \u2014 messages and tool calls, including file paths only ever named by a write tool. Use this before telling the human you lack context: the resume packet summarises one session, this reads the whole space. Returns session_id and turn_id pointers to widen with pantheon_get_turns.",
23082
+ {
23083
+ space: external_exports.string(),
23084
+ query: external_exports.string(),
23085
+ context: external_exports.number().optional().describe("Turns of surrounding conversation to return with each hit (0-5). Use 2 to read a moment without a second call."),
23086
+ limit: external_exports.number().optional().describe("Maximum hits (default 20, max 50).")
23087
+ },
23088
+ async ({ space, query, context, limit }) => safe(() => {
23089
+ const hits = searchSpace(home, space, query, { context, limit });
23090
+ return {
23091
+ hits,
23092
+ note: hits.length ? "Each hit names its session. Widen with pantheon_get_turns (space, session_id, from, to) or read the session end to end with pantheon_get_session." : "No match. Try a different word, or list what exists with pantheon_resume \u2014 its sessions array names every archived conversation in this space."
23093
+ };
23094
+ })
22759
23095
  );
22760
23096
  registerTool(
22761
23097
  server,
@@ -22830,7 +23166,7 @@ import { hostname as hostname2 } from "node:os";
22830
23166
 
22831
23167
  // src/connect.ts
22832
23168
  import { execFileSync as execFileSync2 } from "node:child_process";
22833
- import { existsSync as existsSync6, mkdirSync as mkdirSync5 } from "node:fs";
23169
+ import { existsSync as existsSync6, mkdirSync as mkdirSync5, renameSync } from "node:fs";
22834
23170
  import { join as join6 } from "node:path";
22835
23171
 
22836
23172
  // src/mcp-install.ts
@@ -23117,8 +23453,8 @@ function uninstallMcpClients() {
23117
23453
  if (removeServerFromJson(join5(homedir5(), ".codeium", "windsurf", "mcp_config.json"))) {
23118
23454
  removed.push("Windsurf");
23119
23455
  }
23120
- const slash = removeSlashCommands();
23121
- if (slash) removed.push("/pantheon-* commands");
23456
+ const slash2 = removeSlashCommands();
23457
+ if (slash2) removed.push("/pantheon-* commands");
23122
23458
  for (const dir of [
23123
23459
  join5(homedir5(), ".agents", "skills", "pantheon"),
23124
23460
  join5(homedir5(), ".codex", "skills", "pantheon")
@@ -23216,15 +23552,12 @@ async function connect(opts) {
23216
23552
  const helper = credentialHelperCommand();
23217
23553
  const quiet = { stdio: ["ignore", "pipe", "pipe"] };
23218
23554
  const fresh = !existsSync6(join6(home, ".git"));
23555
+ let archived = "";
23219
23556
  if (fresh) {
23220
23557
  process.stdout.write(" Cloning the vault\u2026\n");
23221
23558
  execFileSync2("git", ["-c", `credential.helper=${helper}`, "clone", body.cloneUrl, home], quiet);
23222
23559
  } else {
23223
- execFileSync2(
23224
- "git",
23225
- ["-c", `credential.helper=${helper}`, "-C", home, "pull", "--ff-only"],
23226
- quiet
23227
- );
23560
+ archived = syncVault2(home, body.cloneUrl, helper, quiet);
23228
23561
  }
23229
23562
  execFileSync2("git", ["-C", home, "config", "credential.helper", helper], quiet);
23230
23563
  execFileSync2("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
@@ -23245,7 +23578,8 @@ async function connect(opts) {
23245
23578
  field("Connected", body.account),
23246
23579
  field("Install", String(body.installationId)),
23247
23580
  field("Repo", `${body.repo} (private)`),
23248
- field("Vault", `${home}${fresh ? " (cloned)" : " (updated)"}`)
23581
+ field("Vault", `${home}${vaultNote(fresh, archived)}`),
23582
+ ...archived ? [field("Set aside", `${archived} \u2014 spaces from the old repo`)] : []
23249
23583
  ].join("\n"),
23250
23584
  failure ? field("MCP", `failed \u2014 ${failure}`) : block("Configured", written),
23251
23585
  block("Skipped", skipped),
@@ -23253,6 +23587,44 @@ async function connect(opts) {
23253
23587
  )
23254
23588
  );
23255
23589
  }
23590
+ function syncVault2(home, cloneUrl, helper, quiet) {
23591
+ const git2 = (...args) => execFileSync2("git", ["-c", `credential.helper=${helper}`, "-C", home, ...args], quiet);
23592
+ try {
23593
+ git2("pull", "--ff-only");
23594
+ return "";
23595
+ } catch (error2) {
23596
+ if (!existsSync6(join6(home, ".git"))) throw error2;
23597
+ }
23598
+ if (sharesHistory(home)) {
23599
+ process.stdout.write(" Merging work from another machine\u2026\n");
23600
+ git2("pull", "--no-rebase", "--no-edit");
23601
+ return "";
23602
+ }
23603
+ const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
23604
+ const archive = `${home}-${stamp2}`;
23605
+ process.stdout.write(" Vault belongs to a deleted repo; setting it aside\u2026\n");
23606
+ renameSync(home, archive);
23607
+ execFileSync2("git", ["-c", `credential.helper=${helper}`, "clone", cloneUrl, home], quiet);
23608
+ return archive;
23609
+ }
23610
+ function sharesHistory(home) {
23611
+ try {
23612
+ const upstream = execFileSync2("git", ["-C", home, "rev-parse", "@{u}"], {
23613
+ stdio: ["ignore", "pipe", "pipe"],
23614
+ encoding: "utf8"
23615
+ }).trim();
23616
+ execFileSync2("git", ["-C", home, "merge-base", "HEAD", upstream], {
23617
+ stdio: ["ignore", "pipe", "pipe"]
23618
+ });
23619
+ return true;
23620
+ } catch {
23621
+ return false;
23622
+ }
23623
+ }
23624
+ function vaultNote(fresh, archived) {
23625
+ if (archived) return " (re-cloned)";
23626
+ return fresh ? " (cloned)" : " (updated)";
23627
+ }
23256
23628
  function credentialHelperCommand() {
23257
23629
  return "!pantheon git-credential";
23258
23630
  }
@@ -23503,10 +23875,10 @@ async function main() {
23503
23875
  return;
23504
23876
  }
23505
23877
  if (AGENT_VERBS.has(cmd)) {
23506
- const slash = ["handoff", "park", "resume", "remember"].includes(cmd);
23878
+ const slash2 = ["handoff", "park", "resume", "remember"].includes(cmd);
23507
23879
  printError(
23508
23880
  new Error(
23509
- slash ? `${cmd} is an MCP tool, not a CLI command. Call pantheon_${cmd.replace(/^pantheon_/, "")}, or type /pantheon-${cmd.replace(/^pantheon_/, "")} <space> in chat.` : `${cmd} is an MCP tool, not a CLI command. Call the pantheon_* tool, or type /pantheon-help.`
23881
+ slash2 ? `${cmd} is an MCP tool, not a CLI command. Call pantheon_${cmd.replace(/^pantheon_/, "")}, or type /pantheon-${cmd.replace(/^pantheon_/, "")} <space> in chat.` : `${cmd} is an MCP tool, not a CLI command. Call the pantheon_* tool, or type /pantheon-help.`
23510
23882
  )
23511
23883
  );
23512
23884
  process.stdout.write(GUIDE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.2",
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",