pantheon-cli 0.2.14 → 0.2.15

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 +60 -29
  2. package/package.json +1 -1
package/dist/pantheon.mjs CHANGED
@@ -21272,6 +21272,7 @@ import {
21272
21272
  writeFileSync as writeFileSync2,
21273
21273
  appendFileSync
21274
21274
  } from "node:fs";
21275
+ import { execFileSync } from "node:child_process";
21275
21276
  import { homedir as homedir2 } from "node:os";
21276
21277
  import { basename as basename2, isAbsolute, join as join3, relative, resolve } from "node:path";
21277
21278
 
@@ -22231,6 +22232,23 @@ function readArtifactFile(path, base) {
22231
22232
  bytes: stat.size
22232
22233
  };
22233
22234
  }
22235
+ function trackedFiles(base) {
22236
+ try {
22237
+ const out = execFileSync("git", ["-C", base, "ls-files", "-z"], {
22238
+ encoding: "utf8",
22239
+ maxBuffer: 64 * 1024 * 1024,
22240
+ stdio: ["ignore", "pipe", "ignore"]
22241
+ });
22242
+ return new Set(
22243
+ out.split("\0").filter(Boolean).map((relative2) => slash(join3(base, relative2)))
22244
+ );
22245
+ } catch {
22246
+ return null;
22247
+ }
22248
+ }
22249
+ function budgetReason(tracked, limit) {
22250
+ return tracked ? `already tracked by git, so the ${limit} went to files that are not` : `over the ${limit}`;
22251
+ }
22234
22252
  function collectWrittenArtifacts(turns, cwd = process.cwd(), opts = {}) {
22235
22253
  const base = slash(resolve(cwd));
22236
22254
  const since = opts.since ?? null;
@@ -22260,11 +22278,13 @@ function collectWrittenArtifacts(turns, cwd = process.cwd(), opts = {}) {
22260
22278
  }
22261
22279
  const found = [];
22262
22280
  const skipped = [];
22281
+ let skippedTotal = 0;
22263
22282
  let total = 0;
22264
22283
  const note = (path, reason) => {
22284
+ skippedTotal += 1;
22265
22285
  if (skipped.length < MAX_SKIP_REPORT) skipped.push({ name: flatName(path, base), reason });
22266
22286
  };
22267
- const store = (path, gate) => {
22287
+ const store = (path, gate, tracked2) => {
22268
22288
  if (!existsSync3(path)) return;
22269
22289
  const stat = statSync2(path);
22270
22290
  if (!stat.isFile() || stat.size === 0) return;
@@ -22276,8 +22296,15 @@ function collectWrittenArtifacts(turns, cwd = process.cwd(), opts = {}) {
22276
22296
  );
22277
22297
  return;
22278
22298
  }
22279
- if (found.length >= MAX_WRITTEN_COUNT || total + stat.size > MAX_WRITTEN_TOTAL) {
22280
- note(path, "this handoff's artifact budget was full");
22299
+ if (found.length >= MAX_WRITTEN_COUNT) {
22300
+ note(path, budgetReason(tracked2, `${MAX_WRITTEN_COUNT}-file limit for one handoff`));
22301
+ return;
22302
+ }
22303
+ if (total + stat.size > MAX_WRITTEN_TOTAL) {
22304
+ note(
22305
+ path,
22306
+ budgetReason(tracked2, `${MAX_WRITTEN_TOTAL / 1024 / 1024}MB total limit for one handoff`)
22307
+ );
22281
22308
  return;
22282
22309
  }
22283
22310
  const file = readArtifactFile(path, base);
@@ -22285,20 +22312,19 @@ function collectWrittenArtifacts(turns, cwd = process.cwd(), opts = {}) {
22285
22312
  total += file.bytes;
22286
22313
  found.push({ name: file.name, content: file.content, encoding: file.encoding });
22287
22314
  };
22288
- for (const path of written) {
22289
- try {
22290
- store(path, false);
22291
- } catch {
22292
- }
22293
- }
22294
- for (const path of touched) {
22295
- if (written.has(path)) continue;
22315
+ const tracked = trackedFiles(base);
22316
+ const queue = [
22317
+ ...[...written].map((path) => ({ path, gate: false })),
22318
+ ...[...touched].filter((path) => !written.has(path)).map((path) => ({ path, gate: true }))
22319
+ ].map((item) => ({ ...item, tracked: tracked?.has(item.path) ?? false }));
22320
+ queue.sort((a, b) => Number(a.tracked) - Number(b.tracked));
22321
+ for (const item of queue) {
22296
22322
  try {
22297
- store(path, true);
22323
+ store(item.path, item.gate, item.tracked);
22298
22324
  } catch {
22299
22325
  }
22300
22326
  }
22301
- return { artifacts: found, skipped };
22327
+ return { artifacts: found, skipped, skippedTotal };
22302
22328
  }
22303
22329
  function collectAttachedArtifacts(turns, cwd = process.cwd()) {
22304
22330
  const base = slash(resolve(cwd));
@@ -22641,6 +22667,9 @@ function writeHandoff(home, input) {
22641
22667
  // Files this session made that the archive would not take. Silence here is
22642
22668
  // how a handoff comes to promise more than it holds.
22643
22669
  skipped: sweep?.skipped ?? [],
22670
+ // The list above is capped. Reporting its length as the total understates
22671
+ // the loss by however many it left out.
22672
+ skippedTotal: sweep?.skippedTotal ?? 0,
22644
22673
  // Usually empty. Only a failure that recurred across separate conversations
22645
22674
  // and is not already documented gets this far.
22646
22675
  skillCandidates: spaceSkillCandidates(root, cwd),
@@ -23088,7 +23117,7 @@ function saveMachineConfig(config2, credentials) {
23088
23117
  }
23089
23118
 
23090
23119
  // ../core/src/vault.ts
23091
- import { execFileSync } from "node:child_process";
23120
+ import { execFileSync as execFileSync2 } from "node:child_process";
23092
23121
  import { existsSync as existsSync5, mkdirSync as mkdirSync4, unlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
23093
23122
  import { homedir as homedir4, tmpdir } from "node:os";
23094
23123
  import { dirname, join as join5 } from "node:path";
@@ -23108,7 +23137,7 @@ function gitEnv(extra = {}) {
23108
23137
  };
23109
23138
  }
23110
23139
  function git(home, args, env) {
23111
- return execFileSync("git", ["-C", home, ...args], {
23140
+ return execFileSync2("git", ["-C", home, ...args], {
23112
23141
  encoding: "utf8",
23113
23142
  stdio: ["ignore", "pipe", "pipe"],
23114
23143
  env: gitEnv(env)
@@ -23214,7 +23243,7 @@ function ensureVaultClone(home, cloneUrl, token) {
23214
23243
  try {
23215
23244
  mkdirSync4(dirname(home), { recursive: true });
23216
23245
  withGitAuth(token, (env) => {
23217
- execFileSync("git", ["clone", "--depth", "50", cloneUrl, home], {
23246
+ execFileSync2("git", ["clone", "--depth", "50", cloneUrl, home], {
23218
23247
  encoding: "utf8",
23219
23248
  stdio: ["ignore", "pipe", "pipe"],
23220
23249
  env: gitEnv({
@@ -23460,8 +23489,10 @@ ${GUIDE}` }]
23460
23489
  // second conversation was open, this is where that shows.
23461
23490
  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,
23462
23491
  // A file the session made and the archive would not take is
23463
- // the one thing the human cannot see for themselves.
23464
- 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,
23492
+ // the one thing the human cannot see for themselves. Say how
23493
+ // many there were as well as which ones, because the list is
23494
+ // capped and reporting its length as the total is a lie.
23495
+ written.skipped?.length ? `Not stored: ${written.skippedTotal} file${written.skippedTotal === 1 ? "" : "s"}${written.skippedTotal > written.skipped.length ? `, of which these ${written.skipped.length}` : ""} \u2014 ${written.skipped.map((file) => `${file.name} (${file.reason})`).join(", ")}. Report the total, not just the named ones, so the human knows what the space does not hold.` : null,
23465
23496
  // Rare by design. Offer it, do not act on it: a skill nobody
23466
23497
  // asked for is context every future agent pays for.
23467
23498
  written.skillCandidates?.length ? `This space has hit the same problem in more than one conversation: ${written.skillCandidates.map((item) => `"${item.title}" (${item.sessions.length} sessions, key ${item.key})`).join("; ")}. Ask the human whether to write a skill for it. Only if they say yes, call pantheon_save_skill using the cited evidence \u2014 read the turns first with pantheon_get_turns rather than writing from memory. If they say no, call pantheon_dismiss_skill with that key so it stops being offered.` : null
@@ -23674,7 +23705,7 @@ async function startMcpServer(home = defaultHome()) {
23674
23705
  import { hostname as hostname3 } from "node:os";
23675
23706
 
23676
23707
  // src/connect.ts
23677
- import { execFileSync as execFileSync2 } from "node:child_process";
23708
+ import { execFileSync as execFileSync3 } from "node:child_process";
23678
23709
  import { existsSync as existsSync7, mkdirSync as mkdirSync6, renameSync } from "node:fs";
23679
23710
  import { hostname as hostname2 } from "node:os";
23680
23711
  import { join as join7 } from "node:path";
@@ -23777,7 +23808,7 @@ function upsertCodex(home) {
23777
23808
 
23778
23809
  ${block2}`);
23779
23810
  }
23780
- 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.';
23811
+ var spaceGate = 'A space is the short name the human chose for a conscience (preorders, auth-refactor). The argument is: $ARGUMENTS\n\nIf that arrived blank, or as an unexpanded placeholder rather than a name, ask: "What should this conscience be named?" and wait. Never invent a name. Otherwise use it exactly as typed \u2014 any single short slug counts, including one that is not in the vault yet.';
23781
23812
  var slashCommands = [
23782
23813
  {
23783
23814
  name: "pantheon-handoff",
@@ -23791,7 +23822,7 @@ Only after you have a real space name, call pantheon_handoff even if that name i
23791
23822
  description: "Load a Pantheon conscience into this chat",
23792
23823
  body: `A space is the short name the human chose for a conscience. The argument is: $ARGUMENTS
23793
23824
 
23794
- Call pantheon_resume immediately. If $ARGUMENTS is missing, empty, still says $ARGUMENTS, or is not a single short name, call pantheon_resume without a space \u2014 it lists live consciences. Show that list and ask which one they meant. Do not invent a name. Once they pick a slug, call pantheon_resume with that slug. It pulls the vault first. If the packet lists artifacts, fetch the ones you need with pantheon_get_artifact. Do not use any other resume tool. Do not run pantheon sync.`
23825
+ Call pantheon_resume immediately, with that name exactly as typed. If it arrived blank or as an unexpanded placeholder, call pantheon_resume without a space \u2014 it lists live consciences. Show that list and ask which one they meant. Do not invent a name. Once they pick a slug, call pantheon_resume with that slug. It pulls the vault first. If the packet lists artifacts, fetch the ones you need with pantheon_get_artifact. Do not use any other resume tool. Do not run pantheon sync.`
23795
23826
  },
23796
23827
  {
23797
23828
  name: "pantheon-park",
@@ -24110,13 +24141,13 @@ async function connect(opts) {
24110
24141
  let archived = "";
24111
24142
  if (fresh) {
24112
24143
  process.stdout.write(" Cloning the vault\u2026\n");
24113
- execFileSync2("git", ["-c", `credential.helper=${helper}`, "clone", body.cloneUrl, home], quiet);
24144
+ execFileSync3("git", ["-c", `credential.helper=${helper}`, "clone", body.cloneUrl, home], quiet);
24114
24145
  } else {
24115
24146
  archived = syncVault2(home, body.cloneUrl, helper, quiet);
24116
24147
  }
24117
- execFileSync2("git", ["-C", home, "config", "credential.helper", helper], quiet);
24118
- execFileSync2("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
24119
- execFileSync2("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
24148
+ execFileSync3("git", ["-C", home, "config", "credential.helper", helper], quiet);
24149
+ execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
24150
+ execFileSync3("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
24120
24151
  let written = [];
24121
24152
  let skipped = [];
24122
24153
  let failure = "";
@@ -24143,7 +24174,7 @@ async function connect(opts) {
24143
24174
  );
24144
24175
  }
24145
24176
  function syncVault2(home, cloneUrl, helper, quiet) {
24146
- const git2 = (...args) => execFileSync2("git", ["-c", `credential.helper=${helper}`, "-C", home, ...args], quiet);
24177
+ const git2 = (...args) => execFileSync3("git", ["-c", `credential.helper=${helper}`, "-C", home, ...args], quiet);
24147
24178
  try {
24148
24179
  git2("pull", "--ff-only");
24149
24180
  return "";
@@ -24159,16 +24190,16 @@ function syncVault2(home, cloneUrl, helper, quiet) {
24159
24190
  const archive = `${home}-${stamp2}`;
24160
24191
  process.stdout.write(" Vault belongs to a deleted repo; setting it aside\u2026\n");
24161
24192
  renameSync(home, archive);
24162
- execFileSync2("git", ["-c", `credential.helper=${helper}`, "clone", cloneUrl, home], quiet);
24193
+ execFileSync3("git", ["-c", `credential.helper=${helper}`, "clone", cloneUrl, home], quiet);
24163
24194
  return archive;
24164
24195
  }
24165
24196
  function sharesHistory(home) {
24166
24197
  try {
24167
- const upstream = execFileSync2("git", ["-C", home, "rev-parse", "@{u}"], {
24198
+ const upstream = execFileSync3("git", ["-C", home, "rev-parse", "@{u}"], {
24168
24199
  stdio: ["ignore", "pipe", "pipe"],
24169
24200
  encoding: "utf8"
24170
24201
  }).trim();
24171
- execFileSync2("git", ["-C", home, "merge-base", "HEAD", upstream], {
24202
+ execFileSync3("git", ["-C", home, "merge-base", "HEAD", upstream], {
24172
24203
  stdio: ["ignore", "pipe", "pipe"]
24173
24204
  });
24174
24205
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
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",