pantheon-cli 0.2.1 → 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.
- package/dist/pantheon.mjs +215 -84
- 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,
|
|
3658
|
+
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
3659
3659
|
const target = {};
|
|
3660
3660
|
if (!skipNormalization) {
|
|
3661
3661
|
base = parse3(serialize(base, options), options);
|
|
3662
|
-
|
|
3662
|
+
relative2 = parse3(serialize(relative2, options), options);
|
|
3663
3663
|
}
|
|
3664
3664
|
options = options || {};
|
|
3665
|
-
if (!options.tolerant &&
|
|
3666
|
-
target.scheme =
|
|
3667
|
-
target.userinfo =
|
|
3668
|
-
target.host =
|
|
3669
|
-
target.port =
|
|
3670
|
-
target.path = removeDotSegments(
|
|
3671
|
-
target.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 (
|
|
3674
|
-
target.userinfo =
|
|
3675
|
-
target.host =
|
|
3676
|
-
target.port =
|
|
3677
|
-
target.path = removeDotSegments(
|
|
3678
|
-
target.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 (!
|
|
3680
|
+
if (!relative2.path) {
|
|
3681
3681
|
target.path = base.path;
|
|
3682
|
-
if (
|
|
3683
|
-
target.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 (
|
|
3689
|
-
target.path = removeDotSegments(
|
|
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 = "/" +
|
|
3692
|
+
target.path = "/" + relative2.path;
|
|
3693
3693
|
} else if (!base.path) {
|
|
3694
|
-
target.path =
|
|
3694
|
+
target.path = relative2.path;
|
|
3695
3695
|
} else {
|
|
3696
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
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 =
|
|
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 =
|
|
3708
|
+
target.fragment = relative2.fragment;
|
|
3709
3709
|
return target;
|
|
3710
3710
|
}
|
|
3711
3711
|
function equal(uriA, uriB, options) {
|
|
@@ -21272,7 +21272,7 @@ 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
21278
|
import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
|
|
@@ -21319,12 +21319,12 @@ function files(path) {
|
|
|
21319
21319
|
return [];
|
|
21320
21320
|
}
|
|
21321
21321
|
}
|
|
21322
|
-
function
|
|
21323
|
-
return
|
|
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 ?
|
|
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 ?
|
|
21520
|
+
const wanted = cwd ? projectKey(cwd) : "";
|
|
21521
21521
|
const found = [];
|
|
21522
21522
|
for (const project of dirs(root)) {
|
|
21523
|
-
|
|
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);
|
|
@@ -21609,14 +21608,33 @@ function tail(path, bytes = HINT_TAIL_BYTES) {
|
|
|
21609
21608
|
return "";
|
|
21610
21609
|
}
|
|
21611
21610
|
}
|
|
21612
|
-
function
|
|
21613
|
-
const
|
|
21614
|
-
|
|
21615
|
-
|
|
21616
|
-
|
|
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
|
|
21617
21631
|
);
|
|
21618
|
-
if (
|
|
21619
|
-
|
|
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)];
|
|
21620
21638
|
}
|
|
21621
21639
|
function captureLocalTranscript(opts = {}) {
|
|
21622
21640
|
const { sessionKey, minTurns = 2 } = opts;
|
|
@@ -21624,10 +21642,7 @@ function captureLocalTranscript(opts = {}) {
|
|
|
21624
21642
|
const scoped = discoverLocalSessions({ cwd, source: opts.source });
|
|
21625
21643
|
const candidates = sessionKey ? discoverLocalSessions({ source: opts.source }).filter(
|
|
21626
21644
|
(item) => item.key === sessionKey || item.key.endsWith(sessionKey)
|
|
21627
|
-
) :
|
|
21628
|
-
scoped.length ? scoped : discoverLocalSessions({ source: opts.source }),
|
|
21629
|
-
opts.hint
|
|
21630
|
-
);
|
|
21645
|
+
) : scoped.length ? scoped : discoverLocalSessions({ source: opts.source });
|
|
21631
21646
|
for (const session of candidates.slice(0, MAX_SCAN)) {
|
|
21632
21647
|
const turns = readLocalSession(session);
|
|
21633
21648
|
if (turns.length >= minTurns) return { session, turns };
|
|
@@ -21814,10 +21829,54 @@ function pathsFromPatch(input) {
|
|
|
21814
21829
|
}
|
|
21815
21830
|
return found;
|
|
21816
21831
|
}
|
|
21817
|
-
var
|
|
21818
|
-
|
|
21819
|
-
|
|
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;
|
|
21820
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
|
+
}
|
|
21821
21880
|
function pathFromInput(input) {
|
|
21822
21881
|
if (!input || typeof input !== "object") return null;
|
|
21823
21882
|
const record2 = input;
|
|
@@ -21828,8 +21887,8 @@ function pathFromInput(input) {
|
|
|
21828
21887
|
return null;
|
|
21829
21888
|
}
|
|
21830
21889
|
function flatName(path, base) {
|
|
21831
|
-
const
|
|
21832
|
-
return
|
|
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, "_");
|
|
21833
21892
|
}
|
|
21834
21893
|
function readArtifactFile(path, base) {
|
|
21835
21894
|
const stat = statSync2(path);
|
|
@@ -21843,44 +21902,85 @@ function readArtifactFile(path, base) {
|
|
|
21843
21902
|
bytes: stat.size
|
|
21844
21903
|
};
|
|
21845
21904
|
}
|
|
21846
|
-
function collectWrittenArtifacts(turns, cwd = process.cwd()) {
|
|
21847
|
-
const base = cwd
|
|
21848
|
-
const
|
|
21849
|
-
const
|
|
21850
|
-
|
|
21851
|
-
|
|
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);
|
|
21852
21918
|
};
|
|
21853
21919
|
for (const turn of turns) {
|
|
21854
21920
|
for (const call of turn.toolCalls ?? []) {
|
|
21855
|
-
if (
|
|
21856
|
-
|
|
21857
|
-
|
|
21858
|
-
|
|
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);
|
|
21859
21930
|
}
|
|
21860
21931
|
}
|
|
21861
21932
|
const found = [];
|
|
21933
|
+
const skipped = [];
|
|
21862
21934
|
let total = 0;
|
|
21863
|
-
|
|
21864
|
-
if (
|
|
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) {
|
|
21865
21960
|
try {
|
|
21866
|
-
|
|
21867
|
-
const file = readArtifactFile(path, base);
|
|
21868
|
-
if (!file) continue;
|
|
21869
|
-
total += file.bytes;
|
|
21870
|
-
found.push({ name: file.name, content: file.content, encoding: file.encoding });
|
|
21961
|
+
store(path, false);
|
|
21871
21962
|
} catch {
|
|
21872
21963
|
}
|
|
21873
21964
|
}
|
|
21874
|
-
|
|
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 };
|
|
21875
21973
|
}
|
|
21876
21974
|
function collectAttachedArtifacts(turns, cwd = process.cwd()) {
|
|
21877
|
-
const base = cwd
|
|
21975
|
+
const base = slash(resolve(cwd));
|
|
21878
21976
|
const paths = /* @__PURE__ */ new Set();
|
|
21879
21977
|
for (const turn of turns) {
|
|
21880
21978
|
if (turn.role !== "user") continue;
|
|
21881
|
-
for (const match of (turn.text || "").matchAll(
|
|
21882
|
-
|
|
21883
|
-
|
|
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);
|
|
21884
21984
|
}
|
|
21885
21985
|
}
|
|
21886
21986
|
const found = [];
|
|
@@ -22078,6 +22178,18 @@ function transcriptLooksThin(turns) {
|
|
|
22078
22178
|
}
|
|
22079
22179
|
return null;
|
|
22080
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
|
+
}
|
|
22081
22193
|
function resolveTranscript(input) {
|
|
22082
22194
|
const supplied = input.transcript ? parseTurns(input.transcript) : [];
|
|
22083
22195
|
if (supplied.length) return { turns: supplied, captured: null };
|
|
@@ -22086,11 +22198,11 @@ function resolveTranscript(input) {
|
|
|
22086
22198
|
"Transcript is empty and capture is disabled. Send the real turns, or drop capture:false to archive this chat from local history."
|
|
22087
22199
|
);
|
|
22088
22200
|
}
|
|
22089
|
-
|
|
22090
|
-
cwd: input.cwd,
|
|
22091
|
-
|
|
22092
|
-
|
|
22093
|
-
});
|
|
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
|
+
}
|
|
22205
|
+
const captured = captureLocalTranscript({ cwd: input.cwd, sessionKey: input.sessionKey });
|
|
22094
22206
|
if (!captured?.turns.length) {
|
|
22095
22207
|
throw new Error(
|
|
22096
22208
|
"No local conversation history found for this workspace. Pass cwd for the project folder, or send the transcript explicitly with every user and assistant turn verbatim."
|
|
@@ -22102,6 +22214,15 @@ function lastSpoken(turns) {
|
|
|
22102
22214
|
const last = [...turns].reverse().find((turn) => turn.role === "user" && turn.text.trim());
|
|
22103
22215
|
return last ? last.text.replace(/\s+/g, " ").trim().slice(0, 160) : null;
|
|
22104
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
|
+
}
|
|
22105
22226
|
function writeHandoff(home, input) {
|
|
22106
22227
|
requireSpaceName(input.space);
|
|
22107
22228
|
const { slug, root } = ensureSpace(home, input.space);
|
|
@@ -22111,11 +22232,12 @@ function writeHandoff(home, input) {
|
|
|
22111
22232
|
if (thin) throw new Error(thin);
|
|
22112
22233
|
}
|
|
22113
22234
|
const cwd = input.cwd || process.cwd();
|
|
22235
|
+
const sweep = captured ? collectWrittenArtifacts(turns, cwd, { since: sessionStart(captured.session.path), home }) : null;
|
|
22114
22236
|
const artifacts = mergeArtifacts(
|
|
22115
22237
|
input.artifacts,
|
|
22116
22238
|
extractFencedArtifacts(turns),
|
|
22117
22239
|
collectDiskArtifacts(turns),
|
|
22118
|
-
|
|
22240
|
+
sweep?.artifacts,
|
|
22119
22241
|
captured ? collectAttachedArtifacts(turns, cwd) : void 0
|
|
22120
22242
|
);
|
|
22121
22243
|
if (!captured) {
|
|
@@ -22151,6 +22273,9 @@ function writeHandoff(home, input) {
|
|
|
22151
22273
|
// So a human can tell at a glance that the right conversation was read.
|
|
22152
22274
|
lastMessage: lastSpoken(session.turns),
|
|
22153
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 ?? [],
|
|
22154
22279
|
truncated: Boolean(input.truncated),
|
|
22155
22280
|
append: Boolean(input.append)
|
|
22156
22281
|
};
|
|
@@ -22733,6 +22858,9 @@ function fail(error2) {
|
|
|
22733
22858
|
}
|
|
22734
22859
|
function hint(message) {
|
|
22735
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
|
+
}
|
|
22736
22864
|
if (text2.includes("not found") && text2.includes("session")) {
|
|
22737
22865
|
return "Call pantheon_search first and use the session_id from a hit.";
|
|
22738
22866
|
}
|
|
@@ -22888,7 +23016,10 @@ ${GUIDE}` }]
|
|
|
22888
23016
|
`Archived ${written.turns} turns${written.added !== written.turns ? ` (${written.added} new)` : ""} from ${written.capturedFrom || "the supplied transcript"}.`,
|
|
22889
23017
|
// Capture reads a chat off disk, so name what it read: if a
|
|
22890
23018
|
// second conversation was open, this is where that shows.
|
|
22891
|
-
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
|
|
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
|
|
22892
23023
|
].filter(Boolean).join(" ")
|
|
22893
23024
|
};
|
|
22894
23025
|
})
|
|
@@ -23322,8 +23453,8 @@ function uninstallMcpClients() {
|
|
|
23322
23453
|
if (removeServerFromJson(join5(homedir5(), ".codeium", "windsurf", "mcp_config.json"))) {
|
|
23323
23454
|
removed.push("Windsurf");
|
|
23324
23455
|
}
|
|
23325
|
-
const
|
|
23326
|
-
if (
|
|
23456
|
+
const slash2 = removeSlashCommands();
|
|
23457
|
+
if (slash2) removed.push("/pantheon-* commands");
|
|
23327
23458
|
for (const dir of [
|
|
23328
23459
|
join5(homedir5(), ".agents", "skills", "pantheon"),
|
|
23329
23460
|
join5(homedir5(), ".codex", "skills", "pantheon")
|
|
@@ -23744,10 +23875,10 @@ async function main() {
|
|
|
23744
23875
|
return;
|
|
23745
23876
|
}
|
|
23746
23877
|
if (AGENT_VERBS.has(cmd)) {
|
|
23747
|
-
const
|
|
23878
|
+
const slash2 = ["handoff", "park", "resume", "remember"].includes(cmd);
|
|
23748
23879
|
printError(
|
|
23749
23880
|
new Error(
|
|
23750
|
-
|
|
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.`
|
|
23751
23882
|
)
|
|
23752
23883
|
);
|
|
23753
23884
|
process.stdout.write(GUIDE);
|
package/package.json
CHANGED