@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
|
@@ -29,10 +29,10 @@ An explicit setup creates the file atomically.
|
|
|
29
29
|
On POSIX, pi-sync creates and replaces it with mode `0600`.
|
|
30
30
|
Pi-sync processes coordinate settings access through `pi-sync.json.mutation-lock`; lock-unaware editors are outside that serialization boundary and should not save the file while a pi-sync settings operation is running.
|
|
31
31
|
Within one process, settings reads wait for earlier writes, including writes that have not acquired the lock yet.
|
|
32
|
-
|
|
32
|
+
Under that lock, a save validates the existing document before editing it. A malformed, invalid, or unsupported source cannot be replaced by relabeling it as a supported version. The writer validates the proposed document before flushing a private temporary file and renaming it over the canonical file; the active file is not moved away first.
|
|
33
33
|
Credentials stay in this canonical private file and are never shown in menus, reviews, status, notifications, errors, logs, or completion metadata.
|
|
34
34
|
|
|
35
|
-
A private `pi-sync.local.json` containing a valid
|
|
35
|
+
A private `pi-sync.local.json` containing a valid supported document is copied byte-for-byte to `pi-sync.json`.
|
|
36
36
|
The old file remains as a recovery copy.
|
|
37
37
|
If both paths exist, `pi-sync.json` wins and the legacy file remains untouched.
|
|
38
38
|
If an older interrupted replacement left `pi-sync.json` missing and a hidden `.pi-sync.json.*.schema-migration-source` or `.pi-sync.json.*.migration-retired` file remains, settings access stops instead of loading the legacy copy.
|
|
@@ -48,16 +48,17 @@ Global settings apply to all setups on this device; they are not remote policy.
|
|
|
48
48
|
|
|
49
49
|
| Scope | Fields | Required values and defaults |
|
|
50
50
|
| --- | --- | --- |
|
|
51
|
-
| Document | `version`, `onSwitch`, `storageConnections`, `syncSetups` | All are required in a manually written document;
|
|
51
|
+
| Document | `version`, `onSwitch`, `storageConnections`, `syncSetups` | All are required in a manually written document; versions 3 through 7 are supported. |
|
|
52
52
|
| Current setup | `activeSyncSetup` | Required when setups exist; absent when the setup catalog is empty. |
|
|
53
53
|
| Global preferences | `skipSecretScan`, `showStatus`, `debug` | Optional booleans; defaults are false, true, and false. |
|
|
54
|
-
| Setup selection | `sync.include`, `sync.automatic` |
|
|
54
|
+
| Setup selection | `sync.scope`, `sync.include`, `sync.automatic` | Directory scope requires version 7 and omits `include`; selected-path setups require `include`. Both require explicit `automatic`. |
|
|
55
55
|
| Setup behavior | `sync.automaticTransfer`, `sync.agentMode`, `sync.continuous`, `sync.mergeSettings`, `sync.mergeContent`, `sync.partialSync` | Optional booleans; all default to false. |
|
|
56
|
-
| Portable policy | `sync.localFields` | Optional array; any explicit array, including `[]`, requires version 4
|
|
57
|
-
| Content/partial policy | `sync.mergeContent`, `sync.partialSync` | Enabling either requires version 5 or
|
|
58
|
-
| Path exclusions | `sync.exclude` | Optional array; an explicit array, including `[]`, requires version 6. |
|
|
56
|
+
| Portable policy | `sync.localFields` | Optional array; any explicit array, including `[]`, requires version 4 or later. |
|
|
57
|
+
| Content/partial policy | `sync.mergeContent`, `sync.partialSync` | Enabling either requires version 5 or later. |
|
|
58
|
+
| Path exclusions | `sync.exclude` | Optional array; an explicit array, including `[]`, requires version 6 or later. |
|
|
59
|
+
| Directory exceptions | `sync.reinclude`, `sync.sessions` | Optional with directory scope. `reinclude` wins over `exclude`; sessions require `true`. |
|
|
59
60
|
|
|
60
|
-
Do not downgrade
|
|
61
|
+
Do not downgrade the settings version when an option is turned off.
|
|
61
62
|
The four automatic controls have separate effects:
|
|
62
63
|
|
|
63
64
|
- **Automatic sync** (`sync.automatic`) enables startup observation and selected-content shutdown pushes when sessions are included.
|
|
@@ -70,8 +71,7 @@ None of these controls is enabled by invoking the configuration skill.
|
|
|
70
71
|
### Editing in the manager
|
|
71
72
|
|
|
72
73
|
Open `/sync` → **Settings** to go directly to **Pi Sync Settings**.
|
|
73
|
-
The screen
|
|
74
|
-
**Included paths**, **Excluded paths**, and **Compare included paths** keep content policy together; comparison covers both rule lists, not file contents.
|
|
74
|
+
The screen uses a searchable flat list without category navigation. Compare content rules separately from file contents; directory scope also exposes its re-inclusion and session settings.
|
|
75
75
|
**Storage location** edits the current setup's coordinates, while **Manage sync setups** and **Manage storage connections** retain the catalog and affected-setup reviews.
|
|
76
76
|
Returning from catalog management refreshes the rows; switching or removing the owning setup closes its old Settings screen.
|
|
77
77
|
|
|
@@ -185,8 +185,8 @@ When adding a setup, locally configured destinations are checked before content
|
|
|
185
185
|
An occupied destination requires an explicit different path; Git requires a different branch because directories do not isolate publications on one branch.
|
|
186
186
|
This check does not contact the server or discover setups configured only on other machines.
|
|
187
187
|
|
|
188
|
-
Every setup requires `sync.
|
|
189
|
-
Setup
|
|
188
|
+
Every setup requires explicit `sync.automatic`. Set `sync.scope` for directory scope, or set `sync.include` for selected paths.
|
|
189
|
+
Setup offers automatic sync with Off first. **Join an existing remote** instead saves with automatic sync and sessions off, then reviews the remote policy without transferring files. Existing values are not rewritten.
|
|
190
190
|
When enabled, the current setup receives one background startup check in TUI/RPC, including reload/new/resume/fork.
|
|
191
191
|
Automatic sync alone does not perform startup transfers or open dialogs; review changes through `/sync`.
|
|
192
192
|
Print/JSON skip startup checks.
|
|
@@ -200,8 +200,8 @@ The check deadline is 30 seconds plus bounded cleanup, with manual retry through
|
|
|
200
200
|
Continuous sync is a separate opt-in.
|
|
201
201
|
See [Background startup checks](https://github.com/narumiruna/pi-extensions/blob/main/packages/pi-sync/README.md#background-startup-checks) for recovery and Git cache exceptions.
|
|
202
202
|
|
|
203
|
-
Recommended includes the nine non-session Pi roots listed below
|
|
204
|
-
The save review
|
|
203
|
+
New setups default to directory scope. For selected paths, Recommended includes the nine non-session Pi roots listed below and Minimal includes `settings.json` and `AGENTS.md`.
|
|
204
|
+
The save review shows the scope, path rules or selected paths, and the full backend destination.
|
|
205
205
|
R2/S3 requires an explicitly entered existing bucket and never creates one.
|
|
206
206
|
Saving setup or connection settings does not contact remote storage.
|
|
207
207
|
|
|
@@ -291,9 +291,36 @@ Authentication and transport failures give credentials/permissions or address/ne
|
|
|
291
291
|
Git reads remote snapshots and checks its local cache; write access is not tested.
|
|
292
292
|
WebDAV retains its isolated conditional-write/cleanup probe and repair of a missing active-snapshot history entry.
|
|
293
293
|
|
|
294
|
+
### Agent-directory scope
|
|
295
|
+
|
|
296
|
+
In a version 7 document, a new sync setup can use:
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"scope": "agent-directory",
|
|
301
|
+
"exclude": ["sessions", "bin", "npm", "skills/private"],
|
|
302
|
+
"reinclude": ["skills/private/shared.md"],
|
|
303
|
+
"automatic": false
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The agent directory is Pi's active agent root, normally `~/.pi/agent/`. Every eligible file is selected unless excluded. A re-inclusion restores an excluded path and only the descendants its rule matches. Literal directories match their subtrees. Rules are relative to the agent root; `sessions/` and `sessions` are equivalent in this scope. The `*`, `?`, and `**` syntax below applies to both lists. List order does not affect matching. If both lists are omitted, all eligible files are selected; the setup wizard saves its starter exclusions explicitly instead of adding them on every read.
|
|
308
|
+
|
|
309
|
+
Pi's `auth.json`, `trust.json`, their locks, and Pi Sync's settings and service state cannot be re-included. Pi's settings lock, dynamic model catalog cache and its lock, `crashes.json`, and `pi-debug.log` also stay local. Session paths remain local until explicitly enabled with `sync.sessions: true` (and not still excluded by a rule). The interactive flow requires a privacy acknowledgement. Symlinks are not followed. Agent-directory transfers do not move Pi's session storage root. Before moving a custom session store yourself, remove its old copy from the agent directory or exclude its old path explicitly. Pi Sync protects the current and default session locations, not unidentified old copies. Review what will transfer; the secret scan cannot identify every sensitive file.
|
|
310
|
+
|
|
311
|
+
The agent-directory scan and projected transfer result are limited to 64 MiB of file content, 16,384 files, and 65,536 visited entries. The projected result counts retained protected sessions and entries such as empty directories that are not stored in a snapshot. Directional apply and merged apply rescan before planned deletions and again before writes. The projection uses current sizes for retained files, but it does not lock out unrelated writers. `settings.json` has a separate 1 MiB limit for session routing. If local files change after review, reopen the transfer preview. A directory replacement is refused if it would remove an unreviewed or excluded descendant.
|
|
312
|
+
|
|
313
|
+
For new directory-scope transactions, the recovery journal records which image was being removed, which staging files it owns, and when the destination can remain empty. Recovery can resume if the remaining files match that evidence. If a staging attempt stops before ownership is saved, recovery can use a fresh staging path without adopting or deleting the unrecorded files. These files remain local and are excluded from sync. If Node cannot verify a stable filesystem creation time, an operation that needs a durable identity, such as resumed staging or removing a nonempty directory, stops and preserves the evidence. Recovery also stops for unrecognized data at a recorded path. Preserve the journal, backups, and remaining files for manual review. Older journals do not gain ownership evidence when you upgrade; do not downgrade with a pending journal.
|
|
314
|
+
|
|
315
|
+
Enabling sessions in the unedited recommended setup removes its starter `sessions` exclusion. If you choose to edit the starter rules or change session opt-in later in **Settings → Agent directory scope**, the toggle leaves both rule lists unchanged. For example, keep `exclude: ["sessions"]` and set `reinclude: ["sessions/work.jsonl"]` with `sessions: true` to select only that session.
|
|
316
|
+
|
|
317
|
+
**Compare sync policies** reviews the remote scope and rules without comparing file contents.
|
|
318
|
+
|
|
319
|
+
Settings version 7 and snapshot version 5 carry the new policy; older clients must refuse it. A local and remote scope mismatch stops transfer, even when forcing it. Use a matching setup or choose a new location. Adopting same-scope rules does not enable sessions on a device that has not opted in. Existing selected-path setups keep their behavior and stored settings. Changing rules does not transfer data, and excluding a path does not erase its old snapshots.
|
|
320
|
+
|
|
294
321
|
### Included content
|
|
295
322
|
|
|
296
|
-
|
|
323
|
+
Selected-path setups use ordered, duplicate-free `sync.include`.
|
|
297
324
|
Supported Pi roots are:
|
|
298
325
|
|
|
299
326
|
```text
|
|
@@ -339,8 +366,7 @@ Pull protects the currently open session file; restart Pi or resume a pulled ses
|
|
|
339
366
|
### Excluded paths
|
|
340
367
|
|
|
341
368
|
`sync.exclude` is an optional per-setup array of relative paths or basic glob patterns; absence means no rules.
|
|
342
|
-
|
|
343
|
-
Other setups without an explicit array keep their existing snapshot format.
|
|
369
|
+
For selected-path setups, an explicit array requires settings version 6 or later and publishes snapshot version 4 with selection policy version 2. Selected-path setups without an explicit array keep their existing snapshot format. Directory scope uses snapshot version 5.
|
|
344
370
|
New clients still read old settings and snapshots; older clients must refuse the opted-in formats.
|
|
345
371
|
|
|
346
372
|
For an existing setup in a version-6 document, the `sync` object can contain:
|
|
@@ -353,7 +379,7 @@ For an existing setup in a version-6 document, the `sync` object can contain:
|
|
|
353
379
|
}
|
|
354
380
|
```
|
|
355
381
|
|
|
356
|
-
Rules win over
|
|
382
|
+
Rules win over `include` in selected-path setups and are anchored to the logical snapshot root, with `/` separators on every platform. In directory scope, a matching `reinclude` rule can restore an excluded path.
|
|
357
383
|
Literal paths match themselves and their descendants; `skills/private` does not match `skills/private-copy`.
|
|
358
384
|
`*` and `?` match within one segment; whole-segment `**` matches zero or more segments.
|
|
359
385
|
A matching directory excludes its whole subtree, including hidden files.
|
|
@@ -362,14 +388,14 @@ Use `**/*.log` for a filename pattern at any depth; `*.log` matches only at the
|
|
|
362
388
|
Sessions use virtual `sessions/...` paths even when stored in a custom physical directory.
|
|
363
389
|
A trailing `/**` also excludes its root; excluding `sessions` or `sessions/**` disables the legacy sessions-enabled shutdown push before state/backend work.
|
|
364
390
|
|
|
365
|
-
|
|
391
|
+
Inline `!` negation, comments, braces, character classes, extglobs, absolute/drive/UNC paths, traversal, backslashes, controls, empty rules, and case-equivalent duplicates are rejected.
|
|
366
392
|
The limits are 1,024 rules, 4,096 UTF-8 bytes per rule, and 256 KiB total.
|
|
367
393
|
Overlapping rules and rules for currently absent or unselected paths are allowed.
|
|
368
394
|
This syntax is not Git ignore compatibility and does not load an ignore file.
|
|
369
395
|
|
|
370
396
|
**Settings → Excluded paths** uses a JSON-array draft and an exact **Save changes**, **Discard changes**, or **Continue editing** review.
|
|
371
397
|
Empty input keeps the current draft; `[]` clears rules.
|
|
372
|
-
Only Save writes settings
|
|
398
|
+
Only Save writes settings; it upgrades a selected-path setup's settings to at least version 6. Cancelling or a stale/failed save leaves the previous valid settings intact.
|
|
373
399
|
Changes apply to subsequent operations and do not start a transfer.
|
|
374
400
|
The canonical user file is the only scope; no project override or environment-variable mirror is added.
|
|
375
401
|
RPC remains read-only and shows the manual settings path.
|
|
@@ -424,8 +450,8 @@ Unknown fields remain preserved and malformed/invalid files block saves, just as
|
|
|
424
450
|
|
|
425
451
|
### Autonomous sync
|
|
426
452
|
|
|
427
|
-
Autonomous sync uses the unchanged `sync.agentMode` key, an optional per-setup boolean, default `false`, in settings versions 3
|
|
428
|
-
Open **Settings → Autonomous sync** and review the setup, destination,
|
|
453
|
+
Autonomous sync uses the unchanged `sync.agentMode` key, an optional per-setup boolean, default `false`, in settings versions 3 through 7.
|
|
454
|
+
Open **Settings → Autonomous sync** and review the setup, destination, content policy, transfer authorization, model disclosure, costs, and autonomous writes before enabling. For directory scope, the review shows session opt-in separately from path rules.
|
|
429
455
|
RPC users can explicitly set the same field in the private settings file.
|
|
430
456
|
Setting it to `true` is authorization, not just a display preference.
|
|
431
457
|
|
|
@@ -446,8 +472,10 @@ First-source selection, policy migrations, explicit push/pull, and rollback keep
|
|
|
446
472
|
`--yes` does not enable Autonomous sync or authorize model disclosure.
|
|
447
473
|
Completed transfers never reload resources automatically.
|
|
448
474
|
|
|
449
|
-
The
|
|
450
|
-
|
|
475
|
+
The daemon uses the initiating session's selected model only if both agree on its full definition and authentication source.
|
|
476
|
+
If the daemon refuses the model, align the Pi host and the daemon's bundled Pi catalog or verify a model that matches on both sides. Selecting an older ID does not help if its definition still differs.
|
|
477
|
+
The daemon does not choose a fallback; ordinary sync without model resolution is unaffected.
|
|
478
|
+
The resolver has an independent in-memory SDK conversation, no tools, no parent conversation, and no discovered extensions, skills, project instructions, or MCP servers.
|
|
451
479
|
Only conflict units are disclosed.
|
|
452
480
|
Settings units contain only the conflicting root fields, with coupled fields kept together; the model selects a complete local or remote unit.
|
|
453
481
|
Other fields are assembled by deterministic code.
|
|
@@ -525,7 +553,7 @@ No Pi core changes or other extension are required.
|
|
|
525
553
|
|
|
526
554
|
### Daemon lifetime and unattended permission
|
|
527
555
|
|
|
528
|
-
|
|
556
|
+
For configured interactive work or an explicit setup or command, Pi starts the daemon bundled with the Pi Sync npm package or connects to an existing compatible owner. The daemon runs in a separate Node.js process, not as another Pi extension or an OS service. Unconfigured reads create no service or settings. The daemon owns the shared lifetime decision. For standalone and bundled CLI commands, see the [daemon CLI guide](https://github.com/narumiruna/pi-extensions/blob/main/packages/pi-sync/docs/daemon-migration.md#daemon-cli).
|
|
529
557
|
|
|
530
558
|
When no registered live client PID remains for that canonical agent directory and no valid explicit after-exit grant covers the active setup, a fixed 30-second grace period starts. Explicit CLI start without clients follows the same rule. Live passive, disconnected, publishing, and orderly retired PIDs keep the service alive. Detach, heartbeat loss, and an empty active-participant list are not proof of exit. `/reload`, `/new`, fork, and resume preserve shared ownership while their Pi process remains alive. A client arriving before shutdown becomes final cancels automatic exit. There is no new setting, environment variable, or keep-alive flag.
|
|
531
559
|
|
|
@@ -541,8 +569,8 @@ A failed consent write blocks automatic work in that service instance. Uncertain
|
|
|
541
569
|
|
|
542
570
|
### Continuous sync
|
|
543
571
|
|
|
544
|
-
`sync.continuous` is an optional per-setup boolean, default `false`, in settings versions 3
|
|
545
|
-
Open **Settings → Continuous sync** after enabling Autonomous sync.
|
|
572
|
+
`sync.continuous` is an optional per-setup boolean, default `false`, in settings versions 3 through 7.
|
|
573
|
+
Open **Settings → Continuous sync** after enabling Autonomous sync. For directory scope, the review shows session opt-in separately from path rules.
|
|
546
574
|
RPC users can set the field explicitly in the private settings file.
|
|
547
575
|
Existing Autonomous sync consent does not enable recurring requests.
|
|
548
576
|
|
|
@@ -674,11 +702,10 @@ Field merging and nonempty portable projections also refuse unsafe integers, non
|
|
|
674
702
|
`sync.localFields` is an explicit sorted string array of whole global `settings.json` root field names, not a heuristic or project override.
|
|
675
703
|
Example: `"localFields": ["shellPath"]`.
|
|
676
704
|
Coupled fields must be excluded together.
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
Existing version-5/6 settings are never downgraded by a field-policy edit.
|
|
705
|
+
Selected-path setups with nonempty rules must include `settings.json` in `sync.include`. Directory-scope setups must omit `sync.include` and can configure local fields without it. Path rules still govern whether `settings.json` syncs, and nonempty field rules require that exact file spelling if it is synced. Absent or explicitly empty rules remain valid for either scope.
|
|
706
|
+
Settings asks for confirmation before saving changes to these rules. An explicit array requires settings version 4 or later, and editing the rules does not downgrade an existing settings version.
|
|
680
707
|
Absent rules keep a setup nonportable, including unrelated setups in a version-4 document.
|
|
681
|
-
An explicit array opts that setup into at least snapshot version 2;
|
|
708
|
+
An explicit array opts that setup into at least snapshot version 2; exclusion-enabled selected-path setups retain version 4, and directory scope retains version 5.
|
|
682
709
|
`[]` after rule removal retains this reviewed opt-in and differs from absence.
|
|
683
710
|
Older clients must refuse portable data rather than replace local-only values.
|
|
684
711
|
|
|
@@ -708,7 +735,7 @@ Capture occurs after accepted directions or journaled merge; cache staging prece
|
|
|
708
735
|
Missing/corrupt cache never invents a baseline from current data or assumes remote retention.
|
|
709
736
|
Preserve unknown/corrupted or nonprivate records and pending journals for manual review; pruning applies the same storage/schema/byte validation as reading.
|
|
710
737
|
Journal identity distinguishes absent and explicit empty policies.
|
|
711
|
-
Integrity validation uses the journal's recorded rules, so intact old-policy journals remain readable after a settings change; ordinary replay still rejects mismatched current rules, while reviewed force push
|
|
738
|
+
Integrity validation uses the journal's recorded rules, so intact old-policy journals remain readable after a settings change; ordinary replay still rejects mismatched current rules, while a reviewed force push or pull may archive a legacy path-policy journal.
|
|
712
739
|
Older absence-conflating journal identities fail closed and remain available for an explicitly reviewed force direction; do not downgrade portable setups.
|
|
713
740
|
To return to an older client, first use this version to review rule removal and publish a complete nonportable copy to a separate version-3 setup, with Pi closed during the change.
|
|
714
741
|
Never reinterpret portable snapshots with an old binary.
|
|
@@ -717,8 +744,8 @@ Never reinterpret portable snapshots with an old binary.
|
|
|
717
744
|
|
|
718
745
|
`sync.mergeContent` and `sync.partialSync` are independent opt-in booleans, both default `false`.
|
|
719
746
|
The owning **Settings → Content merge / partial progress** setting offers Off, Merge only, Merge + partial, and Partial only and confirms an explicit upgrade to at least settings version 5.
|
|
720
|
-
Manual configuration must
|
|
721
|
-
|
|
747
|
+
Manual configuration must use a supported settings version of at least 5 (version 7 for directory scope).
|
|
748
|
+
Partial publications retain snapshot version 4 for exclusion-enabled selected paths and version 5 for directory scope.
|
|
722
749
|
Settings version 5 retains the portable-policy behavior of version 4; moving from a legacy setup can require the existing separately confirmed directional policy migration.
|
|
723
750
|
Disabling options retains the schema and recovery evidence.
|
|
724
751
|
|
|
@@ -183,7 +183,7 @@ export async function executeCommand(
|
|
|
183
183
|
const operations = await loaders.operations();
|
|
184
184
|
throwIfAborted(options.signal);
|
|
185
185
|
const outcome = await operations.syncBoth(ctx, options);
|
|
186
|
-
return { kind: "completed", ...(retryRefusal && outcome ? { outcome } : {}) };
|
|
186
|
+
return { kind: "completed", ...(retryRefusal && outcome && outcome !== "archived" ? { outcome } : {}) };
|
|
187
187
|
}
|
|
188
188
|
case "history": {
|
|
189
189
|
const operations = await loaders.operations();
|
|
@@ -275,7 +275,13 @@ async function showConfig(ctx: ExtensionCommandContext, options: CommandOptions)
|
|
|
275
275
|
`startup transfer: ${startupTransferSummary(config)}`,
|
|
276
276
|
`autonomous sync: ${config.agentMode ? "On" : "Off"}`,
|
|
277
277
|
`continuous sync: ${config.continuous ? (config.agentMode ? "On" : "paused; Autonomous sync is Off") : "Off"}`,
|
|
278
|
-
`included content: ${config.include.join(", ") || "none"}`,
|
|
278
|
+
config.scope ? "sync scope: Pi agent directory" : `included content: ${config.include.join(", ") || "none"}`,
|
|
279
|
+
...(config.scope
|
|
280
|
+
? [
|
|
281
|
+
`excluded paths: ${config.exclude?.map(safeTerminalText).join(", ") || "none"}`,
|
|
282
|
+
`re-included paths: ${config.reinclude?.map(safeTerminalText).join(", ") || "none"}`,
|
|
283
|
+
]
|
|
284
|
+
: []),
|
|
279
285
|
`sessions: ${syncSessionsSelected(config) ? "included" : "not included"}`,
|
|
280
286
|
`settings file: ${localConfigPath()}`,
|
|
281
287
|
...warnings,
|
package/src/daemon/pi-client.ts
CHANGED
|
@@ -110,6 +110,7 @@ const authority: ConfigAuthority = {
|
|
|
110
110
|
const document = await client.readSettings(true);
|
|
111
111
|
client.validate();
|
|
112
112
|
signal?.throwIfAborted();
|
|
113
|
+
if (document) validate(document.parsed);
|
|
113
114
|
const next = update(structuredClone(document?.parsed ?? fallback) as T);
|
|
114
115
|
validate(next);
|
|
115
116
|
await client.run("settings.cas", { expected: fingerprint(document), next }, signal);
|
package/src/settings/config.ts
CHANGED
|
@@ -3,19 +3,27 @@ import type { CommandOptions } from "../commands/command-types.js";
|
|
|
3
3
|
import { remoteOperation } from "../daemon/pi-client.js";
|
|
4
4
|
import type { SetupPullOutcome } from "./setup-switch.js";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
ctx: ExtensionContext,
|
|
8
|
-
operation: string,
|
|
9
|
-
options: CommandOptions,
|
|
10
|
-
): Promise<SetupPullOutcome | undefined> {
|
|
11
|
-
const result = await remoteOperation(ctx, operation, options);
|
|
6
|
+
function transferResult(result: unknown): SetupPullOutcome | undefined {
|
|
12
7
|
if (result === undefined || result === "applied" || result === "cancelled") return result;
|
|
13
8
|
throw new Error("Invalid transfer result from pi-sync-daemon.");
|
|
14
9
|
}
|
|
15
|
-
export const push = (ctx: ExtensionContext, options: CommandOptions) =>
|
|
16
|
-
|
|
17
|
-
export const
|
|
18
|
-
|
|
10
|
+
export const push = async (ctx: ExtensionContext, options: CommandOptions) =>
|
|
11
|
+
transferResult(await remoteOperation(ctx, "push", options));
|
|
12
|
+
export const pull = async (ctx: ExtensionContext, options: CommandOptions) =>
|
|
13
|
+
transferResult(await remoteOperation(ctx, "pull", options));
|
|
14
|
+
export async function syncBoth(ctx: ExtensionContext, options: CommandOptions) {
|
|
15
|
+
const result = await remoteOperation(ctx, options.auto ? "startup-transfer" : "sync", options);
|
|
16
|
+
if (
|
|
17
|
+
result === "archived" &&
|
|
18
|
+
!options.auto &&
|
|
19
|
+
!options.agentRetryRefusal &&
|
|
20
|
+
!options.yes &&
|
|
21
|
+
ctx.hasUI &&
|
|
22
|
+
(ctx.mode === "tui" || ctx.mode === "rpc")
|
|
23
|
+
)
|
|
24
|
+
return result;
|
|
25
|
+
return transferResult(result);
|
|
26
|
+
}
|
|
19
27
|
export async function rollback(ctx: ExtensionContext, options: CommandOptions) {
|
|
20
28
|
await remoteOperation(ctx, "rollback", options);
|
|
21
29
|
}
|
package/src/sync/sync-policy.ts
CHANGED
|
@@ -3,6 +3,8 @@ export {
|
|
|
3
3
|
BUILT_IN_SYNC_ROOTS,
|
|
4
4
|
canonicalSnapshotPathForConfig,
|
|
5
5
|
compareSyncInclude,
|
|
6
|
+
compileSyncPolicyExclude,
|
|
7
|
+
compileSyncPolicyTraversal,
|
|
6
8
|
configuredSnapshotPathMatcher,
|
|
7
9
|
customIncludePathsByLower,
|
|
8
10
|
DEFAULT_SYNC_INCLUDE,
|
|
@@ -16,6 +18,7 @@ export {
|
|
|
16
18
|
isPreservableUnmanagedSnapshotPath,
|
|
17
19
|
isSafeCustomIncludePath,
|
|
18
20
|
isSafeExtraFileName,
|
|
21
|
+
normalizeDirectoryRules,
|
|
19
22
|
normalizeExtraFiles,
|
|
20
23
|
normalizeSyncFiles,
|
|
21
24
|
normalizeSyncInclude,
|
|
@@ -28,7 +31,9 @@ export {
|
|
|
28
31
|
selectionForSnapshot,
|
|
29
32
|
snapshotSelectionExclude,
|
|
30
33
|
snapshotSelectionInclude,
|
|
34
|
+
syncDirectoryPolicyKey,
|
|
31
35
|
syncIncludeSelection,
|
|
36
|
+
syncSelectionHasContent,
|
|
32
37
|
syncSessionsSelected,
|
|
33
38
|
validateSnapshotSelection,
|
|
34
39
|
} from "@narumitw/pi-sync-daemon/engine/sync/sync-policy";
|
|
@@ -3,6 +3,7 @@ import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
|
3
3
|
import { requireSettings, updateLocalConfig } from "../settings/settings-store.js";
|
|
4
4
|
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
5
5
|
import { confirmMergeReview } from "./merge-review.js";
|
|
6
|
+
import { directorySessionOptInLine } from "./setup/directory-rules.js";
|
|
6
7
|
import { safeTerminalText } from "./terminal-text.js";
|
|
7
8
|
|
|
8
9
|
export const AGENT_MODE_DESCRIPTION =
|
|
@@ -43,7 +44,14 @@ export async function saveAgentMode(
|
|
|
43
44
|
`Storage path: ${safeTerminalText(setup.storage.path)}`,
|
|
44
45
|
...(setup.storage.bucket ? [`Bucket: ${safeTerminalText(String(setup.storage.bucket))}`] : []),
|
|
45
46
|
...(setup.storage.branch ? [`Branch: ${safeTerminalText(String(setup.storage.branch))}`] : []),
|
|
46
|
-
|
|
47
|
+
...(setup.sync.scope
|
|
48
|
+
? [
|
|
49
|
+
"Sync scope: all eligible files in the Pi agent directory.",
|
|
50
|
+
directorySessionOptInLine(setup.sync.sessions),
|
|
51
|
+
`Excluded paths: ${setup.sync.exclude?.map(safeTerminalText).join(", ") || "none"}`,
|
|
52
|
+
`Re-included paths: ${setup.sync.reinclude?.map(safeTerminalText).join(", ") || "none"}`,
|
|
53
|
+
]
|
|
54
|
+
: [`Included paths: ${setup.sync.include.map(safeTerminalText).join(", ")}`]),
|
|
47
55
|
continuous ? CONTINUOUS_DESCRIPTION : AGENT_MODE_DESCRIPTION,
|
|
48
56
|
...(continuous
|
|
49
57
|
? [
|
|
@@ -3,8 +3,18 @@ import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
|
3
3
|
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
4
4
|
import { localConfigPath } from "../settings/config-file.js";
|
|
5
5
|
import { updateSyncSetup } from "../settings/settings-management.js";
|
|
6
|
+
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
6
7
|
import { normalizeSyncExclude, sameSyncExclude } from "../sync/exclude-policy.js";
|
|
7
8
|
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
9
|
+
import {
|
|
10
|
+
acknowledgeSessions,
|
|
11
|
+
type DirectoryRulesDraft,
|
|
12
|
+
directoryScopeLines,
|
|
13
|
+
formatDirectoryRules,
|
|
14
|
+
promptDirectoryRules,
|
|
15
|
+
summarizeDirectoryRules,
|
|
16
|
+
} from "./setup/directory-rules.js";
|
|
17
|
+
import { saveReviewedDraft } from "./setup/setup-review.js";
|
|
8
18
|
import { safeTerminalText } from "./terminal-text.js";
|
|
9
19
|
|
|
10
20
|
/** Transactional draft; Pi owns editor input/paste and Kit owns review/cancellation. */
|
|
@@ -21,12 +31,13 @@ export async function showExcludedPaths(ctx: ExtensionCommandContext, setupName:
|
|
|
21
31
|
validate();
|
|
22
32
|
const config = await loadConfig(setupName);
|
|
23
33
|
validate();
|
|
34
|
+
if (config.scope === "agent-directory") return showDirectoryScope(ctx, config, signal);
|
|
24
35
|
if (ctx.mode !== "tui") {
|
|
25
36
|
if (ctx.hasUI)
|
|
26
37
|
ctx.ui.notify(
|
|
27
38
|
[
|
|
28
39
|
`Excluded paths: ${(config.exclude ?? []).map(safeTerminalText).join(", ") || "none"}`,
|
|
29
|
-
`Edit sync.exclude in ${safeTerminalText(localConfigPath())}; an explicit array requires settings version 6.`,
|
|
40
|
+
`Edit sync.exclude in ${safeTerminalText(localConfigPath())}; an explicit array requires settings version 6 or later.`,
|
|
30
41
|
].join("\n"),
|
|
31
42
|
"info",
|
|
32
43
|
);
|
|
@@ -57,7 +68,7 @@ export async function showExcludedPaths(ctx: ExtensionCommandContext, setupName:
|
|
|
57
68
|
title: "Review excluded paths",
|
|
58
69
|
lines: [
|
|
59
70
|
`Setup: ${safeTerminalText(config.setupName)}`,
|
|
60
|
-
"Draft only. Save
|
|
71
|
+
"Draft only. Save requires at least settings version 6 and uses snapshot version 4 for this allowlist setup.",
|
|
61
72
|
"Excluded local files stay untouched. New snapshots omit matching remote files; old history is NOT erased.",
|
|
62
73
|
"Removing rules can expose local content or allow pull to replace it. Review a force push to publish policy changes.",
|
|
63
74
|
"Previously excluded:",
|
|
@@ -89,6 +100,8 @@ export async function showExcludedPaths(ctx: ExtensionCommandContext, setupName:
|
|
|
89
100
|
setupName,
|
|
90
101
|
(setup) => {
|
|
91
102
|
validate();
|
|
103
|
+
if (setup.sync.pathPolicy === "ignore-file")
|
|
104
|
+
throw new Error("Edit the ignore file to change this setup's policy.");
|
|
92
105
|
return { ...setup, sync: { ...setup.sync, exclude } };
|
|
93
106
|
},
|
|
94
107
|
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), upgradeExclude: true, signal },
|
|
@@ -104,3 +117,145 @@ export async function showExcludedPaths(ctx: ExtensionCommandContext, setupName:
|
|
|
104
117
|
return;
|
|
105
118
|
}
|
|
106
119
|
}
|
|
120
|
+
|
|
121
|
+
export function directoryScopeSummary(config: AnySyncConfig) {
|
|
122
|
+
return [
|
|
123
|
+
`Setup: ${safeTerminalText(config.setupName)} · Scope: Pi agent directory`,
|
|
124
|
+
`Excluded paths: ${summarizeDirectoryRules(config.exclude)}`,
|
|
125
|
+
`Re-included paths: ${summarizeDirectoryRules(config.reinclude)}`,
|
|
126
|
+
`Session opt-in: ${config.include.includes("sessions") ? "On (path rules still apply)" : "Off"}`,
|
|
127
|
+
"Pi credentials and project trust always stay local.",
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function showDirectoryScope(ctx: ExtensionCommandContext, config: AnySyncConfig, signal?: AbortSignal) {
|
|
132
|
+
const validate = captureMutationOwner(ctx, signal);
|
|
133
|
+
const isCurrent = () => {
|
|
134
|
+
try {
|
|
135
|
+
validate();
|
|
136
|
+
return true;
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
if (!isCurrent()) return;
|
|
142
|
+
if (ctx.mode !== "tui") {
|
|
143
|
+
if (ctx.hasUI)
|
|
144
|
+
ctx.ui.notify(
|
|
145
|
+
[
|
|
146
|
+
...directoryScopeSummary(config),
|
|
147
|
+
`Edit sync.exclude, sync.reinclude, and sync.sessions in ${safeTerminalText(localConfigPath())}.`,
|
|
148
|
+
].join("\n"),
|
|
149
|
+
"info",
|
|
150
|
+
);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const original: DirectoryRulesDraft = {
|
|
154
|
+
exclude: config.exclude ?? [],
|
|
155
|
+
reinclude: config.reinclude ?? [],
|
|
156
|
+
sessions: config.include.includes("sessions"),
|
|
157
|
+
};
|
|
158
|
+
const draft: DirectoryRulesDraft = { ...original };
|
|
159
|
+
const change = () => ({
|
|
160
|
+
exclude: !sameSyncExclude(draft.exclude, original.exclude),
|
|
161
|
+
reinclude: !sameSyncExclude(draft.reinclude, original.reinclude),
|
|
162
|
+
sessions: draft.sessions !== original.sessions,
|
|
163
|
+
});
|
|
164
|
+
const menu = defineMenu<undefined, "draft", "exclude" | "reinclude" | "sessions" | "review", ExtensionCommandContext>(
|
|
165
|
+
{
|
|
166
|
+
start: "draft",
|
|
167
|
+
screens: {
|
|
168
|
+
draft: () => ({
|
|
169
|
+
kind: "actions",
|
|
170
|
+
title: `Agent directory scope · ${safeTerminalText(config.setupName)}`,
|
|
171
|
+
lines: [
|
|
172
|
+
"Changes stay in this draft until you review and save. Back discards the draft.",
|
|
173
|
+
"Session opt-in does not change path rules. Edit the rules separately to select which sessions can sync.",
|
|
174
|
+
],
|
|
175
|
+
items: [
|
|
176
|
+
{ id: "exclude", label: `Edit excluded paths… (${draft.exclude.length})`, action: "exclude" },
|
|
177
|
+
{ id: "reinclude", label: `Edit re-included paths… (${draft.reinclude.length})`, action: "reinclude" },
|
|
178
|
+
{
|
|
179
|
+
id: "sessions",
|
|
180
|
+
label: `Session opt-in: ${draft.sessions ? "On → Off" : "Off → On"}`,
|
|
181
|
+
action: "sessions",
|
|
182
|
+
},
|
|
183
|
+
{ id: "review", label: "Review changes…", action: "review" },
|
|
184
|
+
],
|
|
185
|
+
hint: "back",
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
actions: {
|
|
189
|
+
exclude: async ({ signal: actionSignal }) => editRules("exclude", actionSignal),
|
|
190
|
+
reinclude: async ({ signal: actionSignal }) => editRules("reinclude", actionSignal),
|
|
191
|
+
sessions: async ({ signal: actionSignal }) => {
|
|
192
|
+
if (!draft.sessions && !(await acknowledgeSessions(ctx, actionSignal))) return { kind: "stay" };
|
|
193
|
+
if (actionSignal.aborted || !isCurrent()) return { kind: "close" };
|
|
194
|
+
draft.sessions = !draft.sessions;
|
|
195
|
+
return { kind: "stay" };
|
|
196
|
+
},
|
|
197
|
+
review: async ({ signal: actionSignal }) => {
|
|
198
|
+
const changed = change();
|
|
199
|
+
if (!changed.exclude && !changed.reinclude && !changed.sessions) return { kind: "close" };
|
|
200
|
+
try {
|
|
201
|
+
validate();
|
|
202
|
+
const saved = await saveReviewedDraft(
|
|
203
|
+
ctx,
|
|
204
|
+
"Review agent directory scope",
|
|
205
|
+
[
|
|
206
|
+
`Setup: ${safeTerminalText(config.setupName)}`,
|
|
207
|
+
"",
|
|
208
|
+
...directoryScopeLines(draft),
|
|
209
|
+
"",
|
|
210
|
+
...formatDirectoryRules("Previously excluded", original.exclude),
|
|
211
|
+
...formatDirectoryRules("Previously re-included", original.reinclude),
|
|
212
|
+
`Previous session opt-in: ${original.sessions ? "On" : "Off"}`,
|
|
213
|
+
"Changing rules can expose or replace files. Existing remote history is not erased.",
|
|
214
|
+
"A remote policy mismatch blocks transfer until reviewed. Saving does not start a transfer.",
|
|
215
|
+
],
|
|
216
|
+
"Save changes",
|
|
217
|
+
(saveSignal) =>
|
|
218
|
+
updateSyncSetup(
|
|
219
|
+
config.setupName,
|
|
220
|
+
(setup) => {
|
|
221
|
+
validate();
|
|
222
|
+
if (setup.sync.scope !== "agent-directory" || setup.sync.pathPolicy === "ignore-file")
|
|
223
|
+
throw new Error("Sync scope changed during review.");
|
|
224
|
+
return {
|
|
225
|
+
...setup,
|
|
226
|
+
sync: {
|
|
227
|
+
...setup.sync,
|
|
228
|
+
...(changed.exclude ? { exclude: draft.exclude } : {}),
|
|
229
|
+
...(changed.reinclude ? { reinclude: draft.reinclude } : {}),
|
|
230
|
+
...(changed.sessions ? { sessions: draft.sessions } : {}),
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), signal: saveSignal },
|
|
235
|
+
),
|
|
236
|
+
actionSignal,
|
|
237
|
+
);
|
|
238
|
+
if (saved && !actionSignal.aborted && isCurrent())
|
|
239
|
+
ctx.ui.notify("Agent directory rules saved. Applies to subsequent sync; no transfer started.", "info");
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if (!actionSignal.aborted && isCurrent())
|
|
242
|
+
ctx.ui.notify(
|
|
243
|
+
`Agent directory rules not saved: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
|
|
244
|
+
"error",
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
return { kind: "close" };
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
);
|
|
252
|
+
const result = await runMenu(ctx, menu, { getState: () => undefined, signal, isCurrent });
|
|
253
|
+
if (result.kind === "error" && isCurrent()) throw result.error;
|
|
254
|
+
|
|
255
|
+
async function editRules(kind: "exclude" | "reinclude", actionSignal: AbortSignal) {
|
|
256
|
+
const rules = await promptDirectoryRules(ctx, kind, draft[kind], actionSignal, validate);
|
|
257
|
+
if (actionSignal.aborted || !isCurrent()) return { kind: "close" as const };
|
|
258
|
+
if (rules) draft[kind] = rules;
|
|
259
|
+
return { kind: "stay" as const };
|
|
260
|
+
}
|
|
261
|
+
}
|
package/src/ui/file-selection.ts
CHANGED
|
@@ -5,12 +5,14 @@ import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
|
5
5
|
import { localConfigPath } from "../settings/config-file.js";
|
|
6
6
|
import { updateSyncSetup } from "../settings/settings-management.js";
|
|
7
7
|
import { agentDir } from "../snapshot/session-paths.js";
|
|
8
|
+
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
8
9
|
import {
|
|
9
10
|
BUILT_IN_SYNC_ROOTS,
|
|
10
11
|
isSafeCustomIncludePath,
|
|
11
12
|
normalizeSyncInclude,
|
|
12
13
|
syncIncludeSelection,
|
|
13
14
|
} from "../sync/sync-policy.js";
|
|
15
|
+
import { showDirectoryScope } from "./excluded-paths-ui.js";
|
|
14
16
|
|
|
15
17
|
const BUILT_IN_PREFIX = "builtin:";
|
|
16
18
|
const CUSTOM_PREFIX = "custom:";
|
|
@@ -24,18 +26,19 @@ interface SelectionDraft {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export async function showFileSelection(ctx: ExtensionCommandContext, setupName?: string, signal?: AbortSignal) {
|
|
29
|
+
const validate = captureMutationOwner(ctx, signal);
|
|
27
30
|
const config = await loadConfig(setupName);
|
|
28
31
|
if (signal?.aborted) return;
|
|
32
|
+
validate();
|
|
33
|
+
if (config.scope === "agent-directory") return showDirectoryScope(ctx, config, signal);
|
|
29
34
|
const selection = syncIncludeSelection(config.include);
|
|
30
35
|
const original: SelectionDraft = {
|
|
31
36
|
builtIns: new Set(selection.builtIns),
|
|
32
37
|
custom: new Set(selection.custom),
|
|
33
38
|
sessions: selection.sessions,
|
|
34
39
|
};
|
|
35
|
-
const draft = cloneDraft(original);
|
|
36
|
-
const customCandidates = await listCustomCandidates(draft.custom);
|
|
37
|
-
|
|
38
40
|
if (ctx.mode !== "tui") {
|
|
41
|
+
if (!ctx.hasUI) return;
|
|
39
42
|
ctx.ui.notify(
|
|
40
43
|
[
|
|
41
44
|
`pi-sync included content for sync setup ${safeTerminalText(config.setupName)}:`,
|
|
@@ -49,6 +52,8 @@ export async function showFileSelection(ctx: ExtensionCommandContext, setupName?
|
|
|
49
52
|
);
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
55
|
+
const draft = cloneDraft(original);
|
|
56
|
+
const customCandidates = await listCustomCandidates(draft.custom);
|
|
52
57
|
|
|
53
58
|
while (!signal?.aborted) {
|
|
54
59
|
await showDraftEditor(ctx, config.setupName, draft, customCandidates, signal);
|
|
@@ -81,10 +86,10 @@ export async function showFileSelection(ctx: ExtensionCommandContext, setupName?
|
|
|
81
86
|
if (signal?.aborted) return;
|
|
82
87
|
await updateSyncSetup(
|
|
83
88
|
config.setupName,
|
|
84
|
-
(setup) =>
|
|
85
|
-
|
|
86
|
-
sync: { ...setup.sync, include }
|
|
87
|
-
}
|
|
89
|
+
(setup) => {
|
|
90
|
+
if (setup.sync.scope === "agent-directory") throw new Error("Sync scope changed during review.");
|
|
91
|
+
return { ...setup, sync: { ...setup.sync, include } };
|
|
92
|
+
},
|
|
88
93
|
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), expectedInclude: config.include, signal },
|
|
89
94
|
);
|
|
90
95
|
if (signal?.aborted) return;
|