@narumitw/pi-sync-daemon 0.7.0 → 0.8.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 +11 -0
- package/README.md +16 -2
- package/dist/consent.js +21 -6
- package/dist/engine/backends/git/git-backend.d.ts +1 -1
- package/dist/engine/backends/git/git-backend.js +17 -2
- package/dist/engine/backends/git/git-storage.d.ts +1 -1
- package/dist/engine/backends/git/git-storage.js +30 -9
- package/dist/engine/backends/s3/s3-backend.js +8 -0
- package/dist/engine/backends/sync-backend.d.ts +1 -0
- package/dist/engine/backends/webdav/webdav-backend.js +8 -0
- package/dist/engine/ignore/effective-ignore-policy.d.ts +10 -0
- package/dist/engine/ignore/effective-ignore-policy.js +33 -0
- package/dist/engine/ignore/ignore-edit.d.ts +13 -0
- package/dist/engine/ignore/ignore-edit.js +102 -0
- package/dist/engine/ignore/ignore-initialization.d.ts +6 -0
- package/dist/engine/ignore/ignore-initialization.js +186 -0
- package/dist/engine/ignore/ignore-migration-prompt.d.ts +7 -0
- package/dist/engine/ignore/ignore-migration-prompt.js +139 -0
- package/dist/engine/ignore/ignore-settings.d.ts +15 -0
- package/dist/engine/ignore/ignore-settings.js +322 -0
- package/dist/engine/ignore/ignore-source.d.ts +27 -0
- package/dist/engine/ignore/ignore-source.js +250 -0
- package/dist/engine/settings/config-file.d.ts +9 -2
- package/dist/engine/settings/config-file.js +124 -28
- package/dist/engine/settings/config.d.ts +3 -0
- package/dist/engine/settings/config.js +93 -7
- package/dist/engine/settings/settings-management.d.ts +2 -2
- package/dist/engine/settings/settings-management.js +16 -8
- package/dist/engine/settings/settings-types.d.ts +23 -2
- package/dist/engine/settings/settings-validation.js +23 -5
- package/dist/engine/snapshot/session-paths.d.ts +1 -1
- package/dist/engine/snapshot/session-paths.js +36 -13
- package/dist/engine/snapshot/snapshot-apply.d.ts +3 -3
- package/dist/engine/snapshot/snapshot-apply.js +23 -4
- package/dist/engine/snapshot/snapshot-codec.d.ts +1 -1
- package/dist/engine/snapshot/snapshot-codec.js +14 -5
- package/dist/engine/snapshot/snapshot-exclude-safety.d.ts +4 -2
- package/dist/engine/snapshot/snapshot-exclude-safety.js +76 -19
- package/dist/engine/snapshot/snapshot-transaction-images.d.ts +3 -1
- package/dist/engine/snapshot/snapshot-transaction-images.js +33 -3
- package/dist/engine/snapshot/snapshot-transaction-policy.d.ts +24 -1
- package/dist/engine/snapshot/snapshot-transaction-policy.js +106 -2
- package/dist/engine/snapshot/snapshot-transaction-verification.d.ts +7 -0
- package/dist/engine/snapshot/snapshot-transaction-verification.js +78 -0
- package/dist/engine/snapshot/snapshot-transaction.d.ts +1 -12
- package/dist/engine/snapshot/snapshot-transaction.js +86 -108
- package/dist/engine/snapshot/snapshot-types.d.ts +23 -1
- package/dist/engine/snapshot/snapshot-types.js +9 -1
- package/dist/engine/snapshot/snapshot.d.ts +6 -4
- package/dist/engine/snapshot/snapshot.js +91 -34
- package/dist/engine/state/state-types.d.ts +1 -0
- package/dist/engine/sync/continuous-sync.js +18 -3
- package/dist/engine/sync/continuous-watch.js +4 -1
- package/dist/engine/sync/initialization.js +3 -2
- package/dist/engine/sync/local-fields.d.ts +3 -1
- package/dist/engine/sync/local-fields.js +62 -1
- package/dist/engine/sync/merge-apply.js +35 -7
- package/dist/engine/sync/merge-journal.d.ts +18 -4
- package/dist/engine/sync/merge-journal.js +115 -8
- package/dist/engine/sync/merged-sync.d.ts +1 -1
- package/dist/engine/sync/merged-sync.js +103 -50
- package/dist/engine/sync/remote-snapshot.d.ts +9 -2
- package/dist/engine/sync/remote-snapshot.js +56 -17
- package/dist/engine/sync/sync-inspection.js +7 -5
- package/dist/engine/sync/sync-mutations.d.ts +2 -1
- package/dist/engine/sync/sync-mutations.js +110 -47
- package/dist/engine/sync/sync-policy.d.ts +24 -8
- package/dist/engine/sync/sync-policy.js +127 -16
- package/dist/engine/sync/sync-queries.js +8 -1
- package/dist/engine/sync/sync-state.d.ts +2 -2
- package/dist/engine/sync/sync-state.js +20 -2
- package/dist/engine-service.js +24 -2
- package/docs/architecture.md +22 -0
- package/package.json +2 -1
|
@@ -3,8 +3,9 @@ import { filterSnapshotForConfigPolicy } from "../snapshot/snapshot.js";
|
|
|
3
3
|
import { safeTerminalText } from "../ui/terminal-text.js";
|
|
4
4
|
import { sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
|
|
5
5
|
import { throwIfAborted } from "./signals.js";
|
|
6
|
-
import { inspectRemoteSelection, remoteSelectionMismatch, sameSnapshotSelection, } from "./sync-policy.js";
|
|
7
|
-
|
|
6
|
+
import { formatIgnorePolicyComparison, inspectRemoteSelection, remoteSelectionMismatch, requireLegacyTransferPolicy, sameSnapshotSelection, } from "./sync-policy.js";
|
|
7
|
+
import { syncPolicyChanged } from "./sync-state.js";
|
|
8
|
+
async function readValidatedSnapshotForHead(backend, head, signal) {
|
|
8
9
|
const snapshot = await backend.readSnapshot(head.snapshotRef, signal);
|
|
9
10
|
throwIfAborted(signal);
|
|
10
11
|
validatePortableSnapshot(snapshot);
|
|
@@ -18,17 +19,58 @@ export async function readSnapshotForHead(backend, head, signal) {
|
|
|
18
19
|
}
|
|
19
20
|
return snapshot;
|
|
20
21
|
}
|
|
22
|
+
export async function readSnapshotForHead(backend, head, signal, config) {
|
|
23
|
+
const snapshot = await readValidatedSnapshotForHead(backend, head, signal);
|
|
24
|
+
if (!config)
|
|
25
|
+
requireLegacyTransferPolicy(snapshot);
|
|
26
|
+
else if (!config.ignorePolicy && snapshot.selection?.version === 4)
|
|
27
|
+
requireCompatibleRemoteSelection(config, snapshot);
|
|
28
|
+
return snapshot;
|
|
29
|
+
}
|
|
30
|
+
export async function readRemoteSnapshotForUpload(backend, config, head, state, options) {
|
|
31
|
+
if (!head)
|
|
32
|
+
return undefined;
|
|
33
|
+
if (config.ignorePolicy ||
|
|
34
|
+
head.selection?.version === 4 ||
|
|
35
|
+
head.snapshotId !== state.lastAppliedSnapshot ||
|
|
36
|
+
syncPolicyChanged(state, config) ||
|
|
37
|
+
(state.lastRemoteRevision && !backend.sameRevision(head.revision, state.lastRemoteRevision)) ||
|
|
38
|
+
(!options.force &&
|
|
39
|
+
(config.scope === "agent-directory" ||
|
|
40
|
+
(head.selection &&
|
|
41
|
+
inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude, config)
|
|
42
|
+
.kind === "different"))))
|
|
43
|
+
return readSnapshotForHead(backend, head, options.signal, config);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
export function sameRemoteHead(backend, left, right) {
|
|
47
|
+
if (!left || !right)
|
|
48
|
+
return left === right;
|
|
49
|
+
return left.snapshotId === right.snapshotId && backend.sameRevision(left.revision, right.revision);
|
|
50
|
+
}
|
|
21
51
|
export function requireCompatibleRemoteSelection(config, snapshot) {
|
|
52
|
+
const state = inspectRemoteSelection(config.include, snapshot, config.exclude, config);
|
|
53
|
+
if (state.kind === "different" && state.ignorePolicyComparison)
|
|
54
|
+
throw selectionMismatch(config, state);
|
|
22
55
|
if (!sameLocalFields(config.localFields, snapshot.localFields))
|
|
23
56
|
throw new Error("Remote local-field policy differs; confirm a reviewed directional migration. Old history is not erased.");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
57
|
+
if (state.kind === "different")
|
|
58
|
+
throw selectionMismatch(config, state);
|
|
59
|
+
}
|
|
60
|
+
export async function inspectHeadSelection(backend, config, head, signal) {
|
|
61
|
+
const remote = !head.selection && config.ignorePolicy
|
|
62
|
+
? await readValidatedSnapshotForHead(backend, head, signal)
|
|
63
|
+
: { selection: head.selection, files: [] };
|
|
64
|
+
return inspectRemoteSelection(config.include, remote, config.exclude, config);
|
|
65
|
+
}
|
|
66
|
+
function selectionMismatch(config, state) {
|
|
67
|
+
return remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config), state.exclude, state);
|
|
28
68
|
}
|
|
29
69
|
export function formatRemoteSelectionStatus(state) {
|
|
30
70
|
if (!state)
|
|
31
71
|
return "remote included content: unavailable (remote is empty)";
|
|
72
|
+
if (state.ignorePolicyComparison)
|
|
73
|
+
return formatIgnorePolicyComparison(state.ignorePolicyComparison);
|
|
32
74
|
if (state.kind === "same")
|
|
33
75
|
return "remote included content: matches this setup";
|
|
34
76
|
if (state.kind === "legacy") {
|
|
@@ -51,15 +93,12 @@ export async function readRemoteSnapshot(backend, config, signal, options = {})
|
|
|
51
93
|
const head = await backend.readHead(signal);
|
|
52
94
|
if (!head)
|
|
53
95
|
return { head: undefined, snapshot: undefined, selectionState: undefined };
|
|
54
|
-
const
|
|
55
|
-
const selectionState = inspectRemoteSelection(config.include,
|
|
56
|
-
if (!options.allowSelectionDifference && selectionState.kind === "different")
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
snapshot: filterSnapshotForConfigPolicy(snapshot, config, { sessionDir: options.sessionDir }),
|
|
63
|
-
selectionState,
|
|
64
|
-
};
|
|
96
|
+
const rawSnapshot = await readValidatedSnapshotForHead(backend, head, signal);
|
|
97
|
+
const selectionState = inspectRemoteSelection(config.include, rawSnapshot, config.exclude, config);
|
|
98
|
+
if (!options.allowSelectionDifference && selectionState.kind === "different")
|
|
99
|
+
throw selectionMismatch(config, selectionState);
|
|
100
|
+
const snapshot = selectionState.ignorePolicyComparison === "local-legacy-remote-ignore"
|
|
101
|
+
? undefined
|
|
102
|
+
: filterSnapshotForConfigPolicy(rawSnapshot, config, { sessionDir: options.sessionDir });
|
|
103
|
+
return { head, snapshot, selectionState };
|
|
65
104
|
}
|
|
@@ -2,9 +2,10 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { createSyncBackend } from "../backends/backend-factory.js";
|
|
3
3
|
import { createSnapshot } from "../snapshot/snapshot.js";
|
|
4
4
|
import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
|
|
5
|
+
import { inspectHeadSelection } from "./remote-snapshot.js";
|
|
5
6
|
import { throwIfAborted } from "./signals.js";
|
|
6
7
|
import { createStartupTimings } from "./startup-timings.js";
|
|
7
|
-
import {
|
|
8
|
+
import { syncSelectionHasContent } from "./sync-policy.js";
|
|
8
9
|
import { fileHashMap, hasLocalChanges, remoteChangedSinceState } from "./sync-state.js";
|
|
9
10
|
/** Advisory baseline-relative observation, never an authorization to transfer files. */
|
|
10
11
|
export async function inspectSync(config, options, signal, factory = createSyncBackend, timings = createStartupTimings()) {
|
|
@@ -17,6 +18,8 @@ export async function inspectSync(config, options, signal, factory = createSyncB
|
|
|
17
18
|
throwIfAborted(signal);
|
|
18
19
|
const head = await timings.measure("remote head", () => backend.readHead(signal));
|
|
19
20
|
throwIfAborted(signal);
|
|
21
|
+
const selectionState = head ? await inspectHeadSelection(backend, config, head, signal) : undefined;
|
|
22
|
+
throwIfAborted(signal);
|
|
20
23
|
const freshness = {
|
|
21
24
|
localIdentity: createHash("sha256")
|
|
22
25
|
.update(JSON.stringify(fileHashMap(local)))
|
|
@@ -25,12 +28,11 @@ export async function inspectSync(config, options, signal, factory = createSyncB
|
|
|
25
28
|
return {
|
|
26
29
|
...freshness,
|
|
27
30
|
head,
|
|
28
|
-
selectionState
|
|
29
|
-
? inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude, config)
|
|
30
|
-
: undefined,
|
|
31
|
+
selectionState,
|
|
31
32
|
localFiles: local.files.length,
|
|
32
33
|
localChanged: hasLocalChanges(local, state, config),
|
|
33
|
-
remoteChanged:
|
|
34
|
+
remoteChanged: (selectionState?.kind === "different" && !!selectionState.ignorePolicyComparison) ||
|
|
35
|
+
remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)),
|
|
34
36
|
firstSync: !state.lastAppliedSnapshot,
|
|
35
37
|
emptyInclude: !syncSelectionHasContent(config),
|
|
36
38
|
stateIdentity: syncStateFingerprint(state),
|
|
@@ -29,9 +29,10 @@ interface InitialPullEvidence {
|
|
|
29
29
|
head: RemoteHead | undefined;
|
|
30
30
|
}
|
|
31
31
|
export declare function pull(ctx: ExtensionCommandContext | ExtensionContext, options: CommandOptions, factory?: SyncBackendFactory, initial?: InitialPullEvidence): Promise<"applied" | "cancelled">;
|
|
32
|
-
export declare function syncBoth(ctx: ExtensionCommandContext | ExtensionContext, options: CommandOptions, factory?: SyncBackendFactory): Promise<"applied" | "cancelled" | undefined>;
|
|
32
|
+
export declare function syncBoth(ctx: ExtensionCommandContext | ExtensionContext, options: CommandOptions, factory?: SyncBackendFactory): Promise<"applied" | "archived" | "cancelled" | undefined>;
|
|
33
33
|
export declare function rollback(ctx: ExtensionCommandContext, options: CommandOptions, factory?: SyncBackendFactory, expectedSelection?: {
|
|
34
34
|
backendIdentity: string;
|
|
35
35
|
setup?: string;
|
|
36
|
+
snapshotId?: string;
|
|
36
37
|
}): Promise<void>;
|
|
37
38
|
export { backupLocal } from "./sync-local.js";
|
|
@@ -4,9 +4,10 @@ import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
|
4
4
|
import { effectiveSessionRoot, requireStableMergeSessionRoot, resolvedSnapshotOptionsForContext, sessionDirForApply, } from "../snapshot/session-paths.js";
|
|
5
5
|
import { createSnapshot, filterSnapshotForConfigPolicy, mergeRemotePreservedFiles, regenerateSnapshotIdentity, scanSnapshot, snapshotIncludesSessions, snapshotWithoutSessions, } from "../snapshot/snapshot.js";
|
|
6
6
|
import { applySnapshot } from "../snapshot/snapshot-apply.js";
|
|
7
|
+
import { ignorePolicyValidator } from "../snapshot/snapshot-transaction-policy.js";
|
|
7
8
|
import { pruneMergeBaselines } from "../state/merge-baseline-store.js";
|
|
8
9
|
import { readStateForConfig, syncStateFingerprint, writeStateForConfig } from "../state/sync-state-store.js";
|
|
9
|
-
import { countPreservedRemoteFiles, formatPullSummary, formatPushSummary, formatRollbackSummary, } from "../ui/sync-format.js";
|
|
10
|
+
import { countPreservedRemoteFiles, formatPublicationPreview, formatPullSummary, formatPushSummary, formatRollbackSummary, } from "../ui/sync-format.js";
|
|
10
11
|
import { setSyncStatus } from "../ui/sync-status.js";
|
|
11
12
|
import { confirmTransferReview } from "../ui/transfer-review.js";
|
|
12
13
|
import { startupTransferEnabled } from "./agent-policy.js";
|
|
@@ -15,12 +16,12 @@ import { confirmFieldMigration } from "./field-migration.js";
|
|
|
15
16
|
import { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
|
|
16
17
|
import { readMergeJournal, requireNoMergeJournal, retireMergeJournal } from "./merge-journal.js";
|
|
17
18
|
import { mergeSync } from "./merged-sync.js";
|
|
18
|
-
import { readRemoteSnapshot, readSnapshotForHead, requireCompatibleRemoteSelection } from "./remote-snapshot.js";
|
|
19
|
+
import { readRemoteSnapshot, readRemoteSnapshotForUpload, readSnapshotForHead, requireCompatibleRemoteSelection, sameRemoteHead, } from "./remote-snapshot.js";
|
|
19
20
|
import { throwIfAborted } from "./signals.js";
|
|
20
21
|
import { createSyncDecision } from "./sync-decision.js";
|
|
21
22
|
import { errorMessage } from "./sync-errors.js";
|
|
22
23
|
import { backupLocal, captureMutationOwner, protectedSessionPaths } from "./sync-local.js";
|
|
23
|
-
import { inspectRemoteSelection, syncSelectionHasContent, syncSessionsSelected } from "./sync-policy.js";
|
|
24
|
+
import { formatIgnorePolicyComparison, inspectRemoteSelection, requireLegacyTransferPolicy, syncSelectionHasContent, syncSessionsSelected, } from "./sync-policy.js";
|
|
24
25
|
import { acceptedSelection, canPullRemoteSessionsOnFirstSync, canPullRemoteSettingsOnFirstSync, fileHashMap, hasLocalChanges, hasRemoteChanges, remoteChangedSinceState, sameHashes, shouldRefreshSyncedState, snapshotHashesMatchState, snapshotsMatch, syncPolicyChanged, } from "./sync-state.js";
|
|
25
26
|
const VERSION = 1;
|
|
26
27
|
const POST_LOCAL_COMMIT_TIMEOUT_MS = 30_000;
|
|
@@ -29,6 +30,14 @@ function requireResolvedDirectionalProgress(state, options, allowForce = true) {
|
|
|
29
30
|
if (state.unresolved?.length && (options.auto || !options.force || !allowForce))
|
|
30
31
|
throw new Error("Unresolved partial conflicts remain. Review /sync conflicts or explicitly choose push --force or pull --force; automatic transfer and rollback cannot accept unresolved groups.");
|
|
31
32
|
}
|
|
33
|
+
function requireIgnoreBaselineReview(ctx, config, state, options) {
|
|
34
|
+
if (config.ignorePolicy &&
|
|
35
|
+
state.lastAppliedSnapshot &&
|
|
36
|
+
syncPolicyChanged(state, config) &&
|
|
37
|
+
(options.auto || options.yes || !ctx.hasUI)) {
|
|
38
|
+
throw new Error("Local ignore-file policy or source changed since the last accepted baseline. Review a foreground directional transfer.");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
32
41
|
export class PublicationStatePersistenceError extends Error {
|
|
33
42
|
head;
|
|
34
43
|
backupPath;
|
|
@@ -68,20 +77,19 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
68
77
|
throwIfAborted(options.signal);
|
|
69
78
|
const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);
|
|
70
79
|
validateMutation();
|
|
80
|
+
const validateIgnorePolicy = ignorePolicyValidator({ ...snapshotOptions, validateMutation });
|
|
71
81
|
const localRaw = input?.local ?? (await createSnapshot(config.snapshotIdentity, snapshotOptions));
|
|
72
82
|
const local = portableSnapshot(localRaw, config.localFields);
|
|
73
83
|
throwIfAborted(options.signal);
|
|
74
84
|
let head = await backend.readHead(options.signal);
|
|
75
|
-
let remoteForUpload = await readRemoteSnapshotForUpload(backend, config, head, state, options
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
(
|
|
81
|
-
inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude, config)
|
|
82
|
-
.kind === "different"))) {
|
|
83
|
-
remoteForUpload = await readSnapshotForHead(backend, head, options.signal);
|
|
85
|
+
let remoteForUpload = await readRemoteSnapshotForUpload(backend, config, head, state, options);
|
|
86
|
+
validateMutation();
|
|
87
|
+
if (config.ignorePolicy && remoteForUpload && options.force && (options.auto || options.yes || !ctx.hasUI)) {
|
|
88
|
+
const comparison = inspectRemoteSelection(config.include, remoteForUpload, config.exclude, config);
|
|
89
|
+
if (comparison.kind === "different")
|
|
90
|
+
requireCompatibleRemoteSelection(config, remoteForUpload);
|
|
84
91
|
}
|
|
92
|
+
requireIgnoreBaselineReview(ctx, config, state, options);
|
|
85
93
|
if (remoteForUpload && !options.force) {
|
|
86
94
|
requireCompatibleRemoteSelection(config, remoteForUpload);
|
|
87
95
|
}
|
|
@@ -104,7 +112,8 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
if (!remoteForUpload && head && (config.localFields !== undefined || !options.yes))
|
|
107
|
-
remoteForUpload = await readSnapshotForHead(backend, head, options.signal);
|
|
115
|
+
remoteForUpload = await readSnapshotForHead(backend, head, options.signal, config);
|
|
116
|
+
validateMutation();
|
|
108
117
|
if (!(await confirmFieldMigration(ctx, config, state, remoteForUpload, options.force, options.signal))) {
|
|
109
118
|
setSyncStatus(ctx, undefined);
|
|
110
119
|
return "cancelled";
|
|
@@ -117,14 +126,17 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
117
126
|
throw new Error(`Refusing to push possible secrets:\n${secrets.map((s) => `- ${s}`).join("\n")}`);
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
|
-
if (!(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload))) {
|
|
129
|
+
if (!(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, validateMutation))) {
|
|
121
130
|
return "cancelled";
|
|
122
131
|
}
|
|
123
132
|
if (options.force) {
|
|
124
133
|
const refreshedHead = await backend.readHead(options.signal);
|
|
134
|
+
validateMutation();
|
|
125
135
|
if (!sameRemoteHead(backend, head, refreshedHead)) {
|
|
136
|
+
if (config.ignorePolicy)
|
|
137
|
+
throw new Error("Remote changed during ignore-file push review; reopen the review.");
|
|
126
138
|
head = refreshedHead;
|
|
127
|
-
remoteForUpload = head ? await readSnapshotForHead(backend, head, options.signal) : undefined;
|
|
139
|
+
remoteForUpload = head ? await readSnapshotForHead(backend, head, options.signal, config) : undefined;
|
|
128
140
|
validateMutation();
|
|
129
141
|
if (!(await confirmFieldMigration(ctx, config, state, remoteForUpload, options.force, options.signal))) {
|
|
130
142
|
setSyncStatus(ctx, undefined);
|
|
@@ -132,7 +144,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
132
144
|
}
|
|
133
145
|
validateMutation();
|
|
134
146
|
upload = await snapshotForUpload(backend, config, local, head, remoteForUpload, snapshotOptions);
|
|
135
|
-
if (!(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, "Remote changed during review. Push the refreshed plan?"))) {
|
|
147
|
+
if (!(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, validateMutation, "Remote changed during review. Push the refreshed plan?"))) {
|
|
136
148
|
return "cancelled";
|
|
137
149
|
}
|
|
138
150
|
}
|
|
@@ -150,7 +162,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
150
162
|
throw new Error("Local content changed during push review; retry from current bytes.");
|
|
151
163
|
}
|
|
152
164
|
const currentState = await readStateForConfig(config);
|
|
153
|
-
if (!options.yes && syncStateFingerprint(currentState) !== syncStateFingerprint(state))
|
|
165
|
+
if ((config.ignorePolicy || !options.yes) && syncStateFingerprint(currentState) !== syncStateFingerprint(state))
|
|
154
166
|
throw new Error("Baseline changed during push review.");
|
|
155
167
|
requireResolvedDirectionalProgress(currentState, options);
|
|
156
168
|
if (config.scope === "agent-directory" &&
|
|
@@ -160,9 +172,14 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
160
172
|
if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
|
|
161
173
|
throw new Error("Settings changed during push review.");
|
|
162
174
|
validateMutation();
|
|
175
|
+
if (validateIgnorePolicy) {
|
|
176
|
+
validatePortableSnapshot(upload);
|
|
177
|
+
await validateIgnorePolicy();
|
|
178
|
+
}
|
|
163
179
|
const result = await backend.publishSnapshot(upload, expectedRemoteHead(head), {
|
|
164
180
|
signal: options.signal,
|
|
165
181
|
onCommit: options.onCommit,
|
|
182
|
+
...(validateIgnorePolicy ? { validateIgnorePolicy } : {}),
|
|
166
183
|
});
|
|
167
184
|
try {
|
|
168
185
|
await writeStateForConfig(config, {
|
|
@@ -212,6 +229,7 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
212
229
|
requireResolvedDirectionalProgress(state, options);
|
|
213
230
|
const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);
|
|
214
231
|
validateMutation();
|
|
232
|
+
const validateIgnorePolicy = ignorePolicyValidator({ ...snapshotOptions, validateMutation });
|
|
215
233
|
if (initial && initial.sessionDir !== snapshotOptions.sessionDir)
|
|
216
234
|
throw new Error("Pi session storage changed before initial pull; run sync again.");
|
|
217
235
|
const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);
|
|
@@ -222,6 +240,7 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
222
240
|
validateMutation();
|
|
223
241
|
if (initial && !matchesInitialHead(initial, backend, head))
|
|
224
242
|
throw new Error("Remote changed before initial pull; run sync again.");
|
|
243
|
+
requireIgnoreBaselineReview(ctx, config, state, options);
|
|
225
244
|
const localChanged = hasLocalChanges(local, state, config);
|
|
226
245
|
if (!remote) {
|
|
227
246
|
throw createSyncDecision({
|
|
@@ -246,7 +265,8 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
246
265
|
const physical = overlayLocalFields(logical, local, config.localFields);
|
|
247
266
|
if (config.scope === "agent-directory")
|
|
248
267
|
requireStableMergeSessionRoot(local, physical, config.scope);
|
|
249
|
-
const
|
|
268
|
+
const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
269
|
+
const remoteChanged = hasRemoteChanges(remote, state, config, reviewedProtectedPaths);
|
|
250
270
|
if (localChanged && remoteChanged && state.lastAppliedSnapshot && !options.force) {
|
|
251
271
|
throw createSyncDecision({
|
|
252
272
|
kind: "both-changed",
|
|
@@ -262,7 +282,7 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
262
282
|
const caseCleanup = options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);
|
|
263
283
|
validateMutation();
|
|
264
284
|
if (!options.yes &&
|
|
265
|
-
!(await confirmTransferReview(ctx, snapshotIncludesSessions(remote) ? "Pull pi settings and sessions?" : "Pull pi settings?", formatPullSummary(config, backend.destination, local, physical,
|
|
285
|
+
!(await confirmTransferReview(ctx, snapshotIncludesSessions(remote) ? "Pull pi settings and sessions?" : "Pull pi settings?", formatPullSummary(config, backend.destination, local, physical, reviewedProtectedPaths, caseCleanup.map((item) => item.path)), options.signal, validateMutation))) {
|
|
266
286
|
setSyncStatus(ctx, undefined);
|
|
267
287
|
ctx.ui.notify("Pull cancelled.", "info");
|
|
268
288
|
return "cancelled";
|
|
@@ -296,7 +316,8 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
296
316
|
await requireFreshRecovery();
|
|
297
317
|
const currentState = await readStateForConfig(config);
|
|
298
318
|
validateMutation();
|
|
299
|
-
if ((initial || !options.yes) &&
|
|
319
|
+
if ((config.ignorePolicy || initial || !options.yes) &&
|
|
320
|
+
syncStateFingerprint(currentState) !== syncStateFingerprint(state))
|
|
300
321
|
throw new Error("Baseline changed during pull review.");
|
|
301
322
|
requireResolvedDirectionalProgress(currentState, options);
|
|
302
323
|
if (!options.yes)
|
|
@@ -310,8 +331,16 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
310
331
|
if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
|
|
311
332
|
throw new Error("Settings changed during pull review.");
|
|
312
333
|
validateMutation();
|
|
334
|
+
if (validateIgnorePolicy) {
|
|
335
|
+
if (!sameRemoteHead(backend, head, await backend.readHead(options.signal)))
|
|
336
|
+
throw new Error("Remote changed during pull review.");
|
|
337
|
+
await validateIgnorePolicy();
|
|
338
|
+
}
|
|
339
|
+
const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
340
|
+
if (validateIgnorePolicy && !samePaths(protectedPaths, reviewedProtectedPaths))
|
|
341
|
+
throw new Error("Live session protection changed during pull review; reopen the review.");
|
|
313
342
|
options.onCommit?.();
|
|
314
|
-
const lastFileHashes = await applySnapshot(physical,
|
|
343
|
+
const lastFileHashes = await applySnapshot(physical, protectedPaths, {
|
|
315
344
|
...snapshotOptions,
|
|
316
345
|
sessionDir: applySessionDir,
|
|
317
346
|
validateMutation,
|
|
@@ -419,6 +448,9 @@ export async function syncBoth(ctx, options, factory = createSyncBackend) {
|
|
|
419
448
|
configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
|
|
420
449
|
throw new Error("Settings or Pi session storage changed before baseline acceptance; run sync again.");
|
|
421
450
|
validateMutation();
|
|
451
|
+
const validateIgnorePolicy = ignorePolicyValidator({ ...snapshotOptions, validateMutation });
|
|
452
|
+
if (validateIgnorePolicy)
|
|
453
|
+
await validateIgnorePolicy();
|
|
422
454
|
}
|
|
423
455
|
const accepted = portableSnapshot(snapshot, config.localFields);
|
|
424
456
|
await writeStateForConfig(config, {
|
|
@@ -500,7 +532,9 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
500
532
|
if (!target)
|
|
501
533
|
throw new Error("Usage: /sync rollback <snapshot-id> [--yes]");
|
|
502
534
|
const config = await loadConfig(options.setup);
|
|
503
|
-
|
|
535
|
+
validateMutation();
|
|
536
|
+
if (config.ignorePolicy && (options.yes || options.auto || !ctx.hasUI))
|
|
537
|
+
throw new Error("Ignore-file rollback requires a separate foreground review; --yes cannot confirm it.");
|
|
504
538
|
const backend = await factory(config);
|
|
505
539
|
if (expectedSelection &&
|
|
506
540
|
(backend.identity !== expectedSelection.backendIdentity || config.setupName !== expectedSelection.setup)) {
|
|
@@ -512,30 +546,47 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
512
546
|
validateMutation();
|
|
513
547
|
requireResolvedDirectionalProgress(state, options, false);
|
|
514
548
|
const decoded = await backend.readSnapshot(target, options.signal);
|
|
549
|
+
validateMutation();
|
|
515
550
|
validatePortableSnapshot(decoded);
|
|
551
|
+
if (!config.ignorePolicy)
|
|
552
|
+
requireLegacyTransferPolicy(decoded);
|
|
553
|
+
if (config.ignorePolicy && expectedSelection?.snapshotId && decoded.id !== expectedSelection.snapshotId)
|
|
554
|
+
throw new Error("Historical snapshot changed while history was open; reopen history and retry.");
|
|
516
555
|
if (!sameLocalFields(decoded.localFields, config.localFields))
|
|
517
556
|
throw new Error("Rollback requires the historical snapshot local-field policy to match the configured rules. Review push --force from current local bytes to migrate policy first; choose matching history afterward.");
|
|
518
557
|
const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);
|
|
519
558
|
validateMutation();
|
|
520
|
-
const
|
|
559
|
+
const validateIgnorePolicy = ignorePolicyValidator({ ...snapshotOptions, validateMutation });
|
|
560
|
+
const selected = filterSnapshotForConfigPolicy(config.ignorePolicy || syncSessionsSelected(config) ? decoded : snapshotWithoutSessions(decoded), config, snapshotOptions);
|
|
521
561
|
const remote = portableSnapshot(regenerateSnapshotIdentity(selected), config.localFields);
|
|
522
562
|
const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);
|
|
523
563
|
const expectedHead = await backend.readHead(options.signal);
|
|
524
|
-
const currentRemote = expectedHead
|
|
564
|
+
const currentRemote = expectedHead
|
|
565
|
+
? await readSnapshotForHead(backend, expectedHead, options.signal, config)
|
|
566
|
+
: undefined;
|
|
525
567
|
validateMutation();
|
|
568
|
+
if (config.ignorePolicy && currentRemote)
|
|
569
|
+
requireCompatibleRemoteSelection(config, currentRemote);
|
|
526
570
|
if (!(await confirmFieldMigration(ctx, config, state, currentRemote, true, options.signal)))
|
|
527
571
|
return;
|
|
528
572
|
validateMutation();
|
|
529
573
|
const physical = overlayLocalFields(remote, local, config.localFields);
|
|
530
574
|
if (config.scope === "agent-directory")
|
|
531
575
|
requireStableMergeSessionRoot(local, physical, config.scope);
|
|
532
|
-
const upload =
|
|
576
|
+
const upload = config.ignorePolicy
|
|
577
|
+
? remote
|
|
578
|
+
: await snapshotForUpload(backend, config, remote, expectedHead, currentRemote, snapshotOptions);
|
|
533
579
|
if (config.scope === "agent-directory")
|
|
534
580
|
validatePortableSnapshot(upload);
|
|
535
581
|
const caseCleanup = options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);
|
|
536
582
|
validateMutation();
|
|
583
|
+
const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
537
584
|
if (!options.yes) {
|
|
538
|
-
const
|
|
585
|
+
const title = snapshotIncludesSessions(remote) ? "Rollback pi settings and sessions?" : "Rollback pi settings?";
|
|
586
|
+
const summary = formatRollbackSummary(config, backend.destination, local, physical, target, reviewedProtectedPaths, caseCleanup.map((item) => item.path));
|
|
587
|
+
const confirmed = config.ignorePolicy
|
|
588
|
+
? await confirmTransferReview(ctx, title, `Historical files are projected through this device's current ignore rules. Historical rules are not adopted. Retained history is not erased.\n\n${summary}\n\nRemote publication:\n${formatPublicationPreview(currentRemote, upload)}`, options.signal, validateMutation)
|
|
589
|
+
: await ctx.ui.confirm(title, summary, { signal: options.signal });
|
|
539
590
|
validateMutation();
|
|
540
591
|
if (!confirmed) {
|
|
541
592
|
ctx.ui.notify("Rollback cancelled.", "info");
|
|
@@ -566,8 +617,16 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
566
617
|
if (syncCheckConfigFingerprint(config) !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
|
|
567
618
|
throw new Error("Settings changed during rollback review.");
|
|
568
619
|
validateMutation();
|
|
620
|
+
if (validateIgnorePolicy) {
|
|
621
|
+
if (!sameRemoteHead(backend, expectedHead, await backend.readHead(options.signal)))
|
|
622
|
+
throw new Error("Remote changed during rollback review.");
|
|
623
|
+
await validateIgnorePolicy();
|
|
624
|
+
}
|
|
625
|
+
const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
626
|
+
if (validateIgnorePolicy && !samePaths(protectedPaths, reviewedProtectedPaths))
|
|
627
|
+
throw new Error("Live session protection changed during rollback review; reopen the review.");
|
|
569
628
|
options.onCommit?.();
|
|
570
|
-
const lastFileHashes = await applySnapshot(physical,
|
|
629
|
+
const lastFileHashes = await applySnapshot(physical, protectedPaths, {
|
|
571
630
|
...snapshotOptions,
|
|
572
631
|
sessionDir: applySessionDir,
|
|
573
632
|
validateMutation,
|
|
@@ -580,8 +639,15 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
580
639
|
validateCommittedOwner();
|
|
581
640
|
let result;
|
|
582
641
|
try {
|
|
642
|
+
const signal = AbortSignal.timeout(POST_LOCAL_COMMIT_TIMEOUT_MS);
|
|
643
|
+
const validateIgnorePolicy = ignorePolicyValidator({
|
|
644
|
+
...snapshotOptions,
|
|
645
|
+
signal,
|
|
646
|
+
validateMutation: validateCommittedOwner,
|
|
647
|
+
});
|
|
583
648
|
result = await backend.publishSnapshot(upload, expectedRemoteHead(expectedHead), {
|
|
584
|
-
signal
|
|
649
|
+
signal,
|
|
650
|
+
...(validateIgnorePolicy ? { validateIgnorePolicy } : {}),
|
|
585
651
|
});
|
|
586
652
|
}
|
|
587
653
|
catch (error) {
|
|
@@ -628,30 +694,29 @@ async function maybeReload(ctx, signal, validateMutation = captureMutationOwner(
|
|
|
628
694
|
await ctx.reload();
|
|
629
695
|
}
|
|
630
696
|
}
|
|
631
|
-
async function readRemoteSnapshotForUpload(backend, config, head, state, signal) {
|
|
632
|
-
if (!head ||
|
|
633
|
-
(head.snapshotId === state.lastAppliedSnapshot &&
|
|
634
|
-
!syncPolicyChanged(state, config) &&
|
|
635
|
-
(!state.lastRemoteRevision || backend.sameRevision(head.revision, state.lastRemoteRevision)))) {
|
|
636
|
-
return undefined;
|
|
637
|
-
}
|
|
638
|
-
return readSnapshotForHead(backend, head, signal);
|
|
639
|
-
}
|
|
640
697
|
async function snapshotForUpload(backend, config, local, head, remote, options) {
|
|
698
|
+
if (config.ignorePolicy)
|
|
699
|
+
return filterSnapshotForConfigPolicy(local, config, { ...options, regenerateId: true });
|
|
641
700
|
if (!head)
|
|
642
701
|
return local;
|
|
643
|
-
const snapshot = remote ?? (await readSnapshotForHead(backend, head, options.signal));
|
|
702
|
+
const snapshot = remote ?? (await readSnapshotForHead(backend, head, options.signal, config));
|
|
644
703
|
const remoteScoped = snapshot.selection?.version === 3;
|
|
645
704
|
if (remoteScoped !== (config.scope === "agent-directory")) {
|
|
646
705
|
throw new Error("Converting an existing remote between included paths and agent-directory scope is not supported. Use a separate storage location.");
|
|
647
706
|
}
|
|
648
707
|
return mergeRemotePreservedFiles(local, snapshot, config, options);
|
|
649
708
|
}
|
|
650
|
-
async function confirmPush(ctx, options, config, backend, local, upload, head, remote, title = snapshotIncludesSessions(upload) ? "Push pi settings and sessions?" : "Push pi settings?") {
|
|
651
|
-
|
|
709
|
+
async function confirmPush(ctx, options, config, backend, local, upload, head, remote, validateMutation, title = snapshotIncludesSessions(upload) ? "Push pi settings and sessions?" : "Push pi settings?") {
|
|
710
|
+
validateMutation();
|
|
652
711
|
if (options.yes)
|
|
653
712
|
return true;
|
|
654
|
-
const
|
|
713
|
+
const summary = formatPushSummary(config, backend.destination, upload, head, countPreservedRemoteFiles(local, upload), remote);
|
|
714
|
+
const comparison = config.ignorePolicy && remote
|
|
715
|
+
? inspectRemoteSelection(config.include, remote, config.exclude, config).ignorePolicyComparison
|
|
716
|
+
: undefined;
|
|
717
|
+
const confirmed = await confirmTransferReview(ctx, title, comparison && comparison !== "match"
|
|
718
|
+
? `${formatIgnorePolicyComparison(comparison)}\nOnly files selected by this device's rules are published. Remote rules are not adopted.\n\n${summary}`
|
|
719
|
+
: summary, options.signal, validateMutation);
|
|
655
720
|
throwIfAborted(options.signal);
|
|
656
721
|
if (confirmed)
|
|
657
722
|
return true;
|
|
@@ -659,12 +724,10 @@ async function confirmPush(ctx, options, config, backend, local, upload, head, r
|
|
|
659
724
|
ctx.ui.notify("Push cancelled.", "info");
|
|
660
725
|
return false;
|
|
661
726
|
}
|
|
662
|
-
function sameRemoteHead(backend, left, right) {
|
|
663
|
-
if (!left || !right)
|
|
664
|
-
return left === right;
|
|
665
|
-
return backend.sameRevision(left.revision, right.revision);
|
|
666
|
-
}
|
|
667
727
|
function matchesInitialHead(initial, backend, current) {
|
|
668
|
-
return
|
|
728
|
+
return sameRemoteHead(backend, initial.head, current);
|
|
729
|
+
}
|
|
730
|
+
function samePaths(left, right) {
|
|
731
|
+
return left.size === right.size && [...left].every((item) => right.has(item));
|
|
669
732
|
}
|
|
670
733
|
export { backupLocal } from "./sync-local.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DirectoryScope, type Snapshot, type SnapshotSelection } from "../snapshot/snapshot-types.js";
|
|
2
2
|
export declare const BUILT_IN_SYNC_ROOTS: readonly ["settings.json", "keybindings.json", "models.json", "AGENTS.md", "APPEND_SYSTEM.md", "skills", "prompts", "themes", "extensions"];
|
|
3
3
|
export declare const DEFAULT_SYNC_INCLUDE: readonly ["settings.json", "keybindings.json", "models.json", "AGENTS.md", "APPEND_SYSTEM.md", "skills", "prompts", "themes", "extensions"];
|
|
4
4
|
export type BuiltInSyncFile = (typeof BUILT_IN_SYNC_ROOTS)[number];
|
|
@@ -11,27 +11,35 @@ export declare function selectionForSnapshot(include: unknown, exclude?: unknown
|
|
|
11
11
|
/** Metadata equality, not policy compatibility: bind the whole projection to its immutable image. */
|
|
12
12
|
export declare function sameSnapshotSelection(left: SnapshotSelection | undefined, right: SnapshotSelection | undefined): boolean;
|
|
13
13
|
export declare function validateSnapshotSelection(snapshot: Pick<Snapshot, "version" | "selection">): void;
|
|
14
|
+
export declare function requireLegacyTransferPolicy(snapshot: Partial<Pick<Snapshot, "version" | "selection">>): void;
|
|
14
15
|
export declare function sameSyncInclude(left: unknown, right: unknown): boolean;
|
|
15
16
|
export declare function compareSyncInclude(local: unknown, remote: unknown): {
|
|
16
17
|
same: boolean;
|
|
17
18
|
remoteOnly: string[];
|
|
18
19
|
localOnly: string[];
|
|
19
20
|
};
|
|
21
|
+
export type IgnorePolicyComparison = "match" | "mismatch" | "local-ignore-remote-legacy" | "local-legacy-remote-ignore";
|
|
22
|
+
type PortableDirectoryScope = Pick<DirectoryScope, "scope" | "reinclude">;
|
|
20
23
|
export type RemoteSelectionState = {
|
|
21
24
|
kind: "legacy";
|
|
22
25
|
discovered: string[];
|
|
26
|
+
ignorePolicyComparison?: never;
|
|
23
27
|
} | ({
|
|
24
28
|
kind: "same";
|
|
25
29
|
include: string[];
|
|
26
30
|
exclude?: string[];
|
|
27
|
-
|
|
31
|
+
ignorePolicyComparison?: "match";
|
|
32
|
+
} & PortableDirectoryScope) | ({
|
|
28
33
|
kind: "different";
|
|
29
34
|
include: string[];
|
|
30
35
|
exclude?: string[];
|
|
31
36
|
remoteOnly: string[];
|
|
32
37
|
localOnly: string[];
|
|
33
38
|
excludeChanged?: boolean;
|
|
34
|
-
|
|
39
|
+
ignorePolicyComparison?: Exclude<IgnorePolicyComparison, "match">;
|
|
40
|
+
} & PortableDirectoryScope);
|
|
41
|
+
export declare function compareIgnorePolicy(local: DirectoryScope["ignorePolicy"], remote: SnapshotSelection | undefined): IgnorePolicyComparison | undefined;
|
|
42
|
+
export declare function formatIgnorePolicyComparison(comparison: IgnorePolicyComparison): "Remote ignore-file policy differs. Edit local rules to match, or review publishing this device's policy." | "Remote ignore-file policy matches this device." | "Remote uses a legacy content policy. Review publishing this device's ignore-file policy." | "Remote uses an ignore-file policy. Configure matching local rules before transferring.";
|
|
35
43
|
export declare function syncDirectoryPolicyKey(config: SyncSelectionConfig): string | undefined;
|
|
36
44
|
export declare function inspectRemoteSelection(localInclude: unknown, snapshot: Pick<Snapshot, "selection" | "files">, localExclude?: unknown, directory?: DirectoryScope): RemoteSelectionState;
|
|
37
45
|
export interface RemoteSelectionDecision {
|
|
@@ -41,21 +49,24 @@ export interface RemoteSelectionDecision {
|
|
|
41
49
|
remoteInclude: readonly string[];
|
|
42
50
|
localExclude?: readonly string[];
|
|
43
51
|
remoteExclude?: readonly string[];
|
|
44
|
-
localDirectory?:
|
|
45
|
-
remoteDirectory?:
|
|
52
|
+
localDirectory?: PortableDirectoryScope;
|
|
53
|
+
remoteDirectory?: PortableDirectoryScope;
|
|
54
|
+
ignorePolicyComparison?: IgnorePolicyComparison;
|
|
46
55
|
}
|
|
47
56
|
export declare class RemoteSelectionMismatchError extends Error {
|
|
48
57
|
readonly decision: RemoteSelectionDecision;
|
|
49
58
|
readonly setupName: string;
|
|
50
59
|
readonly localInclude: string[];
|
|
51
60
|
readonly remoteInclude: string[];
|
|
52
|
-
constructor(setupName: string, localInclude: unknown, remoteInclude: unknown, configIdentity?: string, localExclude?: string[], remoteExclude?: string[], localDirectory?: DirectoryScope, remoteDirectory?:
|
|
61
|
+
constructor(setupName: string, localInclude: unknown, remoteInclude: unknown, configIdentity?: string, localExclude?: string[], remoteExclude?: string[], localDirectory?: DirectoryScope, remoteDirectory?: PortableDirectoryScope, ignorePolicyComparison?: IgnorePolicyComparison);
|
|
53
62
|
}
|
|
54
63
|
export declare function remoteSelectionMismatch(config: {
|
|
55
64
|
setupName: string;
|
|
56
65
|
include: unknown;
|
|
57
66
|
exclude?: string[];
|
|
58
|
-
} & DirectoryScope, remoteInclude: unknown, configIdentity?: string, remoteExclude?: string[], remoteDirectory?:
|
|
67
|
+
} & DirectoryScope, remoteInclude: unknown, configIdentity?: string, remoteExclude?: string[], remoteDirectory?: PortableDirectoryScope & {
|
|
68
|
+
ignorePolicyComparison?: IgnorePolicyComparison;
|
|
69
|
+
}): RemoteSelectionMismatchError;
|
|
59
70
|
export declare function formatRemoteSelectionMismatch(setupName: string, localInclude: readonly string[], remoteInclude: readonly string[], localExclude?: readonly string[], remoteExclude?: readonly string[], localDirectory?: DirectoryScope, remoteDirectory?: DirectoryScope): string;
|
|
60
71
|
export declare function discoverLegacySnapshotInclude(snapshot: Pick<Snapshot, "files">): string[];
|
|
61
72
|
export declare function syncIncludeSelection(value: unknown): {
|
|
@@ -66,6 +77,9 @@ export declare function syncIncludeSelection(value: unknown): {
|
|
|
66
77
|
};
|
|
67
78
|
export declare function customIncludePathsByLower(value: unknown): Map<string, string>;
|
|
68
79
|
export interface SyncSelectionConfig extends DirectoryScope {
|
|
80
|
+
version?: number;
|
|
81
|
+
fingerprint?: string;
|
|
82
|
+
sessions?: boolean;
|
|
69
83
|
include?: unknown;
|
|
70
84
|
exclude?: unknown;
|
|
71
85
|
syncFiles?: unknown;
|
|
@@ -74,10 +88,11 @@ export interface SyncSelectionConfig extends DirectoryScope {
|
|
|
74
88
|
}
|
|
75
89
|
export declare function includeFromSelectionConfig(config: SyncSelectionConfig): string[];
|
|
76
90
|
export declare function syncSelectionHasContent(config: SyncSelectionConfig): boolean;
|
|
91
|
+
export declare function isIgnoreControlPath(relativePath: string, reservedNames?: ReadonlySet<string>): boolean;
|
|
77
92
|
export declare const MAX_AGENT_DIRECTORY_ENTRIES = 65536;
|
|
78
93
|
export declare const MAX_AGENT_DIRECTORY_FILES = 16384;
|
|
79
94
|
export declare function assertAgentDirectoryPathLayout(files: Iterable<string>): void;
|
|
80
|
-
export declare function compileSyncPolicyExclude(config: SyncSelectionConfig): (relativePath: string) => boolean;
|
|
95
|
+
export declare function compileSyncPolicyExclude(config: SyncSelectionConfig): (relativePath: string, directory?: boolean) => boolean;
|
|
81
96
|
export declare function compileSyncPolicyTraversal(config: SyncSelectionConfig): (relativePath: string) => boolean;
|
|
82
97
|
export declare function syncSessionsSelected(config: SyncSelectionConfig): boolean;
|
|
83
98
|
export declare function isConfiguredSnapshotPath(relativePath: string, config: SyncSelectionConfig, _legacyExtraFiles?: Set<string>): boolean;
|
|
@@ -93,3 +108,4 @@ export declare function normalizeExtraFiles(value: unknown): string[];
|
|
|
93
108
|
export declare const extraFilePathsByLower: typeof customIncludePathsByLower;
|
|
94
109
|
export declare const isSafeExtraFileName: typeof isSafeCustomIncludePath;
|
|
95
110
|
export declare const selectedSyncFileSet: (value: unknown) => Set<"AGENTS.md" | "APPEND_SYSTEM.md" | "extensions" | "keybindings.json" | "models.json" | "prompts" | "settings.json" | "skills" | "themes">;
|
|
111
|
+
export {};
|