pantheon-cli 0.2.47 → 0.2.49
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 +165 -49
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -42445,7 +42445,7 @@ function saveMachineConfig(config2, credentials) {
|
|
|
42445
42445
|
|
|
42446
42446
|
// ../core/src/vault.ts
|
|
42447
42447
|
import { execFile, execFileSync as execFileSync2 } from "node:child_process";
|
|
42448
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync4, rmSync as rmSync3, unlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
42448
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, rmSync as rmSync3, statSync as statSync3, unlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
42449
42449
|
import { homedir as homedir4, tmpdir } from "node:os";
|
|
42450
42450
|
import { dirname, join as join5, resolve as resolve2 } from "node:path";
|
|
42451
42451
|
import { promisify } from "node:util";
|
|
@@ -42477,6 +42477,70 @@ function sanitize(error2) {
|
|
|
42477
42477
|
const raw = error2 instanceof Error ? error2.message : String(error2);
|
|
42478
42478
|
return (stderr || raw).replace(/x-access-token:[^\s@]+/g, "x-access-token:***").replace(/gh[pousr]_[A-Za-z0-9]+/g, "***").replace(/PANTHEON_GIT_PASSWORD=\S+/g, "PANTHEON_GIT_PASSWORD=***").trim().slice(0, 400);
|
|
42479
42479
|
}
|
|
42480
|
+
var MUTATION_LOCK_WAIT_MS = 9e4;
|
|
42481
|
+
var MUTATION_LOCK_STALE_MS = 10 * 6e4;
|
|
42482
|
+
function wait(ms) {
|
|
42483
|
+
return new Promise((resolveWait) => setTimeout(resolveWait, ms));
|
|
42484
|
+
}
|
|
42485
|
+
async function withVaultMutationLock(home, task, timeoutMs = MUTATION_LOCK_WAIT_MS) {
|
|
42486
|
+
const lock = join5(home, ".git", "pantheon-mutation.lock");
|
|
42487
|
+
const deadline = Date.now() + timeoutMs;
|
|
42488
|
+
while (true) {
|
|
42489
|
+
try {
|
|
42490
|
+
mkdirSync4(lock);
|
|
42491
|
+
writeFileSync4(join5(lock, "owner"), `${process.pid}
|
|
42492
|
+
${Date.now()}
|
|
42493
|
+
`);
|
|
42494
|
+
break;
|
|
42495
|
+
} catch (error2) {
|
|
42496
|
+
const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
|
|
42497
|
+
if (code !== "EEXIST") throw error2;
|
|
42498
|
+
try {
|
|
42499
|
+
if (Date.now() - statSync3(lock).mtimeMs > MUTATION_LOCK_STALE_MS) {
|
|
42500
|
+
rmSync3(lock, { recursive: true, force: true });
|
|
42501
|
+
continue;
|
|
42502
|
+
}
|
|
42503
|
+
} catch {
|
|
42504
|
+
continue;
|
|
42505
|
+
}
|
|
42506
|
+
if (Date.now() >= deadline) {
|
|
42507
|
+
throw new Error("Another Pantheon write is still running. Retry this operation.");
|
|
42508
|
+
}
|
|
42509
|
+
await wait(100);
|
|
42510
|
+
}
|
|
42511
|
+
}
|
|
42512
|
+
try {
|
|
42513
|
+
return await task();
|
|
42514
|
+
} finally {
|
|
42515
|
+
rmSync3(lock, { recursive: true, force: true });
|
|
42516
|
+
}
|
|
42517
|
+
}
|
|
42518
|
+
function rebaseInProgress(home) {
|
|
42519
|
+
return existsSync5(join5(home, ".git", "rebase-merge")) || existsSync5(join5(home, ".git", "rebase-apply"));
|
|
42520
|
+
}
|
|
42521
|
+
function mergeInProgress(home) {
|
|
42522
|
+
return existsSync5(join5(home, ".git", "MERGE_HEAD"));
|
|
42523
|
+
}
|
|
42524
|
+
function recoverInterruptedGit(home, run) {
|
|
42525
|
+
if (rebaseInProgress(home)) run(["rebase", "--abort"]);
|
|
42526
|
+
if (mergeInProgress(home)) run(["merge", "--abort"]);
|
|
42527
|
+
if (!run(["branch", "--show-current"])) {
|
|
42528
|
+
throw new Error("Vault is not on a branch. Run pantheon connect again to repair the clone.");
|
|
42529
|
+
}
|
|
42530
|
+
}
|
|
42531
|
+
function pullRebase(home, run) {
|
|
42532
|
+
try {
|
|
42533
|
+
run(["pull", "--rebase", "--autostash"]);
|
|
42534
|
+
} catch (error2) {
|
|
42535
|
+
if (rebaseInProgress(home)) {
|
|
42536
|
+
try {
|
|
42537
|
+
run(["rebase", "--abort"]);
|
|
42538
|
+
} catch {
|
|
42539
|
+
}
|
|
42540
|
+
}
|
|
42541
|
+
throw error2;
|
|
42542
|
+
}
|
|
42543
|
+
}
|
|
42480
42544
|
async function mintToken() {
|
|
42481
42545
|
const stored = loadMachineConfig();
|
|
42482
42546
|
if (!stored) throw new Error("Not connected. Run pantheon connect <code> first.");
|
|
@@ -42557,6 +42621,7 @@ function syncVaultWithToken(home, token, opts = {}) {
|
|
|
42557
42621
|
"credential.helper=!f() { echo username=x-access-token; echo password=$PANTHEON_GIT_PASSWORD; }; f"
|
|
42558
42622
|
];
|
|
42559
42623
|
const run = (args) => git(home, [...auth, ...args], env);
|
|
42624
|
+
recoverInterruptedGit(home, run);
|
|
42560
42625
|
if (opts.push) {
|
|
42561
42626
|
run(["add", "-A"]);
|
|
42562
42627
|
if (run(["status", "--porcelain"])) {
|
|
@@ -42568,10 +42633,16 @@ function syncVaultWithToken(home, token, opts = {}) {
|
|
|
42568
42633
|
}
|
|
42569
42634
|
}
|
|
42570
42635
|
}
|
|
42571
|
-
|
|
42636
|
+
pullRebase(home, run);
|
|
42572
42637
|
result.pulled = true;
|
|
42573
42638
|
if (opts.push) {
|
|
42574
|
-
|
|
42639
|
+
try {
|
|
42640
|
+
run(["push"]);
|
|
42641
|
+
} catch (error2) {
|
|
42642
|
+
if (!/fetch first|non-fast-forward|rejected/i.test(sanitize(error2))) throw error2;
|
|
42643
|
+
pullRebase(home, run);
|
|
42644
|
+
run(["push"]);
|
|
42645
|
+
}
|
|
42575
42646
|
result.pushed = true;
|
|
42576
42647
|
}
|
|
42577
42648
|
result.ok = true;
|
|
@@ -43103,6 +43174,22 @@ async function restoreArtifact(artifact, destination, cwd = process.cwd(), clien
|
|
|
43103
43174
|
}
|
|
43104
43175
|
|
|
43105
43176
|
// ../mcp/src/index.ts
|
|
43177
|
+
async function mutateVault(home, vault, message, write) {
|
|
43178
|
+
return withVaultMutationLock(home, async () => {
|
|
43179
|
+
const pulled = await vault.pull(home);
|
|
43180
|
+
if (pulled.ok === false) {
|
|
43181
|
+
throw new Error(
|
|
43182
|
+
`Could not refresh the vault before writing: ${pulled.error || "unknown sync error"}`
|
|
43183
|
+
);
|
|
43184
|
+
}
|
|
43185
|
+
const written = await write();
|
|
43186
|
+
const sync2 = await vault.push(
|
|
43187
|
+
home,
|
|
43188
|
+
typeof message === "function" ? message(written) : message
|
|
43189
|
+
);
|
|
43190
|
+
return { written, sync: sync2 };
|
|
43191
|
+
});
|
|
43192
|
+
}
|
|
43106
43193
|
function readRoot(home, space) {
|
|
43107
43194
|
return resolveSpace(home, space).root;
|
|
43108
43195
|
}
|
|
@@ -43385,16 +43472,20 @@ ${GUIDE}` }]
|
|
|
43385
43472
|
allowLocalPaths: allowCapture,
|
|
43386
43473
|
clientRoots: request.artifacts?.some((item) => "path" in item) ? await clientFileRoots() : []
|
|
43387
43474
|
});
|
|
43388
|
-
const written =
|
|
43389
|
-
|
|
43390
|
-
|
|
43391
|
-
|
|
43392
|
-
|
|
43393
|
-
|
|
43394
|
-
|
|
43395
|
-
|
|
43396
|
-
|
|
43397
|
-
|
|
43475
|
+
const { written, sync: sync2 } = await mutateVault(
|
|
43476
|
+
home,
|
|
43477
|
+
vault,
|
|
43478
|
+
(result) => `handoff ${result.slug}`,
|
|
43479
|
+
() => writeHandoff(home, {
|
|
43480
|
+
...request,
|
|
43481
|
+
artifacts,
|
|
43482
|
+
capture: allowCapture ? request.capture : false,
|
|
43483
|
+
// Which app is on the other end of this stdio pipe. Running locally
|
|
43484
|
+
// is not the same as keeping chats where Pantheon can read them, and
|
|
43485
|
+
// capture needs to tell those apart before it reads anything.
|
|
43486
|
+
client: server.server.getClientVersion()?.name
|
|
43487
|
+
})
|
|
43488
|
+
);
|
|
43398
43489
|
const shouldReview = sync2.ok !== false && written.added > 0;
|
|
43399
43490
|
const review = shouldReview ? (() => {
|
|
43400
43491
|
try {
|
|
@@ -43477,9 +43568,13 @@ ${GUIDE}` }]
|
|
|
43477
43568
|
allowLocalPaths: allowCapture,
|
|
43478
43569
|
clientRoots: request.artifacts?.some((item) => "path" in item) ? await clientFileRoots() : []
|
|
43479
43570
|
});
|
|
43480
|
-
const written
|
|
43481
|
-
|
|
43482
|
-
|
|
43571
|
+
const { written, sync: sync2 } = await mutateVault(
|
|
43572
|
+
home,
|
|
43573
|
+
vault,
|
|
43574
|
+
(result) => `park ${result.slug}`,
|
|
43575
|
+
() => writePark(home, { ...request, artifacts })
|
|
43576
|
+
);
|
|
43577
|
+
return { ok: sync2.ok !== false, ...written, sync: sync2 };
|
|
43483
43578
|
})
|
|
43484
43579
|
);
|
|
43485
43580
|
registerTool(
|
|
@@ -43488,9 +43583,13 @@ ${GUIDE}` }]
|
|
|
43488
43583
|
"Add one durable fact to a Pantheon space. Trigger: /pantheon-remember <space> <fact>. Does not dump the chat.",
|
|
43489
43584
|
{ space: external_exports.string(), fact: external_exports.string() },
|
|
43490
43585
|
async ({ space, fact }) => safe(async () => {
|
|
43491
|
-
const written =
|
|
43492
|
-
|
|
43493
|
-
|
|
43586
|
+
const { written, sync: sync2 } = await mutateVault(
|
|
43587
|
+
home,
|
|
43588
|
+
vault,
|
|
43589
|
+
(result) => `remember ${result.slug}`,
|
|
43590
|
+
() => writeRemember(home, space, fact)
|
|
43591
|
+
);
|
|
43592
|
+
return { ok: sync2.ok !== false, ...written, sync: sync2 };
|
|
43494
43593
|
})
|
|
43495
43594
|
);
|
|
43496
43595
|
registerTool(
|
|
@@ -43587,8 +43686,12 @@ ${GUIDE}` }]
|
|
|
43587
43686
|
session_id: external_exports.string().describe("Exactly as listed in the resume packet.")
|
|
43588
43687
|
},
|
|
43589
43688
|
async ({ space, session_id }) => safe(async () => {
|
|
43590
|
-
const removed =
|
|
43591
|
-
|
|
43689
|
+
const { written: removed, sync: sync2 } = await mutateVault(
|
|
43690
|
+
home,
|
|
43691
|
+
vault,
|
|
43692
|
+
(result) => `forget session ${result.sessionId}`,
|
|
43693
|
+
() => forgetSession(home, space, session_id)
|
|
43694
|
+
);
|
|
43592
43695
|
return {
|
|
43593
43696
|
ok: sync2.ok !== false,
|
|
43594
43697
|
...removed,
|
|
@@ -43613,21 +43716,27 @@ ${GUIDE}` }]
|
|
|
43613
43716
|
...skillDraftSchema.shape
|
|
43614
43717
|
},
|
|
43615
43718
|
async ({ space, name, when, body, key, sessions, evidence }) => safe(async () => {
|
|
43616
|
-
const
|
|
43617
|
-
|
|
43618
|
-
|
|
43619
|
-
|
|
43620
|
-
{
|
|
43621
|
-
|
|
43622
|
-
|
|
43623
|
-
|
|
43624
|
-
|
|
43625
|
-
|
|
43626
|
-
|
|
43627
|
-
|
|
43628
|
-
|
|
43719
|
+
const { written: saved, sync: sync2 } = await mutateVault(
|
|
43720
|
+
home,
|
|
43721
|
+
vault,
|
|
43722
|
+
(result) => `skill draft ${result.name}`,
|
|
43723
|
+
() => {
|
|
43724
|
+
const root = writeRoot(home, space);
|
|
43725
|
+
verifyCitations(root, evidence ?? []);
|
|
43726
|
+
return saveSkill(
|
|
43727
|
+
root,
|
|
43728
|
+
{
|
|
43729
|
+
name,
|
|
43730
|
+
when,
|
|
43731
|
+
body,
|
|
43732
|
+
key,
|
|
43733
|
+
sessions: evidenceSessions(evidence),
|
|
43734
|
+
evidence
|
|
43735
|
+
},
|
|
43736
|
+
"draft"
|
|
43737
|
+
);
|
|
43738
|
+
}
|
|
43629
43739
|
);
|
|
43630
|
-
const sync2 = await vault.push(home, `skill draft ${saved.name}`);
|
|
43631
43740
|
return {
|
|
43632
43741
|
ok: sync2.ok !== false,
|
|
43633
43742
|
...saved,
|
|
@@ -43645,18 +43754,21 @@ ${GUIDE}` }]
|
|
|
43645
43754
|
skills: external_exports.array(skillDraftSchema).min(1).max(MAX_REVIEW_DRAFTS)
|
|
43646
43755
|
},
|
|
43647
43756
|
async ({ space, skills }) => safe(async () => {
|
|
43648
|
-
const
|
|
43649
|
-
const prepared = skills.map((skill) => {
|
|
43650
|
-
verifyCitations(root, skill.evidence ?? []);
|
|
43651
|
-
return {
|
|
43652
|
-
...skill,
|
|
43653
|
-
sessions: evidenceSessions(skill.evidence)
|
|
43654
|
-
};
|
|
43655
|
-
});
|
|
43656
|
-
const saved = saveSkills(root, prepared, "draft");
|
|
43657
|
-
const sync2 = await vault.push(
|
|
43757
|
+
const { written: saved, sync: sync2 } = await mutateVault(
|
|
43658
43758
|
home,
|
|
43659
|
-
|
|
43759
|
+
vault,
|
|
43760
|
+
(result) => `skill drafts ${result.map((skill) => skill.name).join(", ")}`,
|
|
43761
|
+
() => {
|
|
43762
|
+
const root = writeRoot(home, space);
|
|
43763
|
+
const prepared = skills.map((skill) => {
|
|
43764
|
+
verifyCitations(root, skill.evidence ?? []);
|
|
43765
|
+
return {
|
|
43766
|
+
...skill,
|
|
43767
|
+
sessions: evidenceSessions(skill.evidence)
|
|
43768
|
+
};
|
|
43769
|
+
});
|
|
43770
|
+
return saveSkills(root, prepared, "draft");
|
|
43771
|
+
}
|
|
43660
43772
|
);
|
|
43661
43773
|
return {
|
|
43662
43774
|
ok: sync2.ok !== false,
|
|
@@ -43679,8 +43791,12 @@ ${GUIDE}` }]
|
|
|
43679
43791
|
"Record that the human explicitly rejected a deterministic skill candidate. This permanently stops that key being offered again, so never call it merely because an agent decided not to draft the candidate.",
|
|
43680
43792
|
{ space: external_exports.string(), key: external_exports.string() },
|
|
43681
43793
|
async ({ space, key }) => safe(async () => {
|
|
43682
|
-
const done =
|
|
43683
|
-
|
|
43794
|
+
const { written: done, sync: sync2 } = await mutateVault(
|
|
43795
|
+
home,
|
|
43796
|
+
vault,
|
|
43797
|
+
"dismiss skill candidate",
|
|
43798
|
+
() => dismissCandidate(writeRoot(home, space), key)
|
|
43799
|
+
);
|
|
43684
43800
|
return { ok: sync2.ok !== false, ...done, sync: sync2 };
|
|
43685
43801
|
})
|
|
43686
43802
|
);
|
|
@@ -43703,7 +43819,7 @@ ${GUIDE}` }]
|
|
|
43703
43819
|
argsSchema: { space: external_exports.string() }
|
|
43704
43820
|
},
|
|
43705
43821
|
async ({ space }) => promptText(
|
|
43706
|
-
`Call pantheon_handoff for space "${space}" with the real transcript of this chat: user turns are what the human typed, assistant turns are what you replied, copied verbatim. Do not write a recap. Attach every file you generated (especially PDFs) and every upload as base64 artifacts. Do not use any other handoff tool.`
|
|
43822
|
+
allowCapture ? `Call pantheon_handoff for space "${space}" with transcript omitted. Pantheon reads this complete local conversation from disk. Do not ask which session to use and do not retype a shortened transcript. Attach any generated or uploaded file not already available to local capture. Do not use any other handoff tool.` : `Call pantheon_handoff for space "${space}" with the real transcript of this chat: user turns are what the human typed, assistant turns are what you replied, copied verbatim. Do not write a recap. Attach every file you generated (especially PDFs) and every upload as base64 artifacts. Do not use any other handoff tool.`
|
|
43707
43823
|
)
|
|
43708
43824
|
);
|
|
43709
43825
|
server.registerPrompt(
|
package/package.json
CHANGED