@narumitw/pi-sync 0.61.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +46 -25
- package/dist/chunks/{chunk-277VHM2P.ts → chunk-27F5W7DX.ts} +7 -3
- package/dist/chunks/chunk-27F5W7DX.ts.map +7 -0
- package/dist/chunks/{chunk-ZIL6PW5L.ts → chunk-6YKOHBSC.ts} +2 -2
- package/dist/chunks/{chunk-OA4NZLSL.ts → chunk-APZVJAEW.ts} +4 -3
- package/dist/chunks/chunk-CKUGCBHP.ts +114 -0
- package/dist/chunks/chunk-CKUGCBHP.ts.map +7 -0
- package/dist/chunks/chunk-EJDDRS6O.ts +17 -0
- package/dist/chunks/chunk-EJDDRS6O.ts.map +7 -0
- package/dist/chunks/{chunk-JVFCVPPD.ts → chunk-EXDWEFIJ.ts} +87 -147
- package/dist/chunks/chunk-EXDWEFIJ.ts.map +7 -0
- package/dist/chunks/{chunk-4SR3ZYHA.ts → chunk-GELYN4UC.ts} +2 -2
- package/dist/chunks/{chunk-2ZGV5KNC.ts → chunk-HSCAFOT5.ts} +15 -12
- package/dist/chunks/chunk-HSCAFOT5.ts.map +7 -0
- package/dist/chunks/{chunk-YQSFJLJ3.ts → chunk-IBXEM35O.ts} +4 -3
- package/dist/chunks/{chunk-2JHAN3ZO.ts → chunk-JREGWM2B.ts} +3 -3
- package/dist/chunks/chunk-MANNB4WZ.ts +36 -0
- package/dist/chunks/chunk-MANNB4WZ.ts.map +7 -0
- package/dist/chunks/{chunk-EMRFVLZM.ts → chunk-NXWHPVXR.ts} +2 -2
- package/dist/chunks/{chunk-SMVKMYLK.ts → chunk-P4GI7LTT.ts} +2 -2
- package/dist/chunks/{chunk-ZVGRZD4C.ts → chunk-R3SAMXB6.ts} +2 -2
- package/dist/chunks/{chunk-4KTJLJSJ.ts → chunk-S6FUUWV5.ts} +148 -21
- package/dist/chunks/chunk-S6FUUWV5.ts.map +7 -0
- package/dist/chunks/{chunk-PJMM75W5.ts → chunk-SXCH4Q5O.ts} +41 -23
- package/dist/chunks/chunk-SXCH4Q5O.ts.map +7 -0
- package/dist/chunks/{chunk-RNIEVDTR.ts → chunk-T3LABNHF.ts} +2 -2
- package/dist/chunks/{chunk-E3YLRLJM.ts → chunk-UGS6RYDZ.ts} +14 -12
- package/dist/chunks/chunk-UGS6RYDZ.ts.map +7 -0
- package/dist/chunks/{chunk-S3R3W3KF.ts → chunk-UMPA5S7X.ts} +2 -2
- package/dist/chunks/{chunk-EMVZL4PH.ts → chunk-V76KCWHO.ts} +7 -5
- package/dist/chunks/{chunk-EMVZL4PH.ts.map → chunk-V76KCWHO.ts.map} +1 -1
- package/dist/chunks/{chunk-S7F4FOAS.ts → chunk-VQ47JBLF.ts} +5 -5
- package/dist/chunks/{chunk-WP2M67XZ.ts → chunk-WBIOSK76.ts} +2 -2
- package/dist/chunks/chunk-WFBHWYI6.ts +18 -0
- package/dist/chunks/chunk-WFBHWYI6.ts.map +7 -0
- package/dist/chunks/{chunk-HEB6YT64.ts → chunk-ZO52JM4H.ts} +2 -2
- package/dist/chunks/{command-handler-K4XJOGYC.ts → command-handler-VINMQ7ZM.ts} +26 -43
- package/dist/chunks/command-handler-VINMQ7ZM.ts.map +7 -0
- package/dist/chunks/{conflict-review-IGKY2TOJ.ts → conflict-review-PCDFRIVB.ts} +4 -4
- package/dist/chunks/{continuous-record-3XDXDOMV.ts → continuous-record-3SKJ6I3V.ts} +2 -2
- package/dist/chunks/{continuous-storage-HLKCHF6Z.ts → continuous-storage-3EU6I7Z3.ts} +2 -2
- package/dist/chunks/{file-selection-MGGVOKM7.ts → file-selection-KID23GAD.ts} +21 -14
- package/dist/chunks/file-selection-KID23GAD.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-GDB74IOP.ts +20 -0
- package/dist/chunks/{manager-ui-KYQ5AZJS.ts → manager-ui-YHDECYKI.ts} +454 -167
- package/dist/chunks/manager-ui-YHDECYKI.ts.map +7 -0
- package/dist/chunks/remote-selection-ui-GPITNEBF.ts +19 -0
- package/dist/chunks/{setup-switch-D6K6PBPC.ts → setup-switch-L54X5U5I.ts} +7 -7
- package/dist/chunks/{setup-wizard-4DYUDHJR.ts → setup-wizard-YO4MCPUF.ts} +15 -11
- package/dist/chunks/{setup-wizard-4DYUDHJR.ts.map → setup-wizard-YO4MCPUF.ts.map} +1 -1
- package/dist/chunks/{snapshot-5HY3M2NL.ts → snapshot-ZUJJZCFW.ts} +2 -2
- package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts → snapshot-transaction-directory-F46JWRAU.ts} +2 -2
- package/dist/chunks/{state-directory-XXHU73Z3.ts → state-directory-CMAIF34J.ts} +2 -2
- package/dist/chunks/{sync-inspection-J3CRBORL.ts → sync-inspection-H2WX5SUT.ts} +5 -5
- package/dist/chunks/{sync-operations-BVWYYKH3.ts → sync-operations-2MZAYHL2.ts} +13 -9
- package/dist/chunks/sync-operations-2MZAYHL2.ts.map +7 -0
- package/dist/chunks/{sync-state-2LMIXJ2C.ts → sync-state-QIT64TKV.ts} +2 -2
- package/dist/daemon/LICENSE +21 -0
- package/dist/daemon/dist/build-version.js +8 -0
- package/dist/daemon/dist/child-sdk.mjs +17 -0
- package/dist/daemon/dist/cli.js +169 -0
- package/dist/daemon/dist/client.js +909 -0
- package/dist/daemon/dist/consent.js +383 -0
- package/dist/daemon/dist/document.js +6 -0
- package/dist/daemon/dist/endpoint.js +91 -0
- package/dist/daemon/dist/engine/backends/backend-factory.js +16 -0
- package/dist/daemon/dist/engine/backends/backend-identity.js +38 -0
- package/dist/daemon/dist/engine/backends/backend-types.js +1 -0
- package/dist/daemon/dist/engine/backends/git/git-backend.js +746 -0
- package/dist/daemon/dist/engine/backends/git/git-config.js +118 -0
- package/dist/daemon/dist/engine/backends/git/git-runner.js +232 -0
- package/dist/daemon/dist/engine/backends/git/git-storage.js +252 -0
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +444 -0
- package/dist/daemon/dist/engine/backends/s3/s3-client.js +352 -0
- package/dist/daemon/dist/engine/backends/s3/s3-conditions.js +66 -0
- package/dist/daemon/dist/engine/backends/snapshot-pointer.js +22 -0
- package/dist/daemon/dist/engine/backends/sync-backend.js +23 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +542 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +326 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-config.js +73 -0
- package/dist/daemon/dist/engine/commands/command-types.js +1 -0
- package/dist/daemon/dist/engine/host.js +16 -0
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +33 -0
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +102 -0
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +252 -0
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +139 -0
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +393 -0
- package/dist/daemon/dist/engine/ignore/ignore-source.js +250 -0
- package/dist/daemon/dist/engine/paths.js +71 -0
- package/dist/daemon/dist/engine/settings/config-errors.js +4 -0
- package/dist/daemon/dist/engine/settings/config-file.js +736 -0
- package/dist/daemon/dist/engine/settings/config.js +344 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +199 -0
- package/dist/daemon/dist/engine/settings/settings-store.js +41 -0
- package/dist/daemon/dist/engine/settings/settings-types.js +1 -0
- package/dist/daemon/dist/engine/settings/settings-validation.js +384 -0
- package/dist/daemon/dist/engine/snapshot/session-paths.js +165 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +348 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-bounds.js +20 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-case-replacement.js +82 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +61 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-entry-projection.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +262 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-mutation-queues.js +133 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-paths.js +11 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +10 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-reviewed-preimages.js +60 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-root-transition.js +138 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-directory.js +16 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +387 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-plan.js +68 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +296 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-stage.js +303 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-verification.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +855 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +9 -0
- package/dist/daemon/dist/engine/snapshot/snapshot.js +678 -0
- package/dist/daemon/dist/engine/state/json-file.js +49 -0
- package/dist/daemon/dist/engine/state/lock-policy.js +2 -0
- package/dist/daemon/dist/engine/state/lock.js +259 -0
- package/dist/daemon/dist/engine/state/lockfile-fs.js +13 -0
- package/dist/daemon/dist/engine/state/merge-baseline-store.js +198 -0
- package/dist/daemon/dist/engine/state/mutation-directory-sync.js +34 -0
- package/dist/daemon/dist/engine/state/operation-availability.js +40 -0
- package/dist/daemon/dist/engine/state/state-directory.js +227 -0
- package/dist/daemon/dist/engine/state/state-types.js +1 -0
- package/dist/daemon/dist/engine/state/sync-state-store.js +54 -0
- package/dist/daemon/dist/engine/sync/agent-candidate.js +207 -0
- package/dist/daemon/dist/engine/sync/agent-plan.js +85 -0
- package/dist/daemon/dist/engine/sync/agent-policy.js +10 -0
- package/dist/daemon/dist/engine/sync/agent-refusal-retry.js +39 -0
- package/dist/daemon/dist/engine/sync/agent-request.js +13 -0
- package/dist/daemon/dist/engine/sync/agent-runner.js +183 -0
- package/dist/daemon/dist/engine/sync/agent-store.js +177 -0
- package/dist/daemon/dist/engine/sync/agent-sync.js +139 -0
- package/dist/daemon/dist/engine/sync/apply-review.js +52 -0
- package/dist/daemon/dist/engine/sync/conflict-artifact-ownership.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-artifacts.js +158 -0
- package/dist/daemon/dist/engine/sync/conflict-groups.js +76 -0
- package/dist/daemon/dist/engine/sync/conflict-preview.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-resolution.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-retention.js +61 -0
- package/dist/daemon/dist/engine/sync/conflict-review.js +73 -0
- package/dist/daemon/dist/engine/sync/content-conflicts.js +70 -0
- package/dist/daemon/dist/engine/sync/continuous-errors.js +66 -0
- package/dist/daemon/dist/engine/sync/continuous-lease.js +206 -0
- package/dist/daemon/dist/engine/sync/continuous-record.js +199 -0
- package/dist/daemon/dist/engine/sync/continuous-storage.js +59 -0
- package/dist/daemon/dist/engine/sync/continuous-sync.js +538 -0
- package/dist/daemon/dist/engine/sync/continuous-watch.js +140 -0
- package/dist/daemon/dist/engine/sync/exclude-policy.js +86 -0
- package/dist/daemon/dist/engine/sync/field-migration.js +20 -0
- package/dist/daemon/dist/engine/sync/file-merge-planner.js +123 -0
- package/dist/daemon/dist/engine/sync/initialization.js +80 -0
- package/dist/daemon/dist/engine/sync/json-document.js +172 -0
- package/dist/daemon/dist/engine/sync/local-field-policy.js +26 -0
- package/dist/daemon/dist/engine/sync/local-fields.js +196 -0
- package/dist/daemon/dist/engine/sync/merge-acceptance.js +29 -0
- package/dist/daemon/dist/engine/sync/merge-apply.js +532 -0
- package/dist/daemon/dist/engine/sync/merge-journal.js +314 -0
- package/dist/daemon/dist/engine/sync/merge-transfer-error.js +64 -0
- package/dist/daemon/dist/engine/sync/merged-sync.js +666 -0
- package/dist/daemon/dist/engine/sync/mutation-owner.js +18 -0
- package/dist/daemon/dist/engine/sync/package-merge.js +82 -0
- package/dist/daemon/dist/engine/sync/partial-progress.js +41 -0
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +119 -0
- package/dist/daemon/dist/engine/sync/resolver-stream.js +34 -0
- package/dist/daemon/dist/engine/sync/session-merge.js +178 -0
- package/dist/daemon/dist/engine/sync/session-push.js +47 -0
- package/dist/daemon/dist/engine/sync/settings-conflicts.js +56 -0
- package/dist/daemon/dist/engine/sync/settings-merge.js +93 -0
- package/dist/daemon/dist/engine/sync/signals.js +8 -0
- package/dist/daemon/dist/engine/sync/startup-timings.js +44 -0
- package/dist/daemon/dist/engine/sync/sync-decision.js +81 -0
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +55 -0
- package/dist/daemon/dist/engine/sync/sync-errors.js +18 -0
- package/dist/daemon/dist/engine/sync/sync-inspection.js +42 -0
- package/dist/daemon/dist/engine/sync/sync-loaders.js +8 -0
- package/dist/daemon/dist/engine/sync/sync-local.js +40 -0
- package/dist/daemon/dist/engine/sync/sync-mutations.js +754 -0
- package/dist/daemon/dist/engine/sync/sync-operations.js +3 -0
- package/dist/daemon/dist/engine/sync/sync-policy.js +646 -0
- package/dist/daemon/dist/engine/sync/sync-queries.js +212 -0
- package/dist/daemon/dist/engine/sync/sync-state.js +124 -0
- package/dist/daemon/dist/engine/sync/text-merge.js +124 -0
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +82 -0
- package/dist/daemon/dist/engine/types.js +2 -0
- package/dist/daemon/dist/engine/ui/merge-review.js +7 -0
- package/dist/daemon/dist/engine/ui/merged-sync-summary.js +86 -0
- package/dist/daemon/dist/engine/ui/sync-format.js +165 -0
- package/dist/daemon/dist/engine/ui/sync-status.js +30 -0
- package/dist/daemon/dist/engine/ui/terminal-text.js +9 -0
- package/dist/daemon/dist/engine/ui/transfer-changes.js +24 -0
- package/dist/daemon/dist/engine/ui/transfer-review.js +19 -0
- package/dist/daemon/dist/engine-service.js +441 -0
- package/dist/daemon/dist/identity.js +241 -0
- package/dist/daemon/dist/idle-exit.js +77 -0
- package/dist/daemon/dist/index.js +4 -0
- package/dist/daemon/dist/lifecycle-log.js +53 -0
- package/dist/daemon/dist/lifecycle.js +21 -0
- package/dist/daemon/dist/model-signature.js +7 -0
- package/dist/daemon/dist/monitor.js +324 -0
- package/dist/daemon/dist/participant-admission.js +30 -0
- package/dist/daemon/dist/protocol.js +104 -0
- package/dist/daemon/dist/resolver-host.js +78 -0
- package/dist/daemon/dist/server.js +994 -0
- package/dist/daemon/dist/service-host.js +175 -0
- package/dist/daemon/dist/upgrade-repair.js +55 -0
- package/dist/daemon/package.json +3 -0
- package/dist/index.ts +40 -37
- package/dist/index.ts.map +4 -4
- package/dist/package.json +6 -0
- package/docs/daemon-migration.md +27 -16
- package/package.json +9 -3
- package/skills/configure-pi-sync/SKILL.md +24 -46
- package/skills/configure-pi-sync/references/configuration.md +62 -22
- package/src/commands/command-execution.ts +13 -9
- package/src/commands/command-types.ts +1 -0
- package/src/daemon/pi-client.ts +4 -2
- package/src/settings/config.ts +2 -0
- package/src/sync/automatic-sync.ts +9 -2
- package/src/sync/setup-switch.ts +38 -15
- package/src/sync/startup-check.ts +7 -4
- package/src/sync/sync-operations.ts +18 -10
- package/src/ui/excluded-paths-ui.ts +6 -3
- package/src/ui/file-selection.ts +7 -2
- package/src/ui/ignore-file-guidance.ts +7 -0
- package/src/ui/ignore-file-ui.ts +97 -0
- package/src/ui/ignore-migration-prompt.ts +65 -0
- package/src/ui/manager-state.ts +40 -14
- package/src/ui/manager-ui.ts +41 -19
- package/src/ui/remote-selection-ui.ts +88 -28
- package/src/ui/settings-review.ts +26 -0
- package/src/ui/settings-ui.ts +378 -224
- package/src/ui/setup/setup-actions.ts +16 -4
- package/src/ui/setup/setup-prompts.ts +55 -9
- package/src/ui/setup/setup-switcher.ts +24 -11
- package/src/ui/storage-connections-ui.ts +50 -20
- package/src/ui/sync-setups-ui.ts +65 -30
- package/dist/chunks/chunk-277VHM2P.ts.map +0 -7
- package/dist/chunks/chunk-2ZGV5KNC.ts.map +0 -7
- package/dist/chunks/chunk-4KTJLJSJ.ts.map +0 -7
- package/dist/chunks/chunk-E3YLRLJM.ts.map +0 -7
- package/dist/chunks/chunk-ECYCNZOE.ts +0 -12
- package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
- package/dist/chunks/chunk-JVFCVPPD.ts.map +0 -7
- package/dist/chunks/chunk-PJMM75W5.ts.map +0 -7
- package/dist/chunks/command-handler-K4XJOGYC.ts.map +0 -7
- package/dist/chunks/file-selection-MGGVOKM7.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-4VJVDEUD.ts +0 -19
- package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-W3KOZM3W.ts +0 -18
- package/dist/chunks/sync-operations-BVWYYKH3.ts.map +0 -7
- /package/dist/chunks/{chunk-ZIL6PW5L.ts.map → chunk-6YKOHBSC.ts.map} +0 -0
- /package/dist/chunks/{chunk-OA4NZLSL.ts.map → chunk-APZVJAEW.ts.map} +0 -0
- /package/dist/chunks/{chunk-4SR3ZYHA.ts.map → chunk-GELYN4UC.ts.map} +0 -0
- /package/dist/chunks/{chunk-YQSFJLJ3.ts.map → chunk-IBXEM35O.ts.map} +0 -0
- /package/dist/chunks/{chunk-2JHAN3ZO.ts.map → chunk-JREGWM2B.ts.map} +0 -0
- /package/dist/chunks/{chunk-EMRFVLZM.ts.map → chunk-NXWHPVXR.ts.map} +0 -0
- /package/dist/chunks/{chunk-SMVKMYLK.ts.map → chunk-P4GI7LTT.ts.map} +0 -0
- /package/dist/chunks/{chunk-ZVGRZD4C.ts.map → chunk-R3SAMXB6.ts.map} +0 -0
- /package/dist/chunks/{chunk-RNIEVDTR.ts.map → chunk-T3LABNHF.ts.map} +0 -0
- /package/dist/chunks/{chunk-S3R3W3KF.ts.map → chunk-UMPA5S7X.ts.map} +0 -0
- /package/dist/chunks/{chunk-S7F4FOAS.ts.map → chunk-VQ47JBLF.ts.map} +0 -0
- /package/dist/chunks/{chunk-WP2M67XZ.ts.map → chunk-WBIOSK76.ts.map} +0 -0
- /package/dist/chunks/{chunk-HEB6YT64.ts.map → chunk-ZO52JM4H.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-IGKY2TOJ.ts.map → conflict-review-PCDFRIVB.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-3XDXDOMV.ts.map → continuous-record-3SKJ6I3V.ts.map} +0 -0
- /package/dist/chunks/{continuous-storage-HLKCHF6Z.ts.map → continuous-storage-3EU6I7Z3.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-4VJVDEUD.ts.map → manager-result-dispatcher-GDB74IOP.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-W3KOZM3W.ts.map → remote-selection-ui-GPITNEBF.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-D6K6PBPC.ts.map → setup-switch-L54X5U5I.ts.map} +0 -0
- /package/dist/chunks/{snapshot-5HY3M2NL.ts.map → snapshot-ZUJJZCFW.ts.map} +0 -0
- /package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts.map → snapshot-transaction-directory-F46JWRAU.ts.map} +0 -0
- /package/dist/chunks/{state-directory-XXHU73Z3.ts.map → state-directory-CMAIF34J.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-J3CRBORL.ts.map → sync-inspection-H2WX5SUT.ts.map} +0 -0
- /package/dist/chunks/{sync-state-2LMIXJ2C.ts.map → sync-state-QIT64TKV.ts.map} +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { assertRecoveryPolicy, BOUND_DIRECTORY_JOURNAL_VERSION, IGNORE_POLICY_JOURNAL_VERSION, ignorePolicyValidator, ignoreSourceBinding, recoveryPolicyKey, validateJournalPolicy, } from "../snapshot/snapshot-transaction-policy.js";
|
|
5
|
+
import { IGNORE_SNAPSHOT_VERSION } from "../snapshot/snapshot-types.js";
|
|
6
|
+
import { readJsonIfExists, syncDirectory, writeJson } from "../state/json-file.js";
|
|
7
|
+
import { readStateForConfig, statePathForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
|
|
8
|
+
import { confirmMergeReview } from "../ui/merge-review.js";
|
|
9
|
+
import { safeTerminalText } from "../ui/terminal-text.js";
|
|
10
|
+
import { normalizeSyncExclude } from "./exclude-policy.js";
|
|
11
|
+
import { planFileMerge } from "./file-merge-planner.js";
|
|
12
|
+
import { portableSnapshot, sameLocalFields, validatePortableSnapshot, validateSnapshotFieldPolicy, } from "./local-fields.js";
|
|
13
|
+
import { compileSyncPolicyExclude, configuredSnapshotPathMatcher, sameSnapshotSelection, syncDirectoryPolicyKey, validateSnapshotSelection, } from "./sync-policy.js";
|
|
14
|
+
import { fileHashMap, sameHashes } from "./sync-state.js";
|
|
15
|
+
export function mergeJournalPolicy(config) {
|
|
16
|
+
const localPolicyKey = recoveryPolicyKey(config);
|
|
17
|
+
const ignoreSource = config.ignorePolicy ? ignoreSourceBinding(config.ignorePolicy) : undefined;
|
|
18
|
+
if (localPolicyKey)
|
|
19
|
+
return { version: 3, localPolicyKey, ...(ignoreSource ? { ignoreSource } : {}) };
|
|
20
|
+
return ignoreSource ? { version: 2, ignoreSource } : { version: 1 };
|
|
21
|
+
}
|
|
22
|
+
function ignoreRecoveryPolicy(journal) {
|
|
23
|
+
return {
|
|
24
|
+
version: journal.version === 3 ? BOUND_DIRECTORY_JOURNAL_VERSION : IGNORE_POLICY_JOURNAL_VERSION,
|
|
25
|
+
ignoreSource: journal.ignoreSource,
|
|
26
|
+
localPolicyKey: journal.localPolicyKey,
|
|
27
|
+
selection: journal.upload.selection,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function assertMergeJournalPolicy(journal, config) {
|
|
31
|
+
if (journal.localPolicyKey !== recoveryPolicyKey(config))
|
|
32
|
+
throw new Error("Pending merge lacks matching setup or ignore-file policy evidence; preserve its journal for reviewed recovery.");
|
|
33
|
+
if (journal.version === 1 && !config.ignorePolicy && config.pathPolicy !== "ignore-file")
|
|
34
|
+
return;
|
|
35
|
+
if (journal.ignoreSource || config.ignorePolicy || config.pathPolicy === "ignore-file")
|
|
36
|
+
assertRecoveryPolicy(ignoreRecoveryPolicy(journal), config);
|
|
37
|
+
try {
|
|
38
|
+
const identity = JSON.parse(journal.identity);
|
|
39
|
+
if (!Array.isArray(identity) ||
|
|
40
|
+
typeof identity[1] !== "string" ||
|
|
41
|
+
journal.identity !== mergeJournalIdentity(config, identity[1]))
|
|
42
|
+
throw new Error("Inconsistent merge identity.");
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
throw new Error("Pending merge belongs to a different setup or local policy; preserve its journal.");
|
|
46
|
+
}
|
|
47
|
+
const configured = configuredSnapshotPathMatcher(config);
|
|
48
|
+
const excluded = compileSyncPolicyExclude(config);
|
|
49
|
+
if (!journal.applyOnly && journal.upload.files.some((file) => excluded(file.path)))
|
|
50
|
+
throw new Error("Pending publication contains protected paths; preserve its journal.");
|
|
51
|
+
for (const snapshot of [
|
|
52
|
+
journal.before,
|
|
53
|
+
journal.after,
|
|
54
|
+
journal.accepted,
|
|
55
|
+
journal.ignoreSource && !journal.applyOnly ? journal.upload : undefined,
|
|
56
|
+
]) {
|
|
57
|
+
if (snapshot?.files.some((file) => !configured(file.path)))
|
|
58
|
+
throw new Error("Pending merge contains paths outside the current ignore-file policy; preserve its journal.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function mergeJournalIdentity(config, backendIdentity) {
|
|
62
|
+
const localPolicyKey = recoveryPolicyKey(config);
|
|
63
|
+
return JSON.stringify([
|
|
64
|
+
config.setupName,
|
|
65
|
+
backendIdentity,
|
|
66
|
+
[...config.include].sort(),
|
|
67
|
+
config.localFields ?? null,
|
|
68
|
+
...(config.scope === "agent-directory"
|
|
69
|
+
? [syncDirectoryPolicyKey(config)]
|
|
70
|
+
: config.exclude === undefined
|
|
71
|
+
? []
|
|
72
|
+
: ["exclude", normalizeSyncExclude(config.exclude).map((rule) => rule.toLowerCase())]),
|
|
73
|
+
...(localPolicyKey ? [localPolicyKey] : []),
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
export function mergeJournalPath(config) {
|
|
77
|
+
return `${statePathForConfig(config)}.merge-journal.json`;
|
|
78
|
+
}
|
|
79
|
+
export async function readMergeJournal(config) {
|
|
80
|
+
let journal;
|
|
81
|
+
try {
|
|
82
|
+
const stat = await fs.lstat(mergeJournalPath(config));
|
|
83
|
+
if (!stat.isFile() || stat.size > 384 * 1024 * 1024)
|
|
84
|
+
throw new Error("Unsafe or oversized journal.");
|
|
85
|
+
journal = await readJsonIfExists(mergeJournalPath(config));
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error.code === "ENOENT")
|
|
89
|
+
return;
|
|
90
|
+
// A JSON parser error may quote sensitive journal contents; do not retain it in a public error.
|
|
91
|
+
throw new Error("Cannot read the private merge journal; preserve it and review recovery.");
|
|
92
|
+
}
|
|
93
|
+
if (journal === undefined)
|
|
94
|
+
return;
|
|
95
|
+
if (!journal ||
|
|
96
|
+
![1, 2, 3].includes(journal.version) ||
|
|
97
|
+
(journal.version === 1 && journal.ignoreSource !== undefined) ||
|
|
98
|
+
(journal.version === 2 && !journal.ignoreSource) ||
|
|
99
|
+
(journal.version === 3
|
|
100
|
+
? typeof journal.localPolicyKey !== "string" || !/^[0-9a-f]{64}$/u.test(journal.localPolicyKey)
|
|
101
|
+
: journal.localPolicyKey !== undefined) ||
|
|
102
|
+
typeof journal.identity !== "string" ||
|
|
103
|
+
typeof journal.backup !== "string" ||
|
|
104
|
+
typeof journal.stateIdentity !== "string" ||
|
|
105
|
+
(journal.applyOnly !== undefined &&
|
|
106
|
+
(journal.applyOnly !== true ||
|
|
107
|
+
!journal.committedHead ||
|
|
108
|
+
journal.committedHead.revision !== journal.expectedHead?.revision ||
|
|
109
|
+
journal.committedHead.snapshotId !== journal.expectedHead?.snapshotId ||
|
|
110
|
+
journal.upload?.id !== journal.expectedHead?.snapshotId)) ||
|
|
111
|
+
(journal.sessionRoot !== undefined &&
|
|
112
|
+
(typeof journal.sessionRoot !== "string" ||
|
|
113
|
+
!path.isAbsolute(journal.sessionRoot) ||
|
|
114
|
+
path.resolve(journal.sessionRoot) !== journal.sessionRoot)) ||
|
|
115
|
+
(journal.warnings !== undefined &&
|
|
116
|
+
(!Array.isArray(journal.warnings) ||
|
|
117
|
+
journal.warnings.length > 64 ||
|
|
118
|
+
journal.warnings.some((item) => typeof item !== "string"))) ||
|
|
119
|
+
!journal.expectedHead ||
|
|
120
|
+
typeof journal.expectedHead.revision !== "string" ||
|
|
121
|
+
!journal.before ||
|
|
122
|
+
!journal.after ||
|
|
123
|
+
!journal.upload ||
|
|
124
|
+
!Array.isArray(journal.before.files) ||
|
|
125
|
+
!Array.isArray(journal.after.files) ||
|
|
126
|
+
!Array.isArray(journal.upload.files))
|
|
127
|
+
throw new Error("Unsupported or damaged merge journal; preserve it and review recovery before syncing.");
|
|
128
|
+
// Verify every path and byte, including the unmanaged remote files retained for publication.
|
|
129
|
+
try {
|
|
130
|
+
if (journal.ignoreSource !== undefined) {
|
|
131
|
+
validateJournalPolicy(ignoreRecoveryPolicy(journal));
|
|
132
|
+
if ([journal.expectedHead.selection, journal.committedHead?.selection].some((selection) => selection !== undefined && !sameSnapshotSelection(selection, journal.upload.selection)))
|
|
133
|
+
throw new Error("Inconsistent merge head policy.");
|
|
134
|
+
}
|
|
135
|
+
const pinnedPaths = new Set(journal.progress?.groups.flatMap((group) => group.paths) ?? []);
|
|
136
|
+
for (const snapshot of [
|
|
137
|
+
journal.before,
|
|
138
|
+
journal.after,
|
|
139
|
+
journal.upload,
|
|
140
|
+
...(journal.accepted ? [journal.accepted] : []),
|
|
141
|
+
]) {
|
|
142
|
+
validateSnapshotFieldPolicy(snapshot);
|
|
143
|
+
validateSnapshotSelection(snapshot);
|
|
144
|
+
if ((journal.ignoreSource !== undefined
|
|
145
|
+
? snapshot.version !== IGNORE_SNAPSHOT_VERSION ||
|
|
146
|
+
!sameSnapshotSelection(snapshot.selection, journal.upload.selection)
|
|
147
|
+
: ![1, 2, 3, 4, 5].includes(snapshot.version)) ||
|
|
148
|
+
typeof snapshot.id !== "string" ||
|
|
149
|
+
typeof snapshot.profile !== "string" ||
|
|
150
|
+
snapshot.files.length > 16_384 ||
|
|
151
|
+
snapshot.files.reduce((bytes, file) => bytes + (typeof file?.contentBase64 === "string" ? file.contentBase64.length * 0.75 : Infinity), 0) >
|
|
152
|
+
64 * 1024 * 1024)
|
|
153
|
+
throw new Error("Invalid journal input.");
|
|
154
|
+
if (snapshot.selection?.scope) {
|
|
155
|
+
const configured = configuredSnapshotPathMatcher(snapshot.selection);
|
|
156
|
+
if (snapshot.files.some((file) => typeof file?.path !== "string" || !configured(file.path)))
|
|
157
|
+
throw new Error("Journal retains paths outside its recorded directory policy.");
|
|
158
|
+
}
|
|
159
|
+
const plan = planFileMerge({ baseline: {}, local: snapshot.files, remote: [], selectionCompatible: true });
|
|
160
|
+
if (plan.kind !== "planned" ||
|
|
161
|
+
plan.conflicts.some((conflict) => conflict.reason !== "path-collision" || !pinnedPaths.has(conflict.path)))
|
|
162
|
+
throw new Error("Invalid journal collision group.");
|
|
163
|
+
}
|
|
164
|
+
validatePortableSnapshot(journal.upload);
|
|
165
|
+
if (journal.upload.version >= 2 && !journal.accepted)
|
|
166
|
+
throw new Error("Portable merge journal requires an explicit accepted projection.");
|
|
167
|
+
if (journal.accepted)
|
|
168
|
+
validatePortableSnapshot(journal.accepted);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
throw new Error("Invalid merge journal paths, metadata, or bytes; preserve evidence for review.");
|
|
172
|
+
}
|
|
173
|
+
// Integrity is intrinsic to the recorded transaction, not the user's current recovery policy.
|
|
174
|
+
// completeJournal separately checks that the recorded policy matches the current setup.
|
|
175
|
+
try {
|
|
176
|
+
if (journal.accepted &&
|
|
177
|
+
(!sameLocalFields(journal.accepted.localFields, journal.upload.localFields) ||
|
|
178
|
+
!sameHashes(fileHashMap(portableSnapshot(journal.after, journal.upload.localFields)), fileHashMap(portableSnapshot(journal.accepted, journal.upload.localFields)))))
|
|
179
|
+
throw new Error("Projection mismatch.");
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
throw new Error("Invalid accepted merge projection; preserve journal evidence.");
|
|
183
|
+
}
|
|
184
|
+
if (journal.progress) {
|
|
185
|
+
const known = new Set([
|
|
186
|
+
...Object.keys(journal.progress.previous?.lastFileHashes ?? {}),
|
|
187
|
+
...[...journal.before.files, ...journal.after.files, ...journal.upload.files].map((file) => file.path),
|
|
188
|
+
]);
|
|
189
|
+
const progress = journal.progress;
|
|
190
|
+
if (!config.partialSync ||
|
|
191
|
+
!progress.previous ||
|
|
192
|
+
syncStateFingerprint(progress.previous) !== journal.stateIdentity ||
|
|
193
|
+
!Array.isArray(progress.groups) ||
|
|
194
|
+
progress.groups.length > 16_384 ||
|
|
195
|
+
progress.groups.some((group) => !Array.isArray(group.paths) ||
|
|
196
|
+
!group.paths.length ||
|
|
197
|
+
group.paths.length > 16_384 ||
|
|
198
|
+
group.paths.some((filePath) => !known.has(filePath)) ||
|
|
199
|
+
!/^[a-f0-9-]{36}$/u.test(group.artifact)))
|
|
200
|
+
throw new Error("Invalid partial acceptance metadata; preserve journal evidence.");
|
|
201
|
+
}
|
|
202
|
+
if (journal.progress) {
|
|
203
|
+
const before = fileHashMap(journal.before);
|
|
204
|
+
const after = fileHashMap(journal.after);
|
|
205
|
+
const { readConflictArtifact } = await import("./conflict-artifacts.js");
|
|
206
|
+
const backendIdentity = JSON.parse(journal.identity)[1];
|
|
207
|
+
if (typeof backendIdentity !== "string")
|
|
208
|
+
throw new Error("Invalid partial backend identity.");
|
|
209
|
+
const byArtifact = new Map();
|
|
210
|
+
for (const group of journal.progress.groups) {
|
|
211
|
+
const groups = byArtifact.get(group.artifact) ?? [];
|
|
212
|
+
groups.push(group);
|
|
213
|
+
byArtifact.set(group.artifact, groups);
|
|
214
|
+
}
|
|
215
|
+
for (const [token, groups] of byArtifact) {
|
|
216
|
+
const artifact = await readConflictArtifact(config, backendIdentity, token);
|
|
217
|
+
const retainedGroups = new Set(artifact.groups.map((group) => JSON.stringify(group.paths)));
|
|
218
|
+
const remote = fileHashMap(artifact.remote);
|
|
219
|
+
const upload = fileHashMap(journal.upload);
|
|
220
|
+
for (const group of groups) {
|
|
221
|
+
if (!retainedGroups.has(JSON.stringify(group.paths)))
|
|
222
|
+
throw new Error("Partial group does not match retained artifact evidence.");
|
|
223
|
+
for (const filePath of group.paths)
|
|
224
|
+
if (before[filePath] !== after[filePath] ||
|
|
225
|
+
remote[filePath] !== upload[filePath] ||
|
|
226
|
+
journal.progress.previous.lastFileHashes[filePath] !== artifact.state.lastFileHashes[filePath])
|
|
227
|
+
throw new Error("Withheld version changed in journal; preserve evidence.");
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return journal;
|
|
232
|
+
}
|
|
233
|
+
export async function writeMergeJournal(config, journal) {
|
|
234
|
+
await writeJson(mergeJournalPath(config), journal, { maxBytes: 384 * 1024 * 1024 });
|
|
235
|
+
}
|
|
236
|
+
export async function clearMergeJournal(config) {
|
|
237
|
+
await fs.rm(mergeJournalPath(config), { force: true });
|
|
238
|
+
await syncDirectory(path.dirname(mergeJournalPath(config)));
|
|
239
|
+
}
|
|
240
|
+
export async function retireMergeJournal(config) {
|
|
241
|
+
const journal = await readMergeJournal(config);
|
|
242
|
+
if (!journal)
|
|
243
|
+
return;
|
|
244
|
+
assertMergeJournalPolicy(journal, config);
|
|
245
|
+
const validateIgnore = ignorePolicyValidator(config);
|
|
246
|
+
if (validateIgnore)
|
|
247
|
+
await validateIgnore();
|
|
248
|
+
if (journal.ignoreSource)
|
|
249
|
+
throw new Error(ignoreMergeRecoveryGuidance);
|
|
250
|
+
await archiveMergeJournal(config);
|
|
251
|
+
}
|
|
252
|
+
async function archiveMergeJournal(config) {
|
|
253
|
+
const file = mergeJournalPath(config);
|
|
254
|
+
await fs.rename(file, `${file}.${randomUUID()}.resolved`);
|
|
255
|
+
await syncDirectory(path.dirname(file));
|
|
256
|
+
}
|
|
257
|
+
export async function reviewInactiveIgnoreMerge(ctx, config, backend, journal, head, options, validateFresh, isCurrent) {
|
|
258
|
+
if (!isCurrent ||
|
|
259
|
+
options.auto ||
|
|
260
|
+
options.background ||
|
|
261
|
+
options.agentAcceptance ||
|
|
262
|
+
options.yes ||
|
|
263
|
+
!ctx.hasUI ||
|
|
264
|
+
(ctx.mode !== "tui" && ctx.mode !== "rpc")) {
|
|
265
|
+
throw new Error(ignoreMergeRecoveryGuidance);
|
|
266
|
+
}
|
|
267
|
+
await validateFresh();
|
|
268
|
+
if (!(await confirmMergeReview(ctx, "Archive the inactive merge journal?", [
|
|
269
|
+
`Setup: ${safeTerminalText(config.setupName)}`,
|
|
270
|
+
"The original remote head and accepted baseline still match the journal, but local files changed.",
|
|
271
|
+
"Archive only the journal. Keep its backup and all current local and remote files. Do not change the baseline.",
|
|
272
|
+
"Run Sync now again to review a fresh plan.",
|
|
273
|
+
].join("\n"), options.signal, isCurrent, "archive journal only")))
|
|
274
|
+
return "cancelled";
|
|
275
|
+
const state = await readStateForConfig(config);
|
|
276
|
+
await validateFresh();
|
|
277
|
+
const latest = await backend.readHead(options.signal);
|
|
278
|
+
if (!isCurrent())
|
|
279
|
+
return "cancelled";
|
|
280
|
+
await validateFresh();
|
|
281
|
+
if (!sameMergeRecoveryHead(backend, head, latest) ||
|
|
282
|
+
syncStateFingerprint(state) !== journal.stateIdentity ||
|
|
283
|
+
syncStateFingerprint(await readStateForConfig(config)) !== journal.stateIdentity) {
|
|
284
|
+
throw new Error("Remote head or sync baseline changed during recovery review; journal and backup retained.");
|
|
285
|
+
}
|
|
286
|
+
await validateFresh();
|
|
287
|
+
await archiveMergeJournal(config);
|
|
288
|
+
if (!options.silent && isCurrent())
|
|
289
|
+
ctx.ui.notify("Archived the inactive merge journal. Local files, remote files, baseline and backup were kept. Run Sync now again for a fresh plan.", "info");
|
|
290
|
+
return "archived";
|
|
291
|
+
}
|
|
292
|
+
export function sameMergeRecoveryHead(backend, left, right) {
|
|
293
|
+
if (!left || !right)
|
|
294
|
+
return left === right;
|
|
295
|
+
return (backend.sameRevision(left.revision, right.revision) &&
|
|
296
|
+
left.snapshotId === right.snapshotId &&
|
|
297
|
+
left.snapshotRef === right.snapshotRef &&
|
|
298
|
+
sameSnapshotSelection(left.selection, right.selection));
|
|
299
|
+
}
|
|
300
|
+
const ignoreMergeRecoveryGuidance = "An ignore-file merged transfer needs recovery; directional --force cannot bypass it. Inactive journal archiving requires foreground review where supported; --yes does not approve it. Preserve the journal, backup and current files if recovery is unavailable. Do not downgrade or restore old bytes blindly.";
|
|
301
|
+
export async function requireNoMergeJournal(config, options = {}) {
|
|
302
|
+
const journal = await readMergeJournal(config);
|
|
303
|
+
if (!journal)
|
|
304
|
+
return;
|
|
305
|
+
assertMergeJournalPolicy(journal, config);
|
|
306
|
+
const validateIgnore = ignorePolicyValidator(config);
|
|
307
|
+
if (validateIgnore)
|
|
308
|
+
await validateIgnore();
|
|
309
|
+
if (journal.ignoreSource)
|
|
310
|
+
throw new Error(ignoreMergeRecoveryGuidance);
|
|
311
|
+
if (!options.force) {
|
|
312
|
+
throw new Error("A merged transfer needs recovery. Run /sync sync to reconcile it. If newer local edits or remote revisions prevent recovery, review /sync diff and explicitly choose push --force or pull --force; the selected directional result will archive the old journal, not restore old bytes. Keep its backup; do not downgrade while recovery is pending.");
|
|
313
|
+
}
|
|
314
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { safeTerminalText } from "../ui/terminal-text.js";
|
|
2
|
+
const MAX_CAUSES = 4;
|
|
3
|
+
const MAX_DETAIL_LENGTH = 600;
|
|
4
|
+
/** Only the sanitized message is displayed; retain the original cause for outcome handling. */
|
|
5
|
+
export function mergeTransferError(error, backend) {
|
|
6
|
+
const messages = [];
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
let current = error;
|
|
9
|
+
while (current instanceof Error && !seen.has(current) && seen.size < MAX_CAUSES) {
|
|
10
|
+
seen.add(current);
|
|
11
|
+
const code = current.code;
|
|
12
|
+
const status = current.status;
|
|
13
|
+
const metadata = [
|
|
14
|
+
typeof code === "string" && /^[A-Z][A-Z0-9_]{1,63}$/u.test(code) ? code : undefined,
|
|
15
|
+
typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599
|
|
16
|
+
? `HTTP ${status}`
|
|
17
|
+
: undefined,
|
|
18
|
+
].filter(Boolean);
|
|
19
|
+
const message = `${current.message}${metadata.length ? ` (${metadata.join(", ")})` : ""}`;
|
|
20
|
+
if (message && !messages.includes(message))
|
|
21
|
+
messages.push(message);
|
|
22
|
+
current = current.cause;
|
|
23
|
+
}
|
|
24
|
+
let detail = messages.join(" → ") || "No error details available.";
|
|
25
|
+
// Redact before truncation or terminal escaping, including overlapping and encoded credentials.
|
|
26
|
+
for (const secret of credentialVariants(backend))
|
|
27
|
+
detail = detail.replaceAll(secret, "[REDACTED]");
|
|
28
|
+
detail = detail.replace(/\b(Bearer|Basic)\s+[^\s<>"']+/giu, "$1 [REDACTED]");
|
|
29
|
+
detail = safeTerminalText(detail);
|
|
30
|
+
if (detail.length > MAX_DETAIL_LENGTH)
|
|
31
|
+
detail = `${detail.slice(0, MAX_DETAIL_LENGTH)}… (details truncated)`;
|
|
32
|
+
return new Error(`Merged transfer interrupted; journal and backup retained. Run /sync sync to reconcile before further mutations. Transfer failure: ${detail}`, { cause: error });
|
|
33
|
+
}
|
|
34
|
+
function credentialVariants(backend) {
|
|
35
|
+
const secrets = [];
|
|
36
|
+
let address;
|
|
37
|
+
switch (backend.type) {
|
|
38
|
+
case "s3":
|
|
39
|
+
secrets.push(backend.profile.accessKeyId, backend.profile.secretAccessKey, backend.profile.sessionToken ?? "");
|
|
40
|
+
address = backend.profile.endpoint;
|
|
41
|
+
break;
|
|
42
|
+
case "webdav":
|
|
43
|
+
secrets.push(backend.profile.username, backend.profile.password, Buffer.from(`${backend.profile.username}:${backend.profile.password}`).toString("base64"));
|
|
44
|
+
address = backend.profile.url;
|
|
45
|
+
break;
|
|
46
|
+
case "git":
|
|
47
|
+
address = backend.profile.remote;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const url = new URL(address);
|
|
52
|
+
secrets.push(url.username, url.password, ...url.searchParams.values());
|
|
53
|
+
for (const value of [url.username, url.password])
|
|
54
|
+
secrets.push(decodeURIComponent(value));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Git SSH shorthand is not a URL; configured Git remotes cannot contain credentials.
|
|
58
|
+
}
|
|
59
|
+
return [
|
|
60
|
+
...new Set(secrets
|
|
61
|
+
.filter(Boolean)
|
|
62
|
+
.flatMap((value) => [value, encodeURIComponent(value), JSON.stringify(value).slice(1, -1)])),
|
|
63
|
+
].sort((left, right) => right.length - left.length);
|
|
64
|
+
}
|