@narumitw/pi-sync 0.60.5 → 0.62.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 +32 -23
- package/dist/chunks/{chunk-F64YWRXG.ts → chunk-3E3TR3JE.ts} +4 -4
- package/dist/chunks/{chunk-YVH5VJR4.ts → chunk-6PFZUEUG.ts} +138 -61
- package/dist/chunks/chunk-6PFZUEUG.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-KPWZNMKM.ts → chunk-ECYCNZOE.ts} +1 -5
- package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
- package/dist/chunks/chunk-GELYN4UC.ts +14 -0
- package/dist/chunks/chunk-GELYN4UC.ts.map +7 -0
- package/dist/chunks/{chunk-V2QIMC3U.ts → chunk-GSCZ4VXV.ts} +13 -8
- package/dist/chunks/chunk-GSCZ4VXV.ts.map +7 -0
- package/dist/chunks/{chunk-6W2SNZ5P.ts → chunk-IBXEM35O.ts} +8 -3
- package/dist/chunks/{chunk-6W2SNZ5P.ts.map → chunk-IBXEM35O.ts.map} +3 -3
- package/dist/chunks/{chunk-6KIWZ4AY.ts → chunk-INECVQNR.ts} +13 -12
- package/dist/chunks/chunk-INECVQNR.ts.map +7 -0
- package/dist/chunks/chunk-JREGWM2B.ts +139 -0
- package/dist/chunks/chunk-JREGWM2B.ts.map +7 -0
- package/dist/chunks/{chunk-277VHM2P.ts → chunk-MNYRU5U5.ts} +5 -2
- package/dist/chunks/{chunk-277VHM2P.ts.map → chunk-MNYRU5U5.ts.map} +2 -2
- package/dist/chunks/chunk-NHFGAZEC.ts +277 -0
- package/dist/chunks/chunk-NHFGAZEC.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-MCUZFUHY.ts → chunk-PWESMTH6.ts} +10 -10
- package/dist/chunks/{chunk-V4AMI3VL.ts → chunk-R3SAMXB6.ts} +10 -2
- package/dist/chunks/chunk-R3SAMXB6.ts.map +7 -0
- package/dist/chunks/{chunk-RNIEVDTR.ts → chunk-T3LABNHF.ts} +2 -2
- package/dist/chunks/{chunk-S3R3W3KF.ts → chunk-UMPA5S7X.ts} +2 -2
- package/dist/chunks/{chunk-WP2M67XZ.ts → chunk-WBIOSK76.ts} +2 -2
- package/dist/chunks/{chunk-LAXTCSX4.ts → chunk-ZB3GNX3P.ts} +124 -139
- package/dist/chunks/chunk-ZB3GNX3P.ts.map +7 -0
- package/dist/chunks/{chunk-HEB6YT64.ts → chunk-ZO52JM4H.ts} +2 -2
- package/dist/chunks/{command-handler-TNPWFIPG.ts → command-handler-6ATREPG7.ts} +44 -40
- package/dist/chunks/command-handler-6ATREPG7.ts.map +7 -0
- package/dist/chunks/{conflict-review-ETCSYJTH.ts → conflict-review-MAOGTIAI.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-DD6X4J2K.ts → file-selection-QR2KZVGD.ts} +28 -15
- package/dist/chunks/file-selection-QR2KZVGD.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-MC6EQOQY.ts +19 -0
- package/dist/chunks/{manager-ui-LFONXWQN.ts → manager-ui-AOFUNXAJ.ts} +648 -305
- package/dist/chunks/manager-ui-AOFUNXAJ.ts.map +7 -0
- package/dist/chunks/remote-selection-ui-4BTP2OJR.ts +18 -0
- package/dist/chunks/{setup-switch-SPZE7HIQ.ts → setup-switch-Y6AMFFNK.ts} +7 -7
- package/dist/chunks/{setup-wizard-5JYKAEIT.ts → setup-wizard-5G426MOZ.ts} +18 -16
- package/dist/chunks/setup-wizard-5G426MOZ.ts.map +7 -0
- 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-6VGR2UVZ.ts → sync-inspection-ITZ6Z4DE.ts} +7 -7
- package/dist/chunks/{sync-operations-SAKAZL6Z.ts → sync-operations-NMVKF7SE.ts} +13 -9
- package/dist/chunks/sync-operations-NMVKF7SE.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 +265 -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 +715 -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 +186 -0
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +139 -0
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +322 -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 +301 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +193 -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 +160 -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 +276 -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 +813 -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 +84 -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 +132 -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 +521 -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-apply.js +529 -0
- package/dist/daemon/dist/engine/sync/merge-journal.js +295 -0
- package/dist/daemon/dist/engine/sync/merge-transfer-error.js +64 -0
- package/dist/daemon/dist/engine/sync/merged-sync.js +674 -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 +104 -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 +33 -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 +733 -0
- package/dist/daemon/dist/engine/sync/sync-operations.js +3 -0
- package/dist/daemon/dist/engine/sync/sync-policy.js +621 -0
- package/dist/daemon/dist/engine/sync/sync-queries.js +212 -0
- package/dist/daemon/dist/engine/sync/sync-state.js +129 -0
- package/dist/daemon/dist/engine/sync/text-merge.js +124 -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 +344 -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 +272 -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 +953 -0
- package/dist/daemon/dist/service-host.js +174 -0
- package/dist/daemon/dist/upgrade-repair.js +55 -0
- package/dist/daemon/package.json +3 -0
- package/dist/index.ts +32 -32
- package/dist/package.json +6 -0
- package/docs/daemon-migration.md +27 -16
- package/package.json +11 -5
- package/skills/configure-pi-sync/SKILL.md +38 -13
- package/skills/configure-pi-sync/references/configuration.md +61 -34
- package/src/commands/command-execution.ts +8 -2
- package/src/daemon/pi-client.ts +1 -0
- package/src/settings/config.ts +1 -0
- package/src/sync/sync-operations.ts +18 -10
- package/src/sync/sync-policy.ts +5 -0
- package/src/ui/agent-mode-setting.ts +9 -1
- package/src/ui/excluded-paths-ui.ts +157 -2
- package/src/ui/file-selection.ts +12 -7
- package/src/ui/ignore-file-ui.ts +271 -0
- package/src/ui/ignore-migration-prompt.ts +65 -0
- package/src/ui/manager-state.ts +39 -20
- package/src/ui/manager-ui.ts +38 -19
- package/src/ui/remote-selection-ui.ts +159 -33
- package/src/ui/settings-frame.ts +2 -8
- package/src/ui/settings-review.ts +26 -0
- package/src/ui/settings-ui.ts +327 -199
- package/src/ui/setup/directory-rules.ts +81 -0
- package/src/ui/setup/git-ui.ts +14 -24
- package/src/ui/setup/s3-ui.ts +13 -26
- package/src/ui/setup/setup-actions.ts +0 -4
- package/src/ui/setup/setup-prompts.ts +99 -17
- package/src/ui/setup/setup-switcher.ts +4 -2
- package/src/ui/setup/setup-wizard.ts +5 -4
- package/src/ui/setup/webdav-ui.ts +13 -27
- package/src/ui/storage-connections-ui.ts +22 -14
- package/src/ui/sync-attention.ts +8 -3
- package/src/ui/sync-format.ts +8 -1
- package/src/ui/sync-setups-ui.ts +47 -27
- package/dist/chunks/chunk-6KIWZ4AY.ts.map +0 -7
- package/dist/chunks/chunk-KPWZNMKM.ts.map +0 -7
- package/dist/chunks/chunk-LAXTCSX4.ts.map +0 -7
- package/dist/chunks/chunk-V2QIMC3U.ts.map +0 -7
- package/dist/chunks/chunk-V4AMI3VL.ts.map +0 -7
- package/dist/chunks/chunk-YVH5VJR4.ts.map +0 -7
- package/dist/chunks/command-handler-TNPWFIPG.ts.map +0 -7
- package/dist/chunks/file-selection-DD6X4J2K.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-2GFNWHDM.ts +0 -18
- package/dist/chunks/manager-ui-LFONXWQN.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-GFR6TDTX.ts +0 -17
- package/dist/chunks/setup-wizard-5JYKAEIT.ts.map +0 -7
- package/dist/chunks/sync-operations-SAKAZL6Z.ts.map +0 -7
- /package/dist/chunks/{chunk-F64YWRXG.ts.map → chunk-3E3TR3JE.ts.map} +0 -0
- /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-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-MCUZFUHY.ts.map → chunk-PWESMTH6.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-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-ETCSYJTH.ts.map → conflict-review-MAOGTIAI.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-2GFNWHDM.ts.map → manager-result-dispatcher-MC6EQOQY.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-GFR6TDTX.ts.map → remote-selection-ui-4BTP2OJR.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-SPZE7HIQ.ts.map → setup-switch-Y6AMFFNK.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-6VGR2UVZ.ts.map → sync-inspection-ITZ6Z4DE.ts.map} +0 -0
- /package/dist/chunks/{sync-state-2LMIXJ2C.ts.map → sync-state-QIT64TKV.ts.map} +0 -0
|
@@ -1,42 +1,5 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
import {
|
|
4
|
-
dispatchManagerResult
|
|
5
|
-
} from "./chunk-F64YWRXG.ts";
|
|
6
|
-
import {
|
|
7
|
-
captureMutationOwner,
|
|
8
|
-
runCancellableOperation
|
|
9
|
-
} from "./chunk-YVH5VJR4.ts";
|
|
10
|
-
import {
|
|
11
|
-
SETUP_SWITCH_ACTION_OPTIONS,
|
|
12
|
-
saveOnSwitch,
|
|
13
|
-
setupSwitchActionFromLabel,
|
|
14
|
-
setupSwitchActionLabel,
|
|
15
|
-
useSyncSetup
|
|
16
|
-
} from "./chunk-MCUZFUHY.ts";
|
|
17
|
-
import {
|
|
18
|
-
observationMatchesConfig,
|
|
19
|
-
observationSummary,
|
|
20
|
-
readStateForConfig,
|
|
21
|
-
syncAttentionMatchesConfig,
|
|
22
|
-
syncStateFingerprint
|
|
23
|
-
} from "./chunk-V2QIMC3U.ts";
|
|
24
|
-
import {
|
|
25
|
-
normalizeSyncExclude,
|
|
26
|
-
sameSyncExclude
|
|
27
|
-
} from "./chunk-HEB6YT64.ts";
|
|
28
|
-
import {
|
|
29
|
-
confirmMergeReview
|
|
30
|
-
} from "./chunk-GSQGBVKG.ts";
|
|
31
|
-
import {
|
|
32
|
-
loadConfig,
|
|
33
|
-
loadPartialConfig,
|
|
34
|
-
syncCheckConfigFingerprint,
|
|
35
|
-
syncConfigReviewIdentity
|
|
36
|
-
} from "./chunk-277VHM2P.ts";
|
|
37
|
-
import {
|
|
38
|
-
configureSyncStatus
|
|
39
|
-
} from "./chunk-H7VOTY5N.ts";
|
|
40
3
|
import {
|
|
41
4
|
applyS3CredentialUpdate,
|
|
42
5
|
chooseS3CredentialUpdate,
|
|
@@ -45,7 +8,6 @@ import {
|
|
|
45
8
|
refreshTargetCompletions,
|
|
46
9
|
requiredInput,
|
|
47
10
|
requiredValueInput,
|
|
48
|
-
saveReviewedDraft,
|
|
49
11
|
showAddGitStorageProfile,
|
|
50
12
|
showAddGitTarget,
|
|
51
13
|
showAddS3Target,
|
|
@@ -56,55 +18,110 @@ import {
|
|
|
56
18
|
showEditS3Target,
|
|
57
19
|
showEditWebDavStorageProfile,
|
|
58
20
|
showEditWebDavTarget
|
|
59
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ZB3GNX3P.ts";
|
|
22
|
+
import {
|
|
23
|
+
dispatchManagerResult
|
|
24
|
+
} from "./chunk-3E3TR3JE.ts";
|
|
25
|
+
import {
|
|
26
|
+
SETUP_SWITCH_ACTION_OPTIONS,
|
|
27
|
+
saveOnSwitch,
|
|
28
|
+
setupSwitchActionFromLabel,
|
|
29
|
+
setupSwitchActionLabel,
|
|
30
|
+
useSyncSetup
|
|
31
|
+
} from "./chunk-PWESMTH6.ts";
|
|
60
32
|
import {
|
|
61
33
|
isCloudflareR2Endpoint,
|
|
62
34
|
normalizeS3Endpoint,
|
|
63
|
-
ownRecord
|
|
64
|
-
|
|
35
|
+
ownRecord,
|
|
36
|
+
validateSettingsDocument
|
|
37
|
+
} from "./chunk-APZVJAEW.ts";
|
|
65
38
|
import {
|
|
66
|
-
automaticSyncSummary
|
|
67
|
-
|
|
68
|
-
} from "./chunk-KPWZNMKM.ts";
|
|
39
|
+
automaticSyncSummary
|
|
40
|
+
} from "./chunk-ECYCNZOE.ts";
|
|
69
41
|
import {
|
|
70
42
|
loadOnSwitch,
|
|
71
43
|
readLocalConfigObject,
|
|
72
44
|
requireSettings,
|
|
73
45
|
updateLocalConfig
|
|
74
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-WBIOSK76.ts";
|
|
47
|
+
import {
|
|
48
|
+
observationMatchesConfig,
|
|
49
|
+
observationSummary,
|
|
50
|
+
readStateForConfig,
|
|
51
|
+
syncAttentionMatchesConfig,
|
|
52
|
+
syncStateFingerprint
|
|
53
|
+
} from "./chunk-GSCZ4VXV.ts";
|
|
75
54
|
import {
|
|
76
55
|
AUTOMATIC_SYNC_DESCRIPTION,
|
|
77
56
|
STARTUP_TRANSFER_DESCRIPTION,
|
|
78
57
|
startupTransferSummary
|
|
79
58
|
} from "./chunk-HLCML3OW.ts";
|
|
59
|
+
import {
|
|
60
|
+
confirmMergeReview
|
|
61
|
+
} from "./chunk-GSQGBVKG.ts";
|
|
62
|
+
import {
|
|
63
|
+
directoryScopeSummary,
|
|
64
|
+
showExcludedPaths
|
|
65
|
+
} from "./chunk-NHFGAZEC.ts";
|
|
66
|
+
import {
|
|
67
|
+
directorySessionOptInLine,
|
|
68
|
+
saveReviewedDraft
|
|
69
|
+
} from "./chunk-JREGWM2B.ts";
|
|
70
|
+
import {
|
|
71
|
+
activeLocalConfigPath,
|
|
72
|
+
localConfigPath,
|
|
73
|
+
readActiveLocalConfigDocumentForRepair,
|
|
74
|
+
syncErrorGuidance
|
|
75
|
+
} from "./chunk-IBXEM35O.ts";
|
|
76
|
+
import {
|
|
77
|
+
piDaemonClient
|
|
78
|
+
} from "./chunk-INECVQNR.ts";
|
|
79
|
+
import {
|
|
80
|
+
runCancellableOperation,
|
|
81
|
+
runCancellableTask
|
|
82
|
+
} from "./chunk-6PFZUEUG.ts";
|
|
80
83
|
import {
|
|
81
84
|
throwIfAborted
|
|
82
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-UMPA5S7X.ts";
|
|
86
|
+
import {
|
|
87
|
+
captureMutationOwner
|
|
88
|
+
} from "./chunk-GELYN4UC.ts";
|
|
83
89
|
import {
|
|
84
90
|
addStorageConnection,
|
|
85
91
|
removeStorageConnection,
|
|
86
92
|
removeSyncSetup,
|
|
87
93
|
updateStorageConnection,
|
|
88
94
|
updateSyncSetup
|
|
89
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-NXWHPVXR.ts";
|
|
90
96
|
import {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
} from "./chunk-6W2SNZ5P.ts";
|
|
97
|
+
sameSyncExclude
|
|
98
|
+
} from "./chunk-ZO52JM4H.ts";
|
|
94
99
|
import {
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
configFromSettings,
|
|
101
|
+
loadConfig,
|
|
102
|
+
loadPartialConfig,
|
|
103
|
+
loadSettingsConfig,
|
|
104
|
+
syncCheckConfigFingerprint,
|
|
105
|
+
syncConfigReviewIdentity
|
|
106
|
+
} from "./chunk-MNYRU5U5.ts";
|
|
97
107
|
import {
|
|
98
|
-
|
|
99
|
-
} from "./chunk-
|
|
108
|
+
configureSyncStatus
|
|
109
|
+
} from "./chunk-H7VOTY5N.ts";
|
|
110
|
+
import {
|
|
111
|
+
errorMessage
|
|
112
|
+
} from "./chunk-6YKOHBSC.ts";
|
|
100
113
|
import {
|
|
101
114
|
compareSyncInclude,
|
|
102
115
|
syncIncludeSelection,
|
|
116
|
+
syncSelectionHasContent,
|
|
103
117
|
syncSessionsSelected
|
|
104
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-R3SAMXB6.ts";
|
|
119
|
+
import {
|
|
120
|
+
safeTerminalText
|
|
121
|
+
} from "./chunk-2JNFEZ3V.ts";
|
|
105
122
|
|
|
106
123
|
// src/ui/manager-ui.ts
|
|
107
|
-
import { defineMenu as
|
|
124
|
+
import { defineMenu as defineMenu5, runDocumentReview, runMenu as runMenu5 } from "@narumitw/pi-tui-kit";
|
|
108
125
|
|
|
109
126
|
// src/state/operation-availability.ts
|
|
110
127
|
import {
|
|
@@ -112,7 +129,281 @@ import {
|
|
|
112
129
|
inspectOperationAvailability,
|
|
113
130
|
operationBlocksChanges,
|
|
114
131
|
operationCanRecover
|
|
115
|
-
} from "
|
|
132
|
+
} from "#pi-sync-daemon/engine/state/operation-availability";
|
|
133
|
+
|
|
134
|
+
// src/ui/ignore-file-ui.ts
|
|
135
|
+
import { resolve } from "node:path";
|
|
136
|
+
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
137
|
+
import { CURSOR_MARKER, Editor, isKeyRelease, Key, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
|
|
138
|
+
import { HorizontalRule, hardWrapTerminalDocument, runCustomInteraction } from "@narumitw/pi-tui-kit";
|
|
139
|
+
async function ignoreFileSettingsAvailable(ctx, signal) {
|
|
140
|
+
if (signal?.aborted) return false;
|
|
141
|
+
try {
|
|
142
|
+
const client = piDaemonClient(ctx);
|
|
143
|
+
const result = await client.run("ignore.capabilities", {}, signal, ctx);
|
|
144
|
+
client.validate();
|
|
145
|
+
return !signal?.aborted && result?.available === true;
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function manualIgnoreFileGuidance(filename) {
|
|
151
|
+
return `Edit existing ignore rules manually: ${safeTerminalText(resolve(getAgentDir(), filename))}`;
|
|
152
|
+
}
|
|
153
|
+
async function showIgnoreFileAction(ctx, setup, action, filename, signal, offerToken) {
|
|
154
|
+
if (signal.aborted || !ctx.hasUI) return;
|
|
155
|
+
if (ctx.mode !== "tui") {
|
|
156
|
+
if (ctx.mode === "rpc" && action === "edit") ctx.ui.notify(manualIgnoreFileGuidance(filename), "info");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const validateOwner = captureMutationOwner(ctx, signal);
|
|
160
|
+
const client = piDaemonClient(ctx);
|
|
161
|
+
const isCurrent = () => {
|
|
162
|
+
try {
|
|
163
|
+
validateOwner();
|
|
164
|
+
client.validate();
|
|
165
|
+
return true;
|
|
166
|
+
} catch {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const work = async (method, message, payload = {}) => {
|
|
171
|
+
const result = await runCancellableTask(
|
|
172
|
+
ctx,
|
|
173
|
+
message,
|
|
174
|
+
(workSignal, onCommit) => client.run(`ignore.${method}`, { setup, ...payload }, workSignal, ctx, onCommit),
|
|
175
|
+
{
|
|
176
|
+
signal,
|
|
177
|
+
isCurrent,
|
|
178
|
+
cancelledMessage: null,
|
|
179
|
+
commitAware: method !== "read",
|
|
180
|
+
cancelAcrossDialogs: method !== "read"
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
return isCurrent() && result.kind === "completed" ? result : void 0;
|
|
184
|
+
};
|
|
185
|
+
try {
|
|
186
|
+
if (action === "migrate") {
|
|
187
|
+
const result2 = await work("migrate", "Preparing ignore-file migration review\u2026", offerToken ? { offerToken } : {});
|
|
188
|
+
if (isCurrent() && result2?.value === "saved")
|
|
189
|
+
ctx.ui.notify("Ignore-file policy saved locally. No transfer started.", "info");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (action === "switch") {
|
|
193
|
+
const entered = await askIgnoreFilename(ctx, filename, signal);
|
|
194
|
+
if (!isCurrent() || !entered || entered === filename) return;
|
|
195
|
+
const result2 = await work("switch", "Checking the selected ignore file for review\u2026", {
|
|
196
|
+
filename: entered,
|
|
197
|
+
expectedFilename: filename
|
|
198
|
+
});
|
|
199
|
+
if (isCurrent() && result2?.value === "saved") ctx.ui.notify("Ignore file selected. No transfer started.", "info");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const result = await work("read", "Opening existing ignore file\u2026");
|
|
203
|
+
if (!isCurrent() || !result) return;
|
|
204
|
+
const source = decodeIgnoreFile(result.value);
|
|
205
|
+
const path = safeTerminalText(source.path);
|
|
206
|
+
if (!isEditorSafe(source.text)) {
|
|
207
|
+
ctx.ui.notify(
|
|
208
|
+
`Pi cannot edit this file without changing or hiding some characters. Edit ${path} manually.`,
|
|
209
|
+
"warning"
|
|
210
|
+
);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const sharing = source.sharingSetups.length ? `Also used by: ${source.sharingSetups.map((name) => `\u201C${safeTerminalText(name)}\u201D`).join(", ")}` : void 0;
|
|
214
|
+
const draft = await editIgnoreText(ctx, source.text, path, sharing, signal, isCurrent);
|
|
215
|
+
if (!isCurrent() || draft.kind !== "completed") return;
|
|
216
|
+
if (draft.value.kind === "unsafe") {
|
|
217
|
+
ctx.ui.notify(`Unsafe terminal characters in the draft. No save; edit ${path} manually.`, "warning");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (draft.value.kind !== "draft" || draft.value.text === source.text) return;
|
|
221
|
+
const text = draft.value.text;
|
|
222
|
+
const lines = [
|
|
223
|
+
path,
|
|
224
|
+
...sharing ? [sharing] : [],
|
|
225
|
+
"This replaces the local rules. Removing rules may expose more files on a later sync.",
|
|
226
|
+
"No transfer starts; remote history is retained."
|
|
227
|
+
];
|
|
228
|
+
const confirmed = await confirmMergeReview(ctx, "Save ignore rules?", text, signal, isCurrent, "save rules", lines);
|
|
229
|
+
if (!isCurrent() || !confirmed) return;
|
|
230
|
+
const saved = await work("save", "Saving ignore rules\u2026", {
|
|
231
|
+
text,
|
|
232
|
+
sourceDigest: source.sourceDigest,
|
|
233
|
+
identity: source.identity
|
|
234
|
+
});
|
|
235
|
+
if (isCurrent() && saved) ctx.ui.notify("Ignore rules saved. No transfer started.", "info");
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (isCurrent())
|
|
238
|
+
ctx.ui.notify(`Pi Sync: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`, "error");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function decodeIgnoreFile(value) {
|
|
242
|
+
const file = value;
|
|
243
|
+
if (!file || typeof file.filename !== "string" || typeof file.path !== "string")
|
|
244
|
+
throw new Error("Invalid ignore-file response from the daemon.");
|
|
245
|
+
if (file.identity === void 0 && file.text === void 0)
|
|
246
|
+
throw new Error(`Ignore file does not exist: ${file.path}. No file was created.`);
|
|
247
|
+
if (typeof file.text !== "string" || typeof file.identity !== "string" || file.identity.length === 0 || typeof file.sourceDigest !== "string" || !Array.isArray(file.sharingSetups) || !file.sharingSetups.every((setup) => typeof setup === "string"))
|
|
248
|
+
throw new Error("Invalid ignore-file response from the daemon.");
|
|
249
|
+
return file;
|
|
250
|
+
}
|
|
251
|
+
async function askIgnoreFilename(ctx, filename, signal) {
|
|
252
|
+
const cancel = new AbortController();
|
|
253
|
+
const stop = ctx.ui.onTerminalInput((data) => {
|
|
254
|
+
if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) {
|
|
255
|
+
cancel.abort();
|
|
256
|
+
return { consume: true };
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
const inputSignal = AbortSignal.any([signal, cancel.signal]);
|
|
260
|
+
try {
|
|
261
|
+
const entered = await ctx.ui.input(`Existing ignore filename (current: ${safeTerminalText(filename)})`, void 0, {
|
|
262
|
+
signal: inputSignal
|
|
263
|
+
});
|
|
264
|
+
return inputSignal.aborted ? void 0 : entered;
|
|
265
|
+
} finally {
|
|
266
|
+
stop();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function isEditorSafe(text) {
|
|
270
|
+
const flattened = text.replaceAll("\n", "");
|
|
271
|
+
return flattened === safeTerminalText(flattened);
|
|
272
|
+
}
|
|
273
|
+
function editIgnoreText(ctx, original, path, sharing, signal, isCurrent) {
|
|
274
|
+
return runCustomInteraction(ctx, {
|
|
275
|
+
signal,
|
|
276
|
+
isCurrent,
|
|
277
|
+
create: ({ tui, theme, keybindings, complete, signal: editorSignal }) => {
|
|
278
|
+
const muted = (line) => theme.fg("muted", line);
|
|
279
|
+
const editor = new Editor(tui, {
|
|
280
|
+
borderColor: (line) => theme.fg("borderMuted", line),
|
|
281
|
+
selectList: {
|
|
282
|
+
selectedPrefix: (line) => theme.fg("accent", line),
|
|
283
|
+
selectedText: (line) => theme.fg("accent", line),
|
|
284
|
+
description: muted,
|
|
285
|
+
scrollInfo: muted,
|
|
286
|
+
noMatch: muted
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
editor.setText(original);
|
|
290
|
+
let text = original;
|
|
291
|
+
let beforeChange = original;
|
|
292
|
+
editor.onChange = () => {
|
|
293
|
+
beforeChange = text;
|
|
294
|
+
text = editor.getExpandedText();
|
|
295
|
+
if (!isEditorSafe(text)) complete({ kind: "unsafe" });
|
|
296
|
+
};
|
|
297
|
+
editor.onSubmit = () => complete({ kind: "draft", text: beforeChange });
|
|
298
|
+
const rule = new HorizontalRule({ ruleStyle: (line) => theme.fg("border", line) });
|
|
299
|
+
let layout;
|
|
300
|
+
return {
|
|
301
|
+
get focused() {
|
|
302
|
+
return editor.focused;
|
|
303
|
+
},
|
|
304
|
+
set focused(value) {
|
|
305
|
+
editor.focused = value;
|
|
306
|
+
},
|
|
307
|
+
get capturesViewportInput() {
|
|
308
|
+
return true;
|
|
309
|
+
},
|
|
310
|
+
render(width) {
|
|
311
|
+
layout = void 0;
|
|
312
|
+
if (editorSignal.aborted || !Number.isFinite(width) || width <= 0) return [];
|
|
313
|
+
const terminalRows = Number.isFinite(tui.terminal.rows) ? Math.floor(tui.terminal.rows) : 24;
|
|
314
|
+
const rows = Math.max(1, terminalRows - 3);
|
|
315
|
+
const border = rows >= 5 ? rule.render(width) : [];
|
|
316
|
+
const editorRows = editor.render(width).slice(1, -1);
|
|
317
|
+
const header = [
|
|
318
|
+
theme.fg("accent", theme.bold("Edit ignore rules")),
|
|
319
|
+
muted("Submit to review; cancel to discard."),
|
|
320
|
+
...[path, ...sharing ? [sharing] : []].flatMap(
|
|
321
|
+
(line) => hardWrapTerminalDocument(line, width).map(muted)
|
|
322
|
+
)
|
|
323
|
+
].slice(0, rows - 2 * border.length - 1);
|
|
324
|
+
const available = rows - 2 * border.length - header.length;
|
|
325
|
+
const cursorRow = editorRows.findIndex((line) => line.includes(CURSOR_MARKER));
|
|
326
|
+
const offset = Math.max(0, cursorRow - available + 1);
|
|
327
|
+
const body = editorRows.slice(offset, offset + available);
|
|
328
|
+
layout = { width, first: border.length + header.length, count: body.length, editorOffset: offset + 1 };
|
|
329
|
+
return [...border, ...header, ...body, ...border].map((line) => truncateToWidth(line, width, ""));
|
|
330
|
+
},
|
|
331
|
+
invalidate() {
|
|
332
|
+
layout = void 0;
|
|
333
|
+
rule.invalidate();
|
|
334
|
+
editor.invalidate();
|
|
335
|
+
},
|
|
336
|
+
handleInput(data) {
|
|
337
|
+
if (editorSignal.aborted || isKeyRelease(data)) return;
|
|
338
|
+
if (matchesKey(data, Key.ctrl("c")) || keybindings.matches(data, "tui.select.cancel")) {
|
|
339
|
+
complete({ kind: "cancelled" });
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
editor.handleInput(data);
|
|
343
|
+
if (!editorSignal.aborted) tui.requestRender();
|
|
344
|
+
},
|
|
345
|
+
handleMouse(event) {
|
|
346
|
+
if (editorSignal.aborted || !layout || layout.width !== event.width) return;
|
|
347
|
+
const y = event.y - layout.first;
|
|
348
|
+
if (y >= 0 && y < layout.count) return editor.handleMouse({ ...event, y: y + layout.editorOffset });
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/ui/ignore-migration-prompt.ts
|
|
356
|
+
var reviewNow = "Review migration now";
|
|
357
|
+
var notNow = "Not now";
|
|
358
|
+
async function showIgnoreMigrationPrompt(ctx, setup, signal, isCurrent) {
|
|
359
|
+
if (ctx.mode !== "tui" || !ctx.hasUI || signal.aborted || !isCurrent()) return false;
|
|
360
|
+
if (!await ignoreFileSettingsAvailable(ctx, signal) || signal.aborted || !isCurrent()) return false;
|
|
361
|
+
let shown = false;
|
|
362
|
+
try {
|
|
363
|
+
const client = piDaemonClient(ctx);
|
|
364
|
+
const valid = () => {
|
|
365
|
+
if (signal.aborted || !isCurrent()) return false;
|
|
366
|
+
client.validate();
|
|
367
|
+
return true;
|
|
368
|
+
};
|
|
369
|
+
const offer = await client.run("ignore.migration-offer", { setup }, signal, ctx);
|
|
370
|
+
if (!valid()) return false;
|
|
371
|
+
const token = readOfferToken(offer);
|
|
372
|
+
if (!token) return false;
|
|
373
|
+
shown = true;
|
|
374
|
+
const choice = await ctx.ui.select(
|
|
375
|
+
[
|
|
376
|
+
`Review migration for sync setup \u201C${safeTerminalText(setup)}\u201D?`,
|
|
377
|
+
"Your current rules still apply. Review the paths that would change before deciding.",
|
|
378
|
+
"Migration does not start a transfer. You can review it later in Pi Sync Settings."
|
|
379
|
+
].join("\n\n"),
|
|
380
|
+
[reviewNow, notNow],
|
|
381
|
+
{ signal }
|
|
382
|
+
);
|
|
383
|
+
if (!valid()) return true;
|
|
384
|
+
if (choice === notNow) {
|
|
385
|
+
await client.run("ignore.migration-defer", { setup, token }, signal, ctx);
|
|
386
|
+
} else if (choice === reviewNow) {
|
|
387
|
+
await showIgnoreFileAction(ctx, setup, "migrate", ".syncignore", signal, token);
|
|
388
|
+
}
|
|
389
|
+
} catch (error) {
|
|
390
|
+
if (!signal.aborted && isCurrent()) {
|
|
391
|
+
ctx.ui.notify(
|
|
392
|
+
`Pi Sync migration prompt: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
|
|
393
|
+
"warning"
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return shown;
|
|
398
|
+
}
|
|
399
|
+
function readOfferToken(value) {
|
|
400
|
+
if (value === null) return void 0;
|
|
401
|
+
const token = value?.token;
|
|
402
|
+
if (typeof token !== "string" || !/^[0-9a-f]{64}$/u.test(token)) {
|
|
403
|
+
throw new Error("Invalid migration offer from the daemon.");
|
|
404
|
+
}
|
|
405
|
+
return token;
|
|
406
|
+
}
|
|
116
407
|
|
|
117
408
|
// src/ui/manager-attention.ts
|
|
118
409
|
function attentionMainMenuItems(manager) {
|
|
@@ -142,7 +433,7 @@ function blockedSyncMenuItem(label, manager) {
|
|
|
142
433
|
};
|
|
143
434
|
}
|
|
144
435
|
async function showManagerAttention(ctx, attention, runRoute, signal, onSelectionResolved) {
|
|
145
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
436
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-4BTP2OJR.ts");
|
|
146
437
|
if (signal?.aborted) return "close";
|
|
147
438
|
const review = await showRemoteSelectionReview(ctx, attention.decision.setupName, signal, void 0, {
|
|
148
439
|
decision: attention.decision,
|
|
@@ -205,10 +496,31 @@ async function recoverSyncAccess(ctx, manager, runRoute, sessionSignal, actionSi
|
|
|
205
496
|
}
|
|
206
497
|
|
|
207
498
|
// src/ui/manager-state.ts
|
|
208
|
-
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
499
|
+
import { truncateToWidth as truncateToWidth2 } from "@earendil-works/pi-tui";
|
|
209
500
|
|
|
210
501
|
// src/ui/sync-setups-ui.ts
|
|
211
502
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
503
|
+
|
|
504
|
+
// src/ui/settings-review.ts
|
|
505
|
+
async function loadSettingsCatalog() {
|
|
506
|
+
const document = await readActiveLocalConfigDocumentForRepair();
|
|
507
|
+
if (!document) return void 0;
|
|
508
|
+
const settings = validateSettingsDocument(document.parsed);
|
|
509
|
+
const ignoreSetups = Object.entries(settings.syncSetups).filter(([, setup]) => setup.sync.pathPolicy === "ignore-file").map(([name]) => name);
|
|
510
|
+
return { settings, path: document.path, ignoreSetups };
|
|
511
|
+
}
|
|
512
|
+
var IGNORE_SETUP_MANAGEMENT_LIMIT = "Adding, editing, and switching setups are unavailable while any setup uses an ignore file.";
|
|
513
|
+
function ignoreSetupRecovery(settingsPath) {
|
|
514
|
+
return [
|
|
515
|
+
`For manual recovery, close Pi and back up: ${safeTerminalText(settingsPath)}`,
|
|
516
|
+
"Remove the ignore-file entries from syncSetups.",
|
|
517
|
+
"Set activeSyncSetup to a remaining setup, or remove it if none remain.",
|
|
518
|
+
"Keep the settings version, ignore files, and remote data unchanged.",
|
|
519
|
+
"Preserve any pending journal and backup. Review automatic sync before restarting Pi."
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// src/ui/sync-setups-ui.ts
|
|
212
524
|
async function countValidSyncSetups(setups, signal) {
|
|
213
525
|
let count = 0;
|
|
214
526
|
for (const name of Object.keys(setups ?? {})) {
|
|
@@ -237,9 +549,9 @@ async function showSyncSetups(ctx, actions, signal) {
|
|
|
237
549
|
return {
|
|
238
550
|
kind: "actions",
|
|
239
551
|
title: "Sync setups",
|
|
240
|
-
lines: ["What to sync, where to store it, and when to sync."],
|
|
552
|
+
lines: state.recovery ?? ["What to sync, where to store it, and when to sync."],
|
|
241
553
|
items: [
|
|
242
|
-
{ id: "add", label: "Add sync setup", action: "add" },
|
|
554
|
+
...state.recovery ? [] : [{ id: "add", label: "Add sync setup", action: "add" }],
|
|
243
555
|
...names.map((name, index) => {
|
|
244
556
|
const id = `setup:${index}`;
|
|
245
557
|
nameById.set(id, name);
|
|
@@ -259,14 +571,14 @@ async function showSyncSetups(ctx, actions, signal) {
|
|
|
259
571
|
title: state.selected ? `Sync setup \u201C${safeTerminalText(state.selected.name)}\u201D` : "Sync setup",
|
|
260
572
|
lines: state.selected?.detail ?? ["This sync setup no longer exists."],
|
|
261
573
|
items: state.selected ? [
|
|
262
|
-
|
|
574
|
+
...state.recovery || state.selected.name === state.active || !state.selected.valid ? [] : [
|
|
263
575
|
{
|
|
264
576
|
id: "make-current",
|
|
265
577
|
label: "Make current\u2026",
|
|
266
578
|
action: "make-current"
|
|
267
579
|
}
|
|
268
580
|
],
|
|
269
|
-
{ id: "edit", label: "Edit storage location\u2026", action: "edit" },
|
|
581
|
+
...state.recovery ? [] : [{ id: "edit", label: "Edit storage location\u2026", action: "edit" }],
|
|
270
582
|
...state.selected.removeUnavailable ? [] : [
|
|
271
583
|
{
|
|
272
584
|
id: "remove",
|
|
@@ -280,7 +592,8 @@ async function showSyncSetups(ctx, actions, signal) {
|
|
|
280
592
|
})
|
|
281
593
|
},
|
|
282
594
|
actions: {
|
|
283
|
-
add: async () => {
|
|
595
|
+
add: async ({ state }) => {
|
|
596
|
+
if (state.recovery) return { kind: "rejected" };
|
|
284
597
|
try {
|
|
285
598
|
await actions.add(signal);
|
|
286
599
|
} catch (error) {
|
|
@@ -294,8 +607,8 @@ async function showSyncSetups(ctx, actions, signal) {
|
|
|
294
607
|
selectedName = nameById.get(itemId);
|
|
295
608
|
return selectedName ? { kind: "to", screen: "detail" } : { kind: "rejected" };
|
|
296
609
|
},
|
|
297
|
-
"make-current": async () => {
|
|
298
|
-
if (!selectedName) return { kind: "rejected" };
|
|
610
|
+
"make-current": async ({ state }) => {
|
|
611
|
+
if (!selectedName || state.recovery || !state.selected?.valid) return { kind: "rejected" };
|
|
299
612
|
try {
|
|
300
613
|
exit = await actions.makeCurrent(selectedName, signal) === "exit";
|
|
301
614
|
return exit ? { kind: "close" } : { kind: "stay" };
|
|
@@ -304,8 +617,8 @@ async function showSyncSetups(ctx, actions, signal) {
|
|
|
304
617
|
return { kind: "stay" };
|
|
305
618
|
}
|
|
306
619
|
},
|
|
307
|
-
edit: async () => {
|
|
308
|
-
if (!selectedName) return { kind: "rejected" };
|
|
620
|
+
edit: async ({ state }) => {
|
|
621
|
+
if (!selectedName || state.recovery) return { kind: "rejected" };
|
|
309
622
|
try {
|
|
310
623
|
await actions.edit(selectedName, signal);
|
|
311
624
|
} catch (error) {
|
|
@@ -313,8 +626,8 @@ async function showSyncSetups(ctx, actions, signal) {
|
|
|
313
626
|
}
|
|
314
627
|
return { kind: "stay" };
|
|
315
628
|
},
|
|
316
|
-
remove: async () => {
|
|
317
|
-
if (!selectedName) return { kind: "rejected" };
|
|
629
|
+
remove: async ({ state }) => {
|
|
630
|
+
if (!selectedName || !state.selected || state.selected.removeUnavailable) return { kind: "rejected" };
|
|
318
631
|
const name = selectedName;
|
|
319
632
|
try {
|
|
320
633
|
await actions.remove(name, signal);
|
|
@@ -339,31 +652,33 @@ async function showSyncSetups(ctx, actions, signal) {
|
|
|
339
652
|
return exit ? "exit" : void 0;
|
|
340
653
|
}
|
|
341
654
|
async function loadSetupMenuState(selectedName, signal) {
|
|
342
|
-
const
|
|
655
|
+
const catalog = await loadSettingsCatalog();
|
|
343
656
|
throwIfAborted(signal);
|
|
344
|
-
|
|
345
|
-
const
|
|
346
|
-
|
|
657
|
+
if (!catalog) return { setups: {} };
|
|
658
|
+
const { syncSetups: setups, activeSyncSetup: active } = catalog.settings;
|
|
659
|
+
const recovery = catalog.ignoreSetups.length ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(catalog.path)] : void 0;
|
|
660
|
+
if (!selectedName || !Object.hasOwn(setups, selectedName)) return { setups, active, recovery };
|
|
347
661
|
const setupCount = Object.keys(setups).length;
|
|
348
662
|
const isCurrent = selectedName === active;
|
|
349
663
|
let detail;
|
|
350
664
|
let valid = true;
|
|
351
665
|
try {
|
|
352
|
-
const config =
|
|
353
|
-
throwIfAborted(signal);
|
|
666
|
+
const config = configFromSettings(catalog.settings, selectedName);
|
|
354
667
|
const selection = syncIncludeSelection(config.include);
|
|
355
668
|
detail = [
|
|
356
669
|
`Status: ${isCurrent ? "Current" : "Not current"}`,
|
|
357
670
|
`Storage connection: ${safeTerminalText(config.connectionName)}`,
|
|
358
671
|
`Endpoint: ${storageEndpoint(config)}`,
|
|
359
672
|
`Storage location: ${storageLocation(config)}`,
|
|
360
|
-
`Included content: ${selection.builtIns.length} built-in groups \xB7 ${selection.custom.length} extra paths`,
|
|
361
|
-
`Sessions: ${
|
|
673
|
+
config.pathPolicy === "ignore-file" ? `Sync scope: Pi agent directory \xB7 ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}` : config.scope ? `Sync scope: Pi agent directory \xB7 ${config.exclude?.length ?? 0} exclusions \xB7 ${config.reinclude?.length ?? 0} exceptions` : `Included content: ${selection.builtIns.length} built-in groups \xB7 ${selection.custom.length} extra paths`,
|
|
674
|
+
`Sessions: ${syncSessionsSelected(config) ? "On \u2014 privacy-sensitive" : "Off"}`,
|
|
362
675
|
`Automatic sync: ${config.automatic ? "On" : "Off"}`,
|
|
363
676
|
`Automatic transfer at startup: ${config.automaticTransfer ? "On \u2014 may upload, replace, or delete selected files; no reload" : "Off"}`,
|
|
364
677
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
365
678
|
`Continuous sync: ${config.continuous ? config.agentMode ? "On (recurring requests and transfers)" : "Saved On; paused until Autonomous sync is enabled" : "Off"}`,
|
|
366
|
-
|
|
679
|
+
...recovery ? [] : [
|
|
680
|
+
isCurrent ? "Edit included content and automatic sync in /sync \u2192 Settings." : "To edit included content or automatic sync, make this setup current, then open /sync \u2192 Settings."
|
|
681
|
+
]
|
|
367
682
|
];
|
|
368
683
|
} catch (error) {
|
|
369
684
|
valid = false;
|
|
@@ -373,11 +688,19 @@ async function loadSetupMenuState(selectedName, signal) {
|
|
|
373
688
|
"Make current and sync are unavailable until this setup is repaired."
|
|
374
689
|
];
|
|
375
690
|
}
|
|
376
|
-
const
|
|
377
|
-
|
|
691
|
+
const removeNeedsSwitch = isCurrent && setupCount > 1;
|
|
692
|
+
const ignoreSetupsRemain = catalog.ignoreSetups.some((name) => name !== selectedName);
|
|
693
|
+
const removeUnavailable = removeNeedsSwitch || ignoreSetupsRemain;
|
|
694
|
+
if (recovery) {
|
|
695
|
+
if (removeUnavailable) detail.unshift("Remove unavailable here; use manual recovery.");
|
|
696
|
+
detail.unshift(...recovery);
|
|
697
|
+
} else if (removeNeedsSwitch) {
|
|
698
|
+
detail.push("Remove unavailable: switch to another setup first.");
|
|
699
|
+
}
|
|
378
700
|
return {
|
|
379
701
|
setups,
|
|
380
702
|
active,
|
|
703
|
+
recovery,
|
|
381
704
|
selected: { name: selectedName, detail, valid, removeUnavailable }
|
|
382
705
|
};
|
|
383
706
|
}
|
|
@@ -430,8 +753,11 @@ var MAIN_MENU_ACTIONS = [
|
|
|
430
753
|
async function describeManagerState(signal, attention, inspectOperation = inspectOperationAvailability, observation) {
|
|
431
754
|
let raw;
|
|
432
755
|
try {
|
|
433
|
-
|
|
756
|
+
const document = await readActiveLocalConfigDocumentForRepair();
|
|
757
|
+
signal?.throwIfAborted();
|
|
758
|
+
if (document) raw = validateSettingsDocument(document.parsed);
|
|
434
759
|
} catch (error) {
|
|
760
|
+
if (signal?.aborted) throw error;
|
|
435
761
|
return {
|
|
436
762
|
title: [
|
|
437
763
|
"Manage sync",
|
|
@@ -451,8 +777,8 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
|
|
|
451
777
|
actions: ["Set up sync", "Help"]
|
|
452
778
|
};
|
|
453
779
|
}
|
|
454
|
-
const configuredTargets =
|
|
455
|
-
if (
|
|
780
|
+
const configuredTargets = raw.syncSetups;
|
|
781
|
+
if (Object.keys(configuredTargets).length === 0) {
|
|
456
782
|
return {
|
|
457
783
|
title: [
|
|
458
784
|
"Manage sync",
|
|
@@ -466,6 +792,21 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
|
|
|
466
792
|
};
|
|
467
793
|
}
|
|
468
794
|
try {
|
|
795
|
+
const settingsConfig = configFromSettings(raw);
|
|
796
|
+
if (settingsConfig.reservedIgnoreNames !== void 0) {
|
|
797
|
+
return {
|
|
798
|
+
title: [
|
|
799
|
+
"Manage sync",
|
|
800
|
+
`Current sync setup: ${safeTerminalText(settingsConfig.setupName)}`,
|
|
801
|
+
"Transfers are unavailable while ignore-file setups are configured."
|
|
802
|
+
].join("\n"),
|
|
803
|
+
actions: ["Settings", "Sync setups\u2026", "Storage connections\u2026", "Help"],
|
|
804
|
+
settingsReview: {
|
|
805
|
+
setupName: settingsConfig.setupName,
|
|
806
|
+
fingerprint: syncCheckConfigFingerprint(settingsConfig)
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
}
|
|
469
810
|
const config = await loadConfig();
|
|
470
811
|
const operation = await inspectOperation();
|
|
471
812
|
const changesBlocked = operationBlocksChanges(operation);
|
|
@@ -481,10 +822,11 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
|
|
|
481
822
|
}
|
|
482
823
|
const attentionComparison = currentAttention ? compareSyncInclude(currentAttention.decision.localInclude, currentAttention.decision.remoteInclude) : void 0;
|
|
483
824
|
const attentionExclusionsDiffer = currentAttention ? !sameSyncExclude(currentAttention.decision.localExclude, currentAttention.decision.remoteExclude) : false;
|
|
484
|
-
const
|
|
825
|
+
const attentionDirectoryPolicy = currentAttention?.decision.localDirectory || currentAttention?.decision.remoteDirectory;
|
|
826
|
+
const noSyncedContent = !syncSelectionHasContent(config);
|
|
485
827
|
const syncState = changesBlocked ? void 0 : await readStateForConfig(config).catch(() => void 0);
|
|
486
828
|
const currentObservation = observation && observationMatchesConfig(observation, config) && syncState && syncStateFingerprint(syncState) === observation.inspection.stateIdentity ? observation : void 0;
|
|
487
|
-
const lastAppliedSnapshot = changesBlocked ? "Unavailable while operations are locked" : syncState?.lastAppliedSnapshot ? `${
|
|
829
|
+
const lastAppliedSnapshot = changesBlocked ? "Unavailable while operations are locked" : syncState?.lastAppliedSnapshot ? `${truncateToWidth2(safeTerminalText(syncState.lastAppliedSnapshot), 12, "\u2026")} \xB7 application time unavailable` : syncState ? "Never synced" : "Unavailable";
|
|
488
830
|
const canSwitch = await countValidSyncSetups(configuredTargets, signal) > 1;
|
|
489
831
|
const mainActions = [...MAIN_MENU_ACTIONS];
|
|
490
832
|
if (config.agentMode && !noSyncedContent) mainActions.splice(1, 0, "Retry refused model result\u2026");
|
|
@@ -496,10 +838,11 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
|
|
|
496
838
|
"Manage sync",
|
|
497
839
|
`Current sync setup: ${safeTerminalText(config.setupName)}`,
|
|
498
840
|
`Storage: ${backendStorageDescription(config)}`,
|
|
841
|
+
...config.scope ? ["Sync scope: Pi agent directory, with exclusions"] : [],
|
|
499
842
|
...syncState?.unresolved?.length ? [`Unresolved: ${syncState.unresolved.length} dependency groups \xB7 review needed`] : [],
|
|
500
843
|
...currentAttention ? [
|
|
501
844
|
currentAttention.decision.setupName === config.setupName ? "Sync status: Review needed" : `Sync status: Review needed for setup ${safeTerminalText(currentAttention.decision.setupName)}`,
|
|
502
|
-
attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0 ? attentionExclusionsDiffer ? "Synced-content exclusion rules differ." : "Only the synced-content order differs." : `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} \xB7 Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " \xB7 Exclusion rules differ." : ""}`
|
|
845
|
+
attentionDirectoryPolicy ? "Sync scopes or directory rules differ." : attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0 ? attentionExclusionsDiffer ? "Synced-content exclusion rules differ." : "Only the synced-content order differs." : `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} \xB7 Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " \xB7 Exclusion rules differ." : ""}`
|
|
503
846
|
] : currentObservation ? [`Observed ${safeTerminalText(currentObservation.checkedAt)}: ${observationSummary(currentObservation)}`] : ["Remote status: Not checked"],
|
|
504
847
|
`Last applied: ${lastAppliedSnapshot}`,
|
|
505
848
|
...config.agentMode ? ["Auto-apply: On \xB7 AI requests may incur costs"] : config.automaticTransfer || config.automatic && syncSessionsSelected(config) ? ["Automatic transfer permission: On \xB7 see Settings"] : [],
|
|
@@ -539,8 +882,8 @@ async function backgroundSummary(config) {
|
|
|
539
882
|
if (!config.continuous) return [];
|
|
540
883
|
if (!config.agentMode) return ["Background sync: Paused \xB7 enable Autonomous sync"];
|
|
541
884
|
try {
|
|
542
|
-
const { continuousBinding, readContinuousPrivateDocument } = await import("./continuous-storage-
|
|
543
|
-
const recordApi = await import("./continuous-record-
|
|
885
|
+
const { continuousBinding, readContinuousPrivateDocument } = await import("./continuous-storage-3EU6I7Z3.ts");
|
|
886
|
+
const recordApi = await import("./continuous-record-3SKJ6I3V.ts");
|
|
544
887
|
const binding = await continuousBinding(config);
|
|
545
888
|
const document = await readContinuousPrivateDocument(`${binding}.json`);
|
|
546
889
|
if (!document) return ["Background sync: Enabled \xB7 not yet observed"];
|
|
@@ -575,7 +918,7 @@ function operationStatusLines(operation) {
|
|
|
575
918
|
case "free":
|
|
576
919
|
return [];
|
|
577
920
|
case "live": {
|
|
578
|
-
const command =
|
|
921
|
+
const command = truncateToWidth2(safeTerminalText(operation.lock.command), 16, "\u2026");
|
|
579
922
|
return [
|
|
580
923
|
`Running: ${command} (pid ${operation.lock.pid}). Wait, then refresh; Transfer actions and Settings return.`
|
|
581
924
|
];
|
|
@@ -611,7 +954,7 @@ function backendStorageDescription(config) {
|
|
|
611
954
|
}
|
|
612
955
|
|
|
613
956
|
// src/ui/settings-ui.ts
|
|
614
|
-
import { defineMenu as
|
|
957
|
+
import { defineMenu as defineMenu4, runMenu as runMenu4 } from "@narumitw/pi-tui-kit";
|
|
615
958
|
|
|
616
959
|
// src/sync/local-fields.ts
|
|
617
960
|
import {
|
|
@@ -621,7 +964,7 @@ import {
|
|
|
621
964
|
sameLocalFields,
|
|
622
965
|
validatePortableSnapshot,
|
|
623
966
|
validateSnapshotFieldPolicy
|
|
624
|
-
} from "
|
|
967
|
+
} from "#pi-sync-daemon/engine/sync/local-fields";
|
|
625
968
|
|
|
626
969
|
// src/ui/agent-mode-setting.ts
|
|
627
970
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -647,7 +990,12 @@ async function saveAgentMode(ctx, setupName, enabled, signal, preference = "agen
|
|
|
647
990
|
`Storage path: ${safeTerminalText(setup.storage.path)}`,
|
|
648
991
|
...setup.storage.bucket ? [`Bucket: ${safeTerminalText(String(setup.storage.bucket))}`] : [],
|
|
649
992
|
...setup.storage.branch ? [`Branch: ${safeTerminalText(String(setup.storage.branch))}`] : [],
|
|
650
|
-
|
|
993
|
+
...setup.sync.scope ? [
|
|
994
|
+
"Sync scope: all eligible files in the Pi agent directory.",
|
|
995
|
+
directorySessionOptInLine(setup.sync.sessions),
|
|
996
|
+
`Excluded paths: ${setup.sync.exclude?.map(safeTerminalText).join(", ") || "none"}`,
|
|
997
|
+
`Re-included paths: ${setup.sync.reinclude?.map(safeTerminalText).join(", ") || "none"}`
|
|
998
|
+
] : [`Included paths: ${setup.sync.include.map(safeTerminalText).join(", ")}`],
|
|
651
999
|
continuous ? CONTINUOUS_DESCRIPTION : AGENT_MODE_DESCRIPTION,
|
|
652
1000
|
...continuous ? [
|
|
653
1001
|
"Upgrade all Pi processes sharing this agent directory before enabling Continuous sync. Monitoring starts after the /sync command or manager closes. An elected idle local session uses its selected Pi model; another session can use a different provider/model. Each computer is a separate replica.",
|
|
@@ -683,105 +1031,6 @@ async function saveAgentMode(ctx, setupName, enabled, signal, preference = "agen
|
|
|
683
1031
|
return true;
|
|
684
1032
|
}
|
|
685
1033
|
|
|
686
|
-
// src/ui/excluded-paths-ui.ts
|
|
687
|
-
import { defineMenu as defineMenu2, runMenu as runMenu2 } from "@narumitw/pi-tui-kit";
|
|
688
|
-
async function showExcludedPaths(ctx, setupName, signal) {
|
|
689
|
-
const validate = captureMutationOwner(ctx, signal);
|
|
690
|
-
const isCurrent = () => {
|
|
691
|
-
try {
|
|
692
|
-
validate();
|
|
693
|
-
return true;
|
|
694
|
-
} catch {
|
|
695
|
-
return false;
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
validate();
|
|
699
|
-
const config = await loadConfig(setupName);
|
|
700
|
-
validate();
|
|
701
|
-
if (ctx.mode !== "tui") {
|
|
702
|
-
if (ctx.hasUI)
|
|
703
|
-
ctx.ui.notify(
|
|
704
|
-
[
|
|
705
|
-
`Excluded paths: ${(config.exclude ?? []).map(safeTerminalText).join(", ") || "none"}`,
|
|
706
|
-
`Edit sync.exclude in ${safeTerminalText(localConfigPath())}; an explicit array requires settings version 6.`
|
|
707
|
-
].join("\n"),
|
|
708
|
-
"info"
|
|
709
|
-
);
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
let draft = JSON.stringify(config.exclude ?? []);
|
|
713
|
-
while (isCurrent()) {
|
|
714
|
-
const entered = await ctx.ui.input("Excluded paths \xB7 JSON array \xB7 empty input keeps draft", draft, { signal });
|
|
715
|
-
if (!isCurrent() || entered === void 0) return;
|
|
716
|
-
const input = entered || draft;
|
|
717
|
-
draft = input;
|
|
718
|
-
let exclude;
|
|
719
|
-
try {
|
|
720
|
-
const parsed = JSON.parse(input);
|
|
721
|
-
if (!Array.isArray(parsed)) throw new Error("Enter a JSON string array.");
|
|
722
|
-
exclude = normalizeSyncExclude(parsed);
|
|
723
|
-
} catch {
|
|
724
|
-
ctx.ui.notify("Invalid exclude array or unsupported pattern. No settings changed.", "error");
|
|
725
|
-
continue;
|
|
726
|
-
}
|
|
727
|
-
if (sameSyncExclude(exclude, config.exclude)) return;
|
|
728
|
-
let choice;
|
|
729
|
-
const menu = defineMenu2({
|
|
730
|
-
start: "review",
|
|
731
|
-
screens: {
|
|
732
|
-
review: () => ({
|
|
733
|
-
kind: "actions",
|
|
734
|
-
title: "Review excluded paths",
|
|
735
|
-
lines: [
|
|
736
|
-
`Setup: ${safeTerminalText(config.setupName)}`,
|
|
737
|
-
"Draft only. Save opts into settings version 6 / snapshot version 4; older clients must refuse them.",
|
|
738
|
-
"Excluded local files stay untouched. New snapshots omit matching remote files; old history is NOT erased.",
|
|
739
|
-
"Removing rules can expose local content or allow pull to replace it. Review a force push to publish policy changes.",
|
|
740
|
-
"Previously excluded:",
|
|
741
|
-
...config.exclude?.length ? config.exclude.map((rule) => `- ${safeTerminalText(rule)}`) : ["(none)"],
|
|
742
|
-
"Proposed excluded paths:",
|
|
743
|
-
...exclude.length ? exclude.map((rule) => `+ ${safeTerminalText(rule)}`) : ["(none)"]
|
|
744
|
-
],
|
|
745
|
-
items: [
|
|
746
|
-
{ id: "save", label: "Save changes", action: "choose" },
|
|
747
|
-
{ id: "discard", label: "Discard changes", action: "choose" },
|
|
748
|
-
{ id: "edit", label: "Continue editing", action: "choose" }
|
|
749
|
-
],
|
|
750
|
-
hint: "close"
|
|
751
|
-
})
|
|
752
|
-
},
|
|
753
|
-
actions: {
|
|
754
|
-
choose: async ({ itemId }) => {
|
|
755
|
-
choice = itemId === "save" ? "save" : itemId === "edit" ? "edit" : "discard";
|
|
756
|
-
return { kind: "close" };
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
await runMenu2(ctx, menu, { getState: () => void 0, signal, isCurrent });
|
|
761
|
-
if (!isCurrent()) return;
|
|
762
|
-
if (choice === "edit") continue;
|
|
763
|
-
if (choice !== "save") return;
|
|
764
|
-
try {
|
|
765
|
-
await updateSyncSetup(
|
|
766
|
-
setupName,
|
|
767
|
-
(setup) => {
|
|
768
|
-
validate();
|
|
769
|
-
return { ...setup, sync: { ...setup.sync, exclude } };
|
|
770
|
-
},
|
|
771
|
-
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), upgradeExclude: true, signal }
|
|
772
|
-
);
|
|
773
|
-
if (isCurrent()) ctx.ui.notify("Excluded paths saved. Applies to subsequent sync; no transfer started.", "info");
|
|
774
|
-
} catch (error) {
|
|
775
|
-
if (isCurrent())
|
|
776
|
-
ctx.ui.notify(
|
|
777
|
-
`Excluded paths not saved: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
|
|
778
|
-
"error"
|
|
779
|
-
);
|
|
780
|
-
}
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
|
|
785
1034
|
// src/ui/settings-frame.ts
|
|
786
1035
|
import { stripVTControlCharacters } from "node:util";
|
|
787
1036
|
function boundedSettingsUI(ctx) {
|
|
@@ -828,11 +1077,11 @@ function boundedSettingsUI(ctx) {
|
|
|
828
1077
|
|
|
829
1078
|
// src/ui/storage-connections-ui.ts
|
|
830
1079
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
831
|
-
import { defineMenu as
|
|
1080
|
+
import { defineMenu as defineMenu2, runMenu as runMenu2 } from "@narumitw/pi-tui-kit";
|
|
832
1081
|
async function showStorageConnections(ctx, signal) {
|
|
833
1082
|
let selectedName;
|
|
834
1083
|
const nameById = /* @__PURE__ */ new Map();
|
|
835
|
-
const menu =
|
|
1084
|
+
const menu = defineMenu2({
|
|
836
1085
|
start: "list",
|
|
837
1086
|
screens: {
|
|
838
1087
|
list: ({ state }) => {
|
|
@@ -841,9 +1090,9 @@ async function showStorageConnections(ctx, signal) {
|
|
|
841
1090
|
return {
|
|
842
1091
|
kind: "actions",
|
|
843
1092
|
title: "Storage connections",
|
|
844
|
-
lines: state.supportedVersion ? ["Server addresses and sign-in details, reusable across sync setups."] : ["Create supported pi-sync settings before managing storage connections."],
|
|
1093
|
+
lines: state.supportedVersion ? state.recovery ?? ["Server addresses and sign-in details, reusable across sync setups."] : ["Create supported pi-sync settings before managing storage connections."],
|
|
845
1094
|
items: state.supportedVersion ? [
|
|
846
|
-
{ id: "add", label: "Add storage connection", action: "add" },
|
|
1095
|
+
...state.recovery ? [] : [{ id: "add", label: "Add storage connection", action: "add" }],
|
|
847
1096
|
...names.map((name, index) => {
|
|
848
1097
|
const id = `connection:${index}`;
|
|
849
1098
|
nameById.set(id, name);
|
|
@@ -863,8 +1112,8 @@ async function showStorageConnections(ctx, signal) {
|
|
|
863
1112
|
title: state.selected ? `Storage connection \u201C${safeTerminalText(state.selected.name)}\u201D` : "Storage connection",
|
|
864
1113
|
lines: state.selected?.lines ?? ["This storage connection no longer exists."],
|
|
865
1114
|
items: state.selected ? [
|
|
866
|
-
{ id: "edit", label: "Edit storage connection\u2026", action: "edit" },
|
|
867
|
-
|
|
1115
|
+
...state.recovery ? [] : [{ id: "edit", label: "Edit storage connection\u2026", action: "edit" }],
|
|
1116
|
+
...!state.recovery && state.selected.usedBy.length === 0 ? [
|
|
868
1117
|
{
|
|
869
1118
|
id: "remove",
|
|
870
1119
|
label: "Remove storage connection\u2026",
|
|
@@ -877,7 +1126,8 @@ async function showStorageConnections(ctx, signal) {
|
|
|
877
1126
|
})
|
|
878
1127
|
},
|
|
879
1128
|
actions: {
|
|
880
|
-
add: async () => {
|
|
1129
|
+
add: async ({ state }) => {
|
|
1130
|
+
if (state.recovery) return { kind: "rejected" };
|
|
881
1131
|
try {
|
|
882
1132
|
await showAddStorageConnection(ctx, signal);
|
|
883
1133
|
} catch (error) {
|
|
@@ -892,7 +1142,7 @@ async function showStorageConnections(ctx, signal) {
|
|
|
892
1142
|
return selectedName ? { kind: "to", screen: "detail" } : { kind: "rejected" };
|
|
893
1143
|
},
|
|
894
1144
|
edit: async ({ state }) => {
|
|
895
|
-
if (!state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
1145
|
+
if (state.recovery || !state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
896
1146
|
try {
|
|
897
1147
|
await editStorageConnection(ctx, state.selected.name, state.selected.profile, state.selected.usedBy, signal);
|
|
898
1148
|
} catch (error) {
|
|
@@ -901,7 +1151,7 @@ async function showStorageConnections(ctx, signal) {
|
|
|
901
1151
|
return { kind: "stay" };
|
|
902
1152
|
},
|
|
903
1153
|
remove: async ({ state }) => {
|
|
904
|
-
if (!state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
1154
|
+
if (state.recovery || !state.selected || state.selected.name !== selectedName) return { kind: "rejected" };
|
|
905
1155
|
const name = state.selected.name;
|
|
906
1156
|
const confirmed = await ctx.ui.confirm(
|
|
907
1157
|
"Remove storage connection?",
|
|
@@ -925,38 +1175,43 @@ async function showStorageConnections(ctx, signal) {
|
|
|
925
1175
|
}
|
|
926
1176
|
}
|
|
927
1177
|
});
|
|
928
|
-
await
|
|
1178
|
+
await runMenu2(ctx, menu, {
|
|
929
1179
|
getState: () => loadStorageMenuState(selectedName, signal),
|
|
930
1180
|
signal,
|
|
931
1181
|
isCurrent: () => !signal?.aborted
|
|
932
1182
|
});
|
|
933
1183
|
}
|
|
934
1184
|
async function loadStorageMenuState(selectedName, signal) {
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
const
|
|
1185
|
+
const catalog = await loadSettingsCatalog();
|
|
1186
|
+
signal?.throwIfAborted();
|
|
1187
|
+
const raw = catalog?.settings;
|
|
1188
|
+
const profiles = raw?.storageConnections ?? {};
|
|
1189
|
+
const recovery = catalog?.ignoreSetups.length ? ["Connection changes are unavailable while any setup uses an ignore file.", ...ignoreSetupRecovery(catalog.path)] : void 0;
|
|
938
1190
|
const profile = selectedName ? ownRecord(profiles[selectedName]) : void 0;
|
|
939
1191
|
if (!selectedName || !profile) {
|
|
940
1192
|
return {
|
|
941
|
-
supportedVersion: raw
|
|
1193
|
+
supportedVersion: raw !== void 0,
|
|
942
1194
|
profiles,
|
|
1195
|
+
recovery,
|
|
943
1196
|
selected: void 0
|
|
944
1197
|
};
|
|
945
1198
|
}
|
|
946
1199
|
const usedBy = referencingSetups(raw, selectedName);
|
|
947
1200
|
return {
|
|
948
|
-
supportedVersion: raw
|
|
1201
|
+
supportedVersion: raw !== void 0,
|
|
949
1202
|
profiles,
|
|
1203
|
+
recovery,
|
|
950
1204
|
selected: {
|
|
951
1205
|
name: selectedName,
|
|
952
1206
|
profile,
|
|
953
1207
|
usedBy,
|
|
954
1208
|
lines: [
|
|
1209
|
+
...recovery ?? [],
|
|
955
1210
|
`Type: ${connectionType(profile)}`,
|
|
956
1211
|
`Endpoint: ${connectionEndpoint(profile)}`,
|
|
957
1212
|
`Credentials: ${credentialSource(profile)}`,
|
|
958
1213
|
`Used by: ${usedBy.length > 0 ? usedBy.map(safeTerminalText).join(", ") : "No sync setups"}`,
|
|
959
|
-
|
|
1214
|
+
...!recovery && usedBy.length > 0 ? [
|
|
960
1215
|
"Remove unavailable: remove the listed sync setups first. Switch away from a current setup before removing it if other setups remain."
|
|
961
1216
|
] : []
|
|
962
1217
|
]
|
|
@@ -1141,12 +1396,12 @@ function credentialSource(profile) {
|
|
|
1141
1396
|
}
|
|
1142
1397
|
|
|
1143
1398
|
// src/ui/setup/setup-switcher.ts
|
|
1144
|
-
import { defineMenu as
|
|
1399
|
+
import { defineMenu as defineMenu3, runMenu as runMenu3 } from "@narumitw/pi-tui-kit";
|
|
1145
1400
|
async function selectSetupForSwitch(ctx, raw, targets, active, signal) {
|
|
1146
1401
|
let selectedName;
|
|
1147
1402
|
const nameById = /* @__PURE__ */ new Map();
|
|
1148
1403
|
const profiles = ownRecord(raw.storageConnections);
|
|
1149
|
-
const menu =
|
|
1404
|
+
const menu = defineMenu3({
|
|
1150
1405
|
start: "setups",
|
|
1151
1406
|
screens: {
|
|
1152
1407
|
setups: () => ({
|
|
@@ -1178,7 +1433,7 @@ async function selectSetupForSwitch(ctx, raw, targets, active, signal) {
|
|
|
1178
1433
|
}
|
|
1179
1434
|
}
|
|
1180
1435
|
});
|
|
1181
|
-
await
|
|
1436
|
+
await runMenu3(ctx, menu, {
|
|
1182
1437
|
getState: () => void 0,
|
|
1183
1438
|
signal,
|
|
1184
1439
|
isCurrent: () => !signal?.aborted
|
|
@@ -1188,7 +1443,7 @@ async function selectSetupForSwitch(ctx, raw, targets, active, signal) {
|
|
|
1188
1443
|
async function showSetupSwitcher(ctx, runRoute, selectedName, signal) {
|
|
1189
1444
|
const raw = await readLocalConfigObject();
|
|
1190
1445
|
if (signal?.aborted) return false;
|
|
1191
|
-
if (raw
|
|
1446
|
+
if (!raw) {
|
|
1192
1447
|
ctx.ui.notify("Add a second sync setup before switching setups.", "info");
|
|
1193
1448
|
return false;
|
|
1194
1449
|
}
|
|
@@ -1231,7 +1486,7 @@ async function showSetupSwitcher(ctx, runRoute, selectedName, signal) {
|
|
|
1231
1486
|
`From: ${safeTerminalText(active ?? "none")}`,
|
|
1232
1487
|
`To: ${safeTerminalText(name)}`,
|
|
1233
1488
|
`Storage: ${backendStorageDescription(config)}`,
|
|
1234
|
-
`Included content: ${config.include.length} paths`,
|
|
1489
|
+
config.scope === "agent-directory" ? `Scope: Pi agent directory \xB7 ${config.exclude?.length ?? 0} excluded and ${config.reinclude?.length ?? 0} re-included rules` : `Included content: ${config.include.length} paths`,
|
|
1235
1490
|
`Automatic sync: ${automaticSyncSummary(config.automatic)} \xB7 Sessions: ${syncSessionsSelected(config) ? "On" : "Off"}`,
|
|
1236
1491
|
`Automatic transfer at startup: ${config.automaticTransfer ? "On \u2014 may upload, replace, or delete selected files; no reload" : "Off"}`,
|
|
1237
1492
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
@@ -1310,10 +1565,6 @@ async function showAddTarget(ctx, signal) {
|
|
|
1310
1565
|
let raw = await readLocalConfigObject();
|
|
1311
1566
|
if (signal?.aborted) return;
|
|
1312
1567
|
if (!raw) return void ctx.ui.notify("Set up the first sync setup before adding another.", "info");
|
|
1313
|
-
if (raw.version !== 3 && raw.version !== 4 && raw.version !== 5 && raw.version !== 6) {
|
|
1314
|
-
ctx.ui.notify("Version 1 and version 2 settings are unsupported and are never migrated.", "error");
|
|
1315
|
-
return;
|
|
1316
|
-
}
|
|
1317
1568
|
let profiles = ownRecord(raw.storageConnections) ?? {};
|
|
1318
1569
|
const name = await promptResourceName(ctx, "sync setup", "work", signal);
|
|
1319
1570
|
if (!name) return;
|
|
@@ -1391,42 +1642,68 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1391
1642
|
disposition = "exit";
|
|
1392
1643
|
return { kind: "close" };
|
|
1393
1644
|
};
|
|
1394
|
-
if (ctx.mode !== "tui")
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1645
|
+
if (!ctx.hasUI || signal?.aborted || ctx.mode !== "tui" && ctx.mode !== "rpc") return disposition;
|
|
1646
|
+
const validateSettingsOwner = captureMutationOwner(ctx, signal);
|
|
1647
|
+
const isCurrent = () => {
|
|
1648
|
+
try {
|
|
1649
|
+
validateSettingsOwner();
|
|
1650
|
+
return true;
|
|
1651
|
+
} catch {
|
|
1652
|
+
return false;
|
|
1653
|
+
}
|
|
1654
|
+
};
|
|
1655
|
+
if (ctx.mode === "rpc") {
|
|
1656
|
+
const document = await readActiveLocalConfigDocumentForRepair().catch(() => null);
|
|
1657
|
+
if (!isCurrent()) return disposition;
|
|
1658
|
+
const settingsPath = document?.path ?? localConfigPath();
|
|
1659
|
+
let config;
|
|
1660
|
+
try {
|
|
1661
|
+
if (document) config = configFromSettings(validateSettingsDocument(document.parsed), reviewedSetup);
|
|
1662
|
+
} catch {
|
|
1663
|
+
config = void 0;
|
|
1664
|
+
}
|
|
1665
|
+
ctx.ui.notify(
|
|
1666
|
+
[
|
|
1667
|
+
document === null ? "Could not read the active pi-sync settings file. Check file access or repair the JSON before reopening /sync." : `Edit pi-sync settings manually: ${safeTerminalText(settingsPath)}`,
|
|
1668
|
+
...config?.reservedIgnoreNames !== void 0 ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(settingsPath)] : [],
|
|
1669
|
+
...config?.pathPolicy === "ignore-file" ? [manualIgnoreFileGuidance(config.ignoreFile ?? ".syncignore")] : config?.scope === "agent-directory" ? directoryScopeSummary(config) : []
|
|
1670
|
+
].join("\n"),
|
|
1671
|
+
"info"
|
|
1672
|
+
);
|
|
1673
|
+
const management = defineMenu4({
|
|
1674
|
+
start: "management",
|
|
1675
|
+
screens: {
|
|
1676
|
+
management: () => ({
|
|
1677
|
+
kind: "actions",
|
|
1678
|
+
title: "Sync settings management",
|
|
1679
|
+
items: [
|
|
1680
|
+
{ id: "setups", label: "Manage sync setups", action: "setups" },
|
|
1681
|
+
{ id: "connections", label: "Manage storage connections", action: "connections" }
|
|
1682
|
+
],
|
|
1683
|
+
hint: "back"
|
|
1684
|
+
})
|
|
1685
|
+
},
|
|
1686
|
+
actions: {
|
|
1687
|
+
setups: async ({ signal: actionSignal }) => {
|
|
1688
|
+
const result = await showSyncSetupManager(ctx, runRoute, actionSignal);
|
|
1689
|
+
return result === "exit" ? exitSettings() : { kind: "stay" };
|
|
1409
1690
|
},
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
return result === "exit" ? exitSettings() : { kind: "stay" };
|
|
1414
|
-
},
|
|
1415
|
-
connections: async ({ signal: actionSignal }) => {
|
|
1416
|
-
await showStorageConnections(ctx, actionSignal);
|
|
1417
|
-
return { kind: "stay" };
|
|
1418
|
-
}
|
|
1691
|
+
connections: async ({ signal: actionSignal }) => {
|
|
1692
|
+
await showStorageConnections(ctx, actionSignal);
|
|
1693
|
+
return { kind: "stay" };
|
|
1419
1694
|
}
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1695
|
+
}
|
|
1696
|
+
});
|
|
1697
|
+
await runMenu4(ctx, management, { getState: () => void 0, signal, isCurrent });
|
|
1423
1698
|
return disposition;
|
|
1424
1699
|
}
|
|
1425
|
-
const initial = await
|
|
1426
|
-
if (
|
|
1700
|
+
const initial = await loadSettingsConfig(reviewedSetup);
|
|
1701
|
+
if (!isCurrent()) return disposition;
|
|
1702
|
+
const ignoreAvailable = await ignoreFileSettingsAvailable(ctx, signal);
|
|
1703
|
+
if (!isCurrent()) return disposition;
|
|
1427
1704
|
const setupName = initial.setupName;
|
|
1428
1705
|
let saveStatus = "Simple choices save immediately. Back does not undo saved changes.";
|
|
1429
|
-
const menu =
|
|
1706
|
+
const menu = defineMenu4({
|
|
1430
1707
|
start: "settings",
|
|
1431
1708
|
screens: {
|
|
1432
1709
|
settings: ({ state }) => ({
|
|
@@ -1434,30 +1711,68 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1434
1711
|
title: "Pi Sync Settings",
|
|
1435
1712
|
lines: [
|
|
1436
1713
|
`Setup: ${safeTerminalText(state.setupName)} \xB7 Connection: ${safeTerminalText(state.connectionName)}`,
|
|
1437
|
-
|
|
1714
|
+
...state.reservedIgnoreNames !== void 0 ? [
|
|
1715
|
+
"Setup preferences are read-only; adding, editing, and switching setups are unavailable.",
|
|
1716
|
+
state.pathPolicy === "ignore-file" && !ignoreAvailable ? manualIgnoreFileGuidance(state.ignoreFile ?? ".syncignore") : "Open Manage sync setups for manual recovery."
|
|
1717
|
+
] : [saveStatus]
|
|
1438
1718
|
],
|
|
1439
1719
|
items: [
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1720
|
+
...state.pathPolicy === "ignore-file" ? ignoreAvailable ? [
|
|
1721
|
+
{
|
|
1722
|
+
id: "ignoreFile",
|
|
1723
|
+
label: "Ignore file",
|
|
1724
|
+
description: "Select another existing file in the Pi agent directory. No transfer starts.",
|
|
1725
|
+
currentValue: safeTerminalText(state.ignoreFile ?? ".syncignore"),
|
|
1726
|
+
action: "ignore-switch"
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
id: "ignoreRules",
|
|
1730
|
+
label: "Edit ignore rules\u2026",
|
|
1731
|
+
description: `Edit the existing local rules, then confirm separately. Sessions: ${state.include.includes("sessions") ? "opted in (ignore rules still apply)" : "off"}.`,
|
|
1732
|
+
currentValue: "Edit",
|
|
1733
|
+
action: "ignore-edit"
|
|
1734
|
+
}
|
|
1735
|
+
] : [] : ignoreAvailable ? [
|
|
1736
|
+
{
|
|
1737
|
+
id: "migrateIgnoreFile",
|
|
1738
|
+
label: "Migrate to ignore file\u2026",
|
|
1739
|
+
description: "Review the scope change for this legacy setup. Migration does not start a transfer.",
|
|
1740
|
+
currentValue: "Review",
|
|
1741
|
+
action: "ignore-migrate"
|
|
1742
|
+
}
|
|
1743
|
+
] : state.reservedIgnoreNames !== void 0 ? [] : state.scope === "agent-directory" ? [
|
|
1744
|
+
{
|
|
1745
|
+
id: "include",
|
|
1746
|
+
label: "Agent directory scope",
|
|
1747
|
+
description: "Edit exclusions, re-inclusions, and session opt-in in one reviewed draft. No transfer starts.",
|
|
1748
|
+
currentValue: `${state.exclude?.length ?? 0} excluded \xB7 ${state.reinclude?.length ?? 0} re-included \xB7 Sessions ${state.include.includes("sessions") ? "opted in" : "off"}`,
|
|
1749
|
+
action: "include"
|
|
1750
|
+
}
|
|
1751
|
+
] : [
|
|
1752
|
+
{
|
|
1753
|
+
id: "include",
|
|
1754
|
+
label: "Included paths",
|
|
1755
|
+
description: "This setup: choose paths in a draft, then review and Save or Discard. No transfer is started.",
|
|
1756
|
+
currentValue: `${state.include.length} paths \xB7 Edit`,
|
|
1757
|
+
action: "include"
|
|
1758
|
+
},
|
|
1759
|
+
{
|
|
1760
|
+
id: "exclude",
|
|
1761
|
+
label: "Excluded paths",
|
|
1762
|
+
description: "This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
|
|
1763
|
+
currentValue: `${state.exclude?.length ?? 0} rules \xB7 Edit`,
|
|
1764
|
+
action: "exclude"
|
|
1765
|
+
}
|
|
1766
|
+
],
|
|
1767
|
+
...state.reservedIgnoreNames !== void 0 ? [] : [
|
|
1768
|
+
{
|
|
1769
|
+
id: "remoteInclude",
|
|
1770
|
+
label: ignoreAvailable || state.scope === "agent-directory" ? "Compare sync policies" : "Compare included paths",
|
|
1771
|
+
description: "Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
|
|
1772
|
+
currentValue: "Review",
|
|
1773
|
+
action: "remote-include"
|
|
1774
|
+
}
|
|
1775
|
+
],
|
|
1461
1776
|
{
|
|
1462
1777
|
id: "localFields",
|
|
1463
1778
|
label: "Machine-local fields",
|
|
@@ -1475,14 +1790,14 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1475
1790
|
{
|
|
1476
1791
|
id: "setups",
|
|
1477
1792
|
label: "Manage sync setups",
|
|
1478
|
-
description: "This device: add, switch, edit, or remove sync setups. Each edit identifies its owner before saving.",
|
|
1793
|
+
description: state.reservedIgnoreNames !== void 0 ? "Review configured setups and recovery options. Adding, editing, and switching are unavailable." : "This device: add, switch, edit, or remove sync setups. Each edit identifies its owner before saving.",
|
|
1479
1794
|
currentValue: "Open",
|
|
1480
1795
|
action: "setups"
|
|
1481
1796
|
},
|
|
1482
1797
|
{
|
|
1483
1798
|
id: "connections",
|
|
1484
1799
|
label: "Manage storage connections",
|
|
1485
|
-
description: "Shared connections on this device: review affected setups before saving server or credential changes.",
|
|
1800
|
+
description: state.reservedIgnoreNames !== void 0 ? "Review shared connections. Connection changes are unavailable while ignore-file setups are configured." : "Shared connections on this device: review affected setups before saving server or credential changes.",
|
|
1486
1801
|
currentValue: "Open",
|
|
1487
1802
|
action: "connections"
|
|
1488
1803
|
},
|
|
@@ -1537,7 +1852,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1537
1852
|
{
|
|
1538
1853
|
id: "contentPolicy",
|
|
1539
1854
|
label: "Content merge / partial progress",
|
|
1540
|
-
description:
|
|
1855
|
+
description: `This setup, opt-in: ${state.scope === "agent-directory" ? "review format compatibility" : "review the version-5 upgrade"} before saving. Merge bounded text and prefix-only sessions; partial progress keeps withheld versions and baselines. Applies to subsequent sync; disabling does not clear recovery evidence.`,
|
|
1541
1856
|
currentValue: state.mergeContent ? state.partialSync ? "Merge + partial" : "Merge only" : state.partialSync ? "Partial only" : "Off",
|
|
1542
1857
|
values: ["Off", "Merge only", "Merge + partial", "Partial only"],
|
|
1543
1858
|
action: "content-policy"
|
|
@@ -1566,7 +1881,9 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1566
1881
|
values: ["On", "Off"],
|
|
1567
1882
|
action: "debug"
|
|
1568
1883
|
}
|
|
1569
|
-
]
|
|
1884
|
+
].map(
|
|
1885
|
+
(item) => state.reservedIgnoreNames !== void 0 && !["setups", "connections", "ignoreFile", "ignoreRules", "migrateIgnoreFile"].includes(item.id) ? { ...item, disabled: true } : item
|
|
1886
|
+
)
|
|
1570
1887
|
})
|
|
1571
1888
|
},
|
|
1572
1889
|
actions: {
|
|
@@ -1595,7 +1912,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1595
1912
|
const partialSync = value === "Partial only" || value === "Merge + partial";
|
|
1596
1913
|
if (!await ctx.ui.confirm(
|
|
1597
1914
|
"Save content policy?",
|
|
1598
|
-
"This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them. Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes
|
|
1915
|
+
`${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and snapshot version 5; older clients must refuse them." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
|
|
1599
1916
|
{ signal: mutationSignal }
|
|
1600
1917
|
))
|
|
1601
1918
|
return { kind: "rejected" };
|
|
@@ -1604,11 +1921,11 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1604
1921
|
await updateLocalConfig((current) => {
|
|
1605
1922
|
validate();
|
|
1606
1923
|
const setup = current.syncSetups[setupName];
|
|
1607
|
-
if (!setup || Boolean(setup.sync.mergeContent) !== Boolean(previous.mergeContent) || Boolean(setup.sync.partialSync) !== Boolean(previous.partialSync))
|
|
1924
|
+
if (!setup || setup.sync.scope !== previous.scope || Boolean(setup.sync.mergeContent) !== Boolean(previous.mergeContent) || Boolean(setup.sync.partialSync) !== Boolean(previous.partialSync))
|
|
1608
1925
|
throw new Error("Content policy changed during review.");
|
|
1609
1926
|
return {
|
|
1610
1927
|
...current,
|
|
1611
|
-
version: current.version
|
|
1928
|
+
version: current.version >= 6 ? current.version : 5,
|
|
1612
1929
|
syncSetups: {
|
|
1613
1930
|
...current.syncSetups,
|
|
1614
1931
|
[setupName]: { ...setup, sync: { ...setup.sync, mergeContent, partialSync } }
|
|
@@ -1663,7 +1980,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1663
1980
|
if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
|
|
1664
1981
|
const confirmed = await ctx.ui.confirm(
|
|
1665
1982
|
"Save portable field policy?",
|
|
1666
|
-
"This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain
|
|
1983
|
+
`${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
|
|
1667
1984
|
{ signal: mutationSignal }
|
|
1668
1985
|
);
|
|
1669
1986
|
validate();
|
|
@@ -1672,7 +1989,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1672
1989
|
await updateLocalConfig((current) => {
|
|
1673
1990
|
validate();
|
|
1674
1991
|
const setup = current.syncSetups[setupName];
|
|
1675
|
-
if (!setup || !sameLocalFields(setup.sync.localFields, previous.localFields))
|
|
1992
|
+
if (!setup || setup.sync.scope !== previous.scope || !sameLocalFields(setup.sync.localFields, previous.localFields))
|
|
1676
1993
|
throw new Error("Field policy changed while under review; reopen settings.");
|
|
1677
1994
|
return {
|
|
1678
1995
|
...current,
|
|
@@ -1853,9 +2170,13 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1853
2170
|
await showExcludedPaths(ctx, setupName, editorSignal);
|
|
1854
2171
|
return resumeSettings(editorSignal);
|
|
1855
2172
|
},
|
|
1856
|
-
"
|
|
2173
|
+
"ignore-switch": ignoreAction("switch"),
|
|
2174
|
+
"ignore-edit": ignoreAction("edit"),
|
|
2175
|
+
"ignore-migrate": ignoreAction("migrate"),
|
|
2176
|
+
"remote-include": async ({ state, signal: actionSignal }) => {
|
|
2177
|
+
if (state.reservedIgnoreNames !== void 0) return { kind: "rejected" };
|
|
1857
2178
|
const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
1858
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
2179
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-4BTP2OJR.ts");
|
|
1859
2180
|
if (reviewSignal.aborted) return { kind: "rejected" };
|
|
1860
2181
|
const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, void 0, {
|
|
1861
2182
|
origin: "settings",
|
|
@@ -1892,20 +2213,29 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
1892
2213
|
return result;
|
|
1893
2214
|
};
|
|
1894
2215
|
}
|
|
2216
|
+
function ignoreAction(action) {
|
|
2217
|
+
return async ({ state, signal: actionSignal }) => {
|
|
2218
|
+
if (!ignoreAvailable || state.pathPolicy === "ignore-file" === (action === "migrate"))
|
|
2219
|
+
return { kind: "rejected" };
|
|
2220
|
+
const editorSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
2221
|
+
await showIgnoreFileAction(ctx, setupName, action, state.ignoreFile ?? ".syncignore", editorSignal);
|
|
2222
|
+
return resumeSettings(editorSignal);
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
1895
2225
|
async function resumeSettings(editorSignal) {
|
|
1896
|
-
if (editorSignal.aborted) return { kind: "close" };
|
|
2226
|
+
if (editorSignal.aborted || !isCurrent()) return { kind: "close" };
|
|
1897
2227
|
try {
|
|
1898
|
-
const active = await
|
|
1899
|
-
if (editorSignal.aborted || active.setupName !== setupName) return { kind: "close" };
|
|
2228
|
+
const active = await loadSettingsConfig();
|
|
2229
|
+
if (editorSignal.aborted || !isCurrent() || active.setupName !== setupName) return { kind: "close" };
|
|
1900
2230
|
return { kind: "stay" };
|
|
1901
2231
|
} catch {
|
|
1902
2232
|
return { kind: "close" };
|
|
1903
2233
|
}
|
|
1904
2234
|
}
|
|
1905
|
-
await
|
|
1906
|
-
getState: () =>
|
|
2235
|
+
await runMenu4({ ...ctx, ui: boundedSettingsUI(ctx) }, menu, {
|
|
2236
|
+
getState: () => loadSettingsConfig(setupName),
|
|
1907
2237
|
signal,
|
|
1908
|
-
isCurrent
|
|
2238
|
+
isCurrent
|
|
1909
2239
|
});
|
|
1910
2240
|
return disposition;
|
|
1911
2241
|
}
|
|
@@ -1937,7 +2267,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
|
|
|
1937
2267
|
const operationFirst = manager.operation !== void 0 && manager.operation.kind !== "free";
|
|
1938
2268
|
return operationFirst ? [...managerItems, ...attentionItems] : [...attentionItems, ...managerItems];
|
|
1939
2269
|
};
|
|
1940
|
-
const menu =
|
|
2270
|
+
const menu = defineMenu5({
|
|
1941
2271
|
start: "main",
|
|
1942
2272
|
screens: {
|
|
1943
2273
|
main: ({ state }) => ({
|
|
@@ -1970,7 +2300,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
|
|
|
1970
2300
|
if (!attention) {
|
|
1971
2301
|
const observation = state.manager.observation;
|
|
1972
2302
|
if (!observation) return { kind: "stay" };
|
|
1973
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
2303
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-4BTP2OJR.ts");
|
|
1974
2304
|
if (sessionSignal?.aborted) return { kind: "close" };
|
|
1975
2305
|
const config = await loadConfig();
|
|
1976
2306
|
if (sessionSignal?.aborted) return { kind: "close" };
|
|
@@ -2040,8 +2370,10 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
|
|
|
2040
2370
|
const result = await showSetupSwitcher(ctx, runRoute, void 0, sessionSignal);
|
|
2041
2371
|
return result === "pull-attempted" || result === "closed" ? { kind: "close" } : { kind: "stay" };
|
|
2042
2372
|
},
|
|
2043
|
-
settings: async ({ state }) => {
|
|
2044
|
-
const
|
|
2373
|
+
settings: async ({ state, signal: actionSignal }) => {
|
|
2374
|
+
const signal = sessionSignal ? AbortSignal.any([sessionSignal, actionSignal]) : actionSignal;
|
|
2375
|
+
const review = state.manager.settingsReview ?? state.manager.configReview;
|
|
2376
|
+
const result = await showSyncSettings(ctx, runRoute, signal, review?.setupName);
|
|
2045
2377
|
return { kind: result === "exit" ? "close" : "stay" };
|
|
2046
2378
|
},
|
|
2047
2379
|
pull: async ({ state }) => {
|
|
@@ -2102,7 +2434,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
|
|
|
2102
2434
|
const config = await loadConfig(state.manager.configReview?.setupName);
|
|
2103
2435
|
validate();
|
|
2104
2436
|
if (config.continuous) {
|
|
2105
|
-
const { continuousStatusLines } = await import("./continuous-record-
|
|
2437
|
+
const { continuousStatusLines } = await import("./continuous-record-3SKJ6I3V.ts");
|
|
2106
2438
|
validate();
|
|
2107
2439
|
const lines = await continuousStatusLines(config);
|
|
2108
2440
|
validate();
|
|
@@ -2187,10 +2519,11 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
|
|
|
2187
2519
|
const activate = menu.actions[action];
|
|
2188
2520
|
menu.actions[action] = async (invocation) => {
|
|
2189
2521
|
validateOwner();
|
|
2190
|
-
const
|
|
2522
|
+
const { configReview, settingsReview } = invocation.state.manager;
|
|
2523
|
+
const review = action === "settings" ? settingsReview ?? configReview : configReview;
|
|
2191
2524
|
let current = false;
|
|
2192
2525
|
try {
|
|
2193
|
-
const config = await loadConfig();
|
|
2526
|
+
const config = await (action === "settings" ? loadSettingsConfig() : loadConfig());
|
|
2194
2527
|
validateOwner();
|
|
2195
2528
|
invocation.signal.throwIfAborted();
|
|
2196
2529
|
current = review?.fingerprint === syncCheckConfigFingerprint(config);
|
|
@@ -2222,17 +2555,27 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
|
|
|
2222
2555
|
}, customOptions)
|
|
2223
2556
|
}
|
|
2224
2557
|
};
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2558
|
+
let firstOpen = true;
|
|
2559
|
+
const describe = async (signal) => {
|
|
2560
|
+
const pendingAttention = options.getAttention?.();
|
|
2561
|
+
const observation = options.getObservation?.();
|
|
2562
|
+
const manager = await describeManagerState(signal, pendingAttention, void 0, observation);
|
|
2563
|
+
if (signal.aborted || !isCurrent()) return manager;
|
|
2564
|
+
if (observation && options.getObservation?.() === observation && !manager.observation && !(manager.operation && operationBlocksChanges(manager.operation))) {
|
|
2565
|
+
options.onObservationInvalidated?.();
|
|
2566
|
+
}
|
|
2567
|
+
if (pendingAttention && options.getAttention?.() === pendingAttention && !manager.attention) {
|
|
2568
|
+
options.onSelectionResolved?.(pendingAttention);
|
|
2569
|
+
}
|
|
2570
|
+
return manager;
|
|
2571
|
+
};
|
|
2572
|
+
await runMenu5(menuContext, menu, {
|
|
2573
|
+
getState: async ({ signal }) => {
|
|
2574
|
+
const offerOnOpen = firstOpen;
|
|
2575
|
+
firstOpen = false;
|
|
2576
|
+
let manager = await describe(signal);
|
|
2577
|
+
if (offerOnOpen && manager.operation?.kind === "free" && manager.configReview && await showIgnoreMigrationPrompt(ctx, manager.configReview.setupName, signal, isCurrent)) {
|
|
2578
|
+
if (!signal.aborted && isCurrent()) manager = await describe(signal);
|
|
2236
2579
|
}
|
|
2237
2580
|
return { manager };
|
|
2238
2581
|
},
|
|
@@ -2291,4 +2634,4 @@ function syncMainMenuItem(label) {
|
|
|
2291
2634
|
export {
|
|
2292
2635
|
showSyncManager
|
|
2293
2636
|
};
|
|
2294
|
-
//# sourceMappingURL=manager-ui-
|
|
2637
|
+
//# sourceMappingURL=manager-ui-AOFUNXAJ.ts.map
|