@narumitw/pi-sync 0.67.3 → 0.68.0

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 (174) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +26 -48
  3. package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
  4. package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
  5. package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
  6. package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
  7. package/dist/chunks/{chunk-HLJIRWFL.ts → chunk-BCDBT4X3.ts} +7 -7
  8. package/dist/chunks/{chunk-AVTW6WNP.ts → chunk-FQKWGVMA.ts} +20 -54
  9. package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
  10. package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
  11. package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
  12. package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
  13. package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
  14. package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
  15. package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
  16. package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
  17. package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
  18. package/dist/chunks/{chunk-X344HTVV.ts → chunk-WCGLU526.ts} +39 -118
  19. package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
  20. package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
  21. package/dist/chunks/{chunk-CQ4DMLH3.ts → chunk-YV2R5SJU.ts} +21 -81
  22. package/dist/chunks/chunk-YV2R5SJU.ts.map +7 -0
  23. package/dist/chunks/{command-handler-WF2TDDRZ.ts → command-handler-S6BRZMPW.ts} +64 -59
  24. package/dist/chunks/command-handler-S6BRZMPW.ts.map +7 -0
  25. package/dist/chunks/{conflict-review-GWEL4S6C.ts → conflict-review-3XMYDJIK.ts} +2 -2
  26. package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
  27. package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
  28. package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
  29. package/dist/chunks/{manager-ui-FS4QIKRA.ts → manager-ui-KHMCSLLV.ts} +114 -581
  30. package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
  31. package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
  32. package/dist/chunks/{remote-selection-ui-DOYKUMER.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
  33. package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
  34. package/dist/chunks/{setup-wizard-PI45SF2C.ts → setup-wizard-2NRPR433.ts} +11 -16
  35. package/dist/chunks/{setup-wizard-PI45SF2C.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
  36. package/dist/chunks/{sync-inspection-DI5J6EUH.ts → sync-inspection-QGM54YCM.ts} +5 -5
  37. package/dist/chunks/{sync-operations-AGNL7QXA.ts → sync-operations-DTQMKVRQ.ts} +2 -2
  38. package/dist/daemon/dist/build-id.json +1 -1
  39. package/dist/daemon/dist/cli.js +22 -3
  40. package/dist/daemon/dist/client-transport.js +2 -0
  41. package/dist/daemon/dist/client.js +2 -10
  42. package/dist/daemon/dist/consent.js +13 -135
  43. package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
  44. package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
  45. package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
  46. package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
  47. package/dist/daemon/dist/engine/settings/config.js +16 -149
  48. package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
  49. package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
  50. package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
  51. package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
  52. package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
  53. package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
  54. package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
  55. package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
  56. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
  57. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
  58. package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
  59. package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
  60. package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
  61. package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
  62. package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
  63. package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
  64. package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
  65. package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
  66. package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
  67. package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
  68. package/dist/daemon/dist/engine/sync/initialization.js +4 -15
  69. package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
  70. package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
  71. package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
  72. package/dist/daemon/dist/engine/sync/merged-sync.js +12 -70
  73. package/dist/daemon/dist/engine/sync/push-review.js +1 -16
  74. package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
  75. package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
  76. package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
  77. package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
  78. package/dist/daemon/dist/engine/sync/sync-mutations.js +25 -118
  79. package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
  80. package/dist/daemon/dist/engine/sync/sync-queries.js +1 -8
  81. package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
  82. package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
  83. package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
  84. package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
  85. package/dist/daemon/dist/engine-service.js +60 -219
  86. package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
  87. package/dist/daemon/dist/legacy-consent-guard.js +34 -0
  88. package/dist/daemon/dist/server.js +4 -8
  89. package/dist/daemon/dist/service-host.js +3 -9
  90. package/dist/daemon/package.json +1 -1
  91. package/dist/index.ts +45 -46
  92. package/dist/index.ts.map +3 -3
  93. package/docs/continuous-sync-verification.md +1 -1
  94. package/docs/daemon-migration.md +7 -5
  95. package/docs/tui-contract.md +4 -6
  96. package/package.json +2 -3
  97. package/skills/configure-pi-sync/SKILL.md +18 -77
  98. package/skills/configure-pi-sync/references/configuration.md +58 -75
  99. package/src/commands/command-execution.ts +13 -29
  100. package/src/commands/command-handler.ts +0 -4
  101. package/src/commands/command.ts +2 -1
  102. package/src/daemon/directional-recovery.ts +4 -33
  103. package/src/daemon/pi-client.ts +20 -88
  104. package/src/settings/config.ts +0 -1
  105. package/src/sync/setup-switch.ts +1 -4
  106. package/src/sync-extension.ts +10 -24
  107. package/src/ui/cancellable-operation.ts +2 -13
  108. package/src/ui/excluded-paths-ui.ts +1 -4
  109. package/src/ui/file-selection.ts +0 -5
  110. package/src/ui/manager-state.ts +12 -75
  111. package/src/ui/manager-ui.ts +7 -96
  112. package/src/ui/remote-selection-ui.ts +29 -130
  113. package/src/ui/settings-ui.ts +169 -388
  114. package/src/ui/setup/setup-actions.ts +4 -16
  115. package/src/ui/setup/setup-prompts.ts +12 -49
  116. package/src/ui/setup/setup-switcher.ts +8 -14
  117. package/src/ui/storage-connections-ui.ts +21 -32
  118. package/src/ui/sync-setups-ui.ts +27 -53
  119. package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
  120. package/dist/chunks/chunk-33EDXDLC.ts +0 -106
  121. package/dist/chunks/chunk-33EDXDLC.ts.map +0 -7
  122. package/dist/chunks/chunk-AVTW6WNP.ts.map +0 -7
  123. package/dist/chunks/chunk-CQ4DMLH3.ts.map +0 -7
  124. package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
  125. package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
  126. package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
  127. package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
  128. package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
  129. package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
  130. package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
  131. package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
  132. package/dist/chunks/chunk-X344HTVV.ts.map +0 -7
  133. package/dist/chunks/command-handler-WF2TDDRZ.ts.map +0 -7
  134. package/dist/chunks/config-P54GGMXY.ts +0 -39
  135. package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
  136. package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
  137. package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
  138. package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
  139. package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
  140. package/dist/chunks/ignore-file-ui-BEZZZIEE.ts +0 -21
  141. package/dist/chunks/manager-ui-FS4QIKRA.ts.map +0 -7
  142. package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
  143. package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
  144. package/dist/chunks/remote-selection-ui-DOYKUMER.ts.map +0 -7
  145. package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
  146. package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
  147. package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
  148. package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
  149. package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
  150. package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
  151. package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
  152. package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
  153. package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
  154. package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
  155. package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
  156. package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
  157. package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
  158. package/dist/daemon/dist/monitor.js +0 -344
  159. package/src/ui/agent-mode-setting.ts +0 -99
  160. package/src/ui/ignore-file-guidance.ts +0 -7
  161. package/src/ui/ignore-file-ui.ts +0 -105
  162. package/src/ui/ignore-migration-prompt.ts +0 -65
  163. package/src/ui/settings-review.ts +0 -26
  164. /package/dist/chunks/{chunk-HLJIRWFL.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
  165. /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
  166. /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
  167. /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
  168. /package/dist/chunks/{conflict-review-GWEL4S6C.ts.map → conflict-review-3XMYDJIK.ts.map} +0 -0
  169. /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
  170. /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
  171. /package/dist/chunks/{ignore-file-ui-BEZZZIEE.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
  172. /package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
  173. /package/dist/chunks/{sync-inspection-DI5J6EUH.ts.map → sync-inspection-QGM54YCM.ts.map} +0 -0
  174. /package/dist/chunks/{sync-operations-AGNL7QXA.ts.map → sync-operations-DTQMKVRQ.ts.map} +0 -0
@@ -1,39 +1,30 @@
1
1
  import { createHash } from "node:crypto";
2
- import path from "node:path";
3
- import { documentFingerprint } from "../../document.js";
4
2
  import { backendIdentityCoordinates } from "../backends/backend-identity.js";
5
3
  import { normalizeGitBranch, normalizeGitDirectory, normalizeGitRemote } from "../backends/git/git-config.js";
6
4
  import { normalizeWebDavPath, normalizeWebDavUrl } from "../backends/webdav/webdav-config.js";
7
- import { engineHost, getEngineRoot } from "../host.js";
8
- import { compileEffectiveIgnorePolicy } from "../ignore/effective-ignore-policy.js";
9
- import { DEFAULT_IGNORE_FILENAME, readIgnoreSource, validateIgnoreFilename } from "../ignore/ignore-source.js";
10
5
  import { normalizeSyncExclude } from "../sync/exclude-policy.js";
11
6
  import { normalizeLocalFields } from "../sync/local-field-policy.js";
12
- import { localIgnorePolicyKey, normalizeDirectoryRules, normalizeSyncInclude, syncDirectoryPolicyKey, syncSessionsSelected, } from "../sync/sync-policy.js";
13
- import { safeTerminalText } from "../ui/terminal-text.js";
14
- import { localConfigPath, readActiveLocalConfigDocumentForRepair, withLockedLocalConfigDocument, } from "./config-file.js";
15
- import { readLocalConfigDocument, requireSettings } from "./settings-store.js";
7
+ import { normalizeDirectoryRules, normalizeSyncInclude, syncDirectoryPolicyKey, syncSessionsSelected, } from "../sync/sync-policy.js";
8
+ import { localConfigPath, readActiveLocalConfigDocumentForRepair } from "./config-file.js";
9
+ import { assertNoRetiredRuleJournal } from "./retired-ignore-recovery.js";
10
+ import { readLocalConfigDocument } from "./settings-store.js";
16
11
  import { DEFAULT_ON_SWITCH, isCloudflareR2Endpoint, normalizeS3Bucket, normalizeS3Endpoint, normalizeStoragePath, optionalString, ownObject, requiredString, validateConfigName, validateSettingsDocument, } from "./settings-validation.js";
17
12
  export async function loadConfig(setupName, signal) {
18
13
  signal?.throwIfAborted();
14
+ assertNoRetiredRuleJournal();
19
15
  const document = await readLocalConfigDocument();
20
16
  if (!document)
21
17
  throw new Error(`Missing pi-sync settings. Open /sync and choose Set up sync, or create ${localConfigPath()}.`);
22
- return operationalConfig(document, setupName, signal);
18
+ signal?.throwIfAborted();
19
+ return configFromSettings(settingsFromCheckDocument(document), setupName);
23
20
  }
24
21
  /** A background freshness read must never trigger legacy-file publication. */
25
22
  export async function loadConfigForCheck(setupName, signal) {
26
23
  signal?.throwIfAborted();
27
- return operationalConfig(await readActiveLocalConfigDocumentForRepair(), setupName, signal);
28
- }
29
- async function operationalConfig(document, setupName, signal) {
24
+ assertNoRetiredRuleJournal();
25
+ const document = await readActiveLocalConfigDocumentForRepair();
30
26
  signal?.throwIfAborted();
31
- const config = configFromSettings(settingsFromCheckDocument(document), setupName);
32
- if (!config.reservedIgnoreNames)
33
- return config;
34
- if (engineHost().ignoreFileOperationsAvailable === false)
35
- return requireLegacyOperationConfig(config);
36
- return resolveOperationPolicy(config, setupName, signal, document && { kind: "checked", document });
27
+ return configFromSettings(settingsFromCheckDocument(document), setupName);
37
28
  }
38
29
  export async function loadSettingsConfig(setupName) {
39
30
  const settings = settingsFromCheckDocument(await readActiveLocalConfigDocumentForRepair());
@@ -44,123 +35,20 @@ function settingsFromCheckDocument(document) {
44
35
  throw new Error(`Missing pi-sync settings: ${localConfigPath()}`);
45
36
  return validateSettingsDocument(document.parsed);
46
37
  }
47
- export function requireLegacyOperationConfig(config) {
48
- if (config.pathPolicy === "ignore-file" || config.ignorePolicy || config.reservedIgnoreNames !== undefined) {
49
- throw new Error("This Pi Sync operation does not yet support settings with ignore-file policies.");
50
- }
51
- return config;
52
- }
53
- export async function resolveIgnoreConfig(settings, setupName, signal) {
54
- signal?.throwIfAborted();
55
- return resolveOperationPolicy(configFromSettings(validateSettingsDocument(settings), setupName), setupName, signal);
56
- }
57
38
  export function createSettingsConfigView(document) {
58
39
  const settings = validateSettingsDocument(document.parsed);
59
- const ignoreNames = reservedIgnoreFilenames(settings);
60
- const metadata = (setupName) => projectSettingsConfig(settings, setupName, () => ignoreNames);
61
- let fingerprint;
40
+ const metadata = (setupName) => configFromSettings(settings, setupName);
62
41
  return {
63
42
  activeSetupName: settings.activeSyncSetup,
64
43
  setupNames: Object.keys(settings.syncSetups),
65
44
  metadata,
66
45
  async observe(setupName, signal) {
67
46
  signal?.throwIfAborted();
68
- const config = metadata(setupName);
69
- if (!config.reservedIgnoreNames)
70
- return config;
71
- if (engineHost().ignoreFileOperationsAvailable === false)
72
- return requireLegacyOperationConfig(config);
73
- fingerprint ??= settingsDocumentFingerprint(document);
74
- return resolveOperationPolicy(config, setupName, signal, { kind: "view", fingerprint });
75
- },
76
- };
77
- }
78
- function settingsDocumentFingerprint(document) {
79
- return documentFingerprint(document && { bytes: document.bytes.toString("base64"), identity: document.identity });
80
- }
81
- async function resolveOperationPolicy(config, setupName, signal, settingsSource) {
82
- if (!config.reservedIgnoreNames)
83
- return config;
84
- const root = getEngineRoot();
85
- const validateRoot = () => {
86
- signal?.throwIfAborted();
87
- if (root !== getEngineRoot())
88
- throw new Error("The Pi agent directory changed; reopen the review before continuing.");
89
- };
90
- const original = settingsSource?.kind === "checked" ? settingsSource.document : undefined;
91
- const configDocumentFingerprint = settingsSource?.kind === "view" ? settingsSource.fingerprint : original && settingsDocumentFingerprint(original);
92
- const settingsFingerprint = settingsSource?.kind === "view" ? undefined : syncCheckConfigFingerprint(config);
93
- const validateSettings = (document) => {
94
- validateRoot();
95
- if ((original &&
96
- (document?.path !== original.path || settingsDocumentFingerprint(document) !== configDocumentFingerprint)) ||
97
- settingsFingerprint !==
98
- syncCheckConfigFingerprint(configFromSettings(settingsFromCheckDocument(document), setupName))) {
99
- throw new Error("Pi Sync settings changed; reopen the review before continuing.");
100
- }
101
- };
102
- const source = config.pathPolicy === "ignore-file" ? await readIgnoreSource(root, config.ignoreFile, signal) : undefined;
103
- validateRoot();
104
- if (settingsSource && source && !source.present) {
105
- throw new Error(`Ignore file is missing: ${safeTerminalText(path.join(root, source.filename))}. Create it and reopen Pi Sync; starter rules are only a preview.`);
106
- }
107
- if (original && source)
108
- validateSettings(await readActiveLocalConfigDocumentForRepair());
109
- const observed = {
110
- ...config,
111
- ...(configDocumentFingerprint ? { configDocumentFingerprint } : {}),
112
- ...(source ? { ignorePolicy: compileEffectiveIgnorePolicy(source, ignorePolicyInput(config)) } : {}),
113
- ...(source?.identity ? { ignoreSourceIdentity: source.identity } : {}),
114
- };
115
- if (settingsSource?.kind === "view")
116
- return observed;
117
- return {
118
- ...observed,
119
- validateIgnorePolicy: async () => {
120
- validateRoot();
121
- await withLockedLocalConfigDocument(async (document, recheck) => {
122
- validateSettings(document);
123
- if (source) {
124
- const current = await readIgnoreSource(root, source.filename, signal);
125
- validateRoot();
126
- recheck();
127
- if (current.sourceDigest !== source.sourceDigest || current.identity !== source.identity) {
128
- throw new Error("Pi Sync ignore policy changed; reopen the review before continuing.");
129
- }
130
- if (!current.present) {
131
- throw new Error(`Ignore file "${source.filename}" is missing; starter rules can only be used for a preview.`);
132
- }
133
- }
134
- else {
135
- recheck();
136
- }
137
- }, signal, true);
138
- validateRoot();
47
+ return metadata(setupName);
139
48
  },
140
49
  };
141
50
  }
142
- function ignorePolicyInput(config) {
143
- return {
144
- filename: config.ignoreFile,
145
- sessions: config.include.includes("sessions"),
146
- configuredFilenames: config.reservedIgnoreNames ?? [],
147
- };
148
- }
149
- function reservedIgnoreFilenames(settings) {
150
- const names = new Set();
151
- for (const { sync } of Object.values(settings.syncSetups)) {
152
- if (sync.pathPolicy === "ignore-file")
153
- names.add(validateIgnoreFilename(sync.ignoreFile ?? DEFAULT_IGNORE_FILENAME).toLowerCase());
154
- }
155
- if (names.size === 0)
156
- return undefined;
157
- names.add(DEFAULT_IGNORE_FILENAME);
158
- return [...names].sort();
159
- }
160
51
  export function configFromSettings(settings, setupName) {
161
- return projectSettingsConfig(settings, setupName, () => reservedIgnoreFilenames(settings));
162
- }
163
- function projectSettingsConfig(settings, setupName, getReservedIgnoreNames) {
164
52
  const selectedName = setupName ?? settings.activeSyncSetup;
165
53
  if (!selectedName)
166
54
  throw new Error("No sync setups are configured.");
@@ -173,22 +61,19 @@ function projectSettingsConfig(settings, setupName, getReservedIgnoreNames) {
173
61
  if (!connection) {
174
62
  throw new Error(`Invalid pi-sync settings: sync setup “${selectedName}” references missing storage connection “${connectionName}”.`);
175
63
  }
176
- const reservedIgnoreNames = getReservedIgnoreNames();
177
64
  return {
178
65
  ...resolveSyncConfig(selectedName, setup, connectionName, connection, settings.onSwitch, settings.skipSecretScan ?? false, settings.showStatus ?? true),
179
66
  debug: settings.debug ?? false,
180
- ...(reservedIgnoreNames ? { reservedIgnoreNames } : {}),
181
67
  };
182
68
  }
183
69
  /** A validated setup-facing projection used by manager and settings UI. */
184
70
  export async function loadPartialConfig(setupName) {
185
- const config = configFromSettings(await requireSettings(), setupName);
71
+ const config = await loadConfig(setupName);
186
72
  return {
187
73
  setupName: config.setupName,
188
74
  ...storageReviewFromConfig(config),
189
75
  include: [...config.include],
190
76
  ...(config.scope === undefined ? {} : { scope: config.scope }),
191
- ...(config.pathPolicy === undefined ? {} : { pathPolicy: config.pathPolicy, ignoreFile: config.ignoreFile }),
192
77
  ...(config.exclude === undefined ? {} : { exclude: [...config.exclude] }),
193
78
  ...(config.reinclude === undefined ? {} : { reinclude: [...config.reinclude] }),
194
79
  automatic: config.automatic,
@@ -206,10 +91,7 @@ export function syncSetupReviewIdentity(setupName, setup, connectionName, connec
206
91
  return syncConfigReviewIdentity(resolveSyncConfig(setupName, setup, connectionName, connection, DEFAULT_ON_SWITCH, false, true));
207
92
  }
208
93
  export function syncConfigReviewIdentity(config) {
209
- const localPolicy = localIgnorePolicyKey(config);
210
- const directoryPolicy = config.pathPolicy === "ignore-file" && !config.ignorePolicy
211
- ? JSON.stringify([config.pathPolicy, config.ignoreFile])
212
- : syncDirectoryPolicyKey(config);
94
+ const directoryPolicy = syncDirectoryPolicyKey(config);
213
95
  return JSON.stringify([
214
96
  config.setupName,
215
97
  config.connectionName,
@@ -229,7 +111,6 @@ export function syncConfigReviewIdentity(config) {
229
111
  : config.exclude === undefined
230
112
  ? []
231
113
  : ["exclude", normalizeSyncExclude(config.exclude).map((rule) => rule.toLowerCase())]),
232
- ...(localPolicy ? [localPolicy] : []),
233
114
  ]);
234
115
  }
235
116
  export function syncConfigReviewFingerprint(config) {
@@ -241,14 +122,6 @@ export function syncCheckConfigFingerprint(config) {
241
122
  .update(JSON.stringify({ ...config, showStatus: undefined, debug: undefined, settingsVersion: undefined }))
242
123
  .digest("hex");
243
124
  }
244
- export function syncSettingsConfigFingerprint(config) {
245
- return syncCheckConfigFingerprint({
246
- ...config,
247
- configDocumentFingerprint: undefined,
248
- ignoreSourceIdentity: undefined,
249
- ignorePolicy: undefined,
250
- });
251
- }
252
125
  function storageReviewFromConfig(config) {
253
126
  return {
254
127
  connectionName: config.connectionName,
@@ -269,12 +142,6 @@ function resolveSyncConfig(setupName, setup, connectionName, connection, onSwitc
269
142
  ? {
270
143
  scope: policy.scope,
271
144
  include: policy.sessions ? ["sessions"] : [],
272
- ...(policy.pathPolicy === "ignore-file"
273
- ? {
274
- pathPolicy: policy.pathPolicy,
275
- ignoreFile: validateIgnoreFilename(policy.ignoreFile ?? DEFAULT_IGNORE_FILENAME),
276
- }
277
- : {}),
278
145
  ...(policy.exclude === undefined ? {} : { exclude: normalizeDirectoryRules(policy.exclude) }),
279
146
  ...(policy.reinclude === undefined ? {} : { reinclude: normalizeDirectoryRules(policy.reinclude) }),
280
147
  }
@@ -290,8 +157,8 @@ function resolveSyncConfig(setupName, setup, connectionName, connection, onSwitc
290
157
  ...selection,
291
158
  automatic: setup.sync.automatic,
292
159
  automaticTransfer: setup.sync.automaticTransfer ?? false,
293
- agentMode: setup.sync.agentMode ?? false,
294
- continuous: setup.sync.continuous ?? false,
160
+ agentMode: false,
161
+ continuous: false,
295
162
  localFields: setup.sync.localFields === undefined ? undefined : normalizeLocalFields(setup.sync.localFields),
296
163
  mergeSettings: setup.sync.mergeSettings ?? false,
297
164
  mergeContent: setup.sync.mergeContent ?? false,
@@ -0,0 +1,16 @@
1
+ export class RetiredIgnorePolicyError extends Error {
2
+ kind;
3
+ constructor(kind) {
4
+ const reason = {
5
+ settings: "Ignore-file sync settings are no longer supported.",
6
+ snapshot: "This remote uses a retired ignore-file snapshot format.",
7
+ baseline: "The last accepted sync is bound to a retired ignore-file policy.",
8
+ recovery: "An ignore-file operation still needs recovery with a compatible Pi Sync build.",
9
+ }[kind];
10
+ super(`${reason} Preserve the data and use /skill:configure-pi-sync for guidance.`);
11
+ this.kind = kind;
12
+ }
13
+ }
14
+ export function retiredIgnorePolicy(kind) {
15
+ return new RetiredIgnorePolicyError(kind);
16
+ }
@@ -0,0 +1,14 @@
1
+ import { lstatSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { getEngineRoot } from "../host.js";
4
+ import { stateDir } from "../state/state-directory.js";
5
+ import { retiredIgnorePolicy } from "./retired-ignore-policy.js";
6
+ export function hasRetiredRuleJournal(root) {
7
+ return Boolean(lstatSync(path.join(root, ".pi-sync.json.syncignore-creation"), { throwIfNoEntry: false }) ||
8
+ lstatSync(path.join(stateDir(root), "ignore-adoption.json"), { throwIfNoEntry: false }));
9
+ }
10
+ export function assertNoRetiredRuleJournal(root = getEngineRoot()) {
11
+ if (hasRetiredRuleJournal(root)) {
12
+ throw retiredIgnorePolicy("recovery");
13
+ }
14
+ }
@@ -125,10 +125,8 @@ export async function updateSyncSetup(name, update, options = {}) {
125
125
  }
126
126
  export async function removeSyncSetup(name, signal) {
127
127
  validateConfigName(name, "sync setup");
128
- let removedLastIgnoreSetup = false;
129
- const saved = await updateLocalConfig((settings) => {
130
- const setup = settings.syncSetups[name];
131
- if (!Object.hasOwn(settings.syncSetups, name) || !setup)
128
+ await updateLocalConfig((settings) => {
129
+ if (!Object.hasOwn(settings.syncSetups, name))
132
130
  throw new Error(`Sync setup not found: ${name}`);
133
131
  const isCurrent = settings.activeSyncSetup === name;
134
132
  if (isCurrent && Object.keys(settings.syncSetups).length > 1) {
@@ -136,15 +134,11 @@ export async function removeSyncSetup(name, signal) {
136
134
  }
137
135
  const syncSetups = { ...settings.syncSetups };
138
136
  delete syncSetups[name];
139
- removedLastIgnoreSetup =
140
- setup.sync.pathPolicy === "ignore-file" &&
141
- !Object.values(syncSetups).some((remaining) => remaining.sync.pathPolicy === "ignore-file");
142
137
  const next = { ...settings, syncSetups };
143
138
  if (isCurrent)
144
139
  delete next.activeSyncSetup;
145
140
  return next;
146
141
  }, signal);
147
- return { revertedToLegacyOnly: removedLastIgnoreSetup && saved.activeSyncSetup !== undefined };
148
142
  }
149
143
  export async function removeStorageConnection(name, signal) {
150
144
  validateConfigName(name, "storage connection");
@@ -164,8 +158,6 @@ export async function removeStorageConnection(name, signal) {
164
158
  function setupSettingsVersion(current, setup, upgradeExclude) {
165
159
  if (setup.sync.maxFileSizeMiB !== undefined || setup.sync.maxDirectorySizeMiB !== undefined)
166
160
  return 9;
167
- if (current < 8 && setup.sync.pathPolicy === "ignore-file")
168
- return 8;
169
161
  if (current < 7 && setup.sync.scope === "agent-directory")
170
162
  return 7;
171
163
  if (current < 6 && upgradeExclude)
@@ -1,11 +1,11 @@
1
1
  import { normalizeEndpointIdentity } from "../backends/backend-identity.js";
2
2
  import { normalizeGitBranch, normalizeGitDirectory, normalizeGitRemote, normalizeGitRemoteIdentity, } from "../backends/git/git-config.js";
3
3
  import { normalizeWebDavIdentityUrl, normalizeWebDavPath, normalizeWebDavUrl, validateWebDavCredentials, } from "../backends/webdav/webdav-config.js";
4
- import { validateIgnoreFilename } from "../ignore/ignore-source.js";
5
4
  import { normalizeSyncExclude } from "../sync/exclude-policy.js";
6
5
  import { normalizeLocalFields } from "../sync/local-field-policy.js";
7
6
  import { normalizeDirectoryRules, normalizeSyncInclude } from "../sync/sync-policy.js";
8
7
  import { CONFIG_FILE_NAME } from "./config-file.js";
8
+ import { retiredIgnorePolicy } from "./retired-ignore-policy.js";
9
9
  export const DEFAULT_ON_SWITCH = "ask-before-pull";
10
10
  export function normalizeOnSwitch(value) {
11
11
  if (value === "ask-before-pull" || value === "pull-after-switch" || value === "switch-only") {
@@ -130,6 +130,10 @@ function validateSyncSetup(name, value, connections, version) {
130
130
  ], `sync setup “${name}”`);
131
131
  const storage = requireRecord(value.storage, `storage for sync setup “${name}”`);
132
132
  const sync = requireRecord(value.sync, `sync policy for sync setup “${name}”`);
133
+ if (sync.pathPolicy === "ignore-file" || Object.hasOwn(sync, "ignoreFile"))
134
+ throw retiredIgnorePolicy("settings");
135
+ if (Object.hasOwn(sync, "pathPolicy"))
136
+ throw new Error("Invalid pi-sync settings: unsupported sync.pathPolicy.");
133
137
  rejectLegacyFields(storage, ["profile", "prefix", "directory", "namespace"], `storage for sync setup “${name}”`);
134
138
  rejectLegacyFields(sync, ["autoSync", "syncFiles", "syncSessions", "extraFiles"], `sync policy for sync setup “${name}”`);
135
139
  const connectionName = requiredCanonicalReference(storage.connection, `storage connection reference for sync setup “${name}”`);
@@ -156,24 +160,7 @@ function validateSyncSetup(name, value, connections, version) {
156
160
  }
157
161
  }
158
162
  const localFields = normalizeLocalFields(sync.localFields);
159
- if (Object.hasOwn(sync, "pathPolicy")) {
160
- if (sync.pathPolicy !== "ignore-file")
161
- throw new Error("Invalid pi-sync settings: unsupported sync.pathPolicy.");
162
- if (version < 8)
163
- throw new Error("sync.pathPolicy requires explicit settings version 8.");
164
- if (!Object.hasOwn(sync, "scope") || sync.scope !== "agent-directory")
165
- throw new Error("Invalid pi-sync settings: sync.pathPolicy requires agent-directory scope.");
166
- for (const key of ["include", "exclude", "reinclude"]) {
167
- if (Object.hasOwn(sync, key))
168
- throw new Error(`Invalid pi-sync settings: ignore-file policy cannot use sync.${key}.`);
169
- }
170
- if (Object.hasOwn(sync, "ignoreFile"))
171
- validateIgnoreFilename(sync.ignoreFile);
172
- }
173
- else if (Object.hasOwn(sync, "ignoreFile")) {
174
- throw new Error("Invalid pi-sync settings: sync.ignoreFile requires ignore-file pathPolicy.");
175
- }
176
- else if (Object.hasOwn(sync, "scope")) {
163
+ if (Object.hasOwn(sync, "scope")) {
177
164
  if (sync.scope !== "agent-directory")
178
165
  throw new Error("Invalid pi-sync settings: unsupported sync.scope.");
179
166
  if (version < 7)
@@ -182,6 +169,8 @@ function validateSyncSetup(name, value, connections, version) {
182
169
  throw new Error("Invalid pi-sync settings: agent-directory scope cannot use sync.include.");
183
170
  normalizeDirectoryRules(sync.exclude);
184
171
  normalizeDirectoryRules(sync.reinclude);
172
+ if (sync.sessions !== undefined && typeof sync.sessions !== "boolean")
173
+ throw new Error("Invalid pi-sync settings: sync.sessions must be boolean.");
185
174
  }
186
175
  else {
187
176
  if (Object.hasOwn(sync, "sessions") || Object.hasOwn(sync, "reinclude"))
@@ -193,8 +182,6 @@ function validateSyncSetup(name, value, connections, version) {
193
182
  if (localFields.length > 0 && !include.includes("settings.json"))
194
183
  throw new Error("Nonempty localFields requires settings.json in sync.include.");
195
184
  }
196
- if (sync.sessions !== undefined && typeof sync.sessions !== "boolean")
197
- throw new Error("Invalid pi-sync settings: sync.sessions must be boolean.");
198
185
  if (sync.localFields !== undefined && version < 4)
199
186
  throw new Error("localFields requires explicit settings version 4; older binaries must refuse portable state.");
200
187
  if (sync.exclude !== undefined && version < 6)
@@ -1,10 +1,9 @@
1
1
  import fs from "node:fs/promises";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
- import { backendIdentityCoordinates } from "../backends/backend-identity.js";
5
4
  import { getEngineRoot as getAgentDir, } from "../host.js";
6
5
  import { configuredSnapshotPathMatcher } from "../sync/sync-policy.js";
7
- import { agentDirectorySessionRoot, reservedIgnoreTargetGuard } from "./snapshot-exclude-safety.js";
6
+ import { agentDirectorySessionRoot } from "./snapshot-exclude-safety.js";
8
7
  import { sessionStorageRoot } from "./snapshot-paths.js";
9
8
  export function sessionDirFromContext(ctx) {
10
9
  const manager = ctx.sessionManager;
@@ -15,19 +14,10 @@ export function sessionDirFromContext(ctx) {
15
14
  const getSessionDir = manager.getSessionDir;
16
15
  return typeof getSessionDir === "function" ? getSessionDir.call(manager) : undefined;
17
16
  }
18
- export async function configuredSessionDir(options = {}) {
19
- const root = agentDir();
20
- const target = path.join(root, "settings.json");
21
- const guardReserved = reservedIgnoreTargetGuard(root, options);
17
+ export async function configuredSessionDir() {
22
18
  let content;
23
19
  try {
24
- if (guardReserved) {
25
- const { readLegacySnapshotSource } = await import("./snapshot.js");
26
- content = (await readLegacySnapshotSource(target, guardReserved, options.signal)).toString("utf8");
27
- }
28
- else {
29
- content = await fs.readFile(target, "utf8");
30
- }
20
+ content = await fs.readFile(path.join(agentDir(), "settings.json"), "utf8");
31
21
  }
32
22
  catch (error) {
33
23
  if (error.code === "ENOENT")
@@ -46,41 +36,31 @@ export async function configuredSessionDir(options = {}) {
46
36
  }
47
37
  export async function effectiveSessionRoot(ctx, policy, signal) {
48
38
  const sessionDir = sessionDirFromContext(ctx);
49
- const root = agentDir();
50
39
  if (policy?.scope === "agent-directory") {
40
+ const root = agentDir();
51
41
  if (sessionDir !== undefined || ctx.sessionManager.usesDefaultSessionDir?.())
52
- return agentDirectorySessionRoot(root, sessionDir, policy.ignorePolicy, policy.reservedIgnoreNames);
42
+ return agentDirectorySessionRoot(root, sessionDir);
53
43
  if (!configuredSnapshotPathMatcher(policy)("settings.json"))
54
44
  throw new Error("Pi session storage is unknown and settings.json is excluded. Use an active Pi context to sync.");
55
45
  const { agentDirectoryConfiguredSessionDir } = await import("./snapshot.js");
56
46
  signal?.throwIfAborted();
57
- const configured = await agentDirectoryConfiguredSessionDir(signal, root, policy);
58
- return agentDirectorySessionRoot(root, configured, policy.ignorePolicy, policy.reservedIgnoreNames);
47
+ return agentDirectorySessionRoot(root, await agentDirectoryConfiguredSessionDir(signal));
59
48
  }
60
- const resolved = sessionStorageRoot(root, sessionDir ?? (await configuredSessionDir({ ...policy, signal })));
61
- const guardReserved = reservedIgnoreTargetGuard(root, policy ?? {});
62
- if (guardReserved)
63
- await guardReserved(resolved);
64
- return resolved;
49
+ return path.resolve(sessionStorageRoot(agentDir(), sessionDir ?? (await configuredSessionDir())));
65
50
  }
66
51
  export async function sessionDirForApply(ctx, snapshot, options = {}) {
67
52
  const contextSessionDir = sessionDirFromContext(ctx);
68
53
  if (options.scope === "agent-directory") {
69
54
  const root = await effectiveSessionRoot(ctx, options, options.signal);
70
- if (root !==
71
- agentDirectorySessionRoot(agentDir(), options.sessionDir, options.ignorePolicy, options.reservedIgnoreNames))
55
+ if (root !== agentDirectorySessionRoot(agentDir(), options.sessionDir))
72
56
  throw new Error("Pi session storage changed during transfer; retry from a fresh review.");
73
57
  return root;
74
58
  }
75
- const localSessionDir = await configuredSessionDir(options);
76
- const sessionDir = contextSessionDir && path.resolve(contextSessionDir) !== path.resolve(localSessionDir ?? "")
77
- ? contextSessionDir
78
- : (sessionDirFromSnapshot(snapshot) ?? contextSessionDir);
79
- const root = agentDir();
80
- const guardReserved = reservedIgnoreTargetGuard(root, options);
81
- if (guardReserved)
82
- await guardReserved(sessionStorageRoot(root, sessionDir));
83
- return sessionDir;
59
+ const localSessionDir = await configuredSessionDir();
60
+ if (contextSessionDir && path.resolve(contextSessionDir) !== path.resolve(localSessionDir ?? "")) {
61
+ return contextSessionDir;
62
+ }
63
+ return sessionDirFromSnapshot(snapshot) ?? contextSessionDir;
84
64
  }
85
65
  /** Hash-only merge plans cannot describe installation into a different session root. */
86
66
  export function requireStableMergeSessionRoot(before, after, scope) {
@@ -143,16 +123,8 @@ export function snapshotOptionsForContext(ctx, config) {
143
123
  return {
144
124
  include: config.include,
145
125
  ...(config.scope === undefined ? {} : { scope: config.scope }),
146
- ...(config.setupName === undefined ? {} : { setupName: config.setupName }),
147
- ...(config.backend && (config.ignorePolicy || config.reservedIgnoreNames !== undefined)
148
- ? { recoverySetupKey: JSON.stringify([backendIdentityCoordinates(config), config.localFields]) }
149
- : {}),
150
- ...(config.ignorePolicy ? { ignorePolicy: config.ignorePolicy } : {}),
151
- ...(config.ignoreSourceIdentity === undefined ? {} : { ignoreSourceIdentity: config.ignoreSourceIdentity }),
152
- ...(config.validateIgnorePolicy === undefined ? {} : { validateIgnorePolicy: config.validateIgnorePolicy }),
153
126
  ...(config.exclude === undefined ? {} : { exclude: config.exclude }),
154
127
  ...(config.reinclude === undefined ? {} : { reinclude: config.reinclude }),
155
- ...(config.reservedIgnoreNames === undefined ? {} : { reservedIgnoreNames: config.reservedIgnoreNames }),
156
128
  sessionDir: sessionDirFromContext(ctx) ?? defaultScopedSessionDir,
157
129
  };
158
130
  }
@@ -5,7 +5,7 @@ import { assertWithinRoot, isDeniedPath, isPathInside, parentPaths, safeJoin, to
5
5
  import { syncDirectory } from "../state/json-file.js";
6
6
  import { stateDir } from "../state/state-directory.js";
7
7
  import { collidingPaths } from "../sync/file-merge-planner.js";
8
- import { assertSnapshotExcludesDebugLog, compileSyncPolicyExclude, requireLegacyTransferPolicy, sameSnapshotSelection, selectionForSnapshot, } from "../sync/sync-policy.js";
8
+ import { assertSnapshotExcludesDebugLog, compileSyncPolicyExclude, requireLegacyTransferPolicy, } from "../sync/sync-policy.js";
9
9
  import { agentDir } from "./session-paths.js";
10
10
  import { agentDirectoryConfiguredSessionDir, agentDirectoryInventory, createSnapshot, isSessionFilePath, isSessionPath, sessionStorageRoot, snapshotIncludesSessions, snapshotTarget, } from "./snapshot.js";
11
11
  import { assertAgentDirectorySnapshotBound } from "./snapshot-bounds.js";
@@ -14,35 +14,20 @@ import { agentDirectoryPhysicalSessionPath, assertUnexcludedTargets } from "./sn
14
14
  import { decodeBase64Strict } from "./snapshot-payload.js";
15
15
  import { reviewedSnapshotPreimages } from "./snapshot-reviewed-preimages.js";
16
16
  import { applySnapshotTransaction, recoverPendingSnapshotTransactions, } from "./snapshot-transaction.js";
17
- import { ignorePolicyValidator } from "./snapshot-transaction-policy.js";
18
- import { isIgnoreSnapshotVersion, } from "./snapshot-types.js";
19
17
  function sha256(value) {
20
18
  return createHash("sha256").update(value).digest("hex");
21
19
  }
22
20
  function fileHashMap(snapshot) {
23
21
  return Object.fromEntries(snapshot.files.map((file) => [file.path, file.sha256]));
24
22
  }
25
- function assertSnapshotApplyPolicy(snapshot, options) {
26
- assertSnapshotExcludesDebugLog(snapshot);
27
- if (!isIgnoreSnapshotVersion(snapshot.version)) {
28
- requireLegacyTransferPolicy(snapshot);
29
- if (options.ignorePolicy)
30
- throw new Error("Project the snapshot into the reviewed local ignore-file policy before applying it.");
31
- return;
32
- }
33
- if (options.scope !== "agent-directory" || !options.ignorePolicy)
34
- requireLegacyTransferPolicy(snapshot);
35
- if (!sameSnapshotSelection(snapshot.selection, selectionForSnapshot(undefined, undefined, options)))
36
- throw new Error("Snapshot does not match the local ignore-file policy; review and project it before applying it.");
37
- }
38
23
  export async function applySnapshot(snapshot, protectedRelativePaths = new Set(), options = {}) {
39
- assertSnapshotApplyPolicy(snapshot, options);
40
- const validateIgnorePolicy = ignorePolicyValidator(options);
24
+ requireLegacyTransferPolicy(snapshot);
25
+ assertSnapshotExcludesDebugLog(snapshot);
41
26
  const root = agentDir();
42
27
  if (snapshot.version === 5 && options.scope !== "agent-directory")
43
28
  throw new Error("Agent-directory snapshot apply requires the local agent-directory policy.");
44
29
  const sessionDir = options.scope === "agent-directory"
45
- ? sessionStorageRoot(root, options.sessionDir ?? (await agentDirectoryConfiguredSessionDir(options.signal, root, options)))
30
+ ? sessionStorageRoot(root, options.sessionDir ?? (await agentDirectoryConfiguredSessionDir(options.signal, root)))
46
31
  : options.sessionDir;
47
32
  options.validateMutation?.();
48
33
  options = { ...options, sessionDir };
@@ -59,8 +44,6 @@ export async function applySnapshot(snapshot, protectedRelativePaths = new Set()
59
44
  ])),
60
45
  };
61
46
  options.validateMutation?.();
62
- if (validateIgnorePolicy)
63
- await validateIgnorePolicy();
64
47
  await recoverPendingSnapshotTransactions(transactionOptions);
65
48
  const current = await createSnapshot(snapshot.profile, {
66
49
  ...options,
@@ -125,7 +108,8 @@ function sameReviewedFiles(scanned, reviewed) {
125
108
  reviewed.files.every((file) => hashes.get(file.path) === file.sha256));
126
109
  }
127
110
  export function preflightSnapshotApply(root, snapshot, current, options = {}) {
128
- assertSnapshotApplyPolicy(snapshot, options);
111
+ requireLegacyTransferPolicy(snapshot);
112
+ assertSnapshotExcludesDebugLog(snapshot);
129
113
  const seenPaths = new Set();
130
114
  const remotePaths = new Set();
131
115
  const writes = [];
@@ -185,7 +169,7 @@ export function protectSnapshotApplyPlan(root, plan, protectedRelativePaths, ses
185
169
  };
186
170
  }
187
171
  export async function addTopLevelCaseVariantDeletes(root, plan, snapshot, options = {}) {
188
- if (options.scope === "agent-directory" || snapshot.selection?.scope === "agent-directory")
172
+ if (options.scope === "agent-directory" || snapshot.selection?.version === 3)
189
173
  return plan;
190
174
  const excluded = compileSyncPolicyExclude(options);
191
175
  const topLevelPaths = new Map();
@@ -250,7 +234,7 @@ function excludedApplyPath(root, options) {
250
234
  const excluded = compileSyncPolicyExclude(options);
251
235
  if (options.scope !== "agent-directory")
252
236
  return excluded;
253
- const physicalSessionPath = agentDirectoryPhysicalSessionPath(root, options.sessionDir, options.ignorePolicy, options.reservedIgnoreNames);
237
+ const physicalSessionPath = agentDirectoryPhysicalSessionPath(root, options.sessionDir);
254
238
  return (relative) => excluded(relative) ||
255
239
  (/^sessions(?:\/|$)/iu.test(relative) ? !isSessionFilePath(relative) : physicalSessionPath(relative));
256
240
  }
@@ -1,22 +1,20 @@
1
- import { isUtf8 } from "node:buffer";
2
1
  import { Readable, Writable } from "node:stream";
3
2
  import { pipeline } from "node:stream/promises";
4
3
  import { promisify } from "node:util";
5
4
  import { createGunzip, gzip } from "node:zlib";
6
5
  import { throwIfAborted } from "../sync/signals.js";
7
- import { assertSnapshotExcludesDebugLog, snapshotSelectionInclude, validateSnapshotSelection, } from "../sync/sync-policy.js";
8
- import { isIgnoreSnapshotVersion, isSupportedSnapshotVersion } from "./snapshot-types.js";
6
+ import { assertSnapshotExcludesDebugLog, requireLegacyTransferPolicy, validateSnapshotSelection, } from "../sync/sync-policy.js";
7
+ import { isSupportedSnapshotVersion } from "./snapshot-types.js";
9
8
  const VERSION = 1;
10
9
  const MAX_DECOMPRESSED_SNAPSHOT_BYTES = 512 * 1024 * 1024;
11
10
  const gzipAsync = promisify(gzip);
12
11
  export async function encodeSnapshot(snapshot) {
12
+ requireLegacyTransferPolicy(snapshot);
13
13
  if (!isSupportedSnapshotVersion(snapshot?.version))
14
14
  throw new Error("Unsupported snapshot format.");
15
15
  assertSnapshotExcludesDebugLog(snapshot);
16
- if (!isIgnoreSnapshotVersion(snapshot.version))
17
- snapshotSelectionInclude(snapshot);
18
16
  validateSnapshotSelection(snapshot);
19
- if (snapshot.version >= 4 || Object.hasOwn(snapshot, "ignoreRules")) {
17
+ if (snapshot.version >= 4) {
20
18
  const { validatePortableSnapshot } = await import("../sync/local-fields.js");
21
19
  validatePortableSnapshot(snapshot);
22
20
  }
@@ -42,14 +40,14 @@ export async function decodeSnapshot(buffer, options = {}) {
42
40
  throwIfAborted(options.signal);
43
41
  const payload = Buffer.concat(chunks, total);
44
42
  const parsed = JSON.parse(payload.toString("utf8"));
43
+ if (parsed && typeof parsed === "object")
44
+ requireLegacyTransferPolicy(parsed);
45
45
  if (!isSupportedSnapshotVersion(parsed?.version) || !Array.isArray(parsed.files)) {
46
46
  throw new Error("Unsupported snapshot format.");
47
47
  }
48
- if (isIgnoreSnapshotVersion(parsed.version) && !isUtf8(payload))
49
- throw new Error("Invalid snapshot UTF-8.");
50
48
  assertSnapshotExcludesDebugLog(parsed);
51
49
  validateSnapshotSelection(parsed);
52
- if (parsed.version !== VERSION || Object.hasOwn(parsed, "ignoreRules")) {
50
+ if (parsed.version !== VERSION) {
53
51
  const { normalizeLocalFields, validatePortableSnapshot } = await import("../sync/local-fields.js");
54
52
  validatePortableSnapshot(parsed);
55
53
  if (parsed.localFields !== undefined)
@@ -57,7 +55,5 @@ export async function decodeSnapshot(buffer, options = {}) {
57
55
  }
58
56
  else if (parsed.localFields !== undefined)
59
57
  throw new Error("Portable field policy requires snapshot version 2.");
60
- if (!isIgnoreSnapshotVersion(parsed.version))
61
- snapshotSelectionInclude(parsed);
62
58
  return parsed;
63
59
  }