@narumitw/pi-sync 0.61.0 → 0.63.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 (278) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +46 -25
  3. package/dist/chunks/{chunk-277VHM2P.ts → chunk-27F5W7DX.ts} +7 -3
  4. package/dist/chunks/chunk-27F5W7DX.ts.map +7 -0
  5. package/dist/chunks/{chunk-ZIL6PW5L.ts → chunk-6YKOHBSC.ts} +2 -2
  6. package/dist/chunks/{chunk-OA4NZLSL.ts → chunk-APZVJAEW.ts} +4 -3
  7. package/dist/chunks/chunk-CKUGCBHP.ts +114 -0
  8. package/dist/chunks/chunk-CKUGCBHP.ts.map +7 -0
  9. package/dist/chunks/chunk-EJDDRS6O.ts +17 -0
  10. package/dist/chunks/chunk-EJDDRS6O.ts.map +7 -0
  11. package/dist/chunks/{chunk-JVFCVPPD.ts → chunk-EXDWEFIJ.ts} +87 -147
  12. package/dist/chunks/chunk-EXDWEFIJ.ts.map +7 -0
  13. package/dist/chunks/{chunk-4SR3ZYHA.ts → chunk-GELYN4UC.ts} +2 -2
  14. package/dist/chunks/{chunk-2ZGV5KNC.ts → chunk-HSCAFOT5.ts} +15 -12
  15. package/dist/chunks/chunk-HSCAFOT5.ts.map +7 -0
  16. package/dist/chunks/{chunk-YQSFJLJ3.ts → chunk-IBXEM35O.ts} +4 -3
  17. package/dist/chunks/{chunk-2JHAN3ZO.ts → chunk-JREGWM2B.ts} +3 -3
  18. package/dist/chunks/chunk-MANNB4WZ.ts +36 -0
  19. package/dist/chunks/chunk-MANNB4WZ.ts.map +7 -0
  20. package/dist/chunks/{chunk-EMRFVLZM.ts → chunk-NXWHPVXR.ts} +2 -2
  21. package/dist/chunks/{chunk-SMVKMYLK.ts → chunk-P4GI7LTT.ts} +2 -2
  22. package/dist/chunks/{chunk-ZVGRZD4C.ts → chunk-R3SAMXB6.ts} +2 -2
  23. package/dist/chunks/{chunk-4KTJLJSJ.ts → chunk-S6FUUWV5.ts} +148 -21
  24. package/dist/chunks/chunk-S6FUUWV5.ts.map +7 -0
  25. package/dist/chunks/{chunk-PJMM75W5.ts → chunk-SXCH4Q5O.ts} +41 -23
  26. package/dist/chunks/chunk-SXCH4Q5O.ts.map +7 -0
  27. package/dist/chunks/{chunk-RNIEVDTR.ts → chunk-T3LABNHF.ts} +2 -2
  28. package/dist/chunks/{chunk-E3YLRLJM.ts → chunk-UGS6RYDZ.ts} +14 -12
  29. package/dist/chunks/chunk-UGS6RYDZ.ts.map +7 -0
  30. package/dist/chunks/{chunk-S3R3W3KF.ts → chunk-UMPA5S7X.ts} +2 -2
  31. package/dist/chunks/{chunk-EMVZL4PH.ts → chunk-V76KCWHO.ts} +7 -5
  32. package/dist/chunks/{chunk-EMVZL4PH.ts.map → chunk-V76KCWHO.ts.map} +1 -1
  33. package/dist/chunks/{chunk-S7F4FOAS.ts → chunk-VQ47JBLF.ts} +5 -5
  34. package/dist/chunks/{chunk-WP2M67XZ.ts → chunk-WBIOSK76.ts} +2 -2
  35. package/dist/chunks/chunk-WFBHWYI6.ts +18 -0
  36. package/dist/chunks/chunk-WFBHWYI6.ts.map +7 -0
  37. package/dist/chunks/{chunk-HEB6YT64.ts → chunk-ZO52JM4H.ts} +2 -2
  38. package/dist/chunks/{command-handler-K4XJOGYC.ts → command-handler-VINMQ7ZM.ts} +26 -43
  39. package/dist/chunks/command-handler-VINMQ7ZM.ts.map +7 -0
  40. package/dist/chunks/{conflict-review-IGKY2TOJ.ts → conflict-review-PCDFRIVB.ts} +4 -4
  41. package/dist/chunks/{continuous-record-3XDXDOMV.ts → continuous-record-3SKJ6I3V.ts} +2 -2
  42. package/dist/chunks/{continuous-storage-HLKCHF6Z.ts → continuous-storage-3EU6I7Z3.ts} +2 -2
  43. package/dist/chunks/{file-selection-MGGVOKM7.ts → file-selection-KID23GAD.ts} +21 -14
  44. package/dist/chunks/file-selection-KID23GAD.ts.map +7 -0
  45. package/dist/chunks/manager-result-dispatcher-GDB74IOP.ts +20 -0
  46. package/dist/chunks/{manager-ui-KYQ5AZJS.ts → manager-ui-YHDECYKI.ts} +454 -167
  47. package/dist/chunks/manager-ui-YHDECYKI.ts.map +7 -0
  48. package/dist/chunks/remote-selection-ui-GPITNEBF.ts +19 -0
  49. package/dist/chunks/{setup-switch-D6K6PBPC.ts → setup-switch-L54X5U5I.ts} +7 -7
  50. package/dist/chunks/{setup-wizard-4DYUDHJR.ts → setup-wizard-YO4MCPUF.ts} +15 -11
  51. package/dist/chunks/{setup-wizard-4DYUDHJR.ts.map → setup-wizard-YO4MCPUF.ts.map} +1 -1
  52. package/dist/chunks/{snapshot-5HY3M2NL.ts → snapshot-ZUJJZCFW.ts} +2 -2
  53. package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts → snapshot-transaction-directory-F46JWRAU.ts} +2 -2
  54. package/dist/chunks/{state-directory-XXHU73Z3.ts → state-directory-CMAIF34J.ts} +2 -2
  55. package/dist/chunks/{sync-inspection-J3CRBORL.ts → sync-inspection-H2WX5SUT.ts} +5 -5
  56. package/dist/chunks/{sync-operations-BVWYYKH3.ts → sync-operations-2MZAYHL2.ts} +13 -9
  57. package/dist/chunks/sync-operations-2MZAYHL2.ts.map +7 -0
  58. package/dist/chunks/{sync-state-2LMIXJ2C.ts → sync-state-QIT64TKV.ts} +2 -2
  59. package/dist/daemon/LICENSE +21 -0
  60. package/dist/daemon/dist/build-version.js +8 -0
  61. package/dist/daemon/dist/child-sdk.mjs +17 -0
  62. package/dist/daemon/dist/cli.js +169 -0
  63. package/dist/daemon/dist/client.js +909 -0
  64. package/dist/daemon/dist/consent.js +383 -0
  65. package/dist/daemon/dist/document.js +6 -0
  66. package/dist/daemon/dist/endpoint.js +91 -0
  67. package/dist/daemon/dist/engine/backends/backend-factory.js +16 -0
  68. package/dist/daemon/dist/engine/backends/backend-identity.js +38 -0
  69. package/dist/daemon/dist/engine/backends/backend-types.js +1 -0
  70. package/dist/daemon/dist/engine/backends/git/git-backend.js +746 -0
  71. package/dist/daemon/dist/engine/backends/git/git-config.js +118 -0
  72. package/dist/daemon/dist/engine/backends/git/git-runner.js +232 -0
  73. package/dist/daemon/dist/engine/backends/git/git-storage.js +252 -0
  74. package/dist/daemon/dist/engine/backends/s3/s3-backend.js +444 -0
  75. package/dist/daemon/dist/engine/backends/s3/s3-client.js +352 -0
  76. package/dist/daemon/dist/engine/backends/s3/s3-conditions.js +66 -0
  77. package/dist/daemon/dist/engine/backends/snapshot-pointer.js +22 -0
  78. package/dist/daemon/dist/engine/backends/sync-backend.js +23 -0
  79. package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +542 -0
  80. package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +326 -0
  81. package/dist/daemon/dist/engine/backends/webdav/webdav-config.js +73 -0
  82. package/dist/daemon/dist/engine/commands/command-types.js +1 -0
  83. package/dist/daemon/dist/engine/host.js +16 -0
  84. package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +33 -0
  85. package/dist/daemon/dist/engine/ignore/ignore-edit.js +102 -0
  86. package/dist/daemon/dist/engine/ignore/ignore-initialization.js +252 -0
  87. package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +139 -0
  88. package/dist/daemon/dist/engine/ignore/ignore-settings.js +393 -0
  89. package/dist/daemon/dist/engine/ignore/ignore-source.js +250 -0
  90. package/dist/daemon/dist/engine/paths.js +71 -0
  91. package/dist/daemon/dist/engine/settings/config-errors.js +4 -0
  92. package/dist/daemon/dist/engine/settings/config-file.js +736 -0
  93. package/dist/daemon/dist/engine/settings/config.js +344 -0
  94. package/dist/daemon/dist/engine/settings/settings-management.js +199 -0
  95. package/dist/daemon/dist/engine/settings/settings-store.js +41 -0
  96. package/dist/daemon/dist/engine/settings/settings-types.js +1 -0
  97. package/dist/daemon/dist/engine/settings/settings-validation.js +384 -0
  98. package/dist/daemon/dist/engine/snapshot/session-paths.js +165 -0
  99. package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +348 -0
  100. package/dist/daemon/dist/engine/snapshot/snapshot-bounds.js +20 -0
  101. package/dist/daemon/dist/engine/snapshot/snapshot-case-replacement.js +82 -0
  102. package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +61 -0
  103. package/dist/daemon/dist/engine/snapshot/snapshot-entry-projection.js +78 -0
  104. package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +262 -0
  105. package/dist/daemon/dist/engine/snapshot/snapshot-mutation-queues.js +133 -0
  106. package/dist/daemon/dist/engine/snapshot/snapshot-paths.js +11 -0
  107. package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +10 -0
  108. package/dist/daemon/dist/engine/snapshot/snapshot-reviewed-preimages.js +60 -0
  109. package/dist/daemon/dist/engine/snapshot/snapshot-root-transition.js +138 -0
  110. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-directory.js +16 -0
  111. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +387 -0
  112. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-plan.js +68 -0
  113. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +296 -0
  114. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-stage.js +303 -0
  115. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-verification.js +78 -0
  116. package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +855 -0
  117. package/dist/daemon/dist/engine/snapshot/snapshot-types.js +9 -0
  118. package/dist/daemon/dist/engine/snapshot/snapshot.js +678 -0
  119. package/dist/daemon/dist/engine/state/json-file.js +49 -0
  120. package/dist/daemon/dist/engine/state/lock-policy.js +2 -0
  121. package/dist/daemon/dist/engine/state/lock.js +259 -0
  122. package/dist/daemon/dist/engine/state/lockfile-fs.js +13 -0
  123. package/dist/daemon/dist/engine/state/merge-baseline-store.js +198 -0
  124. package/dist/daemon/dist/engine/state/mutation-directory-sync.js +34 -0
  125. package/dist/daemon/dist/engine/state/operation-availability.js +40 -0
  126. package/dist/daemon/dist/engine/state/state-directory.js +227 -0
  127. package/dist/daemon/dist/engine/state/state-types.js +1 -0
  128. package/dist/daemon/dist/engine/state/sync-state-store.js +54 -0
  129. package/dist/daemon/dist/engine/sync/agent-candidate.js +207 -0
  130. package/dist/daemon/dist/engine/sync/agent-plan.js +85 -0
  131. package/dist/daemon/dist/engine/sync/agent-policy.js +10 -0
  132. package/dist/daemon/dist/engine/sync/agent-refusal-retry.js +39 -0
  133. package/dist/daemon/dist/engine/sync/agent-request.js +13 -0
  134. package/dist/daemon/dist/engine/sync/agent-runner.js +183 -0
  135. package/dist/daemon/dist/engine/sync/agent-store.js +177 -0
  136. package/dist/daemon/dist/engine/sync/agent-sync.js +139 -0
  137. package/dist/daemon/dist/engine/sync/apply-review.js +52 -0
  138. package/dist/daemon/dist/engine/sync/conflict-artifact-ownership.js +53 -0
  139. package/dist/daemon/dist/engine/sync/conflict-artifacts.js +158 -0
  140. package/dist/daemon/dist/engine/sync/conflict-groups.js +76 -0
  141. package/dist/daemon/dist/engine/sync/conflict-preview.js +53 -0
  142. package/dist/daemon/dist/engine/sync/conflict-resolution.js +53 -0
  143. package/dist/daemon/dist/engine/sync/conflict-retention.js +61 -0
  144. package/dist/daemon/dist/engine/sync/conflict-review.js +73 -0
  145. package/dist/daemon/dist/engine/sync/content-conflicts.js +70 -0
  146. package/dist/daemon/dist/engine/sync/continuous-errors.js +66 -0
  147. package/dist/daemon/dist/engine/sync/continuous-lease.js +206 -0
  148. package/dist/daemon/dist/engine/sync/continuous-record.js +199 -0
  149. package/dist/daemon/dist/engine/sync/continuous-storage.js +59 -0
  150. package/dist/daemon/dist/engine/sync/continuous-sync.js +538 -0
  151. package/dist/daemon/dist/engine/sync/continuous-watch.js +140 -0
  152. package/dist/daemon/dist/engine/sync/exclude-policy.js +86 -0
  153. package/dist/daemon/dist/engine/sync/field-migration.js +20 -0
  154. package/dist/daemon/dist/engine/sync/file-merge-planner.js +123 -0
  155. package/dist/daemon/dist/engine/sync/initialization.js +80 -0
  156. package/dist/daemon/dist/engine/sync/json-document.js +172 -0
  157. package/dist/daemon/dist/engine/sync/local-field-policy.js +26 -0
  158. package/dist/daemon/dist/engine/sync/local-fields.js +196 -0
  159. package/dist/daemon/dist/engine/sync/merge-acceptance.js +29 -0
  160. package/dist/daemon/dist/engine/sync/merge-apply.js +532 -0
  161. package/dist/daemon/dist/engine/sync/merge-journal.js +314 -0
  162. package/dist/daemon/dist/engine/sync/merge-transfer-error.js +64 -0
  163. package/dist/daemon/dist/engine/sync/merged-sync.js +666 -0
  164. package/dist/daemon/dist/engine/sync/mutation-owner.js +18 -0
  165. package/dist/daemon/dist/engine/sync/package-merge.js +82 -0
  166. package/dist/daemon/dist/engine/sync/partial-progress.js +41 -0
  167. package/dist/daemon/dist/engine/sync/remote-snapshot.js +119 -0
  168. package/dist/daemon/dist/engine/sync/resolver-stream.js +34 -0
  169. package/dist/daemon/dist/engine/sync/session-merge.js +178 -0
  170. package/dist/daemon/dist/engine/sync/session-push.js +47 -0
  171. package/dist/daemon/dist/engine/sync/settings-conflicts.js +56 -0
  172. package/dist/daemon/dist/engine/sync/settings-merge.js +93 -0
  173. package/dist/daemon/dist/engine/sync/signals.js +8 -0
  174. package/dist/daemon/dist/engine/sync/startup-timings.js +44 -0
  175. package/dist/daemon/dist/engine/sync/sync-decision.js +81 -0
  176. package/dist/daemon/dist/engine/sync/sync-error-guidance.js +55 -0
  177. package/dist/daemon/dist/engine/sync/sync-errors.js +18 -0
  178. package/dist/daemon/dist/engine/sync/sync-inspection.js +42 -0
  179. package/dist/daemon/dist/engine/sync/sync-loaders.js +8 -0
  180. package/dist/daemon/dist/engine/sync/sync-local.js +40 -0
  181. package/dist/daemon/dist/engine/sync/sync-mutations.js +754 -0
  182. package/dist/daemon/dist/engine/sync/sync-operations.js +3 -0
  183. package/dist/daemon/dist/engine/sync/sync-policy.js +646 -0
  184. package/dist/daemon/dist/engine/sync/sync-queries.js +212 -0
  185. package/dist/daemon/dist/engine/sync/sync-state.js +124 -0
  186. package/dist/daemon/dist/engine/sync/text-merge.js +124 -0
  187. package/dist/daemon/dist/engine/sync/transfer-freshness.js +82 -0
  188. package/dist/daemon/dist/engine/types.js +2 -0
  189. package/dist/daemon/dist/engine/ui/merge-review.js +7 -0
  190. package/dist/daemon/dist/engine/ui/merged-sync-summary.js +86 -0
  191. package/dist/daemon/dist/engine/ui/sync-format.js +165 -0
  192. package/dist/daemon/dist/engine/ui/sync-status.js +30 -0
  193. package/dist/daemon/dist/engine/ui/terminal-text.js +9 -0
  194. package/dist/daemon/dist/engine/ui/transfer-changes.js +24 -0
  195. package/dist/daemon/dist/engine/ui/transfer-review.js +19 -0
  196. package/dist/daemon/dist/engine-service.js +441 -0
  197. package/dist/daemon/dist/identity.js +241 -0
  198. package/dist/daemon/dist/idle-exit.js +77 -0
  199. package/dist/daemon/dist/index.js +4 -0
  200. package/dist/daemon/dist/lifecycle-log.js +53 -0
  201. package/dist/daemon/dist/lifecycle.js +21 -0
  202. package/dist/daemon/dist/model-signature.js +7 -0
  203. package/dist/daemon/dist/monitor.js +324 -0
  204. package/dist/daemon/dist/participant-admission.js +30 -0
  205. package/dist/daemon/dist/protocol.js +104 -0
  206. package/dist/daemon/dist/resolver-host.js +78 -0
  207. package/dist/daemon/dist/server.js +994 -0
  208. package/dist/daemon/dist/service-host.js +175 -0
  209. package/dist/daemon/dist/upgrade-repair.js +55 -0
  210. package/dist/daemon/package.json +3 -0
  211. package/dist/index.ts +40 -37
  212. package/dist/index.ts.map +4 -4
  213. package/dist/package.json +6 -0
  214. package/docs/daemon-migration.md +27 -16
  215. package/package.json +9 -3
  216. package/skills/configure-pi-sync/SKILL.md +24 -46
  217. package/skills/configure-pi-sync/references/configuration.md +62 -22
  218. package/src/commands/command-execution.ts +13 -9
  219. package/src/commands/command-types.ts +1 -0
  220. package/src/daemon/pi-client.ts +4 -2
  221. package/src/settings/config.ts +2 -0
  222. package/src/sync/automatic-sync.ts +9 -2
  223. package/src/sync/setup-switch.ts +38 -15
  224. package/src/sync/startup-check.ts +7 -4
  225. package/src/sync/sync-operations.ts +18 -10
  226. package/src/ui/excluded-paths-ui.ts +6 -3
  227. package/src/ui/file-selection.ts +7 -2
  228. package/src/ui/ignore-file-guidance.ts +7 -0
  229. package/src/ui/ignore-file-ui.ts +97 -0
  230. package/src/ui/ignore-migration-prompt.ts +65 -0
  231. package/src/ui/manager-state.ts +40 -14
  232. package/src/ui/manager-ui.ts +41 -19
  233. package/src/ui/remote-selection-ui.ts +88 -28
  234. package/src/ui/settings-review.ts +26 -0
  235. package/src/ui/settings-ui.ts +378 -224
  236. package/src/ui/setup/setup-actions.ts +16 -4
  237. package/src/ui/setup/setup-prompts.ts +55 -9
  238. package/src/ui/setup/setup-switcher.ts +24 -11
  239. package/src/ui/storage-connections-ui.ts +50 -20
  240. package/src/ui/sync-setups-ui.ts +65 -30
  241. package/dist/chunks/chunk-277VHM2P.ts.map +0 -7
  242. package/dist/chunks/chunk-2ZGV5KNC.ts.map +0 -7
  243. package/dist/chunks/chunk-4KTJLJSJ.ts.map +0 -7
  244. package/dist/chunks/chunk-E3YLRLJM.ts.map +0 -7
  245. package/dist/chunks/chunk-ECYCNZOE.ts +0 -12
  246. package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
  247. package/dist/chunks/chunk-JVFCVPPD.ts.map +0 -7
  248. package/dist/chunks/chunk-PJMM75W5.ts.map +0 -7
  249. package/dist/chunks/command-handler-K4XJOGYC.ts.map +0 -7
  250. package/dist/chunks/file-selection-MGGVOKM7.ts.map +0 -7
  251. package/dist/chunks/manager-result-dispatcher-4VJVDEUD.ts +0 -19
  252. package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +0 -7
  253. package/dist/chunks/remote-selection-ui-W3KOZM3W.ts +0 -18
  254. package/dist/chunks/sync-operations-BVWYYKH3.ts.map +0 -7
  255. /package/dist/chunks/{chunk-ZIL6PW5L.ts.map → chunk-6YKOHBSC.ts.map} +0 -0
  256. /package/dist/chunks/{chunk-OA4NZLSL.ts.map → chunk-APZVJAEW.ts.map} +0 -0
  257. /package/dist/chunks/{chunk-4SR3ZYHA.ts.map → chunk-GELYN4UC.ts.map} +0 -0
  258. /package/dist/chunks/{chunk-YQSFJLJ3.ts.map → chunk-IBXEM35O.ts.map} +0 -0
  259. /package/dist/chunks/{chunk-2JHAN3ZO.ts.map → chunk-JREGWM2B.ts.map} +0 -0
  260. /package/dist/chunks/{chunk-EMRFVLZM.ts.map → chunk-NXWHPVXR.ts.map} +0 -0
  261. /package/dist/chunks/{chunk-SMVKMYLK.ts.map → chunk-P4GI7LTT.ts.map} +0 -0
  262. /package/dist/chunks/{chunk-ZVGRZD4C.ts.map → chunk-R3SAMXB6.ts.map} +0 -0
  263. /package/dist/chunks/{chunk-RNIEVDTR.ts.map → chunk-T3LABNHF.ts.map} +0 -0
  264. /package/dist/chunks/{chunk-S3R3W3KF.ts.map → chunk-UMPA5S7X.ts.map} +0 -0
  265. /package/dist/chunks/{chunk-S7F4FOAS.ts.map → chunk-VQ47JBLF.ts.map} +0 -0
  266. /package/dist/chunks/{chunk-WP2M67XZ.ts.map → chunk-WBIOSK76.ts.map} +0 -0
  267. /package/dist/chunks/{chunk-HEB6YT64.ts.map → chunk-ZO52JM4H.ts.map} +0 -0
  268. /package/dist/chunks/{conflict-review-IGKY2TOJ.ts.map → conflict-review-PCDFRIVB.ts.map} +0 -0
  269. /package/dist/chunks/{continuous-record-3XDXDOMV.ts.map → continuous-record-3SKJ6I3V.ts.map} +0 -0
  270. /package/dist/chunks/{continuous-storage-HLKCHF6Z.ts.map → continuous-storage-3EU6I7Z3.ts.map} +0 -0
  271. /package/dist/chunks/{manager-result-dispatcher-4VJVDEUD.ts.map → manager-result-dispatcher-GDB74IOP.ts.map} +0 -0
  272. /package/dist/chunks/{remote-selection-ui-W3KOZM3W.ts.map → remote-selection-ui-GPITNEBF.ts.map} +0 -0
  273. /package/dist/chunks/{setup-switch-D6K6PBPC.ts.map → setup-switch-L54X5U5I.ts.map} +0 -0
  274. /package/dist/chunks/{snapshot-5HY3M2NL.ts.map → snapshot-ZUJJZCFW.ts.map} +0 -0
  275. /package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts.map → snapshot-transaction-directory-F46JWRAU.ts.map} +0 -0
  276. /package/dist/chunks/{state-directory-XXHU73Z3.ts.map → state-directory-CMAIF34J.ts.map} +0 -0
  277. /package/dist/chunks/{sync-inspection-J3CRBORL.ts.map → sync-inspection-H2WX5SUT.ts.map} +0 -0
  278. /package/dist/chunks/{sync-state-2LMIXJ2C.ts.map → sync-state-QIT64TKV.ts.map} +0 -0
@@ -0,0 +1,326 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+ import { ContinuousError, continuousFailure, retryAfter } from "../../sync/continuous-errors.js";
3
+ import { throwIfAborted } from "../../sync/signals.js";
4
+ const JSON_LIMIT = 1024 * 1024;
5
+ const ERROR_LIMIT = 64 * 1024;
6
+ const SNAPSHOT_LIMIT = 256 * 1024 * 1024;
7
+ const XML_LIMIT = 1024 * 1024;
8
+ const REQUEST_TIMEOUT_MS = 30_000;
9
+ const MAX_REDIRECTS = 3;
10
+ export class WebDavHttpError extends Error {
11
+ status;
12
+ retryAfterMs;
13
+ constructor(message, status, options, retryAfterMs) {
14
+ super(message, options);
15
+ this.status = status;
16
+ this.retryAfterMs = retryAfterMs;
17
+ this.name = "WebDavHttpError";
18
+ }
19
+ }
20
+ export class WebDavPreconditionError extends WebDavHttpError {
21
+ constructor(message = "WebDAV precondition failed.") {
22
+ super(message, 412);
23
+ this.name = "WebDavPreconditionError";
24
+ }
25
+ }
26
+ export class WebDavClient {
27
+ config;
28
+ signal;
29
+ timeoutMs;
30
+ baseUrl;
31
+ authorization;
32
+ constructor(config, signal, timeoutMs = REQUEST_TIMEOUT_MS) {
33
+ this.config = config;
34
+ this.signal = signal;
35
+ this.timeoutMs = timeoutMs;
36
+ this.baseUrl = new URL(config.profile.url);
37
+ assertSafeAuthenticatedUrl(this.baseUrl);
38
+ if (!config.profile.username ||
39
+ !config.profile.password ||
40
+ config.profile.username.includes(":") ||
41
+ hasControlCharacter(config.profile.username) ||
42
+ hasControlCharacter(config.profile.password)) {
43
+ throw new Error("Invalid WebDAV credentials.");
44
+ }
45
+ this.authorization = `Basic ${Buffer.from(`${config.profile.username}:${config.profile.password}`).toString("base64")}`;
46
+ }
47
+ async getBuffer(remotePath) {
48
+ const response = await this.request(remotePath, { method: "GET" });
49
+ if (response.status === 404) {
50
+ await response.body?.cancel();
51
+ return { missing: true };
52
+ }
53
+ await this.requireOk(response, "read");
54
+ return {
55
+ value: await readBounded(response, SNAPSHOT_LIMIT, "WebDAV response is too large"),
56
+ etag: response.headers.get("etag") ?? undefined,
57
+ missing: false,
58
+ };
59
+ }
60
+ async getJson(remotePath) {
61
+ const response = await this.request(remotePath, { method: "GET" });
62
+ if (response.status === 404) {
63
+ await response.body?.cancel();
64
+ return { missing: true };
65
+ }
66
+ await this.requireOk(response, "read");
67
+ const bytes = await readBounded(response, JSON_LIMIT, "WebDAV JSON response is too large");
68
+ try {
69
+ return {
70
+ value: JSON.parse(bytes.toString("utf8")),
71
+ etag: response.headers.get("etag") ?? undefined,
72
+ missing: false,
73
+ };
74
+ }
75
+ catch (error) {
76
+ throw new Error("WebDAV JSON response is malformed.", { cause: error });
77
+ }
78
+ }
79
+ async putBuffer(remotePath, body, contentType, options = {}) {
80
+ const headers = { "content-type": contentType };
81
+ if (options.ifAbsent)
82
+ headers["if-none-match"] = "*";
83
+ if (options.ifMatch)
84
+ headers["if-match"] = options.ifMatch;
85
+ const response = await this.request(remotePath, {
86
+ method: "PUT",
87
+ headers,
88
+ body: body,
89
+ });
90
+ if (response.status === 412) {
91
+ await response.body?.cancel();
92
+ throw new WebDavPreconditionError();
93
+ }
94
+ await this.requireOk(response, "write");
95
+ await response.body?.cancel();
96
+ return response.headers.get("etag") ?? undefined;
97
+ }
98
+ async putJson(remotePath, value, options = {}) {
99
+ return this.putBuffer(remotePath, Buffer.from(JSON.stringify(value)), "application/json", options);
100
+ }
101
+ async makeCollection(remotePath) {
102
+ const response = await this.request(remotePath, { method: "MKCOL" });
103
+ if (response.status === 405) {
104
+ await response.body?.cancel();
105
+ return false;
106
+ }
107
+ await this.requireOk(response, "create collection");
108
+ await response.body?.cancel();
109
+ return true;
110
+ }
111
+ async ensureCollection(remotePath) {
112
+ const segments = safeSegments(remotePath);
113
+ for (let index = 1; index <= segments.length; index += 1) {
114
+ await this.makeCollection(segments.slice(0, index).join("/"));
115
+ }
116
+ }
117
+ async listCollection(remotePath) {
118
+ const response = await this.request(remotePath, {
119
+ method: "PROPFIND",
120
+ headers: { depth: "1", "content-type": "application/xml; charset=utf-8" },
121
+ body: '<?xml version="1.0"?><d:propfind xmlns:d="DAV:"><d:prop><d:getetag/><d:resourcetype/></d:prop></d:propfind>',
122
+ });
123
+ if (response.status === 404) {
124
+ await response.body?.cancel();
125
+ throw new WebDavHttpError("WebDAV collection is missing.", 404);
126
+ }
127
+ if (response.status !== 207)
128
+ await this.requireOk(response, "list collection");
129
+ const xml = (await readBounded(response, XML_LIMIT, "WebDAV directory response is too large")).toString("utf8");
130
+ try {
131
+ const parsed = new XMLParser({
132
+ removeNSPrefix: true,
133
+ ignoreAttributes: false,
134
+ processEntities: false,
135
+ }).parse(xml);
136
+ if (!parsed.multistatus || parsed.multistatus.response === undefined) {
137
+ throw new Error("Missing DAV multistatus response.");
138
+ }
139
+ const responses = asArray(parsed.multistatus.response);
140
+ return responses.map(parseEntry);
141
+ }
142
+ catch (error) {
143
+ throw new Error("WebDAV directory response is malformed.", { cause: error });
144
+ }
145
+ }
146
+ async delete(remotePath) {
147
+ const response = await this.request(remotePath, { method: "DELETE" });
148
+ if (response.status === 404) {
149
+ await response.body?.cancel();
150
+ return;
151
+ }
152
+ if (response.status === 207) {
153
+ await response.body?.cancel();
154
+ throw new WebDavHttpError("WebDAV probe cleanup returned a partial response.", 207);
155
+ }
156
+ await this.requireOk(response, "delete probe resource");
157
+ await response.body?.cancel();
158
+ }
159
+ async request(remotePath, init) {
160
+ throwIfAborted(this.signal);
161
+ let url = appendRemotePath(this.baseUrl, remotePath);
162
+ for (let redirects = 0;; redirects += 1) {
163
+ const timeout = AbortSignal.timeout(this.timeoutMs);
164
+ const signal = this.signal ? AbortSignal.any([this.signal, timeout]) : timeout;
165
+ let response;
166
+ try {
167
+ response = await fetch(url, {
168
+ ...init,
169
+ headers: {
170
+ accept: "*/*",
171
+ authorization: this.authorization,
172
+ ...headersObject(init.headers),
173
+ },
174
+ redirect: "manual",
175
+ signal,
176
+ });
177
+ }
178
+ catch (error) {
179
+ throwIfAborted(this.signal);
180
+ throw new Error(`WebDAV ${String(init.method ?? "GET")} request failed for ${redactText(safeUrl(url), this.config)}.`, {
181
+ cause: redactError(error, this.config),
182
+ });
183
+ }
184
+ if (![301, 302, 303, 307, 308].includes(response.status))
185
+ return response;
186
+ await response.body?.cancel();
187
+ const method = String(init.method ?? "GET").toUpperCase();
188
+ if ([301, 302, 303].includes(response.status) && method !== "GET" && method !== "HEAD") {
189
+ throw new Error(`WebDAV refused an ambiguous HTTP ${response.status} redirect for ${method}; configure the canonical collection URL or require HTTP 307/308.`);
190
+ }
191
+ if (redirects >= MAX_REDIRECTS)
192
+ throw new Error("WebDAV redirect limit exceeded.");
193
+ const location = response.headers.get("location");
194
+ if (!location)
195
+ throw new Error("WebDAV redirect is missing Location.");
196
+ const next = new URL(location, url);
197
+ if (next.origin !== this.baseUrl.origin) {
198
+ throw new Error("WebDAV refused a cross-origin authenticated redirect.");
199
+ }
200
+ url = next;
201
+ }
202
+ }
203
+ async requireOk(response, action) {
204
+ if (response.ok)
205
+ return;
206
+ const body = (await readBounded(response, ERROR_LIMIT, "WebDAV error body is too large"))
207
+ .toString("utf8")
208
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: Remote error text is untrusted terminal input.
209
+ .replace(/[\u0000-\u001f\u007f-\u009f]/gu, " ")
210
+ .trim();
211
+ const detail = body ? `: ${redactText(body, this.config)}` : "";
212
+ throw new WebDavHttpError(`WebDAV ${action} failed with HTTP ${response.status}${detail}`, response.status, undefined, retryAfter(response));
213
+ }
214
+ }
215
+ function assertSafeAuthenticatedUrl(url) {
216
+ const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "[::1]" || url.hostname === "::1";
217
+ if (url.username ||
218
+ url.password ||
219
+ url.search ||
220
+ url.hash ||
221
+ (url.protocol !== "https:" && !(url.protocol === "http:" && loopback))) {
222
+ throw new Error("Invalid WebDAV URL: HTTPS is required and embedded credentials, query, or fragment are not allowed.");
223
+ }
224
+ }
225
+ function hasControlCharacter(value) {
226
+ return [...value].some((character) => {
227
+ const code = character.codePointAt(0) ?? 0;
228
+ return code < 0x20 || (code >= 0x7f && code <= 0x9f);
229
+ });
230
+ }
231
+ function appendRemotePath(base, remotePath) {
232
+ const url = new URL(base);
233
+ const suffix = safeSegments(remotePath).map(encodeURIComponent).join("/");
234
+ url.pathname = `${base.pathname.replace(/\/+$/u, "")}/${suffix}`;
235
+ return url;
236
+ }
237
+ function safeSegments(value) {
238
+ const segments = value
239
+ .replace(/^\/+|\/+$/gu, "")
240
+ .split("/")
241
+ .filter(Boolean);
242
+ if (segments.some((segment) => segment === "." ||
243
+ segment === ".." ||
244
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: Remote path segments cannot contain controls.
245
+ /[\u0000-\u001f]/u.test(segment))) {
246
+ throw new Error("Invalid WebDAV remote path.");
247
+ }
248
+ return segments;
249
+ }
250
+ async function readBounded(response, limit, message) {
251
+ const length = Number(response.headers.get("content-length"));
252
+ if (Number.isFinite(length) && length > limit) {
253
+ await response.body?.cancel();
254
+ throw new Error(message);
255
+ }
256
+ if (!response.body)
257
+ return Buffer.alloc(0);
258
+ const reader = response.body.getReader();
259
+ const chunks = [];
260
+ let total = 0;
261
+ try {
262
+ while (true) {
263
+ const { done, value } = await reader.read();
264
+ if (done)
265
+ break;
266
+ total += value.byteLength;
267
+ if (total > limit)
268
+ throw new Error(message);
269
+ chunks.push(Buffer.from(value));
270
+ }
271
+ }
272
+ catch (error) {
273
+ await reader.cancel().catch(() => undefined);
274
+ throw error;
275
+ }
276
+ return Buffer.concat(chunks, total);
277
+ }
278
+ function parseEntry(value) {
279
+ if (!value || typeof value !== "object")
280
+ throw new Error("Invalid WebDAV response entry.");
281
+ const record = value;
282
+ const href = typeof record.href === "string" ? record.href : undefined;
283
+ if (!href)
284
+ throw new Error("Invalid WebDAV response href.");
285
+ const propstat = asArray(record.propstat).find((item) => {
286
+ if (!item || typeof item !== "object")
287
+ return false;
288
+ return String(item.status ?? "").includes(" 200 ");
289
+ });
290
+ const prop = propstat?.prop;
291
+ return {
292
+ href,
293
+ etag: typeof prop?.getetag === "string" ? prop.getetag : undefined,
294
+ collection: !!prop?.resourcetype && typeof prop.resourcetype === "object" && Object.hasOwn(prop.resourcetype, "collection"),
295
+ };
296
+ }
297
+ function asArray(value) {
298
+ if (value === undefined)
299
+ return [];
300
+ return Array.isArray(value) ? value : [value];
301
+ }
302
+ function headersObject(headers) {
303
+ return Object.fromEntries(new Headers(headers).entries());
304
+ }
305
+ function safeUrl(url) {
306
+ return `${url.protocol}//${url.host}${url.pathname}`;
307
+ }
308
+ function redactError(error, config) {
309
+ const message = error instanceof Error ? error.message : String(error);
310
+ const failure = continuousFailure(error);
311
+ return new ContinuousError(failure.kind, redactText(message, config), failure.delay);
312
+ }
313
+ function redactText(value, config) {
314
+ let result = value;
315
+ for (const secret of [config.profile.username, config.profile.password, config.profile.url]) {
316
+ if (!secret)
317
+ continue;
318
+ for (const variant of new Set([secret, encodeURIComponent(secret)])) {
319
+ result = result.replace(new RegExp(escapeRegExp(variant), "giu"), "[redacted]");
320
+ }
321
+ }
322
+ return result.replace(/basic\s+[a-z0-9+/=]+/giu, "Basic [redacted]").replace(/\?[^\s]*/gu, "?[redacted]");
323
+ }
324
+ function escapeRegExp(value) {
325
+ return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
326
+ }
@@ -0,0 +1,73 @@
1
+ const DEFAULT_PATH = "pi-sync";
2
+ export function normalizeWebDavIdentityUrl(value) {
3
+ try {
4
+ const url = new URL(value.trim());
5
+ url.username = "";
6
+ url.password = "";
7
+ url.search = "";
8
+ url.hash = "";
9
+ url.pathname = `${url.pathname.replace(/\/+$/u, "")}/`;
10
+ return url.toString();
11
+ }
12
+ catch {
13
+ return value.trim();
14
+ }
15
+ }
16
+ export function normalizeWebDavUrl(value) {
17
+ const normalized = normalizeOptionalString(value);
18
+ if (!normalized)
19
+ return undefined;
20
+ let url;
21
+ try {
22
+ url = new URL(normalized);
23
+ }
24
+ catch {
25
+ throw new Error("Invalid pi-sync WebDAV URL.");
26
+ }
27
+ if (url.username || url.password || url.search || url.hash) {
28
+ throw new Error("Invalid pi-sync WebDAV URL: credentials, query, and fragment are not allowed.");
29
+ }
30
+ const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "[::1]" || url.hostname === "::1";
31
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) {
32
+ throw new Error("Invalid pi-sync WebDAV URL: HTTPS is required except for loopback.");
33
+ }
34
+ url.pathname = `${url.pathname.replace(/\/+$/u, "")}/`;
35
+ return url.toString();
36
+ }
37
+ export function normalizeWebDavPath(value) {
38
+ if (value?.trim() === "." || value?.trim() === "./")
39
+ return "./";
40
+ const normalized = trimSlashes(normalizeOptionalString(value) ?? DEFAULT_PATH);
41
+ if (!normalized ||
42
+ normalized.includes("\\") ||
43
+ hasControlCharacter(normalized) ||
44
+ normalized.split("/").some((segment) => !segment || segment === "." || segment === "..")) {
45
+ throw new Error("Invalid pi-sync WebDAV path.");
46
+ }
47
+ return normalized;
48
+ }
49
+ export function validateWebDavNamespace(value) {
50
+ if (value === "." || value === ".." || value.includes("/") || value.includes("\\") || hasControlCharacter(value)) {
51
+ throw new Error("Invalid pi-sync WebDAV namespace.");
52
+ }
53
+ }
54
+ export function validateWebDavCredentials(username, password) {
55
+ if (username.includes(":") ||
56
+ hasControlCharacter(username) ||
57
+ (password !== undefined && hasControlCharacter(password))) {
58
+ throw new Error("Invalid pi-sync WebDAV credentials.");
59
+ }
60
+ }
61
+ function normalizeOptionalString(value) {
62
+ const normalized = value?.trim();
63
+ return normalized || undefined;
64
+ }
65
+ function trimSlashes(value) {
66
+ return value.replace(/^\/+|\/+$/gu, "");
67
+ }
68
+ function hasControlCharacter(value) {
69
+ return [...value].some((character) => {
70
+ const code = character.codePointAt(0) ?? 0;
71
+ return code < 0x20 || (code >= 0x7f && code <= 0x9f);
72
+ });
73
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ let host;
2
+ /** One explicit host per process. A daemon process serves exactly one canonical root. */
3
+ export function configureEngineHost(value) {
4
+ host = value;
5
+ }
6
+ export function engineHost() {
7
+ if (!host)
8
+ throw new Error("Synchronization engine host is not configured.");
9
+ return host;
10
+ }
11
+ export function getEngineRoot() {
12
+ return engineHost().root();
13
+ }
14
+ export function withEngineMutationQueue(target, action) {
15
+ return engineHost().mutate(target, action);
16
+ }
@@ -0,0 +1,33 @@
1
+ import { compileIgnoreRules, DEFAULT_IGNORE_FILENAME, ignorePolicyFingerprint, readIgnoreSource, validateIgnoreFilename, } from "./ignore-source.js";
2
+ function reservedNames(filename, configuredFilenames) {
3
+ return [
4
+ ...new Set([DEFAULT_IGNORE_FILENAME, filename, ...configuredFilenames].map((name) => validateIgnoreFilename(name).toLowerCase())),
5
+ ].sort();
6
+ }
7
+ export async function loadEffectiveIgnorePolicy(root, input, signal) {
8
+ const source = await readIgnoreSource(root, input.filename, signal);
9
+ signal?.throwIfAborted();
10
+ return compileEffectiveIgnorePolicy(source, input);
11
+ }
12
+ export function compileEffectiveIgnorePolicy(source, input) {
13
+ return {
14
+ filename: source.filename,
15
+ sourceDigest: source.sourceDigest,
16
+ fingerprint: ignorePolicyFingerprint(source.text, input.sessions),
17
+ sessions: input.sessions,
18
+ reservedNames: reservedNames(source.filename, input.configuredFilenames),
19
+ matches: compileIgnoreRules(source.text),
20
+ };
21
+ }
22
+ export async function requireUnchangedIgnorePolicy(root, reviewed, current, signal) {
23
+ const source = await readIgnoreSource(root, current.filename, signal);
24
+ signal?.throwIfAborted();
25
+ const currentNames = reservedNames(source.filename, current.configuredFilenames);
26
+ if (reviewed.filename !== source.filename ||
27
+ reviewed.sourceDigest !== source.sourceDigest ||
28
+ reviewed.sessions !== current.sessions ||
29
+ reviewed.reservedNames.length !== currentNames.length ||
30
+ reviewed.reservedNames.some((name, index) => name !== currentNames[index])) {
31
+ throw new Error("Pi Sync ignore policy changed; reopen the review before continuing.");
32
+ }
33
+ }
@@ -0,0 +1,102 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstatSync, statSync } from "node:fs";
3
+ import path from "node:path";
4
+ import { record } from "../../protocol.js";
5
+ import { getEngineRoot } from "../host.js";
6
+ import { withLockedLocalConfigDocument } from "../settings/config-file.js";
7
+ import { validateConfigName, validateSettingsDocument } from "../settings/settings-validation.js";
8
+ import { compileIgnoreRules, DEFAULT_IGNORE_CREATION_RECORD, DEFAULT_IGNORE_FILENAME, ignoreFileIdentity, readIgnoreSource, sameFile, } from "./ignore-source.js";
9
+ function locateIgnoreFile(document, root, setup) {
10
+ const settings = document && validateSettingsDocument(document.parsed);
11
+ const current = settings && Object.hasOwn(settings.syncSetups, setup) ? settings.syncSetups[setup] : undefined;
12
+ if (!current)
13
+ throw new Error("Sync setup no longer exists; reopen ignore-file settings.");
14
+ if (settings?.version !== 8 || current.sync.scope !== "agent-directory" || current.sync.pathPolicy !== "ignore-file")
15
+ throw new Error("This sync setup does not use an ignore file.");
16
+ const filename = current.sync.ignoreFile ?? DEFAULT_IGNORE_FILENAME;
17
+ return {
18
+ filename,
19
+ path: path.join(root, filename),
20
+ sharingSetups: Object.entries(settings.syncSetups)
21
+ .filter(([name, { sync }]) => name !== setup &&
22
+ sync.scope === "agent-directory" &&
23
+ sync.pathPolicy === "ignore-file" &&
24
+ (sync.ignoreFile ?? DEFAULT_IGNORE_FILENAME) === filename)
25
+ .map(([name]) => name)
26
+ .sort(),
27
+ };
28
+ }
29
+ function statAt(target) {
30
+ return lstatSync(target, { bigint: true, throwIfNoEntry: false });
31
+ }
32
+ function stale(target) {
33
+ throw new Error(`Ignore file changed or disappeared at "${target}"; reopen ignore-file settings.`);
34
+ }
35
+ function assertCurrent(target, expected) {
36
+ const current = statAt(target);
37
+ if (expected ? !current || !sameFile(expected, current) : current)
38
+ stale(target);
39
+ }
40
+ function validateTarget(execution, location) {
41
+ execution.validate();
42
+ const root = getEngineRoot();
43
+ if (location.filename === DEFAULT_IGNORE_FILENAME && statAt(path.join(root, DEFAULT_IGNORE_CREATION_RECORD))) {
44
+ throw new Error(`Ignore file "${location.path}" has an unfinished creation record; repair it before editing.`);
45
+ }
46
+ const target = statAt(location.path);
47
+ if (target &&
48
+ execution.liveClients().some(({ sessionFile }) => {
49
+ const session = sessionFile && statSync(sessionFile, { bigint: true, throwIfNoEntry: false });
50
+ return session && target.dev === session.dev && target.ino === session.ino;
51
+ }))
52
+ throw new Error(`Ignore file "${location.path}" is a protected live session.`);
53
+ return { root, target };
54
+ }
55
+ function editorDigest(setup, location, sourceDigest) {
56
+ return createHash("sha256")
57
+ .update(JSON.stringify(["pi-sync-ignore-editor-v1", setup, sourceDigest, location.sharingSetups]))
58
+ .digest("hex");
59
+ }
60
+ async function loadEditorSource(setup, location, execution) {
61
+ const { root, target: stat } = validateTarget(execution, location);
62
+ if (!stat)
63
+ return { location };
64
+ try {
65
+ const source = await readIgnoreSource(root, location.filename, execution.signal);
66
+ validateTarget(execution, location);
67
+ assertCurrent(location.path, stat);
68
+ if (!source.present || source.identity !== ignoreFileIdentity(stat))
69
+ stale(location.path);
70
+ compileIgnoreRules(source.text);
71
+ const { text, identity } = source;
72
+ return {
73
+ location,
74
+ existing: {
75
+ view: { ...location, text, sourceDigest: editorDigest(setup, location, source.sourceDigest), identity },
76
+ stat,
77
+ },
78
+ };
79
+ }
80
+ catch (cause) {
81
+ execution.validate();
82
+ throw new Error(`Cannot open ignore file "${location.path}": ${cause.message}`, { cause });
83
+ }
84
+ }
85
+ export async function readIgnoreFileEdit(payload, execution) {
86
+ if (!record(payload) || typeof payload.setup !== "string" || Object.keys(payload).some((key) => key !== "setup"))
87
+ throw new Error("Invalid ignore-file request.");
88
+ const { setup } = payload;
89
+ validateConfigName(setup, "sync setup");
90
+ const source = await withLockedLocalConfigDocument(async (document, recheck) => {
91
+ execution.validate();
92
+ const location = locateIgnoreFile(document, getEngineRoot(), setup);
93
+ const result = await loadEditorSource(setup, location, execution);
94
+ validateTarget(execution, location);
95
+ recheck();
96
+ assertCurrent(location.path, result.existing?.stat);
97
+ return result;
98
+ }, execution.signal);
99
+ validateTarget(execution, source.location);
100
+ assertCurrent(source.location.path, source.existing?.stat);
101
+ return source.existing?.view ?? source.location;
102
+ }