@narumitw/pi-sync 0.62.0 → 0.63.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 +26 -0
- package/README.md +40 -23
- 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-INECVQNR.ts → chunk-B5F3JLD3.ts} +6 -4
- package/dist/chunks/chunk-B5F3JLD3.ts.map +7 -0
- 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-ZB3GNX3P.ts → chunk-LBNC5AOM.ts} +140 -13
- package/dist/chunks/chunk-LBNC5AOM.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-GSQGBVKG.ts → chunk-POWOMJ7S.ts} +87 -50
- package/dist/chunks/chunk-POWOMJ7S.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-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-GMRRFWOL.ts} +19 -36
- package/dist/chunks/command-handler-GMRRFWOL.ts.map +7 -0
- package/dist/chunks/{conflict-review-MAOGTIAI.ts → conflict-review-JWEA7DPQ.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-T5J5WG7T.ts} +227 -343
- package/dist/chunks/manager-ui-T5J5WG7T.ts.map +7 -0
- package/dist/chunks/{merge-review-SGDLMVS4.ts → merge-review-OQDXNTJU.ts} +2 -2
- 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-LL6YMGUR.ts} +7 -3
- package/dist/chunks/{setup-wizard-5G426MOZ.ts.map → setup-wizard-LL6YMGUR.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-ITZ6Z4DE.ts → sync-inspection-SRU6HGGK.ts} +3 -3
- package/dist/chunks/{sync-operations-NMVKF7SE.ts → sync-operations-UGSCONZ7.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 +142 -40
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +94 -26
- package/dist/daemon/dist/engine/ignore/ignore-source.js +1 -1
- 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-error-guidance.js +16 -3
- package/dist/daemon/dist/engine/sync/sync-mutations.js +75 -54
- 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/ui/sync-format.js +23 -55
- package/dist/daemon/dist/engine/ui/transfer-review.js +3 -3
- 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/docs/tui-contract.md +1 -1
- package/package.json +3 -3
- package/skills/configure-pi-sync/SKILL.md +128 -74
- package/skills/configure-pi-sync/references/configuration.md +115 -45
- 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 +33 -18
- package/src/ui/manager-ui.ts +27 -18
- package/src/ui/merge-review.ts +28 -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/setup/webdav-ui.ts +1 -1
- package/src/ui/storage-connections-ui.ts +33 -11
- package/src/ui/sync-confirmation.ts +67 -48
- 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-GSQGBVKG.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-JWEA7DPQ.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-MC6EQOQY.ts.map → manager-result-dispatcher-GDB74IOP.ts.map} +0 -0
- /package/dist/chunks/{merge-review-SGDLMVS4.ts.map → merge-review-OQDXNTJU.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-SRU6HGGK.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-NMVKF7SE.ts.map → sync-operations-UGSCONZ7.ts.map} +0 -0
package/src/ui/settings-ui.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { defineMenu, type MenuSettingItem, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
|
-
import {
|
|
3
|
+
import { piDaemonClient } from "../daemon/pi-client.js";
|
|
4
|
+
import { configFromSettings, loadSettingsConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
4
5
|
import { localConfigPath, readActiveLocalConfigDocumentForRepair } from "../settings/config-file.js";
|
|
5
6
|
import { updateSyncSetup } from "../settings/settings-management.js";
|
|
6
7
|
import { updateLocalConfig } from "../settings/settings-store.js";
|
|
7
8
|
import { validateSettingsDocument } from "../settings/settings-validation.js";
|
|
9
|
+
import { startupTransferEnabled } from "../sync/agent-policy.js";
|
|
8
10
|
import { normalizeLocalFields, sameLocalFields } from "../sync/local-fields.js";
|
|
9
11
|
import {
|
|
10
12
|
SETUP_SWITCH_ACTION_OPTIONS,
|
|
@@ -13,6 +15,7 @@ import {
|
|
|
13
15
|
setupSwitchActionLabel,
|
|
14
16
|
} from "../sync/setup-switch.js";
|
|
15
17
|
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
18
|
+
import { syncSessionsSelected } from "../sync/sync-policy.js";
|
|
16
19
|
import {
|
|
17
20
|
AGENT_MODE_DESCRIPTION,
|
|
18
21
|
CONTINUOUS_DESCRIPTION,
|
|
@@ -21,7 +24,8 @@ import {
|
|
|
21
24
|
} from "./agent-mode-setting.js";
|
|
22
25
|
import type { RunRoute } from "./cancellable-operation.js";
|
|
23
26
|
import { directoryScopeSummary, showExcludedPaths } from "./excluded-paths-ui.js";
|
|
24
|
-
import {
|
|
27
|
+
import { manualIgnoreFileGuidance } from "./ignore-file-guidance.js";
|
|
28
|
+
import { ignoreFileSettingsAvailable, showIgnoreFileAction } from "./ignore-file-ui.js";
|
|
25
29
|
import { dispatchManagerResult } from "./manager-result-dispatcher.js";
|
|
26
30
|
import { boundedSettingsUI } from "./settings-frame.js";
|
|
27
31
|
import { IGNORE_SETUP_MANAGEMENT_LIMIT, ignoreSetupRecovery } from "./settings-review.js";
|
|
@@ -65,13 +69,16 @@ export async function showSyncSettings(
|
|
|
65
69
|
} catch {
|
|
66
70
|
config = undefined;
|
|
67
71
|
}
|
|
72
|
+
const limited = config?.reservedIgnoreNames !== undefined && !(await ignoreFileSettingsAvailable(ctx, signal));
|
|
73
|
+
if (!isCurrent()) return disposition;
|
|
68
74
|
ctx.ui.notify(
|
|
69
75
|
[
|
|
70
76
|
document === null
|
|
71
77
|
? "Could not read the active pi-sync settings file. Check file access or repair the JSON before reopening /sync."
|
|
72
78
|
: `Edit pi-sync settings manually: ${safeTerminalText(settingsPath)}`,
|
|
73
|
-
...(
|
|
74
|
-
|
|
79
|
+
...(limited ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(settingsPath)] : []),
|
|
80
|
+
...(!limited && config?.reservedIgnoreNames !== undefined
|
|
81
|
+
? ["Use TUI Settings → Review automatic transfers to approve the current setup separately."]
|
|
75
82
|
: []),
|
|
76
83
|
...(config?.pathPolicy === "ignore-file"
|
|
77
84
|
? [manualIgnoreFileGuidance(config.ignoreFile ?? ".syncignore")]
|
|
@@ -119,6 +126,7 @@ export async function showSyncSettings(
|
|
|
119
126
|
| "automatic-transfer"
|
|
120
127
|
| "agent-mode"
|
|
121
128
|
| "continuous"
|
|
129
|
+
| "authorize-automatic"
|
|
122
130
|
| "merge-settings"
|
|
123
131
|
| "local-fields"
|
|
124
132
|
| "content-policy"
|
|
@@ -129,7 +137,6 @@ export async function showSyncSettings(
|
|
|
129
137
|
| "include"
|
|
130
138
|
| "exclude"
|
|
131
139
|
| "ignore-switch"
|
|
132
|
-
| "ignore-edit"
|
|
133
140
|
| "ignore-migrate"
|
|
134
141
|
| "remote-include"
|
|
135
142
|
| "storage-location"
|
|
@@ -146,14 +153,10 @@ export async function showSyncSettings(
|
|
|
146
153
|
title: "Pi Sync Settings",
|
|
147
154
|
lines: [
|
|
148
155
|
`Setup: ${safeTerminalText(state.setupName)} · Connection: ${safeTerminalText(state.connectionName)}`,
|
|
149
|
-
...(state.reservedIgnoreNames !== undefined
|
|
150
|
-
? [
|
|
151
|
-
"Setup preferences are read-only; adding, editing, and switching setups are unavailable.",
|
|
152
|
-
state.pathPolicy === "ignore-file" && !ignoreAvailable
|
|
153
|
-
? manualIgnoreFileGuidance(state.ignoreFile ?? ".syncignore")
|
|
154
|
-
: "Open Manage sync setups for manual recovery.",
|
|
155
|
-
]
|
|
156
|
+
...(state.reservedIgnoreNames !== undefined && !ignoreAvailable
|
|
157
|
+
? ["Setup preferences are read-only; adding, editing, and switching setups are unavailable."]
|
|
156
158
|
: [saveStatus]),
|
|
159
|
+
...(state.pathPolicy === "ignore-file" ? [manualIgnoreFileGuidance(state.ignoreFile ?? ".syncignore")] : []),
|
|
157
160
|
],
|
|
158
161
|
items: (
|
|
159
162
|
[
|
|
@@ -163,62 +166,55 @@ export async function showSyncSettings(
|
|
|
163
166
|
{
|
|
164
167
|
id: "ignoreFile",
|
|
165
168
|
label: "Ignore file",
|
|
166
|
-
description:
|
|
169
|
+
description: `Select another existing local file. Sessions: ${state.include.includes("sessions") ? "opted in (rules still apply)" : "off"}. No transfer starts.`,
|
|
167
170
|
currentValue: safeTerminalText(state.ignoreFile ?? ".syncignore"),
|
|
168
171
|
action: "ignore-switch" as const,
|
|
169
172
|
},
|
|
170
|
-
{
|
|
171
|
-
id: "ignoreRules",
|
|
172
|
-
label: "Edit ignore rules…",
|
|
173
|
-
description: `Edit the existing local rules, then confirm separately. Sessions: ${state.include.includes("sessions") ? "opted in (ignore rules still apply)" : "off"}.`,
|
|
174
|
-
currentValue: "Edit",
|
|
175
|
-
action: "ignore-edit" as const,
|
|
176
|
-
},
|
|
177
173
|
]
|
|
178
174
|
: []
|
|
179
|
-
: ignoreAvailable
|
|
180
|
-
? [
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
"
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
...(state.reservedIgnoreNames !== undefined
|
|
175
|
+
: state.reservedIgnoreNames !== undefined && !ignoreAvailable
|
|
176
|
+
? []
|
|
177
|
+
: state.scope === "agent-directory"
|
|
178
|
+
? [
|
|
179
|
+
{
|
|
180
|
+
id: "include",
|
|
181
|
+
label: "Agent directory scope",
|
|
182
|
+
description:
|
|
183
|
+
"Edit exclusions, re-inclusions, and session opt-in in one reviewed draft. No transfer starts.",
|
|
184
|
+
currentValue: `${state.exclude?.length ?? 0} excluded · ${state.reinclude?.length ?? 0} re-included · Sessions ${state.include.includes("sessions") ? "opted in" : "off"}`,
|
|
185
|
+
action: "include" as const,
|
|
186
|
+
},
|
|
187
|
+
]
|
|
188
|
+
: [
|
|
189
|
+
{
|
|
190
|
+
id: "include",
|
|
191
|
+
label: "Included paths",
|
|
192
|
+
description:
|
|
193
|
+
"This setup: choose paths in a draft, then review and Save or Discard. No transfer is started.",
|
|
194
|
+
currentValue: `${state.include.length} paths · Edit`,
|
|
195
|
+
action: "include" as const,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "exclude",
|
|
199
|
+
label: "Excluded paths",
|
|
200
|
+
description:
|
|
201
|
+
"This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
|
|
202
|
+
currentValue: `${state.exclude?.length ?? 0} rules · Edit`,
|
|
203
|
+
action: "exclude" as const,
|
|
204
|
+
},
|
|
205
|
+
]),
|
|
206
|
+
...(ignoreAvailable && state.pathPolicy !== "ignore-file"
|
|
207
|
+
? [
|
|
208
|
+
{
|
|
209
|
+
id: "migrateIgnoreFile",
|
|
210
|
+
label: "Migrate to ignore file…",
|
|
211
|
+
description: "Review the scope change for this legacy setup. Migration does not start a transfer.",
|
|
212
|
+
currentValue: "Review",
|
|
213
|
+
action: "ignore-migrate" as const,
|
|
214
|
+
},
|
|
215
|
+
]
|
|
216
|
+
: []),
|
|
217
|
+
...(state.reservedIgnoreNames !== undefined && !ignoreAvailable
|
|
222
218
|
? []
|
|
223
219
|
: [
|
|
224
220
|
{
|
|
@@ -228,7 +224,9 @@ export async function showSyncSettings(
|
|
|
228
224
|
? "Compare sync policies"
|
|
229
225
|
: "Compare included paths",
|
|
230
226
|
description:
|
|
231
|
-
|
|
227
|
+
state.pathPolicy === "ignore-file"
|
|
228
|
+
? "Read-only comparison of local and remote policy, not file contents."
|
|
229
|
+
: "Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
|
|
232
230
|
currentValue: "Review",
|
|
233
231
|
action: "remote-include" as const,
|
|
234
232
|
},
|
|
@@ -257,7 +255,7 @@ export async function showSyncSettings(
|
|
|
257
255
|
id: "setups",
|
|
258
256
|
label: "Manage sync setups",
|
|
259
257
|
description:
|
|
260
|
-
state.reservedIgnoreNames !== undefined
|
|
258
|
+
state.reservedIgnoreNames !== undefined && !ignoreAvailable
|
|
261
259
|
? "Review configured setups and recovery options. Adding, editing, and switching are unavailable."
|
|
262
260
|
: "This device: add, switch, edit, or remove sync setups. Each edit identifies its owner before saving.",
|
|
263
261
|
currentValue: "Open",
|
|
@@ -267,7 +265,7 @@ export async function showSyncSettings(
|
|
|
267
265
|
id: "connections",
|
|
268
266
|
label: "Manage storage connections",
|
|
269
267
|
description:
|
|
270
|
-
state.reservedIgnoreNames !== undefined
|
|
268
|
+
state.reservedIgnoreNames !== undefined && !ignoreAvailable
|
|
271
269
|
? "Review shared connections. Connection changes are unavailable while ignore-file setups are configured."
|
|
272
270
|
: "Shared connections on this device: review affected setups before saving server or credential changes.",
|
|
273
271
|
currentValue: "Open",
|
|
@@ -305,11 +303,27 @@ export async function showSyncSettings(
|
|
|
305
303
|
values: ["On", "Off"],
|
|
306
304
|
action: "continuous",
|
|
307
305
|
},
|
|
306
|
+
...(ignoreAvailable &&
|
|
307
|
+
state.reservedIgnoreNames !== undefined &&
|
|
308
|
+
(startupTransferEnabled(state) || (state.automatic && syncSessionsSelected(state)))
|
|
309
|
+
? [
|
|
310
|
+
{
|
|
311
|
+
id: "authorizeAutomatic",
|
|
312
|
+
label: "Review automatic transfers",
|
|
313
|
+
description:
|
|
314
|
+
"Separate approval for the enabled modes and exact current policy. Saving settings alone does not grant permission.",
|
|
315
|
+
currentValue: "Review",
|
|
316
|
+
action: "authorize-automatic" as const,
|
|
317
|
+
},
|
|
318
|
+
]
|
|
319
|
+
: []),
|
|
308
320
|
{
|
|
309
321
|
id: "onSwitch",
|
|
310
322
|
label: "On setup switch",
|
|
311
323
|
description:
|
|
312
|
-
|
|
324
|
+
state.reservedIgnoreNames === undefined
|
|
325
|
+
? "All setups on this device: ask before a pull review, open it automatically, or switch without pulling. Applies to subsequent switches."
|
|
326
|
+
: "While ignore-file setups exist, switching saves only the active setup. Run a reviewed pull separately.",
|
|
313
327
|
currentValue: setupSwitchActionLabel(state.onSwitch),
|
|
314
328
|
values: SETUP_SWITCH_ACTION_OPTIONS.map(({ label }) => label),
|
|
315
329
|
action: "on-switch",
|
|
@@ -366,8 +380,7 @@ export async function showSyncSettings(
|
|
|
366
380
|
},
|
|
367
381
|
] satisfies MenuSettingItem<Action>[]
|
|
368
382
|
).map((item) =>
|
|
369
|
-
state.reservedIgnoreNames !== undefined &&
|
|
370
|
-
!["setups", "connections", "ignoreFile", "ignoreRules", "migrateIgnoreFile"].includes(item.id)
|
|
383
|
+
state.reservedIgnoreNames !== undefined && !ignoreAvailable && !["setups", "connections"].includes(item.id)
|
|
371
384
|
? { ...item, disabled: true }
|
|
372
385
|
: item,
|
|
373
386
|
),
|
|
@@ -393,14 +406,14 @@ export async function showSyncSettings(
|
|
|
393
406
|
const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
394
407
|
const validate = captureMutationOwner(ctx, mutationSignal);
|
|
395
408
|
try {
|
|
396
|
-
const previous = await
|
|
409
|
+
const previous = await loadSettingsConfig(setupName);
|
|
397
410
|
validate();
|
|
398
411
|
const mergeContent = value === "Merge only" || value === "Merge + partial";
|
|
399
412
|
const partialSync = value === "Partial only" || value === "Merge + partial";
|
|
400
413
|
if (
|
|
401
414
|
!(await ctx.ui.confirm(
|
|
402
415
|
"Save content policy?",
|
|
403
|
-
`${previous.
|
|
416
|
+
`${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and snapshot version 6; older clients must refuse them." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5; older clients must refuse it." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
|
|
404
417
|
{ signal: mutationSignal },
|
|
405
418
|
))
|
|
406
419
|
)
|
|
@@ -457,7 +470,7 @@ export async function showSyncSettings(
|
|
|
457
470
|
const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
458
471
|
const validate = captureMutationOwner(ctx, mutationSignal);
|
|
459
472
|
try {
|
|
460
|
-
const previous = await
|
|
473
|
+
const previous = await loadSettingsConfig(setupName);
|
|
461
474
|
validate();
|
|
462
475
|
const input = await ctx.ui.input(
|
|
463
476
|
"Machine-local settings.json root fields (JSON string array)",
|
|
@@ -475,7 +488,7 @@ export async function showSyncSettings(
|
|
|
475
488
|
if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
|
|
476
489
|
const confirmed = await ctx.ui.confirm(
|
|
477
490
|
"Save portable field policy?",
|
|
478
|
-
`${previous.
|
|
491
|
+
`${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and snapshot version 6." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
|
|
479
492
|
{ signal: mutationSignal },
|
|
480
493
|
);
|
|
481
494
|
validate();
|
|
@@ -513,7 +526,7 @@ export async function showSyncSettings(
|
|
|
513
526
|
const automatic = value === "On";
|
|
514
527
|
const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
515
528
|
try {
|
|
516
|
-
const latest = await
|
|
529
|
+
const latest = await loadSettingsConfig(setupName);
|
|
517
530
|
if (mutationSignal.aborted) return { kind: "rejected" };
|
|
518
531
|
if (latest.automatic === automatic) return { kind: "stay" };
|
|
519
532
|
await updateSyncSetup(setupName, (setup) => ({ ...setup, sync: { ...setup.sync, automatic } }), {
|
|
@@ -607,7 +620,7 @@ export async function showSyncSettings(
|
|
|
607
620
|
const skipSecretScan = value === "On";
|
|
608
621
|
const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
609
622
|
try {
|
|
610
|
-
const latest = await
|
|
623
|
+
const latest = await loadSettingsConfig(setupName);
|
|
611
624
|
if (mutationSignal.aborted) return { kind: "rejected" };
|
|
612
625
|
if (latest.skipSecretScan === skipSecretScan) return { kind: "stay" };
|
|
613
626
|
await updateLocalConfig((settings) => ({ ...settings, skipSecretScan }), mutationSignal);
|
|
@@ -623,7 +636,7 @@ export async function showSyncSettings(
|
|
|
623
636
|
const showStatus = value === "On";
|
|
624
637
|
const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
625
638
|
try {
|
|
626
|
-
const latest = await
|
|
639
|
+
const latest = await loadSettingsConfig(setupName);
|
|
627
640
|
if (mutationSignal.aborted) return { kind: "rejected" };
|
|
628
641
|
if (latest.showStatus === showStatus) return { kind: "stay" };
|
|
629
642
|
await updateLocalConfig((settings) => ({ ...settings, showStatus }), mutationSignal);
|
|
@@ -653,7 +666,7 @@ export async function showSyncSettings(
|
|
|
653
666
|
if (!action) return { kind: "rejected" };
|
|
654
667
|
const mutationSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
655
668
|
try {
|
|
656
|
-
const latest = await
|
|
669
|
+
const latest = await loadSettingsConfig(setupName);
|
|
657
670
|
if (mutationSignal.aborted) return { kind: "rejected" };
|
|
658
671
|
if (latest.onSwitch === action) return { kind: "stay" };
|
|
659
672
|
await saveOnSwitch(action, mutationSignal);
|
|
@@ -675,17 +688,47 @@ export async function showSyncSettings(
|
|
|
675
688
|
await showExcludedPaths(ctx, setupName, editorSignal);
|
|
676
689
|
return resumeSettings(editorSignal);
|
|
677
690
|
},
|
|
691
|
+
"authorize-automatic": async ({ state, signal: actionSignal }) => {
|
|
692
|
+
const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
693
|
+
const validate = captureMutationOwner(ctx, reviewSignal);
|
|
694
|
+
const client = piDaemonClient(ctx);
|
|
695
|
+
try {
|
|
696
|
+
validate();
|
|
697
|
+
const policy = (await client.run("daemon.policy", {}, reviewSignal)) as {
|
|
698
|
+
setup: string;
|
|
699
|
+
fingerprint: string;
|
|
700
|
+
automatic: boolean;
|
|
701
|
+
};
|
|
702
|
+
validate();
|
|
703
|
+
if (policy.setup !== state.setupName) return exitSettings();
|
|
704
|
+
if (policy.automatic) {
|
|
705
|
+
ctx.ui.notify("Automatic work is already approved for this setup and policy.", "info");
|
|
706
|
+
return { kind: "stay" };
|
|
707
|
+
}
|
|
708
|
+
const accepted = await client.run(
|
|
709
|
+
"daemon.authorize-connected",
|
|
710
|
+
{ fingerprint: policy.fingerprint },
|
|
711
|
+
reviewSignal,
|
|
712
|
+
);
|
|
713
|
+
validate();
|
|
714
|
+
if (accepted === true) ctx.ui.notify("Automatic work approved for this setup and policy.", "info");
|
|
715
|
+
return { kind: "stay" };
|
|
716
|
+
} catch (error) {
|
|
717
|
+
if (reviewSignal.aborted || !isCurrent()) return exitSettings();
|
|
718
|
+
notifySaveFailure(ctx, error);
|
|
719
|
+
return { kind: "rejected" };
|
|
720
|
+
}
|
|
721
|
+
},
|
|
678
722
|
"ignore-switch": ignoreAction("switch"),
|
|
679
|
-
"ignore-edit": ignoreAction("edit"),
|
|
680
723
|
"ignore-migrate": ignoreAction("migrate"),
|
|
681
724
|
"remote-include": async ({ state, signal: actionSignal }) => {
|
|
682
|
-
if (state.reservedIgnoreNames !== undefined) return { kind: "rejected" };
|
|
725
|
+
if (state.reservedIgnoreNames !== undefined && !ignoreAvailable) return { kind: "rejected" };
|
|
683
726
|
const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
684
727
|
const { showRemoteSelectionReview } = await import("./remote-selection-ui.js");
|
|
685
728
|
if (reviewSignal.aborted) return { kind: "rejected" };
|
|
686
729
|
const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, undefined, {
|
|
687
730
|
origin: "settings",
|
|
688
|
-
runRoute,
|
|
731
|
+
...(state.pathPolicy === "ignore-file" ? { readOnly: true } : { runRoute }),
|
|
689
732
|
});
|
|
690
733
|
if (reviewSignal.aborted) return { kind: "rejected" };
|
|
691
734
|
if (review.kind === "route-result") {
|
|
@@ -717,7 +760,9 @@ export async function showSyncSettings(
|
|
|
717
760
|
result?.kind === "rejected"
|
|
718
761
|
? "Save failed or rejected. Previous value retained; retry is available."
|
|
719
762
|
: id === "automatic-transfer" || id === "automatic" || id === "debug"
|
|
720
|
-
?
|
|
763
|
+
? action.state.reservedIgnoreNames !== undefined
|
|
764
|
+
? "Saved. Review automatic transfers separately before enabling automatic work for this policy."
|
|
765
|
+
: "Saved. Enabling startup work applies next session start; completed transfers are not undone."
|
|
721
766
|
: "Saved. Applies to subsequent operations; status visibility applies immediately.";
|
|
722
767
|
ctx.ui.notify(saveStatus, result?.kind === "rejected" ? "warning" : "info");
|
|
723
768
|
return result;
|
|
@@ -728,6 +773,12 @@ export async function showSyncSettings(
|
|
|
728
773
|
if (!ignoreAvailable || (state.pathPolicy === "ignore-file") === (action === "migrate"))
|
|
729
774
|
return { kind: "rejected" as const };
|
|
730
775
|
const editorSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
776
|
+
const latest = await loadSettingsConfig();
|
|
777
|
+
if (editorSignal.aborted || !isCurrent()) return { kind: "close" as const };
|
|
778
|
+
if (syncCheckConfigFingerprint(latest) !== syncCheckConfigFingerprint(state)) {
|
|
779
|
+
ctx.ui.notify("Sync setup changed while Settings was open; reopen it before changing the policy.", "warning");
|
|
780
|
+
return { kind: "close" as const };
|
|
781
|
+
}
|
|
731
782
|
await showIgnoreFileAction(ctx, setupName, action, state.ignoreFile ?? ".syncignore", editorSignal);
|
|
732
783
|
return resumeSettings(editorSignal);
|
|
733
784
|
};
|
|
@@ -4,6 +4,7 @@ import { loadPartialConfig } from "../../settings/config.js";
|
|
|
4
4
|
import { removeSyncSetup } from "../../settings/settings-management.js";
|
|
5
5
|
import { readLocalConfigObject } from "../../settings/settings-store.js";
|
|
6
6
|
import { ownRecord } from "../../settings/settings-validation.js";
|
|
7
|
+
import { captureMutationOwner } from "../../sync/sync-local.js";
|
|
7
8
|
import type { RunRoute } from "../cancellable-operation.js";
|
|
8
9
|
import { showAddStorageConnection } from "../storage-connections-ui.js";
|
|
9
10
|
import { showSyncSetups } from "../sync-setups-ui.js";
|
|
@@ -99,15 +100,26 @@ export async function showEditSyncSetupStorage(ctx: ExtensionCommandContext, nam
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
async function showRemoveTarget(ctx: ExtensionCommandContext, name: string, signal?: AbortSignal) {
|
|
103
|
+
const validate = captureMutationOwner(ctx, signal);
|
|
102
104
|
const confirmed = await ctx.ui.confirm(
|
|
103
105
|
"Remove sync setup?",
|
|
104
106
|
`Remove local sync setup “${safeTerminalText(name)}”? Remote data and history are not deleted.`,
|
|
105
107
|
{ signal },
|
|
106
108
|
);
|
|
107
109
|
if (signal?.aborted || !confirmed) return;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
validate();
|
|
111
|
+
const { revertedToLegacyOnly } = await removeSyncSetup(name, signal);
|
|
112
|
+
try {
|
|
113
|
+
validate();
|
|
114
|
+
} catch {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const message = `Removed sync setup “${safeTerminalText(name)}”; remote data was not deleted.`;
|
|
118
|
+
ctx.ui.notify(
|
|
119
|
+
revertedToLegacyOnly
|
|
120
|
+
? `${message} To resume Continuous sync if enabled, close /sync and run /reload in an attached TUI session, or reopen one Pi client.`
|
|
121
|
+
: message,
|
|
122
|
+
"info",
|
|
123
|
+
);
|
|
110
124
|
await refreshTargetCompletions();
|
|
111
|
-
if (signal?.aborted) return;
|
|
112
|
-
ctx.ui.notify(`Removed sync setup “${safeTerminalText(name)}”; remote data was not deleted.`, "info");
|
|
113
125
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { type ExtensionCommandContext, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import { readLocalConfigObject } from "../../settings/settings-store.js";
|
|
3
4
|
import type { SyncPolicySettings } from "../../settings/settings-types.js";
|
|
4
5
|
import { validateConfigName } from "../../settings/settings-validation.js";
|
|
6
|
+
import { captureMutationOwner } from "../../sync/sync-local.js";
|
|
5
7
|
import { DEFAULT_SYNC_INCLUDE } from "../../sync/sync-policy.js";
|
|
8
|
+
import { ignoreFileSettingsAvailable } from "../ignore-file-ui.js";
|
|
6
9
|
import { AUTOMATIC_SYNC_DESCRIPTION } from "../sync-behavior.js";
|
|
7
10
|
import { safeTerminalText } from "../terminal-text.js";
|
|
8
11
|
import {
|
|
@@ -26,11 +29,25 @@ export async function chooseSetupPolicy(
|
|
|
26
29
|
ctx: ExtensionCommandContext,
|
|
27
30
|
signal?: AbortSignal,
|
|
28
31
|
{ legacySessions = false } = {},
|
|
29
|
-
): Promise<{ sync: SyncPolicySettings; lines: string[]; join: boolean } | undefined> {
|
|
32
|
+
): Promise<{ sync: SyncPolicySettings; lines: string[]; join: boolean | "read-only" } | undefined> {
|
|
33
|
+
const validate = captureMutationOwner(ctx, signal);
|
|
34
|
+
const ignoreAvailable = ctx.mode === "tui" && (await ignoreFileSettingsAvailable(ctx, signal));
|
|
35
|
+
if (signal?.aborted) return;
|
|
36
|
+
validate();
|
|
37
|
+
const ignoreChoice = "Use .syncignore (recommended)";
|
|
38
|
+
const directoryChoice = ignoreAvailable ? "Agent directory · legacy rules" : "Agent directory (recommended)";
|
|
30
39
|
const choice = await ctx.ui.select(
|
|
31
|
-
"Choose synced content\n\nAgent directory (recommended): sync all eligible files, including custom paths, except sessions, bin, and npm.\nJoining existing storage? Review its policy after saving. It will not be adopted automatically.\nLegacy mode: use a fixed list of included paths.",
|
|
32
40
|
[
|
|
33
|
-
"
|
|
41
|
+
"Choose synced content",
|
|
42
|
+
ignoreAvailable
|
|
43
|
+
? "Use .syncignore to control eligible files in the Pi agent directory. Its rules stay on this device."
|
|
44
|
+
: "Agent directory (recommended): sync all eligible files, including custom paths, except sessions, bin, and npm.",
|
|
45
|
+
"Joining existing storage? Review its policy after saving. It will not be adopted automatically.",
|
|
46
|
+
"Legacy selected paths use a fixed list of included paths.",
|
|
47
|
+
].join("\n\n"),
|
|
48
|
+
[
|
|
49
|
+
...(ignoreAvailable ? [ignoreChoice] : []),
|
|
50
|
+
directoryChoice,
|
|
34
51
|
"Agent directory · edit starter rules",
|
|
35
52
|
"Join an existing remote",
|
|
36
53
|
"Recommended Pi settings",
|
|
@@ -40,10 +57,12 @@ export async function chooseSetupPolicy(
|
|
|
40
57
|
{ signal },
|
|
41
58
|
);
|
|
42
59
|
if (signal?.aborted || !choice || choice === "Cancel") return undefined;
|
|
60
|
+
validate();
|
|
43
61
|
const join = choice === "Join an existing remote";
|
|
44
62
|
if (
|
|
45
63
|
!join &&
|
|
46
|
-
|
|
64
|
+
!(ignoreAvailable && choice === ignoreChoice) &&
|
|
65
|
+
choice !== directoryChoice &&
|
|
47
66
|
choice !== "Agent directory · edit starter rules" &&
|
|
48
67
|
choice !== "Recommended Pi settings" &&
|
|
49
68
|
choice !== "Minimal settings"
|
|
@@ -52,12 +71,32 @@ export async function chooseSetupPolicy(
|
|
|
52
71
|
const joinScope = join
|
|
53
72
|
? await ctx.ui.select(
|
|
54
73
|
"Choose the existing remote's scope\n\nUse Selected paths for an older setup with an include list. These choices do not change the remote's scope.",
|
|
55
|
-
["Pi agent directory", "Selected paths (legacy)", "Cancel"],
|
|
74
|
+
[...(ignoreAvailable ? [ignoreChoice] : []), "Pi agent directory", "Selected paths (legacy)", "Cancel"],
|
|
56
75
|
{ signal },
|
|
57
76
|
)
|
|
58
77
|
: undefined;
|
|
59
|
-
|
|
78
|
+
const usesIgnore = ignoreAvailable && (choice === ignoreChoice || joinScope === ignoreChoice);
|
|
79
|
+
if (
|
|
80
|
+
signal?.aborted ||
|
|
81
|
+
(join && !usesIgnore && joinScope !== "Pi agent directory" && joinScope !== "Selected paths (legacy)")
|
|
82
|
+
)
|
|
60
83
|
return undefined;
|
|
84
|
+
validate();
|
|
85
|
+
if (usesIgnore) {
|
|
86
|
+
const sessions = join ? false : await chooseSessions(ctx, signal);
|
|
87
|
+
if (signal?.aborted || sessions === undefined) return;
|
|
88
|
+
validate();
|
|
89
|
+
return {
|
|
90
|
+
sync: { scope: "agent-directory", pathPolicy: "ignore-file", sessions, automatic: false },
|
|
91
|
+
lines: [
|
|
92
|
+
`Local ignore file: ${safeTerminalText(resolve(getAgentDir(), ".syncignore"))}`,
|
|
93
|
+
"An existing valid file is reused as-is. If the daemon cannot create it safely, create it manually with the starter line /sessions/, then retry setup. Do not overwrite an existing file.",
|
|
94
|
+
`Sessions: ${sessions ? "opted in — ignore rules still apply" : "Off"}`,
|
|
95
|
+
"Rules are local only. Compare policy before transferring to existing storage. Peers must support ignore-file snapshots before the first push.",
|
|
96
|
+
],
|
|
97
|
+
join: join ? "read-only" : false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
61
100
|
const legacy =
|
|
62
101
|
choice === "Recommended Pi settings" || choice === "Minimal settings" || joinScope === "Selected paths (legacy)";
|
|
63
102
|
const draft = starterDirectoryRules();
|
|
@@ -65,15 +104,19 @@ export async function chooseSetupPolicy(
|
|
|
65
104
|
if (editRules) {
|
|
66
105
|
const exclude = await promptDirectoryRules(ctx, "exclude", draft.exclude, signal);
|
|
67
106
|
if (signal?.aborted || !exclude) return undefined;
|
|
107
|
+
validate();
|
|
68
108
|
draft.exclude = exclude;
|
|
69
109
|
const reinclude = await promptDirectoryRules(ctx, "reinclude", draft.reinclude, signal);
|
|
70
110
|
if (signal?.aborted || !reinclude) return undefined;
|
|
111
|
+
validate();
|
|
71
112
|
draft.reinclude = reinclude;
|
|
72
113
|
}
|
|
73
114
|
const automatic = join ? false : await chooseAutomaticSync(ctx, signal);
|
|
74
115
|
if (signal?.aborted || automatic === undefined) return undefined;
|
|
116
|
+
validate();
|
|
75
117
|
const sessions = join || (legacy && !legacySessions) ? false : await chooseSessions(ctx, signal);
|
|
76
118
|
if (signal?.aborted || sessions === undefined) return undefined;
|
|
119
|
+
validate();
|
|
77
120
|
const remoteWarning = join
|
|
78
121
|
? "After saving, compare the remote policy. Automatic sync and sessions start Off. No policy is adopted without your review."
|
|
79
122
|
: "If this location already has sync data, compare its policy in Settings before transferring. A mismatch blocks sync.";
|
|
@@ -104,7 +147,7 @@ export async function finishSetup(
|
|
|
104
147
|
ctx: ExtensionCommandContext,
|
|
105
148
|
name: string,
|
|
106
149
|
message: string,
|
|
107
|
-
join: boolean,
|
|
150
|
+
join: boolean | "read-only",
|
|
108
151
|
signal?: AbortSignal,
|
|
109
152
|
) {
|
|
110
153
|
if (signal?.aborted) return;
|
|
@@ -112,7 +155,10 @@ export async function finishSetup(
|
|
|
112
155
|
if (!join) return;
|
|
113
156
|
const { showRemoteSelectionReview } = await import("../remote-selection-ui.js");
|
|
114
157
|
if (signal?.aborted) return;
|
|
115
|
-
await showRemoteSelectionReview(ctx, name, signal, undefined, {
|
|
158
|
+
await showRemoteSelectionReview(ctx, name, signal, undefined, {
|
|
159
|
+
origin: "settings",
|
|
160
|
+
...(join === "read-only" ? { readOnly: true } : {}),
|
|
161
|
+
});
|
|
116
162
|
}
|
|
117
163
|
|
|
118
164
|
export async function chooseAutomaticSync(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
loadConfigForCheck,
|
|
5
|
+
loadSettingsConfig,
|
|
6
|
+
syncCheckConfigFingerprint,
|
|
7
|
+
syncConfigReviewIdentity,
|
|
8
|
+
} from "../../settings/config.js";
|
|
4
9
|
import { loadOnSwitch, readLocalConfigObject } from "../../settings/settings-store.js";
|
|
5
10
|
import type { AnySyncConfig } from "../../settings/settings-types.js";
|
|
6
11
|
import { ownRecord } from "../../settings/settings-validation.js";
|
|
@@ -103,8 +108,11 @@ export async function showSetupSwitcher(
|
|
|
103
108
|
return false;
|
|
104
109
|
}
|
|
105
110
|
let config: AnySyncConfig;
|
|
111
|
+
let metadata: AnySyncConfig;
|
|
106
112
|
try {
|
|
107
|
-
|
|
113
|
+
metadata = await loadSettingsConfig(name);
|
|
114
|
+
if (signal?.aborted) return false;
|
|
115
|
+
config = await loadConfigForCheck(name, signal);
|
|
108
116
|
if (signal?.aborted) return false;
|
|
109
117
|
} catch (error) {
|
|
110
118
|
ctx.ui.notify(
|
|
@@ -116,20 +124,24 @@ export async function showSetupSwitcher(
|
|
|
116
124
|
const onSwitch = await loadOnSwitch();
|
|
117
125
|
if (signal?.aborted) return false;
|
|
118
126
|
const switchEffect =
|
|
119
|
-
|
|
120
|
-
? "
|
|
121
|
-
: onSwitch === "
|
|
122
|
-
? "After switching, pi-sync will
|
|
123
|
-
:
|
|
127
|
+
config.reservedIgnoreNames !== undefined
|
|
128
|
+
? "This switch only saves the active setup. To transfer, use a reviewed /sync command."
|
|
129
|
+
: onSwitch === "ask-before-pull"
|
|
130
|
+
? "After switching, pi-sync will ask whether to review a pull for this setup."
|
|
131
|
+
: onSwitch === "pull-after-switch"
|
|
132
|
+
? "After switching, pi-sync will check this setup and show exact changes before applying them."
|
|
133
|
+
: "After switching, pi-sync will not pull or modify synced files.";
|
|
124
134
|
const confirmed = await ctx.ui.confirm(
|
|
125
135
|
"Switch sync setup?",
|
|
126
136
|
[
|
|
127
137
|
`From: ${safeTerminalText(active ?? "none")}`,
|
|
128
138
|
`To: ${safeTerminalText(name)}`,
|
|
129
139
|
`Storage: ${backendStorageDescription(config)}`,
|
|
130
|
-
config.
|
|
131
|
-
? `Scope: Pi agent directory ·
|
|
132
|
-
:
|
|
140
|
+
config.pathPolicy === "ignore-file"
|
|
141
|
+
? `Scope: Pi agent directory · ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}`
|
|
142
|
+
: config.scope === "agent-directory"
|
|
143
|
+
? `Scope: Pi agent directory · ${config.exclude?.length ?? 0} excluded and ${config.reinclude?.length ?? 0} re-included rules`
|
|
144
|
+
: `Included content: ${config.include.length} paths`,
|
|
133
145
|
`Automatic sync: ${automaticSyncSummary(config.automatic)} · Sessions: ${syncSessionsSelected(config) ? "On" : "Off"}`,
|
|
134
146
|
`Automatic transfer at startup: ${config.automaticTransfer ? "On — may upload, replace, or delete selected files; no reload" : "Off"}`,
|
|
135
147
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
@@ -168,7 +180,8 @@ export async function showSetupSwitcher(
|
|
|
168
180
|
},
|
|
169
181
|
onSwitch,
|
|
170
182
|
signal,
|
|
171
|
-
syncConfigReviewIdentity(
|
|
183
|
+
syncConfigReviewIdentity(metadata),
|
|
184
|
+
syncCheckConfigFingerprint(config),
|
|
172
185
|
);
|
|
173
186
|
if (pullClosed) return "closed";
|
|
174
187
|
return result.pullApplied ? "pull-attempted" : "switched";
|