@narumitw/pi-sync 0.67.0 → 0.67.2

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 (79) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/chunks/{chunk-BESRBKVO.ts → chunk-2MSJDLSM.ts} +7 -7
  4. package/dist/chunks/{chunk-BYVHABNR.ts → chunk-2MUAR5GH.ts} +2 -2
  5. package/dist/chunks/{chunk-DAZZ5BEJ.ts → chunk-3NS4PMCI.ts} +6 -2
  6. package/dist/chunks/{chunk-FI2F5JBS.ts → chunk-3Q3DMMID.ts} +8 -8
  7. package/dist/chunks/{chunk-JQ5BAWW2.ts → chunk-C3E75DXW.ts} +84 -21
  8. package/dist/chunks/chunk-C3E75DXW.ts.map +7 -0
  9. package/dist/chunks/{chunk-SZJOUVCL.ts → chunk-DGVZYS7T.ts} +5 -5
  10. package/dist/chunks/{chunk-WJQ4TGN5.ts → chunk-ECUCXF5Y.ts} +2 -2
  11. package/dist/chunks/{chunk-ASU3GZPW.ts → chunk-GRXNUC6O.ts} +6 -6
  12. package/dist/chunks/{chunk-Z5JMOXJM.ts → chunk-I72HGZJJ.ts} +5 -5
  13. package/dist/chunks/{chunk-AYGMIMCV.ts → chunk-PUSMSKIM.ts} +11 -2
  14. package/dist/chunks/chunk-PUSMSKIM.ts.map +7 -0
  15. package/dist/chunks/{chunk-5YOLQKNZ.ts → chunk-UF2HU2NM.ts} +14 -14
  16. package/dist/chunks/{command-handler-SQC2L2FJ.ts → command-handler-HWRPH3K3.ts} +40 -32
  17. package/dist/chunks/command-handler-HWRPH3K3.ts.map +7 -0
  18. package/dist/chunks/config-P54GGMXY.ts +39 -0
  19. package/dist/chunks/{conflict-review-J7L7S4AR.ts → conflict-review-OBBBSVQD.ts} +2 -2
  20. package/dist/chunks/{file-selection-XWACUTAH.ts → file-selection-GASCVN45.ts} +6 -6
  21. package/dist/chunks/{ignore-file-ui-OHFISFVC.ts → ignore-file-ui-5BWA6LBC.ts} +5 -5
  22. package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts → manager-result-dispatcher-MJ6G2CEI.ts} +7 -7
  23. package/dist/chunks/{manager-ui-DWOMAJKE.ts → manager-ui-Z3B5ZTA6.ts} +50 -32
  24. package/dist/chunks/manager-ui-Z3B5ZTA6.ts.map +7 -0
  25. package/dist/chunks/{merge-review-AAC674C6.ts → merge-review-C2KETZKY.ts} +3 -3
  26. package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts → remote-selection-ui-34WC7OFE.ts} +6 -6
  27. package/dist/chunks/{setup-switch-644T6KHG.ts → setup-switch-JZDFQPVW.ts} +4 -4
  28. package/dist/chunks/setup-switch-JZDFQPVW.ts.map +7 -0
  29. package/dist/chunks/{setup-wizard-IEW56AZE.ts → setup-wizard-YOXLXLBY.ts} +9 -9
  30. package/dist/chunks/{sync-inspection-NBBTSMKR.ts → sync-inspection-NIITROKS.ts} +5 -5
  31. package/dist/chunks/{sync-operations-AIEM2KL2.ts → sync-operations-FFI4ZZQL.ts} +2 -2
  32. package/dist/daemon/dist/client.js +32 -18
  33. package/dist/daemon/dist/daemon-recovery.js +5 -3
  34. package/dist/daemon/dist/engine/debug-log.js +19 -0
  35. package/dist/daemon/dist/engine/ignore/adoption-journal.js +6 -3
  36. package/dist/daemon/dist/engine/sync/ignore-adoption.js +8 -2
  37. package/dist/daemon/dist/engine/sync/sync-mutations.js +4 -1
  38. package/dist/daemon/dist/engine-service.js +22 -6
  39. package/dist/daemon/dist/foreground-queue-outcome.js +4 -0
  40. package/dist/daemon/dist/server.js +4 -3
  41. package/dist/daemon/dist/service-host.js +7 -2
  42. package/dist/daemon/package.json +1 -1
  43. package/dist/index.ts +41 -32
  44. package/dist/index.ts.map +2 -2
  45. package/docs/daemon-migration.md +2 -0
  46. package/package.json +2 -2
  47. package/skills/configure-pi-sync/references/configuration.md +2 -0
  48. package/src/commands/command-execution.ts +10 -1
  49. package/src/commands/command-handler.ts +4 -0
  50. package/src/daemon/client-debug.ts +6 -3
  51. package/src/daemon/directional-recovery.ts +35 -5
  52. package/src/daemon/pi-client.ts +83 -14
  53. package/src/sync-extension.ts +17 -9
  54. package/src/ui/cancellable-operation.ts +13 -2
  55. package/src/ui/manager-state.ts +1 -0
  56. package/src/ui/manager-ui.ts +25 -4
  57. package/dist/chunks/chunk-AYGMIMCV.ts.map +0 -7
  58. package/dist/chunks/chunk-JQ5BAWW2.ts.map +0 -7
  59. package/dist/chunks/command-handler-SQC2L2FJ.ts.map +0 -7
  60. package/dist/chunks/manager-ui-DWOMAJKE.ts.map +0 -7
  61. /package/dist/chunks/{chunk-BESRBKVO.ts.map → chunk-2MSJDLSM.ts.map} +0 -0
  62. /package/dist/chunks/{chunk-BYVHABNR.ts.map → chunk-2MUAR5GH.ts.map} +0 -0
  63. /package/dist/chunks/{chunk-DAZZ5BEJ.ts.map → chunk-3NS4PMCI.ts.map} +0 -0
  64. /package/dist/chunks/{chunk-FI2F5JBS.ts.map → chunk-3Q3DMMID.ts.map} +0 -0
  65. /package/dist/chunks/{chunk-SZJOUVCL.ts.map → chunk-DGVZYS7T.ts.map} +0 -0
  66. /package/dist/chunks/{chunk-WJQ4TGN5.ts.map → chunk-ECUCXF5Y.ts.map} +0 -0
  67. /package/dist/chunks/{chunk-ASU3GZPW.ts.map → chunk-GRXNUC6O.ts.map} +0 -0
  68. /package/dist/chunks/{chunk-Z5JMOXJM.ts.map → chunk-I72HGZJJ.ts.map} +0 -0
  69. /package/dist/chunks/{chunk-5YOLQKNZ.ts.map → chunk-UF2HU2NM.ts.map} +0 -0
  70. /package/dist/chunks/{ignore-file-ui-OHFISFVC.ts.map → config-P54GGMXY.ts.map} +0 -0
  71. /package/dist/chunks/{conflict-review-J7L7S4AR.ts.map → conflict-review-OBBBSVQD.ts.map} +0 -0
  72. /package/dist/chunks/{file-selection-XWACUTAH.ts.map → file-selection-GASCVN45.ts.map} +0 -0
  73. /package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts.map → ignore-file-ui-5BWA6LBC.ts.map} +0 -0
  74. /package/dist/chunks/{merge-review-AAC674C6.ts.map → manager-result-dispatcher-MJ6G2CEI.ts.map} +0 -0
  75. /package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts.map → merge-review-C2KETZKY.ts.map} +0 -0
  76. /package/dist/chunks/{setup-switch-644T6KHG.ts.map → remote-selection-ui-34WC7OFE.ts.map} +0 -0
  77. /package/dist/chunks/{setup-wizard-IEW56AZE.ts.map → setup-wizard-YOXLXLBY.ts.map} +0 -0
  78. /package/dist/chunks/{sync-inspection-NBBTSMKR.ts.map → sync-inspection-NIITROKS.ts.map} +0 -0
  79. /package/dist/chunks/{sync-operations-AIEM2KL2.ts.map → sync-operations-FFI4ZZQL.ts.map} +0 -0
@@ -15,11 +15,20 @@ import {
15
15
  readStateForConfig,
16
16
  syncAttentionMatchesConfig,
17
17
  syncStateFingerprint
18
- } from "./chunk-FI2F5JBS.ts";
18
+ } from "./chunk-3Q3DMMID.ts";
19
+ import {
20
+ CompletedDirectionalRecoveryError,
21
+ currentPiDaemonClient,
22
+ piDaemonClient,
23
+ remoteOperation
24
+ } from "./chunk-C3E75DXW.ts";
19
25
  import {
20
26
  combineSignals,
21
27
  throwIfAborted
22
28
  } from "./chunk-UMPA5S7X.ts";
29
+ import {
30
+ setSyncStatus
31
+ } from "./chunk-H7VOTY5N.ts";
23
32
  import {
24
33
  parseOptions,
25
34
  resolveSyncCommand,
@@ -28,6 +37,11 @@ import {
28
37
  usage,
29
38
  validateCommandOptions
30
39
  } from "./chunk-XUZV4OGI.ts";
40
+ import {
41
+ SetupPullRequiresUiError,
42
+ errorMessage,
43
+ isSyncDecisionRequiredError
44
+ } from "./chunk-6YKOHBSC.ts";
31
45
  import {
32
46
  manualIgnoreFileGuidance
33
47
  } from "./chunk-EJDDRS6O.ts";
@@ -38,30 +52,17 @@ import {
38
52
  syncErrorGuidance
39
53
  } from "./chunk-IBXEM35O.ts";
40
54
  import "./chunk-ZO52JM4H.ts";
41
- import {
42
- loadConfig,
43
- loadSettingsConfig,
44
- sessionTokenWarnings,
45
- syncSessionsWarnings
46
- } from "./chunk-DAZZ5BEJ.ts";
47
- import {
48
- CompletedDirectionalRecoveryError,
49
- piDaemonClient,
50
- remoteOperation
51
- } from "./chunk-JQ5BAWW2.ts";
52
- import {
53
- setSyncStatus
54
- } from "./chunk-H7VOTY5N.ts";
55
- import {
56
- SetupPullRequiresUiError,
57
- errorMessage,
58
- isSyncDecisionRequiredError
59
- } from "./chunk-6YKOHBSC.ts";
60
55
  import {
61
56
  RemoteSelectionMismatchError,
62
57
  formatRemoteSelectionMismatch,
63
58
  syncSessionsSelected
64
59
  } from "./chunk-R3SAMXB6.ts";
60
+ import {
61
+ loadConfig,
62
+ loadSettingsConfig,
63
+ sessionTokenWarnings,
64
+ syncSessionsWarnings
65
+ } from "./chunk-3NS4PMCI.ts";
65
66
  import {
66
67
  safeTerminalText
67
68
  } from "./chunk-2JNFEZ3V.ts";
@@ -105,13 +106,15 @@ async function executeRecoveryCommand(rawArgs, ctx, signal, loaders, onCommit, s
105
106
  return { kind: "failed" };
106
107
  }
107
108
  }
108
- async function executeCommand(rawArgs, ctx, signal, loaders, onCommit, setup, onDialog, retryRefusal = false, directionalFingerprint) {
109
+ async function executeCommand(rawArgs, ctx, signal, loaders, onCommit, setup, onDialog, retryRefusal = false, directionalFingerprint, requirePendingAdoption) {
109
110
  ctx = trackOperationDialogs(ctx, onDialog);
110
111
  try {
111
112
  const directionalClient = directionalFingerprint === void 0 ? void 0 : piDaemonClient(ctx);
112
113
  const command = await resolveSyncCommand(rawArgs, ctx);
113
114
  if (signal?.aborted || !command) return { kind: "completed" };
114
115
  const { subcommand, rest } = command;
116
+ if (requirePendingAdoption && (!directionalClient || subcommand !== "pull"))
117
+ throw new Error("Pull recovery requires the original directional action.");
115
118
  if (directionalClient && directionalFingerprint !== void 0) {
116
119
  if (subcommand !== "push" && subcommand !== "pull" || rest.length || !setup || retryRefusal)
117
120
  throw new Error("Invalid directional action.");
@@ -122,7 +125,8 @@ async function executeCommand(rawArgs, ctx, signal, loaders, onCommit, setup, on
122
125
  setup,
123
126
  directionalFingerprint,
124
127
  signal,
125
- onCommit
128
+ onCommit,
129
+ requirePendingAdoption
126
130
  );
127
131
  }
128
132
  const options = parseOptions(rest);
@@ -192,7 +196,7 @@ ${guidance}`,
192
196
  await showConfig(ctx, options);
193
197
  return { kind: "completed" };
194
198
  case "files": {
195
- const { showFileSelection } = await import("./file-selection-XWACUTAH.ts");
199
+ const { showFileSelection } = await import("./file-selection-GASCVN45.ts");
196
200
  throwIfAborted(options.signal);
197
201
  await showFileSelection(ctx, options.setup, options.signal);
198
202
  return { kind: "completed" };
@@ -210,7 +214,7 @@ ${guidance}`,
210
214
  return { kind: "completed" };
211
215
  }
212
216
  case "conflicts": {
213
- const { showConflicts } = await import("./conflict-review-J7L7S4AR.ts");
217
+ const { showConflicts } = await import("./conflict-review-OBBBSVQD.ts");
214
218
  throwIfAborted(options.signal);
215
219
  await showConflicts(ctx, options);
216
220
  return { kind: "completed" };
@@ -281,9 +285,11 @@ ${usage()}`, "warning");
281
285
  return { kind: "failed" };
282
286
  }
283
287
  }
284
- async function runDirectionalAction(client, ctx, direction, setup, fingerprint, signal, onCommit) {
288
+ async function runDirectionalAction(client, ctx, direction, setup, fingerprint, signal, onCommit, requirePendingAdoption) {
285
289
  try {
286
- const result = await client.run(`${direction}.foreground`, { setup, fingerprint }, signal, ctx, onCommit);
290
+ const operation = `${direction}.foreground`;
291
+ const intent = { setup, fingerprint };
292
+ const result = await (requirePendingAdoption ? client.run(operation, intent, signal, ctx, onCommit, void 0, true) : client.run(operation, intent, signal, ctx, onCommit));
287
293
  if (!client.canReportDirectionalResult() || signal?.aborted && result?.outcome !== "applied")
288
294
  return { kind: "failed" };
289
295
  if (!result || result.outcome !== "applied" && result.outcome !== "cancelled" || result.message !== void 0 && typeof result.message !== "string") {
@@ -319,7 +325,7 @@ async function initConfig(ctx, signal) {
319
325
  return;
320
326
  }
321
327
  if (ctx.mode === "tui") {
322
- const { showSetupWizard } = await import("./setup-wizard-IEW56AZE.ts");
328
+ const { showSetupWizard } = await import("./setup-wizard-YOXLXLBY.ts");
323
329
  throwIfAborted(signal);
324
330
  await showSetupWizard(ctx, signal);
325
331
  return;
@@ -425,7 +431,7 @@ async function handleCommand(rawArgs, ctx, sessionSignal, loaders, attention, on
425
431
  }
426
432
  if (!needsDaemonRecovery?.()) await reconcileObservation(attention, sessionSignal);
427
433
  if (sessionSignal.aborted) return;
428
- const run = (route, signal, onCommit, target, onDialog, retryRefusal = false, directionalFingerprint) => {
434
+ const run = (route, signal, onCommit, target, onDialog, retryRefusal = false, directionalFingerprint, requirePendingAdoption) => {
429
435
  const [command, ...args2] = splitArgs(route);
430
436
  if (command === "sync" && !retryRefusal) {
431
437
  try {
@@ -444,16 +450,18 @@ async function handleCommand(rawArgs, ctx, sessionSignal, loaders, attention, on
444
450
  target,
445
451
  onDialog,
446
452
  retryRefusal,
447
- directionalFingerprint
453
+ directionalFingerprint,
454
+ requirePendingAdoption
448
455
  );
449
456
  };
450
457
  if (!rawArgs.trim()) {
451
458
  attention.expand();
452
459
  try {
453
- const { showSyncManager } = await import("./manager-ui-DWOMAJKE.ts");
460
+ const { showSyncManager } = await import("./manager-ui-Z3B5ZTA6.ts");
454
461
  if (sessionSignal.aborted) return;
455
462
  await showSyncManager(ctx, run, sessionSignal, {
456
463
  needsDaemonRecovery,
464
+ getPendingPullReview: () => currentPiDaemonClient()?.pendingPullReview,
457
465
  getAttention: () => attention.current(),
458
466
  getObservation: () => attention.observation(),
459
467
  onObservationInvalidated: () => attention.clearObservation(),
@@ -553,7 +561,7 @@ function directSelectionOrigin(rawArgs) {
553
561
  async function resolveSelectionAttention(ctx, attention, signal, loaders, options = {}) {
554
562
  const current = attention.current();
555
563
  if (!current || signal.aborted) return;
556
- const { dispatchManagerResult } = await import("./manager-result-dispatcher-WXE2BAQO.ts");
564
+ const { dispatchManagerResult } = await import("./manager-result-dispatcher-MJ6G2CEI.ts");
557
565
  if (signal.aborted || attention.current() !== current) return;
558
566
  await dispatchManagerResult(
559
567
  ctx,
@@ -584,4 +592,4 @@ export {
584
592
  handleCommand,
585
593
  resolveSelectionAttention
586
594
  };
587
- //# sourceMappingURL=command-handler-SQC2L2FJ.ts.map
595
+ //# sourceMappingURL=command-handler-HWRPH3K3.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/commands/command-execution.ts", "../../src/commands/command-handler.ts"],
4
+ "sourcesContent": ["import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { CompletedDirectionalRecoveryError } from \"../daemon/directional-recovery.js\";\nimport { type PiDaemonClient, piDaemonClient, remoteOperation } from \"../daemon/pi-client.js\";\nimport { loadSettingsConfig, sessionTokenWarnings, syncSessionsWarnings } from \"../settings/config.js\";\nimport { activeLocalConfigPath, createLocalConfigDocument, localConfigPath } from \"../settings/config-file.js\";\nimport { localConfigTemplate, readLocalConfigObject } from \"../settings/settings-store.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { throwIfAborted } from \"../sync/signals.js\";\nimport { syncErrorGuidance } from \"../sync/sync-error-guidance.js\";\nimport { errorMessage, isSyncDecisionRequiredError, SetupPullRequiresUiError } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { RemoteSelectionMismatchError, syncSessionsSelected } from \"../sync/sync-policy.js\";\nimport { automaticSyncSummary } from \"../ui/automatic-sync-summary.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport { manualIgnoreFileGuidance } from \"../ui/ignore-file-guidance.js\";\nimport { trackOperationDialogs } from \"../ui/operation-dialogs.js\";\nimport { startupTransferSummary } from \"../ui/sync-behavior.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { parseOptions, resolveSyncCommand, splitArgs, usage, validateCommandOptions } from \"./command.js\";\nimport type { CommandOptions } from \"./command-types.js\";\n\nexport async function executeRecoveryCommand(\n rawArgs: string,\n ctx: ExtensionContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n): Promise<RunRouteResult> {\n try {\n const [subcommand, ...rest] = splitArgs(rawArgs);\n if (subcommand !== \"sync\" && subcommand !== \"pull\" && subcommand !== \"push\") {\n throw new Error(`Unsupported sync recovery route: ${subcommand ?? \"missing\"}`);\n }\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n options.reload = false;\n options.auto = false;\n validateCommandOptions(subcommand, options);\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n if (subcommand === \"push\") {\n const outcome = await operations.push(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n if (subcommand === \"pull\") {\n const outcome = await operations.pull(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n await operations.syncBoth(ctx, options);\n return { kind: \"completed\" };\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nexport async function executeCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n directionalFingerprint?: string,\n requirePendingAdoption?: boolean,\n): Promise<RunRouteResult> {\n ctx = trackOperationDialogs(ctx, onDialog);\n try {\n const directionalClient = directionalFingerprint === undefined ? undefined : piDaemonClient(ctx);\n const command = await resolveSyncCommand(rawArgs, ctx);\n if (signal?.aborted || !command) return { kind: \"completed\" };\n const { subcommand, rest } = command;\n if (requirePendingAdoption && (!directionalClient || subcommand !== \"pull\"))\n throw new Error(\"Pull recovery requires the original directional action.\");\n if (directionalClient && directionalFingerprint !== undefined) {\n if ((subcommand !== \"push\" && subcommand !== \"pull\") || rest.length || !setup || retryRefusal)\n throw new Error(\"Invalid directional action.\");\n return await runDirectionalAction(\n directionalClient,\n ctx,\n subcommand,\n setup,\n directionalFingerprint,\n signal,\n onCommit,\n requirePendingAdoption,\n );\n }\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n validateCommandOptions(subcommand, options);\n if (retryRefusal) {\n if (subcommand !== \"sync\") throw new Error(\"A refused-model retry is available only for merged sync.\");\n options.agentRetryRefusal = true;\n }\n\n switch (subcommand) {\n case \"daemon\": {\n const client = piDaemonClient(ctx);\n const action = options.args[0] ?? \"status\";\n if (action === \"recover\") {\n if (rest.length !== 1) throw new Error(\"Usage: /sync daemon recover\");\n const { recoverDaemonOwnership } = await import(\"../daemon/ownership-recovery.js\");\n await recoverDaemonOwnership(ctx, client, signal);\n } else if (action === \"handover\") {\n await client.run(\"daemon.handover\", {}, options.signal);\n } else if (action === \"allow-after-exit\" || action === \"revoke-after-exit\") {\n await client.run(\"daemon.handover\", {}, options.signal);\n const policy = (await client.run(\"daemon.policy\", {}, options.signal)) as { fingerprint: string };\n await client.run(\n \"daemon.authorize\",\n { fingerprint: policy.fingerprint, afterExit: action === \"allow-after-exit\" },\n options.signal,\n );\n } else if (action === \"status\") {\n const connection = await client.verifyConnection(options.signal);\n const guidance = client.ownershipCleanupRequired\n ? \"Use /sync daemon recover to review and stop the daemon.\"\n : \"Use pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.\";\n const state = client.ownershipCleanupRequired ? \"connected; recovery required\" : \"connected\";\n ctx.ui.notify(\n `pi-sync-daemon: ${state}\\nPID: ${connection.identity.pid}\\nInstance: ${connection.identity.instance}\\n${guidance}`,\n \"info\",\n );\n } else throw new Error(\"Use /sync daemon status|recover|handover|allow-after-exit|revoke-after-exit.\");\n return { kind: \"completed\" };\n }\n case \"help\":\n ctx.ui.notify(usage(), \"info\");\n return { kind: \"completed\" };\n case \"use\": {\n const { useSyncSetup } = await loaders.setupSwitch();\n throwIfAborted(options.signal);\n await useSyncSetup(\n ctx,\n options.args[0] ?? \"\",\n async (selectedSetup) => {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n return operations.pull(ctx, { ...options, setup: selectedSetup });\n },\n undefined,\n options.signal,\n );\n return { kind: \"completed\" };\n }\n case \"init\":\n await initConfig(ctx, signal);\n return { kind: \"completed\" };\n case \"config\":\n await showConfig(ctx, options);\n return { kind: \"completed\" };\n case \"files\": {\n const { showFileSelection } = await import(\"../ui/file-selection.js\");\n throwIfAborted(options.signal);\n await showFileSelection(ctx, options.setup, options.signal);\n return { kind: \"completed\" };\n }\n case \"status\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.status(ctx, options);\n return { kind: \"completed\" };\n }\n case \"diff\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.diff(ctx, options);\n return { kind: \"completed\" };\n }\n case \"conflicts\": {\n const { showConflicts } = await import(\"../sync/conflict-review.js\");\n throwIfAborted(options.signal);\n await showConflicts(ctx, options);\n return { kind: \"completed\" };\n }\n case \"doctor\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.doctor(ctx, options);\n return { kind: \"completed\" };\n }\n case \"push\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await operations.push(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"pull\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await operations.pull(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"sync\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await operations.syncBoth(ctx, options);\n return { kind: \"completed\", ...(retryRefusal && outcome && outcome !== \"archived\" ? { outcome } : {}) };\n }\n case \"history\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.history(ctx, options);\n return { kind: \"completed\" };\n }\n case \"rollback\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.rollback(ctx, options);\n return { kind: \"completed\" };\n }\n case \"migrate-state\":\n await migrateStateDirectory(ctx, options);\n return { kind: \"completed\" };\n case \"unlock\":\n await remoteOperation(ctx, \"unlock\", options);\n return { kind: \"completed\" };\n default:\n ctx.ui.notify(`Unknown /sync command: ${subcommand}\\n\\n${usage()}`, \"warning\");\n return { kind: \"failed\" };\n }\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (directionalFingerprint !== undefined) {\n ctx.ui.notify(safeTerminalText(errorMessage(error)).slice(0, 1200), \"error\");\n return { kind: \"failed\" };\n }\n if (error instanceof SetupPullRequiresUiError) throw error;\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nasync function runDirectionalAction(\n client: PiDaemonClient,\n ctx: ExtensionCommandContext,\n direction: \"push\" | \"pull\",\n setup: string,\n fingerprint: string,\n signal: AbortSignal | undefined,\n onCommit: (() => void) | undefined,\n requirePendingAdoption?: boolean,\n): Promise<RunRouteResult> {\n try {\n const operation = `${direction}.foreground`;\n const intent = { setup, fingerprint };\n const result = (await (requirePendingAdoption\n ? client.run(operation, intent, signal, ctx, onCommit, undefined, true)\n : client.run(operation, intent, signal, ctx, onCommit))) as\n | { outcome?: \"applied\" | \"cancelled\"; message?: string }\n | undefined;\n if (!client.canReportDirectionalResult() || (signal?.aborted && result?.outcome !== \"applied\"))\n return { kind: \"failed\" };\n if (\n !result ||\n (result.outcome !== \"applied\" && result.outcome !== \"cancelled\") ||\n (result.message !== undefined && typeof result.message !== \"string\")\n ) {\n throw new Error(\"Invalid result from directional synchronization.\");\n }\n if (result.message) ctx.ui.notify(safeTerminalText(result.message), \"info\");\n return signal?.aborted ? { kind: \"failed\" } : { kind: \"completed\", outcome: result.outcome };\n } catch (error) {\n const completed = error instanceof CompletedDirectionalRecoveryError;\n if (!client.canReportDirectionalResult() || (signal?.aborted && !completed)) return { kind: \"failed\" };\n if (!signal?.aborted) setSyncStatus(ctx, undefined);\n const message = safeTerminalText(errorMessage(error));\n ctx.ui.notify(completed ? message : message.slice(0, 1200), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nasync function migrateStateDirectory(ctx: ExtensionCommandContext, options: CommandOptions) {\n const result = (await remoteOperation(ctx, \"migrate-state\", options)) as\n | { status: string; message?: string }\n | undefined;\n throwIfAborted(options.signal);\n ctx.ui.notify(\n result?.message ?? \"pi-sync already uses the canonical pi-sync/ state directory.\",\n result?.status === \"deferred\" ? \"warning\" : \"info\",\n );\n}\n\nasync function initConfig(ctx: ExtensionCommandContext, signal?: AbortSignal) {\n const configPath = localConfigPath();\n const existing = await readLocalConfigObject();\n throwIfAborted(signal);\n if (existing) {\n const activePath = await activeLocalConfigPath();\n throwIfAborted(signal);\n ctx.ui.notify(`Config already exists: ${activePath}`, \"info\");\n return;\n }\n\n if (ctx.mode === \"tui\") {\n const { showSetupWizard } = await import(\"../ui/setup/setup-wizard.js\");\n throwIfAborted(signal);\n await showSetupWizard(ctx, signal);\n return;\n }\n await createLocalConfigDocument(localConfigTemplate(), signal);\n throwIfAborted(signal);\n ctx.ui.notify(`Created ${configPath}. Add a storage connection and sync setup before syncing.`, \"info\");\n}\n\nasync function showConfig(ctx: ExtensionCommandContext, options: CommandOptions) {\n const config = await loadSettingsConfig(options.setup);\n throwIfAborted(options.signal);\n const warnings = [\n ...(config.backend.type === \"s3\" ? sessionTokenWarnings(config.backend.profile) : []),\n ...syncSessionsWarnings(config),\n ];\n const storageLines = configStorageLines(config);\n ctx.ui.notify(\n [\n \"pi-sync config:\",\n `sync setup: ${config.setupName}`,\n `storage connection: ${config.connectionName}`,\n ...storageLines,\n `storage path: ${config.storagePath}`,\n `automatic sync: ${automaticSyncSummary(config.automatic)}`,\n `settings field merge: ${config.mergeSettings ? \"On\" : \"Off\"}`,\n `machine-local settings.json fields: ${(config.localFields ?? []).map(safeTerminalText).join(\", \") || \"none\"}`,\n `startup transfer: ${startupTransferSummary(config)}`,\n `autonomous sync: ${config.agentMode ? \"On\" : \"Off\"}`,\n `continuous sync: ${config.continuous ? (config.agentMode ? \"On\" : \"paused; Autonomous sync is Off\") : \"Off\"}`,\n config.scope ? \"sync scope: Pi agent directory\" : `included content: ${config.include.join(\", \") || \"none\"}`,\n ...(config.pathPolicy === \"ignore-file\"\n ? [\"path policy: local ignore file\", manualIgnoreFileGuidance(config.ignoreFile ?? \".syncignore\")]\n : config.scope\n ? [\n `excluded paths: ${config.exclude?.map(safeTerminalText).join(\", \") || \"none\"}`,\n `re-included paths: ${config.reinclude?.map(safeTerminalText).join(\", \") || \"none\"}`,\n ]\n : []),\n `sessions: ${syncSessionsSelected(config) ? \"included\" : \"not included\"}`,\n `settings file: ${localConfigPath()}`,\n ...warnings,\n ].join(\"\\n\"),\n warnings.length > 0 ? \"warning\" : \"info\",\n );\n}\n\nfunction configStorageLines(config: AnySyncConfig) {\n switch (config.backend.type) {\n case \"git\":\n return [\n \"kind: git\",\n `remote: ${displayGitRemote(config.backend.profile.remote)}`,\n \"authentication: existing Git/SSH credentials (not stored)\",\n `branch: ${config.backend.destination.branch}`,\n ];\n case \"webdav\":\n return [\n \"kind: webdav\",\n `url: ${displayWebDavUrl(config.backend.profile.url, config.backend.profile.username)}`,\n \"username: configured (value hidden)\",\n \"password: configured\",\n ];\n case \"s3\":\n return [\n \"kind: s3\",\n `endpoint: ${config.backend.profile.endpoint}`,\n `bucket: ${config.backend.destination.bucket}`,\n `region: ${config.backend.profile.region}`,\n \"access key id: configured\",\n \"secret access key: configured\",\n `session token: ${config.backend.profile.sessionToken ? \"configured\" : \"not configured\"}`,\n ];\n }\n}\n\nfunction displayGitRemote(value: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n } catch {\n return value.replace(/^(?:[^@\\s]+@)?(?<host>[^:]+):.+$/u, \"$<host>:\u2026\");\n }\n}\n\nfunction displayWebDavUrl(value: string | undefined, username: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return username ? `${url.origin}/\u2026` : `${url.origin}${url.pathname}`;\n } catch {\n return \"invalid (value hidden)\";\n }\n}\n", "import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { currentPiDaemonClient } from \"../daemon/pi-client.js\";\nimport { loadConfig } from \"../settings/config.js\";\nimport { readStateForConfig, syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { combineSignals } from \"../sync/signals.js\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { formatRemoteSelectionMismatch } from \"../sync/sync-policy.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport {\n observationMatchesConfig,\n type SyncAttentionController,\n type SyncAttentionOrigin,\n syncAttentionMatchesConfig,\n} from \"../ui/sync-attention.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { parseOptions, splitArgs, validateCommandOptions } from \"./command.js\";\nimport { executeCommand, executeRecoveryCommand } from \"./command-execution.js\";\n\nexport async function handleCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n sessionSignal: AbortSignal,\n loaders: SyncLoaders,\n attention: SyncAttentionController,\n onExplicitSync?: (setup?: string) => void,\n needsDaemonRecovery?: () => boolean,\n) {\n const args = splitArgs(rawArgs);\n if (args[0] === \"daemon\" && args[1] === \"recover\") {\n await executeCommand(rawArgs, ctx, sessionSignal, loaders);\n return;\n }\n if (!needsDaemonRecovery?.()) await reconcileObservation(attention, sessionSignal);\n if (sessionSignal.aborted) return;\n const run = (\n route: string,\n signal?: AbortSignal,\n onCommit?: () => void,\n target?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n directionalFingerprint?: string,\n requirePendingAdoption?: boolean,\n ) => {\n const [command, ...args] = splitArgs(route);\n if (command === \"sync\" && !retryRefusal) {\n try {\n const options = parseOptions(args);\n validateCommandOptions(\"sync\", options);\n onExplicitSync?.(target ?? options.setup);\n } catch {\n /* Invalid routes do not request an automatic retry. */\n }\n }\n return executeCommand(\n route,\n ctx,\n combineSignals(sessionSignal, signal),\n loaders,\n observationCommitCallback(attention, sessionSignal, onCommit),\n target,\n onDialog,\n retryRefusal,\n directionalFingerprint,\n requirePendingAdoption,\n );\n };\n if (!rawArgs.trim()) {\n attention.expand();\n try {\n const { showSyncManager } = await import(\"../ui/manager-ui.js\");\n if (sessionSignal.aborted) return;\n await showSyncManager(ctx, run, sessionSignal, {\n needsDaemonRecovery,\n getPendingPullReview: () => currentPiDaemonClient()?.pendingPullReview,\n getAttention: () => attention.current(),\n getObservation: () => attention.observation(),\n onObservationInvalidated: () => attention.clearObservation(),\n onSelectionResolved: (expected) => {\n if (attention.current() === expected) attention.clear(ctx);\n },\n });\n } catch (error) {\n if (sessionSignal.aborted) return;\n setSyncStatus(ctx, undefined);\n ctx.ui.notify(errorMessage(error), \"error\");\n }\n if (sessionSignal.aborted || needsDaemonRecovery?.()) return;\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n return;\n }\n const result = await run(rawArgs);\n if (sessionSignal.aborted || needsDaemonRecovery?.()) return;\n if (result.kind === \"decision-required\") {\n ctx.ui.notify(result.decision.directMessage, \"error\");\n } else if (result.kind === \"remote-selection-required\") {\n const origin = directSelectionOrigin(rawArgs);\n if (origin) attention.set(result.decision, origin);\n const deterministic = splitArgs(rawArgs).some((arg) => arg === \"--yes\" || arg === \"-y\");\n if (origin && ctx.mode === \"tui\" && !deterministic) {\n await resolveSelectionAttention(ctx, attention, sessionSignal, loaders);\n } else {\n ctx.ui.notify(\n formatRemoteSelectionMismatch(\n result.decision.setupName,\n result.decision.localInclude,\n result.decision.remoteInclude,\n ),\n \"error\",\n );\n }\n }\n await clearAttentionAfterCompletedOperation(rawArgs, result, ctx, attention, sessionSignal);\n await reconcileSelectionAttention(ctx, attention, sessionSignal);\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n}\n\nfunction observationCommitCallback(\n attention: SyncAttentionController,\n sessionSignal: AbortSignal,\n onCommit?: () => void,\n) {\n const observed = attention.observation();\n return () => {\n // Opening or cancelling a review changes nothing. A commit may change data\n // even if later publication/baseline cleanup fails; never restore old hints.\n if (!sessionSignal.aborted && attention.observation() === observed) attention.clearObservation();\n onCommit?.();\n };\n}\n\nasync function reconcileObservation(attention: SyncAttentionController, signal: AbortSignal) {\n const observed = attention.observation();\n if (!observed || signal.aborted) return;\n try {\n const config = await loadConfig();\n if (signal.aborted || attention.observation() !== observed) return;\n if (!observationMatchesConfig(observed, config)) {\n attention.clearObservation();\n return;\n }\n const state = await readStateForConfig(config);\n if (signal.aborted || attention.observation() !== observed) return;\n if (syncStateFingerprint(state) !== observed.inspection.stateIdentity) attention.clearObservation();\n } catch {\n if (!signal.aborted && attention.observation() === observed) attention.clearObservation();\n }\n}\n\nasync function clearAttentionAfterCompletedOperation(\n rawArgs: string,\n result: RunRouteResult,\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n if (result.kind !== \"completed\" || result.outcome === \"cancelled\" || signal.aborted) return;\n const [command, ...rest] = splitArgs(rawArgs);\n if (command !== \"sync\" && command !== \"pull\" && command !== \"push\") return;\n const current = attention.current();\n if (!current) return;\n try {\n const options = parseOptions(rest);\n const setupName = options.setup ?? (await loadConfig()).setupName;\n if (signal.aborted || attention.current() !== current) return;\n if (current.decision.setupName === setupName) attention.clear(ctx);\n } catch {\n // Attention reconciliation below owns malformed or concurrently changed settings.\n }\n}\n\nasync function reconcileSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n try {\n const config = await loadConfig(current.decision.setupName);\n if (signal.aborted || attention.current() !== current) return;\n if (!syncAttentionMatchesConfig(current, config)) attention.clear(ctx);\n } catch {\n if (!signal.aborted && attention.current() === current) attention.clear(ctx);\n }\n}\n\nfunction directSelectionOrigin(rawArgs: string): SyncAttentionOrigin | undefined {\n const command = splitArgs(rawArgs)[0];\n return command === \"sync\" || command === \"pull\" || command === \"push\" ? command : undefined;\n}\n\nexport async function resolveSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n loaders: SyncLoaders,\n options: {\n cancelLabel?: string;\n withStateAccess?: <T>(task: () => Promise<T>) => Promise<T>;\n } = {},\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n const { dispatchManagerResult } = await import(\"../ui/manager-result-dispatcher.js\");\n if (signal.aborted || attention.current() !== current) return;\n await dispatchManagerResult(\n ctx,\n { kind: \"remote-selection-required\", decision: current.decision },\n current.origin,\n (route, actionSignal, onCommit, target) => {\n const execute = () =>\n executeRecoveryCommand(\n route,\n ctx,\n combineSignals(signal, actionSignal),\n loaders,\n observationCommitCallback(attention, signal, onCommit),\n target,\n );\n return options.withStateAccess ? options.withStateAccess(execute) : execute();\n },\n signal,\n {\n cancelLabel: options.cancelLabel,\n withStateAccess: options.withStateAccess,\n onSelectionResolved: () => {\n if (attention.current() === current) attention.clear(ctx);\n },\n },\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;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-runtime.mjs; do not edit.
2
+ // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
+ import {
4
+ configFromSettings,
5
+ createSettingsConfigView,
6
+ isEnabled,
7
+ isExplicitlyEnabled,
8
+ loadConfig,
9
+ loadConfigForCheck,
10
+ loadPartialConfig,
11
+ loadSettingsConfig,
12
+ sessionTokenWarnings,
13
+ syncCheckConfigFingerprint,
14
+ syncConfigReviewFingerprint,
15
+ syncConfigReviewIdentity,
16
+ syncSessionsWarnings,
17
+ syncSettingsConfigFingerprint,
18
+ syncSetupReviewIdentity,
19
+ syncSetupStorageReview
20
+ } from "./chunk-3NS4PMCI.ts";
21
+ export {
22
+ configFromSettings,
23
+ createSettingsConfigView,
24
+ isEnabled,
25
+ isExplicitlyEnabled,
26
+ loadConfig,
27
+ loadConfigForCheck,
28
+ loadPartialConfig,
29
+ loadSettingsConfig,
30
+ sessionTokenWarnings,
31
+ syncCheckConfigFingerprint,
32
+ syncConfigReviewFingerprint,
33
+ syncConfigReviewIdentity,
34
+ syncSessionsWarnings,
35
+ syncSettingsConfigFingerprint,
36
+ syncSetupReviewIdentity,
37
+ syncSetupStorageReview
38
+ };
39
+ //# sourceMappingURL=config-P54GGMXY.ts.map
@@ -2,7 +2,7 @@
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
3
  import {
4
4
  remoteOperation
5
- } from "./chunk-JQ5BAWW2.ts";
5
+ } from "./chunk-C3E75DXW.ts";
6
6
  import "./chunk-H7VOTY5N.ts";
7
7
  import "./chunk-6YKOHBSC.ts";
8
8
  import "./chunk-R3SAMXB6.ts";
@@ -15,4 +15,4 @@ async function showConflicts(ctx, options) {
15
15
  export {
16
16
  showConflicts
17
17
  };
18
- //# sourceMappingURL=conflict-review-J7L7S4AR.ts.map
18
+ //# sourceMappingURL=conflict-review-OBBBSVQD.ts.map
@@ -2,7 +2,7 @@
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
3
  import {
4
4
  showDirectoryScope
5
- } from "./chunk-BYVHABNR.ts";
5
+ } from "./chunk-2MUAR5GH.ts";
6
6
  import {
7
7
  manualIgnoreFileGuidance
8
8
  } from "./chunk-EJDDRS6O.ts";
@@ -20,16 +20,16 @@ import {
20
20
  agentDir
21
21
  } from "./chunk-P4GI7LTT.ts";
22
22
  import "./chunk-ZO52JM4H.ts";
23
- import {
24
- loadSettingsConfig,
25
- syncCheckConfigFingerprint
26
- } from "./chunk-DAZZ5BEJ.ts";
27
23
  import {
28
24
  BUILT_IN_SYNC_ROOTS,
29
25
  isSafeCustomIncludePath,
30
26
  normalizeSyncInclude,
31
27
  syncIncludeSelection
32
28
  } from "./chunk-R3SAMXB6.ts";
29
+ import {
30
+ loadSettingsConfig,
31
+ syncCheckConfigFingerprint
32
+ } from "./chunk-3NS4PMCI.ts";
33
33
  import "./chunk-2JNFEZ3V.ts";
34
34
 
35
35
  // src/ui/file-selection.ts
@@ -300,4 +300,4 @@ function safeTerminalText(value) {
300
300
  export {
301
301
  showFileSelection
302
302
  };
303
- //# sourceMappingURL=file-selection-XWACUTAH.ts.map
303
+ //# sourceMappingURL=file-selection-GASCVN45.ts.map
@@ -4,13 +4,13 @@ import {
4
4
  ignoreFileSettingsAvailable,
5
5
  portableIgnoreRulesAvailable,
6
6
  showIgnoreFileAction
7
- } from "./chunk-Z5JMOXJM.ts";
7
+ } from "./chunk-I72HGZJJ.ts";
8
8
  import "./chunk-KNEUL4XN.ts";
9
- import "./chunk-AYGMIMCV.ts";
10
- import "./chunk-GELYN4UC.ts";
11
- import "./chunk-JQ5BAWW2.ts";
9
+ import "./chunk-C3E75DXW.ts";
12
10
  import "./chunk-H7VOTY5N.ts";
11
+ import "./chunk-PUSMSKIM.ts";
13
12
  import "./chunk-6YKOHBSC.ts";
13
+ import "./chunk-GELYN4UC.ts";
14
14
  import "./chunk-R3SAMXB6.ts";
15
15
  import "./chunk-2JNFEZ3V.ts";
16
16
  export {
@@ -18,4 +18,4 @@ export {
18
18
  portableIgnoreRulesAvailable,
19
19
  showIgnoreFileAction
20
20
  };
21
- //# sourceMappingURL=ignore-file-ui-OHFISFVC.ts.map
21
+ //# sourceMappingURL=ignore-file-ui-5BWA6LBC.ts.map
@@ -2,19 +2,19 @@
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
3
  import {
4
4
  dispatchManagerResult
5
- } from "./chunk-BESRBKVO.ts";
6
- import "./chunk-5YOLQKNZ.ts";
5
+ } from "./chunk-2MSJDLSM.ts";
6
+ import "./chunk-UF2HU2NM.ts";
7
7
  import "./chunk-UMPA5S7X.ts";
8
- import "./chunk-AYGMIMCV.ts";
8
+ import "./chunk-H7VOTY5N.ts";
9
+ import "./chunk-PUSMSKIM.ts";
10
+ import "./chunk-6YKOHBSC.ts";
9
11
  import "./chunk-NXWHPVXR.ts";
10
12
  import "./chunk-GELYN4UC.ts";
11
13
  import "./chunk-ZO52JM4H.ts";
12
- import "./chunk-DAZZ5BEJ.ts";
13
- import "./chunk-H7VOTY5N.ts";
14
- import "./chunk-6YKOHBSC.ts";
15
14
  import "./chunk-R3SAMXB6.ts";
15
+ import "./chunk-3NS4PMCI.ts";
16
16
  import "./chunk-2JNFEZ3V.ts";
17
17
  export {
18
18
  dispatchManagerResult
19
19
  };
20
- //# sourceMappingURL=manager-result-dispatcher-WXE2BAQO.ts.map
20
+ //# sourceMappingURL=manager-result-dispatcher-MJ6G2CEI.ts.map
@@ -18,26 +18,26 @@ import {
18
18
  showEditS3Target,
19
19
  showEditWebDavStorageProfile,
20
20
  showEditWebDavTarget
21
- } from "./chunk-ASU3GZPW.ts";
21
+ } from "./chunk-GRXNUC6O.ts";
22
22
  import {
23
23
  automaticSyncSummary
24
24
  } from "./chunk-ECYCNZOE.ts";
25
25
  import {
26
26
  ignoreFileSettingsAvailable,
27
27
  showIgnoreFileAction
28
- } from "./chunk-Z5JMOXJM.ts";
28
+ } from "./chunk-I72HGZJJ.ts";
29
29
  import "./chunk-KNEUL4XN.ts";
30
30
  import {
31
31
  dispatchManagerResult
32
- } from "./chunk-BESRBKVO.ts";
33
- import "./chunk-5YOLQKNZ.ts";
32
+ } from "./chunk-2MSJDLSM.ts";
33
+ import "./chunk-UF2HU2NM.ts";
34
34
  import {
35
35
  SETUP_SWITCH_ACTION_OPTIONS,
36
36
  saveOnSwitch,
37
37
  setupSwitchActionFromLabel,
38
38
  setupSwitchActionLabel,
39
39
  useSyncSetup
40
- } from "./chunk-SZJOUVCL.ts";
40
+ } from "./chunk-DGVZYS7T.ts";
41
41
  import {
42
42
  isCloudflareR2Endpoint,
43
43
  normalizeS3Endpoint,
@@ -59,10 +59,16 @@ import {
59
59
  readStateForConfig,
60
60
  syncAttentionMatchesConfig,
61
61
  syncStateFingerprint
62
- } from "./chunk-FI2F5JBS.ts";
62
+ } from "./chunk-3Q3DMMID.ts";
63
+ import {
64
+ piDaemonClient
65
+ } from "./chunk-C3E75DXW.ts";
63
66
  import {
64
67
  throwIfAborted
65
68
  } from "./chunk-UMPA5S7X.ts";
69
+ import {
70
+ configureSyncStatus
71
+ } from "./chunk-H7VOTY5N.ts";
66
72
  import {
67
73
  AUTOMATIC_SYNC_DESCRIPTION,
68
74
  STARTUP_TRANSFER_DESCRIPTION,
@@ -70,14 +76,17 @@ import {
70
76
  } from "./chunk-XUZV4OGI.ts";
71
77
  import {
72
78
  confirmMergeReview
73
- } from "./chunk-WJQ4TGN5.ts";
79
+ } from "./chunk-ECUCXF5Y.ts";
74
80
  import {
75
81
  runCancellableOperation
76
- } from "./chunk-AYGMIMCV.ts";
82
+ } from "./chunk-PUSMSKIM.ts";
83
+ import {
84
+ errorMessage
85
+ } from "./chunk-6YKOHBSC.ts";
77
86
  import {
78
87
  directoryScopeSummary,
79
88
  showExcludedPaths
80
- } from "./chunk-BYVHABNR.ts";
89
+ } from "./chunk-2MUAR5GH.ts";
81
90
  import {
82
91
  manualIgnoreFileGuidance
83
92
  } from "./chunk-EJDDRS6O.ts";
@@ -103,6 +112,12 @@ import {
103
112
  import {
104
113
  sameSyncExclude
105
114
  } from "./chunk-ZO52JM4H.ts";
115
+ import {
116
+ compareSyncInclude,
117
+ syncIncludeSelection,
118
+ syncSelectionHasContent,
119
+ syncSessionsSelected
120
+ } from "./chunk-R3SAMXB6.ts";
106
121
  import {
107
122
  configFromSettings,
108
123
  createSettingsConfigView,
@@ -112,22 +127,7 @@ import {
112
127
  loadSettingsConfig,
113
128
  syncCheckConfigFingerprint,
114
129
  syncConfigReviewIdentity
115
- } from "./chunk-DAZZ5BEJ.ts";
116
- import {
117
- piDaemonClient
118
- } from "./chunk-JQ5BAWW2.ts";
119
- import {
120
- configureSyncStatus
121
- } from "./chunk-H7VOTY5N.ts";
122
- import {
123
- errorMessage
124
- } from "./chunk-6YKOHBSC.ts";
125
- import {
126
- compareSyncInclude,
127
- syncIncludeSelection,
128
- syncSelectionHasContent,
129
- syncSessionsSelected
130
- } from "./chunk-R3SAMXB6.ts";
130
+ } from "./chunk-3NS4PMCI.ts";
131
131
  import {
132
132
  safeTerminalText
133
133
  } from "./chunk-2JNFEZ3V.ts";
@@ -224,7 +224,7 @@ function blockedSyncMenuItem(label, manager) {
224
224
  };
225
225
  }
226
226
  async function showManagerAttention(ctx, attention, runRoute, signal, onSelectionResolved) {
227
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-E4XZCQ7A.ts");
227
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-34WC7OFE.ts");
228
228
  if (signal?.aborted) return "close";
229
229
  const review = await showRemoteSelectionReview(ctx, attention.decision.setupName, signal, void 0, {
230
230
  decision: attention.decision,
@@ -2072,7 +2072,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
2072
2072
  "remote-include": async ({ state, signal: actionSignal }) => {
2073
2073
  if (state.reservedIgnoreNames !== void 0 && !ignoreAvailable) return { kind: "rejected" };
2074
2074
  const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
2075
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-E4XZCQ7A.ts");
2075
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-34WC7OFE.ts");
2076
2076
  if (reviewSignal.aborted) return { kind: "rejected" };
2077
2077
  const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, void 0, {
2078
2078
  origin: "settings",
@@ -2277,6 +2277,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
2277
2277
  cancelledMessage: direction === "push" ? "Push cancellation requested." : "Pull cancellation requested.",
2278
2278
  target: review.setupName,
2279
2279
  directionalFingerprint: review.fingerprint,
2280
+ requirePendingAdoption: state.manager.recoveryPull,
2280
2281
  signal,
2281
2282
  isCurrent
2282
2283
  }
@@ -2329,7 +2330,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
2329
2330
  if (!attention) {
2330
2331
  const observation = state.manager.observation;
2331
2332
  if (!observation) return { kind: "stay" };
2332
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-E4XZCQ7A.ts");
2333
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-34WC7OFE.ts");
2333
2334
  if (sessionSignal?.aborted) return { kind: "close" };
2334
2335
  const config = await loadConfig();
2335
2336
  if (sessionSignal?.aborted) return { kind: "close" };
@@ -2534,7 +2535,14 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2534
2535
  const activate = menu.actions[action];
2535
2536
  menu.actions[action] = async (invocation) => {
2536
2537
  validateOwner();
2537
- const { configReview, settingsReview } = invocation.state.manager;
2538
+ const { configReview, settingsReview, recoveryPull } = invocation.state.manager;
2539
+ if (action === "pull" && recoveryPull) {
2540
+ if (options.getPendingPullReview?.() !== configReview) {
2541
+ ctx.ui.notify("The original Pull is no longer available for automatic recovery.", "warning");
2542
+ return { kind: "stay" };
2543
+ }
2544
+ return activate(invocation);
2545
+ }
2538
2546
  const review = action === "settings" ? settingsReview ?? configReview : configReview;
2539
2547
  let current = false;
2540
2548
  try {
@@ -2575,8 +2583,18 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2575
2583
  title: "Pi Sync recovery required\nDaemon cleanup could not be confirmed. Stop the daemon before retrying a transfer.",
2576
2584
  actions: ["Stop daemon for recovery\u2026", "Help"]
2577
2585
  };
2586
+ const describeRecovery = () => {
2587
+ const configReview = options.getPendingPullReview?.();
2588
+ if (!configReview) return recovery;
2589
+ return {
2590
+ title: "Pi Sync recovery required\nPull can try to recover the daemon and review the pending transfer.",
2591
+ actions: ["Pull from remote", ...recovery.actions],
2592
+ configReview,
2593
+ recoveryPull: true
2594
+ };
2595
+ };
2578
2596
  const describe = async (signal) => {
2579
- if (options.needsDaemonRecovery?.()) return recovery;
2597
+ if (options.needsDaemonRecovery?.()) return describeRecovery();
2580
2598
  const pendingAttention = options.getAttention?.();
2581
2599
  const observation = options.getObservation?.();
2582
2600
  const manager = await describeManagerState(
@@ -2587,7 +2605,7 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2587
2605
  () => ignoreFileSettingsAvailable(ctx, signal)
2588
2606
  );
2589
2607
  if (signal.aborted || !isCurrent()) return manager;
2590
- if (options.needsDaemonRecovery?.()) return recovery;
2608
+ if (options.needsDaemonRecovery?.()) return describeRecovery();
2591
2609
  if (observation && options.getObservation?.() === observation && !manager.observation && !(manager.operation && operationBlocksChanges(manager.operation))) {
2592
2610
  options.onObservationInvalidated?.();
2593
2611
  }
@@ -2663,4 +2681,4 @@ function syncMainMenuItem(label) {
2663
2681
  export {
2664
2682
  showSyncManager
2665
2683
  };
2666
- //# sourceMappingURL=manager-ui-DWOMAJKE.ts.map
2684
+ //# sourceMappingURL=manager-ui-Z3B5ZTA6.ts.map