@narumitw/pi-sync 0.50.3 → 0.51.1
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/README.md +4 -1
- package/dist/chunks/{chunk-6LP3MCR2.ts → chunk-2JZFHNLM.ts} +3 -5
- package/dist/chunks/chunk-2JZFHNLM.ts.map +7 -0
- package/dist/chunks/{chunk-LCRI3ABW.ts → chunk-2RZSQWBH.ts} +8 -19
- package/dist/chunks/chunk-2RZSQWBH.ts.map +7 -0
- package/dist/chunks/{chunk-IJ6FJFA5.ts → chunk-4AIHXRKE.ts} +11 -17
- package/dist/chunks/chunk-4AIHXRKE.ts.map +7 -0
- package/dist/chunks/{chunk-C7XY5NF5.ts → chunk-4MPIH46N.ts} +29 -51
- package/dist/chunks/chunk-4MPIH46N.ts.map +7 -0
- package/dist/chunks/{chunk-5B3FXBLE.ts → chunk-6546TS54.ts} +16 -20
- package/dist/chunks/chunk-6546TS54.ts.map +7 -0
- package/dist/chunks/{chunk-Q2TUM5X6.ts → chunk-6NT3YFGY.ts} +2 -2
- package/dist/chunks/chunk-6NT3YFGY.ts.map +7 -0
- package/dist/chunks/{chunk-2B2ELUF5.ts → chunk-7D5SF7P3.ts} +1 -1
- package/dist/chunks/chunk-7D5SF7P3.ts.map +7 -0
- package/dist/chunks/{chunk-YDWUZVPN.ts → chunk-7KHKWL3Q.ts} +28 -47
- package/dist/chunks/chunk-7KHKWL3Q.ts.map +7 -0
- package/dist/chunks/{chunk-ZI5MXMEX.ts → chunk-BVVP33U5.ts} +2 -4
- package/dist/chunks/chunk-BVVP33U5.ts.map +7 -0
- package/dist/chunks/{chunk-SZWBGPID.ts → chunk-DM4X4FIA.ts} +8 -13
- package/dist/chunks/chunk-DM4X4FIA.ts.map +7 -0
- package/dist/chunks/{chunk-SL64RLXR.ts → chunk-DZUSTGQV.ts} +8 -16
- package/dist/chunks/chunk-DZUSTGQV.ts.map +7 -0
- package/dist/chunks/{chunk-YHEMENKV.ts → chunk-E42GXD6D.ts} +13 -19
- package/dist/chunks/chunk-E42GXD6D.ts.map +7 -0
- package/dist/chunks/{chunk-Z4DQF6L3.ts → chunk-ECYCNZOE.ts} +1 -1
- package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
- package/dist/chunks/{chunk-OEX4ABY6.ts → chunk-EEJPYTWE.ts} +11 -21
- package/dist/chunks/chunk-EEJPYTWE.ts.map +7 -0
- package/dist/chunks/{chunk-CPEHGXJV.ts → chunk-G4RUXRWZ.ts} +3 -5
- package/dist/chunks/chunk-G4RUXRWZ.ts.map +7 -0
- package/dist/chunks/{chunk-T2B5IU74.ts → chunk-HGJH56KR.ts} +4 -4
- package/dist/chunks/chunk-HGJH56KR.ts.map +7 -0
- package/dist/chunks/{chunk-JAAKLL6M.ts → chunk-IVXEDPAD.ts} +10 -34
- package/dist/chunks/chunk-IVXEDPAD.ts.map +7 -0
- package/dist/chunks/chunk-K3RIEL6J.ts +20 -0
- package/dist/chunks/chunk-K3RIEL6J.ts.map +7 -0
- package/dist/chunks/{chunk-LTBWGSBV.ts → chunk-MSSW6F3R.ts} +1 -1
- package/dist/chunks/chunk-MSSW6F3R.ts.map +7 -0
- package/dist/chunks/{chunk-T3HH3UEJ.ts → chunk-OVDTF5CH.ts} +4 -10
- package/dist/chunks/chunk-OVDTF5CH.ts.map +7 -0
- package/dist/chunks/{chunk-NJFUIVYL.ts → chunk-PWMWOJP4.ts} +1 -1
- package/dist/chunks/chunk-PWMWOJP4.ts.map +7 -0
- package/dist/chunks/{chunk-HUDQATCL.ts → chunk-Q32CQWPM.ts} +6 -8
- package/dist/chunks/chunk-Q32CQWPM.ts.map +7 -0
- package/dist/chunks/{chunk-ETTRJDNP.ts → chunk-QLSN7AGX.ts} +6 -13
- package/dist/chunks/chunk-QLSN7AGX.ts.map +7 -0
- package/dist/chunks/{chunk-THMF4BVL.ts → chunk-SWUXA3MH.ts} +1 -1
- package/dist/chunks/chunk-SWUXA3MH.ts.map +7 -0
- package/dist/chunks/{chunk-TEN2ZBJV.ts → chunk-T2SJD3N7.ts} +2 -4
- package/dist/chunks/chunk-T2SJD3N7.ts.map +7 -0
- package/dist/chunks/{chunk-AUSDLD6F.ts → chunk-T56RNRZJ.ts} +10 -26
- package/dist/chunks/chunk-T56RNRZJ.ts.map +7 -0
- package/dist/chunks/{chunk-DHVFS4QK.ts → chunk-UA7RXOIT.ts} +37 -90
- package/dist/chunks/chunk-UA7RXOIT.ts.map +7 -0
- package/dist/chunks/{chunk-D5X27LCA.ts → chunk-UETBKTDI.ts} +1 -1
- package/dist/chunks/chunk-UETBKTDI.ts.map +7 -0
- package/dist/chunks/{chunk-CHH26D4F.ts → chunk-YFADF5ZQ.ts} +7 -6
- package/dist/chunks/chunk-YFADF5ZQ.ts.map +7 -0
- package/dist/chunks/{chunk-CCSN3F47.ts → chunk-YPXGU5OR.ts} +4 -4
- package/dist/chunks/chunk-YPXGU5OR.ts.map +7 -0
- package/dist/chunks/{file-selection-FTTKAOYX.ts → file-selection-RAVHRYFG.ts} +14 -26
- package/dist/chunks/file-selection-RAVHRYFG.ts.map +7 -0
- package/dist/chunks/{git-backend-GMVS4PD4.ts → git-backend-IAANDL3K.ts} +41 -104
- package/dist/chunks/git-backend-IAANDL3K.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-OTUMQM26.ts +23 -0
- package/dist/chunks/{manager-ui-IPAOAWZA.ts → manager-ui-763NEKJY.ts} +124 -251
- package/dist/chunks/manager-ui-763NEKJY.ts.map +7 -0
- package/dist/chunks/remote-selection-ui-TZTJF32Y.ts +22 -0
- package/dist/chunks/{s3-backend-66O4FGBH.ts → s3-backend-XGXUOPUN.ts} +23 -54
- package/dist/chunks/s3-backend-XGXUOPUN.ts.map +7 -0
- package/dist/chunks/{setup-switch-IS2PEZ3J.ts → setup-switch-5G2VNJHL.ts} +9 -9
- package/dist/chunks/{setup-wizard-JUJZYNNM.ts → setup-wizard-YIEWGX32.ts} +12 -12
- package/dist/chunks/setup-wizard-YIEWGX32.ts.map +7 -0
- package/dist/chunks/{snapshot-HKEWCVK6.ts → snapshot-JL5DFSXI.ts} +5 -5
- package/dist/chunks/sync-inspection-P3ENJLNF.ts +20 -0
- package/dist/chunks/{sync-operations-LBX3GKCM.ts → sync-operations-AR76EB6C.ts} +85 -201
- package/dist/chunks/sync-operations-AR76EB6C.ts.map +7 -0
- package/dist/chunks/{sync-state-Q2FTXTW6.ts → sync-state-VHJUZ4YG.ts} +6 -6
- package/dist/chunks/{webdav-backend-ECIKD7SO.ts → webdav-backend-3EGUONAT.ts} +20 -51
- package/dist/chunks/webdav-backend-3EGUONAT.ts.map +7 -0
- package/dist/index.ts +49 -74
- package/dist/index.ts.map +3 -3
- package/docs/settings.md +9 -0
- package/package.json +61 -62
- package/src/backends/backend-factory.ts +15 -15
- package/src/backends/backend-identity.ts +31 -31
- package/src/backends/backend-types.ts +42 -42
- package/src/backends/git/git-backend.ts +714 -788
- package/src/backends/git/git-config.ts +104 -111
- package/src/backends/git/git-runner.ts +230 -247
- package/src/backends/git/git-storage.ts +228 -245
- package/src/backends/s3/s3-backend.ts +408 -441
- package/src/backends/s3/s3-client.ts +288 -333
- package/src/backends/sync-backend.ts +65 -65
- package/src/backends/webdav/webdav-backend.ts +542 -589
- package/src/backends/webdav/webdav-client.ts +292 -316
- package/src/backends/webdav/webdav-config.ts +57 -68
- package/src/commands/command-execution.ts +270 -289
- package/src/commands/command-handler.ts +160 -163
- package/src/commands/command-types.ts +13 -13
- package/src/commands/command.ts +190 -196
- package/src/commands/setup-completions.ts +1 -1
- package/src/paths.ts +47 -47
- package/src/settings/config-errors.ts +4 -5
- package/src/settings/config-file.ts +473 -506
- package/src/settings/config.ts +171 -174
- package/src/settings/settings-management.ts +191 -216
- package/src/settings/settings-store.ts +63 -77
- package/src/settings/settings-types.ts +78 -75
- package/src/settings/settings-validation.ts +328 -364
- package/src/snapshot/session-paths.ts +41 -55
- package/src/snapshot/snapshot-apply.ts +197 -229
- package/src/snapshot/snapshot-codec.ts +29 -31
- package/src/snapshot/snapshot-paths.ts +4 -6
- package/src/snapshot/snapshot-transaction.ts +161 -170
- package/src/snapshot/snapshot-types.ts +24 -24
- package/src/snapshot/snapshot.ts +310 -343
- package/src/state/json-file.ts +11 -11
- package/src/state/lock.ts +226 -242
- package/src/state/lockfile-fs.ts +20 -20
- package/src/state/operation-availability.ts +36 -41
- package/src/state/state-directory.ts +171 -173
- package/src/state/state-types.ts +15 -15
- package/src/state/sync-state-store.ts +23 -23
- package/src/sync/automatic-sync.ts +75 -80
- package/src/sync/remote-snapshot.ts +52 -60
- package/src/sync/setup-switch.ts +99 -114
- package/src/sync/signals.ts +3 -5
- package/src/sync/startup-check.ts +97 -111
- package/src/sync/sync-decision.ts +76 -80
- package/src/sync/sync-error-guidance.ts +41 -48
- package/src/sync/sync-errors.ts +10 -10
- package/src/sync/sync-inspection.ts +29 -33
- package/src/sync/sync-loaders.ts +28 -36
- package/src/sync/sync-mutations.ts +510 -622
- package/src/sync/sync-operations.ts +7 -7
- package/src/sync/sync-policy.ts +296 -326
- package/src/sync/sync-queries.ts +175 -194
- package/src/sync/sync-state.ts +74 -100
- package/src/sync-extension.ts +89 -101
- package/src/sync.ts +26 -26
- package/src/types.ts +37 -37
- package/src/ui/automatic-sync-summary.ts +1 -3
- package/src/ui/cancellable-operation.ts +89 -101
- package/src/ui/file-selection.ts +250 -274
- package/src/ui/manager-attention.ts +51 -63
- package/src/ui/manager-recovery.ts +48 -57
- package/src/ui/manager-result-dispatcher.ts +62 -76
- package/src/ui/manager-state.ts +200 -232
- package/src/ui/manager-ui.ts +264 -362
- package/src/ui/remote-selection-ui.ts +547 -588
- package/src/ui/secret-input.ts +197 -205
- package/src/ui/settings-ui.ts +175 -172
- package/src/ui/setup/git-ui.ts +232 -261
- package/src/ui/setup/s3-credentials-ui.ts +58 -65
- package/src/ui/setup/s3-ui.ts +171 -195
- package/src/ui/setup/setup-actions.ts +91 -101
- package/src/ui/setup/setup-location-ui.ts +121 -137
- package/src/ui/setup/setup-name-ui.ts +27 -27
- package/src/ui/setup/setup-prompts.ts +65 -65
- package/src/ui/setup/setup-review.ts +58 -59
- package/src/ui/setup/setup-switcher.ts +156 -160
- package/src/ui/setup/setup-wizard.ts +28 -28
- package/src/ui/setup/text-input.ts +54 -58
- package/src/ui/setup/webdav-ui.ts +246 -293
- package/src/ui/storage-connections-ui.ts +317 -369
- package/src/ui/sync-attention.ts +148 -164
- package/src/ui/sync-format.ts +110 -121
- package/src/ui/sync-resolution-ui.ts +147 -153
- package/src/ui/sync-setups-ui.ts +218 -238
- package/src/ui/sync-status.ts +17 -0
- package/src/ui/terminal-text.ts +2 -2
- package/dist/chunks/chunk-2B2ELUF5.ts.map +0 -7
- package/dist/chunks/chunk-5B3FXBLE.ts.map +0 -7
- package/dist/chunks/chunk-6LP3MCR2.ts.map +0 -7
- package/dist/chunks/chunk-AUSDLD6F.ts.map +0 -7
- package/dist/chunks/chunk-C7XY5NF5.ts.map +0 -7
- package/dist/chunks/chunk-CCSN3F47.ts.map +0 -7
- package/dist/chunks/chunk-CHH26D4F.ts.map +0 -7
- package/dist/chunks/chunk-CPEHGXJV.ts.map +0 -7
- package/dist/chunks/chunk-D5X27LCA.ts.map +0 -7
- package/dist/chunks/chunk-DHVFS4QK.ts.map +0 -7
- package/dist/chunks/chunk-ETTRJDNP.ts.map +0 -7
- package/dist/chunks/chunk-HUDQATCL.ts.map +0 -7
- package/dist/chunks/chunk-IJ6FJFA5.ts.map +0 -7
- package/dist/chunks/chunk-JAAKLL6M.ts.map +0 -7
- package/dist/chunks/chunk-LCRI3ABW.ts.map +0 -7
- package/dist/chunks/chunk-LTBWGSBV.ts.map +0 -7
- package/dist/chunks/chunk-NJFUIVYL.ts.map +0 -7
- package/dist/chunks/chunk-OEX4ABY6.ts.map +0 -7
- package/dist/chunks/chunk-Q2TUM5X6.ts.map +0 -7
- package/dist/chunks/chunk-SL64RLXR.ts.map +0 -7
- package/dist/chunks/chunk-SZWBGPID.ts.map +0 -7
- package/dist/chunks/chunk-T2B5IU74.ts.map +0 -7
- package/dist/chunks/chunk-T3HH3UEJ.ts.map +0 -7
- package/dist/chunks/chunk-TEN2ZBJV.ts.map +0 -7
- package/dist/chunks/chunk-THMF4BVL.ts.map +0 -7
- package/dist/chunks/chunk-YDWUZVPN.ts.map +0 -7
- package/dist/chunks/chunk-YHEMENKV.ts.map +0 -7
- package/dist/chunks/chunk-Z4DQF6L3.ts.map +0 -7
- package/dist/chunks/chunk-ZI5MXMEX.ts.map +0 -7
- package/dist/chunks/file-selection-FTTKAOYX.ts.map +0 -7
- package/dist/chunks/git-backend-GMVS4PD4.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-ASKGOSW5.ts +0 -22
- package/dist/chunks/manager-ui-IPAOAWZA.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-QDNR7WEI.ts +0 -21
- package/dist/chunks/s3-backend-66O4FGBH.ts.map +0 -7
- package/dist/chunks/setup-wizard-JUJZYNNM.ts.map +0 -7
- package/dist/chunks/sync-inspection-CST2KL65.ts +0 -20
- package/dist/chunks/sync-operations-LBX3GKCM.ts.map +0 -7
- package/dist/chunks/webdav-backend-ECIKD7SO.ts.map +0 -7
- /package/dist/chunks/{manager-result-dispatcher-ASKGOSW5.ts.map → manager-result-dispatcher-OTUMQM26.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-QDNR7WEI.ts.map → remote-selection-ui-TZTJF32Y.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-IS2PEZ3J.ts.map → setup-switch-5G2VNJHL.ts.map} +0 -0
- /package/dist/chunks/{snapshot-HKEWCVK6.ts.map → snapshot-JL5DFSXI.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-CST2KL65.ts.map → sync-inspection-P3ENJLNF.ts.map} +0 -0
- /package/dist/chunks/{sync-state-Q2FTXTW6.ts.map → sync-state-VHJUZ4YG.ts.map} +0 -0
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
readRemoteSnapshot,
|
|
6
6
|
readSnapshotForHead,
|
|
7
7
|
requireCompatibleRemoteSelection
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-Q32CQWPM.ts";
|
|
9
9
|
import {
|
|
10
10
|
inspectSync
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DM4X4FIA.ts";
|
|
12
12
|
import {
|
|
13
13
|
createSyncBackend
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HGJH56KR.ts";
|
|
15
15
|
import {
|
|
16
16
|
canPullRemoteSessionsOnFirstSync,
|
|
17
17
|
canPullRemoteSettingsOnFirstSync,
|
|
@@ -24,47 +24,50 @@ import {
|
|
|
24
24
|
snapshotHashesMatchState,
|
|
25
25
|
snapshotsMatch,
|
|
26
26
|
syncPolicyChanged
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-T56RNRZJ.ts";
|
|
28
28
|
import {
|
|
29
29
|
applySnapshotTransaction,
|
|
30
30
|
recoverPendingSnapshotTransactions
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-4AIHXRKE.ts";
|
|
32
32
|
import {
|
|
33
33
|
inspectLock,
|
|
34
34
|
isLockGuardHeld,
|
|
35
35
|
isStaleLock,
|
|
36
36
|
withLock
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-QLSN7AGX.ts";
|
|
38
|
+
import {
|
|
39
|
+
setSyncStatus
|
|
40
|
+
} from "./chunk-K3RIEL6J.ts";
|
|
38
41
|
import {
|
|
39
42
|
throwIfAborted
|
|
40
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-PWMWOJP4.ts";
|
|
41
44
|
import {
|
|
42
45
|
readStateForConfig,
|
|
43
46
|
writeStateForConfig
|
|
44
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-YPXGU5OR.ts";
|
|
45
48
|
import {
|
|
46
49
|
safeTerminalText
|
|
47
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-MSSW6F3R.ts";
|
|
48
51
|
import {
|
|
49
52
|
loadConfig,
|
|
50
53
|
syncConfigReviewIdentity,
|
|
51
54
|
syncSessionsWarnings
|
|
52
|
-
} from "./chunk-
|
|
53
|
-
import "./chunk-
|
|
55
|
+
} from "./chunk-4MPIH46N.ts";
|
|
56
|
+
import "./chunk-2JZFHNLM.ts";
|
|
54
57
|
import {
|
|
55
58
|
encodeSnapshot
|
|
56
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-6NT3YFGY.ts";
|
|
57
60
|
import {
|
|
58
61
|
stateDir
|
|
59
|
-
} from "./chunk-
|
|
60
|
-
import "./chunk-
|
|
62
|
+
} from "./chunk-BVVP33U5.ts";
|
|
63
|
+
import "./chunk-T2SJD3N7.ts";
|
|
61
64
|
import {
|
|
62
65
|
expectedRemoteHead
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-UETBKTDI.ts";
|
|
64
67
|
import {
|
|
65
68
|
SyncDecisionRequiredError,
|
|
66
69
|
errorMessage
|
|
67
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-7D5SF7P3.ts";
|
|
68
71
|
import {
|
|
69
72
|
createSnapshot,
|
|
70
73
|
filterSnapshotForConfigPolicy,
|
|
@@ -77,16 +80,16 @@ import {
|
|
|
77
80
|
snapshotIncludesSessions,
|
|
78
81
|
snapshotTarget,
|
|
79
82
|
snapshotWithoutSessions
|
|
80
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-EEJPYTWE.ts";
|
|
81
84
|
import {
|
|
82
85
|
sessionStorageRoot
|
|
83
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-SWUXA3MH.ts";
|
|
84
87
|
import {
|
|
85
88
|
agentDir,
|
|
86
89
|
sessionDirForApply,
|
|
87
90
|
sessionDirFromContext,
|
|
88
91
|
snapshotOptionsForContext
|
|
89
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-OVDTF5CH.ts";
|
|
90
93
|
import {
|
|
91
94
|
assertWithinRoot,
|
|
92
95
|
includeFromSelectionConfig,
|
|
@@ -96,7 +99,7 @@ import {
|
|
|
96
99
|
parentPaths,
|
|
97
100
|
safeJoin,
|
|
98
101
|
toPosix
|
|
99
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-IVXEDPAD.ts";
|
|
100
103
|
|
|
101
104
|
// src/sync/sync-mutations.ts
|
|
102
105
|
import fs2 from "node:fs/promises";
|
|
@@ -153,8 +156,7 @@ function preflightSnapshotApply(root, snapshot, current, options = {}) {
|
|
|
153
156
|
remotePaths.add(normalized);
|
|
154
157
|
const target = snapshotTarget(root, normalized, options.sessionDir);
|
|
155
158
|
const content = decodeBase64Strict(file.contentBase64, normalized);
|
|
156
|
-
if (sha256(content) !== file.sha256)
|
|
157
|
-
throw new Error(`Checksum mismatch in snapshot file: ${normalized}`);
|
|
159
|
+
if (sha256(content) !== file.sha256) throw new Error(`Checksum mismatch in snapshot file: ${normalized}`);
|
|
158
160
|
writes.push({ target, content });
|
|
159
161
|
}
|
|
160
162
|
const deletePaths = /* @__PURE__ */ new Set();
|
|
@@ -175,9 +177,7 @@ function preflightSnapshotApply(root, snapshot, current, options = {}) {
|
|
|
175
177
|
function protectSnapshotApplyPlan(root, plan, protectedRelativePaths, sessionDir) {
|
|
176
178
|
if (protectedRelativePaths.size === 0) return plan;
|
|
177
179
|
const protectedTargets = new Set(
|
|
178
|
-
[...protectedRelativePaths].map(
|
|
179
|
-
(relativePath) => snapshotTarget(root, relativePath, sessionDir)
|
|
180
|
-
)
|
|
180
|
+
[...protectedRelativePaths].map((relativePath) => snapshotTarget(root, relativePath, sessionDir))
|
|
181
181
|
);
|
|
182
182
|
return {
|
|
183
183
|
writes: plan.writes.filter((item) => !protectedTargets.has(item.target)),
|
|
@@ -240,11 +240,7 @@ async function preflightSnapshotMutations(root, plan, sessionDir) {
|
|
|
240
240
|
await assertNoSymlinkParents(rootForTarget(root, target, sessionDir), target);
|
|
241
241
|
}
|
|
242
242
|
for (const item of plan.writes) {
|
|
243
|
-
await prepareSnapshotWrite(
|
|
244
|
-
rootForTarget(root, item.target, sessionDir),
|
|
245
|
-
item.target,
|
|
246
|
-
deletePaths
|
|
247
|
-
);
|
|
243
|
+
await prepareSnapshotWrite(rootForTarget(root, item.target, sessionDir), item.target, deletePaths);
|
|
248
244
|
}
|
|
249
245
|
}
|
|
250
246
|
function rootForTarget(root, target, sessionDir) {
|
|
@@ -257,8 +253,7 @@ async function prepareSnapshotWrite(root, target, deletePaths) {
|
|
|
257
253
|
if (parentWillBeReplaced) return;
|
|
258
254
|
try {
|
|
259
255
|
const stat = await fs.lstat(target);
|
|
260
|
-
if (stat.isSymbolicLink())
|
|
261
|
-
throw new Error(`Refusing to overwrite symlink during snapshot apply: ${target}`);
|
|
256
|
+
if (stat.isSymbolicLink()) throw new Error(`Refusing to overwrite symlink during snapshot apply: ${target}`);
|
|
262
257
|
if (stat.isDirectory() && !deletePaths.has(target)) {
|
|
263
258
|
throw new Error(`Refusing to overwrite directory during snapshot apply: ${target}`);
|
|
264
259
|
}
|
|
@@ -275,8 +270,7 @@ async function ensureSafeDirectory(root, directory, deletePaths) {
|
|
|
275
270
|
current = path.join(current, part);
|
|
276
271
|
try {
|
|
277
272
|
const stat = await fs.lstat(current);
|
|
278
|
-
if (stat.isSymbolicLink())
|
|
279
|
-
throw new Error(`Refusing to follow symlink during snapshot apply: ${current}`);
|
|
273
|
+
if (stat.isSymbolicLink()) throw new Error(`Refusing to follow symlink during snapshot apply: ${current}`);
|
|
280
274
|
if (!stat.isDirectory()) {
|
|
281
275
|
if (deletePaths.has(current)) return true;
|
|
282
276
|
throw new Error(`Snapshot path parent is not a directory: ${current}`);
|
|
@@ -298,10 +292,8 @@ async function assertNoSymlinkParents(root, target) {
|
|
|
298
292
|
current = path.join(current, part);
|
|
299
293
|
try {
|
|
300
294
|
const stat = await fs.lstat(current);
|
|
301
|
-
if (stat.isSymbolicLink())
|
|
302
|
-
|
|
303
|
-
if (!stat.isDirectory())
|
|
304
|
-
throw new Error(`Snapshot path parent is not a directory: ${current}`);
|
|
295
|
+
if (stat.isSymbolicLink()) throw new Error(`Refusing to follow symlink during snapshot apply: ${current}`);
|
|
296
|
+
if (!stat.isDirectory()) throw new Error(`Snapshot path parent is not a directory: ${current}`);
|
|
305
297
|
} catch (error) {
|
|
306
298
|
if (error.code === "ENOENT") return;
|
|
307
299
|
throw error;
|
|
@@ -314,11 +306,7 @@ function formatDiff(local, remote) {
|
|
|
314
306
|
const localMap = fileHashMap(local);
|
|
315
307
|
const remoteMap = fileHashMap(remote);
|
|
316
308
|
const allPaths = [.../* @__PURE__ */ new Set([...Object.keys(localMap), ...Object.keys(remoteMap)])].sort();
|
|
317
|
-
const lines = [
|
|
318
|
-
`local: ${local.files.length} files`,
|
|
319
|
-
`remote: ${remote.id} (${remote.files.length} files)`,
|
|
320
|
-
""
|
|
321
|
-
];
|
|
309
|
+
const lines = [`local: ${local.files.length} files`, `remote: ${remote.id} (${remote.files.length} files)`, ""];
|
|
322
310
|
let changed = 0;
|
|
323
311
|
for (const filePath of allPaths) {
|
|
324
312
|
if (!localMap[filePath]) {
|
|
@@ -336,9 +324,7 @@ function formatDiff(local, remote) {
|
|
|
336
324
|
return lines.join("\n");
|
|
337
325
|
}
|
|
338
326
|
function formatSnapshotOnlyDiff(title, snapshot) {
|
|
339
|
-
return [`${title}: ${snapshot.id}`, ...snapshot.files.map((file) => `Add: ${file.path}`)].join(
|
|
340
|
-
"\n"
|
|
341
|
-
);
|
|
327
|
+
return [`${title}: ${snapshot.id}`, ...snapshot.files.map((file) => `Add: ${file.path}`)].join("\n");
|
|
342
328
|
}
|
|
343
329
|
function formatPushSummary(config, destination, upload, head, preservedRemoteFileCount = 0, remote) {
|
|
344
330
|
return [
|
|
@@ -348,9 +334,7 @@ function formatPushSummary(config, destination, upload, head, preservedRemoteFil
|
|
|
348
334
|
`Sessions: ${upload.syncSessions ? "included \u2014 may contain private conversations" : "not included"}`,
|
|
349
335
|
head ? `Remote latest: ${head.snapshotId}` : "Remote latest: empty",
|
|
350
336
|
"Publication effect: the backend's active head will reference the new immutable snapshot.",
|
|
351
|
-
...remote && inspectRemoteSelection(config.include, remote).kind === "different" ? [
|
|
352
|
-
"Included-content policy effect: replace the differing remote selection with this setup's local selection."
|
|
353
|
-
] : [],
|
|
337
|
+
...remote && inspectRemoteSelection(config.include, remote).kind === "different" ? ["Included-content policy effect: replace the differing remote selection with this setup's local selection."] : [],
|
|
354
338
|
formatPublicationPreview(remote, upload),
|
|
355
339
|
preservedRemoteFileCount > 0 ? `Possible secrets in locally managed files were scanned before this prompt; ${preservedRemoteFileCount} preserved remote file(s) were not rescanned.` : "Possible secrets were scanned before this prompt."
|
|
356
340
|
].join("\n");
|
|
@@ -386,9 +370,7 @@ function formatRollbackSummary(config, destination, local, remote, requestedSnap
|
|
|
386
370
|
}
|
|
387
371
|
function formatPublicationPreview(remote, upload) {
|
|
388
372
|
if (!remote) {
|
|
389
|
-
return ["Remote is empty.", ...upload.files.map((file) => `Add remotely: ${file.path}`)].join(
|
|
390
|
-
"\n"
|
|
391
|
-
);
|
|
373
|
+
return ["Remote is empty.", ...upload.files.map((file) => `Add remotely: ${file.path}`)].join("\n");
|
|
392
374
|
}
|
|
393
375
|
return formatDirectionalChanges(remote, upload, {
|
|
394
376
|
add: "Add remotely",
|
|
@@ -404,8 +386,7 @@ function formatDirectionalChanges(before, after, labels) {
|
|
|
404
386
|
for (const filePath of paths) {
|
|
405
387
|
if (!beforeMap[filePath]) lines.push(`${labels.add}: ${filePath}`);
|
|
406
388
|
else if (!afterMap[filePath]) lines.push(`${labels.remove}: ${filePath}`);
|
|
407
|
-
else if (beforeMap[filePath] !== afterMap[filePath])
|
|
408
|
-
lines.push(`${labels.update}: ${filePath}`);
|
|
389
|
+
else if (beforeMap[filePath] !== afterMap[filePath]) lines.push(`${labels.update}: ${filePath}`);
|
|
409
390
|
}
|
|
410
391
|
if (lines.length === 0) lines.push("No file changes.");
|
|
411
392
|
return lines.join("\n");
|
|
@@ -449,11 +430,7 @@ function createSyncDecision(options) {
|
|
|
449
430
|
"",
|
|
450
431
|
"Why a decision is required:",
|
|
451
432
|
...causeLines,
|
|
452
|
-
...policyChanged ? [
|
|
453
|
-
"",
|
|
454
|
-
`Previously included: ${safeList(previousInclude)}`,
|
|
455
|
-
`Currently included: ${safeList(currentInclude)}`
|
|
456
|
-
] : [],
|
|
433
|
+
...policyChanged ? ["", `Previously included: ${safeList(previousInclude)}`, `Currently included: ${safeList(currentInclude)}`] : [],
|
|
457
434
|
"",
|
|
458
435
|
"Observed differences:",
|
|
459
436
|
...comparison.split("\n").map(safeTerminalText)
|
|
@@ -475,7 +452,6 @@ function safeList(values) {
|
|
|
475
452
|
}
|
|
476
453
|
|
|
477
454
|
// src/sync/sync-mutations.ts
|
|
478
|
-
var STATUS_KEY = "sync";
|
|
479
455
|
var VERSION = 1;
|
|
480
456
|
var POST_LOCAL_COMMIT_TIMEOUT_MS = 3e4;
|
|
481
457
|
var PublicationStatePersistenceError = class extends Error {
|
|
@@ -494,10 +470,9 @@ var PublicationStatePersistenceError = class extends Error {
|
|
|
494
470
|
var RollbackPublicationError = class extends Error {
|
|
495
471
|
backupPath;
|
|
496
472
|
constructor(backupPath, cause) {
|
|
497
|
-
super(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
);
|
|
473
|
+
super(`Rollback applied locally with backup ${backupPath}, but remote publication failed: ${errorMessage(cause)}`, {
|
|
474
|
+
cause
|
|
475
|
+
});
|
|
501
476
|
this.name = "RollbackPublicationError";
|
|
502
477
|
this.backupPath = backupPath;
|
|
503
478
|
}
|
|
@@ -505,32 +480,21 @@ var RollbackPublicationError = class extends Error {
|
|
|
505
480
|
async function push(ctx, options, input, factory = createSyncBackend) {
|
|
506
481
|
const config = input?.config ?? await loadConfig(options.setup);
|
|
507
482
|
throwIfAborted(options.signal);
|
|
508
|
-
ctx
|
|
483
|
+
setSyncStatus(ctx, `pushing ${config.setupName}`);
|
|
509
484
|
const backend = input?.backend ?? await factory(config);
|
|
510
485
|
const state = input?.state ?? await readStateForConfig(config);
|
|
511
486
|
throwIfAborted(options.signal);
|
|
512
487
|
const local = input?.local ?? await createSnapshot(config.snapshotIdentity, snapshotOptionsForContext(ctx, config));
|
|
513
488
|
throwIfAborted(options.signal);
|
|
514
489
|
let head = await backend.readHead(options.signal);
|
|
515
|
-
let remoteForUpload = await readRemoteSnapshotForUpload(
|
|
516
|
-
backend,
|
|
517
|
-
config,
|
|
518
|
-
head,
|
|
519
|
-
state,
|
|
520
|
-
options.signal
|
|
521
|
-
);
|
|
490
|
+
let remoteForUpload = await readRemoteSnapshotForUpload(backend, config, head, state, options.signal);
|
|
522
491
|
if (!options.force && !remoteForUpload && head?.selection && inspectRemoteSelection(config.include, { selection: head.selection, files: [] }).kind === "different") {
|
|
523
492
|
remoteForUpload = await readSnapshotForHead(backend, head, options.signal);
|
|
524
493
|
}
|
|
525
494
|
if (remoteForUpload && !options.force) {
|
|
526
495
|
requireCompatibleRemoteSelection(config, remoteForUpload);
|
|
527
496
|
}
|
|
528
|
-
if (remoteChangedSinceState(
|
|
529
|
-
head,
|
|
530
|
-
state,
|
|
531
|
-
config,
|
|
532
|
-
(left, right) => backend.sameRevision(left, right)
|
|
533
|
-
) && !options.force) {
|
|
497
|
+
if (remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)) && !options.force) {
|
|
534
498
|
const remoteForConflict = remoteForUpload ? filterSnapshotForConfigPolicy(remoteForUpload, config) : void 0;
|
|
535
499
|
if (!remoteForConflict || !snapshotHashesMatchState(remoteForConflict, state, config)) {
|
|
536
500
|
throw createSyncDecision({
|
|
@@ -545,21 +509,12 @@ async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
545
509
|
});
|
|
546
510
|
}
|
|
547
511
|
}
|
|
548
|
-
let upload = await snapshotForUpload(
|
|
549
|
-
backend,
|
|
550
|
-
config,
|
|
551
|
-
local,
|
|
552
|
-
head,
|
|
553
|
-
remoteForUpload,
|
|
554
|
-
options.signal
|
|
555
|
-
);
|
|
512
|
+
let upload = await snapshotForUpload(backend, config, local, head, remoteForUpload, options.signal);
|
|
556
513
|
if (!config.skipSecretScan) {
|
|
557
514
|
const secrets = scanSnapshot(local);
|
|
558
515
|
if (secrets.length > 0) {
|
|
559
|
-
throw new Error(
|
|
560
|
-
|
|
561
|
-
${secrets.map((s) => `- ${s}`).join("\n")}`
|
|
562
|
-
);
|
|
516
|
+
throw new Error(`Refusing to push possible secrets:
|
|
517
|
+
${secrets.map((s) => `- ${s}`).join("\n")}`);
|
|
563
518
|
}
|
|
564
519
|
}
|
|
565
520
|
if (!await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload)) {
|
|
@@ -570,14 +525,7 @@ ${secrets.map((s) => `- ${s}`).join("\n")}`
|
|
|
570
525
|
if (!sameRemoteHead(backend, head, refreshedHead)) {
|
|
571
526
|
head = refreshedHead;
|
|
572
527
|
remoteForUpload = head ? await backend.readSnapshot(head.snapshotRef, options.signal) : void 0;
|
|
573
|
-
upload = await snapshotForUpload(
|
|
574
|
-
backend,
|
|
575
|
-
config,
|
|
576
|
-
local,
|
|
577
|
-
head,
|
|
578
|
-
remoteForUpload,
|
|
579
|
-
options.signal
|
|
580
|
-
);
|
|
528
|
+
upload = await snapshotForUpload(backend, config, local, head, remoteForUpload, options.signal);
|
|
581
529
|
if (!await confirmPush(
|
|
582
530
|
ctx,
|
|
583
531
|
options,
|
|
@@ -610,7 +558,7 @@ ${secrets.map((s) => `- ${s}`).join("\n")}`
|
|
|
610
558
|
throw new PublicationStatePersistenceError(result.head, error);
|
|
611
559
|
}
|
|
612
560
|
if (options.signal?.aborted) return;
|
|
613
|
-
ctx
|
|
561
|
+
setSyncStatus(ctx, void 0);
|
|
614
562
|
if (!options.silent) {
|
|
615
563
|
ctx.ui.notify(
|
|
616
564
|
[
|
|
@@ -625,14 +573,11 @@ ${secrets.map((s) => `- ${s}`).join("\n")}`
|
|
|
625
573
|
async function pull(ctx, options, factory = createSyncBackend) {
|
|
626
574
|
const config = await loadConfig(options.setup);
|
|
627
575
|
throwIfAborted(options.signal);
|
|
628
|
-
ctx
|
|
576
|
+
setSyncStatus(ctx, `pulling ${config.setupName}`);
|
|
629
577
|
const backend = await factory(config);
|
|
630
578
|
const state = await readStateForConfig(config);
|
|
631
579
|
throwIfAborted(options.signal);
|
|
632
|
-
const local = await createSnapshot(
|
|
633
|
-
config.snapshotIdentity,
|
|
634
|
-
snapshotOptionsForContext(ctx, config)
|
|
635
|
-
);
|
|
580
|
+
const local = await createSnapshot(config.snapshotIdentity, snapshotOptionsForContext(ctx, config));
|
|
636
581
|
throwIfAborted(options.signal);
|
|
637
582
|
const { head, snapshot: remote } = await readRemoteSnapshot(backend, config, options.signal);
|
|
638
583
|
throwIfAborted(options.signal);
|
|
@@ -663,24 +608,14 @@ async function pull(ctx, options, factory = createSyncBackend) {
|
|
|
663
608
|
}
|
|
664
609
|
if (!options.yes && !await ctx.ui.confirm(
|
|
665
610
|
snapshotIncludesSessions(remote) ? "Pull pi settings and sessions?" : "Pull pi settings?",
|
|
666
|
-
formatPullSummary(
|
|
667
|
-
config,
|
|
668
|
-
backend.destination,
|
|
669
|
-
local,
|
|
670
|
-
remote,
|
|
671
|
-
protectedSessionPaths(ctx).size
|
|
672
|
-
)
|
|
611
|
+
formatPullSummary(config, backend.destination, local, remote, protectedSessionPaths(ctx).size)
|
|
673
612
|
)) {
|
|
674
|
-
ctx
|
|
613
|
+
setSyncStatus(ctx, void 0);
|
|
675
614
|
ctx.ui.notify("Pull cancelled.", "info");
|
|
676
615
|
return "cancelled";
|
|
677
616
|
}
|
|
678
617
|
throwIfAborted(options.signal);
|
|
679
|
-
const backup = await backupLocal(
|
|
680
|
-
config.snapshotIdentity,
|
|
681
|
-
snapshotOptionsForContext(ctx, config),
|
|
682
|
-
options.signal
|
|
683
|
-
);
|
|
618
|
+
const backup = await backupLocal(config.snapshotIdentity, snapshotOptionsForContext(ctx, config), options.signal);
|
|
684
619
|
const applySessionDir = await sessionDirForApply(ctx, remote);
|
|
685
620
|
throwIfAborted(options.signal);
|
|
686
621
|
options.onCommit?.();
|
|
@@ -697,12 +632,9 @@ async function pull(ctx, options, factory = createSyncBackend) {
|
|
|
697
632
|
include: [...config.include]
|
|
698
633
|
});
|
|
699
634
|
if (options.signal?.aborted) return "applied";
|
|
700
|
-
ctx
|
|
635
|
+
setSyncStatus(ctx, void 0);
|
|
701
636
|
if (!options.silent) {
|
|
702
|
-
ctx.ui.notify(
|
|
703
|
-
`Pulled ${remote.files.length} files from ${remote.id}. Backup: ${backup}`,
|
|
704
|
-
"info"
|
|
705
|
-
);
|
|
637
|
+
ctx.ui.notify(`Pulled ${remote.files.length} files from ${remote.id}. Backup: ${backup}`, "info");
|
|
706
638
|
} else if (options.auto && config.include.includes("sessions") && snapshotIncludesSessions(remote)) {
|
|
707
639
|
ctx.ui.notify(
|
|
708
640
|
"Pulled Pi sessions after startup selected the current session. Restart Pi or resume a pulled session to use newly synced conversations.",
|
|
@@ -718,10 +650,7 @@ async function syncBoth(ctx, options, factory = createSyncBackend) {
|
|
|
718
650
|
const backend = await factory(config);
|
|
719
651
|
const state = await readStateForConfig(config);
|
|
720
652
|
throwIfAborted(options.signal);
|
|
721
|
-
const local = await createSnapshot(
|
|
722
|
-
config.snapshotIdentity,
|
|
723
|
-
snapshotOptionsForContext(ctx, config)
|
|
724
|
-
);
|
|
653
|
+
const local = await createSnapshot(config.snapshotIdentity, snapshotOptionsForContext(ctx, config));
|
|
725
654
|
throwIfAborted(options.signal);
|
|
726
655
|
if (config.include.length === 0) {
|
|
727
656
|
if (!options.silent) {
|
|
@@ -774,8 +703,7 @@ async function syncBoth(ctx, options, factory = createSyncBackend) {
|
|
|
774
703
|
lastFileHashes: fileHashMap(remote),
|
|
775
704
|
include: [...config.include]
|
|
776
705
|
});
|
|
777
|
-
if (!options.silent)
|
|
778
|
-
ctx.ui.notify("pi-sync state initialized; local settings already match remote.", "info");
|
|
706
|
+
if (!options.silent) ctx.ui.notify("pi-sync state initialized; local settings already match remote.", "info");
|
|
779
707
|
return;
|
|
780
708
|
}
|
|
781
709
|
if (localChanged && remoteChanged && remote && snapshotsMatch(local, remote)) {
|
|
@@ -810,13 +738,7 @@ async function syncBoth(ctx, options, factory = createSyncBackend) {
|
|
|
810
738
|
await push(ctx, options, void 0, factory);
|
|
811
739
|
return;
|
|
812
740
|
}
|
|
813
|
-
if (shouldRefreshSyncedState(
|
|
814
|
-
remote,
|
|
815
|
-
head,
|
|
816
|
-
state,
|
|
817
|
-
config,
|
|
818
|
-
(left, right) => backend.sameRevision(left, right)
|
|
819
|
-
)) {
|
|
741
|
+
if (shouldRefreshSyncedState(remote, head, state, config, (left, right) => backend.sameRevision(left, right))) {
|
|
820
742
|
await writeStateForConfig(config, {
|
|
821
743
|
version: VERSION,
|
|
822
744
|
profile: config.snapshotIdentity,
|
|
@@ -835,9 +757,7 @@ async function rollback(ctx, options, factory = createSyncBackend, expectedSelec
|
|
|
835
757
|
throwIfAborted(options.signal);
|
|
836
758
|
const backend = await factory(config);
|
|
837
759
|
if (expectedSelection && (backend.identity !== expectedSelection.backendIdentity || config.setupName !== expectedSelection.setup)) {
|
|
838
|
-
throw new Error(
|
|
839
|
-
"Sync setup or storage location changed while history was open; reopen history and retry."
|
|
840
|
-
);
|
|
760
|
+
throw new Error("Sync setup or storage location changed while history was open; reopen history and retry.");
|
|
841
761
|
}
|
|
842
762
|
const decoded = await backend.readSnapshot(target, options.signal);
|
|
843
763
|
const selected = filterSnapshotForConfigPolicy(
|
|
@@ -845,32 +765,18 @@ async function rollback(ctx, options, factory = createSyncBackend, expectedSelec
|
|
|
845
765
|
config
|
|
846
766
|
);
|
|
847
767
|
const remote = regenerateSnapshotIdentity(selected);
|
|
848
|
-
const local = await createSnapshot(
|
|
849
|
-
config.snapshotIdentity,
|
|
850
|
-
snapshotOptionsForContext(ctx, config)
|
|
851
|
-
);
|
|
768
|
+
const local = await createSnapshot(config.snapshotIdentity, snapshotOptionsForContext(ctx, config));
|
|
852
769
|
const expectedHead = await backend.readHead(options.signal);
|
|
853
770
|
throwIfAborted(options.signal);
|
|
854
771
|
if (!options.yes && !await ctx.ui.confirm(
|
|
855
772
|
snapshotIncludesSessions(remote) ? "Rollback pi settings and sessions?" : "Rollback pi settings?",
|
|
856
|
-
formatRollbackSummary(
|
|
857
|
-
config,
|
|
858
|
-
backend.destination,
|
|
859
|
-
local,
|
|
860
|
-
remote,
|
|
861
|
-
target,
|
|
862
|
-
protectedSessionPaths(ctx).size
|
|
863
|
-
)
|
|
773
|
+
formatRollbackSummary(config, backend.destination, local, remote, target, protectedSessionPaths(ctx).size)
|
|
864
774
|
)) {
|
|
865
775
|
ctx.ui.notify("Rollback cancelled.", "info");
|
|
866
776
|
return;
|
|
867
777
|
}
|
|
868
778
|
throwIfAborted(options.signal);
|
|
869
|
-
const backup = await backupLocal(
|
|
870
|
-
config.snapshotIdentity,
|
|
871
|
-
snapshotOptionsForContext(ctx, config),
|
|
872
|
-
options.signal
|
|
873
|
-
);
|
|
779
|
+
const backup = await backupLocal(config.snapshotIdentity, snapshotOptionsForContext(ctx, config), options.signal);
|
|
874
780
|
const applySessionDir = await sessionDirForApply(ctx, remote);
|
|
875
781
|
throwIfAborted(options.signal);
|
|
876
782
|
options.onCommit?.();
|
|
@@ -881,15 +787,9 @@ async function rollback(ctx, options, factory = createSyncBackend, expectedSelec
|
|
|
881
787
|
let result;
|
|
882
788
|
try {
|
|
883
789
|
const completionSignal = AbortSignal.timeout(POST_LOCAL_COMMIT_TIMEOUT_MS);
|
|
884
|
-
const upload = await snapshotForUpload(
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
remote,
|
|
888
|
-
expectedHead,
|
|
889
|
-
void 0,
|
|
890
|
-
completionSignal,
|
|
891
|
-
{ ignoreUnreadableRemote: true }
|
|
892
|
-
);
|
|
790
|
+
const upload = await snapshotForUpload(backend, config, remote, expectedHead, void 0, completionSignal, {
|
|
791
|
+
ignoreUnreadableRemote: true
|
|
792
|
+
});
|
|
893
793
|
result = await backend.publishSnapshot(upload, expectedRemoteHead(expectedHead), {
|
|
894
794
|
signal: completionSignal
|
|
895
795
|
});
|
|
@@ -959,18 +859,11 @@ async function confirmPush(ctx, options, config, backend, local, upload, head, r
|
|
|
959
859
|
if (options.yes) return true;
|
|
960
860
|
const confirmed = await ctx.ui.confirm(
|
|
961
861
|
title,
|
|
962
|
-
formatPushSummary(
|
|
963
|
-
config,
|
|
964
|
-
backend.destination,
|
|
965
|
-
upload,
|
|
966
|
-
head,
|
|
967
|
-
countPreservedRemoteFiles(local, upload),
|
|
968
|
-
remote
|
|
969
|
-
)
|
|
862
|
+
formatPushSummary(config, backend.destination, upload, head, countPreservedRemoteFiles(local, upload), remote)
|
|
970
863
|
);
|
|
971
864
|
throwIfAborted(options.signal);
|
|
972
865
|
if (confirmed) return true;
|
|
973
|
-
ctx
|
|
866
|
+
setSyncStatus(ctx, void 0);
|
|
974
867
|
ctx.ui.notify("Push cancelled.", "info");
|
|
975
868
|
return false;
|
|
976
869
|
}
|
|
@@ -993,17 +886,21 @@ async function backupLocal(profile, options = {}, signal) {
|
|
|
993
886
|
}
|
|
994
887
|
|
|
995
888
|
// src/sync/sync-queries.ts
|
|
996
|
-
var STATUS_KEY2 = "sync";
|
|
997
889
|
var DEFAULT_PROFILE = "default";
|
|
998
890
|
async function status(ctx, options, factory = createSyncBackend) {
|
|
999
891
|
const config = await loadConfig(options.setup);
|
|
1000
892
|
throwIfAborted(options.signal);
|
|
1001
|
-
ctx
|
|
1002
|
-
const { head, selectionState, localChanged, remoteChanged, localFiles, destination, capability } = await inspectSync(
|
|
893
|
+
setSyncStatus(ctx, `checking ${config.setupName}`);
|
|
894
|
+
const { head, selectionState, localChanged, remoteChanged, localFiles, destination, capability } = await inspectSync(
|
|
895
|
+
config,
|
|
896
|
+
snapshotOptionsForContext(ctx, config),
|
|
897
|
+
options.signal,
|
|
898
|
+
factory
|
|
899
|
+
);
|
|
1003
900
|
throwIfAborted(options.signal);
|
|
1004
901
|
const remoteText = head ? `remote: ${head.snapshotId} from ${head.machine} at ${head.createdAt}` : "remote: empty";
|
|
1005
902
|
const warnings = syncSessionsWarnings(config);
|
|
1006
|
-
ctx
|
|
903
|
+
setSyncStatus(ctx, void 0);
|
|
1007
904
|
ctx.ui.notify(
|
|
1008
905
|
[
|
|
1009
906
|
`sync setup: ${config.setupName}`,
|
|
@@ -1025,21 +922,15 @@ async function status(ctx, options, factory = createSyncBackend) {
|
|
|
1025
922
|
async function diff(ctx, options, factory = createSyncBackend) {
|
|
1026
923
|
const config = await loadConfig(options.setup);
|
|
1027
924
|
throwIfAborted(options.signal);
|
|
1028
|
-
ctx
|
|
925
|
+
setSyncStatus(ctx, `checking ${config.setupName}`);
|
|
1029
926
|
const backend = await factory(config);
|
|
1030
|
-
const local = await createSnapshot(
|
|
1031
|
-
config.snapshotIdentity,
|
|
1032
|
-
snapshotOptionsForContext(ctx, config)
|
|
1033
|
-
);
|
|
927
|
+
const local = await createSnapshot(config.snapshotIdentity, snapshotOptionsForContext(ctx, config));
|
|
1034
928
|
throwIfAborted(options.signal);
|
|
1035
|
-
const { snapshot: remote, selectionState } = await readRemoteSnapshot(
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
options.signal,
|
|
1039
|
-
{ allowSelectionDifference: true }
|
|
1040
|
-
);
|
|
929
|
+
const { snapshot: remote, selectionState } = await readRemoteSnapshot(backend, config, options.signal, {
|
|
930
|
+
allowSelectionDifference: true
|
|
931
|
+
});
|
|
1041
932
|
throwIfAborted(options.signal);
|
|
1042
|
-
ctx
|
|
933
|
+
setSyncStatus(ctx, void 0);
|
|
1043
934
|
const warnings = syncSessionsWarnings(config);
|
|
1044
935
|
const header = [
|
|
1045
936
|
`sync setup: ${config.setupName}`,
|
|
@@ -1052,12 +943,9 @@ async function diff(ctx, options, factory = createSyncBackend) {
|
|
|
1052
943
|
].join("\n");
|
|
1053
944
|
const level = warnings.length > 0 || selectionState?.kind === "different" ? "warning" : "info";
|
|
1054
945
|
if (!remote) {
|
|
1055
|
-
ctx.ui.notify(
|
|
1056
|
-
`${header}
|
|
946
|
+
ctx.ui.notify(`${header}
|
|
1057
947
|
|
|
1058
|
-
${formatSnapshotOnlyDiff("Remote is empty. Local push would upload", local)}`,
|
|
1059
|
-
level
|
|
1060
|
-
);
|
|
948
|
+
${formatSnapshotOnlyDiff("Remote is empty. Local push would upload", local)}`, level);
|
|
1061
949
|
return;
|
|
1062
950
|
}
|
|
1063
951
|
ctx.ui.notify(`${header}
|
|
@@ -1110,16 +998,12 @@ async function doctor(ctx, options, factory = createSyncBackend) {
|
|
|
1110
998
|
throwIfAborted(options.signal);
|
|
1111
999
|
if (lock.status === "valid" && isStaleLock(lock.lock)) {
|
|
1112
1000
|
level = "warning";
|
|
1113
|
-
messages.push(
|
|
1114
|
-
`lock: stale (pid ${lock.lock.pid}); run /sync unlock --stale after verifying no sync is running`
|
|
1115
|
-
);
|
|
1001
|
+
messages.push(`lock: stale (pid ${lock.lock.pid}); run /sync unlock --stale after verifying no sync is running`);
|
|
1116
1002
|
} else if (lock.status === "valid") {
|
|
1117
1003
|
messages.push(`lock: held by pid ${lock.lock.pid} since ${lock.lock.startedAt}`);
|
|
1118
1004
|
} else if (lock.status === "unreadable") {
|
|
1119
1005
|
level = "warning";
|
|
1120
|
-
messages.push(
|
|
1121
|
-
"lock: unreadable; use /sync unlock --stale only after verifying no sync is running"
|
|
1122
|
-
);
|
|
1006
|
+
messages.push("lock: unreadable; use /sync unlock --stale only after verifying no sync is running");
|
|
1123
1007
|
} else if (await isLockGuardHeld()) {
|
|
1124
1008
|
throwIfAborted(options.signal);
|
|
1125
1009
|
level = "warning";
|
|
@@ -1191,4 +1075,4 @@ export {
|
|
|
1191
1075
|
status,
|
|
1192
1076
|
syncBoth
|
|
1193
1077
|
};
|
|
1194
|
-
//# sourceMappingURL=sync-operations-
|
|
1078
|
+
//# sourceMappingURL=sync-operations-AR76EB6C.ts.map
|