pantheon-cli 0.1.0 → 0.1.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 +229 -72
  2. package/package.json +1 -1
package/dist/pantheon.mjs CHANGED
@@ -5436,7 +5436,7 @@ var require_contains = __commonJS({
5436
5436
  const count = gen.let("count", 0);
5437
5437
  validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
5438
5438
  }
5439
- function validateItems(_valid, block) {
5439
+ function validateItems(_valid, block2) {
5440
5440
  gen.forRange("i", 0, len, (i) => {
5441
5441
  cxt.subschema({
5442
5442
  keyword: "contains",
@@ -5444,7 +5444,7 @@ var require_contains = __commonJS({
5444
5444
  dataPropType: util_1.Type.Num,
5445
5445
  compositeRule: true
5446
5446
  }, _valid);
5447
- block();
5447
+ block2();
5448
5448
  });
5449
5449
  }
5450
5450
  function checkLimits(count) {
@@ -12806,10 +12806,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
12806
12806
  const shape = def.shape;
12807
12807
  const propValues = {};
12808
12808
  for (const key in shape) {
12809
- const field = shape[key]._zod;
12810
- if (field.values) {
12809
+ const field2 = shape[key]._zod;
12810
+ if (field2.values) {
12811
12811
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
12812
- for (const v of field.values)
12812
+ for (const v of field2.values)
12813
12813
  propValues[key].add(v);
12814
12814
  }
12815
12815
  }
@@ -20623,11 +20623,11 @@ var McpServer = class {
20623
20623
  return EMPTY_COMPLETION_RESULT;
20624
20624
  }
20625
20625
  const promptShape = getObjectShape(prompt.argsSchema);
20626
- const field = promptShape?.[request.params.argument.name];
20627
- if (!isCompletable(field)) {
20626
+ const field2 = promptShape?.[request.params.argument.name];
20627
+ if (!isCompletable(field2)) {
20628
20628
  return EMPTY_COMPLETION_RESULT;
20629
20629
  }
20630
- const completer = getCompleter(field);
20630
+ const completer = getCompleter(field2);
20631
20631
  if (!completer) {
20632
20632
  return EMPTY_COMPLETION_RESULT;
20633
20633
  }
@@ -20900,8 +20900,8 @@ var McpServer = class {
20900
20900
  };
20901
20901
  this._registeredPrompts[name] = registeredPrompt;
20902
20902
  if (argsSchema) {
20903
- const hasCompletable = Object.values(argsSchema).some((field) => {
20904
- const inner = field instanceof ZodOptional ? field._def?.innerType : field;
20903
+ const hasCompletable = Object.values(argsSchema).some((field2) => {
20904
+ const inner = field2 instanceof ZodOptional ? field2._def?.innerType : field2;
20905
20905
  return isCompletable(inner);
20906
20906
  });
20907
20907
  if (hasCompletable) {
@@ -21110,9 +21110,9 @@ function promptArgumentsFromSchema(schema) {
21110
21110
  const shape = getObjectShape(schema);
21111
21111
  if (!shape)
21112
21112
  return [];
21113
- return Object.entries(shape).map(([name, field]) => {
21114
- const description = getSchemaDescription(field);
21115
- const isOptional = isSchemaOptional(field);
21113
+ return Object.entries(shape).map(([name, field2]) => {
21114
+ const description = getSchemaDescription(field2);
21115
+ const isOptional = isSchemaOptional(field2);
21116
21116
  return {
21117
21117
  name,
21118
21118
  description,
@@ -21656,12 +21656,12 @@ function parseTurns(transcript) {
21656
21656
  toolCalls: turn.toolCalls
21657
21657
  }));
21658
21658
  }
21659
- return transcript.split(/\n{2,}/).map((block, index) => {
21660
- const match = block.match(/^(user|assistant|system)\s*:\s*([\s\S]+)/i);
21659
+ return transcript.split(/\n{2,}/).map((block2, index) => {
21660
+ const match = block2.match(/^(user|assistant|system)\s*:\s*([\s\S]+)/i);
21661
21661
  return {
21662
21662
  id: index + 1,
21663
21663
  role: match?.[1]?.toLowerCase() || "user",
21664
- text: (match?.[2] || block).trim(),
21664
+ text: (match?.[2] || block2).trim(),
21665
21665
  ts: nowIso()
21666
21666
  };
21667
21667
  }).filter((turn) => turn.text);
@@ -21764,6 +21764,110 @@ function collectDiskArtifacts(turns) {
21764
21764
  }
21765
21765
  return found;
21766
21766
  }
21767
+ var WRITE_TOOL = /write|edit|patch|notebook|replace|create|save/i;
21768
+ var PATH_KEYS = [
21769
+ "path",
21770
+ "file_path",
21771
+ "filePath",
21772
+ "target_file",
21773
+ "target_notebook",
21774
+ "notebook_path",
21775
+ "absolute_path"
21776
+ ];
21777
+ function pathsFromPatch(input) {
21778
+ const body = typeof input === "string" ? input : input && typeof input === "object" ? String(input.input ?? input.patch ?? "") : "";
21779
+ if (!body.includes("***")) return [];
21780
+ const found = [];
21781
+ for (const match of body.matchAll(/^\*\*\*\s+(?:Add|Update|Move to) File:\s*(.+)$/gm)) {
21782
+ const path = match[1].trim();
21783
+ if (path) found.push(path);
21784
+ }
21785
+ return found;
21786
+ }
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;
21790
+ var MAX_WRITTEN_COUNT = 200;
21791
+ function pathFromInput(input) {
21792
+ if (!input || typeof input !== "object") return null;
21793
+ const record2 = input;
21794
+ for (const key of PATH_KEYS) {
21795
+ const value = record2[key];
21796
+ if (typeof value === "string" && value.trim()) return value.trim();
21797
+ }
21798
+ return null;
21799
+ }
21800
+ 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, "_");
21803
+ }
21804
+ function readArtifactFile(path, base) {
21805
+ const stat = statSync2(path);
21806
+ if (!stat.isFile() || stat.size === 0 || stat.size > MAX_WRITTEN_FILE) return null;
21807
+ const buf = readFileSync2(path);
21808
+ const binary = buf.includes(0);
21809
+ return {
21810
+ name: flatName(path, base),
21811
+ content: binary ? buf.toString("base64") : buf.toString("utf8"),
21812
+ encoding: binary ? "base64" : "utf8",
21813
+ bytes: stat.size
21814
+ };
21815
+ }
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);
21822
+ };
21823
+ for (const turn of turns) {
21824
+ 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);
21829
+ }
21830
+ }
21831
+ const found = [];
21832
+ let total = 0;
21833
+ for (const path of latest) {
21834
+ if (found.length >= MAX_WRITTEN_COUNT || total >= MAX_WRITTEN_TOTAL) break;
21835
+ 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 });
21841
+ } catch {
21842
+ }
21843
+ }
21844
+ return found;
21845
+ }
21846
+ function collectAttachedArtifacts(turns, cwd = process.cwd()) {
21847
+ const base = cwd.endsWith("/") ? cwd : `${cwd}/`;
21848
+ const paths = /* @__PURE__ */ new Set();
21849
+ for (const turn of turns) {
21850
+ 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);
21854
+ }
21855
+ }
21856
+ const found = [];
21857
+ let total = 0;
21858
+ for (const path of paths) {
21859
+ if (found.length >= 40 || total >= MAX_WRITTEN_TOTAL) break;
21860
+ try {
21861
+ if (!existsSync2(path)) continue;
21862
+ const file = readArtifactFile(path, base);
21863
+ if (!file) continue;
21864
+ total += file.bytes;
21865
+ found.push({ name: file.name, content: file.content, encoding: file.encoding });
21866
+ } catch {
21867
+ }
21868
+ }
21869
+ return found;
21870
+ }
21767
21871
  function missingGeneratedFiles(turns, artifacts = []) {
21768
21872
  const mentioned = mentionedDocuments(turns).map((doc) => doc.name);
21769
21873
  if (!mentioned.length) return null;
@@ -21945,10 +22049,13 @@ function writeHandoff(home, input) {
21945
22049
  const thin = transcriptLooksThin(turns);
21946
22050
  if (thin) throw new Error(thin);
21947
22051
  }
22052
+ const cwd = input.cwd || process.cwd();
21948
22053
  const artifacts = mergeArtifacts(
21949
22054
  input.artifacts,
21950
22055
  extractFencedArtifacts(turns),
21951
- collectDiskArtifacts(turns)
22056
+ collectDiskArtifacts(turns),
22057
+ captured ? collectWrittenArtifacts(turns, cwd) : void 0,
22058
+ captured ? collectAttachedArtifacts(turns, cwd) : void 0
21952
22059
  );
21953
22060
  if (!captured) {
21954
22061
  const missing = missingGeneratedFiles(turns, artifacts);
@@ -22796,7 +22903,7 @@ function upsertCodex(home) {
22796
22903
  mkdirSync4(dirname2(path), { recursive: true });
22797
22904
  const server = mcpServer(home);
22798
22905
  const args = server.args.map(tomlString).join(", ");
22799
- const block = [
22906
+ const block2 = [
22800
22907
  "[mcp_servers.pantheon]",
22801
22908
  `command = ${tomlString(String(server.command))}`,
22802
22909
  `args = [${args}]`,
@@ -22807,14 +22914,14 @@ function upsertCodex(home) {
22807
22914
  ""
22808
22915
  ].join("\n");
22809
22916
  if (!existsSync5(path)) {
22810
- writeFileSync4(path, block);
22917
+ writeFileSync4(path, block2);
22811
22918
  return;
22812
22919
  }
22813
22920
  const existing = readFileSync4(path, "utf8");
22814
22921
  if (existing.includes("[mcp_servers.pantheon]")) {
22815
22922
  const next = existing.replace(
22816
22923
  /\[mcp_servers\.pantheon\][\s\S]*?(?=\n\[(?!mcp_servers\.pantheon)|\s*$)/,
22817
- block.trim()
22924
+ block2.trim()
22818
22925
  );
22819
22926
  writeFileSync4(path, next.endsWith("\n") ? next : `${next}
22820
22927
  `);
@@ -22822,7 +22929,7 @@ function upsertCodex(home) {
22822
22929
  }
22823
22930
  writeFileSync4(path, `${existing.trimEnd()}
22824
22931
 
22825
- ${block}`);
22932
+ ${block2}`);
22826
22933
  }
22827
22934
  var spaceGate = 'A space is the short name the human chose for a conscience (preorders, auth-refactor). The argument is: $ARGUMENTS\n\nIf that value is missing, empty, still says $ARGUMENTS, contains spaces, or is not a single short name, do not call any tool. Ask: "What should this conscience be named?" and wait. Never invent a name.';
22828
22935
  var slashCommands = [
@@ -22915,43 +23022,55 @@ function installAgentAssets() {
22915
23022
  writeSlashCommands();
22916
23023
  writeCodexSkill();
22917
23024
  }
23025
+ function tilde(path) {
23026
+ const home = homedir5();
23027
+ return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
23028
+ }
22918
23029
  function installMcpClients(home) {
22919
23030
  const written = [];
22920
23031
  const skipped = [];
22921
23032
  const server = mcpServer(home);
22922
- mergeMcpJson(join5(homedir5(), ".cursor", "mcp.json"), home, server);
22923
- written.push("Cursor");
22924
- mergeMcpJson(join5(homedir5(), ".claude.json"), home, mcpServer(home, true));
22925
- written.push("Claude Code");
23033
+ const cursor = join5(homedir5(), ".cursor", "mcp.json");
23034
+ mergeMcpJson(cursor, home, server);
23035
+ written.push({ name: "Cursor", detail: tilde(cursor) });
23036
+ const claudeCode = join5(homedir5(), ".claude.json");
23037
+ mergeMcpJson(claudeCode, home, mcpServer(home, true));
23038
+ written.push({ name: "Claude Code", detail: tilde(claudeCode) });
22926
23039
  const desktop = claudeDesktopPath();
22927
23040
  if (existsSync5(dirname2(desktop)) || process.platform === "darwin" || process.platform === "win32") {
22928
23041
  mergeMcpJson(desktop, home, server);
22929
- written.push("Claude Desktop");
23042
+ written.push({ name: "Claude Desktop", detail: tilde(desktop) });
22930
23043
  } else {
22931
- skipped.push("Claude Desktop (app not found)");
23044
+ skipped.push({ name: "Claude Desktop", detail: "app not found" });
22932
23045
  }
22933
23046
  const chatgpt = chatgptDesktopPath();
22934
23047
  if (chatgpt && existsSync5(dirname2(chatgpt))) {
22935
23048
  mergeMcpJson(chatgpt, home, server);
22936
- written.push("ChatGPT.app (shared MCP file)");
23049
+ written.push({ name: "ChatGPT.app", detail: tilde(chatgpt) });
22937
23050
  }
23051
+ const codex = join5(homedir5(), ".codex", "config.toml");
22938
23052
  try {
22939
23053
  upsertCodex(home);
22940
- written.push(process.platform === "darwin" ? "ChatGPT.app / Codex" : "Codex");
23054
+ written.push({ name: "Codex", detail: tilde(codex) });
22941
23055
  } catch {
22942
- skipped.push(process.platform === "darwin" ? "ChatGPT.app / Codex" : "Codex");
23056
+ skipped.push({ name: "Codex", detail: `could not write ${tilde(codex)}` });
22943
23057
  }
22944
- skipped.push("ChatGPT Classic (no local MCP \u2014 use ChatGPT.app Chat or Codex)");
22945
- skipped.push("Replit Desktop (add the HTTPS MCP URL from Settings \u2192 Replit Desktop)");
22946
23058
  const windsurf = join5(homedir5(), ".codeium", "windsurf", "mcp_config.json");
22947
23059
  if (existsSync5(dirname2(windsurf))) {
22948
23060
  mergeMcpJson(windsurf, home, server);
22949
- written.push("Windsurf");
23061
+ written.push({ name: "Windsurf", detail: tilde(windsurf) });
23062
+ } else {
23063
+ skipped.push({ name: "Windsurf", detail: "app not found" });
22950
23064
  }
22951
23065
  writeSlashCommands();
22952
23066
  writeCodexSkill();
22953
- written.push("/pantheon-* commands");
22954
- written.push("ChatGPT / Codex skill");
23067
+ written.push({ name: "/pantheon-* commands", detail: "~/.cursor, ~/.claude" });
23068
+ written.push({ name: "Agent skill", detail: "~/.agents, ~/.codex" });
23069
+ skipped.push({ name: "ChatGPT Classic", detail: "no local MCP \u2014 use ChatGPT.app or Codex" });
23070
+ skipped.push({
23071
+ name: "Replit Desktop",
23072
+ detail: "add the HTTPS URL from Settings \u2192 Connect an agent"
23073
+ });
22955
23074
  return { written, skipped };
22956
23075
  }
22957
23076
  function removeServerFromJson(path, key = "mcpServers") {
@@ -23026,6 +23145,28 @@ function installMcpFromConfig() {
23026
23145
  return installMcpClients(stored.config.home);
23027
23146
  }
23028
23147
 
23148
+ // src/report.ts
23149
+ var LABEL = 12;
23150
+ var NAME = 22;
23151
+ function field(label, value) {
23152
+ return ` ${label.padEnd(LABEL)}${value}`;
23153
+ }
23154
+ function block(title, entries) {
23155
+ if (!entries.length) return "";
23156
+ const lines = [` ${title}`];
23157
+ for (const entry of entries) {
23158
+ lines.push(
23159
+ entry.detail ? ` ${entry.name.padEnd(NAME)}${entry.detail}` : ` ${entry.name}`
23160
+ );
23161
+ }
23162
+ return lines.join("\n");
23163
+ }
23164
+ function report(...sections) {
23165
+ return `
23166
+ ${sections.filter(Boolean).join("\n\n")}
23167
+ `;
23168
+ }
23169
+
23029
23170
  // src/connect.ts
23030
23171
  var PRODUCTION_API_URL = "https://pantheon-ui-web.vercel.app";
23031
23172
  function candidateHosts(explicit) {
@@ -23073,36 +23214,44 @@ async function connect(opts) {
23073
23214
  );
23074
23215
  mkdirSync5(home, { recursive: true });
23075
23216
  const helper = credentialHelperCommand();
23076
- if (!existsSync6(join6(home, ".git"))) {
23077
- process.stdout.write(" Cloning\u2026\n");
23078
- execFileSync2("git", ["-c", `credential.helper=${helper}`, "clone", body.cloneUrl, home], {
23079
- stdio: "inherit"
23080
- });
23217
+ const quiet = { stdio: ["ignore", "pipe", "pipe"] };
23218
+ const fresh = !existsSync6(join6(home, ".git"));
23219
+ if (fresh) {
23220
+ process.stdout.write(" Cloning the vault\u2026\n");
23221
+ execFileSync2("git", ["-c", `credential.helper=${helper}`, "clone", body.cloneUrl, home], quiet);
23081
23222
  } else {
23082
- execFileSync2("git", ["-c", `credential.helper=${helper}`, "-C", home, "pull", "--ff-only"], {
23083
- stdio: "inherit"
23084
- });
23223
+ execFileSync2(
23224
+ "git",
23225
+ ["-c", `credential.helper=${helper}`, "-C", home, "pull", "--ff-only"],
23226
+ quiet
23227
+ );
23085
23228
  }
23086
- execFileSync2("git", ["-C", home, "config", "credential.helper", helper]);
23087
- execFileSync2("git", ["-C", home, "config", "user.name", "Pantheon"]);
23088
- execFileSync2("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"]);
23089
- let mcpNote = "MCP config failed";
23229
+ execFileSync2("git", ["-C", home, "config", "credential.helper", helper], quiet);
23230
+ execFileSync2("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
23231
+ execFileSync2("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
23232
+ let written = [];
23233
+ let skipped = [];
23234
+ let failure = "";
23090
23235
  try {
23091
23236
  const result = installMcpClients(home);
23092
- mcpNote = result.written.join(", ");
23093
- if (result.skipped.length) mcpNote += ` \xB7 skipped ${result.skipped.join(", ")}`;
23237
+ written = result.written;
23238
+ skipped = result.skipped;
23094
23239
  } catch (error2) {
23095
- mcpNote = error2 instanceof Error ? error2.message : String(error2);
23096
- }
23097
- console.log(`
23098
- Connected ${body.account}
23099
- Install ${body.installationId}
23100
- Repo ${body.repo} (private)
23101
- Home ${home}
23102
- MCP ${mcpNote}
23103
-
23104
- Reload MCP in each app, then type /pantheon-handoff <space>
23105
- `);
23240
+ failure = error2 instanceof Error ? error2.message : String(error2);
23241
+ }
23242
+ console.log(
23243
+ report(
23244
+ [
23245
+ field("Connected", body.account),
23246
+ field("Install", String(body.installationId)),
23247
+ field("Repo", `${body.repo} (private)`),
23248
+ field("Vault", `${home}${fresh ? " (cloned)" : " (updated)"}`)
23249
+ ].join("\n"),
23250
+ failure ? field("MCP", `failed \u2014 ${failure}`) : block("Configured", written),
23251
+ block("Skipped", skipped),
23252
+ " Reload MCP in each app, then type /pantheon-handoff <space>"
23253
+ )
23254
+ );
23106
23255
  }
23107
23256
  function credentialHelperCommand() {
23108
23257
  return "!pantheon git-credential";
@@ -23265,18 +23414,22 @@ import { existsSync as existsSync7 } from "node:fs";
23265
23414
  function printStatus() {
23266
23415
  const stored = loadMachineConfig();
23267
23416
  if (!stored) {
23268
- console.log(" Not connected. Open the web app and paste the install command.");
23417
+ console.log("\n Not connected. Open the web app and paste the install command.\n");
23269
23418
  return;
23270
23419
  }
23271
23420
  const { config: config2 } = stored;
23272
- console.log(`
23273
- GitHub ${config2.account}
23274
- Install ${config2.installationId}
23275
- Repo ${config2.repo} (private)
23276
- Home ${config2.home}${existsSync7(config2.home) ? "" : " (missing)"}
23277
- API ${config2.apiUrl}
23278
- Machine ${config2.machineId}
23279
- `);
23421
+ console.log(
23422
+ report(
23423
+ [
23424
+ field("GitHub", config2.account),
23425
+ field("Install", String(config2.installationId)),
23426
+ field("Repo", `${config2.repo} (private)`),
23427
+ field("Vault", `${config2.home}${existsSync7(config2.home) ? "" : " (missing)"}`),
23428
+ field("API", config2.apiUrl),
23429
+ field("Machine", config2.machineId)
23430
+ ].join("\n")
23431
+ )
23432
+ );
23280
23433
  }
23281
23434
 
23282
23435
  // src/sync.ts
@@ -23361,9 +23514,13 @@ async function main() {
23361
23514
  }
23362
23515
  if (cmd === "mcp-install") {
23363
23516
  const result = installMcpFromConfig();
23364
- console.log(` MCP ${result.written.join(", ")}`);
23365
- if (result.skipped.length) console.log(` Skipped ${result.skipped.join(", ")}`);
23366
- console.log("\n Reload MCP in each app, then type /pantheon-handoff <space>\n");
23517
+ console.log(
23518
+ report(
23519
+ block("Configured", result.written),
23520
+ block("Skipped", result.skipped),
23521
+ " Reload MCP in each app, then type /pantheon-handoff <space>"
23522
+ )
23523
+ );
23367
23524
  return;
23368
23525
  }
23369
23526
  if (cmd === "mcp-uninstall") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.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",