@narumitw/pi-sync 0.57.9 → 0.57.11
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/CHANGELOG.md +14 -0
- package/README.md +7 -1
- package/dist/chunks/{agent-candidate-GNEYR225.ts → agent-candidate-OCDPRI5G.ts} +12 -9
- package/dist/chunks/{agent-plan-3L7CRFDM.ts → agent-plan-P5B5RGZ7.ts} +22 -18
- package/dist/chunks/{agent-plan-3L7CRFDM.ts.map → agent-plan-P5B5RGZ7.ts.map} +1 -1
- package/dist/chunks/{agent-refusal-retry-RPTMUQXK.ts → agent-refusal-retry-476YGNU5.ts} +11 -8
- package/dist/chunks/{agent-refusal-retry-RPTMUQXK.ts.map → agent-refusal-retry-476YGNU5.ts.map} +1 -1
- package/dist/chunks/{agent-store-55CZOCPX.ts → agent-store-RJSMNOYP.ts} +12 -11
- package/dist/chunks/{agent-store-55CZOCPX.ts.map → agent-store-RJSMNOYP.ts.map} +1 -1
- package/dist/chunks/agent-sync-EUK2CPSS.ts +22 -0
- package/dist/chunks/{chunk-U3XRI2HF.ts → chunk-3IYAPMST.ts} +11 -11
- package/dist/chunks/{chunk-B4QZBDBT.ts → chunk-45COPAK7.ts} +10 -3
- package/dist/chunks/chunk-45COPAK7.ts.map +7 -0
- package/dist/chunks/chunk-5SFMBY5P.ts +26 -0
- package/dist/chunks/chunk-5SFMBY5P.ts.map +7 -0
- package/dist/chunks/{chunk-ED3TYIVW.ts → chunk-5TSCBBPP.ts} +5 -5
- package/dist/chunks/{chunk-5QAE3G3K.ts → chunk-67INJPKR.ts} +6 -6
- package/dist/chunks/{chunk-IWZH5KYS.ts → chunk-6LD5KX55.ts} +10 -10
- package/dist/chunks/{chunk-AAEEHR7H.ts → chunk-6O3EDBRL.ts} +2 -2
- package/dist/chunks/{chunk-CRKTAPSL.ts → chunk-7A35ZAVO.ts} +333 -237
- package/dist/chunks/chunk-7A35ZAVO.ts.map +7 -0
- package/dist/chunks/{chunk-6FVVRTL5.ts → chunk-7OLLPPLU.ts} +77 -63
- package/dist/chunks/chunk-7OLLPPLU.ts.map +7 -0
- package/dist/chunks/{chunk-PQW6GS4J.ts → chunk-7ZIYU5QS.ts} +12 -10
- package/dist/chunks/{chunk-PQW6GS4J.ts.map → chunk-7ZIYU5QS.ts.map} +1 -1
- package/dist/chunks/{chunk-S7QS4AWK.ts → chunk-AKMV47YC.ts} +5 -5
- package/dist/chunks/chunk-AR2DGDUI.ts +55 -0
- package/dist/chunks/chunk-AR2DGDUI.ts.map +7 -0
- package/dist/chunks/{chunk-GNH73BJ5.ts → chunk-BEST45H2.ts} +7 -7
- package/dist/chunks/chunk-CBLTWXAU.ts +114 -0
- package/dist/chunks/chunk-CBLTWXAU.ts.map +7 -0
- package/dist/chunks/{chunk-GP5DU62N.ts → chunk-CPT2BN6N.ts} +2 -2
- package/dist/chunks/{chunk-UPNVIUBN.ts → chunk-DN4IA7MR.ts} +6 -6
- package/dist/chunks/{chunk-PG7NMFP2.ts → chunk-DRTC4PKM.ts} +8 -8
- package/dist/chunks/chunk-ESKOPQVB.ts +348 -0
- package/dist/chunks/chunk-ESKOPQVB.ts.map +7 -0
- package/dist/chunks/{chunk-MKKF4IMY.ts → chunk-F7E3VFXU.ts} +5 -5
- package/dist/chunks/{chunk-HUZ5CR4W.ts → chunk-FHE2DCA2.ts} +3 -52
- package/dist/chunks/chunk-FHE2DCA2.ts.map +7 -0
- package/dist/chunks/{chunk-UBV24CG4.ts → chunk-FLHCOJCD.ts} +3 -3
- package/dist/chunks/chunk-GNYGNHFF.ts +27 -0
- package/dist/chunks/chunk-GNYGNHFF.ts.map +7 -0
- package/dist/chunks/chunk-KYTT7KV4.ts +319 -0
- package/dist/chunks/chunk-KYTT7KV4.ts.map +7 -0
- package/dist/chunks/{chunk-A6HU4ERM.ts → chunk-MKSMJPVA.ts} +6 -23
- package/dist/chunks/chunk-MKSMJPVA.ts.map +7 -0
- package/dist/chunks/{chunk-ORGBI36T.ts → chunk-OJARL2TG.ts} +4 -4
- package/dist/chunks/{chunk-JCH3VXIO.ts → chunk-OKPPZA4D.ts} +150 -91
- package/dist/chunks/chunk-OKPPZA4D.ts.map +7 -0
- package/dist/chunks/{chunk-QO333NM4.ts → chunk-OVBAW7KV.ts} +180 -133
- package/dist/chunks/chunk-OVBAW7KV.ts.map +7 -0
- package/dist/chunks/{chunk-GSNPASKB.ts → chunk-Q23JJW7E.ts} +6 -6
- package/dist/chunks/{chunk-YK52VDXG.ts → chunk-TIMWN2RH.ts} +10 -8
- package/dist/chunks/{chunk-YK52VDXG.ts.map → chunk-TIMWN2RH.ts.map} +1 -1
- package/dist/chunks/{chunk-UOHR7LRO.ts → chunk-TZC7GDJE.ts} +10 -22
- package/dist/chunks/chunk-TZC7GDJE.ts.map +7 -0
- package/dist/chunks/chunk-X7R6DCVF.ts +28 -0
- package/dist/chunks/chunk-X7R6DCVF.ts.map +7 -0
- package/dist/chunks/{chunk-76NB4R7U.ts → chunk-XJHQPB3E.ts} +2 -2
- package/dist/chunks/{chunk-BDB4IDM3.ts → chunk-Y4UVXOLQ.ts} +8 -6
- package/dist/chunks/{chunk-BDB4IDM3.ts.map → chunk-Y4UVXOLQ.ts.map} +1 -1
- package/dist/chunks/{chunk-P7DD5PWZ.ts → chunk-ZDDBZH72.ts} +3 -3
- package/dist/chunks/command-handler-F2E7A5T5.ts +548 -0
- package/dist/chunks/command-handler-F2E7A5T5.ts.map +7 -0
- package/dist/chunks/{config-KGIYTTXQ.ts → config-HYG7G5EM.ts} +7 -6
- package/dist/chunks/{conflict-artifacts-FXFIIBCB.ts → conflict-artifacts-J6WSDCWP.ts} +13 -9
- package/dist/chunks/{conflict-review-3X37QEIT.ts → conflict-review-2QMO2K6Q.ts} +31 -25
- package/dist/chunks/{conflict-review-3X37QEIT.ts.map → conflict-review-2QMO2K6Q.ts.map} +1 -1
- package/dist/chunks/{continuous-record-SQJ47CXN.ts → continuous-record-AH7JGYKM.ts} +8 -7
- package/dist/chunks/{continuous-sync-Q6QUD6TY.ts → continuous-sync-VRMXCA5X.ts} +33 -28
- package/dist/chunks/{continuous-sync-Q6QUD6TY.ts.map → continuous-sync-VRMXCA5X.ts.map} +1 -1
- package/dist/chunks/{file-selection-3JJYOVNR.ts → file-selection-IELTXSGZ.ts} +11 -10
- package/dist/chunks/{file-selection-3JJYOVNR.ts.map → file-selection-IELTXSGZ.ts.map} +1 -1
- package/dist/chunks/{git-backend-NYKSG5X6.ts → git-backend-KHD36W27.ts} +15 -12
- package/dist/chunks/{git-backend-NYKSG5X6.ts.map → git-backend-KHD36W27.ts.map} +1 -1
- package/dist/chunks/{local-fields-6DGYOOIK.ts → local-fields-JEKAPZKD.ts} +9 -5
- package/dist/chunks/manager-result-dispatcher-6W52NM7F.ts +32 -0
- package/dist/chunks/{manager-ui-ZH6DEC2G.ts → manager-ui-LM7DSJ2Y.ts} +124 -67
- package/dist/chunks/manager-ui-LM7DSJ2Y.ts.map +7 -0
- package/dist/chunks/{merge-baseline-store-RFCAH7KL.ts → merge-baseline-store-65GKUMXI.ts} +6 -5
- package/dist/chunks/remote-selection-ui-TD4C4W3J.ts +31 -0
- package/dist/chunks/{s3-backend-F7PR5FB3.ts → s3-backend-L24UZ6IK.ts} +24 -18
- package/dist/chunks/s3-backend-L24UZ6IK.ts.map +7 -0
- package/dist/chunks/{setup-switch-E7PHKI6J.ts → setup-switch-PIPXYPCW.ts} +6 -7
- package/dist/chunks/{setup-wizard-OVHZYXNW.ts → setup-wizard-RR5U3SUB.ts} +8 -9
- package/dist/chunks/{setup-wizard-OVHZYXNW.ts.map → setup-wizard-RR5U3SUB.ts.map} +1 -1
- package/dist/chunks/{snapshot-THS5EY2L.ts → snapshot-RGNDYT6A.ts} +10 -6
- package/dist/chunks/snapshot-transaction-26BQO36S.ts +24 -0
- package/dist/chunks/sync-inspection-MOMLGUTD.ts +25 -0
- package/dist/chunks/sync-inspection-MOMLGUTD.ts.map +7 -0
- package/dist/chunks/{sync-operations-Y72GNIQ2.ts → sync-operations-CV3TULLD.ts} +66 -57
- package/dist/chunks/{sync-operations-Y72GNIQ2.ts.map → sync-operations-CV3TULLD.ts.map} +1 -1
- package/dist/chunks/{sync-state-CFL4RRRB.ts → sync-state-7L4NT7W2.ts} +8 -5
- package/dist/chunks/sync-state-7L4NT7W2.ts.map +7 -0
- package/dist/chunks/{webdav-backend-TGFUH3SF.ts → webdav-backend-3ZCACILP.ts} +15 -12
- package/dist/chunks/{webdav-backend-TGFUH3SF.ts.map → webdav-backend-3ZCACILP.ts.map} +1 -1
- package/dist/index.ts +54 -537
- package/dist/index.ts.map +3 -3
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +8 -1
- package/src/backends/s3/s3-client.ts +8 -1
- package/src/commands/command-execution.ts +8 -3
- package/src/paths.ts +6 -1
- package/src/settings/config-file.ts +205 -118
- package/src/settings/config.ts +2 -2
- package/src/settings/settings-management.ts +15 -1
- package/src/settings/settings-store.ts +0 -14
- package/src/settings/settings-validation.ts +1 -1
- package/src/snapshot/session-paths.ts +15 -2
- package/src/snapshot/snapshot-mutation-queues.ts +142 -0
- package/src/snapshot/snapshot-transaction-directory.ts +16 -0
- package/src/snapshot/snapshot-transaction.ts +123 -137
- package/src/sync/automatic-sync.ts +12 -6
- package/src/sync/local-field-policy.ts +29 -0
- package/src/sync/local-fields.ts +3 -29
- package/src/sync/merge-apply.ts +6 -0
- package/src/sync/mutation-owner.ts +22 -0
- package/src/sync/startup-check.ts +3 -2
- package/src/sync/sync-loaders.ts +4 -0
- package/src/sync/sync-local.ts +2 -19
- package/src/sync-extension.ts +7 -2
- package/src/ui/cancellable-operation.ts +36 -13
- package/src/ui/manager-state.ts +3 -1
- package/src/ui/manager-ui.ts +76 -24
- package/src/ui/remote-selection-ui.ts +131 -82
- package/src/ui/settings-ui.ts +2 -1
- package/dist/chunks/chunk-6FVVRTL5.ts.map +0 -7
- package/dist/chunks/chunk-A6HU4ERM.ts.map +0 -7
- package/dist/chunks/chunk-B4QZBDBT.ts.map +0 -7
- package/dist/chunks/chunk-CRKTAPSL.ts.map +0 -7
- package/dist/chunks/chunk-HUZ5CR4W.ts.map +0 -7
- package/dist/chunks/chunk-JCH3VXIO.ts.map +0 -7
- package/dist/chunks/chunk-QO333NM4.ts.map +0 -7
- package/dist/chunks/chunk-QOFMXPM5.ts +0 -735
- package/dist/chunks/chunk-QOFMXPM5.ts.map +0 -7
- package/dist/chunks/chunk-UOHR7LRO.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-HOCM2GDA.ts +0 -24
- package/dist/chunks/manager-ui-ZH6DEC2G.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-YFPGYGNE.ts +0 -23
- package/dist/chunks/s3-backend-F7PR5FB3.ts.map +0 -7
- package/dist/chunks/sync-inspection-J25EEKZK.ts +0 -21
- /package/dist/chunks/{agent-candidate-GNEYR225.ts.map → agent-candidate-OCDPRI5G.ts.map} +0 -0
- /package/dist/chunks/{config-KGIYTTXQ.ts.map → agent-sync-EUK2CPSS.ts.map} +0 -0
- /package/dist/chunks/{chunk-U3XRI2HF.ts.map → chunk-3IYAPMST.ts.map} +0 -0
- /package/dist/chunks/{chunk-ED3TYIVW.ts.map → chunk-5TSCBBPP.ts.map} +0 -0
- /package/dist/chunks/{chunk-5QAE3G3K.ts.map → chunk-67INJPKR.ts.map} +0 -0
- /package/dist/chunks/{chunk-IWZH5KYS.ts.map → chunk-6LD5KX55.ts.map} +0 -0
- /package/dist/chunks/{chunk-AAEEHR7H.ts.map → chunk-6O3EDBRL.ts.map} +0 -0
- /package/dist/chunks/{chunk-S7QS4AWK.ts.map → chunk-AKMV47YC.ts.map} +0 -0
- /package/dist/chunks/{chunk-GNH73BJ5.ts.map → chunk-BEST45H2.ts.map} +0 -0
- /package/dist/chunks/{chunk-GP5DU62N.ts.map → chunk-CPT2BN6N.ts.map} +0 -0
- /package/dist/chunks/{chunk-UPNVIUBN.ts.map → chunk-DN4IA7MR.ts.map} +0 -0
- /package/dist/chunks/{chunk-PG7NMFP2.ts.map → chunk-DRTC4PKM.ts.map} +0 -0
- /package/dist/chunks/{chunk-MKKF4IMY.ts.map → chunk-F7E3VFXU.ts.map} +0 -0
- /package/dist/chunks/{chunk-UBV24CG4.ts.map → chunk-FLHCOJCD.ts.map} +0 -0
- /package/dist/chunks/{chunk-ORGBI36T.ts.map → chunk-OJARL2TG.ts.map} +0 -0
- /package/dist/chunks/{chunk-GSNPASKB.ts.map → chunk-Q23JJW7E.ts.map} +0 -0
- /package/dist/chunks/{chunk-76NB4R7U.ts.map → chunk-XJHQPB3E.ts.map} +0 -0
- /package/dist/chunks/{chunk-P7DD5PWZ.ts.map → chunk-ZDDBZH72.ts.map} +0 -0
- /package/dist/chunks/{conflict-artifacts-FXFIIBCB.ts.map → config-HYG7G5EM.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-SQJ47CXN.ts.map → conflict-artifacts-J6WSDCWP.ts.map} +0 -0
- /package/dist/chunks/{local-fields-6DGYOOIK.ts.map → continuous-record-AH7JGYKM.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-HOCM2GDA.ts.map → local-fields-JEKAPZKD.ts.map} +0 -0
- /package/dist/chunks/{merge-baseline-store-RFCAH7KL.ts.map → manager-result-dispatcher-6W52NM7F.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-YFPGYGNE.ts.map → merge-baseline-store-65GKUMXI.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-E7PHKI6J.ts.map → remote-selection-ui-TD4C4W3J.ts.map} +0 -0
- /package/dist/chunks/{snapshot-THS5EY2L.ts.map → setup-switch-PIPXYPCW.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-J25EEKZK.ts.map → snapshot-RGNDYT6A.ts.map} +0 -0
- /package/dist/chunks/{sync-state-CFL4RRRB.ts.map → snapshot-transaction-26BQO36S.ts.map} +0 -0
|
@@ -27,7 +27,7 @@ function assertWithinRoot(root, target, label = target) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
function encodeKey(key) {
|
|
30
|
-
return key.split("/").map(encodeURIComponent).join("/");
|
|
30
|
+
return key.split("/").map(encodeURIComponent).join("/").replace(/[!'()*]/gu, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
31
31
|
}
|
|
32
32
|
function posixJoin(...parts) {
|
|
33
33
|
return parts.map((part) => trimSlashes(part)).filter(Boolean).join("/");
|
|
@@ -48,52 +48,6 @@ function trimSlashes(value) {
|
|
|
48
48
|
return value.replace(/^\/+|\/+$/g, "");
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// src/state/json-file.ts
|
|
52
|
-
import { randomUUID } from "node:crypto";
|
|
53
|
-
import fs from "node:fs/promises";
|
|
54
|
-
import path2 from "node:path";
|
|
55
|
-
async function readJsonIfExists(filePath) {
|
|
56
|
-
try {
|
|
57
|
-
return JSON.parse(await fs.readFile(filePath, "utf8"));
|
|
58
|
-
} catch (error) {
|
|
59
|
-
if (error.code === "ENOENT") return void 0;
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function writeJson(filePath, value, options = {}) {
|
|
64
|
-
const content = `${JSON.stringify(value, null, " ")}
|
|
65
|
-
`;
|
|
66
|
-
if (options.maxBytes !== void 0 && Buffer.byteLength(content) > options.maxBytes)
|
|
67
|
-
throw new Error(
|
|
68
|
-
"Private state document exceeds its storage bound; preserve existing evidence and use reviewed recovery."
|
|
69
|
-
);
|
|
70
|
-
await fs.mkdir(path2.dirname(filePath), { recursive: true, mode: 448 });
|
|
71
|
-
const temp = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
72
|
-
try {
|
|
73
|
-
const handle = await fs.open(temp, "wx", 384);
|
|
74
|
-
try {
|
|
75
|
-
await handle.writeFile(content);
|
|
76
|
-
await handle.sync();
|
|
77
|
-
} finally {
|
|
78
|
-
await handle.close();
|
|
79
|
-
}
|
|
80
|
-
if (process.platform !== "win32") await fs.chmod(temp, 384);
|
|
81
|
-
await fs.rename(temp, filePath);
|
|
82
|
-
await syncDirectory(path2.dirname(filePath));
|
|
83
|
-
} finally {
|
|
84
|
-
await fs.rm(temp, { force: true });
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async function syncDirectory(directory) {
|
|
88
|
-
if (process.platform === "win32") return;
|
|
89
|
-
const handle = await fs.open(directory, "r");
|
|
90
|
-
try {
|
|
91
|
-
await handle.sync();
|
|
92
|
-
} finally {
|
|
93
|
-
await handle.close();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
51
|
export {
|
|
98
52
|
isDeniedPath,
|
|
99
53
|
isPathInside,
|
|
@@ -102,9 +56,6 @@ export {
|
|
|
102
56
|
encodeKey,
|
|
103
57
|
posixJoin,
|
|
104
58
|
parentPaths,
|
|
105
|
-
toPosix
|
|
106
|
-
readJsonIfExists,
|
|
107
|
-
writeJson,
|
|
108
|
-
syncDirectory
|
|
59
|
+
toPosix
|
|
109
60
|
};
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-FHE2DCA2.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/paths.ts"],
|
|
4
|
+
"sourcesContent": ["import path from \"node:path\";\n\nexport function isDeniedPath(relativePath: string) {\n const normalized = toPosix(relativePath);\n const lower = normalized.toLowerCase();\n const segments = lower.split(\"/\");\n const base = path.posix.basename(lower);\n return (\n segments.includes(\"node_modules\") ||\n segments.includes(\".git\") ||\n segments.includes(\".pisync\") ||\n segments.includes(\"pi-sync\") ||\n segments.includes(\".pi-sync-state-migration.lock\") ||\n base === \".env\" ||\n base.startsWith(\".env.\") ||\n base.endsWith(\".env\") ||\n base.includes(\"secret\") ||\n base.includes(\"token\") ||\n base === \"pi-sync.json\" ||\n base.startsWith(\"pi-sync.json.\") ||\n base.startsWith(\".pi-sync.json.\") ||\n base === \"pi-sync.local.json\" ||\n base.startsWith(\"pi-sync.local.json.\") ||\n base.startsWith(\".pi-sync.local.json.\")\n );\n}\n\nexport function isPathInside(parent: string, child: string) {\n const relative = path.relative(path.resolve(parent), path.resolve(child));\n return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n}\n\nexport function safeJoin(root: string, relativePath: string) {\n const target = path.resolve(root, relativePath);\n assertWithinRoot(root, target, relativePath);\n return target;\n}\n\nexport function assertWithinRoot(root: string, target: string, label = target) {\n const resolvedRoot = path.resolve(root);\n const resolvedTarget = path.resolve(target);\n if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(`${resolvedRoot}${path.sep}`)) {\n throw new Error(`Unsafe path in snapshot: ${label}`);\n }\n}\n\nexport function encodeKey(key: string) {\n // SigV4 permits only RFC 3986 unreserved characters and key separators.\n return key\n .split(\"/\")\n .map(encodeURIComponent)\n .join(\"/\")\n .replace(/[!'()*]/gu, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);\n}\n\nexport function posixJoin(...parts: string[]) {\n return parts\n .map((part) => trimSlashes(part))\n .filter(Boolean)\n .join(\"/\");\n}\n\nexport function parentPaths(relativePath: string) {\n const results: string[] = [];\n let index = relativePath.lastIndexOf(\"/\");\n while (index > 0) {\n results.push(relativePath.slice(0, index));\n index = relativePath.lastIndexOf(\"/\", index - 1);\n }\n return results;\n}\n\nexport function toPosix(value: string) {\n return value.split(path.sep).join(\"/\");\n}\n\nfunction trimSlashes(value: string) {\n return value.replace(/^\\/+|\\/+$/g, \"\");\n}\n\nexport function safeName(value: string) {\n return value.replace(/[^A-Za-z0-9._-]/g, \"_\");\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAAA,OAAO,UAAU;AAEV,SAAS,aAAa,cAAsB;AACjD,QAAM,aAAa,QAAQ,YAAY;AACvC,QAAM,QAAQ,WAAW,YAAY;AACrC,QAAM,WAAW,MAAM,MAAM,GAAG;AAChC,QAAM,OAAO,KAAK,MAAM,SAAS,KAAK;AACtC,SACE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,IAAI,CAAC,EAC/B,OAAO,OAAO,EACd,KAAK,GAAG;AACb;AAEO,SAAS,YAAY,cAAsB;AAChD,QAAM,UAAoB,CAAC;AAC3B,MAAI,QAAQ,aAAa,YAAY,GAAG;AACxC,SAAO,QAAQ,GAAG;AAChB,YAAQ,KAAK,aAAa,MAAM,GAAG,KAAK,CAAC;AACzC,YAAQ,aAAa,YAAY,KAAK,QAAQ,CAAC;AAAA,EACjD;AACA,SAAO;AACT;AAEO,SAAS,QAAQ,OAAe;AACrC,SAAO,MAAM,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AACvC;AAEA,SAAS,YAAY,OAAe;AAClC,SAAO,MAAM,QAAQ,cAAc,EAAE;AACvC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-PWMWOJP4.ts";
|
|
6
6
|
import {
|
|
7
7
|
snapshotSelectionInclude
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KYTT7KV4.ts";
|
|
9
9
|
|
|
10
10
|
// src/snapshot/snapshot-codec.ts
|
|
11
11
|
import { Readable, Writable } from "node:stream";
|
|
@@ -42,7 +42,7 @@ async function decodeSnapshot(buffer, options = {}) {
|
|
|
42
42
|
throw new Error("Unsupported snapshot format.");
|
|
43
43
|
}
|
|
44
44
|
if (parsed.version === 2 || parsed.version === 3) {
|
|
45
|
-
const { normalizeLocalFields, validatePortableSnapshot } = await import("./local-fields-
|
|
45
|
+
const { normalizeLocalFields, validatePortableSnapshot } = await import("./local-fields-JEKAPZKD.ts");
|
|
46
46
|
validatePortableSnapshot(parsed);
|
|
47
47
|
if (parsed.localFields !== void 0) parsed.localFields = normalizeLocalFields(parsed.localFields);
|
|
48
48
|
} else if (parsed.localFields !== void 0) throw new Error("Portable field policy requires snapshot version 2.");
|
|
@@ -54,4 +54,4 @@ export {
|
|
|
54
54
|
encodeSnapshot,
|
|
55
55
|
decodeSnapshot
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-FLHCOJCD.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
throwIfAborted
|
|
5
|
+
} from "./chunk-PWMWOJP4.ts";
|
|
6
|
+
import {
|
|
7
|
+
agentDir
|
|
8
|
+
} from "./chunk-CBLTWXAU.ts";
|
|
9
|
+
|
|
10
|
+
// src/sync/mutation-owner.ts
|
|
11
|
+
function captureMutationOwner(ctx, signal) {
|
|
12
|
+
const manager = ctx.sessionManager;
|
|
13
|
+
const file = manager.getSessionFile?.();
|
|
14
|
+
const id = manager.getSessionId?.();
|
|
15
|
+
const cwd = manager.getCwd?.();
|
|
16
|
+
const root = agentDir();
|
|
17
|
+
return () => {
|
|
18
|
+
throwIfAborted(signal);
|
|
19
|
+
if (ctx.sessionManager !== manager || manager.getSessionFile?.() !== file || manager.getSessionId?.() !== id || manager.getCwd?.() !== cwd || agentDir() !== root)
|
|
20
|
+
throw new Error("Session changed during file mutation; evidence retained for review.");
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
captureMutationOwner
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-GNYGNHFF.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/mutation-owner.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { agentDir } from \"../snapshot/session-paths.js\";\nimport { throwIfAborted } from \"./signals.js\";\n\nexport function captureMutationOwner(ctx: ExtensionContext | ExtensionCommandContext, signal?: AbortSignal) {\n const manager = ctx.sessionManager;\n const file = manager.getSessionFile?.();\n const id = manager.getSessionId?.();\n const cwd = manager.getCwd?.();\n const root = agentDir();\n return () => {\n throwIfAborted(signal);\n if (\n ctx.sessionManager !== manager ||\n manager.getSessionFile?.() !== file ||\n manager.getSessionId?.() !== id ||\n manager.getCwd?.() !== cwd ||\n agentDir() !== root\n )\n throw new Error(\"Session changed during file mutation; evidence retained for review.\");\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAIO,SAAS,qBAAqB,KAAiD,QAAsB;AAC1G,QAAM,UAAU,IAAI;AACpB,QAAM,OAAO,QAAQ,iBAAiB;AACtC,QAAM,KAAK,QAAQ,eAAe;AAClC,QAAM,MAAM,QAAQ,SAAS;AAC7B,QAAM,OAAO,SAAS;AACtB,SAAO,MAAM;AACX,mBAAe,MAAM;AACrB,QACE,IAAI,mBAAmB,WACvB,QAAQ,iBAAiB,MAAM,QAC/B,QAAQ,eAAe,MAAM,MAC7B,QAAQ,SAAS,MAAM,OACvB,SAAS,MAAM;AAEf,YAAM,IAAI,MAAM,qEAAqE;AAAA,EACzF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
isDeniedPath,
|
|
5
|
+
toPosix
|
|
6
|
+
} from "./chunk-FHE2DCA2.ts";
|
|
7
|
+
|
|
8
|
+
// src/sync/sync-policy.ts
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
var BUILT_IN_SYNC_ROOTS = [
|
|
11
|
+
"settings.json",
|
|
12
|
+
"keybindings.json",
|
|
13
|
+
"models.json",
|
|
14
|
+
"AGENTS.md",
|
|
15
|
+
"APPEND_SYSTEM.md",
|
|
16
|
+
"skills",
|
|
17
|
+
"prompts",
|
|
18
|
+
"themes",
|
|
19
|
+
"extensions"
|
|
20
|
+
];
|
|
21
|
+
var DEFAULT_SYNC_INCLUDE = [...BUILT_IN_SYNC_ROOTS];
|
|
22
|
+
var SNAPSHOT_SELECTION_VERSION = 1;
|
|
23
|
+
var MAX_SYNC_INCLUDE_ITEMS = 1024;
|
|
24
|
+
var MAX_SYNC_INCLUDE_PATH_BYTES = 4096;
|
|
25
|
+
var MAX_SYNC_INCLUDE_TOTAL_BYTES = 256 * 1024;
|
|
26
|
+
var BUILT_IN_BY_LOWER = new Map(
|
|
27
|
+
BUILT_IN_SYNC_ROOTS.map((fileName) => [fileName.toLowerCase(), fileName])
|
|
28
|
+
);
|
|
29
|
+
var TOP_LEVEL_FILE_PATHS = new Map(
|
|
30
|
+
BUILT_IN_SYNC_ROOTS.filter((fileName) => fileName.includes(".")).map((fileName) => [
|
|
31
|
+
fileName.toLowerCase(),
|
|
32
|
+
fileName
|
|
33
|
+
])
|
|
34
|
+
);
|
|
35
|
+
var TOP_LEVEL_DIRS = new Set(BUILT_IN_SYNC_ROOTS.filter((fileName) => !fileName.includes(".")));
|
|
36
|
+
var RESERVED_TOP_LEVEL_NAMES = /* @__PURE__ */ new Set([...BUILT_IN_BY_LOWER.keys(), "sessions"]);
|
|
37
|
+
function normalizeSyncInclude(value) {
|
|
38
|
+
if (!Array.isArray(value)) {
|
|
39
|
+
throw new Error("Invalid pi-sync settings: sync.include must be an array.");
|
|
40
|
+
}
|
|
41
|
+
if (value.length > MAX_SYNC_INCLUDE_ITEMS) {
|
|
42
|
+
throw new Error(`Invalid pi-sync settings: sync.include has too many items; limit: ${MAX_SYNC_INCLUDE_ITEMS}.`);
|
|
43
|
+
}
|
|
44
|
+
const result = [];
|
|
45
|
+
const seen = /* @__PURE__ */ new Set();
|
|
46
|
+
const pathRoot = { children: /* @__PURE__ */ new Map() };
|
|
47
|
+
let totalBytes = 0;
|
|
48
|
+
for (const item of value) {
|
|
49
|
+
if (typeof item !== "string") {
|
|
50
|
+
throw new Error("Invalid pi-sync settings: sync.include items must be strings.");
|
|
51
|
+
}
|
|
52
|
+
const itemBytes = Buffer.byteLength(item, "utf8");
|
|
53
|
+
if (itemBytes > MAX_SYNC_INCLUDE_PATH_BYTES) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Invalid pi-sync settings: sync.include item is too long; limit: ${MAX_SYNC_INCLUDE_PATH_BYTES} bytes.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
totalBytes += itemBytes;
|
|
59
|
+
if (totalBytes > MAX_SYNC_INCLUDE_TOTAL_BYTES) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Invalid pi-sync settings: sync.include is too large; limit: ${MAX_SYNC_INCLUDE_TOTAL_BYTES} bytes.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const trimmed = item.trim();
|
|
65
|
+
const builtIn = BUILT_IN_BY_LOWER.get(trimmed.toLowerCase());
|
|
66
|
+
const normalized = builtIn ?? (trimmed.toLowerCase() === "sessions" ? "sessions" : trimmed);
|
|
67
|
+
if (!builtIn && normalized !== "sessions") validateAgentRelativeInclude(normalized);
|
|
68
|
+
const identity = normalized.toLowerCase();
|
|
69
|
+
if (seen.has(identity)) {
|
|
70
|
+
throw new Error(`Invalid pi-sync settings: duplicate sync.include item: ${item}`);
|
|
71
|
+
}
|
|
72
|
+
addIncludePath(pathRoot, identity, item);
|
|
73
|
+
seen.add(identity);
|
|
74
|
+
result.push(normalized);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
function addIncludePath(root, identity, source) {
|
|
79
|
+
let node = root;
|
|
80
|
+
for (const segment of identity.split("/")) {
|
|
81
|
+
if (node.selected !== void 0) throwOverlappingInclude(source);
|
|
82
|
+
let child = node.children.get(segment);
|
|
83
|
+
if (!child) {
|
|
84
|
+
child = { children: /* @__PURE__ */ new Map() };
|
|
85
|
+
node.children.set(segment, child);
|
|
86
|
+
}
|
|
87
|
+
node = child;
|
|
88
|
+
}
|
|
89
|
+
if (node.children.size > 0) throwOverlappingInclude(source);
|
|
90
|
+
node.selected = identity;
|
|
91
|
+
}
|
|
92
|
+
function throwOverlappingInclude(item) {
|
|
93
|
+
throw new Error(`Invalid pi-sync settings: overlapping sync.include items are ambiguous: ${item}`);
|
|
94
|
+
}
|
|
95
|
+
function validateAgentRelativeInclude(value) {
|
|
96
|
+
const normalized = toPosix(value);
|
|
97
|
+
const topLevel = normalized.split("/")[0]?.toLowerCase();
|
|
98
|
+
if (!normalized || normalized === "." || normalized === ".." || normalized.startsWith("../") || path.posix.isAbsolute(normalized) || normalized.includes("\\") || path.posix.normalize(normalized) !== normalized || // biome-ignore lint/suspicious/noControlCharactersInRegex: Include paths cannot contain controls.
|
|
99
|
+
/[\u0000-\u001f\u007f-\u009f]/u.test(normalized)) {
|
|
100
|
+
throw new Error(`Invalid pi-sync settings: sync.include item must be a safe agent-relative path: ${value}`);
|
|
101
|
+
}
|
|
102
|
+
if (isDeniedPath(normalized)) {
|
|
103
|
+
throw new Error(`Invalid pi-sync settings: ${value} cannot be synced.`);
|
|
104
|
+
}
|
|
105
|
+
if (topLevel && RESERVED_TOP_LEVEL_NAMES.has(topLevel)) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`Invalid pi-sync settings: use the canonical ${topLevel} root instead of a nested sync.include path.`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function portableSnapshotSelection(value) {
|
|
112
|
+
const selection = value;
|
|
113
|
+
if (!selection || typeof selection !== "object" || Array.isArray(selection) || selection.version !== SNAPSHOT_SELECTION_VERSION || !Object.hasOwn(selection, "include") || Object.keys(selection).some((key) => key !== "version" && key !== "include")) {
|
|
114
|
+
throw new Error("Invalid snapshot selection policy.");
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
version: SNAPSHOT_SELECTION_VERSION,
|
|
118
|
+
include: normalizeSyncInclude(selection.include)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function snapshotSelectionInclude(snapshot) {
|
|
122
|
+
return snapshot.selection === void 0 ? void 0 : portableSnapshotSelection(snapshot.selection).include;
|
|
123
|
+
}
|
|
124
|
+
function selectionForSnapshot(include) {
|
|
125
|
+
return { version: SNAPSHOT_SELECTION_VERSION, include: normalizeSyncInclude(include) };
|
|
126
|
+
}
|
|
127
|
+
function sameSyncInclude(left, right) {
|
|
128
|
+
const normalizedLeft = normalizeSyncInclude(left);
|
|
129
|
+
const normalizedRight = normalizeSyncInclude(right);
|
|
130
|
+
return normalizedLeft.length === normalizedRight.length && normalizedLeft.every((item, index) => item === normalizedRight[index]);
|
|
131
|
+
}
|
|
132
|
+
function compareSyncInclude(local, remote) {
|
|
133
|
+
const localInclude = normalizeSyncInclude(local);
|
|
134
|
+
const remoteInclude = normalizeSyncInclude(remote);
|
|
135
|
+
const localSet = new Set(localInclude);
|
|
136
|
+
const remoteSet = new Set(remoteInclude);
|
|
137
|
+
return {
|
|
138
|
+
same: sameSyncInclude(localInclude, remoteInclude),
|
|
139
|
+
remoteOnly: remoteInclude.filter((item) => !localSet.has(item)),
|
|
140
|
+
localOnly: localInclude.filter((item) => !remoteSet.has(item))
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function inspectRemoteSelection(localInclude, snapshot) {
|
|
144
|
+
const remoteInclude = snapshotSelectionInclude(snapshot);
|
|
145
|
+
if (!remoteInclude) {
|
|
146
|
+
return { kind: "legacy", discovered: discoverLegacySnapshotInclude(snapshot) };
|
|
147
|
+
}
|
|
148
|
+
const comparison = compareSyncInclude(localInclude, remoteInclude);
|
|
149
|
+
return comparison.same ? { kind: "same", include: remoteInclude } : { kind: "different", include: remoteInclude, ...comparison };
|
|
150
|
+
}
|
|
151
|
+
var RemoteSelectionMismatchError = class extends Error {
|
|
152
|
+
decision;
|
|
153
|
+
setupName;
|
|
154
|
+
localInclude;
|
|
155
|
+
remoteInclude;
|
|
156
|
+
constructor(setupName, localInclude, remoteInclude, configIdentity = JSON.stringify([setupName, normalizeSyncInclude(localInclude)])) {
|
|
157
|
+
const local = normalizeSyncInclude(localInclude);
|
|
158
|
+
const remote = normalizeSyncInclude(remoteInclude);
|
|
159
|
+
super(formatRemoteSelectionMismatch(setupName, local, remote));
|
|
160
|
+
this.name = "RemoteSelectionMismatchError";
|
|
161
|
+
this.setupName = setupName;
|
|
162
|
+
this.localInclude = local;
|
|
163
|
+
this.remoteInclude = remote;
|
|
164
|
+
this.decision = {
|
|
165
|
+
setupName,
|
|
166
|
+
configIdentity,
|
|
167
|
+
localInclude: [...local],
|
|
168
|
+
remoteInclude: [...remote]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
function remoteSelectionMismatch(config, remoteInclude, configIdentity) {
|
|
173
|
+
return new RemoteSelectionMismatchError(config.setupName, config.include, remoteInclude, configIdentity);
|
|
174
|
+
}
|
|
175
|
+
function formatRemoteSelectionMismatch(setupName, localInclude, remoteInclude) {
|
|
176
|
+
const comparison = compareSyncInclude(localInclude, remoteInclude);
|
|
177
|
+
const lines = [
|
|
178
|
+
`Synced content differs for sync setup \u201C${stripTerminalControls(setupName)}\u201D.`,
|
|
179
|
+
`Remote-only: ${comparison.remoteOnly.join(", ") || "none"}`,
|
|
180
|
+
`This-device-only: ${comparison.localOnly.join(", ") || "none"}`
|
|
181
|
+
];
|
|
182
|
+
if (comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0) {
|
|
183
|
+
lines.push(
|
|
184
|
+
"Only ordering differs.",
|
|
185
|
+
`Remote order: ${remoteInclude.join(", ") || "none"}`,
|
|
186
|
+
`This device order: ${localInclude.join(", ") || "none"}`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
lines.push("Run /sync in TUI to review both content lists and choose what happens next.");
|
|
190
|
+
return lines.join("\n");
|
|
191
|
+
}
|
|
192
|
+
function stripTerminalControls(value) {
|
|
193
|
+
return value.replace(/[\u0000-\u001f\u007f-\u009f]/gu, "?");
|
|
194
|
+
}
|
|
195
|
+
function discoverLegacySnapshotInclude(snapshot) {
|
|
196
|
+
const builtIns = /* @__PURE__ */ new Set();
|
|
197
|
+
const custom = /* @__PURE__ */ new Set();
|
|
198
|
+
let sessions = false;
|
|
199
|
+
for (const file of snapshot.files) {
|
|
200
|
+
const normalized = toPosix(file.path);
|
|
201
|
+
if (!normalized || file.path.includes("\\") || normalized.length > 4096 || normalized.startsWith("../") || path.posix.isAbsolute(normalized) || path.posix.normalize(normalized) !== normalized || // biome-ignore lint/suspicious/noControlCharactersInRegex: Ignore unsafe legacy paths.
|
|
202
|
+
/[\u0000-\u001f\u007f-\u009f]/u.test(normalized) || isDeniedPath(normalized)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const [topLevel, ...rest] = normalized.split("/");
|
|
206
|
+
if (!topLevel) continue;
|
|
207
|
+
if (topLevel === "sessions" && rest.length > 0) {
|
|
208
|
+
sessions = true;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const builtIn = BUILT_IN_BY_LOWER.get(topLevel.toLowerCase());
|
|
212
|
+
if (builtIn && (TOP_LEVEL_DIRS.has(builtIn) && rest.length > 0 || !TOP_LEVEL_DIRS.has(builtIn) && rest.length === 0)) {
|
|
213
|
+
builtIns.add(builtIn);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (isSafeCustomIncludePath(topLevel)) custom.add(topLevel);
|
|
217
|
+
}
|
|
218
|
+
return [
|
|
219
|
+
...BUILT_IN_SYNC_ROOTS.filter((item) => builtIns.has(item)),
|
|
220
|
+
...[...custom].sort((left, right) => left.localeCompare(right)),
|
|
221
|
+
...sessions ? ["sessions"] : []
|
|
222
|
+
];
|
|
223
|
+
}
|
|
224
|
+
function syncIncludeSelection(value) {
|
|
225
|
+
const include = normalizeSyncInclude(value);
|
|
226
|
+
const builtIns = include.filter((item) => BUILT_IN_BY_LOWER.has(item.toLowerCase()));
|
|
227
|
+
const custom = include.filter((item) => item !== "sessions" && !BUILT_IN_BY_LOWER.has(item.toLowerCase()));
|
|
228
|
+
return { include, builtIns, custom, sessions: include.includes("sessions") };
|
|
229
|
+
}
|
|
230
|
+
function customIncludePathsByLower(value) {
|
|
231
|
+
return new Map(syncIncludeSelection(value).custom.map((relativePath) => [relativePath.toLowerCase(), relativePath]));
|
|
232
|
+
}
|
|
233
|
+
function includeFromSelectionConfig(config) {
|
|
234
|
+
if (config.include !== void 0) return normalizeSyncInclude(config.include);
|
|
235
|
+
return [
|
|
236
|
+
...normalizeSyncFiles(config.syncFiles),
|
|
237
|
+
...normalizeExtraFiles(config.extraFiles),
|
|
238
|
+
...config.syncSessions ? ["sessions"] : []
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
function isConfiguredSnapshotPath(relativePath, config, _legacyExtraFiles) {
|
|
242
|
+
const normalized = toPosix(relativePath);
|
|
243
|
+
const selection = syncIncludeSelection(includeFromSelectionConfig(config));
|
|
244
|
+
if (normalized.startsWith("sessions/")) return selection.sessions;
|
|
245
|
+
const lower = normalized.toLowerCase();
|
|
246
|
+
if (!normalized.includes("/")) {
|
|
247
|
+
const builtIn = BUILT_IN_BY_LOWER.get(lower);
|
|
248
|
+
if (builtIn) return selection.builtIns.includes(builtIn) && !TOP_LEVEL_DIRS.has(builtIn);
|
|
249
|
+
}
|
|
250
|
+
const topLevel = normalized.slice(0, normalized.indexOf("/"));
|
|
251
|
+
if (selection.builtIns.includes(topLevel) && TOP_LEVEL_DIRS.has(topLevel)) {
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
return selection.custom.some((candidate) => {
|
|
255
|
+
const candidateLower = candidate.toLowerCase();
|
|
256
|
+
return lower === candidateLower || lower.startsWith(`${candidateLower}/`);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function canonicalSnapshotPathForConfig(relativePath, includePaths) {
|
|
260
|
+
const normalized = toPosix(relativePath);
|
|
261
|
+
const lower = normalized.toLowerCase();
|
|
262
|
+
return TOP_LEVEL_FILE_PATHS.get(lower) ?? includePaths.get(lower) ?? normalized;
|
|
263
|
+
}
|
|
264
|
+
function isPreservableUnmanagedSnapshotPath(relativePath) {
|
|
265
|
+
const normalized = toPosix(relativePath);
|
|
266
|
+
if (!normalized || isDeniedPath(normalized)) return false;
|
|
267
|
+
if (normalized.startsWith("sessions/")) return normalized.endsWith(".jsonl");
|
|
268
|
+
if (!normalized.includes("/")) {
|
|
269
|
+
const lower = normalized.toLowerCase();
|
|
270
|
+
return TOP_LEVEL_FILE_PATHS.has(lower) || !RESERVED_TOP_LEVEL_NAMES.has(lower);
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
function isSafeCustomIncludePath(relativePath) {
|
|
275
|
+
try {
|
|
276
|
+
validateAgentRelativeInclude(relativePath);
|
|
277
|
+
return true;
|
|
278
|
+
} catch {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function normalizeSyncFiles(value) {
|
|
283
|
+
if (value === void 0) return [...DEFAULT_SYNC_INCLUDE];
|
|
284
|
+
if (Array.isArray(value)) {
|
|
285
|
+
return normalizeSyncInclude(value).filter(
|
|
286
|
+
(item) => BUILT_IN_BY_LOWER.has(item.toLowerCase())
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
throw new Error("Invalid pi-sync settings: expected an include array.");
|
|
290
|
+
}
|
|
291
|
+
function normalizeExtraFiles(value) {
|
|
292
|
+
if (!Array.isArray(value)) return [];
|
|
293
|
+
return value.filter((item) => typeof item === "string" && isSafeCustomIncludePath(item));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export {
|
|
297
|
+
BUILT_IN_SYNC_ROOTS,
|
|
298
|
+
DEFAULT_SYNC_INCLUDE,
|
|
299
|
+
normalizeSyncInclude,
|
|
300
|
+
portableSnapshotSelection,
|
|
301
|
+
snapshotSelectionInclude,
|
|
302
|
+
selectionForSnapshot,
|
|
303
|
+
sameSyncInclude,
|
|
304
|
+
compareSyncInclude,
|
|
305
|
+
inspectRemoteSelection,
|
|
306
|
+
RemoteSelectionMismatchError,
|
|
307
|
+
remoteSelectionMismatch,
|
|
308
|
+
formatRemoteSelectionMismatch,
|
|
309
|
+
syncIncludeSelection,
|
|
310
|
+
customIncludePathsByLower,
|
|
311
|
+
includeFromSelectionConfig,
|
|
312
|
+
isConfiguredSnapshotPath,
|
|
313
|
+
canonicalSnapshotPathForConfig,
|
|
314
|
+
isPreservableUnmanagedSnapshotPath,
|
|
315
|
+
isSafeCustomIncludePath,
|
|
316
|
+
normalizeSyncFiles,
|
|
317
|
+
normalizeExtraFiles
|
|
318
|
+
};
|
|
319
|
+
//# sourceMappingURL=chunk-KYTT7KV4.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/sync-policy.ts"],
|
|
4
|
+
"sourcesContent": ["import path from \"node:path\";\nimport { isDeniedPath, toPosix } from \"../paths.js\";\nimport type { Snapshot, SnapshotSelection } from \"../snapshot/snapshot-types.js\";\n\nexport const BUILT_IN_SYNC_ROOTS = [\n \"settings.json\",\n \"keybindings.json\",\n \"models.json\",\n \"AGENTS.md\",\n \"APPEND_SYSTEM.md\",\n \"skills\",\n \"prompts\",\n \"themes\",\n \"extensions\",\n] as const;\n\nexport const DEFAULT_SYNC_INCLUDE = [...BUILT_IN_SYNC_ROOTS] as const;\nexport type BuiltInSyncFile = (typeof BUILT_IN_SYNC_ROOTS)[number];\nconst SNAPSHOT_SELECTION_VERSION = 1;\nconst MAX_SYNC_INCLUDE_ITEMS = 1_024;\nconst MAX_SYNC_INCLUDE_PATH_BYTES = 4_096;\nconst MAX_SYNC_INCLUDE_TOTAL_BYTES = 256 * 1_024;\n\ninterface IncludePathNode {\n selected?: string;\n children: Map<string, IncludePathNode>;\n}\n\nconst BUILT_IN_BY_LOWER = new Map<string, BuiltInSyncFile>(\n BUILT_IN_SYNC_ROOTS.map((fileName) => [fileName.toLowerCase(), fileName]),\n);\nconst TOP_LEVEL_FILE_PATHS = new Map<string, string>(\n BUILT_IN_SYNC_ROOTS.filter((fileName) => fileName.includes(\".\")).map((fileName) => [\n fileName.toLowerCase(),\n fileName,\n ]),\n);\nconst TOP_LEVEL_DIRS = new Set<string>(BUILT_IN_SYNC_ROOTS.filter((fileName) => !fileName.includes(\".\")));\nconst RESERVED_TOP_LEVEL_NAMES = new Set<string>([...BUILT_IN_BY_LOWER.keys(), \"sessions\"]);\n\nexport function normalizeSyncInclude(value: unknown): string[] {\n if (!Array.isArray(value)) {\n throw new Error(\"Invalid pi-sync settings: sync.include must be an array.\");\n }\n if (value.length > MAX_SYNC_INCLUDE_ITEMS) {\n throw new Error(`Invalid pi-sync settings: sync.include has too many items; limit: ${MAX_SYNC_INCLUDE_ITEMS}.`);\n }\n const result: string[] = [];\n const seen = new Set<string>();\n const pathRoot: IncludePathNode = { children: new Map() };\n let totalBytes = 0;\n for (const item of value) {\n if (typeof item !== \"string\") {\n throw new Error(\"Invalid pi-sync settings: sync.include items must be strings.\");\n }\n const itemBytes = Buffer.byteLength(item, \"utf8\");\n if (itemBytes > MAX_SYNC_INCLUDE_PATH_BYTES) {\n throw new Error(\n `Invalid pi-sync settings: sync.include item is too long; limit: ${MAX_SYNC_INCLUDE_PATH_BYTES} bytes.`,\n );\n }\n totalBytes += itemBytes;\n if (totalBytes > MAX_SYNC_INCLUDE_TOTAL_BYTES) {\n throw new Error(\n `Invalid pi-sync settings: sync.include is too large; limit: ${MAX_SYNC_INCLUDE_TOTAL_BYTES} bytes.`,\n );\n }\n const trimmed = item.trim();\n const builtIn = BUILT_IN_BY_LOWER.get(trimmed.toLowerCase());\n const normalized = builtIn ?? (trimmed.toLowerCase() === \"sessions\" ? \"sessions\" : trimmed);\n if (!builtIn && normalized !== \"sessions\") validateAgentRelativeInclude(normalized);\n const identity = normalized.toLowerCase();\n if (seen.has(identity)) {\n throw new Error(`Invalid pi-sync settings: duplicate sync.include item: ${item}`);\n }\n addIncludePath(pathRoot, identity, item);\n seen.add(identity);\n result.push(normalized);\n }\n return result;\n}\n\nfunction addIncludePath(root: IncludePathNode, identity: string, source: string) {\n let node = root;\n for (const segment of identity.split(\"/\")) {\n if (node.selected !== undefined) throwOverlappingInclude(source);\n let child = node.children.get(segment);\n if (!child) {\n child = { children: new Map() };\n node.children.set(segment, child);\n }\n node = child;\n }\n if (node.children.size > 0) throwOverlappingInclude(source);\n node.selected = identity;\n}\n\nfunction throwOverlappingInclude(item: string): never {\n throw new Error(`Invalid pi-sync settings: overlapping sync.include items are ambiguous: ${item}`);\n}\n\nfunction validateAgentRelativeInclude(value: string) {\n const normalized = toPosix(value);\n const topLevel = normalized.split(\"/\")[0]?.toLowerCase();\n if (\n !normalized ||\n normalized === \".\" ||\n normalized === \"..\" ||\n normalized.startsWith(\"../\") ||\n path.posix.isAbsolute(normalized) ||\n normalized.includes(\"\\\\\") ||\n path.posix.normalize(normalized) !== normalized ||\n // biome-ignore lint/suspicious/noControlCharactersInRegex: Include paths cannot contain controls.\n /[\\u0000-\\u001f\\u007f-\\u009f]/u.test(normalized)\n ) {\n throw new Error(`Invalid pi-sync settings: sync.include item must be a safe agent-relative path: ${value}`);\n }\n if (isDeniedPath(normalized)) {\n throw new Error(`Invalid pi-sync settings: ${value} cannot be synced.`);\n }\n if (topLevel && RESERVED_TOP_LEVEL_NAMES.has(topLevel)) {\n throw new Error(\n `Invalid pi-sync settings: use the canonical ${topLevel} root instead of a nested sync.include path.`,\n );\n }\n}\n\nexport function portableSnapshotSelection(value: unknown): SnapshotSelection {\n const selection = value as Partial<SnapshotSelection> | null;\n if (\n !selection ||\n typeof selection !== \"object\" ||\n Array.isArray(selection) ||\n selection.version !== SNAPSHOT_SELECTION_VERSION ||\n !Object.hasOwn(selection, \"include\") ||\n Object.keys(selection).some((key) => key !== \"version\" && key !== \"include\")\n ) {\n throw new Error(\"Invalid snapshot selection policy.\");\n }\n return {\n version: SNAPSHOT_SELECTION_VERSION,\n include: normalizeSyncInclude(selection.include),\n };\n}\n\nexport function snapshotSelectionInclude(snapshot: Pick<Snapshot, \"selection\">) {\n return snapshot.selection === undefined ? undefined : portableSnapshotSelection(snapshot.selection).include;\n}\n\nexport function selectionForSnapshot(include: unknown): SnapshotSelection {\n return { version: SNAPSHOT_SELECTION_VERSION, include: normalizeSyncInclude(include) };\n}\n\nexport function sameSyncInclude(left: unknown, right: unknown) {\n const normalizedLeft = normalizeSyncInclude(left);\n const normalizedRight = normalizeSyncInclude(right);\n return (\n normalizedLeft.length === normalizedRight.length &&\n normalizedLeft.every((item, index) => item === normalizedRight[index])\n );\n}\n\nexport function compareSyncInclude(local: unknown, remote: unknown) {\n const localInclude = normalizeSyncInclude(local);\n const remoteInclude = normalizeSyncInclude(remote);\n const localSet = new Set(localInclude);\n const remoteSet = new Set(remoteInclude);\n return {\n same: sameSyncInclude(localInclude, remoteInclude),\n remoteOnly: remoteInclude.filter((item) => !localSet.has(item)),\n localOnly: localInclude.filter((item) => !remoteSet.has(item)),\n };\n}\n\nexport type RemoteSelectionState =\n | { kind: \"legacy\"; discovered: string[] }\n | { kind: \"same\"; include: string[] }\n | {\n kind: \"different\";\n include: string[];\n remoteOnly: string[];\n localOnly: string[];\n };\n\nexport function inspectRemoteSelection(\n localInclude: unknown,\n snapshot: Pick<Snapshot, \"selection\" | \"files\">,\n): RemoteSelectionState {\n const remoteInclude = snapshotSelectionInclude(snapshot);\n if (!remoteInclude) {\n return { kind: \"legacy\", discovered: discoverLegacySnapshotInclude(snapshot) };\n }\n const comparison = compareSyncInclude(localInclude, remoteInclude);\n return comparison.same\n ? { kind: \"same\", include: remoteInclude }\n : { kind: \"different\", include: remoteInclude, ...comparison };\n}\n\nexport interface RemoteSelectionDecision {\n setupName: string;\n configIdentity: string;\n localInclude: readonly string[];\n remoteInclude: readonly string[];\n}\n\nexport class RemoteSelectionMismatchError extends Error {\n readonly decision: RemoteSelectionDecision;\n readonly setupName: string;\n readonly localInclude: string[];\n readonly remoteInclude: string[];\n\n constructor(\n setupName: string,\n localInclude: unknown,\n remoteInclude: unknown,\n configIdentity = JSON.stringify([setupName, normalizeSyncInclude(localInclude)]),\n ) {\n const local = normalizeSyncInclude(localInclude);\n const remote = normalizeSyncInclude(remoteInclude);\n super(formatRemoteSelectionMismatch(setupName, local, remote));\n this.name = \"RemoteSelectionMismatchError\";\n this.setupName = setupName;\n this.localInclude = local;\n this.remoteInclude = remote;\n this.decision = {\n setupName,\n configIdentity,\n localInclude: [...local],\n remoteInclude: [...remote],\n };\n }\n}\n\nexport function remoteSelectionMismatch(\n config: { setupName: string; include: unknown },\n remoteInclude: unknown,\n configIdentity?: string,\n) {\n return new RemoteSelectionMismatchError(config.setupName, config.include, remoteInclude, configIdentity);\n}\n\nexport function formatRemoteSelectionMismatch(\n setupName: string,\n localInclude: readonly string[],\n remoteInclude: readonly string[],\n) {\n const comparison = compareSyncInclude(localInclude, remoteInclude);\n const lines = [\n `Synced content differs for sync setup \u201C${stripTerminalControls(setupName)}\u201D.`,\n `Remote-only: ${comparison.remoteOnly.join(\", \") || \"none\"}`,\n `This-device-only: ${comparison.localOnly.join(\", \") || \"none\"}`,\n ];\n if (comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0) {\n lines.push(\n \"Only ordering differs.\",\n `Remote order: ${remoteInclude.join(\", \") || \"none\"}`,\n `This device order: ${localInclude.join(\", \") || \"none\"}`,\n );\n }\n lines.push(\"Run /sync in TUI to review both content lists and choose what happens next.\");\n return lines.join(\"\\n\");\n}\n\nfunction stripTerminalControls(value: string) {\n // biome-ignore lint/suspicious/noControlCharactersInRegex: Escape untrusted terminal controls.\n return value.replace(/[\\u0000-\\u001f\\u007f-\\u009f]/gu, \"?\");\n}\n\nexport function discoverLegacySnapshotInclude(snapshot: Pick<Snapshot, \"files\">) {\n const builtIns = new Set<BuiltInSyncFile>();\n const custom = new Set<string>();\n let sessions = false;\n for (const file of snapshot.files) {\n const normalized = toPosix(file.path);\n if (\n !normalized ||\n file.path.includes(\"\\\\\") ||\n normalized.length > 4096 ||\n normalized.startsWith(\"../\") ||\n path.posix.isAbsolute(normalized) ||\n path.posix.normalize(normalized) !== normalized ||\n // biome-ignore lint/suspicious/noControlCharactersInRegex: Ignore unsafe legacy paths.\n /[\\u0000-\\u001f\\u007f-\\u009f]/u.test(normalized) ||\n isDeniedPath(normalized)\n ) {\n continue;\n }\n const [topLevel, ...rest] = normalized.split(\"/\");\n if (!topLevel) continue;\n if (topLevel === \"sessions\" && rest.length > 0) {\n sessions = true;\n continue;\n }\n const builtIn = BUILT_IN_BY_LOWER.get(topLevel.toLowerCase());\n if (\n builtIn &&\n ((TOP_LEVEL_DIRS.has(builtIn) && rest.length > 0) || (!TOP_LEVEL_DIRS.has(builtIn) && rest.length === 0))\n ) {\n builtIns.add(builtIn);\n continue;\n }\n if (isSafeCustomIncludePath(topLevel)) custom.add(topLevel);\n }\n return [\n ...BUILT_IN_SYNC_ROOTS.filter((item) => builtIns.has(item)),\n ...[...custom].sort((left, right) => left.localeCompare(right)),\n ...(sessions ? [\"sessions\"] : []),\n ];\n}\n\nexport function syncIncludeSelection(value: unknown) {\n const include = normalizeSyncInclude(value);\n const builtIns = include.filter((item): item is BuiltInSyncFile => BUILT_IN_BY_LOWER.has(item.toLowerCase()));\n const custom = include.filter((item) => item !== \"sessions\" && !BUILT_IN_BY_LOWER.has(item.toLowerCase()));\n return { include, builtIns, custom, sessions: include.includes(\"sessions\") };\n}\n\nexport function customIncludePathsByLower(value: unknown) {\n return new Map(syncIncludeSelection(value).custom.map((relativePath) => [relativePath.toLowerCase(), relativePath]));\n}\n\nexport interface SyncSelectionConfig {\n include?: unknown;\n syncFiles?: unknown;\n syncSessions?: boolean;\n extraFiles?: unknown;\n}\n\nexport function includeFromSelectionConfig(config: SyncSelectionConfig) {\n if (config.include !== undefined) return normalizeSyncInclude(config.include);\n return [\n ...normalizeSyncFiles(config.syncFiles),\n ...normalizeExtraFiles(config.extraFiles),\n ...(config.syncSessions ? [\"sessions\"] : []),\n ];\n}\n\nexport function isConfiguredSnapshotPath(\n relativePath: string,\n config: SyncSelectionConfig,\n _legacyExtraFiles?: Set<string>,\n) {\n const normalized = toPosix(relativePath);\n const selection = syncIncludeSelection(includeFromSelectionConfig(config));\n if (normalized.startsWith(\"sessions/\")) return selection.sessions;\n const lower = normalized.toLowerCase();\n if (!normalized.includes(\"/\")) {\n const builtIn = BUILT_IN_BY_LOWER.get(lower);\n if (builtIn) return selection.builtIns.includes(builtIn) && !TOP_LEVEL_DIRS.has(builtIn);\n }\n const topLevel = normalized.slice(0, normalized.indexOf(\"/\"));\n if (selection.builtIns.includes(topLevel as BuiltInSyncFile) && TOP_LEVEL_DIRS.has(topLevel)) {\n return true;\n }\n return selection.custom.some((candidate) => {\n const candidateLower = candidate.toLowerCase();\n return lower === candidateLower || lower.startsWith(`${candidateLower}/`);\n });\n}\n\nexport function canonicalSnapshotPathForConfig(relativePath: string, includePaths: Map<string, string>) {\n const normalized = toPosix(relativePath);\n const lower = normalized.toLowerCase();\n return TOP_LEVEL_FILE_PATHS.get(lower) ?? includePaths.get(lower) ?? normalized;\n}\n\nexport function isPreservableUnmanagedSnapshotPath(relativePath: string) {\n const normalized = toPosix(relativePath);\n if (!normalized || isDeniedPath(normalized)) return false;\n if (normalized.startsWith(\"sessions/\")) return normalized.endsWith(\".jsonl\");\n if (!normalized.includes(\"/\")) {\n const lower = normalized.toLowerCase();\n return TOP_LEVEL_FILE_PATHS.has(lower) || !RESERVED_TOP_LEVEL_NAMES.has(lower);\n }\n return true;\n}\n\nexport function isSafeCustomIncludePath(relativePath: string) {\n try {\n validateAgentRelativeInclude(relativePath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isBuiltInTopLevelFile(fileName: string) {\n return TOP_LEVEL_FILE_PATHS.has(path.posix.basename(fileName).toLowerCase());\n}\n\n/** Compatibility projection for backend-neutral output while callers move to sync.include. */\nexport function normalizeSyncFiles(value: unknown): BuiltInSyncFile[] {\n if (value === undefined) return [...DEFAULT_SYNC_INCLUDE];\n if (Array.isArray(value)) {\n return normalizeSyncInclude(value).filter((item): item is BuiltInSyncFile =>\n BUILT_IN_BY_LOWER.has(item.toLowerCase()),\n );\n }\n throw new Error(\"Invalid pi-sync settings: expected an include array.\");\n}\n\n/** Compatibility projection for old rendering helpers; v3 persistence never writes this split field. */\nexport function normalizeExtraFiles(value: unknown) {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && isSafeCustomIncludePath(item));\n}\n\nexport const extraFilePathsByLower = customIncludePathsByLower;\nexport const isSafeExtraFileName = isSafeCustomIncludePath;\nexport const selectedSyncFileSet = (value: unknown) => new Set(normalizeSyncFiles(value));\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA,OAAO,UAAU;AAIV,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,uBAAuB,CAAC,GAAG,mBAAmB;AAE3D,IAAM,6BAA6B;AACnC,IAAM,yBAAyB;AAC/B,IAAM,8BAA8B;AACpC,IAAM,+BAA+B,MAAM;AAO3C,IAAM,oBAAoB,IAAI;AAAA,EAC5B,oBAAoB,IAAI,CAAC,aAAa,CAAC,SAAS,YAAY,GAAG,QAAQ,CAAC;AAC1E;AACA,IAAM,uBAAuB,IAAI;AAAA,EAC/B,oBAAoB,OAAO,CAAC,aAAa,SAAS,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,aAAa;AAAA,IACjF,SAAS,YAAY;AAAA,IACrB;AAAA,EACF,CAAC;AACH;AACA,IAAM,iBAAiB,IAAI,IAAY,oBAAoB,OAAO,CAAC,aAAa,CAAC,SAAS,SAAS,GAAG,CAAC,CAAC;AACxG,IAAM,2BAA2B,oBAAI,IAAY,CAAC,GAAG,kBAAkB,KAAK,GAAG,UAAU,CAAC;AAEnF,SAAS,qBAAqB,OAA0B;AAC7D,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,UAAM,I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,YAAY;AACvC,MAAI,CAAC,cAAc,aAAa,UAAU,EAAG,QAAO;AACpD,MAAI,WAAW,WAAW,WAAW,EAAG,QAAO,WAAW,SAAS,QAAQ;AAC3E,MAAI,CAAC,WAAW,SAAS,GAAG,GAAG;AAC7B,UAAM,QAAQ,WAAW,YAAY;AACrC,WAAO,qBAAqB,IAAI,KAAK,KAAK,CAAC,yBAAyB,IAAI,KAAK;AAAA,EAC/E;AACA,SAAO;AACT;AAEO,SAAS,wBAAwB,cAAsB;AAC5D,MAAI;AACF,iCAA6B,YAAY;AACzC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOO,SAAS,mBAAmB,OAAmC;AACpE,MAAI,UAAU,OAAW,QAAO,CAAC,GAAG,oBAAoB;AACxD,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,qBAAqB,KAAK,EAAE;AAAA,MAAO,CAAC,SACzC,kBAAkB,IAAI,KAAK,YAAY,CAAC;AAAA,IAC1C;AAAA,EACF;AACA,QAAM,IAAI,MAAM,sDAAsD;AACxE;AAGO,SAAS,oBAAoB,OAAgB;AAClD,MAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACnC,SAAO,MAAM,OAAO,CAAC,SAAyB,OAAO,SAAS,YAAY,wBAAwB,IAAI,CAAC;AACzG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,35 +1,19 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
normalizeLocalFields
|
|
5
|
+
} from "./chunk-X7R6DCVF.ts";
|
|
6
6
|
import {
|
|
7
7
|
jsonEqual,
|
|
8
8
|
parseSettingsDocument,
|
|
9
9
|
renderSettingsMembers
|
|
10
10
|
} from "./chunk-ZW5ZLGBI.ts";
|
|
11
|
+
import {
|
|
12
|
+
regenerateSnapshotIdentity
|
|
13
|
+
} from "./chunk-ESKOPQVB.ts";
|
|
11
14
|
|
|
12
15
|
// src/sync/local-fields.ts
|
|
13
16
|
import { createHash } from "node:crypto";
|
|
14
|
-
function normalizeLocalFields(value) {
|
|
15
|
-
if (value === void 0) return [];
|
|
16
|
-
if (!Array.isArray(value) || value.length > 128 || value.some(
|
|
17
|
-
(field) => typeof field !== "string" || !field || field.length > 128 || /[\p{Cc}\p{Cf}\p{Cs}]/u.test(field) || ["__proto__", "constructor", "prototype"].includes(field)
|
|
18
|
-
))
|
|
19
|
-
throw new Error("localFields must be at most 128 safe settings.json root field names.");
|
|
20
|
-
if (new Set(value).size !== value.length) throw new Error("Duplicate localFields rule.");
|
|
21
|
-
for (const [first, second] of [
|
|
22
|
-
["defaultProvider", "defaultModel"],
|
|
23
|
-
["skills", "enableSkillCommands"],
|
|
24
|
-
["queueMode", "steeringMode"],
|
|
25
|
-
["websockets", "transport"],
|
|
26
|
-
["enableAnalytics", "trackingId"]
|
|
27
|
-
]) {
|
|
28
|
-
if (value.includes(first) !== value.includes(second))
|
|
29
|
-
throw new Error("Coupled settings fields must be excluded together.");
|
|
30
|
-
}
|
|
31
|
-
return [...value].sort();
|
|
32
|
-
}
|
|
33
17
|
function validateSnapshotFieldPolicy(snapshot) {
|
|
34
18
|
if (snapshot.version !== 1 && snapshot.version !== 2 && snapshot.version !== 3)
|
|
35
19
|
throw new Error("Unsupported snapshot format.");
|
|
@@ -114,11 +98,10 @@ function overlayLocalFields(portable, local, fields) {
|
|
|
114
98
|
}
|
|
115
99
|
|
|
116
100
|
export {
|
|
117
|
-
normalizeLocalFields,
|
|
118
101
|
validateSnapshotFieldPolicy,
|
|
119
102
|
validatePortableSnapshot,
|
|
120
103
|
sameLocalFields,
|
|
121
104
|
portableSnapshot,
|
|
122
105
|
overlayLocalFields
|
|
123
106
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-MKSMJPVA.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/local-fields.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { regenerateSnapshotIdentity } from \"../snapshot/snapshot.js\";\nimport type { Snapshot, SnapshotFile } from \"../snapshot/snapshot-types.js\";\nimport {\n type JsonDocument,\n type JsonNode,\n jsonEqual,\n parseSettingsDocument,\n renderSettingsMembers,\n} from \"./json-document.js\";\nimport { normalizeLocalFields } from \"./local-field-policy.js\";\n\nexport { normalizeLocalFields } from \"./local-field-policy.js\";\n\n/** Shared transport contract: older snapshots cannot carry portable policy metadata. */\nexport function validateSnapshotFieldPolicy(snapshot: Pick<Snapshot, \"version\" | \"localFields\">) {\n if (snapshot.version !== 1 && snapshot.version !== 2 && snapshot.version !== 3)\n throw new Error(\"Unsupported snapshot format.\");\n if (snapshot.version === 1 && snapshot.localFields !== undefined)\n throw new Error(\"Portable field policy requires snapshot version 2.\");\n if (snapshot.version === 2 || snapshot.version === 3) {\n if (snapshot.version === 2 && snapshot.localFields === undefined)\n throw new Error(\"Snapshot version 2 requires explicit localFields rules.\");\n normalizeLocalFields(snapshot.localFields);\n }\n}\n/** Portable transport images must not carry values declared machine-local. Physical journal images are different. */\nexport function validatePortableSnapshot(snapshot: Snapshot) {\n validateSnapshotFieldPolicy(snapshot);\n if ((snapshot.version !== 2 && snapshot.version !== 3) || !snapshot.localFields?.length) return;\n try {\n for (const entry of snapshot.files) {\n if (typeof entry?.path !== \"string\" || entry.path.toLowerCase() !== \"settings.json\") continue;\n const document = parseSettingsDocument(Buffer.from(entry.contentBase64, \"base64\"));\n if (snapshot.localFields.some((field) => document.root.members.has(field))) throw new Error(\"Excluded field.\");\n }\n } catch {\n throw new Error(\"Portable snapshot settings.json retains excluded fields or has an unsupported document.\");\n }\n}\nexport function sameLocalFields(left: unknown, right: unknown) {\n if (left === undefined || right === undefined) return left === right;\n return JSON.stringify(normalizeLocalFields(left)) === JSON.stringify(normalizeLocalFields(right));\n}\nfunction file(content: Buffer): SnapshotFile {\n return {\n path: \"settings.json\",\n contentBase64: content.toString(\"base64\"),\n sha256: createHash(\"sha256\").update(content).digest(\"hex\"),\n };\n}\nexport function portableSnapshot(snapshot: Snapshot, fields: string[] | undefined): Snapshot {\n if (fields === undefined) return snapshot;\n const excluded = new Set(normalizeLocalFields(fields));\n const files = snapshot.files.map((entry) => {\n if (entry.path !== \"settings.json\" || excluded.size === 0) return entry;\n const document = parseSettingsDocument(Buffer.from(entry.contentBase64, \"base64\"));\n const object = Object.create(null);\n for (const key of [...document.root.members.keys()].sort())\n if (!excluded.has(key)) object[key] = document.root.members.get(key)?.node.value;\n const canonical = (value: unknown): unknown =>\n Array.isArray(value)\n ? value.map(canonical)\n : value && typeof value === \"object\"\n ? Object.fromEntries(\n Object.entries(value)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n .map(([key, child]) => [key, canonical(child)]),\n )\n : value;\n return file(Buffer.from(`${JSON.stringify(canonical(object))}\\n`));\n });\n return regenerateSnapshotIdentity({ ...snapshot, version: 2, localFields: [...excluded], files });\n}\nexport function overlayLocalFields(portable: Snapshot, local: Snapshot, fields: string[] | undefined): Snapshot {\n if (!fields?.length) return portable;\n const target = portable.files.find((entry) => entry.path === \"settings.json\");\n const current = local.files.find((entry) => entry.path === \"settings.json\");\n if (!target && !current) return portable;\n const original = current\n ? parseSettingsDocument(Buffer.from(current.contentBase64, \"base64\"))\n : parseSettingsDocument(Buffer.from(\"{}\"));\n if (!target) {\n if (fields.some((field) => original.root.members.has(field)))\n throw new Error(\"Portable settings deletion requires manual review; local-only fields were preserved.\");\n return portable;\n }\n const incoming = parseSettingsDocument(Buffer.from(target.contentBase64, \"base64\"));\n const selected = new Map<string, { document: JsonDocument; node: JsonNode }>();\n const excluded = new Set(fields);\n for (const [key, member] of incoming.root.members) {\n if (excluded.has(key)) continue;\n const existing = original.root.members.get(key);\n selected.set(\n key,\n existing && jsonEqual(existing.node.value, member.node.value)\n ? { document: original, node: existing.node }\n : { document: incoming, node: member.node },\n );\n }\n for (const [key, member] of original.root.members)\n if (excluded.has(key)) selected.set(key, { document: original, node: member.node });\n const content = renderSettingsMembers(original, selected);\n return regenerateSnapshotIdentity({\n ...portable,\n files: portable.files.map((entry) => (entry.path === \"settings.json\" ? file(content) : entry)),\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAepB,SAAS,4BAA4B,UAAqD;AAC/F,MAAI,SAAS,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS,YAAY;AAC3E,UAAM,IAAI,MAAM,8BAA8B;AAChD,MAAI,SAAS,YAAY,KAAK,SAAS,gBAAgB;AACrD,UAAM,IAAI,MAAM,oDAAoD;AACtE,MAAI,SAAS,YAAY,KAAK,SAAS,YAAY,GAAG;AACpD,QAAI,SAAS,YAAY,KAAK,SAAS,gBAAgB;AACrD,YAAM,IAAI,MAAM,yDAAyD;AAC3E,yBAAqB,SAAS,WAAW;AAAA,EAC3C;AACF;AAEO,SAAS,yBAAyB,UAAoB;AAC3D,8BAA4B,QAAQ;AACpC,MAAK,SAAS,YAAY,KAAK,SAAS,YAAY,KAAM,CAAC,SAAS,aAAa,OAAQ;AACzF,MAAI;AACF,eAAW,SAAS,SAAS,OAAO;AAClC,UAAI,OAAO,OAAO,SAAS,YAAY,MAAM,KAAK,YAAY,MAAM,gBAAiB;AACrF,YAAM,WAAW,sBAAsB,OAAO,KAAK,MAAM,eAAe,QAAQ,CAAC;AACjF,UAAI,SAAS,YAAY,KAAK,CAAC,UAAU,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,EAAG,OAAM,IAAI,MAAM,iBAAiB;AAAA,IAC/G;AAAA,EACF,QAAQ;AACN,UAAM,IAAI,MAAM,yFAAyF;AAAA,EAC3G;AACF;AACO,SAAS,gBAAgB,MA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AU,UAAU,MAAM,OAAO,KAAK,CAAC;AACpF,QAAM,UAAU,sBAAsB,UAAU,QAAQ;AACxD,SAAO,2BAA2B;AAAA,IAChC,GAAG;AAAA,IACH,OAAO,SAAS,MAAM,IAAI,CAAC,UAAW,MAAM,SAAS,kBAAkB,KAAK,OAAO,IAAI,KAAM;AAAA,EAC/F,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
var createSyncBackend = async (config) => {
|
|
6
6
|
switch (config.backend.type) {
|
|
7
7
|
case "s3": {
|
|
8
|
-
const { S3SyncBackend } = await import("./s3-backend-
|
|
8
|
+
const { S3SyncBackend } = await import("./s3-backend-L24UZ6IK.ts");
|
|
9
9
|
return new S3SyncBackend(config.backend);
|
|
10
10
|
}
|
|
11
11
|
case "webdav": {
|
|
12
|
-
const { WebDavSyncBackend } = await import("./webdav-backend-
|
|
12
|
+
const { WebDavSyncBackend } = await import("./webdav-backend-3ZCACILP.ts");
|
|
13
13
|
return new WebDavSyncBackend(config.backend);
|
|
14
14
|
}
|
|
15
15
|
case "git": {
|
|
16
|
-
const { GitSyncBackend } = await import("./git-backend-
|
|
16
|
+
const { GitSyncBackend } = await import("./git-backend-KHD36W27.ts");
|
|
17
17
|
return new GitSyncBackend(config.backend);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -22,4 +22,4 @@ var createSyncBackend = async (config) => {
|
|
|
22
22
|
export {
|
|
23
23
|
createSyncBackend
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-OJARL2TG.ts.map
|