@narumitw/pi-sync 0.60.4 → 0.61.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +14 -6
  3. package/dist/chunks/chunk-2JHAN3ZO.ts +139 -0
  4. package/dist/chunks/chunk-2JHAN3ZO.ts.map +7 -0
  5. package/dist/chunks/chunk-2ZGV5KNC.ts +274 -0
  6. package/dist/chunks/chunk-2ZGV5KNC.ts.map +7 -0
  7. package/dist/chunks/{chunk-LAXTCSX4.ts → chunk-4KTJLJSJ.ts} +117 -132
  8. package/dist/chunks/chunk-4KTJLJSJ.ts.map +7 -0
  9. package/dist/chunks/chunk-4SR3ZYHA.ts +14 -0
  10. package/dist/chunks/chunk-4SR3ZYHA.ts.map +7 -0
  11. package/dist/chunks/{chunk-VQRDL3SY.ts → chunk-E3YLRLJM.ts} +155 -27
  12. package/dist/chunks/chunk-E3YLRLJM.ts.map +7 -0
  13. package/dist/chunks/{chunk-KPWZNMKM.ts → chunk-ECYCNZOE.ts} +1 -5
  14. package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
  15. package/dist/chunks/{chunk-IGDI5CIH.ts → chunk-EMVZL4PH.ts} +2 -2
  16. package/dist/chunks/{chunk-OVCP2SOB.ts → chunk-H7VOTY5N.ts} +21 -8
  17. package/dist/chunks/chunk-H7VOTY5N.ts.map +7 -0
  18. package/dist/chunks/{chunk-SE7HHBKH.ts → chunk-JVFCVPPD.ts} +105 -51
  19. package/dist/chunks/chunk-JVFCVPPD.ts.map +7 -0
  20. package/dist/chunks/{chunk-MCUZFUHY.ts → chunk-PJMM75W5.ts} +6 -6
  21. package/dist/chunks/{chunk-RJZIKZI3.ts → chunk-S7F4FOAS.ts} +11 -6
  22. package/dist/chunks/chunk-S7F4FOAS.ts.map +7 -0
  23. package/dist/chunks/{chunk-6W2SNZ5P.ts → chunk-YQSFJLJ3.ts} +6 -2
  24. package/dist/chunks/{chunk-6W2SNZ5P.ts.map → chunk-YQSFJLJ3.ts.map} +3 -3
  25. package/dist/chunks/{chunk-V4AMI3VL.ts → chunk-ZVGRZD4C.ts} +9 -1
  26. package/dist/chunks/chunk-ZVGRZD4C.ts.map +7 -0
  27. package/dist/chunks/{command-handler-TMH4US44.ts → command-handler-K4XJOGYC.ts} +41 -37
  28. package/dist/chunks/{command-handler-TMH4US44.ts.map → command-handler-K4XJOGYC.ts.map} +2 -2
  29. package/dist/chunks/{conflict-review-QGUCODDH.ts → conflict-review-IGKY2TOJ.ts} +4 -4
  30. package/dist/chunks/{file-selection-DD6X4J2K.ts → file-selection-MGGVOKM7.ts} +26 -13
  31. package/dist/chunks/file-selection-MGGVOKM7.ts.map +7 -0
  32. package/dist/chunks/{manager-result-dispatcher-YVVD44QD.ts → manager-result-dispatcher-4VJVDEUD.ts} +8 -7
  33. package/dist/chunks/{manager-ui-Q54OHOPR.ts → manager-ui-KYQ5AZJS.ts} +134 -203
  34. package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +7 -0
  35. package/dist/chunks/{remote-selection-ui-ODSUHX5N.ts → remote-selection-ui-W3KOZM3W.ts} +7 -6
  36. package/dist/chunks/{setup-switch-SPZE7HIQ.ts → setup-switch-D6K6PBPC.ts} +3 -3
  37. package/dist/chunks/{setup-wizard-5JYKAEIT.ts → setup-wizard-4DYUDHJR.ts} +13 -11
  38. package/dist/chunks/setup-wizard-4DYUDHJR.ts.map +7 -0
  39. package/dist/chunks/{sync-inspection-ECUTWISE.ts → sync-inspection-J3CRBORL.ts} +6 -6
  40. package/dist/chunks/{sync-operations-REXODWZB.ts → sync-operations-BVWYYKH3.ts} +4 -4
  41. package/dist/index.ts +28 -24
  42. package/dist/index.ts.map +2 -2
  43. package/docs/daemon-migration.md +6 -0
  44. package/package.json +4 -4
  45. package/skills/configure-pi-sync/references/configuration.md +59 -32
  46. package/src/commands/command-execution.ts +7 -1
  47. package/src/daemon/pi-client.ts +79 -22
  48. package/src/daemon/queue-release-ui.ts +88 -0
  49. package/src/sync/sync-policy.ts +5 -0
  50. package/src/sync-extension.ts +6 -2
  51. package/src/ui/agent-mode-setting.ts +9 -1
  52. package/src/ui/excluded-paths-ui.ts +154 -2
  53. package/src/ui/file-selection.ts +12 -7
  54. package/src/ui/manager-state.ts +13 -8
  55. package/src/ui/remote-selection-ui.ts +120 -27
  56. package/src/ui/settings-frame.ts +2 -8
  57. package/src/ui/settings-ui.ts +51 -26
  58. package/src/ui/setup/directory-rules.ts +81 -0
  59. package/src/ui/setup/git-ui.ts +14 -24
  60. package/src/ui/setup/s3-ui.ts +13 -26
  61. package/src/ui/setup/setup-actions.ts +0 -4
  62. package/src/ui/setup/setup-prompts.ts +99 -17
  63. package/src/ui/setup/setup-switcher.ts +4 -2
  64. package/src/ui/setup/setup-wizard.ts +5 -4
  65. package/src/ui/setup/webdav-ui.ts +13 -27
  66. package/src/ui/storage-connections-ui.ts +2 -2
  67. package/src/ui/sync-attention.ts +8 -3
  68. package/src/ui/sync-format.ts +8 -1
  69. package/src/ui/sync-setups-ui.ts +5 -3
  70. package/src/ui/sync-status.ts +27 -7
  71. package/dist/chunks/chunk-KPWZNMKM.ts.map +0 -7
  72. package/dist/chunks/chunk-LAXTCSX4.ts.map +0 -7
  73. package/dist/chunks/chunk-OVCP2SOB.ts.map +0 -7
  74. package/dist/chunks/chunk-RJZIKZI3.ts.map +0 -7
  75. package/dist/chunks/chunk-SE7HHBKH.ts.map +0 -7
  76. package/dist/chunks/chunk-V4AMI3VL.ts.map +0 -7
  77. package/dist/chunks/chunk-VQRDL3SY.ts.map +0 -7
  78. package/dist/chunks/file-selection-DD6X4J2K.ts.map +0 -7
  79. package/dist/chunks/manager-ui-Q54OHOPR.ts.map +0 -7
  80. package/dist/chunks/setup-wizard-5JYKAEIT.ts.map +0 -7
  81. /package/dist/chunks/{chunk-IGDI5CIH.ts.map → chunk-EMVZL4PH.ts.map} +0 -0
  82. /package/dist/chunks/{chunk-MCUZFUHY.ts.map → chunk-PJMM75W5.ts.map} +0 -0
  83. /package/dist/chunks/{conflict-review-QGUCODDH.ts.map → conflict-review-IGKY2TOJ.ts.map} +0 -0
  84. /package/dist/chunks/{manager-result-dispatcher-YVVD44QD.ts.map → manager-result-dispatcher-4VJVDEUD.ts.map} +0 -0
  85. /package/dist/chunks/{remote-selection-ui-ODSUHX5N.ts.map → remote-selection-ui-W3KOZM3W.ts.map} +0 -0
  86. /package/dist/chunks/{setup-switch-SPZE7HIQ.ts.map → setup-switch-D6K6PBPC.ts.map} +0 -0
  87. /package/dist/chunks/{sync-inspection-ECUTWISE.ts.map → sync-inspection-J3CRBORL.ts.map} +0 -0
  88. /package/dist/chunks/{sync-operations-REXODWZB.ts.map → sync-operations-BVWYYKH3.ts.map} +0 -0
@@ -11,13 +11,7 @@ import {
11
11
  chooseInitialRemoteLocation,
12
12
  promptAvailableSetupStorage,
13
13
  } from "./setup-location-ui.js";
14
- import {
15
- chooseAutomaticSync,
16
- chooseSessions,
17
- chooseSetupContent,
18
- includedContentLines,
19
- readSetupConnection,
20
- } from "./setup-prompts.js";
14
+ import { chooseSetupPolicy, finishSetup, readSetupConnection } from "./setup-prompts.js";
21
15
  import { saveReviewedDraft } from "./setup-review.js";
22
16
  import { requiredInput, requiredValueInput } from "./text-input.js";
23
17
 
@@ -51,12 +45,8 @@ export async function showS3Setup(
51
45
  if (!location) return false;
52
46
  const credentials = await chooseS3Credentials(ctx, signal);
53
47
  if (!credentials) return false;
54
- const include = await chooseSetupContent(ctx, signal);
55
- if (!include) return false;
56
- const automatic = await chooseAutomaticSync(ctx, signal);
57
- if (automatic === undefined) return false;
58
- const sessions = await chooseSessions(ctx, signal);
59
- if (sessions === undefined) return false;
48
+ const policy = await chooseSetupPolicy(ctx, signal, { legacySessions: true });
49
+ if (signal?.aborted || !policy) return false;
60
50
  const saved = await saveReviewedDraft(
61
51
  ctx,
62
52
  "Review sync setup",
@@ -67,8 +57,8 @@ export async function showS3Setup(
67
57
  `Region: ${safeTerminalText(region)}`,
68
58
  `Bucket: ${safeTerminalText(location.bucket)}`,
69
59
  `Storage location: ${safeTerminalText(location.path)}`,
70
- ...includedContentLines(include, sessions),
71
- `Automatic sync: ${automaticSyncSummary(automatic)}`,
60
+ ...policy.lines,
61
+ `Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
72
62
  `Credentials: ${credentials.summary}`,
73
63
  "The bucket must already exist. Saving does not contact remote storage or start syncing.",
74
64
  ],
@@ -93,7 +83,7 @@ export async function showS3Setup(
93
83
  bucket: location.bucket,
94
84
  path: location.path,
95
85
  },
96
- sync: { include: [...include, ...(sessions ? ["sessions"] : [])], automatic },
86
+ sync: policy.sync,
97
87
  },
98
88
  },
99
89
  saveSignal,
@@ -102,8 +92,7 @@ export async function showS3Setup(
102
92
  );
103
93
  if (!saved || signal?.aborted) return false;
104
94
  await refreshTargetCompletions();
105
- if (!signal?.aborted)
106
- ctx.ui.notify(`Sync setup “${safeTerminalText(targetName)}” saved. Choose Sync now to start.`, "info");
95
+ await finishSetup(ctx, targetName, `Sync setup “${safeTerminalText(targetName)}” saved.`, policy.join, signal);
107
96
  return true;
108
97
  }
109
98
 
@@ -118,10 +107,8 @@ export async function showAddS3Target(
118
107
  if (!location) return;
119
108
  const storage = await promptAvailableSetupStorage(ctx, { connection: profile, ...location }, signal);
120
109
  if (!storage) return;
121
- const include = await chooseSetupContent(ctx, signal);
122
- if (!include) return;
123
- const automatic = await chooseAutomaticSync(ctx, signal);
124
- if (automatic === undefined) return;
110
+ const policy = await chooseSetupPolicy(ctx, signal);
111
+ if (signal?.aborted || !policy) return;
125
112
  const connection = await readSetupConnection(profile, signal);
126
113
  if (connection.type !== "s3") throw new Error("Storage connection changed; reopen setup.");
127
114
  const saved = await saveReviewedDraft(
@@ -133,18 +120,18 @@ export async function showAddS3Target(
133
120
  `Endpoint: ${safeTerminalText(connection.endpoint)}`,
134
121
  `Bucket: ${safeTerminalText(storage.bucket)}`,
135
122
  `Storage location: ${safeTerminalText(storage.path)}`,
136
- ...includedContentLines(include),
137
- `Automatic sync: ${automaticSyncSummary(automatic)}`,
123
+ ...policy.lines,
124
+ `Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
138
125
  "Only the current setup is checked at startup. Shutdown can push selected content when sessions are included.",
139
126
  "The bucket must already exist. Adding this setup does not sync or modify remote data.",
140
127
  ],
141
128
  "Add sync setup",
142
- (saveSignal) => addSyncSetup(name, { storage, sync: { include, automatic } }, saveSignal, connection),
129
+ (saveSignal) => addSyncSetup(name, { storage, sync: policy.sync }, saveSignal, connection),
143
130
  signal,
144
131
  );
145
132
  if (!saved || signal?.aborted) return;
146
133
  await refreshTargetCompletions();
147
- if (!signal?.aborted) ctx.ui.notify(`Added sync setup “${safeTerminalText(name)}”.`, "info");
134
+ await finishSetup(ctx, name, `Added sync setup “${safeTerminalText(name)}”.`, policy.join, signal);
148
135
  }
149
136
 
150
137
  export async function showEditS3Target(ctx: ExtensionCommandContext, partial: PartialConfig, signal?: AbortSignal) {
@@ -40,10 +40,6 @@ 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 && raw.version !== 6) {
44
- ctx.ui.notify("Version 1 and version 2 settings are unsupported and are never migrated.", "error");
45
- return;
46
- }
47
43
  let profiles = ownRecord(raw.storageConnections) ?? {};
48
44
  const name = await promptResourceName(ctx, "sync setup", "work", signal);
49
45
  if (!name) return;
@@ -1,14 +1,20 @@
1
1
  import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
2
  import { readLocalConfigObject } from "../../settings/settings-store.js";
3
+ import type { SyncPolicySettings } from "../../settings/settings-types.js";
3
4
  import { validateConfigName } from "../../settings/settings-validation.js";
4
5
  import { DEFAULT_SYNC_INCLUDE } from "../../sync/sync-policy.js";
5
6
  import { AUTOMATIC_SYNC_DESCRIPTION } from "../sync-behavior.js";
6
7
  import { safeTerminalText } from "../terminal-text.js";
8
+ import {
9
+ acknowledgeSessions,
10
+ directoryScopeLines,
11
+ promptDirectoryRules,
12
+ starterDirectoryRules,
13
+ } from "./directory-rules.js";
14
+ import { promptTextInput } from "./text-input.js";
7
15
 
8
16
  export { AUTOMATIC_SYNC_DESCRIPTION } from "../sync-behavior.js";
9
17
 
10
- import { promptTextInput } from "./text-input.js";
11
-
12
18
  export async function readSetupConnection(name: string, signal?: AbortSignal) {
13
19
  const connection = (await readLocalConfigObject())?.storageConnections[name];
14
20
  signal?.throwIfAborted();
@@ -16,15 +22,97 @@ export async function readSetupConnection(name: string, signal?: AbortSignal) {
16
22
  return connection;
17
23
  }
18
24
 
19
- export async function chooseSetupContent(ctx: ExtensionCommandContext, signal?: AbortSignal) {
25
+ export async function chooseSetupPolicy(
26
+ ctx: ExtensionCommandContext,
27
+ signal?: AbortSignal,
28
+ { legacySessions = false } = {},
29
+ ): Promise<{ sync: SyncPolicySettings; lines: string[]; join: boolean } | undefined> {
20
30
  const choice = await ctx.ui.select(
21
- "Choose included content\n\nRecommended: Pi settings, instructions, skills, prompts, themes, and extensions.\nMinimal: settings.json and AGENTS.md.\nReview the exact paths before saving.",
22
- ["Recommended Pi settings", "Minimal settings", "Cancel"],
31
+ "Choose synced content\n\nAgent directory (recommended): sync all eligible files, including custom paths, except sessions, bin, and npm.\nJoining existing storage? Review its policy after saving. It will not be adopted automatically.\nLegacy mode: use a fixed list of included paths.",
32
+ [
33
+ "Agent directory (recommended)",
34
+ "Agent directory · edit starter rules",
35
+ "Join an existing remote",
36
+ "Recommended Pi settings",
37
+ "Minimal settings",
38
+ "Cancel",
39
+ ],
23
40
  { signal },
24
41
  );
25
- signal?.throwIfAborted();
26
- if (!choice || choice === "Cancel") return undefined;
27
- return choice === "Minimal settings" ? ["settings.json", "AGENTS.md"] : [...DEFAULT_SYNC_INCLUDE];
42
+ if (signal?.aborted || !choice || choice === "Cancel") return undefined;
43
+ const join = choice === "Join an existing remote";
44
+ if (
45
+ !join &&
46
+ choice !== "Agent directory (recommended)" &&
47
+ choice !== "Agent directory · edit starter rules" &&
48
+ choice !== "Recommended Pi settings" &&
49
+ choice !== "Minimal settings"
50
+ )
51
+ return undefined;
52
+ const joinScope = join
53
+ ? await ctx.ui.select(
54
+ "Choose the existing remote's scope\n\nUse Selected paths for an older setup with an include list. These choices do not change the remote's scope.",
55
+ ["Pi agent directory", "Selected paths (legacy)", "Cancel"],
56
+ { signal },
57
+ )
58
+ : undefined;
59
+ if (signal?.aborted || (join && joinScope !== "Pi agent directory" && joinScope !== "Selected paths (legacy)"))
60
+ return undefined;
61
+ const legacy =
62
+ choice === "Recommended Pi settings" || choice === "Minimal settings" || joinScope === "Selected paths (legacy)";
63
+ const draft = starterDirectoryRules();
64
+ const editRules = choice === "Agent directory · edit starter rules";
65
+ if (editRules) {
66
+ const exclude = await promptDirectoryRules(ctx, "exclude", draft.exclude, signal);
67
+ if (signal?.aborted || !exclude) return undefined;
68
+ draft.exclude = exclude;
69
+ const reinclude = await promptDirectoryRules(ctx, "reinclude", draft.reinclude, signal);
70
+ if (signal?.aborted || !reinclude) return undefined;
71
+ draft.reinclude = reinclude;
72
+ }
73
+ const automatic = join ? false : await chooseAutomaticSync(ctx, signal);
74
+ if (signal?.aborted || automatic === undefined) return undefined;
75
+ const sessions = join || (legacy && !legacySessions) ? false : await chooseSessions(ctx, signal);
76
+ if (signal?.aborted || sessions === undefined) return undefined;
77
+ const remoteWarning = join
78
+ ? "After saving, compare the remote policy. Automatic sync and sessions start Off. No policy is adopted without your review."
79
+ : "If this location already has sync data, compare its policy in Settings before transferring. A mismatch blocks sync.";
80
+ if (legacy) {
81
+ const include = choice === "Minimal settings" ? ["settings.json", "AGENTS.md"] : [...DEFAULT_SYNC_INCLUDE];
82
+ return {
83
+ sync: { include: [...include, ...(sessions ? ["sessions"] : [])], automatic },
84
+ lines: [...includedContentLines(include, sessions), remoteWarning],
85
+ join,
86
+ };
87
+ }
88
+ draft.sessions = sessions;
89
+ if (sessions && !editRules) draft.exclude = draft.exclude.filter((rule) => rule !== "sessions");
90
+ return {
91
+ sync: {
92
+ scope: "agent-directory",
93
+ exclude: draft.exclude,
94
+ ...(draft.reinclude.length ? { reinclude: draft.reinclude } : {}),
95
+ sessions: draft.sessions,
96
+ automatic,
97
+ },
98
+ lines: [...directoryScopeLines(draft), remoteWarning],
99
+ join,
100
+ };
101
+ }
102
+
103
+ export async function finishSetup(
104
+ ctx: ExtensionCommandContext,
105
+ name: string,
106
+ message: string,
107
+ join: boolean,
108
+ signal?: AbortSignal,
109
+ ) {
110
+ if (signal?.aborted) return;
111
+ ctx.ui.notify(message, "info");
112
+ if (!join) return;
113
+ const { showRemoteSelectionReview } = await import("../remote-selection-ui.js");
114
+ if (signal?.aborted) return;
115
+ await showRemoteSelectionReview(ctx, name, signal, undefined, { origin: "settings" });
28
116
  }
29
117
 
30
118
  export async function chooseAutomaticSync(ctx: ExtensionCommandContext, signal?: AbortSignal) {
@@ -37,7 +125,7 @@ export async function chooseAutomaticSync(ctx: ExtensionCommandContext, signal?:
37
125
  return !choice || choice === "Cancel" ? undefined : choice === "Enable automatic sync";
38
126
  }
39
127
 
40
- export async function chooseSessions(ctx: ExtensionCommandContext, signal?: AbortSignal) {
128
+ async function chooseSessions(ctx: ExtensionCommandContext, signal?: AbortSignal) {
41
129
  const choice = await ctx.ui.select(
42
130
  "Session conversations\n\nSessions can contain prompts, tool output, paths, screenshots, and secrets.",
43
131
  ["Keep sessions off (recommended)", "Include session conversations", "Cancel"],
@@ -46,16 +134,10 @@ export async function chooseSessions(ctx: ExtensionCommandContext, signal?: Abor
46
134
  signal?.throwIfAborted();
47
135
  if (!choice || choice === "Cancel") return undefined;
48
136
  if (choice !== "Include session conversations") return false;
49
- const confirmed = await ctx.ui.confirm(
50
- "Include session conversations?",
51
- "I understand that session JSONL can contain prompts, tool output, paths, screenshots, and secrets.",
52
- { signal },
53
- );
54
- signal?.throwIfAborted();
55
- return confirmed ? true : undefined;
137
+ return (await acknowledgeSessions(ctx, signal)) ? true : undefined;
56
138
  }
57
139
 
58
- export function includedContentLines(include: readonly string[], sessions = false) {
140
+ function includedContentLines(include: readonly string[], sessions = false) {
59
141
  const paths = [...include, ...(sessions && !include.includes("sessions") ? ["sessions"] : [])];
60
142
  return [
61
143
  `Included content: ${paths.length} paths`,
@@ -79,7 +79,7 @@ export async function showSetupSwitcher(
79
79
  ) {
80
80
  const raw = await readLocalConfigObject();
81
81
  if (signal?.aborted) return false;
82
- if (raw?.version !== 3 && raw?.version !== 4 && raw?.version !== 5 && raw?.version !== 6) {
82
+ if (!raw) {
83
83
  ctx.ui.notify("Add a second sync setup before switching setups.", "info");
84
84
  return false;
85
85
  }
@@ -127,7 +127,9 @@ export async function showSetupSwitcher(
127
127
  `From: ${safeTerminalText(active ?? "none")}`,
128
128
  `To: ${safeTerminalText(name)}`,
129
129
  `Storage: ${backendStorageDescription(config)}`,
130
- `Included content: ${config.include.length} paths`,
130
+ config.scope === "agent-directory"
131
+ ? `Scope: Pi agent directory · ${config.exclude?.length ?? 0} excluded and ${config.reinclude?.length ?? 0} re-included rules`
132
+ : `Included content: ${config.include.length} paths`,
131
133
  `Automatic sync: ${automaticSyncSummary(config.automatic)} · Sessions: ${syncSessionsSelected(config) ? "On" : "Off"}`,
132
134
  `Automatic transfer at startup: ${config.automaticTransfer ? "On — may upload, replace, or delete selected files; no reload" : "Off"}`,
133
135
  `Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
@@ -9,10 +9,11 @@ import { showWebDavSetup } from "./webdav-ui.js";
9
9
 
10
10
  export async function showSetupWizard(ctx: ExtensionCommandContext, signal?: AbortSignal) {
11
11
  if (ctx.mode !== "tui") {
12
- ctx.ui.notify(
13
- `Guided sync setup requires TUI mode for masked credential input. Create version 3 settings in ${safeTerminalText(localConfigPath())}.`,
14
- "warning",
15
- );
12
+ if (ctx.hasUI)
13
+ ctx.ui.notify(
14
+ `Guided sync setup requires TUI mode for masked credential input. Create settings in ${safeTerminalText(localConfigPath())} (version 7 for agent-directory scope).`,
15
+ "warning",
16
+ );
16
17
  return false;
17
18
  }
18
19
  const preset = await ctx.ui.select(
@@ -16,14 +16,7 @@ import { automaticSyncSummary } from "../automatic-sync-summary.js";
16
16
  import { promptSecret } from "../secret-input.js";
17
17
  import { safeTerminalText as safe } from "../terminal-text.js";
18
18
  import { promptAvailableSetupStorage } from "./setup-location-ui.js";
19
- import {
20
- chooseAutomaticSync,
21
- chooseSessions,
22
- chooseSetupContent,
23
- includedContentLines,
24
- promptResourceName,
25
- readSetupConnection,
26
- } from "./setup-prompts.js";
19
+ import { chooseSetupPolicy, finishSetup, promptResourceName, readSetupConnection } from "./setup-prompts.js";
27
20
  import { saveReviewedDraft } from "./setup-review.js";
28
21
  import { promptTextInput } from "./text-input.js";
29
22
 
@@ -37,12 +30,8 @@ export async function showWebDavSetup(ctx: ExtensionCommandContext, targetName:
37
30
  if (password === undefined) return false;
38
31
  const remotePath = await chooseDestination(ctx, signal);
39
32
  if (!remotePath) return false;
40
- const include = await chooseSetupContent(ctx, signal);
41
- if (!include) return false;
42
- const automatic = await chooseAutomaticSync(ctx, signal);
43
- if (automatic === undefined) return false;
44
- const sessions = await chooseSessions(ctx, signal);
45
- if (sessions === undefined) return false;
33
+ const policy = await chooseSetupPolicy(ctx, signal, { legacySessions: true });
34
+ if (signal?.aborted || !policy) return false;
46
35
  const saved = await saveReviewedDraft(
47
36
  ctx,
48
37
  "Review WebDAV setup",
@@ -52,8 +41,8 @@ export async function showWebDavSetup(ctx: ExtensionCommandContext, targetName:
52
41
  `URL: ${safe(url)}`,
53
42
  `Storage location: ${safe(remotePath)}`,
54
43
  "Username and password: stored privately (values hidden)",
55
- ...includedContentLines(include, sessions),
56
- `Automatic sync: ${automaticSyncSummary(automatic)}`,
44
+ ...policy.lines,
45
+ `Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
57
46
  "Check setup tests whether this server can safely save sync updates using a temporary probe.",
58
47
  "Saving does not contact remote storage or start syncing.",
59
48
  ],
@@ -66,15 +55,14 @@ export async function showWebDavSetup(ctx: ExtensionCommandContext, targetName:
66
55
  connection: { type: "webdav", url, credentials: { username, password } },
67
56
  setup: {
68
57
  storage: { connection: targetName, path: remotePath },
69
- sync: { include: [...include, ...(sessions ? ["sessions"] : [])], automatic },
58
+ sync: policy.sync,
70
59
  },
71
60
  },
72
61
  saveSignal,
73
62
  ),
74
63
  signal,
75
64
  );
76
- if (saved && !signal?.aborted)
77
- ctx.ui.notify(`Sync setup “${safe(targetName)}” saved. Choose Sync now to start.`, "info");
65
+ if (saved) await finishSetup(ctx, targetName, `Sync setup “${safe(targetName)}” saved.`, policy.join, signal);
78
66
  return saved;
79
67
  }
80
68
 
@@ -88,10 +76,8 @@ export async function showAddWebDavTarget(
88
76
  if (!remotePath) return false;
89
77
  const storage = await promptAvailableSetupStorage(ctx, { connection: profile, path: remotePath }, signal);
90
78
  if (!storage) return false;
91
- const include = await chooseSetupContent(ctx, signal);
92
- if (!include) return false;
93
- const automatic = await chooseAutomaticSync(ctx, signal);
94
- if (automatic === undefined) return false;
79
+ const policy = await chooseSetupPolicy(ctx, signal);
80
+ if (signal?.aborted || !policy) return false;
95
81
  const connection = await readSetupConnection(profile, signal);
96
82
  if (connection.type !== "webdav") throw new Error("Storage connection changed; reopen setup.");
97
83
  const saved = await saveReviewedDraft(
@@ -102,15 +88,15 @@ export async function showAddWebDavTarget(
102
88
  `Storage connection: ${safe(profile)}`,
103
89
  `URL: ${safe(connection.url)}`,
104
90
  `Storage location: ${safe(storage.path)}`,
105
- ...includedContentLines(include),
106
- `Automatic sync: ${automaticSyncSummary(automatic)}`,
91
+ ...policy.lines,
92
+ `Automatic sync: ${automaticSyncSummary(policy.sync.automatic)}`,
107
93
  "Adding this setup does not sync or modify remote data.",
108
94
  ],
109
95
  "Add sync setup",
110
- (saveSignal) => addSyncSetup(name, { storage, sync: { include, automatic } }, saveSignal, connection),
96
+ (saveSignal) => addSyncSetup(name, { storage, sync: policy.sync }, saveSignal, connection),
111
97
  signal,
112
98
  );
113
- if (saved && !signal?.aborted) ctx.ui.notify(`Added sync setup “${safe(name)}”.`, "info");
99
+ if (saved) await finishSetup(ctx, name, `Added sync setup “${safe(name)}”.`, policy.join, signal);
114
100
  return saved;
115
101
  }
116
102
 
@@ -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 || raw?.version === 6,
140
+ supportedVersion: raw !== undefined,
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 || raw?.version === 6,
147
+ supportedVersion: raw !== undefined,
148
148
  profiles,
149
149
  selected: {
150
150
  name: selectedName,
@@ -5,7 +5,7 @@ import { syncCheckConfigFingerprint, syncConfigReviewFingerprint } from "../sett
5
5
  import type { AnySyncConfig } from "../settings/settings-types.js";
6
6
  import { sameSyncExclude } from "../sync/exclude-policy.js";
7
7
  import type { StartupObservation } from "../sync/sync-inspection.js";
8
- import { type RemoteSelectionDecision, sameSyncInclude } from "../sync/sync-policy.js";
8
+ import { type RemoteSelectionDecision, sameSyncInclude, syncDirectoryPolicyKey } from "../sync/sync-policy.js";
9
9
  import { setSyncStatus } from "./sync-status.js";
10
10
  import { safeTerminalText } from "./terminal-text.js";
11
11
 
@@ -24,7 +24,13 @@ export function syncAttentionMatchesConfig(attention: SyncAttentionState, config
24
24
  attention.decision.setupName === config.setupName &&
25
25
  attention.decision.configIdentity === syncConfigReviewFingerprint(config) &&
26
26
  sameSyncInclude(attention.decision.localInclude, config.include) &&
27
- sameSyncExclude(attention.decision.localExclude, config.exclude)
27
+ sameSyncExclude(attention.decision.localExclude, config.exclude) &&
28
+ syncDirectoryPolicyKey(config) ===
29
+ syncDirectoryPolicyKey({
30
+ include: attention.decision.localInclude,
31
+ exclude: attention.decision.localExclude,
32
+ ...attention.decision.localDirectory,
33
+ })
28
34
  );
29
35
  }
30
36
 
@@ -165,7 +171,6 @@ export function classifyObservation(observation: StartupObservation): Observatio
165
171
  const result = observation.inspection;
166
172
  // Sync now exits before reading remote content when nothing is selected.
167
173
  if (result.emptyInclude) return "guidance";
168
- // Ordering is part of the existing transfer policy, not merely display order.
169
174
  if (result.selectionState?.kind === "different") return "review";
170
175
  if (result.firstSync) return result.head ? "review" : "guidance";
171
176
  if (!result.head || (result.localChanged && result.remoteChanged)) return "review";
@@ -57,7 +57,7 @@ export function formatPushSummary(
57
57
  ...excludedPolicyLines(config),
58
58
  head ? `Remote latest: ${safeTerminalText(head.snapshotId)}` : "Remote latest: empty",
59
59
  "Publication effect: the backend's active head will reference the new immutable snapshot. Removed paths leave the active snapshot; retained history is not erased.",
60
- ...(remote && inspectRemoteSelection(config.include, remote, config.exclude).kind === "different"
60
+ ...(remote && inspectRemoteSelection(config.include, remote, config.exclude, config).kind === "different"
61
61
  ? ["Included-content policy effect: replace the differing remote selection with this setup's local selection."]
62
62
  : []),
63
63
  formatPublicationPreview(remote, upload),
@@ -70,6 +70,13 @@ export function formatPushSummary(
70
70
  }
71
71
 
72
72
  function excludedPolicyLines(config: CommonSyncConfig) {
73
+ if (config.scope)
74
+ return [
75
+ "Sync scope: all eligible files in the Pi agent directory.",
76
+ `Excluded paths: ${config.exclude?.map(safeTerminalText).join(", ") || "none"}`,
77
+ `Re-included paths: ${config.reinclude?.map(safeTerminalText).join(", ") || "none"}`,
78
+ "Credentials and project trust stay local. Excluded paths are omitted from new publications, not erased from history.",
79
+ ];
73
80
  return config.exclude === undefined
74
81
  ? []
75
82
  : [
@@ -5,7 +5,7 @@ import { readLocalConfigObject } from "../settings/settings-store.js";
5
5
  import { ownRecord } from "../settings/settings-validation.js";
6
6
  import { throwIfAborted } from "../sync/signals.js";
7
7
  import { syncErrorGuidance } from "../sync/sync-error-guidance.js";
8
- import { syncIncludeSelection } from "../sync/sync-policy.js";
8
+ import { syncIncludeSelection, syncSessionsSelected } from "../sync/sync-policy.js";
9
9
  import { safeTerminalText } from "./terminal-text.js";
10
10
 
11
11
  export async function countValidSyncSetups(setups: Record<string, unknown> | undefined, signal?: AbortSignal) {
@@ -189,8 +189,10 @@ async function loadSetupMenuState(selectedName: string | undefined, signal?: Abo
189
189
  `Storage connection: ${safeTerminalText(config.connectionName)}`,
190
190
  `Endpoint: ${storageEndpoint(config)}`,
191
191
  `Storage location: ${storageLocation(config)}`,
192
- `Included content: ${selection.builtIns.length} built-in groups · ${selection.custom.length} extra paths`,
193
- `Sessions: ${selection.sessions ? "On — privacy-sensitive" : "Off"}`,
192
+ config.scope
193
+ ? `Sync scope: Pi agent directory · ${config.exclude?.length ?? 0} exclusions · ${config.reinclude?.length ?? 0} exceptions`
194
+ : `Included content: ${selection.builtIns.length} built-in groups · ${selection.custom.length} extra paths`,
195
+ `Sessions: ${syncSessionsSelected(config) ? "On — privacy-sensitive" : "Off"}`,
194
196
  `Automatic sync: ${config.automatic ? "On" : "Off"}`,
195
197
  `Automatic transfer at startup: ${config.automaticTransfer ? "On — may upload, replace, or delete selected files; no reload" : "Off"}`,
196
198
  `Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
@@ -53,6 +53,7 @@ const enabledBySession = new WeakMap<ExtensionContext["sessionManager"], boolean
53
53
  const publishersBySession = new WeakMap<ExtensionContext["sessionManager"], StatusBinding>();
54
54
  const statusesBySession = new WeakMap<ExtensionContext["sessionManager"], StatusValue>();
55
55
  const connectionStatusBySession = new WeakMap<ExtensionContext["sessionManager"], StatusValue>();
56
+ const recoveryStatusBySession = new WeakMap<ExtensionContext["sessionManager"], StatusValue>();
56
57
 
57
58
  interface StatusValue {
58
59
  value: string;
@@ -145,6 +146,7 @@ export function createSyncStatusPublisher(events: ExtensionAPI["events"] | undef
145
146
  publishersBySession.delete(sessionManager);
146
147
  statusesBySession.delete(sessionManager);
147
148
  connectionStatusBySession.delete(sessionManager);
149
+ recoveryStatusBySession.delete(sessionManager);
148
150
  current = undefined;
149
151
  }
150
152
  // Retire before optional callbacks; withdrawal observers cannot revive first-use binding.
@@ -223,6 +225,7 @@ export function configureSyncStatus(ctx: SyncStatusContext, enabled: boolean) {
223
225
  if (!enabled) {
224
226
  statusesBySession.delete(ctx.sessionManager);
225
227
  connectionStatusBySession.delete(ctx.sessionManager);
228
+ recoveryStatusBySession.delete(ctx.sessionManager);
226
229
  renderSyncStatus(ctx);
227
230
  }
228
231
  }
@@ -232,7 +235,11 @@ function renderSyncStatus(ctx: SyncStatusContext) {
232
235
  const { sessionManager } = ctx;
233
236
  const status = statusesBySession.get(sessionManager);
234
237
  const connection = connectionStatusBySession.get(sessionManager);
235
- const current = status && status.presentation?.activity !== "idle" ? status : (connection ?? status);
238
+ const recovery = recoveryStatusBySession.get(sessionManager);
239
+ const activity = status?.presentation?.activity;
240
+ const normal = status && activity !== "idle" ? status : (connection ?? status);
241
+ // Recovery explains a transfer's wait, but must not obscure confirmed failures or review.
242
+ const current = activity === "blocked" || activity === "review" ? status : (recovery ?? normal);
236
243
  ctx.ui.setStatus(STATUS_KEY, current?.value);
237
244
  publishersBySession.get(sessionManager)?.update(current?.value, current?.presentation);
238
245
  }
@@ -255,17 +262,30 @@ export function setSyncStatus(
255
262
  renderSyncStatus(ctx);
256
263
  }
257
264
 
258
- /** Connection repair never clears or replaces a transfer or review status. */
259
- export function showSyncConnectionStatus(ctx: SyncStatusContext, value: string, presentation: SyncStatusPresentation) {
265
+ function showOwnedStatus(
266
+ statuses: WeakMap<ExtensionContext["sessionManager"], StatusValue>,
267
+ ctx: SyncStatusContext,
268
+ value: string,
269
+ presentation: SyncStatusPresentation,
270
+ ) {
260
271
  if (!ctx.hasUI || enabledBySession.get(ctx.sessionManager) === false) return (_redraw?: boolean) => {};
261
272
  const { sessionManager } = ctx;
262
273
  const status: StatusValue = { value };
263
- connectionStatusBySession.set(sessionManager, status);
274
+ statuses.set(sessionManager, status);
264
275
  status.presentation = statusPresentation(presentation);
265
- if (connectionStatusBySession.get(sessionManager) === status) renderSyncStatus(ctx);
276
+ if (statuses.get(sessionManager) === status) renderSyncStatus(ctx);
266
277
  return (redraw = true) => {
267
- if (connectionStatusBySession.get(sessionManager) !== status) return;
268
- connectionStatusBySession.delete(sessionManager);
278
+ if (statuses.get(sessionManager) !== status) return;
279
+ statuses.delete(sessionManager);
269
280
  if (redraw) renderSyncStatus(ctx);
270
281
  };
271
282
  }
283
+
284
+ /** Connection repair never clears or replaces a transfer or review status. */
285
+ export function showSyncConnectionStatus(ctx: SyncStatusContext, value: string, presentation: SyncStatusPresentation) {
286
+ return showOwnedStatus(connectionStatusBySession, ctx, value, presentation);
287
+ }
288
+
289
+ export function showSyncQueueReleaseRecovery(ctx: SyncStatusContext) {
290
+ return showOwnedStatus(recoveryStatusBySession, ctx, "sync recovering", { activity: "retry", reason: "temp" });
291
+ }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/sync/sync-error-guidance.ts", "../../src/ui/automatic-sync-summary.ts"],
4
- "sourcesContent": ["export type * from \"@narumitw/pi-sync-daemon/engine/sync/sync-error-guidance\";\nexport { syncErrorGuidance } from \"@narumitw/pi-sync-daemon/engine/sync/sync-error-guidance\";\n", "/** Keep the setting's automatic transfer scope visible in every setup summary. */\nexport function automaticSyncSummary(enabled: boolean) {\n return enabled ? \"On (startup check; shutdown pushes selected content if sessions included)\" : \"Off\";\n}\n"],
5
- "mappings": ";;;;AACA,SAAS,yBAAyB;;;ACA3B,SAAS,qBAAqB,SAAkB;AACrD,SAAO,UAAU,8EAA8E;AACjG;",
6
- "names": []
7
- }