@narumitw/pi-sync 0.63.0 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +28 -18
- package/dist/chunks/{chunk-HLCML3OW.ts → chunk-4VKWHVUO.ts} +4 -3
- package/dist/chunks/chunk-4VKWHVUO.ts.map +7 -0
- package/dist/chunks/{chunk-27F5W7DX.ts → chunk-DAZZ5BEJ.ts} +3 -1
- package/dist/chunks/chunk-DAZZ5BEJ.ts.map +7 -0
- package/dist/chunks/{chunk-V76KCWHO.ts → chunk-F3VODLVQ.ts} +3 -3
- package/dist/chunks/{chunk-VQ47JBLF.ts → chunk-FI2F5JBS.ts} +2 -2
- package/dist/chunks/{chunk-S6FUUWV5.ts → chunk-NDEZ52SS.ts} +13 -13
- package/dist/chunks/{chunk-S6FUUWV5.ts.map → chunk-NDEZ52SS.ts.map} +1 -1
- package/dist/chunks/{chunk-UGS6RYDZ.ts → chunk-RW44KNFD.ts} +304 -70
- package/dist/chunks/chunk-RW44KNFD.ts.map +7 -0
- package/dist/chunks/{chunk-EXDWEFIJ.ts → chunk-TJ7YNITN.ts} +5 -5
- package/dist/chunks/{chunk-HSCAFOT5.ts → chunk-TZMVSTAM.ts} +5 -5
- package/dist/chunks/{chunk-SXCH4Q5O.ts → chunk-VPSC7BXM.ts} +3 -3
- package/dist/chunks/chunk-YT6PDRMM.ts +282 -0
- package/dist/chunks/chunk-YT6PDRMM.ts.map +7 -0
- package/dist/chunks/{command-handler-VINMQ7ZM.ts → command-handler-N45GY7AV.ts} +39 -27
- package/dist/chunks/command-handler-N45GY7AV.ts.map +7 -0
- package/dist/chunks/{conflict-review-PCDFRIVB.ts → conflict-review-5E4M44BA.ts} +2 -2
- package/dist/chunks/{file-selection-KID23GAD.ts → file-selection-DDQN4LVD.ts} +9 -9
- package/dist/chunks/{manager-result-dispatcher-GDB74IOP.ts → manager-result-dispatcher-FKW55L7I.ts} +5 -5
- package/dist/chunks/{manager-ui-YHDECYKI.ts → manager-ui-EV23DPZQ.ts} +104 -77
- package/dist/chunks/manager-ui-EV23DPZQ.ts.map +7 -0
- package/dist/chunks/{merge-review-SGDLMVS4.ts → merge-review-6YSLSMGS.ts} +3 -2
- package/dist/chunks/ownership-recovery-UDDHSDSZ.ts +59 -0
- package/dist/chunks/ownership-recovery-UDDHSDSZ.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-GPITNEBF.ts → remote-selection-ui-N4NMWFT2.ts} +4 -4
- package/dist/chunks/{setup-switch-L54X5U5I.ts → setup-switch-HY7K3442.ts} +4 -4
- package/dist/chunks/{setup-wizard-YO4MCPUF.ts → setup-wizard-LEKDQ3HK.ts} +9 -9
- package/dist/chunks/{sync-inspection-H2WX5SUT.ts → sync-inspection-OS2LVOLV.ts} +5 -5
- package/dist/chunks/{sync-operations-2MZAYHL2.ts → sync-operations-D3MDJUQQ.ts} +2 -2
- package/dist/daemon/dist/cli.js +2 -0
- package/dist/daemon/dist/client-transport.js +66 -0
- package/dist/daemon/dist/client.js +116 -86
- package/dist/daemon/dist/consent.js +33 -11
- package/dist/daemon/dist/daemon-debug.js +33 -0
- package/dist/daemon/dist/daemon-recovery.js +75 -0
- package/dist/daemon/dist/engine/backends/git/git-backend.js +39 -12
- package/dist/daemon/dist/engine/backends/git/git-runner.js +6 -1
- package/dist/daemon/dist/engine/backends/git/git-storage.js +5 -9
- package/dist/daemon/dist/engine/backends/publication-encoding.js +19 -0
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +10 -12
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +15 -26
- package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +10 -0
- package/dist/daemon/dist/engine/debug-log.js +134 -0
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +50 -14
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +11 -14
- package/dist/daemon/dist/engine/ignore/ignore-source.js +1 -1
- package/dist/daemon/dist/engine/paths.js +7 -1
- package/dist/daemon/dist/engine/settings/config-file.js +62 -17
- package/dist/daemon/dist/engine/settings/config.js +49 -14
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +30 -8
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +3 -1
- package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +32 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +34 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +50 -7
- package/dist/daemon/dist/engine/snapshot/snapshot.js +64 -25
- package/dist/daemon/dist/engine/state/lock.js +157 -17
- package/dist/daemon/dist/engine/sync/continuous-sync.js +35 -11
- package/dist/daemon/dist/engine/sync/initialization.js +2 -2
- package/dist/daemon/dist/engine/sync/local-fields.js +42 -19
- package/dist/daemon/dist/engine/sync/merged-sync.js +13 -10
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +18 -3
- package/dist/daemon/dist/engine/sync/session-push.js +13 -4
- package/dist/daemon/dist/engine/sync/startup-bootstrap.js +105 -0
- package/dist/daemon/dist/engine/sync/startup-recovery-evidence.js +37 -0
- package/dist/daemon/dist/engine/sync/startup-timings.js +80 -8
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +22 -4
- package/dist/daemon/dist/engine/sync/sync-inspection.js +4 -7
- package/dist/daemon/dist/engine/sync/sync-local.js +3 -1
- package/dist/daemon/dist/engine/sync/sync-mutations.js +13 -7
- package/dist/daemon/dist/engine/sync/sync-policy.js +9 -1
- package/dist/daemon/dist/engine/sync/sync-state.js +12 -4
- package/dist/daemon/dist/engine/ui/sync-format.js +23 -55
- package/dist/daemon/dist/engine/ui/transfer-review.js +3 -3
- package/dist/daemon/dist/engine-service.js +54 -10
- package/dist/daemon/dist/identity.js +36 -6
- package/dist/daemon/dist/index.js +2 -1
- package/dist/daemon/dist/monitor.js +20 -1
- package/dist/daemon/dist/paged-review.js +177 -0
- package/dist/daemon/dist/participant-ledger.js +149 -0
- package/dist/daemon/dist/protocol.js +4 -0
- package/dist/daemon/dist/server.js +268 -120
- package/dist/daemon/dist/service-host.js +29 -9
- package/dist/daemon/dist/state-wait-jobs.js +23 -0
- package/dist/daemon/dist/state-wait.js +34 -0
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +128 -48
- package/dist/index.ts.map +2 -2
- package/docs/continuous-sync-verification.md +2 -0
- package/docs/daemon-migration.md +30 -2
- package/docs/tui-contract.md +8 -2
- package/package.json +2 -2
- package/skills/configure-pi-sync/SKILL.md +119 -18
- package/skills/configure-pi-sync/references/configuration.md +88 -48
- package/src/commands/command-execution.ts +11 -3
- package/src/commands/command-handler.ts +10 -3
- package/src/commands/command.ts +3 -2
- package/src/daemon/client-debug.ts +45 -0
- package/src/daemon/ownership-recovery.ts +50 -0
- package/src/daemon/pi-client.ts +288 -63
- package/src/daemon/startup-bootstrap-client.ts +26 -0
- package/src/settings/config.ts +1 -0
- package/src/sync/automatic-sync.ts +61 -18
- package/src/sync/startup-check.ts +13 -5
- package/src/sync-extension.ts +46 -8
- package/src/ui/manager-state.ts +35 -24
- package/src/ui/manager-ui.ts +39 -18
- package/src/ui/merge-review.ts +75 -12
- package/src/ui/settings-ui.ts +2 -2
- package/src/ui/setup/webdav-ui.ts +1 -1
- package/src/ui/sync-confirmation.ts +81 -65
- package/src/ui/sync-setups-ui.ts +15 -12
- package/dist/chunks/chunk-27F5W7DX.ts.map +0 -7
- package/dist/chunks/chunk-GSQGBVKG.ts +0 -218
- package/dist/chunks/chunk-GSQGBVKG.ts.map +0 -7
- package/dist/chunks/chunk-HLCML3OW.ts.map +0 -7
- package/dist/chunks/chunk-UGS6RYDZ.ts.map +0 -7
- package/dist/chunks/command-handler-VINMQ7ZM.ts.map +0 -7
- package/dist/chunks/manager-ui-YHDECYKI.ts.map +0 -7
- /package/dist/chunks/{chunk-V76KCWHO.ts.map → chunk-F3VODLVQ.ts.map} +0 -0
- /package/dist/chunks/{chunk-VQ47JBLF.ts.map → chunk-FI2F5JBS.ts.map} +0 -0
- /package/dist/chunks/{chunk-EXDWEFIJ.ts.map → chunk-TJ7YNITN.ts.map} +0 -0
- /package/dist/chunks/{chunk-HSCAFOT5.ts.map → chunk-TZMVSTAM.ts.map} +0 -0
- /package/dist/chunks/{chunk-SXCH4Q5O.ts.map → chunk-VPSC7BXM.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-PCDFRIVB.ts.map → conflict-review-5E4M44BA.ts.map} +0 -0
- /package/dist/chunks/{file-selection-KID23GAD.ts.map → file-selection-DDQN4LVD.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-GDB74IOP.ts.map → manager-result-dispatcher-FKW55L7I.ts.map} +0 -0
- /package/dist/chunks/{merge-review-SGDLMVS4.ts.map → merge-review-6YSLSMGS.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-GPITNEBF.ts.map → remote-selection-ui-N4NMWFT2.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-L54X5U5I.ts.map → setup-switch-HY7K3442.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-YO4MCPUF.ts.map → setup-wizard-LEKDQ3HK.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-H2WX5SUT.ts.map → sync-inspection-OS2LVOLV.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-2MZAYHL2.ts.map → sync-operations-D3MDJUQQ.ts.map} +0 -0
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
# Pi Sync settings reference
|
|
2
2
|
|
|
3
3
|
This is the authoritative public settings reference for Pi Sync.
|
|
4
|
-
The
|
|
5
|
-
|
|
6
|
-
- [
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
- [Status
|
|
10
|
-
- [Secret scanning](#secret-scanning)
|
|
11
|
-
- [Autonomous sync](#autonomous-sync)
|
|
12
|
-
- [Continuous sync](#continuous-sync)
|
|
13
|
-
- [Daemon lifetime and unattended permission](#daemon-lifetime-and-unattended-permission)
|
|
14
|
-
- [Ignore-file policy](#ignore-file-policy)
|
|
15
|
-
- [Included content](#included-content)
|
|
16
|
-
- [Excluded paths](#excluded-paths)
|
|
17
|
-
- [Unsupported old settings and recovery](#unsupported-old-settings-and-recovery)
|
|
4
|
+
The configuration skill applies explicitly requested local settings and ignore-rule edits and investigates Pi Sync errors. The user performs operations that require a separate review.
|
|
5
|
+
|
|
6
|
+
- **Configure a setup:** [Required fields](#settings-ownership-and-required-fields), [Manager](#editing-in-the-manager), [Version 3 example](#complete-version-3-example), [Backends](#required-backend-shapes)
|
|
7
|
+
- **Choose what syncs:** [Ignore-file policy](#ignore-file-policy), [Legacy directory scope](#agent-directory-scope), [Included content](#included-content), [Excluded paths](#excluded-paths), [Machine-local settings fields](#settings-field-merge-and-machine-local-fields)
|
|
8
|
+
- **Manage automatic work:** [Controls and approval](#automatic-sync-controls), [Startup transfer](#automatic-startup-transfer), [Autonomous sync](#autonomous-sync), [Daemon lifetime](#daemon-lifetime-and-unattended-permission), [Continuous sync](#continuous-sync)
|
|
9
|
+
- **Handle problems:** [Status](#status-display), [Debug mode](#debug-mode), [Secret scanning](#secret-scanning), [Diagnostics](#diagnostics), [Local troubleshooting](#local-troubleshooting), [Merge and partial progress](#content-merge-and-partial-progress), [Old settings and recovery](#unsupported-old-settings-and-recovery)
|
|
18
10
|
|
|
19
11
|
## ⚙️ Settings
|
|
20
12
|
|
|
@@ -27,12 +19,12 @@ The canonical private user file is:
|
|
|
27
19
|
Pi's configured agent directory replaces `~/.pi/agent` when applicable.
|
|
28
20
|
Missing settings load as unconfigured without creating an agent directory, file, temporary file, or lock.
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Credentials stay in
|
|
22
|
+
Explicit setup creates the file atomically. On POSIX, Pi Sync creates and replaces it with mode `0600`.
|
|
23
|
+
Pi Sync processes coordinate settings access through `pi-sync.json.mutation-lock`. Editors that do not use the lock should not save during a Pi Sync settings operation. Within one process, reads wait for earlier writes, even those still waiting for the lock.
|
|
24
|
+
|
|
25
|
+
Under the lock, Pi Sync validates the existing and proposed documents before saving. Relabeling malformed, invalid, or unsupported settings as a supported version does not bypass validation. Pi Sync flushes a private temporary file and renames it over the canonical file without first moving the active file away.
|
|
26
|
+
|
|
27
|
+
Credentials stay in the private settings file and never appear in menus, reviews, status, notifications, errors, logs, or completion metadata.
|
|
36
28
|
|
|
37
29
|
A private `pi-sync.local.json` containing a valid supported document is copied byte-for-byte to `pi-sync.json`.
|
|
38
30
|
The old file remains as a recovery copy.
|
|
@@ -72,9 +64,9 @@ The four controls select separate behaviors:
|
|
|
72
64
|
- **Autonomous sync** (`sync.agentMode`, unchanged) allows eligible startup and **Sync now** transfers without another transfer confirmation, plus model assistance and disclosure for supported conflicts.
|
|
73
65
|
- **Continuous sync** (`sync.continuous`) adds recurring work only with Autonomous sync enabled.
|
|
74
66
|
|
|
75
|
-
If any setup
|
|
67
|
+
If any setup uses an ignore file, turning on these controls does not authorize transfers, even when the current setup uses a legacy policy. Enable the controls you need for the current setup, then use **Settings → Review automatic transfers** in TUI. Repeat the review after changing settings or rules. Work after the last Pi exits requires [separate permission](#daemon-lifetime-and-unattended-permission).
|
|
76
68
|
|
|
77
|
-
|
|
69
|
+
Invoking the configuration skill neither enables these controls nor grants transfer permission.
|
|
78
70
|
|
|
79
71
|
### Editing in the manager
|
|
80
72
|
|
|
@@ -89,15 +81,13 @@ Escape closes the screen without undoing successful saves.
|
|
|
89
81
|
Complex values retain their input/review flows.
|
|
90
82
|
This navigation change does not alter schema, defaults, automatic-sync behavior, or explicit opt-ins.
|
|
91
83
|
|
|
92
|
-
The
|
|
93
|
-
**
|
|
94
|
-
Last applied shows a compact snapshot ID with application time explicitly unavailable; full IDs remain in History.
|
|
95
|
-
It never uses snapshot creation time as application time.
|
|
84
|
+
The main menu shows cached status separately from transfer, inspection, and management actions. **Check remote status** and **View differences** run their checks only when selected.
|
|
85
|
+
**Last applied** shows a compact snapshot ID and marks application time as unavailable instead of substituting snapshot creation time. **History** shows the full IDs.
|
|
96
86
|
See the [TUI behavior contract](https://github.com/narumiruna/pi-extensions/blob/main/packages/pi-sync/docs/tui-contract.md) for scopes and transfer branches.
|
|
97
87
|
|
|
98
88
|
RPC reports the manual settings path and offers the existing setup/connection catalog dialogs, not the TUI preference or masked-credential editors.
|
|
99
89
|
Print/JSON do not support `/sync`; use the private settings file directly.
|
|
100
|
-
|
|
90
|
+
Command hints list `/sync status`, `/sync diff`, and `/sync help`.
|
|
101
91
|
|
|
102
92
|
### Complete version 3 example
|
|
103
93
|
|
|
@@ -251,14 +241,27 @@ Settings or private-state repair uses `repair`.
|
|
|
251
241
|
A request-window limit is not a currency budget; exhausted attempts for one candidate remain a model block, not a timer-based allowance reset.
|
|
252
242
|
Use the existing manager and **Check remote status** guidance to inspect recovery requirements rather than treating a short marker as a complete diagnosis.
|
|
253
243
|
|
|
254
|
-
|
|
244
|
+
<a id="debug-startup-timings"></a>
|
|
245
|
+
|
|
246
|
+
### Debug mode
|
|
247
|
+
|
|
248
|
+
The top-level user setting `debug` is an optional boolean and defaults to `false` for every setup. Use **/sync → Settings → Debug mode** or edit `<getAgentDir()>/pi-sync.json` (normally `~/.pi/agent/pi-sync.json`). UI changes save immediately through the existing ordered, atomic settings writer. There is no project or environment override.
|
|
249
|
+
|
|
250
|
+
Pi uses the saved value from session start, including `/reload`, new, resume, and fork, for client logging and timing display. The daemon uses the agent directory's validated setting for file logging, not a connected client's value. It applies changes at the next applicable owner, job, or Continuous sync cycle boundary without a restart. A missing or false `debug` value does not enable logging; the daemon can skip records when it cannot validate settings. Turning on Debug mode does not start a new check or transfer, or grant permission for work after Pi exits.
|
|
251
|
+
|
|
252
|
+
#### Shared log
|
|
255
253
|
|
|
256
|
-
|
|
257
|
-
Edit `<getAgentDir()>/pi-sync.json` (normally `~/.pi/agent/pi-sync.json`) or use **/sync → Settings → Debug startup timings**.
|
|
258
|
-
UI changes save immediately through the existing ordered, atomic settings writer; both manual and UI changes take effect on the next session start, including `/reload`, new, resume, and fork.
|
|
259
|
-
There is no project or environment override.
|
|
254
|
+
Pi Sync and the daemon append directly to one private file, `<getAgentDir()>/pi-sync.log` (normally `~/.pi/agent/pi-sync.log`). Each line is a JSON record. Filter the `source` field for `pi-sync` to see client initialization, connection and request outcomes, or `pi-sync-daemon` to see daemon owner, timing, job and Continuous sync outcomes. The daemon can record work that was already authorized to continue after Pi exits. Repeated successful unchanged polls do not add records. Print and JSON modes add no client log writes and do not launch a daemon to log.
|
|
260
255
|
|
|
261
|
-
|
|
256
|
+
Records use fixed events and outcomes rather than error text. They can include timestamps, process IDs, durations, counts, and an opaque operation ID when available, but not credentials, local paths, remote addresses, synced content, subprocess output, or model data. Neither timestamps nor file order prove which action caused another. The file is private (`0600` on POSIX when created). Logging is best effort: an unsafe file or write failure can leave records missing without causing a sync failure. The daemon's bounded operational `lifecycle.log` is separate and not controlled by Debug mode. Neither file is a recovery journal.
|
|
257
|
+
|
|
258
|
+
`pi-sync.log` at the agent root stays local regardless of the selection policy. Include and re-include rules cannot override this protection; the log cannot be used as an ignore file. If an older setup or remote snapshot included this name, preserve the local and remote data and review the reported settings or snapshot error. Do not force a pull or use the error as a reason to rewrite remote history. Protection does not erase previously retained snapshots.
|
|
259
|
+
|
|
260
|
+
Set `debug` to `false` or remove it to stop new logging at the boundaries above. Existing bytes remain; the log is not rotated or deleted automatically. Stop all Pi Sync clients and the daemon for that agent directory before archiving or removing the file. Store archives outside the agent directory, especially before downgrading to a version that may not protect this path. Review the file before sharing it.
|
|
261
|
+
|
|
262
|
+
#### Startup timing display
|
|
263
|
+
|
|
264
|
+
With `debug: true` at Pi session start, reports show local initialization after recovery and settings resolution, then background work when it ends.
|
|
262
265
|
The report shows one line per stage, followed by a total.
|
|
263
266
|
TUI reports are stored as custom session entries, so they remain in the transcript after `/reload` and later notifications without entering model context.
|
|
264
267
|
RPC reports remain notifications.
|
|
@@ -276,10 +279,7 @@ Interrupted stages are marked `interrupted`; cancelled or failed background work
|
|
|
276
279
|
Session replacement and shutdown suppress late reports from the old session.
|
|
277
280
|
Pausing Continuous sync cancels its active cycle and suppresses that cycle’s late report; it does not schedule another startup report on idle resume.
|
|
278
281
|
Labels and durations contain no credentials, paths, file contents, remote addresses, or error text.
|
|
279
|
-
|
|
280
|
-
Print/JSON produce no timing reports.
|
|
281
|
-
The setting does not enable automatic sync or transfer, change safety checks, or report manual/shutdown operations.
|
|
282
|
-
Set `debug` to `false` or remove it, then start a new session to disable reports.
|
|
282
|
+
TUI reports remain in session history even after debugging is disabled, without adding model messages. Print/JSON produce no timing reports. Manual and shutdown work do not produce these startup reports.
|
|
283
283
|
|
|
284
284
|
### Secret scanning
|
|
285
285
|
|
|
@@ -299,11 +299,25 @@ Authentication and transport failures give credentials/permissions or address/ne
|
|
|
299
299
|
Git reads remote snapshots and checks its local cache; write access is not tested.
|
|
300
300
|
WebDAV retains its isolated conditional-write/cleanup probe and repair of a missing active-snapshot history entry.
|
|
301
301
|
|
|
302
|
+
### Local troubleshooting
|
|
303
|
+
|
|
304
|
+
Use the first concrete error, not a generic recovery hint appended to it. Start with checks that do not contact storage or start the daemon.
|
|
305
|
+
|
|
306
|
+
| Error or symptom | Local check and next action |
|
|
307
|
+
| --- | --- |
|
|
308
|
+
| **Autonomous sync requires a separate policy review** | The selected setup has Autonomous sync enabled, but its current policy has no matching automatic-transfer approval. This does not mean that `pi-sync.json` is malformed. Check which setup the operation used and whether settings or rules changed. The user can review **Settings → Review automatic transfers** for the current setup or choose a reviewed directional push or pull. |
|
|
309
|
+
| **Agent directory changed or has an unsafe filesystem layout** | The local scan could not establish a stable filesystem view. Use file metadata to check the agent root, Pi's `settings.json`, the effective session directory (including any `--session-dir` override), and in-scope paths. Symlinks in the session directory path and hard-linked candidate files can trigger this error; ordinary symlinks encountered in the directory scan are skipped. Check whether another Pi process or editor is changing files during the scan. Do not change synchronization settings unless the evidence identifies a relevant setting; this error alone does not identify a path or field. |
|
|
310
|
+
| **Malformed or unsupported settings** | Check the canonical path and documented version and field constraints. Preserve the original private bytes and follow [settings recovery](#unsupported-old-settings-and-recovery); do not replace the document with defaults. |
|
|
311
|
+
| **Backend access or publication failure** | Use the reported error class to distinguish credentials, a missing location, transport, and publication safety. A 404 alone does not identify which remote resource is missing. If local checks are insufficient, explain the backend-specific effects of [Diagnostics](#diagnostics) and leave that action to the user. |
|
|
312
|
+
|
|
313
|
+
A local check does not verify remote connectivity or permissions. Diagnostics can stop at the same local scan error before backend checks run.
|
|
314
|
+
|
|
302
315
|
### Ignore-file policy
|
|
303
316
|
|
|
304
|
-
New TUI setups use `.syncignore` when the daemon advertises support. Existing setups
|
|
317
|
+
New TUI setups use `.syncignore` when the daemon advertises support. Existing setups keep their policy and can coexist with ignore-file setups in version 8.
|
|
318
|
+
To migrate a legacy setup, choose **Review migration now** when first offered in the TUI manager, or **Settings → Migrate to ignore file…** later. **Not now** defers the offer for that setup on this device; closing the prompt without a choice does not save a deferral. Review local and remote paths that enter or leave scope, including what the rules would do for future files. Legacy selected paths and `reinclude` rules do not always translate directly.
|
|
305
319
|
|
|
306
|
-
|
|
320
|
+
This version 8 `sync` fragment shows a setup using the default rule file. It is not a complete settings document or a substitute for review:
|
|
307
321
|
|
|
308
322
|
```json
|
|
309
323
|
{
|
|
@@ -314,22 +328,42 @@ For reference, the `sync` object of a version 8 setup using the default rule fil
|
|
|
314
328
|
}
|
|
315
329
|
```
|
|
316
330
|
|
|
317
|
-
|
|
331
|
+
#### Create or switch rule files
|
|
332
|
+
|
|
333
|
+
After confirmation, the daemon can create a missing default file on Linux, macOS, and Windows. If your filesystem does not support automatic creation, create a regular UTF-8 file using the exact path and starter text Pi Sync shows. Do not overwrite an existing file. Reopen the setup or migration and confirm the review.
|
|
334
|
+
|
|
335
|
+
The starter rules exclude, among other paths, Pi's top-level `git/` package checkouts:
|
|
318
336
|
|
|
319
337
|
```gitignore
|
|
338
|
+
/auth.json
|
|
339
|
+
/git/
|
|
320
340
|
/npm/
|
|
321
341
|
/sessions/
|
|
322
|
-
/auth.json
|
|
323
342
|
/truth.json
|
|
324
343
|
```
|
|
325
344
|
|
|
326
|
-
|
|
345
|
+
Pi Sync reuses a valid existing file, even an empty one. If creation was interrupted, it uses the starter rules recorded before the interruption, even after an upgrade.
|
|
346
|
+
To switch files, choose an existing regular file by its safe filename directly in the agent directory, not a path, symlink, or linked alias. Missing or unsafe rules block transfers. An absent default can inform a preview, but cannot authorize a transfer.
|
|
347
|
+
|
|
348
|
+
**Settings → Ignore file** shows the active path and offers a reviewed switch. `/sync files` shows the path, not matched files. There is no in-app rule save. Edit the existing file only when no sync review, transfer, or recovery is running. Check the affected paths and reopen the transfer review. The edit affects every setup using that file.
|
|
349
|
+
|
|
350
|
+
#### Matching and local protections
|
|
327
351
|
|
|
328
|
-
Use
|
|
352
|
+
Use `/` as the separator; escaped `/` is not supported. A leading `/` anchors a rule to the agent directory, and a trailing `/` matches a directory. Matching is case-sensitive on every device. Blank lines, comments, wildcards, and ordered `!` exceptions follow Git ignore patterns for a single root file. An exception cannot restore a child under an excluded parent. There are no nested or project rules.
|
|
329
353
|
|
|
330
|
-
|
|
354
|
+
Session sync requires both a separate opt-in and rules that allow sessions. The starter `/sessions/` still excludes them. Match sessions by their logical `sessions/` paths even if stored elsewhere. Loaded sessions stay protected during apply.
|
|
331
355
|
|
|
332
|
-
|
|
356
|
+
Pi credentials and trust (`auth.json` and `trust.json`), private Pi Sync files (settings, state, and the [debug log](#shared-log)), and `.syncignore` or its configured alternatives stay local regardless of the rules. `truth.json` is a starter exclusion, not Pi's trust file. Transfers do not replace or remove ignored local files, and exclusions do not erase retained snapshots or backups.
|
|
357
|
+
|
|
358
|
+
#### Transfer review and recovery
|
|
359
|
+
|
|
360
|
+
Setup, migration, rule-file switching, and edits neither start nor authorize transfers. Upgrade all peers before publishing a version 6 snapshot. It stores a policy fingerprint, not the filename or rule text. Use the same rule text and session opt-in on peers: even comment or whitespace changes can change the fingerprint. Do not copy rules from the remote.
|
|
361
|
+
|
|
362
|
+
A legacy or mismatched head requires separately reviewed directional policy publication. Neither `--yes` nor automatic work can authorize it. Inspect scope with `/sync diff` and review the direction in `/sync`. A pull cannot apply a foreign policy, and rollback requires compatible history. If the rules, setup, or head change, reopen the review.
|
|
363
|
+
|
|
364
|
+
If creation or transfer is blocked or interrupted, stop new work. Preserve the rule file, creation marker, journals, backups, and consent records. Use a compatible daemon to review recovery with the originating setup and exact source. If source or remote evidence differs, preserve it instead of forcing replay or deleting a marker. The old policy remains authoritative until settings commit; a verified starter or settings backup can remain after a failed save.
|
|
365
|
+
|
|
366
|
+
After any version 6 publication, downgrading the package alone is not rollback. Close incompatible clients, verify daemon exit, and review compatible local and remote restoration before resuming transfers. Keep retained history intact.
|
|
333
367
|
|
|
334
368
|
### Agent-directory scope
|
|
335
369
|
|
|
@@ -346,7 +380,7 @@ A legacy directory setup in a version 7 or later settings document can use:
|
|
|
346
380
|
|
|
347
381
|
The agent directory is Pi's active agent root, normally `~/.pi/agent/`. Every eligible file is selected unless excluded. A re-inclusion restores an excluded path and only the descendants its rule matches. Literal directories match their subtrees. Rules are relative to the agent root; `sessions/` and `sessions` are equivalent in this scope. The `*`, `?`, and `**` syntax below applies to both lists. List order does not affect matching. If both lists are omitted, all eligible files are selected; the setup wizard saves its starter exclusions explicitly instead of adding them on every read.
|
|
348
382
|
|
|
349
|
-
Pi's `auth.json`, `trust.json`, their locks, and Pi Sync's settings and service state cannot be re-included. Pi's settings lock, dynamic model catalog cache and its lock, `crashes.json`, and `pi-
|
|
383
|
+
Pi's `auth.json`, `trust.json`, their locks, and Pi Sync's settings and service state cannot be re-included. Pi's settings lock, dynamic model catalog cache and its lock, `crashes.json`, `pi-debug.log`, and [Pi Sync's `pi-sync.log`](#shared-log) also stay local. Session paths remain local until explicitly enabled with `sync.sessions: true` (and not still excluded by a rule). The interactive flow requires a privacy acknowledgement. Symlinks are not followed. Agent-directory transfers do not move Pi's session storage root. Before moving a custom session store yourself, remove its old copy from the agent directory or exclude its old path explicitly. Pi Sync protects the current and default session locations, not unidentified old copies. Review what will transfer; the secret scan cannot identify every sensitive file.
|
|
350
384
|
|
|
351
385
|
The agent-directory scan and projected transfer result are limited to 64 MiB of file content, 16,384 files, and 65,536 visited entries. The projected result counts retained protected sessions and entries such as empty directories that are not stored in a snapshot. Directional apply and merged apply rescan before planned deletions and again before writes. The projection uses current sizes for retained files, but it does not lock out unrelated writers. `settings.json` has a separate 1 MiB limit for session routing. If local files change after review, reopen the transfer preview. A directory replacement is refused if it would remove an unreviewed or excluded descendant.
|
|
352
386
|
|
|
@@ -523,8 +557,14 @@ Parent model prompts and tools are not changed.
|
|
|
523
557
|
This is configuration isolation, not an OS sandbox or proof of semantic correctness.
|
|
524
558
|
|
|
525
559
|
Eligible text is global `AGENTS.md` and `.md`/`.txt` files under `prompts/` or `skills/`.
|
|
526
|
-
Global `settings.json`
|
|
527
|
-
|
|
560
|
+
Global `settings.json` follows the existing strict JSON, numeric, coupled-field, unknown-field, and machine-local-field policies. With Autonomous sync enabled, Pi Sync treats `packages` differently from other arrays and nested objects, which remain atomic:
|
|
561
|
+
|
|
562
|
+
- Pi Sync matches packages by source identity. When an npm package is present on both sides with different explicit SemVer versions, the higher version wins, even if one side is unchanged from the verified ancestor. No registry lookup occurs. Equal SemVer precedence preserves a one-sided source edit but requires atomic selection for divergent edits.
|
|
563
|
+
- Per-package merging requires matching filters and unchanged non-npm entries across the local, remote, and ancestor versions. One side may change the ordered npm identity list, or both sides may make the same change. Conflicting order or membership changes require atomic selection to preserve insertion positions and resource precedence.
|
|
564
|
+
- Changed Git refs and local path aliases require atomic selection rather than merging them as separate sources. Delete/upgrade conflicts, duplicate identities, incompatible filters, version ranges, and tags also retain atomic selection when deterministic merging is not possible.
|
|
565
|
+
- An existing local or remote array keeps its JSON spelling if it matches the merged result. Accepted settings files keep their original bytes unless Pi Sync must replace `packages`; then only that value changes.
|
|
566
|
+
|
|
567
|
+
The model does not resolve code/scripts, keybindings, binaries, unknown formats, session histories, deletion/modification conflicts, path collisions, or session-root transitions.
|
|
528
568
|
Existing deterministic merges still follow their own explicit settings.
|
|
529
569
|
Unsupported or refused groups remain unresolved; only an explicitly enabled `partialSync` policy permits progress around them.
|
|
530
570
|
Preserving versions does not mean a conflict is resolved.
|
|
@@ -94,7 +94,11 @@ export async function executeCommand(
|
|
|
94
94
|
case "daemon": {
|
|
95
95
|
const client = piDaemonClient(ctx);
|
|
96
96
|
const action = options.args[0] ?? "status";
|
|
97
|
-
if (action === "
|
|
97
|
+
if (action === "recover") {
|
|
98
|
+
if (rest.length !== 1) throw new Error("Usage: /sync daemon recover");
|
|
99
|
+
const { recoverDaemonOwnership } = await import("../daemon/ownership-recovery.js");
|
|
100
|
+
await recoverDaemonOwnership(ctx, client, signal);
|
|
101
|
+
} else if (action === "handover") {
|
|
98
102
|
await client.run("daemon.handover", {}, options.signal);
|
|
99
103
|
} else if (action === "allow-after-exit" || action === "revoke-after-exit") {
|
|
100
104
|
await client.run("daemon.handover", {}, options.signal);
|
|
@@ -106,11 +110,15 @@ export async function executeCommand(
|
|
|
106
110
|
);
|
|
107
111
|
} else if (action === "status") {
|
|
108
112
|
const connection = await client.verifyConnection(options.signal);
|
|
113
|
+
const guidance = client.ownershipCleanupRequired
|
|
114
|
+
? "Use /sync daemon recover to review and stop the daemon."
|
|
115
|
+
: "Use pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.";
|
|
116
|
+
const state = client.ownershipCleanupRequired ? "connected; recovery required" : "connected";
|
|
109
117
|
ctx.ui.notify(
|
|
110
|
-
`pi-sync-daemon:
|
|
118
|
+
`pi-sync-daemon: ${state}\nPID: ${connection.identity.pid}\nInstance: ${connection.identity.instance}\n${guidance}`,
|
|
111
119
|
"info",
|
|
112
120
|
);
|
|
113
|
-
} else throw new Error("Use /sync daemon status|handover|allow-after-exit|revoke-after-exit.");
|
|
121
|
+
} else throw new Error("Use /sync daemon status|recover|handover|allow-after-exit|revoke-after-exit.");
|
|
114
122
|
return { kind: "completed" };
|
|
115
123
|
}
|
|
116
124
|
case "help":
|
|
@@ -23,8 +23,14 @@ export async function handleCommand(
|
|
|
23
23
|
loaders: SyncLoaders,
|
|
24
24
|
attention: SyncAttentionController,
|
|
25
25
|
onExplicitSync?: (setup?: string) => void,
|
|
26
|
+
needsDaemonRecovery?: () => boolean,
|
|
26
27
|
) {
|
|
27
|
-
|
|
28
|
+
const args = splitArgs(rawArgs);
|
|
29
|
+
if (args[0] === "daemon" && args[1] === "recover") {
|
|
30
|
+
await executeCommand(rawArgs, ctx, sessionSignal, loaders);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!needsDaemonRecovery?.()) await reconcileObservation(attention, sessionSignal);
|
|
28
34
|
if (sessionSignal.aborted) return;
|
|
29
35
|
const run = (
|
|
30
36
|
route: string,
|
|
@@ -61,6 +67,7 @@ export async function handleCommand(
|
|
|
61
67
|
const { showSyncManager } = await import("../ui/manager-ui.js");
|
|
62
68
|
if (sessionSignal.aborted) return;
|
|
63
69
|
await showSyncManager(ctx, run, sessionSignal, {
|
|
70
|
+
needsDaemonRecovery,
|
|
64
71
|
getAttention: () => attention.current(),
|
|
65
72
|
getObservation: () => attention.observation(),
|
|
66
73
|
onObservationInvalidated: () => attention.clearObservation(),
|
|
@@ -73,13 +80,13 @@ export async function handleCommand(
|
|
|
73
80
|
setSyncStatus(ctx, undefined);
|
|
74
81
|
ctx.ui.notify(errorMessage(error), "error");
|
|
75
82
|
}
|
|
76
|
-
if (sessionSignal.aborted) return;
|
|
83
|
+
if (sessionSignal.aborted || needsDaemonRecovery?.()) return;
|
|
77
84
|
await reconcileObservation(attention, sessionSignal);
|
|
78
85
|
if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);
|
|
79
86
|
return;
|
|
80
87
|
}
|
|
81
88
|
const result = await run(rawArgs);
|
|
82
|
-
if (sessionSignal.aborted) return;
|
|
89
|
+
if (sessionSignal.aborted || needsDaemonRecovery?.()) return;
|
|
83
90
|
if (result.kind === "decision-required") {
|
|
84
91
|
ctx.ui.notify(result.decision.directMessage, "error");
|
|
85
92
|
} else if (result.kind === "remote-selection-required") {
|
package/src/commands/command.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const SYNC_COMMANDS = [
|
|
|
19
19
|
{
|
|
20
20
|
name: "daemon",
|
|
21
21
|
description: "Review service handover and unattended permission",
|
|
22
|
-
usageSuffix: " [status|handover|allow-after-exit|revoke-after-exit]",
|
|
22
|
+
usageSuffix: " [status|recover|handover|allow-after-exit|revoke-after-exit]",
|
|
23
23
|
},
|
|
24
24
|
{ name: "push", description: "Upload local settings" },
|
|
25
25
|
{ name: "pull", description: "Apply remote settings" },
|
|
@@ -152,7 +152,7 @@ export function validateCommandOptions(command: string, options: CommandOptions)
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
const DAEMON_ACTIONS = ["status", "handover", "allow-after-exit", "revoke-after-exit"] as const;
|
|
155
|
+
const DAEMON_ACTIONS = ["status", "recover", "handover", "allow-after-exit", "revoke-after-exit"] as const;
|
|
156
156
|
|
|
157
157
|
export function completeSyncArguments(argumentPrefix: string): CommandArgumentCompletion[] | null {
|
|
158
158
|
const prefix = argumentPrefix.trimStart();
|
|
@@ -255,6 +255,7 @@ export function usage() {
|
|
|
255
255
|
return [
|
|
256
256
|
"Usage: /sync <command>",
|
|
257
257
|
`Commands: ${commands}`,
|
|
258
|
+
"Daemon cleanup: /sync daemon recover reviews and stops the existing daemon. It does not start a replacement or retry a transfer.",
|
|
258
259
|
`Automatic sync: ${AUTOMATIC_SYNC_DESCRIPTION}`,
|
|
259
260
|
`Startup transfer: ${STARTUP_TRANSFER_DESCRIPTION}`,
|
|
260
261
|
"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.",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type DebugEvent, debugOperation } from "@narumitw/pi-sync-daemon/engine/debug-log";
|
|
2
|
+
|
|
3
|
+
export function observeDebugJob(operation: string, append: (event: DebugEvent) => void) {
|
|
4
|
+
const kind = debugOperation(operation);
|
|
5
|
+
if (!kind) return undefined;
|
|
6
|
+
let operationId: string | undefined;
|
|
7
|
+
const record = (outcome: Extract<DebugEvent, { event: "job" }>["outcome"]) =>
|
|
8
|
+
append({ event: "job", operation: kind, outcome, ...(operationId ? { operationId } : {}) });
|
|
9
|
+
return {
|
|
10
|
+
onSubmit(id: string) {
|
|
11
|
+
operationId = id;
|
|
12
|
+
record("started");
|
|
13
|
+
},
|
|
14
|
+
returned(result: unknown) {
|
|
15
|
+
if (result === "cancelled") record("cancelled");
|
|
16
|
+
else if (
|
|
17
|
+
result === "archived" ||
|
|
18
|
+
(kind === "initialize" &&
|
|
19
|
+
typeof result === "object" &&
|
|
20
|
+
result !== null &&
|
|
21
|
+
"handoverRequired" in result &&
|
|
22
|
+
result.handoverRequired === true)
|
|
23
|
+
)
|
|
24
|
+
record("blocked");
|
|
25
|
+
else if (
|
|
26
|
+
kind === "migrate-state" &&
|
|
27
|
+
typeof result === "object" &&
|
|
28
|
+
result !== null &&
|
|
29
|
+
"status" in result &&
|
|
30
|
+
result.status === "cancelled"
|
|
31
|
+
)
|
|
32
|
+
record("cancelled");
|
|
33
|
+
else record("completed");
|
|
34
|
+
},
|
|
35
|
+
rejected(error: unknown, cancelled: boolean) {
|
|
36
|
+
if (cancelled || (error instanceof Error && error.name === "AbortError")) record("cancelled");
|
|
37
|
+
else if (
|
|
38
|
+
error instanceof Error &&
|
|
39
|
+
(error.name === "SyncDecisionRequiredError" || error.name === "RemoteSelectionMismatchError")
|
|
40
|
+
)
|
|
41
|
+
record("blocked");
|
|
42
|
+
else record("failed");
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { inspectDaemonRecovery, stopDaemonForRecovery } 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 recoverDaemonOwnership(
|
|
8
|
+
ctx: ExtensionContext,
|
|
9
|
+
client: Pick<PiDaemonClient, "root" | "validate" | "confirmRecoveryExit">,
|
|
10
|
+
signal: AbortSignal | undefined,
|
|
11
|
+
) {
|
|
12
|
+
function current() {
|
|
13
|
+
signal?.throwIfAborted();
|
|
14
|
+
client.validate();
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
current();
|
|
18
|
+
if (!ctx.hasUI || !["tui", "rpc"].includes(ctx.mode)) throw new Error("Daemon recovery requires TUI or RPC mode.");
|
|
19
|
+
const owner = await inspectDaemonRecovery(client.root, signal);
|
|
20
|
+
current();
|
|
21
|
+
if (!owner) {
|
|
22
|
+
ctx.ui.notify("No daemon is running for this agent directory. Use /reload before syncing.", "info");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const approved = await ctx.ui.confirm(
|
|
26
|
+
"Stop Pi Sync daemon for recovery?",
|
|
27
|
+
`Agent directory: ${safeTerminalText(owner.root)}\nPID: ${owner.pid}\n\nStop sync work for all Pi sessions using this daemon. This does not start a replacement, remove sync evidence, or retry a transfer.`,
|
|
28
|
+
{ signal },
|
|
29
|
+
);
|
|
30
|
+
current();
|
|
31
|
+
if (!approved) return;
|
|
32
|
+
await stopDaemonForRecovery(owner, signal);
|
|
33
|
+
current();
|
|
34
|
+
client.confirmRecoveryExit(owner);
|
|
35
|
+
ctx.ui.notify(
|
|
36
|
+
"Pi Sync daemon exited. Use /reload, then open /sync. If a stale lock remains, choose Restore sync access. Check the sync state before retrying any transfer.",
|
|
37
|
+
"info",
|
|
38
|
+
);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
try {
|
|
41
|
+
current();
|
|
42
|
+
} catch {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
ctx.ui.notify(
|
|
46
|
+
`Pi Sync daemon recovery could not finish: ${safeTerminalText(errorMessage(error))}\nKeep recovery files. Use /sync daemon recover to review the owner again, or follow the daemon CLI recovery guide.`,
|
|
47
|
+
"error",
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|