@narumitw/pi-sync 0.67.3 → 0.68.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/CHANGELOG.md +13 -0
- package/README.md +26 -48
- package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
- package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
- package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
- package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
- package/dist/chunks/{chunk-HLJIRWFL.ts → chunk-BCDBT4X3.ts} +7 -7
- package/dist/chunks/{chunk-AVTW6WNP.ts → chunk-FQKWGVMA.ts} +20 -54
- package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
- package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
- package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
- package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
- package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
- package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
- package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
- package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
- package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
- package/dist/chunks/{chunk-X344HTVV.ts → chunk-WCGLU526.ts} +39 -118
- package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
- package/dist/chunks/{chunk-CQ4DMLH3.ts → chunk-WQXUZSY5.ts} +25 -83
- package/dist/chunks/chunk-WQXUZSY5.ts.map +7 -0
- package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
- package/dist/chunks/{command-handler-WF2TDDRZ.ts → command-handler-5LDTCUJE.ts} +64 -59
- package/dist/chunks/command-handler-5LDTCUJE.ts.map +7 -0
- package/dist/chunks/{conflict-review-GWEL4S6C.ts → conflict-review-SZ3AWTX6.ts} +2 -2
- package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
- package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
- package/dist/chunks/{manager-ui-FS4QIKRA.ts → manager-ui-KHMCSLLV.ts} +114 -581
- package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
- package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
- package/dist/chunks/{remote-selection-ui-DOYKUMER.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
- package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
- package/dist/chunks/{setup-wizard-PI45SF2C.ts → setup-wizard-2NRPR433.ts} +11 -16
- package/dist/chunks/{setup-wizard-PI45SF2C.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-DI5J6EUH.ts → sync-inspection-OTI4JDQ2.ts} +5 -5
- package/dist/chunks/{sync-operations-AGNL7QXA.ts → sync-operations-ZUYJLWUN.ts} +2 -2
- package/dist/daemon/dist/build-id.json +1 -1
- package/dist/daemon/dist/cli.js +22 -3
- package/dist/daemon/dist/client-transport.js +2 -0
- package/dist/daemon/dist/client.js +2 -10
- package/dist/daemon/dist/consent.js +13 -135
- package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
- package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
- package/dist/daemon/dist/engine/settings/config.js +16 -149
- package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
- package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
- package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
- package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
- package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
- package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
- package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
- package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
- package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
- package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
- package/dist/daemon/dist/engine/sync/initialization.js +4 -15
- package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
- package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
- package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
- package/dist/daemon/dist/engine/sync/merged-sync.js +12 -70
- package/dist/daemon/dist/engine/sync/push-review.js +1 -16
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
- package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
- package/dist/daemon/dist/engine/sync/sync-mutations.js +25 -118
- package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
- package/dist/daemon/dist/engine/sync/sync-queries.js +81 -65
- package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
- package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
- package/dist/daemon/dist/engine/ui/sync-format.js +1 -1
- package/dist/daemon/dist/engine-service.js +60 -219
- package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
- package/dist/daemon/dist/legacy-consent-guard.js +34 -0
- package/dist/daemon/dist/server.js +4 -8
- package/dist/daemon/dist/service-host.js +4 -10
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +45 -46
- package/dist/index.ts.map +3 -3
- package/docs/continuous-sync-verification.md +1 -1
- package/docs/daemon-migration.md +7 -5
- package/docs/tui-contract.md +4 -6
- package/package.json +2 -3
- package/skills/configure-pi-sync/SKILL.md +18 -77
- package/skills/configure-pi-sync/references/configuration.md +60 -77
- package/src/commands/command-execution.ts +13 -29
- package/src/commands/command-handler.ts +0 -4
- package/src/commands/command.ts +2 -1
- package/src/daemon/directional-recovery.ts +4 -33
- package/src/daemon/pi-client.ts +28 -90
- package/src/settings/config.ts +0 -1
- package/src/sync/setup-switch.ts +1 -4
- package/src/sync-extension.ts +10 -24
- package/src/ui/cancellable-operation.ts +2 -13
- package/src/ui/excluded-paths-ui.ts +1 -4
- package/src/ui/file-selection.ts +0 -5
- package/src/ui/manager-state.ts +12 -75
- package/src/ui/manager-ui.ts +7 -96
- package/src/ui/remote-selection-ui.ts +29 -130
- package/src/ui/settings-ui.ts +169 -388
- package/src/ui/setup/setup-actions.ts +4 -16
- package/src/ui/setup/setup-prompts.ts +12 -49
- package/src/ui/setup/setup-switcher.ts +8 -14
- package/src/ui/storage-connections-ui.ts +21 -32
- package/src/ui/sync-setups-ui.ts +27 -53
- package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
- package/dist/chunks/chunk-33EDXDLC.ts +0 -106
- package/dist/chunks/chunk-33EDXDLC.ts.map +0 -7
- package/dist/chunks/chunk-AVTW6WNP.ts.map +0 -7
- package/dist/chunks/chunk-CQ4DMLH3.ts.map +0 -7
- package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
- package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
- package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
- package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
- package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
- package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
- package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
- package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
- package/dist/chunks/chunk-X344HTVV.ts.map +0 -7
- package/dist/chunks/command-handler-WF2TDDRZ.ts.map +0 -7
- package/dist/chunks/config-P54GGMXY.ts +0 -39
- package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
- package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
- package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
- package/dist/chunks/ignore-file-ui-BEZZZIEE.ts +0 -21
- package/dist/chunks/manager-ui-FS4QIKRA.ts.map +0 -7
- package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
- package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-DOYKUMER.ts.map +0 -7
- package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
- package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
- package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
- package/dist/daemon/dist/monitor.js +0 -344
- package/src/ui/agent-mode-setting.ts +0 -99
- package/src/ui/ignore-file-guidance.ts +0 -7
- package/src/ui/ignore-file-ui.ts +0 -105
- package/src/ui/ignore-migration-prompt.ts +0 -65
- package/src/ui/settings-review.ts +0 -26
- /package/dist/chunks/{chunk-HLJIRWFL.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
- /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
- /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
- /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-GWEL4S6C.ts.map → conflict-review-SZ3AWTX6.ts.map} +0 -0
- /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
- /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-BEZZZIEE.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-DI5J6EUH.ts.map → sync-inspection-OTI4JDQ2.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-AGNL7QXA.ts.map → sync-operations-ZUYJLWUN.ts.map} +0 -0
|
@@ -2,7 +2,7 @@ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
3
|
import { createSyncBackend, type SyncBackendFactory } from "../backends/backend-factory.js";
|
|
4
4
|
import type { RemoteHead, SyncBackend } from "../backends/sync-backend.js";
|
|
5
|
-
import { loadConfig,
|
|
5
|
+
import { loadConfig, syncCheckConfigFingerprint, syncConfigReviewFingerprint } from "../settings/config.js";
|
|
6
6
|
import { SyncSetupReviewChangedError, updateSyncSetup } from "../settings/settings-management.js";
|
|
7
7
|
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
8
8
|
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
compareSyncInclude,
|
|
15
15
|
inspectRemoteSelection,
|
|
16
16
|
type RemoteSelectionDecision,
|
|
17
|
-
RemoteSelectionMismatchError,
|
|
18
17
|
type RemoteSelectionState,
|
|
19
18
|
sameSyncInclude,
|
|
20
19
|
syncDirectoryPolicyKey,
|
|
@@ -34,7 +33,6 @@ export interface RemoteSelectionReviewOptions {
|
|
|
34
33
|
decision?: RemoteSelectionDecision;
|
|
35
34
|
origin?: RemoteSelectionOrigin;
|
|
36
35
|
runRoute?: RunRoute;
|
|
37
|
-
readOnly?: boolean;
|
|
38
36
|
cancelLabel?: string;
|
|
39
37
|
/** The explicit mismatch is resolved or superseded; this does not imply file equality. */
|
|
40
38
|
onSelectionResolved?: () => void;
|
|
@@ -74,33 +72,26 @@ export async function showRemoteSelectionReview(
|
|
|
74
72
|
if (!inspected) return { kind: "stale" };
|
|
75
73
|
// A successful fresh read can supersede an old explicit mismatch without
|
|
76
74
|
// changing local settings. This is not user cancellation or proof of file equality.
|
|
77
|
-
if (inspected.kind === "empty" ||
|
|
75
|
+
if (inspected.kind === "empty" || inspected.state.kind !== "different") {
|
|
78
76
|
options.onSelectionResolved?.();
|
|
79
77
|
}
|
|
80
78
|
if (inspected.kind === "empty") {
|
|
81
79
|
ctx.ui.notify("Remote storage has no snapshot or synced-content list yet.", "info");
|
|
82
80
|
return { kind: "back" };
|
|
83
81
|
}
|
|
84
|
-
if (inspected.kind === "
|
|
85
|
-
|
|
86
|
-
} else if (inspected.state.kind === "same") {
|
|
87
|
-
ctx.ui.notify(
|
|
88
|
-
inspected.state.ignorePolicyComparison === "match"
|
|
89
|
-
? "Remote ignore-file policy matches this device."
|
|
90
|
-
: "Remote synced content already matches this sync setup.",
|
|
91
|
-
"info",
|
|
92
|
-
);
|
|
82
|
+
if (inspected.state.kind === "same") {
|
|
83
|
+
ctx.ui.notify("Remote synced content already matches this sync setup.", "info");
|
|
93
84
|
return { kind: "back" };
|
|
94
|
-
}
|
|
85
|
+
}
|
|
86
|
+
if (inspected.state.kind === "legacy") {
|
|
95
87
|
if (ctx.mode !== "tui") {
|
|
96
88
|
ctx.ui.notify(formatLegacySummary(inspected.config, inspected.state.discovered), "info");
|
|
97
89
|
return { kind: "back" };
|
|
98
90
|
}
|
|
99
91
|
await showLegacyDiscovery(ctx, inspected.config, inspected.state.discovered, signal);
|
|
100
92
|
return signal?.aborted ? { kind: "stale" } : { kind: "back" };
|
|
101
|
-
} else {
|
|
102
|
-
decision = decisionFromState(inspected.config, inspected.state);
|
|
103
93
|
}
|
|
94
|
+
decision = decisionFromState(inspected.config, inspected.state);
|
|
104
95
|
}
|
|
105
96
|
|
|
106
97
|
if (ctx.mode !== "tui") {
|
|
@@ -141,10 +132,6 @@ export async function showRemoteSelectionReview(
|
|
|
141
132
|
ctx.ui.notify("Remote storage no longer has a snapshot or synced-content list.", "warning");
|
|
142
133
|
return { kind: "back" };
|
|
143
134
|
}
|
|
144
|
-
if (refreshed.kind === "decision") {
|
|
145
|
-
currentDecision = refreshed.decision;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
135
|
if (refreshed.state.kind !== "different") {
|
|
149
136
|
ctx.ui.notify(
|
|
150
137
|
refreshed.state.kind === "same"
|
|
@@ -175,23 +162,16 @@ async function showSelectionDifference(
|
|
|
175
162
|
runRoute: RunRoute | undefined,
|
|
176
163
|
sessionSignal: AbortSignal | undefined,
|
|
177
164
|
factory: SyncBackendFactory,
|
|
178
|
-
options: Pick<RemoteSelectionReviewOptions, "
|
|
165
|
+
options: Pick<RemoteSelectionReviewOptions, "cancelLabel" | "onSelectionResolved" | "withStateAccess">,
|
|
179
166
|
validateOwner: () => void,
|
|
180
167
|
): Promise<DifferenceFlowResult> {
|
|
181
168
|
type Screen = "choice" | "review" | "saved";
|
|
182
|
-
type Action = "adopt" | "keep" | "
|
|
169
|
+
type Action = "adopt" | "keep" | "cancel" | "continue" | "done";
|
|
183
170
|
interface FlowState {
|
|
184
171
|
decision: RemoteSelectionDecision;
|
|
185
172
|
saved: boolean;
|
|
186
173
|
}
|
|
187
174
|
const isCurrent = () => isReviewOwnerCurrent(validateOwner);
|
|
188
|
-
const canReviewPull = Boolean(
|
|
189
|
-
runRoute &&
|
|
190
|
-
!options.readOnly &&
|
|
191
|
-
initialDecision.ignorePolicyComparison === "mismatch" &&
|
|
192
|
-
(await (await import("./ignore-file-ui.js")).portableIgnoreRulesAvailable(ctx, sessionSignal)),
|
|
193
|
-
);
|
|
194
|
-
if (!isCurrent()) return { kind: "stale" };
|
|
195
175
|
let flowState: FlowState = { decision: initialDecision, saved: false };
|
|
196
176
|
let continuationFingerprint: string | undefined;
|
|
197
177
|
let nextResult: RemoteSelectionReviewResult | undefined;
|
|
@@ -207,15 +187,11 @@ async function showSelectionDifference(
|
|
|
207
187
|
items: [
|
|
208
188
|
{
|
|
209
189
|
id: "review",
|
|
210
|
-
label:
|
|
211
|
-
|
|
212
|
-
: "Review all paths (recommended)",
|
|
213
|
-
description: state.decision.ignorePolicyComparison
|
|
214
|
-
? "Compare published policy information without adopting rules."
|
|
215
|
-
: "Compare exact remote-only, device-only, and ordered lists.",
|
|
190
|
+
label: "Review all paths (recommended)",
|
|
191
|
+
description: "Compare exact remote-only, device-only, and ordered lists.",
|
|
216
192
|
to: "review",
|
|
217
193
|
},
|
|
218
|
-
...(
|
|
194
|
+
...(adoptionUnavailable(state.decision)
|
|
219
195
|
? []
|
|
220
196
|
: [
|
|
221
197
|
{
|
|
@@ -225,24 +201,12 @@ async function showSelectionDifference(
|
|
|
225
201
|
action: "adopt" as const,
|
|
226
202
|
},
|
|
227
203
|
]),
|
|
228
|
-
...(
|
|
229
|
-
? [
|
|
230
|
-
{
|
|
231
|
-
id: "pull-rules",
|
|
232
|
-
label: "Review pulling the remote rules…",
|
|
233
|
-
description: "Preview overwriting this device's rules and files if the snapshot includes rules.",
|
|
234
|
-
action: "pull-rules" as const,
|
|
235
|
-
},
|
|
236
|
-
]
|
|
237
|
-
: []),
|
|
238
|
-
...(options.readOnly || !canPublishLocalPolicy(state.decision)
|
|
204
|
+
...(scopesDiffer(state.decision)
|
|
239
205
|
? []
|
|
240
206
|
: [
|
|
241
207
|
{
|
|
242
208
|
id: "keep",
|
|
243
|
-
label:
|
|
244
|
-
? "Review publishing this device's policy…"
|
|
245
|
-
: "Keep this device's content list and update remote…",
|
|
209
|
+
label: "Keep this device's content list and update remote…",
|
|
246
210
|
description: "Open the existing exact force-push preview without skipping confirmation.",
|
|
247
211
|
action: "keep" as const,
|
|
248
212
|
},
|
|
@@ -285,7 +249,6 @@ async function showSelectionDifference(
|
|
|
285
249
|
},
|
|
286
250
|
actions: {
|
|
287
251
|
adopt: async ({ state, signal: actionSignal }) => {
|
|
288
|
-
if (options.readOnly) return { kind: "rejected" };
|
|
289
252
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
290
253
|
try {
|
|
291
254
|
const adoption = await runCancellableTask(
|
|
@@ -354,7 +317,7 @@ async function showSelectionDifference(
|
|
|
354
317
|
if (adoption.kind === "cancelled" || !adoption.value) return { kind: "stay" as const };
|
|
355
318
|
validateOwner();
|
|
356
319
|
options.onSelectionResolved?.();
|
|
357
|
-
continuationFingerprint =
|
|
320
|
+
continuationFingerprint = syncCheckConfigFingerprint({
|
|
358
321
|
...adoption.value.config,
|
|
359
322
|
include: [...state.decision.remoteInclude],
|
|
360
323
|
exclude: adoptedExclude(state.decision),
|
|
@@ -375,45 +338,17 @@ async function showSelectionDifference(
|
|
|
375
338
|
return { kind: "stay" as const };
|
|
376
339
|
}
|
|
377
340
|
},
|
|
378
|
-
"pull-rules": async ({ state, signal: actionSignal }) => {
|
|
379
|
-
if (!canReviewPull || !runRoute) return { kind: "rejected" };
|
|
380
|
-
const signal = combineSignals(sessionSignal, actionSignal);
|
|
381
|
-
try {
|
|
382
|
-
const latest = await loadConfig(state.decision.setupName);
|
|
383
|
-
if (signal.aborted) return { kind: "close" };
|
|
384
|
-
validateOwner();
|
|
385
|
-
if (syncConfigReviewFingerprint(latest) !== state.decision.configIdentity) {
|
|
386
|
-
refreshRequested = true;
|
|
387
|
-
return { kind: "close" };
|
|
388
|
-
}
|
|
389
|
-
const result = await runCancellableOperation(ctx, "Preparing remote policy preview…", "pull", runRoute, {
|
|
390
|
-
commitAware: true,
|
|
391
|
-
cancelAcrossDialogs: true,
|
|
392
|
-
target: state.decision.setupName,
|
|
393
|
-
signal,
|
|
394
|
-
});
|
|
395
|
-
return handleNestedRouteResult(result, "pull");
|
|
396
|
-
} catch (error) {
|
|
397
|
-
if (signal.aborted || !isCurrent()) return { kind: "close" };
|
|
398
|
-
ctx.ui.notify(`Could not prepare the local update: ${errorMessage(error)}`, "error");
|
|
399
|
-
return { kind: "stay" };
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
341
|
keep: async ({ state, signal: actionSignal }) => {
|
|
403
|
-
if (options.readOnly) return { kind: "rejected" };
|
|
404
|
-
if (!canPublishLocalPolicy(state.decision)) return { kind: "stay" as const };
|
|
405
342
|
if (!runRoute) {
|
|
406
343
|
ctx.ui.notify("The reviewed update-remote route is unavailable.", "error");
|
|
407
344
|
return { kind: "stay" as const };
|
|
408
345
|
}
|
|
409
346
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
410
347
|
try {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
assertLocalSelectionCurrent(latest, state.decision);
|
|
416
|
-
}
|
|
348
|
+
const latest = await loadConfig(state.decision.setupName);
|
|
349
|
+
if (signal.aborted) return { kind: "close" as const };
|
|
350
|
+
validateOwner();
|
|
351
|
+
assertLocalSelectionCurrent(latest, state.decision);
|
|
417
352
|
const result = await runCancellableOperation(
|
|
418
353
|
ctx,
|
|
419
354
|
"Preparing this device's push preview…",
|
|
@@ -439,14 +374,13 @@ async function showSelectionDifference(
|
|
|
439
374
|
}
|
|
440
375
|
},
|
|
441
376
|
continue: async ({ state, signal: actionSignal }) => {
|
|
442
|
-
if (options.readOnly) return { kind: "rejected" };
|
|
443
377
|
if (!runRoute || !continuationFingerprint) return { kind: "stay" as const };
|
|
444
378
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
445
379
|
try {
|
|
446
380
|
const latest = await loadConfig(state.decision.setupName);
|
|
447
381
|
if (signal.aborted) return { kind: "close" as const };
|
|
448
382
|
validateOwner();
|
|
449
|
-
if (
|
|
383
|
+
if (syncCheckConfigFingerprint(latest) !== continuationFingerprint) {
|
|
450
384
|
throw new StaleRemoteSelectionReviewError(
|
|
451
385
|
`Sync setup “${safeTerminalText(state.decision.setupName)}” changed after the remote content list was saved.`,
|
|
452
386
|
);
|
|
@@ -585,7 +519,6 @@ async function revalidateAndAdopt(
|
|
|
585
519
|
const refusal = adoptionUnavailable(decision);
|
|
586
520
|
if (refusal) throw new Error(refusal);
|
|
587
521
|
const exclude = adoptedExclude(decision);
|
|
588
|
-
if (setup.sync.pathPolicy === "ignore-file") throw new Error("An ignore-file setup cannot adopt remote rules.");
|
|
589
522
|
if (setup.sync.scope === "agent-directory") {
|
|
590
523
|
return {
|
|
591
524
|
...setup,
|
|
@@ -603,7 +536,7 @@ async function revalidateAndAdopt(
|
|
|
603
536
|
};
|
|
604
537
|
},
|
|
605
538
|
{
|
|
606
|
-
expectedConfigFingerprint:
|
|
539
|
+
expectedConfigFingerprint: syncCheckConfigFingerprint(review.config),
|
|
607
540
|
expectedInclude: decision.localInclude,
|
|
608
541
|
upgradeExclude: adoptedExclude(decision) !== undefined,
|
|
609
542
|
signal,
|
|
@@ -620,7 +553,6 @@ async function inspectConfiguredRemoteSelection(
|
|
|
620
553
|
): Promise<
|
|
621
554
|
| { kind: "empty"; config: AnySyncConfig }
|
|
622
555
|
| { kind: "selection"; config: AnySyncConfig; state: RemoteSelectionState }
|
|
623
|
-
| { kind: "decision"; decision: RemoteSelectionDecision }
|
|
624
556
|
| undefined
|
|
625
557
|
> {
|
|
626
558
|
const config = await loadConfig(setupName);
|
|
@@ -634,21 +566,14 @@ async function inspectConfiguredRemoteSelection(
|
|
|
634
566
|
if (signal?.aborted) return undefined;
|
|
635
567
|
validateOwner();
|
|
636
568
|
if (!head) return { kind: "empty", config };
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
};
|
|
646
|
-
} catch (error) {
|
|
647
|
-
if (signal?.aborted) return undefined;
|
|
648
|
-
validateOwner();
|
|
649
|
-
if (error instanceof RemoteSelectionMismatchError) return { kind: "decision", decision: error.decision };
|
|
650
|
-
throw error;
|
|
651
|
-
}
|
|
569
|
+
const snapshot = await readSnapshotForHead(backend, head, signal);
|
|
570
|
+
if (signal?.aborted) return undefined;
|
|
571
|
+
validateOwner();
|
|
572
|
+
return {
|
|
573
|
+
kind: "selection",
|
|
574
|
+
config,
|
|
575
|
+
state: inspectRemoteSelection(config.include, snapshot, config.exclude, config),
|
|
576
|
+
};
|
|
652
577
|
}
|
|
653
578
|
|
|
654
579
|
async function showLegacyDiscovery(
|
|
@@ -711,18 +636,7 @@ function scopesDiffer(decision: RemoteSelectionDecision) {
|
|
|
711
636
|
return decision.localDirectory?.scope !== decision.remoteDirectory?.scope;
|
|
712
637
|
}
|
|
713
638
|
|
|
714
|
-
function canPublishLocalPolicy(decision: RemoteSelectionDecision) {
|
|
715
|
-
if (decision.ignorePolicyComparison) {
|
|
716
|
-
return (
|
|
717
|
-
decision.ignorePolicyComparison !== "match" && decision.ignorePolicyComparison !== "local-legacy-remote-ignore"
|
|
718
|
-
);
|
|
719
|
-
}
|
|
720
|
-
return !scopesDiffer(decision);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
639
|
function adoptionUnavailable(decision: RemoteSelectionDecision) {
|
|
724
|
-
if (decision.ignorePolicyComparison)
|
|
725
|
-
return "A policy comparison does not apply rules. A reviewed Pull can use a snapshot that contains rule text.";
|
|
726
640
|
if (scopesDiffer(decision))
|
|
727
641
|
return "Scope differs. Configure a setup with the remote scope to join it; this location is not migrated in place.";
|
|
728
642
|
if (
|
|
@@ -760,18 +674,6 @@ function directoryReviewLines(decision: RemoteSelectionDecision) {
|
|
|
760
674
|
}
|
|
761
675
|
|
|
762
676
|
function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
763
|
-
if (decision.ignorePolicyComparison) {
|
|
764
|
-
return [
|
|
765
|
-
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
766
|
-
adoptionUnavailable(decision) ?? "Nothing changed.",
|
|
767
|
-
...(decision.ignorePolicyComparison === "local-legacy-remote-ignore"
|
|
768
|
-
? ["The remote uses an ignore-file policy; this device uses a legacy policy."]
|
|
769
|
-
: decision.ignorePolicyComparison === "local-ignore-remote-legacy"
|
|
770
|
-
? ["This device uses an ignore-file policy; the remote uses a legacy policy."]
|
|
771
|
-
: ["The ordered rules or session opt-in differ."]),
|
|
772
|
-
"No files or settings have changed.",
|
|
773
|
-
];
|
|
774
|
-
}
|
|
775
677
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
776
678
|
return [
|
|
777
679
|
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
@@ -789,7 +691,6 @@ function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
|
789
691
|
}
|
|
790
692
|
|
|
791
693
|
function formatSelectionDifference(decision: RemoteSelectionDecision) {
|
|
792
|
-
if (decision.ignorePolicyComparison) return selectionSummaryLines(decision).join("\n");
|
|
793
694
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
794
695
|
return [
|
|
795
696
|
...directoryReviewLines(decision),
|
|
@@ -826,7 +727,6 @@ function formatSelectionDifference(decision: RemoteSelectionDecision) {
|
|
|
826
727
|
}
|
|
827
728
|
|
|
828
729
|
function formatRemoteSelectionSummary(decision: RemoteSelectionDecision) {
|
|
829
|
-
if (decision.ignorePolicyComparison) return selectionSummaryLines(decision).join("\n");
|
|
830
730
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
831
731
|
return [
|
|
832
732
|
`Synced content for “${safeTerminalText(decision.setupName)}” differs from this device.`,
|
|
@@ -869,7 +769,6 @@ function decisionFromState(
|
|
|
869
769
|
return {
|
|
870
770
|
setupName: config.setupName,
|
|
871
771
|
configIdentity: syncConfigReviewFingerprint(config),
|
|
872
|
-
ignorePolicyComparison: state.ignorePolicyComparison,
|
|
873
772
|
localInclude: [...config.include],
|
|
874
773
|
remoteInclude: [...state.include],
|
|
875
774
|
...(config.exclude === undefined ? {} : { localExclude: [...config.exclude] }),
|