@narumitw/pi-sync 0.61.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +46 -25
- package/dist/chunks/{chunk-277VHM2P.ts → chunk-27F5W7DX.ts} +7 -3
- package/dist/chunks/chunk-27F5W7DX.ts.map +7 -0
- package/dist/chunks/{chunk-ZIL6PW5L.ts → chunk-6YKOHBSC.ts} +2 -2
- package/dist/chunks/{chunk-OA4NZLSL.ts → chunk-APZVJAEW.ts} +4 -3
- package/dist/chunks/chunk-CKUGCBHP.ts +114 -0
- package/dist/chunks/chunk-CKUGCBHP.ts.map +7 -0
- package/dist/chunks/chunk-EJDDRS6O.ts +17 -0
- package/dist/chunks/chunk-EJDDRS6O.ts.map +7 -0
- package/dist/chunks/{chunk-JVFCVPPD.ts → chunk-EXDWEFIJ.ts} +87 -147
- package/dist/chunks/chunk-EXDWEFIJ.ts.map +7 -0
- package/dist/chunks/{chunk-4SR3ZYHA.ts → chunk-GELYN4UC.ts} +2 -2
- package/dist/chunks/{chunk-2ZGV5KNC.ts → chunk-HSCAFOT5.ts} +15 -12
- package/dist/chunks/chunk-HSCAFOT5.ts.map +7 -0
- package/dist/chunks/{chunk-YQSFJLJ3.ts → chunk-IBXEM35O.ts} +4 -3
- package/dist/chunks/{chunk-2JHAN3ZO.ts → chunk-JREGWM2B.ts} +3 -3
- package/dist/chunks/chunk-MANNB4WZ.ts +36 -0
- package/dist/chunks/chunk-MANNB4WZ.ts.map +7 -0
- package/dist/chunks/{chunk-EMRFVLZM.ts → chunk-NXWHPVXR.ts} +2 -2
- package/dist/chunks/{chunk-SMVKMYLK.ts → chunk-P4GI7LTT.ts} +2 -2
- package/dist/chunks/{chunk-ZVGRZD4C.ts → chunk-R3SAMXB6.ts} +2 -2
- package/dist/chunks/{chunk-4KTJLJSJ.ts → chunk-S6FUUWV5.ts} +148 -21
- package/dist/chunks/chunk-S6FUUWV5.ts.map +7 -0
- package/dist/chunks/{chunk-PJMM75W5.ts → chunk-SXCH4Q5O.ts} +41 -23
- package/dist/chunks/chunk-SXCH4Q5O.ts.map +7 -0
- package/dist/chunks/{chunk-RNIEVDTR.ts → chunk-T3LABNHF.ts} +2 -2
- package/dist/chunks/{chunk-E3YLRLJM.ts → chunk-UGS6RYDZ.ts} +14 -12
- package/dist/chunks/chunk-UGS6RYDZ.ts.map +7 -0
- package/dist/chunks/{chunk-S3R3W3KF.ts → chunk-UMPA5S7X.ts} +2 -2
- package/dist/chunks/{chunk-EMVZL4PH.ts → chunk-V76KCWHO.ts} +7 -5
- package/dist/chunks/{chunk-EMVZL4PH.ts.map → chunk-V76KCWHO.ts.map} +1 -1
- package/dist/chunks/{chunk-S7F4FOAS.ts → chunk-VQ47JBLF.ts} +5 -5
- package/dist/chunks/{chunk-WP2M67XZ.ts → chunk-WBIOSK76.ts} +2 -2
- package/dist/chunks/chunk-WFBHWYI6.ts +18 -0
- package/dist/chunks/chunk-WFBHWYI6.ts.map +7 -0
- package/dist/chunks/{chunk-HEB6YT64.ts → chunk-ZO52JM4H.ts} +2 -2
- package/dist/chunks/{command-handler-K4XJOGYC.ts → command-handler-VINMQ7ZM.ts} +26 -43
- package/dist/chunks/command-handler-VINMQ7ZM.ts.map +7 -0
- package/dist/chunks/{conflict-review-IGKY2TOJ.ts → conflict-review-PCDFRIVB.ts} +4 -4
- package/dist/chunks/{continuous-record-3XDXDOMV.ts → continuous-record-3SKJ6I3V.ts} +2 -2
- package/dist/chunks/{continuous-storage-HLKCHF6Z.ts → continuous-storage-3EU6I7Z3.ts} +2 -2
- package/dist/chunks/{file-selection-MGGVOKM7.ts → file-selection-KID23GAD.ts} +21 -14
- package/dist/chunks/file-selection-KID23GAD.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-GDB74IOP.ts +20 -0
- package/dist/chunks/{manager-ui-KYQ5AZJS.ts → manager-ui-YHDECYKI.ts} +454 -167
- package/dist/chunks/manager-ui-YHDECYKI.ts.map +7 -0
- package/dist/chunks/remote-selection-ui-GPITNEBF.ts +19 -0
- package/dist/chunks/{setup-switch-D6K6PBPC.ts → setup-switch-L54X5U5I.ts} +7 -7
- package/dist/chunks/{setup-wizard-4DYUDHJR.ts → setup-wizard-YO4MCPUF.ts} +15 -11
- package/dist/chunks/{setup-wizard-4DYUDHJR.ts.map → setup-wizard-YO4MCPUF.ts.map} +1 -1
- package/dist/chunks/{snapshot-5HY3M2NL.ts → snapshot-ZUJJZCFW.ts} +2 -2
- package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts → snapshot-transaction-directory-F46JWRAU.ts} +2 -2
- package/dist/chunks/{state-directory-XXHU73Z3.ts → state-directory-CMAIF34J.ts} +2 -2
- package/dist/chunks/{sync-inspection-J3CRBORL.ts → sync-inspection-H2WX5SUT.ts} +5 -5
- package/dist/chunks/{sync-operations-BVWYYKH3.ts → sync-operations-2MZAYHL2.ts} +13 -9
- package/dist/chunks/sync-operations-2MZAYHL2.ts.map +7 -0
- package/dist/chunks/{sync-state-2LMIXJ2C.ts → sync-state-QIT64TKV.ts} +2 -2
- package/dist/daemon/LICENSE +21 -0
- package/dist/daemon/dist/build-version.js +8 -0
- package/dist/daemon/dist/child-sdk.mjs +17 -0
- package/dist/daemon/dist/cli.js +169 -0
- package/dist/daemon/dist/client.js +909 -0
- package/dist/daemon/dist/consent.js +383 -0
- package/dist/daemon/dist/document.js +6 -0
- package/dist/daemon/dist/endpoint.js +91 -0
- package/dist/daemon/dist/engine/backends/backend-factory.js +16 -0
- package/dist/daemon/dist/engine/backends/backend-identity.js +38 -0
- package/dist/daemon/dist/engine/backends/backend-types.js +1 -0
- package/dist/daemon/dist/engine/backends/git/git-backend.js +746 -0
- package/dist/daemon/dist/engine/backends/git/git-config.js +118 -0
- package/dist/daemon/dist/engine/backends/git/git-runner.js +232 -0
- package/dist/daemon/dist/engine/backends/git/git-storage.js +252 -0
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +444 -0
- package/dist/daemon/dist/engine/backends/s3/s3-client.js +352 -0
- package/dist/daemon/dist/engine/backends/s3/s3-conditions.js +66 -0
- package/dist/daemon/dist/engine/backends/snapshot-pointer.js +22 -0
- package/dist/daemon/dist/engine/backends/sync-backend.js +23 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +542 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +326 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-config.js +73 -0
- package/dist/daemon/dist/engine/commands/command-types.js +1 -0
- package/dist/daemon/dist/engine/host.js +16 -0
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +33 -0
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +102 -0
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +252 -0
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +139 -0
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +393 -0
- package/dist/daemon/dist/engine/ignore/ignore-source.js +250 -0
- package/dist/daemon/dist/engine/paths.js +71 -0
- package/dist/daemon/dist/engine/settings/config-errors.js +4 -0
- package/dist/daemon/dist/engine/settings/config-file.js +736 -0
- package/dist/daemon/dist/engine/settings/config.js +344 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +199 -0
- package/dist/daemon/dist/engine/settings/settings-store.js +41 -0
- package/dist/daemon/dist/engine/settings/settings-types.js +1 -0
- package/dist/daemon/dist/engine/settings/settings-validation.js +384 -0
- package/dist/daemon/dist/engine/snapshot/session-paths.js +165 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +348 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-bounds.js +20 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-case-replacement.js +82 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +61 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-entry-projection.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +262 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-mutation-queues.js +133 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-paths.js +11 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +10 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-reviewed-preimages.js +60 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-root-transition.js +138 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-directory.js +16 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +387 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-plan.js +68 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +296 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-stage.js +303 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-verification.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +855 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +9 -0
- package/dist/daemon/dist/engine/snapshot/snapshot.js +678 -0
- package/dist/daemon/dist/engine/state/json-file.js +49 -0
- package/dist/daemon/dist/engine/state/lock-policy.js +2 -0
- package/dist/daemon/dist/engine/state/lock.js +259 -0
- package/dist/daemon/dist/engine/state/lockfile-fs.js +13 -0
- package/dist/daemon/dist/engine/state/merge-baseline-store.js +198 -0
- package/dist/daemon/dist/engine/state/mutation-directory-sync.js +34 -0
- package/dist/daemon/dist/engine/state/operation-availability.js +40 -0
- package/dist/daemon/dist/engine/state/state-directory.js +227 -0
- package/dist/daemon/dist/engine/state/state-types.js +1 -0
- package/dist/daemon/dist/engine/state/sync-state-store.js +54 -0
- package/dist/daemon/dist/engine/sync/agent-candidate.js +207 -0
- package/dist/daemon/dist/engine/sync/agent-plan.js +85 -0
- package/dist/daemon/dist/engine/sync/agent-policy.js +10 -0
- package/dist/daemon/dist/engine/sync/agent-refusal-retry.js +39 -0
- package/dist/daemon/dist/engine/sync/agent-request.js +13 -0
- package/dist/daemon/dist/engine/sync/agent-runner.js +183 -0
- package/dist/daemon/dist/engine/sync/agent-store.js +177 -0
- package/dist/daemon/dist/engine/sync/agent-sync.js +139 -0
- package/dist/daemon/dist/engine/sync/apply-review.js +52 -0
- package/dist/daemon/dist/engine/sync/conflict-artifact-ownership.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-artifacts.js +158 -0
- package/dist/daemon/dist/engine/sync/conflict-groups.js +76 -0
- package/dist/daemon/dist/engine/sync/conflict-preview.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-resolution.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-retention.js +61 -0
- package/dist/daemon/dist/engine/sync/conflict-review.js +73 -0
- package/dist/daemon/dist/engine/sync/content-conflicts.js +70 -0
- package/dist/daemon/dist/engine/sync/continuous-errors.js +66 -0
- package/dist/daemon/dist/engine/sync/continuous-lease.js +206 -0
- package/dist/daemon/dist/engine/sync/continuous-record.js +199 -0
- package/dist/daemon/dist/engine/sync/continuous-storage.js +59 -0
- package/dist/daemon/dist/engine/sync/continuous-sync.js +538 -0
- package/dist/daemon/dist/engine/sync/continuous-watch.js +140 -0
- package/dist/daemon/dist/engine/sync/exclude-policy.js +86 -0
- package/dist/daemon/dist/engine/sync/field-migration.js +20 -0
- package/dist/daemon/dist/engine/sync/file-merge-planner.js +123 -0
- package/dist/daemon/dist/engine/sync/initialization.js +80 -0
- package/dist/daemon/dist/engine/sync/json-document.js +172 -0
- package/dist/daemon/dist/engine/sync/local-field-policy.js +26 -0
- package/dist/daemon/dist/engine/sync/local-fields.js +196 -0
- package/dist/daemon/dist/engine/sync/merge-acceptance.js +29 -0
- package/dist/daemon/dist/engine/sync/merge-apply.js +532 -0
- package/dist/daemon/dist/engine/sync/merge-journal.js +314 -0
- package/dist/daemon/dist/engine/sync/merge-transfer-error.js +64 -0
- package/dist/daemon/dist/engine/sync/merged-sync.js +666 -0
- package/dist/daemon/dist/engine/sync/mutation-owner.js +18 -0
- package/dist/daemon/dist/engine/sync/package-merge.js +82 -0
- package/dist/daemon/dist/engine/sync/partial-progress.js +41 -0
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +119 -0
- package/dist/daemon/dist/engine/sync/resolver-stream.js +34 -0
- package/dist/daemon/dist/engine/sync/session-merge.js +178 -0
- package/dist/daemon/dist/engine/sync/session-push.js +47 -0
- package/dist/daemon/dist/engine/sync/settings-conflicts.js +56 -0
- package/dist/daemon/dist/engine/sync/settings-merge.js +93 -0
- package/dist/daemon/dist/engine/sync/signals.js +8 -0
- package/dist/daemon/dist/engine/sync/startup-timings.js +44 -0
- package/dist/daemon/dist/engine/sync/sync-decision.js +81 -0
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +55 -0
- package/dist/daemon/dist/engine/sync/sync-errors.js +18 -0
- package/dist/daemon/dist/engine/sync/sync-inspection.js +42 -0
- package/dist/daemon/dist/engine/sync/sync-loaders.js +8 -0
- package/dist/daemon/dist/engine/sync/sync-local.js +40 -0
- package/dist/daemon/dist/engine/sync/sync-mutations.js +754 -0
- package/dist/daemon/dist/engine/sync/sync-operations.js +3 -0
- package/dist/daemon/dist/engine/sync/sync-policy.js +646 -0
- package/dist/daemon/dist/engine/sync/sync-queries.js +212 -0
- package/dist/daemon/dist/engine/sync/sync-state.js +124 -0
- package/dist/daemon/dist/engine/sync/text-merge.js +124 -0
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +82 -0
- package/dist/daemon/dist/engine/types.js +2 -0
- package/dist/daemon/dist/engine/ui/merge-review.js +7 -0
- package/dist/daemon/dist/engine/ui/merged-sync-summary.js +86 -0
- package/dist/daemon/dist/engine/ui/sync-format.js +165 -0
- package/dist/daemon/dist/engine/ui/sync-status.js +30 -0
- package/dist/daemon/dist/engine/ui/terminal-text.js +9 -0
- package/dist/daemon/dist/engine/ui/transfer-changes.js +24 -0
- package/dist/daemon/dist/engine/ui/transfer-review.js +19 -0
- package/dist/daemon/dist/engine-service.js +441 -0
- package/dist/daemon/dist/identity.js +241 -0
- package/dist/daemon/dist/idle-exit.js +77 -0
- package/dist/daemon/dist/index.js +4 -0
- package/dist/daemon/dist/lifecycle-log.js +53 -0
- package/dist/daemon/dist/lifecycle.js +21 -0
- package/dist/daemon/dist/model-signature.js +7 -0
- package/dist/daemon/dist/monitor.js +324 -0
- package/dist/daemon/dist/participant-admission.js +30 -0
- package/dist/daemon/dist/protocol.js +104 -0
- package/dist/daemon/dist/resolver-host.js +78 -0
- package/dist/daemon/dist/server.js +994 -0
- package/dist/daemon/dist/service-host.js +175 -0
- package/dist/daemon/dist/upgrade-repair.js +55 -0
- package/dist/daemon/package.json +3 -0
- package/dist/index.ts +40 -37
- package/dist/index.ts.map +4 -4
- package/dist/package.json +6 -0
- package/docs/daemon-migration.md +27 -16
- package/package.json +9 -3
- package/skills/configure-pi-sync/SKILL.md +24 -46
- package/skills/configure-pi-sync/references/configuration.md +62 -22
- package/src/commands/command-execution.ts +13 -9
- package/src/commands/command-types.ts +1 -0
- package/src/daemon/pi-client.ts +4 -2
- package/src/settings/config.ts +2 -0
- package/src/sync/automatic-sync.ts +9 -2
- package/src/sync/setup-switch.ts +38 -15
- package/src/sync/startup-check.ts +7 -4
- package/src/sync/sync-operations.ts +18 -10
- package/src/ui/excluded-paths-ui.ts +6 -3
- package/src/ui/file-selection.ts +7 -2
- package/src/ui/ignore-file-guidance.ts +7 -0
- package/src/ui/ignore-file-ui.ts +97 -0
- package/src/ui/ignore-migration-prompt.ts +65 -0
- package/src/ui/manager-state.ts +40 -14
- package/src/ui/manager-ui.ts +41 -19
- package/src/ui/remote-selection-ui.ts +88 -28
- package/src/ui/settings-review.ts +26 -0
- package/src/ui/settings-ui.ts +378 -224
- package/src/ui/setup/setup-actions.ts +16 -4
- package/src/ui/setup/setup-prompts.ts +55 -9
- package/src/ui/setup/setup-switcher.ts +24 -11
- package/src/ui/storage-connections-ui.ts +50 -20
- package/src/ui/sync-setups-ui.ts +65 -30
- package/dist/chunks/chunk-277VHM2P.ts.map +0 -7
- package/dist/chunks/chunk-2ZGV5KNC.ts.map +0 -7
- package/dist/chunks/chunk-4KTJLJSJ.ts.map +0 -7
- package/dist/chunks/chunk-E3YLRLJM.ts.map +0 -7
- package/dist/chunks/chunk-ECYCNZOE.ts +0 -12
- package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
- package/dist/chunks/chunk-JVFCVPPD.ts.map +0 -7
- package/dist/chunks/chunk-PJMM75W5.ts.map +0 -7
- package/dist/chunks/command-handler-K4XJOGYC.ts.map +0 -7
- package/dist/chunks/file-selection-MGGVOKM7.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-4VJVDEUD.ts +0 -19
- package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-W3KOZM3W.ts +0 -18
- package/dist/chunks/sync-operations-BVWYYKH3.ts.map +0 -7
- /package/dist/chunks/{chunk-ZIL6PW5L.ts.map → chunk-6YKOHBSC.ts.map} +0 -0
- /package/dist/chunks/{chunk-OA4NZLSL.ts.map → chunk-APZVJAEW.ts.map} +0 -0
- /package/dist/chunks/{chunk-4SR3ZYHA.ts.map → chunk-GELYN4UC.ts.map} +0 -0
- /package/dist/chunks/{chunk-YQSFJLJ3.ts.map → chunk-IBXEM35O.ts.map} +0 -0
- /package/dist/chunks/{chunk-2JHAN3ZO.ts.map → chunk-JREGWM2B.ts.map} +0 -0
- /package/dist/chunks/{chunk-EMRFVLZM.ts.map → chunk-NXWHPVXR.ts.map} +0 -0
- /package/dist/chunks/{chunk-SMVKMYLK.ts.map → chunk-P4GI7LTT.ts.map} +0 -0
- /package/dist/chunks/{chunk-ZVGRZD4C.ts.map → chunk-R3SAMXB6.ts.map} +0 -0
- /package/dist/chunks/{chunk-RNIEVDTR.ts.map → chunk-T3LABNHF.ts.map} +0 -0
- /package/dist/chunks/{chunk-S3R3W3KF.ts.map → chunk-UMPA5S7X.ts.map} +0 -0
- /package/dist/chunks/{chunk-S7F4FOAS.ts.map → chunk-VQ47JBLF.ts.map} +0 -0
- /package/dist/chunks/{chunk-WP2M67XZ.ts.map → chunk-WBIOSK76.ts.map} +0 -0
- /package/dist/chunks/{chunk-HEB6YT64.ts.map → chunk-ZO52JM4H.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-IGKY2TOJ.ts.map → conflict-review-PCDFRIVB.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-3XDXDOMV.ts.map → continuous-record-3SKJ6I3V.ts.map} +0 -0
- /package/dist/chunks/{continuous-storage-HLKCHF6Z.ts.map → continuous-storage-3EU6I7Z3.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-4VJVDEUD.ts.map → manager-result-dispatcher-GDB74IOP.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-W3KOZM3W.ts.map → remote-selection-ui-GPITNEBF.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-D6K6PBPC.ts.map → setup-switch-L54X5U5I.ts.map} +0 -0
- /package/dist/chunks/{snapshot-5HY3M2NL.ts.map → snapshot-ZUJJZCFW.ts.map} +0 -0
- /package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts.map → snapshot-transaction-directory-F46JWRAU.ts.map} +0 -0
- /package/dist/chunks/{state-directory-XXHU73Z3.ts.map → state-directory-CMAIF34J.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-J3CRBORL.ts.map → sync-inspection-H2WX5SUT.ts.map} +0 -0
- /package/dist/chunks/{sync-state-2LMIXJ2C.ts.map → sync-state-QIT64TKV.ts.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { safeTerminalText } from "./terminal-text.js";
|
|
4
|
+
|
|
5
|
+
export function manualIgnoreFileGuidance(filename: string) {
|
|
6
|
+
return `Edit existing ignore rules manually: ${safeTerminalText(resolve(getAgentDir(), filename))}. Edits apply to every setup using this local file on its next sync; they do not rewrite remote history.`;
|
|
7
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { isKeyRelease, Key, matchesKey } from "@earendil-works/pi-tui";
|
|
3
|
+
import { piDaemonClient } from "../daemon/pi-client.js";
|
|
4
|
+
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
5
|
+
import { runCancellableTask } from "./cancellable-operation.js";
|
|
6
|
+
import { trackOperationDialogs } from "./operation-dialogs.js";
|
|
7
|
+
import { safeTerminalText } from "./terminal-text.js";
|
|
8
|
+
|
|
9
|
+
type IgnoreOperation = "switch" | "migrate";
|
|
10
|
+
|
|
11
|
+
export async function ignoreFileSettingsAvailable(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
12
|
+
if (signal?.aborted) return false;
|
|
13
|
+
try {
|
|
14
|
+
const client = piDaemonClient(ctx);
|
|
15
|
+
const result = await client.run("ignore.capabilities", {}, signal, ctx);
|
|
16
|
+
client.validate();
|
|
17
|
+
return !signal?.aborted && (result as { available?: unknown } | undefined)?.available === true;
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function showIgnoreFileAction(
|
|
24
|
+
ctx: ExtensionCommandContext,
|
|
25
|
+
setup: string,
|
|
26
|
+
action: IgnoreOperation,
|
|
27
|
+
filename: string,
|
|
28
|
+
signal: AbortSignal,
|
|
29
|
+
offerToken?: string,
|
|
30
|
+
) {
|
|
31
|
+
if (signal.aborted || !ctx.hasUI || ctx.mode !== "tui") return;
|
|
32
|
+
const validateOwner = captureMutationOwner(ctx, signal);
|
|
33
|
+
const client = piDaemonClient(ctx);
|
|
34
|
+
const isCurrent = () => {
|
|
35
|
+
try {
|
|
36
|
+
validateOwner();
|
|
37
|
+
client.validate();
|
|
38
|
+
return true;
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
let payload: Record<string, unknown> = offerToken ? { offerToken } : {};
|
|
45
|
+
if (action === "switch") {
|
|
46
|
+
const entered = await askIgnoreFilename(ctx, filename, signal);
|
|
47
|
+
if (!isCurrent() || !entered || entered === filename) return;
|
|
48
|
+
payload = { filename: entered, expectedFilename: filename };
|
|
49
|
+
}
|
|
50
|
+
if (!isCurrent()) return;
|
|
51
|
+
const result = await runCancellableTask(
|
|
52
|
+
ctx,
|
|
53
|
+
action === "migrate"
|
|
54
|
+
? "Preparing ignore-file migration review…"
|
|
55
|
+
: "Checking the selected ignore file for review…",
|
|
56
|
+
(workSignal, onCommit, onDialog) =>
|
|
57
|
+
client.run(
|
|
58
|
+
`ignore.${action}`,
|
|
59
|
+
{ setup, ...payload },
|
|
60
|
+
workSignal,
|
|
61
|
+
trackOperationDialogs(ctx, onDialog),
|
|
62
|
+
onCommit,
|
|
63
|
+
),
|
|
64
|
+
{ signal, isCurrent, cancelledMessage: null, commitAware: true, cancelAcrossDialogs: true },
|
|
65
|
+
);
|
|
66
|
+
if (isCurrent() && result.kind === "completed" && result.value === "saved") {
|
|
67
|
+
ctx.ui.notify(
|
|
68
|
+
action === "migrate"
|
|
69
|
+
? "Ignore-file policy saved locally. No transfer started."
|
|
70
|
+
: "Ignore file selected. No transfer started.",
|
|
71
|
+
"info",
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (isCurrent())
|
|
76
|
+
ctx.ui.notify(`Pi Sync: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`, "error");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function askIgnoreFilename(ctx: ExtensionCommandContext, filename: string, signal: AbortSignal) {
|
|
81
|
+
const cancel = new AbortController();
|
|
82
|
+
const stop = ctx.ui.onTerminalInput((data) => {
|
|
83
|
+
if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) {
|
|
84
|
+
cancel.abort();
|
|
85
|
+
return { consume: true };
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
const inputSignal = AbortSignal.any([signal, cancel.signal]);
|
|
89
|
+
try {
|
|
90
|
+
const entered = await ctx.ui.input(`Existing ignore filename (current: ${safeTerminalText(filename)})`, undefined, {
|
|
91
|
+
signal: inputSignal,
|
|
92
|
+
});
|
|
93
|
+
return inputSignal.aborted ? undefined : entered;
|
|
94
|
+
} finally {
|
|
95
|
+
stop();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { piDaemonClient } from "../daemon/pi-client.js";
|
|
3
|
+
import { ignoreFileSettingsAvailable, showIgnoreFileAction } from "./ignore-file-ui.js";
|
|
4
|
+
import { safeTerminalText } from "./terminal-text.js";
|
|
5
|
+
|
|
6
|
+
const reviewNow = "Review migration now";
|
|
7
|
+
const notNow = "Not now";
|
|
8
|
+
|
|
9
|
+
export async function showIgnoreMigrationPrompt(
|
|
10
|
+
ctx: ExtensionCommandContext,
|
|
11
|
+
setup: string,
|
|
12
|
+
signal: AbortSignal,
|
|
13
|
+
isCurrent: () => boolean,
|
|
14
|
+
): Promise<boolean> {
|
|
15
|
+
if (ctx.mode !== "tui" || !ctx.hasUI || signal.aborted || !isCurrent()) return false;
|
|
16
|
+
if (!(await ignoreFileSettingsAvailable(ctx, signal)) || signal.aborted || !isCurrent()) return false;
|
|
17
|
+
|
|
18
|
+
let shown = false;
|
|
19
|
+
try {
|
|
20
|
+
const client = piDaemonClient(ctx);
|
|
21
|
+
const valid = () => {
|
|
22
|
+
if (signal.aborted || !isCurrent()) return false;
|
|
23
|
+
client.validate();
|
|
24
|
+
return true;
|
|
25
|
+
};
|
|
26
|
+
const offer = await client.run("ignore.migration-offer", { setup }, signal, ctx);
|
|
27
|
+
if (!valid()) return false;
|
|
28
|
+
const token = readOfferToken(offer);
|
|
29
|
+
if (!token) return false;
|
|
30
|
+
|
|
31
|
+
shown = true;
|
|
32
|
+
const choice = await ctx.ui.select(
|
|
33
|
+
[
|
|
34
|
+
`Review migration for sync setup “${safeTerminalText(setup)}”?`,
|
|
35
|
+
"Your current rules still apply. Review the paths that would change before deciding.",
|
|
36
|
+
"Migration does not start a transfer. You can review it later in Pi Sync Settings.",
|
|
37
|
+
].join("\n\n"),
|
|
38
|
+
[reviewNow, notNow],
|
|
39
|
+
{ signal },
|
|
40
|
+
);
|
|
41
|
+
if (!valid()) return true;
|
|
42
|
+
if (choice === notNow) {
|
|
43
|
+
await client.run("ignore.migration-defer", { setup, token }, signal, ctx);
|
|
44
|
+
} else if (choice === reviewNow) {
|
|
45
|
+
await showIgnoreFileAction(ctx, setup, "migrate", ".syncignore", signal, token);
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (!signal.aborted && isCurrent()) {
|
|
49
|
+
ctx.ui.notify(
|
|
50
|
+
`Pi Sync migration prompt: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
|
|
51
|
+
"warning",
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return shown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function readOfferToken(value: unknown) {
|
|
59
|
+
if (value === null) return undefined;
|
|
60
|
+
const token = (value as { token?: unknown } | undefined)?.token;
|
|
61
|
+
if (typeof token !== "string" || !/^[0-9a-f]{64}$/u.test(token)) {
|
|
62
|
+
throw new Error("Invalid migration offer from the daemon.");
|
|
63
|
+
}
|
|
64
|
+
return token;
|
|
65
|
+
}
|
package/src/ui/manager-state.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
2
|
-
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
3
|
-
import { activeLocalConfigPath } from "../settings/config-file.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { isCloudflareR2Endpoint, ownRecord } from "../settings/settings-validation.js";
|
|
2
|
+
import { configFromSettings, loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
3
|
+
import { activeLocalConfigPath, readActiveLocalConfigDocumentForRepair } from "../settings/config-file.js";
|
|
4
|
+
import type { AnySyncConfig, PiSyncSettingsV3 } from "../settings/settings-types.js";
|
|
5
|
+
import { isCloudflareR2Endpoint, validateSettingsDocument } from "../settings/settings-validation.js";
|
|
7
6
|
import {
|
|
8
7
|
inspectOperationAvailability,
|
|
9
8
|
type OperationAvailability,
|
|
@@ -39,6 +38,7 @@ export interface ManagerDescription {
|
|
|
39
38
|
title: string;
|
|
40
39
|
actions: string[];
|
|
41
40
|
configReview?: { setupName: string; fingerprint: string };
|
|
41
|
+
settingsReview?: { setupName: string; fingerprint: string };
|
|
42
42
|
operation?: OperationAvailability;
|
|
43
43
|
attention?: SyncAttentionState;
|
|
44
44
|
observation?: StartupObservation;
|
|
@@ -51,11 +51,15 @@ export async function describeManagerState(
|
|
|
51
51
|
attention?: SyncAttentionState,
|
|
52
52
|
inspectOperation: () => Promise<OperationAvailability> = inspectOperationAvailability,
|
|
53
53
|
observation?: StartupObservation,
|
|
54
|
+
canUseIgnoreSettings?: () => Promise<boolean>,
|
|
54
55
|
): Promise<ManagerDescription> {
|
|
55
|
-
let raw:
|
|
56
|
+
let raw: PiSyncSettingsV3 | undefined;
|
|
56
57
|
try {
|
|
57
|
-
|
|
58
|
+
const document = await readActiveLocalConfigDocumentForRepair();
|
|
59
|
+
signal?.throwIfAborted();
|
|
60
|
+
if (document) raw = validateSettingsDocument(document.parsed);
|
|
58
61
|
} catch (error) {
|
|
62
|
+
if (signal?.aborted) throw error;
|
|
59
63
|
return {
|
|
60
64
|
title: [
|
|
61
65
|
"Manage sync",
|
|
@@ -75,12 +79,8 @@ export async function describeManagerState(
|
|
|
75
79
|
actions: ["Set up sync", "Help"],
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
|
-
const configuredTargets =
|
|
79
|
-
if (
|
|
80
|
-
(raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6 || raw.version === 7) &&
|
|
81
|
-
configuredTargets &&
|
|
82
|
-
Object.keys(configuredTargets).length === 0
|
|
83
|
-
) {
|
|
82
|
+
const configuredTargets = raw.syncSetups;
|
|
83
|
+
if (Object.keys(configuredTargets).length === 0) {
|
|
84
84
|
return {
|
|
85
85
|
title: [
|
|
86
86
|
"Manage sync",
|
|
@@ -93,8 +93,15 @@ export async function describeManagerState(
|
|
|
93
93
|
actions: ["Sync setups…", "Storage connections…", "Help"],
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
+
let settingsConfig: AnySyncConfig | undefined;
|
|
96
97
|
try {
|
|
98
|
+
settingsConfig = configFromSettings(raw);
|
|
99
|
+
if (settingsConfig.reservedIgnoreNames && canUseIgnoreSettings && !(await canUseIgnoreSettings())) {
|
|
100
|
+
throw new Error("the connected daemon does not support ignore-file setups");
|
|
101
|
+
}
|
|
102
|
+
signal?.throwIfAborted();
|
|
97
103
|
const config = await loadConfig();
|
|
104
|
+
signal?.throwIfAborted();
|
|
98
105
|
const operation = await inspectOperation();
|
|
99
106
|
const changesBlocked = operationBlocksChanges(operation);
|
|
100
107
|
let currentAttention: SyncAttentionState | undefined;
|
|
@@ -143,7 +150,11 @@ export async function describeManagerState(
|
|
|
143
150
|
"Manage sync",
|
|
144
151
|
`Current sync setup: ${safeTerminalText(config.setupName)}`,
|
|
145
152
|
`Storage: ${backendStorageDescription(config)}`,
|
|
146
|
-
...(config.
|
|
153
|
+
...(config.pathPolicy === "ignore-file"
|
|
154
|
+
? [`Sync scope: Pi agent directory · ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}`]
|
|
155
|
+
: config.scope
|
|
156
|
+
? ["Sync scope: Pi agent directory, with exclusions"]
|
|
157
|
+
: []),
|
|
147
158
|
...(syncState?.unresolved?.length
|
|
148
159
|
? [`Unresolved: ${syncState.unresolved.length} dependency groups · review needed`]
|
|
149
160
|
: []),
|
|
@@ -178,6 +189,7 @@ export async function describeManagerState(
|
|
|
178
189
|
title: (changesBlocked ? ["Manage sync", ...operationStatusLines(operation)] : ordinaryTitle).join("\n"),
|
|
179
190
|
actions: operationActions(operation, noSyncedContent, canSwitch, mainActions),
|
|
180
191
|
configReview: { setupName: config.setupName, fingerprint: syncCheckConfigFingerprint(config) },
|
|
192
|
+
settingsReview: { setupName: settingsConfig.setupName, fingerprint: syncCheckConfigFingerprint(settingsConfig) },
|
|
181
193
|
operation,
|
|
182
194
|
...(currentObservation ? { observation: currentObservation } : {}),
|
|
183
195
|
...(currentAttention
|
|
@@ -190,6 +202,20 @@ export async function describeManagerState(
|
|
|
190
202
|
};
|
|
191
203
|
} catch (error) {
|
|
192
204
|
if (signal?.aborted) throw error;
|
|
205
|
+
if (settingsConfig?.reservedIgnoreNames !== undefined) {
|
|
206
|
+
return {
|
|
207
|
+
title: [
|
|
208
|
+
"Manage sync",
|
|
209
|
+
`Current sync setup: ${safeTerminalText(settingsConfig.setupName)}`,
|
|
210
|
+
`Transfers are unavailable: ${safeTerminalText(errorMessage(error))}`,
|
|
211
|
+
].join("\n"),
|
|
212
|
+
actions: ["Settings", "Sync setups…", "Storage connections…", "Help"],
|
|
213
|
+
settingsReview: {
|
|
214
|
+
setupName: settingsConfig.setupName,
|
|
215
|
+
fingerprint: syncCheckConfigFingerprint(settingsConfig),
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|
|
193
219
|
return {
|
|
194
220
|
title: [
|
|
195
221
|
"Manage sync",
|
package/src/ui/manager-ui.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { Component } from "@earendil-works/pi-tui";
|
|
3
3
|
import { type ActionMenuItem, defineMenu, type MenuDefinition, runDocumentReview, runMenu } from "@narumitw/pi-tui-kit";
|
|
4
|
-
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
4
|
+
import { loadConfig, loadSettingsConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
5
5
|
import { operationBlocksChanges } from "../state/operation-availability.js";
|
|
6
6
|
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
7
7
|
import { type RunRoute, runCancellableOperation } from "./cancellable-operation.js";
|
|
8
|
+
import { ignoreFileSettingsAvailable } from "./ignore-file-ui.js";
|
|
9
|
+
import { showIgnoreMigrationPrompt } from "./ignore-migration-prompt.js";
|
|
8
10
|
import {
|
|
9
11
|
attentionMainMenuItems,
|
|
10
12
|
blockedSyncMenuItem,
|
|
@@ -180,8 +182,10 @@ export async function showSyncManager(
|
|
|
180
182
|
const result = await showSetupSwitcher(ctx, runRoute, undefined, sessionSignal);
|
|
181
183
|
return result === "pull-attempted" || result === "closed" ? { kind: "close" } : { kind: "stay" };
|
|
182
184
|
},
|
|
183
|
-
settings: async ({ state }) => {
|
|
184
|
-
const
|
|
185
|
+
settings: async ({ state, signal: actionSignal }) => {
|
|
186
|
+
const signal = sessionSignal ? AbortSignal.any([sessionSignal, actionSignal]) : actionSignal;
|
|
187
|
+
const review = state.manager.settingsReview ?? state.manager.configReview;
|
|
188
|
+
const result = await showSyncSettings(ctx, runRoute, signal, review?.setupName);
|
|
185
189
|
return { kind: result === "exit" ? "close" : "stay" };
|
|
186
190
|
},
|
|
187
191
|
pull: async ({ state }) => {
|
|
@@ -327,10 +331,11 @@ export async function showSyncManager(
|
|
|
327
331
|
const activate = menu.actions[action];
|
|
328
332
|
menu.actions[action] = async (invocation) => {
|
|
329
333
|
validateOwner();
|
|
330
|
-
const
|
|
334
|
+
const { configReview, settingsReview } = invocation.state.manager;
|
|
335
|
+
const review = action === "settings" ? (settingsReview ?? configReview) : configReview;
|
|
331
336
|
let current = false;
|
|
332
337
|
try {
|
|
333
|
-
const config = await loadConfig();
|
|
338
|
+
const config = await (action === "settings" ? loadSettingsConfig() : loadConfig());
|
|
334
339
|
validateOwner();
|
|
335
340
|
invocation.signal.throwIfAborted();
|
|
336
341
|
current = review?.fingerprint === syncCheckConfigFingerprint(config);
|
|
@@ -365,23 +370,40 @@ export async function showSyncManager(
|
|
|
365
370
|
}, customOptions),
|
|
366
371
|
},
|
|
367
372
|
};
|
|
373
|
+
let firstOpen = true;
|
|
374
|
+
const describe = async (signal: AbortSignal) => {
|
|
375
|
+
const pendingAttention = options.getAttention?.();
|
|
376
|
+
const observation = options.getObservation?.();
|
|
377
|
+
const manager = await describeManagerState(signal, pendingAttention, undefined, observation, () =>
|
|
378
|
+
ignoreFileSettingsAvailable(ctx, signal),
|
|
379
|
+
);
|
|
380
|
+
if (signal.aborted || !isCurrent()) return manager;
|
|
381
|
+
// A busy operation suppresses baseline reads, not the stored check-time hint.
|
|
382
|
+
if (
|
|
383
|
+
observation &&
|
|
384
|
+
options.getObservation?.() === observation &&
|
|
385
|
+
!manager.observation &&
|
|
386
|
+
!(manager.operation && operationBlocksChanges(manager.operation))
|
|
387
|
+
) {
|
|
388
|
+
options.onObservationInvalidated?.();
|
|
389
|
+
}
|
|
390
|
+
if (pendingAttention && options.getAttention?.() === pendingAttention && !manager.attention) {
|
|
391
|
+
options.onSelectionResolved?.(pendingAttention);
|
|
392
|
+
}
|
|
393
|
+
return manager;
|
|
394
|
+
};
|
|
368
395
|
await runMenu(menuContext, menu, {
|
|
369
|
-
getState: async () => {
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (sessionSignal?.aborted) return { manager };
|
|
374
|
-
// A busy operation suppresses baseline reads, not the stored check-time hint.
|
|
396
|
+
getState: async ({ signal }) => {
|
|
397
|
+
const offerOnOpen = firstOpen;
|
|
398
|
+
firstOpen = false;
|
|
399
|
+
let manager = await describe(signal);
|
|
375
400
|
if (
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
401
|
+
offerOnOpen &&
|
|
402
|
+
manager.operation?.kind === "free" &&
|
|
403
|
+
manager.configReview &&
|
|
404
|
+
(await showIgnoreMigrationPrompt(ctx, manager.configReview.setupName, signal, isCurrent))
|
|
380
405
|
) {
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
if (pendingAttention && options.getAttention?.() === pendingAttention && !manager.attention) {
|
|
384
|
-
options.onSelectionResolved?.(pendingAttention);
|
|
406
|
+
if (!signal.aborted && isCurrent()) manager = await describe(signal);
|
|
385
407
|
}
|
|
386
408
|
return { manager };
|
|
387
409
|
},
|
|
@@ -2,7 +2,7 @@ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
3
|
import { createSyncBackend, type SyncBackendFactory } from "../backends/backend-factory.js";
|
|
4
4
|
import type { RemoteHead, SyncBackend } from "../backends/sync-backend.js";
|
|
5
|
-
import { loadConfig,
|
|
5
|
+
import { loadConfig, syncConfigReviewFingerprint, syncSettingsConfigFingerprint } from "../settings/config.js";
|
|
6
6
|
import { SyncSetupReviewChangedError, updateSyncSetup } from "../settings/settings-management.js";
|
|
7
7
|
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
8
8
|
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
compareSyncInclude,
|
|
15
15
|
inspectRemoteSelection,
|
|
16
16
|
type RemoteSelectionDecision,
|
|
17
|
+
RemoteSelectionMismatchError,
|
|
17
18
|
type RemoteSelectionState,
|
|
18
19
|
sameSyncInclude,
|
|
19
20
|
syncDirectoryPolicyKey,
|
|
@@ -33,6 +34,7 @@ export interface RemoteSelectionReviewOptions {
|
|
|
33
34
|
decision?: RemoteSelectionDecision;
|
|
34
35
|
origin?: RemoteSelectionOrigin;
|
|
35
36
|
runRoute?: RunRoute;
|
|
37
|
+
readOnly?: boolean;
|
|
36
38
|
cancelLabel?: string;
|
|
37
39
|
/** The explicit mismatch is resolved or superseded; this does not imply file equality. */
|
|
38
40
|
onSelectionResolved?: () => void;
|
|
@@ -72,26 +74,33 @@ export async function showRemoteSelectionReview(
|
|
|
72
74
|
if (!inspected) return { kind: "stale" };
|
|
73
75
|
// A successful fresh read can supersede an old explicit mismatch without
|
|
74
76
|
// changing local settings. This is not user cancellation or proof of file equality.
|
|
75
|
-
if (inspected.kind === "empty" || inspected.state.kind !== "different") {
|
|
77
|
+
if (inspected.kind === "empty" || (inspected.kind === "selection" && inspected.state.kind !== "different")) {
|
|
76
78
|
options.onSelectionResolved?.();
|
|
77
79
|
}
|
|
78
80
|
if (inspected.kind === "empty") {
|
|
79
81
|
ctx.ui.notify("Remote storage has no snapshot or synced-content list yet.", "info");
|
|
80
82
|
return { kind: "back" };
|
|
81
83
|
}
|
|
82
|
-
if (inspected.
|
|
83
|
-
|
|
84
|
+
if (inspected.kind === "decision") {
|
|
85
|
+
decision = inspected.decision;
|
|
86
|
+
} else if (inspected.state.kind === "same") {
|
|
87
|
+
ctx.ui.notify(
|
|
88
|
+
inspected.state.ignorePolicyComparison === "match"
|
|
89
|
+
? "Remote ignore-file policy matches this device."
|
|
90
|
+
: "Remote synced content already matches this sync setup.",
|
|
91
|
+
"info",
|
|
92
|
+
);
|
|
84
93
|
return { kind: "back" };
|
|
85
|
-
}
|
|
86
|
-
if (inspected.state.kind === "legacy") {
|
|
94
|
+
} else if (inspected.state.kind === "legacy") {
|
|
87
95
|
if (ctx.mode !== "tui") {
|
|
88
96
|
ctx.ui.notify(formatLegacySummary(inspected.config, inspected.state.discovered), "info");
|
|
89
97
|
return { kind: "back" };
|
|
90
98
|
}
|
|
91
99
|
await showLegacyDiscovery(ctx, inspected.config, inspected.state.discovered, signal);
|
|
92
100
|
return signal?.aborted ? { kind: "stale" } : { kind: "back" };
|
|
101
|
+
} else {
|
|
102
|
+
decision = decisionFromState(inspected.config, inspected.state);
|
|
93
103
|
}
|
|
94
|
-
decision = decisionFromState(inspected.config, inspected.state);
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
if (ctx.mode !== "tui") {
|
|
@@ -132,6 +141,10 @@ export async function showRemoteSelectionReview(
|
|
|
132
141
|
ctx.ui.notify("Remote storage no longer has a snapshot or synced-content list.", "warning");
|
|
133
142
|
return { kind: "back" };
|
|
134
143
|
}
|
|
144
|
+
if (refreshed.kind === "decision") {
|
|
145
|
+
currentDecision = refreshed.decision;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
135
148
|
if (refreshed.state.kind !== "different") {
|
|
136
149
|
ctx.ui.notify(
|
|
137
150
|
refreshed.state.kind === "same"
|
|
@@ -162,7 +175,7 @@ async function showSelectionDifference(
|
|
|
162
175
|
runRoute: RunRoute | undefined,
|
|
163
176
|
sessionSignal: AbortSignal | undefined,
|
|
164
177
|
factory: SyncBackendFactory,
|
|
165
|
-
options: Pick<RemoteSelectionReviewOptions, "cancelLabel" | "onSelectionResolved" | "withStateAccess">,
|
|
178
|
+
options: Pick<RemoteSelectionReviewOptions, "readOnly" | "cancelLabel" | "onSelectionResolved" | "withStateAccess">,
|
|
166
179
|
validateOwner: () => void,
|
|
167
180
|
): Promise<DifferenceFlowResult> {
|
|
168
181
|
type Screen = "choice" | "review" | "saved";
|
|
@@ -187,11 +200,15 @@ async function showSelectionDifference(
|
|
|
187
200
|
items: [
|
|
188
201
|
{
|
|
189
202
|
id: "review",
|
|
190
|
-
label:
|
|
191
|
-
|
|
203
|
+
label: state.decision.ignorePolicyComparison
|
|
204
|
+
? "Review policy difference"
|
|
205
|
+
: "Review all paths (recommended)",
|
|
206
|
+
description: state.decision.ignorePolicyComparison
|
|
207
|
+
? "Compare published policy information without adopting rules."
|
|
208
|
+
: "Compare exact remote-only, device-only, and ordered lists.",
|
|
192
209
|
to: "review",
|
|
193
210
|
},
|
|
194
|
-
...(adoptionUnavailable(state.decision)
|
|
211
|
+
...(options.readOnly || adoptionUnavailable(state.decision)
|
|
195
212
|
? []
|
|
196
213
|
: [
|
|
197
214
|
{
|
|
@@ -201,12 +218,14 @@ async function showSelectionDifference(
|
|
|
201
218
|
action: "adopt" as const,
|
|
202
219
|
},
|
|
203
220
|
]),
|
|
204
|
-
...(
|
|
221
|
+
...(options.readOnly || !canPublishLocalPolicy(state.decision)
|
|
205
222
|
? []
|
|
206
223
|
: [
|
|
207
224
|
{
|
|
208
225
|
id: "keep",
|
|
209
|
-
label:
|
|
226
|
+
label: state.decision.ignorePolicyComparison
|
|
227
|
+
? "Review publishing this device's policy…"
|
|
228
|
+
: "Keep this device's content list and update remote…",
|
|
210
229
|
description: "Open the existing exact force-push preview without skipping confirmation.",
|
|
211
230
|
action: "keep" as const,
|
|
212
231
|
},
|
|
@@ -249,6 +268,7 @@ async function showSelectionDifference(
|
|
|
249
268
|
},
|
|
250
269
|
actions: {
|
|
251
270
|
adopt: async ({ state, signal: actionSignal }) => {
|
|
271
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
252
272
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
253
273
|
try {
|
|
254
274
|
const adoption = await runCancellableTask(
|
|
@@ -317,7 +337,7 @@ async function showSelectionDifference(
|
|
|
317
337
|
if (adoption.kind === "cancelled" || !adoption.value) return { kind: "stay" as const };
|
|
318
338
|
validateOwner();
|
|
319
339
|
options.onSelectionResolved?.();
|
|
320
|
-
continuationFingerprint =
|
|
340
|
+
continuationFingerprint = syncSettingsConfigFingerprint({
|
|
321
341
|
...adoption.value.config,
|
|
322
342
|
include: [...state.decision.remoteInclude],
|
|
323
343
|
exclude: adoptedExclude(state.decision),
|
|
@@ -339,16 +359,20 @@ async function showSelectionDifference(
|
|
|
339
359
|
}
|
|
340
360
|
},
|
|
341
361
|
keep: async ({ state, signal: actionSignal }) => {
|
|
362
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
363
|
+
if (!canPublishLocalPolicy(state.decision)) return { kind: "stay" as const };
|
|
342
364
|
if (!runRoute) {
|
|
343
365
|
ctx.ui.notify("The reviewed update-remote route is unavailable.", "error");
|
|
344
366
|
return { kind: "stay" as const };
|
|
345
367
|
}
|
|
346
368
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
347
369
|
try {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
370
|
+
if (!state.decision.ignorePolicyComparison) {
|
|
371
|
+
const latest = await loadConfig(state.decision.setupName);
|
|
372
|
+
if (signal.aborted) return { kind: "close" as const };
|
|
373
|
+
validateOwner();
|
|
374
|
+
assertLocalSelectionCurrent(latest, state.decision);
|
|
375
|
+
}
|
|
352
376
|
const result = await runCancellableOperation(
|
|
353
377
|
ctx,
|
|
354
378
|
"Preparing this device's push preview…",
|
|
@@ -374,13 +398,14 @@ async function showSelectionDifference(
|
|
|
374
398
|
}
|
|
375
399
|
},
|
|
376
400
|
continue: async ({ state, signal: actionSignal }) => {
|
|
401
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
377
402
|
if (!runRoute || !continuationFingerprint) return { kind: "stay" as const };
|
|
378
403
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
379
404
|
try {
|
|
380
405
|
const latest = await loadConfig(state.decision.setupName);
|
|
381
406
|
if (signal.aborted) return { kind: "close" as const };
|
|
382
407
|
validateOwner();
|
|
383
|
-
if (
|
|
408
|
+
if (syncSettingsConfigFingerprint(latest) !== continuationFingerprint) {
|
|
384
409
|
throw new StaleRemoteSelectionReviewError(
|
|
385
410
|
`Sync setup “${safeTerminalText(state.decision.setupName)}” changed after the remote content list was saved.`,
|
|
386
411
|
);
|
|
@@ -519,6 +544,7 @@ async function revalidateAndAdopt(
|
|
|
519
544
|
const refusal = adoptionUnavailable(decision);
|
|
520
545
|
if (refusal) throw new Error(refusal);
|
|
521
546
|
const exclude = adoptedExclude(decision);
|
|
547
|
+
if (setup.sync.pathPolicy === "ignore-file") throw new Error("An ignore-file setup cannot adopt remote rules.");
|
|
522
548
|
if (setup.sync.scope === "agent-directory") {
|
|
523
549
|
return {
|
|
524
550
|
...setup,
|
|
@@ -536,7 +562,7 @@ async function revalidateAndAdopt(
|
|
|
536
562
|
};
|
|
537
563
|
},
|
|
538
564
|
{
|
|
539
|
-
expectedConfigFingerprint:
|
|
565
|
+
expectedConfigFingerprint: syncSettingsConfigFingerprint(review.config),
|
|
540
566
|
expectedInclude: decision.localInclude,
|
|
541
567
|
upgradeExclude: adoptedExclude(decision) !== undefined,
|
|
542
568
|
signal,
|
|
@@ -553,6 +579,7 @@ async function inspectConfiguredRemoteSelection(
|
|
|
553
579
|
): Promise<
|
|
554
580
|
| { kind: "empty"; config: AnySyncConfig }
|
|
555
581
|
| { kind: "selection"; config: AnySyncConfig; state: RemoteSelectionState }
|
|
582
|
+
| { kind: "decision"; decision: RemoteSelectionDecision }
|
|
556
583
|
| undefined
|
|
557
584
|
> {
|
|
558
585
|
const config = await loadConfig(setupName);
|
|
@@ -566,14 +593,21 @@ async function inspectConfiguredRemoteSelection(
|
|
|
566
593
|
if (signal?.aborted) return undefined;
|
|
567
594
|
validateOwner();
|
|
568
595
|
if (!head) return { kind: "empty", config };
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
596
|
+
try {
|
|
597
|
+
const snapshot = await readSnapshotForHead(backend, head, signal, config);
|
|
598
|
+
if (signal?.aborted) return undefined;
|
|
599
|
+
validateOwner();
|
|
600
|
+
return {
|
|
601
|
+
kind: "selection",
|
|
602
|
+
config,
|
|
603
|
+
state: inspectRemoteSelection(config.include, snapshot, config.exclude, config),
|
|
604
|
+
};
|
|
605
|
+
} catch (error) {
|
|
606
|
+
if (signal?.aborted) return undefined;
|
|
607
|
+
validateOwner();
|
|
608
|
+
if (error instanceof RemoteSelectionMismatchError) return { kind: "decision", decision: error.decision };
|
|
609
|
+
throw error;
|
|
610
|
+
}
|
|
577
611
|
}
|
|
578
612
|
|
|
579
613
|
async function showLegacyDiscovery(
|
|
@@ -636,7 +670,18 @@ function scopesDiffer(decision: RemoteSelectionDecision) {
|
|
|
636
670
|
return decision.localDirectory?.scope !== decision.remoteDirectory?.scope;
|
|
637
671
|
}
|
|
638
672
|
|
|
673
|
+
function canPublishLocalPolicy(decision: RemoteSelectionDecision) {
|
|
674
|
+
if (decision.ignorePolicyComparison) {
|
|
675
|
+
return (
|
|
676
|
+
decision.ignorePolicyComparison !== "match" && decision.ignorePolicyComparison !== "local-legacy-remote-ignore"
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
return !scopesDiffer(decision);
|
|
680
|
+
}
|
|
681
|
+
|
|
639
682
|
function adoptionUnavailable(decision: RemoteSelectionDecision) {
|
|
683
|
+
if (decision.ignorePolicyComparison)
|
|
684
|
+
return "Ignore files are local. Published metadata cannot reconstruct remote rules.";
|
|
640
685
|
if (scopesDiffer(decision))
|
|
641
686
|
return "Scope differs. Configure a setup with the remote scope to join it; this location is not migrated in place.";
|
|
642
687
|
if (
|
|
@@ -674,6 +719,18 @@ function directoryReviewLines(decision: RemoteSelectionDecision) {
|
|
|
674
719
|
}
|
|
675
720
|
|
|
676
721
|
function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
722
|
+
if (decision.ignorePolicyComparison) {
|
|
723
|
+
return [
|
|
724
|
+
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
725
|
+
adoptionUnavailable(decision) ?? "Nothing changed.",
|
|
726
|
+
...(decision.ignorePolicyComparison === "local-legacy-remote-ignore"
|
|
727
|
+
? ["The remote uses an ignore-file policy; this device uses a legacy policy."]
|
|
728
|
+
: decision.ignorePolicyComparison === "local-ignore-remote-legacy"
|
|
729
|
+
? ["This device uses an ignore-file policy; the remote uses a legacy policy."]
|
|
730
|
+
: ["The ordered rules or session opt-in differ."]),
|
|
731
|
+
"No files or settings have changed.",
|
|
732
|
+
];
|
|
733
|
+
}
|
|
677
734
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
678
735
|
return [
|
|
679
736
|
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
@@ -691,6 +748,7 @@ function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
|
691
748
|
}
|
|
692
749
|
|
|
693
750
|
function formatSelectionDifference(decision: RemoteSelectionDecision) {
|
|
751
|
+
if (decision.ignorePolicyComparison) return selectionSummaryLines(decision).join("\n");
|
|
694
752
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
695
753
|
return [
|
|
696
754
|
...directoryReviewLines(decision),
|
|
@@ -727,6 +785,7 @@ function formatSelectionDifference(decision: RemoteSelectionDecision) {
|
|
|
727
785
|
}
|
|
728
786
|
|
|
729
787
|
function formatRemoteSelectionSummary(decision: RemoteSelectionDecision) {
|
|
788
|
+
if (decision.ignorePolicyComparison) return selectionSummaryLines(decision).join("\n");
|
|
730
789
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
731
790
|
return [
|
|
732
791
|
`Synced content for “${safeTerminalText(decision.setupName)}” differs from this device.`,
|
|
@@ -769,6 +828,7 @@ function decisionFromState(
|
|
|
769
828
|
return {
|
|
770
829
|
setupName: config.setupName,
|
|
771
830
|
configIdentity: syncConfigReviewFingerprint(config),
|
|
831
|
+
ignorePolicyComparison: state.ignorePolicyComparison,
|
|
772
832
|
localInclude: [...config.include],
|
|
773
833
|
remoteInclude: [...state.include],
|
|
774
834
|
...(config.exclude === undefined ? {} : { localExclude: [...config.exclude] }),
|