@narumitw/pi-sync 0.58.0 → 0.59.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 +12 -6
- package/dist/chunks/{agent-candidate-U2NU3GUX.ts → agent-candidate-ZHN7FTZT.ts} +9 -8
- package/dist/chunks/{agent-plan-3YXDIJXO.ts → agent-plan-ILFEUJ2E.ts} +12 -11
- package/dist/chunks/{agent-plan-3YXDIJXO.ts.map → agent-plan-ILFEUJ2E.ts.map} +1 -1
- package/dist/chunks/{agent-refusal-retry-476YGNU5.ts → agent-refusal-retry-HRMHCX2A.ts} +9 -8
- package/dist/chunks/{agent-refusal-retry-476YGNU5.ts.map → agent-refusal-retry-HRMHCX2A.ts.map} +1 -1
- package/dist/chunks/{agent-store-7GINKTS7.ts → agent-store-CCKN4DPR.ts} +3 -3
- package/dist/chunks/{agent-sync-2R4GG2MF.ts → agent-sync-EGA2I5W7.ts} +4 -4
- package/dist/chunks/{chunk-CQD2TJHE.ts → chunk-25QCU3LY.ts} +4 -4
- package/dist/chunks/{chunk-OJARL2TG.ts → chunk-2UKUKIBI.ts} +4 -4
- package/dist/chunks/{chunk-MW6KUQYA.ts → chunk-2ZZJXITS.ts} +40 -10
- package/dist/chunks/chunk-2ZZJXITS.ts.map +7 -0
- package/dist/chunks/chunk-3JTZF7Z5.ts +77 -0
- package/dist/chunks/chunk-3JTZF7Z5.ts.map +7 -0
- package/dist/chunks/{chunk-DN4IA7MR.ts → chunk-4NVHHDN2.ts} +2 -2
- package/dist/chunks/{chunk-AKMV47YC.ts → chunk-6OFMB6KK.ts} +2 -2
- package/dist/chunks/{chunk-45COPAK7.ts → chunk-6XU5HZAN.ts} +6 -6
- package/dist/chunks/{chunk-45COPAK7.ts.map → chunk-6XU5HZAN.ts.map} +2 -2
- package/dist/chunks/{chunk-Y4UVXOLQ.ts → chunk-6YGRZSCN.ts} +15 -10
- package/dist/chunks/chunk-6YGRZSCN.ts.map +7 -0
- package/dist/chunks/{chunk-XEODG2PE.ts → chunk-76HID27T.ts} +2 -2
- package/dist/chunks/{chunk-7A35ZAVO.ts → chunk-7WYF2KUO.ts} +174 -122
- package/dist/chunks/chunk-7WYF2KUO.ts.map +7 -0
- package/dist/chunks/{chunk-MMQIEDZ6.ts → chunk-APDNHB2T.ts} +78 -35
- package/dist/chunks/chunk-APDNHB2T.ts.map +7 -0
- package/dist/chunks/{chunk-U6GXGY5G.ts → chunk-DTPELCPW.ts} +4 -4
- package/dist/chunks/{chunk-TZC7GDJE.ts → chunk-ILXMZ2HU.ts} +4 -4
- package/dist/chunks/{chunk-CBLTWXAU.ts → chunk-LA3HQMFG.ts} +2 -1
- package/dist/chunks/{chunk-CBLTWXAU.ts.map → chunk-LA3HQMFG.ts.map} +2 -2
- package/dist/chunks/{chunk-ESKOPQVB.ts → chunk-MKC3PXCN.ts} +53 -32
- package/dist/chunks/chunk-MKC3PXCN.ts.map +7 -0
- package/dist/chunks/{chunk-MG66XM5U.ts → chunk-NGW4JMBF.ts} +63 -19
- package/dist/chunks/chunk-NGW4JMBF.ts.map +7 -0
- package/dist/chunks/{chunk-TIMWN2RH.ts → chunk-OQBE2OMB.ts} +13 -14
- package/dist/chunks/chunk-OQBE2OMB.ts.map +7 -0
- package/dist/chunks/{chunk-MKSMJPVA.ts → chunk-P3YD4ONV.ts} +22 -6
- package/dist/chunks/chunk-P3YD4ONV.ts.map +7 -0
- package/dist/chunks/{chunk-JYILGR3K.ts → chunk-PQ75RPUP.ts} +3 -3
- package/dist/chunks/{chunk-FLHCOJCD.ts → chunk-QQVK2XFC.ts} +13 -6
- package/dist/chunks/chunk-QQVK2XFC.ts.map +7 -0
- package/dist/chunks/{chunk-WQMYV4DW.ts → chunk-RDOX3VH5.ts} +5 -5
- package/dist/chunks/{chunk-6O3EDBRL.ts → chunk-S7D6XWHI.ts} +2 -2
- package/dist/chunks/{chunk-7ZIYU5QS.ts → chunk-SHPNS7FM.ts} +7 -7
- package/dist/chunks/{chunk-7ZIYU5QS.ts.map → chunk-SHPNS7FM.ts.map} +2 -2
- package/dist/chunks/{chunk-GNYGNHFF.ts → chunk-T2TYBLXK.ts} +2 -2
- package/dist/chunks/{chunk-6LD5KX55.ts → chunk-UZSDS4HF.ts} +13 -6
- package/dist/chunks/chunk-UZSDS4HF.ts.map +7 -0
- package/dist/chunks/{chunk-5TSCBBPP.ts → chunk-VPODHKOX.ts} +3 -3
- package/dist/chunks/{chunk-BEST45H2.ts → chunk-WEKGW7HV.ts} +17 -8
- package/dist/chunks/chunk-WEKGW7HV.ts.map +7 -0
- package/dist/chunks/{chunk-KYTT7KV4.ts → chunk-WUHRVSWI.ts} +87 -37
- package/dist/chunks/chunk-WUHRVSWI.ts.map +7 -0
- package/dist/chunks/{chunk-OVBAW7KV.ts → chunk-XZ3ZTHKR.ts} +19 -9
- package/dist/chunks/chunk-XZ3ZTHKR.ts.map +7 -0
- package/dist/chunks/{chunk-S5OCYVPS.ts → chunk-YEULK7MK.ts} +3 -3
- package/dist/chunks/{command-handler-KCB6MCWS.ts → command-handler-SDGKIQH2.ts} +17 -14
- package/dist/chunks/command-handler-SDGKIQH2.ts.map +7 -0
- package/dist/chunks/{config-HYG7G5EM.ts → config-J5VZUY4J.ts} +4 -3
- package/dist/chunks/{conflict-artifacts-J6WSDCWP.ts → conflict-artifacts-MYSH3L2J.ts} +10 -9
- package/dist/chunks/{conflict-review-GXA6Y7KY.ts → conflict-review-J6ZSPNWL.ts} +21 -20
- package/dist/chunks/{conflict-review-GXA6Y7KY.ts.map → conflict-review-J6ZSPNWL.ts.map} +1 -1
- package/dist/chunks/{continuous-record-EPHGR2DU.ts → continuous-record-OM64J27R.ts} +4 -4
- package/dist/chunks/{continuous-sync-FAFNLEUW.ts → continuous-sync-BH5SWIRV.ts} +22 -17
- package/dist/chunks/continuous-sync-BH5SWIRV.ts.map +7 -0
- package/dist/chunks/{file-selection-IELTXSGZ.ts → file-selection-7HEVPO4T.ts} +11 -8
- package/dist/chunks/file-selection-7HEVPO4T.ts.map +7 -0
- package/dist/chunks/{git-backend-KHD36W27.ts → git-backend-6CKI6CUG.ts} +12 -15
- package/dist/chunks/{git-backend-KHD36W27.ts.map → git-backend-6CKI6CUG.ts.map} +2 -2
- package/dist/chunks/{local-fields-JEKAPZKD.ts → local-fields-SR7PH66U.ts} +6 -5
- package/dist/chunks/{manager-result-dispatcher-XCYPW7RC.ts → manager-result-dispatcher-CXUP5WDP.ts} +15 -14
- package/dist/chunks/{manager-ui-FMZXKPX2.ts → manager-ui-65ZETN6F.ts} +168 -51
- package/dist/chunks/manager-ui-65ZETN6F.ts.map +7 -0
- package/dist/chunks/{merge-baseline-store-65GKUMXI.ts → merge-baseline-store-4Y2X7P2D.ts} +4 -3
- package/dist/chunks/{remote-selection-ui-MYM2YCPF.ts → remote-selection-ui-W55BQDJQ.ts} +14 -13
- package/dist/chunks/{s3-backend-L24UZ6IK.ts → s3-backend-FDK7JSDQ.ts} +8 -7
- package/dist/chunks/{s3-backend-L24UZ6IK.ts.map → s3-backend-FDK7JSDQ.ts.map} +1 -1
- package/dist/chunks/{setup-switch-KLGESLQX.ts → setup-switch-AB27ADDI.ts} +5 -4
- package/dist/chunks/{setup-wizard-ZQAK35BP.ts → setup-wizard-5FILKFLQ.ts} +6 -5
- package/dist/chunks/{setup-wizard-ZQAK35BP.ts.map → setup-wizard-5FILKFLQ.ts.map} +1 -1
- package/dist/chunks/{snapshot-RGNDYT6A.ts → snapshot-G3W2GOGB.ts} +5 -4
- package/dist/chunks/{snapshot-transaction-26BQO36S.ts → snapshot-transaction-SGRUWT73.ts} +6 -5
- package/dist/chunks/{sync-inspection-MOMLGUTD.ts → sync-inspection-MDYHZHT7.ts} +10 -9
- package/dist/chunks/{sync-operations-45APGOL3.ts → sync-operations-ZAUP65FH.ts} +40 -29
- package/dist/chunks/sync-operations-ZAUP65FH.ts.map +7 -0
- package/dist/chunks/{sync-state-7L4NT7W2.ts → sync-state-H4TFZZ7S.ts} +7 -6
- package/dist/chunks/{webdav-backend-3ZCACILP.ts → webdav-backend-UNMIAXM5.ts} +7 -6
- package/dist/chunks/{webdav-backend-3ZCACILP.ts.map → webdav-backend-UNMIAXM5.ts.map} +1 -1
- package/dist/index.ts +26 -19
- package/dist/index.ts.map +2 -2
- package/docs/exclude-policy-audit.md +54 -0
- package/docs/exclude-review-ledger.md +36 -0
- package/docs/tui-contract.md +1 -1
- package/package.json +3 -2
- package/skills/configure-pi-sync/SKILL.md +4 -3
- package/skills/configure-pi-sync/references/configuration.md +72 -13
- package/src/backends/git/git-storage.ts +12 -11
- package/src/commands/command-execution.ts +2 -2
- package/src/commands/command-handler.ts +1 -0
- package/src/settings/config.ts +9 -3
- package/src/settings/settings-management.ts +4 -3
- package/src/settings/settings-types.ts +4 -1
- package/src/settings/settings-validation.ts +8 -4
- package/src/snapshot/session-paths.ts +1 -0
- package/src/snapshot/snapshot-apply.ts +23 -7
- package/src/snapshot/snapshot-codec.ts +12 -3
- package/src/snapshot/snapshot-exclude-safety.ts +44 -0
- package/src/snapshot/snapshot-transaction.ts +12 -0
- package/src/snapshot/snapshot-types.ts +4 -4
- package/src/snapshot/snapshot.ts +71 -30
- package/src/state/merge-baseline-store.ts +9 -1
- package/src/state/state-types.ts +1 -0
- package/src/sync/automatic-sync.ts +7 -2
- package/src/sync/continuous-watch.ts +4 -2
- package/src/sync/exclude-policy.ts +84 -0
- package/src/sync/local-fields.ts +15 -4
- package/src/sync/merge-apply.ts +6 -1
- package/src/sync/merge-journal.ts +12 -3
- package/src/sync/merged-sync.ts +17 -12
- package/src/sync/partial-progress.ts +1 -0
- package/src/sync/remote-snapshot.ts +7 -8
- package/src/sync/sync-decision.ts +11 -1
- package/src/sync/sync-inspection.ts +3 -1
- package/src/sync/sync-mutations.ts +11 -4
- package/src/sync/sync-policy.ts +101 -37
- package/src/sync/sync-queries.ts +13 -3
- package/src/sync/sync-state.ts +16 -10
- package/src/ui/excluded-paths-ui.ts +106 -0
- package/src/ui/file-selection.ts +6 -3
- package/src/ui/manager-state.ts +11 -5
- package/src/ui/remote-selection-ui.ts +73 -10
- package/src/ui/settings-ui.ts +20 -5
- package/src/ui/setup/setup-actions.ts +1 -1
- package/src/ui/setup/setup-switcher.ts +3 -2
- package/src/ui/storage-connections-ui.ts +2 -2
- package/src/ui/sync-attention.ts +46 -10
- package/src/ui/sync-format.ts +13 -1
- package/dist/chunks/chunk-6LD5KX55.ts.map +0 -7
- package/dist/chunks/chunk-7A35ZAVO.ts.map +0 -7
- package/dist/chunks/chunk-BEST45H2.ts.map +0 -7
- package/dist/chunks/chunk-ESKOPQVB.ts.map +0 -7
- package/dist/chunks/chunk-FLHCOJCD.ts.map +0 -7
- package/dist/chunks/chunk-KYTT7KV4.ts.map +0 -7
- package/dist/chunks/chunk-MG66XM5U.ts.map +0 -7
- package/dist/chunks/chunk-MKSMJPVA.ts.map +0 -7
- package/dist/chunks/chunk-MMQIEDZ6.ts.map +0 -7
- package/dist/chunks/chunk-MW6KUQYA.ts.map +0 -7
- package/dist/chunks/chunk-OVBAW7KV.ts.map +0 -7
- package/dist/chunks/chunk-TIMWN2RH.ts.map +0 -7
- package/dist/chunks/chunk-Y4UVXOLQ.ts.map +0 -7
- package/dist/chunks/command-handler-KCB6MCWS.ts.map +0 -7
- package/dist/chunks/continuous-sync-FAFNLEUW.ts.map +0 -7
- package/dist/chunks/file-selection-IELTXSGZ.ts.map +0 -7
- package/dist/chunks/manager-ui-FMZXKPX2.ts.map +0 -7
- package/dist/chunks/sync-operations-45APGOL3.ts.map +0 -7
- /package/dist/chunks/{agent-candidate-U2NU3GUX.ts.map → agent-candidate-ZHN7FTZT.ts.map} +0 -0
- /package/dist/chunks/{agent-store-7GINKTS7.ts.map → agent-store-CCKN4DPR.ts.map} +0 -0
- /package/dist/chunks/{agent-sync-2R4GG2MF.ts.map → agent-sync-EGA2I5W7.ts.map} +0 -0
- /package/dist/chunks/{chunk-CQD2TJHE.ts.map → chunk-25QCU3LY.ts.map} +0 -0
- /package/dist/chunks/{chunk-OJARL2TG.ts.map → chunk-2UKUKIBI.ts.map} +0 -0
- /package/dist/chunks/{chunk-DN4IA7MR.ts.map → chunk-4NVHHDN2.ts.map} +0 -0
- /package/dist/chunks/{chunk-AKMV47YC.ts.map → chunk-6OFMB6KK.ts.map} +0 -0
- /package/dist/chunks/{chunk-XEODG2PE.ts.map → chunk-76HID27T.ts.map} +0 -0
- /package/dist/chunks/{chunk-U6GXGY5G.ts.map → chunk-DTPELCPW.ts.map} +0 -0
- /package/dist/chunks/{chunk-TZC7GDJE.ts.map → chunk-ILXMZ2HU.ts.map} +0 -0
- /package/dist/chunks/{chunk-JYILGR3K.ts.map → chunk-PQ75RPUP.ts.map} +0 -0
- /package/dist/chunks/{chunk-WQMYV4DW.ts.map → chunk-RDOX3VH5.ts.map} +0 -0
- /package/dist/chunks/{chunk-6O3EDBRL.ts.map → chunk-S7D6XWHI.ts.map} +0 -0
- /package/dist/chunks/{chunk-GNYGNHFF.ts.map → chunk-T2TYBLXK.ts.map} +0 -0
- /package/dist/chunks/{chunk-5TSCBBPP.ts.map → chunk-VPODHKOX.ts.map} +0 -0
- /package/dist/chunks/{chunk-S5OCYVPS.ts.map → chunk-YEULK7MK.ts.map} +0 -0
- /package/dist/chunks/{config-HYG7G5EM.ts.map → config-J5VZUY4J.ts.map} +0 -0
- /package/dist/chunks/{conflict-artifacts-J6WSDCWP.ts.map → conflict-artifacts-MYSH3L2J.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-EPHGR2DU.ts.map → continuous-record-OM64J27R.ts.map} +0 -0
- /package/dist/chunks/{local-fields-JEKAPZKD.ts.map → local-fields-SR7PH66U.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-XCYPW7RC.ts.map → manager-result-dispatcher-CXUP5WDP.ts.map} +0 -0
- /package/dist/chunks/{merge-baseline-store-65GKUMXI.ts.map → merge-baseline-store-4Y2X7P2D.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-MYM2YCPF.ts.map → remote-selection-ui-W55BQDJQ.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-KLGESLQX.ts.map → setup-switch-AB27ADDI.ts.map} +0 -0
- /package/dist/chunks/{snapshot-RGNDYT6A.ts.map → snapshot-G3W2GOGB.ts.map} +0 -0
- /package/dist/chunks/{snapshot-transaction-26BQO36S.ts.map → snapshot-transaction-SGRUWT73.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-MOMLGUTD.ts.map → sync-inspection-MDYHZHT7.ts.map} +0 -0
- /package/dist/chunks/{sync-state-7L4NT7W2.ts.map → sync-state-H4TFZZ7S.ts.map} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
|
+
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
4
|
+
import { localConfigPath } from "../settings/config-file.js";
|
|
5
|
+
import { updateSyncSetup } from "../settings/settings-management.js";
|
|
6
|
+
import { normalizeSyncExclude, sameSyncExclude } from "../sync/exclude-policy.js";
|
|
7
|
+
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
8
|
+
import { safeTerminalText } from "./terminal-text.js";
|
|
9
|
+
|
|
10
|
+
/** Transactional draft; Pi owns editor input/paste and Kit owns review/cancellation. */
|
|
11
|
+
export async function showExcludedPaths(ctx: ExtensionCommandContext, setupName: string, signal?: AbortSignal) {
|
|
12
|
+
const validate = captureMutationOwner(ctx, signal);
|
|
13
|
+
const isCurrent = () => {
|
|
14
|
+
try {
|
|
15
|
+
validate();
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
validate();
|
|
22
|
+
const config = await loadConfig(setupName);
|
|
23
|
+
validate();
|
|
24
|
+
if (ctx.mode !== "tui") {
|
|
25
|
+
if (ctx.hasUI)
|
|
26
|
+
ctx.ui.notify(
|
|
27
|
+
[
|
|
28
|
+
`Excluded paths: ${(config.exclude ?? []).map(safeTerminalText).join(", ") || "none"}`,
|
|
29
|
+
`Edit sync.exclude in ${safeTerminalText(localConfigPath())}; an explicit array requires settings version 6.`,
|
|
30
|
+
].join("\n"),
|
|
31
|
+
"info",
|
|
32
|
+
);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let draft = JSON.stringify(config.exclude ?? []);
|
|
36
|
+
while (isCurrent()) {
|
|
37
|
+
const entered = await ctx.ui.input("Excluded paths · JSON array · empty input keeps draft", draft, { signal });
|
|
38
|
+
if (!isCurrent() || entered === undefined) return;
|
|
39
|
+
const input = entered || draft;
|
|
40
|
+
draft = input;
|
|
41
|
+
let exclude: string[];
|
|
42
|
+
try {
|
|
43
|
+
const parsed: unknown = JSON.parse(input);
|
|
44
|
+
if (!Array.isArray(parsed)) throw new Error("Enter a JSON string array.");
|
|
45
|
+
exclude = normalizeSyncExclude(parsed);
|
|
46
|
+
} catch {
|
|
47
|
+
ctx.ui.notify("Invalid exclude array or unsupported pattern. No settings changed.", "error");
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (sameSyncExclude(exclude, config.exclude)) return;
|
|
51
|
+
let choice: "save" | "discard" | "edit" | undefined;
|
|
52
|
+
const menu = defineMenu<undefined, "review", "choose", ExtensionCommandContext>({
|
|
53
|
+
start: "review",
|
|
54
|
+
screens: {
|
|
55
|
+
review: () => ({
|
|
56
|
+
kind: "actions",
|
|
57
|
+
title: "Review excluded paths",
|
|
58
|
+
lines: [
|
|
59
|
+
`Setup: ${safeTerminalText(config.setupName)}`,
|
|
60
|
+
"Draft only. Save opts into settings version 6 / snapshot version 4; older clients must refuse them.",
|
|
61
|
+
"Excluded local files stay untouched. New snapshots omit matching remote files; old history is NOT erased.",
|
|
62
|
+
"Removing rules can expose local content or allow pull to replace it. Review a force push to publish policy changes.",
|
|
63
|
+
"Previously excluded:",
|
|
64
|
+
...(config.exclude?.length ? config.exclude.map((rule) => `- ${safeTerminalText(rule)}`) : ["(none)"]),
|
|
65
|
+
"Proposed excluded paths:",
|
|
66
|
+
...(exclude.length ? exclude.map((rule) => `+ ${safeTerminalText(rule)}`) : ["(none)"]),
|
|
67
|
+
],
|
|
68
|
+
items: [
|
|
69
|
+
{ id: "save", label: "Save changes", action: "choose" },
|
|
70
|
+
{ id: "discard", label: "Discard changes", action: "choose" },
|
|
71
|
+
{ id: "edit", label: "Continue editing", action: "choose" },
|
|
72
|
+
],
|
|
73
|
+
hint: "close",
|
|
74
|
+
}),
|
|
75
|
+
},
|
|
76
|
+
actions: {
|
|
77
|
+
choose: async ({ itemId }) => {
|
|
78
|
+
choice = itemId === "save" ? "save" : itemId === "edit" ? "edit" : "discard";
|
|
79
|
+
return { kind: "close" };
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
await runMenu(ctx, menu, { getState: () => undefined, signal, isCurrent });
|
|
84
|
+
if (!isCurrent()) return;
|
|
85
|
+
if (choice === "edit") continue;
|
|
86
|
+
if (choice !== "save") return;
|
|
87
|
+
try {
|
|
88
|
+
await updateSyncSetup(
|
|
89
|
+
setupName,
|
|
90
|
+
(setup) => {
|
|
91
|
+
validate();
|
|
92
|
+
return { ...setup, sync: { ...setup.sync, exclude } };
|
|
93
|
+
},
|
|
94
|
+
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), upgradeExclude: true, signal },
|
|
95
|
+
);
|
|
96
|
+
if (isCurrent()) ctx.ui.notify("Excluded paths saved. Applies to subsequent sync; no transfer started.", "info");
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (isCurrent())
|
|
99
|
+
ctx.ui.notify(
|
|
100
|
+
`Excluded paths not saved: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
|
|
101
|
+
"error",
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
package/src/ui/file-selection.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
4
|
-
import { loadConfig } from "../settings/config.js";
|
|
4
|
+
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
5
5
|
import { localConfigPath } from "../settings/config-file.js";
|
|
6
6
|
import { updateSyncSetup } from "../settings/settings-management.js";
|
|
7
7
|
import { agentDir } from "../snapshot/session-paths.js";
|
|
@@ -40,7 +40,10 @@ export async function showFileSelection(ctx: ExtensionCommandContext, setupName?
|
|
|
40
40
|
[
|
|
41
41
|
`pi-sync included content for sync setup ${safeTerminalText(config.setupName)}:`,
|
|
42
42
|
`include: ${config.include.map(safeTerminalText).join(", ") || "none"}`,
|
|
43
|
-
|
|
43
|
+
...(config.exclude === undefined
|
|
44
|
+
? []
|
|
45
|
+
: [`exclude: ${config.exclude.map(safeTerminalText).join(", ") || "none"}`]),
|
|
46
|
+
`Edit sync.include and sync.exclude in ${safeTerminalText(localConfigPath())}.`,
|
|
44
47
|
].join("\n"),
|
|
45
48
|
"info",
|
|
46
49
|
);
|
|
@@ -82,7 +85,7 @@ export async function showFileSelection(ctx: ExtensionCommandContext, setupName?
|
|
|
82
85
|
...setup,
|
|
83
86
|
sync: { ...setup.sync, include },
|
|
84
87
|
}),
|
|
85
|
-
{ expectedInclude: config.include, signal },
|
|
88
|
+
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), expectedInclude: config.include, signal },
|
|
86
89
|
);
|
|
87
90
|
if (signal?.aborted) return;
|
|
88
91
|
ctx.ui.notify(
|
package/src/ui/manager-state.ts
CHANGED
|
@@ -11,9 +11,10 @@ import {
|
|
|
11
11
|
operationCanRecover,
|
|
12
12
|
} from "../state/operation-availability.js";
|
|
13
13
|
import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
|
|
14
|
+
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
14
15
|
import { errorMessage } from "../sync/sync-errors.js";
|
|
15
16
|
import type { StartupObservation } from "../sync/sync-inspection.js";
|
|
16
|
-
import { compareSyncInclude, syncIncludeSelection } from "../sync/sync-policy.js";
|
|
17
|
+
import { compareSyncInclude, syncIncludeSelection, syncSessionsSelected } from "../sync/sync-policy.js";
|
|
17
18
|
import { automaticSyncSummary } from "./automatic-sync-summary.js";
|
|
18
19
|
import {
|
|
19
20
|
observationMatchesConfig,
|
|
@@ -78,7 +79,7 @@ export async function describeManagerState(
|
|
|
78
79
|
}
|
|
79
80
|
const configuredTargets = ownRecord(raw.syncSetups);
|
|
80
81
|
if (
|
|
81
|
-
(raw.version === 3 || raw.version === 4 || raw.version === 5) &&
|
|
82
|
+
(raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6) &&
|
|
82
83
|
configuredTargets &&
|
|
83
84
|
Object.keys(configuredTargets).length === 0
|
|
84
85
|
) {
|
|
@@ -113,6 +114,9 @@ export async function describeManagerState(
|
|
|
113
114
|
const attentionComparison = currentAttention
|
|
114
115
|
? compareSyncInclude(currentAttention.decision.localInclude, currentAttention.decision.remoteInclude)
|
|
115
116
|
: undefined;
|
|
117
|
+
const attentionExclusionsDiffer = currentAttention
|
|
118
|
+
? !sameSyncExclude(currentAttention.decision.localExclude, currentAttention.decision.remoteExclude)
|
|
119
|
+
: false;
|
|
116
120
|
const noSyncedContent = config.include.length === 0;
|
|
117
121
|
const syncState = changesBlocked ? undefined : await readStateForConfig(config).catch(() => undefined);
|
|
118
122
|
const currentObservation =
|
|
@@ -152,8 +156,10 @@ export async function describeManagerState(
|
|
|
152
156
|
? "Sync status: Review needed"
|
|
153
157
|
: `Sync status: Review needed for setup ${safeTerminalText(currentAttention.decision.setupName)}`,
|
|
154
158
|
attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0
|
|
155
|
-
?
|
|
156
|
-
|
|
159
|
+
? attentionExclusionsDiffer
|
|
160
|
+
? "Synced-content exclusion rules differ."
|
|
161
|
+
: "Only the synced-content order differs."
|
|
162
|
+
: `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} · Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " · Exclusion rules differ." : ""}`,
|
|
157
163
|
"Nothing has been changed.",
|
|
158
164
|
]
|
|
159
165
|
: currentObservation
|
|
@@ -162,7 +168,7 @@ export async function describeManagerState(
|
|
|
162
168
|
"Check-time observation only; synchronization rechecks current content.",
|
|
163
169
|
]
|
|
164
170
|
: ["Remote status: Not checked"]),
|
|
165
|
-
`Included: ${selection.builtIns.length} built-in group${selection.builtIns.length === 1 ? "" : "s"} · ${selection.custom.length} extra path${selection.custom.length === 1 ? "" : "s"} · Sessions ${
|
|
171
|
+
`Included: ${selection.builtIns.length} built-in group${selection.builtIns.length === 1 ? "" : "s"} · ${selection.custom.length} extra path${selection.custom.length === 1 ? "" : "s"} · Sessions ${syncSessionsSelected(config) ? "on" : "off"}`,
|
|
166
172
|
`Automatic sync: ${automaticSyncSummary(config.automatic)}`,
|
|
167
173
|
`Startup transfer: ${startupTransferSummary(config)}`,
|
|
168
174
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
@@ -5,6 +5,7 @@ import type { RemoteHead, SyncBackend } from "../backends/sync-backend.js";
|
|
|
5
5
|
import { loadConfig, syncCheckConfigFingerprint, syncConfigReviewFingerprint } from "../settings/config.js";
|
|
6
6
|
import { SyncSetupReviewChangedError, updateSyncSetup } from "../settings/settings-management.js";
|
|
7
7
|
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
8
|
+
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
8
9
|
import { readSnapshotForHead } from "../sync/remote-snapshot.js";
|
|
9
10
|
import { throwIfAborted } from "../sync/signals.js";
|
|
10
11
|
import { errorMessage } from "../sync/sync-errors.js";
|
|
@@ -266,6 +267,22 @@ async function showSelectionDifference(
|
|
|
266
267
|
validateOwner();
|
|
267
268
|
if (!acknowledged) return undefined;
|
|
268
269
|
}
|
|
270
|
+
if (state.decision.remoteExclude !== undefined && currentConfig.exclude === undefined) {
|
|
271
|
+
onDialog?.(true);
|
|
272
|
+
let confirmed: boolean;
|
|
273
|
+
try {
|
|
274
|
+
confirmed = await ctx.ui.confirm(
|
|
275
|
+
"Adopt excluded paths?",
|
|
276
|
+
"This upgrades settings to version 6 / snapshots to version 4. Older clients must refuse them. Both content lists are saved; no files transfer and old history is not erased.",
|
|
277
|
+
{ signal: ownedSignal },
|
|
278
|
+
);
|
|
279
|
+
} finally {
|
|
280
|
+
onDialog?.(false);
|
|
281
|
+
}
|
|
282
|
+
ownedSignal.throwIfAborted();
|
|
283
|
+
validateOwner();
|
|
284
|
+
if (!confirmed) return undefined;
|
|
285
|
+
}
|
|
269
286
|
return runWithOptionalStateAccess(options, async () => {
|
|
270
287
|
const loaded = await loadAdoptionReview(state.decision, ownedSignal, factory, validateOwner);
|
|
271
288
|
ownedSignal.throwIfAborted();
|
|
@@ -288,6 +305,7 @@ async function showSelectionDifference(
|
|
|
288
305
|
continuationFingerprint = syncCheckConfigFingerprint({
|
|
289
306
|
...adoption.value.config,
|
|
290
307
|
include: [...state.decision.remoteInclude],
|
|
308
|
+
exclude: adoptedExclude(state.decision),
|
|
291
309
|
});
|
|
292
310
|
flowState = { decision: state.decision, saved: true };
|
|
293
311
|
return { kind: "to" as const, screen: "saved" as const };
|
|
@@ -435,8 +453,12 @@ async function loadAdoptionReview(
|
|
|
435
453
|
const snapshot = await readSnapshotForHead(backend, reviewedHead, signal);
|
|
436
454
|
throwIfAborted(signal);
|
|
437
455
|
validateOwner();
|
|
438
|
-
const state = inspectRemoteSelection(config.include, snapshot);
|
|
439
|
-
if (
|
|
456
|
+
const state = inspectRemoteSelection(config.include, snapshot, config.exclude);
|
|
457
|
+
if (
|
|
458
|
+
state.kind !== "different" ||
|
|
459
|
+
!sameSyncInclude(state.include, decision.remoteInclude) ||
|
|
460
|
+
!sameSyncExclude(state.exclude, decision.remoteExclude)
|
|
461
|
+
) {
|
|
440
462
|
throw new StaleRemoteSelectionReviewError("Remote synced content changed while the comparison was open.");
|
|
441
463
|
}
|
|
442
464
|
return { config, backend, reviewedHead };
|
|
@@ -457,19 +479,31 @@ async function revalidateAndAdopt(
|
|
|
457
479
|
const currentSnapshot = await readSnapshotForHead(review.backend, currentHead, signal);
|
|
458
480
|
throwIfAborted(signal);
|
|
459
481
|
validateOwner();
|
|
460
|
-
const currentState = inspectRemoteSelection(review.config.include, currentSnapshot);
|
|
461
|
-
if (
|
|
482
|
+
const currentState = inspectRemoteSelection(review.config.include, currentSnapshot, review.config.exclude);
|
|
483
|
+
if (
|
|
484
|
+
currentState.kind !== "different" ||
|
|
485
|
+
!sameSyncInclude(currentState.include, decision.remoteInclude) ||
|
|
486
|
+
!sameSyncExclude(currentState.exclude, decision.remoteExclude)
|
|
487
|
+
) {
|
|
462
488
|
throw new StaleRemoteSelectionReviewError("Remote synced content changed while the comparison was open.");
|
|
463
489
|
}
|
|
464
490
|
await updateSyncSetup(
|
|
465
491
|
decision.setupName,
|
|
466
492
|
(setup) => {
|
|
467
493
|
validateOwner();
|
|
468
|
-
return {
|
|
494
|
+
return {
|
|
495
|
+
...setup,
|
|
496
|
+
sync: {
|
|
497
|
+
...setup.sync,
|
|
498
|
+
include: [...decision.remoteInclude],
|
|
499
|
+
...(adoptedExclude(decision) === undefined ? {} : { exclude: adoptedExclude(decision) }),
|
|
500
|
+
},
|
|
501
|
+
};
|
|
469
502
|
},
|
|
470
503
|
{
|
|
471
504
|
expectedConfigFingerprint: syncCheckConfigFingerprint(review.config),
|
|
472
505
|
expectedInclude: decision.localInclude,
|
|
506
|
+
upgradeExclude: adoptedExclude(decision) !== undefined,
|
|
473
507
|
signal,
|
|
474
508
|
},
|
|
475
509
|
);
|
|
@@ -503,7 +537,7 @@ async function inspectConfiguredRemoteSelection(
|
|
|
503
537
|
return {
|
|
504
538
|
kind: "selection",
|
|
505
539
|
config,
|
|
506
|
-
state: inspectRemoteSelection(config.include, snapshot),
|
|
540
|
+
state: inspectRemoteSelection(config.include, snapshot, config.exclude),
|
|
507
541
|
};
|
|
508
542
|
}
|
|
509
543
|
|
|
@@ -555,12 +589,23 @@ async function showLegacyDiscovery(
|
|
|
555
589
|
});
|
|
556
590
|
}
|
|
557
591
|
|
|
592
|
+
function adoptedExclude(decision: RemoteSelectionDecision) {
|
|
593
|
+
return decision.remoteExclude === undefined
|
|
594
|
+
? decision.localExclude === undefined
|
|
595
|
+
? undefined
|
|
596
|
+
: []
|
|
597
|
+
: [...decision.remoteExclude];
|
|
598
|
+
}
|
|
599
|
+
|
|
558
600
|
function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
559
601
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
560
602
|
return [
|
|
561
603
|
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
562
604
|
"Nothing changed. Review both lists before choosing what happens next.",
|
|
563
|
-
...(
|
|
605
|
+
...excludeReviewLines(decision),
|
|
606
|
+
...(comparison.remoteOnly.length === 0 &&
|
|
607
|
+
comparison.localOnly.length === 0 &&
|
|
608
|
+
sameSyncExclude(decision.localExclude, decision.remoteExclude)
|
|
564
609
|
? ["Only the ordering differs; membership is the same."]
|
|
565
610
|
: [`Remote-only paths: ${comparison.remoteOnly.length} · Device-only paths: ${comparison.localOnly.length}`]),
|
|
566
611
|
];
|
|
@@ -569,7 +614,9 @@ function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
|
569
614
|
function formatSelectionDifference(decision: RemoteSelectionDecision) {
|
|
570
615
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
571
616
|
return [
|
|
572
|
-
...(comparison.remoteOnly.length === 0 &&
|
|
617
|
+
...(comparison.remoteOnly.length === 0 &&
|
|
618
|
+
comparison.localOnly.length === 0 &&
|
|
619
|
+
sameSyncExclude(decision.localExclude, decision.remoteExclude)
|
|
573
620
|
? ["Only ordering differs; both lists contain the same paths.", ""]
|
|
574
621
|
: []),
|
|
575
622
|
"Remote-only paths:",
|
|
@@ -592,6 +639,7 @@ function formatSelectionDifference(decision: RemoteSelectionDecision) {
|
|
|
592
639
|
? decision.localInclude.map((item, index) => `${index + 1}. ${safeTerminalText(item)}`)
|
|
593
640
|
: ["(none)"]),
|
|
594
641
|
"",
|
|
642
|
+
...excludeReviewLines(decision),
|
|
595
643
|
"Using the remote list saves settings only and does not pull files.",
|
|
596
644
|
].join("\n");
|
|
597
645
|
}
|
|
@@ -602,17 +650,29 @@ function formatRemoteSelectionSummary(decision: RemoteSelectionDecision) {
|
|
|
602
650
|
`Synced content for “${safeTerminalText(decision.setupName)}” differs from this device.`,
|
|
603
651
|
`Remote-only: ${safeList(comparison.remoteOnly)}`,
|
|
604
652
|
`Device-only: ${safeList(comparison.localOnly)}`,
|
|
605
|
-
...(comparison.remoteOnly.length === 0 &&
|
|
653
|
+
...(comparison.remoteOnly.length === 0 &&
|
|
654
|
+
comparison.localOnly.length === 0 &&
|
|
655
|
+
sameSyncExclude(decision.localExclude, decision.remoteExclude)
|
|
606
656
|
? [
|
|
607
657
|
"Only ordering differs.",
|
|
608
658
|
`Remote order: ${safeList(decision.remoteInclude)}`,
|
|
609
659
|
`Device order: ${safeList(decision.localInclude)}`,
|
|
610
660
|
]
|
|
611
661
|
: []),
|
|
662
|
+
...excludeReviewLines(decision),
|
|
612
663
|
"Run /sync in TUI to choose a content list; RPC review is read-only.",
|
|
613
664
|
].join("\n");
|
|
614
665
|
}
|
|
615
666
|
|
|
667
|
+
function excludeReviewLines(decision: RemoteSelectionDecision) {
|
|
668
|
+
if (decision.localExclude === undefined && decision.remoteExclude === undefined) return [];
|
|
669
|
+
return [
|
|
670
|
+
`Remote excluded paths: ${safeList(decision.remoteExclude ?? [])}`,
|
|
671
|
+
`This device excluded paths: ${safeList(decision.localExclude ?? [])}`,
|
|
672
|
+
"Removed exclusions can expose or replace content; old history is not erased.",
|
|
673
|
+
];
|
|
674
|
+
}
|
|
675
|
+
|
|
616
676
|
function formatLegacySummary(config: AnySyncConfig, discovered: readonly string[]) {
|
|
617
677
|
return `Remote snapshot for “${safeTerminalText(config.setupName)}” has no portable synced-content list; ${discovered.length} safe path${discovered.length === 1 ? " was" : "s were"} discovered, but the result is partial and read-only.`;
|
|
618
678
|
}
|
|
@@ -626,13 +686,16 @@ function decisionFromState(
|
|
|
626
686
|
configIdentity: syncConfigReviewFingerprint(config),
|
|
627
687
|
localInclude: [...config.include],
|
|
628
688
|
remoteInclude: [...state.include],
|
|
689
|
+
...(config.exclude === undefined ? {} : { localExclude: [...config.exclude] }),
|
|
690
|
+
...(state.exclude === undefined ? {} : { remoteExclude: [...state.exclude] }),
|
|
629
691
|
};
|
|
630
692
|
}
|
|
631
693
|
|
|
632
694
|
function assertLocalSelectionCurrent(config: AnySyncConfig, decision: RemoteSelectionDecision) {
|
|
633
695
|
if (
|
|
634
696
|
syncConfigReviewFingerprint(config) === decision.configIdentity &&
|
|
635
|
-
sameSyncInclude(config.include, decision.localInclude)
|
|
697
|
+
sameSyncInclude(config.include, decision.localInclude) &&
|
|
698
|
+
sameSyncExclude(config.exclude, decision.localExclude)
|
|
636
699
|
) {
|
|
637
700
|
return;
|
|
638
701
|
}
|
package/src/ui/settings-ui.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
saveContinuousMode,
|
|
20
20
|
} from "./agent-mode-setting.js";
|
|
21
21
|
import type { RunRoute } from "./cancellable-operation.js";
|
|
22
|
+
import { showExcludedPaths } from "./excluded-paths-ui.js";
|
|
22
23
|
import { dispatchManagerResult } from "./manager-result-dispatcher.js";
|
|
23
24
|
import { boundedSettingsUI } from "./settings-frame.js";
|
|
24
25
|
import { showEditSyncSetupStorage, showSyncSetupManager } from "./setup/setup-actions.js";
|
|
@@ -88,6 +89,7 @@ export async function showSyncSettings(
|
|
|
88
89
|
| "debug"
|
|
89
90
|
| "on-switch"
|
|
90
91
|
| "include"
|
|
92
|
+
| "exclude"
|
|
91
93
|
| "remote-include"
|
|
92
94
|
| "storage-location"
|
|
93
95
|
| "setups"
|
|
@@ -114,11 +116,19 @@ export async function showSyncSettings(
|
|
|
114
116
|
currentValue: `${state.include.length} paths · Edit`,
|
|
115
117
|
action: "include",
|
|
116
118
|
},
|
|
119
|
+
{
|
|
120
|
+
id: "exclude",
|
|
121
|
+
label: "Excluded paths",
|
|
122
|
+
description:
|
|
123
|
+
"This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
|
|
124
|
+
currentValue: `${state.exclude?.length ?? 0} rules · Edit`,
|
|
125
|
+
action: "exclude",
|
|
126
|
+
},
|
|
117
127
|
{
|
|
118
128
|
id: "remoteInclude",
|
|
119
129
|
label: "Compare included paths",
|
|
120
130
|
description:
|
|
121
|
-
"This setup: compare
|
|
131
|
+
"This setup: compare include and exclude policies, not file contents. Review before saving both lists; no files transfer unless you explicitly Continue.",
|
|
122
132
|
currentValue: "Review",
|
|
123
133
|
action: "remote-include",
|
|
124
134
|
},
|
|
@@ -280,7 +290,7 @@ export async function showSyncSettings(
|
|
|
280
290
|
if (
|
|
281
291
|
!(await ctx.ui.confirm(
|
|
282
292
|
"Save content policy?",
|
|
283
|
-
"This explicitly upgrades settings to version 5; partial snapshots use version 3 and older clients must refuse them. Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.",
|
|
293
|
+
"This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them. Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.",
|
|
284
294
|
{ signal: mutationSignal },
|
|
285
295
|
))
|
|
286
296
|
)
|
|
@@ -298,7 +308,7 @@ export async function showSyncSettings(
|
|
|
298
308
|
throw new Error("Content policy changed during review.");
|
|
299
309
|
return {
|
|
300
310
|
...current,
|
|
301
|
-
version: 5,
|
|
311
|
+
version: current.version === 6 ? 6 : 5,
|
|
302
312
|
syncSetups: {
|
|
303
313
|
...current.syncSetups,
|
|
304
314
|
[setupName]: { ...setup, sync: { ...setup.sync, mergeContent, partialSync } },
|
|
@@ -354,7 +364,7 @@ export async function showSyncSettings(
|
|
|
354
364
|
if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
|
|
355
365
|
const confirmed = await ctx.ui.confirm(
|
|
356
366
|
"Save portable field policy?",
|
|
357
|
-
"This opts into settings/snapshot version 4/2;
|
|
367
|
+
"This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain 6/4. Older clients must refuse them. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.",
|
|
358
368
|
{ signal: mutationSignal },
|
|
359
369
|
);
|
|
360
370
|
validate();
|
|
@@ -367,7 +377,7 @@ export async function showSyncSettings(
|
|
|
367
377
|
throw new Error("Field policy changed while under review; reopen settings.");
|
|
368
378
|
return {
|
|
369
379
|
...current,
|
|
370
|
-
version: current.version
|
|
380
|
+
version: current.version >= 5 ? current.version : 4,
|
|
371
381
|
syncSetups: {
|
|
372
382
|
...current.syncSetups,
|
|
373
383
|
[setupName]: { ...setup, sync: { ...setup.sync, localFields: fields } },
|
|
@@ -545,6 +555,11 @@ export async function showSyncSettings(
|
|
|
545
555
|
await runRoute("files", editorSignal, undefined, setupName);
|
|
546
556
|
return editorSignal.aborted ? { kind: "rejected" } : { kind: "stay" };
|
|
547
557
|
},
|
|
558
|
+
exclude: async ({ signal: actionSignal }) => {
|
|
559
|
+
const editorSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
560
|
+
await showExcludedPaths(ctx, setupName, editorSignal);
|
|
561
|
+
return resumeSettings(editorSignal);
|
|
562
|
+
},
|
|
548
563
|
"remote-include": async ({ signal: actionSignal }) => {
|
|
549
564
|
const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
550
565
|
const { showRemoteSelectionReview } = await import("./remote-selection-ui.js");
|
|
@@ -40,7 +40,7 @@ async function showAddTarget(ctx: ExtensionCommandContext, signal?: AbortSignal)
|
|
|
40
40
|
let raw = await readLocalConfigObject();
|
|
41
41
|
if (signal?.aborted) return;
|
|
42
42
|
if (!raw) return void ctx.ui.notify("Set up the first sync setup before adding another.", "info");
|
|
43
|
-
if (raw.version !== 3 && raw.version !== 4 && raw.version !== 5) {
|
|
43
|
+
if (raw.version !== 3 && raw.version !== 4 && raw.version !== 5 && raw.version !== 6) {
|
|
44
44
|
ctx.ui.notify("Version 1 and version 2 settings are unsupported and are never migrated.", "error");
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
@@ -6,6 +6,7 @@ import type { AnySyncConfig } from "../../settings/settings-types.js";
|
|
|
6
6
|
import { ownRecord } from "../../settings/settings-validation.js";
|
|
7
7
|
import { useSyncSetup } from "../../sync/setup-switch.js";
|
|
8
8
|
import { errorMessage } from "../../sync/sync-errors.js";
|
|
9
|
+
import { syncSessionsSelected } from "../../sync/sync-policy.js";
|
|
9
10
|
import { automaticSyncSummary } from "../automatic-sync-summary.js";
|
|
10
11
|
import { type RunRoute, runCancellableOperation } from "../cancellable-operation.js";
|
|
11
12
|
import { dispatchManagerResult } from "../manager-result-dispatcher.js";
|
|
@@ -78,7 +79,7 @@ export async function showSetupSwitcher(
|
|
|
78
79
|
) {
|
|
79
80
|
const raw = await readLocalConfigObject();
|
|
80
81
|
if (signal?.aborted) return false;
|
|
81
|
-
if (raw?.version !== 3 && raw?.version !== 4 && raw?.version !== 5) {
|
|
82
|
+
if (raw?.version !== 3 && raw?.version !== 4 && raw?.version !== 5 && raw?.version !== 6) {
|
|
82
83
|
ctx.ui.notify("Add a second sync setup before switching setups.", "info");
|
|
83
84
|
return false;
|
|
84
85
|
}
|
|
@@ -127,7 +128,7 @@ export async function showSetupSwitcher(
|
|
|
127
128
|
`To: ${safeTerminalText(name)}`,
|
|
128
129
|
`Storage: ${backendStorageDescription(config)}`,
|
|
129
130
|
`Included content: ${config.include.length} paths`,
|
|
130
|
-
`Automatic sync: ${automaticSyncSummary(config.automatic)} · Sessions: ${config
|
|
131
|
+
`Automatic sync: ${automaticSyncSummary(config.automatic)} · Sessions: ${syncSessionsSelected(config) ? "On" : "Off"}`,
|
|
131
132
|
`Automatic transfer at startup: ${config.automaticTransfer ? "On — may upload, replace, or delete selected files; no reload" : "Off"}`,
|
|
132
133
|
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
133
134
|
`Continuous sync: ${config.continuous ? (config.agentMode ? "On (recurring requests and transfers)" : "Saved On; paused until Autonomous sync is enabled") : "Off"}`,
|
|
@@ -137,14 +137,14 @@ async function loadStorageMenuState(selectedName: string | undefined, signal?: A
|
|
|
137
137
|
const profile = selectedName ? ownRecord(profiles[selectedName]) : undefined;
|
|
138
138
|
if (!selectedName || !profile) {
|
|
139
139
|
return {
|
|
140
|
-
supportedVersion: raw?.version === 3 || raw?.version === 4 || raw?.version === 5,
|
|
140
|
+
supportedVersion: raw?.version === 3 || raw?.version === 4 || raw?.version === 5 || raw?.version === 6,
|
|
141
141
|
profiles,
|
|
142
142
|
selected: undefined,
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
const usedBy = referencingSetups(raw, selectedName);
|
|
146
146
|
return {
|
|
147
|
-
supportedVersion: raw?.version === 3 || raw?.version === 4 || raw?.version === 5,
|
|
147
|
+
supportedVersion: raw?.version === 3 || raw?.version === 4 || raw?.version === 5 || raw?.version === 6,
|
|
148
148
|
profiles,
|
|
149
149
|
selected: {
|
|
150
150
|
name: selectedName,
|
package/src/ui/sync-attention.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import type { EditorStatusWidgetState } from "@narumitw/pi-tui-kit/editor-status-widget";
|
|
3
4
|
import { syncCheckConfigFingerprint, syncConfigReviewFingerprint } from "../settings/config.js";
|
|
4
5
|
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
6
|
+
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
5
7
|
import type { StartupObservation } from "../sync/sync-inspection.js";
|
|
6
8
|
import { compareSyncInclude, type RemoteSelectionDecision, sameSyncInclude } from "../sync/sync-policy.js";
|
|
7
9
|
import { setSyncStatus } from "./sync-status.js";
|
|
@@ -21,7 +23,8 @@ export function syncAttentionMatchesConfig(attention: SyncAttentionState, config
|
|
|
21
23
|
return (
|
|
22
24
|
attention.decision.setupName === config.setupName &&
|
|
23
25
|
attention.decision.configIdentity === syncConfigReviewFingerprint(config) &&
|
|
24
|
-
sameSyncInclude(attention.decision.localInclude, config.include)
|
|
26
|
+
sameSyncInclude(attention.decision.localInclude, config.include) &&
|
|
27
|
+
sameSyncExclude(attention.decision.localExclude, config.exclude)
|
|
25
28
|
);
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -35,6 +38,7 @@ export interface SyncAttentionController {
|
|
|
35
38
|
markOffered(): boolean;
|
|
36
39
|
clear(ctx: ExtensionContext): void;
|
|
37
40
|
reset(ctx: ExtensionContext): void;
|
|
41
|
+
expand(): void;
|
|
38
42
|
publish(ctx: ExtensionContext, signal?: AbortSignal): Promise<void>;
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -42,6 +46,7 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
42
46
|
let state: SyncAttentionState | undefined;
|
|
43
47
|
let observation: StartupObservation | undefined;
|
|
44
48
|
let generation = 0;
|
|
49
|
+
let widgetState: EditorStatusWidgetState = { collapsed: false };
|
|
45
50
|
|
|
46
51
|
return {
|
|
47
52
|
observe(value) {
|
|
@@ -81,8 +86,12 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
81
86
|
generation++;
|
|
82
87
|
state = undefined;
|
|
83
88
|
observation = undefined;
|
|
89
|
+
widgetState = { collapsed: false };
|
|
84
90
|
clearAttentionPresentation(ctx);
|
|
85
91
|
},
|
|
92
|
+
expand() {
|
|
93
|
+
widgetState.collapsed = false;
|
|
94
|
+
},
|
|
86
95
|
async publish(ctx, signal) {
|
|
87
96
|
const currentGeneration = ++generation;
|
|
88
97
|
if (signal?.aborted || !ctx.hasUI) return;
|
|
@@ -100,10 +109,7 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
100
109
|
}
|
|
101
110
|
const presentation = state
|
|
102
111
|
? attentionPresentation(state.decision)
|
|
103
|
-
:
|
|
104
|
-
status: "sync ⇕",
|
|
105
|
-
lines: observationLines(observation as StartupObservation),
|
|
106
|
-
};
|
|
112
|
+
: observationPresentation(observation as StartupObservation);
|
|
107
113
|
if (ctx.mode !== "tui") {
|
|
108
114
|
ctx.ui.setWidget(WIDGET_KEY, undefined);
|
|
109
115
|
setSyncStatus(ctx, presentation.status, { activity: "review" });
|
|
@@ -116,11 +122,15 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
116
122
|
});
|
|
117
123
|
if (generation !== currentGeneration || signal?.aborted) return;
|
|
118
124
|
setSyncStatus(ctx, presentation.status, { activity: "review" });
|
|
125
|
+
const presentationState = widgetState;
|
|
119
126
|
ctx.ui.setWidget(
|
|
120
127
|
WIDGET_KEY,
|
|
121
128
|
(_tui, theme) =>
|
|
122
129
|
new EditorStatusWidget({
|
|
123
130
|
theme,
|
|
131
|
+
name: "Sync",
|
|
132
|
+
summary: "Needs review",
|
|
133
|
+
state: presentationState,
|
|
124
134
|
renderBody: (width) =>
|
|
125
135
|
presentation.lines.map((line, index) =>
|
|
126
136
|
width === 0 ? "" : truncateToWidth(theme.fg(index === 0 ? "warning" : "muted", line), width, "…"),
|
|
@@ -134,13 +144,39 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
134
144
|
function attentionPresentation(decision: RemoteSelectionDecision) {
|
|
135
145
|
const setupName = safeTerminalText(decision.setupName);
|
|
136
146
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
137
|
-
const difference =
|
|
138
|
-
comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0
|
|
139
|
-
? "Only list order differs"
|
|
140
|
-
: `Remote ${comparison.remoteOnly.length} · Device ${comparison.localOnly.length}`;
|
|
141
147
|
return {
|
|
142
148
|
status: "sync ⇕",
|
|
143
|
-
lines: [
|
|
149
|
+
lines: [
|
|
150
|
+
`Setup: ${setupName}`,
|
|
151
|
+
selectionDifference({
|
|
152
|
+
...comparison,
|
|
153
|
+
excludeChanged: !sameSyncExclude(decision.localExclude, decision.remoteExclude),
|
|
154
|
+
}),
|
|
155
|
+
"No transfer performed · Run /sync to review",
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function selectionDifference(comparison: {
|
|
161
|
+
remoteOnly: readonly string[];
|
|
162
|
+
localOnly: readonly string[];
|
|
163
|
+
excludeChanged?: boolean;
|
|
164
|
+
}) {
|
|
165
|
+
if (comparison.excludeChanged) return "Selection: excluded paths differ; review needed";
|
|
166
|
+
return comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0
|
|
167
|
+
? "Selection: only list order differs"
|
|
168
|
+
: `Selection: ${comparison.remoteOnly.length} remote-only · ${comparison.localOnly.length} device-only`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function observationPresentation(observation: StartupObservation) {
|
|
172
|
+
const selection = observation.inspection.selectionState;
|
|
173
|
+
return {
|
|
174
|
+
status: "sync ⇕",
|
|
175
|
+
lines: [
|
|
176
|
+
`Setup: ${safeTerminalText(observation.setupName)}`,
|
|
177
|
+
selection?.kind === "different" ? selectionDifference(selection) : observationSummary(observation),
|
|
178
|
+
"No transfer performed · Run /sync to review",
|
|
179
|
+
],
|
|
144
180
|
};
|
|
145
181
|
}
|
|
146
182
|
|