@narumitw/pi-sync 0.63.0 → 0.63.1
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 +13 -0
- package/README.md +16 -13
- package/dist/chunks/{chunk-UGS6RYDZ.ts → chunk-B5F3JLD3.ts} +2 -2
- package/dist/chunks/{chunk-S6FUUWV5.ts → chunk-LBNC5AOM.ts} +3 -3
- package/dist/chunks/{chunk-S6FUUWV5.ts.map → chunk-LBNC5AOM.ts.map} +1 -1
- package/dist/chunks/{chunk-GSQGBVKG.ts → chunk-POWOMJ7S.ts} +87 -50
- package/dist/chunks/chunk-POWOMJ7S.ts.map +7 -0
- package/dist/chunks/{command-handler-VINMQ7ZM.ts → command-handler-GMRRFWOL.ts} +5 -5
- package/dist/chunks/{conflict-review-PCDFRIVB.ts → conflict-review-JWEA7DPQ.ts} +2 -2
- package/dist/chunks/{manager-ui-YHDECYKI.ts → manager-ui-T5J5WG7T.ts} +33 -24
- package/dist/chunks/manager-ui-T5J5WG7T.ts.map +7 -0
- package/dist/chunks/{merge-review-SGDLMVS4.ts → merge-review-OQDXNTJU.ts} +2 -2
- package/dist/chunks/{setup-wizard-YO4MCPUF.ts → setup-wizard-LL6YMGUR.ts} +3 -3
- package/dist/chunks/{sync-inspection-H2WX5SUT.ts → sync-inspection-SRU6HGGK.ts} +2 -2
- package/dist/chunks/{sync-operations-2MZAYHL2.ts → sync-operations-UGSCONZ7.ts} +2 -2
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +50 -14
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +11 -14
- package/dist/daemon/dist/engine/ignore/ignore-source.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +16 -3
- package/dist/daemon/dist/engine/sync/sync-mutations.js +4 -4
- package/dist/daemon/dist/engine/ui/sync-format.js +23 -55
- package/dist/daemon/dist/engine/ui/transfer-review.js +3 -3
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +4 -4
- package/docs/tui-contract.md +1 -1
- package/package.json +2 -2
- package/skills/configure-pi-sync/SKILL.md +119 -18
- package/skills/configure-pi-sync/references/configuration.md +67 -37
- package/src/ui/manager-state.ts +6 -3
- package/src/ui/manager-ui.ts +23 -17
- package/src/ui/merge-review.ts +28 -1
- package/src/ui/setup/webdav-ui.ts +1 -1
- package/src/ui/sync-confirmation.ts +67 -48
- package/dist/chunks/chunk-GSQGBVKG.ts.map +0 -7
- package/dist/chunks/manager-ui-YHDECYKI.ts.map +0 -7
- /package/dist/chunks/{chunk-UGS6RYDZ.ts.map → chunk-B5F3JLD3.ts.map} +0 -0
- /package/dist/chunks/{command-handler-VINMQ7ZM.ts.map → command-handler-GMRRFWOL.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-PCDFRIVB.ts.map → conflict-review-JWEA7DPQ.ts.map} +0 -0
- /package/dist/chunks/{merge-review-SGDLMVS4.ts.map → merge-review-OQDXNTJU.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-YO4MCPUF.ts.map → setup-wizard-LL6YMGUR.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-H2WX5SUT.ts.map → sync-inspection-SRU6HGGK.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-2MZAYHL2.ts.map → sync-operations-UGSCONZ7.ts.map} +0 -0
|
@@ -2,8 +2,11 @@ import { constants, lstatSync, realpathSync, unlinkSync } from "node:fs";
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { DEFAULT_IGNORE_CREATION_RECORD, DEFAULT_IGNORE_FILENAME, DEFAULT_IGNORE_RULES, ignoreFileIdentity, readIgnoreSource, sameFile, sameIdentity, } from "./ignore-source.js";
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const recordPrefix = "pi-sync-ignore-creation-v1\n";
|
|
6
|
+
const records = [
|
|
7
|
+
Buffer.from(`${recordPrefix}${DEFAULT_IGNORE_RULES}`),
|
|
8
|
+
Buffer.from(`${recordPrefix}/npm/\n/sessions/\n/auth.json\n/truth.json\n`),
|
|
9
|
+
];
|
|
7
10
|
const noFollow = (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0);
|
|
8
11
|
const openRead = constants.O_RDONLY | noFollow;
|
|
9
12
|
const openExisting = process.platform === "win32" ? constants.O_RDWR | noFollow : openRead;
|
|
@@ -28,10 +31,35 @@ export async function checkAutomaticIgnoreCreation(root, signal) {
|
|
|
28
31
|
signal.throwIfAborted();
|
|
29
32
|
}
|
|
30
33
|
}
|
|
34
|
+
function creationRecordToken(stat) {
|
|
35
|
+
return `${ignoreFileIdentity(stat)}:${stat.size}:${stat.ctimeNs}:${stat.mtimeNs}`;
|
|
36
|
+
}
|
|
37
|
+
export async function readPendingIgnoreCreation(root, signal) {
|
|
38
|
+
signal.throwIfAborted();
|
|
39
|
+
root = path.resolve(root);
|
|
40
|
+
const initialRoot = await fs.lstat(root, { bigint: true });
|
|
41
|
+
const checkRoot = () => {
|
|
42
|
+
signal.throwIfAborted();
|
|
43
|
+
assertRoot(root, initialRoot);
|
|
44
|
+
};
|
|
45
|
+
checkRoot();
|
|
46
|
+
const target = path.join(root, DEFAULT_IGNORE_CREATION_RECORD);
|
|
47
|
+
const prior = await fs.lstat(target, { bigint: true });
|
|
48
|
+
assertOwned(prior, DEFAULT_IGNORE_CREATION_RECORD, true);
|
|
49
|
+
const marker = await fs.open(target, openRead);
|
|
50
|
+
try {
|
|
51
|
+
const { stat, bytes } = await verifyCreationFile(marker, target, target, records, checkRoot, prior, false);
|
|
52
|
+
return { token: creationRecordToken(stat), text: bytes.toString("utf8", recordPrefix.length) };
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
await marker.close();
|
|
56
|
+
signal.throwIfAborted();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
31
59
|
export async function initializeDefaultIgnoreSource(root, signal) {
|
|
32
60
|
return (await prepareDefaultIgnoreSource(root, signal)).source;
|
|
33
61
|
}
|
|
34
|
-
export async function prepareDefaultIgnoreSource(root, signal) {
|
|
62
|
+
export async function prepareDefaultIgnoreSource(root, signal, reviewedCreation) {
|
|
35
63
|
signal?.throwIfAborted();
|
|
36
64
|
root = path.resolve(root);
|
|
37
65
|
try {
|
|
@@ -43,6 +71,10 @@ export async function prepareDefaultIgnoreSource(root, signal) {
|
|
|
43
71
|
};
|
|
44
72
|
checkRoot();
|
|
45
73
|
const priorRecord = statAt(path.join(root, DEFAULT_IGNORE_CREATION_RECORD));
|
|
74
|
+
if (reviewedCreation !== undefined &&
|
|
75
|
+
reviewedCreation !== (priorRecord ? creationRecordToken(priorRecord) : null)) {
|
|
76
|
+
changed(DEFAULT_IGNORE_CREATION_RECORD);
|
|
77
|
+
}
|
|
46
78
|
if (!priorRecord) {
|
|
47
79
|
const source = await readIgnoreSource(root, DEFAULT_IGNORE_FILENAME, signal);
|
|
48
80
|
checkRoot();
|
|
@@ -67,7 +99,8 @@ export async function prepareDefaultIgnoreSource(root, signal) {
|
|
|
67
99
|
throw error;
|
|
68
100
|
});
|
|
69
101
|
try {
|
|
70
|
-
const markerStat = await
|
|
102
|
+
const { stat: markerStat, bytes } = await verifyCreationFile(marker, markerPath, path.join(root, DEFAULT_IGNORE_CREATION_RECORD), records, priorRecord ? checkRoot : verifyRoot, priorRecord);
|
|
103
|
+
const starter = bytes.subarray(recordPrefix.length);
|
|
71
104
|
await flushDirectory();
|
|
72
105
|
checkRoot();
|
|
73
106
|
assertCurrent(markerPath, markerStat);
|
|
@@ -85,7 +118,7 @@ export async function prepareDefaultIgnoreSource(root, signal) {
|
|
|
85
118
|
});
|
|
86
119
|
try {
|
|
87
120
|
const checkTargetRoot = priorFile ? checkRoot : verifyRoot;
|
|
88
|
-
const fileStat = await
|
|
121
|
+
const { stat: fileStat } = await verifyCreationFile(file, target, path.join(root, DEFAULT_IGNORE_FILENAME), [starter], () => {
|
|
89
122
|
checkTargetRoot();
|
|
90
123
|
assertCurrent(markerPath, markerStat);
|
|
91
124
|
}, priorFile);
|
|
@@ -98,7 +131,7 @@ export async function prepareDefaultIgnoreSource(root, signal) {
|
|
|
98
131
|
checkRoot();
|
|
99
132
|
const source = await readIgnoreSource(root, DEFAULT_IGNORE_FILENAME, signal);
|
|
100
133
|
checkRoot();
|
|
101
|
-
if (source.identity !== ignoreFileIdentity(fileStat) || source.text !==
|
|
134
|
+
if (source.identity !== ignoreFileIdentity(fileStat) || source.text !== starter.toString("utf8")) {
|
|
102
135
|
changed(DEFAULT_IGNORE_FILENAME);
|
|
103
136
|
}
|
|
104
137
|
return { source, created: priorFile === undefined };
|
|
@@ -210,8 +243,9 @@ function assertOwned(stat, name, privateRecord) {
|
|
|
210
243
|
throw new Error(`unsafe "${name}"; preserve it for manual recovery`);
|
|
211
244
|
}
|
|
212
245
|
}
|
|
213
|
-
async function
|
|
246
|
+
async function verifyCreationFile(handle, target, canonical, expected, checkRoot, prior, persist = true) {
|
|
214
247
|
const name = path.basename(target);
|
|
248
|
+
const privateRecord = name === DEFAULT_IGNORE_CREATION_RECORD;
|
|
215
249
|
const opened = await handle.stat({ bigint: true });
|
|
216
250
|
assertOwned(opened, name, privateRecord);
|
|
217
251
|
if (prior && !sameFile(prior, opened))
|
|
@@ -221,15 +255,15 @@ async function flushAndVerify(handle, target, canonical, expected, checkRoot, pr
|
|
|
221
255
|
throw new Error(`use the exact on-disk filename "${name}"`);
|
|
222
256
|
checkRoot();
|
|
223
257
|
assertCurrent(target, opened);
|
|
224
|
-
if (!prior)
|
|
225
|
-
await handle.writeFile(expected);
|
|
258
|
+
if (!prior && persist)
|
|
259
|
+
await handle.writeFile(expected[0]);
|
|
226
260
|
const before = await handle.stat({ bigint: true });
|
|
227
261
|
assertOwned(before, name, privateRecord);
|
|
228
262
|
if (!(prior ? sameFile(opened, before) : sameIdentity(opened, before)))
|
|
229
263
|
changed(name);
|
|
230
264
|
checkRoot();
|
|
231
265
|
assertCurrent(target, before);
|
|
232
|
-
const observed = Buffer.alloc(expected.length + 1);
|
|
266
|
+
const observed = Buffer.alloc(Math.max(...expected.map((bytes) => bytes.length)) + 1);
|
|
233
267
|
let count = 0;
|
|
234
268
|
while (count < observed.length) {
|
|
235
269
|
checkRoot();
|
|
@@ -238,15 +272,17 @@ async function flushAndVerify(handle, target, canonical, expected, checkRoot, pr
|
|
|
238
272
|
break;
|
|
239
273
|
count += bytesRead;
|
|
240
274
|
}
|
|
241
|
-
|
|
275
|
+
const bytes = expected.find((candidate) => observed.subarray(0, count).equals(candidate));
|
|
276
|
+
if (!bytes) {
|
|
242
277
|
throw new Error(privateRecord
|
|
243
278
|
? `invalid creation record "${name}"; preserve it for manual recovery`
|
|
244
|
-
: `unfinished creation of "${name}"; move the incomplete file outside the Pi agent directory or restore the full starter rules, then retry confirmed setup or migration`);
|
|
279
|
+
: `unfinished creation of "${name}"; move the incomplete file outside the Pi agent directory or restore the full starter rules recorded in "${DEFAULT_IGNORE_CREATION_RECORD}", then retry confirmed setup or migration`);
|
|
245
280
|
}
|
|
246
|
-
|
|
281
|
+
if (persist)
|
|
282
|
+
await handle.sync();
|
|
247
283
|
if (!sameFile(before, await handle.stat({ bigint: true })))
|
|
248
284
|
changed(name);
|
|
249
285
|
checkRoot();
|
|
250
286
|
assertCurrent(target, before);
|
|
251
|
-
return before;
|
|
287
|
+
return { stat: before, bytes };
|
|
252
288
|
}
|
|
@@ -21,7 +21,7 @@ import { requireNoMergeJournal } from "../sync/merge-journal.js";
|
|
|
21
21
|
import { configuredSnapshotPathMatcher } from "../sync/sync-policy.js";
|
|
22
22
|
import { safeTerminalText, snapshotPathLabel } from "../ui/terminal-text.js";
|
|
23
23
|
import { compileEffectiveIgnorePolicy } from "./effective-ignore-policy.js";
|
|
24
|
-
import { AutomaticIgnoreCreationUnavailable, checkAutomaticIgnoreCreation, prepareDefaultIgnoreSource, } from "./ignore-initialization.js";
|
|
24
|
+
import { AutomaticIgnoreCreationUnavailable, checkAutomaticIgnoreCreation, prepareDefaultIgnoreSource, readPendingIgnoreCreation, } from "./ignore-initialization.js";
|
|
25
25
|
import { assertCurrentIgnoreMigrationOffer } from "./ignore-migration-prompt.js";
|
|
26
26
|
import { compileIgnoreRules, DEFAULT_IGNORE_CREATION_RECORD, DEFAULT_IGNORE_FILENAME, DEFAULT_IGNORE_RULES, IgnoreCreationPendingError, ignoreSourceDigest, readIgnoreSource, validateIgnoreFilename, } from "./ignore-source.js";
|
|
27
27
|
export function runIgnorePolicyChange(operation, payload, execution) {
|
|
@@ -93,18 +93,14 @@ async function readSetupSource(root, filename, signal) {
|
|
|
93
93
|
!(error instanceof Error) ||
|
|
94
94
|
!(error.cause instanceof IgnoreCreationPendingError))
|
|
95
95
|
throw error;
|
|
96
|
-
|
|
97
|
-
throw error;
|
|
98
|
-
const marker = await fs.lstat(path.join(root, DEFAULT_IGNORE_CREATION_RECORD), { bigint: true });
|
|
96
|
+
const { text, token } = await readPendingIgnoreCreation(root, signal);
|
|
99
97
|
signal.throwIfAborted();
|
|
100
|
-
if (!marker.isFile() || marker.nlink !== 1n)
|
|
101
|
-
throw error;
|
|
102
98
|
return {
|
|
103
99
|
filename,
|
|
104
100
|
present: false,
|
|
105
|
-
text
|
|
106
|
-
sourceDigest: ignoreSourceDigest(filename, false, Buffer.from(
|
|
107
|
-
pendingCreation:
|
|
101
|
+
text,
|
|
102
|
+
sourceDigest: ignoreSourceDigest(filename, false, Buffer.from(text)),
|
|
103
|
+
pendingCreation: token,
|
|
108
104
|
};
|
|
109
105
|
}
|
|
110
106
|
}
|
|
@@ -170,7 +166,7 @@ export async function prepareReviewedIgnoreSource(root, reviewed, execution) {
|
|
|
170
166
|
stale();
|
|
171
167
|
if (current.present)
|
|
172
168
|
return { source: current, created: false };
|
|
173
|
-
const prepared = await prepareDefaultIgnoreSource(root, execution.signal).catch((error) => {
|
|
169
|
+
const prepared = await prepareDefaultIgnoreSource(root, execution.signal, current.pendingCreation ?? null).catch((error) => {
|
|
174
170
|
execution.validate();
|
|
175
171
|
throw creationFailure(root, current, error);
|
|
176
172
|
});
|
|
@@ -342,11 +338,12 @@ export async function migrateIgnoreSetup(execution, setupName, offerToken) {
|
|
|
342
338
|
}));
|
|
343
339
|
}
|
|
344
340
|
function describeSource(source) {
|
|
345
|
-
if (source.
|
|
346
|
-
return "
|
|
347
|
-
|
|
348
|
-
? "
|
|
341
|
+
if (source.present)
|
|
342
|
+
return "Keep the existing rule file unchanged.";
|
|
343
|
+
const action = source.pendingCreation
|
|
344
|
+
? "Verify or complete the interrupted creation of the starter rules. Incomplete content will not be used."
|
|
349
345
|
: "Create the default rule file with the starter rules.";
|
|
346
|
+
return `${action}\n${source.text.trimEnd()}`;
|
|
350
347
|
}
|
|
351
348
|
function describeChanges(label, before, after) {
|
|
352
349
|
const oldPaths = new Set(before);
|
|
@@ -6,7 +6,7 @@ import ignore from "ignore";
|
|
|
6
6
|
import { isDeniedPath } from "../paths.js";
|
|
7
7
|
export const DEFAULT_IGNORE_FILENAME = ".syncignore";
|
|
8
8
|
export const DEFAULT_IGNORE_CREATION_RECORD = ".pi-sync.json.syncignore-creation";
|
|
9
|
-
export const DEFAULT_IGNORE_RULES = "/npm/\n/sessions/\n/
|
|
9
|
+
export const DEFAULT_IGNORE_RULES = "/auth.json\n/git/\n/npm/\n/sessions/\n/truth.json\n";
|
|
10
10
|
export const MAX_IGNORE_BYTES = 64 * 1024;
|
|
11
11
|
const MAX_MATCH_PATH_BYTES = 4_096;
|
|
12
12
|
const MATCH_CACHE_PATH_BUDGET = 2_048;
|
|
@@ -15,20 +15,33 @@ export function syncErrorGuidance(error) {
|
|
|
15
15
|
else if (code && ["EBUSY", "EIO", "EMFILE", "ENFILE"].includes(code)) {
|
|
16
16
|
next = "Check local disk availability and other processes using the private settings file, then retry.";
|
|
17
17
|
}
|
|
18
|
+
else if (/\bagent directory exceeds the scan entry bound\b/iu.test(message)) {
|
|
19
|
+
next =
|
|
20
|
+
"Reduce the number of entries Pi Sync must scan before retrying. Exclude whole subdirectories to skip their contents. Use /sync config to review the active scope.";
|
|
21
|
+
}
|
|
22
|
+
else if (/\bprojected agent directory exceeds the (64 MiB scan byte|scan file) bound\b/iu.test(message)) {
|
|
23
|
+
next =
|
|
24
|
+
"The resulting files would exceed the sync limit. Review the current scope with /sync config and reduce the local or incoming sync content before retrying.";
|
|
25
|
+
}
|
|
26
|
+
else if (/\bagent directory exceeds the (64 MiB scan byte|scan file) bound\b/iu.test(message)) {
|
|
27
|
+
next =
|
|
28
|
+
"Reduce the files managed by this setup before retrying. Use /sync config to find the active ignore file, or edit Agent directory scope in /sync → Settings for legacy rules.";
|
|
29
|
+
}
|
|
18
30
|
else if (/changed while|type changed|reopen/iu.test(message)) {
|
|
19
31
|
next = "Reopen the item in /sync and review its current settings before saving again.";
|
|
20
32
|
}
|
|
21
33
|
else if (status === 401 ||
|
|
22
34
|
status === 403 ||
|
|
23
35
|
/Permission denied|Authentication failed|HTTP (401|403)|failed \((401|403)\)/iu.test(message)) {
|
|
24
|
-
next =
|
|
36
|
+
next =
|
|
37
|
+
"Check the storage connection's credentials and remote permissions. In the TUI, open /sync → Settings → Manage storage connections.";
|
|
25
38
|
}
|
|
26
39
|
else if (status === 404 || /HTTP 404|failed \(404\)/iu.test(message)) {
|
|
27
40
|
next =
|
|
28
41
|
"Verify the connection address and setup's bucket, branch, or path with your provider; this response alone does not prove which resource is missing.";
|
|
29
42
|
}
|
|
30
43
|
else if (status !== undefined && status >= 500) {
|
|
31
|
-
next = "Check your storage provider's service status, then
|
|
44
|
+
next = "Check your storage provider's service status, then run /sync doctor before syncing.";
|
|
32
45
|
}
|
|
33
46
|
else if (/timed out|timeout|request failed|resolve host|Could not resolve|ENOTFOUND|ECONNREFUSED/iu.test(message)) {
|
|
34
47
|
next = "Check the server address and network connection, then run /sync doctor for the affected setup.";
|
|
@@ -49,7 +62,7 @@ export function syncErrorGuidance(error) {
|
|
|
49
62
|
"Correct the named field or item in /sync. If the settings file is invalid, repair it before retrying; do not replace it with defaults.";
|
|
50
63
|
}
|
|
51
64
|
else {
|
|
52
|
-
next = "
|
|
65
|
+
next = "For setup and storage checks, run /sync doctor or choose Diagnostics in /sync.";
|
|
53
66
|
}
|
|
54
67
|
return `${message}\n${next}`;
|
|
55
68
|
}
|
|
@@ -7,7 +7,7 @@ import { applySnapshot } from "../snapshot/snapshot-apply.js";
|
|
|
7
7
|
import { ignorePolicyValidator } from "../snapshot/snapshot-transaction-policy.js";
|
|
8
8
|
import { pruneMergeBaselines } from "../state/merge-baseline-store.js";
|
|
9
9
|
import { readStateForConfig, syncStateFingerprint, writeStateForConfig } from "../state/sync-state-store.js";
|
|
10
|
-
import { countPreservedRemoteFiles, formatPublicationPreview, formatPullSummary, formatPushSummary, formatRollbackSummary, } from "../ui/sync-format.js";
|
|
10
|
+
import { countPreservedRemoteFiles, formatPublicationPreview, formatPullSummary, formatPushSummary, formatRollbackSummary, formatTransferReview, } from "../ui/sync-format.js";
|
|
11
11
|
import { setSyncStatus } from "../ui/sync-status.js";
|
|
12
12
|
import { confirmTransferReview } from "../ui/transfer-review.js";
|
|
13
13
|
import { startupTransferEnabled } from "./agent-policy.js";
|
|
@@ -605,8 +605,8 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
605
605
|
const title = snapshotIncludesSessions(remote) ? "Rollback pi settings and sessions?" : "Rollback pi settings?";
|
|
606
606
|
const summary = formatRollbackSummary(config, backend.destination, local, physical, target, reviewedProtectedPaths, caseCleanup.map((item) => item.path));
|
|
607
607
|
const confirmed = config.ignorePolicy
|
|
608
|
-
? await confirmTransferReview(ctx, title,
|
|
609
|
-
: await ctx.ui.confirm(title, summary, { signal: options.signal });
|
|
608
|
+
? 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)
|
|
609
|
+
: await ctx.ui.confirm(title, summary.content, { signal: options.signal });
|
|
610
610
|
validateMutation();
|
|
611
611
|
if (!confirmed) {
|
|
612
612
|
ctx.ui.notify("Rollback cancelled.", "info");
|
|
@@ -739,7 +739,7 @@ async function confirmPush(ctx, options, config, backend, local, upload, head, r
|
|
|
739
739
|
? inspectRemoteSelection(config.include, remote, config.exclude, config).ignorePolicyComparison
|
|
740
740
|
: undefined;
|
|
741
741
|
const confirmed = await confirmTransferReview(ctx, title, comparison && comparison !== "match"
|
|
742
|
-
?
|
|
742
|
+
? formatTransferReview(formatIgnorePolicyComparison(comparison), "Only files selected by this device's rules are published. Remote rules are not adopted.", "", summary)
|
|
743
743
|
: summary, options.signal, validateMutation);
|
|
744
744
|
throwIfAborted(options.signal);
|
|
745
745
|
if (confirmed)
|
|
@@ -37,29 +37,22 @@ export function formatSnapshotOnlyDiff(title, snapshot) {
|
|
|
37
37
|
...snapshot.files.map((file) => `Add: ${snapshotPathLabel(file.path)}`),
|
|
38
38
|
].join("\n");
|
|
39
39
|
}
|
|
40
|
+
export function formatTransferReview(...sections) {
|
|
41
|
+
return {
|
|
42
|
+
lines: sections.flatMap((section) => (typeof section === "string" ? section.split("\n") : section.lines)),
|
|
43
|
+
content: sections.map((section) => (typeof section === "string" ? section : section.content)).join("\n"),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
40
46
|
export function formatPushSummary(config, destination, upload, head, preservedRemoteFileCount = 0, remote) {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...(remote && inspectRemoteSelection(config.include, remote, config.exclude, config).kind === "different"
|
|
51
|
-
? ["Included-content policy effect: replace the differing remote selection with this setup's local selection."]
|
|
52
|
-
: []),
|
|
53
|
-
formatPublicationPreview(remote, upload),
|
|
54
|
-
config.skipSecretScan
|
|
55
|
-
? "Warning: possible-secret scanning is disabled for this push."
|
|
56
|
-
: preservedRemoteFileCount > 0
|
|
57
|
-
? `Possible secrets in locally managed files were scanned before this prompt; ${preservedRemoteFileCount} preserved remote file(s) were not rescanned.`
|
|
58
|
-
: "Possible secrets were scanned before this prompt.",
|
|
59
|
-
...(config.scope === "agent-directory"
|
|
60
|
-
? ["Warning: synced files may contain secrets or other sensitive data that the scanner cannot identify."]
|
|
61
|
-
: []),
|
|
62
|
-
].join("\n");
|
|
47
|
+
return formatTransferReview(`Sync setup: ${safeTerminalText(config.setupName)}`, `Storage location: ${safeTerminalText(destination)}`, `Direction: Local → Remote. Source: ${safeTerminalText(agentDir())}.`, `Publish a snapshot containing ${upload.files.length} files; unchanged and preserved files are not counted as changes.`, `Sessions: ${upload.syncSessions ? "included — may contain private conversations" : "not included"}`, ...excludedPolicyLines(config), head ? `Remote latest: ${safeTerminalText(head.snapshotId)}` : "Remote latest: empty", "Publication effect: the backend's active head will reference the new immutable snapshot. Removed paths leave the active snapshot; retained history is not erased.", ...(remote && inspectRemoteSelection(config.include, remote, config.exclude, config).kind === "different"
|
|
48
|
+
? ["Included-content policy effect: replace the differing remote selection with this setup's local selection."]
|
|
49
|
+
: []), formatPublicationPreview(remote, upload), config.skipSecretScan
|
|
50
|
+
? "Warning: possible-secret scanning is disabled for this push."
|
|
51
|
+
: preservedRemoteFileCount > 0
|
|
52
|
+
? `Possible secrets in locally managed files were scanned before this prompt; ${preservedRemoteFileCount} preserved remote file(s) were not rescanned.`
|
|
53
|
+
: "Possible secrets were scanned before this prompt.", ...(config.scope === "agent-directory"
|
|
54
|
+
? ["Warning: synced files may contain secrets or other sensitive data that the scanner cannot identify."]
|
|
55
|
+
: []));
|
|
63
56
|
}
|
|
64
57
|
function excludedPolicyLines(config) {
|
|
65
58
|
const scoped = config.scope === "agent-directory";
|
|
@@ -89,36 +82,10 @@ export function formatApplyPreview(local, remote, protectedPaths = new Set(), ad
|
|
|
89
82
|
}, protectedPaths, additionalRemovals);
|
|
90
83
|
}
|
|
91
84
|
export function formatPullSummary(config, destination, local, remote, protectedPaths, additionalRemovals = []) {
|
|
92
|
-
return [
|
|
93
|
-
`Sync setup: ${safeTerminalText(config.setupName)}`,
|
|
94
|
-
`Storage location: ${safeTerminalText(destination)}`,
|
|
95
|
-
"Direction: Remote → Local.",
|
|
96
|
-
`Snapshot: ${safeTerminalText(remote.id)}`,
|
|
97
|
-
...excludedPolicyLines(config),
|
|
98
|
-
`Sessions: ${remote.syncSessions ? "included — may contain private conversations" : "not included"}`,
|
|
99
|
-
`Protected live sessions: ${protectedPaths.size || "none"}`,
|
|
100
|
-
formatApplyPreview(local, remote, protectedPaths, additionalRemovals),
|
|
101
|
-
...(additionalRemovals.length
|
|
102
|
-
? ["Case-variant aliases listed above are removed before writing canonical paths."]
|
|
103
|
-
: []),
|
|
104
|
-
"A local backup is created before these writes/deletes. The remote active snapshot is unchanged.",
|
|
105
|
-
].join("\n");
|
|
85
|
+
return formatTransferReview(`Sync setup: ${safeTerminalText(config.setupName)}`, `Storage location: ${safeTerminalText(destination)}`, "Direction: Remote → Local.", `Snapshot: ${safeTerminalText(remote.id)}`, ...excludedPolicyLines(config), `Sessions: ${remote.syncSessions ? "included — may contain private conversations" : "not included"}`, `Protected live sessions: ${protectedPaths.size || "none"}`, formatApplyPreview(local, remote, protectedPaths, additionalRemovals), ...(additionalRemovals.length ? ["Case-variant aliases are removed before writing canonical paths."] : []), "A local backup is created before these writes/deletes. The remote active snapshot is unchanged.");
|
|
106
86
|
}
|
|
107
87
|
export function formatRollbackSummary(config, destination, local, remote, requestedSnapshot, protectedPaths, additionalRemovals = []) {
|
|
108
|
-
return [
|
|
109
|
-
`Sync setup: ${safeTerminalText(config.setupName)}`,
|
|
110
|
-
`Storage location: ${safeTerminalText(destination)}`,
|
|
111
|
-
"Direction: Historical snapshot → Local and remote active head.",
|
|
112
|
-
`Snapshot: ${safeTerminalText(requestedSnapshot)}`,
|
|
113
|
-
...excludedPolicyLines(config),
|
|
114
|
-
`Sessions: ${remote.syncSessions ? "included — may contain private conversations" : "not included"}`,
|
|
115
|
-
`Protected live sessions: ${protectedPaths.size || "none"}`,
|
|
116
|
-
formatApplyPreview(local, remote, protectedPaths, additionalRemovals),
|
|
117
|
-
...(additionalRemovals.length
|
|
118
|
-
? ["Case-variant aliases listed above are removed before writing canonical paths."]
|
|
119
|
-
: []),
|
|
120
|
-
"A local backup is created before applying; the backend's active head will change.",
|
|
121
|
-
].join("\n");
|
|
88
|
+
return formatTransferReview(`Sync setup: ${safeTerminalText(config.setupName)}`, `Storage location: ${safeTerminalText(destination)}`, "Direction: Historical snapshot → Local and remote active head.", `Snapshot: ${safeTerminalText(requestedSnapshot)}`, ...excludedPolicyLines(config), `Sessions: ${remote.syncSessions ? "included — may contain private conversations" : "not included"}`, `Protected live sessions: ${protectedPaths.size || "none"}`, formatApplyPreview(local, remote, protectedPaths, additionalRemovals), ...(additionalRemovals.length ? ["Case-variant aliases are removed before writing canonical paths."] : []), "A local backup is created before applying; the backend's active head will change.");
|
|
122
89
|
}
|
|
123
90
|
export function formatPublicationPreview(remote, upload) {
|
|
124
91
|
return formatDirectionalChanges(remote, upload, {
|
|
@@ -138,11 +105,12 @@ function formatDirectionalChanges(before, after, labels, protectedPaths = new Se
|
|
|
138
105
|
}
|
|
139
106
|
const counts = transferCounts(changes);
|
|
140
107
|
const label = { Add: labels.add, Update: labels.update, Delete: labels.remove };
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
108
|
+
const heading = `Changes: ${counts.add} add · ${counts.update} update · ${counts.remove} remove`;
|
|
109
|
+
const lines = changes.length ? [heading] : [heading, "No file changes."];
|
|
110
|
+
return {
|
|
111
|
+
lines,
|
|
112
|
+
content: [...lines, ...changes.map((change) => `${label[change.action]}: ${snapshotPathLabel(change.path)}`)].join("\n"),
|
|
113
|
+
};
|
|
146
114
|
}
|
|
147
115
|
export function countPreservedRemoteFiles(local, upload) {
|
|
148
116
|
const localPaths = new Set(local.files.map((file) => file.path));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { confirmMergeReview } from "./merge-review.js";
|
|
2
2
|
/** Presentation is supplied by the host; RPC keeps its existing directional confirmation. */
|
|
3
|
-
export async function confirmTransferReview(ctx, title,
|
|
3
|
+
export async function confirmTransferReview(ctx, title, review, signal, validate) {
|
|
4
4
|
validate();
|
|
5
5
|
const isCurrent = () => {
|
|
6
6
|
try {
|
|
@@ -12,8 +12,8 @@ export async function confirmTransferReview(ctx, title, content, signal, validat
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
const confirmed = ctx.mode === "tui" && ctx.hasUI
|
|
15
|
-
? await confirmMergeReview(ctx, title, content, signal, isCurrent, "apply reviewed transfer",
|
|
16
|
-
: await ctx.ui.confirm(title, content, { signal });
|
|
15
|
+
? await confirmMergeReview(ctx, title, review.content, signal, isCurrent, "apply reviewed transfer", review.lines)
|
|
16
|
+
: await ctx.ui.confirm(title, review.content, { signal });
|
|
17
17
|
validate();
|
|
18
18
|
return confirmed;
|
|
19
19
|
}
|
package/dist/daemon/package.json
CHANGED
package/dist/index.ts
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
installPiDaemonHost,
|
|
25
25
|
piDaemonClient,
|
|
26
26
|
withPiDaemonClient
|
|
27
|
-
} from "./chunks/chunk-
|
|
27
|
+
} from "./chunks/chunk-B5F3JLD3.ts";
|
|
28
28
|
import {
|
|
29
29
|
combineSignals,
|
|
30
30
|
throwIfAborted
|
|
@@ -292,12 +292,12 @@ function createStartupCheck(loaders, attention, timeoutMs = 3e4, publish) {
|
|
|
292
292
|
// src/sync/sync-loaders.ts
|
|
293
293
|
function createSyncLoaders(dependencies) {
|
|
294
294
|
const loaders = {
|
|
295
|
-
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-
|
|
296
|
-
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-
|
|
295
|
+
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-GMRRFWOL.ts"))),
|
|
296
|
+
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-SRU6HGGK.ts"))),
|
|
297
297
|
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-L54X5U5I.ts"))),
|
|
298
298
|
snapshot: cachedModuleLoader(dependencies.loadSnapshot ?? (() => import("./chunks/snapshot-ZUJJZCFW.ts"))),
|
|
299
299
|
syncState: cachedModuleLoader(dependencies.loadSyncState ?? (() => import("./chunks/sync-state-QIT64TKV.ts"))),
|
|
300
|
-
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-
|
|
300
|
+
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-UGSCONZ7.ts")))
|
|
301
301
|
};
|
|
302
302
|
return loaders;
|
|
303
303
|
}
|
package/docs/tui-contract.md
CHANGED
|
@@ -68,7 +68,7 @@ Startup transfer summaries report the preference and prerequisites, not a claim
|
|
|
68
68
|
| Explicit `--yes` | Existing documented review bypass only | Mandatory migration and operation safety remain; existing route suites |
|
|
69
69
|
| 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` |
|
|
70
70
|
|
|
71
|
-
TUI Pull and
|
|
71
|
+
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.
|
|
72
72
|
|
|
73
73
|
## Resource reload after a transfer
|
|
74
74
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-sync",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.1",
|
|
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.9.
|
|
60
|
+
"@narumitw/pi-sync-daemon": "^0.9.1",
|
|
61
61
|
"@types/proper-lockfile": "^4.1.4",
|
|
62
62
|
"@types/semver": "^7.8.0",
|
|
63
63
|
"esbuild": "0.28.2",
|