pantheon-cli 0.2.12 → 0.2.14

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 +39 -8
  2. package/package.json +1 -1
package/dist/pantheon.mjs CHANGED
@@ -21637,9 +21637,11 @@ function describe(session, mentionsHint) {
21637
21637
  mentionsHint
21638
21638
  };
21639
21639
  }
21640
+ var CLOSE_MS = 10 * 60 * 1e3;
21641
+ function gapMs(a, b) {
21642
+ return Math.abs(Date.parse(a.updatedAt) - Date.parse(b.updatedAt));
21643
+ }
21640
21644
  function ambiguousCapture(opts = {}) {
21641
- const needle = opts.hint?.trim().toLowerCase();
21642
- if (!needle || needle.length < 3) return null;
21643
21645
  const cwd = opts.cwd || process.cwd();
21644
21646
  const scoped = discoverLocalSessions({ cwd, source: opts.source });
21645
21647
  const candidates = (scoped.length ? scoped : discoverLocalSessions({ source: opts.source })).slice(
@@ -21648,10 +21650,29 @@ function ambiguousCapture(opts = {}) {
21648
21650
  );
21649
21651
  if (candidates.length < 2) return null;
21650
21652
  const [newest, ...rest2] = candidates;
21651
- if (tail(newest.path).toLowerCase().includes(needle)) return null;
21652
- const named = rest2.filter((session) => tail(session.path).toLowerCase().includes(needle));
21653
- if (!named.length) return null;
21654
- return [...named.slice(0, 3).map((s) => describe(s, true)), describe(newest, false)];
21653
+ const needle = opts.hint?.trim().toLowerCase();
21654
+ const usable = needle && needle.length >= 3 ? needle : null;
21655
+ const seen = /* @__PURE__ */ new Map();
21656
+ const mentions = (session) => {
21657
+ if (!usable) return false;
21658
+ const hit = seen.get(session.key);
21659
+ if (hit !== void 0) return hit;
21660
+ const found = tail(session.path).toLowerCase().includes(usable);
21661
+ seen.set(session.key, found);
21662
+ return found;
21663
+ };
21664
+ const close = rest2.filter((session) => gapMs(newest, session) <= CLOSE_MS);
21665
+ if (mentions(newest)) {
21666
+ const rivals = close.filter(mentions);
21667
+ if (!rivals.length) return null;
21668
+ return [newest, ...rivals.slice(0, 3)].map((session) => describe(session, true));
21669
+ }
21670
+ const named = rest2.filter(mentions);
21671
+ if (named.length) {
21672
+ return [...named.slice(0, 3).map((s) => describe(s, true)), describe(newest, false)];
21673
+ }
21674
+ if (!close.length) return null;
21675
+ return [newest, ...close.slice(0, 3)].map((session) => describe(session, false));
21655
21676
  }
21656
21677
  function captureLocalTranscript(opts = {}) {
21657
21678
  const { sessionKey, minTurns = 2 } = opts;
@@ -22497,14 +22518,24 @@ function transcriptLooksThin(turns) {
22497
22518
  }
22498
22519
  return null;
22499
22520
  }
22521
+ function agoLabel(when) {
22522
+ const ms = Date.now() - Date.parse(when);
22523
+ if (!Number.isFinite(ms) || ms < 6e4) return "seconds ago";
22524
+ const minutes = Math.round(ms / 6e4);
22525
+ if (minutes < 60) return `${minutes}m ago`;
22526
+ const hours = Math.round(minutes / 60);
22527
+ return hours < 24 ? `${hours}h ago` : `${Math.round(hours / 24)}d ago`;
22528
+ }
22500
22529
  function choiceLine(choice, space) {
22501
- const why = choice.mentionsHint ? `mentions "${space}"` : "most recently written";
22530
+ const why = choice.mentionsHint ? `mentions "${space}"` : `last written ${agoLabel(choice.updatedAt)}`;
22502
22531
  const last = choice.lastMessage ? ` \xB7 last human message: "${choice.lastMessage}"` : "";
22503
22532
  return `- sessionKey: ${choice.key} \u2014 ${choice.turns} turns, ${why}${last}`;
22504
22533
  }
22505
22534
  function chooseSessionMessage(space, choices) {
22535
+ const named = choices.some((choice) => choice.mentionsHint);
22536
+ const why = named ? `the most recently written is not the one that mentions "${space}"` : "they were written minutes apart, and a chat is usually the last to flush its own turns to disk \u2014 so the newest file is not reliably the one asking";
22506
22537
  return [
22507
- `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.`,
22538
+ `More than one conversation in this workspace could be the one being handed off, and ${why}. Do not guess.`,
22508
22539
  "Show the human this list, ask which conversation they are in, then call pantheon_handoff again with that sessionKey:",
22509
22540
  ...choices.map((choice) => choiceLine(choice, space))
22510
22541
  ].join("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
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",