@narumitw/pi-sync 0.61.0 → 0.62.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 (250) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +24 -17
  3. package/dist/chunks/{chunk-EMVZL4PH.ts → chunk-3E3TR3JE.ts} +4 -4
  4. package/dist/chunks/{chunk-JVFCVPPD.ts → chunk-6PFZUEUG.ts} +41 -18
  5. package/dist/chunks/chunk-6PFZUEUG.ts.map +7 -0
  6. package/dist/chunks/{chunk-ZIL6PW5L.ts → chunk-6YKOHBSC.ts} +2 -2
  7. package/dist/chunks/{chunk-OA4NZLSL.ts → chunk-APZVJAEW.ts} +4 -3
  8. package/dist/chunks/{chunk-4SR3ZYHA.ts → chunk-GELYN4UC.ts} +2 -2
  9. package/dist/chunks/{chunk-S7F4FOAS.ts → chunk-GSCZ4VXV.ts} +5 -5
  10. package/dist/chunks/{chunk-YQSFJLJ3.ts → chunk-IBXEM35O.ts} +4 -3
  11. package/dist/chunks/{chunk-E3YLRLJM.ts → chunk-INECVQNR.ts} +10 -10
  12. package/dist/chunks/{chunk-2JHAN3ZO.ts → chunk-JREGWM2B.ts} +3 -3
  13. package/dist/chunks/{chunk-277VHM2P.ts → chunk-MNYRU5U5.ts} +5 -2
  14. package/dist/chunks/{chunk-277VHM2P.ts.map → chunk-MNYRU5U5.ts.map} +2 -2
  15. package/dist/chunks/{chunk-2ZGV5KNC.ts → chunk-NHFGAZEC.ts} +11 -8
  16. package/dist/chunks/chunk-NHFGAZEC.ts.map +7 -0
  17. package/dist/chunks/{chunk-EMRFVLZM.ts → chunk-NXWHPVXR.ts} +2 -2
  18. package/dist/chunks/{chunk-SMVKMYLK.ts → chunk-P4GI7LTT.ts} +2 -2
  19. package/dist/chunks/{chunk-PJMM75W5.ts → chunk-PWESMTH6.ts} +6 -6
  20. package/dist/chunks/{chunk-ZVGRZD4C.ts → chunk-R3SAMXB6.ts} +2 -2
  21. package/dist/chunks/{chunk-RNIEVDTR.ts → chunk-T3LABNHF.ts} +2 -2
  22. package/dist/chunks/{chunk-S3R3W3KF.ts → chunk-UMPA5S7X.ts} +2 -2
  23. package/dist/chunks/{chunk-WP2M67XZ.ts → chunk-WBIOSK76.ts} +2 -2
  24. package/dist/chunks/{chunk-4KTJLJSJ.ts → chunk-ZB3GNX3P.ts} +11 -11
  25. package/dist/chunks/{chunk-HEB6YT64.ts → chunk-ZO52JM4H.ts} +2 -2
  26. package/dist/chunks/{command-handler-K4XJOGYC.ts → command-handler-6ATREPG7.ts} +16 -16
  27. package/dist/chunks/command-handler-6ATREPG7.ts.map +7 -0
  28. package/dist/chunks/{conflict-review-IGKY2TOJ.ts → conflict-review-MAOGTIAI.ts} +4 -4
  29. package/dist/chunks/{continuous-record-3XDXDOMV.ts → continuous-record-3SKJ6I3V.ts} +2 -2
  30. package/dist/chunks/{continuous-storage-HLKCHF6Z.ts → continuous-storage-3EU6I7Z3.ts} +2 -2
  31. package/dist/chunks/{file-selection-MGGVOKM7.ts → file-selection-QR2KZVGD.ts} +10 -10
  32. package/dist/chunks/manager-result-dispatcher-MC6EQOQY.ts +19 -0
  33. package/dist/chunks/{manager-ui-KYQ5AZJS.ts → manager-ui-AOFUNXAJ.ts} +547 -135
  34. package/dist/chunks/manager-ui-AOFUNXAJ.ts.map +7 -0
  35. package/dist/chunks/remote-selection-ui-4BTP2OJR.ts +18 -0
  36. package/dist/chunks/{setup-switch-D6K6PBPC.ts → setup-switch-Y6AMFFNK.ts} +7 -7
  37. package/dist/chunks/{setup-wizard-4DYUDHJR.ts → setup-wizard-5G426MOZ.ts} +10 -10
  38. package/dist/chunks/{snapshot-5HY3M2NL.ts → snapshot-ZUJJZCFW.ts} +2 -2
  39. package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts → snapshot-transaction-directory-F46JWRAU.ts} +2 -2
  40. package/dist/chunks/{state-directory-XXHU73Z3.ts → state-directory-CMAIF34J.ts} +2 -2
  41. package/dist/chunks/{sync-inspection-J3CRBORL.ts → sync-inspection-ITZ6Z4DE.ts} +5 -5
  42. package/dist/chunks/{sync-operations-BVWYYKH3.ts → sync-operations-NMVKF7SE.ts} +13 -9
  43. package/dist/chunks/sync-operations-NMVKF7SE.ts.map +7 -0
  44. package/dist/chunks/{sync-state-2LMIXJ2C.ts → sync-state-QIT64TKV.ts} +2 -2
  45. package/dist/daemon/LICENSE +21 -0
  46. package/dist/daemon/dist/build-version.js +8 -0
  47. package/dist/daemon/dist/child-sdk.mjs +17 -0
  48. package/dist/daemon/dist/cli.js +169 -0
  49. package/dist/daemon/dist/client.js +909 -0
  50. package/dist/daemon/dist/consent.js +265 -0
  51. package/dist/daemon/dist/document.js +6 -0
  52. package/dist/daemon/dist/endpoint.js +91 -0
  53. package/dist/daemon/dist/engine/backends/backend-factory.js +16 -0
  54. package/dist/daemon/dist/engine/backends/backend-identity.js +38 -0
  55. package/dist/daemon/dist/engine/backends/backend-types.js +1 -0
  56. package/dist/daemon/dist/engine/backends/git/git-backend.js +715 -0
  57. package/dist/daemon/dist/engine/backends/git/git-config.js +118 -0
  58. package/dist/daemon/dist/engine/backends/git/git-runner.js +232 -0
  59. package/dist/daemon/dist/engine/backends/git/git-storage.js +252 -0
  60. package/dist/daemon/dist/engine/backends/s3/s3-backend.js +444 -0
  61. package/dist/daemon/dist/engine/backends/s3/s3-client.js +352 -0
  62. package/dist/daemon/dist/engine/backends/s3/s3-conditions.js +66 -0
  63. package/dist/daemon/dist/engine/backends/snapshot-pointer.js +22 -0
  64. package/dist/daemon/dist/engine/backends/sync-backend.js +23 -0
  65. package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +542 -0
  66. package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +326 -0
  67. package/dist/daemon/dist/engine/backends/webdav/webdav-config.js +73 -0
  68. package/dist/daemon/dist/engine/commands/command-types.js +1 -0
  69. package/dist/daemon/dist/engine/host.js +16 -0
  70. package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +33 -0
  71. package/dist/daemon/dist/engine/ignore/ignore-edit.js +102 -0
  72. package/dist/daemon/dist/engine/ignore/ignore-initialization.js +186 -0
  73. package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +139 -0
  74. package/dist/daemon/dist/engine/ignore/ignore-settings.js +322 -0
  75. package/dist/daemon/dist/engine/ignore/ignore-source.js +250 -0
  76. package/dist/daemon/dist/engine/paths.js +71 -0
  77. package/dist/daemon/dist/engine/settings/config-errors.js +4 -0
  78. package/dist/daemon/dist/engine/settings/config-file.js +736 -0
  79. package/dist/daemon/dist/engine/settings/config.js +301 -0
  80. package/dist/daemon/dist/engine/settings/settings-management.js +193 -0
  81. package/dist/daemon/dist/engine/settings/settings-store.js +41 -0
  82. package/dist/daemon/dist/engine/settings/settings-types.js +1 -0
  83. package/dist/daemon/dist/engine/settings/settings-validation.js +384 -0
  84. package/dist/daemon/dist/engine/snapshot/session-paths.js +160 -0
  85. package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +348 -0
  86. package/dist/daemon/dist/engine/snapshot/snapshot-bounds.js +20 -0
  87. package/dist/daemon/dist/engine/snapshot/snapshot-case-replacement.js +82 -0
  88. package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +61 -0
  89. package/dist/daemon/dist/engine/snapshot/snapshot-entry-projection.js +78 -0
  90. package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +262 -0
  91. package/dist/daemon/dist/engine/snapshot/snapshot-mutation-queues.js +133 -0
  92. package/dist/daemon/dist/engine/snapshot/snapshot-paths.js +11 -0
  93. package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +10 -0
  94. package/dist/daemon/dist/engine/snapshot/snapshot-reviewed-preimages.js +60 -0
  95. package/dist/daemon/dist/engine/snapshot/snapshot-root-transition.js +138 -0
  96. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-directory.js +16 -0
  97. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +387 -0
  98. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-plan.js +68 -0
  99. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +276 -0
  100. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-stage.js +303 -0
  101. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-verification.js +78 -0
  102. package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +813 -0
  103. package/dist/daemon/dist/engine/snapshot/snapshot-types.js +9 -0
  104. package/dist/daemon/dist/engine/snapshot/snapshot.js +678 -0
  105. package/dist/daemon/dist/engine/state/json-file.js +49 -0
  106. package/dist/daemon/dist/engine/state/lock-policy.js +2 -0
  107. package/dist/daemon/dist/engine/state/lock.js +259 -0
  108. package/dist/daemon/dist/engine/state/lockfile-fs.js +13 -0
  109. package/dist/daemon/dist/engine/state/merge-baseline-store.js +198 -0
  110. package/dist/daemon/dist/engine/state/mutation-directory-sync.js +34 -0
  111. package/dist/daemon/dist/engine/state/operation-availability.js +40 -0
  112. package/dist/daemon/dist/engine/state/state-directory.js +227 -0
  113. package/dist/daemon/dist/engine/state/state-types.js +1 -0
  114. package/dist/daemon/dist/engine/state/sync-state-store.js +54 -0
  115. package/dist/daemon/dist/engine/sync/agent-candidate.js +207 -0
  116. package/dist/daemon/dist/engine/sync/agent-plan.js +84 -0
  117. package/dist/daemon/dist/engine/sync/agent-policy.js +10 -0
  118. package/dist/daemon/dist/engine/sync/agent-refusal-retry.js +39 -0
  119. package/dist/daemon/dist/engine/sync/agent-request.js +13 -0
  120. package/dist/daemon/dist/engine/sync/agent-runner.js +183 -0
  121. package/dist/daemon/dist/engine/sync/agent-store.js +177 -0
  122. package/dist/daemon/dist/engine/sync/agent-sync.js +132 -0
  123. package/dist/daemon/dist/engine/sync/apply-review.js +52 -0
  124. package/dist/daemon/dist/engine/sync/conflict-artifact-ownership.js +53 -0
  125. package/dist/daemon/dist/engine/sync/conflict-artifacts.js +158 -0
  126. package/dist/daemon/dist/engine/sync/conflict-groups.js +76 -0
  127. package/dist/daemon/dist/engine/sync/conflict-preview.js +53 -0
  128. package/dist/daemon/dist/engine/sync/conflict-resolution.js +53 -0
  129. package/dist/daemon/dist/engine/sync/conflict-retention.js +61 -0
  130. package/dist/daemon/dist/engine/sync/conflict-review.js +73 -0
  131. package/dist/daemon/dist/engine/sync/content-conflicts.js +70 -0
  132. package/dist/daemon/dist/engine/sync/continuous-errors.js +66 -0
  133. package/dist/daemon/dist/engine/sync/continuous-lease.js +206 -0
  134. package/dist/daemon/dist/engine/sync/continuous-record.js +199 -0
  135. package/dist/daemon/dist/engine/sync/continuous-storage.js +59 -0
  136. package/dist/daemon/dist/engine/sync/continuous-sync.js +521 -0
  137. package/dist/daemon/dist/engine/sync/continuous-watch.js +140 -0
  138. package/dist/daemon/dist/engine/sync/exclude-policy.js +86 -0
  139. package/dist/daemon/dist/engine/sync/field-migration.js +20 -0
  140. package/dist/daemon/dist/engine/sync/file-merge-planner.js +123 -0
  141. package/dist/daemon/dist/engine/sync/initialization.js +80 -0
  142. package/dist/daemon/dist/engine/sync/json-document.js +172 -0
  143. package/dist/daemon/dist/engine/sync/local-field-policy.js +26 -0
  144. package/dist/daemon/dist/engine/sync/local-fields.js +196 -0
  145. package/dist/daemon/dist/engine/sync/merge-apply.js +529 -0
  146. package/dist/daemon/dist/engine/sync/merge-journal.js +295 -0
  147. package/dist/daemon/dist/engine/sync/merge-transfer-error.js +64 -0
  148. package/dist/daemon/dist/engine/sync/merged-sync.js +674 -0
  149. package/dist/daemon/dist/engine/sync/mutation-owner.js +18 -0
  150. package/dist/daemon/dist/engine/sync/package-merge.js +82 -0
  151. package/dist/daemon/dist/engine/sync/partial-progress.js +41 -0
  152. package/dist/daemon/dist/engine/sync/remote-snapshot.js +104 -0
  153. package/dist/daemon/dist/engine/sync/resolver-stream.js +34 -0
  154. package/dist/daemon/dist/engine/sync/session-merge.js +178 -0
  155. package/dist/daemon/dist/engine/sync/session-push.js +33 -0
  156. package/dist/daemon/dist/engine/sync/settings-conflicts.js +56 -0
  157. package/dist/daemon/dist/engine/sync/settings-merge.js +93 -0
  158. package/dist/daemon/dist/engine/sync/signals.js +8 -0
  159. package/dist/daemon/dist/engine/sync/startup-timings.js +44 -0
  160. package/dist/daemon/dist/engine/sync/sync-decision.js +81 -0
  161. package/dist/daemon/dist/engine/sync/sync-error-guidance.js +55 -0
  162. package/dist/daemon/dist/engine/sync/sync-errors.js +18 -0
  163. package/dist/daemon/dist/engine/sync/sync-inspection.js +42 -0
  164. package/dist/daemon/dist/engine/sync/sync-loaders.js +8 -0
  165. package/dist/daemon/dist/engine/sync/sync-local.js +40 -0
  166. package/dist/daemon/dist/engine/sync/sync-mutations.js +733 -0
  167. package/dist/daemon/dist/engine/sync/sync-operations.js +3 -0
  168. package/dist/daemon/dist/engine/sync/sync-policy.js +621 -0
  169. package/dist/daemon/dist/engine/sync/sync-queries.js +212 -0
  170. package/dist/daemon/dist/engine/sync/sync-state.js +129 -0
  171. package/dist/daemon/dist/engine/sync/text-merge.js +124 -0
  172. package/dist/daemon/dist/engine/types.js +2 -0
  173. package/dist/daemon/dist/engine/ui/merge-review.js +7 -0
  174. package/dist/daemon/dist/engine/ui/merged-sync-summary.js +86 -0
  175. package/dist/daemon/dist/engine/ui/sync-format.js +165 -0
  176. package/dist/daemon/dist/engine/ui/sync-status.js +30 -0
  177. package/dist/daemon/dist/engine/ui/terminal-text.js +9 -0
  178. package/dist/daemon/dist/engine/ui/transfer-changes.js +24 -0
  179. package/dist/daemon/dist/engine/ui/transfer-review.js +19 -0
  180. package/dist/daemon/dist/engine-service.js +344 -0
  181. package/dist/daemon/dist/identity.js +241 -0
  182. package/dist/daemon/dist/idle-exit.js +77 -0
  183. package/dist/daemon/dist/index.js +4 -0
  184. package/dist/daemon/dist/lifecycle-log.js +53 -0
  185. package/dist/daemon/dist/lifecycle.js +21 -0
  186. package/dist/daemon/dist/model-signature.js +7 -0
  187. package/dist/daemon/dist/monitor.js +272 -0
  188. package/dist/daemon/dist/participant-admission.js +30 -0
  189. package/dist/daemon/dist/protocol.js +104 -0
  190. package/dist/daemon/dist/resolver-host.js +78 -0
  191. package/dist/daemon/dist/server.js +953 -0
  192. package/dist/daemon/dist/service-host.js +174 -0
  193. package/dist/daemon/dist/upgrade-repair.js +55 -0
  194. package/dist/daemon/package.json +3 -0
  195. package/dist/index.ts +21 -21
  196. package/dist/package.json +6 -0
  197. package/docs/daemon-migration.md +27 -16
  198. package/package.json +9 -3
  199. package/skills/configure-pi-sync/SKILL.md +38 -13
  200. package/skills/configure-pi-sync/references/configuration.md +2 -2
  201. package/src/commands/command-execution.ts +1 -1
  202. package/src/settings/config.ts +1 -0
  203. package/src/sync/sync-operations.ts +18 -10
  204. package/src/ui/excluded-paths-ui.ts +4 -1
  205. package/src/ui/ignore-file-ui.ts +271 -0
  206. package/src/ui/ignore-migration-prompt.ts +65 -0
  207. package/src/ui/manager-state.ts +27 -13
  208. package/src/ui/manager-ui.ts +38 -19
  209. package/src/ui/remote-selection-ui.ts +41 -8
  210. package/src/ui/settings-review.ts +26 -0
  211. package/src/ui/settings-ui.ts +316 -213
  212. package/src/ui/storage-connections-ui.ts +20 -12
  213. package/src/ui/sync-setups-ui.ts +45 -27
  214. package/dist/chunks/chunk-2ZGV5KNC.ts.map +0 -7
  215. package/dist/chunks/chunk-JVFCVPPD.ts.map +0 -7
  216. package/dist/chunks/command-handler-K4XJOGYC.ts.map +0 -7
  217. package/dist/chunks/manager-result-dispatcher-4VJVDEUD.ts +0 -19
  218. package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +0 -7
  219. package/dist/chunks/remote-selection-ui-W3KOZM3W.ts +0 -18
  220. package/dist/chunks/sync-operations-BVWYYKH3.ts.map +0 -7
  221. /package/dist/chunks/{chunk-EMVZL4PH.ts.map → chunk-3E3TR3JE.ts.map} +0 -0
  222. /package/dist/chunks/{chunk-ZIL6PW5L.ts.map → chunk-6YKOHBSC.ts.map} +0 -0
  223. /package/dist/chunks/{chunk-OA4NZLSL.ts.map → chunk-APZVJAEW.ts.map} +0 -0
  224. /package/dist/chunks/{chunk-4SR3ZYHA.ts.map → chunk-GELYN4UC.ts.map} +0 -0
  225. /package/dist/chunks/{chunk-S7F4FOAS.ts.map → chunk-GSCZ4VXV.ts.map} +0 -0
  226. /package/dist/chunks/{chunk-YQSFJLJ3.ts.map → chunk-IBXEM35O.ts.map} +0 -0
  227. /package/dist/chunks/{chunk-E3YLRLJM.ts.map → chunk-INECVQNR.ts.map} +0 -0
  228. /package/dist/chunks/{chunk-2JHAN3ZO.ts.map → chunk-JREGWM2B.ts.map} +0 -0
  229. /package/dist/chunks/{chunk-EMRFVLZM.ts.map → chunk-NXWHPVXR.ts.map} +0 -0
  230. /package/dist/chunks/{chunk-SMVKMYLK.ts.map → chunk-P4GI7LTT.ts.map} +0 -0
  231. /package/dist/chunks/{chunk-PJMM75W5.ts.map → chunk-PWESMTH6.ts.map} +0 -0
  232. /package/dist/chunks/{chunk-ZVGRZD4C.ts.map → chunk-R3SAMXB6.ts.map} +0 -0
  233. /package/dist/chunks/{chunk-RNIEVDTR.ts.map → chunk-T3LABNHF.ts.map} +0 -0
  234. /package/dist/chunks/{chunk-S3R3W3KF.ts.map → chunk-UMPA5S7X.ts.map} +0 -0
  235. /package/dist/chunks/{chunk-WP2M67XZ.ts.map → chunk-WBIOSK76.ts.map} +0 -0
  236. /package/dist/chunks/{chunk-4KTJLJSJ.ts.map → chunk-ZB3GNX3P.ts.map} +0 -0
  237. /package/dist/chunks/{chunk-HEB6YT64.ts.map → chunk-ZO52JM4H.ts.map} +0 -0
  238. /package/dist/chunks/{conflict-review-IGKY2TOJ.ts.map → conflict-review-MAOGTIAI.ts.map} +0 -0
  239. /package/dist/chunks/{continuous-record-3XDXDOMV.ts.map → continuous-record-3SKJ6I3V.ts.map} +0 -0
  240. /package/dist/chunks/{continuous-storage-HLKCHF6Z.ts.map → continuous-storage-3EU6I7Z3.ts.map} +0 -0
  241. /package/dist/chunks/{file-selection-MGGVOKM7.ts.map → file-selection-QR2KZVGD.ts.map} +0 -0
  242. /package/dist/chunks/{manager-result-dispatcher-4VJVDEUD.ts.map → manager-result-dispatcher-MC6EQOQY.ts.map} +0 -0
  243. /package/dist/chunks/{remote-selection-ui-W3KOZM3W.ts.map → remote-selection-ui-4BTP2OJR.ts.map} +0 -0
  244. /package/dist/chunks/{setup-switch-D6K6PBPC.ts.map → setup-switch-Y6AMFFNK.ts.map} +0 -0
  245. /package/dist/chunks/{setup-wizard-4DYUDHJR.ts.map → setup-wizard-5G426MOZ.ts.map} +0 -0
  246. /package/dist/chunks/{snapshot-5HY3M2NL.ts.map → snapshot-ZUJJZCFW.ts.map} +0 -0
  247. /package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts.map → snapshot-transaction-directory-F46JWRAU.ts.map} +0 -0
  248. /package/dist/chunks/{state-directory-XXHU73Z3.ts.map → state-directory-CMAIF34J.ts.map} +0 -0
  249. /package/dist/chunks/{sync-inspection-J3CRBORL.ts.map → sync-inspection-ITZ6Z4DE.ts.map} +0 -0
  250. /package/dist/chunks/{sync-state-2LMIXJ2C.ts.map → sync-state-QIT64TKV.ts.map} +0 -0
@@ -18,22 +18,23 @@ import {
18
18
  showEditS3Target,
19
19
  showEditWebDavStorageProfile,
20
20
  showEditWebDavTarget
21
- } from "./chunk-4KTJLJSJ.ts";
21
+ } from "./chunk-ZB3GNX3P.ts";
22
22
  import {
23
23
  dispatchManagerResult
24
- } from "./chunk-EMVZL4PH.ts";
24
+ } from "./chunk-3E3TR3JE.ts";
25
25
  import {
26
26
  SETUP_SWITCH_ACTION_OPTIONS,
27
27
  saveOnSwitch,
28
28
  setupSwitchActionFromLabel,
29
29
  setupSwitchActionLabel,
30
30
  useSyncSetup
31
- } from "./chunk-PJMM75W5.ts";
31
+ } from "./chunk-PWESMTH6.ts";
32
32
  import {
33
33
  isCloudflareR2Endpoint,
34
34
  normalizeS3Endpoint,
35
- ownRecord
36
- } from "./chunk-OA4NZLSL.ts";
35
+ ownRecord,
36
+ validateSettingsDocument
37
+ } from "./chunk-APZVJAEW.ts";
37
38
  import {
38
39
  automaticSyncSummary
39
40
  } from "./chunk-ECYCNZOE.ts";
@@ -42,14 +43,14 @@ import {
42
43
  readLocalConfigObject,
43
44
  requireSettings,
44
45
  updateLocalConfig
45
- } from "./chunk-WP2M67XZ.ts";
46
+ } from "./chunk-WBIOSK76.ts";
46
47
  import {
47
48
  observationMatchesConfig,
48
49
  observationSummary,
49
50
  readStateForConfig,
50
51
  syncAttentionMatchesConfig,
51
52
  syncStateFingerprint
52
- } from "./chunk-S7F4FOAS.ts";
53
+ } from "./chunk-GSCZ4VXV.ts";
53
54
  import {
54
55
  AUTOMATIC_SYNC_DESCRIPTION,
55
56
  STARTUP_TRANSFER_DESCRIPTION,
@@ -61,53 +62,60 @@ import {
61
62
  import {
62
63
  directoryScopeSummary,
63
64
  showExcludedPaths
64
- } from "./chunk-2ZGV5KNC.ts";
65
+ } from "./chunk-NHFGAZEC.ts";
65
66
  import {
66
67
  directorySessionOptInLine,
67
68
  saveReviewedDraft
68
- } from "./chunk-2JHAN3ZO.ts";
69
+ } from "./chunk-JREGWM2B.ts";
69
70
  import {
70
71
  activeLocalConfigPath,
71
72
  localConfigPath,
73
+ readActiveLocalConfigDocumentForRepair,
72
74
  syncErrorGuidance
73
- } from "./chunk-YQSFJLJ3.ts";
75
+ } from "./chunk-IBXEM35O.ts";
74
76
  import {
75
- runCancellableOperation
76
- } from "./chunk-JVFCVPPD.ts";
77
+ piDaemonClient
78
+ } from "./chunk-INECVQNR.ts";
79
+ import {
80
+ runCancellableOperation,
81
+ runCancellableTask
82
+ } from "./chunk-6PFZUEUG.ts";
77
83
  import {
78
84
  throwIfAborted
79
- } from "./chunk-S3R3W3KF.ts";
85
+ } from "./chunk-UMPA5S7X.ts";
80
86
  import {
81
87
  captureMutationOwner
82
- } from "./chunk-4SR3ZYHA.ts";
88
+ } from "./chunk-GELYN4UC.ts";
83
89
  import {
84
90
  addStorageConnection,
85
91
  removeStorageConnection,
86
92
  removeSyncSetup,
87
93
  updateStorageConnection,
88
94
  updateSyncSetup
89
- } from "./chunk-EMRFVLZM.ts";
95
+ } from "./chunk-NXWHPVXR.ts";
90
96
  import {
91
97
  sameSyncExclude
92
- } from "./chunk-HEB6YT64.ts";
98
+ } from "./chunk-ZO52JM4H.ts";
93
99
  import {
100
+ configFromSettings,
94
101
  loadConfig,
95
102
  loadPartialConfig,
103
+ loadSettingsConfig,
96
104
  syncCheckConfigFingerprint,
97
105
  syncConfigReviewIdentity
98
- } from "./chunk-277VHM2P.ts";
106
+ } from "./chunk-MNYRU5U5.ts";
99
107
  import {
100
108
  configureSyncStatus
101
109
  } from "./chunk-H7VOTY5N.ts";
102
110
  import {
103
111
  errorMessage
104
- } from "./chunk-ZIL6PW5L.ts";
112
+ } from "./chunk-6YKOHBSC.ts";
105
113
  import {
106
114
  compareSyncInclude,
107
115
  syncIncludeSelection,
108
116
  syncSelectionHasContent,
109
117
  syncSessionsSelected
110
- } from "./chunk-ZVGRZD4C.ts";
118
+ } from "./chunk-R3SAMXB6.ts";
111
119
  import {
112
120
  safeTerminalText
113
121
  } from "./chunk-2JNFEZ3V.ts";
@@ -121,7 +129,281 @@ import {
121
129
  inspectOperationAvailability,
122
130
  operationBlocksChanges,
123
131
  operationCanRecover
124
- } from "@narumitw/pi-sync-daemon/engine/state/operation-availability";
132
+ } from "#pi-sync-daemon/engine/state/operation-availability";
133
+
134
+ // src/ui/ignore-file-ui.ts
135
+ import { resolve } from "node:path";
136
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
137
+ import { CURSOR_MARKER, Editor, isKeyRelease, Key, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
138
+ import { HorizontalRule, hardWrapTerminalDocument, runCustomInteraction } from "@narumitw/pi-tui-kit";
139
+ async function ignoreFileSettingsAvailable(ctx, signal) {
140
+ if (signal?.aborted) return false;
141
+ try {
142
+ const client = piDaemonClient(ctx);
143
+ const result = await client.run("ignore.capabilities", {}, signal, ctx);
144
+ client.validate();
145
+ return !signal?.aborted && result?.available === true;
146
+ } catch {
147
+ return false;
148
+ }
149
+ }
150
+ function manualIgnoreFileGuidance(filename) {
151
+ return `Edit existing ignore rules manually: ${safeTerminalText(resolve(getAgentDir(), filename))}`;
152
+ }
153
+ async function showIgnoreFileAction(ctx, setup, action, filename, signal, offerToken) {
154
+ if (signal.aborted || !ctx.hasUI) return;
155
+ if (ctx.mode !== "tui") {
156
+ if (ctx.mode === "rpc" && action === "edit") ctx.ui.notify(manualIgnoreFileGuidance(filename), "info");
157
+ return;
158
+ }
159
+ const validateOwner = captureMutationOwner(ctx, signal);
160
+ const client = piDaemonClient(ctx);
161
+ const isCurrent = () => {
162
+ try {
163
+ validateOwner();
164
+ client.validate();
165
+ return true;
166
+ } catch {
167
+ return false;
168
+ }
169
+ };
170
+ const work = async (method, message, payload = {}) => {
171
+ const result = await runCancellableTask(
172
+ ctx,
173
+ message,
174
+ (workSignal, onCommit) => client.run(`ignore.${method}`, { setup, ...payload }, workSignal, ctx, onCommit),
175
+ {
176
+ signal,
177
+ isCurrent,
178
+ cancelledMessage: null,
179
+ commitAware: method !== "read",
180
+ cancelAcrossDialogs: method !== "read"
181
+ }
182
+ );
183
+ return isCurrent() && result.kind === "completed" ? result : void 0;
184
+ };
185
+ try {
186
+ if (action === "migrate") {
187
+ const result2 = await work("migrate", "Preparing ignore-file migration review\u2026", offerToken ? { offerToken } : {});
188
+ if (isCurrent() && result2?.value === "saved")
189
+ ctx.ui.notify("Ignore-file policy saved locally. No transfer started.", "info");
190
+ return;
191
+ }
192
+ if (action === "switch") {
193
+ const entered = await askIgnoreFilename(ctx, filename, signal);
194
+ if (!isCurrent() || !entered || entered === filename) return;
195
+ const result2 = await work("switch", "Checking the selected ignore file for review\u2026", {
196
+ filename: entered,
197
+ expectedFilename: filename
198
+ });
199
+ if (isCurrent() && result2?.value === "saved") ctx.ui.notify("Ignore file selected. No transfer started.", "info");
200
+ return;
201
+ }
202
+ const result = await work("read", "Opening existing ignore file\u2026");
203
+ if (!isCurrent() || !result) return;
204
+ const source = decodeIgnoreFile(result.value);
205
+ const path = safeTerminalText(source.path);
206
+ if (!isEditorSafe(source.text)) {
207
+ ctx.ui.notify(
208
+ `Pi cannot edit this file without changing or hiding some characters. Edit ${path} manually.`,
209
+ "warning"
210
+ );
211
+ return;
212
+ }
213
+ const sharing = source.sharingSetups.length ? `Also used by: ${source.sharingSetups.map((name) => `\u201C${safeTerminalText(name)}\u201D`).join(", ")}` : void 0;
214
+ const draft = await editIgnoreText(ctx, source.text, path, sharing, signal, isCurrent);
215
+ if (!isCurrent() || draft.kind !== "completed") return;
216
+ if (draft.value.kind === "unsafe") {
217
+ ctx.ui.notify(`Unsafe terminal characters in the draft. No save; edit ${path} manually.`, "warning");
218
+ return;
219
+ }
220
+ if (draft.value.kind !== "draft" || draft.value.text === source.text) return;
221
+ const text = draft.value.text;
222
+ const lines = [
223
+ path,
224
+ ...sharing ? [sharing] : [],
225
+ "This replaces the local rules. Removing rules may expose more files on a later sync.",
226
+ "No transfer starts; remote history is retained."
227
+ ];
228
+ const confirmed = await confirmMergeReview(ctx, "Save ignore rules?", text, signal, isCurrent, "save rules", lines);
229
+ if (!isCurrent() || !confirmed) return;
230
+ const saved = await work("save", "Saving ignore rules\u2026", {
231
+ text,
232
+ sourceDigest: source.sourceDigest,
233
+ identity: source.identity
234
+ });
235
+ if (isCurrent() && saved) ctx.ui.notify("Ignore rules saved. No transfer started.", "info");
236
+ } catch (error) {
237
+ if (isCurrent())
238
+ ctx.ui.notify(`Pi Sync: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`, "error");
239
+ }
240
+ }
241
+ function decodeIgnoreFile(value) {
242
+ const file = value;
243
+ if (!file || typeof file.filename !== "string" || typeof file.path !== "string")
244
+ throw new Error("Invalid ignore-file response from the daemon.");
245
+ if (file.identity === void 0 && file.text === void 0)
246
+ throw new Error(`Ignore file does not exist: ${file.path}. No file was created.`);
247
+ if (typeof file.text !== "string" || typeof file.identity !== "string" || file.identity.length === 0 || typeof file.sourceDigest !== "string" || !Array.isArray(file.sharingSetups) || !file.sharingSetups.every((setup) => typeof setup === "string"))
248
+ throw new Error("Invalid ignore-file response from the daemon.");
249
+ return file;
250
+ }
251
+ async function askIgnoreFilename(ctx, filename, signal) {
252
+ const cancel = new AbortController();
253
+ const stop = ctx.ui.onTerminalInput((data) => {
254
+ if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) {
255
+ cancel.abort();
256
+ return { consume: true };
257
+ }
258
+ });
259
+ const inputSignal = AbortSignal.any([signal, cancel.signal]);
260
+ try {
261
+ const entered = await ctx.ui.input(`Existing ignore filename (current: ${safeTerminalText(filename)})`, void 0, {
262
+ signal: inputSignal
263
+ });
264
+ return inputSignal.aborted ? void 0 : entered;
265
+ } finally {
266
+ stop();
267
+ }
268
+ }
269
+ function isEditorSafe(text) {
270
+ const flattened = text.replaceAll("\n", "");
271
+ return flattened === safeTerminalText(flattened);
272
+ }
273
+ function editIgnoreText(ctx, original, path, sharing, signal, isCurrent) {
274
+ return runCustomInteraction(ctx, {
275
+ signal,
276
+ isCurrent,
277
+ create: ({ tui, theme, keybindings, complete, signal: editorSignal }) => {
278
+ const muted = (line) => theme.fg("muted", line);
279
+ const editor = new Editor(tui, {
280
+ borderColor: (line) => theme.fg("borderMuted", line),
281
+ selectList: {
282
+ selectedPrefix: (line) => theme.fg("accent", line),
283
+ selectedText: (line) => theme.fg("accent", line),
284
+ description: muted,
285
+ scrollInfo: muted,
286
+ noMatch: muted
287
+ }
288
+ });
289
+ editor.setText(original);
290
+ let text = original;
291
+ let beforeChange = original;
292
+ editor.onChange = () => {
293
+ beforeChange = text;
294
+ text = editor.getExpandedText();
295
+ if (!isEditorSafe(text)) complete({ kind: "unsafe" });
296
+ };
297
+ editor.onSubmit = () => complete({ kind: "draft", text: beforeChange });
298
+ const rule = new HorizontalRule({ ruleStyle: (line) => theme.fg("border", line) });
299
+ let layout;
300
+ return {
301
+ get focused() {
302
+ return editor.focused;
303
+ },
304
+ set focused(value) {
305
+ editor.focused = value;
306
+ },
307
+ get capturesViewportInput() {
308
+ return true;
309
+ },
310
+ render(width) {
311
+ layout = void 0;
312
+ if (editorSignal.aborted || !Number.isFinite(width) || width <= 0) return [];
313
+ const terminalRows = Number.isFinite(tui.terminal.rows) ? Math.floor(tui.terminal.rows) : 24;
314
+ const rows = Math.max(1, terminalRows - 3);
315
+ const border = rows >= 5 ? rule.render(width) : [];
316
+ const editorRows = editor.render(width).slice(1, -1);
317
+ const header = [
318
+ theme.fg("accent", theme.bold("Edit ignore rules")),
319
+ muted("Submit to review; cancel to discard."),
320
+ ...[path, ...sharing ? [sharing] : []].flatMap(
321
+ (line) => hardWrapTerminalDocument(line, width).map(muted)
322
+ )
323
+ ].slice(0, rows - 2 * border.length - 1);
324
+ const available = rows - 2 * border.length - header.length;
325
+ const cursorRow = editorRows.findIndex((line) => line.includes(CURSOR_MARKER));
326
+ const offset = Math.max(0, cursorRow - available + 1);
327
+ const body = editorRows.slice(offset, offset + available);
328
+ layout = { width, first: border.length + header.length, count: body.length, editorOffset: offset + 1 };
329
+ return [...border, ...header, ...body, ...border].map((line) => truncateToWidth(line, width, ""));
330
+ },
331
+ invalidate() {
332
+ layout = void 0;
333
+ rule.invalidate();
334
+ editor.invalidate();
335
+ },
336
+ handleInput(data) {
337
+ if (editorSignal.aborted || isKeyRelease(data)) return;
338
+ if (matchesKey(data, Key.ctrl("c")) || keybindings.matches(data, "tui.select.cancel")) {
339
+ complete({ kind: "cancelled" });
340
+ return;
341
+ }
342
+ editor.handleInput(data);
343
+ if (!editorSignal.aborted) tui.requestRender();
344
+ },
345
+ handleMouse(event) {
346
+ if (editorSignal.aborted || !layout || layout.width !== event.width) return;
347
+ const y = event.y - layout.first;
348
+ if (y >= 0 && y < layout.count) return editor.handleMouse({ ...event, y: y + layout.editorOffset });
349
+ }
350
+ };
351
+ }
352
+ });
353
+ }
354
+
355
+ // src/ui/ignore-migration-prompt.ts
356
+ var reviewNow = "Review migration now";
357
+ var notNow = "Not now";
358
+ async function showIgnoreMigrationPrompt(ctx, setup, signal, isCurrent) {
359
+ if (ctx.mode !== "tui" || !ctx.hasUI || signal.aborted || !isCurrent()) return false;
360
+ if (!await ignoreFileSettingsAvailable(ctx, signal) || signal.aborted || !isCurrent()) return false;
361
+ let shown = false;
362
+ try {
363
+ const client = piDaemonClient(ctx);
364
+ const valid = () => {
365
+ if (signal.aborted || !isCurrent()) return false;
366
+ client.validate();
367
+ return true;
368
+ };
369
+ const offer = await client.run("ignore.migration-offer", { setup }, signal, ctx);
370
+ if (!valid()) return false;
371
+ const token = readOfferToken(offer);
372
+ if (!token) return false;
373
+ shown = true;
374
+ const choice = await ctx.ui.select(
375
+ [
376
+ `Review migration for sync setup \u201C${safeTerminalText(setup)}\u201D?`,
377
+ "Your current rules still apply. Review the paths that would change before deciding.",
378
+ "Migration does not start a transfer. You can review it later in Pi Sync Settings."
379
+ ].join("\n\n"),
380
+ [reviewNow, notNow],
381
+ { signal }
382
+ );
383
+ if (!valid()) return true;
384
+ if (choice === notNow) {
385
+ await client.run("ignore.migration-defer", { setup, token }, signal, ctx);
386
+ } else if (choice === reviewNow) {
387
+ await showIgnoreFileAction(ctx, setup, "migrate", ".syncignore", signal, token);
388
+ }
389
+ } catch (error) {
390
+ if (!signal.aborted && isCurrent()) {
391
+ ctx.ui.notify(
392
+ `Pi Sync migration prompt: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
393
+ "warning"
394
+ );
395
+ }
396
+ }
397
+ return shown;
398
+ }
399
+ function readOfferToken(value) {
400
+ if (value === null) return void 0;
401
+ const token = value?.token;
402
+ if (typeof token !== "string" || !/^[0-9a-f]{64}$/u.test(token)) {
403
+ throw new Error("Invalid migration offer from the daemon.");
404
+ }
405
+ return token;
406
+ }
125
407
 
126
408
  // src/ui/manager-attention.ts
127
409
  function attentionMainMenuItems(manager) {
@@ -151,7 +433,7 @@ function blockedSyncMenuItem(label, manager) {
151
433
  };
152
434
  }
153
435
  async function showManagerAttention(ctx, attention, runRoute, signal, onSelectionResolved) {
154
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-W3KOZM3W.ts");
436
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-4BTP2OJR.ts");
155
437
  if (signal?.aborted) return "close";
156
438
  const review = await showRemoteSelectionReview(ctx, attention.decision.setupName, signal, void 0, {
157
439
  decision: attention.decision,
@@ -214,10 +496,31 @@ async function recoverSyncAccess(ctx, manager, runRoute, sessionSignal, actionSi
214
496
  }
215
497
 
216
498
  // src/ui/manager-state.ts
217
- import { truncateToWidth } from "@earendil-works/pi-tui";
499
+ import { truncateToWidth as truncateToWidth2 } from "@earendil-works/pi-tui";
218
500
 
219
501
  // src/ui/sync-setups-ui.ts
220
502
  import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
503
+
504
+ // src/ui/settings-review.ts
505
+ async function loadSettingsCatalog() {
506
+ const document = await readActiveLocalConfigDocumentForRepair();
507
+ if (!document) return void 0;
508
+ const settings = validateSettingsDocument(document.parsed);
509
+ const ignoreSetups = Object.entries(settings.syncSetups).filter(([, setup]) => setup.sync.pathPolicy === "ignore-file").map(([name]) => name);
510
+ return { settings, path: document.path, ignoreSetups };
511
+ }
512
+ var IGNORE_SETUP_MANAGEMENT_LIMIT = "Adding, editing, and switching setups are unavailable while any setup uses an ignore file.";
513
+ function ignoreSetupRecovery(settingsPath) {
514
+ return [
515
+ `For manual recovery, close Pi and back up: ${safeTerminalText(settingsPath)}`,
516
+ "Remove the ignore-file entries from syncSetups.",
517
+ "Set activeSyncSetup to a remaining setup, or remove it if none remain.",
518
+ "Keep the settings version, ignore files, and remote data unchanged.",
519
+ "Preserve any pending journal and backup. Review automatic sync before restarting Pi."
520
+ ];
521
+ }
522
+
523
+ // src/ui/sync-setups-ui.ts
221
524
  async function countValidSyncSetups(setups, signal) {
222
525
  let count = 0;
223
526
  for (const name of Object.keys(setups ?? {})) {
@@ -246,9 +549,9 @@ async function showSyncSetups(ctx, actions, signal) {
246
549
  return {
247
550
  kind: "actions",
248
551
  title: "Sync setups",
249
- lines: ["What to sync, where to store it, and when to sync."],
552
+ lines: state.recovery ?? ["What to sync, where to store it, and when to sync."],
250
553
  items: [
251
- { id: "add", label: "Add sync setup", action: "add" },
554
+ ...state.recovery ? [] : [{ id: "add", label: "Add sync setup", action: "add" }],
252
555
  ...names.map((name, index) => {
253
556
  const id = `setup:${index}`;
254
557
  nameById.set(id, name);
@@ -268,14 +571,14 @@ async function showSyncSetups(ctx, actions, signal) {
268
571
  title: state.selected ? `Sync setup \u201C${safeTerminalText(state.selected.name)}\u201D` : "Sync setup",
269
572
  lines: state.selected?.detail ?? ["This sync setup no longer exists."],
270
573
  items: state.selected ? [
271
- ...!state.selected.name || state.selected.name === state.active || !state.selected.valid ? [] : [
574
+ ...state.recovery || state.selected.name === state.active || !state.selected.valid ? [] : [
272
575
  {
273
576
  id: "make-current",
274
577
  label: "Make current\u2026",
275
578
  action: "make-current"
276
579
  }
277
580
  ],
278
- { id: "edit", label: "Edit storage location\u2026", action: "edit" },
581
+ ...state.recovery ? [] : [{ id: "edit", label: "Edit storage location\u2026", action: "edit" }],
279
582
  ...state.selected.removeUnavailable ? [] : [
280
583
  {
281
584
  id: "remove",
@@ -289,7 +592,8 @@ async function showSyncSetups(ctx, actions, signal) {
289
592
  })
290
593
  },
291
594
  actions: {
292
- add: async () => {
595
+ add: async ({ state }) => {
596
+ if (state.recovery) return { kind: "rejected" };
293
597
  try {
294
598
  await actions.add(signal);
295
599
  } catch (error) {
@@ -303,8 +607,8 @@ async function showSyncSetups(ctx, actions, signal) {
303
607
  selectedName = nameById.get(itemId);
304
608
  return selectedName ? { kind: "to", screen: "detail" } : { kind: "rejected" };
305
609
  },
306
- "make-current": async () => {
307
- if (!selectedName) return { kind: "rejected" };
610
+ "make-current": async ({ state }) => {
611
+ if (!selectedName || state.recovery || !state.selected?.valid) return { kind: "rejected" };
308
612
  try {
309
613
  exit = await actions.makeCurrent(selectedName, signal) === "exit";
310
614
  return exit ? { kind: "close" } : { kind: "stay" };
@@ -313,8 +617,8 @@ async function showSyncSetups(ctx, actions, signal) {
313
617
  return { kind: "stay" };
314
618
  }
315
619
  },
316
- edit: async () => {
317
- if (!selectedName) return { kind: "rejected" };
620
+ edit: async ({ state }) => {
621
+ if (!selectedName || state.recovery) return { kind: "rejected" };
318
622
  try {
319
623
  await actions.edit(selectedName, signal);
320
624
  } catch (error) {
@@ -322,8 +626,8 @@ async function showSyncSetups(ctx, actions, signal) {
322
626
  }
323
627
  return { kind: "stay" };
324
628
  },
325
- remove: async () => {
326
- if (!selectedName) return { kind: "rejected" };
629
+ remove: async ({ state }) => {
630
+ if (!selectedName || !state.selected || state.selected.removeUnavailable) return { kind: "rejected" };
327
631
  const name = selectedName;
328
632
  try {
329
633
  await actions.remove(name, signal);
@@ -348,31 +652,33 @@ async function showSyncSetups(ctx, actions, signal) {
348
652
  return exit ? "exit" : void 0;
349
653
  }
350
654
  async function loadSetupMenuState(selectedName, signal) {
351
- const raw = await readLocalConfigObject();
655
+ const catalog = await loadSettingsCatalog();
352
656
  throwIfAborted(signal);
353
- const setups = ownRecord(raw?.syncSetups) ?? {};
354
- const active = typeof raw?.activeSyncSetup === "string" ? raw.activeSyncSetup : void 0;
355
- if (!selectedName || !ownRecord(setups[selectedName])) return { setups, active };
657
+ if (!catalog) return { setups: {} };
658
+ const { syncSetups: setups, activeSyncSetup: active } = catalog.settings;
659
+ const recovery = catalog.ignoreSetups.length ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(catalog.path)] : void 0;
660
+ if (!selectedName || !Object.hasOwn(setups, selectedName)) return { setups, active, recovery };
356
661
  const setupCount = Object.keys(setups).length;
357
662
  const isCurrent = selectedName === active;
358
663
  let detail;
359
664
  let valid = true;
360
665
  try {
361
- const config = await loadConfig(selectedName);
362
- throwIfAborted(signal);
666
+ const config = configFromSettings(catalog.settings, selectedName);
363
667
  const selection = syncIncludeSelection(config.include);
364
668
  detail = [
365
669
  `Status: ${isCurrent ? "Current" : "Not current"}`,
366
670
  `Storage connection: ${safeTerminalText(config.connectionName)}`,
367
671
  `Endpoint: ${storageEndpoint(config)}`,
368
672
  `Storage location: ${storageLocation(config)}`,
369
- config.scope ? `Sync scope: Pi agent directory \xB7 ${config.exclude?.length ?? 0} exclusions \xB7 ${config.reinclude?.length ?? 0} exceptions` : `Included content: ${selection.builtIns.length} built-in groups \xB7 ${selection.custom.length} extra paths`,
673
+ config.pathPolicy === "ignore-file" ? `Sync scope: Pi agent directory \xB7 ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}` : config.scope ? `Sync scope: Pi agent directory \xB7 ${config.exclude?.length ?? 0} exclusions \xB7 ${config.reinclude?.length ?? 0} exceptions` : `Included content: ${selection.builtIns.length} built-in groups \xB7 ${selection.custom.length} extra paths`,
370
674
  `Sessions: ${syncSessionsSelected(config) ? "On \u2014 privacy-sensitive" : "Off"}`,
371
675
  `Automatic sync: ${config.automatic ? "On" : "Off"}`,
372
676
  `Automatic transfer at startup: ${config.automaticTransfer ? "On \u2014 may upload, replace, or delete selected files; no reload" : "Off"}`,
373
677
  `Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
374
678
  `Continuous sync: ${config.continuous ? config.agentMode ? "On (recurring requests and transfers)" : "Saved On; paused until Autonomous sync is enabled" : "Off"}`,
375
- isCurrent ? "Edit included content and automatic sync in /sync \u2192 Settings." : "To edit included content or automatic sync, make this setup current, then open /sync \u2192 Settings."
679
+ ...recovery ? [] : [
680
+ isCurrent ? "Edit included content and automatic sync in /sync \u2192 Settings." : "To edit included content or automatic sync, make this setup current, then open /sync \u2192 Settings."
681
+ ]
376
682
  ];
377
683
  } catch (error) {
378
684
  valid = false;
@@ -382,11 +688,19 @@ async function loadSetupMenuState(selectedName, signal) {
382
688
  "Make current and sync are unavailable until this setup is repaired."
383
689
  ];
384
690
  }
385
- const removeUnavailable = isCurrent && setupCount > 1;
386
- if (removeUnavailable) detail.push("Remove unavailable: switch to another setup first.");
691
+ const removeNeedsSwitch = isCurrent && setupCount > 1;
692
+ const ignoreSetupsRemain = catalog.ignoreSetups.some((name) => name !== selectedName);
693
+ const removeUnavailable = removeNeedsSwitch || ignoreSetupsRemain;
694
+ if (recovery) {
695
+ if (removeUnavailable) detail.unshift("Remove unavailable here; use manual recovery.");
696
+ detail.unshift(...recovery);
697
+ } else if (removeNeedsSwitch) {
698
+ detail.push("Remove unavailable: switch to another setup first.");
699
+ }
387
700
  return {
388
701
  setups,
389
702
  active,
703
+ recovery,
390
704
  selected: { name: selectedName, detail, valid, removeUnavailable }
391
705
  };
392
706
  }
@@ -439,8 +753,11 @@ var MAIN_MENU_ACTIONS = [
439
753
  async function describeManagerState(signal, attention, inspectOperation = inspectOperationAvailability, observation) {
440
754
  let raw;
441
755
  try {
442
- raw = await readLocalConfigObject();
756
+ const document = await readActiveLocalConfigDocumentForRepair();
757
+ signal?.throwIfAborted();
758
+ if (document) raw = validateSettingsDocument(document.parsed);
443
759
  } catch (error) {
760
+ if (signal?.aborted) throw error;
444
761
  return {
445
762
  title: [
446
763
  "Manage sync",
@@ -460,8 +777,8 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
460
777
  actions: ["Set up sync", "Help"]
461
778
  };
462
779
  }
463
- const configuredTargets = ownRecord(raw.syncSetups);
464
- if ((raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6 || raw.version === 7) && configuredTargets && Object.keys(configuredTargets).length === 0) {
780
+ const configuredTargets = raw.syncSetups;
781
+ if (Object.keys(configuredTargets).length === 0) {
465
782
  return {
466
783
  title: [
467
784
  "Manage sync",
@@ -475,6 +792,21 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
475
792
  };
476
793
  }
477
794
  try {
795
+ const settingsConfig = configFromSettings(raw);
796
+ if (settingsConfig.reservedIgnoreNames !== void 0) {
797
+ return {
798
+ title: [
799
+ "Manage sync",
800
+ `Current sync setup: ${safeTerminalText(settingsConfig.setupName)}`,
801
+ "Transfers are unavailable while ignore-file setups are configured."
802
+ ].join("\n"),
803
+ actions: ["Settings", "Sync setups\u2026", "Storage connections\u2026", "Help"],
804
+ settingsReview: {
805
+ setupName: settingsConfig.setupName,
806
+ fingerprint: syncCheckConfigFingerprint(settingsConfig)
807
+ }
808
+ };
809
+ }
478
810
  const config = await loadConfig();
479
811
  const operation = await inspectOperation();
480
812
  const changesBlocked = operationBlocksChanges(operation);
@@ -494,7 +826,7 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
494
826
  const noSyncedContent = !syncSelectionHasContent(config);
495
827
  const syncState = changesBlocked ? void 0 : await readStateForConfig(config).catch(() => void 0);
496
828
  const currentObservation = observation && observationMatchesConfig(observation, config) && syncState && syncStateFingerprint(syncState) === observation.inspection.stateIdentity ? observation : void 0;
497
- const lastAppliedSnapshot = changesBlocked ? "Unavailable while operations are locked" : syncState?.lastAppliedSnapshot ? `${truncateToWidth(safeTerminalText(syncState.lastAppliedSnapshot), 12, "\u2026")} \xB7 application time unavailable` : syncState ? "Never synced" : "Unavailable";
829
+ const lastAppliedSnapshot = changesBlocked ? "Unavailable while operations are locked" : syncState?.lastAppliedSnapshot ? `${truncateToWidth2(safeTerminalText(syncState.lastAppliedSnapshot), 12, "\u2026")} \xB7 application time unavailable` : syncState ? "Never synced" : "Unavailable";
498
830
  const canSwitch = await countValidSyncSetups(configuredTargets, signal) > 1;
499
831
  const mainActions = [...MAIN_MENU_ACTIONS];
500
832
  if (config.agentMode && !noSyncedContent) mainActions.splice(1, 0, "Retry refused model result\u2026");
@@ -550,8 +882,8 @@ async function backgroundSummary(config) {
550
882
  if (!config.continuous) return [];
551
883
  if (!config.agentMode) return ["Background sync: Paused \xB7 enable Autonomous sync"];
552
884
  try {
553
- const { continuousBinding, readContinuousPrivateDocument } = await import("./continuous-storage-HLKCHF6Z.ts");
554
- const recordApi = await import("./continuous-record-3XDXDOMV.ts");
885
+ const { continuousBinding, readContinuousPrivateDocument } = await import("./continuous-storage-3EU6I7Z3.ts");
886
+ const recordApi = await import("./continuous-record-3SKJ6I3V.ts");
555
887
  const binding = await continuousBinding(config);
556
888
  const document = await readContinuousPrivateDocument(`${binding}.json`);
557
889
  if (!document) return ["Background sync: Enabled \xB7 not yet observed"];
@@ -586,7 +918,7 @@ function operationStatusLines(operation) {
586
918
  case "free":
587
919
  return [];
588
920
  case "live": {
589
- const command = truncateToWidth(safeTerminalText(operation.lock.command), 16, "\u2026");
921
+ const command = truncateToWidth2(safeTerminalText(operation.lock.command), 16, "\u2026");
590
922
  return [
591
923
  `Running: ${command} (pid ${operation.lock.pid}). Wait, then refresh; Transfer actions and Settings return.`
592
924
  ];
@@ -632,7 +964,7 @@ import {
632
964
  sameLocalFields,
633
965
  validatePortableSnapshot,
634
966
  validateSnapshotFieldPolicy
635
- } from "@narumitw/pi-sync-daemon/engine/sync/local-fields";
967
+ } from "#pi-sync-daemon/engine/sync/local-fields";
636
968
 
637
969
  // src/ui/agent-mode-setting.ts
638
970
  import { isDeepStrictEqual } from "node:util";
@@ -758,9 +1090,9 @@ async function showStorageConnections(ctx, signal) {
758
1090
  return {
759
1091
  kind: "actions",
760
1092
  title: "Storage connections",
761
- lines: state.supportedVersion ? ["Server addresses and sign-in details, reusable across sync setups."] : ["Create supported pi-sync settings before managing storage connections."],
1093
+ lines: state.supportedVersion ? state.recovery ?? ["Server addresses and sign-in details, reusable across sync setups."] : ["Create supported pi-sync settings before managing storage connections."],
762
1094
  items: state.supportedVersion ? [
763
- { id: "add", label: "Add storage connection", action: "add" },
1095
+ ...state.recovery ? [] : [{ id: "add", label: "Add storage connection", action: "add" }],
764
1096
  ...names.map((name, index) => {
765
1097
  const id = `connection:${index}`;
766
1098
  nameById.set(id, name);
@@ -780,8 +1112,8 @@ async function showStorageConnections(ctx, signal) {
780
1112
  title: state.selected ? `Storage connection \u201C${safeTerminalText(state.selected.name)}\u201D` : "Storage connection",
781
1113
  lines: state.selected?.lines ?? ["This storage connection no longer exists."],
782
1114
  items: state.selected ? [
783
- { id: "edit", label: "Edit storage connection\u2026", action: "edit" },
784
- ...state.selected.usedBy.length === 0 ? [
1115
+ ...state.recovery ? [] : [{ id: "edit", label: "Edit storage connection\u2026", action: "edit" }],
1116
+ ...!state.recovery && state.selected.usedBy.length === 0 ? [
785
1117
  {
786
1118
  id: "remove",
787
1119
  label: "Remove storage connection\u2026",
@@ -794,7 +1126,8 @@ async function showStorageConnections(ctx, signal) {
794
1126
  })
795
1127
  },
796
1128
  actions: {
797
- add: async () => {
1129
+ add: async ({ state }) => {
1130
+ if (state.recovery) return { kind: "rejected" };
798
1131
  try {
799
1132
  await showAddStorageConnection(ctx, signal);
800
1133
  } catch (error) {
@@ -809,7 +1142,7 @@ async function showStorageConnections(ctx, signal) {
809
1142
  return selectedName ? { kind: "to", screen: "detail" } : { kind: "rejected" };
810
1143
  },
811
1144
  edit: async ({ state }) => {
812
- if (!state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
1145
+ if (state.recovery || !state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
813
1146
  try {
814
1147
  await editStorageConnection(ctx, state.selected.name, state.selected.profile, state.selected.usedBy, signal);
815
1148
  } catch (error) {
@@ -818,7 +1151,7 @@ async function showStorageConnections(ctx, signal) {
818
1151
  return { kind: "stay" };
819
1152
  },
820
1153
  remove: async ({ state }) => {
821
- if (!state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
1154
+ if (state.recovery || !state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
822
1155
  const name = state.selected.name;
823
1156
  const confirmed = await ctx.ui.confirm(
824
1157
  "Remove storage connection?",
@@ -849,14 +1182,17 @@ async function showStorageConnections(ctx, signal) {
849
1182
  });
850
1183
  }
851
1184
  async function loadStorageMenuState(selectedName, signal) {
852
- const raw = await readLocalConfigObject();
853
- if (signal?.aborted) throw signal.reason;
854
- const profiles = ownRecord(raw?.storageConnections) ?? {};
1185
+ const catalog = await loadSettingsCatalog();
1186
+ signal?.throwIfAborted();
1187
+ const raw = catalog?.settings;
1188
+ const profiles = raw?.storageConnections ?? {};
1189
+ const recovery = catalog?.ignoreSetups.length ? ["Connection changes are unavailable while any setup uses an ignore file.", ...ignoreSetupRecovery(catalog.path)] : void 0;
855
1190
  const profile = selectedName ? ownRecord(profiles[selectedName]) : void 0;
856
1191
  if (!selectedName || !profile) {
857
1192
  return {
858
1193
  supportedVersion: raw !== void 0,
859
1194
  profiles,
1195
+ recovery,
860
1196
  selected: void 0
861
1197
  };
862
1198
  }
@@ -864,16 +1200,18 @@ async function loadStorageMenuState(selectedName, signal) {
864
1200
  return {
865
1201
  supportedVersion: raw !== void 0,
866
1202
  profiles,
1203
+ recovery,
867
1204
  selected: {
868
1205
  name: selectedName,
869
1206
  profile,
870
1207
  usedBy,
871
1208
  lines: [
1209
+ ...recovery ?? [],
872
1210
  `Type: ${connectionType(profile)}`,
873
1211
  `Endpoint: ${connectionEndpoint(profile)}`,
874
1212
  `Credentials: ${credentialSource(profile)}`,
875
1213
  `Used by: ${usedBy.length > 0 ? usedBy.map(safeTerminalText).join(", ") : "No sync setups"}`,
876
- ...usedBy.length > 0 ? [
1214
+ ...!recovery && usedBy.length > 0 ? [
877
1215
  "Remove unavailable: remove the listed sync setups first. Switch away from a current setup before removing it if other setups remain."
878
1216
  ] : []
879
1217
  ]
@@ -1304,47 +1642,65 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1304
1642
  disposition = "exit";
1305
1643
  return { kind: "close" };
1306
1644
  };
1307
- if (ctx.mode !== "tui") {
1308
- if (ctx.mode === "rpc" && ctx.hasUI) {
1309
- const config = await loadConfig(reviewedSetup).catch(() => void 0);
1310
- if (signal?.aborted) return disposition;
1311
- ctx.ui.notify(
1312
- [
1313
- `Edit pi-sync settings manually: ${safeTerminalText(localConfigPath())}`,
1314
- ...config?.scope === "agent-directory" ? directoryScopeSummary(config) : []
1315
- ].join("\n"),
1316
- "info"
1317
- );
1318
- const management = defineMenu4({
1319
- start: "management",
1320
- screens: {
1321
- management: () => ({
1322
- kind: "actions",
1323
- title: "Sync settings management",
1324
- items: [
1325
- { id: "setups", label: "Manage sync setups", action: "setups" },
1326
- { id: "connections", label: "Manage storage connections", action: "connections" }
1327
- ],
1328
- hint: "back"
1329
- })
1645
+ if (!ctx.hasUI || signal?.aborted || ctx.mode !== "tui" && ctx.mode !== "rpc") return disposition;
1646
+ const validateSettingsOwner = captureMutationOwner(ctx, signal);
1647
+ const isCurrent = () => {
1648
+ try {
1649
+ validateSettingsOwner();
1650
+ return true;
1651
+ } catch {
1652
+ return false;
1653
+ }
1654
+ };
1655
+ if (ctx.mode === "rpc") {
1656
+ const document = await readActiveLocalConfigDocumentForRepair().catch(() => null);
1657
+ if (!isCurrent()) return disposition;
1658
+ const settingsPath = document?.path ?? localConfigPath();
1659
+ let config;
1660
+ try {
1661
+ if (document) config = configFromSettings(validateSettingsDocument(document.parsed), reviewedSetup);
1662
+ } catch {
1663
+ config = void 0;
1664
+ }
1665
+ ctx.ui.notify(
1666
+ [
1667
+ document === null ? "Could not read the active pi-sync settings file. Check file access or repair the JSON before reopening /sync." : `Edit pi-sync settings manually: ${safeTerminalText(settingsPath)}`,
1668
+ ...config?.reservedIgnoreNames !== void 0 ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(settingsPath)] : [],
1669
+ ...config?.pathPolicy === "ignore-file" ? [manualIgnoreFileGuidance(config.ignoreFile ?? ".syncignore")] : config?.scope === "agent-directory" ? directoryScopeSummary(config) : []
1670
+ ].join("\n"),
1671
+ "info"
1672
+ );
1673
+ const management = defineMenu4({
1674
+ start: "management",
1675
+ screens: {
1676
+ management: () => ({
1677
+ kind: "actions",
1678
+ title: "Sync settings management",
1679
+ items: [
1680
+ { id: "setups", label: "Manage sync setups", action: "setups" },
1681
+ { id: "connections", label: "Manage storage connections", action: "connections" }
1682
+ ],
1683
+ hint: "back"
1684
+ })
1685
+ },
1686
+ actions: {
1687
+ setups: async ({ signal: actionSignal }) => {
1688
+ const result = await showSyncSetupManager(ctx, runRoute, actionSignal);
1689
+ return result === "exit" ? exitSettings() : { kind: "stay" };
1330
1690
  },
1331
- actions: {
1332
- setups: async ({ signal: actionSignal }) => {
1333
- const result = await showSyncSetupManager(ctx, runRoute, actionSignal);
1334
- return result === "exit" ? exitSettings() : { kind: "stay" };
1335
- },
1336
- connections: async ({ signal: actionSignal }) => {
1337
- await showStorageConnections(ctx, actionSignal);
1338
- return { kind: "stay" };
1339
- }
1691
+ connections: async ({ signal: actionSignal }) => {
1692
+ await showStorageConnections(ctx, actionSignal);
1693
+ return { kind: "stay" };
1340
1694
  }
1341
- });
1342
- await runMenu4(ctx, management, { getState: () => void 0, signal, isCurrent: () => !signal?.aborted });
1343
- }
1695
+ }
1696
+ });
1697
+ await runMenu4(ctx, management, { getState: () => void 0, signal, isCurrent });
1344
1698
  return disposition;
1345
1699
  }
1346
- const initial = await loadConfig(reviewedSetup);
1347
- if (signal?.aborted) return "back";
1700
+ const initial = await loadSettingsConfig(reviewedSetup);
1701
+ if (!isCurrent()) return disposition;
1702
+ const ignoreAvailable = await ignoreFileSettingsAvailable(ctx, signal);
1703
+ if (!isCurrent()) return disposition;
1348
1704
  const setupName = initial.setupName;
1349
1705
  let saveStatus = "Simple choices save immediately. Back does not undo saved changes.";
1350
1706
  const menu = defineMenu4({
@@ -1355,10 +1711,36 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1355
1711
  title: "Pi Sync Settings",
1356
1712
  lines: [
1357
1713
  `Setup: ${safeTerminalText(state.setupName)} \xB7 Connection: ${safeTerminalText(state.connectionName)}`,
1358
- saveStatus
1714
+ ...state.reservedIgnoreNames !== void 0 ? [
1715
+ "Setup preferences are read-only; adding, editing, and switching setups are unavailable.",
1716
+ state.pathPolicy === "ignore-file" && !ignoreAvailable ? manualIgnoreFileGuidance(state.ignoreFile ?? ".syncignore") : "Open Manage sync setups for manual recovery."
1717
+ ] : [saveStatus]
1359
1718
  ],
1360
1719
  items: [
1361
- ...state.scope === "agent-directory" ? [
1720
+ ...state.pathPolicy === "ignore-file" ? ignoreAvailable ? [
1721
+ {
1722
+ id: "ignoreFile",
1723
+ label: "Ignore file",
1724
+ description: "Select another existing file in the Pi agent directory. No transfer starts.",
1725
+ currentValue: safeTerminalText(state.ignoreFile ?? ".syncignore"),
1726
+ action: "ignore-switch"
1727
+ },
1728
+ {
1729
+ id: "ignoreRules",
1730
+ label: "Edit ignore rules\u2026",
1731
+ description: `Edit the existing local rules, then confirm separately. Sessions: ${state.include.includes("sessions") ? "opted in (ignore rules still apply)" : "off"}.`,
1732
+ currentValue: "Edit",
1733
+ action: "ignore-edit"
1734
+ }
1735
+ ] : [] : ignoreAvailable ? [
1736
+ {
1737
+ id: "migrateIgnoreFile",
1738
+ label: "Migrate to ignore file\u2026",
1739
+ description: "Review the scope change for this legacy setup. Migration does not start a transfer.",
1740
+ currentValue: "Review",
1741
+ action: "ignore-migrate"
1742
+ }
1743
+ ] : state.reservedIgnoreNames !== void 0 ? [] : state.scope === "agent-directory" ? [
1362
1744
  {
1363
1745
  id: "include",
1364
1746
  label: "Agent directory scope",
@@ -1382,13 +1764,15 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1382
1764
  action: "exclude"
1383
1765
  }
1384
1766
  ],
1385
- {
1386
- id: "remoteInclude",
1387
- label: state.scope === "agent-directory" ? "Compare sync policies" : "Compare included paths",
1388
- description: "Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
1389
- currentValue: "Review",
1390
- action: "remote-include"
1391
- },
1767
+ ...state.reservedIgnoreNames !== void 0 ? [] : [
1768
+ {
1769
+ id: "remoteInclude",
1770
+ label: ignoreAvailable || state.scope === "agent-directory" ? "Compare sync policies" : "Compare included paths",
1771
+ description: "Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
1772
+ currentValue: "Review",
1773
+ action: "remote-include"
1774
+ }
1775
+ ],
1392
1776
  {
1393
1777
  id: "localFields",
1394
1778
  label: "Machine-local fields",
@@ -1406,14 +1790,14 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1406
1790
  {
1407
1791
  id: "setups",
1408
1792
  label: "Manage sync setups",
1409
- description: "This device: add, switch, edit, or remove sync setups. Each edit identifies its owner before saving.",
1793
+ description: state.reservedIgnoreNames !== void 0 ? "Review configured setups and recovery options. Adding, editing, and switching are unavailable." : "This device: add, switch, edit, or remove sync setups. Each edit identifies its owner before saving.",
1410
1794
  currentValue: "Open",
1411
1795
  action: "setups"
1412
1796
  },
1413
1797
  {
1414
1798
  id: "connections",
1415
1799
  label: "Manage storage connections",
1416
- description: "Shared connections on this device: review affected setups before saving server or credential changes.",
1800
+ description: state.reservedIgnoreNames !== void 0 ? "Review shared connections. Connection changes are unavailable while ignore-file setups are configured." : "Shared connections on this device: review affected setups before saving server or credential changes.",
1417
1801
  currentValue: "Open",
1418
1802
  action: "connections"
1419
1803
  },
@@ -1497,7 +1881,9 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1497
1881
  values: ["On", "Off"],
1498
1882
  action: "debug"
1499
1883
  }
1500
- ]
1884
+ ].map(
1885
+ (item) => state.reservedIgnoreNames !== void 0 && !["setups", "connections", "ignoreFile", "ignoreRules", "migrateIgnoreFile"].includes(item.id) ? { ...item, disabled: true } : item
1886
+ )
1501
1887
  })
1502
1888
  },
1503
1889
  actions: {
@@ -1784,9 +2170,13 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1784
2170
  await showExcludedPaths(ctx, setupName, editorSignal);
1785
2171
  return resumeSettings(editorSignal);
1786
2172
  },
1787
- "remote-include": async ({ signal: actionSignal }) => {
2173
+ "ignore-switch": ignoreAction("switch"),
2174
+ "ignore-edit": ignoreAction("edit"),
2175
+ "ignore-migrate": ignoreAction("migrate"),
2176
+ "remote-include": async ({ state, signal: actionSignal }) => {
2177
+ if (state.reservedIgnoreNames !== void 0) return { kind: "rejected" };
1788
2178
  const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
1789
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-W3KOZM3W.ts");
2179
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-4BTP2OJR.ts");
1790
2180
  if (reviewSignal.aborted) return { kind: "rejected" };
1791
2181
  const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, void 0, {
1792
2182
  origin: "settings",
@@ -1823,20 +2213,29 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1823
2213
  return result;
1824
2214
  };
1825
2215
  }
2216
+ function ignoreAction(action) {
2217
+ return async ({ state, signal: actionSignal }) => {
2218
+ if (!ignoreAvailable || state.pathPolicy === "ignore-file" === (action === "migrate"))
2219
+ return { kind: "rejected" };
2220
+ const editorSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
2221
+ await showIgnoreFileAction(ctx, setupName, action, state.ignoreFile ?? ".syncignore", editorSignal);
2222
+ return resumeSettings(editorSignal);
2223
+ };
2224
+ }
1826
2225
  async function resumeSettings(editorSignal) {
1827
- if (editorSignal.aborted) return { kind: "close" };
2226
+ if (editorSignal.aborted || !isCurrent()) return { kind: "close" };
1828
2227
  try {
1829
- const active = await loadConfig();
1830
- if (editorSignal.aborted || active.setupName !== setupName) return { kind: "close" };
2228
+ const active = await loadSettingsConfig();
2229
+ if (editorSignal.aborted || !isCurrent() || active.setupName !== setupName) return { kind: "close" };
1831
2230
  return { kind: "stay" };
1832
2231
  } catch {
1833
2232
  return { kind: "close" };
1834
2233
  }
1835
2234
  }
1836
2235
  await runMenu4({ ...ctx, ui: boundedSettingsUI(ctx) }, menu, {
1837
- getState: () => loadConfig(setupName),
2236
+ getState: () => loadSettingsConfig(setupName),
1838
2237
  signal,
1839
- isCurrent: () => !signal?.aborted
2238
+ isCurrent
1840
2239
  });
1841
2240
  return disposition;
1842
2241
  }
@@ -1901,7 +2300,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
1901
2300
  if (!attention) {
1902
2301
  const observation = state.manager.observation;
1903
2302
  if (!observation) return { kind: "stay" };
1904
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-W3KOZM3W.ts");
2303
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-4BTP2OJR.ts");
1905
2304
  if (sessionSignal?.aborted) return { kind: "close" };
1906
2305
  const config = await loadConfig();
1907
2306
  if (sessionSignal?.aborted) return { kind: "close" };
@@ -1971,8 +2370,10 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
1971
2370
  const result = await showSetupSwitcher(ctx, runRoute, void 0, sessionSignal);
1972
2371
  return result === "pull-attempted" || result === "closed" ? { kind: "close" } : { kind: "stay" };
1973
2372
  },
1974
- settings: async ({ state }) => {
1975
- const result = await showSyncSettings(ctx, runRoute, sessionSignal, state.manager.configReview?.setupName);
2373
+ settings: async ({ state, signal: actionSignal }) => {
2374
+ const signal = sessionSignal ? AbortSignal.any([sessionSignal, actionSignal]) : actionSignal;
2375
+ const review = state.manager.settingsReview ?? state.manager.configReview;
2376
+ const result = await showSyncSettings(ctx, runRoute, signal, review?.setupName);
1976
2377
  return { kind: result === "exit" ? "close" : "stay" };
1977
2378
  },
1978
2379
  pull: async ({ state }) => {
@@ -2033,7 +2434,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
2033
2434
  const config = await loadConfig(state.manager.configReview?.setupName);
2034
2435
  validate();
2035
2436
  if (config.continuous) {
2036
- const { continuousStatusLines } = await import("./continuous-record-3XDXDOMV.ts");
2437
+ const { continuousStatusLines } = await import("./continuous-record-3SKJ6I3V.ts");
2037
2438
  validate();
2038
2439
  const lines = await continuousStatusLines(config);
2039
2440
  validate();
@@ -2118,10 +2519,11 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2118
2519
  const activate = menu.actions[action];
2119
2520
  menu.actions[action] = async (invocation) => {
2120
2521
  validateOwner();
2121
- const review = invocation.state.manager.configReview;
2522
+ const { configReview, settingsReview } = invocation.state.manager;
2523
+ const review = action === "settings" ? settingsReview ?? configReview : configReview;
2122
2524
  let current = false;
2123
2525
  try {
2124
- const config = await loadConfig();
2526
+ const config = await (action === "settings" ? loadSettingsConfig() : loadConfig());
2125
2527
  validateOwner();
2126
2528
  invocation.signal.throwIfAborted();
2127
2529
  current = review?.fingerprint === syncCheckConfigFingerprint(config);
@@ -2153,17 +2555,27 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2153
2555
  }, customOptions)
2154
2556
  }
2155
2557
  };
2558
+ let firstOpen = true;
2559
+ const describe = async (signal) => {
2560
+ const pendingAttention = options.getAttention?.();
2561
+ const observation = options.getObservation?.();
2562
+ const manager = await describeManagerState(signal, pendingAttention, void 0, observation);
2563
+ if (signal.aborted || !isCurrent()) return manager;
2564
+ if (observation && options.getObservation?.() === observation && !manager.observation && !(manager.operation && operationBlocksChanges(manager.operation))) {
2565
+ options.onObservationInvalidated?.();
2566
+ }
2567
+ if (pendingAttention && options.getAttention?.() === pendingAttention && !manager.attention) {
2568
+ options.onSelectionResolved?.(pendingAttention);
2569
+ }
2570
+ return manager;
2571
+ };
2156
2572
  await runMenu5(menuContext, menu, {
2157
- getState: async () => {
2158
- const pendingAttention = options.getAttention?.();
2159
- const observation = options.getObservation?.();
2160
- const manager = await describeManagerState(sessionSignal, pendingAttention, void 0, observation);
2161
- if (sessionSignal?.aborted) return { manager };
2162
- if (observation && options.getObservation?.() === observation && !manager.observation && !(manager.operation && operationBlocksChanges(manager.operation))) {
2163
- options.onObservationInvalidated?.();
2164
- }
2165
- if (pendingAttention && options.getAttention?.() === pendingAttention && !manager.attention) {
2166
- options.onSelectionResolved?.(pendingAttention);
2573
+ getState: async ({ signal }) => {
2574
+ const offerOnOpen = firstOpen;
2575
+ firstOpen = false;
2576
+ let manager = await describe(signal);
2577
+ if (offerOnOpen && manager.operation?.kind === "free" && manager.configReview && await showIgnoreMigrationPrompt(ctx, manager.configReview.setupName, signal, isCurrent)) {
2578
+ if (!signal.aborted && isCurrent()) manager = await describe(signal);
2167
2579
  }
2168
2580
  return { manager };
2169
2581
  },
@@ -2222,4 +2634,4 @@ function syncMainMenuItem(label) {
2222
2634
  export {
2223
2635
  showSyncManager
2224
2636
  };
2225
- //# sourceMappingURL=manager-ui-KYQ5AZJS.ts.map
2637
+ //# sourceMappingURL=manager-ui-AOFUNXAJ.ts.map