@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
@@ -1,9 +1,12 @@
1
1
  import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
2
  import { defineMenu, type MenuSettingItem, runMenu } from "@narumitw/pi-tui-kit";
3
- import { loadConfig } from "../settings/config.js";
4
- import { localConfigPath } from "../settings/config-file.js";
3
+ import { piDaemonClient } from "../daemon/pi-client.js";
4
+ import { configFromSettings, loadSettingsConfig, syncCheckConfigFingerprint } from "../settings/config.js";
5
+ import { localConfigPath, readActiveLocalConfigDocumentForRepair } from "../settings/config-file.js";
5
6
  import { updateSyncSetup } from "../settings/settings-management.js";
6
7
  import { updateLocalConfig } from "../settings/settings-store.js";
8
+ import { validateSettingsDocument } from "../settings/settings-validation.js";
9
+ import { startupTransferEnabled } from "../sync/agent-policy.js";
7
10
  import { normalizeLocalFields, sameLocalFields } from "../sync/local-fields.js";
8
11
  import {
9
12
  SETUP_SWITCH_ACTION_OPTIONS,
@@ -12,6 +15,7 @@ import {
12
15
  setupSwitchActionLabel,
13
16
  } from "../sync/setup-switch.js";
14
17
  import { captureMutationOwner } from "../sync/sync-local.js";
18
+ import { syncSessionsSelected } from "../sync/sync-policy.js";
15
19
  import {
16
20
  AGENT_MODE_DESCRIPTION,
17
21
  CONTINUOUS_DESCRIPTION,
@@ -20,8 +24,11 @@ import {
20
24
  } from "./agent-mode-setting.js";
21
25
  import type { RunRoute } from "./cancellable-operation.js";
22
26
  import { directoryScopeSummary, showExcludedPaths } from "./excluded-paths-ui.js";
27
+ import { manualIgnoreFileGuidance } from "./ignore-file-guidance.js";
28
+ import { ignoreFileSettingsAvailable, showIgnoreFileAction } from "./ignore-file-ui.js";
23
29
  import { dispatchManagerResult } from "./manager-result-dispatcher.js";
24
30
  import { boundedSettingsUI } from "./settings-frame.js";
31
+ import { IGNORE_SETUP_MANAGEMENT_LIMIT, ignoreSetupRecovery } from "./settings-review.js";
25
32
  import { showEditSyncSetupStorage, showSyncSetupManager } from "./setup/setup-actions.js";
26
33
  import { showStorageConnections } from "./storage-connections-ui.js";
27
34
  import { AUTOMATIC_SYNC_DESCRIPTION, STARTUP_TRANSFER_DESCRIPTION, startupTransferSummary } from "./sync-behavior.js";
@@ -41,54 +48,85 @@ export async function showSyncSettings(
41
48
  disposition = "exit";
42
49
  return { kind: "close" as const };
43
50
  };
44
- if (ctx.mode !== "tui") {
45
- if (ctx.mode === "rpc" && ctx.hasUI) {
46
- // Preserve RPC catalog management; preference/credential editing stays TUI-only.
47
- const config = await loadConfig(reviewedSetup).catch(() => undefined);
48
- if (signal?.aborted) return disposition;
49
- ctx.ui.notify(
50
- [
51
- `Edit pi-sync settings manually: ${safeTerminalText(localConfigPath())}`,
52
- ...(config?.scope === "agent-directory" ? directoryScopeSummary(config) : []),
53
- ].join("\n"),
54
- "info",
55
- );
56
- const management = defineMenu<undefined, "management", "setups" | "connections", ExtensionCommandContext>({
57
- start: "management",
58
- screens: {
59
- management: () => ({
60
- kind: "actions",
61
- title: "Sync settings management",
62
- items: [
63
- { id: "setups", label: "Manage sync setups", action: "setups" },
64
- { id: "connections", label: "Manage storage connections", action: "connections" },
65
- ],
66
- hint: "back",
67
- }),
51
+ if (!ctx.hasUI || signal?.aborted || (ctx.mode !== "tui" && ctx.mode !== "rpc")) return disposition;
52
+ const validateSettingsOwner = captureMutationOwner(ctx, signal);
53
+ const isCurrent = () => {
54
+ try {
55
+ validateSettingsOwner();
56
+ return true;
57
+ } catch {
58
+ return false;
59
+ }
60
+ };
61
+ if (ctx.mode === "rpc") {
62
+ // Preserve RPC catalog management; preference/credential editing stays TUI-only.
63
+ const document = await readActiveLocalConfigDocumentForRepair().catch(() => null);
64
+ if (!isCurrent()) return disposition;
65
+ const settingsPath = document?.path ?? localConfigPath();
66
+ let config: Awaited<ReturnType<typeof loadSettingsConfig>> | undefined;
67
+ try {
68
+ if (document) config = configFromSettings(validateSettingsDocument(document.parsed), reviewedSetup);
69
+ } catch {
70
+ config = undefined;
71
+ }
72
+ const limited = config?.reservedIgnoreNames !== undefined && !(await ignoreFileSettingsAvailable(ctx, signal));
73
+ if (!isCurrent()) return disposition;
74
+ ctx.ui.notify(
75
+ [
76
+ document === null
77
+ ? "Could not read the active pi-sync settings file. Check file access or repair the JSON before reopening /sync."
78
+ : `Edit pi-sync settings manually: ${safeTerminalText(settingsPath)}`,
79
+ ...(limited ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(settingsPath)] : []),
80
+ ...(!limited && config?.reservedIgnoreNames !== undefined
81
+ ? ["Use TUI Settings → Review automatic transfers to approve the current setup separately."]
82
+ : []),
83
+ ...(config?.pathPolicy === "ignore-file"
84
+ ? [manualIgnoreFileGuidance(config.ignoreFile ?? ".syncignore")]
85
+ : config?.scope === "agent-directory"
86
+ ? directoryScopeSummary(config)
87
+ : []),
88
+ ].join("\n"),
89
+ "info",
90
+ );
91
+ const management = defineMenu<undefined, "management", "setups" | "connections", ExtensionCommandContext>({
92
+ start: "management",
93
+ screens: {
94
+ management: () => ({
95
+ kind: "actions",
96
+ title: "Sync settings management",
97
+ items: [
98
+ { id: "setups", label: "Manage sync setups", action: "setups" },
99
+ { id: "connections", label: "Manage storage connections", action: "connections" },
100
+ ],
101
+ hint: "back",
102
+ }),
103
+ },
104
+ actions: {
105
+ setups: async ({ signal: actionSignal }) => {
106
+ const result = await showSyncSetupManager(ctx, runRoute, actionSignal);
107
+ return result === "exit" ? exitSettings() : { kind: "stay" };
68
108
  },
69
- actions: {
70
- setups: async ({ signal: actionSignal }) => {
71
- const result = await showSyncSetupManager(ctx, runRoute, actionSignal);
72
- return result === "exit" ? exitSettings() : { kind: "stay" };
73
- },
74
- connections: async ({ signal: actionSignal }) => {
75
- await showStorageConnections(ctx, actionSignal);
76
- return { kind: "stay" };
77
- },
109
+ connections: async ({ signal: actionSignal }) => {
110
+ await showStorageConnections(ctx, actionSignal);
111
+ return { kind: "stay" };
78
112
  },
79
- });
80
- await runMenu(ctx, management, { getState: () => undefined, signal, isCurrent: () => !signal?.aborted });
81
- }
113
+ },
114
+ });
115
+ await runMenu(ctx, management, { getState: () => undefined, signal, isCurrent });
82
116
  return disposition;
83
117
  }
84
- const initial = await loadConfig(reviewedSetup);
85
- if (signal?.aborted) return "back";
118
+ const initial = await loadSettingsConfig(reviewedSetup);
119
+ if (!isCurrent()) return disposition;
120
+ const ignoreAvailable = await ignoreFileSettingsAvailable(ctx, signal);
121
+ if (!isCurrent()) return disposition;
86
122
  const setupName = initial.setupName;
123
+ type SettingsState = Awaited<ReturnType<typeof loadSettingsConfig>>;
87
124
  type Action =
88
125
  | "automatic"
89
126
  | "automatic-transfer"
90
127
  | "agent-mode"
91
128
  | "continuous"
129
+ | "authorize-automatic"
92
130
  | "merge-settings"
93
131
  | "local-fields"
94
132
  | "content-policy"
@@ -98,6 +136,8 @@ export async function showSyncSettings(
98
136
  | "on-switch"
99
137
  | "include"
100
138
  | "exclude"
139
+ | "ignore-switch"
140
+ | "ignore-migrate"
101
141
  | "remote-include"
102
142
  | "storage-location"
103
143
  | "setups"
@@ -105,7 +145,7 @@ export async function showSyncSettings(
105
145
  let saveStatus = "Simple choices save immediately. Back does not undo saved changes.";
106
146
  // Keep Kit's existing settings adapter: native SettingsList has no async save/rollback
107
147
  // contract or injected keybindings. Kit preserves these safety and accessibility behaviors.
108
- const menu = defineMenu<Awaited<ReturnType<typeof loadConfig>>, "settings", Action, ExtensionCommandContext>({
148
+ const menu = defineMenu<SettingsState, "settings", Action, ExtensionCommandContext>({
109
149
  start: "settings",
110
150
  screens: {
111
151
  settings: ({ state }) => ({
@@ -113,174 +153,237 @@ export async function showSyncSettings(
113
153
  title: "Pi Sync Settings",
114
154
  lines: [
115
155
  `Setup: ${safeTerminalText(state.setupName)} · Connection: ${safeTerminalText(state.connectionName)}`,
116
- saveStatus,
156
+ ...(state.reservedIgnoreNames !== undefined && !ignoreAvailable
157
+ ? ["Setup preferences are read-only; adding, editing, and switching setups are unavailable."]
158
+ : [saveStatus]),
159
+ ...(state.pathPolicy === "ignore-file" ? [manualIgnoreFileGuidance(state.ignoreFile ?? ".syncignore")] : []),
117
160
  ],
118
- items: [
119
- ...(state.scope === "agent-directory"
120
- ? [
121
- {
122
- id: "include",
123
- label: "Agent directory scope",
124
- description:
125
- "Edit exclusions, re-inclusions, and session opt-in in one reviewed draft. No transfer starts.",
126
- currentValue: `${state.exclude?.length ?? 0} excluded · ${state.reinclude?.length ?? 0} re-included · Sessions ${state.include.includes("sessions") ? "opted in" : "off"}`,
127
- action: "include" as const,
128
- },
129
- ]
130
- : [
131
- {
132
- id: "include",
133
- label: "Included paths",
134
- description:
135
- "This setup: choose paths in a draft, then review and Save or Discard. No transfer is started.",
136
- currentValue: `${state.include.length} paths · Edit`,
137
- action: "include" as const,
138
- },
139
- {
140
- id: "exclude",
141
- label: "Excluded paths",
142
- description:
143
- "This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
144
- currentValue: `${state.exclude?.length ?? 0} rules · Edit`,
145
- action: "exclude" as const,
146
- },
147
- ]),
148
- {
149
- id: "remoteInclude",
150
- label: state.scope === "agent-directory" ? "Compare sync policies" : "Compare included paths",
151
- description:
152
- "Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
153
- currentValue: "Review",
154
- action: "remote-include",
155
- },
156
- {
157
- id: "localFields",
158
- label: "Machine-local fields",
159
- description:
160
- "This setup: settings.json root fields excluded from future portable snapshots, not project overrides. Policy changes require reviewed directional migration; old history remains.",
161
- currentValue: `${state.localFields?.length ?? 0} fields · Edit`,
162
- action: "local-fields",
163
- },
164
- {
165
- id: "storageLocation",
166
- label: "Storage location",
167
- description: "This setup: review and save bucket, branch, or path changes. Remote history is not moved.",
168
- currentValue:
169
- state.backend.type === "s3"
170
- ? `${safeTerminalText(state.backend.destination.bucket)} · ${safeTerminalText(state.backend.destination.prefix)}`
171
- : state.backend.type === "git"
172
- ? `${safeTerminalText(state.backend.destination.branch)} · ${safeTerminalText(state.backend.destination.directory)}`
173
- : safeTerminalText(state.backend.destination.path),
174
- action: "storage-location",
175
- },
176
- {
177
- id: "setups",
178
- label: "Manage sync setups",
179
- description:
180
- "This device: add, switch, edit, or remove sync setups. Each edit identifies its owner before saving.",
181
- currentValue: "Open",
182
- action: "setups",
183
- },
184
- {
185
- id: "connections",
186
- label: "Manage storage connections",
187
- description:
188
- "Shared connections on this device: review affected setups before saving server or credential changes.",
189
- currentValue: "Open",
190
- action: "connections",
191
- },
192
- {
193
- id: "automatic",
194
- label: "Automatic sync",
195
- description: AUTOMATIC_SYNC_DESCRIPTION,
196
- currentValue: state.automatic ? "On" : "Off",
197
- values: ["On", "Off"],
198
- action: "automatic",
199
- },
200
- {
201
- id: "automaticTransfer",
202
- label: "Startup transfer",
203
- description: `${STARTUP_TRANSFER_DESCRIPTION} Saved preference and requirements: ${startupTransferSummary(state)}.`,
204
- currentValue: state.automaticTransfer ? "On" : "Off",
205
- values: ["On", "Off"],
206
- action: "automatic-transfer",
207
- },
208
- {
209
- id: "agentMode",
210
- label: "Autonomous sync",
211
- description: AGENT_MODE_DESCRIPTION,
212
- currentValue: state.agentMode ? "On" : "Off",
213
- values: ["On", "Off"],
214
- action: "agent-mode",
215
- },
216
- {
217
- id: "continuous",
218
- label: "Continuous sync",
219
- description: `${CONTINUOUS_DESCRIPTION}${state.continuous && !state.agentMode ? " Saved On, but paused until Autonomous sync is enabled." : ""}`,
220
- currentValue: state.continuous ? "On" : "Off",
221
- values: ["On", "Off"],
222
- action: "continuous",
223
- },
224
- {
225
- id: "onSwitch",
226
- label: "On setup switch",
227
- description:
228
- "All setups on this device: ask before a pull review, open it automatically, or switch without pulling. Applies to subsequent switches.",
229
- currentValue: setupSwitchActionLabel(state.onSwitch),
230
- values: SETUP_SWITCH_ACTION_OPTIONS.map(({ label }) => label),
231
- action: "on-switch",
232
- },
233
- {
234
- id: "mergeSettings",
235
- label: "Merge settings fields",
236
- description:
237
- "This setup, opt-in: merge independent global settings.json root fields with a verified private ancestor. Arrays and nested objects remain atomic. Applies to subsequent sync; no reload.",
238
- currentValue: state.mergeSettings ? "On" : "Off",
239
- values: ["On", "Off"],
240
- action: "merge-settings",
241
- },
242
- {
243
- id: "contentPolicy",
244
- label: "Content merge / partial progress",
245
- description: `This setup, opt-in: ${state.scope === "agent-directory" ? "review format compatibility" : "review the version-5 upgrade"} before saving. Merge bounded text and prefix-only sessions; partial progress keeps withheld versions and baselines. Applies to subsequent sync; disabling does not clear recovery evidence.`,
246
- currentValue: state.mergeContent
247
- ? state.partialSync
248
- ? "Merge + partial"
249
- : "Merge only"
250
- : state.partialSync
251
- ? "Partial only"
252
- : "Off",
253
- values: ["Off", "Merge only", "Merge + partial", "Partial only"],
254
- action: "content-policy",
255
- },
256
- {
257
- id: "skipSecretScan",
258
- label: "Skip secret scan",
259
- description:
260
- "All setups on this device: skip possible-secret checks on subsequent pushes, including automatic pushes. Other safety checks remain. Diagnostics still scans.",
261
- currentValue: state.skipSecretScan ? "On" : "Off",
262
- values: ["On", "Off"],
263
- action: "skip-secret-scan",
264
- },
265
- {
266
- id: "showStatus",
267
- label: "Show sync status",
268
- description:
269
- "All setups on this device: saved and applied immediately to Pi status. Review widgets and notifications remain available.",
270
- currentValue: state.showStatus ? "On" : "Off",
271
- values: ["On", "Off"],
272
- action: "show-status",
273
- },
274
- {
275
- id: "debug",
276
- label: "Debug startup timings",
277
- description:
278
- "All setups on this device: show startup durations in the TUI transcript or RPC notifications, including initial Continuous sync. Applies next session start; no credentials or file contents.",
279
- currentValue: state.debug ? "On" : "Off",
280
- values: ["On", "Off"],
281
- action: "debug",
282
- },
283
- ] satisfies MenuSettingItem<Action>[],
161
+ items: (
162
+ [
163
+ ...(state.pathPolicy === "ignore-file"
164
+ ? ignoreAvailable
165
+ ? [
166
+ {
167
+ id: "ignoreFile",
168
+ label: "Ignore file",
169
+ description: `Select another existing local file. Sessions: ${state.include.includes("sessions") ? "opted in (rules still apply)" : "off"}. No transfer starts.`,
170
+ currentValue: safeTerminalText(state.ignoreFile ?? ".syncignore"),
171
+ action: "ignore-switch" as const,
172
+ },
173
+ ]
174
+ : []
175
+ : state.reservedIgnoreNames !== undefined && !ignoreAvailable
176
+ ? []
177
+ : state.scope === "agent-directory"
178
+ ? [
179
+ {
180
+ id: "include",
181
+ label: "Agent directory scope",
182
+ description:
183
+ "Edit exclusions, re-inclusions, and session opt-in in one reviewed draft. No transfer starts.",
184
+ currentValue: `${state.exclude?.length ?? 0} excluded · ${state.reinclude?.length ?? 0} re-included · Sessions ${state.include.includes("sessions") ? "opted in" : "off"}`,
185
+ action: "include" as const,
186
+ },
187
+ ]
188
+ : [
189
+ {
190
+ id: "include",
191
+ label: "Included paths",
192
+ description:
193
+ "This setup: choose paths in a draft, then review and Save or Discard. No transfer is started.",
194
+ currentValue: `${state.include.length} paths · Edit`,
195
+ action: "include" as const,
196
+ },
197
+ {
198
+ id: "exclude",
199
+ label: "Excluded paths",
200
+ description:
201
+ "This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
202
+ currentValue: `${state.exclude?.length ?? 0} rules · Edit`,
203
+ action: "exclude" as const,
204
+ },
205
+ ]),
206
+ ...(ignoreAvailable && state.pathPolicy !== "ignore-file"
207
+ ? [
208
+ {
209
+ id: "migrateIgnoreFile",
210
+ label: "Migrate to ignore file…",
211
+ description: "Review the scope change for this legacy setup. Migration does not start a transfer.",
212
+ currentValue: "Review",
213
+ action: "ignore-migrate" as const,
214
+ },
215
+ ]
216
+ : []),
217
+ ...(state.reservedIgnoreNames !== undefined && !ignoreAvailable
218
+ ? []
219
+ : [
220
+ {
221
+ id: "remoteInclude",
222
+ label:
223
+ ignoreAvailable || state.scope === "agent-directory"
224
+ ? "Compare sync policies"
225
+ : "Compare included paths",
226
+ description:
227
+ state.pathPolicy === "ignore-file"
228
+ ? "Read-only comparison of local and remote policy, not file contents."
229
+ : "Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
230
+ currentValue: "Review",
231
+ action: "remote-include" as const,
232
+ },
233
+ ]),
234
+ {
235
+ id: "localFields",
236
+ label: "Machine-local fields",
237
+ description:
238
+ "This setup: settings.json root fields excluded from future portable snapshots, not project overrides. Policy changes require reviewed directional migration; old history remains.",
239
+ currentValue: `${state.localFields?.length ?? 0} fields · Edit`,
240
+ action: "local-fields",
241
+ },
242
+ {
243
+ id: "storageLocation",
244
+ label: "Storage location",
245
+ description: "This setup: review and save bucket, branch, or path changes. Remote history is not moved.",
246
+ currentValue:
247
+ state.backend.type === "s3"
248
+ ? `${safeTerminalText(state.backend.destination.bucket)} · ${safeTerminalText(state.backend.destination.prefix)}`
249
+ : state.backend.type === "git"
250
+ ? `${safeTerminalText(state.backend.destination.branch)} · ${safeTerminalText(state.backend.destination.directory)}`
251
+ : safeTerminalText(state.backend.destination.path),
252
+ action: "storage-location",
253
+ },
254
+ {
255
+ id: "setups",
256
+ label: "Manage sync setups",
257
+ description:
258
+ state.reservedIgnoreNames !== undefined && !ignoreAvailable
259
+ ? "Review configured setups and recovery options. Adding, editing, and switching are unavailable."
260
+ : "This device: add, switch, edit, or remove sync setups. Each edit identifies its owner before saving.",
261
+ currentValue: "Open",
262
+ action: "setups",
263
+ },
264
+ {
265
+ id: "connections",
266
+ label: "Manage storage connections",
267
+ description:
268
+ state.reservedIgnoreNames !== undefined && !ignoreAvailable
269
+ ? "Review shared connections. Connection changes are unavailable while ignore-file setups are configured."
270
+ : "Shared connections on this device: review affected setups before saving server or credential changes.",
271
+ currentValue: "Open",
272
+ action: "connections",
273
+ },
274
+ {
275
+ id: "automatic",
276
+ label: "Automatic sync",
277
+ description: AUTOMATIC_SYNC_DESCRIPTION,
278
+ currentValue: state.automatic ? "On" : "Off",
279
+ values: ["On", "Off"],
280
+ action: "automatic",
281
+ },
282
+ {
283
+ id: "automaticTransfer",
284
+ label: "Startup transfer",
285
+ description: `${STARTUP_TRANSFER_DESCRIPTION} Saved preference and requirements: ${startupTransferSummary(state)}.`,
286
+ currentValue: state.automaticTransfer ? "On" : "Off",
287
+ values: ["On", "Off"],
288
+ action: "automatic-transfer",
289
+ },
290
+ {
291
+ id: "agentMode",
292
+ label: "Autonomous sync",
293
+ description: AGENT_MODE_DESCRIPTION,
294
+ currentValue: state.agentMode ? "On" : "Off",
295
+ values: ["On", "Off"],
296
+ action: "agent-mode",
297
+ },
298
+ {
299
+ id: "continuous",
300
+ label: "Continuous sync",
301
+ description: `${CONTINUOUS_DESCRIPTION}${state.continuous && !state.agentMode ? " Saved On, but paused until Autonomous sync is enabled." : ""}`,
302
+ currentValue: state.continuous ? "On" : "Off",
303
+ values: ["On", "Off"],
304
+ action: "continuous",
305
+ },
306
+ ...(ignoreAvailable &&
307
+ state.reservedIgnoreNames !== undefined &&
308
+ (startupTransferEnabled(state) || (state.automatic && syncSessionsSelected(state)))
309
+ ? [
310
+ {
311
+ id: "authorizeAutomatic",
312
+ label: "Review automatic transfers",
313
+ description:
314
+ "Separate approval for the enabled modes and exact current policy. Saving settings alone does not grant permission.",
315
+ currentValue: "Review",
316
+ action: "authorize-automatic" as const,
317
+ },
318
+ ]
319
+ : []),
320
+ {
321
+ id: "onSwitch",
322
+ label: "On setup switch",
323
+ description:
324
+ state.reservedIgnoreNames === undefined
325
+ ? "All setups on this device: ask before a pull review, open it automatically, or switch without pulling. Applies to subsequent switches."
326
+ : "While ignore-file setups exist, switching saves only the active setup. Run a reviewed pull separately.",
327
+ currentValue: setupSwitchActionLabel(state.onSwitch),
328
+ values: SETUP_SWITCH_ACTION_OPTIONS.map(({ label }) => label),
329
+ action: "on-switch",
330
+ },
331
+ {
332
+ id: "mergeSettings",
333
+ label: "Merge settings fields",
334
+ description:
335
+ "This setup, opt-in: merge independent global settings.json root fields with a verified private ancestor. Arrays and nested objects remain atomic. Applies to subsequent sync; no reload.",
336
+ currentValue: state.mergeSettings ? "On" : "Off",
337
+ values: ["On", "Off"],
338
+ action: "merge-settings",
339
+ },
340
+ {
341
+ id: "contentPolicy",
342
+ label: "Content merge / partial progress",
343
+ description: `This setup, opt-in: ${state.scope === "agent-directory" ? "review format compatibility" : "review the version-5 upgrade"} before saving. Merge bounded text and prefix-only sessions; partial progress keeps withheld versions and baselines. Applies to subsequent sync; disabling does not clear recovery evidence.`,
344
+ currentValue: state.mergeContent
345
+ ? state.partialSync
346
+ ? "Merge + partial"
347
+ : "Merge only"
348
+ : state.partialSync
349
+ ? "Partial only"
350
+ : "Off",
351
+ values: ["Off", "Merge only", "Merge + partial", "Partial only"],
352
+ action: "content-policy",
353
+ },
354
+ {
355
+ id: "skipSecretScan",
356
+ label: "Skip secret scan",
357
+ description:
358
+ "All setups on this device: skip possible-secret checks on subsequent pushes, including automatic pushes. Other safety checks remain. Diagnostics still scans.",
359
+ currentValue: state.skipSecretScan ? "On" : "Off",
360
+ values: ["On", "Off"],
361
+ action: "skip-secret-scan",
362
+ },
363
+ {
364
+ id: "showStatus",
365
+ label: "Show sync status",
366
+ description:
367
+ "All setups on this device: saved and applied immediately to Pi status. Review widgets and notifications remain available.",
368
+ currentValue: state.showStatus ? "On" : "Off",
369
+ values: ["On", "Off"],
370
+ action: "show-status",
371
+ },
372
+ {
373
+ id: "debug",
374
+ label: "Debug startup timings",
375
+ description:
376
+ "All setups on this device: show startup durations in the TUI transcript or RPC notifications, including initial Continuous sync. Applies next session start; no credentials or file contents.",
377
+ currentValue: state.debug ? "On" : "Off",
378
+ values: ["On", "Off"],
379
+ action: "debug",
380
+ },
381
+ ] satisfies MenuSettingItem<Action>[]
382
+ ).map((item) =>
383
+ state.reservedIgnoreNames !== undefined && !ignoreAvailable && !["setups", "connections"].includes(item.id)
384
+ ? { ...item, disabled: true }
385
+ : item,
386
+ ),
284
387
  }),
285
388
  },
286
389
  actions: {
@@ -303,14 +406,14 @@ export async function showSyncSettings(
303
406
  const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
304
407
  const validate = captureMutationOwner(ctx, mutationSignal);
305
408
  try {
306
- const previous = await loadConfig(setupName);
409
+ const previous = await loadSettingsConfig(setupName);
307
410
  validate();
308
411
  const mergeContent = value === "Merge only" || value === "Merge + partial";
309
412
  const partialSync = value === "Partial only" || value === "Merge + partial";
310
413
  if (
311
414
  !(await ctx.ui.confirm(
312
415
  "Save content policy?",
313
- `${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and snapshot version 5; older clients must refuse them." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
416
+ `${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and snapshot version 6; older clients must refuse them." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5; older clients must refuse it." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
314
417
  { signal: mutationSignal },
315
418
  ))
316
419
  )
@@ -367,7 +470,7 @@ export async function showSyncSettings(
367
470
  const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
368
471
  const validate = captureMutationOwner(ctx, mutationSignal);
369
472
  try {
370
- const previous = await loadConfig(setupName);
473
+ const previous = await loadSettingsConfig(setupName);
371
474
  validate();
372
475
  const input = await ctx.ui.input(
373
476
  "Machine-local settings.json root fields (JSON string array)",
@@ -385,7 +488,7 @@ export async function showSyncSettings(
385
488
  if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
386
489
  const confirmed = await ctx.ui.confirm(
387
490
  "Save portable field policy?",
388
- `${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
491
+ `${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and snapshot version 6." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
389
492
  { signal: mutationSignal },
390
493
  );
391
494
  validate();
@@ -423,7 +526,7 @@ export async function showSyncSettings(
423
526
  const automatic = value === "On";
424
527
  const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
425
528
  try {
426
- const latest = await loadConfig(setupName);
529
+ const latest = await loadSettingsConfig(setupName);
427
530
  if (mutationSignal.aborted) return { kind: "rejected" };
428
531
  if (latest.automatic === automatic) return { kind: "stay" };
429
532
  await updateSyncSetup(setupName, (setup) => ({ ...setup, sync: { ...setup.sync, automatic } }), {
@@ -517,7 +620,7 @@ export async function showSyncSettings(
517
620
  const skipSecretScan = value === "On";
518
621
  const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
519
622
  try {
520
- const latest = await loadConfig(setupName);
623
+ const latest = await loadSettingsConfig(setupName);
521
624
  if (mutationSignal.aborted) return { kind: "rejected" };
522
625
  if (latest.skipSecretScan === skipSecretScan) return { kind: "stay" };
523
626
  await updateLocalConfig((settings) => ({ ...settings, skipSecretScan }), mutationSignal);
@@ -533,7 +636,7 @@ export async function showSyncSettings(
533
636
  const showStatus = value === "On";
534
637
  const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
535
638
  try {
536
- const latest = await loadConfig(setupName);
639
+ const latest = await loadSettingsConfig(setupName);
537
640
  if (mutationSignal.aborted) return { kind: "rejected" };
538
641
  if (latest.showStatus === showStatus) return { kind: "stay" };
539
642
  await updateLocalConfig((settings) => ({ ...settings, showStatus }), mutationSignal);
@@ -563,7 +666,7 @@ export async function showSyncSettings(
563
666
  if (!action) return { kind: "rejected" };
564
667
  const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
565
668
  try {
566
- const latest = await loadConfig(setupName);
669
+ const latest = await loadSettingsConfig(setupName);
567
670
  if (mutationSignal.aborted) return { kind: "rejected" };
568
671
  if (latest.onSwitch === action) return { kind: "stay" };
569
672
  await saveOnSwitch(action, mutationSignal);
@@ -585,13 +688,47 @@ export async function showSyncSettings(
585
688
  await showExcludedPaths(ctx, setupName, editorSignal);
586
689
  return resumeSettings(editorSignal);
587
690
  },
588
- "remote-include": async ({ signal: actionSignal }) => {
691
+ "authorize-automatic": async ({ state, signal: actionSignal }) => {
692
+ const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
693
+ const validate = captureMutationOwner(ctx, reviewSignal);
694
+ const client = piDaemonClient(ctx);
695
+ try {
696
+ validate();
697
+ const policy = (await client.run("daemon.policy", {}, reviewSignal)) as {
698
+ setup: string;
699
+ fingerprint: string;
700
+ automatic: boolean;
701
+ };
702
+ validate();
703
+ if (policy.setup !== state.setupName) return exitSettings();
704
+ if (policy.automatic) {
705
+ ctx.ui.notify("Automatic work is already approved for this setup and policy.", "info");
706
+ return { kind: "stay" };
707
+ }
708
+ const accepted = await client.run(
709
+ "daemon.authorize-connected",
710
+ { fingerprint: policy.fingerprint },
711
+ reviewSignal,
712
+ );
713
+ validate();
714
+ if (accepted === true) ctx.ui.notify("Automatic work approved for this setup and policy.", "info");
715
+ return { kind: "stay" };
716
+ } catch (error) {
717
+ if (reviewSignal.aborted || !isCurrent()) return exitSettings();
718
+ notifySaveFailure(ctx, error);
719
+ return { kind: "rejected" };
720
+ }
721
+ },
722
+ "ignore-switch": ignoreAction("switch"),
723
+ "ignore-migrate": ignoreAction("migrate"),
724
+ "remote-include": async ({ state, signal: actionSignal }) => {
725
+ if (state.reservedIgnoreNames !== undefined && !ignoreAvailable) return { kind: "rejected" };
589
726
  const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
590
727
  const { showRemoteSelectionReview } = await import("./remote-selection-ui.js");
591
728
  if (reviewSignal.aborted) return { kind: "rejected" };
592
729
  const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, undefined, {
593
730
  origin: "settings",
594
- runRoute,
731
+ ...(state.pathPolicy === "ignore-file" ? { readOnly: true } : { runRoute }),
595
732
  });
596
733
  if (reviewSignal.aborted) return { kind: "rejected" };
597
734
  if (review.kind === "route-result") {
@@ -623,17 +760,34 @@ export async function showSyncSettings(
623
760
  result?.kind === "rejected"
624
761
  ? "Save failed or rejected. Previous value retained; retry is available."
625
762
  : id === "automatic-transfer" || id === "automatic" || id === "debug"
626
- ? "Saved. Enabling startup work applies next session start; completed transfers are not undone."
763
+ ? action.state.reservedIgnoreNames !== undefined
764
+ ? "Saved. Review automatic transfers separately before enabling automatic work for this policy."
765
+ : "Saved. Enabling startup work applies next session start; completed transfers are not undone."
627
766
  : "Saved. Applies to subsequent operations; status visibility applies immediately.";
628
767
  ctx.ui.notify(saveStatus, result?.kind === "rejected" ? "warning" : "info");
629
768
  return result;
630
769
  };
631
770
  }
771
+ function ignoreAction(action: Parameters<typeof showIgnoreFileAction>[2]) {
772
+ return async ({ state, signal: actionSignal }: { state: SettingsState; signal: AbortSignal }) => {
773
+ if (!ignoreAvailable || (state.pathPolicy === "ignore-file") === (action === "migrate"))
774
+ return { kind: "rejected" as const };
775
+ const editorSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
776
+ const latest = await loadSettingsConfig();
777
+ if (editorSignal.aborted || !isCurrent()) return { kind: "close" as const };
778
+ if (syncCheckConfigFingerprint(latest) !== syncCheckConfigFingerprint(state)) {
779
+ ctx.ui.notify("Sync setup changed while Settings was open; reopen it before changing the policy.", "warning");
780
+ return { kind: "close" as const };
781
+ }
782
+ await showIgnoreFileAction(ctx, setupName, action, state.ignoreFile ?? ".syncignore", editorSignal);
783
+ return resumeSettings(editorSignal);
784
+ };
785
+ }
632
786
  async function resumeSettings(editorSignal: AbortSignal) {
633
- if (editorSignal.aborted) return { kind: "close" as const };
787
+ if (editorSignal.aborted || !isCurrent()) return { kind: "close" as const };
634
788
  try {
635
- const active = await loadConfig();
636
- if (editorSignal.aborted || active.setupName !== setupName) return { kind: "close" as const };
789
+ const active = await loadSettingsConfig();
790
+ if (editorSignal.aborted || !isCurrent() || active.setupName !== setupName) return { kind: "close" as const };
637
791
  // Stay reloads authoritative rows without pushing a duplicate screen or clearing search.
638
792
  return { kind: "stay" as const };
639
793
  } catch {
@@ -641,9 +795,9 @@ export async function showSyncSettings(
641
795
  }
642
796
  }
643
797
  await runMenu({ ...ctx, ui: boundedSettingsUI(ctx) }, menu, {
644
- getState: () => loadConfig(setupName),
798
+ getState: () => loadSettingsConfig(setupName),
645
799
  signal,
646
- isCurrent: () => !signal?.aborted,
800
+ isCurrent,
647
801
  });
648
802
  return disposition;
649
803
  }