@narumitw/pi-sync 0.67.3 → 0.68.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 +7 -0
- package/README.md +26 -48
- package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
- package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
- package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
- package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
- package/dist/chunks/{chunk-HLJIRWFL.ts → chunk-BCDBT4X3.ts} +7 -7
- package/dist/chunks/{chunk-AVTW6WNP.ts → chunk-FQKWGVMA.ts} +20 -54
- package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
- package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
- package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
- package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
- package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
- package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
- package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
- package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
- package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
- package/dist/chunks/{chunk-X344HTVV.ts → chunk-WCGLU526.ts} +39 -118
- package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
- package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
- package/dist/chunks/{chunk-CQ4DMLH3.ts → chunk-YV2R5SJU.ts} +21 -81
- package/dist/chunks/chunk-YV2R5SJU.ts.map +7 -0
- package/dist/chunks/{command-handler-WF2TDDRZ.ts → command-handler-S6BRZMPW.ts} +64 -59
- package/dist/chunks/command-handler-S6BRZMPW.ts.map +7 -0
- package/dist/chunks/{conflict-review-GWEL4S6C.ts → conflict-review-3XMYDJIK.ts} +2 -2
- package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
- package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
- package/dist/chunks/{manager-ui-FS4QIKRA.ts → manager-ui-KHMCSLLV.ts} +114 -581
- package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
- package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
- package/dist/chunks/{remote-selection-ui-DOYKUMER.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
- package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
- package/dist/chunks/{setup-wizard-PI45SF2C.ts → setup-wizard-2NRPR433.ts} +11 -16
- package/dist/chunks/{setup-wizard-PI45SF2C.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-DI5J6EUH.ts → sync-inspection-QGM54YCM.ts} +5 -5
- package/dist/chunks/{sync-operations-AGNL7QXA.ts → sync-operations-DTQMKVRQ.ts} +2 -2
- package/dist/daemon/dist/build-id.json +1 -1
- package/dist/daemon/dist/cli.js +22 -3
- package/dist/daemon/dist/client-transport.js +2 -0
- package/dist/daemon/dist/client.js +2 -10
- package/dist/daemon/dist/consent.js +13 -135
- package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
- package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
- package/dist/daemon/dist/engine/settings/config.js +16 -149
- package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
- package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
- package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
- package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
- package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
- package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
- package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
- package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
- package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
- package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
- package/dist/daemon/dist/engine/sync/initialization.js +4 -15
- package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
- package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
- package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
- package/dist/daemon/dist/engine/sync/merged-sync.js +12 -70
- package/dist/daemon/dist/engine/sync/push-review.js +1 -16
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
- package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
- package/dist/daemon/dist/engine/sync/sync-mutations.js +25 -118
- package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
- package/dist/daemon/dist/engine/sync/sync-queries.js +1 -8
- package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
- package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
- package/dist/daemon/dist/engine-service.js +60 -219
- package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
- package/dist/daemon/dist/legacy-consent-guard.js +34 -0
- package/dist/daemon/dist/server.js +4 -8
- package/dist/daemon/dist/service-host.js +3 -9
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +45 -46
- package/dist/index.ts.map +3 -3
- package/docs/continuous-sync-verification.md +1 -1
- package/docs/daemon-migration.md +7 -5
- package/docs/tui-contract.md +4 -6
- package/package.json +2 -3
- package/skills/configure-pi-sync/SKILL.md +18 -77
- package/skills/configure-pi-sync/references/configuration.md +58 -75
- package/src/commands/command-execution.ts +13 -29
- package/src/commands/command-handler.ts +0 -4
- package/src/commands/command.ts +2 -1
- package/src/daemon/directional-recovery.ts +4 -33
- package/src/daemon/pi-client.ts +20 -88
- package/src/settings/config.ts +0 -1
- package/src/sync/setup-switch.ts +1 -4
- package/src/sync-extension.ts +10 -24
- package/src/ui/cancellable-operation.ts +2 -13
- package/src/ui/excluded-paths-ui.ts +1 -4
- package/src/ui/file-selection.ts +0 -5
- package/src/ui/manager-state.ts +12 -75
- package/src/ui/manager-ui.ts +7 -96
- package/src/ui/remote-selection-ui.ts +29 -130
- package/src/ui/settings-ui.ts +169 -388
- package/src/ui/setup/setup-actions.ts +4 -16
- package/src/ui/setup/setup-prompts.ts +12 -49
- package/src/ui/setup/setup-switcher.ts +8 -14
- package/src/ui/storage-connections-ui.ts +21 -32
- package/src/ui/sync-setups-ui.ts +27 -53
- package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
- package/dist/chunks/chunk-33EDXDLC.ts +0 -106
- package/dist/chunks/chunk-33EDXDLC.ts.map +0 -7
- package/dist/chunks/chunk-AVTW6WNP.ts.map +0 -7
- package/dist/chunks/chunk-CQ4DMLH3.ts.map +0 -7
- package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
- package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
- package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
- package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
- package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
- package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
- package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
- package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
- package/dist/chunks/chunk-X344HTVV.ts.map +0 -7
- package/dist/chunks/command-handler-WF2TDDRZ.ts.map +0 -7
- package/dist/chunks/config-P54GGMXY.ts +0 -39
- package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
- package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
- package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
- package/dist/chunks/ignore-file-ui-BEZZZIEE.ts +0 -21
- package/dist/chunks/manager-ui-FS4QIKRA.ts.map +0 -7
- package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
- package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-DOYKUMER.ts.map +0 -7
- package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
- package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
- package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
- package/dist/daemon/dist/monitor.js +0 -344
- package/src/ui/agent-mode-setting.ts +0 -99
- package/src/ui/ignore-file-guidance.ts +0 -7
- package/src/ui/ignore-file-ui.ts +0 -105
- package/src/ui/ignore-migration-prompt.ts +0 -65
- package/src/ui/settings-review.ts +0 -26
- /package/dist/chunks/{chunk-HLJIRWFL.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
- /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
- /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
- /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-GWEL4S6C.ts.map → conflict-review-3XMYDJIK.ts.map} +0 -0
- /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
- /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-BEZZZIEE.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-DI5J6EUH.ts.map → sync-inspection-QGM54YCM.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-AGNL7QXA.ts.map → sync-operations-DTQMKVRQ.ts.map} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { currentPiDaemonClient } from "../daemon/pi-client.js";
|
|
3
2
|
import { loadConfig } from "../settings/config.js";
|
|
4
3
|
import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
|
|
5
4
|
import { combineSignals } from "../sync/signals.js";
|
|
@@ -41,7 +40,6 @@ export async function handleCommand(
|
|
|
41
40
|
onDialog?: (active: boolean) => void,
|
|
42
41
|
retryRefusal = false,
|
|
43
42
|
directionalFingerprint?: string,
|
|
44
|
-
requirePendingAdoption?: boolean,
|
|
45
43
|
) => {
|
|
46
44
|
const [command, ...args] = splitArgs(route);
|
|
47
45
|
if (command === "sync" && !retryRefusal) {
|
|
@@ -63,7 +61,6 @@ export async function handleCommand(
|
|
|
63
61
|
onDialog,
|
|
64
62
|
retryRefusal,
|
|
65
63
|
directionalFingerprint,
|
|
66
|
-
requirePendingAdoption,
|
|
67
64
|
);
|
|
68
65
|
};
|
|
69
66
|
if (!rawArgs.trim()) {
|
|
@@ -73,7 +70,6 @@ export async function handleCommand(
|
|
|
73
70
|
if (sessionSignal.aborted) return;
|
|
74
71
|
await showSyncManager(ctx, run, sessionSignal, {
|
|
75
72
|
needsDaemonRecovery,
|
|
76
|
-
getPendingPullReview: () => currentPiDaemonClient()?.pendingPullReview,
|
|
77
73
|
getAttention: () => attention.current(),
|
|
78
74
|
getObservation: () => attention.observation(),
|
|
79
75
|
onObservationInvalidated: () => attention.clearObservation(),
|
package/src/commands/command.ts
CHANGED
|
@@ -260,7 +260,8 @@ export function usage() {
|
|
|
260
260
|
`Automatic sync: ${AUTOMATIC_SYNC_DESCRIPTION}`,
|
|
261
261
|
`Startup transfer: ${STARTUP_TRANSFER_DESCRIPTION}`,
|
|
262
262
|
"Automatic transfer at startup is a separate opt-in: one conflict-free established-baseline transfer at idle in TUI/RPC, with conditional/lease publication and no resource reload.",
|
|
263
|
-
"
|
|
263
|
+
"Autonomous sync and Continuous sync are retired. Saved flags no longer transfer files or call a model. Use Sync now to review a transfer or enable Startup transfer for one eligible startup sync.",
|
|
264
|
+
"New after-exit grants are not supported. Use /sync daemon revoke-after-exit to clear a retained grant.",
|
|
264
265
|
"Settings: use /sync init or edit storage connections and sync setups in ~/.pi/agent/pi-sync.json (or the configured Pi agent directory). Version 1 and version 2 settings are unsupported and are never rewritten.",
|
|
265
266
|
].join("\n");
|
|
266
267
|
}
|
|
@@ -32,11 +32,6 @@ export class DirectionalCheckpoint {
|
|
|
32
32
|
function recoveryOutcome(value: unknown) {
|
|
33
33
|
if (!value || typeof value !== "object" || !("foregroundQueueCleanup" in value)) return;
|
|
34
34
|
if (value.foregroundQueueCleanup === "before-mutation") return { phase: "unchanged" as const };
|
|
35
|
-
if (value.foregroundQueueCleanup === "resume-adoption") {
|
|
36
|
-
if (!("journal" in value) || typeof value.journal !== "string" || !/^[a-f0-9]{64}$/u.test(value.journal))
|
|
37
|
-
throw new Error("The recorded Pull could not be verified. Use /sync daemon recover.");
|
|
38
|
-
return { phase: "adoption" as const, journal: value.journal };
|
|
39
|
-
}
|
|
40
35
|
if (value.foregroundQueueCleanup === "verified-result" && "result" in value)
|
|
41
36
|
return { phase: "completed" as const, result: value.result };
|
|
42
37
|
}
|
|
@@ -58,26 +53,16 @@ function cancelledAfterCompletion(result: unknown, cause: unknown) {
|
|
|
58
53
|
return error;
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
export interface PendingAdoptionRecovery {
|
|
62
|
-
owner: DaemonConnection;
|
|
63
|
-
job: string;
|
|
64
|
-
journal: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
56
|
export async function runDirectionalRecovery(
|
|
68
57
|
connection: DaemonConnection,
|
|
69
58
|
signal: AbortSignal,
|
|
70
|
-
run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string
|
|
59
|
+
run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string) => Promise<unknown>,
|
|
71
60
|
recover: (connection: DaemonConnection, job: string, signal: AbortSignal) => Promise<DaemonConnection>,
|
|
72
61
|
markCleanupRequired: () => void,
|
|
73
|
-
adoption?: { pending?: PendingAdoptionRecovery; retain(value: PendingAdoptionRecovery | undefined): void },
|
|
74
62
|
) {
|
|
75
63
|
signal.throwIfAborted();
|
|
76
|
-
const pending = adoption?.pending;
|
|
77
|
-
if (pending && pending.owner !== connection) throw new Error("The daemon changed before Pull recovery.");
|
|
78
64
|
const attempt = new DirectionalCheckpoint(connection);
|
|
79
|
-
|
|
80
|
-
const result = pending ? { foregroundQueueCleanup: "resume-adoption", journal: pending.journal } : await run(attempt);
|
|
65
|
+
const result = await run(attempt);
|
|
81
66
|
const primary = recoveryOutcome(result);
|
|
82
67
|
if (!primary) return result;
|
|
83
68
|
markCleanupRequired();
|
|
@@ -85,16 +70,9 @@ export async function runDirectionalRecovery(
|
|
|
85
70
|
const bounded = AbortSignal.any([signal, AbortSignal.timeout(45_000)]);
|
|
86
71
|
try {
|
|
87
72
|
bounded.throwIfAborted();
|
|
88
|
-
if (
|
|
89
|
-
!attempt.job ||
|
|
90
|
-
(primary.phase === "unchanged" && !attempt.fingerprint) ||
|
|
91
|
-
(primary.phase === "adoption" && (!adoption || (!pending && !attempt.fingerprint)))
|
|
92
|
-
)
|
|
73
|
+
if (!attempt.job || (primary.phase === "unchanged" && !attempt.fingerprint))
|
|
93
74
|
throw new Error("The original transfer scope could not be verified.");
|
|
94
|
-
if (primary.phase === "adoption")
|
|
95
|
-
adoption?.retain({ owner: connection, job: attempt.job, journal: primary.journal });
|
|
96
75
|
replacement = await recover(connection, attempt.job, bounded);
|
|
97
|
-
if (primary.phase === "adoption") adoption?.retain(undefined);
|
|
98
76
|
bounded.throwIfAborted();
|
|
99
77
|
} catch (error) {
|
|
100
78
|
if (signal.aborted) {
|
|
@@ -107,14 +85,12 @@ export async function runDirectionalRecovery(
|
|
|
107
85
|
`The transfer finished, but file-queue recovery stopped. ${detail}${restoreMessage(primary.result)}`,
|
|
108
86
|
{ cause: error },
|
|
109
87
|
);
|
|
110
|
-
if (primary.phase === "adoption")
|
|
111
|
-
throw new Error(`Pull recovery stopped. The adoption journal was kept. ${detail}`, { cause: error });
|
|
112
88
|
throw new Error(`No transfer was applied, but file-queue recovery stopped. ${detail}`, { cause: error });
|
|
113
89
|
}
|
|
114
90
|
if (primary.phase === "completed") return primary.result;
|
|
115
91
|
const retryCheckpoint = primary.phase === "unchanged" ? attempt.fingerprint : undefined;
|
|
116
92
|
const retry = new DirectionalCheckpoint(replacement, retryCheckpoint);
|
|
117
|
-
const retried = await run(retry, retryCheckpoint
|
|
93
|
+
const retried = await run(retry, retryCheckpoint);
|
|
118
94
|
const remaining = recoveryOutcome(retried);
|
|
119
95
|
if (!remaining) return retried;
|
|
120
96
|
markCleanupRequired();
|
|
@@ -124,10 +100,5 @@ export async function runDirectionalRecovery(
|
|
|
124
100
|
`Transfer finished, but file-queue cleanup is still uncertain after one recovery attempt.${restoreMessage(remaining.result)}`,
|
|
125
101
|
);
|
|
126
102
|
}
|
|
127
|
-
if (remaining.phase === "adoption") {
|
|
128
|
-
if (retry.job && retry.fingerprint)
|
|
129
|
-
adoption?.retain({ owner: replacement, job: retry.job, journal: remaining.journal });
|
|
130
|
-
throw new Error("File-queue cleanup is still uncertain after one recovery attempt. The adoption journal was kept.");
|
|
131
|
-
}
|
|
132
103
|
throw new Error("File-queue release could not be verified after one recovery attempt. No transfer was applied.");
|
|
133
104
|
}
|
package/src/daemon/pi-client.ts
CHANGED
|
@@ -44,17 +44,17 @@ import {
|
|
|
44
44
|
import { safeTerminalText } from "../ui/terminal-text.js";
|
|
45
45
|
import { PiApplyGate } from "./apply-gate.js";
|
|
46
46
|
import { observeDebugJob } from "./client-debug.js";
|
|
47
|
-
import {
|
|
48
|
-
type DirectionalCheckpoint,
|
|
49
|
-
isForegroundDirection,
|
|
50
|
-
type PendingAdoptionRecovery,
|
|
51
|
-
runDirectionalRecovery,
|
|
52
|
-
} from "./directional-recovery.js";
|
|
47
|
+
import { type DirectionalCheckpoint, isForegroundDirection, runDirectionalRecovery } from "./directional-recovery.js";
|
|
53
48
|
import { createQueueReleaseUI, type QueueReleaseEvent } from "./queue-release-ui.js";
|
|
54
49
|
import { quarantineClient, recoverDetachedClients } from "./recovery.js";
|
|
55
50
|
import { requestStartupBootstrap } from "./startup-bootstrap-client.js";
|
|
56
51
|
|
|
52
|
+
const PROTECTION_ONLY_GUIDANCE =
|
|
53
|
+
"This session is only protecting its files on an incompatible Pi Sync daemon. Stop it safely, then use /reload with the matching build.";
|
|
54
|
+
|
|
57
55
|
type DaemonAddress = Pick<Awaited<ReturnType<typeof ensureDaemon>>, "paths" | "identity" | "needsUpgrade"> & {
|
|
56
|
+
ignoreFilesRetired?: boolean;
|
|
57
|
+
autonomousSyncRetired?: boolean;
|
|
58
58
|
upgradeStop?: boolean;
|
|
59
59
|
};
|
|
60
60
|
|
|
@@ -280,11 +280,6 @@ export class PiDaemonClient {
|
|
|
280
280
|
private reloadRequest?: { received: boolean };
|
|
281
281
|
private pendingReload?: AbortController;
|
|
282
282
|
private directionalCheckpoint?: DirectionalCheckpoint;
|
|
283
|
-
private adoptionRecovery?: {
|
|
284
|
-
pending: PendingAdoptionRecovery;
|
|
285
|
-
review: { setupName: string; fingerprint: string };
|
|
286
|
-
assertRoot(): void;
|
|
287
|
-
};
|
|
288
283
|
private recoveringDirectionalOwner = false;
|
|
289
284
|
private readonly busy = new Set<string>();
|
|
290
285
|
private initialized = false;
|
|
@@ -506,10 +501,7 @@ export class PiDaemonClient {
|
|
|
506
501
|
validateStartup();
|
|
507
502
|
if (!existing && this.blockedUpgrade?.error !== undefined) throw this.blockedUpgrade.error;
|
|
508
503
|
if (this.connection) {
|
|
509
|
-
if (!existing && this.protectionOnly)
|
|
510
|
-
throw new Error(
|
|
511
|
-
"This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.",
|
|
512
|
-
);
|
|
504
|
+
if (!existing && this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
513
505
|
return this.connection;
|
|
514
506
|
}
|
|
515
507
|
this.connecting ??= (async () => {
|
|
@@ -534,7 +526,7 @@ export class PiDaemonClient {
|
|
|
534
526
|
: await this.ensureWithSessionProtection(startupSignal, validateStartup);
|
|
535
527
|
validateStartup();
|
|
536
528
|
if (daemon.paths.root !== this.root) throw new Error("Daemon root changed before attach.");
|
|
537
|
-
const protectionOnly = daemon.needsUpgrade
|
|
529
|
+
const protectionOnly = daemon.needsUpgrade || !daemon.ignoreFilesRetired || !daemon.autonomousSyncRetired;
|
|
538
530
|
const connection = new DaemonConnection(daemon.paths, daemon.identity, this.facts(protectionOnly), {
|
|
539
531
|
callback: (callback, signal) => this.callback(connection, callback, signal, protectionOnly),
|
|
540
532
|
mergeReview:
|
|
@@ -631,8 +623,7 @@ export class PiDaemonClient {
|
|
|
631
623
|
const connection = await this.connecting;
|
|
632
624
|
validateStartup();
|
|
633
625
|
if (!existing && this.blockedUpgrade?.error !== undefined) throw this.blockedUpgrade.error;
|
|
634
|
-
if (!existing && this.protectionOnly)
|
|
635
|
-
throw new Error("This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.");
|
|
626
|
+
if (!existing && this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
636
627
|
return connection;
|
|
637
628
|
}
|
|
638
629
|
private ownsContactUI() {
|
|
@@ -796,7 +787,7 @@ export class PiDaemonClient {
|
|
|
796
787
|
this.assertNoDirectionalRecovery();
|
|
797
788
|
const connection = this.connection;
|
|
798
789
|
if (!connection) return;
|
|
799
|
-
if (this.protectionOnly) throw new Error(
|
|
790
|
+
if (this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
800
791
|
await this.publishFacts(connection, signal);
|
|
801
792
|
this.validateFactsScope(connection, signal);
|
|
802
793
|
this.assertNoDirectionalRecovery();
|
|
@@ -825,20 +816,7 @@ export class PiDaemonClient {
|
|
|
825
816
|
get ownershipCleanupRequired() {
|
|
826
817
|
return this.cleanupRequired;
|
|
827
818
|
}
|
|
828
|
-
get pendingPullReview() {
|
|
829
|
-
const recovery = this.adoptionRecovery;
|
|
830
|
-
if (
|
|
831
|
-
!this.cleanupRequired ||
|
|
832
|
-
!recovery ||
|
|
833
|
-
this.paused ||
|
|
834
|
-
recovery.pending.owner !== this.connection ||
|
|
835
|
-
!recovery.pending.owner.canRecoverForeground(recovery.pending.job)
|
|
836
|
-
)
|
|
837
|
-
return undefined;
|
|
838
|
-
return recovery.review;
|
|
839
|
-
}
|
|
840
819
|
confirmRecoveryExit(owner: DaemonRecoveryTarget) {
|
|
841
|
-
this.adoptionRecovery = undefined;
|
|
842
820
|
this.cleanupRequired = true;
|
|
843
821
|
this.recoveredOwner = owner;
|
|
844
822
|
}
|
|
@@ -861,17 +839,10 @@ export class PiDaemonClient {
|
|
|
861
839
|
ctx = this.ctx,
|
|
862
840
|
onCommit?: () => void,
|
|
863
841
|
reload?: AbortController,
|
|
864
|
-
requirePendingAdoption = false,
|
|
865
842
|
) {
|
|
866
843
|
const diagnostics = this.debug ? observeDebugJob(operation, (event) => this.recordDebug(event)) : undefined;
|
|
867
|
-
const adoptionRecovery =
|
|
868
|
-
operation === "pull.foreground" && this.pendingPullReview ? this.adoptionRecovery : undefined;
|
|
869
844
|
const result = this.work
|
|
870
|
-
.then(() =>
|
|
871
|
-
if (requirePendingAdoption && !adoptionRecovery)
|
|
872
|
-
throw new Error("The original Pull is no longer available for automatic recovery.");
|
|
873
|
-
return this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics, adoptionRecovery);
|
|
874
|
-
})
|
|
845
|
+
.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics))
|
|
875
846
|
.catch((error: unknown) => {
|
|
876
847
|
diagnostics?.rejected(error, Boolean(signal?.aborted || reload?.signal.aborted));
|
|
877
848
|
this.recordOwnershipFailure(error);
|
|
@@ -909,6 +880,7 @@ export class PiDaemonClient {
|
|
|
909
880
|
assertRoot();
|
|
910
881
|
const attached = await this.attachConnection(replacement, signal);
|
|
911
882
|
this.validateFactsScope(attached, signal);
|
|
883
|
+
if (this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
912
884
|
assertRoot();
|
|
913
885
|
return attached;
|
|
914
886
|
} finally {
|
|
@@ -923,11 +895,8 @@ export class PiDaemonClient {
|
|
|
923
895
|
onCommit?: () => void,
|
|
924
896
|
reload?: AbortController,
|
|
925
897
|
diagnostics?: ReturnType<typeof observeDebugJob>,
|
|
926
|
-
adoptionRecovery?: PiDaemonClient["adoptionRecovery"],
|
|
927
898
|
) {
|
|
928
899
|
this.validate();
|
|
929
|
-
if (adoptionRecovery && (this.adoptionRecovery !== adoptionRecovery || !this.pendingPullReview))
|
|
930
|
-
throw new Error("The original Pull is no longer available for automatic recovery.");
|
|
931
900
|
signal?.throwIfAborted();
|
|
932
901
|
reload?.signal.throwIfAborted();
|
|
933
902
|
if (this.pendingReload) throw new Error("Pi resources are about to reload.");
|
|
@@ -956,39 +925,17 @@ export class PiDaemonClient {
|
|
|
956
925
|
runSignal.addEventListener("abort", clearForeground, { once: true });
|
|
957
926
|
try {
|
|
958
927
|
const root = isForegroundDirection(operation) ? lstatSync(this.root) : undefined;
|
|
959
|
-
const assertRoot =
|
|
960
|
-
|
|
961
|
-
(()
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
throw new Error("The agent directory changed during the transfer.");
|
|
965
|
-
});
|
|
928
|
+
const assertRoot = () => {
|
|
929
|
+
const current = lstatSync(this.root);
|
|
930
|
+
if (!root || !current.isDirectory() || current.dev !== root.dev || current.ino !== root.ino)
|
|
931
|
+
throw new Error("The agent directory changed during the transfer.");
|
|
932
|
+
};
|
|
966
933
|
const intent = root ? structuredClone(payload) : payload;
|
|
967
|
-
const pull = operation === "pull.foreground" ? (intent as { setup: string; fingerprint: string }) : undefined;
|
|
968
|
-
if (
|
|
969
|
-
adoptionRecovery &&
|
|
970
|
-
(!pull ||
|
|
971
|
-
pull.setup !== adoptionRecovery.review.setupName ||
|
|
972
|
-
pull.fingerprint !== adoptionRecovery.review.fingerprint)
|
|
973
|
-
)
|
|
974
|
-
throw new Error("The sync setup changed before Pull recovery.");
|
|
975
|
-
if (adoptionRecovery) {
|
|
976
|
-
assertRoot();
|
|
977
|
-
const { createSettingsConfigView, syncCheckConfigFingerprint } = await import("../settings/config.js");
|
|
978
|
-
this.validateFactsScope(connection, runSignal);
|
|
979
|
-
const document = await peekLocalConfigDocument();
|
|
980
|
-
this.validateFactsScope(connection, runSignal);
|
|
981
|
-
const config = document && (await createSettingsConfigView(document).observe(undefined, runSignal));
|
|
982
|
-
this.validateFactsScope(connection, runSignal);
|
|
983
|
-
assertRoot();
|
|
984
|
-
if (!config || syncCheckConfigFingerprint(config) !== adoptionRecovery.review.fingerprint)
|
|
985
|
-
throw new Error("The sync setup changed before Pull recovery.");
|
|
986
|
-
}
|
|
987
934
|
const result = root
|
|
988
935
|
? await runDirectionalRecovery(
|
|
989
936
|
connection,
|
|
990
937
|
runSignal,
|
|
991
|
-
async (checkpoint, retryCheckpoint
|
|
938
|
+
async (checkpoint, retryCheckpoint) => {
|
|
992
939
|
const current = checkpoint.connection;
|
|
993
940
|
this.validateFactsScope(current, runSignal);
|
|
994
941
|
assertRoot();
|
|
@@ -996,11 +943,7 @@ export class PiDaemonClient {
|
|
|
996
943
|
try {
|
|
997
944
|
return await current.run(
|
|
998
945
|
operation,
|
|
999
|
-
|
|
1000
|
-
? { ...pull, retryAdoptionJournal }
|
|
1001
|
-
: retryCheckpoint === undefined
|
|
1002
|
-
? intent
|
|
1003
|
-
: { ...(intent as object), retryCheckpoint },
|
|
946
|
+
retryCheckpoint === undefined ? intent : { ...(intent as object), retryCheckpoint },
|
|
1004
947
|
runSignal,
|
|
1005
948
|
onCommit,
|
|
1006
949
|
(id) => {
|
|
@@ -1016,16 +959,6 @@ export class PiDaemonClient {
|
|
|
1016
959
|
() => {
|
|
1017
960
|
this.cleanupRequired = true;
|
|
1018
961
|
},
|
|
1019
|
-
pull && {
|
|
1020
|
-
pending: adoptionRecovery?.pending,
|
|
1021
|
-
retain: (pending) => {
|
|
1022
|
-
this.adoptionRecovery = pending && {
|
|
1023
|
-
pending,
|
|
1024
|
-
review: { setupName: pull.setup, fingerprint: pull.fingerprint },
|
|
1025
|
-
assertRoot,
|
|
1026
|
-
};
|
|
1027
|
-
},
|
|
1028
|
-
},
|
|
1029
962
|
)
|
|
1030
963
|
: await connection.run(operation, payload, runSignal, onCommit, diagnostics?.onSubmit);
|
|
1031
964
|
diagnostics?.returned(result, runSignal.aborted || reload?.signal.aborted);
|
|
@@ -1210,7 +1143,6 @@ export class PiDaemonClient {
|
|
|
1210
1143
|
helpText?: string;
|
|
1211
1144
|
background?: boolean;
|
|
1212
1145
|
fingerprint?: string;
|
|
1213
|
-
adoptionRecovery?: number;
|
|
1214
1146
|
};
|
|
1215
1147
|
if (callback.kind === "queue-release") {
|
|
1216
1148
|
if (typeof payload?.reservation !== "string") throw new Error("Invalid queue release.");
|
|
@@ -1224,7 +1156,7 @@ export class PiDaemonClient {
|
|
|
1224
1156
|
this.validateFactsScope(connection, this.runSignal);
|
|
1225
1157
|
if (protectionOnly || this.directionalCheckpoint?.accept(connection, callback.job, payload?.fingerprint) !== true)
|
|
1226
1158
|
return false;
|
|
1227
|
-
return
|
|
1159
|
+
return true;
|
|
1228
1160
|
}
|
|
1229
1161
|
if (callback.kind === "queue-acquire") {
|
|
1230
1162
|
if (this.pendingReload) throw new Error("Pi resources are about to reload.");
|
package/src/settings/config.ts
CHANGED
package/src/sync/setup-switch.ts
CHANGED
|
@@ -62,9 +62,7 @@ export async function useSyncSetup(
|
|
|
62
62
|
validate();
|
|
63
63
|
const operationIdentity = syncCheckConfigFingerprint(loadedConfig);
|
|
64
64
|
if (expectedOperationIdentity !== undefined && operationIdentity !== expectedOperationIdentity) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
"Setup settings or local rule source changed while the switch preview was open; reopen it and review again.",
|
|
67
|
-
);
|
|
65
|
+
throw new Error("Setup settings changed while the switch preview was open; reopen it and review again.");
|
|
68
66
|
}
|
|
69
67
|
const switchResult: { action: OnSwitchAction; switched: boolean } = {
|
|
70
68
|
action: "ask-before-pull",
|
|
@@ -89,7 +87,6 @@ export async function useSyncSetup(
|
|
|
89
87
|
if (expectedAction !== undefined && switchResult.action !== expectedAction) {
|
|
90
88
|
throw new Error("Setup-switch behavior changed while the preview was open; reopen it and retry.");
|
|
91
89
|
}
|
|
92
|
-
if (loadedConfig.reservedIgnoreNames !== undefined) switchResult.action = "switch-only";
|
|
93
90
|
if (switchResult.action === "pull-after-switch" && !ctx.hasUI) {
|
|
94
91
|
throw new SetupPullRequiresUiError(
|
|
95
92
|
`Automatic setup pulls require interactive confirmation; sync setup “${safeTerminalText(normalized)}” was not switched. Use TUI or RPC mode.`,
|
package/src/sync-extension.ts
CHANGED
|
@@ -65,23 +65,15 @@ export default function sync(pi: ExtensionAPI, dependencies: Partial<SyncDepende
|
|
|
65
65
|
}
|
|
66
66
|
const commands = await loaders.commands();
|
|
67
67
|
if (signal.aborted || owner !== client) return;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
attention,
|
|
78
|
-
undefined,
|
|
79
|
-
needsDaemonRecovery,
|
|
80
|
-
);
|
|
81
|
-
} finally {
|
|
82
|
-
if (recoveryMenu && !signal.aborted && owner === client)
|
|
83
|
-
await client.setBusy("command", false, !needsDaemonRecovery()).catch(() => {});
|
|
84
|
-
}
|
|
68
|
+
await commands.handleCommand(
|
|
69
|
+
args,
|
|
70
|
+
ctx,
|
|
71
|
+
commandSignal,
|
|
72
|
+
loaders,
|
|
73
|
+
attention,
|
|
74
|
+
undefined,
|
|
75
|
+
needsDaemonRecovery,
|
|
76
|
+
);
|
|
85
77
|
return;
|
|
86
78
|
}
|
|
87
79
|
const daemonStatus = command === "daemon" && (!action || action === "status");
|
|
@@ -205,13 +197,7 @@ export default function sync(pi: ExtensionAPI, dependencies: Partial<SyncDepende
|
|
|
205
197
|
client.disableQueueReleaseUI();
|
|
206
198
|
releaseStatus();
|
|
207
199
|
}
|
|
208
|
-
if (
|
|
209
|
-
ready &&
|
|
210
|
-
!signal.aborted &&
|
|
211
|
-
owner === client &&
|
|
212
|
-
!(ready.continuous && ready.agentMode) &&
|
|
213
|
-
(ready.automatic || startupTransferEnabled(ready))
|
|
214
|
-
)
|
|
200
|
+
if (ready && !signal.aborted && owner === client && (ready.automatic || startupTransferEnabled(ready)))
|
|
215
201
|
await withPiDaemonClient(ctx, async () => {
|
|
216
202
|
check.start(
|
|
217
203
|
ctx,
|
|
@@ -19,7 +19,6 @@ export type RunRoute = (
|
|
|
19
19
|
onDialog?: (active: boolean) => void,
|
|
20
20
|
retryRefusal?: boolean,
|
|
21
21
|
directionalFingerprint?: string,
|
|
22
|
-
requirePendingAdoption?: boolean,
|
|
23
22
|
) => Promise<RunRouteResult | undefined>;
|
|
24
23
|
|
|
25
24
|
export type CancellableOperationResult = RunRouteResult | { kind: "closed" } | { kind: "cancelled" };
|
|
@@ -30,7 +29,6 @@ interface CancellableOperationOptions {
|
|
|
30
29
|
cancelledMessage?: string | null;
|
|
31
30
|
target?: string;
|
|
32
31
|
directionalFingerprint?: string;
|
|
33
|
-
requirePendingAdoption?: boolean;
|
|
34
32
|
signal?: AbortSignal;
|
|
35
33
|
isCurrent?: () => boolean;
|
|
36
34
|
}
|
|
@@ -46,16 +44,7 @@ export async function runCancellableOperation(
|
|
|
46
44
|
ctx,
|
|
47
45
|
message,
|
|
48
46
|
(signal, onCommit, onDialog) =>
|
|
49
|
-
runRoute(
|
|
50
|
-
route,
|
|
51
|
-
signal,
|
|
52
|
-
onCommit,
|
|
53
|
-
options.target,
|
|
54
|
-
onDialog,
|
|
55
|
-
undefined,
|
|
56
|
-
options.directionalFingerprint,
|
|
57
|
-
options.requirePendingAdoption,
|
|
58
|
-
),
|
|
47
|
+
runRoute(route, signal, onCommit, options.target, onDialog, undefined, options.directionalFingerprint),
|
|
59
48
|
options,
|
|
60
49
|
);
|
|
61
50
|
return result.kind === "completed" ? (result.value ?? { kind: "failed" }) : result;
|
|
@@ -75,7 +64,7 @@ export async function runCancellableTask<Value>(
|
|
|
75
64
|
onCommit?: () => void,
|
|
76
65
|
onDialog?: (active: boolean) => void,
|
|
77
66
|
) => Promise<Value>,
|
|
78
|
-
options: Omit<CancellableOperationOptions, "target" | "directionalFingerprint"
|
|
67
|
+
options: Omit<CancellableOperationOptions, "target" | "directionalFingerprint"> = {},
|
|
79
68
|
): Promise<CancellableTaskResult<Value>> {
|
|
80
69
|
const {
|
|
81
70
|
commitAware = false,
|
|
@@ -100,8 +100,6 @@ export async function showExcludedPaths(ctx: ExtensionCommandContext, setupName:
|
|
|
100
100
|
setupName,
|
|
101
101
|
(setup) => {
|
|
102
102
|
validate();
|
|
103
|
-
if (setup.sync.pathPolicy === "ignore-file")
|
|
104
|
-
throw new Error("Edit the ignore file to change this setup's policy.");
|
|
105
103
|
return { ...setup, sync: { ...setup.sync, exclude } };
|
|
106
104
|
},
|
|
107
105
|
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), upgradeExclude: true, signal },
|
|
@@ -219,8 +217,7 @@ export async function showDirectoryScope(ctx: ExtensionCommandContext, config: A
|
|
|
219
217
|
config.setupName,
|
|
220
218
|
(setup) => {
|
|
221
219
|
validate();
|
|
222
|
-
if (setup.sync.scope !== "agent-directory"
|
|
223
|
-
throw new Error("Sync scope changed during review.");
|
|
220
|
+
if (setup.sync.scope !== "agent-directory") throw new Error("Sync scope changed during review.");
|
|
224
221
|
return {
|
|
225
222
|
...setup,
|
|
226
223
|
sync: {
|
package/src/ui/file-selection.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
syncIncludeSelection,
|
|
14
14
|
} from "../sync/sync-policy.js";
|
|
15
15
|
import { showDirectoryScope } from "./excluded-paths-ui.js";
|
|
16
|
-
import { manualIgnoreFileGuidance } from "./ignore-file-guidance.js";
|
|
17
16
|
|
|
18
17
|
const BUILT_IN_PREFIX = "builtin:";
|
|
19
18
|
const CUSTOM_PREFIX = "custom:";
|
|
@@ -31,10 +30,6 @@ export async function showFileSelection(ctx: ExtensionCommandContext, setupName?
|
|
|
31
30
|
const config = await loadSettingsConfig(setupName);
|
|
32
31
|
if (signal?.aborted) return;
|
|
33
32
|
validate();
|
|
34
|
-
if (config.pathPolicy === "ignore-file") {
|
|
35
|
-
if (ctx.hasUI) ctx.ui.notify(manualIgnoreFileGuidance(config.ignoreFile ?? ".syncignore"), "info");
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
33
|
if (config.scope === "agent-directory") return showDirectoryScope(ctx, config, signal);
|
|
39
34
|
const selection = syncIncludeSelection(config.include);
|
|
40
35
|
const original: SelectionDraft = {
|