@narumitw/pi-sync 0.58.1 → 0.60.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.
- package/CHANGELOG.md +21 -0
- package/README.md +28 -15
- package/dist/chunks/{chunk-AMJRUXFT.ts → chunk-2JNFEZ3V.ts} +2 -6
- package/dist/chunks/{chunk-AMJRUXFT.ts.map → chunk-2JNFEZ3V.ts.map} +1 -1
- package/dist/chunks/{chunk-MG66XM5U.ts → chunk-4RNCZZY7.ts} +86 -36
- package/dist/chunks/chunk-4RNCZZY7.ts.map +7 -0
- package/dist/chunks/{config-HYG7G5EM.ts → chunk-7AC2RX4M.ts} +6 -12
- package/dist/chunks/chunk-7AC2RX4M.ts.map +7 -0
- package/dist/chunks/{chunk-XEODG2PE.ts → chunk-BGGKHHO4.ts} +18 -14
- package/dist/chunks/{chunk-XEODG2PE.ts.map → chunk-BGGKHHO4.ts.map} +1 -1
- package/dist/chunks/chunk-BWWTOQOW.ts +737 -0
- package/dist/chunks/chunk-BWWTOQOW.ts.map +7 -0
- package/dist/chunks/chunk-CEMFCWIU.ts +20 -0
- package/dist/chunks/chunk-CEMFCWIU.ts.map +7 -0
- package/dist/chunks/chunk-CZNBKIM5.ts +20 -0
- package/dist/chunks/chunk-CZNBKIM5.ts.map +7 -0
- package/dist/chunks/{chunk-YIPK23JW.ts → chunk-ENFHHB5O.ts} +1 -16
- package/dist/chunks/{chunk-YIPK23JW.ts.map → chunk-ENFHHB5O.ts.map} +1 -1
- package/dist/chunks/{chunk-KHBPED6W.ts → chunk-GSQGBVKG.ts} +2 -2
- package/dist/chunks/chunk-HNKLBM3U.ts +18 -0
- package/dist/chunks/chunk-HNKLBM3U.ts.map +7 -0
- package/dist/chunks/{chunk-QPC5HT3A.ts → chunk-J5COV5TY.ts} +21 -2
- package/dist/chunks/chunk-J5COV5TY.ts.map +7 -0
- package/dist/chunks/chunk-JKBUYCPC.ts +52 -0
- package/dist/chunks/chunk-JKBUYCPC.ts.map +7 -0
- package/dist/chunks/chunk-JZKCOM62.ts +26 -0
- package/dist/chunks/chunk-JZKCOM62.ts.map +7 -0
- package/dist/chunks/chunk-M7RHV3H6.ts +33 -0
- package/dist/chunks/chunk-M7RHV3H6.ts.map +7 -0
- package/dist/chunks/{chunk-REMGB255.ts → chunk-MIXZVHFR.ts} +35 -10
- package/dist/chunks/chunk-MIXZVHFR.ts.map +7 -0
- package/dist/chunks/chunk-NPT2G4FU.ts +15 -0
- package/dist/chunks/chunk-NPT2G4FU.ts.map +7 -0
- package/dist/chunks/chunk-PDBTD2K6.ts +11 -0
- package/dist/chunks/chunk-PDBTD2K6.ts.map +7 -0
- package/dist/chunks/chunk-UBE6XWOM.ts +29 -0
- package/dist/chunks/chunk-UBE6XWOM.ts.map +7 -0
- package/dist/chunks/{chunk-JYILGR3K.ts → chunk-UZUUUY7C.ts} +8 -8
- package/dist/chunks/chunk-VZCWYXRS.ts +23 -0
- package/dist/chunks/chunk-VZCWYXRS.ts.map +7 -0
- package/dist/chunks/{chunk-U6GXGY5G.ts → chunk-YWEYRRQI.ts} +45 -37
- package/dist/chunks/chunk-YWEYRRQI.ts.map +7 -0
- package/dist/chunks/{chunk-ECYCNZOE.ts → chunk-ZMNVNECV.ts} +5 -1
- package/dist/chunks/chunk-ZMNVNECV.ts.map +7 -0
- package/dist/chunks/{command-handler-MRXE5AKK.ts → command-handler-3O76V7Q5.ts} +83 -87
- package/dist/chunks/command-handler-3O76V7Q5.ts.map +7 -0
- package/dist/chunks/conflict-review-XBSME2ER.ts +18 -0
- package/dist/chunks/conflict-review-XBSME2ER.ts.map +7 -0
- package/dist/chunks/{continuous-record-EPHGR2DU.ts → continuous-record-ZHUXVO4E.ts} +5 -13
- package/dist/chunks/continuous-record-ZHUXVO4E.ts.map +7 -0
- package/dist/chunks/{file-selection-IELTXSGZ.ts → file-selection-S6CNNNQI.ts} +14 -14
- package/dist/chunks/file-selection-S6CNNNQI.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-I2AMCCE7.ts +18 -0
- package/dist/chunks/{manager-ui-AY34N4UY.ts → manager-ui-SJOBTJLY.ts} +221 -147
- package/dist/chunks/manager-ui-SJOBTJLY.ts.map +7 -0
- package/dist/chunks/merge-review-SGDLMVS4.ts +10 -0
- package/dist/chunks/remote-selection-ui-GZHPDQ4L.ts +17 -0
- package/dist/chunks/{setup-switch-KLGESLQX.ts → setup-switch-M3BAFGJM.ts} +9 -12
- package/dist/chunks/{setup-wizard-ZQAK35BP.ts → setup-wizard-NFAWP4KF.ts} +18 -20
- package/dist/chunks/{setup-wizard-ZQAK35BP.ts.map → setup-wizard-NFAWP4KF.ts.map} +1 -1
- package/dist/chunks/{snapshot-RGNDYT6A.ts → snapshot-D4SFDP5J.ts} +8 -12
- package/dist/chunks/snapshot-D4SFDP5J.ts.map +7 -0
- package/dist/chunks/snapshot-transaction-directory-TNKBQ3UQ.ts +13 -0
- package/dist/chunks/snapshot-transaction-directory-TNKBQ3UQ.ts.map +7 -0
- package/dist/chunks/state-directory-JZSZVVPX.ts +17 -0
- package/dist/chunks/sync-inspection-BJ4KPPNO.ts +23 -0
- package/dist/chunks/sync-inspection-BJ4KPPNO.ts.map +7 -0
- package/dist/chunks/sync-operations-TLWER2TT.ts +45 -0
- package/dist/chunks/sync-operations-TLWER2TT.ts.map +7 -0
- package/dist/chunks/{sync-state-7L4NT7W2.ts → sync-state-FVCJJ7MY.ts} +5 -10
- package/dist/chunks/sync-state-FVCJJ7MY.ts.map +7 -0
- package/dist/index.ts +269 -306
- package/dist/index.ts.map +4 -4
- package/docs/daemon-migration.md +93 -0
- package/docs/exclude-policy-audit.md +54 -0
- package/docs/exclude-review-ledger.md +36 -0
- package/docs/tui-contract.md +1 -1
- package/package.json +3 -5
- package/skills/configure-pi-sync/SKILL.md +5 -4
- package/skills/configure-pi-sync/references/configuration.md +91 -19
- package/src/backends/backend-factory.ts +2 -23
- package/src/backends/backend-identity.ts +5 -40
- package/src/backends/backend-types.ts +1 -81
- package/src/backends/git/git-backend.ts +6 -784
- package/src/backends/git/git-config.ts +8 -130
- package/src/backends/git/git-runner.ts +7 -255
- package/src/backends/git/git-storage.ts +14 -292
- package/src/backends/s3/s3-backend.ts +11 -523
- package/src/backends/s3/s3-client.ts +2 -399
- package/src/backends/s3/s3-conditions.ts +2 -67
- package/src/backends/snapshot-pointer.ts +2 -27
- package/src/backends/sync-backend.ts +6 -101
- package/src/backends/webdav/webdav-backend.ts +10 -622
- package/src/backends/webdav/webdav-client.ts +6 -370
- package/src/backends/webdav/webdav-config.ts +8 -82
- package/src/commands/command-execution.ts +42 -38
- package/src/commands/command.ts +23 -1
- package/src/daemon/apply-gate.ts +146 -0
- package/src/daemon/pi-client.ts +591 -0
- package/src/daemon/recovery.ts +103 -0
- package/src/paths.ts +12 -83
- package/src/settings/config-errors.ts +2 -6
- package/src/settings/config-file.ts +19 -693
- package/src/settings/config.ts +16 -257
- package/src/settings/settings-management.ts +11 -253
- package/src/settings/settings-store.ts +10 -48
- package/src/settings/settings-types.ts +1 -154
- package/src/settings/settings-validation.ts +17 -431
- package/src/snapshot/session-paths.ts +11 -110
- package/src/snapshot/snapshot-apply.ts +9 -306
- package/src/snapshot/snapshot-case-replacement.ts +6 -80
- package/src/snapshot/snapshot-codec.ts +2 -50
- package/src/snapshot/snapshot-exclude-safety.ts +2 -0
- package/src/snapshot/snapshot-mutation-queues.ts +6 -142
- package/src/snapshot/snapshot-paths.ts +2 -11
- package/src/snapshot/snapshot-root-transition.ts +6 -154
- package/src/snapshot/snapshot-transaction-directory.ts +5 -16
- package/src/snapshot/snapshot-transaction-plan.ts +2 -72
- package/src/snapshot/snapshot-transaction.ts +6 -934
- package/src/snapshot/snapshot-types.ts +1 -43
- package/src/snapshot/snapshot.ts +18 -405
- package/src/state/json-file.ts +2 -47
- package/src/state/lock-policy.ts +2 -2
- package/src/state/lock.ts +10 -292
- package/src/state/lockfile-fs.ts +2 -25
- package/src/state/merge-baseline-store.ts +8 -200
- package/src/state/mutation-directory-sync.ts +2 -34
- package/src/state/operation-availability.ts +7 -59
- package/src/state/state-directory.ts +8 -243
- package/src/state/state-types.ts +1 -24
- package/src/state/sync-state-store.ts +11 -75
- package/src/sync/agent-candidate.ts +7 -256
- package/src/sync/agent-plan.ts +2 -107
- package/src/sync/agent-policy.ts +10 -13
- package/src/sync/agent-refusal-retry.ts +2 -54
- package/src/sync/agent-request.ts +2 -19
- package/src/sync/agent-runner.ts +2 -191
- package/src/sync/agent-store.ts +7 -182
- package/src/sync/agent-sync.ts +2 -141
- package/src/sync/apply-review.ts +2 -63
- package/src/sync/automatic-sync.ts +55 -106
- package/src/sync/conflict-artifact-ownership.ts +2 -63
- package/src/sync/conflict-artifacts.ts +8 -195
- package/src/sync/conflict-groups.ts +2 -68
- package/src/sync/conflict-preview.ts +2 -56
- package/src/sync/conflict-resolution.ts +2 -93
- package/src/sync/conflict-retention.ts +2 -72
- package/src/sync/conflict-review.ts +3 -92
- package/src/sync/content-conflicts.ts +2 -73
- package/src/sync/continuous-errors.ts +7 -85
- package/src/sync/continuous-lease.ts +2 -216
- package/src/sync/continuous-record.ts +10 -261
- package/src/sync/continuous-storage.ts +12 -64
- package/src/sync/continuous-sync.ts +2 -563
- package/src/sync/continuous-watch.ts +2 -59
- package/src/sync/exclude-policy.ts +6 -0
- package/src/sync/field-migration.ts +2 -39
- package/src/sync/file-merge-planner.ts +2 -143
- package/src/sync/json-document.ts +7 -184
- package/src/sync/local-field-policy.ts +2 -29
- package/src/sync/local-fields.ts +9 -108
- package/src/sync/merge-apply.ts +2 -434
- package/src/sync/merge-journal.ts +10 -219
- package/src/sync/merge-transfer-error.ts +2 -72
- package/src/sync/merged-sync.ts +2 -914
- package/src/sync/mutation-owner.ts +2 -22
- package/src/sync/package-merge.ts +2 -87
- package/src/sync/partial-progress.ts +2 -54
- package/src/sync/remote-snapshot.ts +7 -80
- package/src/sync/session-merge.ts +2 -194
- package/src/sync/settings-conflicts.ts +2 -64
- package/src/sync/settings-merge.ts +6 -121
- package/src/sync/signals.ts +2 -8
- package/src/sync/startup-check.ts +15 -31
- package/src/sync/startup-timings.ts +2 -94
- package/src/sync/sync-decision.ts +3 -101
- package/src/sync/sync-error-guidance.ts +2 -46
- package/src/sync/sync-errors.ts +7 -23
- package/src/sync/sync-inspection.ts +10 -57
- package/src/sync/sync-local.ts +2 -44
- package/src/sync/sync-mutations.ts +10 -781
- package/src/sync/sync-operations.ts +32 -11
- package/src/sync/sync-policy.ts +34 -410
- package/src/sync/sync-queries.ts +2 -237
- package/src/sync/sync-state.ts +18 -151
- package/src/sync/text-merge.ts +10 -133
- package/src/sync-extension.ts +192 -142
- package/src/ui/excluded-paths-ui.ts +106 -0
- package/src/ui/file-selection.ts +6 -3
- package/src/ui/manager-state.ts +11 -5
- package/src/ui/remote-selection-ui.ts +73 -10
- package/src/ui/settings-ui.ts +20 -5
- package/src/ui/setup/setup-actions.ts +1 -1
- package/src/ui/setup/setup-switcher.ts +3 -2
- package/src/ui/storage-connections-ui.ts +2 -2
- package/src/ui/sync-attention.ts +17 -3
- package/src/ui/sync-format.ts +13 -1
- package/dist/chunks/agent-candidate-U2NU3GUX.ts +0 -29
- package/dist/chunks/agent-plan-3YXDIJXO.ts +0 -123
- package/dist/chunks/agent-plan-3YXDIJXO.ts.map +0 -7
- package/dist/chunks/agent-refusal-retry-476YGNU5.ts +0 -72
- package/dist/chunks/agent-refusal-retry-476YGNU5.ts.map +0 -7
- package/dist/chunks/agent-runner-FCRV2Z75.ts +0 -185
- package/dist/chunks/agent-runner-FCRV2Z75.ts.map +0 -7
- package/dist/chunks/agent-store-7GINKTS7.ts +0 -175
- package/dist/chunks/agent-store-7GINKTS7.ts.map +0 -7
- package/dist/chunks/agent-sync-2R4GG2MF.ts +0 -22
- package/dist/chunks/chunk-2JZFHNLM.ts +0 -113
- package/dist/chunks/chunk-2JZFHNLM.ts.map +0 -7
- package/dist/chunks/chunk-3ST7RSYN.ts +0 -21
- package/dist/chunks/chunk-3ST7RSYN.ts.map +0 -7
- package/dist/chunks/chunk-45COPAK7.ts +0 -205
- package/dist/chunks/chunk-45COPAK7.ts.map +0 -7
- package/dist/chunks/chunk-5SFMBY5P.ts +0 -26
- package/dist/chunks/chunk-5SFMBY5P.ts.map +0 -7
- package/dist/chunks/chunk-5TSCBBPP.ts +0 -229
- package/dist/chunks/chunk-5TSCBBPP.ts.map +0 -7
- package/dist/chunks/chunk-6LD5KX55.ts +0 -396
- package/dist/chunks/chunk-6LD5KX55.ts.map +0 -7
- package/dist/chunks/chunk-6O3EDBRL.ts +0 -258
- package/dist/chunks/chunk-6O3EDBRL.ts.map +0 -7
- package/dist/chunks/chunk-7A35ZAVO.ts +0 -1109
- package/dist/chunks/chunk-7A35ZAVO.ts.map +0 -7
- package/dist/chunks/chunk-7D5SF7P3.ts +0 -29
- package/dist/chunks/chunk-7D5SF7P3.ts.map +0 -7
- package/dist/chunks/chunk-7ZIYU5QS.ts +0 -64
- package/dist/chunks/chunk-7ZIYU5QS.ts.map +0 -7
- package/dist/chunks/chunk-AKMV47YC.ts +0 -215
- package/dist/chunks/chunk-AKMV47YC.ts.map +0 -7
- package/dist/chunks/chunk-AR2DGDUI.ts +0 -55
- package/dist/chunks/chunk-AR2DGDUI.ts.map +0 -7
- package/dist/chunks/chunk-BEST45H2.ts +0 -153
- package/dist/chunks/chunk-BEST45H2.ts.map +0 -7
- package/dist/chunks/chunk-CBLTWXAU.ts +0 -114
- package/dist/chunks/chunk-CBLTWXAU.ts.map +0 -7
- package/dist/chunks/chunk-CQD2TJHE.ts +0 -220
- package/dist/chunks/chunk-CQD2TJHE.ts.map +0 -7
- package/dist/chunks/chunk-DN4IA7MR.ts +0 -61
- package/dist/chunks/chunk-DN4IA7MR.ts.map +0 -7
- package/dist/chunks/chunk-DT7M4VQS.ts +0 -69
- package/dist/chunks/chunk-DT7M4VQS.ts.map +0 -7
- package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
- package/dist/chunks/chunk-ESKOPQVB.ts +0 -348
- package/dist/chunks/chunk-ESKOPQVB.ts.map +0 -7
- package/dist/chunks/chunk-FHE2DCA2.ts +0 -61
- package/dist/chunks/chunk-FHE2DCA2.ts.map +0 -7
- package/dist/chunks/chunk-FLHCOJCD.ts +0 -57
- package/dist/chunks/chunk-FLHCOJCD.ts.map +0 -7
- package/dist/chunks/chunk-G4RUXRWZ.ts +0 -48
- package/dist/chunks/chunk-G4RUXRWZ.ts.map +0 -7
- package/dist/chunks/chunk-GNYGNHFF.ts +0 -27
- package/dist/chunks/chunk-GNYGNHFF.ts.map +0 -7
- package/dist/chunks/chunk-KYTT7KV4.ts +0 -319
- package/dist/chunks/chunk-KYTT7KV4.ts.map +0 -7
- package/dist/chunks/chunk-M6VQJIOU.ts +0 -54
- package/dist/chunks/chunk-M6VQJIOU.ts.map +0 -7
- package/dist/chunks/chunk-MG66XM5U.ts.map +0 -7
- package/dist/chunks/chunk-MKSMJPVA.ts +0 -107
- package/dist/chunks/chunk-MKSMJPVA.ts.map +0 -7
- package/dist/chunks/chunk-MMQIEDZ6.ts +0 -1994
- package/dist/chunks/chunk-MMQIEDZ6.ts.map +0 -7
- package/dist/chunks/chunk-OJARL2TG.ts +0 -25
- package/dist/chunks/chunk-OJARL2TG.ts.map +0 -7
- package/dist/chunks/chunk-OVBAW7KV.ts +0 -1174
- package/dist/chunks/chunk-OVBAW7KV.ts.map +0 -7
- package/dist/chunks/chunk-PRUEIIK7.ts +0 -24
- package/dist/chunks/chunk-PRUEIIK7.ts.map +0 -7
- package/dist/chunks/chunk-PWMWOJP4.ts +0 -17
- package/dist/chunks/chunk-PWMWOJP4.ts.map +0 -7
- package/dist/chunks/chunk-QPC5HT3A.ts.map +0 -7
- package/dist/chunks/chunk-REMGB255.ts.map +0 -7
- package/dist/chunks/chunk-S5OCYVPS.ts +0 -415
- package/dist/chunks/chunk-S5OCYVPS.ts.map +0 -7
- package/dist/chunks/chunk-SWRVXVFD.ts +0 -248
- package/dist/chunks/chunk-SWRVXVFD.ts.map +0 -7
- package/dist/chunks/chunk-T2SJD3N7.ts +0 -99
- package/dist/chunks/chunk-T2SJD3N7.ts.map +0 -7
- package/dist/chunks/chunk-TIMWN2RH.ts +0 -89
- package/dist/chunks/chunk-TIMWN2RH.ts.map +0 -7
- package/dist/chunks/chunk-TZC7GDJE.ts +0 -58
- package/dist/chunks/chunk-TZC7GDJE.ts.map +0 -7
- package/dist/chunks/chunk-U6GXGY5G.ts.map +0 -7
- package/dist/chunks/chunk-WQMYV4DW.ts +0 -140
- package/dist/chunks/chunk-WQMYV4DW.ts.map +0 -7
- package/dist/chunks/chunk-X7R6DCVF.ts +0 -28
- package/dist/chunks/chunk-X7R6DCVF.ts.map +0 -7
- package/dist/chunks/chunk-XJHQPB3E.ts +0 -107
- package/dist/chunks/chunk-XJHQPB3E.ts.map +0 -7
- package/dist/chunks/chunk-Y4UVXOLQ.ts +0 -123
- package/dist/chunks/chunk-Y4UVXOLQ.ts.map +0 -7
- package/dist/chunks/chunk-YDVQYUHE.ts +0 -34
- package/dist/chunks/chunk-YDVQYUHE.ts.map +0 -7
- package/dist/chunks/chunk-YHT4YTYG.ts +0 -31
- package/dist/chunks/chunk-YHT4YTYG.ts.map +0 -7
- package/dist/chunks/chunk-ZW5ZLGBI.ts +0 -154
- package/dist/chunks/chunk-ZW5ZLGBI.ts.map +0 -7
- package/dist/chunks/command-handler-MRXE5AKK.ts.map +0 -7
- package/dist/chunks/conflict-artifacts-J6WSDCWP.ts +0 -32
- package/dist/chunks/conflict-review-GXA6Y7KY.ts +0 -189
- package/dist/chunks/conflict-review-GXA6Y7KY.ts.map +0 -7
- package/dist/chunks/continuous-sync-FAFNLEUW.ts +0 -585
- package/dist/chunks/continuous-sync-FAFNLEUW.ts.map +0 -7
- package/dist/chunks/file-selection-IELTXSGZ.ts.map +0 -7
- package/dist/chunks/git-backend-KHD36W27.ts +0 -1077
- package/dist/chunks/git-backend-KHD36W27.ts.map +0 -7
- package/dist/chunks/local-fields-JEKAPZKD.ts +0 -26
- package/dist/chunks/local-fields-JEKAPZKD.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-XCYPW7RC.ts +0 -32
- package/dist/chunks/manager-result-dispatcher-XCYPW7RC.ts.map +0 -7
- package/dist/chunks/manager-ui-AY34N4UY.ts.map +0 -7
- package/dist/chunks/merge-baseline-store-65GKUMXI.ts +0 -25
- package/dist/chunks/merge-baseline-store-65GKUMXI.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-MYM2YCPF.ts +0 -31
- package/dist/chunks/remote-selection-ui-MYM2YCPF.ts.map +0 -7
- package/dist/chunks/s3-backend-L24UZ6IK.ts +0 -844
- package/dist/chunks/s3-backend-L24UZ6IK.ts.map +0 -7
- package/dist/chunks/setup-switch-KLGESLQX.ts.map +0 -7
- package/dist/chunks/snapshot-RGNDYT6A.ts.map +0 -7
- package/dist/chunks/snapshot-transaction-26BQO36S.ts +0 -24
- package/dist/chunks/snapshot-transaction-26BQO36S.ts.map +0 -7
- package/dist/chunks/sync-inspection-MOMLGUTD.ts +0 -25
- package/dist/chunks/sync-inspection-MOMLGUTD.ts.map +0 -7
- package/dist/chunks/sync-operations-45APGOL3.ts +0 -1021
- package/dist/chunks/sync-operations-45APGOL3.ts.map +0 -7
- package/dist/chunks/sync-state-7L4NT7W2.ts.map +0 -7
- package/dist/chunks/webdav-backend-3ZCACILP.ts +0 -851
- package/dist/chunks/webdav-backend-3ZCACILP.ts.map +0 -7
- /package/dist/chunks/{chunk-KHBPED6W.ts.map → chunk-GSQGBVKG.ts.map} +0 -0
- /package/dist/chunks/{chunk-JYILGR3K.ts.map → chunk-UZUUUY7C.ts.map} +0 -0
- /package/dist/chunks/{agent-candidate-U2NU3GUX.ts.map → manager-result-dispatcher-I2AMCCE7.ts.map} +0 -0
- /package/dist/chunks/{agent-sync-2R4GG2MF.ts.map → merge-review-SGDLMVS4.ts.map} +0 -0
- /package/dist/chunks/{config-HYG7G5EM.ts.map → remote-selection-ui-GZHPDQ4L.ts.map} +0 -0
- /package/dist/chunks/{conflict-artifacts-J6WSDCWP.ts.map → setup-switch-M3BAFGJM.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-EPHGR2DU.ts.map → state-directory-JZSZVVPX.ts.map} +0 -0
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
-
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
|
|
4
|
-
// src/state/lock-policy.ts
|
|
5
|
-
var LOCK_GUARD_STALE_MS = 3e4;
|
|
6
|
-
var LOCK_GUARD_UPDATE_MS = 1e4;
|
|
7
|
-
|
|
8
|
-
// src/state/lockfile-fs.ts
|
|
9
|
-
import {
|
|
10
|
-
mkdir,
|
|
11
|
-
mkdirSync,
|
|
12
|
-
realpath,
|
|
13
|
-
realpathSync,
|
|
14
|
-
rmdir,
|
|
15
|
-
rmdirSync,
|
|
16
|
-
stat,
|
|
17
|
-
statSync,
|
|
18
|
-
utimes,
|
|
19
|
-
utimesSync
|
|
20
|
-
} from "node:fs";
|
|
21
|
-
var LOCKFILE_FS_ADAPTER = {
|
|
22
|
-
mkdir,
|
|
23
|
-
mkdirSync,
|
|
24
|
-
realpath,
|
|
25
|
-
realpathSync,
|
|
26
|
-
rmdir,
|
|
27
|
-
rmdirSync,
|
|
28
|
-
stat,
|
|
29
|
-
statSync,
|
|
30
|
-
utimes,
|
|
31
|
-
utimesSync
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// src/state/state-directory.ts
|
|
35
|
-
import { lstatSync } from "node:fs";
|
|
36
|
-
import fs from "node:fs/promises";
|
|
37
|
-
import path from "node:path";
|
|
38
|
-
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
39
|
-
import lockfile from "proper-lockfile";
|
|
40
|
-
var CANONICAL_DIRECTORY_NAME = "pi-sync";
|
|
41
|
-
var LEGACY_DIRECTORY_NAME = ".pisync";
|
|
42
|
-
var MIGRATION_LOCK_NAME = ".pi-sync-state-migration.lock";
|
|
43
|
-
var MIGRATION_LOCK_STALE_MS = 3e4;
|
|
44
|
-
var MIGRATION_LOCK_UPDATE_MS = 1e4;
|
|
45
|
-
var sharedStateDirectoryGuards = /* @__PURE__ */ new Map();
|
|
46
|
-
function stateDir() {
|
|
47
|
-
const roots = inspectStateRoots();
|
|
48
|
-
if (roots.canonical) return canonicalStateDir();
|
|
49
|
-
if (roots.legacy) return legacyStateDir();
|
|
50
|
-
return canonicalStateDir();
|
|
51
|
-
}
|
|
52
|
-
function legacyStateDir() {
|
|
53
|
-
return path.join(getAgentDir(), LEGACY_DIRECTORY_NAME);
|
|
54
|
-
}
|
|
55
|
-
function stateDirectoryMigrationNotice() {
|
|
56
|
-
const roots = inspectStateRoots();
|
|
57
|
-
if (!roots.legacy) return void 0;
|
|
58
|
-
return "Legacy pi-sync state is still stored in .pisync. Close other Pi sessions, then run /sync migrate-state to move it to pi-sync/.";
|
|
59
|
-
}
|
|
60
|
-
async function withStateDirectoryAccess(fn) {
|
|
61
|
-
const roots = inspectStateRoots();
|
|
62
|
-
if (!roots.legacy) return fn();
|
|
63
|
-
return runWithStateDirectoryGuard(await acquireSharedStateDirectoryGuard(), fn);
|
|
64
|
-
}
|
|
65
|
-
async function migrateLegacyStateDirectory() {
|
|
66
|
-
const initial = inspectStateRoots();
|
|
67
|
-
if (initial.canonical || !initial.legacy) return { status: "ready" };
|
|
68
|
-
let guard;
|
|
69
|
-
try {
|
|
70
|
-
guard = await acquireStateDirectoryGuard();
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if (!isLockHeldError(error)) throw error;
|
|
73
|
-
return {
|
|
74
|
-
status: "deferred",
|
|
75
|
-
message: "pi-sync state migration was deferred because another state user is active. Close other Pi sessions and retry."
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return runWithStateDirectoryGuard(guard, async () => {
|
|
79
|
-
const roots = inspectStateRoots();
|
|
80
|
-
if (roots.canonical || !roots.legacy) return { status: "ready" };
|
|
81
|
-
const legacyLock = path.join(legacyStateDir(), "lock");
|
|
82
|
-
const legacyGuardHeld = await lockfile.check(legacyLock, {
|
|
83
|
-
fs: LOCKFILE_FS_ADAPTER,
|
|
84
|
-
lockfilePath: `${legacyLock}.guard`,
|
|
85
|
-
realpath: false,
|
|
86
|
-
stale: LOCK_GUARD_STALE_MS
|
|
87
|
-
});
|
|
88
|
-
const schedulerHeld = await lockfile.check(path.join(legacyStateDir(), "continuous", "scheduler"), {
|
|
89
|
-
fs: LOCKFILE_FS_ADAPTER,
|
|
90
|
-
realpath: false,
|
|
91
|
-
stale: LOCK_GUARD_STALE_MS
|
|
92
|
-
});
|
|
93
|
-
if (legacyGuardHeld || schedulerHeld || await pathExists(legacyLock)) {
|
|
94
|
-
return {
|
|
95
|
-
status: "deferred",
|
|
96
|
-
message: "pi-sync state migration was deferred because the legacy directory is busy. Close other Pi sessions, clear any confirmed stale sync lock, and retry."
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
guard.throwIfCompromised();
|
|
100
|
-
await fs.rename(legacyStateDir(), canonicalStateDir());
|
|
101
|
-
guard.throwIfCompromised();
|
|
102
|
-
inspectStateRoots();
|
|
103
|
-
return {
|
|
104
|
-
status: "migrated",
|
|
105
|
-
message: `Migrated pi-sync state from ${legacyStateDir()} to ${canonicalStateDir()}.`
|
|
106
|
-
};
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
async function acquireSharedStateDirectoryGuard() {
|
|
110
|
-
const key = migrationLockPath();
|
|
111
|
-
for (; ; ) {
|
|
112
|
-
let shared = sharedStateDirectoryGuards.get(key);
|
|
113
|
-
if (shared?.closing) {
|
|
114
|
-
await shared.closing;
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
if (!shared) {
|
|
118
|
-
shared = { guard: acquireStateDirectoryGuard(), users: 0 };
|
|
119
|
-
sharedStateDirectoryGuards.set(key, shared);
|
|
120
|
-
}
|
|
121
|
-
shared.users += 1;
|
|
122
|
-
let guard;
|
|
123
|
-
try {
|
|
124
|
-
guard = await shared.guard;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
if (sharedStateDirectoryGuards.get(key) === shared) {
|
|
127
|
-
sharedStateDirectoryGuards.delete(key);
|
|
128
|
-
}
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
let released = false;
|
|
132
|
-
return {
|
|
133
|
-
throwIfCompromised: guard.throwIfCompromised,
|
|
134
|
-
release: async () => {
|
|
135
|
-
if (released) return;
|
|
136
|
-
released = true;
|
|
137
|
-
shared.users -= 1;
|
|
138
|
-
if (shared.users > 0) return;
|
|
139
|
-
const closing = guard.release();
|
|
140
|
-
shared.closing = closing;
|
|
141
|
-
try {
|
|
142
|
-
await closing;
|
|
143
|
-
} finally {
|
|
144
|
-
if (sharedStateDirectoryGuards.get(key) === shared) {
|
|
145
|
-
sharedStateDirectoryGuards.delete(key);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async function acquireStateDirectoryGuard() {
|
|
153
|
-
let compromisedError;
|
|
154
|
-
const release = await lockfile.lock(getAgentDir(), {
|
|
155
|
-
fs: LOCKFILE_FS_ADAPTER,
|
|
156
|
-
lockfilePath: migrationLockPath(),
|
|
157
|
-
realpath: false,
|
|
158
|
-
stale: MIGRATION_LOCK_STALE_MS,
|
|
159
|
-
update: MIGRATION_LOCK_UPDATE_MS,
|
|
160
|
-
retries: { retries: 20, minTimeout: 10, maxTimeout: 50 },
|
|
161
|
-
onCompromised: (error) => {
|
|
162
|
-
compromisedError = error;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
return {
|
|
166
|
-
release,
|
|
167
|
-
throwIfCompromised: () => {
|
|
168
|
-
if (compromisedError) throw compromisedError;
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
async function runWithStateDirectoryGuard(guard, fn) {
|
|
173
|
-
let result;
|
|
174
|
-
let failed = false;
|
|
175
|
-
let failure;
|
|
176
|
-
try {
|
|
177
|
-
guard.throwIfCompromised();
|
|
178
|
-
result = await fn();
|
|
179
|
-
guard.throwIfCompromised();
|
|
180
|
-
} catch (error) {
|
|
181
|
-
failed = true;
|
|
182
|
-
failure = error;
|
|
183
|
-
}
|
|
184
|
-
try {
|
|
185
|
-
await guard.release();
|
|
186
|
-
} catch (error) {
|
|
187
|
-
if (!failed) {
|
|
188
|
-
failed = true;
|
|
189
|
-
failure = error;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (failed) throw failure;
|
|
193
|
-
return result;
|
|
194
|
-
}
|
|
195
|
-
function isLockHeldError(error) {
|
|
196
|
-
return error.code === "ELOCKED";
|
|
197
|
-
}
|
|
198
|
-
function canonicalStateDir() {
|
|
199
|
-
return path.join(getAgentDir(), CANONICAL_DIRECTORY_NAME);
|
|
200
|
-
}
|
|
201
|
-
function migrationLockPath() {
|
|
202
|
-
return path.join(getAgentDir(), MIGRATION_LOCK_NAME);
|
|
203
|
-
}
|
|
204
|
-
function inspectStateRoots() {
|
|
205
|
-
const canonical = isDirectoryRoot(canonicalStateDir(), "canonical");
|
|
206
|
-
const legacy = isDirectoryRoot(legacyStateDir(), "legacy");
|
|
207
|
-
if (canonical && legacy) {
|
|
208
|
-
throw new Error(
|
|
209
|
-
`Both legacy ${legacyStateDir()} and canonical ${canonicalStateDir()} pi-sync state directories exist. Close all Pi sessions and reconcile the directories manually; pi-sync will not merge or delete either directory.`
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
return { canonical, legacy };
|
|
213
|
-
}
|
|
214
|
-
function isDirectoryRoot(directory, label) {
|
|
215
|
-
try {
|
|
216
|
-
const entry = lstatSync(directory);
|
|
217
|
-
if (entry.isSymbolicLink()) {
|
|
218
|
-
throw new Error(`Refusing to use ${label} pi-sync state directory symbolic link: ${directory}`);
|
|
219
|
-
}
|
|
220
|
-
if (!entry.isDirectory()) {
|
|
221
|
-
throw new Error(`${label} pi-sync state path is not a directory: ${directory}`);
|
|
222
|
-
}
|
|
223
|
-
return true;
|
|
224
|
-
} catch (error) {
|
|
225
|
-
if (error.code === "ENOENT") return false;
|
|
226
|
-
throw error;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
async function pathExists(filePath) {
|
|
230
|
-
try {
|
|
231
|
-
await fs.lstat(filePath);
|
|
232
|
-
return true;
|
|
233
|
-
} catch (error) {
|
|
234
|
-
if (error.code === "ENOENT") return false;
|
|
235
|
-
throw error;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export {
|
|
240
|
-
LOCK_GUARD_STALE_MS,
|
|
241
|
-
LOCK_GUARD_UPDATE_MS,
|
|
242
|
-
LOCKFILE_FS_ADAPTER,
|
|
243
|
-
stateDir,
|
|
244
|
-
stateDirectoryMigrationNotice,
|
|
245
|
-
withStateDirectoryAccess,
|
|
246
|
-
migrateLegacyStateDirectory
|
|
247
|
-
};
|
|
248
|
-
//# sourceMappingURL=chunk-SWRVXVFD.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/state/lock-policy.ts", "../../src/state/lockfile-fs.ts", "../../src/state/state-directory.ts"],
|
|
4
|
-
"sourcesContent": ["export const LOCK_GUARD_STALE_MS = 30_000;\nexport const LOCK_GUARD_UPDATE_MS = 10_000;\n", "import {\n mkdir,\n mkdirSync,\n realpath,\n realpathSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n utimes,\n utimesSync,\n} from \"node:fs\";\n\nexport const LOCKFILE_FS_ADAPTER = {\n mkdir,\n mkdirSync,\n realpath,\n realpathSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n utimes,\n utimesSync,\n};\n", "import { lstatSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport lockfile from \"proper-lockfile\";\nimport { LOCK_GUARD_STALE_MS } from \"./lock-policy.js\";\nimport { LOCKFILE_FS_ADAPTER } from \"./lockfile-fs.js\";\n\nconst CANONICAL_DIRECTORY_NAME = \"pi-sync\";\nconst LEGACY_DIRECTORY_NAME = \".pisync\";\nconst MIGRATION_LOCK_NAME = \".pi-sync-state-migration.lock\";\nconst MIGRATION_LOCK_STALE_MS = 30_000;\nconst MIGRATION_LOCK_UPDATE_MS = 10_000;\n\nexport type StateDirectoryPreparation =\n | { status: \"ready\" }\n | { status: \"migrated\"; message: string }\n | { status: \"deferred\"; message: string };\n\ninterface StateDirectoryGuard {\n release: () => Promise<void>;\n throwIfCompromised: () => void;\n}\n\ninterface SharedStateDirectoryGuard {\n guard: Promise<StateDirectoryGuard>;\n users: number;\n closing?: Promise<void>;\n}\n\nconst sharedStateDirectoryGuards = new Map<string, SharedStateDirectoryGuard>();\n\nexport function stateDir() {\n const roots = inspectStateRoots();\n if (roots.canonical) return canonicalStateDir();\n if (roots.legacy) return legacyStateDir();\n return canonicalStateDir();\n}\n\nexport function legacyStateDir() {\n return path.join(getAgentDir(), LEGACY_DIRECTORY_NAME);\n}\n\nexport function stateDirectoryMigrationNotice() {\n const roots = inspectStateRoots();\n if (!roots.legacy) return undefined;\n return \"Legacy pi-sync state is still stored in .pisync. Close other Pi sessions, then run /sync migrate-state to move it to pi-sync/.\";\n}\n\nexport async function withStateDirectoryAccess<T>(fn: () => Promise<T>): Promise<T> {\n const roots = inspectStateRoots();\n if (!roots.legacy) return fn();\n return runWithStateDirectoryGuard(await acquireSharedStateDirectoryGuard(), fn);\n}\n\nexport async function migrateLegacyStateDirectory(): Promise<StateDirectoryPreparation> {\n const initial = inspectStateRoots();\n if (initial.canonical || !initial.legacy) return { status: \"ready\" };\n\n let guard: StateDirectoryGuard;\n try {\n guard = await acquireStateDirectoryGuard();\n } catch (error) {\n if (!isLockHeldError(error)) throw error;\n return {\n status: \"deferred\",\n message:\n \"pi-sync state migration was deferred because another state user is active. Close other Pi sessions and retry.\",\n };\n }\n return runWithStateDirectoryGuard(guard, async () => {\n const roots = inspectStateRoots();\n if (roots.canonical || !roots.legacy) return { status: \"ready\" };\n\n const legacyLock = path.join(legacyStateDir(), \"lock\");\n const legacyGuardHeld = await lockfile.check(legacyLock, {\n fs: LOCKFILE_FS_ADAPTER,\n lockfilePath: `${legacyLock}.guard`,\n realpath: false,\n stale: LOCK_GUARD_STALE_MS,\n });\n // Idle continuous owners do not retain the exclusive migration guard.\n // A live renewable lease still prevents moving their private state root.\n const schedulerHeld = await lockfile.check(path.join(legacyStateDir(), \"continuous\", \"scheduler\"), {\n fs: LOCKFILE_FS_ADAPTER,\n realpath: false,\n stale: LOCK_GUARD_STALE_MS,\n });\n if (legacyGuardHeld || schedulerHeld || (await pathExists(legacyLock))) {\n return {\n status: \"deferred\",\n message:\n \"pi-sync state migration was deferred because the legacy directory is busy. Close other Pi sessions, clear any confirmed stale sync lock, and retry.\",\n };\n }\n guard.throwIfCompromised();\n await fs.rename(legacyStateDir(), canonicalStateDir());\n guard.throwIfCompromised();\n inspectStateRoots();\n return {\n status: \"migrated\",\n message: `Migrated pi-sync state from ${legacyStateDir()} to ${canonicalStateDir()}.`,\n };\n });\n}\n\nasync function acquireSharedStateDirectoryGuard(): Promise<StateDirectoryGuard> {\n const key = migrationLockPath();\n for (;;) {\n let shared = sharedStateDirectoryGuards.get(key);\n if (shared?.closing) {\n await shared.closing;\n continue;\n }\n if (!shared) {\n shared = { guard: acquireStateDirectoryGuard(), users: 0 };\n sharedStateDirectoryGuards.set(key, shared);\n }\n shared.users += 1;\n let guard: StateDirectoryGuard;\n try {\n guard = await shared.guard;\n } catch (error) {\n if (sharedStateDirectoryGuards.get(key) === shared) {\n sharedStateDirectoryGuards.delete(key);\n }\n throw error;\n }\n let released = false;\n return {\n throwIfCompromised: guard.throwIfCompromised,\n release: async () => {\n if (released) return;\n released = true;\n shared.users -= 1;\n if (shared.users > 0) return;\n const closing = guard.release();\n shared.closing = closing;\n try {\n await closing;\n } finally {\n if (sharedStateDirectoryGuards.get(key) === shared) {\n sharedStateDirectoryGuards.delete(key);\n }\n }\n },\n };\n }\n}\n\nasync function acquireStateDirectoryGuard(): Promise<StateDirectoryGuard> {\n let compromisedError: Error | undefined;\n const release = await lockfile.lock(getAgentDir(), {\n fs: LOCKFILE_FS_ADAPTER,\n lockfilePath: migrationLockPath(),\n realpath: false,\n stale: MIGRATION_LOCK_STALE_MS,\n update: MIGRATION_LOCK_UPDATE_MS,\n retries: { retries: 20, minTimeout: 10, maxTimeout: 50 },\n onCompromised: (error) => {\n compromisedError = error;\n },\n });\n return {\n release,\n throwIfCompromised: () => {\n if (compromisedError) throw compromisedError;\n },\n };\n}\n\nasync function runWithStateDirectoryGuard<T>(guard: StateDirectoryGuard, fn: () => Promise<T>) {\n let result: T | undefined;\n let failed = false;\n let failure: unknown;\n try {\n guard.throwIfCompromised();\n result = await fn();\n guard.throwIfCompromised();\n } catch (error) {\n failed = true;\n failure = error;\n }\n try {\n await guard.release();\n } catch (error) {\n if (!failed) {\n failed = true;\n failure = error;\n }\n }\n if (failed) throw failure;\n return result as T;\n}\n\nfunction isLockHeldError(error: unknown) {\n return (error as NodeJS.ErrnoException).code === \"ELOCKED\";\n}\n\nfunction canonicalStateDir() {\n return path.join(getAgentDir(), CANONICAL_DIRECTORY_NAME);\n}\n\nfunction migrationLockPath() {\n return path.join(getAgentDir(), MIGRATION_LOCK_NAME);\n}\n\nfunction inspectStateRoots() {\n const canonical = isDirectoryRoot(canonicalStateDir(), \"canonical\");\n const legacy = isDirectoryRoot(legacyStateDir(), \"legacy\");\n if (canonical && legacy) {\n throw new Error(\n `Both legacy ${legacyStateDir()} and canonical ${canonicalStateDir()} pi-sync state directories exist. Close all Pi sessions and reconcile the directories manually; pi-sync will not merge or delete either directory.`,\n );\n }\n return { canonical, legacy };\n}\n\nfunction isDirectoryRoot(directory: string, label: string) {\n try {\n const entry = lstatSync(directory);\n if (entry.isSymbolicLink()) {\n throw new Error(`Refusing to use ${label} pi-sync state directory symbolic link: ${directory}`);\n }\n if (!entry.isDirectory()) {\n throw new Error(`${label} pi-sync state path is not a directory: ${directory}`);\n }\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n throw error;\n }\n}\n\nasync function pathExists(filePath: string) {\n try {\n await fs.lstat(filePath);\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n throw error;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;AAAO,IAAM,sBAAsB;AAC5B,IAAM,uBAAuB;;;ACDpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACxBA,SAAS,iBAAiB;AAC1B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,mBAAmB;AAC5B,OAAO,cAAc;AAIrB,IAAM,2BAA2B;AACjC,IAAM,wBAAwB;AAC9B,IAAM,sBAAsB;AAC5B,IAAM,0BAA0B;AAChC,IAAM,2BAA2B;AAkBjC,IAAM,6BAA6B,oBAAI,IAAuC;AAEvE,SAAS,WAAW;AACzB,QAAM,QAAQ,kBAAkB;AAChC,MAAI,MAAM,UAAW,QAAO,kBAAkB;AAC9C,MAAI,MAAM,OAAQ,QAAO,eAAe;AACxC,SAAO,kBAAkB;AAC3B;AAEO,SAAS,iBAAiB;AAC/B,SAAO,KAAK,KAAK,YAAY,GAAG,qBAAqB;AACvD;AAEO,SAAS,gCAAgC;AAC9C,QAAM,QAAQ,kBAAkB;AAChC,MAAI,CAAC,MAAM,OAAQ,QAAO;AAC1B,SAAO;AACT;AAEA,eAAsB,yBAA4B,IAAkC;A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K,MAAgC,SAAS,SAAU,QAAO;AAC/D,UAAM;AAAA,EACR;AACF;AAEA,eAAe,WAAW,UAAkB;AAC1C,MAAI;AACF,UAAM,GAAG,MAAM,QAAQ;AACvB,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAK,MAAgC,SAAS,SAAU,QAAO;AAC/D,UAAM;AAAA,EACR;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
-
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
|
|
4
|
-
// src/backends/git/git-config.ts
|
|
5
|
-
var DEFAULT_GIT_BRANCH = "pi-sync";
|
|
6
|
-
var DEFAULT_GIT_DIRECTORY = "pi-sync";
|
|
7
|
-
function normalizeGitRemote(value) {
|
|
8
|
-
const normalized = normalizeOptionalString(value);
|
|
9
|
-
if (!normalized) return void 0;
|
|
10
|
-
if (hasControlCharacter(normalized) || /\s/u.test(normalized) || normalized.startsWith("-") || normalized.includes("\\")) {
|
|
11
|
-
throw new Error("Invalid pi-sync Git remote.");
|
|
12
|
-
}
|
|
13
|
-
if (!normalized.includes("://") && /^(?:[A-Za-z0-9._-]+@)?(?:\[[0-9A-Fa-f:]+\]|[A-Za-z0-9.-]+):(?!-)[^:].+$/u.test(normalized)) {
|
|
14
|
-
return normalized;
|
|
15
|
-
}
|
|
16
|
-
if (/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(normalized) && !normalized.includes("://")) {
|
|
17
|
-
throw new Error("Invalid pi-sync Git remote: unsupported transport or remote-helper syntax.");
|
|
18
|
-
}
|
|
19
|
-
let url;
|
|
20
|
-
try {
|
|
21
|
-
url = new URL(normalized);
|
|
22
|
-
} catch {
|
|
23
|
-
throw new Error("Invalid pi-sync Git remote: use an SSH or HTTPS remote.");
|
|
24
|
-
}
|
|
25
|
-
if (url.protocol !== "https:" && url.protocol !== "ssh:") {
|
|
26
|
-
throw new Error("Invalid pi-sync Git remote: only SSH and HTTPS are supported.");
|
|
27
|
-
}
|
|
28
|
-
if (url.password || url.protocol === "https:" && url.username) {
|
|
29
|
-
throw new Error("Invalid pi-sync Git remote: URL credentials or userinfo are not allowed.");
|
|
30
|
-
}
|
|
31
|
-
if (url.search || url.hash || !url.hostname || !url.pathname || url.pathname === "/") {
|
|
32
|
-
throw new Error("Invalid pi-sync Git remote.");
|
|
33
|
-
}
|
|
34
|
-
return url.toString();
|
|
35
|
-
}
|
|
36
|
-
function normalizeGitRemoteIdentity(value) {
|
|
37
|
-
const normalized = normalizeGitRemote(value);
|
|
38
|
-
if (!normalized) return "";
|
|
39
|
-
if (!normalized.includes("://")) {
|
|
40
|
-
const match = /^(?<user>[A-Za-z0-9._-]+@)?(?<host>\[[0-9A-Fa-f:]+\]|[A-Za-z0-9.-]+):(?<path>.+)$/u.exec(normalized);
|
|
41
|
-
if (!match?.groups) return normalized;
|
|
42
|
-
const userAndHost = `${match.groups.user ?? ""}${match.groups.host.toLowerCase()}`;
|
|
43
|
-
const remotePath = match.groups.path.replace(/\/+$/gu, "");
|
|
44
|
-
return remotePath.startsWith("/") ? `scp-absolute://${userAndHost}${remotePath}` : `ssh://${userAndHost}/${remotePath}`;
|
|
45
|
-
}
|
|
46
|
-
const url = new URL(normalized);
|
|
47
|
-
url.hostname = url.hostname.toLowerCase();
|
|
48
|
-
if (url.protocol === "ssh:" && url.port === "22") url.port = "";
|
|
49
|
-
url.pathname = url.pathname.replace(/\/+$/gu, "");
|
|
50
|
-
if (url.protocol === "ssh:") {
|
|
51
|
-
return `ssh://${url.username ? `${url.username}@` : ""}${url.host}${url.pathname}`;
|
|
52
|
-
}
|
|
53
|
-
return url.toString();
|
|
54
|
-
}
|
|
55
|
-
function normalizeGitBranch(value) {
|
|
56
|
-
const branch = normalizeOptionalString(value) ?? DEFAULT_GIT_BRANCH;
|
|
57
|
-
if (branch === "@" || branch.startsWith("-") || branch.startsWith("refs/") || branch.startsWith("/") || branch.endsWith("/") || branch.endsWith(".") || branch.includes("..") || branch.includes("@{") || branch.includes("\\") || hasControlCharacter(branch) || /[ ~^:?*[\]]/u.test(branch) || branch.split("/").some((segment) => !segment || segment.startsWith(".") || segment.endsWith(".lock"))) {
|
|
58
|
-
throw new Error("Invalid pi-sync Git branch.");
|
|
59
|
-
}
|
|
60
|
-
return branch;
|
|
61
|
-
}
|
|
62
|
-
function normalizeGitDirectory(value) {
|
|
63
|
-
if (value?.trim() === "." || value?.trim() === "./") return "./";
|
|
64
|
-
const directory = trimSlashes(normalizeOptionalString(value) ?? DEFAULT_GIT_DIRECTORY);
|
|
65
|
-
if (!directory || directory.startsWith("-") || directory.includes("\\") || hasControlCharacter(directory) || directory.split("/").some((segment) => !segment || segment === "." || segment === ".." || segment === ".git")) {
|
|
66
|
-
throw new Error("Invalid pi-sync Git directory.");
|
|
67
|
-
}
|
|
68
|
-
return directory;
|
|
69
|
-
}
|
|
70
|
-
function validateGitNamespace(value) {
|
|
71
|
-
if (value.length > 256 || value === "." || value === ".." || value.includes("/") || value.includes("\\") || hasControlCharacter(value)) {
|
|
72
|
-
throw new Error("Invalid pi-sync Git namespace.");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function normalizeOptionalString(value) {
|
|
76
|
-
if (value !== void 0 && typeof value !== "string") {
|
|
77
|
-
throw new Error("Invalid pi-sync settings: expected a string.");
|
|
78
|
-
}
|
|
79
|
-
const normalized = value?.trim();
|
|
80
|
-
return normalized || void 0;
|
|
81
|
-
}
|
|
82
|
-
function trimSlashes(value) {
|
|
83
|
-
return value.replace(/^\/+|\/+$/gu, "");
|
|
84
|
-
}
|
|
85
|
-
function hasControlCharacter(value) {
|
|
86
|
-
return [...value].some((character) => {
|
|
87
|
-
const code = character.codePointAt(0) ?? 0;
|
|
88
|
-
return code < 32 || code >= 127 && code <= 159;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export {
|
|
93
|
-
normalizeGitRemote,
|
|
94
|
-
normalizeGitRemoteIdentity,
|
|
95
|
-
normalizeGitBranch,
|
|
96
|
-
normalizeGitDirectory,
|
|
97
|
-
validateGitNamespace
|
|
98
|
-
};
|
|
99
|
-
//# sourceMappingURL=chunk-T2SJD3N7.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/backends/git/git-config.ts"],
|
|
4
|
-
"sourcesContent": ["const DEFAULT_GIT_BRANCH = \"pi-sync\";\nconst DEFAULT_GIT_DIRECTORY = \"pi-sync\";\n\nexport function normalizeGitRemote(value: string | undefined) {\n const normalized = normalizeOptionalString(value);\n if (!normalized) return undefined;\n if (\n hasControlCharacter(normalized) ||\n /\\s/u.test(normalized) ||\n normalized.startsWith(\"-\") ||\n normalized.includes(\"\\\\\")\n ) {\n throw new Error(\"Invalid pi-sync Git remote.\");\n }\n if (\n !normalized.includes(\"://\") &&\n /^(?:[A-Za-z0-9._-]+@)?(?:\\[[0-9A-Fa-f:]+\\]|[A-Za-z0-9.-]+):(?!-)[^:].+$/u.test(normalized)\n ) {\n return normalized;\n }\n if (/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(normalized) && !normalized.includes(\"://\")) {\n throw new Error(\"Invalid pi-sync Git remote: unsupported transport or remote-helper syntax.\");\n }\n let url: URL;\n try {\n url = new URL(normalized);\n } catch {\n throw new Error(\"Invalid pi-sync Git remote: use an SSH or HTTPS remote.\");\n }\n if (url.protocol !== \"https:\" && url.protocol !== \"ssh:\") {\n throw new Error(\"Invalid pi-sync Git remote: only SSH and HTTPS are supported.\");\n }\n if (url.password || (url.protocol === \"https:\" && url.username)) {\n throw new Error(\"Invalid pi-sync Git remote: URL credentials or userinfo are not allowed.\");\n }\n if (url.search || url.hash || !url.hostname || !url.pathname || url.pathname === \"/\") {\n throw new Error(\"Invalid pi-sync Git remote.\");\n }\n return url.toString();\n}\n\nexport function normalizeGitRemoteIdentity(value: string) {\n const normalized = normalizeGitRemote(value);\n if (!normalized) return \"\";\n if (!normalized.includes(\"://\")) {\n const match = /^(?<user>[A-Za-z0-9._-]+@)?(?<host>\\[[0-9A-Fa-f:]+\\]|[A-Za-z0-9.-]+):(?<path>.+)$/u.exec(normalized);\n if (!match?.groups) return normalized;\n const userAndHost = `${match.groups.user ?? \"\"}${match.groups.host.toLowerCase()}`;\n const remotePath = match.groups.path.replace(/\\/+$/gu, \"\");\n return remotePath.startsWith(\"/\")\n ? `scp-absolute://${userAndHost}${remotePath}`\n : `ssh://${userAndHost}/${remotePath}`;\n }\n const url = new URL(normalized);\n url.hostname = url.hostname.toLowerCase();\n if (url.protocol === \"ssh:\" && url.port === \"22\") url.port = \"\";\n url.pathname = url.pathname.replace(/\\/+$/gu, \"\");\n if (url.protocol === \"ssh:\") {\n return `ssh://${url.username ? `${url.username}@` : \"\"}${url.host}${url.pathname}`;\n }\n return url.toString();\n}\n\nexport function normalizeGitBranch(value: string | undefined) {\n const branch = normalizeOptionalString(value) ?? DEFAULT_GIT_BRANCH;\n if (\n branch === \"@\" ||\n branch.startsWith(\"-\") ||\n branch.startsWith(\"refs/\") ||\n branch.startsWith(\"/\") ||\n branch.endsWith(\"/\") ||\n branch.endsWith(\".\") ||\n branch.includes(\"..\") ||\n branch.includes(\"@{\") ||\n branch.includes(\"\\\\\") ||\n hasControlCharacter(branch) ||\n /[ ~^:?*[\\]]/u.test(branch) ||\n branch.split(\"/\").some((segment) => !segment || segment.startsWith(\".\") || segment.endsWith(\".lock\"))\n ) {\n throw new Error(\"Invalid pi-sync Git branch.\");\n }\n return branch;\n}\n\nexport function normalizeGitDirectory(value: string | undefined) {\n if (value?.trim() === \".\" || value?.trim() === \"./\") return \"./\";\n const directory = trimSlashes(normalizeOptionalString(value) ?? DEFAULT_GIT_DIRECTORY);\n if (\n !directory ||\n directory.startsWith(\"-\") ||\n directory.includes(\"\\\\\") ||\n hasControlCharacter(directory) ||\n directory.split(\"/\").some((segment) => !segment || segment === \".\" || segment === \"..\" || segment === \".git\")\n ) {\n throw new Error(\"Invalid pi-sync Git directory.\");\n }\n return directory;\n}\n\nexport function validateGitNamespace(value: string) {\n if (\n value.length > 256 ||\n value === \".\" ||\n value === \"..\" ||\n value.includes(\"/\") ||\n value.includes(\"\\\\\") ||\n hasControlCharacter(value)\n ) {\n throw new Error(\"Invalid pi-sync Git namespace.\");\n }\n}\n\nfunction normalizeOptionalString(value: unknown) {\n if (value !== undefined && typeof value !== \"string\") {\n throw new Error(\"Invalid pi-sync settings: expected a string.\");\n }\n const normalized = value?.trim();\n return normalized || undefined;\n}\n\nfunction trimSlashes(value: string) {\n return value.replace(/^\\/+|\\/+$/gu, \"\");\n}\n\nfunction hasControlCharacter(value: string) {\n return [...value].some((character) => {\n const code = character.codePointAt(0) ?? 0;\n return code < 0x20 || (code >= 0x7f && code <= 0x9f);\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;AAAA,IAAM,qBAAqB;AAC3B,IAAM,wBAAwB;AAEvB,SAAS,mBAAmB,OAA2B;AAC5D,QAAM,aAAa,wBAAwB,KAAK;AAChD,MAAI,CAAC,WAAY,QAAO;AACxB,MACE,oBAAoB,UAAU,KAC9B,MAAM,KAAK,UAAU,KACrB,WAAW,WAAW,GAAG,KACzB,WAAW,SAAS,IAAI,GACxB;AACA,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,MACE,CAAC,WAAW,SAAS,KAAK,KAC1B,2EAA2E,KAAK,UAAU,GAC1F;AACA,WAAO;AAAA,EACT;AACA,MAAI,6BAA6B,KAAK,UAAU,KAAK,CAAC,WAAW,SAAS,KAAK,GAAG;AAChF,UAAM,IAAI,MAAM,4EAA4E;AAAA,EAC9F;AACA,MAAI;AACJ,MAAI;AACF,UAAM,IAAI,IAAI,UAAU;AAAA,EAC1B,QAAQ;AACN,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AACA,MAAI,IAAI,aAAa,YAAY,IAAI,aAAa,QAAQ;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BAAoB,OAAe;AAC1C,SAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,cAAc;AACpC,UAAM,OAAO,UAAU,YAAY,CAAC,KAAK;AACzC,WAAO,OAAO,MAAS,QAAQ,OAAQ,QAAQ;AAAA,EACjD,CAAC;AACH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
-
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
import {
|
|
4
|
-
sameLocalFields,
|
|
5
|
-
validatePortableSnapshot
|
|
6
|
-
} from "./chunk-MKSMJPVA.ts";
|
|
7
|
-
import {
|
|
8
|
-
safeTerminalText
|
|
9
|
-
} from "./chunk-AMJRUXFT.ts";
|
|
10
|
-
import {
|
|
11
|
-
syncConfigReviewFingerprint
|
|
12
|
-
} from "./chunk-OVBAW7KV.ts";
|
|
13
|
-
import {
|
|
14
|
-
throwIfAborted
|
|
15
|
-
} from "./chunk-PWMWOJP4.ts";
|
|
16
|
-
import {
|
|
17
|
-
filterSnapshotForConfigPolicy
|
|
18
|
-
} from "./chunk-ESKOPQVB.ts";
|
|
19
|
-
import {
|
|
20
|
-
inspectRemoteSelection,
|
|
21
|
-
remoteSelectionMismatch,
|
|
22
|
-
sameSyncInclude,
|
|
23
|
-
snapshotSelectionInclude
|
|
24
|
-
} from "./chunk-KYTT7KV4.ts";
|
|
25
|
-
|
|
26
|
-
// src/sync/remote-snapshot.ts
|
|
27
|
-
async function readSnapshotForHead(backend, head, signal) {
|
|
28
|
-
const snapshot = await backend.readSnapshot(head.snapshotRef, signal);
|
|
29
|
-
throwIfAborted(signal);
|
|
30
|
-
validatePortableSnapshot(snapshot);
|
|
31
|
-
if (snapshot.id !== head.snapshotId) {
|
|
32
|
-
throw new Error(`Remote head ${head.snapshotId} resolved to unexpected snapshot ${snapshot.id}.`);
|
|
33
|
-
}
|
|
34
|
-
if (head.selection) {
|
|
35
|
-
const snapshotInclude = snapshotSelectionInclude(snapshot);
|
|
36
|
-
if (!snapshotInclude || !sameSyncInclude(head.selection.include, snapshotInclude)) {
|
|
37
|
-
throw new Error("Remote head selection does not match its immutable snapshot.");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return snapshot;
|
|
41
|
-
}
|
|
42
|
-
function requireCompatibleRemoteSelection(config, snapshot) {
|
|
43
|
-
if (!sameLocalFields(config.localFields, snapshot.localFields))
|
|
44
|
-
throw new Error(
|
|
45
|
-
"Remote local-field policy differs; confirm a reviewed directional migration. Old history is not erased."
|
|
46
|
-
);
|
|
47
|
-
const state = inspectRemoteSelection(config.include, snapshot);
|
|
48
|
-
if (state.kind === "different") {
|
|
49
|
-
throw remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function formatRemoteSelectionStatus(state) {
|
|
53
|
-
if (!state) return "remote included content: unavailable (remote is empty)";
|
|
54
|
-
if (state.kind === "same") return "remote included content: matches this setup";
|
|
55
|
-
if (state.kind === "legacy") {
|
|
56
|
-
return `remote included content: unavailable in legacy snapshot (${state.discovered.length} path${state.discovered.length === 1 ? "" : "s"} discovered, partial)`;
|
|
57
|
-
}
|
|
58
|
-
return [
|
|
59
|
-
"remote included content: differs from this setup",
|
|
60
|
-
`remote-only selection: ${safeList(state.remoteOnly)}`,
|
|
61
|
-
`local-only selection: ${safeList(state.localOnly)}`
|
|
62
|
-
].join("\n");
|
|
63
|
-
}
|
|
64
|
-
function safeList(values) {
|
|
65
|
-
return values.length > 0 ? values.map(safeTerminalText).join(", ") : "none";
|
|
66
|
-
}
|
|
67
|
-
async function readRemoteSnapshot(backend, config, signal, options = {}) {
|
|
68
|
-
const head = await backend.readHead(signal);
|
|
69
|
-
if (!head) return { head: void 0, snapshot: void 0, selectionState: void 0 };
|
|
70
|
-
const snapshot = await readSnapshotForHead(backend, head, signal);
|
|
71
|
-
const selectionState = inspectRemoteSelection(config.include, snapshot);
|
|
72
|
-
if (!options.allowSelectionDifference && selectionState.kind === "different") {
|
|
73
|
-
const configIdentity = syncConfigReviewFingerprint(config);
|
|
74
|
-
throw remoteSelectionMismatch(config, selectionState.include, configIdentity);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
head,
|
|
78
|
-
snapshot: filterSnapshotForConfigPolicy(snapshot, config),
|
|
79
|
-
selectionState
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
readSnapshotForHead,
|
|
85
|
-
requireCompatibleRemoteSelection,
|
|
86
|
-
formatRemoteSelectionStatus,
|
|
87
|
-
readRemoteSnapshot
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=chunk-TIMWN2RH.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/sync/remote-snapshot.ts"],
|
|
4
|
-
"sourcesContent": ["import type { RemoteHead, SyncBackend } from \"../backends/sync-backend.js\";\nimport { syncConfigReviewFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { filterSnapshotForConfigPolicy } from \"../snapshot/snapshot.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { sameLocalFields, validatePortableSnapshot } from \"./local-fields.js\";\nimport { throwIfAborted } from \"./signals.js\";\nimport {\n inspectRemoteSelection,\n type RemoteSelectionState,\n remoteSelectionMismatch,\n sameSyncInclude,\n snapshotSelectionInclude,\n} from \"./sync-policy.js\";\n\nexport async function readSnapshotForHead(backend: SyncBackend, head: RemoteHead, signal?: AbortSignal) {\n const snapshot = await backend.readSnapshot(head.snapshotRef, signal);\n throwIfAborted(signal);\n validatePortableSnapshot(snapshot);\n if (snapshot.id !== head.snapshotId) {\n throw new Error(`Remote head ${head.snapshotId} resolved to unexpected snapshot ${snapshot.id}.`);\n }\n if (head.selection) {\n const snapshotInclude = snapshotSelectionInclude(snapshot);\n if (!snapshotInclude || !sameSyncInclude(head.selection.include, snapshotInclude)) {\n throw new Error(\"Remote head selection does not match its immutable snapshot.\");\n }\n }\n return snapshot;\n}\n\nexport function requireCompatibleRemoteSelection(config: AnySyncConfig, snapshot: Snapshot) {\n if (!sameLocalFields(config.localFields, snapshot.localFields))\n throw new Error(\n \"Remote local-field policy differs; confirm a reviewed directional migration. Old history is not erased.\",\n );\n const state = inspectRemoteSelection(config.include, snapshot);\n if (state.kind === \"different\") {\n throw remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config));\n }\n}\n\nexport function formatRemoteSelectionStatus(state: RemoteSelectionState | undefined) {\n if (!state) return \"remote included content: unavailable (remote is empty)\";\n if (state.kind === \"same\") return \"remote included content: matches this setup\";\n if (state.kind === \"legacy\") {\n return `remote included content: unavailable in legacy snapshot (${state.discovered.length} path${state.discovered.length === 1 ? \"\" : \"s\"} discovered, partial)`;\n }\n return [\n \"remote included content: differs from this setup\",\n `remote-only selection: ${safeList(state.remoteOnly)}`,\n `local-only selection: ${safeList(state.localOnly)}`,\n ].join(\"\\n\");\n}\n\nfunction safeList(values: readonly string[]) {\n return values.length > 0 ? values.map(safeTerminalText).join(\", \") : \"none\";\n}\n\nexport async function readRemoteSnapshot(\n backend: SyncBackend,\n config: AnySyncConfig,\n signal?: AbortSignal,\n options: { allowSelectionDifference?: boolean } = {},\n) {\n const head = await backend.readHead(signal);\n if (!head) return { head: undefined, snapshot: undefined, selectionState: undefined };\n const snapshot = await readSnapshotForHead(backend, head, signal);\n const selectionState = inspectRemoteSelection(config.include, snapshot);\n if (!options.allowSelectionDifference && selectionState.kind === \"different\") {\n const configIdentity = syncConfigReviewFingerprint(config);\n throw remoteSelectionMismatch(config, selectionState.include, configIdentity);\n }\n return {\n head,\n snapshot: filterSnapshotForConfigPolicy(snapshot, config),\n selectionState,\n };\n}\n"],
|
|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EAAE,KAAK,IAAI,IAAI;AACvE;AAEA,eAAsB,mBACpB,SACA,QACA,QACA,UAAkD,CAAC,GACnD;AACA,QAAM,OAAO,MAAM,QAAQ,SAAS,MAAM;AAC1C,MAAI,CAAC,KAAM,QAAO,EAAE,MAAM,QAAW,UAAU,QAAW,gBAAgB,OAAU;AACpF,QAAM,WAAW,MAAM,oBAAoB,SAAS,MAAM,MAAM;AAChE,QAAM,iBAAiB,uBAAuB,OAAO,SAAS,QAAQ;AACtE,MAAI,CAAC,QAAQ,4BAA4B,eAAe,SAAS,aAAa;AAC5E,UAAM,iBAAiB,4BAA4B,MAAM;AACzD,UAAM,wBAAwB,QAAQ,eAAe,SAAS,cAAc;AAAA,EAC9E;AACA,SAAO;AAAA,IACL;AAAA,IACA,UAAU,8BAA8B,UAAU,MAAM;AAAA,IACxD;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
-
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
import {
|
|
4
|
-
encodeSnapshot
|
|
5
|
-
} from "./chunk-FLHCOJCD.ts";
|
|
6
|
-
import {
|
|
7
|
-
throwIfAborted
|
|
8
|
-
} from "./chunk-PWMWOJP4.ts";
|
|
9
|
-
import {
|
|
10
|
-
syncDirectory
|
|
11
|
-
} from "./chunk-AR2DGDUI.ts";
|
|
12
|
-
import {
|
|
13
|
-
stateDir
|
|
14
|
-
} from "./chunk-SWRVXVFD.ts";
|
|
15
|
-
import {
|
|
16
|
-
createSnapshot,
|
|
17
|
-
sessionSnapshotPathFromAbsolute
|
|
18
|
-
} from "./chunk-ESKOPQVB.ts";
|
|
19
|
-
import {
|
|
20
|
-
sessionDirFromContext
|
|
21
|
-
} from "./chunk-CBLTWXAU.ts";
|
|
22
|
-
|
|
23
|
-
// src/sync/sync-local.ts
|
|
24
|
-
import fs from "node:fs/promises";
|
|
25
|
-
import path from "node:path";
|
|
26
|
-
function protectedSessionPaths(ctx, sessionRoot = sessionDirFromContext(ctx)) {
|
|
27
|
-
const getSessionFile = ctx.sessionManager.getSessionFile;
|
|
28
|
-
if (typeof getSessionFile !== "function") return /* @__PURE__ */ new Set();
|
|
29
|
-
const sessionFile = getSessionFile.call(ctx.sessionManager);
|
|
30
|
-
const snapshotPath = sessionFile ? sessionSnapshotPathFromAbsolute(sessionFile, sessionRoot) : void 0;
|
|
31
|
-
return snapshotPath ? /* @__PURE__ */ new Set([snapshotPath]) : /* @__PURE__ */ new Set();
|
|
32
|
-
}
|
|
33
|
-
async function backupLocal(profile, options = {}, signal) {
|
|
34
|
-
throwIfAborted(signal);
|
|
35
|
-
const snapshot = await createSnapshot(profile, { ...options, signal });
|
|
36
|
-
throwIfAborted(signal);
|
|
37
|
-
const backupDirectory = path.join(stateDir(), "backups");
|
|
38
|
-
await fs.mkdir(backupDirectory, { recursive: true, mode: 448 });
|
|
39
|
-
throwIfAborted(signal);
|
|
40
|
-
const backupPath = path.join(backupDirectory, `${snapshot.id}.json.gz`);
|
|
41
|
-
const encoded = await encodeSnapshot(snapshot);
|
|
42
|
-
throwIfAborted(signal);
|
|
43
|
-
const handle = await fs.open(backupPath, "wx", 384);
|
|
44
|
-
try {
|
|
45
|
-
await handle.writeFile(encoded);
|
|
46
|
-
await handle.sync();
|
|
47
|
-
} finally {
|
|
48
|
-
await handle.close();
|
|
49
|
-
}
|
|
50
|
-
await syncDirectory(backupDirectory);
|
|
51
|
-
return backupPath;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
protectedSessionPaths,
|
|
56
|
-
backupLocal
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=chunk-TZC7GDJE.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/sync/sync-local.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { sessionDirFromContext } from \"../snapshot/session-paths.js\";\nimport { createSnapshot, sessionSnapshotPathFromAbsolute } from \"../snapshot/snapshot.js\";\nimport { encodeSnapshot } from \"../snapshot/snapshot-codec.js\";\nimport type { SnapshotOptions } from \"../snapshot/snapshot-types.js\";\nimport { syncDirectory } from \"../state/json-file.js\";\nimport { stateDir } from \"../state/state-directory.js\";\nimport { throwIfAborted } from \"./signals.js\";\n\nexport function protectedSessionPaths(\n ctx: ExtensionCommandContext | ExtensionContext,\n sessionRoot = sessionDirFromContext(ctx),\n) {\n const getSessionFile = ctx.sessionManager.getSessionFile;\n if (typeof getSessionFile !== \"function\") return new Set<string>();\n const sessionFile = getSessionFile.call(ctx.sessionManager) as string | undefined;\n const snapshotPath = sessionFile ? sessionSnapshotPathFromAbsolute(sessionFile, sessionRoot) : undefined;\n return snapshotPath ? new Set([snapshotPath]) : new Set<string>();\n}\n\nexport { captureMutationOwner } from \"./mutation-owner.js\";\n\nexport async function backupLocal(profile: string, options: SnapshotOptions = {}, signal?: AbortSignal) {\n throwIfAborted(signal);\n const snapshot = await createSnapshot(profile, { ...options, signal });\n throwIfAborted(signal);\n const backupDirectory = path.join(stateDir(), \"backups\");\n await fs.mkdir(backupDirectory, { recursive: true, mode: 0o700 });\n throwIfAborted(signal);\n const backupPath = path.join(backupDirectory, `${snapshot.id}.json.gz`);\n const encoded = await encodeSnapshot(snapshot);\n throwIfAborted(signal);\n const handle = await fs.open(backupPath, \"wx\", 0o600);\n try {\n await handle.writeFile(encoded);\n await handle.sync();\n } finally {\n await handle.close();\n }\n await syncDirectory(backupDirectory);\n return backupPath;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAUV,SAAS,sBACd,KACA,cAAc,sBAAsB,GAAG,GACvC;AACA,QAAM,iBAAiB,IAAI,eAAe;AAC1C,MAAI,OAAO,mBAAmB,WAAY,QAAO,oBAAI,IAAY;AACjE,QAAM,cAAc,eAAe,KAAK,IAAI,cAAc;AAC1D,QAAM,eAAe,cAAc,gCAAgC,aAAa,WAAW,IAAI;AAC/F,SAAO,eAAe,oBAAI,IAAI,CAAC,YAAY,CAAC,IAAI,oBAAI,IAAY;AAClE;AAIA,eAAsB,YAAY,SAAiB,UAA2B,CAAC,GAAG,QAAsB;AACtG,iBAAe,MAAM;AACrB,QAAM,WAAW,MAAM,eAAe,SAAS,EAAE,GAAG,SAAS,OAAO,CAAC;AACrE,iBAAe,MAAM;AACrB,QAAM,kBAAkB,KAAK,KAAK,SAAS,GAAG,SAAS;AACvD,QAAM,GAAG,MAAM,iBAAiB,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAChE,iBAAe,MAAM;AACrB,QAAM,aAAa,KAAK,KAAK,iBAAiB,GAAG,SAAS,EAAE,UAAU;AACtE,QAAM,UAAU,MAAM,eAAe,QAAQ;AAC7C,iBAAe,MAAM;AACrB,QAAM,SAAS,MAAM,GAAG,KAAK,YAAY,MAAM,GAAK;AACpD,MAAI;AACF,UAAM,OAAO,UAAU,OAAO;AAC9B,UAAM,OAAO,KAAK;AAAA,EACpB,UAAE;AACA,UAAM,OAAO,MAAM;AAAA,EACrB;AACA,QAAM,cAAc,eAAe;AACnC,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|