pantheon-cli 0.2.23 → 0.2.27

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 +285 -110
  2. package/package.json +1 -1
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(serialize2(uri, options), options);
3643
+ parse4(serialize2(uri, options), options);
3644
3644
  }
3645
3645
  return uri;
3646
3646
  }
@@ -3658,8 +3658,8 @@ var require_fast_uri = __commonJS({
3658
3658
  function resolveComponent(base, relative2, options, skipNormalization) {
3659
3659
  const target = {};
3660
3660
  if (!skipNormalization) {
3661
- base = parse3(serialize2(base, options), options);
3662
- relative2 = parse3(serialize2(relative2, options), options);
3661
+ base = parse4(serialize2(base, options), options);
3662
+ relative2 = parse4(serialize2(relative2, options), options);
3663
3663
  }
3664
3664
  options = options || {};
3665
3665
  if (!options.tolerant && relative2.scheme) {
@@ -3903,7 +3903,7 @@ var require_fast_uri = __commonJS({
3903
3903
  }
3904
3904
  return { parsed, malformedAuthorityOrPort };
3905
3905
  }
3906
- function parse3(uri, opts) {
3906
+ function parse4(uri, opts) {
3907
3907
  return parseWithStatus(uri, opts).parsed;
3908
3908
  }
3909
3909
  function normalizeString(uri, opts) {
@@ -3932,7 +3932,7 @@ var require_fast_uri = __commonJS({
3932
3932
  resolveComponent,
3933
3933
  equal,
3934
3934
  serialize: serialize2,
3935
- parse: parse3
3935
+ parse: parse4
3936
3936
  };
3937
3937
  module.exports = fastUri;
3938
3938
  module.exports.default = fastUri;
@@ -6928,7 +6928,7 @@ var require_content_type = __commonJS({
6928
6928
  var QUOTE_REGEXP = /([\\"])/g;
6929
6929
  var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
6930
6930
  exports.format = format;
6931
- exports.parse = parse3;
6931
+ exports.parse = parse4;
6932
6932
  function format(obj) {
6933
6933
  if (!obj || typeof obj !== "object") {
6934
6934
  throw new TypeError("argument obj is required");
@@ -6952,7 +6952,7 @@ var require_content_type = __commonJS({
6952
6952
  }
6953
6953
  return string3;
6954
6954
  }
6955
- function parse3(string3) {
6955
+ function parse4(string3) {
6956
6956
  if (!string3) {
6957
6957
  throw new TypeError("argument string is required");
6958
6958
  }
@@ -22011,6 +22011,15 @@ function dirsIn(root) {
22011
22011
  if (!existsSync3(root)) return [];
22012
22012
  return readdirSync3(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => ({ name: entry.name, dir: join3(root, entry.name) }));
22013
22013
  }
22014
+ function hasContent(dir) {
22015
+ try {
22016
+ return readdirSync3(dir, { withFileTypes: true }).some(
22017
+ (entry) => entry.isDirectory() ? hasContent(join3(dir, entry.name)) : true
22018
+ );
22019
+ } catch {
22020
+ return false;
22021
+ }
22022
+ }
22014
22023
  function sharedMatches(home, slug) {
22015
22024
  return dirsIn(sharedHome(home)).map((owner) => ({ owner: owner.name, root: join3(owner.dir, slug) })).filter((match) => existsSync3(match.root));
22016
22025
  }
@@ -22933,11 +22942,9 @@ function summarise(dir, slug, name, extra = {}) {
22933
22942
  };
22934
22943
  }
22935
22944
  function listSpaces(home) {
22936
- const own = dirsIn(join3(resolve(home), "spaces")).map(
22937
- (entry) => summarise(entry.dir, entry.name, entry.name)
22938
- );
22945
+ const own = dirsIn(join3(resolve(home), "spaces")).filter((entry) => hasContent(entry.dir)).map((entry) => summarise(entry.dir, entry.name, entry.name));
22939
22946
  const shared = dirsIn(sharedHome(home)).flatMap(
22940
- (owner) => dirsIn(owner.dir).map(
22947
+ (owner) => dirsIn(owner.dir).filter((space) => hasContent(space.dir)).map(
22941
22948
  (space) => summarise(space.dir, `${owner.name}/${space.name}`, space.name, {
22942
22949
  owner: owner.name,
22943
22950
  shared: true
@@ -23268,14 +23275,16 @@ esac
23268
23275
  }
23269
23276
  }
23270
23277
  }
23271
- function retarget(home) {
23278
+ function boundElsewhere(home) {
23272
23279
  try {
23273
23280
  const stored = loadMachineConfig();
23274
- if (!stored?.config.cloneUrl) return;
23275
- if (resolve2(stored.config.home) !== resolve2(home)) return;
23276
- if (git(home, ["remote", "get-url", "origin"]) === stored.config.cloneUrl) return;
23277
- git(home, ["remote", "set-url", "origin", stored.config.cloneUrl]);
23281
+ if (!stored?.config.cloneUrl) return null;
23282
+ if (resolve2(stored.config.home) !== resolve2(home)) return null;
23283
+ const origin = git(home, ["remote", "get-url", "origin"]);
23284
+ if (origin === stored.config.cloneUrl) return null;
23285
+ return `This vault pushes to ${origin}, but this machine is connected to ${stored.config.repo}. Run pantheon connect <code> to switch it over \u2014 that sets the current vault aside instead of rewriting it.`;
23278
23286
  } catch {
23287
+ return null;
23279
23288
  }
23280
23289
  }
23281
23290
  function syncVaultWithToken(home, token, opts = {}) {
@@ -23284,7 +23293,11 @@ function syncVaultWithToken(home, token, opts = {}) {
23284
23293
  result.error = "Vault is not a git repo.";
23285
23294
  return result;
23286
23295
  }
23287
- retarget(home);
23296
+ const bound = boundElsewhere(home);
23297
+ if (bound) {
23298
+ result.error = bound;
23299
+ return result;
23300
+ }
23288
23301
  try {
23289
23302
  return withGitAuth(token, (env) => {
23290
23303
  const auth = [
@@ -23352,6 +23365,136 @@ async function syncVault(home, opts = {}) {
23352
23365
  }
23353
23366
  }
23354
23367
 
23368
+ // ../core/src/shares.ts
23369
+ import { existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync4, readFileSync as readFileSync5, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
23370
+ import { dirname as dirname2, join as join6 } from "node:path";
23371
+ function ledgerPath(root) {
23372
+ return join6(root, "manifest.json");
23373
+ }
23374
+ function readLedger(root) {
23375
+ try {
23376
+ return JSON.parse(readFileSync5(ledgerPath(root), "utf8"));
23377
+ } catch {
23378
+ return {};
23379
+ }
23380
+ }
23381
+ function safeSegment(value) {
23382
+ const clean = (value || "").trim();
23383
+ if (!clean || clean === "." || clean === "..") return null;
23384
+ if (clean.includes("/") || clean.includes("\\") || clean.includes("\0")) return null;
23385
+ return clean;
23386
+ }
23387
+ function safeRelative(value) {
23388
+ const parts = (value || "").split("/").filter(Boolean);
23389
+ if (!parts.length) return null;
23390
+ if (parts.some((part) => !safeSegment(part))) return null;
23391
+ return parts.join("/");
23392
+ }
23393
+ async function fetchShares(apiUrl, auth) {
23394
+ const res = await fetch(`${apiUrl}/api/cli/shares`, { headers: { authorization: auth } });
23395
+ if (!res.ok) throw new Error(`Could not list shares (${res.status}).`);
23396
+ const body = await res.json();
23397
+ if (!Array.isArray(body.shares)) throw new Error("Could not read the share list.");
23398
+ return body.shares;
23399
+ }
23400
+ async function pullShares(home) {
23401
+ const stored = loadMachineConfig();
23402
+ if (!stored) return { ok: false, spaces: 0, fetched: 0, error: "Not connected." };
23403
+ const auth = `Bearer ${stored.config.machineId}.${stored.credentials.machineSecret}`;
23404
+ const root = sharedHome(home);
23405
+ let shares;
23406
+ try {
23407
+ shares = await fetchShares(stored.config.apiUrl, auth);
23408
+ } catch (error2) {
23409
+ return {
23410
+ ok: false,
23411
+ spaces: 0,
23412
+ fetched: 0,
23413
+ error: error2 instanceof Error ? error2.message : String(error2)
23414
+ };
23415
+ }
23416
+ if (!shares.length) {
23417
+ if (existsSync6(root)) rmSync3(root, { recursive: true, force: true });
23418
+ return { ok: true, spaces: 0, fetched: 0 };
23419
+ }
23420
+ mkdirSync5(root, { recursive: true });
23421
+ const ledger = readLedger(root);
23422
+ const next = {};
23423
+ const keep = /* @__PURE__ */ new Set();
23424
+ const jobs = [];
23425
+ for (const share of shares) {
23426
+ const owner = safeSegment(share.owner);
23427
+ const slug = safeSegment(share.slug);
23428
+ if (!owner || !slug) continue;
23429
+ keep.add(`${owner}/${slug}`);
23430
+ const spaceDir2 = join6(root, owner, slug);
23431
+ const wanted = /* @__PURE__ */ new Set();
23432
+ for (const file of share.files || []) {
23433
+ const relative2 = safeRelative(file.path);
23434
+ if (!relative2) continue;
23435
+ wanted.add(relative2);
23436
+ const key = `${owner}/${slug}/${relative2}`;
23437
+ next[key] = file.sha;
23438
+ const dest = join6(spaceDir2, relative2);
23439
+ if (ledger[key] === file.sha && existsSync6(dest)) continue;
23440
+ jobs.push({ key, owner, slug, relative: relative2, dest });
23441
+ }
23442
+ prune(spaceDir2, spaceDir2, wanted);
23443
+ }
23444
+ let fetched = 0;
23445
+ await pool(jobs, async (job) => {
23446
+ const url = `${stored.config.apiUrl}/api/cli/shares/${encodeURIComponent(job.owner)}/${encodeURIComponent(job.slug)}?path=${encodeURIComponent(job.relative)}`;
23447
+ const res = await fetch(url, { headers: { authorization: auth } }).catch(() => null);
23448
+ if (!res?.ok) {
23449
+ delete next[job.key];
23450
+ return;
23451
+ }
23452
+ mkdirSync5(dirname2(job.dest), { recursive: true });
23453
+ writeFileSync5(job.dest, Buffer.from(await res.arrayBuffer()));
23454
+ fetched += 1;
23455
+ });
23456
+ for (const owner of dirNames(root)) {
23457
+ for (const slug of dirNames(join6(root, owner))) {
23458
+ if (keep.has(`${owner}/${slug}`)) continue;
23459
+ rmSync3(join6(root, owner, slug), { recursive: true, force: true });
23460
+ }
23461
+ if (!dirNames(join6(root, owner)).length) rmSync3(join6(root, owner), { recursive: true, force: true });
23462
+ }
23463
+ writeFileSync5(ledgerPath(root), `${JSON.stringify(next, null, 2)}
23464
+ `);
23465
+ return { ok: true, spaces: keep.size, fetched };
23466
+ }
23467
+ async function pool(items, run, limit = 12) {
23468
+ let cursor = 0;
23469
+ const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
23470
+ while (cursor < items.length) {
23471
+ const item = items[cursor++];
23472
+ await run(item);
23473
+ }
23474
+ });
23475
+ await Promise.all(workers);
23476
+ }
23477
+ function prune(base, dir, wanted) {
23478
+ if (!existsSync6(dir)) return;
23479
+ for (const entry of readdirSync4(dir, { withFileTypes: true })) {
23480
+ const full = join6(dir, entry.name);
23481
+ if (entry.isDirectory()) {
23482
+ prune(base, full, wanted);
23483
+ if (!readdirSync4(full).length) rmSync3(full, { recursive: true, force: true });
23484
+ continue;
23485
+ }
23486
+ const relative2 = full.slice(base.length + 1).split("\\").join("/");
23487
+ if (!wanted.has(relative2)) rmSync3(full, { force: true });
23488
+ }
23489
+ }
23490
+ function dirNames(root) {
23491
+ try {
23492
+ return readdirSync4(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
23493
+ } catch {
23494
+ return [];
23495
+ }
23496
+ }
23497
+
23355
23498
  // ../mcp/src/index.ts
23356
23499
  function readRoot(home, space) {
23357
23500
  return resolveSpace(home, space).root;
@@ -23361,7 +23504,12 @@ function writeRoot(home, space) {
23361
23504
  }
23362
23505
  function defaultHooks() {
23363
23506
  return {
23364
- pull: (home) => syncVault(home, { push: false }),
23507
+ pull: async (home) => {
23508
+ const sync2 = await syncVault(home, { push: false });
23509
+ await pullShares(home).catch(() => {
23510
+ });
23511
+ return sync2;
23512
+ },
23365
23513
  push: (home, message) => syncVault(home, { push: true, message })
23366
23514
  };
23367
23515
  }
@@ -23805,24 +23953,24 @@ import { hostname as hostname3 } from "node:os";
23805
23953
 
23806
23954
  // src/connect.ts
23807
23955
  import { execFileSync as execFileSync3 } from "node:child_process";
23808
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, renameSync as renameSync2 } from "node:fs";
23956
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, renameSync as renameSync2 } from "node:fs";
23809
23957
  import { hostname as hostname2 } from "node:os";
23810
- import { join as join7 } from "node:path";
23958
+ import { join as join8 } from "node:path";
23811
23959
 
23812
23960
  // src/mcp-install.ts
23813
- import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "node:fs";
23961
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync6, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
23814
23962
  import { homedir as homedir5 } from "node:os";
23815
- import { dirname as dirname2, join as join6 } from "node:path";
23963
+ import { dirname as dirname3, join as join7 } from "node:path";
23816
23964
  import { fileURLToPath } from "node:url";
23817
- var here = dirname2(fileURLToPath(import.meta.url));
23965
+ var here = dirname3(fileURLToPath(import.meta.url));
23818
23966
  function pantheonBin() {
23819
23967
  const self = fileURLToPath(import.meta.url);
23820
- if (self.endsWith(".ts")) return join6(here, "../bin/pantheon.mjs");
23968
+ if (self.endsWith(".ts")) return join7(here, "../bin/pantheon.mjs");
23821
23969
  return self;
23822
23970
  }
23823
23971
  function launchEnv(home) {
23824
- const nodeDir = dirname2(process.execPath);
23825
- const binDir = dirname2(pantheonBin());
23972
+ const nodeDir = dirname3(process.execPath);
23973
+ const binDir = dirname3(pantheonBin());
23826
23974
  const sep = process.platform === "win32" ? ";" : ":";
23827
23975
  const pathKey = process.platform === "win32" ? "Path" : "PATH";
23828
23976
  return {
@@ -23910,8 +24058,8 @@ function isPlainObject3(value) {
23910
24058
  return typeof value === "object" && value !== null && !Array.isArray(value);
23911
24059
  }
23912
24060
  function readJson(path) {
23913
- if (!existsSync6(path)) return {};
23914
- const text2 = readFileSync5(path, "utf8").replace(/^\uFEFF/, "");
24061
+ if (!existsSync7(path)) return {};
24062
+ const text2 = readFileSync6(path, "utf8").replace(/^\uFEFF/, "");
23915
24063
  if (!text2.trim()) return {};
23916
24064
  let value;
23917
24065
  try {
@@ -23930,13 +24078,13 @@ function readJson(path) {
23930
24078
  return value;
23931
24079
  }
23932
24080
  function writeAtomic(path, text2) {
23933
- mkdirSync5(dirname2(path), { recursive: true });
24081
+ mkdirSync6(dirname3(path), { recursive: true });
23934
24082
  const temp = `${path}.pantheon-${process.pid}.tmp`;
23935
24083
  try {
23936
- writeFileSync5(temp, text2);
24084
+ writeFileSync6(temp, text2);
23937
24085
  renameSync(temp, path);
23938
24086
  } catch (error2) {
23939
- if (existsSync6(temp)) unlinkSync2(temp);
24087
+ if (existsSync7(temp)) unlinkSync2(temp);
23940
24088
  throw error2;
23941
24089
  }
23942
24090
  }
@@ -23955,20 +24103,20 @@ function tomlString(value) {
23955
24103
  }
23956
24104
  function chatgptDesktopPath() {
23957
24105
  if (process.platform !== "darwin") return null;
23958
- return join6(homedir5(), "Library", "Application Support", "ChatGPT", "chatgpt_mcp_config.json");
24106
+ return join7(homedir5(), "Library", "Application Support", "ChatGPT", "chatgpt_mcp_config.json");
23959
24107
  }
23960
24108
  function claudeDesktopPath() {
23961
24109
  if (process.platform === "darwin") {
23962
- return join6(homedir5(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
24110
+ return join7(homedir5(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
23963
24111
  }
23964
24112
  if (process.platform === "win32") {
23965
- return join6(process.env.APPDATA || homedir5(), "Claude", "claude_desktop_config.json");
24113
+ return join7(process.env.APPDATA || homedir5(), "Claude", "claude_desktop_config.json");
23966
24114
  }
23967
- return join6(homedir5(), ".config", "Claude", "claude_desktop_config.json");
24115
+ return join7(homedir5(), ".config", "Claude", "claude_desktop_config.json");
23968
24116
  }
23969
24117
  function upsertCodex(home) {
23970
- const path = join6(homedir5(), ".codex", "config.toml");
23971
- mkdirSync5(dirname2(path), { recursive: true });
24118
+ const path = join7(homedir5(), ".codex", "config.toml");
24119
+ mkdirSync6(dirname3(path), { recursive: true });
23972
24120
  const server = mcpServer(home);
23973
24121
  const args = server.args.map(tomlString).join(", ");
23974
24122
  const block2 = [
@@ -23981,11 +24129,11 @@ function upsertCodex(home) {
23981
24129
  `PANTHEON_HOME = ${tomlString(home)}`,
23982
24130
  ""
23983
24131
  ].join("\n");
23984
- if (!existsSync6(path)) {
24132
+ if (!existsSync7(path)) {
23985
24133
  writeAtomic(path, block2);
23986
24134
  return;
23987
24135
  }
23988
- const existing = readFileSync5(path, "utf8");
24136
+ const existing = readFileSync6(path, "utf8");
23989
24137
  if (existing.includes("[mcp_servers.pantheon]")) {
23990
24138
  const next = existing.replace(
23991
24139
  /\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/,
@@ -24041,7 +24189,7 @@ Parse the rest of the argument as the fact. Only then call pantheon_remember, ev
24041
24189
  }
24042
24190
  ];
24043
24191
  function writeCodexSkill() {
24044
- const dirs2 = [join6(homedir5(), ".agents", "skills", "pantheon"), join6(homedir5(), ".codex", "skills", "pantheon")];
24192
+ const dirs2 = [join7(homedir5(), ".agents", "skills", "pantheon"), join7(homedir5(), ".codex", "skills", "pantheon")];
24045
24193
  const skill = `---
24046
24194
  name: pantheon
24047
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.
@@ -24106,17 +24254,17 @@ where the work was, which is the part the human asked for, so never fold that
24106
24254
  into cells.
24107
24255
  `;
24108
24256
  for (const dir of dirs2) {
24109
- mkdirSync5(dir, { recursive: true });
24110
- writeFileSync5(join6(dir, "SKILL.md"), skill);
24257
+ mkdirSync6(dir, { recursive: true });
24258
+ writeFileSync6(join7(dir, "SKILL.md"), skill);
24111
24259
  }
24112
24260
  }
24113
24261
  function writeSlashCommands() {
24114
- const dirs2 = [join6(homedir5(), ".cursor", "commands"), join6(homedir5(), ".claude", "commands")];
24262
+ const dirs2 = [join7(homedir5(), ".cursor", "commands"), join7(homedir5(), ".claude", "commands")];
24115
24263
  for (const dir of dirs2) {
24116
- mkdirSync5(dir, { recursive: true });
24264
+ mkdirSync6(dir, { recursive: true });
24117
24265
  for (const command of slashCommands) {
24118
- writeFileSync5(
24119
- join6(dir, `${command.name}.md`),
24266
+ writeFileSync6(
24267
+ join7(dir, `${command.name}.md`),
24120
24268
  `---
24121
24269
  description: ${command.description}
24122
24270
  ---
@@ -24139,42 +24287,42 @@ function detectApps() {
24139
24287
  const home = homedir5();
24140
24288
  const mac = process.platform === "darwin";
24141
24289
  const win = process.platform === "win32";
24142
- const local = process.env.LOCALAPPDATA || join6(home, "AppData", "Local");
24143
- const roaming = process.env.APPDATA || join6(home, "AppData", "Roaming");
24290
+ const local = process.env.LOCALAPPDATA || join7(home, "AppData", "Local");
24291
+ const roaming = process.env.APPDATA || join7(home, "AppData", "Roaming");
24144
24292
  const evidence = {
24145
24293
  Cursor: [
24146
- join6(home, ".cursor", "extensions"),
24147
- join6(home, ".cursor", "argv.json"),
24148
- join6(home, ".cursor", "cli"),
24149
- ...mac ? ["/Applications/Cursor.app", join6(home, "Applications", "Cursor.app")] : [],
24150
- ...win ? [join6(local, "Programs", "cursor")] : []
24294
+ join7(home, ".cursor", "extensions"),
24295
+ join7(home, ".cursor", "argv.json"),
24296
+ join7(home, ".cursor", "cli"),
24297
+ ...mac ? ["/Applications/Cursor.app", join7(home, "Applications", "Cursor.app")] : [],
24298
+ ...win ? [join7(local, "Programs", "cursor")] : []
24151
24299
  ],
24152
24300
  "Claude Code": [
24153
- join6(home, ".claude", "projects"),
24154
- join6(home, ".claude", "settings.json"),
24155
- join6(home, ".claude", "history.jsonl"),
24156
- join6(home, ".claude", "statsig")
24301
+ join7(home, ".claude", "projects"),
24302
+ join7(home, ".claude", "settings.json"),
24303
+ join7(home, ".claude", "history.jsonl"),
24304
+ join7(home, ".claude", "statsig")
24157
24305
  ],
24158
24306
  "Claude Desktop": [
24159
- ...mac ? ["/Applications/Claude.app", join6(home, "Applications", "Claude.app")] : [],
24160
- ...win ? [join6(local, "AnthropicClaude"), join6(roaming, "Claude", "window-state.json")] : [],
24161
- ...!mac && !win ? [join6(home, ".config", "Claude", "window-state.json")] : []
24307
+ ...mac ? ["/Applications/Claude.app", join7(home, "Applications", "Claude.app")] : [],
24308
+ ...win ? [join7(local, "AnthropicClaude"), join7(roaming, "Claude", "window-state.json")] : [],
24309
+ ...!mac && !win ? [join7(home, ".config", "Claude", "window-state.json")] : []
24162
24310
  ],
24163
- "ChatGPT.app": mac ? ["/Applications/ChatGPT.app", join6(home, "Applications", "ChatGPT.app")] : [],
24311
+ "ChatGPT.app": mac ? ["/Applications/ChatGPT.app", join7(home, "Applications", "ChatGPT.app")] : [],
24164
24312
  Codex: [
24165
- join6(home, ".codex", "sessions"),
24166
- join6(home, ".codex", "auth.json"),
24167
- join6(home, ".codex", "history.jsonl"),
24168
- join6(home, ".codex", "log")
24313
+ join7(home, ".codex", "sessions"),
24314
+ join7(home, ".codex", "auth.json"),
24315
+ join7(home, ".codex", "history.jsonl"),
24316
+ join7(home, ".codex", "log")
24169
24317
  ],
24170
24318
  Windsurf: [
24171
- join6(home, ".codeium", "windsurf"),
24172
- ...mac ? ["/Applications/Windsurf.app", join6(home, "Applications", "Windsurf.app")] : []
24319
+ join7(home, ".codeium", "windsurf"),
24320
+ ...mac ? ["/Applications/Windsurf.app", join7(home, "Applications", "Windsurf.app")] : []
24173
24321
  ]
24174
24322
  };
24175
24323
  const found = /* @__PURE__ */ new Set();
24176
24324
  for (const [name, paths] of Object.entries(evidence)) {
24177
- if (paths.some((path) => existsSync6(path))) found.add(name);
24325
+ if (paths.some((path) => existsSync7(path))) found.add(name);
24178
24326
  }
24179
24327
  return found;
24180
24328
  }
@@ -24203,25 +24351,25 @@ function installMcpClients(home) {
24203
24351
  skipped.push({ name, detail: why.replace(homedir5(), "~") });
24204
24352
  }
24205
24353
  };
24206
- install("Cursor", join6(homedir5(), ".cursor", "mcp.json"), server);
24207
- install("Claude Code", join6(homedir5(), ".claude.json"), mcpServer(home, true));
24354
+ install("Cursor", join7(homedir5(), ".cursor", "mcp.json"), server);
24355
+ install("Claude Code", join7(homedir5(), ".claude.json"), mcpServer(home, true));
24208
24356
  const desktop = claudeDesktopPath();
24209
- if (existsSync6(dirname2(desktop)) || process.platform === "darwin" || process.platform === "win32") {
24357
+ if (existsSync7(dirname3(desktop)) || process.platform === "darwin" || process.platform === "win32") {
24210
24358
  install("Claude Desktop", desktop, server);
24211
24359
  } else {
24212
24360
  skipped.push({ name: "Claude Desktop", detail: "app not found" });
24213
24361
  }
24214
24362
  const chatgpt = chatgptDesktopPath();
24215
- if (chatgpt && existsSync6(dirname2(chatgpt))) install("ChatGPT.app", chatgpt, server);
24216
- const codex = join6(homedir5(), ".codex", "config.toml");
24363
+ if (chatgpt && existsSync7(dirname3(chatgpt))) install("ChatGPT.app", chatgpt, server);
24364
+ const codex = join7(homedir5(), ".codex", "config.toml");
24217
24365
  try {
24218
24366
  upsertCodex(home);
24219
24367
  (found.has("Codex") ? written : ahead).push({ name: "Codex", detail: tilde(codex) });
24220
24368
  } catch {
24221
24369
  skipped.push({ name: "Codex", detail: `could not write ${tilde(codex)}` });
24222
24370
  }
24223
- const windsurf = join6(homedir5(), ".codeium", "windsurf", "mcp_config.json");
24224
- if (existsSync6(dirname2(windsurf))) {
24371
+ const windsurf = join7(homedir5(), ".codeium", "windsurf", "mcp_config.json");
24372
+ if (existsSync7(dirname3(windsurf))) {
24225
24373
  install("Windsurf", windsurf, server);
24226
24374
  } else {
24227
24375
  skipped.push({ name: "Windsurf", detail: "app not found" });
@@ -24238,7 +24386,7 @@ function installMcpClients(home) {
24238
24386
  return { written, ahead, skipped, found: [...found] };
24239
24387
  }
24240
24388
  function removeServerFromJson(path, key = "mcpServers") {
24241
- if (!existsSync6(path)) return false;
24389
+ if (!existsSync7(path)) return false;
24242
24390
  let current;
24243
24391
  try {
24244
24392
  current = readJson(path);
@@ -24253,9 +24401,9 @@ function removeServerFromJson(path, key = "mcpServers") {
24253
24401
  return true;
24254
24402
  }
24255
24403
  function removeCodex() {
24256
- const path = join6(homedir5(), ".codex", "config.toml");
24257
- if (!existsSync6(path)) return false;
24258
- const existing = readFileSync5(path, "utf8");
24404
+ const path = join7(homedir5(), ".codex", "config.toml");
24405
+ if (!existsSync7(path)) return false;
24406
+ const existing = readFileSync6(path, "utf8");
24259
24407
  if (!existing.includes("[mcp_servers.pantheon]")) return false;
24260
24408
  const next = existing.replace(/\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/, "").replace(/\n{3,}/g, "\n\n").trimEnd();
24261
24409
  writeAtomic(path, next ? `${next}
@@ -24263,12 +24411,12 @@ function removeCodex() {
24263
24411
  return true;
24264
24412
  }
24265
24413
  function removeSlashCommands() {
24266
- const dirs2 = [join6(homedir5(), ".cursor", "commands"), join6(homedir5(), ".claude", "commands")];
24414
+ const dirs2 = [join7(homedir5(), ".cursor", "commands"), join7(homedir5(), ".claude", "commands")];
24267
24415
  let removed = 0;
24268
24416
  for (const dir of dirs2) {
24269
24417
  for (const command of slashCommands) {
24270
- const file = join6(dir, `${command.name}.md`);
24271
- if (!existsSync6(file)) continue;
24418
+ const file = join7(dir, `${command.name}.md`);
24419
+ if (!existsSync7(file)) continue;
24272
24420
  unlinkSync2(file);
24273
24421
  removed += 1;
24274
24422
  }
@@ -24277,32 +24425,32 @@ function removeSlashCommands() {
24277
24425
  }
24278
24426
  function uninstallMcpClients() {
24279
24427
  const removed = [];
24280
- if (removeServerFromJson(join6(homedir5(), ".cursor", "mcp.json"))) removed.push("Cursor");
24281
- if (removeServerFromJson(join6(homedir5(), ".claude.json"))) removed.push("Claude Code");
24428
+ if (removeServerFromJson(join7(homedir5(), ".cursor", "mcp.json"))) removed.push("Cursor");
24429
+ if (removeServerFromJson(join7(homedir5(), ".claude.json"))) removed.push("Claude Code");
24282
24430
  if (removeServerFromJson(claudeDesktopPath())) removed.push("Claude Desktop");
24283
24431
  const chatgpt = chatgptDesktopPath();
24284
24432
  if (chatgpt && removeServerFromJson(chatgpt)) removed.push("ChatGPT.app (shared MCP file)");
24285
24433
  if (removeCodex()) removed.push("ChatGPT.app / Codex");
24286
- if (removeServerFromJson(join6(homedir5(), ".codeium", "windsurf", "mcp_config.json"))) {
24434
+ if (removeServerFromJson(join7(homedir5(), ".codeium", "windsurf", "mcp_config.json"))) {
24287
24435
  removed.push("Windsurf");
24288
24436
  }
24289
24437
  const slash2 = removeSlashCommands();
24290
24438
  if (slash2) removed.push("/pantheon-* commands");
24291
24439
  for (const dir of [
24292
- join6(homedir5(), ".agents", "skills", "pantheon"),
24293
- join6(homedir5(), ".codex", "skills", "pantheon")
24440
+ join7(homedir5(), ".agents", "skills", "pantheon"),
24441
+ join7(homedir5(), ".codex", "skills", "pantheon")
24294
24442
  ]) {
24295
- const file = join6(dir, "SKILL.md");
24296
- if (!existsSync6(file)) continue;
24443
+ const file = join7(dir, "SKILL.md");
24444
+ if (!existsSync7(file)) continue;
24297
24445
  unlinkSync2(file);
24298
24446
  removed.push("ChatGPT / Codex skill");
24299
24447
  break;
24300
24448
  }
24301
24449
  for (const launcher of [
24302
- join6(homedir5(), ".local", "bin", "pantheon-mcp"),
24303
- join6(homedir5(), ".local", "bin", "pantheon-mcp.cmd")
24450
+ join7(homedir5(), ".local", "bin", "pantheon-mcp"),
24451
+ join7(homedir5(), ".local", "bin", "pantheon-mcp.cmd")
24304
24452
  ]) {
24305
- if (!existsSync6(launcher)) continue;
24453
+ if (!existsSync7(launcher)) continue;
24306
24454
  unlinkSync2(launcher);
24307
24455
  removed.push("pantheon-mcp launcher");
24308
24456
  }
@@ -24385,18 +24533,18 @@ async function connect(opts) {
24385
24533
  },
24386
24534
  { machineSecret: body.machineSecret }
24387
24535
  );
24388
- mkdirSync6(home, { recursive: true });
24389
- const helper = credentialHelperCommand();
24536
+ mkdirSync7(home, { recursive: true });
24537
+ const auth = authArgs();
24390
24538
  const quiet = { stdio: ["ignore", "pipe", "pipe"] };
24391
- const fresh = !existsSync7(join7(home, ".git"));
24539
+ const fresh = !existsSync8(join8(home, ".git"));
24392
24540
  let archived = "";
24393
24541
  if (fresh) {
24394
24542
  process.stdout.write(" Cloning the vault\u2026\n");
24395
- execFileSync3("git", ["-c", `credential.helper=${helper}`, "clone", body.cloneUrl, home], quiet);
24543
+ execFileSync3("git", [...auth, "clone", body.cloneUrl, home], quiet);
24396
24544
  } else {
24397
- archived = syncVault2(home, body.cloneUrl, helper, quiet);
24545
+ archived = syncVault2(home, body.cloneUrl, auth, quiet);
24398
24546
  }
24399
- execFileSync3("git", ["-C", home, "config", "credential.helper", helper], quiet);
24547
+ claimCredentials(home, quiet);
24400
24548
  execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
24401
24549
  execFileSync3("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
24402
24550
  let written = [];
@@ -24429,14 +24577,14 @@ async function connect(opts) {
24429
24577
  )
24430
24578
  );
24431
24579
  }
24432
- function syncVault2(home, cloneUrl, helper, quiet) {
24433
- const git2 = (...args) => execFileSync3("git", ["-c", `credential.helper=${helper}`, "-C", home, ...args], quiet);
24434
- retarget2(home, cloneUrl, quiet);
24580
+ function syncVault2(home, cloneUrl, auth, quiet) {
24581
+ const git2 = (...args) => execFileSync3("git", [...auth, "-C", home, ...args], quiet);
24582
+ retarget(home, cloneUrl, quiet);
24435
24583
  try {
24436
24584
  git2("pull", "--ff-only");
24437
24585
  return "";
24438
24586
  } catch (error2) {
24439
- if (!existsSync7(join7(home, ".git"))) throw error2;
24587
+ if (!existsSync8(join8(home, ".git"))) throw error2;
24440
24588
  }
24441
24589
  if (sharesHistory(home)) {
24442
24590
  process.stdout.write(" Merging work from another machine\u2026\n");
@@ -24447,10 +24595,10 @@ function syncVault2(home, cloneUrl, helper, quiet) {
24447
24595
  const archive = `${home}-${stamp2}`;
24448
24596
  process.stdout.write(" Vault belongs to a different repo; setting it aside\u2026\n");
24449
24597
  renameSync2(home, archive);
24450
- execFileSync3("git", ["-c", `credential.helper=${helper}`, "clone", cloneUrl, home], quiet);
24598
+ execFileSync3("git", [...auth, "clone", cloneUrl, home], quiet);
24451
24599
  return archive;
24452
24600
  }
24453
- function retarget2(home, cloneUrl, quiet) {
24601
+ function retarget(home, cloneUrl, quiet) {
24454
24602
  try {
24455
24603
  execFileSync3("git", ["-C", home, "remote", "set-url", "origin", cloneUrl], quiet);
24456
24604
  } catch {
@@ -24478,6 +24626,17 @@ function vaultNote(fresh, archived) {
24478
24626
  function credentialHelperCommand() {
24479
24627
  return "!pantheon git-credential";
24480
24628
  }
24629
+ function authArgs() {
24630
+ return ["-c", "credential.helper=", "-c", `credential.helper=${credentialHelperCommand()}`];
24631
+ }
24632
+ function claimCredentials(home, quiet) {
24633
+ execFileSync3("git", ["-C", home, "config", "--replace-all", "credential.helper", ""], quiet);
24634
+ execFileSync3(
24635
+ "git",
24636
+ ["-C", home, "config", "--add", "credential.helper", credentialHelperCommand()],
24637
+ quiet
24638
+ );
24639
+ }
24481
24640
 
24482
24641
  // src/bootstrap.ts
24483
24642
  function log(message) {
@@ -24545,9 +24704,10 @@ async function bootstrapFromToken(token, opts = {}) {
24545
24704
  }
24546
24705
 
24547
24706
  // src/credential.ts
24548
- async function handleGitCredential() {
24549
- const input = await readStdin();
24550
- if (!input.startsWith("get")) return;
24707
+ async function handleGitCredential(operation) {
24708
+ if (operation !== "get") return;
24709
+ const request = parse3(await readStdin());
24710
+ if (request.host && request.host !== "github.com") return;
24551
24711
  const stored = loadMachineConfig();
24552
24712
  if (!stored) return;
24553
24713
  const res = await fetch(`${stored.config.apiUrl}/api/cli/token`, {
@@ -24562,6 +24722,14 @@ async function handleGitCredential() {
24562
24722
  password=${body.token}
24563
24723
  `);
24564
24724
  }
24725
+ function parse3(input) {
24726
+ const fields = {};
24727
+ for (const line of input.split("\n")) {
24728
+ const eq = line.indexOf("=");
24729
+ if (eq > 0) fields[line.slice(0, eq).trim()] = line.slice(eq + 1).trim();
24730
+ }
24731
+ return fields;
24732
+ }
24565
24733
  function readStdin() {
24566
24734
  return new Promise((resolve3) => {
24567
24735
  let data = "";
@@ -24632,7 +24800,7 @@ function printSpaces() {
24632
24800
  }
24633
24801
 
24634
24802
  // src/status.ts
24635
- import { existsSync as existsSync8 } from "node:fs";
24803
+ import { existsSync as existsSync9 } from "node:fs";
24636
24804
  function printStatus() {
24637
24805
  const stored = loadMachineConfig();
24638
24806
  if (!stored) {
@@ -24646,7 +24814,7 @@ function printStatus() {
24646
24814
  field("GitHub", config2.account),
24647
24815
  field("Install", String(config2.installationId)),
24648
24816
  field("Repo", `${config2.repo} (private)`),
24649
- field("Vault", `${config2.home}${existsSync8(config2.home) ? "" : " (missing)"}`),
24817
+ field("Vault", `${config2.home}${existsSync9(config2.home) ? "" : " (missing)"}`),
24650
24818
  field("API", config2.apiUrl),
24651
24819
  field("Machine", config2.machineId)
24652
24820
  ].join("\n")
@@ -24666,6 +24834,13 @@ async function sync() {
24666
24834
  result.pushed ? "pushed" : null
24667
24835
  ].filter(Boolean);
24668
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}`);
24843
+ }
24669
24844
  }
24670
24845
 
24671
24846
  // src/index.ts
@@ -24790,7 +24965,7 @@ async function main() {
24790
24965
  return;
24791
24966
  }
24792
24967
  if (cmd === "git-credential") {
24793
- await handleGitCredential();
24968
+ await handleGitCredential(rest[0]);
24794
24969
  return;
24795
24970
  }
24796
24971
  printError(new Error(`Unknown command: ${cmd}. Run pantheon help.`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.2.23",
3
+ "version": "0.2.27",
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",