pantheon-cli 0.2.75 → 0.2.78
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 +99 -19
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -43701,7 +43701,7 @@ import { gzipSync } from "node:zlib";
|
|
|
43701
43701
|
var DRIVE_MAX_FILE_BYTES = 200 * 1024 * 1024;
|
|
43702
43702
|
var DRIVE_MAX_CHANGE_BYTES = 256 * 1024 * 1024;
|
|
43703
43703
|
var DRIVE_MAX_CHANGES = 100;
|
|
43704
|
-
var DRIVE_MAX_REQUEST_BYTES =
|
|
43704
|
+
var DRIVE_MAX_REQUEST_BYTES = 4 * 1024 * 1024;
|
|
43705
43705
|
var CONTROL_NAMES = /* @__PURE__ */ new Set([
|
|
43706
43706
|
".git",
|
|
43707
43707
|
".pantheon",
|
|
@@ -43758,7 +43758,8 @@ function driveWorkspaceStatePaths(home) {
|
|
|
43758
43758
|
return {
|
|
43759
43759
|
ledger: `${base}.pantheon-sync.json`,
|
|
43760
43760
|
outbox: `${base}.pantheon-outbox.json`,
|
|
43761
|
-
conflicts: `${base}.pantheon-conflicts
|
|
43761
|
+
conflicts: `${base}.pantheon-conflicts`,
|
|
43762
|
+
skipped: `${base}.pantheon-skipped.json`
|
|
43762
43763
|
};
|
|
43763
43764
|
}
|
|
43764
43765
|
function writeJsonAtomic(path, value) {
|
|
@@ -43782,6 +43783,39 @@ function readJsonSafe(path) {
|
|
|
43782
43783
|
function writeLedger(path, vaultId, manifest) {
|
|
43783
43784
|
writeJsonAtomic(path, { ...manifest, vaultId });
|
|
43784
43785
|
}
|
|
43786
|
+
function updateSkippedLedger(home, vaultId, attempted, deleted, skipped) {
|
|
43787
|
+
const path = driveWorkspaceStatePaths(home).skipped;
|
|
43788
|
+
const previous = readJsonSafe(path);
|
|
43789
|
+
const entries = previous?.vaultId === vaultId ? { ...previous.entries } : {};
|
|
43790
|
+
for (const [key, entry] of Object.entries(entries)) {
|
|
43791
|
+
const file = join7(home, ...key.split("/"));
|
|
43792
|
+
if (!existsSync7(file) || !lstatSync2(file).isFile() || readFileSync6(file).length !== entry.size || sha256(readFileSync6(file)) !== entry.sha256) {
|
|
43793
|
+
delete entries[key];
|
|
43794
|
+
}
|
|
43795
|
+
}
|
|
43796
|
+
for (const change of attempted) delete entries[change.path];
|
|
43797
|
+
for (const deletedPath of deleted) delete entries[deletedPath];
|
|
43798
|
+
const byPath = new Map(attempted.map((change) => [change.path, change]));
|
|
43799
|
+
for (const item of skipped) {
|
|
43800
|
+
const change = byPath.get(item.path);
|
|
43801
|
+
if (!change) continue;
|
|
43802
|
+
entries[item.path] = {
|
|
43803
|
+
path: item.path,
|
|
43804
|
+
sha256: change.sha256,
|
|
43805
|
+
size: change.size,
|
|
43806
|
+
reason: item.reason
|
|
43807
|
+
};
|
|
43808
|
+
}
|
|
43809
|
+
if (Object.keys(entries).length) {
|
|
43810
|
+
writeJsonAtomic(path, {
|
|
43811
|
+
version: 1,
|
|
43812
|
+
vaultId,
|
|
43813
|
+
entries
|
|
43814
|
+
});
|
|
43815
|
+
} else {
|
|
43816
|
+
rmSync5(path, { force: true });
|
|
43817
|
+
}
|
|
43818
|
+
}
|
|
43785
43819
|
function quarantineUnownedDriveWorkspace(home, vaultId, now = /* @__PURE__ */ new Date()) {
|
|
43786
43820
|
const paths = driveWorkspaceStatePaths(home);
|
|
43787
43821
|
const ledger = readJsonSafe(paths.ledger);
|
|
@@ -43800,6 +43834,7 @@ function quarantineUnownedDriveWorkspace(home, vaultId, now = /* @__PURE__ */ ne
|
|
|
43800
43834
|
if (ledger?.vaultId !== vaultId) {
|
|
43801
43835
|
rmSync5(paths.ledger, { force: true });
|
|
43802
43836
|
rmSync5(paths.outbox, { force: true });
|
|
43837
|
+
rmSync5(paths.skipped, { force: true });
|
|
43803
43838
|
}
|
|
43804
43839
|
return quarantined;
|
|
43805
43840
|
}
|
|
@@ -43838,9 +43873,13 @@ function scanDriveWorkspace(home) {
|
|
|
43838
43873
|
}
|
|
43839
43874
|
function diffDriveManifest(home, manifest) {
|
|
43840
43875
|
const local = scanDriveWorkspace(home);
|
|
43876
|
+
const skipped = readJsonSafe(driveWorkspaceStatePaths(home).skipped)?.entries ?? {};
|
|
43841
43877
|
const changes = [];
|
|
43842
43878
|
let total = 0;
|
|
43843
43879
|
for (const [path, entry] of Object.entries(local)) {
|
|
43880
|
+
if (skipped[path]?.sha256 === entry.sha256 && skipped[path]?.size === entry.size) {
|
|
43881
|
+
continue;
|
|
43882
|
+
}
|
|
43844
43883
|
if (manifest.entries[path]?.sha256 === entry.sha256 && manifest.entries[path]?.size === entry.size) {
|
|
43845
43884
|
continue;
|
|
43846
43885
|
}
|
|
@@ -43892,18 +43931,22 @@ async function responseError(response) {
|
|
|
43892
43931
|
);
|
|
43893
43932
|
}
|
|
43894
43933
|
async function publishOutbox(config2, credentials, outbox, fetcher) {
|
|
43895
|
-
const requestBudget = DRIVE_MAX_REQUEST_BYTES -
|
|
43934
|
+
const requestBudget = DRIVE_MAX_REQUEST_BYTES - 128 * 1024;
|
|
43935
|
+
const maxChangesPerBatch = 5;
|
|
43896
43936
|
const groups = [];
|
|
43937
|
+
const skipped = [];
|
|
43897
43938
|
let group = [];
|
|
43898
43939
|
let groupBytes = 0;
|
|
43899
43940
|
for (const change of outbox.changes) {
|
|
43900
43941
|
const bytes = Buffer.byteLength(JSON.stringify(change)) + 1;
|
|
43901
43942
|
if (bytes > requestBudget) {
|
|
43902
|
-
|
|
43903
|
-
|
|
43904
|
-
|
|
43943
|
+
skipped.push({
|
|
43944
|
+
path: change.path,
|
|
43945
|
+
reason: `${(change.size / 1024 / 1024).toFixed(1)} MB cannot fit safely in one hosted Drive request. The file remains on this machine; the rest of the handoff was saved.`
|
|
43946
|
+
});
|
|
43947
|
+
continue;
|
|
43905
43948
|
}
|
|
43906
|
-
if (group.length && groupBytes + bytes > requestBudget) {
|
|
43949
|
+
if (group.length && (group.length >= maxChangesPerBatch || groupBytes + bytes > requestBudget)) {
|
|
43907
43950
|
groups.push(group);
|
|
43908
43951
|
group = [];
|
|
43909
43952
|
groupBytes = 0;
|
|
@@ -43929,24 +43972,37 @@ async function publishOutbox(config2, credentials, outbox, fetcher) {
|
|
|
43929
43972
|
if (Buffer.byteLength(body) > DRIVE_MAX_REQUEST_BYTES) {
|
|
43930
43973
|
throw new Error("Drive sync batch exceeds the request limit.");
|
|
43931
43974
|
}
|
|
43932
|
-
|
|
43933
|
-
|
|
43934
|
-
|
|
43935
|
-
|
|
43936
|
-
|
|
43937
|
-
|
|
43938
|
-
|
|
43939
|
-
|
|
43940
|
-
|
|
43941
|
-
|
|
43942
|
-
|
|
43975
|
+
for (let attempt = 1; attempt <= 4; attempt += 1) {
|
|
43976
|
+
const response = await fetcher(`${config2.apiUrl}/api/cli/workspace/sync`, {
|
|
43977
|
+
method: "POST",
|
|
43978
|
+
headers: {
|
|
43979
|
+
...auth(config2, credentials),
|
|
43980
|
+
"content-type": "application/json"
|
|
43981
|
+
},
|
|
43982
|
+
body,
|
|
43983
|
+
signal: AbortSignal.timeout(6e4)
|
|
43984
|
+
});
|
|
43985
|
+
if (response.ok) {
|
|
43986
|
+
published = await response.json();
|
|
43987
|
+
break;
|
|
43988
|
+
}
|
|
43989
|
+
const error2 = await responseError(response);
|
|
43990
|
+
if (error2.status !== 503 || !/already uploading/i.test(error2.message) || attempt === 4) {
|
|
43991
|
+
throw error2;
|
|
43992
|
+
}
|
|
43993
|
+
await new Promise((resolveDelay) => setTimeout(resolveDelay, 2e3));
|
|
43994
|
+
}
|
|
43995
|
+
if (!published) {
|
|
43996
|
+
throw new Error("Drive sync batch did not return a published revision.");
|
|
43997
|
+
}
|
|
43943
43998
|
baseRevision = published.revision;
|
|
43944
43999
|
merged ||= Boolean(published.merged);
|
|
43945
44000
|
}
|
|
43946
44001
|
if (!published) throw new Error("Drive sync did not publish any batches.");
|
|
43947
44002
|
return {
|
|
43948
44003
|
...published,
|
|
43949
|
-
...merged ? { merged: true } : {}
|
|
44004
|
+
...merged ? { merged: true } : {},
|
|
44005
|
+
...skipped.length ? { skipped } : {}
|
|
43950
44006
|
};
|
|
43951
44007
|
}
|
|
43952
44008
|
function httpDriveWorkspaceHooks(config2, credentials, fetcher = fetch) {
|
|
@@ -43965,6 +44021,12 @@ function httpDriveWorkspaceHooks(config2, credentials, fetcher = fetch) {
|
|
|
43965
44021
|
return manifest;
|
|
43966
44022
|
}
|
|
43967
44023
|
async function applyManifest(home, manifest, protectedPaths = /* @__PURE__ */ new Set()) {
|
|
44024
|
+
const locallySkipped = readJsonSafe(paths.skipped);
|
|
44025
|
+
if (locallySkipped?.vaultId === config2.vaultId) {
|
|
44026
|
+
for (const path of Object.keys(locallySkipped.entries)) {
|
|
44027
|
+
protectedPaths.add(path);
|
|
44028
|
+
}
|
|
44029
|
+
}
|
|
43968
44030
|
const staged = [];
|
|
43969
44031
|
const previous = readJsonSafe(paths.ledger);
|
|
43970
44032
|
mkdirSync6(home, { recursive: true });
|
|
@@ -44078,6 +44140,14 @@ function httpDriveWorkspaceHooks(config2, credentials, fetcher = fetch) {
|
|
|
44078
44140
|
fetcher
|
|
44079
44141
|
);
|
|
44080
44142
|
writeLedger(paths.ledger, config2.vaultId, published.manifest);
|
|
44143
|
+
updateSkippedLedger(
|
|
44144
|
+
home,
|
|
44145
|
+
config2.vaultId,
|
|
44146
|
+
currentPending.changes,
|
|
44147
|
+
currentPending.deletes,
|
|
44148
|
+
published.skipped ?? []
|
|
44149
|
+
);
|
|
44150
|
+
result.skipped = published.skipped;
|
|
44081
44151
|
rmSync5(paths.outbox, { force: true });
|
|
44082
44152
|
pending = null;
|
|
44083
44153
|
} catch (error2) {
|
|
@@ -44144,12 +44214,20 @@ function httpDriveWorkspaceHooks(config2, credentials, fetcher = fetch) {
|
|
|
44144
44214
|
}
|
|
44145
44215
|
const published = await publishOutbox(config2, credentials, outbox, fetcher);
|
|
44146
44216
|
writeLedger(paths.ledger, config2.vaultId, published.manifest);
|
|
44217
|
+
updateSkippedLedger(
|
|
44218
|
+
home,
|
|
44219
|
+
config2.vaultId,
|
|
44220
|
+
outbox.changes,
|
|
44221
|
+
outbox.deletes,
|
|
44222
|
+
published.skipped ?? []
|
|
44223
|
+
);
|
|
44147
44224
|
rmSync5(paths.outbox, { force: true });
|
|
44148
44225
|
result.ok = true;
|
|
44149
44226
|
result.changed = true;
|
|
44150
44227
|
result.committed = true;
|
|
44151
44228
|
result.pushed = true;
|
|
44152
44229
|
result.revision = { id: published.revision };
|
|
44230
|
+
result.skipped = published.skipped;
|
|
44153
44231
|
return result;
|
|
44154
44232
|
} catch (error2) {
|
|
44155
44233
|
if (outbox && error2 instanceof DriveWorkspaceHttpError && error2.status === 409) {
|
|
@@ -45069,6 +45147,7 @@ ${GUIDE}` }]
|
|
|
45069
45147
|
ok: sync2.ok !== false,
|
|
45070
45148
|
...written,
|
|
45071
45149
|
sync: sync2,
|
|
45150
|
+
storageSkipped: sync2.skipped ?? [],
|
|
45072
45151
|
skillReview: review,
|
|
45073
45152
|
skillReviewAction: !shouldReview ? null : {
|
|
45074
45153
|
requiresAgentJudgment: true,
|
|
@@ -45087,6 +45166,7 @@ ${GUIDE}` }]
|
|
|
45087
45166
|
// many there were as well as which ones, because the list is
|
|
45088
45167
|
// capped and reporting its length as the total is a lie.
|
|
45089
45168
|
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,
|
|
45169
|
+
sync2.skipped?.length ? `Drive skipped ${sync2.skipped.length} oversized file${sync2.skipped.length === 1 ? "" : "s"} without blocking the handoff: ${sync2.skipped.map((file) => `${file.path} (${file.reason})`).join(", ")}. Clearly tell the human which files remain local.` : null,
|
|
45090
45170
|
shouldReview ? review ? AUTO_SKILL_REVIEW : `The post-handoff skill review could not run. Call pantheon_skill_review for "${written.slug}" and continue without asking permission.` : null
|
|
45091
45171
|
].filter(Boolean).join(" ")
|
|
45092
45172
|
};
|
package/package.json
CHANGED