@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
|
@@ -4,6 +4,7 @@ import { loadPartialConfig } from "../../settings/config.js";
|
|
|
4
4
|
import { removeSyncSetup } from "../../settings/settings-management.js";
|
|
5
5
|
import { readLocalConfigObject } from "../../settings/settings-store.js";
|
|
6
6
|
import { ownRecord } from "../../settings/settings-validation.js";
|
|
7
|
+
import { captureMutationOwner } from "../../sync/sync-local.js";
|
|
7
8
|
import type { RunRoute } from "../cancellable-operation.js";
|
|
8
9
|
import { showAddStorageConnection } from "../storage-connections-ui.js";
|
|
9
10
|
import { showSyncSetups } from "../sync-setups-ui.js";
|
|
@@ -99,15 +100,26 @@ export async function showEditSyncSetupStorage(ctx: ExtensionCommandContext, nam
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
async function showRemoveTarget(ctx: ExtensionCommandContext, name: string, signal?: AbortSignal) {
|
|
103
|
+
const validate = captureMutationOwner(ctx, signal);
|
|
102
104
|
const confirmed = await ctx.ui.confirm(
|
|
103
105
|
"Remove sync setup?",
|
|
104
106
|
`Remove local sync setup “${safeTerminalText(name)}”? Remote data and history are not deleted.`,
|
|
105
107
|
{ signal },
|
|
106
108
|
);
|
|
107
109
|
if (signal?.aborted || !confirmed) return;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
validate();
|
|
111
|
+
const { revertedToLegacyOnly } = await removeSyncSetup(name, signal);
|
|
112
|
+
try {
|
|
113
|
+
validate();
|
|
114
|
+
} catch {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const message = `Removed sync setup “${safeTerminalText(name)}”; remote data was not deleted.`;
|
|
118
|
+
ctx.ui.notify(
|
|
119
|
+
revertedToLegacyOnly
|
|
120
|
+
? `${message} To resume Continuous sync if enabled, close /sync and run /reload in an attached TUI session, or reopen one Pi client.`
|
|
121
|
+
: message,
|
|
122
|
+
"info",
|
|
123
|
+
);
|
|
110
124
|
await refreshTargetCompletions();
|
|
111
|
-
if (signal?.aborted) return;
|
|
112
|
-
ctx.ui.notify(`Removed sync setup “${safeTerminalText(name)}”; remote data was not deleted.`, "info");
|
|
113
125
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { type ExtensionCommandContext, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import { readLocalConfigObject } from "../../settings/settings-store.js";
|
|
3
4
|
import type { SyncPolicySettings } from "../../settings/settings-types.js";
|
|
4
5
|
import { validateConfigName } from "../../settings/settings-validation.js";
|
|
6
|
+
import { captureMutationOwner } from "../../sync/sync-local.js";
|
|
5
7
|
import { DEFAULT_SYNC_INCLUDE } from "../../sync/sync-policy.js";
|
|
8
|
+
import { ignoreFileSettingsAvailable } from "../ignore-file-ui.js";
|
|
6
9
|
import { AUTOMATIC_SYNC_DESCRIPTION } from "../sync-behavior.js";
|
|
7
10
|
import { safeTerminalText } from "../terminal-text.js";
|
|
8
11
|
import {
|
|
@@ -26,11 +29,25 @@ export async function chooseSetupPolicy(
|
|
|
26
29
|
ctx: ExtensionCommandContext,
|
|
27
30
|
signal?: AbortSignal,
|
|
28
31
|
{ legacySessions = false } = {},
|
|
29
|
-
): Promise<{ sync: SyncPolicySettings; lines: string[]; join: boolean } | undefined> {
|
|
32
|
+
): Promise<{ sync: SyncPolicySettings; lines: string[]; join: boolean | "read-only" } | undefined> {
|
|
33
|
+
const validate = captureMutationOwner(ctx, signal);
|
|
34
|
+
const ignoreAvailable = ctx.mode === "tui" && (await ignoreFileSettingsAvailable(ctx, signal));
|
|
35
|
+
if (signal?.aborted) return;
|
|
36
|
+
validate();
|
|
37
|
+
const ignoreChoice = "Use .syncignore (recommended)";
|
|
38
|
+
const directoryChoice = ignoreAvailable ? "Agent directory · legacy rules" : "Agent directory (recommended)";
|
|
30
39
|
const choice = await ctx.ui.select(
|
|
31
|
-
"Choose synced content\n\nAgent directory (recommended): sync all eligible files, including custom paths, except sessions, bin, and npm.\nJoining existing storage? Review its policy after saving. It will not be adopted automatically.\nLegacy mode: use a fixed list of included paths.",
|
|
32
40
|
[
|
|
33
|
-
"
|
|
41
|
+
"Choose synced content",
|
|
42
|
+
ignoreAvailable
|
|
43
|
+
? "Use .syncignore to control eligible files in the Pi agent directory. Its rules stay on this device."
|
|
44
|
+
: "Agent directory (recommended): sync all eligible files, including custom paths, except sessions, bin, and npm.",
|
|
45
|
+
"Joining existing storage? Review its policy after saving. It will not be adopted automatically.",
|
|
46
|
+
"Legacy selected paths use a fixed list of included paths.",
|
|
47
|
+
].join("\n\n"),
|
|
48
|
+
[
|
|
49
|
+
...(ignoreAvailable ? [ignoreChoice] : []),
|
|
50
|
+
directoryChoice,
|
|
34
51
|
"Agent directory · edit starter rules",
|
|
35
52
|
"Join an existing remote",
|
|
36
53
|
"Recommended Pi settings",
|
|
@@ -40,10 +57,12 @@ export async function chooseSetupPolicy(
|
|
|
40
57
|
{ signal },
|
|
41
58
|
);
|
|
42
59
|
if (signal?.aborted || !choice || choice === "Cancel") return undefined;
|
|
60
|
+
validate();
|
|
43
61
|
const join = choice === "Join an existing remote";
|
|
44
62
|
if (
|
|
45
63
|
!join &&
|
|
46
|
-
|
|
64
|
+
!(ignoreAvailable && choice === ignoreChoice) &&
|
|
65
|
+
choice !== directoryChoice &&
|
|
47
66
|
choice !== "Agent directory · edit starter rules" &&
|
|
48
67
|
choice !== "Recommended Pi settings" &&
|
|
49
68
|
choice !== "Minimal settings"
|
|
@@ -52,12 +71,32 @@ export async function chooseSetupPolicy(
|
|
|
52
71
|
const joinScope = join
|
|
53
72
|
? await ctx.ui.select(
|
|
54
73
|
"Choose the existing remote's scope\n\nUse Selected paths for an older setup with an include list. These choices do not change the remote's scope.",
|
|
55
|
-
["Pi agent directory", "Selected paths (legacy)", "Cancel"],
|
|
74
|
+
[...(ignoreAvailable ? [ignoreChoice] : []), "Pi agent directory", "Selected paths (legacy)", "Cancel"],
|
|
56
75
|
{ signal },
|
|
57
76
|
)
|
|
58
77
|
: undefined;
|
|
59
|
-
|
|
78
|
+
const usesIgnore = ignoreAvailable && (choice === ignoreChoice || joinScope === ignoreChoice);
|
|
79
|
+
if (
|
|
80
|
+
signal?.aborted ||
|
|
81
|
+
(join && !usesIgnore && joinScope !== "Pi agent directory" && joinScope !== "Selected paths (legacy)")
|
|
82
|
+
)
|
|
60
83
|
return undefined;
|
|
84
|
+
validate();
|
|
85
|
+
if (usesIgnore) {
|
|
86
|
+
const sessions = join ? false : await chooseSessions(ctx, signal);
|
|
87
|
+
if (signal?.aborted || sessions === undefined) return;
|
|
88
|
+
validate();
|
|
89
|
+
return {
|
|
90
|
+
sync: { scope: "agent-directory", pathPolicy: "ignore-file", sessions, automatic: false },
|
|
91
|
+
lines: [
|
|
92
|
+
`Local ignore file: ${safeTerminalText(resolve(getAgentDir(), ".syncignore"))}`,
|
|
93
|
+
"An existing valid file is reused as-is. If the daemon cannot create it safely, create it manually with the starter line /sessions/, then retry setup. Do not overwrite an existing file.",
|
|
94
|
+
`Sessions: ${sessions ? "opted in — ignore rules still apply" : "Off"}`,
|
|
95
|
+
"Rules are local only. Compare policy before transferring to existing storage. Peers must support ignore-file snapshots before the first push.",
|
|
96
|
+
],
|
|
97
|
+
join: join ? "read-only" : false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
61
100
|
const legacy =
|
|
62
101
|
choice === "Recommended Pi settings" || choice === "Minimal settings" || joinScope === "Selected paths (legacy)";
|
|
63
102
|
const draft = starterDirectoryRules();
|
|
@@ -65,15 +104,19 @@ export async function chooseSetupPolicy(
|
|
|
65
104
|
if (editRules) {
|
|
66
105
|
const exclude = await promptDirectoryRules(ctx, "exclude", draft.exclude, signal);
|
|
67
106
|
if (signal?.aborted || !exclude) return undefined;
|
|
107
|
+
validate();
|
|
68
108
|
draft.exclude = exclude;
|
|
69
109
|
const reinclude = await promptDirectoryRules(ctx, "reinclude", draft.reinclude, signal);
|
|
70
110
|
if (signal?.aborted || !reinclude) return undefined;
|
|
111
|
+
validate();
|
|
71
112
|
draft.reinclude = reinclude;
|
|
72
113
|
}
|
|
73
114
|
const automatic = join ? false : await chooseAutomaticSync(ctx, signal);
|
|
74
115
|
if (signal?.aborted || automatic === undefined) return undefined;
|
|
116
|
+
validate();
|
|
75
117
|
const sessions = join || (legacy && !legacySessions) ? false : await chooseSessions(ctx, signal);
|
|
76
118
|
if (signal?.aborted || sessions === undefined) return undefined;
|
|
119
|
+
validate();
|
|
77
120
|
const remoteWarning = join
|
|
78
121
|
? "After saving, compare the remote policy. Automatic sync and sessions start Off. No policy is adopted without your review."
|
|
79
122
|
: "If this location already has sync data, compare its policy in Settings before transferring. A mismatch blocks sync.";
|
|
@@ -104,7 +147,7 @@ export async function finishSetup(
|
|
|
104
147
|
ctx: ExtensionCommandContext,
|
|
105
148
|
name: string,
|
|
106
149
|
message: string,
|
|
107
|
-
join: boolean,
|
|
150
|
+
join: boolean | "read-only",
|
|
108
151
|
signal?: AbortSignal,
|
|
109
152
|
) {
|
|
110
153
|
if (signal?.aborted) return;
|
|
@@ -112,7 +155,10 @@ export async function finishSetup(
|
|
|
112
155
|
if (!join) return;
|
|
113
156
|
const { showRemoteSelectionReview } = await import("../remote-selection-ui.js");
|
|
114
157
|
if (signal?.aborted) return;
|
|
115
|
-
await showRemoteSelectionReview(ctx, name, signal, undefined, {
|
|
158
|
+
await showRemoteSelectionReview(ctx, name, signal, undefined, {
|
|
159
|
+
origin: "settings",
|
|
160
|
+
...(join === "read-only" ? { readOnly: true } : {}),
|
|
161
|
+
});
|
|
116
162
|
}
|
|
117
163
|
|
|
118
164
|
export async function chooseAutomaticSync(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
loadConfigForCheck,
|
|
5
|
+
loadSettingsConfig,
|
|
6
|
+
syncCheckConfigFingerprint,
|
|
7
|
+
syncConfigReviewIdentity,
|
|
8
|
+
} from "../../settings/config.js";
|
|
4
9
|
import { loadOnSwitch, readLocalConfigObject } from "../../settings/settings-store.js";
|
|
5
10
|
import type { AnySyncConfig } from "../../settings/settings-types.js";
|
|
6
11
|
import { ownRecord } from "../../settings/settings-validation.js";
|
|
@@ -103,8 +108,11 @@ export async function showSetupSwitcher(
|
|
|
103
108
|
return false;
|
|
104
109
|
}
|
|
105
110
|
let config: AnySyncConfig;
|
|
111
|
+
let metadata: AnySyncConfig;
|
|
106
112
|
try {
|
|
107
|
-
|
|
113
|
+
metadata = await loadSettingsConfig(name);
|
|
114
|
+
if (signal?.aborted) return false;
|
|
115
|
+
config = await loadConfigForCheck(name, signal);
|
|
108
116
|
if (signal?.aborted) return false;
|
|
109
117
|
} catch (error) {
|
|
110
118
|
ctx.ui.notify(
|
|
@@ -116,20 +124,24 @@ export async function showSetupSwitcher(
|
|
|
116
124
|
const onSwitch = await loadOnSwitch();
|
|
117
125
|
if (signal?.aborted) return false;
|
|
118
126
|
const switchEffect =
|
|
119
|
-
|
|
120
|
-
? "
|
|
121
|
-
: onSwitch === "
|
|
122
|
-
? "After switching, pi-sync will
|
|
123
|
-
:
|
|
127
|
+
config.reservedIgnoreNames !== undefined
|
|
128
|
+
? "This switch only saves the active setup. To transfer, use a reviewed /sync command."
|
|
129
|
+
: onSwitch === "ask-before-pull"
|
|
130
|
+
? "After switching, pi-sync will ask whether to review a pull for this setup."
|
|
131
|
+
: onSwitch === "pull-after-switch"
|
|
132
|
+
? "After switching, pi-sync will check this setup and show exact changes before applying them."
|
|
133
|
+
: "After switching, pi-sync will not pull or modify synced files.";
|
|
124
134
|
const confirmed = await ctx.ui.confirm(
|
|
125
135
|
"Switch sync setup?",
|
|
126
136
|
[
|
|
127
137
|
`From: ${safeTerminalText(active ?? "none")}`,
|
|
128
138
|
`To: ${safeTerminalText(name)}`,
|
|
129
139
|
`Storage: ${backendStorageDescription(config)}`,
|
|
130
|
-
config.
|
|
131
|
-
? `Scope: Pi agent directory ·
|
|
132
|
-
:
|
|
140
|
+
config.pathPolicy === "ignore-file"
|
|
141
|
+
? `Scope: Pi agent directory · ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}`
|
|
142
|
+
: config.scope === "agent-directory"
|
|
143
|
+
? `Scope: Pi agent directory · ${config.exclude?.length ?? 0} excluded and ${config.reinclude?.length ?? 0} re-included rules`
|
|
144
|
+
: `Included content: ${config.include.length} paths`,
|
|
133
145
|
`Automatic sync: ${automaticSyncSummary(config.automatic)} · Sessions: ${syncSessionsSelected(config) ? "On" : "Off"}`,
|
|
134
146
|
`Automatic transfer at startup: ${config.automaticTransfer ? "On — may upload, replace, or delete selected files; no reload" : "Off"}`,
|
|
135
147
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
@@ -168,7 +180,8 @@ export async function showSetupSwitcher(
|
|
|
168
180
|
},
|
|
169
181
|
onSwitch,
|
|
170
182
|
signal,
|
|
171
|
-
syncConfigReviewIdentity(
|
|
183
|
+
syncConfigReviewIdentity(metadata),
|
|
184
|
+
syncCheckConfigFingerprint(config),
|
|
172
185
|
);
|
|
173
186
|
if (pullClosed) return "closed";
|
|
174
187
|
return result.pullApplied ? "pull-attempted" : "switched";
|
|
@@ -6,9 +6,11 @@ import {
|
|
|
6
6
|
removeStorageConnection,
|
|
7
7
|
updateStorageConnection,
|
|
8
8
|
} from "../settings/settings-management.js";
|
|
9
|
-
import { readLocalConfigObject } from "../settings/settings-store.js";
|
|
10
9
|
import { isCloudflareR2Endpoint, normalizeS3Endpoint, ownRecord } from "../settings/settings-validation.js";
|
|
11
10
|
import { syncErrorGuidance } from "../sync/sync-error-guidance.js";
|
|
11
|
+
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
12
|
+
import { ignoreFileSettingsAvailable } from "./ignore-file-ui.js";
|
|
13
|
+
import { ignoreSetupRecovery, loadSettingsCatalog } from "./settings-review.js";
|
|
12
14
|
import { showAddGitStorageProfile, showEditGitStorageProfile } from "./setup/git-ui.js";
|
|
13
15
|
import { applyS3CredentialUpdate, chooseS3Credentials, chooseS3CredentialUpdate } from "./setup/s3-credentials-ui.js";
|
|
14
16
|
import { promptResourceName } from "./setup/setup-prompts.js";
|
|
@@ -18,6 +20,15 @@ import { showAddWebDavStorageProfile, showEditWebDavStorageProfile } from "./set
|
|
|
18
20
|
import { safeTerminalText } from "./terminal-text.js";
|
|
19
21
|
|
|
20
22
|
export async function showStorageConnections(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
23
|
+
const validateOwner = captureMutationOwner(ctx, signal);
|
|
24
|
+
const isCurrent = () => {
|
|
25
|
+
try {
|
|
26
|
+
validateOwner();
|
|
27
|
+
return true;
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
21
32
|
let selectedName: string | undefined;
|
|
22
33
|
const nameById = new Map<string, string>();
|
|
23
34
|
type Screen = "list" | "detail";
|
|
@@ -32,11 +43,11 @@ export async function showStorageConnections(ctx: ExtensionCommandContext, signa
|
|
|
32
43
|
kind: "actions",
|
|
33
44
|
title: "Storage connections",
|
|
34
45
|
lines: state.supportedVersion
|
|
35
|
-
? ["Server addresses and sign-in details, reusable across sync setups."]
|
|
46
|
+
? (state.recovery ?? ["Server addresses and sign-in details, reusable across sync setups."])
|
|
36
47
|
: ["Create supported pi-sync settings before managing storage connections."],
|
|
37
48
|
items: state.supportedVersion
|
|
38
49
|
? [
|
|
39
|
-
{ id: "add", label: "Add storage connection", action: "add" as const },
|
|
50
|
+
...(state.recovery ? [] : [{ id: "add", label: "Add storage connection", action: "add" as const }]),
|
|
40
51
|
...names.map((name, index) => {
|
|
41
52
|
const id = `connection:${index}`;
|
|
42
53
|
nameById.set(id, name);
|
|
@@ -58,8 +69,8 @@ export async function showStorageConnections(ctx: ExtensionCommandContext, signa
|
|
|
58
69
|
lines: state.selected?.lines ?? ["This storage connection no longer exists."],
|
|
59
70
|
items: state.selected
|
|
60
71
|
? [
|
|
61
|
-
{ id: "edit", label: "Edit storage connection…", action: "edit" },
|
|
62
|
-
...(state.selected.usedBy.length === 0
|
|
72
|
+
...(state.recovery ? [] : [{ id: "edit", label: "Edit storage connection…", action: "edit" as const }]),
|
|
73
|
+
...(!state.recovery && state.selected.usedBy.length === 0
|
|
63
74
|
? [
|
|
64
75
|
{
|
|
65
76
|
id: "remove",
|
|
@@ -75,7 +86,8 @@ export async function showStorageConnections(ctx: ExtensionCommandContext, signa
|
|
|
75
86
|
}),
|
|
76
87
|
},
|
|
77
88
|
actions: {
|
|
78
|
-
add: async () => {
|
|
89
|
+
add: async ({ state }) => {
|
|
90
|
+
if (state.recovery) return { kind: "rejected" };
|
|
79
91
|
try {
|
|
80
92
|
await showAddStorageConnection(ctx, signal);
|
|
81
93
|
} catch (error) {
|
|
@@ -90,7 +102,7 @@ export async function showStorageConnections(ctx: ExtensionCommandContext, signa
|
|
|
90
102
|
return selectedName ? { kind: "to", screen: "detail" } : { kind: "rejected" };
|
|
91
103
|
},
|
|
92
104
|
edit: async ({ state }) => {
|
|
93
|
-
if (!state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
105
|
+
if (state.recovery || !state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
94
106
|
try {
|
|
95
107
|
await editStorageConnection(ctx, state.selected.name, state.selected.profile, state.selected.usedBy, signal);
|
|
96
108
|
} catch (error) {
|
|
@@ -98,22 +110,24 @@ export async function showStorageConnections(ctx: ExtensionCommandContext, signa
|
|
|
98
110
|
}
|
|
99
111
|
return { kind: "stay" };
|
|
100
112
|
},
|
|
101
|
-
remove: async ({ state }) => {
|
|
102
|
-
if (!state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
113
|
+
remove: async ({ state, signal: actionSignal }) => {
|
|
114
|
+
if (state.recovery || !state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
103
115
|
const name = state.selected.name;
|
|
104
116
|
const confirmed = await ctx.ui.confirm(
|
|
105
117
|
"Remove storage connection?",
|
|
106
118
|
`Remove local storage connection “${safeTerminalText(name)}”? Remote data and history are not deleted.`,
|
|
107
|
-
{ signal },
|
|
119
|
+
{ signal: actionSignal },
|
|
108
120
|
);
|
|
109
|
-
if (!confirmed ||
|
|
121
|
+
if (!confirmed || actionSignal.aborted || !isCurrent()) return { kind: "rejected" };
|
|
110
122
|
try {
|
|
111
|
-
await removeStorageConnection(name,
|
|
123
|
+
await removeStorageConnection(name, actionSignal);
|
|
124
|
+
if (actionSignal.aborted || !isCurrent()) return { kind: "close" };
|
|
112
125
|
ctx.ui.notify(`Removed storage connection “${safeTerminalText(name)}”.`, "info");
|
|
113
126
|
selectedName = undefined;
|
|
114
127
|
return { kind: "back" };
|
|
115
128
|
} catch (error) {
|
|
116
|
-
|
|
129
|
+
if (actionSignal.aborted || !isCurrent()) return { kind: "close" };
|
|
130
|
+
notifyConnectionError(ctx, name, error, actionSignal);
|
|
117
131
|
return { kind: "stay" };
|
|
118
132
|
}
|
|
119
133
|
},
|
|
@@ -124,21 +138,35 @@ export async function showStorageConnections(ctx: ExtensionCommandContext, signa
|
|
|
124
138
|
},
|
|
125
139
|
});
|
|
126
140
|
await runMenu(ctx, menu, {
|
|
127
|
-
getState: () => loadStorageMenuState(selectedName,
|
|
141
|
+
getState: ({ signal: loadSignal }) => loadStorageMenuState(ctx, selectedName, loadSignal),
|
|
128
142
|
signal,
|
|
129
|
-
isCurrent
|
|
143
|
+
isCurrent,
|
|
130
144
|
});
|
|
131
145
|
}
|
|
132
146
|
|
|
133
|
-
async function loadStorageMenuState(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
async function loadStorageMenuState(
|
|
148
|
+
ctx: ExtensionCommandContext,
|
|
149
|
+
selectedName: string | undefined,
|
|
150
|
+
signal: AbortSignal,
|
|
151
|
+
) {
|
|
152
|
+
const catalog = await loadSettingsCatalog();
|
|
153
|
+
signal?.throwIfAborted();
|
|
154
|
+
const raw = catalog?.settings;
|
|
155
|
+
const profiles = raw?.storageConnections ?? {};
|
|
156
|
+
const recovery =
|
|
157
|
+
catalog?.ignoreSetups.length && !(await ignoreFileSettingsAvailable(ctx, signal))
|
|
158
|
+
? [
|
|
159
|
+
"Connection changes are unavailable while any setup uses an ignore file.",
|
|
160
|
+
...ignoreSetupRecovery(catalog.path),
|
|
161
|
+
]
|
|
162
|
+
: undefined;
|
|
163
|
+
signal.throwIfAborted();
|
|
137
164
|
const profile = selectedName ? ownRecord(profiles[selectedName]) : undefined;
|
|
138
165
|
if (!selectedName || !profile) {
|
|
139
166
|
return {
|
|
140
167
|
supportedVersion: raw !== undefined,
|
|
141
168
|
profiles,
|
|
169
|
+
recovery,
|
|
142
170
|
selected: undefined,
|
|
143
171
|
};
|
|
144
172
|
}
|
|
@@ -146,16 +174,18 @@ async function loadStorageMenuState(selectedName: string | undefined, signal?: A
|
|
|
146
174
|
return {
|
|
147
175
|
supportedVersion: raw !== undefined,
|
|
148
176
|
profiles,
|
|
177
|
+
recovery,
|
|
149
178
|
selected: {
|
|
150
179
|
name: selectedName,
|
|
151
180
|
profile,
|
|
152
181
|
usedBy,
|
|
153
182
|
lines: [
|
|
183
|
+
...(recovery ?? []),
|
|
154
184
|
`Type: ${connectionType(profile)}`,
|
|
155
185
|
`Endpoint: ${connectionEndpoint(profile)}`,
|
|
156
186
|
`Credentials: ${credentialSource(profile)}`,
|
|
157
187
|
`Used by: ${usedBy.length > 0 ? usedBy.map(safeTerminalText).join(", ") : "No sync setups"}`,
|
|
158
|
-
...(usedBy.length > 0
|
|
188
|
+
...(!recovery && usedBy.length > 0
|
|
159
189
|
? [
|
|
160
190
|
"Remove unavailable: remove the listed sync setups first. Switch away from a current setup before removing it if other setups remain.",
|
|
161
191
|
]
|
package/src/ui/sync-setups-ui.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
|
-
import { loadConfig } from "../settings/config.js";
|
|
4
|
-
import { readLocalConfigObject } from "../settings/settings-store.js";
|
|
3
|
+
import { configFromSettings, loadConfig } from "../settings/config.js";
|
|
5
4
|
import { ownRecord } from "../settings/settings-validation.js";
|
|
6
5
|
import { throwIfAborted } from "../sync/signals.js";
|
|
7
6
|
import { syncErrorGuidance } from "../sync/sync-error-guidance.js";
|
|
7
|
+
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
8
8
|
import { syncIncludeSelection, syncSessionsSelected } from "../sync/sync-policy.js";
|
|
9
|
+
import { ignoreFileSettingsAvailable } from "./ignore-file-ui.js";
|
|
10
|
+
import { IGNORE_SETUP_MANAGEMENT_LIMIT, ignoreSetupRecovery, loadSettingsCatalog } from "./settings-review.js";
|
|
9
11
|
import { safeTerminalText } from "./terminal-text.js";
|
|
10
12
|
|
|
11
13
|
export async function countValidSyncSetups(setups: Record<string, unknown> | undefined, signal?: AbortSignal) {
|
|
@@ -35,6 +37,7 @@ type SyncSetupActions = {
|
|
|
35
37
|
interface SetupMenuState {
|
|
36
38
|
setups: Record<string, unknown>;
|
|
37
39
|
active?: string;
|
|
40
|
+
recovery?: string[];
|
|
38
41
|
selected?: {
|
|
39
42
|
name: string;
|
|
40
43
|
detail: string[];
|
|
@@ -48,6 +51,15 @@ export async function showSyncSetups(
|
|
|
48
51
|
actions: SyncSetupActions,
|
|
49
52
|
signal?: AbortSignal,
|
|
50
53
|
): Promise<"exit" | undefined> {
|
|
54
|
+
const validateOwner = captureMutationOwner(ctx, signal);
|
|
55
|
+
const isCurrent = () => {
|
|
56
|
+
try {
|
|
57
|
+
validateOwner();
|
|
58
|
+
return true;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
51
63
|
let selectedName: string | undefined;
|
|
52
64
|
let exit = false;
|
|
53
65
|
const nameById = new Map<string, string>();
|
|
@@ -62,9 +74,9 @@ export async function showSyncSetups(
|
|
|
62
74
|
return {
|
|
63
75
|
kind: "actions",
|
|
64
76
|
title: "Sync setups",
|
|
65
|
-
lines: ["What to sync, where to store it, and when to sync."],
|
|
77
|
+
lines: state.recovery ?? ["What to sync, where to store it, and when to sync."],
|
|
66
78
|
items: [
|
|
67
|
-
{ id: "add", label: "Add sync setup", action: "add" },
|
|
79
|
+
...(state.recovery ? [] : [{ id: "add", label: "Add sync setup", action: "add" as const }]),
|
|
68
80
|
...names.map((name, index) => {
|
|
69
81
|
const id = `setup:${index}`;
|
|
70
82
|
nameById.set(id, name);
|
|
@@ -85,7 +97,7 @@ export async function showSyncSetups(
|
|
|
85
97
|
lines: state.selected?.detail ?? ["This sync setup no longer exists."],
|
|
86
98
|
items: state.selected
|
|
87
99
|
? [
|
|
88
|
-
...(
|
|
100
|
+
...(state.recovery || state.selected.name === state.active || !state.selected.valid
|
|
89
101
|
? []
|
|
90
102
|
: [
|
|
91
103
|
{
|
|
@@ -94,7 +106,7 @@ export async function showSyncSetups(
|
|
|
94
106
|
action: "make-current" as const,
|
|
95
107
|
},
|
|
96
108
|
]),
|
|
97
|
-
{ id: "edit", label: "Edit storage location…", action: "edit" },
|
|
109
|
+
...(state.recovery ? [] : [{ id: "edit", label: "Edit storage location…", action: "edit" as const }]),
|
|
98
110
|
...(state.selected.removeUnavailable
|
|
99
111
|
? []
|
|
100
112
|
: [
|
|
@@ -111,7 +123,8 @@ export async function showSyncSetups(
|
|
|
111
123
|
}),
|
|
112
124
|
},
|
|
113
125
|
actions: {
|
|
114
|
-
add: async () => {
|
|
126
|
+
add: async ({ state }) => {
|
|
127
|
+
if (state.recovery) return { kind: "rejected" };
|
|
115
128
|
try {
|
|
116
129
|
await actions.add(signal);
|
|
117
130
|
} catch (error) {
|
|
@@ -125,8 +138,8 @@ export async function showSyncSetups(
|
|
|
125
138
|
selectedName = nameById.get(itemId);
|
|
126
139
|
return selectedName ? { kind: "to", screen: "detail" } : { kind: "rejected" };
|
|
127
140
|
},
|
|
128
|
-
"make-current": async () => {
|
|
129
|
-
if (!selectedName) return { kind: "rejected" };
|
|
141
|
+
"make-current": async ({ state }) => {
|
|
142
|
+
if (!selectedName || state.recovery || !state.selected?.valid) return { kind: "rejected" };
|
|
130
143
|
try {
|
|
131
144
|
exit = (await actions.makeCurrent(selectedName, signal)) === "exit";
|
|
132
145
|
return exit ? { kind: "close" } : { kind: "stay" };
|
|
@@ -135,8 +148,8 @@ export async function showSyncSetups(
|
|
|
135
148
|
return { kind: "stay" };
|
|
136
149
|
}
|
|
137
150
|
},
|
|
138
|
-
edit: async () => {
|
|
139
|
-
if (!selectedName) return { kind: "rejected" };
|
|
151
|
+
edit: async ({ state }) => {
|
|
152
|
+
if (!selectedName || state.recovery) return { kind: "rejected" };
|
|
140
153
|
try {
|
|
141
154
|
await actions.edit(selectedName, signal);
|
|
142
155
|
} catch (error) {
|
|
@@ -144,8 +157,8 @@ export async function showSyncSetups(
|
|
|
144
157
|
}
|
|
145
158
|
return { kind: "stay" };
|
|
146
159
|
},
|
|
147
|
-
remove: async () => {
|
|
148
|
-
if (!selectedName) return { kind: "rejected" };
|
|
160
|
+
remove: async ({ state }) => {
|
|
161
|
+
if (!selectedName || !state.selected || state.selected.removeUnavailable) return { kind: "rejected" };
|
|
149
162
|
const name = selectedName;
|
|
150
163
|
try {
|
|
151
164
|
await actions.remove(name, signal);
|
|
@@ -163,43 +176,57 @@ export async function showSyncSetups(
|
|
|
163
176
|
},
|
|
164
177
|
});
|
|
165
178
|
await runMenu(ctx, menu, {
|
|
166
|
-
getState: async () => loadSetupMenuState(selectedName,
|
|
179
|
+
getState: async ({ signal: loadSignal }) => loadSetupMenuState(ctx, selectedName, loadSignal),
|
|
167
180
|
signal,
|
|
168
|
-
isCurrent
|
|
181
|
+
isCurrent,
|
|
169
182
|
});
|
|
170
183
|
return exit ? "exit" : undefined;
|
|
171
184
|
}
|
|
172
185
|
|
|
173
|
-
async function loadSetupMenuState(
|
|
174
|
-
|
|
186
|
+
async function loadSetupMenuState(
|
|
187
|
+
ctx: ExtensionCommandContext,
|
|
188
|
+
selectedName: string | undefined,
|
|
189
|
+
signal: AbortSignal,
|
|
190
|
+
): Promise<SetupMenuState> {
|
|
191
|
+
const catalog = await loadSettingsCatalog();
|
|
192
|
+
throwIfAborted(signal);
|
|
193
|
+
if (!catalog) return { setups: {} };
|
|
194
|
+
const { syncSetups: setups, activeSyncSetup: active } = catalog.settings;
|
|
195
|
+
const recovery =
|
|
196
|
+
catalog.ignoreSetups.length && !(await ignoreFileSettingsAvailable(ctx, signal))
|
|
197
|
+
? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(catalog.path)]
|
|
198
|
+
: undefined;
|
|
175
199
|
throwIfAborted(signal);
|
|
176
|
-
|
|
177
|
-
const active = typeof raw?.activeSyncSetup === "string" ? raw.activeSyncSetup : undefined;
|
|
178
|
-
if (!selectedName || !ownRecord(setups[selectedName])) return { setups, active };
|
|
200
|
+
if (!selectedName || !Object.hasOwn(setups, selectedName)) return { setups, active, recovery };
|
|
179
201
|
const setupCount = Object.keys(setups).length;
|
|
180
202
|
const isCurrent = selectedName === active;
|
|
181
203
|
let detail: string[];
|
|
182
204
|
let valid = true;
|
|
183
205
|
try {
|
|
184
|
-
const config =
|
|
185
|
-
throwIfAborted(signal);
|
|
206
|
+
const config = configFromSettings(catalog.settings, selectedName);
|
|
186
207
|
const selection = syncIncludeSelection(config.include);
|
|
187
208
|
detail = [
|
|
188
209
|
`Status: ${isCurrent ? "Current" : "Not current"}`,
|
|
189
210
|
`Storage connection: ${safeTerminalText(config.connectionName)}`,
|
|
190
211
|
`Endpoint: ${storageEndpoint(config)}`,
|
|
191
212
|
`Storage location: ${storageLocation(config)}`,
|
|
192
|
-
config.
|
|
193
|
-
? `Sync scope: Pi agent directory ·
|
|
194
|
-
:
|
|
213
|
+
config.pathPolicy === "ignore-file"
|
|
214
|
+
? `Sync scope: Pi agent directory · ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}`
|
|
215
|
+
: config.scope
|
|
216
|
+
? `Sync scope: Pi agent directory · ${config.exclude?.length ?? 0} exclusions · ${config.reinclude?.length ?? 0} exceptions`
|
|
217
|
+
: `Included content: ${selection.builtIns.length} built-in groups · ${selection.custom.length} extra paths`,
|
|
195
218
|
`Sessions: ${syncSessionsSelected(config) ? "On — privacy-sensitive" : "Off"}`,
|
|
196
219
|
`Automatic sync: ${config.automatic ? "On" : "Off"}`,
|
|
197
220
|
`Automatic transfer at startup: ${config.automaticTransfer ? "On — may upload, replace, or delete selected files; no reload" : "Off"}`,
|
|
198
221
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
199
222
|
`Continuous sync: ${config.continuous ? (config.agentMode ? "On (recurring requests and transfers)" : "Saved On; paused until Autonomous sync is enabled") : "Off"}`,
|
|
200
|
-
|
|
201
|
-
?
|
|
202
|
-
:
|
|
223
|
+
...(recovery
|
|
224
|
+
? []
|
|
225
|
+
: [
|
|
226
|
+
isCurrent
|
|
227
|
+
? "Edit included content and automatic sync in /sync → Settings."
|
|
228
|
+
: "To edit included content or automatic sync, make this setup current, then open /sync → Settings.",
|
|
229
|
+
]),
|
|
203
230
|
];
|
|
204
231
|
} catch (error) {
|
|
205
232
|
valid = false;
|
|
@@ -209,11 +236,19 @@ async function loadSetupMenuState(selectedName: string | undefined, signal?: Abo
|
|
|
209
236
|
"Make current and sync are unavailable until this setup is repaired.",
|
|
210
237
|
];
|
|
211
238
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
239
|
+
const removeNeedsSwitch = isCurrent && setupCount > 1;
|
|
240
|
+
const ignoreSetupsRemain = catalog.ignoreSetups.some((name) => name !== selectedName);
|
|
241
|
+
const removeUnavailable = removeNeedsSwitch || Boolean(recovery && ignoreSetupsRemain);
|
|
242
|
+
if (recovery) {
|
|
243
|
+
if (removeUnavailable) detail.unshift("Remove unavailable here; use manual recovery.");
|
|
244
|
+
detail.unshift(...recovery);
|
|
245
|
+
} else if (removeNeedsSwitch) {
|
|
246
|
+
detail.push("Remove unavailable: switch to another setup first.");
|
|
247
|
+
}
|
|
214
248
|
return {
|
|
215
249
|
setups,
|
|
216
250
|
active,
|
|
251
|
+
recovery,
|
|
217
252
|
selected: { name: selectedName, detail, valid, removeUnavailable },
|
|
218
253
|
};
|
|
219
254
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/settings/config.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/pi-sync-daemon/engine/settings/config\";\nexport {\n configFromSettings,\n isEnabled,\n isExplicitlyEnabled,\n loadConfig,\n loadConfigForCheck,\n loadPartialConfig,\n sessionTokenWarnings,\n syncCheckConfigFingerprint,\n syncConfigReviewFingerprint,\n syncConfigReviewIdentity,\n syncSessionsWarnings,\n syncSetupReviewIdentity,\n syncSetupStorageReview,\n} from \"@narumitw/pi-sync-daemon/engine/settings/config\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|