@narumitw/pi-sync 0.60.5 → 0.61.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 +8 -6
- package/dist/chunks/chunk-2JHAN3ZO.ts +139 -0
- package/dist/chunks/chunk-2JHAN3ZO.ts.map +7 -0
- package/dist/chunks/chunk-2ZGV5KNC.ts +274 -0
- package/dist/chunks/chunk-2ZGV5KNC.ts.map +7 -0
- package/dist/chunks/{chunk-LAXTCSX4.ts → chunk-4KTJLJSJ.ts} +117 -132
- package/dist/chunks/chunk-4KTJLJSJ.ts.map +7 -0
- package/dist/chunks/chunk-4SR3ZYHA.ts +14 -0
- package/dist/chunks/chunk-4SR3ZYHA.ts.map +7 -0
- package/dist/chunks/{chunk-6KIWZ4AY.ts → chunk-E3YLRLJM.ts} +5 -4
- package/dist/chunks/chunk-E3YLRLJM.ts.map +7 -0
- package/dist/chunks/{chunk-KPWZNMKM.ts → chunk-ECYCNZOE.ts} +1 -5
- package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
- package/dist/chunks/{chunk-F64YWRXG.ts → chunk-EMVZL4PH.ts} +2 -2
- package/dist/chunks/{chunk-YVH5VJR4.ts → chunk-JVFCVPPD.ts} +104 -50
- package/dist/chunks/chunk-JVFCVPPD.ts.map +7 -0
- package/dist/chunks/{chunk-MCUZFUHY.ts → chunk-PJMM75W5.ts} +6 -6
- package/dist/chunks/{chunk-V2QIMC3U.ts → chunk-S7F4FOAS.ts} +10 -5
- package/dist/chunks/chunk-S7F4FOAS.ts.map +7 -0
- package/dist/chunks/{chunk-6W2SNZ5P.ts → chunk-YQSFJLJ3.ts} +6 -2
- package/dist/chunks/{chunk-6W2SNZ5P.ts.map → chunk-YQSFJLJ3.ts.map} +3 -3
- package/dist/chunks/{chunk-V4AMI3VL.ts → chunk-ZVGRZD4C.ts} +9 -1
- package/dist/chunks/chunk-ZVGRZD4C.ts.map +7 -0
- package/dist/chunks/{command-handler-TNPWFIPG.ts → command-handler-K4XJOGYC.ts} +41 -37
- package/dist/chunks/{command-handler-TNPWFIPG.ts.map → command-handler-K4XJOGYC.ts.map} +2 -2
- package/dist/chunks/{conflict-review-ETCSYJTH.ts → conflict-review-IGKY2TOJ.ts} +3 -3
- package/dist/chunks/{file-selection-DD6X4J2K.ts → file-selection-MGGVOKM7.ts} +26 -13
- package/dist/chunks/file-selection-MGGVOKM7.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-2GFNWHDM.ts → manager-result-dispatcher-4VJVDEUD.ts} +7 -6
- package/dist/chunks/{manager-ui-LFONXWQN.ts → manager-ui-KYQ5AZJS.ts} +134 -203
- package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-GFR6TDTX.ts → remote-selection-ui-W3KOZM3W.ts} +6 -5
- package/dist/chunks/{setup-switch-SPZE7HIQ.ts → setup-switch-D6K6PBPC.ts} +3 -3
- package/dist/chunks/{setup-wizard-5JYKAEIT.ts → setup-wizard-4DYUDHJR.ts} +13 -11
- package/dist/chunks/setup-wizard-4DYUDHJR.ts.map +7 -0
- package/dist/chunks/{sync-inspection-6VGR2UVZ.ts → sync-inspection-J3CRBORL.ts} +5 -5
- package/dist/chunks/{sync-operations-SAKAZL6Z.ts → sync-operations-BVWYYKH3.ts} +3 -3
- package/dist/index.ts +21 -21
- package/package.json +4 -4
- package/skills/configure-pi-sync/references/configuration.md +59 -32
- package/src/commands/command-execution.ts +7 -1
- package/src/daemon/pi-client.ts +1 -0
- package/src/sync/sync-policy.ts +5 -0
- package/src/ui/agent-mode-setting.ts +9 -1
- package/src/ui/excluded-paths-ui.ts +154 -2
- package/src/ui/file-selection.ts +12 -7
- package/src/ui/manager-state.ts +13 -8
- package/src/ui/remote-selection-ui.ts +120 -27
- package/src/ui/settings-frame.ts +2 -8
- package/src/ui/settings-ui.ts +51 -26
- package/src/ui/setup/directory-rules.ts +81 -0
- package/src/ui/setup/git-ui.ts +14 -24
- package/src/ui/setup/s3-ui.ts +13 -26
- package/src/ui/setup/setup-actions.ts +0 -4
- package/src/ui/setup/setup-prompts.ts +99 -17
- package/src/ui/setup/setup-switcher.ts +4 -2
- package/src/ui/setup/setup-wizard.ts +5 -4
- package/src/ui/setup/webdav-ui.ts +13 -27
- package/src/ui/storage-connections-ui.ts +2 -2
- package/src/ui/sync-attention.ts +8 -3
- package/src/ui/sync-format.ts +8 -1
- package/src/ui/sync-setups-ui.ts +5 -3
- package/dist/chunks/chunk-6KIWZ4AY.ts.map +0 -7
- package/dist/chunks/chunk-KPWZNMKM.ts.map +0 -7
- package/dist/chunks/chunk-LAXTCSX4.ts.map +0 -7
- package/dist/chunks/chunk-V2QIMC3U.ts.map +0 -7
- package/dist/chunks/chunk-V4AMI3VL.ts.map +0 -7
- package/dist/chunks/chunk-YVH5VJR4.ts.map +0 -7
- package/dist/chunks/file-selection-DD6X4J2K.ts.map +0 -7
- package/dist/chunks/manager-ui-LFONXWQN.ts.map +0 -7
- package/dist/chunks/setup-wizard-5JYKAEIT.ts.map +0 -7
- /package/dist/chunks/{chunk-F64YWRXG.ts.map → chunk-EMVZL4PH.ts.map} +0 -0
- /package/dist/chunks/{chunk-MCUZFUHY.ts.map → chunk-PJMM75W5.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-ETCSYJTH.ts.map → conflict-review-IGKY2TOJ.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-2GFNWHDM.ts.map → manager-result-dispatcher-4VJVDEUD.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-GFR6TDTX.ts.map → remote-selection-ui-W3KOZM3W.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-SPZE7HIQ.ts.map → setup-switch-D6K6PBPC.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-6VGR2UVZ.ts.map → sync-inspection-J3CRBORL.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-SAKAZL6Z.ts.map → sync-operations-BVWYYKH3.ts.map} +0 -0
package/src/ui/manager-state.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-st
|
|
|
14
14
|
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
15
15
|
import { errorMessage } from "../sync/sync-errors.js";
|
|
16
16
|
import type { StartupObservation } from "../sync/sync-inspection.js";
|
|
17
|
-
import { compareSyncInclude, syncSessionsSelected } from "../sync/sync-policy.js";
|
|
17
|
+
import { compareSyncInclude, syncSelectionHasContent, syncSessionsSelected } from "../sync/sync-policy.js";
|
|
18
18
|
import {
|
|
19
19
|
observationMatchesConfig,
|
|
20
20
|
observationSummary,
|
|
@@ -77,7 +77,7 @@ export async function describeManagerState(
|
|
|
77
77
|
}
|
|
78
78
|
const configuredTargets = ownRecord(raw.syncSetups);
|
|
79
79
|
if (
|
|
80
|
-
(raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6) &&
|
|
80
|
+
(raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6 || raw.version === 7) &&
|
|
81
81
|
configuredTargets &&
|
|
82
82
|
Object.keys(configuredTargets).length === 0
|
|
83
83
|
) {
|
|
@@ -114,7 +114,9 @@ export async function describeManagerState(
|
|
|
114
114
|
const attentionExclusionsDiffer = currentAttention
|
|
115
115
|
? !sameSyncExclude(currentAttention.decision.localExclude, currentAttention.decision.remoteExclude)
|
|
116
116
|
: false;
|
|
117
|
-
const
|
|
117
|
+
const attentionDirectoryPolicy =
|
|
118
|
+
currentAttention?.decision.localDirectory || currentAttention?.decision.remoteDirectory;
|
|
119
|
+
const noSyncedContent = !syncSelectionHasContent(config);
|
|
118
120
|
const syncState = changesBlocked ? undefined : await readStateForConfig(config).catch(() => undefined);
|
|
119
121
|
const currentObservation =
|
|
120
122
|
observation &&
|
|
@@ -141,6 +143,7 @@ export async function describeManagerState(
|
|
|
141
143
|
"Manage sync",
|
|
142
144
|
`Current sync setup: ${safeTerminalText(config.setupName)}`,
|
|
143
145
|
`Storage: ${backendStorageDescription(config)}`,
|
|
146
|
+
...(config.scope ? ["Sync scope: Pi agent directory, with exclusions"] : []),
|
|
144
147
|
...(syncState?.unresolved?.length
|
|
145
148
|
? [`Unresolved: ${syncState.unresolved.length} dependency groups · review needed`]
|
|
146
149
|
: []),
|
|
@@ -149,11 +152,13 @@ export async function describeManagerState(
|
|
|
149
152
|
currentAttention.decision.setupName === config.setupName
|
|
150
153
|
? "Sync status: Review needed"
|
|
151
154
|
: `Sync status: Review needed for setup ${safeTerminalText(currentAttention.decision.setupName)}`,
|
|
152
|
-
|
|
153
|
-
?
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
attentionDirectoryPolicy
|
|
156
|
+
? "Sync scopes or directory rules differ."
|
|
157
|
+
: attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0
|
|
158
|
+
? attentionExclusionsDiffer
|
|
159
|
+
? "Synced-content exclusion rules differ."
|
|
160
|
+
: "Only the synced-content order differs."
|
|
161
|
+
: `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} · Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " · Exclusion rules differ." : ""}`,
|
|
157
162
|
]
|
|
158
163
|
: currentObservation
|
|
159
164
|
? [`Observed ${safeTerminalText(currentObservation.checkedAt)}: ${observationSummary(currentObservation)}`]
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
type RemoteSelectionDecision,
|
|
17
17
|
type RemoteSelectionState,
|
|
18
18
|
sameSyncInclude,
|
|
19
|
+
syncDirectoryPolicyKey,
|
|
19
20
|
} from "../sync/sync-policy.js";
|
|
20
21
|
import {
|
|
21
22
|
type RunRoute,
|
|
@@ -190,18 +191,26 @@ async function showSelectionDifference(
|
|
|
190
191
|
description: "Compare exact remote-only, device-only, and ordered lists.",
|
|
191
192
|
to: "review",
|
|
192
193
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
194
|
+
...(adoptionUnavailable(state.decision)
|
|
195
|
+
? []
|
|
196
|
+
: [
|
|
197
|
+
{
|
|
198
|
+
id: "adopt",
|
|
199
|
+
label: "Use remote content list",
|
|
200
|
+
description: "Save the reviewed rules on this device without pulling files.",
|
|
201
|
+
action: "adopt" as const,
|
|
202
|
+
},
|
|
203
|
+
]),
|
|
204
|
+
...(scopesDiffer(state.decision)
|
|
205
|
+
? []
|
|
206
|
+
: [
|
|
207
|
+
{
|
|
208
|
+
id: "keep",
|
|
209
|
+
label: "Keep this device's content list and update remote…",
|
|
210
|
+
description: "Open the existing exact force-push preview without skipping confirmation.",
|
|
211
|
+
action: "keep" as const,
|
|
212
|
+
},
|
|
213
|
+
]),
|
|
205
214
|
{ id: "cancel", label: options.cancelLabel ?? "Cancel", action: "cancel" },
|
|
206
215
|
],
|
|
207
216
|
hint: "back",
|
|
@@ -251,6 +260,8 @@ async function showSelectionDifference(
|
|
|
251
260
|
ownedSignal.throwIfAborted();
|
|
252
261
|
validateOwner();
|
|
253
262
|
assertLocalSelectionCurrent(currentConfig, state.decision);
|
|
263
|
+
const refusal = adoptionUnavailable(state.decision);
|
|
264
|
+
if (refusal) throw new Error(refusal);
|
|
254
265
|
if (!currentConfig.include.includes("sessions") && state.decision.remoteInclude.includes("sessions")) {
|
|
255
266
|
onDialog?.(true);
|
|
256
267
|
let acknowledged: boolean;
|
|
@@ -267,7 +278,11 @@ async function showSelectionDifference(
|
|
|
267
278
|
validateOwner();
|
|
268
279
|
if (!acknowledged) return undefined;
|
|
269
280
|
}
|
|
270
|
-
if (
|
|
281
|
+
if (
|
|
282
|
+
!currentConfig.scope &&
|
|
283
|
+
state.decision.remoteExclude !== undefined &&
|
|
284
|
+
currentConfig.exclude === undefined
|
|
285
|
+
) {
|
|
271
286
|
onDialog?.(true);
|
|
272
287
|
let confirmed: boolean;
|
|
273
288
|
try {
|
|
@@ -306,6 +321,9 @@ async function showSelectionDifference(
|
|
|
306
321
|
...adoption.value.config,
|
|
307
322
|
include: [...state.decision.remoteInclude],
|
|
308
323
|
exclude: adoptedExclude(state.decision),
|
|
324
|
+
...(adoption.value.config.scope
|
|
325
|
+
? { reinclude: [...(state.decision.remoteDirectory?.reinclude ?? [])] }
|
|
326
|
+
: {}),
|
|
309
327
|
});
|
|
310
328
|
flowState = { decision: state.decision, saved: true };
|
|
311
329
|
return { kind: "to" as const, screen: "saved" as const };
|
|
@@ -453,11 +471,12 @@ async function loadAdoptionReview(
|
|
|
453
471
|
const snapshot = await readSnapshotForHead(backend, reviewedHead, signal);
|
|
454
472
|
throwIfAborted(signal);
|
|
455
473
|
validateOwner();
|
|
456
|
-
const state = inspectRemoteSelection(config.include, snapshot, config.exclude);
|
|
474
|
+
const state = inspectRemoteSelection(config.include, snapshot, config.exclude, config);
|
|
457
475
|
if (
|
|
458
476
|
state.kind !== "different" ||
|
|
459
477
|
!sameSyncInclude(state.include, decision.remoteInclude) ||
|
|
460
|
-
!sameSyncExclude(state.exclude, decision.remoteExclude)
|
|
478
|
+
!sameSyncExclude(state.exclude, decision.remoteExclude) ||
|
|
479
|
+
!matchesRemoteDirectory(state, decision)
|
|
461
480
|
) {
|
|
462
481
|
throw new StaleRemoteSelectionReviewError("Remote synced content changed while the comparison was open.");
|
|
463
482
|
}
|
|
@@ -479,11 +498,17 @@ async function revalidateAndAdopt(
|
|
|
479
498
|
const currentSnapshot = await readSnapshotForHead(review.backend, currentHead, signal);
|
|
480
499
|
throwIfAborted(signal);
|
|
481
500
|
validateOwner();
|
|
482
|
-
const currentState = inspectRemoteSelection(
|
|
501
|
+
const currentState = inspectRemoteSelection(
|
|
502
|
+
review.config.include,
|
|
503
|
+
currentSnapshot,
|
|
504
|
+
review.config.exclude,
|
|
505
|
+
review.config,
|
|
506
|
+
);
|
|
483
507
|
if (
|
|
484
508
|
currentState.kind !== "different" ||
|
|
485
509
|
!sameSyncInclude(currentState.include, decision.remoteInclude) ||
|
|
486
|
-
!sameSyncExclude(currentState.exclude, decision.remoteExclude)
|
|
510
|
+
!sameSyncExclude(currentState.exclude, decision.remoteExclude) ||
|
|
511
|
+
!matchesRemoteDirectory(currentState, decision)
|
|
487
512
|
) {
|
|
488
513
|
throw new StaleRemoteSelectionReviewError("Remote synced content changed while the comparison was open.");
|
|
489
514
|
}
|
|
@@ -491,13 +516,23 @@ async function revalidateAndAdopt(
|
|
|
491
516
|
decision.setupName,
|
|
492
517
|
(setup) => {
|
|
493
518
|
validateOwner();
|
|
519
|
+
const refusal = adoptionUnavailable(decision);
|
|
520
|
+
if (refusal) throw new Error(refusal);
|
|
521
|
+
const exclude = adoptedExclude(decision);
|
|
522
|
+
if (setup.sync.scope === "agent-directory") {
|
|
523
|
+
return {
|
|
524
|
+
...setup,
|
|
525
|
+
sync: {
|
|
526
|
+
...setup.sync,
|
|
527
|
+
exclude,
|
|
528
|
+
reinclude: [...(decision.remoteDirectory?.reinclude ?? [])],
|
|
529
|
+
sessions: decision.remoteInclude.includes("sessions"),
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
}
|
|
494
533
|
return {
|
|
495
534
|
...setup,
|
|
496
|
-
sync: {
|
|
497
|
-
...setup.sync,
|
|
498
|
-
include: [...decision.remoteInclude],
|
|
499
|
-
...(adoptedExclude(decision) === undefined ? {} : { exclude: adoptedExclude(decision) }),
|
|
500
|
-
},
|
|
535
|
+
sync: { ...setup.sync, include: [...decision.remoteInclude], ...(exclude === undefined ? {} : { exclude }) },
|
|
501
536
|
};
|
|
502
537
|
},
|
|
503
538
|
{
|
|
@@ -537,7 +572,7 @@ async function inspectConfiguredRemoteSelection(
|
|
|
537
572
|
return {
|
|
538
573
|
kind: "selection",
|
|
539
574
|
config,
|
|
540
|
-
state: inspectRemoteSelection(config.include, snapshot, config.exclude),
|
|
575
|
+
state: inspectRemoteSelection(config.include, snapshot, config.exclude, config),
|
|
541
576
|
};
|
|
542
577
|
}
|
|
543
578
|
|
|
@@ -597,13 +632,57 @@ function adoptedExclude(decision: RemoteSelectionDecision) {
|
|
|
597
632
|
: [...decision.remoteExclude];
|
|
598
633
|
}
|
|
599
634
|
|
|
635
|
+
function scopesDiffer(decision: RemoteSelectionDecision) {
|
|
636
|
+
return decision.localDirectory?.scope !== decision.remoteDirectory?.scope;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function adoptionUnavailable(decision: RemoteSelectionDecision) {
|
|
640
|
+
if (scopesDiffer(decision))
|
|
641
|
+
return "Scope differs. Configure a setup with the remote scope to join it; this location is not migrated in place.";
|
|
642
|
+
if (
|
|
643
|
+
decision.remoteDirectory?.scope &&
|
|
644
|
+
decision.remoteInclude.includes("sessions") &&
|
|
645
|
+
!decision.localInclude.includes("sessions")
|
|
646
|
+
)
|
|
647
|
+
return "Enable session sync explicitly in Settings before adopting these rules.";
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function matchesRemoteDirectory(
|
|
651
|
+
state: Extract<RemoteSelectionState, { kind: "different" }>,
|
|
652
|
+
decision: RemoteSelectionDecision,
|
|
653
|
+
) {
|
|
654
|
+
return (
|
|
655
|
+
syncDirectoryPolicyKey(state) ===
|
|
656
|
+
syncDirectoryPolicyKey({
|
|
657
|
+
include: decision.remoteInclude,
|
|
658
|
+
exclude: decision.remoteExclude,
|
|
659
|
+
...decision.remoteDirectory,
|
|
660
|
+
})
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function directoryReviewLines(decision: RemoteSelectionDecision) {
|
|
665
|
+
if (!decision.localDirectory?.scope && !decision.remoteDirectory?.scope) return [];
|
|
666
|
+
const unavailable = adoptionUnavailable(decision);
|
|
667
|
+
return [
|
|
668
|
+
`Remote scope: ${decision.remoteDirectory?.scope ? "Pi agent directory" : "selected paths or legacy"}`,
|
|
669
|
+
`This device scope: ${decision.localDirectory?.scope ? "Pi agent directory" : "selected paths"}`,
|
|
670
|
+
`Remote re-included paths: ${safeList(decision.remoteDirectory?.reinclude ?? [])}`,
|
|
671
|
+
`This device re-included paths: ${safeList(decision.localDirectory?.reinclude ?? [])}`,
|
|
672
|
+
...(unavailable ? [unavailable] : []),
|
|
673
|
+
];
|
|
674
|
+
}
|
|
675
|
+
|
|
600
676
|
function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
601
677
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
602
678
|
return [
|
|
603
679
|
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
604
680
|
"Nothing changed. Review both lists before choosing what happens next.",
|
|
681
|
+
...directoryReviewLines(decision),
|
|
605
682
|
...excludeReviewLines(decision),
|
|
606
|
-
...(
|
|
683
|
+
...(!decision.localDirectory?.scope &&
|
|
684
|
+
!decision.remoteDirectory?.scope &&
|
|
685
|
+
comparison.remoteOnly.length === 0 &&
|
|
607
686
|
comparison.localOnly.length === 0 &&
|
|
608
687
|
sameSyncExclude(decision.localExclude, decision.remoteExclude)
|
|
609
688
|
? ["Only the ordering differs; membership is the same."]
|
|
@@ -614,7 +693,10 @@ function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
|
614
693
|
function formatSelectionDifference(decision: RemoteSelectionDecision) {
|
|
615
694
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
616
695
|
return [
|
|
617
|
-
...(
|
|
696
|
+
...directoryReviewLines(decision),
|
|
697
|
+
...(!decision.localDirectory?.scope &&
|
|
698
|
+
!decision.remoteDirectory?.scope &&
|
|
699
|
+
comparison.remoteOnly.length === 0 &&
|
|
618
700
|
comparison.localOnly.length === 0 &&
|
|
619
701
|
sameSyncExclude(decision.localExclude, decision.remoteExclude)
|
|
620
702
|
? ["Only ordering differs; both lists contain the same paths.", ""]
|
|
@@ -650,7 +732,10 @@ function formatRemoteSelectionSummary(decision: RemoteSelectionDecision) {
|
|
|
650
732
|
`Synced content for “${safeTerminalText(decision.setupName)}” differs from this device.`,
|
|
651
733
|
`Remote-only: ${safeList(comparison.remoteOnly)}`,
|
|
652
734
|
`Device-only: ${safeList(comparison.localOnly)}`,
|
|
653
|
-
...(
|
|
735
|
+
...directoryReviewLines(decision),
|
|
736
|
+
...(!decision.localDirectory?.scope &&
|
|
737
|
+
!decision.remoteDirectory?.scope &&
|
|
738
|
+
comparison.remoteOnly.length === 0 &&
|
|
654
739
|
comparison.localOnly.length === 0 &&
|
|
655
740
|
sameSyncExclude(decision.localExclude, decision.remoteExclude)
|
|
656
741
|
? [
|
|
@@ -688,6 +773,8 @@ function decisionFromState(
|
|
|
688
773
|
remoteInclude: [...state.include],
|
|
689
774
|
...(config.exclude === undefined ? {} : { localExclude: [...config.exclude] }),
|
|
690
775
|
...(state.exclude === undefined ? {} : { remoteExclude: [...state.exclude] }),
|
|
776
|
+
...(config.scope ? { localDirectory: { scope: config.scope, reinclude: config.reinclude } } : {}),
|
|
777
|
+
...(state.scope ? { remoteDirectory: { scope: state.scope, reinclude: state.reinclude } } : {}),
|
|
691
778
|
};
|
|
692
779
|
}
|
|
693
780
|
|
|
@@ -695,7 +782,13 @@ function assertLocalSelectionCurrent(config: AnySyncConfig, decision: RemoteSele
|
|
|
695
782
|
if (
|
|
696
783
|
syncConfigReviewFingerprint(config) === decision.configIdentity &&
|
|
697
784
|
sameSyncInclude(config.include, decision.localInclude) &&
|
|
698
|
-
sameSyncExclude(config.exclude, decision.localExclude)
|
|
785
|
+
sameSyncExclude(config.exclude, decision.localExclude) &&
|
|
786
|
+
syncDirectoryPolicyKey(config) ===
|
|
787
|
+
syncDirectoryPolicyKey({
|
|
788
|
+
include: decision.localInclude,
|
|
789
|
+
exclude: decision.localExclude,
|
|
790
|
+
...decision.localDirectory,
|
|
791
|
+
})
|
|
699
792
|
) {
|
|
700
793
|
return;
|
|
701
794
|
}
|
package/src/ui/settings-frame.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stripVTControlCharacters } from "node:util";
|
|
2
2
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
3
4
|
|
|
4
5
|
/** Adapt only public rendering/input boundaries; Kit still owns search, saves and focus. */
|
|
5
6
|
export function boundedSettingsUI(ctx: ExtensionCommandContext): ExtensionCommandContext["ui"] {
|
|
@@ -19,14 +20,7 @@ export function boundedSettingsUI(ctx: ExtensionCommandContext): ExtensionComman
|
|
|
19
20
|
return typeof value === "function" ? value.bind(target) : value;
|
|
20
21
|
},
|
|
21
22
|
});
|
|
22
|
-
const guard = <
|
|
23
|
-
T extends {
|
|
24
|
-
render(width: number): string[];
|
|
25
|
-
handleMouse?: import("@earendil-works/pi-tui").Component["handleMouse"];
|
|
26
|
-
},
|
|
27
|
-
>(
|
|
28
|
-
component: T,
|
|
29
|
-
): T => {
|
|
23
|
+
const guard = <T extends Component>(component: T): T => {
|
|
30
24
|
const render = component.render.bind(component);
|
|
31
25
|
const handleMouse = component.handleMouse?.bind(component);
|
|
32
26
|
let sourceRow = 0;
|
package/src/ui/settings-ui.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
saveContinuousMode,
|
|
20
20
|
} from "./agent-mode-setting.js";
|
|
21
21
|
import type { RunRoute } from "./cancellable-operation.js";
|
|
22
|
-
import { showExcludedPaths } from "./excluded-paths-ui.js";
|
|
22
|
+
import { directoryScopeSummary, showExcludedPaths } from "./excluded-paths-ui.js";
|
|
23
23
|
import { dispatchManagerResult } from "./manager-result-dispatcher.js";
|
|
24
24
|
import { boundedSettingsUI } from "./settings-frame.js";
|
|
25
25
|
import { showEditSyncSetupStorage, showSyncSetupManager } from "./setup/setup-actions.js";
|
|
@@ -42,9 +42,17 @@ export async function showSyncSettings(
|
|
|
42
42
|
return { kind: "close" as const };
|
|
43
43
|
};
|
|
44
44
|
if (ctx.mode !== "tui") {
|
|
45
|
-
ctx.ui.notify(`Edit pi-sync settings manually: ${safeTerminalText(localConfigPath())}`, "info");
|
|
46
45
|
if (ctx.mode === "rpc" && ctx.hasUI) {
|
|
47
46
|
// Preserve RPC catalog management; preference/credential editing stays TUI-only.
|
|
47
|
+
const config = await loadConfig(reviewedSetup).catch(() => undefined);
|
|
48
|
+
if (signal?.aborted) return disposition;
|
|
49
|
+
ctx.ui.notify(
|
|
50
|
+
[
|
|
51
|
+
`Edit pi-sync settings manually: ${safeTerminalText(localConfigPath())}`,
|
|
52
|
+
...(config?.scope === "agent-directory" ? directoryScopeSummary(config) : []),
|
|
53
|
+
].join("\n"),
|
|
54
|
+
"info",
|
|
55
|
+
);
|
|
48
56
|
const management = defineMenu<undefined, "management", "setups" | "connections", ExtensionCommandContext>({
|
|
49
57
|
start: "management",
|
|
50
58
|
screens: {
|
|
@@ -108,27 +116,40 @@ export async function showSyncSettings(
|
|
|
108
116
|
saveStatus,
|
|
109
117
|
],
|
|
110
118
|
items: [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
...(state.scope === "agent-directory"
|
|
120
|
+
? [
|
|
121
|
+
{
|
|
122
|
+
id: "include",
|
|
123
|
+
label: "Agent directory scope",
|
|
124
|
+
description:
|
|
125
|
+
"Edit exclusions, re-inclusions, and session opt-in in one reviewed draft. No transfer starts.",
|
|
126
|
+
currentValue: `${state.exclude?.length ?? 0} excluded · ${state.reinclude?.length ?? 0} re-included · Sessions ${state.include.includes("sessions") ? "opted in" : "off"}`,
|
|
127
|
+
action: "include" as const,
|
|
128
|
+
},
|
|
129
|
+
]
|
|
130
|
+
: [
|
|
131
|
+
{
|
|
132
|
+
id: "include",
|
|
133
|
+
label: "Included paths",
|
|
134
|
+
description:
|
|
135
|
+
"This setup: choose paths in a draft, then review and Save or Discard. No transfer is started.",
|
|
136
|
+
currentValue: `${state.include.length} paths · Edit`,
|
|
137
|
+
action: "include" as const,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "exclude",
|
|
141
|
+
label: "Excluded paths",
|
|
142
|
+
description:
|
|
143
|
+
"This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
|
|
144
|
+
currentValue: `${state.exclude?.length ?? 0} rules · Edit`,
|
|
145
|
+
action: "exclude" as const,
|
|
146
|
+
},
|
|
147
|
+
]),
|
|
127
148
|
{
|
|
128
149
|
id: "remoteInclude",
|
|
129
|
-
label: "Compare included paths",
|
|
150
|
+
label: state.scope === "agent-directory" ? "Compare sync policies" : "Compare included paths",
|
|
130
151
|
description:
|
|
131
|
-
"
|
|
152
|
+
"Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
|
|
132
153
|
currentValue: "Review",
|
|
133
154
|
action: "remote-include",
|
|
134
155
|
},
|
|
@@ -221,8 +242,7 @@ export async function showSyncSettings(
|
|
|
221
242
|
{
|
|
222
243
|
id: "contentPolicy",
|
|
223
244
|
label: "Content merge / partial progress",
|
|
224
|
-
description:
|
|
225
|
-
"This setup, opt-in: review the version-5 upgrade before saving. Merge bounded text and prefix-only sessions; partial progress keeps withheld versions and baselines. Applies to subsequent sync; disabling does not clear recovery evidence.",
|
|
245
|
+
description: `This setup, opt-in: ${state.scope === "agent-directory" ? "review format compatibility" : "review the version-5 upgrade"} before saving. Merge bounded text and prefix-only sessions; partial progress keeps withheld versions and baselines. Applies to subsequent sync; disabling does not clear recovery evidence.`,
|
|
226
246
|
currentValue: state.mergeContent
|
|
227
247
|
? state.partialSync
|
|
228
248
|
? "Merge + partial"
|
|
@@ -290,7 +310,7 @@ export async function showSyncSettings(
|
|
|
290
310
|
if (
|
|
291
311
|
!(await ctx.ui.confirm(
|
|
292
312
|
"Save content policy?",
|
|
293
|
-
"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
|
|
313
|
+
`${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and snapshot version 5; older clients must refuse them." : "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.`,
|
|
294
314
|
{ signal: mutationSignal },
|
|
295
315
|
))
|
|
296
316
|
)
|
|
@@ -302,13 +322,14 @@ export async function showSyncSettings(
|
|
|
302
322
|
const setup = current.syncSetups[setupName];
|
|
303
323
|
if (
|
|
304
324
|
!setup ||
|
|
325
|
+
setup.sync.scope !== previous.scope ||
|
|
305
326
|
Boolean(setup.sync.mergeContent) !== Boolean(previous.mergeContent) ||
|
|
306
327
|
Boolean(setup.sync.partialSync) !== Boolean(previous.partialSync)
|
|
307
328
|
)
|
|
308
329
|
throw new Error("Content policy changed during review.");
|
|
309
330
|
return {
|
|
310
331
|
...current,
|
|
311
|
-
version: current.version
|
|
332
|
+
version: current.version >= 6 ? current.version : 5,
|
|
312
333
|
syncSetups: {
|
|
313
334
|
...current.syncSetups,
|
|
314
335
|
[setupName]: { ...setup, sync: { ...setup.sync, mergeContent, partialSync } },
|
|
@@ -364,7 +385,7 @@ export async function showSyncSettings(
|
|
|
364
385
|
if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
|
|
365
386
|
const confirmed = await ctx.ui.confirm(
|
|
366
387
|
"Save portable field policy?",
|
|
367
|
-
"This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain
|
|
388
|
+
`${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and 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.`,
|
|
368
389
|
{ signal: mutationSignal },
|
|
369
390
|
);
|
|
370
391
|
validate();
|
|
@@ -373,7 +394,11 @@ export async function showSyncSettings(
|
|
|
373
394
|
await updateLocalConfig((current) => {
|
|
374
395
|
validate();
|
|
375
396
|
const setup = current.syncSetups[setupName];
|
|
376
|
-
if (
|
|
397
|
+
if (
|
|
398
|
+
!setup ||
|
|
399
|
+
setup.sync.scope !== previous.scope ||
|
|
400
|
+
!sameLocalFields(setup.sync.localFields, previous.localFields)
|
|
401
|
+
)
|
|
377
402
|
throw new Error("Field policy changed while under review; reopen settings.");
|
|
378
403
|
return {
|
|
379
404
|
...current,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { normalizeDirectoryRules } from "../../sync/sync-policy.js";
|
|
3
|
+
import { safeTerminalText } from "../terminal-text.js";
|
|
4
|
+
|
|
5
|
+
export interface DirectoryRulesDraft {
|
|
6
|
+
exclude: string[];
|
|
7
|
+
reinclude: string[];
|
|
8
|
+
sessions: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const DIRECTORY_SCOPE_ALWAYS_LOCAL =
|
|
12
|
+
"Always local: Pi credentials (auth.json), project trust (trust.json), their locks, and Pi Sync's settings and service state. Rules cannot override these protections.";
|
|
13
|
+
|
|
14
|
+
export const SESSION_PRIVACY_WARNING =
|
|
15
|
+
"Session JSONL can contain prompts, tool output, paths, screenshots, and secrets. Sync sessions only to storage you trust.";
|
|
16
|
+
|
|
17
|
+
export function starterDirectoryRules(): DirectoryRulesDraft {
|
|
18
|
+
return { exclude: ["sessions", "bin", "npm"], reinclude: [], sessions: false };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function directorySessionOptInLine(sessions: boolean | undefined) {
|
|
22
|
+
return `Sessions: ${sessions ? "On — explicit opt-in; path rules still apply" : "Off — rules cannot enable sessions"}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function acknowledgeSessions(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
26
|
+
const confirmed = await ctx.ui.confirm("Include session conversations?", SESSION_PRIVACY_WARNING, { signal });
|
|
27
|
+
return !signal?.aborted && confirmed;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function promptDirectoryRules(
|
|
31
|
+
ctx: ExtensionCommandContext,
|
|
32
|
+
kind: "exclude" | "reinclude",
|
|
33
|
+
initial: readonly string[],
|
|
34
|
+
signal?: AbortSignal,
|
|
35
|
+
validate: () => void = () => signal?.throwIfAborted(),
|
|
36
|
+
) {
|
|
37
|
+
let draft = JSON.stringify(initial);
|
|
38
|
+
while (!signal?.aborted) {
|
|
39
|
+
const title = kind === "exclude" ? "Excluded paths" : "Re-included paths";
|
|
40
|
+
const input = await ctx.ui.input(
|
|
41
|
+
`${title}\n\nCurrent rules: ${summarizeDirectoryRules(initial)}\nEnter a JSON string array. Blank keeps the draft; [] clears it.`,
|
|
42
|
+
draft,
|
|
43
|
+
{ signal },
|
|
44
|
+
);
|
|
45
|
+
if (signal?.aborted || input === undefined) return undefined;
|
|
46
|
+
validate();
|
|
47
|
+
draft = input || draft;
|
|
48
|
+
try {
|
|
49
|
+
const parsed: unknown = JSON.parse(draft);
|
|
50
|
+
if (!Array.isArray(parsed)) throw new Error("Enter a JSON string array.");
|
|
51
|
+
return normalizeDirectoryRules(parsed);
|
|
52
|
+
} catch {
|
|
53
|
+
ctx.ui.notify("Invalid rule array or unsupported pattern. No settings changed.", "error");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function summarizeDirectoryRules(rules: readonly string[] = []) {
|
|
60
|
+
if (!rules.length) return "none";
|
|
61
|
+
const sample = rules.slice(0, 5).map((rule) => {
|
|
62
|
+
const safe = safeTerminalText(rule);
|
|
63
|
+
return safe.length > 80 ? `${safe.slice(0, 80)}…` : safe;
|
|
64
|
+
});
|
|
65
|
+
return `${rules.length} · ${sample.join(", ")}${rules.length > sample.length ? ", …" : ""}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function formatDirectoryRules(label: string, rules: readonly string[]) {
|
|
69
|
+
return [`${label}:`, ...(rules.length ? rules.map((rule) => ` ${safeTerminalText(rule)}`) : [" (none)"])];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function directoryScopeLines(draft: DirectoryRulesDraft) {
|
|
73
|
+
return [
|
|
74
|
+
"Scope: Pi agent directory · all eligible files, including custom paths",
|
|
75
|
+
...formatDirectoryRules("Excluded paths", draft.exclude),
|
|
76
|
+
...formatDirectoryRules("Re-included paths (override exclusions)", draft.reinclude),
|
|
77
|
+
directorySessionOptInLine(draft.sessions),
|
|
78
|
+
DIRECTORY_SCOPE_ALWAYS_LOCAL,
|
|
79
|
+
"Synced files can contain sensitive data the secret scanner cannot identify. Review the preview before transferring.",
|
|
80
|
+
];
|
|
81
|
+
}
|
package/src/ui/setup/git-ui.ts
CHANGED
|
@@ -11,13 +11,7 @@ import type { PartialConfig } from "../../settings/settings-types.js";
|
|
|
11
11
|
import { automaticSyncSummary } from "../automatic-sync-summary.js";
|
|
12
12
|
import { safeTerminalText } from "../terminal-text.js";
|
|
13
13
|
import { promptAvailableSetupStorage } from "./setup-location-ui.js";
|
|
14
|
-
import {
|
|
15
|
-
chooseAutomaticSync,
|
|
16
|
-
chooseSetupContent,
|
|
17
|
-
includedContentLines,
|
|
18
|
-
promptResourceName,
|
|
19
|
-
readSetupConnection,
|
|
20
|
-
} from "./setup-prompts.js";
|
|
14
|
+
import { chooseSetupPolicy, finishSetup, promptResourceName, readSetupConnection } from "./setup-prompts.js";
|
|
21
15
|
import { saveReviewedDraft } from "./setup-review.js";
|
|
22
16
|
import { requiredInput, requiredValueInput } from "./text-input.js";
|
|
23
17
|
|
|
@@ -26,10 +20,8 @@ export async function showGitSetup(ctx: ExtensionCommandContext, targetName: str
|
|
|
26
20
|
if (!remote) return false;
|
|
27
21
|
const destination = await promptGitDestination(ctx, signal);
|
|
28
22
|
if (!destination) return false;
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
32
|
-
if (automatic === undefined) return false;
|
|
23
|
+
const policy = await chooseSetupPolicy(ctx, signal);
|
|
24
|
+
if (signal?.aborted || !policy) return false;
|
|
33
25
|
const saved = await saveReviewedDraft(
|
|
34
26
|
ctx,
|
|
35
27
|
"Review Git sync setup",
|
|
@@ -39,8 +31,8 @@ export async function showGitSetup(ctx: ExtensionCommandContext, targetName: str
|
|
|
39
31
|
`Remote: ${safeTerminalText(remote)}`,
|
|
40
32
|
`Sync branch: ${safeTerminalText(destination.branch)}`,
|
|
41
33
|
`Storage location: ${safeTerminalText(destination.directory)}`,
|
|
42
|
-
...
|
|
43
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
34
|
+
...policy.lines,
|
|
35
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
44
36
|
"Authentication: existing Git credential helper or SSH configuration (not stored by pi-sync).",
|
|
45
37
|
"pi-sync manages the entire branch. The repository must already exist; a new branch is created on first push.",
|
|
46
38
|
"Saving does not contact remote storage or start syncing.",
|
|
@@ -58,15 +50,15 @@ export async function showGitSetup(ctx: ExtensionCommandContext, targetName: str
|
|
|
58
50
|
branch: destination.branch,
|
|
59
51
|
path: destination.directory,
|
|
60
52
|
},
|
|
61
|
-
sync:
|
|
53
|
+
sync: policy.sync,
|
|
62
54
|
},
|
|
63
55
|
},
|
|
64
56
|
saveSignal,
|
|
65
57
|
),
|
|
66
58
|
signal,
|
|
67
59
|
);
|
|
68
|
-
if (saved
|
|
69
|
-
ctx
|
|
60
|
+
if (saved)
|
|
61
|
+
await finishSetup(ctx, targetName, `Saved Git sync setup “${safeTerminalText(targetName)}”.`, policy.join, signal);
|
|
70
62
|
return saved;
|
|
71
63
|
}
|
|
72
64
|
|
|
@@ -143,10 +135,8 @@ export async function showAddGitTarget(
|
|
|
143
135
|
signal,
|
|
144
136
|
);
|
|
145
137
|
if (!storage) return false;
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
148
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
149
|
-
if (automatic === undefined) return false;
|
|
138
|
+
const policy = await chooseSetupPolicy(ctx, signal);
|
|
139
|
+
if (signal?.aborted || !policy) return false;
|
|
150
140
|
const connection = await readSetupConnection(profile, signal);
|
|
151
141
|
if (connection?.type !== "git") throw new Error("Storage connection changed; reopen setup.");
|
|
152
142
|
const saved = await saveReviewedDraft(
|
|
@@ -158,15 +148,15 @@ export async function showAddGitTarget(
|
|
|
158
148
|
`Remote: ${safeTerminalText(connection.remote)}`,
|
|
159
149
|
`Sync branch: ${safeTerminalText(storage.branch)}`,
|
|
160
150
|
`Storage location: ${safeTerminalText(storage.path)}`,
|
|
161
|
-
...
|
|
162
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
151
|
+
...policy.lines,
|
|
152
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
163
153
|
"pi-sync manages the entire branch. Adding this setup does not sync or modify remote data.",
|
|
164
154
|
],
|
|
165
155
|
"Add sync setup",
|
|
166
|
-
(saveSignal) => addSyncSetup(name, { storage, sync:
|
|
156
|
+
(saveSignal) => addSyncSetup(name, { storage, sync: policy.sync }, saveSignal, connection),
|
|
167
157
|
signal,
|
|
168
158
|
);
|
|
169
|
-
if (saved
|
|
159
|
+
if (saved) await finishSetup(ctx, name, `Added sync setup “${safeTerminalText(name)}”.`, policy.join, signal);
|
|
170
160
|
return saved;
|
|
171
161
|
}
|
|
172
162
|
|