@narumitw/pi-sync 0.58.0 → 0.59.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 +16 -0
- package/README.md +12 -6
- package/dist/chunks/{agent-candidate-U2NU3GUX.ts → agent-candidate-ZHN7FTZT.ts} +9 -8
- package/dist/chunks/{agent-plan-3YXDIJXO.ts → agent-plan-ILFEUJ2E.ts} +12 -11
- package/dist/chunks/{agent-plan-3YXDIJXO.ts.map → agent-plan-ILFEUJ2E.ts.map} +1 -1
- package/dist/chunks/{agent-refusal-retry-476YGNU5.ts → agent-refusal-retry-HRMHCX2A.ts} +9 -8
- package/dist/chunks/{agent-refusal-retry-476YGNU5.ts.map → agent-refusal-retry-HRMHCX2A.ts.map} +1 -1
- package/dist/chunks/{agent-store-7GINKTS7.ts → agent-store-CCKN4DPR.ts} +3 -3
- package/dist/chunks/{agent-sync-2R4GG2MF.ts → agent-sync-EGA2I5W7.ts} +4 -4
- package/dist/chunks/{chunk-CQD2TJHE.ts → chunk-25QCU3LY.ts} +4 -4
- package/dist/chunks/{chunk-OJARL2TG.ts → chunk-2UKUKIBI.ts} +4 -4
- package/dist/chunks/{chunk-MW6KUQYA.ts → chunk-2ZZJXITS.ts} +40 -10
- package/dist/chunks/chunk-2ZZJXITS.ts.map +7 -0
- package/dist/chunks/chunk-3JTZF7Z5.ts +77 -0
- package/dist/chunks/chunk-3JTZF7Z5.ts.map +7 -0
- package/dist/chunks/{chunk-DN4IA7MR.ts → chunk-4NVHHDN2.ts} +2 -2
- package/dist/chunks/{chunk-AKMV47YC.ts → chunk-6OFMB6KK.ts} +2 -2
- package/dist/chunks/{chunk-45COPAK7.ts → chunk-6XU5HZAN.ts} +6 -6
- package/dist/chunks/{chunk-45COPAK7.ts.map → chunk-6XU5HZAN.ts.map} +2 -2
- package/dist/chunks/{chunk-Y4UVXOLQ.ts → chunk-6YGRZSCN.ts} +15 -10
- package/dist/chunks/chunk-6YGRZSCN.ts.map +7 -0
- package/dist/chunks/{chunk-XEODG2PE.ts → chunk-76HID27T.ts} +2 -2
- package/dist/chunks/{chunk-7A35ZAVO.ts → chunk-7WYF2KUO.ts} +174 -122
- package/dist/chunks/chunk-7WYF2KUO.ts.map +7 -0
- package/dist/chunks/{chunk-MMQIEDZ6.ts → chunk-APDNHB2T.ts} +78 -35
- package/dist/chunks/chunk-APDNHB2T.ts.map +7 -0
- package/dist/chunks/{chunk-U6GXGY5G.ts → chunk-DTPELCPW.ts} +4 -4
- package/dist/chunks/{chunk-TZC7GDJE.ts → chunk-ILXMZ2HU.ts} +4 -4
- package/dist/chunks/{chunk-CBLTWXAU.ts → chunk-LA3HQMFG.ts} +2 -1
- package/dist/chunks/{chunk-CBLTWXAU.ts.map → chunk-LA3HQMFG.ts.map} +2 -2
- package/dist/chunks/{chunk-ESKOPQVB.ts → chunk-MKC3PXCN.ts} +53 -32
- package/dist/chunks/chunk-MKC3PXCN.ts.map +7 -0
- package/dist/chunks/{chunk-MG66XM5U.ts → chunk-NGW4JMBF.ts} +63 -19
- package/dist/chunks/chunk-NGW4JMBF.ts.map +7 -0
- package/dist/chunks/{chunk-TIMWN2RH.ts → chunk-OQBE2OMB.ts} +13 -14
- package/dist/chunks/chunk-OQBE2OMB.ts.map +7 -0
- package/dist/chunks/{chunk-MKSMJPVA.ts → chunk-P3YD4ONV.ts} +22 -6
- package/dist/chunks/chunk-P3YD4ONV.ts.map +7 -0
- package/dist/chunks/{chunk-JYILGR3K.ts → chunk-PQ75RPUP.ts} +3 -3
- package/dist/chunks/{chunk-FLHCOJCD.ts → chunk-QQVK2XFC.ts} +13 -6
- package/dist/chunks/chunk-QQVK2XFC.ts.map +7 -0
- package/dist/chunks/{chunk-WQMYV4DW.ts → chunk-RDOX3VH5.ts} +5 -5
- package/dist/chunks/{chunk-6O3EDBRL.ts → chunk-S7D6XWHI.ts} +2 -2
- package/dist/chunks/{chunk-7ZIYU5QS.ts → chunk-SHPNS7FM.ts} +7 -7
- package/dist/chunks/{chunk-7ZIYU5QS.ts.map → chunk-SHPNS7FM.ts.map} +2 -2
- package/dist/chunks/{chunk-GNYGNHFF.ts → chunk-T2TYBLXK.ts} +2 -2
- package/dist/chunks/{chunk-6LD5KX55.ts → chunk-UZSDS4HF.ts} +13 -6
- package/dist/chunks/chunk-UZSDS4HF.ts.map +7 -0
- package/dist/chunks/{chunk-5TSCBBPP.ts → chunk-VPODHKOX.ts} +3 -3
- package/dist/chunks/{chunk-BEST45H2.ts → chunk-WEKGW7HV.ts} +17 -8
- package/dist/chunks/chunk-WEKGW7HV.ts.map +7 -0
- package/dist/chunks/{chunk-KYTT7KV4.ts → chunk-WUHRVSWI.ts} +87 -37
- package/dist/chunks/chunk-WUHRVSWI.ts.map +7 -0
- package/dist/chunks/{chunk-OVBAW7KV.ts → chunk-XZ3ZTHKR.ts} +19 -9
- package/dist/chunks/chunk-XZ3ZTHKR.ts.map +7 -0
- package/dist/chunks/{chunk-S5OCYVPS.ts → chunk-YEULK7MK.ts} +3 -3
- package/dist/chunks/{command-handler-KCB6MCWS.ts → command-handler-SDGKIQH2.ts} +17 -14
- package/dist/chunks/command-handler-SDGKIQH2.ts.map +7 -0
- package/dist/chunks/{config-HYG7G5EM.ts → config-J5VZUY4J.ts} +4 -3
- package/dist/chunks/{conflict-artifacts-J6WSDCWP.ts → conflict-artifacts-MYSH3L2J.ts} +10 -9
- package/dist/chunks/{conflict-review-GXA6Y7KY.ts → conflict-review-J6ZSPNWL.ts} +21 -20
- package/dist/chunks/{conflict-review-GXA6Y7KY.ts.map → conflict-review-J6ZSPNWL.ts.map} +1 -1
- package/dist/chunks/{continuous-record-EPHGR2DU.ts → continuous-record-OM64J27R.ts} +4 -4
- package/dist/chunks/{continuous-sync-FAFNLEUW.ts → continuous-sync-BH5SWIRV.ts} +22 -17
- package/dist/chunks/continuous-sync-BH5SWIRV.ts.map +7 -0
- package/dist/chunks/{file-selection-IELTXSGZ.ts → file-selection-7HEVPO4T.ts} +11 -8
- package/dist/chunks/file-selection-7HEVPO4T.ts.map +7 -0
- package/dist/chunks/{git-backend-KHD36W27.ts → git-backend-6CKI6CUG.ts} +12 -15
- package/dist/chunks/{git-backend-KHD36W27.ts.map → git-backend-6CKI6CUG.ts.map} +2 -2
- package/dist/chunks/{local-fields-JEKAPZKD.ts → local-fields-SR7PH66U.ts} +6 -5
- package/dist/chunks/{manager-result-dispatcher-XCYPW7RC.ts → manager-result-dispatcher-CXUP5WDP.ts} +15 -14
- package/dist/chunks/{manager-ui-FMZXKPX2.ts → manager-ui-65ZETN6F.ts} +168 -51
- package/dist/chunks/manager-ui-65ZETN6F.ts.map +7 -0
- package/dist/chunks/{merge-baseline-store-65GKUMXI.ts → merge-baseline-store-4Y2X7P2D.ts} +4 -3
- package/dist/chunks/{remote-selection-ui-MYM2YCPF.ts → remote-selection-ui-W55BQDJQ.ts} +14 -13
- package/dist/chunks/{s3-backend-L24UZ6IK.ts → s3-backend-FDK7JSDQ.ts} +8 -7
- package/dist/chunks/{s3-backend-L24UZ6IK.ts.map → s3-backend-FDK7JSDQ.ts.map} +1 -1
- package/dist/chunks/{setup-switch-KLGESLQX.ts → setup-switch-AB27ADDI.ts} +5 -4
- package/dist/chunks/{setup-wizard-ZQAK35BP.ts → setup-wizard-5FILKFLQ.ts} +6 -5
- package/dist/chunks/{setup-wizard-ZQAK35BP.ts.map → setup-wizard-5FILKFLQ.ts.map} +1 -1
- package/dist/chunks/{snapshot-RGNDYT6A.ts → snapshot-G3W2GOGB.ts} +5 -4
- package/dist/chunks/{snapshot-transaction-26BQO36S.ts → snapshot-transaction-SGRUWT73.ts} +6 -5
- package/dist/chunks/{sync-inspection-MOMLGUTD.ts → sync-inspection-MDYHZHT7.ts} +10 -9
- package/dist/chunks/{sync-operations-45APGOL3.ts → sync-operations-ZAUP65FH.ts} +40 -29
- package/dist/chunks/sync-operations-ZAUP65FH.ts.map +7 -0
- package/dist/chunks/{sync-state-7L4NT7W2.ts → sync-state-H4TFZZ7S.ts} +7 -6
- package/dist/chunks/{webdav-backend-3ZCACILP.ts → webdav-backend-UNMIAXM5.ts} +7 -6
- package/dist/chunks/{webdav-backend-3ZCACILP.ts.map → webdav-backend-UNMIAXM5.ts.map} +1 -1
- package/dist/index.ts +26 -19
- package/dist/index.ts.map +2 -2
- package/docs/exclude-policy-audit.md +54 -0
- package/docs/exclude-review-ledger.md +36 -0
- package/docs/tui-contract.md +1 -1
- package/package.json +3 -2
- package/skills/configure-pi-sync/SKILL.md +4 -3
- package/skills/configure-pi-sync/references/configuration.md +72 -13
- package/src/backends/git/git-storage.ts +12 -11
- package/src/commands/command-execution.ts +2 -2
- package/src/commands/command-handler.ts +1 -0
- package/src/settings/config.ts +9 -3
- package/src/settings/settings-management.ts +4 -3
- package/src/settings/settings-types.ts +4 -1
- package/src/settings/settings-validation.ts +8 -4
- package/src/snapshot/session-paths.ts +1 -0
- package/src/snapshot/snapshot-apply.ts +23 -7
- package/src/snapshot/snapshot-codec.ts +12 -3
- package/src/snapshot/snapshot-exclude-safety.ts +44 -0
- package/src/snapshot/snapshot-transaction.ts +12 -0
- package/src/snapshot/snapshot-types.ts +4 -4
- package/src/snapshot/snapshot.ts +71 -30
- package/src/state/merge-baseline-store.ts +9 -1
- package/src/state/state-types.ts +1 -0
- package/src/sync/automatic-sync.ts +7 -2
- package/src/sync/continuous-watch.ts +4 -2
- package/src/sync/exclude-policy.ts +84 -0
- package/src/sync/local-fields.ts +15 -4
- package/src/sync/merge-apply.ts +6 -1
- package/src/sync/merge-journal.ts +12 -3
- package/src/sync/merged-sync.ts +17 -12
- package/src/sync/partial-progress.ts +1 -0
- package/src/sync/remote-snapshot.ts +7 -8
- package/src/sync/sync-decision.ts +11 -1
- package/src/sync/sync-inspection.ts +3 -1
- package/src/sync/sync-mutations.ts +11 -4
- package/src/sync/sync-policy.ts +101 -37
- package/src/sync/sync-queries.ts +13 -3
- package/src/sync/sync-state.ts +16 -10
- package/src/ui/excluded-paths-ui.ts +106 -0
- package/src/ui/file-selection.ts +6 -3
- package/src/ui/manager-state.ts +11 -5
- package/src/ui/remote-selection-ui.ts +73 -10
- package/src/ui/settings-ui.ts +20 -5
- package/src/ui/setup/setup-actions.ts +1 -1
- package/src/ui/setup/setup-switcher.ts +3 -2
- package/src/ui/storage-connections-ui.ts +2 -2
- package/src/ui/sync-attention.ts +46 -10
- package/src/ui/sync-format.ts +13 -1
- package/dist/chunks/chunk-6LD5KX55.ts.map +0 -7
- package/dist/chunks/chunk-7A35ZAVO.ts.map +0 -7
- package/dist/chunks/chunk-BEST45H2.ts.map +0 -7
- package/dist/chunks/chunk-ESKOPQVB.ts.map +0 -7
- package/dist/chunks/chunk-FLHCOJCD.ts.map +0 -7
- package/dist/chunks/chunk-KYTT7KV4.ts.map +0 -7
- package/dist/chunks/chunk-MG66XM5U.ts.map +0 -7
- package/dist/chunks/chunk-MKSMJPVA.ts.map +0 -7
- package/dist/chunks/chunk-MMQIEDZ6.ts.map +0 -7
- package/dist/chunks/chunk-MW6KUQYA.ts.map +0 -7
- package/dist/chunks/chunk-OVBAW7KV.ts.map +0 -7
- package/dist/chunks/chunk-TIMWN2RH.ts.map +0 -7
- package/dist/chunks/chunk-Y4UVXOLQ.ts.map +0 -7
- package/dist/chunks/command-handler-KCB6MCWS.ts.map +0 -7
- package/dist/chunks/continuous-sync-FAFNLEUW.ts.map +0 -7
- package/dist/chunks/file-selection-IELTXSGZ.ts.map +0 -7
- package/dist/chunks/manager-ui-FMZXKPX2.ts.map +0 -7
- package/dist/chunks/sync-operations-45APGOL3.ts.map +0 -7
- /package/dist/chunks/{agent-candidate-U2NU3GUX.ts.map → agent-candidate-ZHN7FTZT.ts.map} +0 -0
- /package/dist/chunks/{agent-store-7GINKTS7.ts.map → agent-store-CCKN4DPR.ts.map} +0 -0
- /package/dist/chunks/{agent-sync-2R4GG2MF.ts.map → agent-sync-EGA2I5W7.ts.map} +0 -0
- /package/dist/chunks/{chunk-CQD2TJHE.ts.map → chunk-25QCU3LY.ts.map} +0 -0
- /package/dist/chunks/{chunk-OJARL2TG.ts.map → chunk-2UKUKIBI.ts.map} +0 -0
- /package/dist/chunks/{chunk-DN4IA7MR.ts.map → chunk-4NVHHDN2.ts.map} +0 -0
- /package/dist/chunks/{chunk-AKMV47YC.ts.map → chunk-6OFMB6KK.ts.map} +0 -0
- /package/dist/chunks/{chunk-XEODG2PE.ts.map → chunk-76HID27T.ts.map} +0 -0
- /package/dist/chunks/{chunk-U6GXGY5G.ts.map → chunk-DTPELCPW.ts.map} +0 -0
- /package/dist/chunks/{chunk-TZC7GDJE.ts.map → chunk-ILXMZ2HU.ts.map} +0 -0
- /package/dist/chunks/{chunk-JYILGR3K.ts.map → chunk-PQ75RPUP.ts.map} +0 -0
- /package/dist/chunks/{chunk-WQMYV4DW.ts.map → chunk-RDOX3VH5.ts.map} +0 -0
- /package/dist/chunks/{chunk-6O3EDBRL.ts.map → chunk-S7D6XWHI.ts.map} +0 -0
- /package/dist/chunks/{chunk-GNYGNHFF.ts.map → chunk-T2TYBLXK.ts.map} +0 -0
- /package/dist/chunks/{chunk-5TSCBBPP.ts.map → chunk-VPODHKOX.ts.map} +0 -0
- /package/dist/chunks/{chunk-S5OCYVPS.ts.map → chunk-YEULK7MK.ts.map} +0 -0
- /package/dist/chunks/{config-HYG7G5EM.ts.map → config-J5VZUY4J.ts.map} +0 -0
- /package/dist/chunks/{conflict-artifacts-J6WSDCWP.ts.map → conflict-artifacts-MYSH3L2J.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-EPHGR2DU.ts.map → continuous-record-OM64J27R.ts.map} +0 -0
- /package/dist/chunks/{local-fields-JEKAPZKD.ts.map → local-fields-SR7PH66U.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-XCYPW7RC.ts.map → manager-result-dispatcher-CXUP5WDP.ts.map} +0 -0
- /package/dist/chunks/{merge-baseline-store-65GKUMXI.ts.map → merge-baseline-store-4Y2X7P2D.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-MYM2YCPF.ts.map → remote-selection-ui-W55BQDJQ.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-KLGESLQX.ts.map → setup-switch-AB27ADDI.ts.map} +0 -0
- /package/dist/chunks/{snapshot-RGNDYT6A.ts.map → snapshot-G3W2GOGB.ts.map} +0 -0
- /package/dist/chunks/{snapshot-transaction-26BQO36S.ts.map → snapshot-transaction-SGRUWT73.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-MOMLGUTD.ts.map → sync-inspection-MDYHZHT7.ts.map} +0 -0
- /package/dist/chunks/{sync-state-7L4NT7W2.ts.map → sync-state-H4TFZZ7S.ts.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/remote-selection-ui.ts", "../../src/ui/cancellable-operation.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, syncCheckConfigFingerprint, syncConfigReviewFingerprint } 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 type RemoteSelectionState,\n sameSyncInclude,\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 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.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.state.kind === \"same\") {\n ctx.ui.notify(\"Remote synced content already matches this sync setup.\", \"info\");\n return { kind: \"back\" };\n }\n 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 }\n decision = decisionFromState(inspected.config, inspected.state);\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.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, \"cancelLabel\" | \"onSelectionResolved\" | \"withStateAccess\">,\n validateOwner: () => void,\n): Promise<DifferenceFlowResult> {\n type Screen = \"choice\" | \"review\" | \"saved\";\n type Action = \"adopt\" | \"keep\" | \"cancel\" | \"continue\" | \"done\";\n interface FlowState {\n decision: RemoteSelectionDecision;\n saved: boolean;\n }\n const isCurrent = () => isReviewOwnerCurrent(validateOwner);\n let flowState: FlowState = { decision: initialDecision, saved: false };\n let continuationFingerprint: string | undefined;\n let nextResult: RemoteSelectionReviewResult | undefined;\n let refreshRequested = false;\n const route = origin === \"settings\" ? \"sync\" : origin;\n const menu = defineMenu<FlowState, Screen, Action, ExtensionContext>({\n start: \"choice\",\n screens: {\n choice: ({ state }) => ({\n kind: \"actions\",\n title: \"Synced content differs\",\n lines: selectionSummaryLines(state.decision),\n items: [\n {\n id: \"review\",\n label: \"Review all paths (recommended)\",\n description: \"Compare exact remote-only, device-only, and ordered lists.\",\n to: \"review\",\n },\n {\n id: \"adopt\",\n label: \"Use remote content list\",\n description: \"Save the reviewed list on this device without pulling files.\",\n action: \"adopt\",\n },\n {\n id: \"keep\",\n label: \"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\",\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 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 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 (state.decision.remoteExclude !== undefined && currentConfig.exclude === undefined) {\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 = syncCheckConfigFingerprint({\n ...adoption.value.config,\n include: [...state.decision.remoteInclude],\n exclude: adoptedExclude(state.decision),\n });\n flowState = { decision: state.decision, saved: true };\n return { kind: \"to\" as const, screen: \"saved\" as const };\n } catch (error) {\n if (signal.aborted || !isCurrent()) return { kind: \"close\" as const };\n if (isStaleReviewError(error)) {\n ctx.ui.notify(`${errorMessage(error)} Refreshing the comparison.`, \"warning\");\n refreshRequested = true;\n return { kind: \"close\" as const };\n }\n ctx.ui.notify(`Could not save the remote content list: ${errorMessage(error)}`, \"error\");\n return { kind: \"stay\" as const };\n }\n },\n keep: async ({ state, signal: actionSignal }) => {\n if (!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 const latest = await loadConfig(state.decision.setupName);\n if (signal.aborted) return { kind: \"close\" as const };\n validateOwner();\n assertLocalSelectionCurrent(latest, state.decision);\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 (!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 (syncCheckConfigFingerprint(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);\n if (\n state.kind !== \"different\" ||\n !sameSyncInclude(state.include, decision.remoteInclude) ||\n !sameSyncExclude(state.exclude, decision.remoteExclude)\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(review.config.include, currentSnapshot, review.config.exclude);\n if (\n currentState.kind !== \"different\" ||\n !sameSyncInclude(currentState.include, decision.remoteInclude) ||\n !sameSyncExclude(currentState.exclude, decision.remoteExclude)\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 return {\n ...setup,\n sync: {\n ...setup.sync,\n include: [...decision.remoteInclude],\n ...(adoptedExclude(decision) === undefined ? {} : { exclude: adoptedExclude(decision) }),\n },\n };\n },\n {\n expectedConfigFingerprint: syncCheckConfigFingerprint(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 | 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 const snapshot = await readSnapshotForHead(backend, head, signal);\n if (signal?.aborted) return undefined;\n validateOwner();\n return {\n kind: \"selection\",\n config,\n state: inspectRemoteSelection(config.include, snapshot, config.exclude),\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 selectionSummaryLines(decision: RemoteSelectionDecision) {\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 ...excludeReviewLines(decision),\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 const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);\n return [\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 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 ...(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 localInclude: [...config.include],\n remoteInclude: [...state.include],\n ...(config.exclude === undefined ? {} : { localExclude: [...config.exclude] }),\n ...(state.exclude === undefined ? {} : { remoteExclude: [...state.exclude] }),\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 ) {\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", "import { BorderedLoader, type ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { isKeyRelease, Key, matchesKey, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport { formatInteractionHints, runCustomInteraction } from \"@narumitw/pi-tui-kit\";\nimport type { SetupPullOutcome } from \"../sync/setup-switch.js\";\nimport type { SyncDecision } from \"../sync/sync-decision.js\";\nimport type { RemoteSelectionDecision } from \"../sync/sync-policy.js\";\n\nexport type RunRouteResult =\n | { kind: \"completed\"; outcome?: SetupPullOutcome }\n | { kind: \"decision-required\"; decision: SyncDecision }\n | { kind: \"remote-selection-required\"; decision: RemoteSelectionDecision }\n | { kind: \"failed\" };\n\nexport type RunRoute = (\n route: string,\n signal?: AbortSignal,\n onCommit?: () => void,\n target?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal?: boolean,\n) => Promise<RunRouteResult | undefined>;\n\nexport type CancellableOperationResult = RunRouteResult | { kind: \"closed\" } | { kind: \"cancelled\" };\n\ninterface CancellableOperationOptions {\n commitAware?: boolean;\n cancelAcrossDialogs?: boolean;\n cancelledMessage?: string | null;\n target?: string;\n signal?: AbortSignal;\n isCurrent?: () => boolean;\n}\n\nexport async function runCancellableOperation(\n ctx: ExtensionContext,\n message: string,\n route: string,\n runRoute: RunRoute,\n options: CancellableOperationOptions = {},\n): Promise<CancellableOperationResult> {\n const result = await runCancellableTask(\n ctx,\n message,\n (signal, onCommit, onDialog) => runRoute(route, signal, onCommit, options.target, onDialog),\n options,\n );\n return result.kind === \"completed\" ? (result.value ?? { kind: \"failed\" }) : result;\n}\n\nexport type CancellableTaskResult<Value> =\n | { kind: \"completed\"; value: Value }\n | { kind: \"closed\" }\n | { kind: \"cancelled\" };\n\n/** Keep non-route work under the same cancellation and drain owner as transfers. */\nexport async function runCancellableTask<Value>(\n ctx: ExtensionContext,\n message: string,\n task: (\n signal: AbortSignal | undefined,\n onCommit?: () => void,\n onDialog?: (active: boolean) => void,\n ) => Promise<Value>,\n options: Omit<CancellableOperationOptions, \"target\"> = {},\n): Promise<CancellableTaskResult<Value>> {\n const {\n commitAware = false,\n cancelAcrossDialogs = false,\n cancelledMessage = \"Check cancelled; no settings or files were changed.\",\n signal,\n isCurrent = () => true,\n } = options;\n if (signal?.aborted || !isCurrent()) return { kind: \"closed\" };\n if (ctx.mode !== \"tui\") return { kind: \"completed\", value: await task(signal) };\n let commitStarted = false;\n let taskResult!: Value;\n const interaction = await runCustomInteraction<{ cancelled?: boolean; error?: unknown }, ExtensionContext>(ctx, {\n signal,\n isCurrent: () => !signal?.aborted && isCurrent(),\n create: ({ tui, theme, keybindings, signal: interactionSignal, complete }) => {\n const loader = new BorderedLoader(tui, theme, message, { cancellable: false });\n const cancelHint = formatInteractionHints(keybindings, [\n {\n keys: [...keybindings.getKeys(\"tui.select.cancel\").filter((key) => !hasControlCharacter(key)), \"ctrl+c\"],\n label: \"cancel\",\n },\n ]);\n const cancel = (data: string) => {\n // Raw terminal listeners run before Pi filters Kitty key releases.\n if (isKeyRelease(data)) return false;\n if (!matchesKey(data, Key.ctrl(\"c\")) && !keybindings.matches(data, \"tui.select.cancel\")) return false;\n if (commitStarted) {\n ctx.ui.notify(\"Applying or publishing has started and cannot be cancelled safely.\", \"warning\");\n } else complete({ cancelled: true });\n return true;\n };\n // Pi dialogs replace this loader and restore the normal editor. Defer\n // ordinary keys while they are open; retain raw cancellation afterward.\n // Ctrl+C remains the root flow's hard-cancel path regardless of focus.\n let activeDialogs = 0;\n const unsubscribe = cancelAcrossDialogs\n ? ctx.ui.onTerminalInput((data) => {\n if (isKeyRelease(data)) return;\n if (activeDialogs > 0 && !matchesKey(data, Key.ctrl(\"c\"))) return;\n return cancel(data) ? { consume: true } : undefined;\n })\n : undefined;\n let pendingTask: Promise<Value>;\n try {\n pendingTask = task(\n interactionSignal,\n commitAware ? () => (commitStarted = true) : undefined,\n cancelAcrossDialogs\n ? (active) => {\n activeDialogs += active ? 1 : -1;\n }\n : undefined,\n );\n } catch (error) {\n unsubscribe?.();\n loader.dispose();\n throw error;\n }\n const operation = pendingTask.then(\n (result) => {\n taskResult = result;\n complete({});\n },\n (error: unknown) => complete({ error }),\n );\n return {\n render(width: number) {\n if (width <= 0) return [];\n const safeWidth = Math.max(1, width);\n const lines = loader.render(safeWidth);\n const bottomBorder = lines.at(-1);\n return [\n ...lines.slice(0, -1),\n truncateToWidth(theme.fg(\"dim\", cancelHint), safeWidth, \"\"),\n ...(bottomBorder === undefined ? [] : [bottomBorder]),\n ];\n },\n invalidate: () => loader.invalidate(),\n handleInput: cancel,\n dispose() {\n unsubscribe?.();\n loader.dispose();\n },\n waitForPending: () => operation,\n };\n },\n });\n if (interaction.kind === \"error\") throw interaction.error;\n if (interaction.kind !== \"completed\") return { kind: \"closed\" };\n if (interaction.value.cancelled) {\n if (cancelledMessage) ctx.ui.notify(cancelledMessage, \"info\");\n return { kind: \"cancelled\" };\n }\n if (interaction.value.error) throw interaction.value.error;\n return { kind: \"completed\", value: taskResult };\n}\n\nfunction hasControlCharacter(value: string) {\n // biome-ignore lint/suspicious/noControlCharactersInRegex: Unsafe key labels must be omitted.\n return /[\\u0000-\\u001f\\u007f-\\u009f]/u.test(value);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;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1E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,25 +3,24 @@
|
|
|
3
3
|
import {
|
|
4
4
|
sameLocalFields,
|
|
5
5
|
validatePortableSnapshot
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-P3YD4ONV.ts";
|
|
7
7
|
import {
|
|
8
8
|
safeTerminalText
|
|
9
9
|
} from "./chunk-AMJRUXFT.ts";
|
|
10
10
|
import {
|
|
11
11
|
syncConfigReviewFingerprint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XZ3ZTHKR.ts";
|
|
13
13
|
import {
|
|
14
14
|
throwIfAborted
|
|
15
15
|
} from "./chunk-PWMWOJP4.ts";
|
|
16
16
|
import {
|
|
17
17
|
filterSnapshotForConfigPolicy
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-MKC3PXCN.ts";
|
|
19
19
|
import {
|
|
20
20
|
inspectRemoteSelection,
|
|
21
21
|
remoteSelectionMismatch,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} from "./chunk-KYTT7KV4.ts";
|
|
22
|
+
sameSnapshotSelection
|
|
23
|
+
} from "./chunk-WUHRVSWI.ts";
|
|
25
24
|
|
|
26
25
|
// src/sync/remote-snapshot.ts
|
|
27
26
|
async function readSnapshotForHead(backend, head, signal) {
|
|
@@ -32,8 +31,7 @@ async function readSnapshotForHead(backend, head, signal) {
|
|
|
32
31
|
throw new Error(`Remote head ${head.snapshotId} resolved to unexpected snapshot ${snapshot.id}.`);
|
|
33
32
|
}
|
|
34
33
|
if (head.selection) {
|
|
35
|
-
|
|
36
|
-
if (!snapshotInclude || !sameSyncInclude(head.selection.include, snapshotInclude)) {
|
|
34
|
+
if (!sameSnapshotSelection(head.selection, snapshot.selection)) {
|
|
37
35
|
throw new Error("Remote head selection does not match its immutable snapshot.");
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -44,9 +42,9 @@ function requireCompatibleRemoteSelection(config, snapshot) {
|
|
|
44
42
|
throw new Error(
|
|
45
43
|
"Remote local-field policy differs; confirm a reviewed directional migration. Old history is not erased."
|
|
46
44
|
);
|
|
47
|
-
const state = inspectRemoteSelection(config.include, snapshot);
|
|
45
|
+
const state = inspectRemoteSelection(config.include, snapshot, config.exclude);
|
|
48
46
|
if (state.kind === "different") {
|
|
49
|
-
throw remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config));
|
|
47
|
+
throw remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config), state.exclude);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
function formatRemoteSelectionStatus(state) {
|
|
@@ -58,7 +56,8 @@ function formatRemoteSelectionStatus(state) {
|
|
|
58
56
|
return [
|
|
59
57
|
"remote included content: differs from this setup",
|
|
60
58
|
`remote-only selection: ${safeList(state.remoteOnly)}`,
|
|
61
|
-
`local-only selection: ${safeList(state.localOnly)}
|
|
59
|
+
`local-only selection: ${safeList(state.localOnly)}`,
|
|
60
|
+
`remote excluded paths: ${safeList(state.exclude ?? [])}`
|
|
62
61
|
].join("\n");
|
|
63
62
|
}
|
|
64
63
|
function safeList(values) {
|
|
@@ -68,10 +67,10 @@ async function readRemoteSnapshot(backend, config, signal, options = {}) {
|
|
|
68
67
|
const head = await backend.readHead(signal);
|
|
69
68
|
if (!head) return { head: void 0, snapshot: void 0, selectionState: void 0 };
|
|
70
69
|
const snapshot = await readSnapshotForHead(backend, head, signal);
|
|
71
|
-
const selectionState = inspectRemoteSelection(config.include, snapshot);
|
|
70
|
+
const selectionState = inspectRemoteSelection(config.include, snapshot, config.exclude);
|
|
72
71
|
if (!options.allowSelectionDifference && selectionState.kind === "different") {
|
|
73
72
|
const configIdentity = syncConfigReviewFingerprint(config);
|
|
74
|
-
throw remoteSelectionMismatch(config, selectionState.include, configIdentity);
|
|
73
|
+
throw remoteSelectionMismatch(config, selectionState.include, configIdentity, selectionState.exclude);
|
|
75
74
|
}
|
|
76
75
|
return {
|
|
77
76
|
head,
|
|
@@ -86,4 +85,4 @@ export {
|
|
|
86
85
|
formatRemoteSelectionStatus,
|
|
87
86
|
readRemoteSnapshot
|
|
88
87
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-OQBE2OMB.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/remote-snapshot.ts"],
|
|
4
|
+
"sourcesContent": ["import type { RemoteHead, SyncBackend } from \"../backends/sync-backend.js\";\nimport { syncConfigReviewFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { filterSnapshotForConfigPolicy } from \"../snapshot/snapshot.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { sameLocalFields, validatePortableSnapshot } from \"./local-fields.js\";\nimport { throwIfAborted } from \"./signals.js\";\nimport {\n inspectRemoteSelection,\n type RemoteSelectionState,\n remoteSelectionMismatch,\n sameSnapshotSelection,\n} from \"./sync-policy.js\";\n\nexport async function readSnapshotForHead(backend: SyncBackend, head: RemoteHead, signal?: AbortSignal) {\n const snapshot = await backend.readSnapshot(head.snapshotRef, signal);\n throwIfAborted(signal);\n validatePortableSnapshot(snapshot);\n if (snapshot.id !== head.snapshotId) {\n throw new Error(`Remote head ${head.snapshotId} resolved to unexpected snapshot ${snapshot.id}.`);\n }\n if (head.selection) {\n if (!sameSnapshotSelection(head.selection, snapshot.selection)) {\n throw new Error(\"Remote head selection does not match its immutable snapshot.\");\n }\n }\n return snapshot;\n}\n\nexport function requireCompatibleRemoteSelection(config: AnySyncConfig, snapshot: Snapshot) {\n if (!sameLocalFields(config.localFields, snapshot.localFields))\n throw new Error(\n \"Remote local-field policy differs; confirm a reviewed directional migration. Old history is not erased.\",\n );\n const state = inspectRemoteSelection(config.include, snapshot, config.exclude);\n if (state.kind === \"different\") {\n throw remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config), state.exclude);\n }\n}\n\nexport function formatRemoteSelectionStatus(state: RemoteSelectionState | undefined) {\n if (!state) return \"remote included content: unavailable (remote is empty)\";\n if (state.kind === \"same\") return \"remote included content: matches this setup\";\n if (state.kind === \"legacy\") {\n return `remote included content: unavailable in legacy snapshot (${state.discovered.length} path${state.discovered.length === 1 ? \"\" : \"s\"} discovered, partial)`;\n }\n return [\n \"remote included content: differs from this setup\",\n `remote-only selection: ${safeList(state.remoteOnly)}`,\n `local-only selection: ${safeList(state.localOnly)}`,\n `remote excluded paths: ${safeList(state.exclude ?? [])}`,\n ].join(\"\\n\");\n}\n\nfunction safeList(values: readonly string[]) {\n return values.length > 0 ? values.map(safeTerminalText).join(\", \") : \"none\";\n}\n\nexport async function readRemoteSnapshot(\n backend: SyncBackend,\n config: AnySyncConfig,\n signal?: AbortSignal,\n options: { allowSelectionDifference?: boolean } = {},\n) {\n const head = await backend.readHead(signal);\n if (!head) return { head: undefined, snapshot: undefined, selectionState: undefined };\n const snapshot = await readSnapshotForHead(backend, head, signal);\n const selectionState = inspectRemoteSelection(config.include, snapshot, config.exclude);\n if (!options.allowSelectionDifference && selectionState.kind === \"different\") {\n const configIdentity = syncConfigReviewFingerprint(config);\n throw remoteSelectionMismatch(config, selectionState.include, configIdentity, selectionState.exclude);\n }\n return {\n head,\n snapshot: filterSnapshotForConfigPolicy(snapshot, config),\n selectionState,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAeA,eAAsB,oBAAoB,SAAsB,MAAkB,QAAsB;AACtG,QAAM,WAAW,MAAM,QAAQ,aAAa,KAAK,aAAa,MAAM;AACpE,iBAAe,MAAM;AACrB,2BAAyB,QAAQ;AACjC,MAAI,SAAS,OAAO,KAAK,YAAY;AACnC,UAAM,IAAI,MAAM,eAAe,KAAK,UAAU,oCAAoC,SAAS,EAAE,GAAG;AAAA,EAClG;AACA,MAAI,KAAK,WA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AAU,OAAO,OAAO;AACtF,MAAI,CAAC,QAAQ,4BAA4B,eAAe,SAAS,aAAa;AAC5E,UAAM,iBAAiB,4BAA4B,MAAM;AACzD,UAAM,wBAAwB,QAAQ,eAAe,SAAS,gBAAgB,eAAe,OAAO;AAAA,EACtG;AACA,SAAO;AAAA,IACL;AAAA,IACA,UAAU,8BAA8B,UAAU,MAAM;AAAA,IACxD;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -10,16 +10,23 @@ import {
|
|
|
10
10
|
} from "./chunk-ZW5ZLGBI.ts";
|
|
11
11
|
import {
|
|
12
12
|
regenerateSnapshotIdentity
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-MKC3PXCN.ts";
|
|
14
|
+
import {
|
|
15
|
+
snapshotSelectionExclude,
|
|
16
|
+
validateSnapshotSelection
|
|
17
|
+
} from "./chunk-WUHRVSWI.ts";
|
|
18
|
+
import {
|
|
19
|
+
compileSyncExclude
|
|
20
|
+
} from "./chunk-3JTZF7Z5.ts";
|
|
14
21
|
|
|
15
22
|
// src/sync/local-fields.ts
|
|
16
23
|
import { createHash } from "node:crypto";
|
|
17
24
|
function validateSnapshotFieldPolicy(snapshot) {
|
|
18
|
-
if (snapshot.version !== 1 && snapshot.version !== 2 && snapshot.version !== 3)
|
|
25
|
+
if (snapshot.version !== 1 && snapshot.version !== 2 && snapshot.version !== 3 && snapshot.version !== 4)
|
|
19
26
|
throw new Error("Unsupported snapshot format.");
|
|
20
27
|
if (snapshot.version === 1 && snapshot.localFields !== void 0)
|
|
21
28
|
throw new Error("Portable field policy requires snapshot version 2.");
|
|
22
|
-
if (snapshot.version === 2 || snapshot.version === 3) {
|
|
29
|
+
if (snapshot.version === 2 || snapshot.version === 3 || snapshot.version === 4) {
|
|
23
30
|
if (snapshot.version === 2 && snapshot.localFields === void 0)
|
|
24
31
|
throw new Error("Snapshot version 2 requires explicit localFields rules.");
|
|
25
32
|
normalizeLocalFields(snapshot.localFields);
|
|
@@ -27,7 +34,11 @@ function validateSnapshotFieldPolicy(snapshot) {
|
|
|
27
34
|
}
|
|
28
35
|
function validatePortableSnapshot(snapshot) {
|
|
29
36
|
validateSnapshotFieldPolicy(snapshot);
|
|
30
|
-
|
|
37
|
+
validateSnapshotSelection(snapshot);
|
|
38
|
+
const excludedPath = compileSyncExclude(snapshotSelectionExclude(snapshot));
|
|
39
|
+
if (snapshot.files.some((file2) => excludedPath(file2.path)))
|
|
40
|
+
throw new Error("Portable snapshot retains excluded paths.");
|
|
41
|
+
if (snapshot.version === 1 || !snapshot.localFields?.length) return;
|
|
31
42
|
try {
|
|
32
43
|
for (const entry of snapshot.files) {
|
|
33
44
|
if (typeof entry?.path !== "string" || entry.path.toLowerCase() !== "settings.json") continue;
|
|
@@ -64,7 +75,12 @@ function portableSnapshot(snapshot, fields) {
|
|
|
64
75
|
return file(Buffer.from(`${JSON.stringify(canonical(object))}
|
|
65
76
|
`));
|
|
66
77
|
});
|
|
67
|
-
return regenerateSnapshotIdentity({
|
|
78
|
+
return regenerateSnapshotIdentity({
|
|
79
|
+
...snapshot,
|
|
80
|
+
version: snapshot.version === 4 ? 4 : 2,
|
|
81
|
+
localFields: [...excluded],
|
|
82
|
+
files
|
|
83
|
+
});
|
|
68
84
|
}
|
|
69
85
|
function overlayLocalFields(portable, local, fields) {
|
|
70
86
|
if (!fields?.length) return portable;
|
|
@@ -104,4 +120,4 @@ export {
|
|
|
104
120
|
portableSnapshot,
|
|
105
121
|
overlayLocalFields
|
|
106
122
|
};
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-P3YD4ONV.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/local-fields.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { regenerateSnapshotIdentity } from \"../snapshot/snapshot.js\";\nimport type { Snapshot, SnapshotFile } from \"../snapshot/snapshot-types.js\";\nimport { compileSyncExclude } from \"./exclude-policy.js\";\nimport {\n type JsonDocument,\n type JsonNode,\n jsonEqual,\n parseSettingsDocument,\n renderSettingsMembers,\n} from \"./json-document.js\";\nimport { normalizeLocalFields } from \"./local-field-policy.js\";\nimport { snapshotSelectionExclude, validateSnapshotSelection } from \"./sync-policy.js\";\n\nexport { normalizeLocalFields } from \"./local-field-policy.js\";\n\n/** Shared transport contract: older snapshots cannot carry portable policy metadata. */\nexport function validateSnapshotFieldPolicy(snapshot: Pick<Snapshot, \"version\" | \"localFields\">) {\n if (snapshot.version !== 1 && snapshot.version !== 2 && snapshot.version !== 3 && snapshot.version !== 4)\n throw new Error(\"Unsupported snapshot format.\");\n if (snapshot.version === 1 && snapshot.localFields !== undefined)\n throw new Error(\"Portable field policy requires snapshot version 2.\");\n if (snapshot.version === 2 || snapshot.version === 3 || snapshot.version === 4) {\n if (snapshot.version === 2 && snapshot.localFields === undefined)\n throw new Error(\"Snapshot version 2 requires explicit localFields rules.\");\n normalizeLocalFields(snapshot.localFields);\n }\n}\n/** Portable transport images must not carry values declared machine-local. Physical journal images are different. */\nexport function validatePortableSnapshot(snapshot: Snapshot) {\n validateSnapshotFieldPolicy(snapshot);\n validateSnapshotSelection(snapshot);\n const excludedPath = compileSyncExclude(snapshotSelectionExclude(snapshot));\n if (snapshot.files.some((file) => excludedPath(file.path)))\n throw new Error(\"Portable snapshot retains excluded paths.\");\n if (snapshot.version === 1 || !snapshot.localFields?.length) return;\n try {\n for (const entry of snapshot.files) {\n if (typeof entry?.path !== \"string\" || entry.path.toLowerCase() !== \"settings.json\") continue;\n const document = parseSettingsDocument(Buffer.from(entry.contentBase64, \"base64\"));\n if (snapshot.localFields.some((field) => document.root.members.has(field))) throw new Error(\"Excluded field.\");\n }\n } catch {\n throw new Error(\"Portable snapshot settings.json retains excluded fields or has an unsupported document.\");\n }\n}\nexport function sameLocalFields(left: unknown, right: unknown) {\n if (left === undefined || right === undefined) return left === right;\n return JSON.stringify(normalizeLocalFields(left)) === JSON.stringify(normalizeLocalFields(right));\n}\nfunction file(content: Buffer): SnapshotFile {\n return {\n path: \"settings.json\",\n contentBase64: content.toString(\"base64\"),\n sha256: createHash(\"sha256\").update(content).digest(\"hex\"),\n };\n}\nexport function portableSnapshot(snapshot: Snapshot, fields: string[] | undefined): Snapshot {\n if (fields === undefined) return snapshot;\n const excluded = new Set(normalizeLocalFields(fields));\n const files = snapshot.files.map((entry) => {\n if (entry.path !== \"settings.json\" || excluded.size === 0) return entry;\n const document = parseSettingsDocument(Buffer.from(entry.contentBase64, \"base64\"));\n const object = Object.create(null);\n for (const key of [...document.root.members.keys()].sort())\n if (!excluded.has(key)) object[key] = document.root.members.get(key)?.node.value;\n const canonical = (value: unknown): unknown =>\n Array.isArray(value)\n ? value.map(canonical)\n : value && typeof value === \"object\"\n ? Object.fromEntries(\n Object.entries(value)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n .map(([key, child]) => [key, canonical(child)]),\n )\n : value;\n return file(Buffer.from(`${JSON.stringify(canonical(object))}\\n`));\n });\n return regenerateSnapshotIdentity({\n ...snapshot,\n version: snapshot.version === 4 ? 4 : 2,\n localFields: [...excluded],\n files,\n });\n}\nexport function overlayLocalFields(portable: Snapshot, local: Snapshot, fields: string[] | undefined): Snapshot {\n if (!fields?.length) return portable;\n const target = portable.files.find((entry) => entry.path === \"settings.json\");\n const current = local.files.find((entry) => entry.path === \"settings.json\");\n if (!target && !current) return portable;\n const original = current\n ? parseSettingsDocument(Buffer.from(current.contentBase64, \"base64\"))\n : parseSettingsDocument(Buffer.from(\"{}\"));\n if (!target) {\n if (fields.some((field) => original.root.members.has(field)))\n throw new Error(\"Portable settings deletion requires manual review; local-only fields were preserved.\");\n return portable;\n }\n const incoming = parseSettingsDocument(Buffer.from(target.contentBase64, \"base64\"));\n const selected = new Map<string, { document: JsonDocument; node: JsonNode }>();\n const excluded = new Set(fields);\n for (const [key, member] of incoming.root.members) {\n if (excluded.has(key)) continue;\n const existing = original.root.members.get(key);\n selected.set(\n key,\n existing && jsonEqual(existing.node.value, member.node.value)\n ? { document: original, node: existing.node }\n : { document: incoming, node: member.node },\n );\n }\n for (const [key, member] of original.root.members)\n if (excluded.has(key)) selected.set(key, { document: original, node: member.node });\n const content = renderSettingsMembers(original, selected);\n return regenerateSnapshotIdentity({\n ...portable,\n files: portable.files.map((entry) => (entry.path === \"settings.json\" ? file(content) : entry)),\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAiBpB,SAAS,4BAA4B,UAAqD;AAC/F,MAAI,SAAS,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS,YAAY;AACrG,UAAM,IAAI,MAAM,8BAA8B;AAChD,MAAI,SAAS,YAAY,KAAK,SAAS,gBAAgB;AACrD,UAAM,IAAI,MAAM,oDAAoD;AACtE,MAAI,SAAS,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS,YAAY,GAAG;AAC9E,QAAI,SAAS,YAAY,KAAK,SAAS,gBAAgB;AACrD,YAAM,IAAI,MAAM,yDAAyD;AAC3E,yBAAqB,SAAS,WAAW;AAAA,EAC3C;AACF;AAEO,SAAS,yBAAyB,UAAoB;AAC3D,8BAA4B,QAAQ;AACpC,4BAA0B,QAAQ;AAClC,QAAM,eAAe,mBAAmB,yBAAyB,QAAQ,CAAC;AAC1E,MAAI,SAAS,MAAM,KAAK,CAACA,UAAS,aAAaA,MAAK,IAAI,CAAC;AACvD,UAAM,IAAI,MAAM,2CAA2C;AAC7D,MAAI,SAAS,YAAY,KAAK,CAAC,SAAS,aAAa,OAAQ;AAC7D,MAAI;AACF,eAAW,SAAS,SAAS,OAAO;AAClC,UAAI,OAAO,OAAO,SAAS,YAAY,MAAM,KAAK,YAAY,MAAM,gBAAiB;AACrF,YAAM,WAAW,sBAAsB,OAAO,KAAK,MAAM,eAAe,QAAQ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,MACA,YAAY,UAAU,SAAS,KAAK,OAAO,OAAO,KAAK,KAAK,IACxD,EAAE,UAAU,UAAU,MAAM,SAAS,KAAK,IAC1C,EAAE,UAAU,UAAU,MAAM,OAAO,KAAK;AAAA,IAC9C;AAAA,EACF;AACA,aAAW,CAAC,KAAK,MAAM,KAAK,SAAS,KAAK;AACxC,QAAI,SAAS,IAAI,GAAG,EAAG,UAAS,IAAI,KAAK,EAAE,UAAU,UAAU,MAAM,OAAO,KAAK,CAAC;AACpF,QAAM,UAAU,sBAAsB,UAAU,QAAQ;AACxD,SAAO,2BAA2B;AAAA,IAChC,GAAG;AAAA,IACH,OAAO,SAAS,MAAM,IAAI,CAAC,UAAW,MAAM,SAAS,kBAAkB,KAAK,OAAO,IAAI,KAAM;AAAA,EAC/F,CAAC;AACH;",
|
|
6
|
+
"names": ["file"]
|
|
7
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
runCancellableOperation,
|
|
5
5
|
showRemoteSelectionReview
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NGW4JMBF.ts";
|
|
7
7
|
import {
|
|
8
8
|
safeTerminalText
|
|
9
9
|
} from "./chunk-AMJRUXFT.ts";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
loadConfig,
|
|
15
15
|
syncConfigReviewIdentity
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-XZ3ZTHKR.ts";
|
|
17
17
|
|
|
18
18
|
// src/ui/sync-resolution-ui.ts
|
|
19
19
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
@@ -206,4 +206,4 @@ async function dispatchManagerResult(ctx, initialResult, origin, runRoute, signa
|
|
|
206
206
|
export {
|
|
207
207
|
dispatchManagerResult
|
|
208
208
|
};
|
|
209
|
-
//# sourceMappingURL=chunk-
|
|
209
|
+
//# sourceMappingURL=chunk-PQ75RPUP.ts.map
|
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
throwIfAborted
|
|
5
5
|
} from "./chunk-PWMWOJP4.ts";
|
|
6
6
|
import {
|
|
7
|
-
snapshotSelectionInclude
|
|
8
|
-
|
|
7
|
+
snapshotSelectionInclude,
|
|
8
|
+
validateSnapshotSelection
|
|
9
|
+
} from "./chunk-WUHRVSWI.ts";
|
|
9
10
|
|
|
10
11
|
// src/snapshot/snapshot-codec.ts
|
|
11
12
|
import { Readable, Writable } from "node:stream";
|
|
@@ -17,6 +18,11 @@ var MAX_DECOMPRESSED_SNAPSHOT_BYTES = 512 * 1024 * 1024;
|
|
|
17
18
|
var gzipAsync = promisify(gzip);
|
|
18
19
|
async function encodeSnapshot(snapshot) {
|
|
19
20
|
snapshotSelectionInclude(snapshot);
|
|
21
|
+
validateSnapshotSelection(snapshot);
|
|
22
|
+
if (snapshot.version === 4) {
|
|
23
|
+
const { validatePortableSnapshot } = await import("./local-fields-SR7PH66U.ts");
|
|
24
|
+
validatePortableSnapshot(snapshot);
|
|
25
|
+
}
|
|
20
26
|
return gzipAsync(Buffer.from(JSON.stringify(snapshot), "utf8"));
|
|
21
27
|
}
|
|
22
28
|
async function decodeSnapshot(buffer, options = {}) {
|
|
@@ -38,11 +44,12 @@ async function decodeSnapshot(buffer, options = {}) {
|
|
|
38
44
|
await pipeline(Readable.from([buffer]), createGunzip(), sink, { signal: options.signal });
|
|
39
45
|
throwIfAborted(options.signal);
|
|
40
46
|
const parsed = JSON.parse(Buffer.concat(chunks, total).toString("utf8"));
|
|
41
|
-
if (parsed.version !== VERSION && parsed.version !== 2 && parsed.version !== 3 || !Array.isArray(parsed.files)) {
|
|
47
|
+
if (parsed.version !== VERSION && parsed.version !== 2 && parsed.version !== 3 && parsed.version !== 4 || !Array.isArray(parsed.files)) {
|
|
42
48
|
throw new Error("Unsupported snapshot format.");
|
|
43
49
|
}
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
validateSnapshotSelection(parsed);
|
|
51
|
+
if (parsed.version === 2 || parsed.version === 3 || parsed.version === 4) {
|
|
52
|
+
const { normalizeLocalFields, validatePortableSnapshot } = await import("./local-fields-SR7PH66U.ts");
|
|
46
53
|
validatePortableSnapshot(parsed);
|
|
47
54
|
if (parsed.localFields !== void 0) parsed.localFields = normalizeLocalFields(parsed.localFields);
|
|
48
55
|
} else if (parsed.localFields !== void 0) throw new Error("Portable field policy requires snapshot version 2.");
|
|
@@ -54,4 +61,4 @@ export {
|
|
|
54
61
|
encodeSnapshot,
|
|
55
62
|
decodeSnapshot
|
|
56
63
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-QQVK2XFC.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/snapshot/snapshot-codec.ts"],
|
|
4
|
+
"sourcesContent": ["import { Readable, Writable } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\nimport { promisify } from \"node:util\";\nimport { createGunzip, gzip } from \"node:zlib\";\nimport { throwIfAborted } from \"../sync/signals.js\";\nimport { snapshotSelectionInclude, validateSnapshotSelection } from \"../sync/sync-policy.js\";\nimport type { Snapshot } from \"./snapshot-types.js\";\n\nconst VERSION = 1;\nconst MAX_DECOMPRESSED_SNAPSHOT_BYTES = 512 * 1024 * 1024;\nconst gzipAsync = promisify(gzip);\n\nexport async function encodeSnapshot(snapshot: Snapshot) {\n snapshotSelectionInclude(snapshot);\n validateSnapshotSelection(snapshot);\n if (snapshot.version === 4) {\n const { validatePortableSnapshot } = await import(\"../sync/local-fields.js\");\n validatePortableSnapshot(snapshot);\n }\n return gzipAsync(Buffer.from(JSON.stringify(snapshot), \"utf8\"));\n}\n\nexport async function decodeSnapshot(\n buffer: Buffer,\n options: { signal?: AbortSignal; maxOutputLength?: number } = {},\n): Promise<Snapshot> {\n throwIfAborted(options.signal);\n const limit = options.maxOutputLength ?? MAX_DECOMPRESSED_SNAPSHOT_BYTES;\n const chunks: Buffer[] = [];\n let total = 0;\n const sink = new Writable({\n write(chunk: Buffer, _encoding, callback) {\n total += chunk.byteLength;\n if (total > limit) {\n callback(new Error(`Decompressed snapshot exceeds the ${limit}-byte limit.`));\n return;\n }\n chunks.push(Buffer.from(chunk));\n callback();\n },\n });\n await pipeline(Readable.from([buffer]), createGunzip(), sink, { signal: options.signal });\n throwIfAborted(options.signal);\n const parsed = JSON.parse(Buffer.concat(chunks, total).toString(\"utf8\")) as Snapshot;\n if (\n (parsed.version !== VERSION && parsed.version !== 2 && parsed.version !== 3 && parsed.version !== 4) ||\n !Array.isArray(parsed.files)\n ) {\n throw new Error(\"Unsupported snapshot format.\");\n }\n validateSnapshotSelection(parsed);\n if (parsed.version === 2 || parsed.version === 3 || parsed.version === 4) {\n const { normalizeLocalFields, validatePortableSnapshot } = await import(\"../sync/local-fields.js\");\n validatePortableSnapshot(parsed);\n if (parsed.localFields !== undefined) parsed.localFields = normalizeLocalFields(parsed.localFields);\n } else if (parsed.localFields !== undefined) throw new Error(\"Portable field policy requires snapshot version 2.\");\n snapshotSelectionInclude(parsed);\n return parsed;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAAA,SAAS,UAAU,gBAAgB;AACnC,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,cAAc,YAAY;AAKnC,IAAM,UAAU;AAChB,IAAM,kCAAkC,MAAM,OAAO;AACrD,IAAM,YAAY,UAAU,IAAI;AAEhC,eAAsB,eAAe,UAAoB;AACvD,2BAAyB,QAAQ;AACjC,4BAA0B,QAAQ;AAClC,MAAI,SAAS,YAAY,GAAG;AAC1B,UAAM,EAAE,yBAAyB,IAAI,MAAM,OAAO,4BAAyB;AAC3E,6BAAyB,QAAQ;AAAA,EACnC;AACA,SAAO,UAAU,OAAO,KAAK,KAAK,UAAU,QAAQ,GAAG,MAAM,CAAC;AAChE;AAEA,eAAsB,eACpB,QACA,UAA8D,CAAC,GAC5C;AACnB,iBAAe,Q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+
} from "./chunk-S7D6XWHI.ts";
|
|
12
12
|
import {
|
|
13
13
|
ContinuousError
|
|
14
14
|
} from "./chunk-DT7M4VQS.ts";
|
|
@@ -29,8 +29,8 @@ async function withAgentSyncLock(ctx, options, run) {
|
|
|
29
29
|
if (!(error instanceof AgentResolutionRequired)) throw error;
|
|
30
30
|
request = error;
|
|
31
31
|
}
|
|
32
|
-
const { withAgentClaim, readAgentCandidate, saveAgentCandidate, replaceRefusedAgentCandidate } = await import("./agent-store-
|
|
33
|
-
const { parseAgentCandidate } = await import("./agent-candidate-
|
|
32
|
+
const { withAgentClaim, readAgentCandidate, saveAgentCandidate, replaceRefusedAgentCandidate } = await import("./agent-store-CCKN4DPR.ts");
|
|
33
|
+
const { parseAgentCandidate } = await import("./agent-candidate-ZHN7FTZT.ts");
|
|
34
34
|
const { runAgentResolver } = await import("./agent-runner-FCRV2Z75.ts");
|
|
35
35
|
return withAgentClaim(async (assertOwner) => {
|
|
36
36
|
const clearStatus = () => setSyncStatus(ctx, void 0);
|
|
@@ -69,7 +69,7 @@ async function withAgentSyncLock(ctx, options, run) {
|
|
|
69
69
|
expectedRefusal = parseAgentCandidate(JSON.stringify(cached), request.evidence);
|
|
70
70
|
if (!expectedRefusal.results.some((row) => "refuse" in row))
|
|
71
71
|
throw new Error("The current cached result is not a refusal. Use Sync now.");
|
|
72
|
-
const { confirmAgentRefusalRetry } = await import("./agent-refusal-retry-
|
|
72
|
+
const { confirmAgentRefusalRetry } = await import("./agent-refusal-retry-HRMHCX2A.ts");
|
|
73
73
|
options.signal?.throwIfAborted();
|
|
74
74
|
if (!await confirmAgentRefusalRetry(ctx, options.setup, request.evidence, validate, options.signal))
|
|
75
75
|
return "cancelled";
|
|
@@ -137,4 +137,4 @@ async function withAgentSyncLock(ctx, options, run) {
|
|
|
137
137
|
export {
|
|
138
138
|
withAgentSyncLock
|
|
139
139
|
};
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-RDOX3VH5.ts.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
ensureStateDir,
|
|
8
8
|
lockPath
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4NVHHDN2.ts";
|
|
10
10
|
import {
|
|
11
11
|
LOCKFILE_FS_ADAPTER,
|
|
12
12
|
LOCK_GUARD_STALE_MS,
|
|
@@ -255,4 +255,4 @@ export {
|
|
|
255
255
|
isStaleLock,
|
|
256
256
|
unlock
|
|
257
257
|
};
|
|
258
|
-
//# sourceMappingURL=chunk-
|
|
258
|
+
//# sourceMappingURL=chunk-S7D6XWHI.ts.map
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
fileHashMap,
|
|
5
5
|
hasLocalChanges,
|
|
6
6
|
remoteChangedSinceState
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6YGRZSCN.ts";
|
|
8
8
|
import {
|
|
9
9
|
createSyncBackend
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2UKUKIBI.ts";
|
|
11
11
|
import {
|
|
12
12
|
createStartupTimings
|
|
13
13
|
} from "./chunk-M6VQJIOU.ts";
|
|
@@ -17,13 +17,13 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
readStateForConfig,
|
|
19
19
|
syncStateFingerprint
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4NVHHDN2.ts";
|
|
21
21
|
import {
|
|
22
22
|
createSnapshot
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-MKC3PXCN.ts";
|
|
24
24
|
import {
|
|
25
25
|
inspectRemoteSelection
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-WUHRVSWI.ts";
|
|
27
27
|
|
|
28
28
|
// src/sync/sync-inspection.ts
|
|
29
29
|
import { createHash } from "node:crypto";
|
|
@@ -46,7 +46,7 @@ async function inspectSync(config, options, signal, factory = createSyncBackend,
|
|
|
46
46
|
return {
|
|
47
47
|
...freshness,
|
|
48
48
|
head,
|
|
49
|
-
selectionState: head ? inspectRemoteSelection(config.include, { selection: head.selection, files: [] }) : void 0,
|
|
49
|
+
selectionState: head ? inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude) : void 0,
|
|
50
50
|
localFiles: local.files.length,
|
|
51
51
|
localChanged: hasLocalChanges(local, state, config),
|
|
52
52
|
remoteChanged: remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)),
|
|
@@ -61,4 +61,4 @@ async function inspectSync(config, options, signal, factory = createSyncBackend,
|
|
|
61
61
|
export {
|
|
62
62
|
inspectSync
|
|
63
63
|
};
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-SHPNS7FM.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sync/sync-inspection.ts"],
|
|
4
|
-
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { createSyncBackend, type SyncBackendFactory } from \"../backends/backend-factory.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { createSnapshot } from \"../snapshot/snapshot.js\";\nimport type { SnapshotOptions } from \"../snapshot/snapshot-types.js\";\nimport { readStateForConfig, syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { throwIfAborted } from \"./signals.js\";\nimport { createStartupTimings, type StartupTimings } from \"./startup-timings.js\";\nimport { inspectRemoteSelection } from \"./sync-policy.js\";\nimport { fileHashMap, hasLocalChanges, remoteChangedSinceState } from \"./sync-state.js\";\n\n/** Advisory baseline-relative observation, never an authorization to transfer files. */\nexport async function inspectSync(\n config: AnySyncConfig,\n options: SnapshotOptions,\n signal?: AbortSignal,\n factory: SyncBackendFactory = createSyncBackend,\n timings: StartupTimings = createStartupTimings(),\n) {\n throwIfAborted(signal);\n const backend = await timings.measure(\"backend initialization\", () => factory(config));\n throwIfAborted(signal);\n const local = await timings.measure(\"local snapshot\", () =>\n createSnapshot(config.snapshotIdentity, { ...options, signal }),\n );\n throwIfAborted(signal);\n const state = await timings.measure(\"sync state read\", () => readStateForConfig(config));\n throwIfAborted(signal);\n const head = await timings.measure(\"remote head\", () => backend.readHead(signal));\n throwIfAborted(signal);\n const freshness: { localIdentity?: string } = {\n localIdentity: createHash(\"sha256\")\n .update(JSON.stringify(fileHashMap(local)))\n .digest(\"hex\"),\n };\n return {\n ...freshness,\n head,\n selectionState: head
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAY3B,eAAsB,YACpB,QACA,SACA,QACA,UAA8B,mBAC9B,UAA0B,qBAAqB,GAC/C;AACA,iBAAe,MAAM;AACrB,QAAM,UAAU,MAAM,QAAQ,QAAQ,0BAA0B,MAAM,QAAQ,MAAM,CAAC;AACrF,iBAAe,MAAM;AACrB,QAAM,QAAQ,MAAM,QAAQ;AAAA,IAAQ;AAAA,IAAkB,MACpD,eAAe,OAAO,kBAAkB,EAAE,GAAG,SAAS,OAAO,CAAC;AAAA,EAChE;AACA,iBAAe,MAAM;AACrB,QAAM,QAAQ,MAAM,QAAQ,QAAQ,mBAAmB,MAAM,mBAAmB,MAAM,CAAC;AACvF,iBAAe,MAAM;AACrB,QAAM,OAAO,MAAM,QAAQ,QAAQ,eAAe,MAAM,QAAQ,SAAS,MAAM,CAAC;AAChF,iBAAe,MAAM;AACrB,QAAM,YAAwC;AAAA,IAC5C,eAAe,WAAW,QAAQ,EAC/B,OAAO,KAAK,UAAU,YAAY,KAAK,CAAC,CAAC,EACzC,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,gBAAgB,
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { createSyncBackend, type SyncBackendFactory } from \"../backends/backend-factory.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { createSnapshot } from \"../snapshot/snapshot.js\";\nimport type { SnapshotOptions } from \"../snapshot/snapshot-types.js\";\nimport { readStateForConfig, syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { throwIfAborted } from \"./signals.js\";\nimport { createStartupTimings, type StartupTimings } from \"./startup-timings.js\";\nimport { inspectRemoteSelection } from \"./sync-policy.js\";\nimport { fileHashMap, hasLocalChanges, remoteChangedSinceState } from \"./sync-state.js\";\n\n/** Advisory baseline-relative observation, never an authorization to transfer files. */\nexport async function inspectSync(\n config: AnySyncConfig,\n options: SnapshotOptions,\n signal?: AbortSignal,\n factory: SyncBackendFactory = createSyncBackend,\n timings: StartupTimings = createStartupTimings(),\n) {\n throwIfAborted(signal);\n const backend = await timings.measure(\"backend initialization\", () => factory(config));\n throwIfAborted(signal);\n const local = await timings.measure(\"local snapshot\", () =>\n createSnapshot(config.snapshotIdentity, { ...options, signal }),\n );\n throwIfAborted(signal);\n const state = await timings.measure(\"sync state read\", () => readStateForConfig(config));\n throwIfAborted(signal);\n const head = await timings.measure(\"remote head\", () => backend.readHead(signal));\n throwIfAborted(signal);\n const freshness: { localIdentity?: string } = {\n localIdentity: createHash(\"sha256\")\n .update(JSON.stringify(fileHashMap(local)))\n .digest(\"hex\"),\n };\n return {\n ...freshness,\n head,\n selectionState: head\n ? inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude)\n : undefined,\n localFiles: local.files.length,\n localChanged: hasLocalChanges(local, state, config),\n remoteChanged: remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)),\n firstSync: !state.lastAppliedSnapshot,\n emptyInclude: config.include.length === 0,\n stateIdentity: syncStateFingerprint(state),\n destination: backend.destination,\n capability: backend.capability,\n };\n}\n\nexport type SyncInspection = Awaited<ReturnType<typeof inspectSync>>;\n\nexport interface StartupObservation {\n setupName: string;\n configIdentity: string;\n checkedAt: string;\n automaticTransfer?: boolean;\n inspection: SyncInspection;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;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@ import {
|
|
|
5
5
|
} from "./chunk-PWMWOJP4.ts";
|
|
6
6
|
import {
|
|
7
7
|
agentDir
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LA3HQMFG.ts";
|
|
9
9
|
|
|
10
10
|
// src/sync/mutation-owner.ts
|
|
11
11
|
function captureMutationOwner(ctx, signal) {
|
|
@@ -24,4 +24,4 @@ function captureMutationOwner(ctx, signal) {
|
|
|
24
24
|
export {
|
|
25
25
|
captureMutationOwner
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-T2TYBLXK.ts.map
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
statePathForConfig,
|
|
13
13
|
syncStateFingerprint
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-4NVHHDN2.ts";
|
|
15
15
|
import {
|
|
16
16
|
syncDirectory,
|
|
17
17
|
writeJson
|
|
@@ -19,6 +19,10 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
backendIdentityCoordinates
|
|
21
21
|
} from "./chunk-2JZFHNLM.ts";
|
|
22
|
+
import {
|
|
23
|
+
compileSyncExclude,
|
|
24
|
+
normalizeSyncExclude
|
|
25
|
+
} from "./chunk-3JTZF7Z5.ts";
|
|
22
26
|
|
|
23
27
|
// src/state/merge-baseline-store.ts
|
|
24
28
|
import { createHash } from "node:crypto";
|
|
@@ -258,7 +262,8 @@ function identity(config) {
|
|
|
258
262
|
config.setupName,
|
|
259
263
|
backendIdentityCoordinates(config),
|
|
260
264
|
config.include,
|
|
261
|
-
config.localFields ?? []
|
|
265
|
+
config.localFields ?? [],
|
|
266
|
+
...config.exclude === void 0 ? [] : ["exclude", normalizeSyncExclude(config.exclude).map((rule) => rule.toLowerCase())]
|
|
262
267
|
]);
|
|
263
268
|
}
|
|
264
269
|
function directory(config) {
|
|
@@ -276,8 +281,9 @@ function baselinePath(config, state) {
|
|
|
276
281
|
}
|
|
277
282
|
async function stageMergeBaseline(config, snapshot, accepted, previous) {
|
|
278
283
|
const collisions = collidingPaths(snapshot.files.map((file) => file.path));
|
|
284
|
+
const excluded = compileSyncExclude(config.exclude);
|
|
279
285
|
const files = snapshot.files.filter((file) => {
|
|
280
|
-
return !collisions.has(file.path) && accepted.lastFileHashes[file.path] === file.sha256 && (file.path === "settings.json" || config.mergeContent || config.agentMode && isMergeTextPath(file.path)) && eligible(file);
|
|
286
|
+
return !excluded(file.path) && !collisions.has(file.path) && accepted.lastFileHashes[file.path] === file.sha256 && (file.path === "settings.json" || config.mergeContent || config.agentMode && isMergeTextPath(file.path)) && eligible(file);
|
|
281
287
|
});
|
|
282
288
|
if (previous) {
|
|
283
289
|
const stagedPaths = new Set(files.map((file) => file.path));
|
|
@@ -287,7 +293,7 @@ async function stageMergeBaseline(config, snapshot, accepted, previous) {
|
|
|
287
293
|
} catch {
|
|
288
294
|
}
|
|
289
295
|
for (const ancestor of ancestors)
|
|
290
|
-
if (!collisions.has(ancestor.path) && accepted.lastFileHashes[ancestor.path] === ancestor.sha256 && !stagedPaths.has(ancestor.path)) {
|
|
296
|
+
if (!excluded(ancestor.path) && !collisions.has(ancestor.path) && accepted.lastFileHashes[ancestor.path] === ancestor.sha256 && !stagedPaths.has(ancestor.path)) {
|
|
291
297
|
files.push(ancestor);
|
|
292
298
|
stagedPaths.add(ancestor.path);
|
|
293
299
|
}
|
|
@@ -331,7 +337,8 @@ async function readMergeAncestors(config, state) {
|
|
|
331
337
|
if (error.code === "ENOENT") return;
|
|
332
338
|
throw new Error("Merge ancestor is invalid; preserve its private cache and review the conflict.");
|
|
333
339
|
}
|
|
334
|
-
|
|
340
|
+
const excluded = compileSyncExclude(config.exclude);
|
|
341
|
+
return record.files.filter((file) => !excluded(file.path));
|
|
335
342
|
}
|
|
336
343
|
async function hasCurrentMergeBaseline(config, snapshot, state) {
|
|
337
344
|
try {
|
|
@@ -393,4 +400,4 @@ export {
|
|
|
393
400
|
readMergeAncestor,
|
|
394
401
|
pruneMergeBaselines
|
|
395
402
|
};
|
|
396
|
-
//# sourceMappingURL=chunk-
|
|
403
|
+
//# sourceMappingURL=chunk-UZSDS4HF.ts.map
|