@narumitw/pi-sync 0.57.9 → 0.57.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -0
  3. package/dist/chunks/{agent-candidate-GNEYR225.ts → agent-candidate-EYB35AGL.ts} +12 -9
  4. package/dist/chunks/{agent-plan-3L7CRFDM.ts → agent-plan-KO43GTOR.ts} +22 -18
  5. package/dist/chunks/{agent-plan-3L7CRFDM.ts.map → agent-plan-KO43GTOR.ts.map} +1 -1
  6. package/dist/chunks/{agent-refusal-retry-RPTMUQXK.ts → agent-refusal-retry-C2HQROTP.ts} +11 -8
  7. package/dist/chunks/{agent-refusal-retry-RPTMUQXK.ts.map → agent-refusal-retry-C2HQROTP.ts.map} +1 -1
  8. package/dist/chunks/{agent-store-55CZOCPX.ts → agent-store-UT52DS7B.ts} +12 -11
  9. package/dist/chunks/{agent-store-55CZOCPX.ts.map → agent-store-UT52DS7B.ts.map} +1 -1
  10. package/dist/chunks/agent-sync-VM3TXWA3.ts +22 -0
  11. package/dist/chunks/{chunk-6FVVRTL5.ts → chunk-2VSN3MFX.ts} +71 -63
  12. package/dist/chunks/{chunk-6FVVRTL5.ts.map → chunk-2VSN3MFX.ts.map} +1 -1
  13. package/dist/chunks/{chunk-PG7NMFP2.ts → chunk-4RLATUP4.ts} +7 -7
  14. package/dist/chunks/chunk-5SFMBY5P.ts +26 -0
  15. package/dist/chunks/chunk-5SFMBY5P.ts.map +7 -0
  16. package/dist/chunks/chunk-5WJQ6XOW.ts +27 -0
  17. package/dist/chunks/chunk-5WJQ6XOW.ts.map +7 -0
  18. package/dist/chunks/{chunk-GNH73BJ5.ts → chunk-66GAUVDL.ts} +7 -7
  19. package/dist/chunks/{chunk-UPNVIUBN.ts → chunk-73MDIVYJ.ts} +3 -3
  20. package/dist/chunks/{chunk-CRKTAPSL.ts → chunk-AAPAHANE.ts} +24 -29
  21. package/dist/chunks/chunk-AAPAHANE.ts.map +7 -0
  22. package/dist/chunks/{chunk-S7QS4AWK.ts → chunk-AO6EDUA6.ts} +5 -5
  23. package/dist/chunks/chunk-AR2DGDUI.ts +55 -0
  24. package/dist/chunks/chunk-AR2DGDUI.ts.map +7 -0
  25. package/dist/chunks/{chunk-JCH3VXIO.ts → chunk-BJXSCGQK.ts} +9 -9
  26. package/dist/chunks/{chunk-IWZH5KYS.ts → chunk-CDQGSZL3.ts} +7 -7
  27. package/dist/chunks/chunk-DFJGTVPX.ts +319 -0
  28. package/dist/chunks/chunk-DFJGTVPX.ts.map +7 -0
  29. package/dist/chunks/chunk-DO55XUNU.ts +104 -0
  30. package/dist/chunks/chunk-DO55XUNU.ts.map +7 -0
  31. package/dist/chunks/{chunk-ED3TYIVW.ts → chunk-DOJRPBQU.ts} +5 -5
  32. package/dist/chunks/{chunk-5QAE3G3K.ts → chunk-IMMMZUFC.ts} +6 -6
  33. package/dist/chunks/{chunk-B4QZBDBT.ts → chunk-JXWTEJS5.ts} +3 -3
  34. package/dist/chunks/{chunk-BDB4IDM3.ts → chunk-JY2RVOUL.ts} +8 -6
  35. package/dist/chunks/{chunk-BDB4IDM3.ts.map → chunk-JY2RVOUL.ts.map} +1 -1
  36. package/dist/chunks/{chunk-P7DD5PWZ.ts → chunk-M5IV3KL2.ts} +3 -3
  37. package/dist/chunks/{chunk-AAEEHR7H.ts → chunk-MDUORMCK.ts} +2 -2
  38. package/dist/chunks/{chunk-UBV24CG4.ts → chunk-MRIPZGPR.ts} +3 -3
  39. package/dist/chunks/{chunk-MKKF4IMY.ts → chunk-ODF2M4RF.ts} +5 -5
  40. package/dist/chunks/chunk-PHANBTVM.ts +348 -0
  41. package/dist/chunks/chunk-PHANBTVM.ts.map +7 -0
  42. package/dist/chunks/{chunk-GP5DU62N.ts → chunk-PWA3YN5Z.ts} +2 -2
  43. package/dist/chunks/{chunk-YK52VDXG.ts → chunk-QWV3XKNJ.ts} +10 -8
  44. package/dist/chunks/{chunk-YK52VDXG.ts.map → chunk-QWV3XKNJ.ts.map} +1 -1
  45. package/dist/chunks/{chunk-ORGBI36T.ts → chunk-RAMHGOX2.ts} +4 -4
  46. package/dist/chunks/{chunk-QO333NM4.ts → chunk-RX3WGWVL.ts} +5 -5
  47. package/dist/chunks/chunk-RX3WGWVL.ts.map +7 -0
  48. package/dist/chunks/{chunk-PQW6GS4J.ts → chunk-STVQQ5KG.ts} +12 -10
  49. package/dist/chunks/{chunk-PQW6GS4J.ts.map → chunk-STVQQ5KG.ts.map} +1 -1
  50. package/dist/chunks/{chunk-76NB4R7U.ts → chunk-TO2GMX3K.ts} +2 -2
  51. package/dist/chunks/{chunk-GSNPASKB.ts → chunk-U77DWNRH.ts} +6 -6
  52. package/dist/chunks/{chunk-U3XRI2HF.ts → chunk-UCD7TQDT.ts} +11 -11
  53. package/dist/chunks/{chunk-A6HU4ERM.ts → chunk-UGSSZWQ6.ts} +6 -23
  54. package/dist/chunks/chunk-UGSSZWQ6.ts.map +7 -0
  55. package/dist/chunks/chunk-X7R6DCVF.ts +28 -0
  56. package/dist/chunks/chunk-X7R6DCVF.ts.map +7 -0
  57. package/dist/chunks/{chunk-HUZ5CR4W.ts → chunk-YZ5BQNRZ.ts} +2 -51
  58. package/dist/chunks/{chunk-HUZ5CR4W.ts.map → chunk-YZ5BQNRZ.ts.map} +4 -4
  59. package/dist/chunks/{chunk-UOHR7LRO.ts → chunk-Z5O2TLNF.ts} +9 -21
  60. package/dist/chunks/chunk-Z5O2TLNF.ts.map +7 -0
  61. package/dist/chunks/command-handler-FO6F2APH.ts +543 -0
  62. package/dist/chunks/command-handler-FO6F2APH.ts.map +7 -0
  63. package/dist/chunks/{config-KGIYTTXQ.ts → config-B37W7FXW.ts} +5 -6
  64. package/dist/chunks/{conflict-artifacts-FXFIIBCB.ts → conflict-artifacts-6XGSSU5S.ts} +13 -9
  65. package/dist/chunks/{conflict-review-3X37QEIT.ts → conflict-review-BQSHSJB3.ts} +31 -25
  66. package/dist/chunks/{conflict-review-3X37QEIT.ts.map → conflict-review-BQSHSJB3.ts.map} +1 -1
  67. package/dist/chunks/{continuous-record-SQJ47CXN.ts → continuous-record-4DQ2EAZS.ts} +8 -7
  68. package/dist/chunks/{continuous-sync-Q6QUD6TY.ts → continuous-sync-ZT3UEQLK.ts} +33 -28
  69. package/dist/chunks/{continuous-sync-Q6QUD6TY.ts.map → continuous-sync-ZT3UEQLK.ts.map} +1 -1
  70. package/dist/chunks/{file-selection-3JJYOVNR.ts → file-selection-FBLKM25V.ts} +12 -10
  71. package/dist/chunks/{file-selection-3JJYOVNR.ts.map → file-selection-FBLKM25V.ts.map} +1 -1
  72. package/dist/chunks/{git-backend-NYKSG5X6.ts → git-backend-7PCWECRN.ts} +16 -12
  73. package/dist/chunks/{git-backend-NYKSG5X6.ts.map → git-backend-7PCWECRN.ts.map} +1 -1
  74. package/dist/chunks/{local-fields-6DGYOOIK.ts → local-fields-B6JWLPAE.ts} +10 -5
  75. package/dist/chunks/manager-result-dispatcher-NODX3KKH.ts +28 -0
  76. package/dist/chunks/{manager-ui-ZH6DEC2G.ts → manager-ui-DGRTG76I.ts} +46 -40
  77. package/dist/chunks/{manager-ui-ZH6DEC2G.ts.map → manager-ui-DGRTG76I.ts.map} +1 -1
  78. package/dist/chunks/{merge-baseline-store-RFCAH7KL.ts → merge-baseline-store-HL3VLMAM.ts} +6 -5
  79. package/dist/chunks/{remote-selection-ui-YFPGYGNE.ts → remote-selection-ui-OHMIQ32X.ts} +14 -10
  80. package/dist/chunks/{s3-backend-F7PR5FB3.ts → s3-backend-CJXBEWWU.ts} +21 -17
  81. package/dist/chunks/{s3-backend-F7PR5FB3.ts.map → s3-backend-CJXBEWWU.ts.map} +1 -1
  82. package/dist/chunks/{setup-switch-E7PHKI6J.ts → setup-switch-66GWMBNH.ts} +6 -7
  83. package/dist/chunks/{setup-wizard-OVHZYXNW.ts → setup-wizard-OHZXJVQZ.ts} +8 -9
  84. package/dist/chunks/{setup-wizard-OVHZYXNW.ts.map → setup-wizard-OHZXJVQZ.ts.map} +1 -1
  85. package/dist/chunks/{snapshot-THS5EY2L.ts → snapshot-VRHNAUUH.ts} +11 -6
  86. package/dist/chunks/snapshot-transaction-EUGA4VX6.ts +24 -0
  87. package/dist/chunks/sync-inspection-4WFQEJOE.ts +25 -0
  88. package/dist/chunks/sync-inspection-4WFQEJOE.ts.map +7 -0
  89. package/dist/chunks/{sync-operations-Y72GNIQ2.ts → sync-operations-X4AOXMBT.ts} +66 -57
  90. package/dist/chunks/{sync-operations-Y72GNIQ2.ts.map → sync-operations-X4AOXMBT.ts.map} +1 -1
  91. package/dist/chunks/{sync-state-CFL4RRRB.ts → sync-state-SWLSMK4G.ts} +9 -5
  92. package/dist/chunks/sync-state-SWLSMK4G.ts.map +7 -0
  93. package/dist/chunks/{webdav-backend-TGFUH3SF.ts → webdav-backend-2Q5ZEBST.ts} +16 -12
  94. package/dist/chunks/{webdav-backend-TGFUH3SF.ts.map → webdav-backend-2Q5ZEBST.ts.map} +1 -1
  95. package/dist/index.ts +54 -537
  96. package/dist/index.ts.map +3 -3
  97. package/package.json +2 -2
  98. package/src/settings/config.ts +1 -1
  99. package/src/settings/settings-validation.ts +1 -1
  100. package/src/snapshot/snapshot-transaction-directory.ts +16 -0
  101. package/src/snapshot/snapshot-transaction.ts +1 -12
  102. package/src/sync/automatic-sync.ts +12 -6
  103. package/src/sync/local-field-policy.ts +29 -0
  104. package/src/sync/local-fields.ts +3 -29
  105. package/src/sync/mutation-owner.ts +22 -0
  106. package/src/sync/startup-check.ts +3 -2
  107. package/src/sync/sync-loaders.ts +4 -0
  108. package/src/sync/sync-local.ts +2 -19
  109. package/src/sync-extension.ts +7 -2
  110. package/dist/chunks/chunk-A6HU4ERM.ts.map +0 -7
  111. package/dist/chunks/chunk-CRKTAPSL.ts.map +0 -7
  112. package/dist/chunks/chunk-QO333NM4.ts.map +0 -7
  113. package/dist/chunks/chunk-QOFMXPM5.ts +0 -735
  114. package/dist/chunks/chunk-QOFMXPM5.ts.map +0 -7
  115. package/dist/chunks/chunk-UOHR7LRO.ts.map +0 -7
  116. package/dist/chunks/manager-result-dispatcher-HOCM2GDA.ts +0 -24
  117. package/dist/chunks/sync-inspection-J25EEKZK.ts +0 -21
  118. /package/dist/chunks/{agent-candidate-GNEYR225.ts.map → agent-candidate-EYB35AGL.ts.map} +0 -0
  119. /package/dist/chunks/{config-KGIYTTXQ.ts.map → agent-sync-VM3TXWA3.ts.map} +0 -0
  120. /package/dist/chunks/{chunk-PG7NMFP2.ts.map → chunk-4RLATUP4.ts.map} +0 -0
  121. /package/dist/chunks/{chunk-GNH73BJ5.ts.map → chunk-66GAUVDL.ts.map} +0 -0
  122. /package/dist/chunks/{chunk-UPNVIUBN.ts.map → chunk-73MDIVYJ.ts.map} +0 -0
  123. /package/dist/chunks/{chunk-S7QS4AWK.ts.map → chunk-AO6EDUA6.ts.map} +0 -0
  124. /package/dist/chunks/{chunk-JCH3VXIO.ts.map → chunk-BJXSCGQK.ts.map} +0 -0
  125. /package/dist/chunks/{chunk-IWZH5KYS.ts.map → chunk-CDQGSZL3.ts.map} +0 -0
  126. /package/dist/chunks/{chunk-ED3TYIVW.ts.map → chunk-DOJRPBQU.ts.map} +0 -0
  127. /package/dist/chunks/{chunk-5QAE3G3K.ts.map → chunk-IMMMZUFC.ts.map} +0 -0
  128. /package/dist/chunks/{chunk-B4QZBDBT.ts.map → chunk-JXWTEJS5.ts.map} +0 -0
  129. /package/dist/chunks/{chunk-P7DD5PWZ.ts.map → chunk-M5IV3KL2.ts.map} +0 -0
  130. /package/dist/chunks/{chunk-AAEEHR7H.ts.map → chunk-MDUORMCK.ts.map} +0 -0
  131. /package/dist/chunks/{chunk-UBV24CG4.ts.map → chunk-MRIPZGPR.ts.map} +0 -0
  132. /package/dist/chunks/{chunk-MKKF4IMY.ts.map → chunk-ODF2M4RF.ts.map} +0 -0
  133. /package/dist/chunks/{chunk-GP5DU62N.ts.map → chunk-PWA3YN5Z.ts.map} +0 -0
  134. /package/dist/chunks/{chunk-ORGBI36T.ts.map → chunk-RAMHGOX2.ts.map} +0 -0
  135. /package/dist/chunks/{chunk-76NB4R7U.ts.map → chunk-TO2GMX3K.ts.map} +0 -0
  136. /package/dist/chunks/{chunk-GSNPASKB.ts.map → chunk-U77DWNRH.ts.map} +0 -0
  137. /package/dist/chunks/{chunk-U3XRI2HF.ts.map → chunk-UCD7TQDT.ts.map} +0 -0
  138. /package/dist/chunks/{conflict-artifacts-FXFIIBCB.ts.map → config-B37W7FXW.ts.map} +0 -0
  139. /package/dist/chunks/{continuous-record-SQJ47CXN.ts.map → conflict-artifacts-6XGSSU5S.ts.map} +0 -0
  140. /package/dist/chunks/{local-fields-6DGYOOIK.ts.map → continuous-record-4DQ2EAZS.ts.map} +0 -0
  141. /package/dist/chunks/{manager-result-dispatcher-HOCM2GDA.ts.map → local-fields-B6JWLPAE.ts.map} +0 -0
  142. /package/dist/chunks/{merge-baseline-store-RFCAH7KL.ts.map → manager-result-dispatcher-NODX3KKH.ts.map} +0 -0
  143. /package/dist/chunks/{remote-selection-ui-YFPGYGNE.ts.map → merge-baseline-store-HL3VLMAM.ts.map} +0 -0
  144. /package/dist/chunks/{setup-switch-E7PHKI6J.ts.map → remote-selection-ui-OHMIQ32X.ts.map} +0 -0
  145. /package/dist/chunks/{snapshot-THS5EY2L.ts.map → setup-switch-66GWMBNH.ts.map} +0 -0
  146. /package/dist/chunks/{sync-inspection-J25EEKZK.ts.map → snapshot-VRHNAUUH.ts.map} +0 -0
  147. /package/dist/chunks/{sync-state-CFL4RRRB.ts.map → snapshot-transaction-EUGA4VX6.ts.map} +0 -0
@@ -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-YZ5BQNRZ.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-DFJGTVPX.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,CA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AAO,SAAS,YAAY,wBAAwB,IAAI,CAAC;AACzG;",
6
+ "names": []
7
+ }
@@ -0,0 +1,104 @@
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
+ readJsonIfExists
5
+ } from "./chunk-AR2DGDUI.ts";
6
+
7
+ // src/snapshot/snapshot-paths.ts
8
+ import path from "node:path";
9
+ function expandHome(value) {
10
+ if (value === "~") return process.env.HOME ?? value;
11
+ if (value.startsWith("~/")) return path.join(process.env.HOME ?? "~", value.slice(2));
12
+ return value;
13
+ }
14
+ function sessionStorageRoot(root, configuredSessionDir2) {
15
+ return configuredSessionDir2 ? path.resolve(expandHome(configuredSessionDir2)) : path.resolve(root, "sessions");
16
+ }
17
+
18
+ // src/snapshot/session-paths.ts
19
+ import os from "node:os";
20
+ import path2 from "node:path";
21
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
22
+ function sessionDirFromContext(ctx) {
23
+ const manager = ctx.sessionManager;
24
+ const usesDefaultSessionDir = manager.usesDefaultSessionDir;
25
+ if (typeof usesDefaultSessionDir === "function" && usesDefaultSessionDir.call(manager)) {
26
+ return void 0;
27
+ }
28
+ const getSessionDir = manager.getSessionDir;
29
+ return typeof getSessionDir === "function" ? getSessionDir.call(manager) : void 0;
30
+ }
31
+ async function configuredSessionDir() {
32
+ const settings = await readJsonIfExists(path2.join(agentDir(), "settings.json"));
33
+ return settings?.sessionDir ? expandSessionDir(settings.sessionDir) : void 0;
34
+ }
35
+ async function effectiveSessionRoot(ctx) {
36
+ return path2.resolve(sessionStorageRoot(agentDir(), sessionDirFromContext(ctx) ?? await configuredSessionDir()));
37
+ }
38
+ async function sessionDirForApply(ctx, snapshot) {
39
+ const contextSessionDir = sessionDirFromContext(ctx);
40
+ const localSessionDir = await configuredSessionDir();
41
+ if (contextSessionDir && path2.resolve(contextSessionDir) !== path2.resolve(localSessionDir ?? "")) {
42
+ return contextSessionDir;
43
+ }
44
+ return sessionDirFromSnapshot(snapshot) ?? contextSessionDir;
45
+ }
46
+ function requireStableMergeSessionRoot(before, after) {
47
+ const root = agentDir();
48
+ if (path2.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(before))) !== path2.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(after)))) {
49
+ throw new Error(
50
+ "Merged transfer changes the session root; no local apply or baseline acceptance is allowed. Review /sync diff and choose an explicit push or pull direction."
51
+ );
52
+ }
53
+ }
54
+ function sessionDirFromSnapshot(snapshot) {
55
+ const settingsFile = snapshot.files.find((file) => file.path === "settings.json");
56
+ if (!settingsFile) return void 0;
57
+ let settings;
58
+ try {
59
+ settings = JSON.parse(
60
+ new TextDecoder("utf-8", { fatal: true }).decode(
61
+ decodeBase64Strict(settingsFile.contentBase64, settingsFile.path)
62
+ )
63
+ );
64
+ } catch {
65
+ throw new Error("Merged settings cannot be parsed; review a directional recovery.");
66
+ }
67
+ if (!settings || typeof settings !== "object" || Array.isArray(settings))
68
+ throw new Error("Merged settings must be a JSON object; review a directional recovery.");
69
+ const sessionDir = settings.sessionDir;
70
+ if (sessionDir !== void 0 && typeof sessionDir !== "string")
71
+ throw new Error("Merged sessionDir must be a string; review a directional recovery.");
72
+ return sessionDir ? expandSessionDir(sessionDir) : void 0;
73
+ }
74
+ function decodeBase64Strict(value, filePath) {
75
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(value) || value.length % 4 !== 0) {
76
+ throw new Error(`Invalid base64 content in snapshot file: ${filePath}`);
77
+ }
78
+ return Buffer.from(value, "base64");
79
+ }
80
+ function agentDir() {
81
+ return getAgentDir();
82
+ }
83
+ function expandSessionDir(value) {
84
+ return value === "~" || value.startsWith("~/") ? path2.join(os.homedir(), value.slice(2)) : value;
85
+ }
86
+ function snapshotOptionsForContext(ctx, config) {
87
+ return {
88
+ include: config.include,
89
+ sessionDir: sessionDirFromContext(ctx)
90
+ };
91
+ }
92
+
93
+ export {
94
+ sessionStorageRoot,
95
+ sessionDirFromContext,
96
+ configuredSessionDir,
97
+ effectiveSessionRoot,
98
+ sessionDirForApply,
99
+ requireStableMergeSessionRoot,
100
+ agentDir,
101
+ expandSessionDir,
102
+ snapshotOptionsForContext
103
+ };
104
+ //# sourceMappingURL=chunk-DO55XUNU.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/snapshot/snapshot-paths.ts", "../../src/snapshot/session-paths.ts"],
4
+ "sourcesContent": ["import path from \"node:path\";\n\nfunction expandHome(value: string) {\n if (value === \"~\") return process.env.HOME ?? value;\n if (value.startsWith(\"~/\")) return path.join(process.env.HOME ?? \"~\", value.slice(2));\n return value;\n}\n\nexport function sessionStorageRoot(root: string, configuredSessionDir?: string) {\n return configuredSessionDir ? path.resolve(expandHome(configuredSessionDir)) : path.resolve(root, \"sessions\");\n}\n", "import os from \"node:os\";\nimport path from \"node:path\";\nimport { type ExtensionCommandContext, type ExtensionContext, getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { readJsonIfExists } from \"../state/json-file.js\";\nimport { sessionStorageRoot } from \"./snapshot-paths.js\";\nimport type { Snapshot, SnapshotOptions } from \"./snapshot-types.js\";\n\nexport function sessionDirFromContext(ctx: ExtensionCommandContext | ExtensionContext) {\n const manager = ctx.sessionManager as typeof ctx.sessionManager & {\n usesDefaultSessionDir?: () => boolean;\n };\n const usesDefaultSessionDir = manager.usesDefaultSessionDir;\n if (typeof usesDefaultSessionDir === \"function\" && usesDefaultSessionDir.call(manager)) {\n return undefined;\n }\n const getSessionDir = manager.getSessionDir;\n return typeof getSessionDir === \"function\" ? (getSessionDir.call(manager) as string | undefined) : undefined;\n}\n\nexport async function configuredSessionDir() {\n const settings = await readJsonIfExists<{ sessionDir?: string }>(path.join(agentDir(), \"settings.json\"));\n return settings?.sessionDir ? expandSessionDir(settings.sessionDir) : undefined;\n}\n\nexport async function effectiveSessionRoot(ctx: ExtensionCommandContext | ExtensionContext) {\n return path.resolve(sessionStorageRoot(agentDir(), sessionDirFromContext(ctx) ?? (await configuredSessionDir())));\n}\n\nexport async function sessionDirForApply(ctx: ExtensionCommandContext | ExtensionContext, snapshot: Snapshot) {\n const contextSessionDir = sessionDirFromContext(ctx);\n const localSessionDir = await configuredSessionDir();\n if (contextSessionDir && path.resolve(contextSessionDir) !== path.resolve(localSessionDir ?? \"\")) {\n return contextSessionDir;\n }\n return sessionDirFromSnapshot(snapshot) ?? contextSessionDir;\n}\n\n/** Hash-only merge plans cannot describe installation into a different session root. */\nexport function requireStableMergeSessionRoot(before: Snapshot, after: Snapshot) {\n const root = agentDir();\n if (\n path.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(before))) !==\n path.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(after)))\n ) {\n throw new Error(\n \"Merged transfer changes the session root; no local apply or baseline acceptance is allowed. Review /sync diff and choose an explicit push or pull direction.\",\n );\n }\n}\n\nfunction sessionDirFromSnapshot(snapshot: Snapshot) {\n const settingsFile = snapshot.files.find((file) => file.path === \"settings.json\");\n if (!settingsFile) return undefined;\n let settings: unknown;\n try {\n settings = JSON.parse(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(\n decodeBase64Strict(settingsFile.contentBase64, settingsFile.path),\n ),\n );\n } catch {\n // JSON parser errors can quote private settings values; never surface their payload.\n throw new Error(\"Merged settings cannot be parsed; review a directional recovery.\");\n }\n if (!settings || typeof settings !== \"object\" || Array.isArray(settings))\n throw new Error(\"Merged settings must be a JSON object; review a directional recovery.\");\n const sessionDir = (settings as { sessionDir?: unknown }).sessionDir;\n if (sessionDir !== undefined && typeof sessionDir !== \"string\")\n throw new Error(\"Merged sessionDir must be a string; review a directional recovery.\");\n return sessionDir ? expandSessionDir(sessionDir) : undefined;\n}\n\nfunction decodeBase64Strict(value: string, filePath: string) {\n if (!/^[A-Za-z0-9+/]*={0,2}$/.test(value) || value.length % 4 !== 0) {\n throw new Error(`Invalid base64 content in snapshot file: ${filePath}`);\n }\n return Buffer.from(value, \"base64\");\n}\n\nexport function agentDir() {\n return getAgentDir();\n}\n\nexport function expandSessionDir(value: string) {\n return value === \"~\" || value.startsWith(\"~/\") ? path.join(os.homedir(), value.slice(2)) : value;\n}\n\nexport function snapshotOptionsForContext(\n ctx: ExtensionCommandContext | ExtensionContext,\n config: AnySyncConfig,\n): SnapshotOptions {\n return {\n include: config.include,\n sessionDir: sessionDirFromContext(ctx),\n };\n}\n"],
5
+ "mappings": ";;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,WAAW,OAAe;AACjC,MAAI,UAAU,IAAK,QAAO,QAAQ,IAAI,QAAQ;AAC9C,MAAI,MAAM,WAAW,IAAI,EAAG,QAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,MAAM,CAAC,CAAC;AACpF,SAAO;AACT;AAEO,SAAS,mBAAmB,MAAcA,uBAA+B;AAC9E,SAAOA,wBAAuB,KAAK,QAAQ,WAAWA,qBAAoB,CAAC,IAAI,KAAK,QAAQ,MAAM,UAAU;AAC9G;;;ACVA,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,SAA8D,mBAAmB;AAM1E,SAAS,sBAAsB,KAAiD;AACrF,QAAM,UAAU,IAAI;AAGpB,QAAM,wBAAwB,QAAQ;AACtC,MAAI,OAAO,0BAA0B,cAAc,sBAAsB,KAAK,OAAO,GAAG;AACtF,WAAO;AAAA,EACT;AACA,QAAM,gBAAgB,QAAQ;AAC9B,SAAO,OAAO,kBAAkB,aAAc,cAAc,KAAK,OAAO,IAA2B;AACrG;AAEA,eAAsB,uBAAuB;AAC3C,QAAM,WAAW,MAAM,iBAA0CC,MAAK,KAAK,SAAS,GAAG,eAAe,CAAC;AACvG,SAAO,UAAU,aAAa,iBAAiB,SAAS,UAAU,IAAI;AACxE;AAEA,eAAsB,qBAAqB,KAAiD;AAC1F,SAAOA,MAAK,QAAQ,mBAAmB,SAAS,GAAG,sBAAsB,GAAG,KAAM,MAAM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,IAAI,MAAM,4CAA4C,QAAQ,EAAE;AAAA,EACxE;AACA,SAAO,OAAO,KAAK,OAAO,QAAQ;AACpC;AAEO,SAAS,WAAW;AACzB,SAAO,YAAY;AACrB;AAEO,SAAS,iBAAiB,OAAe;AAC9C,SAAO,UAAU,OAAO,MAAM,WAAW,IAAI,IAAIA,MAAK,KAAK,GAAG,QAAQ,GAAG,MAAM,MAAM,CAAC,CAAC,IAAI;AAC7F;AAEO,SAAS,0BACd,KACA,QACiB;AACjB,SAAO;AAAA,IACL,SAAS,OAAO;AAAA,IAChB,YAAY,sBAAsB,GAAG;AAAA,EACvC;AACF;",
6
+ "names": ["configuredSessionDir", "path", "path"]
7
+ }
@@ -2,19 +2,19 @@
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
3
  import {
4
4
  mergeJournalIdentity
5
- } from "./chunk-GNH73BJ5.ts";
5
+ } from "./chunk-66GAUVDL.ts";
6
6
  import {
7
7
  mergePathIdentity,
8
8
  planFileMerge
9
- } from "./chunk-76NB4R7U.ts";
9
+ } from "./chunk-TO2GMX3K.ts";
10
10
  import {
11
11
  statePathForConfig,
12
12
  syncStateFingerprint
13
- } from "./chunk-UPNVIUBN.ts";
13
+ } from "./chunk-73MDIVYJ.ts";
14
14
  import {
15
15
  syncDirectory,
16
16
  writeJson
17
- } from "./chunk-HUZ5CR4W.ts";
17
+ } from "./chunk-AR2DGDUI.ts";
18
18
 
19
19
  // src/sync/conflict-artifacts.ts
20
20
  import { createHash, randomUUID } from "node:crypto";
@@ -226,4 +226,4 @@ export {
226
226
  saveConflictArtifact,
227
227
  readConflictArtifact
228
228
  };
229
- //# sourceMappingURL=chunk-ED3TYIVW.ts.map
229
+ //# sourceMappingURL=chunk-DOJRPBQU.ts.map
@@ -4,20 +4,20 @@ import {
4
4
  COUPLED_FIELDS,
5
5
  mergeSettingsJson,
6
6
  snapshotFile
7
- } from "./chunk-S7QS4AWK.ts";
8
- import {
9
- scanSnapshot
10
- } from "./chunk-QOFMXPM5.ts";
7
+ } from "./chunk-AO6EDUA6.ts";
11
8
  import {
12
9
  edits,
13
10
  isMergeTextPath,
14
11
  lines,
15
12
  text
16
- } from "./chunk-IWZH5KYS.ts";
13
+ } from "./chunk-CDQGSZL3.ts";
17
14
  import {
18
15
  parseJsonObjectDocument,
19
16
  parseSettingsDocument
20
17
  } from "./chunk-ZW5ZLGBI.ts";
18
+ import {
19
+ scanSnapshot
20
+ } from "./chunk-PHANBTVM.ts";
21
21
  import {
22
22
  AGENT_INPUT_BYTES,
23
23
  AGENT_MAX_UNITS,
@@ -217,4 +217,4 @@ export {
217
217
  parseAgentCandidate,
218
218
  applyAgentCandidate
219
219
  };
220
- //# sourceMappingURL=chunk-5QAE3G3K.ts.map
220
+ //# sourceMappingURL=chunk-IMMMZUFC.ts.map
@@ -6,10 +6,10 @@ import {
6
6
  syncSetupStorageReview,
7
7
  updateLocalConfig,
8
8
  validateConfigName
9
- } from "./chunk-QO333NM4.ts";
9
+ } from "./chunk-RX3WGWVL.ts";
10
10
  import {
11
11
  normalizeSyncInclude
12
- } from "./chunk-QOFMXPM5.ts";
12
+ } from "./chunk-DFJGTVPX.ts";
13
13
 
14
14
  // src/settings/settings-management.ts
15
15
  import { isDeepStrictEqual } from "node:util";
@@ -195,4 +195,4 @@ export {
195
195
  removeSyncSetup,
196
196
  removeStorageConnection
197
197
  };
198
- //# sourceMappingURL=chunk-B4QZBDBT.ts.map
198
+ //# sourceMappingURL=chunk-JXWTEJS5.ts.map
@@ -3,19 +3,21 @@
3
3
  import {
4
4
  portableSnapshot,
5
5
  sameLocalFields
6
- } from "./chunk-A6HU4ERM.ts";
6
+ } from "./chunk-UGSSZWQ6.ts";
7
+ import {
8
+ filterSnapshotForConfigPolicy,
9
+ isSessionPath
10
+ } from "./chunk-PHANBTVM.ts";
7
11
  import {
8
12
  canonicalSnapshotPathForConfig,
9
13
  customIncludePathsByLower,
10
- filterSnapshotForConfigPolicy,
11
14
  includeFromSelectionConfig,
12
15
  isConfiguredSnapshotPath,
13
- isSessionPath,
14
16
  normalizeSyncInclude
15
- } from "./chunk-QOFMXPM5.ts";
17
+ } from "./chunk-DFJGTVPX.ts";
16
18
  import {
17
19
  toPosix
18
- } from "./chunk-HUZ5CR4W.ts";
20
+ } from "./chunk-YZ5BQNRZ.ts";
19
21
 
20
22
  // src/sync/sync-state.ts
21
23
  function hasLocalChanges(local, state, config) {
@@ -118,4 +120,4 @@ export {
118
120
  canPullRemoteSettingsOnFirstSync,
119
121
  canPullRemoteSessionsOnFirstSync
120
122
  };
121
- //# sourceMappingURL=chunk-BDB4IDM3.ts.map
123
+ //# sourceMappingURL=chunk-JY2RVOUL.ts.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/sync/sync-state.ts"],
4
4
  "sourcesContent": ["import type { RemoteHead } from \"../backends/sync-backend.js\";\nimport { toPosix } from \"../paths.js\";\nimport {\n canonicalSnapshotPathForConfig,\n filterSnapshotForConfigPolicy,\n isConfiguredSnapshotPath,\n isSessionPath,\n} from \"../snapshot/snapshot.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport type { SyncState } from \"../state/state-types.js\";\nimport { portableSnapshot, sameLocalFields } from \"./local-fields.js\";\nimport {\n customIncludePathsByLower,\n includeFromSelectionConfig,\n normalizeSyncInclude,\n type SyncSelectionConfig,\n} from \"./sync-policy.js\";\n\ntype SyncPolicyConfig = SyncSelectionConfig & { localFields?: string[] };\n\nexport function hasLocalChanges(local: Snapshot, state: SyncState, config: SyncPolicyConfig) {\n return (\n (Boolean(state.lastAppliedSnapshot) && !sameLocalFields(state.localFields, config.localFields)) ||\n !sameHashes(fileHashMap(portableSnapshot(local, config.localFields)), stateHashMapForConfig(state, config))\n );\n}\n\nexport function remoteChangedSinceState(\n head: RemoteHead | undefined,\n state: SyncState,\n config: SyncPolicyConfig,\n sameRevision: (left: string, right: string) => boolean,\n) {\n if (!head) return Boolean(state.lastAppliedSnapshot);\n if (head.snapshotId !== state.lastAppliedSnapshot) return true;\n if (state.lastRemoteRevision && !sameRevision(head.revision, state.lastRemoteRevision)) return true;\n if (syncPolicyChanged(state, config)) return true;\n return (\n includeFromSelectionConfig(config).includes(\"sessions\") && !state.include?.includes(\"sessions\") && head.syncSessions\n );\n}\n\nexport function hasRemoteChanges(\n remote: Snapshot,\n state: SyncState,\n config: SyncPolicyConfig,\n ignoredPaths = new Set<string>(),\n) {\n if (remote.id === state.lastAppliedSnapshot && !syncPolicyChanged(state, config)) return false;\n return !snapshotHashesMatchState(\n portableSnapshot(filterSnapshotForConfigPolicy(remote, config), remote.localFields),\n state,\n config,\n ignoredPaths,\n );\n}\n\nexport function sameHashes(left: Record<string, string>, right: Record<string, string>) {\n const keys = new Set([...Object.keys(left), ...Object.keys(right)]);\n for (const key of keys) if (left[key] !== right[key]) return false;\n return true;\n}\n\nexport function fileHashMap(snapshot: Snapshot) {\n return Object.fromEntries(snapshot.files.map((file) => [file.path, file.sha256]));\n}\n\nfunction stateHashMapForConfig(state: SyncState, config: SyncPolicyConfig) {\n const includePaths = customIncludePathsByLower(includeFromSelectionConfig(config));\n return Object.fromEntries(\n Object.entries(state.lastFileHashes)\n .filter(([filePath]) => isConfiguredSnapshotPath(filePath, config))\n .map(([filePath, hash]) => [canonicalSnapshotPathForConfig(filePath, includePaths), hash]),\n );\n}\n\nexport function snapshotHashesMatchState(\n snapshot: Snapshot,\n state: SyncState,\n config: SyncPolicyConfig,\n ignoredPaths = new Set<string>(),\n) {\n return sameHashes(\n withoutHashPaths(fileHashMap(snapshot), ignoredPaths),\n withoutHashPaths(stateHashMapForConfig(state, config), ignoredPaths),\n );\n}\n\nexport function snapshotsMatch(left: Snapshot, right: Snapshot) {\n return left.syncSessions === right.syncSessions && sameHashes(fileHashMap(left), fileHashMap(right));\n}\n\nfunction withoutHashPaths(hashes: Record<string, string>, ignoredPaths: Set<string>) {\n if (ignoredPaths.size === 0) return hashes;\n return Object.fromEntries(Object.entries(hashes).filter(([filePath]) => !ignoredPaths.has(toPosix(filePath))));\n}\n\nexport function syncPolicyChanged(state: SyncState, config: SyncPolicyConfig) {\n return syncIncludeChanged(state, config) || !sameLocalFields(state.localFields, config.localFields);\n}\n\nexport function shouldRefreshSyncedState(\n remote: Snapshot,\n head: RemoteHead | undefined,\n state: SyncState,\n config: SyncPolicyConfig,\n sameRevision: (left: string, right: string) => boolean,\n) {\n return (\n remote.id !== state.lastAppliedSnapshot ||\n Boolean(head && (!state.lastRemoteRevision || !sameRevision(head.revision, state.lastRemoteRevision))) ||\n syncPolicyChanged(state, config)\n );\n}\n\nfunction syncIncludeChanged(state: SyncState, config: SyncPolicyConfig) {\n const stored = state.include ? normalizeSyncInclude(state.include) : includeFromSelectionConfig(state);\n const current = includeFromSelectionConfig(config);\n return stored.length !== current.length || stored.some((item, index) => item !== current[index]);\n}\n\nexport function settingsHashMap(snapshot: Snapshot) {\n return Object.fromEntries(\n snapshot.files.filter((file) => !isSessionPath(file.path)).map((file) => [file.path, file.sha256]),\n );\n}\n\nexport function sessionHashMap(snapshot: Snapshot) {\n return Object.fromEntries(\n snapshot.files.filter((file) => isSessionPath(file.path)).map((file) => [file.path, file.sha256]),\n );\n}\n\nexport function settingsHashMapFromState(state: SyncState) {\n return Object.fromEntries(Object.entries(state.lastFileHashes).filter(([filePath]) => !isSessionPath(filePath)));\n}\n\nexport function settingsHashesMatchState(remote: Snapshot, state: SyncState) {\n return sameHashes(settingsHashMap(remote), settingsHashMapFromState(state));\n}\n\nexport function canPullRemoteSettingsOnFirstSync(local: Snapshot, remote: Snapshot) {\n const remoteSettings = settingsHashMap(remote);\n return Object.entries(settingsHashMap(local)).every(([filePath, hash]) => remoteSettings[filePath] === hash);\n}\n\nexport function canPullRemoteSessionsOnFirstSync(local: Snapshot, remote: Snapshot) {\n const localSessions = sessionHashMap(local);\n const remoteSessions = sessionHashMap(remote);\n return Object.entries(localSessions).every(([filePath, hash]) => remoteSessions[filePath] === hash);\n}\n"],
5
- "mapp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