@narumitw/pi-sync 0.71.1 → 0.71.2
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 +6 -0
- package/README.md +1 -1
- package/dist/chunks/{agent-plan-A6CS3XXA.ts → agent-plan-RZYCE5OS.ts} +15 -15
- package/dist/chunks/{chunk-RFJWUIV5.ts → chunk-36CY6QDF.ts} +30 -31
- package/dist/chunks/chunk-36CY6QDF.ts.map +7 -0
- package/dist/chunks/{chunk-IFJXUHHC.ts → chunk-3LB5YP2P.ts} +3 -3
- package/dist/chunks/{chunk-MS6HLJFR.ts → chunk-3LGVYJFC.ts} +7 -7
- package/dist/chunks/{chunk-T22OVZSI.ts → chunk-4FEFBPVA.ts} +4 -4
- package/dist/chunks/{chunk-TAOYC2YG.ts → chunk-5O6O74G5.ts} +2 -2
- package/dist/chunks/{chunk-W3YS4Y2Q.ts → chunk-5UURT4LR.ts} +15 -6
- package/dist/chunks/chunk-5UURT4LR.ts.map +7 -0
- package/dist/chunks/{chunk-JPLT2DG6.ts → chunk-72AVEVDF.ts} +6 -6
- package/dist/chunks/{chunk-RRFW2UAD.ts → chunk-7FMAJ56J.ts} +4 -4
- package/dist/chunks/{chunk-QJTU5SCJ.ts → chunk-ABU7CXAG.ts} +2 -2
- package/dist/chunks/{chunk-D34Y5JSL.ts → chunk-BC4P223U.ts} +4 -4
- package/dist/chunks/{chunk-WT2722L4.ts → chunk-CH4KLBTH.ts} +6 -6
- package/dist/chunks/{chunk-QRSESWT2.ts → chunk-CXNCR2AE.ts} +2 -2
- package/dist/chunks/{chunk-AA2G3HTW.ts → chunk-DA5AW5JQ.ts} +3 -3
- package/dist/chunks/{chunk-ES4FIIHZ.ts → chunk-DN5GOY65.ts} +1 -1
- package/dist/chunks/{chunk-ES4FIIHZ.ts.map → chunk-DN5GOY65.ts.map} +2 -2
- package/dist/chunks/{chunk-3M3KQFSQ.ts → chunk-EEPH2FPC.ts} +2 -2
- package/dist/chunks/{chunk-V66NV2HZ.ts → chunk-G4DPBJAU.ts} +7 -7
- package/dist/chunks/{chunk-KDTDGAOM.ts → chunk-GKIBDRT3.ts} +2 -2
- package/dist/chunks/{chunk-WETDHZAD.ts → chunk-HUUQUCSX.ts} +3 -3
- package/dist/chunks/{chunk-YLVRV6NM.ts → chunk-IJECQD65.ts} +2 -2
- package/dist/chunks/{chunk-MTUR4H7S.ts → chunk-K4LJOMYD.ts} +9 -9
- package/dist/chunks/{chunk-FT45DX6E.ts → chunk-KFUZZROG.ts} +14 -14
- package/dist/chunks/{chunk-AVLYLWA7.ts → chunk-KZKBQ474.ts} +5 -5
- package/dist/chunks/{chunk-YV776ZPN.ts → chunk-LZGSJKKQ.ts} +4 -4
- package/dist/chunks/{chunk-DLA5RPFP.ts → chunk-M6C5UVNO.ts} +2 -2
- package/dist/chunks/{chunk-FIEW5453.ts → chunk-M7ZDYH7G.ts} +5 -5
- package/dist/chunks/{chunk-NFZMKZ2D.ts → chunk-MEXYSX5Y.ts} +2 -2
- package/dist/chunks/{chunk-2G6GTIWW.ts → chunk-N6ZK34AM.ts} +7 -7
- package/dist/chunks/{chunk-MHERAG42.ts → chunk-NOAQCRP6.ts} +6 -6
- package/dist/chunks/{chunk-INUH2UXN.ts → chunk-NOPE2X6N.ts} +2 -2
- package/dist/chunks/{chunk-U6CORBHU.ts → chunk-NP6NTBI2.ts} +2 -2
- package/dist/chunks/{chunk-NFW5HLKA.ts → chunk-PFVGR5PB.ts} +5 -5
- package/dist/chunks/{chunk-2BMTS5OW.ts → chunk-RLP6VXRF.ts} +3 -3
- package/dist/chunks/{chunk-A7KJUFLX.ts → chunk-SJRCMS56.ts} +15 -8
- package/dist/chunks/chunk-SJRCMS56.ts.map +7 -0
- package/dist/chunks/{chunk-GDA35HWZ.ts → chunk-TDYYLKSB.ts} +6 -6
- package/dist/chunks/{chunk-YVHXQZIH.ts → chunk-TS2REUA6.ts} +4 -4
- package/dist/chunks/{chunk-DH52CVRD.ts → chunk-V6FUEJJA.ts} +22 -22
- package/dist/chunks/{chunk-DH52CVRD.ts.map → chunk-V6FUEJJA.ts.map} +2 -2
- package/dist/chunks/{chunk-6VGQ6THO.ts → chunk-YATSYNIM.ts} +3 -3
- package/dist/chunks/{chunk-C2YD64T6.ts → chunk-YHOVBAQI.ts} +3 -3
- package/dist/chunks/{chunk-GC5XDUVA.ts → chunk-YUKFRKAE.ts} +7 -7
- package/dist/chunks/{chunk-OTI4XVCS.ts → chunk-ZNAA4FNG.ts} +2 -2
- package/dist/chunks/{chunk-ZWOKNJDT.ts → chunk-ZSH6DHQI.ts} +4 -4
- package/dist/chunks/{command-handler-SMARANCT.ts → command-handler-XB2GQIQ4.ts} +21 -21
- package/dist/chunks/{config-PUZS2ZBP.ts → config-JPCGGETF.ts} +6 -6
- package/dist/chunks/{conflict-artifacts-77PI6IXK.ts → conflict-artifacts-UUWACJBW.ts} +12 -12
- package/dist/chunks/{conflict-review-OO57TGMR.ts → conflict-review-GKFIWYCK.ts} +15 -15
- package/dist/chunks/{conflict-review-HHGVL5TP.ts → conflict-review-SACA5537.ts} +26 -26
- package/dist/chunks/{continuous-record-QIIFQNKP.ts → continuous-record-AP6LVXUJ.ts} +9 -9
- package/dist/chunks/{debug-tool-execution-AIQAGPMJ.ts → debug-tool-execution-HQ4ITDWB.ts} +11 -11
- package/dist/chunks/{diff-review-QRHOHG5C.ts → diff-review-LVIYNDLG.ts} +5 -5
- package/dist/chunks/{file-selection-ZEBPDRHG.ts → file-selection-4UE2RUOC.ts} +14 -14
- package/dist/chunks/{git-backend-I2IJ5ULJ.ts → git-backend-XOAHKZMR.ts} +8 -8
- package/dist/chunks/{initialization-XGYWRNPQ.ts → initialization-OVZUKZ6H.ts} +10 -10
- package/dist/chunks/{local-diff-review-OGZM3TA7.ts → local-diff-review-CJWITN2A.ts} +29 -29
- package/dist/chunks/{local-fields-PIKOEXWR.ts → local-fields-Z4RMLREX.ts} +6 -6
- package/dist/chunks/{manager-result-dispatcher-72YGSLHL.ts → manager-result-dispatcher-N2INFZFN.ts} +18 -18
- package/dist/chunks/{manager-ui-5SXPS4SE.ts → manager-ui-ROKHMOQF.ts} +28 -28
- package/dist/chunks/{merge-baseline-store-MI7SHGDH.ts → merge-baseline-store-M3HLNMAE.ts} +7 -7
- package/dist/chunks/{merge-journal-46QC5N7D.ts → merge-journal-37ED5KZY.ts} +11 -11
- package/dist/chunks/{remote-selection-ui-4BXJAZUD.ts → remote-selection-ui-CJ5ICXMF.ts} +17 -17
- package/dist/chunks/{s3-backend-ZRMOWH5R.ts → s3-backend-CBUPAAS4.ts} +13 -13
- package/dist/chunks/{session-push-55IV4IW3.ts → session-push-TNYJYIKE.ts} +16 -16
- package/dist/chunks/{setup-switch-DXDUBDQI.ts → setup-switch-QBW7RNRW.ts} +12 -12
- package/dist/chunks/{setup-wizard-ICPQERAE.ts → setup-wizard-IX67AV3T.ts} +14 -14
- package/dist/chunks/{snapshot-HDARHOQZ.ts → snapshot-I7EZP5Q7.ts} +5 -5
- package/dist/chunks/{snapshot-LZ6XKFA4.ts → snapshot-T26QGKIX.ts} +5 -5
- package/dist/chunks/{snapshot-transaction-LYR5OFLR.ts → snapshot-transaction-C2SEYO5T.ts} +11 -11
- package/dist/chunks/{sync-inspection-PMEXXLDK.ts → sync-inspection-HIGQPANV.ts} +10 -10
- package/dist/chunks/sync-inspection-T7COH3PW.ts +29 -0
- package/dist/chunks/sync-operations-E7SAZJEF.ts +69 -0
- package/dist/chunks/{sync-operations-VSMA5GSA.ts → sync-operations-XI7RJZWI.ts} +14 -14
- package/dist/chunks/{sync-state-72ZDKUQW.ts → sync-state-7R5EOJIY.ts} +7 -7
- package/dist/chunks/{sync-state-store-YTMAZQ3Z.ts → sync-state-store-ELTCECE4.ts} +5 -5
- package/dist/chunks/{webdav-backend-3AZOECVQ.ts → webdav-backend-EK5UCAQE.ts} +10 -10
- package/dist/index.ts +19 -19
- package/docs/daemon-migration.md +1 -1
- package/docs/merge-implementation-audit.md +2 -2
- package/package.json +1 -1
- package/skills/configure-pi-sync/references/configuration.md +1 -0
- package/src/engine/host.ts +1 -0
- package/src/engine/snapshot/snapshot-apply.ts +1 -1
- package/src/engine/snapshot/snapshot-transaction-policy.ts +1 -0
- package/src/engine/snapshot/snapshot-transaction.ts +7 -0
- package/src/engine/sync/sync-mutations.ts +14 -12
- package/src/runtime/local-host.ts +1 -0
- package/src/runtime/session-presence.ts +13 -4
- package/dist/chunks/chunk-A7KJUFLX.ts.map +0 -7
- package/dist/chunks/chunk-RFJWUIV5.ts.map +0 -7
- package/dist/chunks/chunk-W3YS4Y2Q.ts.map +0 -7
- package/dist/chunks/sync-inspection-N6TELULU.ts +0 -29
- package/dist/chunks/sync-operations-KKSIS2CI.ts +0 -69
- /package/dist/chunks/{agent-plan-A6CS3XXA.ts.map → agent-plan-RZYCE5OS.ts.map} +0 -0
- /package/dist/chunks/{chunk-IFJXUHHC.ts.map → chunk-3LB5YP2P.ts.map} +0 -0
- /package/dist/chunks/{chunk-MS6HLJFR.ts.map → chunk-3LGVYJFC.ts.map} +0 -0
- /package/dist/chunks/{chunk-T22OVZSI.ts.map → chunk-4FEFBPVA.ts.map} +0 -0
- /package/dist/chunks/{chunk-TAOYC2YG.ts.map → chunk-5O6O74G5.ts.map} +0 -0
- /package/dist/chunks/{chunk-JPLT2DG6.ts.map → chunk-72AVEVDF.ts.map} +0 -0
- /package/dist/chunks/{chunk-RRFW2UAD.ts.map → chunk-7FMAJ56J.ts.map} +0 -0
- /package/dist/chunks/{chunk-QJTU5SCJ.ts.map → chunk-ABU7CXAG.ts.map} +0 -0
- /package/dist/chunks/{chunk-D34Y5JSL.ts.map → chunk-BC4P223U.ts.map} +0 -0
- /package/dist/chunks/{chunk-WT2722L4.ts.map → chunk-CH4KLBTH.ts.map} +0 -0
- /package/dist/chunks/{chunk-QRSESWT2.ts.map → chunk-CXNCR2AE.ts.map} +0 -0
- /package/dist/chunks/{chunk-AA2G3HTW.ts.map → chunk-DA5AW5JQ.ts.map} +0 -0
- /package/dist/chunks/{chunk-3M3KQFSQ.ts.map → chunk-EEPH2FPC.ts.map} +0 -0
- /package/dist/chunks/{chunk-V66NV2HZ.ts.map → chunk-G4DPBJAU.ts.map} +0 -0
- /package/dist/chunks/{chunk-KDTDGAOM.ts.map → chunk-GKIBDRT3.ts.map} +0 -0
- /package/dist/chunks/{chunk-WETDHZAD.ts.map → chunk-HUUQUCSX.ts.map} +0 -0
- /package/dist/chunks/{chunk-YLVRV6NM.ts.map → chunk-IJECQD65.ts.map} +0 -0
- /package/dist/chunks/{chunk-MTUR4H7S.ts.map → chunk-K4LJOMYD.ts.map} +0 -0
- /package/dist/chunks/{chunk-FT45DX6E.ts.map → chunk-KFUZZROG.ts.map} +0 -0
- /package/dist/chunks/{chunk-AVLYLWA7.ts.map → chunk-KZKBQ474.ts.map} +0 -0
- /package/dist/chunks/{chunk-YV776ZPN.ts.map → chunk-LZGSJKKQ.ts.map} +0 -0
- /package/dist/chunks/{chunk-DLA5RPFP.ts.map → chunk-M6C5UVNO.ts.map} +0 -0
- /package/dist/chunks/{chunk-FIEW5453.ts.map → chunk-M7ZDYH7G.ts.map} +0 -0
- /package/dist/chunks/{chunk-NFZMKZ2D.ts.map → chunk-MEXYSX5Y.ts.map} +0 -0
- /package/dist/chunks/{chunk-2G6GTIWW.ts.map → chunk-N6ZK34AM.ts.map} +0 -0
- /package/dist/chunks/{chunk-MHERAG42.ts.map → chunk-NOAQCRP6.ts.map} +0 -0
- /package/dist/chunks/{chunk-INUH2UXN.ts.map → chunk-NOPE2X6N.ts.map} +0 -0
- /package/dist/chunks/{chunk-U6CORBHU.ts.map → chunk-NP6NTBI2.ts.map} +0 -0
- /package/dist/chunks/{chunk-NFW5HLKA.ts.map → chunk-PFVGR5PB.ts.map} +0 -0
- /package/dist/chunks/{chunk-2BMTS5OW.ts.map → chunk-RLP6VXRF.ts.map} +0 -0
- /package/dist/chunks/{chunk-GDA35HWZ.ts.map → chunk-TDYYLKSB.ts.map} +0 -0
- /package/dist/chunks/{chunk-YVHXQZIH.ts.map → chunk-TS2REUA6.ts.map} +0 -0
- /package/dist/chunks/{chunk-6VGQ6THO.ts.map → chunk-YATSYNIM.ts.map} +0 -0
- /package/dist/chunks/{chunk-C2YD64T6.ts.map → chunk-YHOVBAQI.ts.map} +0 -0
- /package/dist/chunks/{chunk-GC5XDUVA.ts.map → chunk-YUKFRKAE.ts.map} +0 -0
- /package/dist/chunks/{chunk-OTI4XVCS.ts.map → chunk-ZNAA4FNG.ts.map} +0 -0
- /package/dist/chunks/{chunk-ZWOKNJDT.ts.map → chunk-ZSH6DHQI.ts.map} +0 -0
- /package/dist/chunks/{command-handler-SMARANCT.ts.map → command-handler-XB2GQIQ4.ts.map} +0 -0
- /package/dist/chunks/{config-PUZS2ZBP.ts.map → config-JPCGGETF.ts.map} +0 -0
- /package/dist/chunks/{conflict-artifacts-77PI6IXK.ts.map → conflict-artifacts-UUWACJBW.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-OO57TGMR.ts.map → conflict-review-GKFIWYCK.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-HHGVL5TP.ts.map → conflict-review-SACA5537.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-QIIFQNKP.ts.map → continuous-record-AP6LVXUJ.ts.map} +0 -0
- /package/dist/chunks/{debug-tool-execution-AIQAGPMJ.ts.map → debug-tool-execution-HQ4ITDWB.ts.map} +0 -0
- /package/dist/chunks/{diff-review-QRHOHG5C.ts.map → diff-review-LVIYNDLG.ts.map} +0 -0
- /package/dist/chunks/{file-selection-ZEBPDRHG.ts.map → file-selection-4UE2RUOC.ts.map} +0 -0
- /package/dist/chunks/{git-backend-I2IJ5ULJ.ts.map → git-backend-XOAHKZMR.ts.map} +0 -0
- /package/dist/chunks/{initialization-XGYWRNPQ.ts.map → initialization-OVZUKZ6H.ts.map} +0 -0
- /package/dist/chunks/{local-diff-review-OGZM3TA7.ts.map → local-diff-review-CJWITN2A.ts.map} +0 -0
- /package/dist/chunks/{local-fields-PIKOEXWR.ts.map → local-fields-Z4RMLREX.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-72YGSLHL.ts.map → manager-result-dispatcher-N2INFZFN.ts.map} +0 -0
- /package/dist/chunks/{manager-ui-5SXPS4SE.ts.map → manager-ui-ROKHMOQF.ts.map} +0 -0
- /package/dist/chunks/{merge-baseline-store-MI7SHGDH.ts.map → merge-baseline-store-M3HLNMAE.ts.map} +0 -0
- /package/dist/chunks/{merge-journal-46QC5N7D.ts.map → merge-journal-37ED5KZY.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-4BXJAZUD.ts.map → remote-selection-ui-CJ5ICXMF.ts.map} +0 -0
- /package/dist/chunks/{s3-backend-ZRMOWH5R.ts.map → s3-backend-CBUPAAS4.ts.map} +0 -0
- /package/dist/chunks/{session-push-55IV4IW3.ts.map → session-push-TNYJYIKE.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-DXDUBDQI.ts.map → setup-switch-QBW7RNRW.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-ICPQERAE.ts.map → setup-wizard-IX67AV3T.ts.map} +0 -0
- /package/dist/chunks/{snapshot-HDARHOQZ.ts.map → snapshot-I7EZP5Q7.ts.map} +0 -0
- /package/dist/chunks/{snapshot-LZ6XKFA4.ts.map → snapshot-T26QGKIX.ts.map} +0 -0
- /package/dist/chunks/{snapshot-transaction-LYR5OFLR.ts.map → snapshot-transaction-C2SEYO5T.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-N6TELULU.ts.map → sync-inspection-HIGQPANV.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-PMEXXLDK.ts.map → sync-inspection-T7COH3PW.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-KKSIS2CI.ts.map → sync-operations-E7SAZJEF.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-VSMA5GSA.ts.map → sync-operations-XI7RJZWI.ts.map} +0 -0
- /package/dist/chunks/{sync-state-72ZDKUQW.ts.map → sync-state-7R5EOJIY.ts.map} +0 -0
- /package/dist/chunks/{sync-state-store-YTMAZQ3Z.ts.map → sync-state-store-ELTCECE4.ts.map} +0 -0
- /package/dist/chunks/{webdav-backend-3AZOECVQ.ts.map → webdav-backend-EK5UCAQE.ts.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @narumitw/pi-sync
|
|
2
2
|
|
|
3
|
+
## 0.71.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 44e6724: Stop Pull before creating a backup when another Pi uses the same agent directory. Report a refusal before local writes without warning that files may have been applied.
|
|
8
|
+
|
|
3
9
|
## 0.71.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -376,7 +376,7 @@ Snapshot recovery is guarded: new journals record before/after images, older jou
|
|
|
376
376
|
Before pull or rollback, Pi Sync writes a backup under `<agent-dir>/pi-sync/backups/`. It leaves byte-identical regular files in place when their exact paths already match and no structural change is needed. It checks those files again before accepting the transfer. See [Restore a local backup](#restore-a-local-backup) for local edits that were never published.
|
|
377
377
|
Snapshot apply and recovery require canonical agent and session paths. Preflight refuses parent aliases it detects because Pi's file queue uses different keys for existing and missing aliases. Node's path-based writes and deletes cannot prevent another process from replacing a parent directory after a check. Use directories you control, and pause tools that move or replace their directories during sync. Preserve any pending recovery evidence; an unresolved startup recovery barrier still blocks transfers. Old journals recorded under an alias require manual review because their exact root and target paths remain pinned. Changing the agent path alone does not authorize recovery or rewriting those journals.
|
|
378
378
|
Apply preflights paths and checksums, journals mutations, and restores prior state only when current bytes match verified preimages or planned postimages. Unknown intermediate directory states and newer edits require review rather than a blind rollback. An interruption after replacement is armed can require manual recovery even if installation never ran; a later deletion of installed content is not treated as an unfinished remove.
|
|
379
|
-
Pi's file queues coordinate writers in the current Pi process. Cross-process locks serialize Pi Sync settings saves and sync operations; writes to Pi's own `settings.json` also use Pi's settings lock. Pi Sync protects known active session files and blocks managed local writes while another registered Pi uses the same agent directory.
|
|
379
|
+
Pi's file queues coordinate writers in the current Pi process. Cross-process locks serialize Pi Sync settings saves and sync operations; writes to Pi's own `settings.json` also use Pi's settings lock. Pi Sync protects known active session files and blocks managed local writes while another registered Pi uses the same agent directory. Pull checks for other registered Pi processes before creating its backup. It checks again when it starts a protected write. Before applying a transfer, close the other Pi processes that use this directory and review `/sync diff`. If you usually keep several Pi windows open, leave **Startup transfer** off and run a reviewed transfer from the only open Pi. Protection starts when Pi Sync registers the session, not when Pi core first opens it. It does not detect every Pi process or exclude arbitrary editors. Close older Pi processes and pause other writers before applying a transfer. Hash-based journals cannot distinguish a later write of identical recorded bytes or provide an atomic check-and-write against those writers.
|
|
380
380
|
Merged transfers instead retain a private publication/apply/baseline journal and roll forward only when the active remote candidate and every changed local preimage/postimage can be verified. A crash or uncertain publication is reconciled through `/sync sync` without blind republishing. If newer local or remote changes prevent reconciliation, preserve the evidence and review `/sync diff`. An explicitly reviewed `push --force` or `pull --force` can archive the old journal. Disabling automatic transfer does not undo completed transfers. Do not downgrade while a merge or snapshot recovery journal is pending.
|
|
381
381
|
|
|
382
382
|
Removing a local setup or connection never deletes remote data.
|
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
COUPLED_FIELDS,
|
|
5
5
|
mergeSettingsJson,
|
|
6
6
|
snapshotFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EEPH2FPC.ts";
|
|
8
8
|
import {
|
|
9
9
|
fileHashMap,
|
|
10
10
|
sameHashes
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BC4P223U.ts";
|
|
12
12
|
import {
|
|
13
13
|
ContinuousError
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-GKIBDRT3.ts";
|
|
15
|
+
import "./chunk-M6C5UVNO.ts";
|
|
16
16
|
import {
|
|
17
17
|
AGENT_INPUT_BYTES,
|
|
18
18
|
AGENT_MAX_UNITS,
|
|
@@ -24,18 +24,18 @@ import {
|
|
|
24
24
|
lines,
|
|
25
25
|
readMergeAncestors,
|
|
26
26
|
text
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-TS2REUA6.ts";
|
|
28
28
|
import {
|
|
29
29
|
readStateForConfig,
|
|
30
30
|
syncStateFingerprint
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-PFVGR5PB.ts";
|
|
32
32
|
import "./chunk-ESUMO4TW.ts";
|
|
33
33
|
import {
|
|
34
34
|
syncConfigReviewIdentity
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import "./chunk-
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-KZKBQ474.ts";
|
|
36
|
+
import "./chunk-5O6O74G5.ts";
|
|
37
|
+
import "./chunk-MEXYSX5Y.ts";
|
|
38
|
+
import "./chunk-YHOVBAQI.ts";
|
|
39
39
|
import "./chunk-5WUWHDCJ.ts";
|
|
40
40
|
import {
|
|
41
41
|
parseJsonObjectDocument,
|
|
@@ -44,12 +44,12 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
createSnapshot,
|
|
46
46
|
scanSnapshot
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-HUUQUCSX.ts";
|
|
48
48
|
import "./chunk-QIL27OLJ.ts";
|
|
49
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-7FMAJ56J.ts";
|
|
50
50
|
import "./chunk-ULNEZ53E.ts";
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-
|
|
51
|
+
import "./chunk-ZNAA4FNG.ts";
|
|
52
|
+
import "./chunk-DN5GOY65.ts";
|
|
53
53
|
import "./chunk-C66HLRRZ.ts";
|
|
54
54
|
|
|
55
55
|
// src/engine/sync/agent-candidate.ts
|
|
@@ -334,4 +334,4 @@ async function resolveAgentPlan(ctx, options, config, backend, state, local, loc
|
|
|
334
334
|
export {
|
|
335
335
|
resolveAgentPlan
|
|
336
336
|
};
|
|
337
|
-
//# sourceMappingURL=agent-plan-
|
|
337
|
+
//# sourceMappingURL=agent-plan-RZYCE5OS.ts.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
DirectionalDestinationConflict,
|
|
5
5
|
needsDirectionalForce,
|
|
6
6
|
recheckDirectionalReview
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LZGSJKKQ.ts";
|
|
8
8
|
import {
|
|
9
9
|
addTopLevelCaseVariantDeletes,
|
|
10
10
|
applySnapshot,
|
|
@@ -23,25 +23,25 @@ import {
|
|
|
23
23
|
selectedPublicationImage,
|
|
24
24
|
selectedPullImage,
|
|
25
25
|
transferSizeLimitsEnabled
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-V6FUEJJA.ts";
|
|
27
27
|
import {
|
|
28
28
|
LocalBackupVerificationError,
|
|
29
29
|
backupDirectionalSnapshot,
|
|
30
30
|
backupLocal,
|
|
31
31
|
maybeReload,
|
|
32
32
|
protectedSessionPaths
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-72AVEVDF.ts";
|
|
34
34
|
import {
|
|
35
35
|
readMergeJournal,
|
|
36
36
|
requireNoMergeJournal,
|
|
37
37
|
retireMergeJournal
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-N6ZK34AM.ts";
|
|
39
39
|
import {
|
|
40
40
|
inspectSync
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-G4DPBJAU.ts";
|
|
42
42
|
import {
|
|
43
43
|
createSyncBackend
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-ZSH6DHQI.ts";
|
|
45
45
|
import {
|
|
46
46
|
formatRemoteSelectionStatus,
|
|
47
47
|
readRemoteSnapshot,
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
safeTerminalText,
|
|
52
52
|
sameRemoteHead,
|
|
53
53
|
snapshotForUpload
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-NOAQCRP6.ts";
|
|
55
55
|
import {
|
|
56
56
|
acceptedSelection,
|
|
57
57
|
canPullRemoteSessionsOnFirstSync,
|
|
@@ -65,32 +65,32 @@ import {
|
|
|
65
65
|
snapshotHashesMatchState,
|
|
66
66
|
snapshotsMatch,
|
|
67
67
|
syncPolicyChanged
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-BC4P223U.ts";
|
|
69
69
|
import {
|
|
70
70
|
HISTORY_PREVIEW_LIMIT,
|
|
71
71
|
SyncBackendConflictError,
|
|
72
72
|
expectedRemoteHead
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-M6C5UVNO.ts";
|
|
74
74
|
import {
|
|
75
75
|
startupTransferEnabled
|
|
76
76
|
} from "./chunk-2YHXXWUF.ts";
|
|
77
77
|
import {
|
|
78
78
|
pruneMergeBaselines
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-TS2REUA6.ts";
|
|
80
80
|
import {
|
|
81
81
|
inspectLock,
|
|
82
82
|
isLockGuardHeld,
|
|
83
83
|
isStaleLock,
|
|
84
84
|
withLock
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-4FEFBPVA.ts";
|
|
86
86
|
import {
|
|
87
87
|
readStateForConfig,
|
|
88
88
|
syncStateFingerprint,
|
|
89
89
|
writeStateForConfig
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-PFVGR5PB.ts";
|
|
91
91
|
import {
|
|
92
92
|
captureMutationOwner
|
|
93
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-ABU7CXAG.ts";
|
|
94
94
|
import {
|
|
95
95
|
PublicationStatePersistenceError,
|
|
96
96
|
RollbackPublicationError,
|
|
@@ -101,10 +101,10 @@ import {
|
|
|
101
101
|
loadConfigForCheck,
|
|
102
102
|
syncCheckConfigFingerprint,
|
|
103
103
|
syncSessionsWarnings
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-KZKBQ474.ts";
|
|
105
105
|
import {
|
|
106
106
|
pendingTransactionEntries
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-CXNCR2AE.ts";
|
|
108
108
|
import {
|
|
109
109
|
throwIfAborted
|
|
110
110
|
} from "./chunk-SPRHJBJC.ts";
|
|
@@ -113,7 +113,7 @@ import {
|
|
|
113
113
|
portableSnapshot,
|
|
114
114
|
sameLocalFields,
|
|
115
115
|
validatePortableSnapshot
|
|
116
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-YHOVBAQI.ts";
|
|
117
117
|
import {
|
|
118
118
|
agentDirectoryInventory,
|
|
119
119
|
createSnapshot,
|
|
@@ -122,22 +122,22 @@ import {
|
|
|
122
122
|
scanSnapshot,
|
|
123
123
|
snapshotIncludesSessions,
|
|
124
124
|
snapshotWithoutSessions
|
|
125
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-HUUQUCSX.ts";
|
|
126
126
|
import {
|
|
127
127
|
agentDir,
|
|
128
128
|
effectiveSessionRoot,
|
|
129
129
|
requireStableMergeSessionRoot,
|
|
130
130
|
resolvedSnapshotOptionsForContext,
|
|
131
131
|
sessionDirForApply
|
|
132
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-7FMAJ56J.ts";
|
|
133
133
|
import {
|
|
134
134
|
requireLegacyTransferPolicy,
|
|
135
135
|
syncSelectionHasContent,
|
|
136
136
|
syncSessionsSelected
|
|
137
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-ZNAA4FNG.ts";
|
|
138
138
|
import {
|
|
139
139
|
engineHost
|
|
140
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-DN5GOY65.ts";
|
|
141
141
|
|
|
142
142
|
// src/engine/sync/apply-review.ts
|
|
143
143
|
import { createHash } from "node:crypto";
|
|
@@ -1044,6 +1044,8 @@ async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
1044
1044
|
if (!sameRemoteHead(backend, head, await backend.readHead(options.signal)))
|
|
1045
1045
|
throw new Error("Remote changed during pull review.");
|
|
1046
1046
|
validateMutation();
|
|
1047
|
+
await engineHost().requireExclusiveLocalWriter?.();
|
|
1048
|
+
validateMutation();
|
|
1047
1049
|
const restorePoint = action ? await backupDirectionalSnapshot(local, options.signal) : void 0;
|
|
1048
1050
|
const backup = restorePoint?.backupPath ?? await backupLocal(config.snapshotIdentity, snapshotOptions, options.signal);
|
|
1049
1051
|
let mayHaveApplied = false;
|
|
@@ -1082,10 +1084,7 @@ async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
1082
1084
|
head,
|
|
1083
1085
|
protectedPaths: reviewedProtectedPaths,
|
|
1084
1086
|
signal: options.signal,
|
|
1085
|
-
onCommit:
|
|
1086
|
-
options.onCommit?.();
|
|
1087
|
-
mayHaveApplied = true;
|
|
1088
|
-
} : options.onCommit,
|
|
1087
|
+
onCommit: options.onCommit,
|
|
1089
1088
|
validateMutation,
|
|
1090
1089
|
validateSettings: action ? async () => {
|
|
1091
1090
|
await restorePoint?.validate();
|
|
@@ -1095,14 +1094,14 @@ async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
1095
1094
|
effectiveRoot: Boolean(action)
|
|
1096
1095
|
});
|
|
1097
1096
|
applyGuards.validateMutation();
|
|
1098
|
-
if (!action)
|
|
1099
|
-
options.onCommit?.();
|
|
1100
|
-
mayHaveApplied = true;
|
|
1101
|
-
}
|
|
1097
|
+
if (!action) options.onCommit?.();
|
|
1102
1098
|
const lastFileHashes = await applySnapshot(physical, protectedPaths, {
|
|
1103
1099
|
...snapshotOptions,
|
|
1104
1100
|
sessionDir: applySessionDir,
|
|
1105
1101
|
...applyGuards,
|
|
1102
|
+
onApplyStart: () => {
|
|
1103
|
+
mayHaveApplied = true;
|
|
1104
|
+
},
|
|
1106
1105
|
...action || config.scope === "agent-directory" || sizeLimited ? { reviewedLocal: local } : {},
|
|
1107
1106
|
expectedFileHashes: config.localFields?.length ? { "settings.json": fileHashMap(local)["settings.json"] ?? null } : void 0
|
|
1108
1107
|
});
|
|
@@ -1128,7 +1127,7 @@ async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
1128
1127
|
} catch (error) {
|
|
1129
1128
|
if (options.signal?.aborted && !mayHaveApplied) throw error;
|
|
1130
1129
|
const outcome = installed ? "applied" : mayHaveApplied ? "unknown" : "not-applied";
|
|
1131
|
-
const restore = error instanceof LocalBackupVerificationError ? "" : localRestoreGuidance(backup);
|
|
1130
|
+
const restore = outcome === "not-applied" || error instanceof LocalBackupVerificationError ? "" : localRestoreGuidance(backup);
|
|
1132
1131
|
const failure = new PullOutcomeError(outcome, [restore, errorMessage(error)].filter(Boolean).join(" "), error);
|
|
1133
1132
|
if (error instanceof AggregateError) throw new AggregateError(error.errors, failure.message, { cause: failure });
|
|
1134
1133
|
throw failure;
|
|
@@ -1328,7 +1327,7 @@ async function status(ctx, options, factory = createSyncBackend) {
|
|
|
1328
1327
|
factory
|
|
1329
1328
|
);
|
|
1330
1329
|
throwIfAborted(options.signal);
|
|
1331
|
-
const continuous = config.continuous ? await (await import("./continuous-record-
|
|
1330
|
+
const continuous = config.continuous ? await (await import("./continuous-record-AP6LVXUJ.ts")).continuousStatusLines(config) : [];
|
|
1332
1331
|
throwIfAborted(options.signal);
|
|
1333
1332
|
const warnings = syncSessionsWarnings(config);
|
|
1334
1333
|
const files = fileCount(localFiles);
|
|
@@ -1619,4 +1618,4 @@ export {
|
|
|
1619
1618
|
doctor,
|
|
1620
1619
|
history
|
|
1621
1620
|
};
|
|
1622
|
-
//# sourceMappingURL=chunk-
|
|
1621
|
+
//# sourceMappingURL=chunk-36CY6QDF.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/engine/sync/apply-review.ts", "../../src/engine/sync/field-migration.ts", "../../src/engine/sync/transfer-freshness.ts", "../../src/engine/sync/sync-rollback.ts", "../../src/engine/ui/sync-status.ts", "../../src/engine/ui/transfer-review.ts", "../../src/engine/sync/directional-action.ts", "../../src/engine/sync/pull-outcome.ts", "../../src/engine/sync/push-review.ts", "../../src/engine/sync/sync-mutations.ts", "../../src/engine/sync/sync-queries.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { agentDir } from \"../snapshot/session-paths.js\";\nimport { addTopLevelCaseVariantDeletes } from \"../snapshot/snapshot-apply.js\";\nimport type { Snapshot, SnapshotOptions } from \"../snapshot/snapshot-types.js\";\nimport { throwIfAborted } from \"./signals.js\";\n\nexport interface CaseCleanupReview {\n path: string;\n fingerprint: string;\n}\n\nexport async function inspectCaseCleanup(snapshot: Snapshot, options: SnapshotOptions): Promise<CaseCleanupReview[]> {\n const { signal } = options;\n throwIfAborted(signal);\n const root = agentDir();\n const plan = await addTopLevelCaseVariantDeletes(root, { writes: [], deletes: [] }, snapshot, options);\n throwIfAborted(signal);\n const review: CaseCleanupReview[] = [];\n for (const target of plan.deletes.sort()) {\n const stat = await fs.lstat(target);\n throwIfAborted(signal);\n const hash = createHash(\"sha256\");\n if (stat.isSymbolicLink()) hash.update(await fs.readlink(target));\n else {\n if (!stat.isFile()) throw new Error(\"Case-variant path is no longer a regular file or symlink.\");\n const handle = await fs.open(\n target,\n constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0),\n );\n try {\n throwIfAborted(signal);\n const opened = await handle.stat();\n if (!opened.isFile() || opened.dev !== stat.dev || opened.ino !== stat.ino)\n throw new Error(\"Case-variant file changed while preparing review.\");\n for await (const bytes of handle.createReadStream({ autoClose: false, signal })) {\n throwIfAborted(signal);\n hash.update(bytes);\n }\n } finally {\n await handle.close();\n }\n }\n throwIfAborted(signal);\n review.push({\n path: path.basename(target),\n fingerprint: `${stat.dev}:${stat.ino}:${stat.mode}:${hash.digest(\"hex\")}`,\n });\n }\n return review;\n}\n\nexport async function revalidateCaseCleanup(\n expected: readonly CaseCleanupReview[],\n snapshot: Snapshot,\n options: SnapshotOptions,\n) {\n const current = await inspectCaseCleanup(snapshot, options);\n if (JSON.stringify(current) !== JSON.stringify(expected))\n throw new Error(\"Case-variant paths changed during transfer review; reopen the preview.\");\n}\n", "import type { EngineContext as ExtensionContext } from \"../host.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport type { SyncState } from \"../state/state-types.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { sameLocalFields } from \"./local-fields.js\";\nimport { captureMutationOwner } from \"./sync-local.js\";\n\nexport async function confirmFieldMigration(\n ctx: ExtensionContext,\n config: AnySyncConfig,\n state: SyncState,\n remote: Snapshot | undefined,\n force: boolean,\n signal?: AbortSignal,\n) {\n if (remote?.localFields !== undefined && config.localFields === undefined)\n throw new Error(\n \"Portable snapshots require settings version 4 and explicit localFields rules on this machine; older policy must not replace local-only values.\",\n );\n const changed =\n (Boolean(state.lastAppliedSnapshot) && !sameLocalFields(state.localFields, config.localFields)) ||\n (remote !== undefined && !sameLocalFields(remote.localFields, config.localFields));\n if (!changed) return true;\n if (!force)\n throw new Error(\n \"Local-field policy changed; review an explicit push --force or pull --force migration. Old remote history is not erased.\",\n );\n const validate = captureMutationOwner(ctx, signal);\n if (!ctx.hasUI) throw new Error(\"Local-field migration requires observable TUI/RPC confirmation.\");\n validate();\n const confirmed = await ctx.ui.confirm(\n \"Migrate portable settings policy?\",\n `New machine-local fields: ${(config.localFields ?? []).map(safeTerminalText).join(\", \") || \"none\"}. Additions remove fields from future snapshots, not old history. Removals make local-only values portable again and a pull may replace them. The selected direction is authoritative; inspect /sync diff first. This confirmation is required even with --yes.`,\n { signal },\n );\n validate();\n return confirmed;\n}\n", "import type { RemoteHead, SyncBackend } from \"../backends/sync-backend.js\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { EngineContext } from \"../host.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { effectiveSessionRoot, resolvedSnapshotOptionsForContext } from \"../snapshot/session-paths.js\";\nimport { createSnapshot } from \"../snapshot/snapshot.js\";\nimport type { Snapshot, SnapshotOptions } from \"../snapshot/snapshot-types.js\";\nimport type { SyncState } from \"../state/state-types.js\";\nimport { readStateForConfig, syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { ContinuousError } from \"./continuous-errors.js\";\nimport { preflightMergedTargets } from \"./merge-apply.js\";\nimport { sameRemoteHead } from \"./remote-snapshot.js\";\nimport { protectedSessionPaths } from \"./sync-local.js\";\nimport { fileHashMap, sameHashes } from \"./sync-state.js\";\n\nexport function requireResolvedDirectionalProgress(state: SyncState, options: CommandOptions, allowForce = true) {\n if (state.unresolved?.length && (options.auto || !options.force || !allowForce))\n throw new Error(\n \"Unresolved partial conflicts remain. Review /sync conflicts or explicitly choose push --force or pull --force; automatic transfer and rollback cannot accept unresolved groups.\",\n );\n}\n\nexport async function validateDirectionalPublication(\n ctx: EngineContext,\n config: AnySyncConfig,\n options: SnapshotOptions,\n state: SyncState,\n expectedHashes: Record<string, string>,\n validatePolicy: () => Promise<void>,\n direction: \"push\" | \"rollback\",\n effectiveRoot = false,\n) {\n const current = await createSnapshot(config.snapshotIdentity, options);\n if (!sameHashes(fileHashMap(current), expectedHashes))\n throw new Error(`Local bytes changed at the ${direction} publication boundary.`);\n if (syncStateFingerprint(await readStateForConfig(config)) !== syncStateFingerprint(state))\n throw new Error(`Baseline changed at the ${direction} publication boundary.`);\n if (\n (config.scope === \"agent-directory\" || direction === \"push\") &&\n options.sessionDir !==\n (effectiveRoot\n ? await effectiveSessionRoot(ctx, config, options.signal)\n : (await resolvedSnapshotOptionsForContext(ctx, config, options.signal)).sessionDir)\n )\n throw new Error(`Pi session storage changed at the ${direction} publication boundary.`);\n await validatePolicy();\n}\n\nexport function checkLiveProtection(ctx: EngineContext, sessionDir: string | undefined, reviewed: ReadonlySet<string>) {\n const current = protectedSessionPaths(ctx, sessionDir);\n if (current.size !== reviewed.size || [...current].some((item) => !reviewed.has(item)))\n throw new Error(\"Live session protection changed during review; reopen the review.\");\n}\n\nexport function directionalApplyGuards({\n ctx,\n config,\n backend,\n state,\n sessionDir,\n head,\n protectedPaths,\n signal,\n validateMutation,\n strictReview,\n validateSettings,\n onCommit,\n effectiveRoot = false,\n}: {\n ctx: EngineContext;\n config: AnySyncConfig;\n backend: SyncBackend;\n state: SyncState;\n sessionDir?: string;\n head?: RemoteHead;\n protectedPaths: ReadonlySet<string>;\n signal?: AbortSignal;\n validateMutation: () => void;\n strictReview?: boolean;\n validateSettings?: () => Promise<void>;\n onCommit?: () => void;\n effectiveRoot?: boolean;\n}) {\n if (!strictReview) return { validateMutation, validateApplyReview: validateSettings };\n const validateOwner = () => {\n validateMutation();\n checkLiveProtection(ctx, sessionDir, protectedPaths);\n };\n let committed = false;\n return {\n validateMutation: validateOwner,\n validateApplyReview: async () => {\n if (!sameRemoteHead(backend, head, await backend.readHead(signal)))\n throw new Error(\"Remote changed before local apply; reopen the review.\");\n if (syncStateFingerprint(await readStateForConfig(config)) !== syncStateFingerprint(state))\n throw new Error(\"Baseline changed before local apply; reopen the review.\");\n if (\n sessionDir !==\n (effectiveRoot\n ? await effectiveSessionRoot(ctx, config, signal)\n : (await resolvedSnapshotOptionsForContext(ctx, config, signal)).sessionDir)\n )\n throw new Error(\"Pi session storage changed before local apply; reopen the review.\");\n await validateSettings?.();\n validateOwner();\n if (!committed) {\n onCommit?.();\n committed = true;\n }\n },\n };\n}\n\nexport async function validateMergeApplyReview(\n backend: SyncBackend,\n config: AnySyncConfig,\n head: RemoteHead,\n stateIdentity: string,\n validateFresh: () => Promise<void>,\n signal?: AbortSignal,\n) {\n if (!sameRemoteHead(backend, head, await backend.readHead(signal)))\n throw new Error(\"Remote head changed before merged apply; journal and backup retained.\");\n if (syncStateFingerprint(await readStateForConfig(config)) !== stateIdentity)\n throw new Error(\"Sync baseline changed before merged apply; journal and backup retained.\");\n await validateFresh();\n}\n\nexport async function validateMergedPublication(\n ctx: EngineContext,\n config: AnySyncConfig,\n options: SnapshotOptions,\n before: Snapshot,\n after: Snapshot,\n stateIdentity: string,\n validateFresh: () => Promise<void>,\n) {\n await validateFresh();\n const current = await createSnapshot(config.snapshotIdentity, options);\n const state = await readStateForConfig(config);\n if (!sameHashes(fileHashMap(current), fileHashMap(before)) || syncStateFingerprint(state) !== stateIdentity)\n throw new ContinuousError(\n \"stale\",\n \"Local content or baseline changed at publication; journal and backup retained.\",\n );\n await preflightMergedTargets(current, after, options, [\n ...(ctx.protectedSessionFiles ?? []),\n ...[ctx.sessionManager.getSessionFile?.()].filter((file): file is string => Boolean(file)),\n ]);\n await validateFresh();\n}\n", "import { createSyncBackend, type SyncBackendFactory } from \"../backends/backend-factory.js\";\nimport { expectedRemoteHead, type PublishSnapshotResult } from \"../backends/sync-backend.js\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { EngineContext as ExtensionCommandContext } from \"../host.js\";\nimport { loadConfig, syncCheckConfigFingerprint } from \"../settings/config.js\";\nimport {\n effectiveSessionRoot,\n requireStableMergeSessionRoot,\n resolvedSnapshotOptionsForContext,\n sessionDirForApply,\n} from \"../snapshot/session-paths.js\";\nimport {\n createSnapshot,\n filterSnapshotForConfigPolicy,\n regenerateSnapshotIdentity,\n snapshotIncludesSessions,\n snapshotWithoutSessions,\n} from \"../snapshot/snapshot.js\";\nimport { applySnapshot } from \"../snapshot/snapshot-apply.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport { pruneMergeBaselines } from \"../state/merge-baseline-store.js\";\nimport { readStateForConfig, syncStateFingerprint, writeStateForConfig } from \"../state/sync-state-store.js\";\nimport { formatRollbackSummary } from \"../ui/sync-format.js\";\nimport { inspectCaseCleanup, revalidateCaseCleanup } from \"./apply-review.js\";\nimport { confirmFieldMigration } from \"./field-migration.js\";\nimport { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from \"./local-fields.js\";\nimport { requireNoMergeJournal, retireMergeJournal } from \"./merge-journal.js\";\nimport { readSnapshotForHead, sameRemoteHead, snapshotForUpload } from \"./remote-snapshot.js\";\nimport { throwIfAborted } from \"./signals.js\";\nimport { PublicationStatePersistenceError, RollbackPublicationError } from \"./sync-errors.js\";\nimport { backupLocal, captureMutationOwner, maybeReload, protectedSessionPaths } from \"./sync-local.js\";\nimport { requireLegacyTransferPolicy, syncSessionsSelected } from \"./sync-policy.js\";\nimport { acceptedSelection, fileHashMap, sameHashes } from \"./sync-state.js\";\nimport {\n checkLiveProtection,\n directionalApplyGuards,\n requireResolvedDirectionalProgress,\n} from \"./transfer-freshness.js\";\n\nimport {\n requireTransferSize,\n selectedPublicationImage,\n selectedPullImage,\n transferSizeLimitsEnabled,\n} from \"./transfer-size-limits.js\";\n\nconst VERSION = 1;\nconst POST_LOCAL_COMMIT_TIMEOUT_MS = 30_000;\n\nexport async function rollback(\n ctx: ExtensionCommandContext,\n options: CommandOptions,\n factory: SyncBackendFactory = createSyncBackend,\n expectedSelection?: { backendIdentity: string; setup?: string; snapshotId?: string },\n) {\n if (options.directionalAction) throw new Error(\"Single-action transfer cannot authorize rollback.\");\n const validateMutation = captureMutationOwner(ctx, options.signal);\n const validateCommittedOwner = captureMutationOwner(ctx);\n const target = options.args[0];\n if (!target) throw new Error(\"Usage: /sync rollback <snapshot-id> [--yes]\");\n\n const config = await loadConfig(options.setup);\n validateMutation();\n\n const backend = await factory(config);\n if (\n expectedSelection &&\n (backend.identity !== expectedSelection.backendIdentity || config.setupName !== expectedSelection.setup)\n ) {\n throw new Error(\"Sync setup or storage location changed while history was open; reopen history and retry.\");\n }\n await requireNoMergeJournal(config);\n const state = await readStateForConfig(config);\n validateMutation();\n requireResolvedDirectionalProgress(state, options, false);\n const decoded = await backend.readSnapshot(target, options.signal);\n validateMutation();\n validatePortableSnapshot(decoded);\n requireLegacyTransferPolicy(decoded);\n\n if (!sameLocalFields(decoded.localFields, config.localFields))\n throw new Error(\n \"Rollback requires the historical snapshot local-field policy to match the configured rules. Review push --force from current local bytes to migrate policy first; choose matching history afterward.\",\n );\n const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);\n validateMutation();\n const selected = filterSnapshotForConfigPolicy(\n syncSessionsSelected(config) ? decoded : snapshotWithoutSessions(decoded),\n config,\n snapshotOptions,\n );\n const remote = portableSnapshot(regenerateSnapshotIdentity(selected), config.localFields);\n const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n const expectedHead = await backend.readHead(options.signal);\n const currentRemote = expectedHead ? await readSnapshotForHead(backend, expectedHead, options.signal) : undefined;\n validateMutation();\n\n if (!(await confirmFieldMigration(ctx, config, state, currentRemote, true, options.signal))) return;\n validateMutation();\n const physical = overlayLocalFields(remote, local, config.localFields);\n if (config.scope === \"agent-directory\") requireStableMergeSessionRoot(local, physical, config.scope);\n const upload: Snapshot = await snapshotForUpload(\n backend,\n config,\n remote,\n expectedHead,\n currentRemote,\n snapshotOptions,\n );\n validateMutation();\n if (config.scope === \"agent-directory\") validatePortableSnapshot(upload);\n const caseCleanup = options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);\n validateMutation();\n const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);\n const sizeLimited = transferSizeLimitsEnabled(config);\n if (sizeLimited)\n requireTransferSize(\n config,\n selectedPullImage(remote, local, reviewedProtectedPaths),\n selectedPublicationImage(upload, config, snapshotOptions.sessionDir),\n );\n\n if (!options.yes) {\n const title = snapshotIncludesSessions(remote) ? \"Rollback pi settings and sessions?\" : \"Rollback pi settings?\";\n const summary = formatRollbackSummary(\n config,\n backend.destination,\n local,\n physical,\n target,\n reviewedProtectedPaths,\n caseCleanup.map((item) => item.path),\n );\n const confirmed = await ctx.ui.confirm(title, summary.content, { signal: options.signal });\n validateMutation();\n if (!confirmed) {\n ctx.ui.notify(\"Rollback cancelled.\", \"info\");\n return;\n }\n }\n\n validateMutation();\n const currentLocal = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n if (!sameHashes(fileHashMap(currentLocal), fileHashMap(local)))\n throw new Error(\"Local bytes changed during rollback review.\");\n if (syncCheckConfigFingerprint(config) !== syncCheckConfigFingerprint(await loadConfig(options.setup)))\n throw new Error(\"Settings changed during rollback review.\");\n if (!sameRemoteHead(backend, expectedHead, await backend.readHead(options.signal)))\n throw new Error(\"Remote changed during rollback review.\");\n validateMutation();\n throwIfAborted(options.signal);\n const backup = await backupLocal(config.snapshotIdentity, snapshotOptions, options.signal);\n const applySessionDir = await sessionDirForApply(ctx, config.scope ? physical : remote, snapshotOptions);\n const currentState = await readStateForConfig(config);\n if (!options.yes && syncStateFingerprint(currentState) !== syncStateFingerprint(state))\n throw new Error(\"Baseline changed during rollback review.\");\n requireResolvedDirectionalProgress(currentState, options, false);\n if (!options.yes) await revalidateCaseCleanup(caseCleanup, physical, snapshotOptions);\n if (config.scope && applySessionDir !== (await effectiveSessionRoot(ctx, config, options.signal)))\n throw new Error(\"Pi session storage changed during rollback review.\");\n validateMutation();\n if (syncCheckConfigFingerprint(config) !== syncCheckConfigFingerprint(await loadConfig(options.setup)))\n throw new Error(\"Settings changed during rollback review.\");\n validateMutation();\n\n const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);\n if (sizeLimited) checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);\n const applyGuards = directionalApplyGuards({\n ctx,\n config,\n backend,\n state,\n sessionDir: snapshotOptions.sessionDir,\n head: expectedHead,\n protectedPaths: reviewedProtectedPaths,\n signal: options.signal,\n onCommit: options.onCommit,\n validateMutation,\n\n validateSettings: async () => {\n if (\n syncCheckConfigFingerprint(config) !==\n syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal))\n )\n throw new Error(\"Settings changed before rollback apply.\");\n validateMutation();\n if (sizeLimited) checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);\n },\n });\n applyGuards.validateMutation();\n options.onCommit?.();\n const lastFileHashes = await applySnapshot(physical, protectedPaths, {\n ...snapshotOptions,\n sessionDir: applySessionDir,\n ...applyGuards,\n ...(config.scope === \"agent-directory\" || sizeLimited ? { reviewedLocal: local } : {}),\n expectedFileHashes: config.localFields?.length\n ? { \"settings.json\": fileHashMap(local)[\"settings.json\"] ?? null }\n : undefined,\n });\n validateCommittedOwner();\n let result: PublishSnapshotResult;\n try {\n const signal = AbortSignal.timeout(POST_LOCAL_COMMIT_TIMEOUT_MS);\n result = await backend.publishSnapshot(upload, expectedRemoteHead(expectedHead), {\n signal,\n });\n } catch (error) {\n throw new RollbackPublicationError(backup, error);\n }\n try {\n await writeStateForConfig(\n config,\n {\n version: VERSION,\n profile: config.snapshotIdentity,\n lastAppliedSnapshot: result.head.snapshotId,\n lastRemoteRevision: result.head.revision,\n lastFileHashes: config.localFields?.length\n ? { ...lastFileHashes, \"settings.json\": fileHashMap(remote)[\"settings.json\"] }\n : lastFileHashes,\n ...acceptedSelection(config),\n ...(config.localFields !== undefined ? { localFields: config.localFields } : {}),\n },\n remote,\n validateCommittedOwner,\n );\n } catch (error) {\n throw new PublicationStatePersistenceError(result.head, error, backup);\n }\n await retireMergeJournal(config);\n await pruneMergeBaselines(config, await readStateForConfig(config), validateCommittedOwner);\n validateCommittedOwner();\n if (options.signal?.aborted) return;\n ctx.ui.notify(\n [\n `Rolled back sync setup \u201C${config.setupName}\u201D to ${target}; latest: ${result.head.snapshotId}. Backup: ${backup}`,\n ...result.warnings,\n ]\n .filter(Boolean)\n .join(\"\\n\"),\n result.warnings.length > 0 ? \"warning\" : \"info\",\n );\n await maybeReload(ctx, options.signal, validateMutation);\n}\n", "import { type EngineContext, engineHost } from \"../host.js\";\nimport type { ContinuousErrorKind } from \"../sync/continuous-errors.js\";\n\nconst enabled = new WeakMap<EngineContext[\"sessionManager\"], boolean>();\nexport type SyncStatusPresentation = { activity: string; reason?: string };\nconst reasons: Record<ContinuousErrorKind, string> = {\n transient: \"temp\",\n contention: \"busy\",\n stale: \"stale\",\n authentication: \"auth\",\n storage: \"storage\",\n unsafe: \"review\",\n model: \"model\",\n budget: \"limit\",\n unknown: \"unknown\",\n};\nexport function syncStatusFailureReason(kind: ContinuousErrorKind | undefined) {\n return kind && Object.hasOwn(reasons, kind) ? reasons[kind] : \"unknown\";\n}\nexport function configureSyncStatus(ctx: EngineContext, value: boolean) {\n enabled.set(ctx.sessionManager, value);\n if (!value) setSyncStatus(ctx, undefined);\n}\nexport function setSyncStatus(ctx: EngineContext, value: string | undefined, presentation?: SyncStatusPresentation) {\n if (!ctx.hasUI || (value !== undefined && enabled.get(ctx.sessionManager) === false)) return;\n const host = engineHost();\n if (host.status) host.status(ctx, value, presentation);\n else ctx.ui.setStatus(\"sync\", value);\n}\n", "import type { EngineContext } from \"../host.js\";\nimport { confirmMergeReview } from \"./merge-review.js\";\nimport type { TransferReview } from \"./sync-format.js\";\n\nexport async function confirmTransferReview(\n ctx: EngineContext,\n title: string,\n review: TransferReview,\n signal: AbortSignal | undefined,\n validate: () => void,\n reviewInRpc = false,\n) {\n validate();\n const isCurrent = () => {\n try {\n validate();\n return true;\n } catch {\n return false;\n }\n };\n const confirmed =\n ctx.hasUI && (ctx.mode === \"tui\" || (reviewInRpc && ctx.mode === \"rpc\"))\n ? await confirmMergeReview(ctx, title, review.content, signal, isCurrent, \"apply reviewed transfer\", review.lines)\n : await ctx.ui.confirm(title, review.content, { signal });\n validate();\n return confirmed;\n}\n", "import { createHash } from \"node:crypto\";\nimport type { RemoteHead } from \"../backends/sync-backend.js\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { EngineContext } from \"../host.js\";\nimport { loadConfigForCheck, syncCheckConfigFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { effectiveSessionRoot } from \"../snapshot/session-paths.js\";\nimport {\n agentDirectoryInventory,\n filterSnapshotForConfigPolicy,\n snapshotWithoutSessions,\n} from \"../snapshot/snapshot.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport type { SyncState } from \"../state/state-types.js\";\nimport { syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { inspectCaseCleanup } from \"./apply-review.js\";\nimport { requireCompatibleRemoteSelection } from \"./remote-snapshot.js\";\nimport { syncSelectionHasContent, syncSessionsSelected } from \"./sync-policy.js\";\nimport { fileHashMap, syncPolicyChanged } from \"./sync-state.js\";\nimport { checkLiveProtection } from \"./transfer-freshness.js\";\n\nexport function foregroundDirectionalAction(ctx: EngineContext, options: CommandOptions) {\n const action = options.directionalAction;\n if (\n action &&\n (options.auto ||\n options.background ||\n options.force ||\n options.yes ||\n options.reload ||\n options.stale ||\n options.args.length > 0 ||\n options.agentRetryRefusal ||\n !ctx.hasUI ||\n (ctx.mode !== \"tui\" && ctx.mode !== \"rpc\"))\n )\n throw new Error(\"Single-action transfer requires a bound foreground Push or Pull.\");\n return action;\n}\n\nexport async function validateDirectionalSettings(\n options: CommandOptions,\n config: AnySyncConfig,\n validateMutation: () => void,\n) {\n const current = await loadConfigForCheck(undefined, options.signal);\n validateMutation();\n options.directionalAction?.validate(current);\n if (syncCheckConfigFingerprint(current) !== syncCheckConfigFingerprint(config))\n throw new Error(\"Settings changed before the directional transfer could write.\");\n}\n\nexport async function checkpointDirectionalAction(\n options: CommandOptions,\n evidence: {\n direction: \"push\" | \"pull\";\n config: AnySyncConfig;\n state: SyncState;\n head: RemoteHead | undefined;\n local: Snapshot;\n remote: Snapshot | undefined;\n sessionDir: string | undefined;\n protectedPaths: ReadonlySet<string>;\n },\n) {\n const { direction, config, state, head, local, remote, sessionDir, protectedPaths } = evidence;\n const hash = createHash(\"sha256\")\n .update(\n JSON.stringify([\n direction,\n syncCheckConfigFingerprint(config),\n syncStateFingerprint(state),\n head,\n Object.entries(fileHashMap(local)).sort(),\n [...(agentDirectoryInventory(local)?.entries ?? [])].filter(([, kind]) => kind === \"directory\").sort(),\n remote && Object.entries(fileHashMap(remote)).sort(),\n sessionDir,\n [...protectedPaths].sort(),\n ]),\n )\n .digest(\"hex\");\n await options.directionalAction?.checkpoint?.(hash);\n}\n\nexport function requireDirectionalSelection(\n config: AnySyncConfig,\n state: SyncState,\n _local: Snapshot,\n remote: Snapshot | undefined,\n _sessionDir: string | undefined,\n) {\n if (!syncSelectionHasContent(config)) throw new Error(\"This setup has no managed content for the transfer.\");\n if (remote) requireCompatibleRemoteSelection(config, remote);\n if (state.lastAppliedSnapshot && syncPolicyChanged(state, config))\n throw new Error(\n \"Managed content policy changed and this transfer cannot prove that it only narrows the accepted selection. Review the new policy before transferring.\",\n );\n}\n\nexport function keepProtectedRemoteSessions(\n config: AnySyncConfig,\n upload: Snapshot,\n remote: Snapshot | undefined,\n sessionDir: string | undefined,\n protectedPaths: ReadonlySet<string>,\n) {\n if (!protectedPaths.size) return upload;\n const retained = (remote?.files ?? []).filter((file) => protectedPaths.has(file.path));\n const selectedRemote = remote && filterSnapshotForConfigPolicy(remote, config, { sessionDir });\n const uploaded = new Set(upload.files.map((file) => file.path));\n const selected = new Set(selectedRemote?.files.map((file) => file.path));\n if (retained.some((file) => !selected.has(file.path) && !uploaded.has(file.path)))\n throw new Error(\"Push would remove a protected live session from remote storage.\");\n const files = [...upload.files.filter((file) => !protectedPaths.has(file.path)), ...retained];\n return {\n ...upload,\n files: files.sort((a, b) => a.path.localeCompare(b.path)),\n };\n}\n\nexport async function requireDirectionalPullBoundary(\n ctx: EngineContext,\n options: CommandOptions,\n config: AnySyncConfig,\n physical: Snapshot,\n snapshotOptions: Parameters<typeof inspectCaseCleanup>[1],\n protectedPaths: ReadonlySet<string>,\n validateMutation: () => void,\n) {\n await validateDirectionalSettings(options, config, validateMutation);\n if ((await effectiveSessionRoot(ctx, config, options.signal)) !== snapshotOptions.sessionDir)\n throw new Error(\"Pi session storage changed before Pull could write.\");\n if ((await inspectCaseCleanup(physical, snapshotOptions)).length)\n throw new Error(\n \"Pull would remove case-variant paths not represented in its local backup. Review a separate Pull instead.\",\n );\n validateMutation();\n checkLiveProtection(ctx, snapshotOptions.sessionDir, protectedPaths);\n}\n\nexport function notifyDirectionalSuccess(\n ctx: EngineContext,\n options: CommandOptions,\n message: string,\n warning = false,\n) {\n if (options.directionalAction?.notifySuccess) options.directionalAction.notifySuccess(message);\n else if (!options.silent) ctx.ui.notify(message, warning ? \"warning\" : \"info\");\n}\n\nexport function remoteRestoreGuidance(\n head: RemoteHead,\n previous: Snapshot,\n config: AnySyncConfig,\n sessionDir: string | undefined,\n) {\n const ref = head.snapshotRef === head.snapshotId ? \"\" : ` (reference ${safeTerminalText(head.snapshotRef)})`;\n const version = `${safeTerminalText(head.snapshotId)}${ref}`;\n const eligible = syncSessionsSelected(config) ? previous : snapshotWithoutSessions(previous);\n const selected = filterSnapshotForConfigPolicy(eligible, config, { sessionDir });\n return selected.files.length === previous.files.length\n ? `Restore the previous remote version ${version} from /sync \u2192 History.`\n : `History retains remote version ${version}. Rollback uses the current rules and does not restore excluded files. See \u201CRecover excluded files from History\u201D in the Pi Sync README.`;\n}\n\nexport function localRestoreGuidance(backup: string) {\n return `Local backup: ${safeTerminalText(backup)}. To restore locally, close Pi and follow the local backup restore steps in the Pi Sync README.`;\n}\n", "export type PullOutcome = \"not-applied\" | \"applied\" | \"unknown\";\n\nexport class PullOutcomeError extends Error {\n constructor(\n readonly outcome: PullOutcome,\n detail: string,\n cause: unknown,\n ) {\n const summary: Record<PullOutcome, string> = {\n \"not-applied\": \"Pull stopped before applying local files.\",\n applied: \"Local snapshot was applied, but final bookkeeping failed.\",\n unknown: \"Local apply did not finish; its outcome is not verified. Keep the journal and backups.\",\n };\n super(`${summary[outcome]} ${detail}`.trimEnd(), { cause });\n }\n}\n", "import type { RemoteHead, SyncBackend } from \"../backends/sync-backend.js\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { EngineContext } from \"../host.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { snapshotIncludesSessions } from \"../snapshot/snapshot.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport { countPreservedRemoteFiles, formatPushSummary, formatTransferReview } from \"../ui/sync-format.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { confirmTransferReview } from \"../ui/transfer-review.js\";\nimport { throwIfAborted } from \"./signals.js\";\n\nexport async function confirmPush(\n ctx: EngineContext,\n options: CommandOptions,\n config: AnySyncConfig,\n backend: SyncBackend,\n local: Snapshot,\n upload: Snapshot,\n head: RemoteHead | undefined,\n remote: Snapshot | undefined,\n validateMutation: () => void,\n title = snapshotIncludesSessions(upload) ? \"Push pi settings and sessions?\" : \"Push pi settings?\",\n) {\n validateMutation();\n if (options.yes) return true;\n const summary = formatPushSummary(\n config,\n backend.destination,\n upload,\n head,\n countPreservedRemoteFiles(local, upload),\n remote,\n );\n const confirmed = await confirmTransferReview(\n ctx,\n title,\n formatTransferReview(summary),\n options.signal,\n validateMutation,\n options.directionalAction?.intent === \"review-force\",\n );\n throwIfAborted(options.signal);\n if (confirmed) return true;\n setSyncStatus(ctx, undefined);\n ctx.ui.notify(\"Push cancelled.\", \"info\");\n return false;\n}\n", "import { createSyncBackend, type SyncBackendFactory } from \"../backends/backend-factory.js\";\nimport {\n expectedRemoteHead,\n type PublishSnapshotResult,\n type RemoteHead,\n type SyncBackend,\n SyncBackendConflictError,\n} from \"../backends/sync-backend.js\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport {\n type EngineContext as ExtensionCommandContext,\n type EngineContext as ExtensionContext,\n engineHost,\n} from \"../host.js\";\nimport { loadConfig, loadConfigForCheck, syncCheckConfigFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport {\n effectiveSessionRoot,\n requireStableMergeSessionRoot,\n resolvedSnapshotOptionsForContext,\n sessionDirForApply,\n} from \"../snapshot/session-paths.js\";\nimport {\n createSnapshot,\n filterSnapshotForConfigPolicy,\n scanSnapshot,\n snapshotIncludesSessions,\n} from \"../snapshot/snapshot.js\";\nimport { applySnapshot } from \"../snapshot/snapshot-apply.js\";\nimport { pendingTransactionEntries } from \"../snapshot/snapshot-transaction-directory.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport { pruneMergeBaselines } from \"../state/merge-baseline-store.js\";\nimport type { SyncState } from \"../state/state-types.js\";\nimport { readStateForConfig, syncStateFingerprint, writeStateForConfig } from \"../state/sync-state-store.js\";\nimport { formatPullSummary } from \"../ui/sync-format.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { confirmTransferReview } from \"../ui/transfer-review.js\";\nimport { startupTransferEnabled } from \"./agent-policy.js\";\nimport { inspectCaseCleanup, revalidateCaseCleanup } from \"./apply-review.js\";\nimport {\n checkpointDirectionalAction,\n foregroundDirectionalAction,\n keepProtectedRemoteSessions,\n localRestoreGuidance,\n notifyDirectionalSuccess,\n remoteRestoreGuidance,\n requireDirectionalPullBoundary,\n requireDirectionalSelection,\n validateDirectionalSettings,\n} from \"./directional-action.js\";\nimport {\n DirectionalDestinationConflict,\n needsDirectionalForce,\n recheckDirectionalReview,\n} from \"./directional-conflict.js\";\nimport { confirmFieldMigration } from \"./field-migration.js\";\nimport { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from \"./local-fields.js\";\nimport { readMergeJournal, requireNoMergeJournal, retireMergeJournal } from \"./merge-journal.js\";\nimport { mergeSync } from \"./merged-sync.js\";\nimport { PullOutcomeError } from \"./pull-outcome.js\";\nimport { confirmPush } from \"./push-review.js\";\nimport {\n readRemoteSnapshot,\n readRemoteSnapshotForUpload,\n readSnapshotForHead,\n requireCompatibleRemoteSelection,\n sameRemoteHead,\n snapshotForUpload,\n} from \"./remote-snapshot.js\";\nimport { throwIfAborted } from \"./signals.js\";\nimport { createSyncDecision } from \"./sync-decision.js\";\nimport { errorMessage, PublicationStatePersistenceError } from \"./sync-errors.js\";\n\nimport {\n backupDirectionalSnapshot,\n backupLocal,\n captureMutationOwner,\n LocalBackupVerificationError,\n maybeReload,\n protectedSessionPaths,\n} from \"./sync-local.js\";\nimport { syncSelectionHasContent, syncSessionsSelected } from \"./sync-policy.js\";\nimport {\n acceptedSelection,\n canPullRemoteSessionsOnFirstSync,\n canPullRemoteSettingsOnFirstSync,\n fileHashMap,\n hasLocalChanges,\n hasRemoteChanges,\n remoteChangedSinceState,\n sameHashes,\n shouldRefreshSyncedState,\n snapshotHashesMatchState,\n snapshotsMatch,\n syncPolicyChanged,\n} from \"./sync-state.js\";\nimport {\n checkLiveProtection,\n directionalApplyGuards,\n requireResolvedDirectionalProgress,\n validateDirectionalPublication,\n} from \"./transfer-freshness.js\";\n\nimport {\n requireTransferSize,\n selectedPublicationImage,\n selectedPullImage,\n transferSizeLimitsEnabled,\n} from \"./transfer-size-limits.js\";\n\nconst VERSION = 1;\n\nexport { PublicationStatePersistenceError, RollbackPublicationError } from \"./sync-errors.js\";\nexport { rollback } from \"./sync-rollback.js\";\n\ninterface PushInput {\n config: AnySyncConfig;\n state: SyncState;\n local: Snapshot;\n backend?: SyncBackend;\n}\n\nexport async function push(\n ctx: ExtensionCommandContext | ExtensionContext,\n options: CommandOptions,\n input?: PushInput,\n factory: SyncBackendFactory = createSyncBackend,\n) {\n const validateOwner = captureMutationOwner(ctx, options.signal);\n const validateCommittedOwner = captureMutationOwner(ctx);\n const action = foregroundDirectionalAction(ctx, options);\n if (action && input) throw new Error(\"Single-action Push must load the bound foreground setup.\");\n const config = action\n ? await loadConfigForCheck(undefined, options.signal)\n : (input?.config ?? (await loadConfig(options.setup, options.signal)));\n const validateMutation = () => {\n validateOwner();\n options.background?.validate(config);\n action?.validate(config);\n };\n validateMutation();\n await requireNoMergeJournal(config, options);\n const state = input?.state ?? (await readStateForConfig(config));\n validateMutation();\n requireResolvedDirectionalProgress(state, options);\n if (\n options.auto &&\n (config.scope === \"agent-directory\" || state.scope !== undefined) &&\n (options.force || !state.lastAppliedSnapshot || syncPolicyChanged(state, config))\n ) {\n throw new Error(\"Automatic push requires an accepted baseline with matching content policy.\");\n }\n setSyncStatus(ctx, `pushing ${config.setupName}`, { activity: \"pushing\" });\n const backend = input?.backend ?? (await factory(config));\n validateMutation();\n const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);\n if (action) snapshotOptions.sessionDir = await effectiveSessionRoot(ctx, config, options.signal);\n validateMutation();\n const localRaw = input?.local ?? (await createSnapshot(config.snapshotIdentity, snapshotOptions));\n const local = portableSnapshot(localRaw, config.localFields);\n const reviewedProtectedPaths = action ? protectedSessionPaths(ctx, snapshotOptions.sessionDir) : new Set<string>();\n\n throwIfAborted(options.signal);\n\n let head = await backend.readHead(options.signal);\n let remoteForUpload =\n action && head\n ? await readSnapshotForHead(backend, head, options.signal)\n : await readRemoteSnapshotForUpload(backend, config, head, state, options);\n validateMutation();\n if (action) requireDirectionalSelection(config, state, localRaw, remoteForUpload, snapshotOptions.sessionDir);\n if (!action && remoteForUpload && !options.force) {\n requireCompatibleRemoteSelection(config, remoteForUpload);\n }\n if (\n !action &&\n remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)) &&\n !options.force\n ) {\n const remoteForConflict = remoteForUpload\n ? filterSnapshotForConfigPolicy(remoteForUpload, config, snapshotOptions)\n : undefined;\n if (!remoteForConflict || !snapshotHashesMatchState(remoteForConflict, state, config)) {\n throw createSyncDecision({\n kind: head ? \"remote-or-policy-changed\" : \"remote-empty\",\n config,\n state,\n local,\n remote: remoteForConflict,\n localChanged: hasLocalChanges(local, state, config),\n remoteChanged: true,\n directMessage: \"Remote or sync policy changed since last sync. Run /sync pull first or /sync push --force.\",\n });\n }\n }\n\n if (!remoteForUpload && head && (config.localFields !== undefined || !options.yes))\n remoteForUpload = await readSnapshotForHead(backend, head, options.signal);\n validateMutation();\n if (!(await confirmFieldMigration(ctx, config, state, remoteForUpload, options.force, options.signal))) {\n setSyncStatus(ctx, undefined);\n return \"cancelled\" as const;\n }\n const configIdentity = syncCheckConfigFingerprint(config);\n const validateSettings = async () => {\n if (action) await validateDirectionalSettings(options, config, validateMutation);\n else if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))\n throw new Error(\"Settings changed during push review.\");\n validateMutation();\n };\n const checkUpload = (upload: Snapshot) => {\n if (transferSizeLimitsEnabled(config))\n requireTransferSize(config, selectedPublicationImage(upload, config, snapshotOptions.sessionDir));\n };\n let upload = await snapshotForUpload(backend, config, local, head, remoteForUpload, snapshotOptions);\n if (action) {\n upload = keepProtectedRemoteSessions(\n config,\n upload,\n remoteForUpload,\n snapshotOptions.sessionDir,\n reviewedProtectedPaths,\n );\n validatePortableSnapshot(upload);\n }\n validateMutation();\n checkUpload(upload);\n if (!config.skipSecretScan) {\n const secrets = scanSnapshot(local);\n if (secrets.length > 0) {\n throw new Error(`Refusing to push possible secrets:\\n${secrets.map((s) => `- ${s}`).join(\"\\n\")}`);\n }\n }\n\n if (action?.intent) {\n if (!head && state.lastAppliedSnapshot)\n throw new Error(\"The previously synced remote snapshot is missing. Review sync recovery before publishing.\");\n const selected = (snapshot: Snapshot) => filterSnapshotForConfigPolicy(snapshot, config, snapshotOptions);\n const conflict = needsDirectionalForce(\n action.intent,\n config,\n state,\n remoteForUpload && selected(remoteForUpload),\n selected(upload),\n reviewedProtectedPaths,\n );\n if (action.intent === \"reject-conflicts\" && conflict) {\n setSyncStatus(ctx, undefined);\n throw new DirectionalDestinationConflict();\n }\n if (action.intent === \"review-force\") {\n if (\n !(await confirmPush(\n ctx,\n options,\n config,\n backend,\n local,\n upload,\n head,\n remoteForUpload,\n validateMutation,\n \"Force push?\",\n ))\n )\n return \"cancelled\" as const;\n await validateSettings();\n await recheckDirectionalReview(backend, head, localRaw, snapshotOptions, validateMutation);\n }\n } else if (\n !action &&\n !(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, validateMutation))\n ) {\n return \"cancelled\" as const;\n }\n if (action) {\n await checkpointDirectionalAction(options, {\n direction: \"push\",\n config,\n state,\n local: localRaw,\n remote: remoteForUpload,\n head,\n sessionDir: snapshotOptions.sessionDir,\n protectedPaths: reviewedProtectedPaths,\n });\n validateMutation();\n }\n\n if (options.force) {\n const refreshedHead = await backend.readHead(options.signal);\n validateMutation();\n if (!sameRemoteHead(backend, head, refreshedHead)) {\n head = refreshedHead;\n remoteForUpload = head ? await readSnapshotForHead(backend, head, options.signal) : undefined;\n validateMutation();\n if (!(await confirmFieldMigration(ctx, config, state, remoteForUpload, options.force, options.signal))) {\n setSyncStatus(ctx, undefined);\n return \"cancelled\" as const;\n }\n validateMutation();\n upload = await snapshotForUpload(backend, config, local, head, remoteForUpload, snapshotOptions);\n validateMutation();\n checkUpload(upload);\n if (\n !(await confirmPush(\n ctx,\n options,\n config,\n backend,\n local,\n upload,\n head,\n remoteForUpload,\n validateMutation,\n \"Remote changed during review. Push the refreshed plan?\",\n ))\n ) {\n return \"cancelled\" as const;\n }\n }\n }\n\n validateMutation();\n await validateSettings();\n if (\n !action &&\n (config.scope === \"agent-directory\" ||\n !options.yes ||\n config.localFields !== undefined ||\n (await readMergeJournal(config)))\n ) {\n const current = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n if (!sameHashes(fileHashMap(current), fileHashMap(localRaw)))\n throw new Error(\"Local content changed during push review; retry from current bytes.\");\n }\n const currentState = await readStateForConfig(config);\n if (!options.yes && syncStateFingerprint(currentState) !== syncStateFingerprint(state))\n throw new Error(\"Baseline changed during push review.\");\n requireResolvedDirectionalProgress(currentState, options);\n if (\n config.scope === \"agent-directory\" &&\n snapshotOptions.sessionDir !== (await effectiveSessionRoot(ctx, config, options.signal))\n )\n throw new Error(\"Pi session storage changed during push review.\");\n validateMutation();\n await validateSettings();\n const validatePublication =\n options.background || action\n ? async () => {\n if (action && !sameRemoteHead(backend, head, await backend.readHead(options.signal)))\n throw new Error(\"Remote changed before Push could publish.\");\n validateMutation();\n await validateDirectionalPublication(\n ctx,\n config,\n snapshotOptions,\n state,\n fileHashMap(localRaw),\n action\n ? async () => {\n await validateDirectionalSettings(options, config, validateMutation);\n checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);\n }\n : validateSettings,\n \"push\",\n Boolean(action),\n );\n }\n : validateSettings;\n\n if (action) await validatePublication?.();\n const accepted = action ? filterSnapshotForConfigPolicy(upload, config, snapshotOptions) : local;\n const restore =\n action && head && remoteForUpload\n ? remoteRestoreGuidance(head, remoteForUpload, config, snapshotOptions.sessionDir)\n : undefined;\n let result: PublishSnapshotResult;\n let startedPublication = false;\n try {\n result = await backend.publishSnapshot(upload, expectedRemoteHead(head), {\n ...(restore ? { preservePreviousHead: true } : {}),\n signal: options.signal,\n onCommit: action\n ? () => {\n options.onCommit?.();\n startedPublication = true;\n }\n : options.onCommit,\n validatePublication,\n });\n } catch (error) {\n if (!action || (!startedPublication && options.signal?.aborted)) throw error;\n const mightCommit =\n startedPublication && !(error instanceof SyncBackendConflictError && error.phase === \"before-commit\");\n const phase = mightCommit ? \"Push publication outcome is not verified.\" : \"Push did not replace the remote head.\";\n throw new Error([phase, errorMessage(error), startedPublication ? restore : undefined].filter(Boolean).join(\" \"), {\n cause: error,\n });\n }\n try {\n await writeStateForConfig(\n config,\n {\n version: VERSION,\n profile: config.snapshotIdentity,\n lastAppliedSnapshot: result.head.snapshotId,\n lastRemoteRevision: result.head.revision,\n lastFileHashes: fileHashMap(accepted),\n ...acceptedSelection(config),\n ...(config.localFields !== undefined ? { localFields: config.localFields } : {}),\n },\n accepted,\n validateCommittedOwner,\n );\n } catch (error) {\n const persistence = new PublicationStatePersistenceError(result.head, error);\n throw restore ? new Error(`${persistence.message} ${restore}`, { cause: persistence }) : persistence;\n }\n try {\n if (!action) await retireMergeJournal(config);\n await pruneMergeBaselines(config, await readStateForConfig(config), validateCommittedOwner);\n validateCommittedOwner();\n } catch (error) {\n if (!action) throw error;\n throw new Error(\n [\n `Remote publication ${result.head.snapshotId} is active, but final bookkeeping failed: ${errorMessage(error)}`,\n restore,\n ]\n .filter(Boolean)\n .join(\" \"),\n { cause: error },\n );\n }\n if (!options.signal?.aborted) setSyncStatus(ctx, undefined);\n if (options.signal?.aborted && !action) return;\n notifyDirectionalSuccess(\n ctx,\n options,\n [\n `Pushed ${upload.files.length} files from sync setup \u201C${config.setupName}\u201D as ${result.head.snapshotId}.`,\n restore,\n ...result.warnings,\n ]\n .filter(Boolean)\n .join(\"\\n\"),\n result.warnings.length > 0,\n );\n return \"applied\" as const;\n}\n\ninterface InitialPullEvidence {\n configIdentity: string;\n stateIdentity: string;\n sessionDir: string | undefined;\n localHashes: Record<string, string>;\n head: RemoteHead | undefined;\n}\n\nexport async function pull(\n ctx: ExtensionCommandContext | ExtensionContext,\n options: CommandOptions,\n factory: SyncBackendFactory = createSyncBackend,\n initial?: InitialPullEvidence,\n) {\n const action = foregroundDirectionalAction(ctx, options);\n if (action && initial) throw new Error(\"Single-action Pull cannot be used for initial-source selection.\");\n const validateOwner = captureMutationOwner(ctx, options.signal);\n const validateCommittedOwner = captureMutationOwner(ctx);\n const config = action ? await loadConfigForCheck(undefined, options.signal) : await loadConfig(options.setup);\n const validateMutation = () => {\n validateOwner();\n action?.validate(config);\n };\n validateMutation();\n const configIdentity = syncCheckConfigFingerprint(config);\n if (initial && initial.configIdentity !== configIdentity)\n throw new Error(\"Settings changed before initial pull; run sync again.\");\n await requireNoMergeJournal(config, options);\n if (action && (await pendingTransactionEntries()).length)\n throw new Error(\"A pending local transaction must be reconciled before Pull; its evidence was retained.\");\n validateMutation();\n setSyncStatus(ctx, `pulling ${config.setupName}`, { activity: \"pulling\" });\n const backend = await factory(config);\n const state = await readStateForConfig(config);\n validateMutation();\n if (initial && initial.stateIdentity !== syncStateFingerprint(state))\n throw new Error(\"Baseline changed before initial pull; run sync again.\");\n requireResolvedDirectionalProgress(state, options);\n const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);\n if (action) snapshotOptions.sessionDir = await effectiveSessionRoot(ctx, config, options.signal);\n validateMutation();\n if (initial && initial.sessionDir !== snapshotOptions.sessionDir)\n throw new Error(\"Pi session storage changed before initial pull; run sync again.\");\n const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n validateMutation();\n if (initial && !sameHashes(initial.localHashes, fileHashMap(local)))\n throw new Error(\"Local bytes changed before initial pull; run sync again.\");\n let preimageRemote: Snapshot | undefined;\n const { head, snapshot: remote } = await readRemoteSnapshot(backend, config, options.signal, {\n ...snapshotOptions,\n ...(action\n ? {\n validateSelection: (raw: Snapshot) => {\n requireDirectionalSelection(config, state, local, raw, snapshotOptions.sessionDir);\n preimageRemote = raw;\n },\n }\n : {}),\n });\n validateMutation();\n if (initial && !matchesInitialHead(initial, backend, head))\n throw new Error(\"Remote changed before initial pull; run sync again.\");\n const localChanged = hasLocalChanges(local, state, config);\n if (!remote) {\n throw createSyncDecision({\n kind: \"remote-empty\",\n config,\n state,\n local,\n localChanged,\n remoteChanged: false,\n directMessage: \"Remote is empty. Run /sync push from a configured machine first.\",\n });\n }\n\n if (!sameLocalFields(config.localFields, remote.localFields)) {\n setSyncStatus(ctx, undefined);\n throw new Error(\n \"Pull requires the configured local-field policy to match the remote. To change the remote policy, review push --force from the authoritative machine first, then pull using matching rules; old history is not erased.\",\n );\n }\n if (!(await confirmFieldMigration(ctx, config, state, remote, options.force, options.signal))) {\n setSyncStatus(ctx, undefined);\n return \"cancelled\" as const;\n }\n const logical = portableSnapshot(remote, config.localFields);\n const physical = overlayLocalFields(logical, local, config.localFields);\n if (action || config.scope === \"agent-directory\") requireStableMergeSessionRoot(local, physical, config.scope);\n const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);\n const sizeLimited = transferSizeLimitsEnabled(config);\n if (sizeLimited) requireTransferSize(config, selectedPullImage(logical, local, reviewedProtectedPaths));\n const remoteChanged = hasRemoteChanges(remote, state, config, reviewedProtectedPaths);\n if (!action && localChanged && remoteChanged && state.lastAppliedSnapshot && !options.force) {\n throw createSyncDecision({\n kind: \"both-changed\",\n config,\n state,\n local,\n remote,\n localChanged,\n remoteChanged,\n directMessage:\n \"Both local and remote changed since last sync. Run /sync diff, then choose /sync pull --force or /sync push --force.\",\n });\n }\n\n const validateActionBoundary = action\n ? () =>\n requireDirectionalPullBoundary(\n ctx,\n options,\n config,\n config.scope ? physical : { ...physical, files: [...local.files, ...physical.files] },\n snapshotOptions,\n reviewedProtectedPaths,\n validateMutation,\n )\n : undefined;\n if (action?.intent) {\n await validateActionBoundary?.();\n validateMutation();\n const conflict = needsDirectionalForce(\n action.intent,\n config,\n state,\n portableSnapshot(local, config.localFields),\n logical,\n reviewedProtectedPaths,\n );\n if (action.intent === \"reject-conflicts\" && conflict) {\n setSyncStatus(ctx, undefined);\n throw new DirectionalDestinationConflict();\n }\n }\n const caseCleanup = action || options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);\n validateMutation();\n if (\n ((!action && !options.yes) || action?.intent === \"review-force\") &&\n !(await confirmTransferReview(\n ctx,\n action?.intent === \"review-force\"\n ? \"Force pull?\"\n : snapshotIncludesSessions(remote)\n ? \"Pull pi settings and sessions?\"\n : \"Pull pi settings?\",\n formatPullSummary(\n config,\n backend.destination,\n local,\n physical,\n reviewedProtectedPaths,\n caseCleanup.map((item) => item.path),\n ),\n options.signal,\n validateMutation,\n action?.intent === \"review-force\",\n ))\n ) {\n setSyncStatus(ctx, undefined);\n ctx.ui.notify(\"Pull cancelled.\", \"info\");\n return \"cancelled\" as const;\n }\n\n if (action?.intent === \"review-force\") {\n await validateActionBoundary?.();\n await recheckDirectionalReview(backend, head, local, snapshotOptions, validateMutation);\n }\n if (action) {\n await checkpointDirectionalAction(options, {\n direction: \"pull\",\n config,\n state,\n local,\n remote: preimageRemote,\n head,\n sessionDir: snapshotOptions.sessionDir,\n protectedPaths: reviewedProtectedPaths,\n });\n validateMutation();\n await validateActionBoundary?.();\n }\n\n throwIfAborted(options.signal);\n const recoveringMerge = Boolean(await readMergeJournal(config));\n const requireFreshRecovery = async () => {\n validateMutation();\n const currentHead = await backend.readHead(options.signal);\n validateMutation();\n const current = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n validateMutation();\n if (!sameHashes(fileHashMap(current), fileHashMap(local)) || !sameRemoteHead(backend, head, currentHead)) {\n throw new Error(\"Local or remote content changed during recovery review; retry from a fresh diff.\");\n }\n };\n if (recoveringMerge) await requireFreshRecovery();\n if (!action && configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))\n throw new Error(\"Settings changed during pull review.\");\n validateMutation();\n const refreshed = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n if (!sameHashes(fileHashMap(local), fileHashMap(refreshed)))\n throw new Error(\"Local bytes changed during pull review.\");\n if (!sameRemoteHead(backend, head, await backend.readHead(options.signal)))\n throw new Error(\"Remote changed during pull review.\");\n validateMutation();\n await engineHost().requireExclusiveLocalWriter?.();\n validateMutation();\n const restorePoint = action ? await backupDirectionalSnapshot(local, options.signal) : undefined;\n const backup =\n restorePoint?.backupPath ?? (await backupLocal(config.snapshotIdentity, snapshotOptions, options.signal));\n let mayHaveApplied = false;\n let installed = false;\n try {\n const applySessionDir = action\n ? snapshotOptions.sessionDir\n : await sessionDirForApply(ctx, physical, snapshotOptions);\n if (recoveringMerge) await requireFreshRecovery();\n const currentState = await readStateForConfig(config);\n validateMutation();\n if ((initial || !options.yes) && syncStateFingerprint(currentState) !== syncStateFingerprint(state))\n throw new Error(\"Baseline changed during pull review.\");\n requireResolvedDirectionalProgress(currentState, options);\n if (!action && !options.yes) await revalidateCaseCleanup(caseCleanup, physical, snapshotOptions);\n if (initial && !matchesInitialHead(initial, backend, await backend.readHead(options.signal)))\n throw new Error(\"Remote changed during initial pull; run sync again.\");\n validateMutation();\n if (config.scope && applySessionDir !== (await effectiveSessionRoot(ctx, config, options.signal)))\n throw new Error(\"Pi session storage changed during pull review.\");\n validateMutation();\n if (!action && configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))\n throw new Error(\"Settings changed during pull review.\");\n validateMutation();\n\n const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);\n const validateApplySettings = async () => {\n if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))\n throw new Error(\"Settings changed before pull apply.\");\n validateMutation();\n if (sizeLimited) checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);\n };\n const applyGuards = directionalApplyGuards({\n ctx,\n config,\n backend,\n state,\n sessionDir: snapshotOptions.sessionDir,\n head,\n protectedPaths: reviewedProtectedPaths,\n signal: options.signal,\n onCommit: options.onCommit,\n validateMutation,\n validateSettings: action\n ? async () => {\n await restorePoint?.validate();\n await validateActionBoundary?.();\n }\n : validateApplySettings,\n strictReview: Boolean(action),\n effectiveRoot: Boolean(action),\n });\n applyGuards.validateMutation();\n if (!action) options.onCommit?.();\n const lastFileHashes = await applySnapshot(physical, protectedPaths, {\n ...snapshotOptions,\n sessionDir: applySessionDir,\n ...applyGuards,\n onApplyStart: () => {\n mayHaveApplied = true;\n },\n ...(action || config.scope === \"agent-directory\" || sizeLimited ? { reviewedLocal: local } : {}),\n expectedFileHashes: config.localFields?.length\n ? { \"settings.json\": fileHashMap(local)[\"settings.json\"] ?? null }\n : undefined,\n });\n installed = true;\n validateCommittedOwner();\n await writeStateForConfig(\n config,\n {\n version: VERSION,\n profile: config.snapshotIdentity,\n lastAppliedSnapshot: remote.id,\n lastRemoteRevision: head?.revision,\n lastFileHashes: config.localFields?.length\n ? { ...lastFileHashes, \"settings.json\": fileHashMap(logical)[\"settings.json\"] }\n : lastFileHashes,\n ...acceptedSelection(config),\n ...(config.localFields !== undefined ? { localFields: config.localFields } : {}),\n },\n logical,\n validateCommittedOwner,\n );\n if (!action) await retireMergeJournal(config);\n await pruneMergeBaselines(config, await readStateForConfig(config), validateCommittedOwner);\n validateCommittedOwner();\n } catch (error) {\n if (options.signal?.aborted && !mayHaveApplied) throw error;\n const outcome = installed ? \"applied\" : mayHaveApplied ? \"unknown\" : \"not-applied\";\n const restore =\n outcome === \"not-applied\" || error instanceof LocalBackupVerificationError ? \"\" : localRestoreGuidance(backup);\n const failure = new PullOutcomeError(outcome, [restore, errorMessage(error)].filter(Boolean).join(\" \"), error);\n if (error instanceof AggregateError) throw new AggregateError(error.errors, failure.message, { cause: failure });\n throw failure;\n }\n if (options.signal?.aborted && !action) return \"applied\" as const;\n if (!options.signal?.aborted) setSyncStatus(ctx, undefined);\n if (action) {\n notifyDirectionalSuccess(ctx, options, `Pulled snapshot ${remote.id}. ${localRestoreGuidance(backup)}`);\n } else if (!options.silent) {\n ctx.ui.notify(`Pulled ${remote.files.length} files from ${remote.id}. Backup: ${backup}`, \"info\");\n } else if (options.auto && syncSessionsSelected(config) && snapshotIncludesSessions(remote)) {\n ctx.ui.notify(\n \"Pulled Pi sessions after startup selected the current session. Restart Pi or resume a pulled session to use newly synced conversations.\",\n \"warning\",\n );\n }\n if (options.reload) await maybeReload(ctx, options.signal, validateMutation);\n return \"applied\" as const;\n}\n\nexport async function syncBoth(\n ctx: ExtensionCommandContext | ExtensionContext,\n options: CommandOptions,\n factory: SyncBackendFactory = createSyncBackend,\n) {\n if (options.directionalAction) throw new Error(\"Single-action transfer cannot authorize bidirectional Sync.\");\n const validateMutation = captureMutationOwner(ctx, options.signal);\n const config = await loadConfig(options.setup);\n throwIfAborted(options.signal);\n options.background?.validate(config);\n if (options.agentRetryRefusal) {\n options.validateAgentRetryPolicy?.(config);\n if (!config.agentMode || options.auto || options.background || !ctx.hasUI)\n throw new Error(\"Enable Autonomous sync and use the foreground manager to retry a cached refusal.\");\n const state = await readStateForConfig(config);\n validateMutation();\n const pending = await readMergeJournal(config);\n validateMutation();\n if (!syncSelectionHasContent(config) || !state.lastAppliedSnapshot || pending)\n throw new Error(\"Retry requires an accepted baseline and no pending journal. Use Sync now or reviewed recovery.\");\n return mergeSync(ctx, options, factory);\n }\n if (syncSelectionHasContent(config) && options.auto && startupTransferEnabled(config))\n return mergeSync(ctx, options, factory);\n if (options.recoveryOnly) return mergeSync(ctx, options, factory);\n if (!options.auto && syncSelectionHasContent(config) && (await readMergeJournal(config)))\n return mergeSync(ctx, options, factory);\n const state = await readStateForConfig(config);\n throwIfAborted(options.signal);\n if (!options.auto && syncSelectionHasContent(config) && state.lastAppliedSnapshot)\n return mergeSync(ctx, options, factory);\n if (!syncSelectionHasContent(config)) {\n options.noteDebugOutcome?.(\"skipped\");\n if (!options.silent) {\n ctx.ui.notify(\n `Sync setup \u201C${config.setupName}\u201D includes no files. Choose included content in /sync Settings before syncing.`,\n \"warning\",\n );\n }\n return;\n }\n const backend = await factory(config);\n const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);\n validateMutation();\n const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n throwIfAborted(options.signal);\n const { head, snapshot: remote } = await readRemoteSnapshot(backend, config, options.signal, snapshotOptions);\n throwIfAborted(options.signal);\n const localChanged = hasLocalChanges(local, state, config);\n const remoteChanged = remote\n ? hasRemoteChanges(remote, state, config, protectedSessionPaths(ctx, snapshotOptions.sessionDir))\n : false;\n if (options.auto) throw new Error(\"Automatic transfer is not authorized by the current settings.\");\n\n const portableLocal = portableSnapshot(local, config.localFields);\n const configIdentity = syncCheckConfigFingerprint(config);\n const pullInitialSource = () => {\n validateMutation();\n return pull(ctx, options, factory, {\n configIdentity,\n stateIdentity: syncStateFingerprint(state),\n sessionDir: snapshotOptions.sessionDir,\n localHashes: fileHashMap(local),\n head,\n });\n };\n const acceptMatchingState = async (snapshot: Snapshot) => {\n requireCompatibleRemoteSelection(config, snapshot);\n if (config.scope === \"agent-directory\") {\n const current = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n const currentState = await readStateForConfig(config);\n const currentHead = await backend.readHead(options.signal);\n if (\n !sameHashes(fileHashMap(current), fileHashMap(local)) ||\n syncStateFingerprint(currentState) !== syncStateFingerprint(state) ||\n !sameRemoteHead(backend, head, currentHead)\n )\n throw new Error(\"Initial source changed before baseline acceptance; run sync again.\");\n if (\n snapshotOptions.sessionDir !== (await effectiveSessionRoot(ctx, config, options.signal)) ||\n configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup))\n )\n throw new Error(\"Settings or Pi session storage changed before baseline acceptance; run sync again.\");\n validateMutation();\n }\n const accepted = portableSnapshot(snapshot, config.localFields);\n await writeStateForConfig(\n config,\n {\n version: VERSION,\n profile: config.snapshotIdentity,\n lastAppliedSnapshot: snapshot.id,\n lastRemoteRevision: head?.revision,\n lastFileHashes: fileHashMap(accepted),\n ...acceptedSelection(config),\n ...(config.localFields !== undefined ? { localFields: config.localFields } : {}),\n },\n accepted,\n validateMutation,\n );\n await pruneMergeBaselines(config, await readStateForConfig(config), validateMutation);\n validateMutation();\n };\n if (remote && remote.files.length > 0 && local.files.length > 0) {\n requireCompatibleRemoteSelection(config, remote);\n const portableRemote = portableSnapshot(remote, config.localFields);\n if (!canPullRemoteSettingsOnFirstSync(portableLocal, portableRemote)) {\n throw createSyncDecision({\n kind: \"first-sync-settings-diverged\",\n config,\n state,\n local,\n remote,\n localChanged: true,\n remoteChanged: true,\n directMessage:\n \"Remote settings exist and this machine has different local Pi settings. Run /sync diff, then manually choose /sync pull or /sync push.\",\n });\n }\n if (!sameHashes(fileHashMap(portableLocal), fileHashMap(portableRemote))) {\n if (!canPullRemoteSessionsOnFirstSync(portableLocal, portableRemote)) {\n throw createSyncDecision({\n kind: \"first-sync-sessions-diverged\",\n config,\n state,\n local,\n remote,\n localChanged: true,\n remoteChanged: true,\n directMessage:\n \"Remote settings match, but local and remote Pi sessions differ. Run /sync diff, then manually choose /sync pull or /sync push.\",\n });\n }\n if ((await pullInitialSource()) === \"cancelled\") options.noteDebugOutcome?.(\"cancelled\");\n return;\n }\n await acceptMatchingState(remote);\n if (!options.silent) ctx.ui.notify(\"pi-sync state initialized; local settings already match remote.\", \"info\");\n return;\n }\n if (\n localChanged &&\n remoteChanged &&\n remote &&\n snapshotsMatch(portableLocal, portableSnapshot(remote, remote.localFields))\n ) {\n requireCompatibleRemoteSelection(config, remote);\n await acceptMatchingState(remote);\n if (!options.silent) ctx.ui.notify(\"pi-sync is already up to date.\", \"info\");\n return;\n }\n if (remoteChanged) {\n if ((await pullInitialSource()) === \"cancelled\") options.noteDebugOutcome?.(\"cancelled\");\n return;\n }\n if (localChanged || !remote) {\n if ((await push(ctx, options, { config, state, local, backend }, factory)) === \"cancelled\")\n options.noteDebugOutcome?.(\"cancelled\");\n return;\n }\n if (shouldRefreshSyncedState(remote, head, state, config, (left, right) => backend.sameRevision(left, right))) {\n await acceptMatchingState(remote);\n } else options.noteDebugOutcome?.(\"skipped\");\n if (!options.silent) ctx.ui.notify(\"pi-sync is already up to date.\", \"info\");\n}\n\nfunction matchesInitialHead(initial: InitialPullEvidence, backend: SyncBackend, current: RemoteHead | undefined) {\n return sameRemoteHead(backend, initial.head, current);\n}\n\nexport { backupLocal } from \"./sync-local.js\";\n", "import { createSyncBackend, type SyncBackendFactory } from \"../backends/backend-factory.js\";\nimport { HISTORY_PREVIEW_LIMIT, type SyncBackend } from \"../backends/sync-backend.js\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { EngineContext as ExtensionCommandContext } from \"../host.js\";\nimport {\n loadConfig,\n loadConfigForCheck,\n syncCheckConfigFingerprint,\n syncSessionsWarnings,\n} from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { resolvedSnapshotOptionsForContext } from \"../snapshot/session-paths.js\";\nimport { createSnapshot, scanSnapshot } from \"../snapshot/snapshot.js\";\nimport type { SnapshotCaptureLimits } from \"../snapshot/snapshot-capture-limit.js\";\nimport type { SnapshotOptions } from \"../snapshot/snapshot-types.js\";\nimport { inspectLock, isLockGuardHeld, isStaleLock, withLock } from \"../state/lock.js\";\nimport { readStateForConfig } from \"../state/sync-state-store.js\";\nimport { formatDiff, formatSnapshotOnlyDiff, publicationCapabilityDescription } from \"../ui/sync-format.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { portableSnapshot } from \"./local-fields.js\";\nimport { captureMutationOwner } from \"./mutation-owner.js\";\nimport { formatRemoteSelectionStatus, readRemoteSnapshot } from \"./remote-snapshot.js\";\nimport { throwIfAborted } from \"./signals.js\";\nimport { errorMessage } from \"./sync-errors.js\";\nimport { inspectSync } from \"./sync-inspection.js\";\nimport { rollback } from \"./sync-mutations.js\";\nimport { syncSessionsSelected } from \"./sync-policy.js\";\n\nfunction contentLines(config: AnySyncConfig) {\n return [\n config.scope === \"agent-directory\"\n ? \"included content: eligible files in the Pi agent directory\"\n : `included content: ${config.include.map(safeTerminalText).join(\", \") || \"none\"}`,\n ...(config.exclude === undefined\n ? []\n : [`excluded paths: ${config.exclude.map(safeTerminalText).join(\", \") || \"none\"}`]),\n ...(config.reinclude === undefined\n ? []\n : [`re-included paths: ${config.reinclude.map(safeTerminalText).join(\", \") || \"none\"}`]),\n `sessions: ${syncSessionsSelected(config) ? \"included\" : \"excluded\"}`,\n ];\n}\n\nfunction fileCount(count: number) {\n return `${count} ${count === 1 ? \"file\" : \"files\"}`;\n}\n\nfunction reportSection(title: string, lines: readonly string[]) {\n return lines.length > 0 ? [\"\", title, ...lines.map((line) => ` ${line}`)] : [];\n}\n\nfunction storageSection(connection: string, destination: string, details: readonly string[]) {\n return reportSection(`Storage \u00B7 ${safeTerminalText(connection)}`, [\n `Location: ${safeTerminalText(destination)}`,\n ...details,\n ]);\n}\n\nexport async function status(\n ctx: ExtensionCommandContext,\n options: CommandOptions,\n factory: SyncBackendFactory = createSyncBackend,\n) {\n const config = await loadConfig(options.setup);\n throwIfAborted(options.signal);\n setSyncStatus(ctx, `checking ${config.setupName}`, { activity: \"checking\" });\n const { head, selectionState, localChanged, remoteChanged, localFiles, firstSync, destination, capability } =\n await inspectSync(\n config,\n await resolvedSnapshotOptionsForContext(ctx, config, options.signal),\n options.signal,\n factory,\n );\n throwIfAborted(options.signal);\n\n const continuous = config.continuous\n ? await (await import(\"./continuous-record.js\")).continuousStatusLines(config)\n : [];\n throwIfAborted(options.signal);\n const warnings = syncSessionsWarnings(config);\n const files = fileCount(localFiles);\n const comparison = firstSync\n ? [`Local: ${files}`, `Remote: ${head ? \"snapshot available\" : \"empty\"}`]\n : [\n `Local: ${localChanged ? \"changed\" : \"unchanged\"} (${files})`,\n `Remote: ${remoteChanged ? \"changed\" : \"unchanged\"}`,\n ];\n setSyncStatus(ctx, undefined);\n ctx.ui.notify(\n [\n `Remote status \u00B7 ${safeTerminalText(config.setupName)}`,\n ...reportSection(firstSync ? \"No previous sync recorded\" : \"Changes since last sync\", [\n ...comparison,\n ...(head ? formatRemoteSelectionStatus(selectionState).split(\"\\n\") : []),\n ]),\n ...reportSection(\"Needs attention\", warnings),\n ...storageSection(config.connectionName, destination, [\n `Publication safety: ${publicationCapabilityDescription(capability)}`,\n ...(head\n ? [\n `Latest snapshot: ${safeTerminalText(head.snapshotId)}`,\n `Device: ${safeTerminalText(head.machine)}`,\n `Created: ${safeTerminalText(head.createdAt)}`,\n ]\n : firstSync\n ? []\n : [\"Latest snapshot: none\"]),\n ]),\n ...reportSection(\"Background activity\", continuous.map(safeTerminalText)),\n ...reportSection(\"Sync scope\", contentLines(config)),\n ].join(\"\\n\"),\n localChanged || remoteChanged || selectionState?.kind === \"different\" || warnings.length > 0 ? \"warning\" : \"info\",\n \"report\",\n );\n}\n\nexport async function diff(\n ctx: ExtensionCommandContext,\n options: CommandOptions,\n factory: SyncBackendFactory = createSyncBackend,\n) {\n const config = await loadConfig(options.setup);\n throwIfAborted(options.signal);\n setSyncStatus(ctx, `checking ${config.setupName}`, { activity: \"checking\" });\n const { local, remote, lines, warnings, selectionState } = await captureDiffComparison(\n ctx,\n config,\n options.signal,\n factory,\n );\n setSyncStatus(ctx, undefined);\n\n const header = lines.join(\"\\n\");\n const level = warnings.length > 0 || selectionState?.kind === \"different\" ? \"warning\" : \"info\";\n if (!remote) {\n ctx.ui.notify(`${header}\\n\\n${formatSnapshotOnlyDiff(\"Remote is empty. Local push would upload\", local)}`, level);\n return;\n }\n\n ctx.ui.notify(`${header}\\n\\n${formatDiff(local, remote)}`, level);\n}\n\nexport async function captureDiffComparison(\n ctx: ExtensionCommandContext,\n config: AnySyncConfig,\n signal?: AbortSignal,\n factory: SyncBackendFactory = createSyncBackend,\n limits?: { local: SnapshotCaptureLimits; remoteBytes: number },\n) {\n const backend = await factory(config);\n throwIfAborted(signal);\n const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, signal);\n throwIfAborted(signal);\n const local = portableSnapshot(\n await createSnapshot(config.snapshotIdentity, snapshotOptions, limits?.local),\n config.localFields,\n );\n throwIfAborted(signal);\n const { snapshot: remote, selectionState } = await readRemoteSnapshot(backend, config, signal, {\n allowSelectionDifference: true,\n sessionDir: snapshotOptions.sessionDir,\n maxBytes: limits?.remoteBytes,\n });\n throwIfAborted(signal);\n const warnings = syncSessionsWarnings(config);\n return {\n local,\n remote: remote && portableSnapshot(remote, remote.localFields),\n warnings,\n selectionState,\n lines: [\n `sync setup: ${config.setupName}`,\n `storage connection: ${config.connectionName}`,\n `storage location: ${safeTerminalText(backend.destination)}`,\n ...contentLines(config),\n ...formatRemoteSelectionStatus(selectionState).split(\"\\n\"),\n ...warnings,\n ],\n };\n}\n\nexport async function doctor(\n ctx: ExtensionCommandContext,\n options: CommandOptions,\n factory: SyncBackendFactory = createSyncBackend,\n) {\n const attention: string[] = [];\n const localChecks: string[] = [];\n let config: AnySyncConfig | undefined;\n let snapshotOptions: SnapshotOptions | undefined;\n let backend: SyncBackend | undefined;\n\n try {\n config = await loadConfig(options.setup);\n throwIfAborted(options.signal);\n snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);\n throwIfAborted(options.signal);\n backend = await factory(config);\n throwIfAborted(options.signal);\n localChecks.push(\"Configuration: OK\");\n attention.push(...syncSessionsWarnings(config));\n } catch (error) {\n throwIfAborted(options.signal);\n attention.push(`Configuration: ${safeTerminalText(errorMessage(error))}`);\n }\n\n if (config && snapshotOptions) {\n const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);\n throwIfAborted(options.signal);\n const secrets = scanSnapshot(local);\n if (secrets.length > 0) {\n attention.push(\n \"Secret scan: possible secrets found\",\n ...secrets.map((secret) => ` - ${safeTerminalText(secret)}`),\n );\n } else {\n localChecks.push(`Secret scan: OK (${fileCount(local.files.length)} checked)`);\n }\n } else localChecks.push(\"Secret scan: skipped without a valid content policy\");\n\n const lock = await inspectLock();\n throwIfAborted(options.signal);\n if (lock.status === \"valid\" && isStaleLock(lock.lock)) {\n attention.push(\n `Operation lock: stale (PID ${lock.lock.pid}); run /sync unlock --stale after verifying no sync is running`,\n );\n } else if (lock.status === \"valid\") {\n localChecks.push(`Operation lock: held by PID ${lock.lock.pid} since ${safeTerminalText(lock.lock.startedAt)}`);\n } else if (lock.status === \"unreadable\") {\n attention.push(\"Operation lock: unreadable; use /sync unlock --stale only after verifying no sync is running\");\n } else if (await isLockGuardHeld()) {\n attention.push(\"Operation lock: guard active while metadata is missing or still being initialized\");\n } else {\n localChecks.push(\"Operation lock: free\");\n }\n throwIfAborted(options.signal);\n\n const storageChecks: string[] = [];\n if (backend) {\n const diagnostics = await backend.diagnose(options.signal);\n throwIfAborted(options.signal);\n for (const diagnostic of diagnostics) {\n if (diagnostic.key === \"s3-config\" && diagnostic.level === \"info\") continue;\n const finding = safeTerminalText(diagnostic.message.replaceAll(\"\\n\", \" \"));\n (diagnostic.level === \"info\" ? storageChecks : attention).push(finding);\n }\n }\n ctx.ui.notify(\n [\n config ? `Diagnostics \u00B7 ${safeTerminalText(config.setupName)}` : \"Diagnostics\",\n ...reportSection(\"Needs attention\", attention),\n ...reportSection(\"Local checks\", localChecks),\n ...(config && backend\n ? storageSection(config.connectionName, backend.destination, [\n ...storageChecks,\n `Publication safety: ${publicationCapabilityDescription(backend.capability)}`,\n ])\n : []),\n ...(config ? reportSection(\"Sync scope\", contentLines(config)) : []),\n ].join(\"\\n\"),\n attention.length > 0 ? \"warning\" : \"info\",\n \"report\",\n );\n}\n\nexport async function history(\n ctx: ExtensionCommandContext,\n options: CommandOptions,\n factory: SyncBackendFactory = createSyncBackend,\n validateJob?: () => void,\n beforeWrite?: () => Promise<boolean>,\n) {\n const { signal } = options;\n const validateSession = captureMutationOwner(ctx, signal);\n const validateOwner = () => {\n validateJob?.();\n validateSession();\n };\n validateOwner();\n const config = await loadConfig(options.setup, signal);\n validateOwner();\n const backend = await factory(config);\n validateOwner();\n const entries = await backend.listHistory(signal);\n validateOwner();\n const interactive = ctx.hasUI && (ctx.mode === \"tui\" || ctx.mode === \"rpc\");\n const repair =\n interactive && !options.auto && config.backend.type === \"webdav\"\n ? backend.repairActiveHistory?.bind(backend)\n : undefined;\n const head = repair\n ? await backend.readHead(signal).catch(() => {\n validateOwner();\n ctx.ui.notify(\"History repair is unavailable because the active WebDAV snapshot could not be read.\", \"warning\");\n return undefined;\n })\n : undefined;\n validateOwner();\n const repairHead = head && !entries.some((entry) => entry.snapshotRef === head.snapshotRef) ? head : undefined;\n const snapshots = entries.slice(-HISTORY_PREVIEW_LIMIT).reverse();\n const lastApplied = await readStateForConfig(config)\n .then((state) => state.lastAppliedSnapshot)\n .catch(() => undefined);\n validateOwner();\n const appliedDetails = lastApplied\n ? `Last applied snapshot ID: ${safeTerminalText(lastApplied)}\\nApplication time: unavailable. Snapshot dates are creation times.`\n : \"Last applied snapshot ID: unavailable.\";\n if (snapshots.length === 0 && !repairHead) {\n ctx.ui.notify(`No remote pi-sync history found.\\n${appliedDetails}`, \"info\");\n return;\n }\n\n const previewRollback = interactive && ctx.mode === \"tui\";\n if (!previewRollback) {\n ctx.ui.notify(\n [\n appliedDetails,\n ...snapshots.map(\n (item) =>\n `${safeTerminalText(item.snapshotRef)} ${safeTerminalText(item.createdAt)} ${safeTerminalText(item.machine)}`,\n ),\n ].join(\"\\n\"),\n \"info\",\n );\n if (!repairHead) return;\n }\n\n const currentSnapshot = repair ? head?.snapshotId : snapshots[0]?.snapshotId;\n const labels = previewRollback\n ? snapshots.map(\n (item, index) =>\n `${index + 1}. ${safeTerminalText(item.createdAt)} \u00B7 ${safeTerminalText(item.machine)} \u00B7 ${safeTerminalText(item.snapshotId)}${item.snapshotId === currentSnapshot ? \" (current)\" : \"\"}${item.syncSessions ? \" \u00B7 sessions\" : \"\"}`,\n )\n : [];\n const setupName = safeTerminalText(config.setupName);\n const repairChoice = \"Repair active snapshot history\";\n const selected = await ctx.ui.select(\n [\n `History for sync setup \u201C${setupName}\u201D`,\n appliedDetails,\n ...(labels.length > 0 ? [\"Choose a snapshot to preview rollback.\"] : []),\n ...(repairHead ? [\"The active WebDAV snapshot is missing from History.\"] : []),\n ].join(\"\\n\\n\"),\n [...labels, ...(repairHead ? [repairChoice] : []), \"Back\"],\n { signal },\n );\n validateOwner();\n if (!selected || selected === \"Back\") return;\n if (selected === repairChoice && repairHead && repair) {\n const validateRepairOwner = () => {\n validateOwner();\n if (!ctx.hasUI || (ctx.mode !== \"tui\" && ctx.mode !== \"rpc\"))\n throw new Error(\"History repair no longer has an observable TUI or RPC client.\");\n };\n validateRepairOwner();\n const fingerprint = syncCheckConfigFingerprint(config);\n const confirmed = await ctx.ui.confirm(\n \"Repair active WebDAV snapshot history?\",\n [\n `Setup: ${setupName}`,\n `Storage: ${safeTerminalText(backend.destination)}`,\n `Active snapshot: ${safeTerminalText(repairHead.snapshotId)}`,\n \"This runs a temporary conditional write/delete probe, then adds this snapshot to remote History if it is still missing. If History is full, the oldest entry is dropped. The active snapshot and local files do not change.\",\n ].join(\"\\n\"),\n { signal },\n );\n validateRepairOwner();\n if (!confirmed) return;\n const validateSettings = async () => {\n validateRepairOwner();\n const current = await loadConfigForCheck(options.setup, signal);\n validateRepairOwner();\n if (syncCheckConfigFingerprint(current) !== fingerprint)\n throw new Error(\"The sync setup settings changed. Reopen History before repairing it.\");\n };\n if (beforeWrite && !(await beforeWrite())) return;\n const repaired = await withLock(\"history repair\", async () => {\n await validateSettings();\n validateRepairOwner();\n return repair(repairHead, {\n signal,\n validateOwner: validateRepairOwner,\n validateSettings,\n onCommit: options.onCommit,\n });\n });\n validateRepairOwner();\n ctx.ui.notify(\n repaired ? \"Active WebDAV snapshot added to History.\" : \"The active WebDAV snapshot is already in History.\",\n \"info\",\n );\n return;\n }\n const snapshot = snapshots[labels.indexOf(selected)];\n if (!snapshot || (beforeWrite && !(await beforeWrite()))) return;\n await withLock(\"rollback\", () => {\n validateOwner();\n return rollback(ctx, { ...options, args: [snapshot.snapshotRef], yes: false }, factory, {\n backendIdentity: backend.identity,\n setup: config.setupName,\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,OAAO,QAAQ;AACf,OAAO,UAAU;AAWjB,eAAsB,mBAAmB,UAAoB,SAAwD;AACnH,QAAM,EAAE,OAAO,IAAI;AACnB,iBAAe,MAAM;AACrB,QAAM,OAAO,SAAS;AACtB,QAAM,OAAO,MAAM,8BAA8B,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,UAAU,OAAO;AACrG,iBAAe,MAAM;AACrB,QAAM,SAA8B,CAAC;AACrC,aAAW,UAAU,KAAK,QAAQ,KAAK,GAAG;AACxC,UAAM,OAAO,MAAM,GAAG,MAAM,MAAM;AAClC,mBAAe,MAAM;AACrB,UAAM,OAAO,WAAW,QAAQ;AAChC,QAAI,KAAK,eAAe,EAAG,MAAK,OAAO,MAAM,GAAG,SAAS,MAAM,CAAC;AAAA,SAC3D;AACH,UAAI,CAAC,KAAK,OAAO,EAAG,OAAM,IAAI,MAAM,2DAA2D;AAC/F,YAAM,SAAS,MAAM,GAAG;AAAA,QACtB;AAAA,QACA,UAAU,YAAY,UAA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MACpB,CAAC;AAAA,IACH,CAAC;AACD,wBAAoB;AACpB,QAAI,GAAG;AAAA,MACL,WAAW,6CAA6C;AAAA,MACxD;AAAA,IACF;AACA;AAAA,EACF;AACA,QAAM,WAAW,UAAU,OAAO,QAAQ,QAAQ,CAAC;AACnD,MAAI,CAAC,YAAa,eAAe,CAAE,MAAM,YAAY,EAAK;AAC1D,QAAM,SAAS,YAAY,MAAM;AAC/B,kBAAc;AACd,WAAO,SAAS,KAAK,EAAE,GAAG,SAAS,MAAM,CAAC,SAAS,WAAW,GAAG,KAAK,MAAM,GAAG,SAAS;AAAA,MACtF,iBAAiB,QAAQ;AAAA,MACzB,OAAO,OAAO;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;",
|
|
6
|
+
"names": ["createHash", "createHash", "VERSION", "upload", "state"]
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
showRemoteSelectionReview
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YUKFRKAE.ts";
|
|
6
6
|
import {
|
|
7
7
|
runCancellableOperation
|
|
8
8
|
} from "./chunk-5ERTMRNE.ts";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
loadConfig,
|
|
17
17
|
syncConfigReviewIdentity
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KZKBQ474.ts";
|
|
19
19
|
|
|
20
20
|
// src/ui/sync-resolution-ui.ts
|
|
21
21
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
@@ -209,4 +209,4 @@ async function dispatchManagerResult(ctx, initialResult, origin, runRoute, signa
|
|
|
209
209
|
export {
|
|
210
210
|
dispatchManagerResult
|
|
211
211
|
};
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
212
|
+
//# sourceMappingURL=chunk-3LB5YP2P.ts.map
|