@narumitw/pi-sync 0.65.0 → 0.66.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 +10 -0
- package/README.md +4 -4
- package/dist/chunks/{chunk-OWEOZZZE.ts → chunk-5YOLQKNZ.ts} +38 -2
- package/dist/chunks/chunk-5YOLQKNZ.ts.map +7 -0
- package/dist/chunks/{chunk-OBVJTKVY.ts → chunk-ASU3GZPW.ts} +10 -92
- package/dist/chunks/chunk-ASU3GZPW.ts.map +7 -0
- package/dist/chunks/{chunk-IOM6E5FW.ts → chunk-BESRBKVO.ts} +2 -2
- package/dist/chunks/{chunk-TZMVSTAM.ts → chunk-BYVHABNR.ts} +4 -4
- package/dist/chunks/chunk-ECYCNZOE.ts +12 -0
- package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
- package/dist/chunks/{chunk-MANNB4WZ.ts → chunk-KNEUL4XN.ts} +1 -7
- package/dist/chunks/chunk-KNEUL4XN.ts.map +7 -0
- package/dist/chunks/chunk-Z5JMOXJM.ts +106 -0
- package/dist/chunks/chunk-Z5JMOXJM.ts.map +7 -0
- package/dist/chunks/{command-handler-YZ4DXQ7N.ts → command-handler-44EFGPWH.ts} +9 -7
- package/dist/chunks/{command-handler-YZ4DXQ7N.ts.map → command-handler-44EFGPWH.ts.map} +1 -1
- package/dist/chunks/{file-selection-DDQN4LVD.ts → file-selection-XWACUTAH.ts} +8 -8
- package/dist/chunks/ignore-file-ui-OHFISFVC.ts +21 -0
- package/dist/chunks/{manager-result-dispatcher-XB75YLEG.ts → manager-result-dispatcher-WXE2BAQO.ts} +3 -3
- package/dist/chunks/{manager-ui-RGA26Z6G.ts → manager-ui-CVZLMXJ5.ts} +57 -45
- package/dist/chunks/manager-ui-CVZLMXJ5.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-WVMET5RI.ts → remote-selection-ui-E4XZCQ7A.ts} +2 -2
- package/dist/chunks/remote-selection-ui-E4XZCQ7A.ts.map +7 -0
- package/dist/chunks/{setup-wizard-YP2KF2WQ.ts → setup-wizard-IEW56AZE.ts} +7 -5
- package/dist/chunks/{setup-wizard-YP2KF2WQ.ts.map → setup-wizard-IEW56AZE.ts.map} +1 -1
- package/dist/daemon/dist/consent.js +14 -2
- package/dist/daemon/dist/engine/backends/git/git-backend.js +5 -3
- package/dist/daemon/dist/engine/backends/git/git-storage.js +15 -3
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +143 -0
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +39 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +2 -2
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +6 -6
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +5 -1
- package/dist/daemon/dist/engine/snapshot/snapshot.js +5 -2
- package/dist/daemon/dist/engine/sync/conflict-review.js +2 -0
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -2
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -8
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +50 -0
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +401 -0
- package/dist/daemon/dist/engine/sync/ignore-publication.js +23 -0
- package/dist/daemon/dist/engine/sync/initialization.js +12 -0
- package/dist/daemon/dist/engine/sync/local-fields.js +6 -3
- package/dist/daemon/dist/engine/sync/merge-journal.js +2 -2
- package/dist/daemon/dist/engine/sync/merged-sync.js +14 -3
- package/dist/daemon/dist/engine/sync/sync-local.js +2 -1
- package/dist/daemon/dist/engine/sync/sync-mutations.js +82 -19
- package/dist/daemon/dist/engine/sync/sync-policy.js +5 -5
- package/dist/daemon/dist/engine/sync/sync-queries.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-rollback.js +9 -3
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +18 -0
- package/dist/daemon/dist/engine-service.js +1 -1
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +1 -1
- package/docs/tui-contract.md +3 -3
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +10 -8
- package/src/ui/ignore-file-ui.ts +13 -5
- package/src/ui/manager-state.ts +15 -8
- package/src/ui/manager-ui.ts +1 -1
- package/src/ui/remote-selection-ui.ts +43 -2
- package/src/ui/settings-ui.ts +30 -30
- package/dist/chunks/chunk-MANNB4WZ.ts.map +0 -7
- package/dist/chunks/chunk-OBVJTKVY.ts.map +0 -7
- package/dist/chunks/chunk-OWEOZZZE.ts.map +0 -7
- package/dist/chunks/manager-ui-RGA26Z6G.ts.map +0 -7
- /package/dist/chunks/{chunk-IOM6E5FW.ts.map → chunk-BESRBKVO.ts.map} +0 -0
- /package/dist/chunks/{chunk-TZMVSTAM.ts.map → chunk-BYVHABNR.ts.map} +0 -0
- /package/dist/chunks/{file-selection-DDQN4LVD.ts.map → file-selection-XWACUTAH.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-XB75YLEG.ts.map → ignore-file-ui-OHFISFVC.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-WVMET5RI.ts.map → manager-result-dispatcher-WXE2BAQO.ts.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @narumitw/pi-sync
|
|
2
2
|
|
|
3
|
+
## 0.66.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 94d781f: Include the active ignore file in new snapshots unless it ignores itself. Require a reviewed overwrite for either direction of a policy conflict, and let Pull adopt verified remote rules without changing the remote. Upgrade all peers before publishing the new snapshot format and review automatic transfers again.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 39e05a9: Find Settings by searching for storage connections in the sync menu. Show setting-specific save confirmations instead of generic transfer advice.
|
|
12
|
+
|
|
3
13
|
## 0.65.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -242,9 +242,9 @@ Successful transfers show one summary. They do not reload resources, activate ex
|
|
|
242
242
|
|
|
243
243
|
**Settings → Merge settings fields** controls the per-setup `sync.mergeSettings` opt-in, default **Off**. It combines independent global `settings.json` fields, not arbitrary JSON or keybindings. Missing/corrupt ancestors, unsupported syntax, and incompatible fields retain whole-transfer review. Sensitive accepted content is cached privately under the denied state root; disabling does not delete evidence.
|
|
244
244
|
|
|
245
|
-
**Settings → Machine-local fields** edits explicit `sync.localFields` root field names for global `settings.json` (default none). Excluded values and absence stay local; future portable snapshots omit them. An explicit array requires at least settings version 4 and snapshot version 2; legacy directory scope keeps settings version 7 or later and snapshot version 5; ignore-file setups use settings version 8 and snapshot version
|
|
245
|
+
**Settings → Machine-local fields** edits explicit `sync.localFields` root field names for global `settings.json` (default none). Excluded values and absence stay local; future portable snapshots omit them. An explicit array requires at least settings version 4 and snapshot version 2; legacy directory scope keeps settings version 7 or later and snapshot version 5; ignore-file setups use settings version 8 and publish snapshot version 7. Nonempty rules require `settings.json` in `sync.include` only for selected-path setups. All receiving machines must configure compatible rules. Additions/removals require a separately confirmed force-direction migration, even with `--yes`; old remote history is **not erased**. See [settings merge and local fields](./skills/configure-pi-sync/references/configuration.md#settings-field-merge-and-machine-local-fields) for formats, compatibility and recovery.
|
|
246
246
|
|
|
247
|
-
**Settings → Content merge / partial progress** controls independent `sync.mergeContent` and `sync.partialSync` opt-ins, both default **Off**. Saving opts into at least settings version 5; partial publications use snapshot version 3 for selected paths, version 4 with selected-path exclusions, version 5 for legacy directory scope, or version
|
|
247
|
+
**Settings → Content merge / partial progress** controls independent `sync.mergeContent` and `sync.partialSync` opt-ins, both default **Off**. Saving opts into at least settings version 5; partial publications use snapshot version 3 for selected paths, version 4 with selected-path exclusions, version 5 for legacy directory scope, or version 7 for ignore-file policy. Older readers must refuse unsupported formats. Supported Markdown/plain-text resources merge bounded independent line edits without Git or conflict markers. Diff grids and hunk comparisons share an eight-million-work-unit budget across the operation and its retries; exhausted paths remain conflicts for review. Same-session reconciliation only accepts validated complete byte-prefix extensions; divergent histories and the loaded session require review. A syntactically clean text merge is **not a semantic correctness guarantee**.
|
|
248
248
|
|
|
249
249
|
Partial sync keeps each side's unresolved versions, preserves their previous accepted hashes/ancestors, and advances only independent paths. Resource/collision dependency groups are withheld together, including local-only files, never represented as deletion. The conditional **Review unresolved conflicts** action, or `/sync conflicts`, opens exact private versions on request and resolves one freshly validated whole group. Automatic pushes, non-forced push/pull, and rollback refuse unresolved groups; use group review or an explicit manual push/pull force direction instead. Artifacts remain below the denied state root, with stable conflict identity and at most 32 proven-completed records retained; unresolved or unrecognized evidence is never automatically pruned. Failed attempts release only newly created artifacts whose inode/content ownership and lack of state/journal references are verified. See [content merge and partial recovery](./docs/content-merge-audit.md).
|
|
250
250
|
|
|
@@ -300,9 +300,9 @@ These routes require ignore-file support in the running daemon. In TUI, eligible
|
|
|
300
300
|
|
|
301
301
|
An existing valid rule file is reused as-is. After confirmation, the daemon can create a missing default `.syncignore` on Linux, macOS, and Windows without overwriting an existing file. If automatic creation is unavailable on your filesystem, follow the displayed path and starter rules: create a regular UTF-8 file there without replacing an existing file, then reopen the setup or migration review. **Settings → Ignore file** shows the current path and lets you review a switch to another existing file. Edit the file manually; there is no in-app rule save. Edits affect every setup that uses that file. Setup, migration, switching the file, and editing rules do not authorize or trigger a transfer.
|
|
302
302
|
|
|
303
|
-
The [starter rules](./skills/configure-pi-sync/references/configuration.md#ignore-file-policy) exclude top-level `git/` package checkouts and `/sessions/`, even if you opt into session sync. To sync sessions, both opt in and adjust the rule. Pi credentials, trust, Pi Sync settings and state, and rule files stay local
|
|
303
|
+
The [starter rules](./skills/configure-pi-sync/references/configuration.md#ignore-file-policy) exclude top-level `git/` package checkouts and `/sessions/`, even if you opt into session sync. To sync sessions, both opt in and adjust the rule. Pi credentials, trust, Pi Sync settings and state, and other setups' rule files stay local. New snapshots include the active rule file unless it excludes itself (for example, `/.syncignore`). Included rules and comments become visible to readers of remote history. Exclusion does **not** erase retained snapshots or backups.
|
|
304
304
|
|
|
305
|
-
Upgrade all peers
|
|
305
|
+
Upgrade all peers before publishing a version 7 snapshot. When policies differ, Push and Pull both require a directional preview and explicit confirmation. Push replaces the remote policy; Pull can replace the local rules only if the snapshot contains rule text. A fingerprint-only or self-excluding snapshot cannot replace or delete the local rule file. Background sync, `--yes`, and `--force` cannot approve a policy overwrite. See [Ignore-file policy and recovery](./skills/configure-pi-sync/references/configuration.md#ignore-file-policy) before adopting or recovering rules.
|
|
306
306
|
|
|
307
307
|
### Legacy path rules
|
|
308
308
|
|
|
@@ -159,6 +159,10 @@ async function showRemoteSelectionReview(ctx, setupName, signal, factory = creat
|
|
|
159
159
|
}
|
|
160
160
|
async function showSelectionDifference(ctx, initialDecision, origin, runRoute, sessionSignal, factory, options, validateOwner) {
|
|
161
161
|
const isCurrent = () => isReviewOwnerCurrent(validateOwner);
|
|
162
|
+
const canReviewPull = Boolean(
|
|
163
|
+
runRoute && !options.readOnly && initialDecision.ignorePolicyComparison === "mismatch" && await (await import("./ignore-file-ui-OHFISFVC.ts")).portableIgnoreRulesAvailable(ctx, sessionSignal)
|
|
164
|
+
);
|
|
165
|
+
if (!isCurrent()) return { kind: "stale" };
|
|
162
166
|
let flowState = { decision: initialDecision, saved: false };
|
|
163
167
|
let continuationFingerprint;
|
|
164
168
|
let nextResult;
|
|
@@ -186,6 +190,14 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
186
190
|
action: "adopt"
|
|
187
191
|
}
|
|
188
192
|
],
|
|
193
|
+
...canReviewPull ? [
|
|
194
|
+
{
|
|
195
|
+
id: "pull-rules",
|
|
196
|
+
label: "Review pulling the remote rules\u2026",
|
|
197
|
+
description: "Preview overwriting this device's rules and files if the snapshot includes rules.",
|
|
198
|
+
action: "pull-rules"
|
|
199
|
+
}
|
|
200
|
+
] : [],
|
|
189
201
|
...options.readOnly || !canPublishLocalPolicy(state.decision) ? [] : [
|
|
190
202
|
{
|
|
191
203
|
id: "keep",
|
|
@@ -314,6 +326,30 @@ async function showSelectionDifference(ctx, initialDecision, origin, runRoute, s
|
|
|
314
326
|
return { kind: "stay" };
|
|
315
327
|
}
|
|
316
328
|
},
|
|
329
|
+
"pull-rules": async ({ state, signal: actionSignal }) => {
|
|
330
|
+
if (!canReviewPull || !runRoute) return { kind: "rejected" };
|
|
331
|
+
const signal = combineSignals(sessionSignal, actionSignal);
|
|
332
|
+
try {
|
|
333
|
+
const latest = await loadConfig(state.decision.setupName);
|
|
334
|
+
if (signal.aborted) return { kind: "close" };
|
|
335
|
+
validateOwner();
|
|
336
|
+
if (syncConfigReviewFingerprint(latest) !== state.decision.configIdentity) {
|
|
337
|
+
refreshRequested = true;
|
|
338
|
+
return { kind: "close" };
|
|
339
|
+
}
|
|
340
|
+
const result = await runCancellableOperation(ctx, "Preparing remote policy preview\u2026", "pull", runRoute, {
|
|
341
|
+
commitAware: true,
|
|
342
|
+
cancelAcrossDialogs: true,
|
|
343
|
+
target: state.decision.setupName,
|
|
344
|
+
signal
|
|
345
|
+
});
|
|
346
|
+
return handleNestedRouteResult(result, "pull");
|
|
347
|
+
} catch (error) {
|
|
348
|
+
if (signal.aborted || !isCurrent()) return { kind: "close" };
|
|
349
|
+
ctx.ui.notify(`Could not prepare the local update: ${errorMessage(error)}`, "error");
|
|
350
|
+
return { kind: "stay" };
|
|
351
|
+
}
|
|
352
|
+
},
|
|
317
353
|
keep: async ({ state, signal: actionSignal }) => {
|
|
318
354
|
if (options.readOnly) return { kind: "rejected" };
|
|
319
355
|
if (!canPublishLocalPolicy(state.decision)) return { kind: "stay" };
|
|
@@ -570,7 +606,7 @@ function canPublishLocalPolicy(decision) {
|
|
|
570
606
|
}
|
|
571
607
|
function adoptionUnavailable(decision) {
|
|
572
608
|
if (decision.ignorePolicyComparison)
|
|
573
|
-
return "
|
|
609
|
+
return "A policy comparison does not apply rules. A reviewed Pull can use a snapshot that contains rule text.";
|
|
574
610
|
if (scopesDiffer(decision))
|
|
575
611
|
return "Scope differs. Configure a setup with the remote scope to join it; this location is not migrated in place.";
|
|
576
612
|
if (decision.remoteDirectory?.scope && decision.remoteInclude.includes("sessions") && !decision.localInclude.includes("sessions"))
|
|
@@ -732,4 +768,4 @@ function combineSignals(sessionSignal, actionSignal) {
|
|
|
732
768
|
export {
|
|
733
769
|
showRemoteSelectionReview
|
|
734
770
|
};
|
|
735
|
-
//# sourceMappingURL=chunk-
|
|
771
|
+
//# sourceMappingURL=chunk-5YOLQKNZ.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\" | \"pull-rules\" | \"cancel\" | \"continue\" | \"done\";\n interface FlowState {\n decision: RemoteSelectionDecision;\n saved: boolean;\n }\n const isCurrent = () => isReviewOwnerCurrent(validateOwner);\n const canReviewPull = Boolean(\n runRoute &&\n !options.readOnly &&\n initialDecision.ignorePolicyComparison === \"mismatch\" &&\n (await (await import(\"./ignore-file-ui.js\")).portableIgnoreRulesAvailable(ctx, sessionSignal)),\n );\n if (!isCurrent()) return { kind: \"stale\" };\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 ...(canReviewPull\n ? [\n {\n id: \"pull-rules\",\n label: \"Review pulling the remote rules\u2026\",\n description: \"Preview overwriting this device's rules and files if the snapshot includes rules.\",\n action: \"pull-rules\" as const,\n },\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 \"pull-rules\": async ({ state, signal: actionSignal }) => {\n if (!canReviewPull || !runRoute) return { kind: \"rejected\" };\n const signal = combineSignals(sessionSignal, actionSignal);\n try {\n const latest = await loadConfig(state.decision.setupName);\n if (signal.aborted) return { kind: \"close\" };\n validateOwner();\n if (syncConfigReviewFingerprint(latest) !== state.decision.configIdentity) {\n refreshRequested = true;\n return { kind: \"close\" };\n }\n const result = await runCancellableOperation(ctx, \"Preparing remote policy preview\u2026\", \"pull\", runRoute, {\n commitAware: true,\n cancelAcrossDialogs: true,\n target: state.decision.setupName,\n signal,\n });\n return handleNestedRouteResult(result, \"pull\");\n } catch (error) {\n if (signal.aborted || !isCurrent()) return { kind: \"close\" };\n ctx.ui.notify(`Could not prepare the local update: ${errorMessage(error)}`, \"error\");\n return { kind: \"stay\" };\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 \"A policy comparison does not apply rules. A reviewed Pull can use a snapshot that contains rule text.\";\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,UAA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AAmB,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
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
automaticSyncSummary
|
|
5
|
+
} from "./chunk-ECYCNZOE.ts";
|
|
6
|
+
import {
|
|
7
|
+
ignoreFileSettingsAvailable
|
|
8
|
+
} from "./chunk-Z5JMOXJM.ts";
|
|
3
9
|
import {
|
|
4
10
|
effectiveSyncSetupRemoteIdentity,
|
|
5
11
|
normalizeS3Bucket,
|
|
@@ -9,10 +15,6 @@ import {
|
|
|
9
15
|
requiredString,
|
|
10
16
|
validateConfigName
|
|
11
17
|
} from "./chunk-APZVJAEW.ts";
|
|
12
|
-
import {
|
|
13
|
-
automaticSyncSummary,
|
|
14
|
-
trackOperationDialogs
|
|
15
|
-
} from "./chunk-MANNB4WZ.ts";
|
|
16
18
|
import {
|
|
17
19
|
configuredSyncSetupNames,
|
|
18
20
|
readLocalConfigObject
|
|
@@ -24,9 +26,6 @@ import {
|
|
|
24
26
|
AUTOMATIC_SYNC_DESCRIPTION,
|
|
25
27
|
setSyncSetupCompletions
|
|
26
28
|
} from "./chunk-XUZV4OGI.ts";
|
|
27
|
-
import {
|
|
28
|
-
runCancellableTask
|
|
29
|
-
} from "./chunk-AYGMIMCV.ts";
|
|
30
29
|
import {
|
|
31
30
|
acknowledgeSessions,
|
|
32
31
|
directoryScopeLines,
|
|
@@ -44,9 +43,6 @@ import {
|
|
|
44
43
|
import {
|
|
45
44
|
captureMutationOwner
|
|
46
45
|
} from "./chunk-GELYN4UC.ts";
|
|
47
|
-
import {
|
|
48
|
-
piDaemonClient
|
|
49
|
-
} from "./chunk-JQ5BAWW2.ts";
|
|
50
46
|
import {
|
|
51
47
|
errorMessage
|
|
52
48
|
} from "./chunk-6YKOHBSC.ts";
|
|
@@ -62,82 +58,6 @@ async function refreshTargetCompletions() {
|
|
|
62
58
|
setSyncSetupCompletions(await configuredSyncSetupNames());
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
// src/ui/ignore-file-ui.ts
|
|
66
|
-
import { isKeyRelease, Key, matchesKey } from "@earendil-works/pi-tui";
|
|
67
|
-
async function ignoreFileSettingsAvailable(ctx, signal) {
|
|
68
|
-
if (signal?.aborted) return false;
|
|
69
|
-
try {
|
|
70
|
-
const client = piDaemonClient(ctx);
|
|
71
|
-
const result = await client.run("ignore.capabilities", {}, signal, ctx);
|
|
72
|
-
client.validate();
|
|
73
|
-
return !signal?.aborted && result?.available === true;
|
|
74
|
-
} catch {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async function showIgnoreFileAction(ctx, setup, action, filename, signal, offerToken) {
|
|
79
|
-
if (signal.aborted || !ctx.hasUI || ctx.mode !== "tui") return;
|
|
80
|
-
const validateOwner = captureMutationOwner(ctx, signal);
|
|
81
|
-
const client = piDaemonClient(ctx);
|
|
82
|
-
const isCurrent = () => {
|
|
83
|
-
try {
|
|
84
|
-
validateOwner();
|
|
85
|
-
client.validate();
|
|
86
|
-
return true;
|
|
87
|
-
} catch {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
try {
|
|
92
|
-
let payload = offerToken ? { offerToken } : {};
|
|
93
|
-
if (action === "switch") {
|
|
94
|
-
const entered = await askIgnoreFilename(ctx, filename, signal);
|
|
95
|
-
if (!isCurrent() || !entered || entered === filename) return;
|
|
96
|
-
payload = { filename: entered, expectedFilename: filename };
|
|
97
|
-
}
|
|
98
|
-
if (!isCurrent()) return;
|
|
99
|
-
const result = await runCancellableTask(
|
|
100
|
-
ctx,
|
|
101
|
-
action === "migrate" ? "Preparing ignore-file migration review\u2026" : "Checking the selected ignore file for review\u2026",
|
|
102
|
-
(workSignal, onCommit, onDialog) => client.run(
|
|
103
|
-
`ignore.${action}`,
|
|
104
|
-
{ setup, ...payload },
|
|
105
|
-
workSignal,
|
|
106
|
-
trackOperationDialogs(ctx, onDialog),
|
|
107
|
-
onCommit
|
|
108
|
-
),
|
|
109
|
-
{ signal, isCurrent, cancelledMessage: null, commitAware: true, cancelAcrossDialogs: true }
|
|
110
|
-
);
|
|
111
|
-
if (isCurrent() && result.kind === "completed" && result.value === "saved") {
|
|
112
|
-
ctx.ui.notify(
|
|
113
|
-
action === "migrate" ? "Ignore-file policy saved locally. No transfer started." : "Ignore file selected. No transfer started.",
|
|
114
|
-
"info"
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if (isCurrent())
|
|
119
|
-
ctx.ui.notify(`Pi Sync: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`, "error");
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
async function askIgnoreFilename(ctx, filename, signal) {
|
|
123
|
-
const cancel = new AbortController();
|
|
124
|
-
const stop = ctx.ui.onTerminalInput((data) => {
|
|
125
|
-
if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) {
|
|
126
|
-
cancel.abort();
|
|
127
|
-
return { consume: true };
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
const inputSignal = AbortSignal.any([signal, cancel.signal]);
|
|
131
|
-
try {
|
|
132
|
-
const entered = await ctx.ui.input(`Existing ignore filename (current: ${safeTerminalText(filename)})`, void 0, {
|
|
133
|
-
signal: inputSignal
|
|
134
|
-
});
|
|
135
|
-
return inputSignal.aborted ? void 0 : entered;
|
|
136
|
-
} finally {
|
|
137
|
-
stop();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
61
|
// src/backends/git/git-config.ts
|
|
142
62
|
import {
|
|
143
63
|
normalizeGitBranch,
|
|
@@ -398,7 +318,7 @@ async function finishSetup(ctx, name, message, join, signal) {
|
|
|
398
318
|
if (signal?.aborted) return;
|
|
399
319
|
ctx.ui.notify(message, "info");
|
|
400
320
|
if (!join) return;
|
|
401
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
321
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-E4XZCQ7A.ts");
|
|
402
322
|
if (signal?.aborted) return;
|
|
403
323
|
await showRemoteSelectionReview(ctx, name, signal, void 0, {
|
|
404
324
|
origin: "settings",
|
|
@@ -672,7 +592,7 @@ async function promptGitDestination(ctx, signal, current = {}) {
|
|
|
672
592
|
}
|
|
673
593
|
|
|
674
594
|
// src/ui/secret-input.ts
|
|
675
|
-
import { isKeyRelease
|
|
595
|
+
import { isKeyRelease, Key, matchesKey } from "@earendil-works/pi-tui";
|
|
676
596
|
import { runSecretInput } from "@narumitw/pi-tui-kit";
|
|
677
597
|
async function promptSecret(ctx, title, options = { required: true }) {
|
|
678
598
|
if (ctx.mode !== "tui" || options.signal?.aborted) return void 0;
|
|
@@ -682,7 +602,7 @@ async function promptSecret(ctx, title, options = { required: true }) {
|
|
|
682
602
|
const component = await factory(...args);
|
|
683
603
|
const handleInput = component.handleInput?.bind(component);
|
|
684
604
|
component.handleInput = (data) => {
|
|
685
|
-
if (!
|
|
605
|
+
if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) cancel.abort();
|
|
686
606
|
else handleInput?.(data);
|
|
687
607
|
};
|
|
688
608
|
return component;
|
|
@@ -1131,8 +1051,6 @@ export {
|
|
|
1131
1051
|
refreshTargetCompletions,
|
|
1132
1052
|
requiredInput,
|
|
1133
1053
|
requiredValueInput,
|
|
1134
|
-
ignoreFileSettingsAvailable,
|
|
1135
|
-
showIgnoreFileAction,
|
|
1136
1054
|
promptResourceName,
|
|
1137
1055
|
showGitSetup,
|
|
1138
1056
|
showAddGitStorageProfile,
|
|
@@ -1151,4 +1069,4 @@ export {
|
|
|
1151
1069
|
showAddWebDavStorageProfile,
|
|
1152
1070
|
showEditWebDavStorageProfile
|
|
1153
1071
|
};
|
|
1154
|
-
//# sourceMappingURL=chunk-
|
|
1072
|
+
//# sourceMappingURL=chunk-ASU3GZPW.ts.map
|