@narumitw/pi-sync 0.65.0 → 0.67.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 +16 -0
- package/README.md +13 -4
- package/dist/chunks/{chunk-OWEOZZZE.ts → chunk-5YOLQKNZ.ts} +38 -2
- package/dist/chunks/chunk-5YOLQKNZ.ts.map +7 -0
- package/dist/chunks/{chunk-OBVJTKVY.ts → chunk-ASU3GZPW.ts} +10 -92
- package/dist/chunks/chunk-ASU3GZPW.ts.map +7 -0
- package/dist/chunks/{chunk-IOM6E5FW.ts → chunk-BESRBKVO.ts} +2 -2
- package/dist/chunks/{chunk-TZMVSTAM.ts → chunk-BYVHABNR.ts} +4 -4
- package/dist/chunks/chunk-ECYCNZOE.ts +12 -0
- package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
- package/dist/chunks/{chunk-MANNB4WZ.ts → chunk-KNEUL4XN.ts} +1 -7
- package/dist/chunks/chunk-KNEUL4XN.ts.map +7 -0
- package/dist/chunks/chunk-Z5JMOXJM.ts +106 -0
- package/dist/chunks/chunk-Z5JMOXJM.ts.map +7 -0
- package/dist/chunks/{command-handler-YZ4DXQ7N.ts → command-handler-SQC2L2FJ.ts} +9 -7
- package/dist/chunks/{command-handler-YZ4DXQ7N.ts.map → command-handler-SQC2L2FJ.ts.map} +1 -1
- package/dist/chunks/{file-selection-DDQN4LVD.ts → file-selection-XWACUTAH.ts} +8 -8
- package/dist/chunks/ignore-file-ui-OHFISFVC.ts +21 -0
- package/dist/chunks/{manager-result-dispatcher-XB75YLEG.ts → manager-result-dispatcher-WXE2BAQO.ts} +3 -3
- package/dist/chunks/{manager-ui-RGA26Z6G.ts → manager-ui-DWOMAJKE.ts} +170 -45
- package/dist/chunks/manager-ui-DWOMAJKE.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-WVMET5RI.ts → remote-selection-ui-E4XZCQ7A.ts} +2 -2
- package/dist/chunks/remote-selection-ui-E4XZCQ7A.ts.map +7 -0
- package/dist/chunks/{setup-wizard-YP2KF2WQ.ts → setup-wizard-IEW56AZE.ts} +7 -5
- package/dist/chunks/{setup-wizard-YP2KF2WQ.ts.map → setup-wizard-IEW56AZE.ts.map} +1 -1
- package/dist/daemon/dist/consent.js +14 -2
- package/dist/daemon/dist/engine/backends/git/git-backend.js +5 -3
- package/dist/daemon/dist/engine/backends/git/git-storage.js +15 -3
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +143 -0
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +2 -2
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +2 -1
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +39 -0
- package/dist/daemon/dist/engine/settings/config-file.js +3 -0
- package/dist/daemon/dist/engine/settings/config.js +5 -5
- package/dist/daemon/dist/engine/settings/settings-management.js +6 -1
- package/dist/daemon/dist/engine/settings/settings-validation.js +21 -2
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +2 -2
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +6 -6
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +5 -1
- package/dist/daemon/dist/engine/snapshot/snapshot.js +5 -2
- package/dist/daemon/dist/engine/sync/conflict-review.js +2 -0
- package/dist/daemon/dist/engine/sync/continuous-errors.js +6 -0
- package/dist/daemon/dist/engine/sync/continuous-sync.js +4 -2
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -2
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -8
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +50 -0
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +410 -0
- package/dist/daemon/dist/engine/sync/ignore-publication.js +23 -0
- package/dist/daemon/dist/engine/sync/initialization.js +12 -0
- package/dist/daemon/dist/engine/sync/local-fields.js +6 -3
- package/dist/daemon/dist/engine/sync/merge-apply.js +18 -1
- package/dist/daemon/dist/engine/sync/merge-journal.js +2 -2
- package/dist/daemon/dist/engine/sync/merged-sync.js +50 -7
- package/dist/daemon/dist/engine/sync/push-review.js +33 -0
- package/dist/daemon/dist/engine/sync/sync-local.js +2 -1
- package/dist/daemon/dist/engine/sync/sync-mutations.js +108 -55
- package/dist/daemon/dist/engine/sync/sync-policy.js +5 -5
- package/dist/daemon/dist/engine/sync/sync-queries.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-rollback.js +25 -5
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +3 -2
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +92 -0
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +18 -0
- package/dist/daemon/dist/engine-service.js +1 -1
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +1 -1
- package/docs/daemon-migration.md +6 -0
- package/docs/tui-contract.md +6 -5
- package/package.json +2 -2
- package/skills/configure-pi-sync/SKILL.md +1 -1
- package/skills/configure-pi-sync/references/configuration.md +43 -14
- package/src/ui/ignore-file-ui.ts +13 -5
- package/src/ui/manager-state.ts +15 -8
- package/src/ui/manager-ui.ts +1 -1
- package/src/ui/remote-selection-ui.ts +43 -2
- package/src/ui/settings-ui.ts +156 -32
- package/dist/chunks/chunk-MANNB4WZ.ts.map +0 -7
- package/dist/chunks/chunk-OBVJTKVY.ts.map +0 -7
- package/dist/chunks/chunk-OWEOZZZE.ts.map +0 -7
- package/dist/chunks/manager-ui-RGA26Z6G.ts.map +0 -7
- /package/dist/chunks/{chunk-IOM6E5FW.ts.map → chunk-BESRBKVO.ts.map} +0 -0
- /package/dist/chunks/{chunk-TZMVSTAM.ts.map → chunk-BYVHABNR.ts.map} +0 -0
- /package/dist/chunks/{file-selection-DDQN4LVD.ts.map → file-selection-XWACUTAH.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-XB75YLEG.ts.map → ignore-file-ui-OHFISFVC.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-WVMET5RI.ts.map → manager-result-dispatcher-WXE2BAQO.ts.map} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createSyncBackend } from "../backends/backend-factory.js";
|
|
2
2
|
import { expectedRemoteHead } from "../backends/sync-backend.js";
|
|
3
|
+
import { requireNoPendingAdoption } from "../ignore/adoption-journal.js";
|
|
3
4
|
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
4
5
|
import { effectiveSessionRoot, requireStableMergeSessionRoot, resolvedSnapshotOptionsForContext, sessionDirForApply, } from "../snapshot/session-paths.js";
|
|
5
|
-
import { createSnapshot, filterSnapshotForConfigPolicy, regenerateSnapshotIdentity, snapshotIncludesSessions, snapshotWithoutSessions, } from "../snapshot/snapshot.js";
|
|
6
|
+
import { createSnapshot, filterSnapshotForConfigPolicy, regenerateSnapshotIdentity, scanSnapshot, snapshotIncludesSessions, snapshotWithoutSessions, } from "../snapshot/snapshot.js";
|
|
6
7
|
import { applySnapshot } from "../snapshot/snapshot-apply.js";
|
|
7
8
|
import { ignorePolicyValidator } from "../snapshot/snapshot-transaction-policy.js";
|
|
8
9
|
import { pruneMergeBaselines } from "../state/merge-baseline-store.js";
|
|
@@ -11,6 +12,7 @@ import { formatPublicationPreview, formatRollbackSummary, formatTransferReview }
|
|
|
11
12
|
import { confirmTransferReview } from "../ui/transfer-review.js";
|
|
12
13
|
import { inspectCaseCleanup, revalidateCaseCleanup } from "./apply-review.js";
|
|
13
14
|
import { confirmFieldMigration } from "./field-migration.js";
|
|
15
|
+
import { ignorePublicationNotice, withPublishedIgnoreRules } from "./ignore-publication.js";
|
|
14
16
|
import { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
|
|
15
17
|
import { requireNoMergeJournal, retireMergeJournal } from "./merge-journal.js";
|
|
16
18
|
import { readSnapshotForHead, requireCompatibleRemoteSelection, sameRemoteHead, snapshotForUpload, } from "./remote-snapshot.js";
|
|
@@ -19,12 +21,14 @@ import { PublicationStatePersistenceError, RollbackPublicationError } from "./sy
|
|
|
19
21
|
import { backupLocal, captureMutationOwner, maybeReload, protectedSessionPaths } from "./sync-local.js";
|
|
20
22
|
import { requireLegacyTransferPolicy, syncSessionsSelected } from "./sync-policy.js";
|
|
21
23
|
import { acceptedSelection, fileHashMap, sameHashes } from "./sync-state.js";
|
|
22
|
-
import { directionalApplyGuards, requireIgnoreBaselineReview, requireResolvedDirectionalProgress, validateDirectionalPublication, } from "./transfer-freshness.js";
|
|
24
|
+
import { checkLiveProtection, directionalApplyGuards, requireIgnoreBaselineReview, requireResolvedDirectionalProgress, validateDirectionalPublication, } from "./transfer-freshness.js";
|
|
25
|
+
import { requireTransferSize, selectedPublicationImage, selectedPullImage, transferSizeLimitsEnabled, } from "./transfer-size-limits.js";
|
|
23
26
|
const VERSION = 1;
|
|
24
27
|
const POST_LOCAL_COMMIT_TIMEOUT_MS = 30_000;
|
|
25
28
|
export async function rollback(ctx, options, factory = createSyncBackend, expectedSelection) {
|
|
26
29
|
if (options.directionalAction)
|
|
27
30
|
throw new Error("Single-action transfer cannot authorize rollback.");
|
|
31
|
+
requireNoPendingAdoption();
|
|
28
32
|
const validateMutation = captureMutationOwner(ctx, options.signal);
|
|
29
33
|
const validateCommittedOwner = captureMutationOwner(ctx);
|
|
30
34
|
const target = options.args[0];
|
|
@@ -73,18 +77,24 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
73
77
|
if (config.scope === "agent-directory")
|
|
74
78
|
requireStableMergeSessionRoot(local, physical, config.scope);
|
|
75
79
|
const upload = config.ignorePolicy
|
|
76
|
-
? remote
|
|
80
|
+
? await withPublishedIgnoreRules(remote, config, options.signal)
|
|
77
81
|
: await snapshotForUpload(backend, config, remote, expectedHead, currentRemote, snapshotOptions);
|
|
82
|
+
validateMutation();
|
|
78
83
|
if (config.scope === "agent-directory")
|
|
79
84
|
validatePortableSnapshot(upload);
|
|
85
|
+
if (upload.ignoreRules && !config.skipSecretScan && scanSnapshot({ ...upload, files: [] }).length)
|
|
86
|
+
throw new Error("Refusing to publish possible secrets in the ignore file.");
|
|
80
87
|
const caseCleanup = options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);
|
|
81
88
|
validateMutation();
|
|
82
89
|
const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
90
|
+
const sizeLimited = transferSizeLimitsEnabled(config);
|
|
91
|
+
if (sizeLimited)
|
|
92
|
+
requireTransferSize(config, selectedPullImage(remote, local, reviewedProtectedPaths), selectedPublicationImage(upload, config, snapshotOptions.sessionDir));
|
|
83
93
|
if (!options.yes) {
|
|
84
94
|
const title = snapshotIncludesSessions(remote) ? "Rollback pi settings and sessions?" : "Rollback pi settings?";
|
|
85
95
|
const summary = formatRollbackSummary(config, backend.destination, local, physical, target, reviewedProtectedPaths, caseCleanup.map((item) => item.path));
|
|
86
96
|
const confirmed = config.ignorePolicy
|
|
87
|
-
? await confirmTransferReview(ctx, title, formatTransferReview("Historical files are projected through this device's current ignore rules. Historical rules are not adopted. Retained history is not erased.", "", summary, "", "Remote publication:", formatPublicationPreview(currentRemote, upload)), options.signal, validateMutation)
|
|
97
|
+
? await confirmTransferReview(ctx, title, formatTransferReview("Historical files are projected through this device's current ignore rules. Historical rules are not adopted. Retained history is not erased.", ignorePublicationNotice(upload) ?? "", summary, "", "Remote publication:", formatPublicationPreview(currentRemote, upload)), options.signal, validateMutation)
|
|
88
98
|
: await ctx.ui.confirm(title, summary.content, { signal: options.signal });
|
|
89
99
|
validateMutation();
|
|
90
100
|
if (!confirmed) {
|
|
@@ -122,6 +132,8 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
122
132
|
await validateIgnorePolicy();
|
|
123
133
|
}
|
|
124
134
|
const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
135
|
+
if (sizeLimited)
|
|
136
|
+
checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
125
137
|
const applyGuards = directionalApplyGuards({
|
|
126
138
|
ctx,
|
|
127
139
|
config,
|
|
@@ -134,6 +146,14 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
134
146
|
onCommit: options.onCommit,
|
|
135
147
|
validateMutation,
|
|
136
148
|
validateIgnorePolicy,
|
|
149
|
+
validateSettings: async () => {
|
|
150
|
+
if (syncCheckConfigFingerprint(config) !==
|
|
151
|
+
syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))
|
|
152
|
+
throw new Error("Settings changed before rollback apply.");
|
|
153
|
+
validateMutation();
|
|
154
|
+
if (sizeLimited)
|
|
155
|
+
checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
156
|
+
},
|
|
137
157
|
});
|
|
138
158
|
applyGuards.validateMutation();
|
|
139
159
|
if (!validateIgnorePolicy)
|
|
@@ -142,7 +162,7 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
142
162
|
...snapshotOptions,
|
|
143
163
|
sessionDir: applySessionDir,
|
|
144
164
|
...applyGuards,
|
|
145
|
-
...(config.scope === "agent-directory" || validateIgnorePolicy ? { reviewedLocal: local } : {}),
|
|
165
|
+
...(config.scope === "agent-directory" || validateIgnorePolicy || sizeLimited ? { reviewedLocal: local } : {}),
|
|
146
166
|
expectedFileHashes: config.localFields?.length
|
|
147
167
|
? { "settings.json": fileHashMap(local)["settings.json"] ?? null }
|
|
148
168
|
: undefined,
|
|
@@ -38,9 +38,9 @@ export function checkLiveProtection(ctx, sessionDir, reviewed) {
|
|
|
38
38
|
if (current.size !== reviewed.size || [...current].some((item) => !reviewed.has(item)))
|
|
39
39
|
throw new StaleIgnorePolicyError("Live session protection changed during review; reopen the review.");
|
|
40
40
|
}
|
|
41
|
-
export function directionalApplyGuards({ ctx, config, backend, state, sessionDir, head, protectedPaths, signal, validateMutation, validateIgnorePolicy, onCommit, effectiveRoot = false, }) {
|
|
41
|
+
export function directionalApplyGuards({ ctx, config, backend, state, sessionDir, head, protectedPaths, signal, validateMutation, validateIgnorePolicy, validateSettings, onCommit, effectiveRoot = false, }) {
|
|
42
42
|
if (!validateIgnorePolicy)
|
|
43
|
-
return { validateMutation };
|
|
43
|
+
return { validateMutation, validateApplyReview: validateSettings };
|
|
44
44
|
const validateOwner = () => {
|
|
45
45
|
validateMutation();
|
|
46
46
|
checkLiveProtection(ctx, sessionDir, protectedPaths);
|
|
@@ -58,6 +58,7 @@ export function directionalApplyGuards({ ctx, config, backend, state, sessionDir
|
|
|
58
58
|
? await effectiveSessionRoot(ctx, config, signal)
|
|
59
59
|
: (await resolvedSnapshotOptionsForContext(ctx, config, signal)).sessionDir))
|
|
60
60
|
throw new StaleIgnorePolicyError("Pi session storage changed before local apply; reopen the review.");
|
|
61
|
+
await validateSettings?.();
|
|
61
62
|
await validateIgnorePolicy();
|
|
62
63
|
validateOwner();
|
|
63
64
|
if (!committed) {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { parentPaths } from "../paths.js";
|
|
2
|
+
import { filterSnapshotForConfigPolicy } from "../snapshot/snapshot.js";
|
|
3
|
+
import { snapshotBase64Size } from "../snapshot/snapshot-payload.js";
|
|
4
|
+
import { snapshotPathLabel } from "../ui/terminal-text.js";
|
|
5
|
+
import { TransferSizeError } from "./continuous-errors.js";
|
|
6
|
+
const MIB = 1024 ** 2;
|
|
7
|
+
const MAX_FINDINGS = 8;
|
|
8
|
+
export function transferSizeLimitsEnabled(config) {
|
|
9
|
+
return config.maxFileSizeMiB !== undefined || config.maxDirectorySizeMiB !== undefined;
|
|
10
|
+
}
|
|
11
|
+
export function selectedPublicationImage(snapshot, config, sessionDir) {
|
|
12
|
+
return {
|
|
13
|
+
side: "Remote",
|
|
14
|
+
files: filterSnapshotForConfigPolicy(snapshot, config, { sessionDir }).files,
|
|
15
|
+
ignoreRules: snapshot.ignoreRules,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function selectedPullImage(incoming, local, protectedPaths, ignoreRules) {
|
|
19
|
+
return {
|
|
20
|
+
side: "Local",
|
|
21
|
+
files: protectedPaths.size
|
|
22
|
+
? [
|
|
23
|
+
...incoming.files.filter((file) => !protectedPaths.has(file.path)),
|
|
24
|
+
...local.files.filter((file) => protectedPaths.has(file.path)),
|
|
25
|
+
]
|
|
26
|
+
: incoming.files,
|
|
27
|
+
ignoreRules,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function compareFindings(a, b) {
|
|
31
|
+
if (a.side !== b.side)
|
|
32
|
+
return a.side < b.side ? -1 : 1;
|
|
33
|
+
if (a.path !== b.path)
|
|
34
|
+
return a.path < b.path ? -1 : 1;
|
|
35
|
+
return a.kind === b.kind ? 0 : a.kind < b.kind ? -1 : 1;
|
|
36
|
+
}
|
|
37
|
+
export function transferSizeDetails(config, images) {
|
|
38
|
+
if (!transferSizeLimitsEnabled(config))
|
|
39
|
+
return;
|
|
40
|
+
const fileLimit = (config.maxFileSizeMiB ?? Infinity) * MIB;
|
|
41
|
+
const directoryLimit = (config.maxDirectorySizeMiB ?? Infinity) * MIB;
|
|
42
|
+
const findings = [];
|
|
43
|
+
let count = 0;
|
|
44
|
+
for (const { side, files, ignoreRules } of images) {
|
|
45
|
+
const directories = new Map();
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
const measure = (path, size, kind, limit) => {
|
|
48
|
+
if (size <= limit)
|
|
49
|
+
return;
|
|
50
|
+
count++;
|
|
51
|
+
const finding = { side, path, size, kind, limit };
|
|
52
|
+
if (findings.length === MAX_FINDINGS && compareFindings(finding, findings[MAX_FINDINGS - 1]) >= 0)
|
|
53
|
+
return;
|
|
54
|
+
findings.push(finding);
|
|
55
|
+
findings.sort(compareFindings);
|
|
56
|
+
if (findings.length > MAX_FINDINGS)
|
|
57
|
+
findings.pop();
|
|
58
|
+
};
|
|
59
|
+
const measureFile = (path, size) => {
|
|
60
|
+
if (seen.has(path))
|
|
61
|
+
return;
|
|
62
|
+
seen.add(path);
|
|
63
|
+
measure(path, size, "file", fileLimit);
|
|
64
|
+
if (directoryLimit !== Infinity)
|
|
65
|
+
for (const parent of parentPaths(path))
|
|
66
|
+
directories.set(parent, (directories.get(parent) ?? 0) + size);
|
|
67
|
+
};
|
|
68
|
+
if (ignoreRules)
|
|
69
|
+
measureFile(ignoreRules.filename, Buffer.byteLength(ignoreRules.text, "utf8"));
|
|
70
|
+
for (const file of files)
|
|
71
|
+
measureFile(file.path, snapshotBase64Size(file.contentBase64, file.path));
|
|
72
|
+
for (const [path, size] of directories)
|
|
73
|
+
measure(path, size, "directory", directoryLimit);
|
|
74
|
+
}
|
|
75
|
+
if (!count)
|
|
76
|
+
return;
|
|
77
|
+
const omitted = count - findings.length;
|
|
78
|
+
return [
|
|
79
|
+
...findings.map(({ path, side, size, kind, limit }) => {
|
|
80
|
+
const label = JSON.stringify(snapshotPathLabel(path.slice(0, 160))).slice(1, -1);
|
|
81
|
+
const shortened = path.length > 160 || label.length > 240;
|
|
82
|
+
return `${side} ${kind} "${label.slice(0, 240)}${shortened ? "…" : ""}": ${size} bytes (limit ${limit} bytes).`;
|
|
83
|
+
}),
|
|
84
|
+
...(omitted ? [`${omitted} additional ${omitted === 1 ? "finding" : "findings"} omitted.`] : []),
|
|
85
|
+
`Use /sync diff, adjust ${config.pathPolicy === "ignore-file" ? ".syncignore (or your configured rule file)" : "exclusions in /sync → Settings"}, then review a Push or Pull.`,
|
|
86
|
+
].join(" ");
|
|
87
|
+
}
|
|
88
|
+
export function requireTransferSize(config, ...images) {
|
|
89
|
+
const details = transferSizeDetails(config, images);
|
|
90
|
+
if (details)
|
|
91
|
+
throw new TransferSizeError(`Transfer blocked by size limits. ${details}`);
|
|
92
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { snapshotPathLabel } from "./terminal-text.js";
|
|
2
|
+
export function formatRuleChanges(before, after) {
|
|
3
|
+
if (before === after) {
|
|
4
|
+
const message = before === undefined ? "Rule text is unavailable on both sides." : "Rule text is unchanged.";
|
|
5
|
+
return { lines: [message], content: message };
|
|
6
|
+
}
|
|
7
|
+
const lines = (text, prefix) => text === undefined
|
|
8
|
+
? [`${prefix} (rule text not in snapshot)`]
|
|
9
|
+
: text.split(/(?<=\n)/u).map((line) => `${prefix} ${snapshotPathLabel(JSON.stringify(line))}`);
|
|
10
|
+
return {
|
|
11
|
+
lines: ["Rule text changes. View details for the exact lines."],
|
|
12
|
+
content: [
|
|
13
|
+
"Rule text (− before, + after; JSON quotes show whitespace):",
|
|
14
|
+
...lines(before, "-"),
|
|
15
|
+
...lines(after, "+"),
|
|
16
|
+
].join("\n"),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -49,7 +49,7 @@ export function createEngineService(root, ignoreFileSettingsAvailable = false) {
|
|
|
49
49
|
const execute = (operation, payload, execution) => host.run(execution, async () => {
|
|
50
50
|
if (operation === "ignore.capabilities") {
|
|
51
51
|
execution.validate();
|
|
52
|
-
return { available: ignoreFileSettingsAvailable };
|
|
52
|
+
return { available: ignoreFileSettingsAvailable, ...(ignoreFileSettingsAvailable ? { portableRules: 1 } : {}) };
|
|
53
53
|
}
|
|
54
54
|
if (operation === "ignore.migration-offer" || operation === "ignore.migration-defer") {
|
|
55
55
|
execution.validate();
|
package/dist/daemon/package.json
CHANGED
package/dist/index.ts
CHANGED
|
@@ -334,7 +334,7 @@ function createStartupCheck(loaders, attention, timeoutMs = 3e4, publish) {
|
|
|
334
334
|
// src/sync/sync-loaders.ts
|
|
335
335
|
function createSyncLoaders(dependencies) {
|
|
336
336
|
const loaders = {
|
|
337
|
-
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-
|
|
337
|
+
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-SQC2L2FJ.ts"))),
|
|
338
338
|
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-NBBTSMKR.ts"))),
|
|
339
339
|
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-644T6KHG.ts"))),
|
|
340
340
|
snapshot: cachedModuleLoader(dependencies.loadSnapshot ?? (() => import("./chunks/snapshot-ZUJJZCFW.ts"))),
|
package/docs/daemon-migration.md
CHANGED
|
@@ -68,6 +68,8 @@ Before the first daemon-owned transfer, close or upgrade every older Pi process
|
|
|
68
68
|
|
|
69
69
|
Backend formats, `pi-sync.json`, `pi-sync/`, `.pisync/`, backups, and journals remain owned by the extracted engine. Legacy directory migration remains explicit. Coexisting or unsafe state roots must be reconciled without merging or deleting evidence automatically.
|
|
70
70
|
|
|
71
|
+
Before enabling [transfer size limits](../skills/configure-pi-sync/references/configuration.md#transfer-size-limits), make sure the running owner supports both saving and enforcing the limits. A healthy `status` handshake alone does not establish that support. If an old owner remains after an update or an in-place rebuild, use the exit checks above before reloading Pi. Upgrade or close all older clients using that agent directory. Enabling a limit requires version 9 for the entire local settings document, which older processes refuse. It does not change the IPC protocol or remote snapshots.
|
|
72
|
+
|
|
71
73
|
## Lifetime is not consent
|
|
72
74
|
|
|
73
75
|
Old Continuous consent was limited to an open Pi session. Existing Automatic, Autonomous, and Continuous defaults stay unchanged. When no registered live client PID remains for that canonical root and no valid explicit after-exit grant covers the active setup, a fixed 30-second grace period starts. Explicit CLI start without clients follows the same policy. Live passive, disconnected, publishing, and orderly retired PIDs keep the owner alive; detach, heartbeat loss, and an empty active-participant list do not prove process exit. `/reload`, `/new`, fork, and resume retain protection while their Pi process lives. A client arriving before shutdown becomes final cancels automatic exit. No new setting, environment variable, or keep-alive flag is added.
|
|
@@ -145,6 +147,10 @@ Before rollback:
|
|
|
145
147
|
65,536 bytes because it keeps all other fields when revoking grants. Builds with the old
|
|
146
148
|
65,536-byte limit cannot read that file. Preserve it and use a build that supports the larger
|
|
147
149
|
file. Do not delete it or restore an older copy to make the rollback work.
|
|
150
|
+
5. Check settings compatibility. Version 9 remains after both transfer limits are cleared. Keep a
|
|
151
|
+
compatible owner; do not relabel the document as version 8 or replace it with older bytes to
|
|
152
|
+
bypass the check. Keep journals and backups and verify the local and remote snapshot IDs before
|
|
153
|
+
retrying uncertain work.
|
|
148
154
|
|
|
149
155
|
Operation retries are instance-bound and deduplicated. An expired result or old instance requires journal reconciliation, not blind replay. A full bounded result ledger requires an explicit drained restart.
|
|
150
156
|
|
package/docs/tui-contract.md
CHANGED
|
@@ -4,7 +4,7 @@ This reference records the setting and transfer contracts used by the TUI. It do
|
|
|
4
4
|
|
|
5
5
|
## Action palette
|
|
6
6
|
|
|
7
|
-
The `/sync` TUI manager uses Kit's public searchable `ChoiceScreen` with at most five visible choices. Ordinary rows contain only labels; the selected action's short description appears below the list and is included in search. Search and selection survive a cancelled operation. Navigation, confirmation, cancellation, paste, focus, scrolling and constrained-height framing remain Kit-owned. RPC keeps an unfiltered list with the established **Sync now** label and a **Done** exit; TUI displays **Sync…** for that same action.
|
|
7
|
+
The `/sync` TUI manager uses Kit's public searchable `ChoiceScreen` with at most five visible choices. Ordinary rows contain only labels; the selected action's short description appears below the list and is included in search. Searching for `storage connections` finds **Settings** in the configured manager. Search and selection survive a cancelled operation. Navigation, confirmation, cancellation, paste, focus, scrolling and constrained-height framing remain Kit-owned. RPC keeps an unfiltered list with the established **Sync now** label and a **Done** exit; TUI displays **Sync…** for that same action.
|
|
8
8
|
|
|
9
9
|
The homepage shows setup/storage, cached remote observations, last applied state and relevant automatic-transfer permissions. It does not render scheduler owners, leases, request accounting or candidate limits. Recorded background phases and successful background-transfer timestamps are explicitly historical; neither replaces a fresh remote check. Missing records show **not yet observed**, and unreadable or invalid records show **Unknown**. Last applied does not invent a timestamp or direction.
|
|
10
10
|
|
|
@@ -33,11 +33,12 @@ All settings are private to this device. There are no project overrides. Default
|
|
|
33
33
|
| Manage storage connections | `storageConnections` | Shared by named setups | Existing affected-setup review; changes future operations |
|
|
34
34
|
| Merge settings fields | `sync.mergeSettings`, false | Current setup | Immediate save; opt-in merge on subsequent sync with a verified ancestor |
|
|
35
35
|
| Content merge / partial progress | `sync.mergeContent`, `sync.partialSync`, false/false | Current setup | Explicit compatibility review and atomic save; Off, Merge only, Merge + partial, Partial only preserve all combinations |
|
|
36
|
+
| Max file size / Max directory size | `sync.maxFileSizeMiB`, `sync.maxDirectorySizeMiB`, both absent | Current setup | Independent inputs; review before upgrading the settings document to version 9; subsequent transfers only. See [transfer size limits](../skills/configure-pi-sync/references/configuration.md#transfer-size-limits). |
|
|
36
37
|
| Skip secret scan | `skipSecretScan`, false | All setups | Immediate save; subsequent manual/automatic pushes; Diagnostics still scans |
|
|
37
38
|
| Show sync status | `showStatus`, true | All setups | Immediate save and immediate status visibility change; notifications/widgets remain |
|
|
38
39
|
| Debug mode | `debug`, false | All setups | Immediate save; Pi logging and timing display use the next session start in TUI/RPC; daemon log uses the next owner, job, or Continuous sync cycle boundary |
|
|
39
40
|
|
|
40
|
-
Opening foreground Settings cancels and drains startup work. Back does not undo successful saves; cancelling a draft or compatibility review leaves that change unsaved. A failed save retains the previous document and effective/displayed value. Completed transfers are never undone by changing a preference.
|
|
41
|
+
Opening foreground Settings cancels and drains startup work. Simple changes report saving, then one setting-specific confirmation or an error in Pi's notifications. Back does not undo successful saves; cancelling a draft or compatibility review leaves that change unsaved. In a transfer-size input or its version-upgrade review, Ctrl+C discards the draft and closes the `/sync` flow; ordinary cancellation returns to Settings. A failed save retains the previous document and effective/displayed value. Completed transfers are never undone by changing a preference.
|
|
41
42
|
|
|
42
43
|
Writers queue the complete read-modify-write operation, hold the cross-process lock through validation and same-directory atomic replacement, preserve unknown fields and private permissions, and refuse invalid existing files. UI changes do not replace those writers.
|
|
43
44
|
|
|
@@ -49,7 +50,7 @@ Check the setting's save and rollback with non-default bindings and verify next-
|
|
|
49
50
|
|
|
50
51
|
## Presentation decisions
|
|
51
52
|
|
|
52
|
-
Selecting **Settings** in `/sync` opens **Pi Sync Settings** directly as one searchable flat list
|
|
53
|
+
Selecting **Settings** in `/sync` opens **Pi Sync Settings** directly as one searchable flat list with no category navigation or headings. Included paths, Excluded paths, and Compare included paths keep both content policies together. Excluded paths has a transactional JSON-array draft and reviewed Save/Discard/Continue flow; other rows retain their existing actions and save behavior. Typing searches the list. Back returns directly to the manager; hard Ctrl+C closes the flow. No `/ Search` hint is added because slash is ordinary search text.
|
|
53
54
|
|
|
54
55
|
The existing public Kit settings adapter is retained rather than adding a second selector or accessing private Pi fields. Installed `SettingsList` provides `updateValue()` and `selectItem()`, but has no injected keybinding or awaited-save/rejection contract and does not expose search focus. Kit already owns ordered pending changes, rollback, retained search/selection, IME focus, bounded frames, and clipped mouse coordinates. This is an intentional existing deviation from the literal native-component convention. No new Kit API, dependency floor, or release is required. A package-owned public rendering boundary returns no lines at zero width and retains the selected row (or search when nothing matches) below five content rows; compact mouse events map back to the original rendered row. It does not access private component state or add key handlers. Search placeholder and position-footer relocation remain unsupported by that public API; the existing native-style hints and position indicator are retained rather than patched through private fields.
|
|
55
56
|
|
|
@@ -71,10 +72,10 @@ Startup transfer summaries report the preference and prerequisites, not a claim
|
|
|
71
72
|
| Conflicts | Review complete dependency group and separately choose authority | Artifact fingerprint, group versions, baseline, config, owner and head checks; `conflict-confirmation.test.ts`, `conflict-preview.test.ts` |
|
|
72
73
|
| Case-variant cleanup | Pull/rollback include the apply engine’s additional top-level alias removals, even when canonical snapshot bytes are unchanged | `apply-review.ts` uses the authoritative apply planner, streams file hashes, records symlink identity without following its target, and rechecks the complete alias set before commit; `transfer-preview.test.ts` covers changed, added, removed, cancelled and symlink aliases plus descriptor cleanup on cancellation. Merge preflight rejects noncanonical changed targets instead of deleting aliases. |
|
|
73
74
|
| History rollback | Historical snapshot → local and active remote head; backup and protected-session summary | Settings, local bytes, current head, selected backend/setup and baseline rechecked; `history-confirmation-cancellation.test.ts`, `history-cancellation.test.ts`, `rollback-field-policy.test.ts` |
|
|
74
|
-
| Explicit `--yes` | Existing documented review bypass only | Mandatory migration and
|
|
75
|
+
| Explicit `--yes` | Existing documented review bypass only | Mandatory migration, configured transfer size limits, and other safety checks remain |
|
|
75
76
|
| Automatic startup / shutdown | No new modal; existing opt-in, capability, idle, all-or-nothing conflict and secret policies | `automatic-transfer.test.ts`, `startup-check.test.ts`, `backend-orchestration.test.ts` |
|
|
76
77
|
|
|
77
|
-
TUI Pull, Push, and ignore-file rollback show directional counts and safety notes in the confirmation. Exact path rows are available in the read-only **View details** document. Older daemons can send the complete file list as the directional summary; the TUI moves only recognized path groups with verified counts out of that summary, without changing the exact details or the approval requirement. The configured Up and Down actions always select an option; selection-page bindings and the mouse wheel scroll the summary independently. Approval still requires displaying every row of the compact summary; a resize restarts the review. On a terminal too short to show the summary, resize to continue or cancel. RPC and legacy History rollback retain full file lists in their existing confirmation protocols. All changed counts come from effective snapshot differences rather than raw merge decisions. Protected paths, preserved remote files, merged bytes, and withheld paths must be accounted for before rendering. Cancellation performs no transfer; pre-commit preparation may retain recovery evidence. After the commit boundary, existing completion/recovery rules apply instead of promising undo.
|
|
78
|
+
On an ignore-policy mismatch, Push and Pull both require explicit directional approval. The review names the affected side and offers the available rule text and exact file changes in details. Pull does not offer an overwrite when the snapshot omits rule text; it does not change the remote or the Sessions setting. An aborted review performs no transfer. TUI Pull, Push, and ignore-file rollback show directional counts and safety notes in the confirmation. Exact path rows are available in the read-only **View details** document. Older daemons can send the complete file list as the directional summary; the TUI moves only recognized path groups with verified counts out of that summary, without changing the exact details or the approval requirement. The configured Up and Down actions always select an option; selection-page bindings and the mouse wheel scroll the summary independently. Approval still requires displaying every row of the compact summary; a resize restarts the review. On a terminal too short to show the summary, resize to continue or cancel. RPC and legacy History rollback retain full file lists in their existing confirmation protocols. All changed counts come from effective snapshot differences rather than raw merge decisions. Protected paths, preserved remote files, merged bytes, and withheld paths must be accounted for before rendering. Cancellation performs no transfer; pre-commit preparation may retain recovery evidence. After the commit boundary, existing completion/recovery rules apply instead of promising undo.
|
|
78
79
|
|
|
79
80
|
## Resource reload after a transfer
|
|
80
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-sync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"description": "Pi extension that syncs Pi configuration through Git, WebDAV, Cloudflare R2, or S3-compatible storage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
59
59
|
"@earendil-works/pi-tui": "1.6.0",
|
|
60
|
-
"@narumitw/pi-sync-daemon": "^0.
|
|
60
|
+
"@narumitw/pi-sync-daemon": "^0.13.0",
|
|
61
61
|
"@types/proper-lockfile": "^4.1.4",
|
|
62
62
|
"@types/semver": "^7.8.0",
|
|
63
63
|
"esbuild": "0.28.2",
|
|
@@ -128,7 +128,7 @@ Check which [automatic sync control](references/configuration.md#automatic-sync-
|
|
|
128
128
|
Inspect only the necessary local metadata and relevant non-secret configuration facts; do not expose raw settings, credentials, session contents, daemon records, journals, or backups in tool output or chat.
|
|
129
129
|
Do not ask the user to paste those contents or execute text copied from them.
|
|
130
130
|
|
|
131
|
-
Leave operations that Pi Sync requires the user to review in `/sync`, including initial setup, credential and destination changes, reviewed legacy path selection and policy changes, session opt-in, secret-scan bypass, enabling automatic behavior, rule-file activation or switching, and remote policy publication.
|
|
131
|
+
Leave operations that Pi Sync requires the user to review in `/sync`, including initial setup, credential and destination changes, reviewed legacy path selection and policy changes, session opt-in, secret-scan bypass, enabling automatic behavior, upgrading the settings document to enable a [transfer size limit](references/configuration.md#transfer-size-limits), rule-file activation or switching, and remote policy publication.
|
|
132
132
|
Use the masked credential input in Pi; do not infer transfer or model consent from a settings edit.
|
|
133
133
|
Do not start sync, run `/sync doctor` or backend/network commands, remove locks or recovery evidence, or bypass scan checks.
|
|
134
134
|
|
|
@@ -4,7 +4,7 @@ This is the authoritative public settings reference for Pi Sync.
|
|
|
4
4
|
The configuration skill applies explicitly requested local settings and ignore-rule edits and investigates Pi Sync errors. The user performs operations that require a separate review.
|
|
5
5
|
|
|
6
6
|
- **Configure a setup:** [Required fields](#settings-ownership-and-required-fields), [Manager](#editing-in-the-manager), [Version 3 example](#complete-version-3-example), [Backends](#required-backend-shapes)
|
|
7
|
-
- **Choose what syncs:** [Ignore-file policy](#ignore-file-policy), [Legacy directory scope](#agent-directory-scope), [Included content](#included-content), [Excluded paths](#excluded-paths), [Machine-local settings fields](#settings-field-merge-and-machine-local-fields)
|
|
7
|
+
- **Choose what syncs:** [Ignore-file policy](#ignore-file-policy), [Legacy directory scope](#agent-directory-scope), [Included content](#included-content), [Excluded paths](#excluded-paths), [Transfer size limits](#transfer-size-limits), [Machine-local settings fields](#settings-field-merge-and-machine-local-fields)
|
|
8
8
|
- **Manage automatic work:** [Controls and approval](#automatic-sync-controls), [Startup transfer](#automatic-startup-transfer), [Autonomous sync](#autonomous-sync), [Daemon lifetime](#daemon-lifetime-and-unattended-permission), [Continuous sync](#continuous-sync)
|
|
9
9
|
- **Handle problems:** [Status](#status-display), [Debug mode](#debug-mode), [Secret scanning](#secret-scanning), [Diagnostics](#diagnostics), [Local troubleshooting](#local-troubleshooting), [Merge and partial progress](#content-merge-and-partial-progress), [Old settings and recovery](#unsupported-old-settings-and-recovery)
|
|
10
10
|
|
|
@@ -42,12 +42,13 @@ Global settings apply to all setups on this device; they are not remote policy.
|
|
|
42
42
|
|
|
43
43
|
| Scope | Fields | Required values and defaults |
|
|
44
44
|
| --- | --- | --- |
|
|
45
|
-
| Document | `version`, `onSwitch`, `storageConnections`, `syncSetups` | All are required in a manually written document; versions 3 through
|
|
45
|
+
| Document | `version`, `onSwitch`, `storageConnections`, `syncSetups` | All are required in a manually written document; versions 3 through 9 are supported. |
|
|
46
46
|
| Current setup | `activeSyncSetup` | Required when setups exist; absent when the setup catalog is empty. |
|
|
47
47
|
| Global preferences | `skipSecretScan`, `showStatus`, `debug` | Optional booleans; defaults are false, true, and false. |
|
|
48
48
|
| Setup selection | `sync.scope`, `sync.include`, `sync.automatic` | Legacy directory scope requires version 7 or later and omits `include`; selected-path setups require `include`. Both require explicit `automatic`. |
|
|
49
|
-
| Ignore-file selection | `sync.scope`, `sync.pathPolicy`, `sync.ignoreFile`, `sync.sessions` | Version 8, `scope: "agent-directory"`, `pathPolicy: "ignore-file"`. `ignoreFile` defaults to `.syncignore`; sessions require `true` and the rules must allow them. Use reviewed setup or migration, not manual JSON edits. |
|
|
49
|
+
| Ignore-file selection | `sync.scope`, `sync.pathPolicy`, `sync.ignoreFile`, `sync.sessions` | Version 8 or later, `scope: "agent-directory"`, `pathPolicy: "ignore-file"`. `ignoreFile` defaults to `.syncignore`; sessions require `true` and the rules must allow them. Use reviewed setup or migration, not manual JSON edits. |
|
|
50
50
|
| Setup behavior | `sync.automaticTransfer`, `sync.agentMode`, `sync.continuous`, `sync.mergeSettings`, `sync.mergeContent`, `sync.partialSync` | Optional booleans; all default to false. |
|
|
51
|
+
| Transfer size limits | `sync.maxFileSizeMiB`, `sync.maxDirectorySizeMiB` | Independent optional positive whole numbers; absence means Off. Either value requires version 9. |
|
|
51
52
|
| Portable policy | `sync.localFields` | Optional array; any explicit array, including `[]`, requires version 4 or later. |
|
|
52
53
|
| Content/partial policy | `sync.mergeContent`, `sync.partialSync` | Enabling either requires version 5 or later. |
|
|
53
54
|
| Path exclusions | `sync.exclude` | Optional array; an explicit array, including `[]`, requires version 6 or later. |
|
|
@@ -76,7 +77,7 @@ The screen uses a searchable flat list without category navigation. Compare cont
|
|
|
76
77
|
Returning from catalog management refreshes the rows; switching or removing the owning setup closes its old Settings screen.
|
|
77
78
|
|
|
78
79
|
Descriptions identify the owner: this setup, all setups on this device, or shared connections.
|
|
79
|
-
Simple choices report
|
|
80
|
+
Simple choices report saving, then a setting-specific confirmation or an error in Pi's notifications. They preserve the selected row and search during refresh and restore the previous value if saving fails.
|
|
80
81
|
Escape closes the screen without undoing successful saves.
|
|
81
82
|
Complex values retain their input/review flows.
|
|
82
83
|
This navigation change does not alter schema, defaults, automatic-sync behavior, or explicit opt-ins.
|
|
@@ -307,6 +308,7 @@ Use the first concrete error, not a generic recovery hint appended to it. Start
|
|
|
307
308
|
| --- | --- |
|
|
308
309
|
| **Autonomous sync requires a separate policy review** | The selected setup has Autonomous sync enabled, but its current policy has no matching automatic-transfer approval. This does not mean that `pi-sync.json` is malformed. Check which setup the operation used and whether settings or rules changed. The user can review **Settings → Review automatic transfers** for the current setup or choose a reviewed directional push or pull. |
|
|
309
310
|
| **Agent directory changed or has an unsafe filesystem layout** | The local scan could not establish a stable filesystem view. Use file metadata to check the agent root, Pi's `settings.json`, the effective session directory (including any `--session-dir` override), and in-scope paths. Symlinks in the session directory path and hard-linked candidate files can trigger this error; ordinary symlinks encountered in the directory scan are skipped. Check whether another Pi process or editor is changing files during the scan. Do not change synchronization settings unless the evidence identifies a relevant setting; this error alone does not identify a path or field. |
|
|
311
|
+
| **Transfer blocked by size limits** | Check the reported paths and byte counts. Use `/sync diff`, then narrow the selection or review a different source. See [transfer size limits](#transfer-size-limits). |
|
|
310
312
|
| **Malformed or unsupported settings** | Check the canonical path and documented version and field constraints. Preserve the original private bytes and follow [settings recovery](#unsupported-old-settings-and-recovery); do not replace the document with defaults. |
|
|
311
313
|
| **Backend access or publication failure** | Use the reported error class to distinguish credentials, a missing location, transport, and publication safety. A 404 alone does not identify which remote resource is missing. If local checks are insufficient, explain the backend-specific effects of [Diagnostics](#diagnostics) and leave that action to the user. |
|
|
312
314
|
|
|
@@ -314,7 +316,7 @@ A local check does not verify remote connectivity or permissions. Diagnostics ca
|
|
|
314
316
|
|
|
315
317
|
### Ignore-file policy
|
|
316
318
|
|
|
317
|
-
New TUI setups use `.syncignore` when the daemon advertises support. Existing setups keep their policy and can coexist with ignore-file setups in version 8.
|
|
319
|
+
New TUI setups use `.syncignore` when the daemon advertises support. Existing setups keep their policy and can coexist with ignore-file setups in version 8 or later.
|
|
318
320
|
To migrate a legacy setup, choose **Review migration now** when first offered in the TUI manager, or **Settings → Migrate to ignore file…** later. **Not now** defers the offer for that setup on this device; closing the prompt without a choice does not save a deferral. Review local and remote paths that enter or leave scope, including what the rules would do for future files. Legacy selected paths and `reinclude` rules do not always translate directly.
|
|
319
321
|
|
|
320
322
|
This version 8 `sync` fragment shows a setup using the default rule file. It is not a complete settings document or a substitute for review:
|
|
@@ -353,17 +355,19 @@ Use `/` as the separator; escaped `/` is not supported. A leading `/` anchors a
|
|
|
353
355
|
|
|
354
356
|
Session sync requires both a separate opt-in and rules that allow sessions. The starter `/sessions/` still excludes them. Match sessions by their logical `sessions/` paths even if stored elsewhere. Loaded sessions stay protected during apply.
|
|
355
357
|
|
|
356
|
-
Pi credentials and trust (`auth.json` and `trust.json`), private Pi Sync files (settings, state, and the [debug log](#shared-log)), and
|
|
358
|
+
Pi credentials and trust (`auth.json` and `trust.json`), private Pi Sync files (settings, state, and the [debug log](#shared-log)), and other setups' rule files stay local. `truth.json` is a starter exclusion, not Pi's trust file. A new snapshot includes the active rule text and filename unless the file excludes itself. Add `/.syncignore` to keep the default rule file out of future snapshots. A later `!/.syncignore` can include it again. This does not erase rules or comments from retained history.
|
|
357
359
|
|
|
358
360
|
#### Transfer review and recovery
|
|
359
361
|
|
|
360
|
-
Setup, migration, rule-file switching, and edits neither start nor authorize transfers. Upgrade all peers before publishing a version
|
|
362
|
+
Setup, migration, rule-file switching, and edits neither start nor authorize transfers. Upgrade all peers before publishing a version 7 snapshot. A version 6 snapshot has only the policy fingerprint; an upgraded publisher with matching rules can publish again to include rule text. Comments, whitespace and session opt-in affect the fingerprint. Re-review automatic transfers after upgrading an ignore-file setup.
|
|
361
363
|
|
|
362
|
-
|
|
364
|
+
When policies differ, a reviewed Push can replace the remote policy. Pull can preview and adopt verified remote rules without writing to the remote. Cancel to leave both sides unchanged. Neither `--force`, `--yes` nor background work approves a policy overwrite. If rule text is unavailable, match the publisher's rules manually. If Sessions opt-in differs, review that setting locally first. Select a dedicated rule file before adopting into a shared source. An omitted rule file is not a request to delete it. Rollback projects historical content through the current local rules; it does not adopt historical rules.
|
|
363
365
|
|
|
364
|
-
If
|
|
366
|
+
If adoption is interrupted, keep the local rules, backups and journals. Startup recovers an interrupted local file transaction before opening sync, without adopting rules or contacting the backend. If startup cannot verify the recovery evidence, do not edit the affected files; preserve the journals for review.
|
|
365
367
|
|
|
366
|
-
|
|
368
|
+
Run `/sync pull` on the originating setup to review resumption. It uses the recorded, retained snapshot even if another device has since published a newer one. If that snapshot is missing or the local evidence no longer matches, preserve the journals and backups; do not replace them with the newer snapshot. After recovery, run `/sync status` to check the newer remote state. The successful transfer reports the backup path for the previous rule text.
|
|
369
|
+
|
|
370
|
+
After a version 6 or 7 publication, downgrading the package alone is not rollback. Close incompatible clients, verify daemon exit, and review compatible local and remote restoration before resuming transfers. Keep retained history intact.
|
|
367
371
|
|
|
368
372
|
### Agent-directory scope
|
|
369
373
|
|
|
@@ -489,6 +493,29 @@ Clearing rules retains `[]` and the newer versions; never downgrade in place.
|
|
|
489
493
|
A pending transaction or merge journal under different rules remains available for reviewed recovery rather than replaying old writes.
|
|
490
494
|
To return to an older client, stop automatic work, resolve pending recovery with a compatible client, preserve backups, and create a separate reviewed legacy-compatible setup/location.
|
|
491
495
|
|
|
496
|
+
### Transfer size limits
|
|
497
|
+
|
|
498
|
+
Use **/sync → Settings → Max file size** or **Max directory size** for the current setup. The file limit applies to each included file. The directory limit applies to the sum of included files in each directory below the logical sync root, including the logical `sessions/` tree. A nested file contributes once to each of its parent directories below that root. The root itself has no size limit from this setting. A size equal to the limit passes.
|
|
499
|
+
|
|
500
|
+
Both settings default to **Off** and can be set independently. Enter `Off` or a positive whole number of MiB (`1 MiB = 1,048,576 bytes`) whose byte count is a safe integer. The settings file takes JSON numbers, not strings, booleans, zero, fractions, or `null`. In RPC or other non-TUI use, close Pi Sync clients, drain and stop the daemon, and verify owner exit before editing the canonical private `pi-sync.json`. Keep unrelated fields and private permissions. For example, in a version-9 document, add the following fields to the existing `syncSetups.<name>.sync` object:
|
|
501
|
+
|
|
502
|
+
```json
|
|
503
|
+
{
|
|
504
|
+
"maxFileSizeMiB": 4,
|
|
505
|
+
"maxDirectorySizeMiB": 8
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Omit a key to turn that limit Off. There is no project or environment override. Older documents are not changed merely because both limits are Off. To enable a limit manually, set the document's top-level `version` to `9` in the same edit. In the TUI, review the compatibility warning before the first save that upgrades the file. **Close or upgrade older Pi Sync clients and daemon builds that share this agent directory before enabling a limit.** Older processes cannot use any setup in the version-9 document, even after both limits are cleared. Each device enforces its own limits, with no snapshot format change or remote settings migration. See [daemon ownership and upgrade](https://github.com/narumiruna/pi-extensions/blob/main/packages/pi-sync/docs/daemon-migration.md#ownership-and-upgrade) if the running owner does not support the limits.
|
|
510
|
+
|
|
511
|
+
A saved change applies to subsequent transfer attempts. It starts no transfer and grants no new automatic permission. If the change invalidates existing permission, review automatic transfers again through the existing controls. The daemon measures the actual uncompressed bytes after content selection, portable field projection, and any applicable merge or conflict resolution. It checks each side's proposed image separately, so the same path on both sides does not count twice. With partial sync or live-session protection, count only what belongs to that side's selected result. Ignored paths, preserved out-of-scope content, and old destination bytes outside that result do not count. Neither do transport encoding, backups, or History. If the active ignore file is included and the transfer writes or publishes it as rule metadata, its actual UTF-8 bytes count toward the limits.
|
|
512
|
+
|
|
513
|
+
A violation blocks new publication or local apply without skipping the offending files or advancing the accepted baseline. This applies to automatic work, reviewed rollback, and Pull that adopts remote rules. Neither `--force` nor `--yes` bypasses it. The error lists a bounded set of relative paths, measured sizes, and limits, plus the omitted count if there are more findings. An unchanged automatic size violation is a safety block, not a transient retry. The existing scan, decode, merge, and backend bounds still apply and can stop work earlier.
|
|
514
|
+
|
|
515
|
+
Use `/sync diff` to inspect the difference or policy mismatch. For example, if `skills/local-cache/` makes `skills/` exceed an 8 MiB directory cap, add `/skills/local-cache/` to the active ignore file, or exclude `skills/local-cache` through the legacy Settings editor. Check the new selection, then use `/sync push` and confirm the reviewed direction if this device is authoritative. Review any policy replacement separately; a legacy policy mismatch can require a reviewed `/sync push --force` without `--yes`. If the remote is authoritative, use a reviewed `/sync pull` with an applicable selection. Previous remote versions remain in History; Pull keeps its local backup, so a compliant source can replace larger managed destination bytes without losing the restore point.
|
|
516
|
+
|
|
517
|
+
Read-only reviews remain available. A new limit does not prevent verified reconciliation of an already committed transfer. A pending local-only merge or rule adoption that has not installed its rule file can still be blocked: matching local files do not prove that the interrupted transfer wrote them. When a limit is on, local-only merge recovery also stops if it finds new or changed included files outside the journal's recorded images. Keep the settings, backups, and journals. Review the limits and verify the local and remote snapshots with a compatible daemon before retrying. Turning both limits Off restores the previous size policy for future transfers without changing version 9 or rewriting history.
|
|
518
|
+
|
|
492
519
|
### Automatic startup transfer
|
|
493
520
|
|
|
494
521
|
`sync.automaticTransfer` is optional and accepts only a boolean; absent means `false`.
|
|
@@ -524,7 +551,7 @@ Unknown fields remain preserved and malformed/invalid files block saves, just as
|
|
|
524
551
|
|
|
525
552
|
### Autonomous sync
|
|
526
553
|
|
|
527
|
-
Autonomous sync uses the unchanged `sync.agentMode` key, an optional per-setup boolean
|
|
554
|
+
Autonomous sync uses the unchanged `sync.agentMode` key, an optional per-setup boolean that defaults to `false`.
|
|
528
555
|
Open **Settings → Autonomous sync** and review the setup, destination, content policy, transfer authorization, model disclosure, costs, and autonomous writes before enabling. For directory scope, the review shows session opt-in separately from path rules.
|
|
529
556
|
In a legacy-only settings file, RPC users can authorize Autonomous sync by explicitly setting this field to `true`. If any setup uses an ignore file, follow the [separate approval step](#automatic-sync-controls) after enabling it.
|
|
530
557
|
|
|
@@ -648,7 +675,7 @@ A failed consent write blocks automatic work in that service instance. Uncertain
|
|
|
648
675
|
|
|
649
676
|
### Continuous sync
|
|
650
677
|
|
|
651
|
-
`sync.continuous` is an optional per-setup boolean
|
|
678
|
+
`sync.continuous` is an optional per-setup boolean that defaults to `false`.
|
|
652
679
|
Open **Settings → Continuous sync** after enabling Autonomous sync. For directory scope, the review shows session opt-in separately from path rules.
|
|
653
680
|
In a legacy-only settings file, RPC users can opt in by explicitly setting this field to `true`. If any setup uses an ignore file, follow the [separate approval step](#automatic-sync-controls) after enabling it.
|
|
654
681
|
Existing Autonomous sync consent does not enable recurring requests.
|
|
@@ -785,7 +812,7 @@ Coupled fields must be excluded together.
|
|
|
785
812
|
Selected-path setups with nonempty rules must include `settings.json` in `sync.include`. Directory-scope setups must omit `sync.include` and can configure local fields without it. Path rules still govern whether `settings.json` syncs, and nonempty field rules require that exact file spelling if it is synced. Absent or explicitly empty rules remain valid for either scope.
|
|
786
813
|
Settings asks for confirmation before saving changes to these rules. An explicit array requires settings version 4 or later, and editing the rules does not downgrade an existing settings version.
|
|
787
814
|
Absent rules keep a setup nonportable, including unrelated setups in a version-4 document.
|
|
788
|
-
An explicit array opts that setup into at least snapshot version 2; exclusion-enabled selected-path setups retain version 4, legacy directory scope retains version 5, and ignore-file setups
|
|
815
|
+
An explicit array opts that setup into at least snapshot version 2; exclusion-enabled selected-path setups retain version 4, legacy directory scope retains version 5, and ignore-file setups publish version 7.
|
|
789
816
|
`[]` after rule removal retains this reviewed opt-in and differs from absence.
|
|
790
817
|
Older clients must refuse portable data rather than replace local-only values.
|
|
791
818
|
|
|
@@ -825,7 +852,7 @@ Never reinterpret portable snapshots with an old binary.
|
|
|
825
852
|
`sync.mergeContent` and `sync.partialSync` are independent opt-in booleans, both default `false`.
|
|
826
853
|
The owning **Settings → Content merge / partial progress** setting offers Off, Merge only, Merge + partial, and Partial only and confirms an explicit upgrade to at least settings version 5.
|
|
827
854
|
Use a supported settings version of at least 5 (at least 7 for legacy directory scope and 8 for ignore-file policy).
|
|
828
|
-
Partial publications retain snapshot version 4 for exclusion-enabled selected paths, version 5 for legacy directory scope, and version
|
|
855
|
+
Partial publications retain snapshot version 4 for exclusion-enabled selected paths, version 5 for legacy directory scope, and version 7 for ignore-file policy.
|
|
829
856
|
Settings version 5 retains the portable-policy behavior of version 4; moving from a legacy setup can require the existing separately confirmed directional policy migration.
|
|
830
857
|
Disabling options retains the schema and recovery evidence.
|
|
831
858
|
|
|
@@ -880,5 +907,7 @@ Recovery:
|
|
|
880
907
|
4. run `/sync doctor`, inspect the exact storage path, and review the first pull or push;
|
|
881
908
|
5. restore the retained file and a compatible older package only if rolling back.
|
|
882
909
|
|
|
910
|
+
If your processes reject a newer settings version, keep the document and use compatible Pi Sync and daemon builds. In particular, [clearing transfer size limits](#transfer-size-limits) never downgrades version 9. Do not use the recovery steps above to replace a newer document.
|
|
911
|
+
|
|
883
912
|
Malformed, invalid, unsupported, symlinked, or concurrently changed documents remain untouched.
|
|
884
913
|
Failed UI saves keep the previous file and displayed/effective state.
|
package/src/ui/ignore-file-ui.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import type { ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { isKeyRelease, Key, matchesKey } from "@earendil-works/pi-tui";
|
|
3
3
|
import { piDaemonClient } from "../daemon/pi-client.js";
|
|
4
4
|
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
@@ -8,18 +8,26 @@ import { safeTerminalText } from "./terminal-text.js";
|
|
|
8
8
|
|
|
9
9
|
type IgnoreOperation = "switch" | "migrate";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
if (signal?.aborted) return
|
|
11
|
+
async function ignoreCapabilities(ctx: ExtensionContext, signal?: AbortSignal) {
|
|
12
|
+
if (signal?.aborted) return;
|
|
13
13
|
try {
|
|
14
14
|
const client = piDaemonClient(ctx);
|
|
15
15
|
const result = await client.run("ignore.capabilities", {}, signal, ctx);
|
|
16
16
|
client.validate();
|
|
17
|
-
|
|
17
|
+
if (!signal?.aborted) return result as { available?: unknown; portableRules?: unknown } | undefined;
|
|
18
18
|
} catch {
|
|
19
|
-
return
|
|
19
|
+
return;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export async function ignoreFileSettingsAvailable(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
24
|
+
return (await ignoreCapabilities(ctx, signal))?.available === true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function portableIgnoreRulesAvailable(ctx: ExtensionContext, signal?: AbortSignal) {
|
|
28
|
+
return (await ignoreCapabilities(ctx, signal))?.portableRules === 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
export async function showIgnoreFileAction(
|
|
24
32
|
ctx: ExtensionCommandContext,
|
|
25
33
|
setup: string,
|
package/src/ui/manager-state.ts
CHANGED
|
@@ -159,7 +159,12 @@ export async function describeManagerState(
|
|
|
159
159
|
`Current sync setup: ${safeTerminalText(config.setupName)}`,
|
|
160
160
|
`Storage: ${backendStorageDescription(config)}`,
|
|
161
161
|
...(config.pathPolicy === "ignore-file"
|
|
162
|
-
? [
|
|
162
|
+
? [
|
|
163
|
+
`Sync scope: Pi agent directory · ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}`,
|
|
164
|
+
...(config.ignorePolicy?.matches(config.ignorePolicy.filename) === false
|
|
165
|
+
? ["New snapshots include this rule file and its comments in remote history."]
|
|
166
|
+
: []),
|
|
167
|
+
]
|
|
163
168
|
: config.scope
|
|
164
169
|
? ["Sync scope: Pi agent directory, with exclusions"]
|
|
165
170
|
: []),
|
|
@@ -171,13 +176,15 @@ export async function describeManagerState(
|
|
|
171
176
|
currentAttention.decision.setupName === config.setupName
|
|
172
177
|
? "Sync status: Review needed"
|
|
173
178
|
: `Sync status: Review needed for setup ${safeTerminalText(currentAttention.decision.setupName)}`,
|
|
174
|
-
|
|
175
|
-
? "
|
|
176
|
-
:
|
|
177
|
-
?
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
currentAttention.decision.ignorePolicyComparison
|
|
180
|
+
? "Ignore-file policies differ."
|
|
181
|
+
: attentionDirectoryPolicy
|
|
182
|
+
? "Sync scopes or directory rules differ."
|
|
183
|
+
: attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0
|
|
184
|
+
? attentionExclusionsDiffer
|
|
185
|
+
? "Synced-content exclusion rules differ."
|
|
186
|
+
: "Only the synced-content order differs."
|
|
187
|
+
: `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} · Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " · Exclusion rules differ." : ""}`,
|
|
181
188
|
]
|
|
182
189
|
: currentObservation
|
|
183
190
|
? [`Observed ${safeTerminalText(currentObservation.checkedAt)}: ${observationSummary(currentObservation)}`]
|