@narumitw/pi-sync-daemon 0.6.2 → 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 +19 -0
- package/README.md +17 -3
- package/dist/consent.js +26 -1
- 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 +39 -13
- 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/paths.js +1 -1
- package/dist/engine/settings/config-file.d.ts +9 -2
- package/dist/engine/settings/config-file.js +126 -28
- package/dist/engine/settings/config.d.ts +5 -4
- package/dist/engine/settings/config.js +114 -13
- package/dist/engine/settings/settings-management.js +34 -32
- package/dist/engine/settings/settings-types.d.ts +40 -5
- package/dist/engine/settings/settings-validation.js +52 -24
- package/dist/engine/snapshot/session-paths.d.ts +6 -4
- package/dist/engine/snapshot/session-paths.js +84 -15
- package/dist/engine/snapshot/snapshot-apply.d.ts +7 -8
- package/dist/engine/snapshot/snapshot-apply.js +107 -21
- package/dist/engine/snapshot/snapshot-bounds.d.ts +4 -0
- package/dist/engine/snapshot/snapshot-bounds.js +20 -0
- package/dist/engine/snapshot/snapshot-codec.d.ts +1 -1
- package/dist/engine/snapshot/snapshot-codec.js +15 -7
- package/dist/engine/snapshot/snapshot-entry-projection.d.ts +10 -0
- package/dist/engine/snapshot/snapshot-entry-projection.js +78 -0
- package/dist/engine/snapshot/snapshot-exclude-safety.d.ts +9 -2
- package/dist/engine/snapshot/snapshot-exclude-safety.js +239 -24
- package/dist/engine/snapshot/snapshot-payload.d.ts +2 -0
- package/dist/engine/snapshot/snapshot-payload.js +10 -0
- package/dist/engine/snapshot/snapshot-reviewed-preimages.d.ts +2 -0
- package/dist/engine/snapshot/snapshot-reviewed-preimages.js +60 -0
- package/dist/engine/snapshot/snapshot-root-transition.d.ts +4 -0
- package/dist/engine/snapshot/snapshot-root-transition.js +16 -0
- package/dist/engine/snapshot/snapshot-transaction-images.d.ts +39 -0
- package/dist/engine/snapshot/snapshot-transaction-images.js +387 -0
- package/dist/engine/snapshot/snapshot-transaction-policy.d.ts +73 -0
- package/dist/engine/snapshot/snapshot-transaction-policy.js +276 -0
- package/dist/engine/snapshot/snapshot-transaction-stage.d.ts +32 -0
- package/dist/engine/snapshot/snapshot-transaction-stage.js +303 -0
- 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 -11
- package/dist/engine/snapshot/snapshot-transaction.js +390 -364
- package/dist/engine/snapshot/snapshot-types.d.ts +47 -2
- package/dist/engine/snapshot/snapshot-types.js +9 -1
- package/dist/engine/snapshot/snapshot.d.ts +22 -3
- package/dist/engine/snapshot/snapshot.js +357 -43
- package/dist/engine/state/merge-baseline-store.js +20 -9
- package/dist/engine/state/state-types.d.ts +3 -0
- package/dist/engine/sync/apply-review.d.ts +3 -3
- package/dist/engine/sync/apply-review.js +5 -4
- package/dist/engine/sync/continuous-sync.js +37 -12
- package/dist/engine/sync/continuous-watch.d.ts +4 -1
- package/dist/engine/sync/continuous-watch.js +90 -15
- package/dist/engine/sync/exclude-policy.d.ts +4 -0
- package/dist/engine/sync/exclude-policy.js +8 -1
- package/dist/engine/sync/initialization.js +9 -4
- package/dist/engine/sync/local-fields.d.ts +3 -1
- package/dist/engine/sync/local-fields.js +88 -8
- package/dist/engine/sync/merge-apply.js +190 -47
- package/dist/engine/sync/merge-journal.d.ts +18 -4
- package/dist/engine/sync/merge-journal.js +126 -10
- package/dist/engine/sync/merged-sync.d.ts +1 -1
- package/dist/engine/sync/merged-sync.js +124 -68
- package/dist/engine/sync/partial-progress.js +5 -3
- package/dist/engine/sync/remote-snapshot.d.ts +10 -2
- package/dist/engine/sync/remote-snapshot.js +59 -17
- package/dist/engine/sync/session-push.js +7 -6
- package/dist/engine/sync/sync-decision.d.ts +4 -0
- package/dist/engine/sync/sync-decision.js +17 -2
- package/dist/engine/sync/sync-inspection.js +8 -6
- package/dist/engine/sync/sync-mutations.d.ts +10 -2
- package/dist/engine/sync/sync-mutations.js +245 -101
- package/dist/engine/sync/sync-policy.d.ts +36 -10
- package/dist/engine/sync/sync-policy.js +285 -20
- package/dist/engine/sync/sync-queries.js +49 -32
- package/dist/engine/sync/sync-state.d.ts +11 -0
- package/dist/engine/sync/sync-state.js +42 -5
- package/dist/engine/ui/sync-format.js +22 -7
- package/dist/engine-service.js +24 -2
- package/docs/architecture.md +28 -0
- package/package.json +2 -1
|
@@ -37,10 +37,16 @@ export function createSyncDecision(options) {
|
|
|
37
37
|
...(policyChanged
|
|
38
38
|
? [
|
|
39
39
|
"",
|
|
40
|
-
`Previously included: ${
|
|
41
|
-
`Currently included: ${
|
|
40
|
+
`Previously included: ${selectionLabel(state.scope, previousInclude)}`,
|
|
41
|
+
`Currently included: ${selectionLabel(config.scope, currentInclude)}`,
|
|
42
42
|
`Previously excluded: ${safeList(state.exclude ?? [])}`,
|
|
43
43
|
`Currently excluded: ${safeList(config.exclude ?? [])}`,
|
|
44
|
+
...(state.scope || config.scope
|
|
45
|
+
? [
|
|
46
|
+
`Previously re-included: ${safeList(state.reinclude ?? [])}`,
|
|
47
|
+
`Currently re-included: ${safeList(config.reinclude ?? [])}`,
|
|
48
|
+
]
|
|
49
|
+
: []),
|
|
44
50
|
]
|
|
45
51
|
: []),
|
|
46
52
|
"",
|
|
@@ -56,11 +62,20 @@ export function createSyncDecision(options) {
|
|
|
56
62
|
currentInclude,
|
|
57
63
|
...(policyChanged && state.exclude !== undefined ? { previousExclude: [...state.exclude] } : {}),
|
|
58
64
|
...(config.exclude === undefined ? {} : { currentExclude: [...config.exclude] }),
|
|
65
|
+
...(policyChanged && state.scope !== undefined ? { previousScope: state.scope } : {}),
|
|
66
|
+
...(config.scope === undefined ? {} : { currentScope: config.scope }),
|
|
67
|
+
...(policyChanged && state.reinclude !== undefined ? { previousReinclude: [...state.reinclude] } : {}),
|
|
68
|
+
...(config.reinclude === undefined ? {} : { currentReinclude: [...config.reinclude] }),
|
|
59
69
|
review,
|
|
60
70
|
directions: kind === "remote-empty" ? ["push"] : ["push", "pull"],
|
|
61
71
|
directMessage: options.directMessage,
|
|
62
72
|
});
|
|
63
73
|
}
|
|
74
|
+
function selectionLabel(scope, include) {
|
|
75
|
+
return scope === "agent-directory"
|
|
76
|
+
? `eligible files in the Pi agent directory (sessions ${include.includes("sessions") ? "opted in" : "off"})`
|
|
77
|
+
: safeList(include);
|
|
78
|
+
}
|
|
64
79
|
function safeList(values) {
|
|
65
80
|
return values.length > 0 ? values.map(safeTerminalText).join(", ") : "none";
|
|
66
81
|
}
|
|
@@ -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,14 +28,13 @@ 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)
|
|
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
|
-
emptyInclude: config
|
|
37
|
+
emptyInclude: !syncSelectionHasContent(config),
|
|
36
38
|
stateIdentity: syncStateFingerprint(state),
|
|
37
39
|
destination: backend.destination,
|
|
38
40
|
capability: backend.capability,
|
|
@@ -21,10 +21,18 @@ interface PushInput {
|
|
|
21
21
|
backend?: SyncBackend;
|
|
22
22
|
}
|
|
23
23
|
export declare function push(ctx: ExtensionCommandContext | ExtensionContext, options: CommandOptions, input?: PushInput, factory?: SyncBackendFactory): Promise<"applied" | "cancelled" | undefined>;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
interface InitialPullEvidence {
|
|
25
|
+
configIdentity: string;
|
|
26
|
+
stateIdentity: string;
|
|
27
|
+
sessionDir: string | undefined;
|
|
28
|
+
localHashes: Record<string, string>;
|
|
29
|
+
head: RemoteHead | undefined;
|
|
30
|
+
}
|
|
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" | "archived" | "cancelled" | undefined>;
|
|
26
33
|
export declare function rollback(ctx: ExtensionCommandContext, options: CommandOptions, factory?: SyncBackendFactory, expectedSelection?: {
|
|
27
34
|
backendIdentity: string;
|
|
28
35
|
setup?: string;
|
|
36
|
+
snapshotId?: string;
|
|
29
37
|
}): Promise<void>;
|
|
30
38
|
export { backupLocal } from "./sync-local.js";
|