@narumitw/pi-sync 0.60.2 → 0.60.5

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 (45) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +10 -0
  3. package/dist/chunks/{chunk-FOMZEZER.ts → chunk-6KIWZ4AY.ts} +360 -60
  4. package/dist/chunks/chunk-6KIWZ4AY.ts.map +7 -0
  5. package/dist/chunks/{chunk-B53FS4RW.ts → chunk-F64YWRXG.ts} +2 -2
  6. package/dist/chunks/{chunk-ENFHHB5O.ts → chunk-H7VOTY5N.ts} +55 -6
  7. package/dist/chunks/chunk-H7VOTY5N.ts.map +7 -0
  8. package/dist/chunks/{chunk-E7UJHMNW.ts → chunk-V2QIMC3U.ts} +2 -2
  9. package/dist/chunks/{chunk-3YXBG7BQ.ts → chunk-YVH5VJR4.ts} +2 -2
  10. package/dist/chunks/{command-handler-RTBEFZUX.ts → command-handler-TNPWFIPG.ts} +10 -8
  11. package/dist/chunks/command-handler-TNPWFIPG.ts.map +7 -0
  12. package/dist/chunks/{conflict-review-YXROU42F.ts → conflict-review-ETCSYJTH.ts} +3 -3
  13. package/dist/chunks/{manager-result-dispatcher-4PEUHK7F.ts → manager-result-dispatcher-2GFNWHDM.ts} +4 -4
  14. package/dist/chunks/{manager-ui-TNAMQNEU.ts → manager-ui-LFONXWQN.ts} +8 -8
  15. package/dist/chunks/{remote-selection-ui-47H7V62F.ts → remote-selection-ui-GFR6TDTX.ts} +3 -3
  16. package/dist/chunks/{sync-inspection-5GQEB62G.ts → sync-inspection-6VGR2UVZ.ts} +3 -3
  17. package/dist/chunks/{sync-operations-65HDA67O.ts → sync-operations-SAKAZL6Z.ts} +3 -3
  18. package/dist/index.ts +64 -41
  19. package/dist/index.ts.map +3 -3
  20. package/docs/agent-mode-verification.md +1 -1
  21. package/docs/agent-quality-verification.md +1 -1
  22. package/docs/continuous-sync-verification.md +1 -1
  23. package/docs/daemon-migration.md +88 -6
  24. package/docs/tui-contract.md +7 -1
  25. package/package.json +3 -3
  26. package/skills/configure-pi-sync/references/configuration.md +1 -0
  27. package/src/commands/command-execution.ts +1 -1
  28. package/src/commands/command-handler.ts +2 -0
  29. package/src/daemon/pi-client.ts +302 -57
  30. package/src/daemon/queue-release-ui.ts +88 -0
  31. package/src/sync-extension.ts +68 -43
  32. package/src/ui/sync-status.ts +67 -4
  33. package/dist/chunks/chunk-ENFHHB5O.ts.map +0 -7
  34. package/dist/chunks/chunk-FOMZEZER.ts.map +0 -7
  35. package/dist/chunks/command-handler-RTBEFZUX.ts.map +0 -7
  36. package/docs/settings.md +0 -90
  37. /package/dist/chunks/{chunk-B53FS4RW.ts.map → chunk-F64YWRXG.ts.map} +0 -0
  38. /package/dist/chunks/{chunk-E7UJHMNW.ts.map → chunk-V2QIMC3U.ts.map} +0 -0
  39. /package/dist/chunks/{chunk-3YXBG7BQ.ts.map → chunk-YVH5VJR4.ts.map} +0 -0
  40. /package/dist/chunks/{conflict-review-YXROU42F.ts.map → conflict-review-ETCSYJTH.ts.map} +0 -0
  41. /package/dist/chunks/{manager-result-dispatcher-4PEUHK7F.ts.map → manager-result-dispatcher-2GFNWHDM.ts.map} +0 -0
  42. /package/dist/chunks/{manager-ui-TNAMQNEU.ts.map → manager-ui-LFONXWQN.ts.map} +0 -0
  43. /package/dist/chunks/{remote-selection-ui-47H7V62F.ts.map → remote-selection-ui-GFR6TDTX.ts.map} +0 -0
  44. /package/dist/chunks/{sync-inspection-5GQEB62G.ts.map → sync-inspection-6VGR2UVZ.ts.map} +0 -0
  45. /package/dist/chunks/{sync-operations-65HDA67O.ts.map → sync-operations-SAKAZL6Z.ts.map} +0 -0
@@ -4,9 +4,54 @@ This daemon extraction is experimental. Deterministic Linux verification passed,
4
4
 
5
5
  ## Ownership and upgrade
6
6
 
7
- The non-extension npm package is `@narumitw/pi-sync-daemon`; its executable is `pi-sync-daemon`. These replace `@narumitw/sync-daemon` and `sync-daemon`; the new package does not provide the old executable alias. Stop an existing installation with `sync-daemon stop --root <agent-directory>` before replacing it, then use `pi-sync-daemon` after installation. The rename changes package identity, imports, the package directory, and executable names, not IPC names, authorization digests, or settings/state formats. The existing Pi extension remains `@narumitw/pi-sync`, with `/sync` as its user interface. Pi starts or connects to one detached service per canonical agent directory; the daemon, not an individual Pi shutdown hook, decides when the shared owner can exit. No OS service or supervisor is installed.
8
-
9
- Stop the service before updating its package or rebuilding a local checkout: a surviving Node process can otherwise combine cached code with newly loaded modules from the replaced directory. A compatible protocol handshake does not upgrade the running implementation; restart explicitly after installation.
7
+ The non-extension npm package is `@narumitw/pi-sync-daemon`; its executable is `pi-sync-daemon`. These replace `@narumitw/sync-daemon` and `sync-daemon`; the new package does not provide the old executable alias. The rename changes the package and executable names, not the IPC names, authorization digests, or
8
+ settings and state formats. The Pi extension remains `@narumitw/pi-sync`. Pi uses one detached service
9
+ per canonical agent directory. It does not install an OS service.
10
+
11
+ After an update, use `/reload` in open Pi sessions. On the next active connection, the new client
12
+ checks the owner's build over compatible, authenticated IPC. For an older or unversioned owner, the
13
+ client checks that no retained unattended permission blocks the upgrade. It then requests a stop
14
+ and starts the replacement only after the owner releases its identity and exits. If any check fails,
15
+ follow manual recovery. The upgrade does not run a transfer, replay an operation, or change sync
16
+ settings. Passive print, JSON, and shutdown paths do not replace an older owner. If an upgrade fails
17
+ while switching sessions, Pi Sync reports the failure and tries to attach the new session to the
18
+ same owner for file protection only. That attachment cannot submit sync work. Use `/reload`
19
+ after recovery.
20
+
21
+ Manual recovery:
22
+
23
+ 1. Revoke all retained unattended grants before updating. `/sync daemon revoke-after-exit` applies
24
+ only to the active setup. For each setup with a retained grant, make it active, run the command,
25
+ and confirm revocation. If the upgraded client blocks on consent before creating a pending
26
+ upgrade record, use an already available compatible Pi client to revoke each grant from the
27
+ still-running owner.
28
+ Without a pending record, `repair-upgrade` returns `repaired: false` and does not revoke permission.
29
+ If no compatible client is available or revocation fails, stop here and preserve the consent,
30
+ identity, and recovery files.
31
+ 2. Run `pi-sync-daemon status --root <agent-directory>`.
32
+ - A verified `pid` identifies the owner that answered the handshake. Record it before stopping
33
+ that owner. Check `pendingUpgradePid` for any pending owner, even if `running` is `false` or `null`.
34
+ - `running: null` means the handshake failed, even if there is no pending upgrade. `recordedPid`
35
+ comes from the validated identity file and is only a lead. Unknown status does not prove exit
36
+ or compatibility. Use diagnostics from an already available compatible version to identify the
37
+ owner. If you cannot identify it, stop here and preserve the records.
38
+
39
+ To stop an identified, running owner, use `pi-sync-daemon stop --root <agent-directory>` if
40
+ compatible. This works even if the old executable was removed. If the old executable is still
41
+ installed and compatible, you can use `sync-daemon stop --root <agent-directory>` instead.
42
+ 3. Check the recorded PID in the operating system. On macOS or Linux, use `ps -p <pid> -o pid,args`.
43
+ On Windows, look up the PID in Task Manager's **Details** tab. A successful `stop` confirms
44
+ identity release, not process exit. Wait for the old process to exit. If exit is uncertain, do
45
+ not force a second owner or delete recovery files.
46
+ 4. If a pending upgrade still blocks restart after exit, close other Pi sessions for that root.
47
+ Run `pi-sync-daemon repair-upgrade --root <agent-directory>`. It verifies exit, revokes all
48
+ retained after-exit grants for that root, and moves the upgrade record and any stale identity
49
+ to the private archive path it reports. It does not start a daemon or transfer data. If repair
50
+ fails, keep the records. Do not edit or delete them to force startup.
51
+ 5. Use `/reload`, then `/sync daemon status`. Review after-exit permission again if you need it.
52
+
53
+ Stop the service before rebuilding a local checkout in place. A source rebuild without a package
54
+ version change does not trigger automatic replacement.
10
55
 
11
56
  Before the first daemon-owned transfer, close or upgrade every older Pi process and review `/sync daemon handover`. The existing operation lock excludes observed transfers, but an idle older client cannot be detected from an absent lock. Older binaries cannot be made to honor a new handover record retroactively. Do not run an old and new engine as interchangeable writers.
12
57
 
@@ -28,20 +73,42 @@ The service owns synchronization scheduling and execution, not every writer on t
28
73
 
29
74
  Protect the union of all registered live-PID sessions, including ambiguously disconnected and orderly retired clients. Retired clients cannot authorize work or hold back zero-client scheduling, but their protection survives another attach and daemon restart until confirmed PID exit. A contact timeout revokes work; it is not permission to overwrite that session or release an acquired mutation grant. An uncertain grant remains quarantined until explicit release or confirmed daemon exit. Unregistered editors, shell commands, older clients, and extensions remain independent writers; preimages, conditional publication, backups, and journal recovery are still required.
30
75
 
76
+ When a running daemon expires a Pi client's heartbeat (for example, during
77
+ computer sleep), the TUI or RPC client tries to reconnect to that same daemon
78
+ without reloading Pi. The next `/sync` command also checks contact before
79
+ submitting work. `/sync daemon status` reports `connected` only after the daemon
80
+ accepts the current participant's facts. An older daemon can stay reachable
81
+ without supporting this repair; a healthy CLI status alone does not confirm Pi
82
+ participation.
83
+
84
+ Reconnect does not replay a submitted operation or restart startup transfers.
85
+ If Pi releases a file queue but the local acknowledgement is lost in transit,
86
+ it retries that acknowledgement with the same daemon. Brief retries stay
87
+ quiet; longer retries show `sync recovering` when sync status is enabled.
88
+ If a background release remains unconfirmed during a command, Pi reports it
89
+ after the command finishes.
90
+ A release acknowledgement alone does not confirm that a transfer succeeded.
91
+ If a write or file-queue release cannot be confirmed, preserve the journals and
92
+ use the existing recovery path before retrying a transfer. Reconnect does not
93
+ stop or restart the service, and it does not extend transfer or model permission.
94
+
31
95
  ## Diagnostics and rollback
32
96
 
33
97
  If saving consent fails, that service instance blocks automatic work. Uncertain consent publication, failed revocation, or cleanup failure keeps the owner paused and retains evidence; automatic exit or implicit restart must not clear the barrier and restore an older persisted grant. Preserve the retained file, repair persistence, and revoke permission through the existing repair/revocation path before an explicit restart; a failed save does not prove the previous grant changed. Cleanup failure is not a successful exit.
34
98
 
35
- Use `pi-sync-daemon status --root <agent-directory>` without starting a missing service. `stop` drains compatible work. `restart` must not replace an incompatible, unavailable live, or uncertain owner silently. The Pi client must report failure rather than fall back to in-process transfers.
99
+ Use `pi-sync-daemon status --root <agent-directory>` without starting a missing service. `stop` drains compatible work. `restart` must not replace an incompatible, unavailable live, or uncertain owner silently. The Pi client must report failure rather than fall back to in-process transfers. If the initial consent check blocked the update before a pending record was created, follow step 1 of [manual recovery](#ownership-and-upgrade); `repair-upgrade` cannot help in that case.
36
100
 
37
- CLI `status` includes an owner-private, bounded lifecycle-log path. Only timestamps and lifecycle phases are retained; no request content, credentials, model output, or exception text is logged. This log is not transaction recovery evidence.
101
+ A successful CLI `status` handshake reports an owner-private, bounded lifecycle-log path. Only timestamps and lifecycle phases are retained; no request content, credentials, model output, or exception text is logged. This log is not transaction recovery evidence.
38
102
 
39
103
  Before rollback:
40
104
 
41
105
  1. Stop the daemon explicitly and verify owner exit.
42
106
  2. Close all upgraded clients and retain settings, state, journals, and backups.
43
107
  3. Reconcile pending or uncertain publication through the supported engine recovery path.
44
- 4. Only then consider a compatible code/package rollback; do not blindly restore old local or remote bytes.
108
+ 4. Check consent compatibility before rolling back. A repair can leave `daemon.json` larger than
109
+ 65,536 bytes because it keeps all other fields when revoking grants. Builds with the old
110
+ 65,536-byte limit cannot read that file. Preserve it and use a build that supports the larger
111
+ file. Do not delete it or restore an older copy to make the rollback work.
45
112
 
46
113
  Operation retries are instance-bound and deduplicated. An expired result or old instance requires journal reconciliation, not blind replay. A full bounded result ledger requires an explicit drained restart.
47
114
 
@@ -66,6 +133,20 @@ The semantic audit used `docs/extension-conventions.md`, `docs/extension-setting
66
133
 
67
134
  Intentional compatibility limits are explicit: there is no legacy in-process fallback; unsupported parent-only providers remain unavailable; print/JSON do not launch a service but protect sessions in an existing one; a cancelled SDK switch/fork stays paused until reload; arbitrary external writers are not covered by a universal filesystem compare-and-swap. Normal closed clients retain live-PID protection without blocking reviewed zero-client work. No package publication, tag, release dispatch, paid provider request, or production-storage action was performed.
68
135
 
136
+ ### Heartbeat recovery verification
137
+
138
+ An isolated daemon clock and real Pi RPC clients reproduced the stuck first
139
+ command before the fix. Regression tests now verify same-owner, same-session
140
+ recovery with and without a command, and no replay or remote write after an
141
+ interrupted loopback WebDAV push. Daemon tests exercise admission, lifecycle
142
+ cancellation, legacy replies, committed work, and uncertain queue release.
143
+ The Jiti tests load the built extension and exercise its lazy command path.
144
+
145
+ Physical suspend and wake timing on target devices remains unverified. See
146
+ [External handoff](#external-handoff) before making a platform claim or
147
+ preparing a release. This change neither publishes a package nor authorizes
148
+ production cutover.
149
+
69
150
  ## Measured process cost
70
151
 
71
152
  These are same-host observations on Linux with Node `v26.11.1`, not limits or statistically controlled performance claims. The baseline was reconstructed from archived commit `a01c1d75` after implementation, rather than measured before editing. Both Pi cases loaded generated Jiti entries through real offline RPC processes with the same installed parent SDK and synthetic loopback WebDAV/model endpoints. No production stores, credentials, or paid model calls were used.
@@ -92,6 +173,7 @@ The archived previous engine also held its real operation lock in a separate pro
92
173
  | Responsible role | Prerequisite and action | Expected result | Unverified behavior and restriction |
93
174
  | --- | --- | --- | --- |
94
175
  | npm/release account owner | Passing package gates and explicit approval; verify publication rights for `@narumitw/pi-sync-daemon` and dependency-first publication | The daemon resolves before the dependent Pi client is released | Scope permissions and first publication are not verified; no publication, visibility change, tags, or workflow dispatch without approval |
176
+ | Device operator | Verified builds and an isolated setup; suspend and wake the target device, then run `/sync daemon status` and `/sync status` in the same Pi session | Both commands work without reload; the daemon and session stay the same | Physical wake timing is not verified by clock-controlled tests; do not claim tested platforms without this check |
95
177
  | Deployment operator | Verified cutover/recovery evidence and backups; close older Pi processes and authorize each real root | One recognized owner with unchanged compatible data | Only the explicitly approved checkout-service stop/restart was used for package-identity and runtime maintenance; no production-storage transfer or settings change was made, and no real-data cutover is included |
96
178
  | Native platform maintainer | Prepared transport/process tests; run native Windows/macOS checks | Correct local transport, permissions, independent lifetime, and recovery | Native ACL/named-pipe, logout, and physical power-loss behavior remain unverified; do not advertise new unverified guarantees or silently remove previous support |
97
179
  | Provider/storage account owner | Explicit cost/network authorization and isolated data; optional live smoke | Authorized dispatch/publication without exposed credentials | Entitlements and custom-provider/production behavior remain unverified; deterministic providers and loopback stores are the default |
@@ -70,6 +70,12 @@ Startup transfer summaries report the preference and prerequisites, not a claim
70
70
 
71
71
  TUI Pull and Push reviews reuse the existing scrollable safe-default confirmation and exact Details document; RPC and History rollback retain their observable confirmation protocols. The existing History dialog ownership/cancellation flow is not replaced. All changed counts come from effective snapshot differences rather than raw merge decisions. Protected paths, preserved remote files, merged bytes, and withheld paths must be accounted for before rendering. Cancellation performs no transfer; pre-commit preparation may retain recovery evidence. After the commit boundary, existing completion/recovery rules apply instead of promising undo.
72
72
 
73
+ ## Resource reload after a transfer
74
+
75
+ If the user accepts the reload prompt after a pull or rollback, `/sync` waits for the daemon job and closes its dialogs before asking Pi to reload. Declining leaves the completed transfer in place without reloading. Reload still waits for session shutdown and daemon cleanup.
76
+
77
+ RPC and the TUI harness verify this ordering. The native Fedora/tmux flow from [issue #1935](https://github.com/narumiruna/pi-extensions/issues/1935) was not run. To verify it, repeat the issue's loopback WebDAV steps with a temporary agent directory. After accepting reload, check that the progress display closes and the next editor input or `/sync` command works.
78
+
73
79
  ## Review boundaries
74
80
 
75
81
  This change does not touch model prompts, tool exposure, shared-terminal handoff, settings formats, credentials, or default sync policies. Existing startup/session signals and Kit/custom-interaction disposal own new UI calls. Any awaited review is followed by owner validation, and each mutating operation revalidates its mutable inputs before its existing commit boundary. Status and differences actions use existing routes; manager opening/refresh remains observational and does not contact the remote. Diagnostics discloses its WebDAV write/repair behavior before execution.
@@ -119,7 +125,7 @@ Verification evidence:
119
125
 
120
126
  - Root `npm run check` and `npm test` passed: 935 test files, 20,528 passed tests, 34 existing skips, and no unhandled errors.
121
127
  - The focused Pi Sync suite passed: 185 files, 3,293 passed tests, and 19 existing skips. Cases cover all four Settings descriptions, TUI/RPC consent, cancellation, the RPC Done exit without authorization, durable saves and failure recovery, Continuous sync dependencies, non-default keys, narrow rendering, and current/legacy documentation anchors.
122
- - A fenced-code-aware heading audit passed for all 37 package READMEs. Legacy fragment aliases remain in the README, authoritative settings reference, and compatibility index.
128
+ - A fenced-code-aware heading audit passed for all 37 package READMEs. Legacy fragment aliases were verified in the README and authoritative settings reference.
123
129
  - `npm run package:pack -- sync` and an actual temporary tarball inspection passed: 330 entries include the runtime, source, docs, skill, license, and changelog, without tests or repository plans.
124
130
 
125
131
  The first direct-Vitest run used a symlinked macOS temporary path and triggered existing alias-path safety checks; the successful focused run used the canonical temporary root, as the root runner does. New RPC choice assertions were corrected to include Kit's existing Done exit, and both consent flows now test that exit. No runtime safety check or acceptance criterion was relaxed. Later full-suite command-level rechecks exceeded the harness's 300-second command limit. A background full-suite recheck hit the readiness watchdog in the unchanged `test/packed-publish-native.test.ts`; that file passed separately. The final full-suite recheck uses a managed background runner without changing per-test limits. Biome reports existing schema-version and unrelated lint advisories; its gates pass without changing repository tooling.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-sync",
3
- "version": "0.60.2",
3
+ "version": "0.60.5",
4
4
  "description": "Pi extension that syncs Pi configuration through Git, WebDAV, Cloudflare R2, or S3-compatible storage.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,8 +46,8 @@
46
46
  "typecheck": "tsc --noEmit"
47
47
  },
48
48
  "dependencies": {
49
- "@narumitw/pi-sync-daemon": "^0.3.0",
50
- "@narumitw/pi-tui-kit": "^0.70.0"
49
+ "@narumitw/pi-sync-daemon": "^0.6.0",
50
+ "@narumitw/pi-tui-kit": "^0.70.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@earendil-works/pi-coding-agent": "1.5.0",
@@ -251,6 +251,7 @@ UI changes save immediately through the existing ordered, atomic settings writer
251
251
  There is no project or environment override.
252
252
 
253
253
  With `debug: true`, reports show local initialization after recovery and settings resolution, then background work when it ends.
254
+ The report shows one line per stage, followed by a total.
254
255
  TUI reports are stored as custom session entries, so they remain in the transcript after `/reload` and later notifications without entering model context.
255
256
  RPC reports remain notifications.
256
257
  When Continuous sync is enabled, the background report covers its first cycle rather than the separate one-shot startup check; later polls and same-session idle resumes do not publish more timing reports.
@@ -104,7 +104,7 @@ export async function executeCommand(
104
104
  options.signal,
105
105
  );
106
106
  } else if (action === "status") {
107
- const connection = await client.connect();
107
+ const connection = await client.verifyConnection(options.signal);
108
108
  ctx.ui.notify(
109
109
  `pi-sync-daemon: connected\nPID: ${connection.identity.pid}\nInstance: ${connection.identity.instance}\nUse pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.`,
110
110
  "info",
@@ -73,11 +73,13 @@ export async function handleCommand(
73
73
  setSyncStatus(ctx, undefined);
74
74
  ctx.ui.notify(errorMessage(error), "error");
75
75
  }
76
+ if (sessionSignal.aborted) return;
76
77
  await reconcileObservation(attention, sessionSignal);
77
78
  if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);
78
79
  return;
79
80
  }
80
81
  const result = await run(rawArgs);
82
+ if (sessionSignal.aborted) return;
81
83
  if (result.kind === "decision-required") {
82
84
  ctx.ui.notify(result.decision.directMessage, "error");
83
85
  } else if (result.kind === "remote-selection-required") {