@narumitw/pi-sync 0.60.5 → 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 (80) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +8 -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-6KIWZ4AY.ts → chunk-E3YLRLJM.ts} +5 -4
  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-F64YWRXG.ts → chunk-EMVZL4PH.ts} +2 -2
  16. package/dist/chunks/{chunk-YVH5VJR4.ts → chunk-JVFCVPPD.ts} +104 -50
  17. package/dist/chunks/chunk-JVFCVPPD.ts.map +7 -0
  18. package/dist/chunks/{chunk-MCUZFUHY.ts → chunk-PJMM75W5.ts} +6 -6
  19. package/dist/chunks/{chunk-V2QIMC3U.ts → chunk-S7F4FOAS.ts} +10 -5
  20. package/dist/chunks/chunk-S7F4FOAS.ts.map +7 -0
  21. package/dist/chunks/{chunk-6W2SNZ5P.ts → chunk-YQSFJLJ3.ts} +6 -2
  22. package/dist/chunks/{chunk-6W2SNZ5P.ts.map → chunk-YQSFJLJ3.ts.map} +3 -3
  23. package/dist/chunks/{chunk-V4AMI3VL.ts → chunk-ZVGRZD4C.ts} +9 -1
  24. package/dist/chunks/chunk-ZVGRZD4C.ts.map +7 -0
  25. package/dist/chunks/{command-handler-TNPWFIPG.ts → command-handler-K4XJOGYC.ts} +41 -37
  26. package/dist/chunks/{command-handler-TNPWFIPG.ts.map → command-handler-K4XJOGYC.ts.map} +2 -2
  27. package/dist/chunks/{conflict-review-ETCSYJTH.ts → conflict-review-IGKY2TOJ.ts} +3 -3
  28. package/dist/chunks/{file-selection-DD6X4J2K.ts → file-selection-MGGVOKM7.ts} +26 -13
  29. package/dist/chunks/file-selection-MGGVOKM7.ts.map +7 -0
  30. package/dist/chunks/{manager-result-dispatcher-2GFNWHDM.ts → manager-result-dispatcher-4VJVDEUD.ts} +7 -6
  31. package/dist/chunks/{manager-ui-LFONXWQN.ts → manager-ui-KYQ5AZJS.ts} +134 -203
  32. package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +7 -0
  33. package/dist/chunks/{remote-selection-ui-GFR6TDTX.ts → remote-selection-ui-W3KOZM3W.ts} +6 -5
  34. package/dist/chunks/{setup-switch-SPZE7HIQ.ts → setup-switch-D6K6PBPC.ts} +3 -3
  35. package/dist/chunks/{setup-wizard-5JYKAEIT.ts → setup-wizard-4DYUDHJR.ts} +13 -11
  36. package/dist/chunks/setup-wizard-4DYUDHJR.ts.map +7 -0
  37. package/dist/chunks/{sync-inspection-6VGR2UVZ.ts → sync-inspection-J3CRBORL.ts} +5 -5
  38. package/dist/chunks/{sync-operations-SAKAZL6Z.ts → sync-operations-BVWYYKH3.ts} +3 -3
  39. package/dist/index.ts +21 -21
  40. package/package.json +4 -4
  41. package/skills/configure-pi-sync/references/configuration.md +59 -32
  42. package/src/commands/command-execution.ts +7 -1
  43. package/src/daemon/pi-client.ts +1 -0
  44. package/src/sync/sync-policy.ts +5 -0
  45. package/src/ui/agent-mode-setting.ts +9 -1
  46. package/src/ui/excluded-paths-ui.ts +154 -2
  47. package/src/ui/file-selection.ts +12 -7
  48. package/src/ui/manager-state.ts +13 -8
  49. package/src/ui/remote-selection-ui.ts +120 -27
  50. package/src/ui/settings-frame.ts +2 -8
  51. package/src/ui/settings-ui.ts +51 -26
  52. package/src/ui/setup/directory-rules.ts +81 -0
  53. package/src/ui/setup/git-ui.ts +14 -24
  54. package/src/ui/setup/s3-ui.ts +13 -26
  55. package/src/ui/setup/setup-actions.ts +0 -4
  56. package/src/ui/setup/setup-prompts.ts +99 -17
  57. package/src/ui/setup/setup-switcher.ts +4 -2
  58. package/src/ui/setup/setup-wizard.ts +5 -4
  59. package/src/ui/setup/webdav-ui.ts +13 -27
  60. package/src/ui/storage-connections-ui.ts +2 -2
  61. package/src/ui/sync-attention.ts +8 -3
  62. package/src/ui/sync-format.ts +8 -1
  63. package/src/ui/sync-setups-ui.ts +5 -3
  64. package/dist/chunks/chunk-6KIWZ4AY.ts.map +0 -7
  65. package/dist/chunks/chunk-KPWZNMKM.ts.map +0 -7
  66. package/dist/chunks/chunk-LAXTCSX4.ts.map +0 -7
  67. package/dist/chunks/chunk-V2QIMC3U.ts.map +0 -7
  68. package/dist/chunks/chunk-V4AMI3VL.ts.map +0 -7
  69. package/dist/chunks/chunk-YVH5VJR4.ts.map +0 -7
  70. package/dist/chunks/file-selection-DD6X4J2K.ts.map +0 -7
  71. package/dist/chunks/manager-ui-LFONXWQN.ts.map +0 -7
  72. package/dist/chunks/setup-wizard-5JYKAEIT.ts.map +0 -7
  73. /package/dist/chunks/{chunk-F64YWRXG.ts.map → chunk-EMVZL4PH.ts.map} +0 -0
  74. /package/dist/chunks/{chunk-MCUZFUHY.ts.map → chunk-PJMM75W5.ts.map} +0 -0
  75. /package/dist/chunks/{conflict-review-ETCSYJTH.ts.map → conflict-review-IGKY2TOJ.ts.map} +0 -0
  76. /package/dist/chunks/{manager-result-dispatcher-2GFNWHDM.ts.map → manager-result-dispatcher-4VJVDEUD.ts.map} +0 -0
  77. /package/dist/chunks/{remote-selection-ui-GFR6TDTX.ts.map → remote-selection-ui-W3KOZM3W.ts.map} +0 -0
  78. /package/dist/chunks/{setup-switch-SPZE7HIQ.ts.map → setup-switch-D6K6PBPC.ts.map} +0 -0
  79. /package/dist/chunks/{sync-inspection-6VGR2UVZ.ts.map → sync-inspection-J3CRBORL.ts.map} +0 -0
  80. /package/dist/chunks/{sync-operations-SAKAZL6Z.ts.map → sync-operations-BVWYYKH3.ts.map} +0 -0
@@ -1,42 +1,5 @@
1
1
  // @generated by scripts/build-runtime.mjs; do not edit.
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
- import {
4
- dispatchManagerResult
5
- } from "./chunk-F64YWRXG.ts";
6
- import {
7
- captureMutationOwner,
8
- runCancellableOperation
9
- } from "./chunk-YVH5VJR4.ts";
10
- import {
11
- SETUP_SWITCH_ACTION_OPTIONS,
12
- saveOnSwitch,
13
- setupSwitchActionFromLabel,
14
- setupSwitchActionLabel,
15
- useSyncSetup
16
- } from "./chunk-MCUZFUHY.ts";
17
- import {
18
- observationMatchesConfig,
19
- observationSummary,
20
- readStateForConfig,
21
- syncAttentionMatchesConfig,
22
- syncStateFingerprint
23
- } from "./chunk-V2QIMC3U.ts";
24
- import {
25
- normalizeSyncExclude,
26
- sameSyncExclude
27
- } from "./chunk-HEB6YT64.ts";
28
- import {
29
- confirmMergeReview
30
- } from "./chunk-GSQGBVKG.ts";
31
- import {
32
- loadConfig,
33
- loadPartialConfig,
34
- syncCheckConfigFingerprint,
35
- syncConfigReviewIdentity
36
- } from "./chunk-277VHM2P.ts";
37
- import {
38
- configureSyncStatus
39
- } from "./chunk-H7VOTY5N.ts";
40
3
  import {
41
4
  applyS3CredentialUpdate,
42
5
  chooseS3CredentialUpdate,
@@ -45,7 +8,6 @@ import {
45
8
  refreshTargetCompletions,
46
9
  requiredInput,
47
10
  requiredValueInput,
48
- saveReviewedDraft,
49
11
  showAddGitStorageProfile,
50
12
  showAddGitTarget,
51
13
  showAddS3Target,
@@ -56,30 +18,68 @@ import {
56
18
  showEditS3Target,
57
19
  showEditWebDavStorageProfile,
58
20
  showEditWebDavTarget
59
- } from "./chunk-LAXTCSX4.ts";
21
+ } from "./chunk-4KTJLJSJ.ts";
22
+ import {
23
+ dispatchManagerResult
24
+ } from "./chunk-EMVZL4PH.ts";
25
+ import {
26
+ SETUP_SWITCH_ACTION_OPTIONS,
27
+ saveOnSwitch,
28
+ setupSwitchActionFromLabel,
29
+ setupSwitchActionLabel,
30
+ useSyncSetup
31
+ } from "./chunk-PJMM75W5.ts";
60
32
  import {
61
33
  isCloudflareR2Endpoint,
62
34
  normalizeS3Endpoint,
63
35
  ownRecord
64
36
  } from "./chunk-OA4NZLSL.ts";
65
37
  import {
66
- automaticSyncSummary,
67
- syncErrorGuidance
68
- } from "./chunk-KPWZNMKM.ts";
38
+ automaticSyncSummary
39
+ } from "./chunk-ECYCNZOE.ts";
69
40
  import {
70
41
  loadOnSwitch,
71
42
  readLocalConfigObject,
72
43
  requireSettings,
73
44
  updateLocalConfig
74
45
  } from "./chunk-WP2M67XZ.ts";
46
+ import {
47
+ observationMatchesConfig,
48
+ observationSummary,
49
+ readStateForConfig,
50
+ syncAttentionMatchesConfig,
51
+ syncStateFingerprint
52
+ } from "./chunk-S7F4FOAS.ts";
75
53
  import {
76
54
  AUTOMATIC_SYNC_DESCRIPTION,
77
55
  STARTUP_TRANSFER_DESCRIPTION,
78
56
  startupTransferSummary
79
57
  } from "./chunk-HLCML3OW.ts";
58
+ import {
59
+ confirmMergeReview
60
+ } from "./chunk-GSQGBVKG.ts";
61
+ import {
62
+ directoryScopeSummary,
63
+ showExcludedPaths
64
+ } from "./chunk-2ZGV5KNC.ts";
65
+ import {
66
+ directorySessionOptInLine,
67
+ saveReviewedDraft
68
+ } from "./chunk-2JHAN3ZO.ts";
69
+ import {
70
+ activeLocalConfigPath,
71
+ localConfigPath,
72
+ syncErrorGuidance
73
+ } from "./chunk-YQSFJLJ3.ts";
74
+ import {
75
+ runCancellableOperation
76
+ } from "./chunk-JVFCVPPD.ts";
80
77
  import {
81
78
  throwIfAborted
82
79
  } from "./chunk-S3R3W3KF.ts";
80
+ import {
81
+ captureMutationOwner
82
+ } from "./chunk-4SR3ZYHA.ts";
83
83
  import {
84
84
  addStorageConnection,
85
85
  removeStorageConnection,
@@ -88,23 +88,32 @@ import {
88
88
  updateSyncSetup
89
89
  } from "./chunk-EMRFVLZM.ts";
90
90
  import {
91
- activeLocalConfigPath,
92
- localConfigPath
93
- } from "./chunk-6W2SNZ5P.ts";
91
+ sameSyncExclude
92
+ } from "./chunk-HEB6YT64.ts";
93
+ import {
94
+ loadConfig,
95
+ loadPartialConfig,
96
+ syncCheckConfigFingerprint,
97
+ syncConfigReviewIdentity
98
+ } from "./chunk-277VHM2P.ts";
99
+ import {
100
+ configureSyncStatus
101
+ } from "./chunk-H7VOTY5N.ts";
94
102
  import {
95
103
  errorMessage
96
104
  } from "./chunk-ZIL6PW5L.ts";
97
- import {
98
- safeTerminalText
99
- } from "./chunk-2JNFEZ3V.ts";
100
105
  import {
101
106
  compareSyncInclude,
102
107
  syncIncludeSelection,
108
+ syncSelectionHasContent,
103
109
  syncSessionsSelected
104
- } from "./chunk-V4AMI3VL.ts";
110
+ } from "./chunk-ZVGRZD4C.ts";
111
+ import {
112
+ safeTerminalText
113
+ } from "./chunk-2JNFEZ3V.ts";
105
114
 
106
115
  // src/ui/manager-ui.ts
107
- import { defineMenu as defineMenu6, runDocumentReview, runMenu as runMenu6 } from "@narumitw/pi-tui-kit";
116
+ import { defineMenu as defineMenu5, runDocumentReview, runMenu as runMenu5 } from "@narumitw/pi-tui-kit";
108
117
 
109
118
  // src/state/operation-availability.ts
110
119
  import {
@@ -142,7 +151,7 @@ function blockedSyncMenuItem(label, manager) {
142
151
  };
143
152
  }
144
153
  async function showManagerAttention(ctx, attention, runRoute, signal, onSelectionResolved) {
145
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-GFR6TDTX.ts");
154
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-W3KOZM3W.ts");
146
155
  if (signal?.aborted) return "close";
147
156
  const review = await showRemoteSelectionReview(ctx, attention.decision.setupName, signal, void 0, {
148
157
  decision: attention.decision,
@@ -357,8 +366,8 @@ async function loadSetupMenuState(selectedName, signal) {
357
366
  `Storage connection: ${safeTerminalText(config.connectionName)}`,
358
367
  `Endpoint: ${storageEndpoint(config)}`,
359
368
  `Storage location: ${storageLocation(config)}`,
360
- `Included content: ${selection.builtIns.length} built-in groups \xB7 ${selection.custom.length} extra paths`,
361
- `Sessions: ${selection.sessions ? "On \u2014 privacy-sensitive" : "Off"}`,
369
+ config.scope ? `Sync scope: Pi agent directory \xB7 ${config.exclude?.length ?? 0} exclusions \xB7 ${config.reinclude?.length ?? 0} exceptions` : `Included content: ${selection.builtIns.length} built-in groups \xB7 ${selection.custom.length} extra paths`,
370
+ `Sessions: ${syncSessionsSelected(config) ? "On \u2014 privacy-sensitive" : "Off"}`,
362
371
  `Automatic sync: ${config.automatic ? "On" : "Off"}`,
363
372
  `Automatic transfer at startup: ${config.automaticTransfer ? "On \u2014 may upload, replace, or delete selected files; no reload" : "Off"}`,
364
373
  `Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
@@ -452,7 +461,7 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
452
461
  };
453
462
  }
454
463
  const configuredTargets = ownRecord(raw.syncSetups);
455
- if ((raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6) && configuredTargets && Object.keys(configuredTargets).length === 0) {
464
+ if ((raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6 || raw.version === 7) && configuredTargets && Object.keys(configuredTargets).length === 0) {
456
465
  return {
457
466
  title: [
458
467
  "Manage sync",
@@ -481,7 +490,8 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
481
490
  }
482
491
  const attentionComparison = currentAttention ? compareSyncInclude(currentAttention.decision.localInclude, currentAttention.decision.remoteInclude) : void 0;
483
492
  const attentionExclusionsDiffer = currentAttention ? !sameSyncExclude(currentAttention.decision.localExclude, currentAttention.decision.remoteExclude) : false;
484
- const noSyncedContent = config.include.length === 0;
493
+ const attentionDirectoryPolicy = currentAttention?.decision.localDirectory || currentAttention?.decision.remoteDirectory;
494
+ const noSyncedContent = !syncSelectionHasContent(config);
485
495
  const syncState = changesBlocked ? void 0 : await readStateForConfig(config).catch(() => void 0);
486
496
  const currentObservation = observation && observationMatchesConfig(observation, config) && syncState && syncStateFingerprint(syncState) === observation.inspection.stateIdentity ? observation : void 0;
487
497
  const lastAppliedSnapshot = changesBlocked ? "Unavailable while operations are locked" : syncState?.lastAppliedSnapshot ? `${truncateToWidth(safeTerminalText(syncState.lastAppliedSnapshot), 12, "\u2026")} \xB7 application time unavailable` : syncState ? "Never synced" : "Unavailable";
@@ -496,10 +506,11 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
496
506
  "Manage sync",
497
507
  `Current sync setup: ${safeTerminalText(config.setupName)}`,
498
508
  `Storage: ${backendStorageDescription(config)}`,
509
+ ...config.scope ? ["Sync scope: Pi agent directory, with exclusions"] : [],
499
510
  ...syncState?.unresolved?.length ? [`Unresolved: ${syncState.unresolved.length} dependency groups \xB7 review needed`] : [],
500
511
  ...currentAttention ? [
501
512
  currentAttention.decision.setupName === config.setupName ? "Sync status: Review needed" : `Sync status: Review needed for setup ${safeTerminalText(currentAttention.decision.setupName)}`,
502
- attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0 ? attentionExclusionsDiffer ? "Synced-content exclusion rules differ." : "Only the synced-content order differs." : `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} \xB7 Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " \xB7 Exclusion rules differ." : ""}`
513
+ attentionDirectoryPolicy ? "Sync scopes or directory rules differ." : attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0 ? attentionExclusionsDiffer ? "Synced-content exclusion rules differ." : "Only the synced-content order differs." : `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} \xB7 Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " \xB7 Exclusion rules differ." : ""}`
503
514
  ] : currentObservation ? [`Observed ${safeTerminalText(currentObservation.checkedAt)}: ${observationSummary(currentObservation)}`] : ["Remote status: Not checked"],
504
515
  `Last applied: ${lastAppliedSnapshot}`,
505
516
  ...config.agentMode ? ["Auto-apply: On \xB7 AI requests may incur costs"] : config.automaticTransfer || config.automatic && syncSessionsSelected(config) ? ["Automatic transfer permission: On \xB7 see Settings"] : [],
@@ -611,7 +622,7 @@ function backendStorageDescription(config) {
611
622
  }
612
623
 
613
624
  // src/ui/settings-ui.ts
614
- import { defineMenu as defineMenu5, runMenu as runMenu5 } from "@narumitw/pi-tui-kit";
625
+ import { defineMenu as defineMenu4, runMenu as runMenu4 } from "@narumitw/pi-tui-kit";
615
626
 
616
627
  // src/sync/local-fields.ts
617
628
  import {
@@ -647,7 +658,12 @@ async function saveAgentMode(ctx, setupName, enabled, signal, preference = "agen
647
658
  `Storage path: ${safeTerminalText(setup.storage.path)}`,
648
659
  ...setup.storage.bucket ? [`Bucket: ${safeTerminalText(String(setup.storage.bucket))}`] : [],
649
660
  ...setup.storage.branch ? [`Branch: ${safeTerminalText(String(setup.storage.branch))}`] : [],
650
- `Included paths: ${setup.sync.include.map(safeTerminalText).join(", ")}`,
661
+ ...setup.sync.scope ? [
662
+ "Sync scope: all eligible files in the Pi agent directory.",
663
+ directorySessionOptInLine(setup.sync.sessions),
664
+ `Excluded paths: ${setup.sync.exclude?.map(safeTerminalText).join(", ") || "none"}`,
665
+ `Re-included paths: ${setup.sync.reinclude?.map(safeTerminalText).join(", ") || "none"}`
666
+ ] : [`Included paths: ${setup.sync.include.map(safeTerminalText).join(", ")}`],
651
667
  continuous ? CONTINUOUS_DESCRIPTION : AGENT_MODE_DESCRIPTION,
652
668
  ...continuous ? [
653
669
  "Upgrade all Pi processes sharing this agent directory before enabling Continuous sync. Monitoring starts after the /sync command or manager closes. An elected idle local session uses its selected Pi model; another session can use a different provider/model. Each computer is a separate replica.",
@@ -683,105 +699,6 @@ async function saveAgentMode(ctx, setupName, enabled, signal, preference = "agen
683
699
  return true;
684
700
  }
685
701
 
686
- // src/ui/excluded-paths-ui.ts
687
- import { defineMenu as defineMenu2, runMenu as runMenu2 } from "@narumitw/pi-tui-kit";
688
- async function showExcludedPaths(ctx, setupName, signal) {
689
- const validate = captureMutationOwner(ctx, signal);
690
- const isCurrent = () => {
691
- try {
692
- validate();
693
- return true;
694
- } catch {
695
- return false;
696
- }
697
- };
698
- validate();
699
- const config = await loadConfig(setupName);
700
- validate();
701
- if (ctx.mode !== "tui") {
702
- if (ctx.hasUI)
703
- ctx.ui.notify(
704
- [
705
- `Excluded paths: ${(config.exclude ?? []).map(safeTerminalText).join(", ") || "none"}`,
706
- `Edit sync.exclude in ${safeTerminalText(localConfigPath())}; an explicit array requires settings version 6.`
707
- ].join("\n"),
708
- "info"
709
- );
710
- return;
711
- }
712
- let draft = JSON.stringify(config.exclude ?? []);
713
- while (isCurrent()) {
714
- const entered = await ctx.ui.input("Excluded paths \xB7 JSON array \xB7 empty input keeps draft", draft, { signal });
715
- if (!isCurrent() || entered === void 0) return;
716
- const input = entered || draft;
717
- draft = input;
718
- let exclude;
719
- try {
720
- const parsed = JSON.parse(input);
721
- if (!Array.isArray(parsed)) throw new Error("Enter a JSON string array.");
722
- exclude = normalizeSyncExclude(parsed);
723
- } catch {
724
- ctx.ui.notify("Invalid exclude array or unsupported pattern. No settings changed.", "error");
725
- continue;
726
- }
727
- if (sameSyncExclude(exclude, config.exclude)) return;
728
- let choice;
729
- const menu = defineMenu2({
730
- start: "review",
731
- screens: {
732
- review: () => ({
733
- kind: "actions",
734
- title: "Review excluded paths",
735
- lines: [
736
- `Setup: ${safeTerminalText(config.setupName)}`,
737
- "Draft only. Save opts into settings version 6 / snapshot version 4; older clients must refuse them.",
738
- "Excluded local files stay untouched. New snapshots omit matching remote files; old history is NOT erased.",
739
- "Removing rules can expose local content or allow pull to replace it. Review a force push to publish policy changes.",
740
- "Previously excluded:",
741
- ...config.exclude?.length ? config.exclude.map((rule) => `- ${safeTerminalText(rule)}`) : ["(none)"],
742
- "Proposed excluded paths:",
743
- ...exclude.length ? exclude.map((rule) => `+ ${safeTerminalText(rule)}`) : ["(none)"]
744
- ],
745
- items: [
746
- { id: "save", label: "Save changes", action: "choose" },
747
- { id: "discard", label: "Discard changes", action: "choose" },
748
- { id: "edit", label: "Continue editing", action: "choose" }
749
- ],
750
- hint: "close"
751
- })
752
- },
753
- actions: {
754
- choose: async ({ itemId }) => {
755
- choice = itemId === "save" ? "save" : itemId === "edit" ? "edit" : "discard";
756
- return { kind: "close" };
757
- }
758
- }
759
- });
760
- await runMenu2(ctx, menu, { getState: () => void 0, signal, isCurrent });
761
- if (!isCurrent()) return;
762
- if (choice === "edit") continue;
763
- if (choice !== "save") return;
764
- try {
765
- await updateSyncSetup(
766
- setupName,
767
- (setup) => {
768
- validate();
769
- return { ...setup, sync: { ...setup.sync, exclude } };
770
- },
771
- { expectedConfigFingerprint: syncCheckConfigFingerprint(config), upgradeExclude: true, signal }
772
- );
773
- if (isCurrent()) ctx.ui.notify("Excluded paths saved. Applies to subsequent sync; no transfer started.", "info");
774
- } catch (error) {
775
- if (isCurrent())
776
- ctx.ui.notify(
777
- `Excluded paths not saved: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
778
- "error"
779
- );
780
- }
781
- return;
782
- }
783
- }
784
-
785
702
  // src/ui/settings-frame.ts
786
703
  import { stripVTControlCharacters } from "node:util";
787
704
  function boundedSettingsUI(ctx) {
@@ -828,11 +745,11 @@ function boundedSettingsUI(ctx) {
828
745
 
829
746
  // src/ui/storage-connections-ui.ts
830
747
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
831
- import { defineMenu as defineMenu3, runMenu as runMenu3 } from "@narumitw/pi-tui-kit";
748
+ import { defineMenu as defineMenu2, runMenu as runMenu2 } from "@narumitw/pi-tui-kit";
832
749
  async function showStorageConnections(ctx, signal) {
833
750
  let selectedName;
834
751
  const nameById = /* @__PURE__ */ new Map();
835
- const menu = defineMenu3({
752
+ const menu = defineMenu2({
836
753
  start: "list",
837
754
  screens: {
838
755
  list: ({ state }) => {
@@ -925,7 +842,7 @@ async function showStorageConnections(ctx, signal) {
925
842
  }
926
843
  }
927
844
  });
928
- await runMenu3(ctx, menu, {
845
+ await runMenu2(ctx, menu, {
929
846
  getState: () => loadStorageMenuState(selectedName, signal),
930
847
  signal,
931
848
  isCurrent: () => !signal?.aborted
@@ -938,14 +855,14 @@ async function loadStorageMenuState(selectedName, signal) {
938
855
  const profile = selectedName ? ownRecord(profiles[selectedName]) : void 0;
939
856
  if (!selectedName || !profile) {
940
857
  return {
941
- supportedVersion: raw?.version === 3 || raw?.version === 4 || raw?.version === 5 || raw?.version === 6,
858
+ supportedVersion: raw !== void 0,
942
859
  profiles,
943
860
  selected: void 0
944
861
  };
945
862
  }
946
863
  const usedBy = referencingSetups(raw, selectedName);
947
864
  return {
948
- supportedVersion: raw?.version === 3 || raw?.version === 4 || raw?.version === 5 || raw?.version === 6,
865
+ supportedVersion: raw !== void 0,
949
866
  profiles,
950
867
  selected: {
951
868
  name: selectedName,
@@ -1141,12 +1058,12 @@ function credentialSource(profile) {
1141
1058
  }
1142
1059
 
1143
1060
  // src/ui/setup/setup-switcher.ts
1144
- import { defineMenu as defineMenu4, runMenu as runMenu4 } from "@narumitw/pi-tui-kit";
1061
+ import { defineMenu as defineMenu3, runMenu as runMenu3 } from "@narumitw/pi-tui-kit";
1145
1062
  async function selectSetupForSwitch(ctx, raw, targets, active, signal) {
1146
1063
  let selectedName;
1147
1064
  const nameById = /* @__PURE__ */ new Map();
1148
1065
  const profiles = ownRecord(raw.storageConnections);
1149
- const menu = defineMenu4({
1066
+ const menu = defineMenu3({
1150
1067
  start: "setups",
1151
1068
  screens: {
1152
1069
  setups: () => ({
@@ -1178,7 +1095,7 @@ async function selectSetupForSwitch(ctx, raw, targets, active, signal) {
1178
1095
  }
1179
1096
  }
1180
1097
  });
1181
- await runMenu4(ctx, menu, {
1098
+ await runMenu3(ctx, menu, {
1182
1099
  getState: () => void 0,
1183
1100
  signal,
1184
1101
  isCurrent: () => !signal?.aborted
@@ -1188,7 +1105,7 @@ async function selectSetupForSwitch(ctx, raw, targets, active, signal) {
1188
1105
  async function showSetupSwitcher(ctx, runRoute, selectedName, signal) {
1189
1106
  const raw = await readLocalConfigObject();
1190
1107
  if (signal?.aborted) return false;
1191
- if (raw?.version !== 3 && raw?.version !== 4 && raw?.version !== 5 && raw?.version !== 6) {
1108
+ if (!raw) {
1192
1109
  ctx.ui.notify("Add a second sync setup before switching setups.", "info");
1193
1110
  return false;
1194
1111
  }
@@ -1231,7 +1148,7 @@ async function showSetupSwitcher(ctx, runRoute, selectedName, signal) {
1231
1148
  `From: ${safeTerminalText(active ?? "none")}`,
1232
1149
  `To: ${safeTerminalText(name)}`,
1233
1150
  `Storage: ${backendStorageDescription(config)}`,
1234
- `Included content: ${config.include.length} paths`,
1151
+ config.scope === "agent-directory" ? `Scope: Pi agent directory \xB7 ${config.exclude?.length ?? 0} excluded and ${config.reinclude?.length ?? 0} re-included rules` : `Included content: ${config.include.length} paths`,
1235
1152
  `Automatic sync: ${automaticSyncSummary(config.automatic)} \xB7 Sessions: ${syncSessionsSelected(config) ? "On" : "Off"}`,
1236
1153
  `Automatic transfer at startup: ${config.automaticTransfer ? "On \u2014 may upload, replace, or delete selected files; no reload" : "Off"}`,
1237
1154
  `Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
@@ -1310,10 +1227,6 @@ async function showAddTarget(ctx, signal) {
1310
1227
  let raw = await readLocalConfigObject();
1311
1228
  if (signal?.aborted) return;
1312
1229
  if (!raw) return void ctx.ui.notify("Set up the first sync setup before adding another.", "info");
1313
- if (raw.version !== 3 && raw.version !== 4 && raw.version !== 5 && raw.version !== 6) {
1314
- ctx.ui.notify("Version 1 and version 2 settings are unsupported and are never migrated.", "error");
1315
- return;
1316
- }
1317
1230
  let profiles = ownRecord(raw.storageConnections) ?? {};
1318
1231
  const name = await promptResourceName(ctx, "sync setup", "work", signal);
1319
1232
  if (!name) return;
@@ -1392,9 +1305,17 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1392
1305
  return { kind: "close" };
1393
1306
  };
1394
1307
  if (ctx.mode !== "tui") {
1395
- ctx.ui.notify(`Edit pi-sync settings manually: ${safeTerminalText(localConfigPath())}`, "info");
1396
1308
  if (ctx.mode === "rpc" && ctx.hasUI) {
1397
- const management = defineMenu5({
1309
+ const config = await loadConfig(reviewedSetup).catch(() => void 0);
1310
+ if (signal?.aborted) return disposition;
1311
+ ctx.ui.notify(
1312
+ [
1313
+ `Edit pi-sync settings manually: ${safeTerminalText(localConfigPath())}`,
1314
+ ...config?.scope === "agent-directory" ? directoryScopeSummary(config) : []
1315
+ ].join("\n"),
1316
+ "info"
1317
+ );
1318
+ const management = defineMenu4({
1398
1319
  start: "management",
1399
1320
  screens: {
1400
1321
  management: () => ({
@@ -1418,7 +1339,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1418
1339
  }
1419
1340
  }
1420
1341
  });
1421
- await runMenu5(ctx, management, { getState: () => void 0, signal, isCurrent: () => !signal?.aborted });
1342
+ await runMenu4(ctx, management, { getState: () => void 0, signal, isCurrent: () => !signal?.aborted });
1422
1343
  }
1423
1344
  return disposition;
1424
1345
  }
@@ -1426,7 +1347,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1426
1347
  if (signal?.aborted) return "back";
1427
1348
  const setupName = initial.setupName;
1428
1349
  let saveStatus = "Simple choices save immediately. Back does not undo saved changes.";
1429
- const menu = defineMenu5({
1350
+ const menu = defineMenu4({
1430
1351
  start: "settings",
1431
1352
  screens: {
1432
1353
  settings: ({ state }) => ({
@@ -1437,24 +1358,34 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1437
1358
  saveStatus
1438
1359
  ],
1439
1360
  items: [
1440
- {
1441
- id: "include",
1442
- label: "Included paths",
1443
- description: "This setup: choose paths in a draft, then review and Save or Discard. No transfer is started.",
1444
- currentValue: `${state.include.length} paths \xB7 Edit`,
1445
- action: "include"
1446
- },
1447
- {
1448
- id: "exclude",
1449
- label: "Excluded paths",
1450
- description: "This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
1451
- currentValue: `${state.exclude?.length ?? 0} rules \xB7 Edit`,
1452
- action: "exclude"
1453
- },
1361
+ ...state.scope === "agent-directory" ? [
1362
+ {
1363
+ id: "include",
1364
+ label: "Agent directory scope",
1365
+ description: "Edit exclusions, re-inclusions, and session opt-in in one reviewed draft. No transfer starts.",
1366
+ currentValue: `${state.exclude?.length ?? 0} excluded \xB7 ${state.reinclude?.length ?? 0} re-included \xB7 Sessions ${state.include.includes("sessions") ? "opted in" : "off"}`,
1367
+ action: "include"
1368
+ }
1369
+ ] : [
1370
+ {
1371
+ id: "include",
1372
+ label: "Included paths",
1373
+ description: "This setup: choose paths in a draft, then review and Save or Discard. No transfer is started.",
1374
+ currentValue: `${state.include.length} paths \xB7 Edit`,
1375
+ action: "include"
1376
+ },
1377
+ {
1378
+ id: "exclude",
1379
+ label: "Excluded paths",
1380
+ description: "This setup: draft relative paths or *, ?, ** patterns, then review Save/Discard. No transfer starts; old history is retained.",
1381
+ currentValue: `${state.exclude?.length ?? 0} rules \xB7 Edit`,
1382
+ action: "exclude"
1383
+ }
1384
+ ],
1454
1385
  {
1455
1386
  id: "remoteInclude",
1456
- label: "Compare included paths",
1457
- description: "This setup: compare include and exclude policies, not file contents. Review before saving both lists; no files transfer unless you explicitly Continue.",
1387
+ label: state.scope === "agent-directory" ? "Compare sync policies" : "Compare included paths",
1388
+ description: "Compare what sync manages on this device and the remote, not file contents. No files transfer unless you explicitly Continue.",
1458
1389
  currentValue: "Review",
1459
1390
  action: "remote-include"
1460
1391
  },
@@ -1537,7 +1468,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1537
1468
  {
1538
1469
  id: "contentPolicy",
1539
1470
  label: "Content merge / partial progress",
1540
- description: "This setup, opt-in: review the version-5 upgrade before saving. Merge bounded text and prefix-only sessions; partial progress keeps withheld versions and baselines. Applies to subsequent sync; disabling does not clear recovery evidence.",
1471
+ description: `This setup, opt-in: ${state.scope === "agent-directory" ? "review format compatibility" : "review the version-5 upgrade"} before saving. Merge bounded text and prefix-only sessions; partial progress keeps withheld versions and baselines. Applies to subsequent sync; disabling does not clear recovery evidence.`,
1541
1472
  currentValue: state.mergeContent ? state.partialSync ? "Merge + partial" : "Merge only" : state.partialSync ? "Partial only" : "Off",
1542
1473
  values: ["Off", "Merge only", "Merge + partial", "Partial only"],
1543
1474
  action: "content-policy"
@@ -1595,7 +1526,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1595
1526
  const partialSync = value === "Partial only" || value === "Merge + partial";
1596
1527
  if (!await ctx.ui.confirm(
1597
1528
  "Save content policy?",
1598
- "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them. Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.",
1529
+ `${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and snapshot version 5; older clients must refuse them." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
1599
1530
  { signal: mutationSignal }
1600
1531
  ))
1601
1532
  return { kind: "rejected" };
@@ -1604,11 +1535,11 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1604
1535
  await updateLocalConfig((current) => {
1605
1536
  validate();
1606
1537
  const setup = current.syncSetups[setupName];
1607
- if (!setup || Boolean(setup.sync.mergeContent) !== Boolean(previous.mergeContent) || Boolean(setup.sync.partialSync) !== Boolean(previous.partialSync))
1538
+ if (!setup || setup.sync.scope !== previous.scope || Boolean(setup.sync.mergeContent) !== Boolean(previous.mergeContent) || Boolean(setup.sync.partialSync) !== Boolean(previous.partialSync))
1608
1539
  throw new Error("Content policy changed during review.");
1609
1540
  return {
1610
1541
  ...current,
1611
- version: current.version === 6 ? 6 : 5,
1542
+ version: current.version >= 6 ? current.version : 5,
1612
1543
  syncSetups: {
1613
1544
  ...current.syncSetups,
1614
1545
  [setupName]: { ...setup, sync: { ...setup.sync, mergeContent, partialSync } }
@@ -1663,7 +1594,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1663
1594
  if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
1664
1595
  const confirmed = await ctx.ui.confirm(
1665
1596
  "Save portable field policy?",
1666
- "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain 6/4. Older clients must refuse them. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.",
1597
+ `${previous.scope === "agent-directory" ? "Agent directory scope keeps settings version 7 and snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
1667
1598
  { signal: mutationSignal }
1668
1599
  );
1669
1600
  validate();
@@ -1672,7 +1603,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1672
1603
  await updateLocalConfig((current) => {
1673
1604
  validate();
1674
1605
  const setup = current.syncSetups[setupName];
1675
- if (!setup || !sameLocalFields(setup.sync.localFields, previous.localFields))
1606
+ if (!setup || setup.sync.scope !== previous.scope || !sameLocalFields(setup.sync.localFields, previous.localFields))
1676
1607
  throw new Error("Field policy changed while under review; reopen settings.");
1677
1608
  return {
1678
1609
  ...current,
@@ -1855,7 +1786,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1855
1786
  },
1856
1787
  "remote-include": async ({ signal: actionSignal }) => {
1857
1788
  const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
1858
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-GFR6TDTX.ts");
1789
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-W3KOZM3W.ts");
1859
1790
  if (reviewSignal.aborted) return { kind: "rejected" };
1860
1791
  const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, void 0, {
1861
1792
  origin: "settings",
@@ -1902,7 +1833,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1902
1833
  return { kind: "close" };
1903
1834
  }
1904
1835
  }
1905
- await runMenu5({ ...ctx, ui: boundedSettingsUI(ctx) }, menu, {
1836
+ await runMenu4({ ...ctx, ui: boundedSettingsUI(ctx) }, menu, {
1906
1837
  getState: () => loadConfig(setupName),
1907
1838
  signal,
1908
1839
  isCurrent: () => !signal?.aborted
@@ -1937,7 +1868,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
1937
1868
  const operationFirst = manager.operation !== void 0 && manager.operation.kind !== "free";
1938
1869
  return operationFirst ? [...managerItems, ...attentionItems] : [...attentionItems, ...managerItems];
1939
1870
  };
1940
- const menu = defineMenu6({
1871
+ const menu = defineMenu5({
1941
1872
  start: "main",
1942
1873
  screens: {
1943
1874
  main: ({ state }) => ({
@@ -1970,7 +1901,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
1970
1901
  if (!attention) {
1971
1902
  const observation = state.manager.observation;
1972
1903
  if (!observation) return { kind: "stay" };
1973
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-GFR6TDTX.ts");
1904
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-W3KOZM3W.ts");
1974
1905
  if (sessionSignal?.aborted) return { kind: "close" };
1975
1906
  const config = await loadConfig();
1976
1907
  if (sessionSignal?.aborted) return { kind: "close" };
@@ -2222,7 +2153,7 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2222
2153
  }, customOptions)
2223
2154
  }
2224
2155
  };
2225
- await runMenu6(menuContext, menu, {
2156
+ await runMenu5(menuContext, menu, {
2226
2157
  getState: async () => {
2227
2158
  const pendingAttention = options.getAttention?.();
2228
2159
  const observation = options.getObservation?.();
@@ -2291,4 +2222,4 @@ function syncMainMenuItem(label) {
2291
2222
  export {
2292
2223
  showSyncManager
2293
2224
  };
2294
- //# sourceMappingURL=manager-ui-LFONXWQN.ts.map
2225
+ //# sourceMappingURL=manager-ui-KYQ5AZJS.ts.map