@narumitw/pi-sync 0.67.2 → 0.68.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 (180) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +29 -49
  3. package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
  4. package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
  5. package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
  6. package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
  7. package/dist/chunks/{chunk-2MSJDLSM.ts → chunk-BCDBT4X3.ts} +7 -7
  8. package/dist/chunks/{chunk-GRXNUC6O.ts → chunk-FQKWGVMA.ts} +20 -54
  9. package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
  10. package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
  11. package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
  12. package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
  13. package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
  14. package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
  15. package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
  16. package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
  17. package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
  18. package/dist/chunks/{chunk-UF2HU2NM.ts → chunk-WCGLU526.ts} +39 -118
  19. package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
  20. package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
  21. package/dist/chunks/{chunk-C3E75DXW.ts → chunk-YV2R5SJU.ts} +73 -85
  22. package/dist/chunks/chunk-YV2R5SJU.ts.map +7 -0
  23. package/dist/chunks/{command-handler-HWRPH3K3.ts → command-handler-S6BRZMPW.ts} +117 -69
  24. package/dist/chunks/command-handler-S6BRZMPW.ts.map +7 -0
  25. package/dist/chunks/{conflict-review-OBBBSVQD.ts → conflict-review-3XMYDJIK.ts} +2 -2
  26. package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
  27. package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
  28. package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
  29. package/dist/chunks/{manager-ui-Z3B5ZTA6.ts → manager-ui-KHMCSLLV.ts} +114 -581
  30. package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
  31. package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
  32. package/dist/chunks/{remote-selection-ui-34WC7OFE.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
  33. package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
  34. package/dist/chunks/{setup-wizard-YOXLXLBY.ts → setup-wizard-2NRPR433.ts} +11 -16
  35. package/dist/chunks/{setup-wizard-YOXLXLBY.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
  36. package/dist/chunks/{sync-inspection-NIITROKS.ts → sync-inspection-QGM54YCM.ts} +5 -5
  37. package/dist/chunks/{sync-operations-FFI4ZZQL.ts → sync-operations-DTQMKVRQ.ts} +2 -2
  38. package/dist/daemon/dist/build-id.json +1 -0
  39. package/dist/daemon/dist/build-version.js +24 -4
  40. package/dist/daemon/dist/cli.js +51 -67
  41. package/dist/daemon/dist/client-transport.js +15 -5
  42. package/dist/daemon/dist/client.js +2 -10
  43. package/dist/daemon/dist/consent.js +13 -126
  44. package/dist/daemon/dist/daemon-startup.js +135 -30
  45. package/dist/daemon/dist/daemon-status.js +56 -0
  46. package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
  47. package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
  48. package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
  49. package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
  50. package/dist/daemon/dist/engine/settings/config.js +16 -149
  51. package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
  52. package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
  53. package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
  54. package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
  55. package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
  56. package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
  57. package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
  58. package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
  59. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
  60. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
  61. package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
  62. package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
  63. package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
  64. package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
  65. package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
  66. package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
  67. package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
  68. package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
  69. package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
  70. package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
  71. package/dist/daemon/dist/engine/sync/initialization.js +4 -15
  72. package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
  73. package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
  74. package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
  75. package/dist/daemon/dist/engine/sync/merged-sync.js +13 -70
  76. package/dist/daemon/dist/engine/sync/push-review.js +1 -16
  77. package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
  78. package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
  79. package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
  80. package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
  81. package/dist/daemon/dist/engine/sync/sync-mutations.js +26 -118
  82. package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
  83. package/dist/daemon/dist/engine/sync/sync-queries.js +1 -8
  84. package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
  85. package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
  86. package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
  87. package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
  88. package/dist/daemon/dist/engine-service.js +62 -205
  89. package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
  90. package/dist/daemon/dist/index.js +2 -0
  91. package/dist/daemon/dist/legacy-consent-guard.js +34 -0
  92. package/dist/daemon/dist/server.js +99 -11
  93. package/dist/daemon/dist/service-host.js +3 -9
  94. package/dist/daemon/package.json +1 -1
  95. package/dist/index.ts +49 -49
  96. package/dist/index.ts.map +3 -3
  97. package/docs/agent-continuous-hardening.md +2 -0
  98. package/docs/continuous-sync-verification.md +1 -1
  99. package/docs/daemon-migration.md +17 -15
  100. package/docs/tui-contract.md +4 -6
  101. package/package.json +2 -3
  102. package/skills/configure-pi-sync/SKILL.md +23 -78
  103. package/skills/configure-pi-sync/references/configuration.md +59 -76
  104. package/src/commands/command-execution.ts +15 -38
  105. package/src/commands/command-handler.ts +0 -4
  106. package/src/commands/command.ts +2 -1
  107. package/src/daemon/daemon-status-ui.ts +64 -0
  108. package/src/daemon/directional-recovery.ts +4 -33
  109. package/src/daemon/pi-client.ts +87 -94
  110. package/src/settings/config.ts +0 -1
  111. package/src/sync/setup-switch.ts +1 -4
  112. package/src/sync-extension.ts +14 -27
  113. package/src/ui/cancellable-operation.ts +2 -13
  114. package/src/ui/excluded-paths-ui.ts +1 -4
  115. package/src/ui/file-selection.ts +0 -5
  116. package/src/ui/manager-state.ts +12 -75
  117. package/src/ui/manager-ui.ts +7 -96
  118. package/src/ui/remote-selection-ui.ts +29 -130
  119. package/src/ui/settings-ui.ts +169 -388
  120. package/src/ui/setup/setup-actions.ts +4 -16
  121. package/src/ui/setup/setup-prompts.ts +12 -49
  122. package/src/ui/setup/setup-switcher.ts +8 -14
  123. package/src/ui/storage-connections-ui.ts +21 -32
  124. package/src/ui/sync-setups-ui.ts +27 -53
  125. package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
  126. package/dist/chunks/chunk-C3E75DXW.ts.map +0 -7
  127. package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
  128. package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
  129. package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
  130. package/dist/chunks/chunk-GRXNUC6O.ts.map +0 -7
  131. package/dist/chunks/chunk-I72HGZJJ.ts +0 -106
  132. package/dist/chunks/chunk-I72HGZJJ.ts.map +0 -7
  133. package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
  134. package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
  135. package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
  136. package/dist/chunks/chunk-UF2HU2NM.ts.map +0 -7
  137. package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
  138. package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
  139. package/dist/chunks/command-handler-HWRPH3K3.ts.map +0 -7
  140. package/dist/chunks/config-P54GGMXY.ts +0 -39
  141. package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
  142. package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
  143. package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
  144. package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
  145. package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
  146. package/dist/chunks/ignore-file-ui-5BWA6LBC.ts +0 -21
  147. package/dist/chunks/manager-ui-Z3B5ZTA6.ts.map +0 -7
  148. package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
  149. package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
  150. package/dist/chunks/remote-selection-ui-34WC7OFE.ts.map +0 -7
  151. package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
  152. package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
  153. package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
  154. package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
  155. package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
  156. package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
  157. package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
  158. package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
  159. package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
  160. package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
  161. package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
  162. package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
  163. package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
  164. package/dist/daemon/dist/monitor.js +0 -344
  165. package/src/ui/agent-mode-setting.ts +0 -99
  166. package/src/ui/ignore-file-guidance.ts +0 -7
  167. package/src/ui/ignore-file-ui.ts +0 -105
  168. package/src/ui/ignore-migration-prompt.ts +0 -65
  169. package/src/ui/settings-review.ts +0 -26
  170. /package/dist/chunks/{chunk-2MSJDLSM.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
  171. /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
  172. /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
  173. /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
  174. /package/dist/chunks/{conflict-review-OBBBSVQD.ts.map → conflict-review-3XMYDJIK.ts.map} +0 -0
  175. /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
  176. /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
  177. /package/dist/chunks/{ignore-file-ui-5BWA6LBC.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
  178. /package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
  179. /package/dist/chunks/{sync-inspection-NIITROKS.ts.map → sync-inspection-QGM54YCM.ts.map} +0 -0
  180. /package/dist/chunks/{sync-operations-FFI4ZZQL.ts.map → sync-operations-DTQMKVRQ.ts.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  import type { ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import { showDaemonStatus } from "../daemon/daemon-status-ui.js";
2
3
  import { CompletedDirectionalRecoveryError } from "../daemon/directional-recovery.js";
3
4
  import { type PiDaemonClient, piDaemonClient, remoteOperation } from "../daemon/pi-client.js";
4
5
  import { loadSettingsConfig, sessionTokenWarnings, syncSessionsWarnings } from "../settings/config.js";
@@ -12,7 +13,6 @@ import type { SyncLoaders } from "../sync/sync-loaders.js";
12
13
  import { RemoteSelectionMismatchError, syncSessionsSelected } from "../sync/sync-policy.js";
13
14
  import { automaticSyncSummary } from "../ui/automatic-sync-summary.js";
14
15
  import type { RunRouteResult } from "../ui/cancellable-operation.js";
15
- import { manualIgnoreFileGuidance } from "../ui/ignore-file-guidance.js";
16
16
  import { trackOperationDialogs } from "../ui/operation-dialogs.js";
17
17
  import { startupTransferSummary } from "../ui/sync-behavior.js";
18
18
  import { setSyncStatus } from "../ui/sync-status.js";
@@ -76,7 +76,6 @@ export async function executeCommand(
76
76
  onDialog?: (active: boolean) => void,
77
77
  retryRefusal = false,
78
78
  directionalFingerprint?: string,
79
- requirePendingAdoption?: boolean,
80
79
  ): Promise<RunRouteResult> {
81
80
  ctx = trackOperationDialogs(ctx, onDialog);
82
81
  try {
@@ -84,8 +83,6 @@ export async function executeCommand(
84
83
  const command = await resolveSyncCommand(rawArgs, ctx);
85
84
  if (signal?.aborted || !command) return { kind: "completed" };
86
85
  const { subcommand, rest } = command;
87
- if (requirePendingAdoption && (!directionalClient || subcommand !== "pull"))
88
- throw new Error("Pull recovery requires the original directional action.");
89
86
  if (directionalClient && directionalFingerprint !== undefined) {
90
87
  if ((subcommand !== "push" && subcommand !== "pull") || rest.length || !setup || retryRefusal)
91
88
  throw new Error("Invalid directional action.");
@@ -97,7 +94,6 @@ export async function executeCommand(
97
94
  directionalFingerprint,
98
95
  signal,
99
96
  onCommit,
100
- requirePendingAdoption,
101
97
  );
102
98
  }
103
99
  const options = parseOptions(rest);
@@ -105,10 +101,7 @@ export async function executeCommand(
105
101
  if (signal) options.signal = signal;
106
102
  if (onCommit) options.onCommit = onCommit;
107
103
  validateCommandOptions(subcommand, options);
108
- if (retryRefusal) {
109
- if (subcommand !== "sync") throw new Error("A refused-model retry is available only for merged sync.");
110
- options.agentRetryRefusal = true;
111
- }
104
+ if (retryRefusal) throw new Error("Model retries are no longer supported. Use reviewed manual sync.");
112
105
 
113
106
  switch (subcommand) {
114
107
  case "daemon": {
@@ -120,24 +113,14 @@ export async function executeCommand(
120
113
  await recoverDaemonOwnership(ctx, client, signal);
121
114
  } else if (action === "handover") {
122
115
  await client.run("daemon.handover", {}, options.signal);
123
- } else if (action === "allow-after-exit" || action === "revoke-after-exit") {
116
+ } else if (action === "allow-after-exit") {
117
+ throw new Error("Continuous sync was retired. New after-exit grants are not supported.");
118
+ } else if (action === "revoke-after-exit") {
124
119
  await client.run("daemon.handover", {}, options.signal);
125
120
  const policy = (await client.run("daemon.policy", {}, options.signal)) as { fingerprint: string };
126
- await client.run(
127
- "daemon.authorize",
128
- { fingerprint: policy.fingerprint, afterExit: action === "allow-after-exit" },
129
- options.signal,
130
- );
121
+ await client.run("daemon.authorize", { fingerprint: policy.fingerprint, afterExit: false }, options.signal);
131
122
  } else if (action === "status") {
132
- const connection = await client.verifyConnection(options.signal);
133
- const guidance = client.ownershipCleanupRequired
134
- ? "Use /sync daemon recover to review and stop the daemon."
135
- : "Use pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.";
136
- const state = client.ownershipCleanupRequired ? "connected; recovery required" : "connected";
137
- ctx.ui.notify(
138
- `pi-sync-daemon: ${state}\nPID: ${connection.identity.pid}\nInstance: ${connection.identity.instance}\n${guidance}`,
139
- "info",
140
- );
123
+ await showDaemonStatus(ctx, client, options.signal);
141
124
  } else throw new Error("Use /sync daemon status|recover|handover|allow-after-exit|revoke-after-exit.");
142
125
  return { kind: "completed" };
143
126
  }
@@ -263,14 +246,11 @@ async function runDirectionalAction(
263
246
  fingerprint: string,
264
247
  signal: AbortSignal | undefined,
265
248
  onCommit: (() => void) | undefined,
266
- requirePendingAdoption?: boolean,
267
249
  ): Promise<RunRouteResult> {
268
250
  try {
269
251
  const operation = `${direction}.foreground`;
270
252
  const intent = { setup, fingerprint };
271
- const result = (await (requirePendingAdoption
272
- ? client.run(operation, intent, signal, ctx, onCommit, undefined, true)
273
- : client.run(operation, intent, signal, ctx, onCommit))) as
253
+ const result = (await client.run(operation, intent, signal, ctx, onCommit)) as
274
254
  | { outcome?: "applied" | "cancelled"; message?: string }
275
255
  | undefined;
276
256
  if (!client.canReportDirectionalResult() || (signal?.aborted && result?.outcome !== "applied"))
@@ -346,17 +326,14 @@ async function showConfig(ctx: ExtensionCommandContext, options: CommandOptions)
346
326
  `settings field merge: ${config.mergeSettings ? "On" : "Off"}`,
347
327
  `machine-local settings.json fields: ${(config.localFields ?? []).map(safeTerminalText).join(", ") || "none"}`,
348
328
  `startup transfer: ${startupTransferSummary(config)}`,
349
- `autonomous sync: ${config.agentMode ? "On" : "Off"}`,
350
- `continuous sync: ${config.continuous ? (config.agentMode ? "On" : "paused; Autonomous sync is Off") : "Off"}`,
329
+ "Autonomous sync and Continuous sync are retired. Saved legacy flags have no effect.",
351
330
  config.scope ? "sync scope: Pi agent directory" : `included content: ${config.include.join(", ") || "none"}`,
352
- ...(config.pathPolicy === "ignore-file"
353
- ? ["path policy: local ignore file", manualIgnoreFileGuidance(config.ignoreFile ?? ".syncignore")]
354
- : config.scope
355
- ? [
356
- `excluded paths: ${config.exclude?.map(safeTerminalText).join(", ") || "none"}`,
357
- `re-included paths: ${config.reinclude?.map(safeTerminalText).join(", ") || "none"}`,
358
- ]
359
- : []),
331
+ ...(config.scope
332
+ ? [
333
+ `excluded paths: ${config.exclude?.map(safeTerminalText).join(", ") || "none"}`,
334
+ `re-included paths: ${config.reinclude?.map(safeTerminalText).join(", ") || "none"}`,
335
+ ]
336
+ : []),
360
337
  `sessions: ${syncSessionsSelected(config) ? "included" : "not included"}`,
361
338
  `settings file: ${localConfigPath()}`,
362
339
  ...warnings,
@@ -1,5 +1,4 @@
1
1
  import type { ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import { currentPiDaemonClient } from "../daemon/pi-client.js";
3
2
  import { loadConfig } from "../settings/config.js";
4
3
  import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
5
4
  import { combineSignals } from "../sync/signals.js";
@@ -41,7 +40,6 @@ export async function handleCommand(
41
40
  onDialog?: (active: boolean) => void,
42
41
  retryRefusal = false,
43
42
  directionalFingerprint?: string,
44
- requirePendingAdoption?: boolean,
45
43
  ) => {
46
44
  const [command, ...args] = splitArgs(route);
47
45
  if (command === "sync" && !retryRefusal) {
@@ -63,7 +61,6 @@ export async function handleCommand(
63
61
  onDialog,
64
62
  retryRefusal,
65
63
  directionalFingerprint,
66
- requirePendingAdoption,
67
64
  );
68
65
  };
69
66
  if (!rawArgs.trim()) {
@@ -73,7 +70,6 @@ export async function handleCommand(
73
70
  if (sessionSignal.aborted) return;
74
71
  await showSyncManager(ctx, run, sessionSignal, {
75
72
  needsDaemonRecovery,
76
- getPendingPullReview: () => currentPiDaemonClient()?.pendingPullReview,
77
73
  getAttention: () => attention.current(),
78
74
  getObservation: () => attention.observation(),
79
75
  onObservationInvalidated: () => attention.clearObservation(),
@@ -260,7 +260,8 @@ export function usage() {
260
260
  `Automatic sync: ${AUTOMATIC_SYNC_DESCRIPTION}`,
261
261
  `Startup transfer: ${STARTUP_TRANSFER_DESCRIPTION}`,
262
262
  "Automatic transfer at startup is a separate opt-in: one conflict-free established-baseline transfer at idle in TUI/RPC, with conditional/lease publication and no resource reload.",
263
- "Continuous sync is a separate default-Off opt-in in Settings. It requires Autonomous sync and can incur recurring network/model costs. After the last Pi exits, the service closes after a 30-second grace period unless a valid /sync daemon allow-after-exit grant applies. Zero-client work still requires that separate review. Safety blocks and durable automatic request limits remain.",
263
+ "Autonomous sync and Continuous sync are retired. Saved flags no longer transfer files or call a model. Use Sync now to review a transfer or enable Startup transfer for one eligible startup sync.",
264
+ "New after-exit grants are not supported. Use /sync daemon revoke-after-exit to clear a retained grant.",
264
265
  "Settings: use /sync init or edit storage connections and sync setups in ~/.pi/agent/pi-sync.json (or the configured Pi agent directory). Version 1 and version 2 settings are unsupported and are never rewritten.",
265
266
  ].join("\n");
266
267
  }
@@ -0,0 +1,64 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import { inspectDaemonStatus } from "@narumitw/pi-sync-daemon";
3
+ import { errorMessage } from "../sync/sync-errors.js";
4
+ import { safeTerminalText } from "../ui/terminal-text.js";
5
+ import type { PiDaemonClient } from "./pi-client.js";
6
+
7
+ export async function showDaemonStatus(ctx: ExtensionContext, client: PiDaemonClient, signal?: AbortSignal) {
8
+ let attachedInstance: string | undefined;
9
+ let connectionError: string | undefined;
10
+ try {
11
+ attachedInstance = (await client.verifyConnection(signal))?.identity.instance;
12
+ } catch (error) {
13
+ connectionError = safeTerminalText(errorMessage(error).slice(0, 1200));
14
+ }
15
+ signal?.throwIfAborted();
16
+ client.validate();
17
+ const status = await inspectDaemonStatus(client.root, signal);
18
+ signal?.throwIfAborted();
19
+ client.validate();
20
+ if (!ctx.hasUI) return;
21
+ const connected = status.running === true && status.instance === attachedInstance;
22
+ const recovery = client.ownershipCleanupRequired || status.pendingUpgradePid !== undefined;
23
+ const state = connected
24
+ ? "connected"
25
+ : status.running
26
+ ? "running; not connected"
27
+ : status.running === null
28
+ ? "owner could not be verified"
29
+ : "not running";
30
+ const lines = [`pi-sync-daemon: ${state}${recovery ? "; recovery required" : ""}`];
31
+ if (status.running) {
32
+ lines.push(`PID: ${status.pid}`, `Instance: ${status.instance}`);
33
+ lines.push(`Running build: ${formatBuild(status.buildVersion, status.buildId)}`);
34
+ }
35
+ lines.push(`Expected build: ${formatBuild(status.expectedBuildVersion, status.expectedBuildId)}`);
36
+ if (status.pendingUpgradePid !== undefined) lines.push(`Pending replacement PID: ${status.pendingUpgradePid}`);
37
+ const blocked = status.running ? client.blockedUpgradeReason(status.instance) : undefined;
38
+ if (blocked) lines.push(`Upgrade blocked: ${blocked.slice(0, 1200)}`);
39
+ else if (connectionError) lines.push(`Connection: ${connectionError}`);
40
+ if (client.ownershipCleanupRequired) lines.push("Use /sync daemon recover to review and stop the daemon.");
41
+ else if (recovery || status.running === null)
42
+ lines.push("Check daemon CLI status and follow daemon recovery. Do not force a restart.");
43
+ else if (status.running && (status.buildComparison === "older" || status.buildComparison === "unversioned")) {
44
+ if (!blocked)
45
+ lines.push(
46
+ status.guardedUpgrade
47
+ ? "Daemon upgrade is required. Use /reload when sync work is idle."
48
+ : "This owner does not support guarded upgrades. When sync work is idle, use the intended daemon CLI restart, then /reload.",
49
+ );
50
+ } else if (status.running && status.buildComparison === "different")
51
+ lines.push("Same version, different build. Use the intended build's daemon CLI restart, then /reload.");
52
+ else if (status.running && status.buildComparison === "unverified")
53
+ lines.push(
54
+ "Build match is unverified. Use the intended build's daemon CLI to inspect or explicitly restart, then /reload.",
55
+ );
56
+ else if (status.running && status.buildComparison === "newer")
57
+ lines.push("The running daemon is newer than the loaded build. It was left unchanged.");
58
+ else lines.push("Use pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.");
59
+ ctx.ui.notify(lines.join("\n"), connected && !recovery ? "info" : "warning");
60
+ }
61
+
62
+ function formatBuild(version?: string, id?: string) {
63
+ return `${version ?? "unknown version"} (${id?.slice(0, 12) ?? "unknown build ID"})`;
64
+ }
@@ -32,11 +32,6 @@ export class DirectionalCheckpoint {
32
32
  function recoveryOutcome(value: unknown) {
33
33
  if (!value || typeof value !== "object" || !("foregroundQueueCleanup" in value)) return;
34
34
  if (value.foregroundQueueCleanup === "before-mutation") return { phase: "unchanged" as const };
35
- if (value.foregroundQueueCleanup === "resume-adoption") {
36
- if (!("journal" in value) || typeof value.journal !== "string" || !/^[a-f0-9]{64}$/u.test(value.journal))
37
- throw new Error("The recorded Pull could not be verified. Use /sync daemon recover.");
38
- return { phase: "adoption" as const, journal: value.journal };
39
- }
40
35
  if (value.foregroundQueueCleanup === "verified-result" && "result" in value)
41
36
  return { phase: "completed" as const, result: value.result };
42
37
  }
@@ -58,26 +53,16 @@ function cancelledAfterCompletion(result: unknown, cause: unknown) {
58
53
  return error;
59
54
  }
60
55
 
61
- export interface PendingAdoptionRecovery {
62
- owner: DaemonConnection;
63
- job: string;
64
- journal: string;
65
- }
66
-
67
56
  export async function runDirectionalRecovery(
68
57
  connection: DaemonConnection,
69
58
  signal: AbortSignal,
70
- run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string, retryAdoptionJournal?: string) => Promise<unknown>,
59
+ run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string) => Promise<unknown>,
71
60
  recover: (connection: DaemonConnection, job: string, signal: AbortSignal) => Promise<DaemonConnection>,
72
61
  markCleanupRequired: () => void,
73
- adoption?: { pending?: PendingAdoptionRecovery; retain(value: PendingAdoptionRecovery | undefined): void },
74
62
  ) {
75
63
  signal.throwIfAborted();
76
- const pending = adoption?.pending;
77
- if (pending && pending.owner !== connection) throw new Error("The daemon changed before Pull recovery.");
78
64
  const attempt = new DirectionalCheckpoint(connection);
79
- attempt.job = pending?.job;
80
- const result = pending ? { foregroundQueueCleanup: "resume-adoption", journal: pending.journal } : await run(attempt);
65
+ const result = await run(attempt);
81
66
  const primary = recoveryOutcome(result);
82
67
  if (!primary) return result;
83
68
  markCleanupRequired();
@@ -85,16 +70,9 @@ export async function runDirectionalRecovery(
85
70
  const bounded = AbortSignal.any([signal, AbortSignal.timeout(45_000)]);
86
71
  try {
87
72
  bounded.throwIfAborted();
88
- if (
89
- !attempt.job ||
90
- (primary.phase === "unchanged" && !attempt.fingerprint) ||
91
- (primary.phase === "adoption" && (!adoption || (!pending && !attempt.fingerprint)))
92
- )
73
+ if (!attempt.job || (primary.phase === "unchanged" && !attempt.fingerprint))
93
74
  throw new Error("The original transfer scope could not be verified.");
94
- if (primary.phase === "adoption")
95
- adoption?.retain({ owner: connection, job: attempt.job, journal: primary.journal });
96
75
  replacement = await recover(connection, attempt.job, bounded);
97
- if (primary.phase === "adoption") adoption?.retain(undefined);
98
76
  bounded.throwIfAborted();
99
77
  } catch (error) {
100
78
  if (signal.aborted) {
@@ -107,14 +85,12 @@ export async function runDirectionalRecovery(
107
85
  `The transfer finished, but file-queue recovery stopped. ${detail}${restoreMessage(primary.result)}`,
108
86
  { cause: error },
109
87
  );
110
- if (primary.phase === "adoption")
111
- throw new Error(`Pull recovery stopped. The adoption journal was kept. ${detail}`, { cause: error });
112
88
  throw new Error(`No transfer was applied, but file-queue recovery stopped. ${detail}`, { cause: error });
113
89
  }
114
90
  if (primary.phase === "completed") return primary.result;
115
91
  const retryCheckpoint = primary.phase === "unchanged" ? attempt.fingerprint : undefined;
116
92
  const retry = new DirectionalCheckpoint(replacement, retryCheckpoint);
117
- const retried = await run(retry, retryCheckpoint, primary.phase === "adoption" ? primary.journal : undefined);
93
+ const retried = await run(retry, retryCheckpoint);
118
94
  const remaining = recoveryOutcome(retried);
119
95
  if (!remaining) return retried;
120
96
  markCleanupRequired();
@@ -124,10 +100,5 @@ export async function runDirectionalRecovery(
124
100
  `Transfer finished, but file-queue cleanup is still uncertain after one recovery attempt.${restoreMessage(remaining.result)}`,
125
101
  );
126
102
  }
127
- if (remaining.phase === "adoption") {
128
- if (retry.job && retry.fingerprint)
129
- adoption?.retain({ owner: replacement, job: retry.job, journal: remaining.journal });
130
- throw new Error("File-queue cleanup is still uncertain after one recovery attempt. The adoption journal was kept.");
131
- }
132
103
  throw new Error("File-queue release could not be verified after one recovery attempt. No transfer was applied.");
133
104
  }