@narumitw/pi-sync 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +29 -15
- package/dist/chunks/{chunk-MNYRU5U5.ts → chunk-27F5W7DX.ts} +3 -2
- package/dist/chunks/{chunk-MNYRU5U5.ts.map → chunk-27F5W7DX.ts.map} +2 -2
- package/dist/chunks/chunk-CKUGCBHP.ts +114 -0
- package/dist/chunks/chunk-CKUGCBHP.ts.map +7 -0
- package/dist/chunks/chunk-EJDDRS6O.ts +17 -0
- package/dist/chunks/chunk-EJDDRS6O.ts.map +7 -0
- package/dist/chunks/{chunk-6PFZUEUG.ts → chunk-EXDWEFIJ.ts} +52 -135
- package/dist/chunks/chunk-EXDWEFIJ.ts.map +7 -0
- package/dist/chunks/{chunk-NHFGAZEC.ts → chunk-HSCAFOT5.ts} +7 -7
- package/dist/chunks/chunk-HSCAFOT5.ts.map +7 -0
- package/dist/chunks/chunk-MANNB4WZ.ts +36 -0
- package/dist/chunks/chunk-MANNB4WZ.ts.map +7 -0
- package/dist/chunks/{chunk-ZB3GNX3P.ts → chunk-S6FUUWV5.ts} +139 -12
- package/dist/chunks/chunk-S6FUUWV5.ts.map +7 -0
- package/dist/chunks/{chunk-PWESMTH6.ts → chunk-SXCH4Q5O.ts} +38 -20
- package/dist/chunks/chunk-SXCH4Q5O.ts.map +7 -0
- package/dist/chunks/{chunk-INECVQNR.ts → chunk-UGS6RYDZ.ts} +5 -3
- package/dist/chunks/chunk-UGS6RYDZ.ts.map +7 -0
- package/dist/chunks/{chunk-3E3TR3JE.ts → chunk-V76KCWHO.ts} +6 -4
- package/dist/chunks/{chunk-3E3TR3JE.ts.map → chunk-V76KCWHO.ts.map} +1 -1
- package/dist/chunks/{chunk-GSCZ4VXV.ts → chunk-VQ47JBLF.ts} +2 -2
- package/dist/chunks/chunk-WFBHWYI6.ts +18 -0
- package/dist/chunks/chunk-WFBHWYI6.ts.map +7 -0
- package/dist/chunks/{command-handler-6ATREPG7.ts → command-handler-VINMQ7ZM.ts} +19 -36
- package/dist/chunks/command-handler-VINMQ7ZM.ts.map +7 -0
- package/dist/chunks/{conflict-review-MAOGTIAI.ts → conflict-review-PCDFRIVB.ts} +2 -2
- package/dist/chunks/{file-selection-QR2KZVGD.ts → file-selection-KID23GAD.ts} +15 -8
- package/dist/chunks/file-selection-KID23GAD.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-MC6EQOQY.ts → manager-result-dispatcher-GDB74IOP.ts} +6 -5
- package/dist/chunks/{manager-ui-AOFUNXAJ.ts → manager-ui-YHDECYKI.ts} +197 -322
- package/dist/chunks/manager-ui-YHDECYKI.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-4BTP2OJR.ts → remote-selection-ui-GPITNEBF.ts} +5 -4
- package/dist/chunks/{setup-switch-Y6AMFFNK.ts → setup-switch-L54X5U5I.ts} +4 -4
- package/dist/chunks/{setup-wizard-5G426MOZ.ts → setup-wizard-YO4MCPUF.ts} +7 -3
- package/dist/chunks/{setup-wizard-5G426MOZ.ts.map → setup-wizard-YO4MCPUF.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-ITZ6Z4DE.ts → sync-inspection-H2WX5SUT.ts} +3 -3
- package/dist/chunks/{sync-operations-NMVKF7SE.ts → sync-operations-2MZAYHL2.ts} +2 -2
- package/dist/daemon/dist/cli.js +1 -1
- package/dist/daemon/dist/consent.js +134 -16
- package/dist/daemon/dist/engine/backends/git/git-backend.js +61 -30
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +93 -27
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +85 -14
- package/dist/daemon/dist/engine/settings/config-file.js +1 -1
- package/dist/daemon/dist/engine/settings/config.js +71 -28
- package/dist/daemon/dist/engine/settings/settings-management.js +8 -2
- package/dist/daemon/dist/engine/snapshot/session-paths.js +7 -2
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +37 -17
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +55 -13
- package/dist/daemon/dist/engine/sync/agent-plan.js +1 -0
- package/dist/daemon/dist/engine/sync/agent-sync.js +8 -1
- package/dist/daemon/dist/engine/sync/continuous-sync.js +32 -15
- package/dist/daemon/dist/engine/sync/merge-acceptance.js +29 -0
- package/dist/daemon/dist/engine/sync/merge-apply.js +7 -4
- package/dist/daemon/dist/engine/sync/merge-journal.js +33 -14
- package/dist/daemon/dist/engine/sync/merged-sync.js +31 -39
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +17 -2
- package/dist/daemon/dist/engine/sync/session-push.js +20 -6
- package/dist/daemon/dist/engine/sync/sync-mutations.js +71 -50
- package/dist/daemon/dist/engine/sync/sync-policy.js +28 -3
- package/dist/daemon/dist/engine/sync/sync-state.js +3 -8
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +82 -0
- package/dist/daemon/dist/engine-service.js +124 -27
- package/dist/daemon/dist/monitor.js +84 -32
- package/dist/daemon/dist/server.js +46 -5
- package/dist/daemon/dist/service-host.js +2 -1
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +28 -25
- package/dist/index.ts.map +4 -4
- package/package.json +3 -3
- package/skills/configure-pi-sync/SKILL.md +17 -64
- package/skills/configure-pi-sync/references/configuration.md +60 -20
- package/src/commands/command-execution.ts +12 -8
- package/src/commands/command-types.ts +1 -0
- package/src/daemon/pi-client.ts +4 -2
- package/src/settings/config.ts +1 -0
- package/src/sync/automatic-sync.ts +9 -2
- package/src/sync/setup-switch.ts +38 -15
- package/src/sync/startup-check.ts +7 -4
- package/src/ui/excluded-paths-ui.ts +2 -2
- package/src/ui/file-selection.ts +7 -2
- package/src/ui/ignore-file-guidance.ts +7 -0
- package/src/ui/ignore-file-ui.ts +28 -202
- package/src/ui/manager-state.ts +27 -15
- package/src/ui/manager-ui.ts +4 -1
- package/src/ui/remote-selection-ui.ts +51 -24
- package/src/ui/settings-ui.ts +132 -81
- package/src/ui/setup/setup-actions.ts +16 -4
- package/src/ui/setup/setup-prompts.ts +55 -9
- package/src/ui/setup/setup-switcher.ts +24 -11
- package/src/ui/storage-connections-ui.ts +33 -11
- package/src/ui/sync-setups-ui.ts +24 -7
- package/dist/chunks/chunk-6PFZUEUG.ts.map +0 -7
- package/dist/chunks/chunk-ECYCNZOE.ts +0 -12
- package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
- package/dist/chunks/chunk-INECVQNR.ts.map +0 -7
- package/dist/chunks/chunk-NHFGAZEC.ts.map +0 -7
- package/dist/chunks/chunk-PWESMTH6.ts.map +0 -7
- package/dist/chunks/chunk-ZB3GNX3P.ts.map +0 -7
- package/dist/chunks/command-handler-6ATREPG7.ts.map +0 -7
- package/dist/chunks/file-selection-QR2KZVGD.ts.map +0 -7
- package/dist/chunks/manager-ui-AOFUNXAJ.ts.map +0 -7
- /package/dist/chunks/{chunk-GSCZ4VXV.ts.map → chunk-VQ47JBLF.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-MAOGTIAI.ts.map → conflict-review-PCDFRIVB.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-MC6EQOQY.ts.map → manager-result-dispatcher-GDB74IOP.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-4BTP2OJR.ts.map → remote-selection-ui-GPITNEBF.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-Y6AMFFNK.ts.map → setup-switch-L54X5U5I.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-ITZ6Z4DE.ts.map → sync-inspection-H2WX5SUT.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-NMVKF7SE.ts.map → sync-operations-2MZAYHL2.ts.map} +0 -0
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
runCancellableOperation,
|
|
5
|
+
runCancellableTask
|
|
6
|
+
} from "./chunk-CKUGCBHP.ts";
|
|
3
7
|
import {
|
|
4
8
|
throwIfAborted
|
|
5
9
|
} from "./chunk-UMPA5S7X.ts";
|
|
6
|
-
import {
|
|
7
|
-
captureMutationOwner
|
|
8
|
-
} from "./chunk-GELYN4UC.ts";
|
|
9
10
|
import {
|
|
10
11
|
SyncSetupReviewChangedError,
|
|
11
12
|
updateSyncSetup
|
|
12
13
|
} from "./chunk-NXWHPVXR.ts";
|
|
14
|
+
import {
|
|
15
|
+
captureMutationOwner
|
|
16
|
+
} from "./chunk-GELYN4UC.ts";
|
|
13
17
|
import {
|
|
14
18
|
sameSyncExclude
|
|
15
19
|
} from "./chunk-ZO52JM4H.ts";
|
|
16
20
|
import {
|
|
17
21
|
loadConfig,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
syncConfigReviewFingerprint,
|
|
23
|
+
syncSettingsConfigFingerprint
|
|
24
|
+
} from "./chunk-27F5W7DX.ts";
|
|
21
25
|
import {
|
|
22
26
|
setSyncStatus
|
|
23
27
|
} from "./chunk-H7VOTY5N.ts";
|
|
@@ -25,6 +29,7 @@ import {
|
|
|
25
29
|
errorMessage
|
|
26
30
|
} from "./chunk-6YKOHBSC.ts";
|
|
27
31
|
import {
|
|
32
|
+
RemoteSelectionMismatchError,
|
|
28
33
|
compareSyncInclude,
|
|
29
34
|
inspectRemoteSelection,
|
|
30
35
|
sameSyncInclude,
|
|
@@ -48,112 +53,6 @@ import {
|
|
|
48
53
|
requireCompatibleRemoteSelection
|
|
49
54
|
} from "#pi-sync-daemon/engine/sync/remote-snapshot";
|
|
50
55
|
|
|
51
|
-
// src/ui/cancellable-operation.ts
|
|
52
|
-
import { BorderedLoader } from "@earendil-works/pi-coding-agent";
|
|
53
|
-
import { isKeyRelease, Key, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
|
|
54
|
-
import { formatInteractionHints, runCustomInteraction } from "@narumitw/pi-tui-kit";
|
|
55
|
-
async function runCancellableOperation(ctx, message, route, runRoute, options = {}) {
|
|
56
|
-
const result = await runCancellableTask(
|
|
57
|
-
ctx,
|
|
58
|
-
message,
|
|
59
|
-
(signal, onCommit, onDialog) => runRoute(route, signal, onCommit, options.target, onDialog),
|
|
60
|
-
options
|
|
61
|
-
);
|
|
62
|
-
return result.kind === "completed" ? result.value ?? { kind: "failed" } : result;
|
|
63
|
-
}
|
|
64
|
-
async function runCancellableTask(ctx, message, task, options = {}) {
|
|
65
|
-
const {
|
|
66
|
-
commitAware = false,
|
|
67
|
-
cancelAcrossDialogs = false,
|
|
68
|
-
cancelledMessage = "Check cancelled; no settings or files were changed.",
|
|
69
|
-
signal,
|
|
70
|
-
isCurrent = () => true
|
|
71
|
-
} = options;
|
|
72
|
-
if (signal?.aborted || !isCurrent()) return { kind: "closed" };
|
|
73
|
-
if (ctx.mode !== "tui") return { kind: "completed", value: await task(signal) };
|
|
74
|
-
let commitStarted = false;
|
|
75
|
-
let taskResult;
|
|
76
|
-
const interaction = await runCustomInteraction(ctx, {
|
|
77
|
-
signal,
|
|
78
|
-
isCurrent: () => !signal?.aborted && isCurrent(),
|
|
79
|
-
create: ({ tui, theme, keybindings, signal: interactionSignal, complete }) => {
|
|
80
|
-
const loader = new BorderedLoader(tui, theme, message, { cancellable: false });
|
|
81
|
-
const cancelHint = formatInteractionHints(keybindings, [
|
|
82
|
-
{
|
|
83
|
-
keys: [...keybindings.getKeys("tui.select.cancel").filter((key) => !hasControlCharacter(key)), "ctrl+c"],
|
|
84
|
-
label: "cancel"
|
|
85
|
-
}
|
|
86
|
-
]);
|
|
87
|
-
const cancel = (data) => {
|
|
88
|
-
if (isKeyRelease(data)) return false;
|
|
89
|
-
if (!matchesKey(data, Key.ctrl("c")) && !keybindings.matches(data, "tui.select.cancel")) return false;
|
|
90
|
-
if (commitStarted) {
|
|
91
|
-
ctx.ui.notify("Applying or publishing has started and cannot be cancelled safely.", "warning");
|
|
92
|
-
} else complete({ cancelled: true });
|
|
93
|
-
return true;
|
|
94
|
-
};
|
|
95
|
-
let activeDialogs = 0;
|
|
96
|
-
const unsubscribe = cancelAcrossDialogs ? ctx.ui.onTerminalInput((data) => {
|
|
97
|
-
if (isKeyRelease(data)) return;
|
|
98
|
-
if (activeDialogs > 0 && !matchesKey(data, Key.ctrl("c"))) return;
|
|
99
|
-
return cancel(data) ? { consume: true } : void 0;
|
|
100
|
-
}) : void 0;
|
|
101
|
-
let pendingTask;
|
|
102
|
-
try {
|
|
103
|
-
pendingTask = task(
|
|
104
|
-
interactionSignal,
|
|
105
|
-
commitAware ? () => commitStarted = true : void 0,
|
|
106
|
-
cancelAcrossDialogs ? (active) => {
|
|
107
|
-
activeDialogs += active ? 1 : -1;
|
|
108
|
-
} : void 0
|
|
109
|
-
);
|
|
110
|
-
} catch (error) {
|
|
111
|
-
unsubscribe?.();
|
|
112
|
-
loader.dispose();
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
const operation = pendingTask.then(
|
|
116
|
-
(result) => {
|
|
117
|
-
taskResult = result;
|
|
118
|
-
complete({});
|
|
119
|
-
},
|
|
120
|
-
(error) => complete({ error })
|
|
121
|
-
);
|
|
122
|
-
return {
|
|
123
|
-
render(width) {
|
|
124
|
-
if (width <= 0) return [];
|
|
125
|
-
const safeWidth = Math.max(1, width);
|
|
126
|
-
const lines = loader.render(safeWidth);
|
|
127
|
-
const bottomBorder = lines.at(-1);
|
|
128
|
-
return [
|
|
129
|
-
...lines.slice(0, -1),
|
|
130
|
-
truncateToWidth(theme.fg("dim", cancelHint), safeWidth, ""),
|
|
131
|
-
...bottomBorder === void 0 ? [] : [bottomBorder]
|
|
132
|
-
];
|
|
133
|
-
},
|
|
134
|
-
invalidate: () => loader.invalidate(),
|
|
135
|
-
handleInput: cancel,
|
|
136
|
-
dispose() {
|
|
137
|
-
unsubscribe?.();
|
|
138
|
-
loader.dispose();
|
|
139
|
-
},
|
|
140
|
-
waitForPending: () => operation
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
if (interaction.kind === "error") throw interaction.error;
|
|
145
|
-
if (interaction.kind !== "completed") return { kind: "closed" };
|
|
146
|
-
if (interaction.value.cancelled) {
|
|
147
|
-
if (cancelledMessage) ctx.ui.notify(cancelledMessage, "info");
|
|
148
|
-
return { kind: "cancelled" };
|
|
149
|
-
}
|
|
150
|
-
if (interaction.value.error) throw interaction.value.error;
|
|
151
|
-
return { kind: "completed", value: taskResult };
|
|
152
|
-
}
|
|
153
|
-
function hasControlCharacter(value) {
|
|
154
|
-
return /[\u0000-\u001f\u007f-\u009f]/u.test(value);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
56
|
// src/ui/remote-selection-ui.ts
|
|
158
57
|
async function showRemoteSelectionReview(ctx, setupName, signal, factory = createSyncBackend, options = {}) {
|
|
159
58
|
const validateOwner = captureMutationOwner(ctx, signal);
|
|
@@ -173,26 +72,31 @@ async function showRemoteSelectionReview(ctx, setupName, signal, factory = creat
|
|
|
173
72
|
validateOwner();
|
|
174
73
|
const inspected = inspection.value;
|
|
175
74
|
if (!inspected) return { kind: "stale" };
|
|
176
|
-
if (inspected.kind === "empty" || inspected.state.kind !== "different") {
|
|
75
|
+
if (inspected.kind === "empty" || inspected.kind === "selection" && inspected.state.kind !== "different") {
|
|
177
76
|
options.onSelectionResolved?.();
|
|
178
77
|
}
|
|
179
78
|
if (inspected.kind === "empty") {
|
|
180
79
|
ctx.ui.notify("Remote storage has no snapshot or synced-content list yet.", "info");
|
|
181
80
|
return { kind: "back" };
|
|
182
81
|
}
|
|
183
|
-
if (inspected.
|
|
184
|
-
|
|
82
|
+
if (inspected.kind === "decision") {
|
|
83
|
+
decision = inspected.decision;
|
|
84
|
+
} else if (inspected.state.kind === "same") {
|
|
85
|
+
ctx.ui.notify(
|
|
86
|
+
inspected.state.ignorePolicyComparison === "match" ? "Remote ignore-file policy matches this device." : "Remote synced content already matches this sync setup.",
|
|
87
|
+
"info"
|
|
88
|
+
);
|
|
185
89
|
return { kind: "back" };
|
|
186
|
-
}
|
|
187
|
-
if (inspected.state.kind === "legacy") {
|
|
90
|
+
} else if (inspected.state.kind === "legacy") {
|
|
188
91
|
if (ctx.mode !== "tui") {
|
|
189
92
|
ctx.ui.notify(formatLegacySummary(inspected.config, inspected.state.discovered), "info");
|
|
190
93
|
return { kind: "back" };
|
|
191
94
|
}
|
|
192
95
|
await showLegacyDiscovery(ctx, inspected.config, inspected.state.discovered, signal);
|
|
193
96
|
return signal?.aborted ? { kind: "stale" } : { kind: "back" };
|
|
97
|
+
} else {
|
|
98
|
+
decision = decisionFromState(inspected.config, inspected.state);
|
|
194
99
|
}
|
|
195
|
-
decision = decisionFromState(inspected.config, inspected.state);
|
|
196
100
|
}
|
|
197
101
|
if (ctx.mode !== "tui") {
|
|
198
102
|
ctx.ui.notify(formatRemoteSelectionSummary(decision), "warning");
|
|
@@ -231,6 +135,10 @@ async function showRemoteSelectionReview(ctx, setupName, signal, factory = creat
|
|
|
231
135
|
ctx.ui.notify("Remote storage no longer has a snapshot or synced-content list.", "warning");
|
|
232
136
|
return { kind: "back" };
|
|
233
137
|
}
|
|
138
|
+
if (refreshed.kind === "decision") {
|
|
139
|
+
currentDecision = refreshed.decision;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
234
142
|
if (refreshed.state.kind !== "different") {
|
|
235
143
|
ctx.ui.notify(
|
|
236
144
|
refreshed.state.kind === "same" ? "Remote synced content now matches this sync setup." : "The refreshed legacy snapshot has no authoritative synced-content list.",
|
|
@@ -270,7 +178,7 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
270
178
|
description: state.decision.ignorePolicyComparison ? "Compare published policy information without adopting rules." : "Compare exact remote-only, device-only, and ordered lists.",
|
|
271
179
|
to: "review"
|
|
272
180
|
},
|
|
273
|
-
...adoptionUnavailable(state.decision) ? [] : [
|
|
181
|
+
...options.readOnly || adoptionUnavailable(state.decision) ? [] : [
|
|
274
182
|
{
|
|
275
183
|
id: "adopt",
|
|
276
184
|
label: "Use remote content list",
|
|
@@ -278,7 +186,7 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
278
186
|
action: "adopt"
|
|
279
187
|
}
|
|
280
188
|
],
|
|
281
|
-
|
|
189
|
+
...options.readOnly || !canPublishLocalPolicy(state.decision) ? [] : [
|
|
282
190
|
{
|
|
283
191
|
id: "keep",
|
|
284
192
|
label: state.decision.ignorePolicyComparison ? "Review publishing this device's policy\u2026" : "Keep this device's content list and update remote\u2026",
|
|
@@ -322,6 +230,7 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
322
230
|
},
|
|
323
231
|
actions: {
|
|
324
232
|
adopt: async ({ state, signal: actionSignal }) => {
|
|
233
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
325
234
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
326
235
|
try {
|
|
327
236
|
const adoption = await runCancellableTask(
|
|
@@ -386,7 +295,7 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
386
295
|
if (adoption.kind === "cancelled" || !adoption.value) return { kind: "stay" };
|
|
387
296
|
validateOwner();
|
|
388
297
|
options.onSelectionResolved?.();
|
|
389
|
-
continuationFingerprint =
|
|
298
|
+
continuationFingerprint = syncSettingsConfigFingerprint({
|
|
390
299
|
...adoption.value.config,
|
|
391
300
|
include: [...state.decision.remoteInclude],
|
|
392
301
|
exclude: adoptedExclude(state.decision),
|
|
@@ -406,6 +315,7 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
406
315
|
}
|
|
407
316
|
},
|
|
408
317
|
keep: async ({ state, signal: actionSignal }) => {
|
|
318
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
409
319
|
if (!canPublishLocalPolicy(state.decision)) return { kind: "stay" };
|
|
410
320
|
if (!runRoute) {
|
|
411
321
|
ctx.ui.notify("The reviewed update-remote route is unavailable.", "error");
|
|
@@ -444,13 +354,14 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
444
354
|
}
|
|
445
355
|
},
|
|
446
356
|
continue: async ({ state, signal: actionSignal }) => {
|
|
357
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
447
358
|
if (!runRoute || !continuationFingerprint) return { kind: "stay" };
|
|
448
359
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
449
360
|
try {
|
|
450
361
|
const latest = await loadConfig(state.decision.setupName);
|
|
451
362
|
if (signal.aborted) return { kind: "close" };
|
|
452
363
|
validateOwner();
|
|
453
|
-
if (
|
|
364
|
+
if (syncSettingsConfigFingerprint(latest) !== continuationFingerprint) {
|
|
454
365
|
throw new StaleRemoteSelectionReviewError(
|
|
455
366
|
`Sync setup \u201C${safeTerminalText(state.decision.setupName)}\u201D changed after the remote content list was saved.`
|
|
456
367
|
);
|
|
@@ -570,7 +481,7 @@ async function revalidateAndAdopt(review, decision, signal, validateOwner) {
|
|
|
570
481
|
};
|
|
571
482
|
},
|
|
572
483
|
{
|
|
573
|
-
expectedConfigFingerprint:
|
|
484
|
+
expectedConfigFingerprint: syncSettingsConfigFingerprint(review.config),
|
|
574
485
|
expectedInclude: decision.localInclude,
|
|
575
486
|
upgradeExclude: adoptedExclude(decision) !== void 0,
|
|
576
487
|
signal
|
|
@@ -589,14 +500,21 @@ async function inspectConfiguredRemoteSelection(ctx, setupName, signal, factory,
|
|
|
589
500
|
if (signal?.aborted) return void 0;
|
|
590
501
|
validateOwner();
|
|
591
502
|
if (!head) return { kind: "empty", config };
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
503
|
+
try {
|
|
504
|
+
const snapshot = await readSnapshotForHead(backend, head, signal, config);
|
|
505
|
+
if (signal?.aborted) return void 0;
|
|
506
|
+
validateOwner();
|
|
507
|
+
return {
|
|
508
|
+
kind: "selection",
|
|
509
|
+
config,
|
|
510
|
+
state: inspectRemoteSelection(config.include, snapshot, config.exclude, config)
|
|
511
|
+
};
|
|
512
|
+
} catch (error) {
|
|
513
|
+
if (signal?.aborted) return void 0;
|
|
514
|
+
validateOwner();
|
|
515
|
+
if (error instanceof RemoteSelectionMismatchError) return { kind: "decision", decision: error.decision };
|
|
516
|
+
throw error;
|
|
517
|
+
}
|
|
600
518
|
}
|
|
601
519
|
async function showLegacyDiscovery(ctx, config, discovered, signal) {
|
|
602
520
|
const menu = defineMenu({
|
|
@@ -681,7 +599,8 @@ function selectionSummaryLines(decision) {
|
|
|
681
599
|
return [
|
|
682
600
|
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
683
601
|
adoptionUnavailable(decision) ?? "Nothing changed.",
|
|
684
|
-
decision.ignorePolicyComparison === "local-legacy-remote-ignore" ? "The remote uses an ignore policy
|
|
602
|
+
...decision.ignorePolicyComparison === "local-legacy-remote-ignore" ? ["The remote uses an ignore-file policy; this device uses a legacy policy."] : decision.ignorePolicyComparison === "local-ignore-remote-legacy" ? ["This device uses an ignore-file policy; the remote uses a legacy policy."] : ["The ordered rules or session opt-in differ."],
|
|
603
|
+
"No files or settings have changed."
|
|
685
604
|
];
|
|
686
605
|
}
|
|
687
606
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
@@ -811,8 +730,6 @@ function combineSignals(sessionSignal, actionSignal) {
|
|
|
811
730
|
}
|
|
812
731
|
|
|
813
732
|
export {
|
|
814
|
-
runCancellableOperation,
|
|
815
|
-
runCancellableTask,
|
|
816
733
|
showRemoteSelectionReview
|
|
817
734
|
};
|
|
818
|
-
//# sourceMappingURL=chunk-
|
|
735
|
+
//# sourceMappingURL=chunk-EXDWEFIJ.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/remote-selection-ui.ts", "../../src/backends/backend-factory.ts", "../../src/sync/remote-snapshot.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { defineMenu, runMenu } from \"@narumitw/pi-tui-kit\";\nimport { createSyncBackend, type SyncBackendFactory } from \"../backends/backend-factory.js\";\nimport type { RemoteHead, SyncBackend } from \"../backends/sync-backend.js\";\nimport { loadConfig, syncConfigReviewFingerprint, syncSettingsConfigFingerprint } from \"../settings/config.js\";\nimport { SyncSetupReviewChangedError, updateSyncSetup } from \"../settings/settings-management.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { sameSyncExclude } from \"../sync/exclude-policy.js\";\nimport { readSnapshotForHead } from \"../sync/remote-snapshot.js\";\nimport { throwIfAborted } from \"../sync/signals.js\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\nimport { captureMutationOwner } from \"../sync/sync-local.js\";\nimport {\n compareSyncInclude,\n inspectRemoteSelection,\n type RemoteSelectionDecision,\n RemoteSelectionMismatchError,\n type RemoteSelectionState,\n sameSyncInclude,\n syncDirectoryPolicyKey,\n} from \"../sync/sync-policy.js\";\nimport {\n type RunRoute,\n type RunRouteResult,\n runCancellableOperation,\n runCancellableTask,\n} from \"./cancellable-operation.js\";\nimport { setSyncStatus } from \"./sync-status.js\";\nimport { safeTerminalText } from \"./terminal-text.js\";\n\nexport type RemoteSelectionOrigin = \"settings\" | \"sync\" | \"pull\" | \"push\";\n\nexport interface RemoteSelectionReviewOptions {\n decision?: RemoteSelectionDecision;\n origin?: RemoteSelectionOrigin;\n runRoute?: RunRoute;\n readOnly?: boolean;\n cancelLabel?: string;\n /** The explicit mismatch is resolved or superseded; this does not imply file equality. */\n onSelectionResolved?: () => void;\n withStateAccess?: <T>(task: () => Promise<T>) => Promise<T>;\n}\n\nexport type RemoteSelectionReviewResult =\n | { kind: \"back\" }\n | { kind: \"closed\" }\n | { kind: \"done\" }\n | { kind: \"stale\" }\n | { kind: \"route-result\"; result: RunRouteResult; route: \"sync\" | \"pull\" | \"push\" };\n\nexport async function showRemoteSelectionReview(\n ctx: ExtensionContext,\n setupName?: string,\n signal?: AbortSignal,\n factory: SyncBackendFactory = createSyncBackend,\n options: RemoteSelectionReviewOptions = {},\n): Promise<RemoteSelectionReviewResult> {\n const validateOwner = captureMutationOwner(ctx, signal);\n const isCurrent = () => isReviewOwnerCurrent(validateOwner);\n try {\n validateOwner();\n let decision = options.decision;\n if (!decision) {\n const inspection = await runCancellableTask(\n ctx,\n \"Checking remote content list\u2026\",\n (workSignal) => inspectConfiguredRemoteSelection(ctx, setupName, workSignal, factory, validateOwner),\n { signal, isCurrent, cancelledMessage: null },\n );\n if (!isCurrent()) return { kind: \"stale\" };\n if (inspection.kind !== \"completed\") return { kind: inspection.kind === \"cancelled\" ? \"back\" : \"closed\" };\n validateOwner();\n const inspected = inspection.value;\n if (!inspected) return { kind: \"stale\" };\n // A successful fresh read can supersede an old explicit mismatch without\n // changing local settings. This is not user cancellation or proof of file equality.\n if (inspected.kind === \"empty\" || (inspected.kind === \"selection\" && inspected.state.kind !== \"different\")) {\n options.onSelectionResolved?.();\n }\n if (inspected.kind === \"empty\") {\n ctx.ui.notify(\"Remote storage has no snapshot or synced-content list yet.\", \"info\");\n return { kind: \"back\" };\n }\n if (inspected.kind === \"decision\") {\n decision = inspected.decision;\n } else if (inspected.state.kind === \"same\") {\n ctx.ui.notify(\n inspected.state.ignorePolicyComparison === \"match\"\n ? \"Remote ignore-file policy matches this device.\"\n : \"Remote synced content already matches this sync setup.\",\n \"info\",\n );\n return { kind: \"back\" };\n } else if (inspected.state.kind === \"legacy\") {\n if (ctx.mode !== \"tui\") {\n ctx.ui.notify(formatLegacySummary(inspected.config, inspected.state.discovered), \"info\");\n return { kind: \"back\" };\n }\n await showLegacyDiscovery(ctx, inspected.config, inspected.state.discovered, signal);\n return signal?.aborted ? { kind: \"stale\" } : { kind: \"back\" };\n } else {\n decision = decisionFromState(inspected.config, inspected.state);\n }\n }\n\n if (ctx.mode !== \"tui\") {\n ctx.ui.notify(formatRemoteSelectionSummary(decision), \"warning\");\n return { kind: \"back\" };\n }\n\n let currentDecision = decision;\n for (;;) {\n if (signal?.aborted) return { kind: \"stale\" };\n const result = await showSelectionDifference(\n ctx,\n currentDecision,\n options.origin ?? \"settings\",\n options.runRoute,\n signal,\n factory,\n options,\n validateOwner,\n );\n if (result.kind !== \"refresh\") return result;\n const refresh = await runCancellableTask(\n ctx,\n \"Refreshing remote content list\u2026\",\n (workSignal) =>\n runWithOptionalStateAccess(options, () =>\n inspectConfiguredRemoteSelection(ctx, currentDecision.setupName, workSignal, factory, validateOwner),\n ),\n { signal, isCurrent, cancelledMessage: null },\n );\n if (!isCurrent()) return { kind: \"stale\" };\n if (refresh.kind !== \"completed\") return { kind: refresh.kind === \"cancelled\" ? \"back\" : \"closed\" };\n validateOwner();\n const refreshed = refresh.value;\n if (!refreshed) return { kind: \"stale\" };\n if (refreshed.kind === \"empty\") {\n options.onSelectionResolved?.();\n ctx.ui.notify(\"Remote storage no longer has a snapshot or synced-content list.\", \"warning\");\n return { kind: \"back\" };\n }\n if (refreshed.kind === \"decision\") {\n currentDecision = refreshed.decision;\n continue;\n }\n if (refreshed.state.kind !== \"different\") {\n ctx.ui.notify(\n refreshed.state.kind === \"same\"\n ? \"Remote synced content now matches this sync setup.\"\n : \"The refreshed legacy snapshot has no authoritative synced-content list.\",\n \"info\",\n );\n options.onSelectionResolved?.();\n return { kind: \"done\" };\n }\n currentDecision = decisionFromState(refreshed.config, refreshed.state);\n }\n } catch (error) {\n if (!isCurrent()) return { kind: \"stale\" };\n ctx.ui.notify(`Could not review synced content: ${errorMessage(error)}`, \"error\");\n return { kind: \"back\" };\n } finally {\n if (isCurrent()) setSyncStatus(ctx, undefined);\n }\n}\n\ntype DifferenceFlowResult = RemoteSelectionReviewResult | { kind: \"refresh\" };\n\nasync function showSelectionDifference(\n ctx: ExtensionContext,\n initialDecision: RemoteSelectionDecision,\n origin: RemoteSelectionOrigin,\n runRoute: RunRoute | undefined,\n sessionSignal: AbortSignal | undefined,\n factory: SyncBackendFactory,\n options: Pick<RemoteSelectionReviewOptions, \"readOnly\" | \"cancelLabel\" | \"onSelectionResolved\" | \"withStateAccess\">,\n validateOwner: () => void,\n): Promise<DifferenceFlowResult> {\n type Screen = \"choice\" | \"review\" | \"saved\";\n type Action = \"adopt\" | \"keep\" | \"cancel\" | \"continue\" | \"done\";\n interface FlowState {\n decision: RemoteSelectionDecision;\n saved: boolean;\n }\n const isCurrent = () => isReviewOwnerCurrent(validateOwner);\n let flowState: FlowState = { decision: initialDecision, saved: false };\n let continuationFingerprint: string | undefined;\n let nextResult: RemoteSelectionReviewResult | undefined;\n let refreshRequested = false;\n const route = origin === \"settings\" ? \"sync\" : origin;\n const menu = defineMenu<FlowState, Screen, Action, ExtensionContext>({\n start: \"choice\",\n screens: {\n choice: ({ state }) => ({\n kind: \"actions\",\n title: \"Synced content differs\",\n lines: selectionSummaryLines(state.decision),\n items: [\n {\n id: \"review\",\n label: state.decision.ignorePolicyComparison\n ? \"Review policy difference\"\n : \"Review all paths (recommended)\",\n description: state.decision.ignorePolicyComparison\n ? \"Compare published policy information without adopting rules.\"\n : \"Compare exact remote-only, device-only, and ordered lists.\",\n to: \"review\",\n },\n ...(options.readOnly || adoptionUnavailable(state.decision)\n ? []\n : [\n {\n id: \"adopt\",\n label: \"Use remote content list\",\n description: \"Save the reviewed rules on this device without pulling files.\",\n action: \"adopt\" as const,\n },\n ]),\n ...(options.readOnly || !canPublishLocalPolicy(state.decision)\n ? []\n : [\n {\n id: \"keep\",\n label: state.decision.ignorePolicyComparison\n ? \"Review publishing this device's policy\u2026\"\n : \"Keep this device's content list and update remote\u2026\",\n description: \"Open the existing exact force-push preview without skipping confirmation.\",\n action: \"keep\" as const,\n },\n ]),\n { id: \"cancel\", label: options.cancelLabel ?? \"Cancel\", action: \"cancel\" },\n ],\n hint: \"back\",\n }),\n review: ({ state }) => ({\n kind: \"review\",\n title: `Review synced content \u00B7 ${safeTerminalText(state.decision.setupName)}`,\n content: formatSelectionDifference(state.decision),\n format: { kind: \"text\" },\n viewportSize: \"adaptive\",\n hint: \"back\",\n }),\n saved: ({ state }) => ({\n kind: \"actions\",\n title: \"Remote content list saved\",\n lines: [\n `Sync setup: ${safeTerminalText(state.decision.setupName)}`,\n \"Only the included-content setting was saved.\",\n \"No files were pulled and sync state was not changed.\",\n ],\n items: [\n ...(runRoute\n ? [\n {\n id: \"continue\",\n label: continueLabel(origin),\n description: \"Start a fresh check and exact preview for this sync setup.\",\n action: \"continue\" as const,\n },\n ]\n : []),\n { id: \"done\", label: \"Done\", action: \"done\" },\n ],\n hint: \"close\",\n }),\n },\n actions: {\n adopt: async ({ state, signal: actionSignal }) => {\n if (options.readOnly) return { kind: \"rejected\" };\n const signal = combineSignals(sessionSignal, actionSignal);\n try {\n const adoption = await runCancellableTask(\n ctx,\n \"Checking and saving remote content list\u2026\",\n async (workSignal, _onCommit, onDialog) => {\n const ownedSignal = workSignal ?? signal;\n const currentConfig = await loadConfig(state.decision.setupName);\n ownedSignal.throwIfAborted();\n validateOwner();\n assertLocalSelectionCurrent(currentConfig, state.decision);\n const refusal = adoptionUnavailable(state.decision);\n if (refusal) throw new Error(refusal);\n if (!currentConfig.include.includes(\"sessions\") && state.decision.remoteInclude.includes(\"sessions\")) {\n onDialog?.(true);\n let acknowledged: boolean;\n try {\n acknowledged = await ctx.ui.confirm(\n \"Use a content list that includes session conversations?\",\n \"Session JSONL may contain prompts, tool output, file paths, images, and secrets. This saves the list only; it does not pull files.\",\n { signal: ownedSignal },\n );\n } finally {\n onDialog?.(false);\n }\n ownedSignal.throwIfAborted();\n validateOwner();\n if (!acknowledged) return undefined;\n }\n if (\n !currentConfig.scope &&\n state.decision.remoteExclude !== undefined &&\n currentConfig.exclude === undefined\n ) {\n onDialog?.(true);\n let confirmed: boolean;\n try {\n confirmed = await ctx.ui.confirm(\n \"Adopt excluded paths?\",\n \"This upgrades settings to version 6 / snapshots to version 4. Older clients must refuse them. Both content lists are saved; no files transfer and old history is not erased.\",\n { signal: ownedSignal },\n );\n } finally {\n onDialog?.(false);\n }\n ownedSignal.throwIfAborted();\n validateOwner();\n if (!confirmed) return undefined;\n }\n return runWithOptionalStateAccess(options, async () => {\n const loaded = await loadAdoptionReview(state.decision, ownedSignal, factory, validateOwner);\n ownedSignal.throwIfAborted();\n validateOwner();\n await revalidateAndAdopt(loaded, state.decision, ownedSignal, validateOwner);\n return loaded;\n });\n },\n {\n signal,\n isCurrent,\n cancelAcrossDialogs: true,\n cancelledMessage: \"Remote content-list adoption cancelled.\",\n },\n );\n if (signal.aborted || adoption.kind === \"closed\") return { kind: \"close\" as const };\n if (adoption.kind === \"cancelled\" || !adoption.value) return { kind: \"stay\" as const };\n validateOwner();\n options.onSelectionResolved?.();\n continuationFingerprint = syncSettingsConfigFingerprint({\n ...adoption.value.config,\n include: [...state.decision.remoteInclude],\n exclude: adoptedExclude(state.decision),\n ...(adoption.value.config.scope\n ? { reinclude: [...(state.decision.remoteDirectory?.reinclude ?? [])] }\n : {}),\n });\n flowState = { decision: state.decision, saved: true };\n return { kind: \"to\" as const, screen: \"saved\" as const };\n } catch (error) {\n if (signal.aborted || !isCurrent()) return { kind: \"close\" as const };\n if (isStaleReviewError(error)) {\n ctx.ui.notify(`${errorMessage(error)} Refreshing the comparison.`, \"warning\");\n refreshRequested = true;\n return { kind: \"close\" as const };\n }\n ctx.ui.notify(`Could not save the remote content list: ${errorMessage(error)}`, \"error\");\n return { kind: \"stay\" as const };\n }\n },\n keep: async ({ state, signal: actionSignal }) => {\n if (options.readOnly) return { kind: \"rejected\" };\n if (!canPublishLocalPolicy(state.decision)) return { kind: \"stay\" as const };\n if (!runRoute) {\n ctx.ui.notify(\"The reviewed update-remote route is unavailable.\", \"error\");\n return { kind: \"stay\" as const };\n }\n const signal = combineSignals(sessionSignal, actionSignal);\n try {\n if (!state.decision.ignorePolicyComparison) {\n const latest = await loadConfig(state.decision.setupName);\n if (signal.aborted) return { kind: \"close\" as const };\n validateOwner();\n assertLocalSelectionCurrent(latest, state.decision);\n }\n const result = await runCancellableOperation(\n ctx,\n \"Preparing this device's push preview\u2026\",\n \"push --force\",\n runRoute,\n {\n commitAware: true,\n cancelledMessage: \"Push preparation cancelled; no remote files were changed.\",\n target: state.decision.setupName,\n signal,\n },\n );\n return handleNestedRouteResult(result, \"push\");\n } catch (error) {\n if (signal.aborted || !isCurrent()) return { kind: \"close\" as const };\n if (isStaleReviewError(error)) {\n ctx.ui.notify(`${errorMessage(error)} Refreshing the comparison.`, \"warning\");\n refreshRequested = true;\n return { kind: \"close\" as const };\n }\n ctx.ui.notify(`Could not prepare the remote update: ${errorMessage(error)}`, \"error\");\n return { kind: \"stay\" as const };\n }\n },\n continue: async ({ state, signal: actionSignal }) => {\n if (options.readOnly) return { kind: \"rejected\" };\n if (!runRoute || !continuationFingerprint) return { kind: \"stay\" as const };\n const signal = combineSignals(sessionSignal, actionSignal);\n try {\n const latest = await loadConfig(state.decision.setupName);\n if (signal.aborted) return { kind: \"close\" as const };\n validateOwner();\n if (syncSettingsConfigFingerprint(latest) !== continuationFingerprint) {\n throw new StaleRemoteSelectionReviewError(\n `Sync setup \u201C${safeTerminalText(state.decision.setupName)}\u201D changed after the remote content list was saved.`,\n );\n }\n const result = await runCancellableOperation(ctx, continueBusyLabel(origin), route, runRoute, {\n commitAware: true,\n cancelledMessage: continuationCancelledMessage(route),\n target: state.decision.setupName,\n signal,\n });\n return handleNestedRouteResult(result, route);\n } catch (error) {\n if (signal.aborted || !isCurrent()) return { kind: \"close\" as const };\n ctx.ui.notify(`Could not continue: ${errorMessage(error)}`, \"error\");\n return { kind: \"stay\" as const };\n }\n },\n cancel: async () => ({ kind: \"back\" }),\n done: async () => {\n nextResult = { kind: \"done\" };\n return { kind: \"close\" };\n },\n },\n });\n\n function handleNestedRouteResult(\n result: Awaited<ReturnType<typeof runCancellableOperation>>,\n nestedRoute: \"sync\" | \"pull\" | \"push\",\n ) {\n if (result.kind === \"completed\" && result.outcome === \"applied\") {\n options.onSelectionResolved?.();\n }\n if (result.kind === \"closed\") {\n nextResult = { kind: \"closed\" };\n return { kind: \"close\" as const };\n }\n if (\n result.kind === \"cancelled\" ||\n (result.kind === \"completed\" && result.outcome === \"cancelled\") ||\n result.kind === \"failed\"\n ) {\n return { kind: \"stay\" as const };\n }\n nextResult = { kind: \"route-result\", result, route: nestedRoute };\n return { kind: \"close\" as const };\n }\n\n const menuResult = await runMenu(ctx, menu, {\n getState: () => flowState,\n signal: sessionSignal,\n isCurrent,\n onError: (_menuCtx, error) => ctx.ui.notify(errorMessage(error), \"error\"),\n });\n if (!isCurrent() || menuResult.kind === \"stale\") return { kind: \"stale\" };\n if (refreshRequested) return { kind: \"refresh\" };\n if (nextResult) return nextResult;\n if (menuResult.kind === \"closed\") {\n return menuResult.reason === \"back\" ? { kind: \"back\" } : { kind: \"closed\" };\n }\n return { kind: \"closed\" };\n}\n\ninterface AdoptionReview {\n config: AnySyncConfig;\n backend: SyncBackend;\n reviewedHead: RemoteHead;\n}\n\nasync function loadAdoptionReview(\n decision: RemoteSelectionDecision,\n signal: AbortSignal,\n factory: SyncBackendFactory,\n validateOwner: () => void,\n): Promise<AdoptionReview> {\n const config = await loadConfig(decision.setupName);\n throwIfAborted(signal);\n validateOwner();\n assertLocalSelectionCurrent(config, decision);\n const backend = await factory(config);\n throwIfAborted(signal);\n validateOwner();\n const reviewedHead = await backend.readHead(signal);\n throwIfAborted(signal);\n validateOwner();\n if (!reviewedHead) {\n throw new StaleRemoteSelectionReviewError(\"Remote storage changed while the comparison was open.\");\n }\n const snapshot = await readSnapshotForHead(backend, reviewedHead, signal);\n throwIfAborted(signal);\n validateOwner();\n const state = inspectRemoteSelection(config.include, snapshot, config.exclude, config);\n if (\n state.kind !== \"different\" ||\n !sameSyncInclude(state.include, decision.remoteInclude) ||\n !sameSyncExclude(state.exclude, decision.remoteExclude) ||\n !matchesRemoteDirectory(state, decision)\n ) {\n throw new StaleRemoteSelectionReviewError(\"Remote synced content changed while the comparison was open.\");\n }\n return { config, backend, reviewedHead };\n}\n\nasync function revalidateAndAdopt(\n review: AdoptionReview,\n decision: RemoteSelectionDecision,\n signal: AbortSignal,\n validateOwner: () => void,\n) {\n const currentHead = await review.backend.readHead(signal);\n throwIfAborted(signal);\n validateOwner();\n if (!currentHead || !review.backend.sameRevision(review.reviewedHead.revision, currentHead.revision)) {\n throw new StaleRemoteSelectionReviewError(\"Remote storage changed while the comparison was open.\");\n }\n const currentSnapshot = await readSnapshotForHead(review.backend, currentHead, signal);\n throwIfAborted(signal);\n validateOwner();\n const currentState = inspectRemoteSelection(\n review.config.include,\n currentSnapshot,\n review.config.exclude,\n review.config,\n );\n if (\n currentState.kind !== \"different\" ||\n !sameSyncInclude(currentState.include, decision.remoteInclude) ||\n !sameSyncExclude(currentState.exclude, decision.remoteExclude) ||\n !matchesRemoteDirectory(currentState, decision)\n ) {\n throw new StaleRemoteSelectionReviewError(\"Remote synced content changed while the comparison was open.\");\n }\n await updateSyncSetup(\n decision.setupName,\n (setup) => {\n validateOwner();\n const refusal = adoptionUnavailable(decision);\n if (refusal) throw new Error(refusal);\n const exclude = adoptedExclude(decision);\n if (setup.sync.pathPolicy === \"ignore-file\") throw new Error(\"An ignore-file setup cannot adopt remote rules.\");\n if (setup.sync.scope === \"agent-directory\") {\n return {\n ...setup,\n sync: {\n ...setup.sync,\n exclude,\n reinclude: [...(decision.remoteDirectory?.reinclude ?? [])],\n sessions: decision.remoteInclude.includes(\"sessions\"),\n },\n };\n }\n return {\n ...setup,\n sync: { ...setup.sync, include: [...decision.remoteInclude], ...(exclude === undefined ? {} : { exclude }) },\n };\n },\n {\n expectedConfigFingerprint: syncSettingsConfigFingerprint(review.config),\n expectedInclude: decision.localInclude,\n upgradeExclude: adoptedExclude(decision) !== undefined,\n signal,\n },\n );\n}\n\nasync function inspectConfiguredRemoteSelection(\n ctx: ExtensionContext,\n setupName: string | undefined,\n signal: AbortSignal | undefined,\n factory: SyncBackendFactory,\n validateOwner: () => void,\n): Promise<\n | { kind: \"empty\"; config: AnySyncConfig }\n | { kind: \"selection\"; config: AnySyncConfig; state: RemoteSelectionState }\n | { kind: \"decision\"; decision: RemoteSelectionDecision }\n | undefined\n> {\n const config = await loadConfig(setupName);\n if (signal?.aborted) return undefined;\n validateOwner();\n setSyncStatus(ctx, `checking synced content for ${safeTerminalText(config.setupName)}`, { activity: \"checking\" });\n const backend = await factory(config);\n if (signal?.aborted) return undefined;\n validateOwner();\n const head = await backend.readHead(signal);\n if (signal?.aborted) return undefined;\n validateOwner();\n if (!head) return { kind: \"empty\", config };\n try {\n const snapshot = await readSnapshotForHead(backend, head, signal, config);\n if (signal?.aborted) return undefined;\n validateOwner();\n return {\n kind: \"selection\",\n config,\n state: inspectRemoteSelection(config.include, snapshot, config.exclude, config),\n };\n } catch (error) {\n if (signal?.aborted) return undefined;\n validateOwner();\n if (error instanceof RemoteSelectionMismatchError) return { kind: \"decision\", decision: error.decision };\n throw error;\n }\n}\n\nasync function showLegacyDiscovery(\n ctx: ExtensionContext,\n config: AnySyncConfig,\n discovered: string[],\n signal?: AbortSignal,\n) {\n const menu = defineMenu<undefined, \"choice\" | \"review\", \"back\", ExtensionContext>({\n start: \"choice\",\n screens: {\n choice: () => ({\n kind: \"actions\",\n title: `Compare synced content \u00B7 ${safeTerminalText(config.setupName)}`,\n lines: [\n \"This legacy snapshot has no portable synced-content list.\",\n \"Discovered paths are partial and read-only; preserved files may not have been selected.\",\n ],\n items: [\n { id: \"review\", label: \"Review discovered paths\", to: \"review\" },\n { id: \"back\", label: \"Back\", action: \"back\" },\n ],\n hint: \"close\",\n }),\n review: () => ({\n kind: \"review\",\n title: \"Partial discovery from legacy snapshot\",\n content: [\n \"Partial discovery only \u2014 not an authoritative selection.\",\n \"\",\n ...(discovered.length > 0\n ? discovered.map((item) => `Discovered: ${safeTerminalText(item)}`)\n : [\"No safe paths were discovered.\"]),\n \"\",\n \"Use Add custom path\u2026 in the local Included Content editor if needed.\",\n ].join(\"\\n\"),\n format: { kind: \"text\" },\n viewportSize: \"adaptive\",\n hint: \"back\",\n }),\n },\n actions: { back: async () => ({ kind: \"close\" }) },\n });\n await runMenu(ctx, menu, {\n getState: () => undefined,\n signal,\n isCurrent: () => !signal?.aborted,\n });\n}\n\nfunction adoptedExclude(decision: RemoteSelectionDecision) {\n return decision.remoteExclude === undefined\n ? decision.localExclude === undefined\n ? undefined\n : []\n : [...decision.remoteExclude];\n}\n\nfunction scopesDiffer(decision: RemoteSelectionDecision) {\n return decision.localDirectory?.scope !== decision.remoteDirectory?.scope;\n}\n\nfunction canPublishLocalPolicy(decision: RemoteSelectionDecision) {\n if (decision.ignorePolicyComparison) {\n return (\n decision.ignorePolicyComparison !== \"match\" && decision.ignorePolicyComparison !== \"local-legacy-remote-ignore\"\n );\n }\n return !scopesDiffer(decision);\n}\n\nfunction adoptionUnavailable(decision: RemoteSelectionDecision) {\n if (decision.ignorePolicyComparison)\n return \"Ignore files are local. Published metadata cannot reconstruct remote rules.\";\n if (scopesDiffer(decision))\n return \"Scope differs. Configure a setup with the remote scope to join it; this location is not migrated in place.\";\n if (\n decision.remoteDirectory?.scope &&\n decision.remoteInclude.includes(\"sessions\") &&\n !decision.localInclude.includes(\"sessions\")\n )\n return \"Enable session sync explicitly in Settings before adopting these rules.\";\n}\n\nfunction matchesRemoteDirectory(\n state: Extract<RemoteSelectionState, { kind: \"different\" }>,\n decision: RemoteSelectionDecision,\n) {\n return (\n syncDirectoryPolicyKey(state) ===\n syncDirectoryPolicyKey({\n include: decision.remoteInclude,\n exclude: decision.remoteExclude,\n ...decision.remoteDirectory,\n })\n );\n}\n\nfunction directoryReviewLines(decision: RemoteSelectionDecision) {\n if (!decision.localDirectory?.scope && !decision.remoteDirectory?.scope) return [];\n const unavailable = adoptionUnavailable(decision);\n return [\n `Remote scope: ${decision.remoteDirectory?.scope ? \"Pi agent directory\" : \"selected paths or legacy\"}`,\n `This device scope: ${decision.localDirectory?.scope ? \"Pi agent directory\" : \"selected paths\"}`,\n `Remote re-included paths: ${safeList(decision.remoteDirectory?.reinclude ?? [])}`,\n `This device re-included paths: ${safeList(decision.localDirectory?.reinclude ?? [])}`,\n ...(unavailable ? [unavailable] : []),\n ];\n}\n\nfunction selectionSummaryLines(decision: RemoteSelectionDecision) {\n if (decision.ignorePolicyComparison) {\n return [\n `Sync setup: ${safeTerminalText(decision.setupName)}`,\n adoptionUnavailable(decision) ?? \"Nothing changed.\",\n ...(decision.ignorePolicyComparison === \"local-legacy-remote-ignore\"\n ? [\"The remote uses an ignore-file policy; this device uses a legacy policy.\"]\n : decision.ignorePolicyComparison === \"local-ignore-remote-legacy\"\n ? [\"This device uses an ignore-file policy; the remote uses a legacy policy.\"]\n : [\"The ordered rules or session opt-in differ.\"]),\n \"No files or settings have changed.\",\n ];\n }\n const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);\n return [\n `Sync setup: ${safeTerminalText(decision.setupName)}`,\n \"Nothing changed. Review both lists before choosing what happens next.\",\n ...directoryReviewLines(decision),\n ...excludeReviewLines(decision),\n ...(!decision.localDirectory?.scope &&\n !decision.remoteDirectory?.scope &&\n comparison.remoteOnly.length === 0 &&\n comparison.localOnly.length === 0 &&\n sameSyncExclude(decision.localExclude, decision.remoteExclude)\n ? [\"Only the ordering differs; membership is the same.\"]\n : [`Remote-only paths: ${comparison.remoteOnly.length} \u00B7 Device-only paths: ${comparison.localOnly.length}`]),\n ];\n}\n\nfunction formatSelectionDifference(decision: RemoteSelectionDecision) {\n if (decision.ignorePolicyComparison) return selectionSummaryLines(decision).join(\"\\n\");\n const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);\n return [\n ...directoryReviewLines(decision),\n ...(!decision.localDirectory?.scope &&\n !decision.remoteDirectory?.scope &&\n comparison.remoteOnly.length === 0 &&\n comparison.localOnly.length === 0 &&\n sameSyncExclude(decision.localExclude, decision.remoteExclude)\n ? [\"Only ordering differs; both lists contain the same paths.\", \"\"]\n : []),\n \"Remote-only paths:\",\n ...(comparison.remoteOnly.length > 0\n ? comparison.remoteOnly.map((item) => `+ ${safeTerminalText(item)}`)\n : [\"(none)\"]),\n \"\",\n \"Device-only paths:\",\n ...(comparison.localOnly.length > 0\n ? comparison.localOnly.map((item) => `- ${safeTerminalText(item)}`)\n : [\"(none)\"]),\n \"\",\n \"Remote ordered list:\",\n ...(decision.remoteInclude.length > 0\n ? decision.remoteInclude.map((item, index) => `${index + 1}. ${safeTerminalText(item)}`)\n : [\"(none)\"]),\n \"\",\n \"This device's ordered list:\",\n ...(decision.localInclude.length > 0\n ? decision.localInclude.map((item, index) => `${index + 1}. ${safeTerminalText(item)}`)\n : [\"(none)\"]),\n \"\",\n ...excludeReviewLines(decision),\n \"Using the remote list saves settings only and does not pull files.\",\n ].join(\"\\n\");\n}\n\nfunction formatRemoteSelectionSummary(decision: RemoteSelectionDecision) {\n if (decision.ignorePolicyComparison) return selectionSummaryLines(decision).join(\"\\n\");\n const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);\n return [\n `Synced content for \u201C${safeTerminalText(decision.setupName)}\u201D differs from this device.`,\n `Remote-only: ${safeList(comparison.remoteOnly)}`,\n `Device-only: ${safeList(comparison.localOnly)}`,\n ...directoryReviewLines(decision),\n ...(!decision.localDirectory?.scope &&\n !decision.remoteDirectory?.scope &&\n comparison.remoteOnly.length === 0 &&\n comparison.localOnly.length === 0 &&\n sameSyncExclude(decision.localExclude, decision.remoteExclude)\n ? [\n \"Only ordering differs.\",\n `Remote order: ${safeList(decision.remoteInclude)}`,\n `Device order: ${safeList(decision.localInclude)}`,\n ]\n : []),\n ...excludeReviewLines(decision),\n \"Run /sync in TUI to choose a content list; RPC review is read-only.\",\n ].join(\"\\n\");\n}\n\nfunction excludeReviewLines(decision: RemoteSelectionDecision) {\n if (decision.localExclude === undefined && decision.remoteExclude === undefined) return [];\n return [\n `Remote excluded paths: ${safeList(decision.remoteExclude ?? [])}`,\n `This device excluded paths: ${safeList(decision.localExclude ?? [])}`,\n \"Removed exclusions can expose or replace content; old history is not erased.\",\n ];\n}\n\nfunction formatLegacySummary(config: AnySyncConfig, discovered: readonly string[]) {\n return `Remote snapshot for \u201C${safeTerminalText(config.setupName)}\u201D has no portable synced-content list; ${discovered.length} safe path${discovered.length === 1 ? \" was\" : \"s were\"} discovered, but the result is partial and read-only.`;\n}\n\nfunction decisionFromState(\n config: AnySyncConfig,\n state: Extract<RemoteSelectionState, { kind: \"different\" }>,\n): RemoteSelectionDecision {\n return {\n setupName: config.setupName,\n configIdentity: syncConfigReviewFingerprint(config),\n ignorePolicyComparison: state.ignorePolicyComparison,\n localInclude: [...config.include],\n remoteInclude: [...state.include],\n ...(config.exclude === undefined ? {} : { localExclude: [...config.exclude] }),\n ...(state.exclude === undefined ? {} : { remoteExclude: [...state.exclude] }),\n ...(config.scope ? { localDirectory: { scope: config.scope, reinclude: config.reinclude } } : {}),\n ...(state.scope ? { remoteDirectory: { scope: state.scope, reinclude: state.reinclude } } : {}),\n };\n}\n\nfunction assertLocalSelectionCurrent(config: AnySyncConfig, decision: RemoteSelectionDecision) {\n if (\n syncConfigReviewFingerprint(config) === decision.configIdentity &&\n sameSyncInclude(config.include, decision.localInclude) &&\n sameSyncExclude(config.exclude, decision.localExclude) &&\n syncDirectoryPolicyKey(config) ===\n syncDirectoryPolicyKey({\n include: decision.localInclude,\n exclude: decision.localExclude,\n ...decision.localDirectory,\n })\n ) {\n return;\n }\n throw new StaleRemoteSelectionReviewError(\n `Sync setup \u201C${safeTerminalText(config.setupName)}\u201D changed while the comparison was open.`,\n );\n}\n\nfunction continueLabel(origin: RemoteSelectionOrigin) {\n if (origin === \"pull\") return \"Continue Pull now\u2026\";\n if (origin === \"push\") return \"Continue Push now\u2026\";\n return \"Continue Sync now\u2026\";\n}\n\nfunction continueBusyLabel(origin: RemoteSelectionOrigin) {\n if (origin === \"pull\") return \"Checking remote changes\u2026\";\n if (origin === \"push\") return \"Preparing push preview\u2026\";\n return \"Checking current sync setup\u2026\";\n}\n\nfunction continuationCancelledMessage(route: \"sync\" | \"pull\" | \"push\") {\n if (route === \"pull\") return \"Pull check cancelled; no local files were changed.\";\n if (route === \"push\") return \"Push preparation cancelled; no remote files were changed.\";\n return \"Sync check cancelled; no settings or files were changed.\";\n}\n\nfunction safeList(values: readonly string[]) {\n return values.length > 0 ? values.map(safeTerminalText).join(\", \") : \"none\";\n}\n\nclass StaleRemoteSelectionReviewError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"StaleRemoteSelectionReviewError\";\n }\n}\n\nfunction isStaleReviewError(error: unknown) {\n return error instanceof StaleRemoteSelectionReviewError || error instanceof SyncSetupReviewChangedError;\n}\n\nfunction runWithOptionalStateAccess<T>(\n options: Pick<RemoteSelectionReviewOptions, \"withStateAccess\">,\n task: () => Promise<T>,\n) {\n return options.withStateAccess ? options.withStateAccess(task) : task();\n}\n\nfunction isReviewOwnerCurrent(validateOwner: () => void) {\n try {\n validateOwner();\n return true;\n } catch {\n return false;\n }\n}\n\nfunction combineSignals(sessionSignal: AbortSignal | undefined, actionSignal: AbortSignal) {\n return sessionSignal ? AbortSignal.any([sessionSignal, actionSignal]) : actionSignal;\n}\n", "export type * from \"@narumitw/pi-sync-daemon/engine/backends/backend-factory\";\nexport { createSyncBackend } from \"@narumitw/pi-sync-daemon/engine/backends/backend-factory\";\n", "export type * from \"@narumitw/pi-sync-daemon/engine/sync/remote-snapshot\";\nexport {\n formatRemoteSelectionStatus,\n readRemoteSnapshot,\n readSnapshotForHead,\n requireCompatibleRemoteSelection,\n} from \"@narumitw/pi-sync-daemon/engine/sync/remote-snapshot\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,YAAY,eAAe;;;ACApC,SAAS,yBAAyB;;;ACAlC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;AF4CP,eAAsB,0BACpB,KACA,WACA,QACA,UAA8B,mBAC9B,UAAwC,CAAC,GACH;AACtC,QAAM,gBAAgB,qBAAqB,KAAK,MAAM;AACtD,QAAM,YAAY,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AAO;AAAA,EACd;AACF;AAEA,SAAS,mBAAmB,OAAgB;AAC1C,SAAO,iBAAiB,mCAAmC,iBAAiB;AAC9E;AAEA,SAAS,2BACP,SACA,MACA;AACA,SAAO,QAAQ,kBAAkB,QAAQ,gBAAgB,IAAI,IAAI,KAAK;AACxE;AAEA,SAAS,qBAAqB,eAA2B;AACvD,MAAI;AACF,kBAAc;AACd,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,eAAe,eAAwC,cAA2B;AACzF,SAAO,gBAAgB,YAAY,IAAI,CAAC,eAAe,YAAY,CAAC,IAAI;AAC1E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -11,20 +11,20 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
localConfigPath
|
|
13
13
|
} from "./chunk-IBXEM35O.ts";
|
|
14
|
-
import {
|
|
15
|
-
captureMutationOwner
|
|
16
|
-
} from "./chunk-GELYN4UC.ts";
|
|
17
14
|
import {
|
|
18
15
|
updateSyncSetup
|
|
19
16
|
} from "./chunk-NXWHPVXR.ts";
|
|
17
|
+
import {
|
|
18
|
+
captureMutationOwner
|
|
19
|
+
} from "./chunk-GELYN4UC.ts";
|
|
20
20
|
import {
|
|
21
21
|
normalizeSyncExclude,
|
|
22
22
|
sameSyncExclude
|
|
23
23
|
} from "./chunk-ZO52JM4H.ts";
|
|
24
24
|
import {
|
|
25
|
-
|
|
25
|
+
loadSettingsConfig,
|
|
26
26
|
syncCheckConfigFingerprint
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-27F5W7DX.ts";
|
|
28
28
|
import {
|
|
29
29
|
safeTerminalText
|
|
30
30
|
} from "./chunk-2JNFEZ3V.ts";
|
|
@@ -42,7 +42,7 @@ async function showExcludedPaths(ctx, setupName, signal) {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
validate();
|
|
45
|
-
const config = await
|
|
45
|
+
const config = await loadSettingsConfig(setupName);
|
|
46
46
|
validate();
|
|
47
47
|
if (config.scope === "agent-directory") return showDirectoryScope(ctx, config, signal);
|
|
48
48
|
if (ctx.mode !== "tui") {
|
|
@@ -274,4 +274,4 @@ export {
|
|
|
274
274
|
directoryScopeSummary,
|
|
275
275
|
showDirectoryScope
|
|
276
276
|
};
|
|
277
|
-
//# sourceMappingURL=chunk-
|
|
277
|
+
//# sourceMappingURL=chunk-HSCAFOT5.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/excluded-paths-ui.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { defineMenu, runMenu } from \"@narumitw/pi-tui-kit\";\nimport { loadSettingsConfig, syncCheckConfigFingerprint } from \"../settings/config.js\";\nimport { localConfigPath } from \"../settings/config-file.js\";\nimport { updateSyncSetup } from \"../settings/settings-management.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { normalizeSyncExclude, sameSyncExclude } from \"../sync/exclude-policy.js\";\nimport { captureMutationOwner } from \"../sync/sync-local.js\";\nimport {\n acknowledgeSessions,\n type DirectoryRulesDraft,\n directoryScopeLines,\n formatDirectoryRules,\n promptDirectoryRules,\n summarizeDirectoryRules,\n} from \"./setup/directory-rules.js\";\nimport { saveReviewedDraft } from \"./setup/setup-review.js\";\nimport { safeTerminalText } from \"./terminal-text.js\";\n\n/** Transactional draft; Pi owns editor input/paste and Kit owns review/cancellation. */\nexport async function showExcludedPaths(ctx: ExtensionCommandContext, setupName: string, signal?: AbortSignal) {\n const validate = captureMutationOwner(ctx, signal);\n const isCurrent = () => {\n try {\n validate();\n return true;\n } catch {\n return false;\n }\n };\n validate();\n const config = await loadSettingsConfig(setupName);\n validate();\n if (config.scope === \"agent-directory\") return showDirectoryScope(ctx, config, signal);\n if (ctx.mode !== \"tui\") {\n if (ctx.hasUI)\n ctx.ui.notify(\n [\n `Excluded paths: ${(config.exclude ?? []).map(safeTerminalText).join(\", \") || \"none\"}`,\n `Edit sync.exclude in ${safeTerminalText(localConfigPath())}; an explicit array requires settings version 6 or later.`,\n ].join(\"\\n\"),\n \"info\",\n );\n return;\n }\n let draft = JSON.stringify(config.exclude ?? []);\n while (isCurrent()) {\n const entered = await ctx.ui.input(\"Excluded paths \u00B7 JSON array \u00B7 empty input keeps draft\", draft, { signal });\n if (!isCurrent() || entered === undefined) return;\n const input = entered || draft;\n draft = input;\n let exclude: string[];\n try {\n const parsed: unknown = JSON.parse(input);\n if (!Array.isArray(parsed)) throw new Error(\"Enter a JSON string array.\");\n exclude = normalizeSyncExclude(parsed);\n } catch {\n ctx.ui.notify(\"Invalid exclude array or unsupported pattern. No settings changed.\", \"error\");\n continue;\n }\n if (sameSyncExclude(exclude, config.exclude)) return;\n let choice: \"save\" | \"discard\" | \"edit\" | undefined;\n const menu = defineMenu<undefined, \"review\", \"choose\", ExtensionCommandContext>({\n start: \"review\",\n screens: {\n review: () => ({\n kind: \"actions\",\n title: \"Review excluded paths\",\n lines: [\n `Setup: ${safeTerminalText(config.setupName)}`,\n \"Draft only. Save requires at least settings version 6 and uses snapshot version 4 for this allowlist setup.\",\n \"Excluded local files stay untouched. New snapshots omit matching remote files; old history is NOT erased.\",\n \"Removing rules can expose local content or allow pull to replace it. Review a force push to publish policy changes.\",\n \"Previously excluded:\",\n ...(config.exclude?.length ? config.exclude.map((rule) => `- ${safeTerminalText(rule)}`) : [\"(none)\"]),\n \"Proposed excluded paths:\",\n ...(exclude.length ? exclude.map((rule) => `+ ${safeTerminalText(rule)}`) : [\"(none)\"]),\n ],\n items: [\n { id: \"save\", label: \"Save changes\", action: \"choose\" },\n { id: \"discard\", label: \"Discard changes\", action: \"choose\" },\n { id: \"edit\", label: \"Continue editing\", action: \"choose\" },\n ],\n hint: \"close\",\n }),\n },\n actions: {\n choose: async ({ itemId }) => {\n choice = itemId === \"save\" ? \"save\" : itemId === \"edit\" ? \"edit\" : \"discard\";\n return { kind: \"close\" };\n },\n },\n });\n await runMenu(ctx, menu, { getState: () => undefined, signal, isCurrent });\n if (!isCurrent()) return;\n if (choice === \"edit\") continue;\n if (choice !== \"save\") return;\n try {\n await updateSyncSetup(\n setupName,\n (setup) => {\n validate();\n if (setup.sync.pathPolicy === \"ignore-file\")\n throw new Error(\"Edit the ignore file to change this setup's policy.\");\n return { ...setup, sync: { ...setup.sync, exclude } };\n },\n { expectedConfigFingerprint: syncCheckConfigFingerprint(config), upgradeExclude: true, signal },\n );\n if (isCurrent()) ctx.ui.notify(\"Excluded paths saved. Applies to subsequent sync; no transfer started.\", \"info\");\n } catch (error) {\n if (isCurrent())\n ctx.ui.notify(\n `Excluded paths not saved: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,\n \"error\",\n );\n }\n return;\n }\n}\n\nexport function directoryScopeSummary(config: AnySyncConfig) {\n return [\n `Setup: ${safeTerminalText(config.setupName)} \u00B7 Scope: Pi agent directory`,\n `Excluded paths: ${summarizeDirectoryRules(config.exclude)}`,\n `Re-included paths: ${summarizeDirectoryRules(config.reinclude)}`,\n `Session opt-in: ${config.include.includes(\"sessions\") ? \"On (path rules still apply)\" : \"Off\"}`,\n \"Pi credentials and project trust always stay local.\",\n ];\n}\n\nexport async function showDirectoryScope(ctx: ExtensionCommandContext, config: AnySyncConfig, signal?: AbortSignal) {\n const validate = captureMutationOwner(ctx, signal);\n const isCurrent = () => {\n try {\n validate();\n return true;\n } catch {\n return false;\n }\n };\n if (!isCurrent()) return;\n if (ctx.mode !== \"tui\") {\n if (ctx.hasUI)\n ctx.ui.notify(\n [\n ...directoryScopeSummary(config),\n `Edit sync.exclude, sync.reinclude, and sync.sessions in ${safeTerminalText(localConfigPath())}.`,\n ].join(\"\\n\"),\n \"info\",\n );\n return;\n }\n const original: DirectoryRulesDraft = {\n exclude: config.exclude ?? [],\n reinclude: config.reinclude ?? [],\n sessions: config.include.includes(\"sessions\"),\n };\n const draft: DirectoryRulesDraft = { ...original };\n const change = () => ({\n exclude: !sameSyncExclude(draft.exclude, original.exclude),\n reinclude: !sameSyncExclude(draft.reinclude, original.reinclude),\n sessions: draft.sessions !== original.sessions,\n });\n const menu = defineMenu<undefined, \"draft\", \"exclude\" | \"reinclude\" | \"sessions\" | \"review\", ExtensionCommandContext>(\n {\n start: \"draft\",\n screens: {\n draft: () => ({\n kind: \"actions\",\n title: `Agent directory scope \u00B7 ${safeTerminalText(config.setupName)}`,\n lines: [\n \"Changes stay in this draft until you review and save. Back discards the draft.\",\n \"Session opt-in does not change path rules. Edit the rules separately to select which sessions can sync.\",\n ],\n items: [\n { id: \"exclude\", label: `Edit excluded paths\u2026 (${draft.exclude.length})`, action: \"exclude\" },\n { id: \"reinclude\", label: `Edit re-included paths\u2026 (${draft.reinclude.length})`, action: \"reinclude\" },\n {\n id: \"sessions\",\n label: `Session opt-in: ${draft.sessions ? \"On \u2192 Off\" : \"Off \u2192 On\"}`,\n action: \"sessions\",\n },\n { id: \"review\", label: \"Review changes\u2026\", action: \"review\" },\n ],\n hint: \"back\",\n }),\n },\n actions: {\n exclude: async ({ signal: actionSignal }) => editRules(\"exclude\", actionSignal),\n reinclude: async ({ signal: actionSignal }) => editRules(\"reinclude\", actionSignal),\n sessions: async ({ signal: actionSignal }) => {\n if (!draft.sessions && !(await acknowledgeSessions(ctx, actionSignal))) return { kind: \"stay\" };\n if (actionSignal.aborted || !isCurrent()) return { kind: \"close\" };\n draft.sessions = !draft.sessions;\n return { kind: \"stay\" };\n },\n review: async ({ signal: actionSignal }) => {\n const changed = change();\n if (!changed.exclude && !changed.reinclude && !changed.sessions) return { kind: \"close\" };\n try {\n validate();\n const saved = await saveReviewedDraft(\n ctx,\n \"Review agent directory scope\",\n [\n `Setup: ${safeTerminalText(config.setupName)}`,\n \"\",\n ...directoryScopeLines(draft),\n \"\",\n ...formatDirectoryRules(\"Previously excluded\", original.exclude),\n ...formatDirectoryRules(\"Previously re-included\", original.reinclude),\n `Previous session opt-in: ${original.sessions ? \"On\" : \"Off\"}`,\n \"Changing rules can expose or replace files. Existing remote history is not erased.\",\n \"A remote policy mismatch blocks transfer until reviewed. Saving does not start a transfer.\",\n ],\n \"Save changes\",\n (saveSignal) =>\n updateSyncSetup(\n config.setupName,\n (setup) => {\n validate();\n if (setup.sync.scope !== \"agent-directory\" || setup.sync.pathPolicy === \"ignore-file\")\n throw new Error(\"Sync scope changed during review.\");\n return {\n ...setup,\n sync: {\n ...setup.sync,\n ...(changed.exclude ? { exclude: draft.exclude } : {}),\n ...(changed.reinclude ? { reinclude: draft.reinclude } : {}),\n ...(changed.sessions ? { sessions: draft.sessions } : {}),\n },\n };\n },\n { expectedConfigFingerprint: syncCheckConfigFingerprint(config), signal: saveSignal },\n ),\n actionSignal,\n );\n if (saved && !actionSignal.aborted && isCurrent())\n ctx.ui.notify(\"Agent directory rules saved. Applies to subsequent sync; no transfer started.\", \"info\");\n } catch (error) {\n if (!actionSignal.aborted && isCurrent())\n ctx.ui.notify(\n `Agent directory rules not saved: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,\n \"error\",\n );\n }\n return { kind: \"close\" };\n },\n },\n },\n );\n const result = await runMenu(ctx, menu, { getState: () => undefined, signal, isCurrent });\n if (result.kind === \"error\" && isCurrent()) throw result.error;\n\n async function editRules(kind: \"exclude\" | \"reinclude\", actionSignal: AbortSignal) {\n const rules = await promptDirectoryRules(ctx, kind, draft[kind], actionSignal, validate);\n if (actionSignal.aborted || !isCurrent()) return { kind: \"close\" as const };\n if (rules) draft[kind] = rules;\n return { kind: \"stay\" as const };\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,YAAY,eAAe;AAmBpC,eAAsB,kBAAkB,KAA8B,WAAmB,QAAsB;AAC7G,QAAM,WAAW,qBAAqB,KAAK,MAAM;AACjD,QAAM,YAAY,MAAM;AACtB,QAAI;AACF,eAAS;AACT,aAAO;AAAA,IACT,QAAQ;AACN,aAA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IACF;AAAA,EACF;AACA,QAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,EAAE,UAAU,MAAM,QAAW,QAAQ,UAAU,CAAC;AACxF,MAAI,OAAO,SAAS,WAAW,UAAU,EAAG,OAAM,OAAO;AAEzD,iBAAe,UAAU,MAA+B,cAA2B;AACjF,UAAM,QAAQ,MAAM,qBAAqB,KAAK,MAAM,MAAM,IAAI,GAAG,cAAc,QAAQ;AACvF,QAAI,aAAa,WAAW,CAAC,UAAU,EAAG,QAAO,EAAE,MAAM,QAAiB;AAC1E,QAAI,MAAO,OAAM,IAAI,IAAI;AACzB,WAAO,EAAE,MAAM,OAAgB;AAAA,EACjC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
|
|
4
|
+
// src/ui/automatic-sync-summary.ts
|
|
5
|
+
function automaticSyncSummary(enabled) {
|
|
6
|
+
return enabled ? "On (startup check; shutdown pushes selected content if sessions included)" : "Off";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/ui/operation-dialogs.ts
|
|
10
|
+
function trackOperationDialogs(ctx, onDialog) {
|
|
11
|
+
if (!onDialog) return ctx;
|
|
12
|
+
const runDialog = async (task) => {
|
|
13
|
+
onDialog(true);
|
|
14
|
+
try {
|
|
15
|
+
return await task();
|
|
16
|
+
} finally {
|
|
17
|
+
onDialog(false);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const ui = {
|
|
21
|
+
...ctx.ui,
|
|
22
|
+
select: (...args) => runDialog(() => ctx.ui.select(...args)),
|
|
23
|
+
confirm: (...args) => runDialog(() => ctx.ui.confirm(...args))
|
|
24
|
+
};
|
|
25
|
+
return new Proxy(ctx, {
|
|
26
|
+
get(target, key, receiver) {
|
|
27
|
+
return key === "ui" ? ui : Reflect.get(target, key, receiver);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
automaticSyncSummary,
|
|
34
|
+
trackOperationDialogs
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-MANNB4WZ.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/automatic-sync-summary.ts", "../../src/ui/operation-dialogs.ts"],
|
|
4
|
+
"sourcesContent": ["/** Keep the setting's automatic transfer scope visible in every setup summary. */\nexport function automaticSyncSummary(enabled: boolean) {\n return enabled ? \"On (startup check; shutdown pushes selected content if sessions included)\" : \"Off\";\n}\n", "import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\n\n/** Track History's Pi-owned selector/confirmation lifetime without inspecting renderer internals. */\nexport function trackOperationDialogs<Context extends ExtensionContext>(\n ctx: Context,\n onDialog?: (active: boolean) => void,\n): Context {\n if (!onDialog) return ctx;\n const runDialog = async <Value>(task: () => Promise<Value>): Promise<Value> => {\n onDialog(true);\n try {\n return await task();\n } finally {\n onDialog(false);\n }\n };\n const ui: ExtensionContext[\"ui\"] = {\n ...ctx.ui,\n select: (...args) => runDialog(() => ctx.ui.select(...args)),\n confirm: (...args) => runDialog(() => ctx.ui.confirm(...args)),\n };\n // Forward live context properties: copying the context would hide session\n // replacement from mutation-owner revalidation after a dialog settles.\n return new Proxy(ctx, {\n get(target, key, receiver) {\n return key === \"ui\" ? ui : Reflect.get(target, key, receiver);\n },\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;AACO,SAAS,qBAAqB,SAAkB;AACrD,SAAO,UAAU,8EAA8E;AACjG;;;ACAO,SAAS,sBACd,KACA,UACS;AACT,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,YAAY,OAAc,SAA+C;AAC7E,aAAS,IAAI;AACb,QAAI;AACF,aAAO,MAAM,KAAK;AAAA,IACpB,UAAE;AACA,eAAS,KAAK;AAAA,IAChB;AAAA,EACF;AACA,QAAM,KAA6B;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,IAAI,SAAS,UAAU,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAAA,IAC3D,SAAS,IAAI,SAAS,UAAU,MAAM,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC;AAAA,EAC/D;AAGA,SAAO,IAAI,MAAM,KAAK;AAAA,IACpB,IAAI,QAAQ,KAAK,UAAU;AACzB,aAAO,QAAQ,OAAO,KAAK,QAAQ,IAAI,QAAQ,KAAK,QAAQ;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|