@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { normalizeDirectoryRules } from "../../sync/sync-policy.js";
|
|
3
|
+
import { safeTerminalText } from "../terminal-text.js";
|
|
4
|
+
|
|
5
|
+
export interface DirectoryRulesDraft {
|
|
6
|
+
exclude: string[];
|
|
7
|
+
reinclude: string[];
|
|
8
|
+
sessions: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const DIRECTORY_SCOPE_ALWAYS_LOCAL =
|
|
12
|
+
"Always local: Pi credentials (auth.json), project trust (trust.json), their locks, and Pi Sync's settings and service state. Rules cannot override these protections.";
|
|
13
|
+
|
|
14
|
+
export const SESSION_PRIVACY_WARNING =
|
|
15
|
+
"Session JSONL can contain prompts, tool output, paths, screenshots, and secrets. Sync sessions only to storage you trust.";
|
|
16
|
+
|
|
17
|
+
export function starterDirectoryRules(): DirectoryRulesDraft {
|
|
18
|
+
return { exclude: ["sessions", "bin", "npm"], reinclude: [], sessions: false };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function directorySessionOptInLine(sessions: boolean | undefined) {
|
|
22
|
+
return `Sessions: ${sessions ? "On — explicit opt-in; path rules still apply" : "Off — rules cannot enable sessions"}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function acknowledgeSessions(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
26
|
+
const confirmed = await ctx.ui.confirm("Include session conversations?", SESSION_PRIVACY_WARNING, { signal });
|
|
27
|
+
return !signal?.aborted && confirmed;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function promptDirectoryRules(
|
|
31
|
+
ctx: ExtensionCommandContext,
|
|
32
|
+
kind: "exclude" | "reinclude",
|
|
33
|
+
initial: readonly string[],
|
|
34
|
+
signal?: AbortSignal,
|
|
35
|
+
validate: () => void = () => signal?.throwIfAborted(),
|
|
36
|
+
) {
|
|
37
|
+
let draft = JSON.stringify(initial);
|
|
38
|
+
while (!signal?.aborted) {
|
|
39
|
+
const title = kind === "exclude" ? "Excluded paths" : "Re-included paths";
|
|
40
|
+
const input = await ctx.ui.input(
|
|
41
|
+
`${title}\n\nCurrent rules: ${summarizeDirectoryRules(initial)}\nEnter a JSON string array. Blank keeps the draft; [] clears it.`,
|
|
42
|
+
draft,
|
|
43
|
+
{ signal },
|
|
44
|
+
);
|
|
45
|
+
if (signal?.aborted || input === undefined) return undefined;
|
|
46
|
+
validate();
|
|
47
|
+
draft = input || draft;
|
|
48
|
+
try {
|
|
49
|
+
const parsed: unknown = JSON.parse(draft);
|
|
50
|
+
if (!Array.isArray(parsed)) throw new Error("Enter a JSON string array.");
|
|
51
|
+
return normalizeDirectoryRules(parsed);
|
|
52
|
+
} catch {
|
|
53
|
+
ctx.ui.notify("Invalid rule array or unsupported pattern. No settings changed.", "error");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function summarizeDirectoryRules(rules: readonly string[] = []) {
|
|
60
|
+
if (!rules.length) return "none";
|
|
61
|
+
const sample = rules.slice(0, 5).map((rule) => {
|
|
62
|
+
const safe = safeTerminalText(rule);
|
|
63
|
+
return safe.length > 80 ? `${safe.slice(0, 80)}…` : safe;
|
|
64
|
+
});
|
|
65
|
+
return `${rules.length} · ${sample.join(", ")}${rules.length > sample.length ? ", …" : ""}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function formatDirectoryRules(label: string, rules: readonly string[]) {
|
|
69
|
+
return [`${label}:`, ...(rules.length ? rules.map((rule) => ` ${safeTerminalText(rule)}`) : [" (none)"])];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function directoryScopeLines(draft: DirectoryRulesDraft) {
|
|
73
|
+
return [
|
|
74
|
+
"Scope: Pi agent directory · all eligible files, including custom paths",
|
|
75
|
+
...formatDirectoryRules("Excluded paths", draft.exclude),
|
|
76
|
+
...formatDirectoryRules("Re-included paths (override exclusions)", draft.reinclude),
|
|
77
|
+
directorySessionOptInLine(draft.sessions),
|
|
78
|
+
DIRECTORY_SCOPE_ALWAYS_LOCAL,
|
|
79
|
+
"Synced files can contain sensitive data the secret scanner cannot identify. Review the preview before transferring.",
|
|
80
|
+
];
|
|
81
|
+
}
|
package/src/ui/setup/git-ui.ts
CHANGED
|
@@ -11,13 +11,7 @@ import type { PartialConfig } from "../../settings/settings-types.js";
|
|
|
11
11
|
import { automaticSyncSummary } from "../automatic-sync-summary.js";
|
|
12
12
|
import { safeTerminalText } from "../terminal-text.js";
|
|
13
13
|
import { promptAvailableSetupStorage } from "./setup-location-ui.js";
|
|
14
|
-
import {
|
|
15
|
-
chooseAutomaticSync,
|
|
16
|
-
chooseSetupContent,
|
|
17
|
-
includedContentLines,
|
|
18
|
-
promptResourceName,
|
|
19
|
-
readSetupConnection,
|
|
20
|
-
} from "./setup-prompts.js";
|
|
14
|
+
import { chooseSetupPolicy, finishSetup, promptResourceName, readSetupConnection } from "./setup-prompts.js";
|
|
21
15
|
import { saveReviewedDraft } from "./setup-review.js";
|
|
22
16
|
import { requiredInput, requiredValueInput } from "./text-input.js";
|
|
23
17
|
|
|
@@ -26,10 +20,8 @@ export async function showGitSetup(ctx: ExtensionCommandContext, targetName: str
|
|
|
26
20
|
if (!remote) return false;
|
|
27
21
|
const destination = await promptGitDestination(ctx, signal);
|
|
28
22
|
if (!destination) return false;
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
32
|
-
if (automatic === undefined) return false;
|
|
23
|
+
const policy = await chooseSetupPolicy(ctx, signal);
|
|
24
|
+
if (signal?.aborted || !policy) return false;
|
|
33
25
|
const saved = await saveReviewedDraft(
|
|
34
26
|
ctx,
|
|
35
27
|
"Review Git sync setup",
|
|
@@ -39,8 +31,8 @@ export async function showGitSetup(ctx: ExtensionCommandContext, targetName: str
|
|
|
39
31
|
`Remote: ${safeTerminalText(remote)}`,
|
|
40
32
|
`Sync branch: ${safeTerminalText(destination.branch)}`,
|
|
41
33
|
`Storage location: ${safeTerminalText(destination.directory)}`,
|
|
42
|
-
...
|
|
43
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
34
|
+
...policy.lines,
|
|
35
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
44
36
|
"Authentication: existing Git credential helper or SSH configuration (not stored by pi-sync).",
|
|
45
37
|
"pi-sync manages the entire branch. The repository must already exist; a new branch is created on first push.",
|
|
46
38
|
"Saving does not contact remote storage or start syncing.",
|
|
@@ -58,15 +50,15 @@ export async function showGitSetup(ctx: ExtensionCommandContext, targetName: str
|
|
|
58
50
|
branch: destination.branch,
|
|
59
51
|
path: destination.directory,
|
|
60
52
|
},
|
|
61
|
-
sync:
|
|
53
|
+
sync: policy.sync,
|
|
62
54
|
},
|
|
63
55
|
},
|
|
64
56
|
saveSignal,
|
|
65
57
|
),
|
|
66
58
|
signal,
|
|
67
59
|
);
|
|
68
|
-
if (saved
|
|
69
|
-
ctx
|
|
60
|
+
if (saved)
|
|
61
|
+
await finishSetup(ctx, targetName, `Saved Git sync setup “${safeTerminalText(targetName)}”.`, policy.join, signal);
|
|
70
62
|
return saved;
|
|
71
63
|
}
|
|
72
64
|
|
|
@@ -143,10 +135,8 @@ export async function showAddGitTarget(
|
|
|
143
135
|
signal,
|
|
144
136
|
);
|
|
145
137
|
if (!storage) return false;
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
148
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
149
|
-
if (automatic === undefined) return false;
|
|
138
|
+
const policy = await chooseSetupPolicy(ctx, signal);
|
|
139
|
+
if (signal?.aborted || !policy) return false;
|
|
150
140
|
const connection = await readSetupConnection(profile, signal);
|
|
151
141
|
if (connection?.type !== "git") throw new Error("Storage connection changed; reopen setup.");
|
|
152
142
|
const saved = await saveReviewedDraft(
|
|
@@ -158,15 +148,15 @@ export async function showAddGitTarget(
|
|
|
158
148
|
`Remote: ${safeTerminalText(connection.remote)}`,
|
|
159
149
|
`Sync branch: ${safeTerminalText(storage.branch)}`,
|
|
160
150
|
`Storage location: ${safeTerminalText(storage.path)}`,
|
|
161
|
-
...
|
|
162
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
151
|
+
...policy.lines,
|
|
152
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
163
153
|
"pi-sync manages the entire branch. Adding this setup does not sync or modify remote data.",
|
|
164
154
|
],
|
|
165
155
|
"Add sync setup",
|
|
166
|
-
(saveSignal) => addSyncSetup(name, { storage, sync:
|
|
156
|
+
(saveSignal) => addSyncSetup(name, { storage, sync: policy.sync }, saveSignal, connection),
|
|
167
157
|
signal,
|
|
168
158
|
);
|
|
169
|
-
if (saved
|
|
159
|
+
if (saved) await finishSetup(ctx, name, `Added sync setup “${safeTerminalText(name)}”.`, policy.join, signal);
|
|
170
160
|
return saved;
|
|
171
161
|
}
|
|
172
162
|
|
package/src/ui/setup/s3-ui.ts
CHANGED
|
@@ -11,13 +11,7 @@ import {
|
|
|
11
11
|
chooseInitialRemoteLocation,
|
|
12
12
|
promptAvailableSetupStorage,
|
|
13
13
|
} from "./setup-location-ui.js";
|
|
14
|
-
import {
|
|
15
|
-
chooseAutomaticSync,
|
|
16
|
-
chooseSessions,
|
|
17
|
-
chooseSetupContent,
|
|
18
|
-
includedContentLines,
|
|
19
|
-
readSetupConnection,
|
|
20
|
-
} from "./setup-prompts.js";
|
|
14
|
+
import { chooseSetupPolicy, finishSetup, readSetupConnection } from "./setup-prompts.js";
|
|
21
15
|
import { saveReviewedDraft } from "./setup-review.js";
|
|
22
16
|
import { requiredInput, requiredValueInput } from "./text-input.js";
|
|
23
17
|
|
|
@@ -51,12 +45,8 @@ export async function showS3Setup(
|
|
|
51
45
|
if (!location) return false;
|
|
52
46
|
const credentials = await chooseS3Credentials(ctx, signal);
|
|
53
47
|
if (!credentials) return false;
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
57
|
-
if (automatic === undefined) return false;
|
|
58
|
-
const sessions = await chooseSessions(ctx, signal);
|
|
59
|
-
if (sessions === undefined) return false;
|
|
48
|
+
const policy = await chooseSetupPolicy(ctx, signal, { legacySessions: true });
|
|
49
|
+
if (signal?.aborted || !policy) return false;
|
|
60
50
|
const saved = await saveReviewedDraft(
|
|
61
51
|
ctx,
|
|
62
52
|
"Review sync setup",
|
|
@@ -67,8 +57,8 @@ export async function showS3Setup(
|
|
|
67
57
|
`Region: ${safeTerminalText(region)}`,
|
|
68
58
|
`Bucket: ${safeTerminalText(location.bucket)}`,
|
|
69
59
|
`Storage location: ${safeTerminalText(location.path)}`,
|
|
70
|
-
...
|
|
71
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
60
|
+
...policy.lines,
|
|
61
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
72
62
|
`Credentials: ${credentials.summary}`,
|
|
73
63
|
"The bucket must already exist. Saving does not contact remote storage or start syncing.",
|
|
74
64
|
],
|
|
@@ -93,7 +83,7 @@ export async function showS3Setup(
|
|
|
93
83
|
bucket: location.bucket,
|
|
94
84
|
path: location.path,
|
|
95
85
|
},
|
|
96
|
-
sync:
|
|
86
|
+
sync: policy.sync,
|
|
97
87
|
},
|
|
98
88
|
},
|
|
99
89
|
saveSignal,
|
|
@@ -102,8 +92,7 @@ export async function showS3Setup(
|
|
|
102
92
|
);
|
|
103
93
|
if (!saved || signal?.aborted) return false;
|
|
104
94
|
await refreshTargetCompletions();
|
|
105
|
-
|
|
106
|
-
ctx.ui.notify(`Sync setup “${safeTerminalText(targetName)}” saved. Choose Sync now to start.`, "info");
|
|
95
|
+
await finishSetup(ctx, targetName, `Sync setup “${safeTerminalText(targetName)}” saved.`, policy.join, signal);
|
|
107
96
|
return true;
|
|
108
97
|
}
|
|
109
98
|
|
|
@@ -118,10 +107,8 @@ export async function showAddS3Target(
|
|
|
118
107
|
if (!location) return;
|
|
119
108
|
const storage = await promptAvailableSetupStorage(ctx, { connection: profile, ...location }, signal);
|
|
120
109
|
if (!storage) return;
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
123
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
124
|
-
if (automatic === undefined) return;
|
|
110
|
+
const policy = await chooseSetupPolicy(ctx, signal);
|
|
111
|
+
if (signal?.aborted || !policy) return;
|
|
125
112
|
const connection = await readSetupConnection(profile, signal);
|
|
126
113
|
if (connection.type !== "s3") throw new Error("Storage connection changed; reopen setup.");
|
|
127
114
|
const saved = await saveReviewedDraft(
|
|
@@ -133,18 +120,18 @@ export async function showAddS3Target(
|
|
|
133
120
|
`Endpoint: ${safeTerminalText(connection.endpoint)}`,
|
|
134
121
|
`Bucket: ${safeTerminalText(storage.bucket)}`,
|
|
135
122
|
`Storage location: ${safeTerminalText(storage.path)}`,
|
|
136
|
-
...
|
|
137
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
123
|
+
...policy.lines,
|
|
124
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
138
125
|
"Only the current setup is checked at startup. Shutdown can push selected content when sessions are included.",
|
|
139
126
|
"The bucket must already exist. Adding this setup does not sync or modify remote data.",
|
|
140
127
|
],
|
|
141
128
|
"Add sync setup",
|
|
142
|
-
(saveSignal) => addSyncSetup(name, { storage, sync:
|
|
129
|
+
(saveSignal) => addSyncSetup(name, { storage, sync: policy.sync }, saveSignal, connection),
|
|
143
130
|
signal,
|
|
144
131
|
);
|
|
145
132
|
if (!saved || signal?.aborted) return;
|
|
146
133
|
await refreshTargetCompletions();
|
|
147
|
-
|
|
134
|
+
await finishSetup(ctx, name, `Added sync setup “${safeTerminalText(name)}”.`, policy.join, signal);
|
|
148
135
|
}
|
|
149
136
|
|
|
150
137
|
export async function showEditS3Target(ctx: ExtensionCommandContext, partial: PartialConfig, signal?: AbortSignal) {
|
|
@@ -40,10 +40,6 @@ async function showAddTarget(ctx: ExtensionCommandContext, signal?: AbortSignal)
|
|
|
40
40
|
let raw = await readLocalConfigObject();
|
|
41
41
|
if (signal?.aborted) return;
|
|
42
42
|
if (!raw) return void ctx.ui.notify("Set up the first sync setup before adding another.", "info");
|
|
43
|
-
if (raw.version !== 3 && raw.version !== 4 && raw.version !== 5 && raw.version !== 6) {
|
|
44
|
-
ctx.ui.notify("Version 1 and version 2 settings are unsupported and are never migrated.", "error");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
43
|
let profiles = ownRecord(raw.storageConnections) ?? {};
|
|
48
44
|
const name = await promptResourceName(ctx, "sync setup", "work", signal);
|
|
49
45
|
if (!name) return;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { readLocalConfigObject } from "../../settings/settings-store.js";
|
|
3
|
+
import type { SyncPolicySettings } from "../../settings/settings-types.js";
|
|
3
4
|
import { validateConfigName } from "../../settings/settings-validation.js";
|
|
4
5
|
import { DEFAULT_SYNC_INCLUDE } from "../../sync/sync-policy.js";
|
|
5
6
|
import { AUTOMATIC_SYNC_DESCRIPTION } from "../sync-behavior.js";
|
|
6
7
|
import { safeTerminalText } from "../terminal-text.js";
|
|
8
|
+
import {
|
|
9
|
+
acknowledgeSessions,
|
|
10
|
+
directoryScopeLines,
|
|
11
|
+
promptDirectoryRules,
|
|
12
|
+
starterDirectoryRules,
|
|
13
|
+
} from "./directory-rules.js";
|
|
14
|
+
import { promptTextInput } from "./text-input.js";
|
|
7
15
|
|
|
8
16
|
export { AUTOMATIC_SYNC_DESCRIPTION } from "../sync-behavior.js";
|
|
9
17
|
|
|
10
|
-
import { promptTextInput } from "./text-input.js";
|
|
11
|
-
|
|
12
18
|
export async function readSetupConnection(name: string, signal?: AbortSignal) {
|
|
13
19
|
const connection = (await readLocalConfigObject())?.storageConnections[name];
|
|
14
20
|
signal?.throwIfAborted();
|
|
@@ -16,15 +22,97 @@ export async function readSetupConnection(name: string, signal?: AbortSignal) {
|
|
|
16
22
|
return connection;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
export async function
|
|
25
|
+
export async function chooseSetupPolicy(
|
|
26
|
+
ctx: ExtensionCommandContext,
|
|
27
|
+
signal?: AbortSignal,
|
|
28
|
+
{ legacySessions = false } = {},
|
|
29
|
+
): Promise<{ sync: SyncPolicySettings; lines: string[]; join: boolean } | undefined> {
|
|
20
30
|
const choice = await ctx.ui.select(
|
|
21
|
-
"Choose
|
|
22
|
-
[
|
|
31
|
+
"Choose synced content\n\nAgent directory (recommended): sync all eligible files, including custom paths, except sessions, bin, and npm.\nJoining existing storage? Review its policy after saving. It will not be adopted automatically.\nLegacy mode: use a fixed list of included paths.",
|
|
32
|
+
[
|
|
33
|
+
"Agent directory (recommended)",
|
|
34
|
+
"Agent directory · edit starter rules",
|
|
35
|
+
"Join an existing remote",
|
|
36
|
+
"Recommended Pi settings",
|
|
37
|
+
"Minimal settings",
|
|
38
|
+
"Cancel",
|
|
39
|
+
],
|
|
23
40
|
{ signal },
|
|
24
41
|
);
|
|
25
|
-
signal?.
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
if (signal?.aborted || !choice || choice === "Cancel") return undefined;
|
|
43
|
+
const join = choice === "Join an existing remote";
|
|
44
|
+
if (
|
|
45
|
+
!join &&
|
|
46
|
+
choice !== "Agent directory (recommended)" &&
|
|
47
|
+
choice !== "Agent directory · edit starter rules" &&
|
|
48
|
+
choice !== "Recommended Pi settings" &&
|
|
49
|
+
choice !== "Minimal settings"
|
|
50
|
+
)
|
|
51
|
+
return undefined;
|
|
52
|
+
const joinScope = join
|
|
53
|
+
? await ctx.ui.select(
|
|
54
|
+
"Choose the existing remote's scope\n\nUse Selected paths for an older setup with an include list. These choices do not change the remote's scope.",
|
|
55
|
+
["Pi agent directory", "Selected paths (legacy)", "Cancel"],
|
|
56
|
+
{ signal },
|
|
57
|
+
)
|
|
58
|
+
: undefined;
|
|
59
|
+
if (signal?.aborted || (join && joinScope !== "Pi agent directory" && joinScope !== "Selected paths (legacy)"))
|
|
60
|
+
return undefined;
|
|
61
|
+
const legacy =
|
|
62
|
+
choice === "Recommended Pi settings" || choice === "Minimal settings" || joinScope === "Selected paths (legacy)";
|
|
63
|
+
const draft = starterDirectoryRules();
|
|
64
|
+
const editRules = choice === "Agent directory · edit starter rules";
|
|
65
|
+
if (editRules) {
|
|
66
|
+
const exclude = await promptDirectoryRules(ctx, "exclude", draft.exclude, signal);
|
|
67
|
+
if (signal?.aborted || !exclude) return undefined;
|
|
68
|
+
draft.exclude = exclude;
|
|
69
|
+
const reinclude = await promptDirectoryRules(ctx, "reinclude", draft.reinclude, signal);
|
|
70
|
+
if (signal?.aborted || !reinclude) return undefined;
|
|
71
|
+
draft.reinclude = reinclude;
|
|
72
|
+
}
|
|
73
|
+
const automatic = join ? false : await chooseAutomaticSync(ctx, signal);
|
|
74
|
+
if (signal?.aborted || automatic === undefined) return undefined;
|
|
75
|
+
const sessions = join || (legacy && !legacySessions) ? false : await chooseSessions(ctx, signal);
|
|
76
|
+
if (signal?.aborted || sessions === undefined) return undefined;
|
|
77
|
+
const remoteWarning = join
|
|
78
|
+
? "After saving, compare the remote policy. Automatic sync and sessions start Off. No policy is adopted without your review."
|
|
79
|
+
: "If this location already has sync data, compare its policy in Settings before transferring. A mismatch blocks sync.";
|
|
80
|
+
if (legacy) {
|
|
81
|
+
const include = choice === "Minimal settings" ? ["settings.json", "AGENTS.md"] : [...DEFAULT_SYNC_INCLUDE];
|
|
82
|
+
return {
|
|
83
|
+
sync: { include: [...include, ...(sessions ? ["sessions"] : [])], automatic },
|
|
84
|
+
lines: [...includedContentLines(include, sessions), remoteWarning],
|
|
85
|
+
join,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
draft.sessions = sessions;
|
|
89
|
+
if (sessions && !editRules) draft.exclude = draft.exclude.filter((rule) => rule !== "sessions");
|
|
90
|
+
return {
|
|
91
|
+
sync: {
|
|
92
|
+
scope: "agent-directory",
|
|
93
|
+
exclude: draft.exclude,
|
|
94
|
+
...(draft.reinclude.length ? { reinclude: draft.reinclude } : {}),
|
|
95
|
+
sessions: draft.sessions,
|
|
96
|
+
automatic,
|
|
97
|
+
},
|
|
98
|
+
lines: [...directoryScopeLines(draft), remoteWarning],
|
|
99
|
+
join,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function finishSetup(
|
|
104
|
+
ctx: ExtensionCommandContext,
|
|
105
|
+
name: string,
|
|
106
|
+
message: string,
|
|
107
|
+
join: boolean,
|
|
108
|
+
signal?: AbortSignal,
|
|
109
|
+
) {
|
|
110
|
+
if (signal?.aborted) return;
|
|
111
|
+
ctx.ui.notify(message, "info");
|
|
112
|
+
if (!join) return;
|
|
113
|
+
const { showRemoteSelectionReview } = await import("../remote-selection-ui.js");
|
|
114
|
+
if (signal?.aborted) return;
|
|
115
|
+
await showRemoteSelectionReview(ctx, name, signal, undefined, { origin: "settings" });
|
|
28
116
|
}
|
|
29
117
|
|
|
30
118
|
export async function chooseAutomaticSync(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
@@ -37,7 +125,7 @@ export async function chooseAutomaticSync(ctx: ExtensionCommandContext, signal?:
|
|
|
37
125
|
return !choice || choice === "Cancel" ? undefined : choice === "Enable automatic sync";
|
|
38
126
|
}
|
|
39
127
|
|
|
40
|
-
|
|
128
|
+
async function chooseSessions(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
41
129
|
const choice = await ctx.ui.select(
|
|
42
130
|
"Session conversations\n\nSessions can contain prompts, tool output, paths, screenshots, and secrets.",
|
|
43
131
|
["Keep sessions off (recommended)", "Include session conversations", "Cancel"],
|
|
@@ -46,16 +134,10 @@ export async function chooseSessions(ctx: ExtensionCommandContext, signal?: Abor
|
|
|
46
134
|
signal?.throwIfAborted();
|
|
47
135
|
if (!choice || choice === "Cancel") return undefined;
|
|
48
136
|
if (choice !== "Include session conversations") return false;
|
|
49
|
-
|
|
50
|
-
"Include session conversations?",
|
|
51
|
-
"I understand that session JSONL can contain prompts, tool output, paths, screenshots, and secrets.",
|
|
52
|
-
{ signal },
|
|
53
|
-
);
|
|
54
|
-
signal?.throwIfAborted();
|
|
55
|
-
return confirmed ? true : undefined;
|
|
137
|
+
return (await acknowledgeSessions(ctx, signal)) ? true : undefined;
|
|
56
138
|
}
|
|
57
139
|
|
|
58
|
-
|
|
140
|
+
function includedContentLines(include: readonly string[], sessions = false) {
|
|
59
141
|
const paths = [...include, ...(sessions && !include.includes("sessions") ? ["sessions"] : [])];
|
|
60
142
|
return [
|
|
61
143
|
`Included content: ${paths.length} paths`,
|
|
@@ -79,7 +79,7 @@ export async function showSetupSwitcher(
|
|
|
79
79
|
) {
|
|
80
80
|
const raw = await readLocalConfigObject();
|
|
81
81
|
if (signal?.aborted) return false;
|
|
82
|
-
if (raw
|
|
82
|
+
if (!raw) {
|
|
83
83
|
ctx.ui.notify("Add a second sync setup before switching setups.", "info");
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
@@ -127,7 +127,9 @@ export async function showSetupSwitcher(
|
|
|
127
127
|
`From: ${safeTerminalText(active ?? "none")}`,
|
|
128
128
|
`To: ${safeTerminalText(name)}`,
|
|
129
129
|
`Storage: ${backendStorageDescription(config)}`,
|
|
130
|
-
|
|
130
|
+
config.scope === "agent-directory"
|
|
131
|
+
? `Scope: Pi agent directory · ${config.exclude?.length ?? 0} excluded and ${config.reinclude?.length ?? 0} re-included rules`
|
|
132
|
+
: `Included content: ${config.include.length} paths`,
|
|
131
133
|
`Automatic sync: ${automaticSyncSummary(config.automatic)} · Sessions: ${syncSessionsSelected(config) ? "On" : "Off"}`,
|
|
132
134
|
`Automatic transfer at startup: ${config.automaticTransfer ? "On — may upload, replace, or delete selected files; no reload" : "Off"}`,
|
|
133
135
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
@@ -9,10 +9,11 @@ import { showWebDavSetup } from "./webdav-ui.js";
|
|
|
9
9
|
|
|
10
10
|
export async function showSetupWizard(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
11
11
|
if (ctx.mode !== "tui") {
|
|
12
|
-
ctx.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (ctx.hasUI)
|
|
13
|
+
ctx.ui.notify(
|
|
14
|
+
`Guided sync setup requires TUI mode for masked credential input. Create settings in ${safeTerminalText(localConfigPath())} (version 7 for agent-directory scope).`,
|
|
15
|
+
"warning",
|
|
16
|
+
);
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
19
|
const preset = await ctx.ui.select(
|
|
@@ -16,14 +16,7 @@ import { automaticSyncSummary } from "../automatic-sync-summary.js";
|
|
|
16
16
|
import { promptSecret } from "../secret-input.js";
|
|
17
17
|
import { safeTerminalText as safe } from "../terminal-text.js";
|
|
18
18
|
import { promptAvailableSetupStorage } from "./setup-location-ui.js";
|
|
19
|
-
import {
|
|
20
|
-
chooseAutomaticSync,
|
|
21
|
-
chooseSessions,
|
|
22
|
-
chooseSetupContent,
|
|
23
|
-
includedContentLines,
|
|
24
|
-
promptResourceName,
|
|
25
|
-
readSetupConnection,
|
|
26
|
-
} from "./setup-prompts.js";
|
|
19
|
+
import { chooseSetupPolicy, finishSetup, promptResourceName, readSetupConnection } from "./setup-prompts.js";
|
|
27
20
|
import { saveReviewedDraft } from "./setup-review.js";
|
|
28
21
|
import { promptTextInput } from "./text-input.js";
|
|
29
22
|
|
|
@@ -37,12 +30,8 @@ export async function showWebDavSetup(ctx: ExtensionCommandContext, targetName:
|
|
|
37
30
|
if (password === undefined) return false;
|
|
38
31
|
const remotePath = await chooseDestination(ctx, signal);
|
|
39
32
|
if (!remotePath) return false;
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
43
|
-
if (automatic === undefined) return false;
|
|
44
|
-
const sessions = await chooseSessions(ctx, signal);
|
|
45
|
-
if (sessions === undefined) return false;
|
|
33
|
+
const policy = await chooseSetupPolicy(ctx, signal, { legacySessions: true });
|
|
34
|
+
if (signal?.aborted || !policy) return false;
|
|
46
35
|
const saved = await saveReviewedDraft(
|
|
47
36
|
ctx,
|
|
48
37
|
"Review WebDAV setup",
|
|
@@ -52,8 +41,8 @@ export async function showWebDavSetup(ctx: ExtensionCommandContext, targetName:
|
|
|
52
41
|
`URL: ${safe(url)}`,
|
|
53
42
|
`Storage location: ${safe(remotePath)}`,
|
|
54
43
|
"Username and password: stored privately (values hidden)",
|
|
55
|
-
...
|
|
56
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
44
|
+
...policy.lines,
|
|
45
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
57
46
|
"Check setup tests whether this server can safely save sync updates using a temporary probe.",
|
|
58
47
|
"Saving does not contact remote storage or start syncing.",
|
|
59
48
|
],
|
|
@@ -66,15 +55,14 @@ export async function showWebDavSetup(ctx: ExtensionCommandContext, targetName:
|
|
|
66
55
|
connection: { type: "webdav", url, credentials: { username, password } },
|
|
67
56
|
setup: {
|
|
68
57
|
storage: { connection: targetName, path: remotePath },
|
|
69
|
-
sync:
|
|
58
|
+
sync: policy.sync,
|
|
70
59
|
},
|
|
71
60
|
},
|
|
72
61
|
saveSignal,
|
|
73
62
|
),
|
|
74
63
|
signal,
|
|
75
64
|
);
|
|
76
|
-
if (saved
|
|
77
|
-
ctx.ui.notify(`Sync setup “${safe(targetName)}” saved. Choose Sync now to start.`, "info");
|
|
65
|
+
if (saved) await finishSetup(ctx, targetName, `Sync setup “${safe(targetName)}” saved.`, policy.join, signal);
|
|
78
66
|
return saved;
|
|
79
67
|
}
|
|
80
68
|
|
|
@@ -88,10 +76,8 @@ export async function showAddWebDavTarget(
|
|
|
88
76
|
if (!remotePath) return false;
|
|
89
77
|
const storage = await promptAvailableSetupStorage(ctx, { connection: profile, path: remotePath }, signal);
|
|
90
78
|
if (!storage) return false;
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
93
|
-
const automatic = await chooseAutomaticSync(ctx, signal);
|
|
94
|
-
if (automatic === undefined) return false;
|
|
79
|
+
const policy = await chooseSetupPolicy(ctx, signal);
|
|
80
|
+
if (signal?.aborted || !policy) return false;
|
|
95
81
|
const connection = await readSetupConnection(profile, signal);
|
|
96
82
|
if (connection.type !== "webdav") throw new Error("Storage connection changed; reopen setup.");
|
|
97
83
|
const saved = await saveReviewedDraft(
|
|
@@ -102,15 +88,15 @@ export async function showAddWebDavTarget(
|
|
|
102
88
|
`Storage connection: ${safe(profile)}`,
|
|
103
89
|
`URL: ${safe(connection.url)}`,
|
|
104
90
|
`Storage location: ${safe(storage.path)}`,
|
|
105
|
-
...
|
|
106
|
-
`Automatic sync: ${automaticSyncSummary(automatic)}`,
|
|
91
|
+
...policy.lines,
|
|
92
|
+
`Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
|
|
107
93
|
"Adding this setup does not sync or modify remote data.",
|
|
108
94
|
],
|
|
109
95
|
"Add sync setup",
|
|
110
|
-
(saveSignal) => addSyncSetup(name, { storage, sync:
|
|
96
|
+
(saveSignal) => addSyncSetup(name, { storage, sync: policy.sync }, saveSignal, connection),
|
|
111
97
|
signal,
|
|
112
98
|
);
|
|
113
|
-
if (saved
|
|
99
|
+
if (saved) await finishSetup(ctx, name, `Added sync setup “${safe(name)}”.`, policy.join, signal);
|
|
114
100
|
return saved;
|
|
115
101
|
}
|
|
116
102
|
|