@narumitw/pi-sync 0.60.0 → 0.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +11 -12
- package/dist/chunks/{chunk-7AC2RX4M.ts → chunk-277VHM2P.ts} +2 -2
- package/dist/chunks/chunk-277VHM2P.ts.map +7 -0
- package/dist/chunks/{chunk-4RNCZZY7.ts → chunk-3YXBG7BQ.ts} +14 -10
- package/dist/chunks/{chunk-4RNCZZY7.ts.map → chunk-3YXBG7BQ.ts.map} +2 -2
- package/dist/chunks/{chunk-UBE6XWOM.ts → chunk-6W2SNZ5P.ts} +2 -2
- package/dist/chunks/chunk-6W2SNZ5P.ts.map +7 -0
- package/dist/chunks/{chunk-UZUUUY7C.ts → chunk-B53FS4RW.ts} +4 -4
- package/dist/chunks/{chunk-MIXZVHFR.ts → chunk-E7UJHMNW.ts} +11 -42
- package/dist/chunks/chunk-E7UJHMNW.ts.map +7 -0
- package/dist/chunks/{chunk-JZKCOM62.ts → chunk-EMRFVLZM.ts} +2 -2
- package/dist/chunks/chunk-EMRFVLZM.ts.map +7 -0
- package/dist/chunks/{chunk-BWWTOQOW.ts → chunk-FOMZEZER.ts} +100 -53
- package/dist/chunks/chunk-FOMZEZER.ts.map +7 -0
- package/dist/chunks/{chunk-NPT2G4FU.ts → chunk-HEB6YT64.ts} +2 -2
- package/dist/chunks/chunk-HEB6YT64.ts.map +7 -0
- package/dist/chunks/{chunk-J5COV5TY.ts → chunk-HLCML3OW.ts} +2 -2
- package/dist/chunks/{chunk-J5COV5TY.ts.map → chunk-HLCML3OW.ts.map} +1 -1
- package/dist/chunks/{chunk-ZMNVNECV.ts → chunk-KPWZNMKM.ts} +2 -2
- package/dist/chunks/chunk-KPWZNMKM.ts.map +7 -0
- package/dist/chunks/{chunk-YWEYRRQI.ts → chunk-LAXTCSX4.ts} +11 -11
- package/dist/chunks/chunk-LAXTCSX4.ts.map +7 -0
- package/dist/chunks/{chunk-BGGKHHO4.ts → chunk-MCUZFUHY.ts} +7 -7
- package/dist/chunks/{chunk-M7RHV3H6.ts → chunk-OA4NZLSL.ts} +2 -2
- package/dist/chunks/chunk-OA4NZLSL.ts.map +7 -0
- package/dist/chunks/{chunk-CEMFCWIU.ts → chunk-RNIEVDTR.ts} +2 -2
- package/dist/chunks/chunk-RNIEVDTR.ts.map +7 -0
- package/dist/chunks/{chunk-PDBTD2K6.ts → chunk-S3R3W3KF.ts} +2 -2
- package/dist/chunks/chunk-S3R3W3KF.ts.map +7 -0
- package/dist/chunks/{chunk-CZNBKIM5.ts → chunk-SMVKMYLK.ts} +2 -2
- package/dist/chunks/chunk-SMVKMYLK.ts.map +7 -0
- package/dist/chunks/{chunk-JKBUYCPC.ts → chunk-V4AMI3VL.ts} +2 -2
- package/dist/chunks/chunk-V4AMI3VL.ts.map +7 -0
- package/dist/chunks/{chunk-VZCWYXRS.ts → chunk-WP2M67XZ.ts} +2 -2
- package/dist/chunks/chunk-WP2M67XZ.ts.map +7 -0
- package/dist/chunks/{chunk-HNKLBM3U.ts → chunk-ZIL6PW5L.ts} +2 -2
- package/dist/chunks/chunk-ZIL6PW5L.ts.map +7 -0
- package/dist/chunks/{command-handler-3O76V7Q5.ts → command-handler-RTBEFZUX.ts} +19 -19
- package/dist/chunks/{command-handler-3O76V7Q5.ts.map → command-handler-RTBEFZUX.ts.map} +2 -2
- package/dist/chunks/{conflict-review-XBSME2ER.ts → conflict-review-YXROU42F.ts} +4 -4
- package/dist/chunks/{continuous-record-ZHUXVO4E.ts → continuous-record-3XDXDOMV.ts} +2 -2
- package/dist/chunks/continuous-record-3XDXDOMV.ts.map +7 -0
- package/dist/chunks/continuous-storage-HLKCHF6Z.ts +27 -0
- package/dist/chunks/continuous-storage-HLKCHF6Z.ts.map +7 -0
- package/dist/chunks/{file-selection-S6CNNNQI.ts → file-selection-DD6X4J2K.ts} +6 -6
- package/dist/chunks/manager-result-dispatcher-4PEUHK7F.ts +18 -0
- package/dist/chunks/{manager-ui-SJOBTJLY.ts → manager-ui-TNAMQNEU.ts} +123 -64
- package/dist/chunks/manager-ui-TNAMQNEU.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-GZHPDQ4L.ts → remote-selection-ui-47H7V62F.ts} +8 -8
- package/dist/chunks/{setup-switch-M3BAFGJM.ts → setup-switch-SPZE7HIQ.ts} +8 -8
- package/dist/chunks/{setup-wizard-NFAWP4KF.ts → setup-wizard-5JYKAEIT.ts} +11 -11
- package/dist/chunks/{snapshot-D4SFDP5J.ts → snapshot-5HY3M2NL.ts} +2 -2
- package/dist/chunks/snapshot-5HY3M2NL.ts.map +7 -0
- package/dist/chunks/{snapshot-transaction-directory-TNKBQ3UQ.ts → snapshot-transaction-directory-OU2D7R7A.ts} +2 -2
- package/dist/chunks/snapshot-transaction-directory-OU2D7R7A.ts.map +7 -0
- package/dist/chunks/{state-directory-JZSZVVPX.ts → state-directory-XXHU73Z3.ts} +2 -2
- package/dist/chunks/{sync-inspection-BJ4KPPNO.ts → sync-inspection-5GQEB62G.ts} +5 -5
- package/dist/chunks/sync-inspection-5GQEB62G.ts.map +7 -0
- package/dist/chunks/{sync-operations-TLWER2TT.ts → sync-operations-65HDA67O.ts} +5 -5
- package/dist/chunks/{sync-operations-TLWER2TT.ts.map → sync-operations-65HDA67O.ts.map} +2 -2
- package/dist/chunks/{sync-state-FVCJJ7MY.ts → sync-state-2LMIXJ2C.ts} +2 -2
- package/dist/chunks/sync-state-2LMIXJ2C.ts.map +7 -0
- package/dist/index.ts +22 -22
- package/dist/index.ts.map +1 -1
- package/docs/daemon-migration.md +10 -6
- package/docs/tui-contract.md +12 -0
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +8 -4
- package/src/backends/backend-factory.ts +2 -2
- package/src/backends/backend-identity.ts +2 -2
- package/src/backends/backend-types.ts +1 -1
- package/src/backends/git/git-backend.ts +2 -2
- package/src/backends/git/git-config.ts +2 -2
- package/src/backends/git/git-runner.ts +2 -2
- package/src/backends/git/git-storage.ts +2 -2
- package/src/backends/s3/s3-backend.ts +2 -2
- package/src/backends/s3/s3-client.ts +6 -2
- package/src/backends/s3/s3-conditions.ts +2 -2
- package/src/backends/snapshot-pointer.ts +2 -2
- package/src/backends/sync-backend.ts +2 -2
- package/src/backends/webdav/webdav-backend.ts +2 -2
- package/src/backends/webdav/webdav-client.ts +2 -2
- package/src/backends/webdav/webdav-config.ts +2 -2
- package/src/commands/command-execution.ts +1 -1
- package/src/commands/command.ts +1 -1
- package/src/daemon/apply-gate.ts +1 -1
- package/src/daemon/pi-client.ts +105 -54
- package/src/daemon/recovery.ts +1 -1
- package/src/paths.ts +2 -2
- package/src/settings/config-errors.ts +2 -2
- package/src/settings/config-file.ts +2 -2
- package/src/settings/config.ts +2 -2
- package/src/settings/settings-management.ts +2 -2
- package/src/settings/settings-store.ts +2 -2
- package/src/settings/settings-types.ts +1 -1
- package/src/settings/settings-validation.ts +2 -2
- package/src/snapshot/session-paths.ts +2 -2
- package/src/snapshot/snapshot-apply.ts +2 -2
- package/src/snapshot/snapshot-case-replacement.ts +2 -2
- package/src/snapshot/snapshot-codec.ts +2 -2
- package/src/snapshot/snapshot-exclude-safety.ts +2 -2
- package/src/snapshot/snapshot-mutation-queues.ts +2 -2
- package/src/snapshot/snapshot-paths.ts +2 -2
- package/src/snapshot/snapshot-root-transition.ts +2 -2
- package/src/snapshot/snapshot-transaction-directory.ts +2 -2
- package/src/snapshot/snapshot-transaction-plan.ts +2 -2
- package/src/snapshot/snapshot-transaction.ts +2 -2
- package/src/snapshot/snapshot-types.ts +1 -1
- package/src/snapshot/snapshot.ts +2 -2
- package/src/state/json-file.ts +2 -2
- package/src/state/lock-policy.ts +2 -2
- package/src/state/lock.ts +2 -2
- package/src/state/lockfile-fs.ts +2 -2
- package/src/state/merge-baseline-store.ts +2 -2
- package/src/state/mutation-directory-sync.ts +2 -2
- package/src/state/operation-availability.ts +2 -2
- package/src/state/state-directory.ts +2 -2
- package/src/state/state-types.ts +1 -1
- package/src/state/sync-state-store.ts +2 -2
- package/src/sync/agent-candidate.ts +2 -2
- package/src/sync/agent-plan.ts +2 -2
- package/src/sync/agent-policy.ts +2 -2
- package/src/sync/agent-refusal-retry.ts +2 -2
- package/src/sync/agent-request.ts +2 -2
- package/src/sync/agent-runner.ts +2 -2
- package/src/sync/agent-store.ts +2 -2
- package/src/sync/agent-sync.ts +2 -2
- package/src/sync/apply-review.ts +2 -2
- package/src/sync/conflict-artifact-ownership.ts +2 -2
- package/src/sync/conflict-artifacts.ts +2 -2
- package/src/sync/conflict-groups.ts +2 -2
- package/src/sync/conflict-preview.ts +2 -2
- package/src/sync/conflict-resolution.ts +2 -2
- package/src/sync/conflict-retention.ts +2 -2
- package/src/sync/content-conflicts.ts +2 -2
- package/src/sync/continuous-errors.ts +2 -2
- package/src/sync/continuous-lease.ts +2 -2
- package/src/sync/continuous-record.ts +2 -2
- package/src/sync/continuous-storage.ts +2 -2
- package/src/sync/continuous-sync.ts +2 -2
- package/src/sync/continuous-watch.ts +2 -2
- package/src/sync/exclude-policy.ts +2 -2
- package/src/sync/field-migration.ts +2 -2
- package/src/sync/file-merge-planner.ts +6 -2
- package/src/sync/json-document.ts +2 -2
- package/src/sync/local-field-policy.ts +2 -2
- package/src/sync/local-fields.ts +2 -2
- package/src/sync/merge-apply.ts +2 -2
- package/src/sync/merge-journal.ts +2 -2
- package/src/sync/merge-transfer-error.ts +2 -2
- package/src/sync/merged-sync.ts +2 -2
- package/src/sync/mutation-owner.ts +2 -2
- package/src/sync/package-merge.ts +2 -2
- package/src/sync/partial-progress.ts +2 -2
- package/src/sync/remote-snapshot.ts +2 -2
- package/src/sync/session-merge.ts +2 -2
- package/src/sync/settings-conflicts.ts +2 -2
- package/src/sync/settings-merge.ts +2 -2
- package/src/sync/signals.ts +2 -2
- package/src/sync/startup-timings.ts +2 -2
- package/src/sync/sync-decision.ts +2 -2
- package/src/sync/sync-error-guidance.ts +2 -2
- package/src/sync/sync-errors.ts +2 -2
- package/src/sync/sync-inspection.ts +2 -2
- package/src/sync/sync-local.ts +6 -2
- package/src/sync/sync-mutations.ts +2 -2
- package/src/sync/sync-operations.ts +1 -1
- package/src/sync/sync-policy.ts +2 -2
- package/src/sync/sync-queries.ts +2 -2
- package/src/sync/sync-state.ts +2 -2
- package/src/sync/text-merge.ts +2 -2
- package/src/ui/manager-state.ts +35 -23
- package/src/ui/manager-ui.ts +80 -36
- package/src/ui/sync-attention.ts +7 -49
- package/dist/chunks/chunk-7AC2RX4M.ts.map +0 -7
- package/dist/chunks/chunk-BWWTOQOW.ts.map +0 -7
- package/dist/chunks/chunk-CEMFCWIU.ts.map +0 -7
- package/dist/chunks/chunk-CZNBKIM5.ts.map +0 -7
- package/dist/chunks/chunk-HNKLBM3U.ts.map +0 -7
- package/dist/chunks/chunk-JKBUYCPC.ts.map +0 -7
- package/dist/chunks/chunk-JZKCOM62.ts.map +0 -7
- package/dist/chunks/chunk-M7RHV3H6.ts.map +0 -7
- package/dist/chunks/chunk-MIXZVHFR.ts.map +0 -7
- package/dist/chunks/chunk-NPT2G4FU.ts.map +0 -7
- package/dist/chunks/chunk-PDBTD2K6.ts.map +0 -7
- package/dist/chunks/chunk-UBE6XWOM.ts.map +0 -7
- package/dist/chunks/chunk-VZCWYXRS.ts.map +0 -7
- package/dist/chunks/chunk-YWEYRRQI.ts.map +0 -7
- package/dist/chunks/chunk-ZMNVNECV.ts.map +0 -7
- package/dist/chunks/continuous-record-ZHUXVO4E.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-I2AMCCE7.ts +0 -18
- package/dist/chunks/manager-ui-SJOBTJLY.ts.map +0 -7
- package/dist/chunks/snapshot-D4SFDP5J.ts.map +0 -7
- package/dist/chunks/snapshot-transaction-directory-TNKBQ3UQ.ts.map +0 -7
- package/dist/chunks/sync-inspection-BJ4KPPNO.ts.map +0 -7
- package/dist/chunks/sync-state-FVCJJ7MY.ts.map +0 -7
- /package/dist/chunks/{chunk-UZUUUY7C.ts.map → chunk-B53FS4RW.ts.map} +0 -0
- /package/dist/chunks/{chunk-BGGKHHO4.ts.map → chunk-MCUZFUHY.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-XBSME2ER.ts.map → conflict-review-YXROU42F.ts.map} +0 -0
- /package/dist/chunks/{file-selection-S6CNNNQI.ts.map → file-selection-DD6X4J2K.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-I2AMCCE7.ts.map → manager-result-dispatcher-4PEUHK7F.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-GZHPDQ4L.ts.map → remote-selection-ui-47H7V62F.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-M3BAFGJM.ts.map → setup-switch-SPZE7HIQ.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-NFAWP4KF.ts.map → setup-wizard-5JYKAEIT.ts.map} +0 -0
- /package/dist/chunks/{state-directory-JZSZVVPX.ts.map → state-directory-XXHU73Z3.ts.map} +0 -0
package/src/ui/manager-state.ts
CHANGED
|
@@ -14,15 +14,13 @@ import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-st
|
|
|
14
14
|
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
15
15
|
import { errorMessage } from "../sync/sync-errors.js";
|
|
16
16
|
import type { StartupObservation } from "../sync/sync-inspection.js";
|
|
17
|
-
import { compareSyncInclude,
|
|
18
|
-
import { automaticSyncSummary } from "./automatic-sync-summary.js";
|
|
17
|
+
import { compareSyncInclude, syncSessionsSelected } from "../sync/sync-policy.js";
|
|
19
18
|
import {
|
|
20
19
|
observationMatchesConfig,
|
|
21
20
|
observationSummary,
|
|
22
21
|
type SyncAttentionState,
|
|
23
22
|
syncAttentionMatchesConfig,
|
|
24
23
|
} from "./sync-attention.js";
|
|
25
|
-
import { startupTransferSummary } from "./sync-behavior.js";
|
|
26
24
|
import { countValidSyncSetups } from "./sync-setups-ui.js";
|
|
27
25
|
import { safeTerminalText } from "./terminal-text.js";
|
|
28
26
|
|
|
@@ -99,7 +97,6 @@ export async function describeManagerState(
|
|
|
99
97
|
const config = await loadConfig();
|
|
100
98
|
const operation = await inspectOperation();
|
|
101
99
|
const changesBlocked = operationBlocksChanges(operation);
|
|
102
|
-
const selection = syncIncludeSelection(config.include);
|
|
103
100
|
let currentAttention: SyncAttentionState | undefined;
|
|
104
101
|
if (attention) {
|
|
105
102
|
try {
|
|
@@ -129,7 +126,7 @@ export async function describeManagerState(
|
|
|
129
126
|
const lastAppliedSnapshot = changesBlocked
|
|
130
127
|
? "Unavailable while operations are locked"
|
|
131
128
|
: syncState?.lastAppliedSnapshot
|
|
132
|
-
? `${truncateToWidth(safeTerminalText(syncState.lastAppliedSnapshot),
|
|
129
|
+
? `${truncateToWidth(safeTerminalText(syncState.lastAppliedSnapshot), 12, "…")} · application time unavailable`
|
|
133
130
|
: syncState
|
|
134
131
|
? "Never synced"
|
|
135
132
|
: "Unavailable";
|
|
@@ -138,17 +135,14 @@ export async function describeManagerState(
|
|
|
138
135
|
if (config.agentMode && !noSyncedContent) mainActions.splice(1, 0, "Retry refused model result…");
|
|
139
136
|
if (canSwitch) mainActions.push("Switch sync setup");
|
|
140
137
|
if (syncState?.unresolved?.length) mainActions.unshift("Review unresolved conflicts");
|
|
138
|
+
const background = changesBlocked ? [] : await backgroundSummary(config);
|
|
139
|
+
signal?.throwIfAborted();
|
|
141
140
|
const ordinaryTitle = [
|
|
142
141
|
"Manage sync",
|
|
143
|
-
"",
|
|
144
142
|
`Current sync setup: ${safeTerminalText(config.setupName)}`,
|
|
145
143
|
`Storage: ${backendStorageDescription(config)}`,
|
|
146
|
-
"CURRENT STATE",
|
|
147
144
|
...(syncState?.unresolved?.length
|
|
148
|
-
? [
|
|
149
|
-
`Unresolved: ${syncState.unresolved.length} dependency groups · choose Review unresolved conflicts`,
|
|
150
|
-
`Last observed: ${safeTerminalText(syncState.lastObservedSnapshot ?? "unknown")}`,
|
|
151
|
-
]
|
|
145
|
+
? [`Unresolved: ${syncState.unresolved.length} dependency groups · review needed`]
|
|
152
146
|
: []),
|
|
153
147
|
...(currentAttention
|
|
154
148
|
? [
|
|
@@ -160,25 +154,20 @@ export async function describeManagerState(
|
|
|
160
154
|
? "Synced-content exclusion rules differ."
|
|
161
155
|
: "Only the synced-content order differs."
|
|
162
156
|
: `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} · Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " · Exclusion rules differ." : ""}`,
|
|
163
|
-
"Nothing has been changed.",
|
|
164
157
|
]
|
|
165
158
|
: currentObservation
|
|
166
|
-
? [
|
|
167
|
-
`Startup check (${safeTerminalText(currentObservation.checkedAt)}): ${observationSummary(currentObservation)}`,
|
|
168
|
-
"Check-time observation only; synchronization rechecks current content.",
|
|
169
|
-
]
|
|
159
|
+
? [`Observed ${safeTerminalText(currentObservation.checkedAt)}: ${observationSummary(currentObservation)}`]
|
|
170
160
|
: ["Remote status: Not checked"]),
|
|
171
|
-
`Included: ${selection.builtIns.length} built-in group${selection.builtIns.length === 1 ? "" : "s"} · ${selection.custom.length} extra path${selection.custom.length === 1 ? "" : "s"} · Sessions ${syncSessionsSelected(config) ? "on" : "off"}`,
|
|
172
|
-
`Automatic sync: ${automaticSyncSummary(config.automatic)}`,
|
|
173
|
-
`Startup transfer: ${startupTransferSummary(config)}`,
|
|
174
|
-
`Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
|
|
175
|
-
...(config.continuous ? await (await import("../sync/continuous-record.js")).continuousStatusLines(config) : []),
|
|
176
161
|
`Last applied: ${lastAppliedSnapshot}`,
|
|
162
|
+
...(config.agentMode
|
|
163
|
+
? ["Auto-apply: On · AI requests may incur costs"]
|
|
164
|
+
: config.automaticTransfer || (config.automatic && syncSessionsSelected(config))
|
|
165
|
+
? ["Automatic transfer permission: On · see Settings"]
|
|
166
|
+
: []),
|
|
167
|
+
...background,
|
|
177
168
|
...(noSyncedContent
|
|
178
169
|
? ["", "No included content is selected. Choose included content in Settings before syncing."]
|
|
179
170
|
: []),
|
|
180
|
-
"",
|
|
181
|
-
"ACTIONS · transfer, inspect, or manage",
|
|
182
171
|
];
|
|
183
172
|
return {
|
|
184
173
|
title: (changesBlocked ? ["Manage sync", ...operationStatusLines(operation)] : ordinaryTitle).join("\n"),
|
|
@@ -212,6 +201,29 @@ export async function describeManagerState(
|
|
|
212
201
|
}
|
|
213
202
|
}
|
|
214
203
|
|
|
204
|
+
async function backgroundSummary(config: AnySyncConfig): Promise<string[]> {
|
|
205
|
+
if (!config.continuous) return [];
|
|
206
|
+
if (!config.agentMode) return ["Background sync: Paused · enable Autonomous sync"];
|
|
207
|
+
try {
|
|
208
|
+
const { continuousBinding, readContinuousPrivateDocument } = await import("../sync/continuous-storage.js");
|
|
209
|
+
const recordApi: typeof import("../sync/continuous-record.js") = await import("../sync/continuous-record.js");
|
|
210
|
+
const binding = await continuousBinding(config);
|
|
211
|
+
const document = await readContinuousPrivateDocument(`${binding}.json`);
|
|
212
|
+
if (!document) return ["Background sync: Enabled · not yet observed"];
|
|
213
|
+
recordApi.validateContinuousRecord(document.value, binding);
|
|
214
|
+
const record = document.value;
|
|
215
|
+
const phases = { waiting: "Waiting", syncing: "Syncing", retry: "Retry", blocked: "Blocked" };
|
|
216
|
+
return [
|
|
217
|
+
`Background sync (recorded): ${phases[record.phase]}${record.error ? ` · ${record.error}` : ""}`,
|
|
218
|
+
...(record.transferred === undefined
|
|
219
|
+
? []
|
|
220
|
+
: [`Last background transfer: Success · ${new Date(record.transferred).toISOString()}`]),
|
|
221
|
+
];
|
|
222
|
+
} catch {
|
|
223
|
+
return ["Background sync: Unknown · open Diagnostics"];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
215
227
|
function operationActions(
|
|
216
228
|
operation: OperationAvailability,
|
|
217
229
|
noSyncedContent: boolean,
|
package/src/ui/manager-ui.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { Component } from "@earendil-works/pi-tui";
|
|
3
|
-
import { type ActionMenuItem, defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
|
+
import { type ActionMenuItem, defineMenu, type MenuDefinition, runDocumentReview, runMenu } from "@narumitw/pi-tui-kit";
|
|
4
4
|
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
5
5
|
import { operationBlocksChanges } from "../state/operation-availability.js";
|
|
6
6
|
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
@@ -42,6 +42,7 @@ export async function showSyncManager(
|
|
|
42
42
|
};
|
|
43
43
|
type Screen = "main";
|
|
44
44
|
type Action =
|
|
45
|
+
| "activate"
|
|
45
46
|
| "review-attention"
|
|
46
47
|
| "retry-refusal"
|
|
47
48
|
| "sync"
|
|
@@ -63,29 +64,45 @@ export async function showSyncManager(
|
|
|
63
64
|
interface State {
|
|
64
65
|
manager: Awaited<ReturnType<typeof describeManagerState>>;
|
|
65
66
|
}
|
|
66
|
-
const
|
|
67
|
+
const menuItems = (manager: State["manager"]) => {
|
|
68
|
+
const attentionItems = attentionMainMenuItems(manager);
|
|
69
|
+
const managerItems = manager.actions.map((label) => blockedSyncMenuItem(label, manager) ?? syncMainMenuItem(label));
|
|
70
|
+
const operationFirst = manager.operation !== undefined && manager.operation.kind !== "free";
|
|
71
|
+
return operationFirst ? [...managerItems, ...attentionItems] : [...attentionItems, ...managerItems];
|
|
72
|
+
};
|
|
73
|
+
const menu: MenuDefinition<State, Screen, Action, ExtensionCommandContext> = defineMenu<
|
|
74
|
+
State,
|
|
75
|
+
Screen,
|
|
76
|
+
Action,
|
|
77
|
+
ExtensionCommandContext
|
|
78
|
+
>({
|
|
67
79
|
start: "main",
|
|
68
80
|
screens: {
|
|
69
|
-
main: ({ state }) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
81
|
+
main: ({ state }) => ({
|
|
82
|
+
kind: "choice",
|
|
83
|
+
title: "Manage sync",
|
|
84
|
+
lines: state.manager.title.split("\n").slice(1),
|
|
85
|
+
items: menuItems(state.manager).map((item) => ({
|
|
86
|
+
id: item.id,
|
|
87
|
+
label: ctx.mode === "tui" && item.id === "sync" ? "Sync…" : item.label,
|
|
88
|
+
details: [item.description ?? "Review synced content."],
|
|
89
|
+
searchText: `${item.label} ${item.description ?? ""}`,
|
|
90
|
+
disabled: item.disabled,
|
|
91
|
+
disabledReason: item.disabledReason,
|
|
92
|
+
})),
|
|
93
|
+
action: "activate",
|
|
94
|
+
enableSearch: true,
|
|
95
|
+
viewportSize: 5,
|
|
96
|
+
hint: "close",
|
|
97
|
+
}),
|
|
87
98
|
},
|
|
88
99
|
actions: {
|
|
100
|
+
activate: async (invocation) => {
|
|
101
|
+
const item = menuItems(invocation.state.manager).find((candidate) => candidate.id === invocation.itemId);
|
|
102
|
+
if (!item || item.disabled || !("action" in item) || !item.action) return { kind: "stay" };
|
|
103
|
+
// Forward through the handlers below after their setup-ownership guards are installed.
|
|
104
|
+
return menu.actions[item.action](invocation);
|
|
105
|
+
},
|
|
89
106
|
"review-attention": async ({ state }) => {
|
|
90
107
|
const attention = state.manager.attention;
|
|
91
108
|
if (attention && options.getAttention?.() !== attention) return { kind: "stay" };
|
|
@@ -224,6 +241,30 @@ export async function showSyncManager(
|
|
|
224
241
|
const validate = captureMutationOwner(ctx, signal);
|
|
225
242
|
const config = await loadConfig(state.manager.configReview?.setupName);
|
|
226
243
|
validate();
|
|
244
|
+
if (config.continuous) {
|
|
245
|
+
const { continuousStatusLines } = await import("../sync/continuous-record.js");
|
|
246
|
+
validate();
|
|
247
|
+
const lines = await continuousStatusLines(config);
|
|
248
|
+
validate();
|
|
249
|
+
const review = await runDocumentReview(ctx, {
|
|
250
|
+
title: "Sync diagnostics",
|
|
251
|
+
lines: [`Setup: ${safeTerminalText(config.setupName)} · local observations only`],
|
|
252
|
+
content: lines.join("\n"),
|
|
253
|
+
confirmation: { label: "Continue to backend checks…" },
|
|
254
|
+
hint: "back",
|
|
255
|
+
signal,
|
|
256
|
+
isCurrent,
|
|
257
|
+
});
|
|
258
|
+
validate();
|
|
259
|
+
if (review.kind === "cancelled") return { kind: review.reason === "close" ? "close" : "stay" };
|
|
260
|
+
if (review.kind !== "confirmed") return { kind: "stay" };
|
|
261
|
+
const current = await loadConfig();
|
|
262
|
+
validate();
|
|
263
|
+
if (syncCheckConfigFingerprint(config) !== syncCheckConfigFingerprint(current)) {
|
|
264
|
+
ctx.ui.notify("Setup changed during diagnostics review; reopen Diagnostics.", "warning");
|
|
265
|
+
return { kind: "stay" };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
227
268
|
const confirmed = await ctx.ui.confirm(
|
|
228
269
|
"Run diagnostics?",
|
|
229
270
|
`Setup: ${safeTerminalText(config.setupName)}\nStorage: ${backendStorageDescription(config)}\nS3/R2 reads the latest pointer without writing. Git reads remote snapshots and checks its cache. WebDAV probes conditional writes and cleanup, and can repair a missing history entry. Possible-secret checks still run. This is not the read-only Check remote status action.`,
|
|
@@ -397,21 +438,24 @@ function syncMainMenuItem(
|
|
|
397
438
|
id: action,
|
|
398
439
|
label,
|
|
399
440
|
action,
|
|
400
|
-
description:
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
441
|
+
description: {
|
|
442
|
+
sync: "Merge changes on both sides.",
|
|
443
|
+
"retry-refusal": "Retry model; may incur costs.",
|
|
444
|
+
pull: "Remote → this device.",
|
|
445
|
+
push: "This device → remote snapshot.",
|
|
446
|
+
diff: "Inspect changes; no transfer.",
|
|
447
|
+
status: "Check remote; no transfer.",
|
|
448
|
+
settings: "Change sync settings.",
|
|
449
|
+
history: "Review snapshots and rollback.",
|
|
450
|
+
doctor: "Review backend diagnostics.",
|
|
451
|
+
switch: "Choose another sync setup.",
|
|
452
|
+
conflicts: "Review unresolved file groups.",
|
|
453
|
+
recover: "Review local lock recovery.",
|
|
454
|
+
refresh: "Recheck the operation lock.",
|
|
455
|
+
setups: "Manage sync setups.",
|
|
456
|
+
connections: "Manage storage connections.",
|
|
457
|
+
help: "Read sync commands and safety.",
|
|
458
|
+
init: "Configure a sync setup.",
|
|
459
|
+
}[action],
|
|
416
460
|
};
|
|
417
461
|
}
|
package/src/ui/sync-attention.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { syncCheckConfigFingerprint, syncConfigReviewFingerprint } from "../sett
|
|
|
5
5
|
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
6
6
|
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
7
7
|
import type { StartupObservation } from "../sync/sync-inspection.js";
|
|
8
|
-
import {
|
|
8
|
+
import { type RemoteSelectionDecision, sameSyncInclude } from "../sync/sync-policy.js";
|
|
9
9
|
import { setSyncStatus } from "./sync-status.js";
|
|
10
10
|
import { safeTerminalText } from "./terminal-text.js";
|
|
11
11
|
|
|
@@ -107,12 +107,10 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
107
107
|
});
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
? attentionPresentation(state.decision)
|
|
112
|
-
: observationPresentation(observation as StartupObservation);
|
|
110
|
+
const setupName = safeTerminalText(state?.decision.setupName ?? observation?.setupName ?? "");
|
|
113
111
|
if (ctx.mode !== "tui") {
|
|
114
112
|
ctx.ui.setWidget(WIDGET_KEY, undefined);
|
|
115
|
-
setSyncStatus(ctx,
|
|
113
|
+
setSyncStatus(ctx, "sync ⇕", { activity: "review" });
|
|
116
114
|
return;
|
|
117
115
|
}
|
|
118
116
|
// Keep Kit outside the eager startup graph; module loading owns no cancellable resources.
|
|
@@ -121,7 +119,7 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
121
119
|
throw error;
|
|
122
120
|
});
|
|
123
121
|
if (generation !== currentGeneration || signal?.aborted) return;
|
|
124
|
-
setSyncStatus(ctx,
|
|
122
|
+
setSyncStatus(ctx, "sync ⇕", { activity: "review" });
|
|
125
123
|
const presentationState = widgetState;
|
|
126
124
|
ctx.ui.setWidget(
|
|
127
125
|
WIDGET_KEY,
|
|
@@ -131,55 +129,15 @@ export function createSyncAttentionController(): SyncAttentionController {
|
|
|
131
129
|
name: "Sync",
|
|
132
130
|
summary: "Needs review",
|
|
133
131
|
state: presentationState,
|
|
134
|
-
renderBody: (width) =>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
),
|
|
132
|
+
renderBody: (width) => [
|
|
133
|
+
width === 0 ? "" : truncateToWidth(theme.fg("muted", `Open /sync to review · ${setupName}`), width, "…"),
|
|
134
|
+
],
|
|
138
135
|
}),
|
|
139
136
|
);
|
|
140
137
|
},
|
|
141
138
|
};
|
|
142
139
|
}
|
|
143
140
|
|
|
144
|
-
function attentionPresentation(decision: RemoteSelectionDecision) {
|
|
145
|
-
const setupName = safeTerminalText(decision.setupName);
|
|
146
|
-
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
147
|
-
return {
|
|
148
|
-
status: "sync ⇕",
|
|
149
|
-
lines: [
|
|
150
|
-
`Setup: ${setupName}`,
|
|
151
|
-
selectionDifference({
|
|
152
|
-
...comparison,
|
|
153
|
-
excludeChanged: !sameSyncExclude(decision.localExclude, decision.remoteExclude),
|
|
154
|
-
}),
|
|
155
|
-
"No transfer performed · Run /sync to review",
|
|
156
|
-
],
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function selectionDifference(comparison: {
|
|
161
|
-
remoteOnly: readonly string[];
|
|
162
|
-
localOnly: readonly string[];
|
|
163
|
-
excludeChanged?: boolean;
|
|
164
|
-
}) {
|
|
165
|
-
if (comparison.excludeChanged) return "Selection: excluded paths differ; review needed";
|
|
166
|
-
return comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0
|
|
167
|
-
? "Selection: only list order differs"
|
|
168
|
-
: `Selection: ${comparison.remoteOnly.length} remote-only · ${comparison.localOnly.length} device-only`;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function observationPresentation(observation: StartupObservation) {
|
|
172
|
-
const selection = observation.inspection.selectionState;
|
|
173
|
-
return {
|
|
174
|
-
status: "sync ⇕",
|
|
175
|
-
lines: [
|
|
176
|
-
`Setup: ${safeTerminalText(observation.setupName)}`,
|
|
177
|
-
selection?.kind === "different" ? selectionDifference(selection) : observationSummary(observation),
|
|
178
|
-
"No transfer performed · Run /sync to review",
|
|
179
|
-
],
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
141
|
export function observationMatchesConfig(observation: StartupObservation, config: AnySyncConfig) {
|
|
184
142
|
return observation.configIdentity === syncCheckConfigFingerprint(config);
|
|
185
143
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/settings/config.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/settings/config\";\nexport {\n configFromSettings,\n isEnabled,\n isExplicitlyEnabled,\n loadConfig,\n loadConfigForCheck,\n loadPartialConfig,\n sessionTokenWarnings,\n syncCheckConfigFingerprint,\n syncConfigReviewFingerprint,\n syncConfigReviewIdentity,\n syncSessionsWarnings,\n syncSetupReviewIdentity,\n syncSetupStorageReview,\n} from \"@narumitw/sync-daemon/engine/settings/config\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/daemon/pi-client.ts", "../../src/daemon/apply-gate.ts", "../../src/daemon/recovery.ts"],
|
|
4
|
-
"sourcesContent": ["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { randomUUID } from \"node:crypto\";\nimport { realpathSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type ExtensionContext, getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport {\n type Callback,\n type ClientFacts,\n type ClientHandoff,\n DaemonConnection,\n DaemonError,\n type DocumentView,\n documentFingerprint,\n ensureDaemon,\n findDaemon,\n MAX_SETTINGS_BYTES,\n modelSignature,\n} from \"@narumitw/sync-daemon\";\nimport { type ConfigAuthority, configureEngineHost } from \"@narumitw/sync-daemon/engine/host\";\nimport { type LocalConfigDocument, peekLocalConfigDocument } from \"@narumitw/sync-daemon/engine/settings/config-file\";\nimport { validateSettingsDocument } from \"@narumitw/sync-daemon/engine/settings/settings-validation\";\nimport { sessionDirFromContext } from \"@narumitw/sync-daemon/engine/snapshot/session-paths\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { StartupTimingPublisher } from \"../sync/startup-timings.js\";\nimport { SyncDecisionRequiredError } from \"../sync/sync-errors.js\";\nimport { RemoteSelectionMismatchError } from \"../sync/sync-policy.js\";\nimport { type SyncStatusPresentation, setSyncStatus } from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { PiApplyGate } from \"./apply-gate.js\";\nimport { quarantineClient, recoverDetachedClients } from \"./recovery.js\";\n\nconst scope = new AsyncLocalStorage<PiDaemonClient>();\nconst clients = new WeakMap<ExtensionContext[\"sessionManager\"], PiDaemonClient>();\nexport function currentPiDaemonClient() {\n return current();\n}\nfunction current() {\n const client = scope.getStore();\n if (!client) throw new Error(\"Pi synchronization requires a current session-bound daemon client.\");\n client.validate();\n return client;\n}\nfunction canonicalPath(value: string | undefined): string | undefined {\n if (value === undefined) return undefined;\n if (!path.isAbsolute(value)) throw new Error(\"Pi session paths must be absolute.\");\n const parts: string[] = [];\n let cursor = path.resolve(value);\n for (;;) {\n try {\n return path.join(realpathSync(cursor), ...parts.toReversed());\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\" || path.dirname(cursor) === cursor) throw error;\n parts.push(path.basename(cursor));\n cursor = path.dirname(cursor);\n }\n }\n}\nfunction decode(value: unknown): LocalConfigDocument | undefined {\n if (value === null) return undefined;\n const document = value as DocumentView;\n if (\n !document ||\n typeof document.path !== \"string\" ||\n typeof document.bytes !== \"string\" ||\n !document.identity ||\n !document.parsed\n )\n throw new Error(\"Invalid settings response.\");\n return { ...document, bytes: Buffer.from(document.bytes, \"base64\") };\n}\nfunction fingerprint(document: LocalConfigDocument | undefined) {\n return documentFingerprint(\n document ? { bytes: document.bytes.toString(\"base64\"), identity: document.identity } : undefined,\n );\n}\nlet settingsQueue = Promise.resolve();\nconst authority: ConfigAuthority = {\n read: (repair) => {\n const client = current();\n return settingsQueue.then(() => {\n client.validate();\n return client.readSettings(repair);\n });\n },\n update: <T extends Record<string, unknown>>(\n fallback: T,\n update: (value: T) => T,\n validate: (value: Record<string, unknown>) => void,\n signal?: AbortSignal,\n ): Promise<T> => {\n const client = current();\n // Capture ownership and invocation order before prerequisite awaits.\n const operation = settingsQueue.then(async () => {\n client.validate();\n signal?.throwIfAborted();\n const document = await client.readSettings(true);\n client.validate();\n signal?.throwIfAborted();\n const next = update(structuredClone(document?.parsed ?? fallback) as T);\n validate(next);\n await client.run(\"settings.cas\", { expected: fingerprint(document), next }, signal);\n client.validate();\n return next;\n });\n settingsQueue = operation.then(\n () => undefined,\n () => undefined,\n );\n return operation;\n },\n create: async (next, signal) => {\n await current().run(\"settings.cas\", { expected: null, next }, signal);\n },\n replace: async (document, next) => {\n await current().run(\"settings.cas\", { expected: fingerprint(document), next });\n },\n};\n/** Factory registration installs only adapters; it starts no process and performs no I/O. */\nexport function installPiDaemonHost() {\n configureEngineHost({\n root: () => scope.getStore()?.root ?? path.resolve(getAgentDir()),\n config: authority,\n mutate: async () => {\n throw new Error(\"File mutation belongs to sync-daemon; no in-process fallback is permitted.\");\n },\n review: async () => {\n throw new Error(\"Engine reviews must arrive through the daemon API.\");\n },\n });\n}\nexport function bindPiDaemonClient(ctx: ExtensionContext, signal: AbortSignal, publish?: StartupTimingPublisher) {\n const client = new PiDaemonClient(ctx, signal, publish);\n clients.set(ctx.sessionManager, client);\n return client;\n}\nexport function piDaemonClient(ctx: ExtensionContext) {\n const client = clients.get(ctx.sessionManager);\n if (!client) throw new Error(\"The Pi synchronization client is not attached to this session.\");\n client.validate();\n return client;\n}\nexport function withPiDaemonClient<Context extends ExtensionContext, T>(\n ctx: Context,\n action: (owned: Context) => Promise<T>,\n) {\n const client = piDaemonClient(ctx);\n // TUI input arrives from Pi's event loop, outside the command's async call tree.\n // Bind public component methods so later menu actions retain this exact owner,\n // never a replacement session selected through a global fallback.\n const ui = new Proxy(ctx.ui, {\n get(target, property) {\n if (property !== \"custom\") return Reflect.get(target, property, target);\n return (...args: Parameters<ExtensionContext[\"ui\"][\"custom\"]>) => {\n const [factory, options] = args;\n const wrap = (component: Awaited<ReturnType<typeof factory>>) => {\n const methods = new Map<PropertyKey, { source: unknown; bound: unknown }>();\n return new Proxy(component, {\n get(original, key) {\n const value: unknown = Reflect.get(original, key, original);\n if (typeof value !== \"function\") return value;\n const saved = methods.get(key);\n if (saved?.source === value) return saved.bound;\n const bound = (...values: unknown[]) => scope.run(client, () => Reflect.apply(value, original, values));\n methods.set(key, { source: value, bound });\n return bound;\n },\n });\n };\n const invoke = (...provided: Parameters<typeof factory>) => {\n const component = scope.run(client, () => factory(...provided));\n return component instanceof Promise ? component.then(wrap) : wrap(component);\n };\n // Do not turn synchronous editors/reviews into asynchronous factories.\n return target.custom(\n factory.constructor.name === \"AsyncFunction\" ? async (...provided) => invoke(...provided) : invoke,\n options,\n );\n };\n },\n });\n const owned = new Proxy(ctx, {\n get(target, key) {\n return key === \"ui\" ? ui : Reflect.get(target, key, target);\n },\n });\n return scope.run(client, () => action(owned));\n}\nexport async function remoteOperation(ctx: ExtensionContext, operation: string, options: CommandOptions) {\n const client = piDaemonClient(ctx);\n const { signal, onCommit, args, setup } = options;\n const payload = {\n args,\n ...(setup === undefined ? {} : { setup }),\n yes: options.yes,\n force: options.force,\n stale: options.stale,\n silent: options.silent,\n reload: options.reload,\n ...(options.agentRetryRefusal ? { agentRetryRefusal: true } : {}),\n };\n return client.run(operation, payload, signal, ctx, onCommit);\n}\nexport class PiDaemonClient {\n private connection?: DaemonConnection;\n private partialConnection?: DaemonConnection;\n private work = Promise.resolve();\n private closing = false;\n private paused = false;\n private pausing?: Promise<void>;\n private connecting?: Promise<DaemonConnection>;\n private disposed = false;\n private disposing?: Promise<void>;\n private uiContext: ExtensionContext;\n private reloadRequested = false;\n private readonly busy = new Set<string>();\n private initialized = false;\n private startupDebug = false;\n readonly id = randomUUID();\n readonly generation = randomUUID();\n readonly root: string;\n private readonly rawRoot: string;\n private readonly gate: PiApplyGate;\n private readonly manager: ExtensionContext[\"sessionManager\"];\n constructor(\n private readonly ctx: ExtensionContext,\n private readonly signal: AbortSignal,\n private readonly publish?: StartupTimingPublisher,\n ) {\n this.uiContext = ctx;\n this.manager = ctx.sessionManager;\n this.rawRoot = getAgentDir();\n const root = canonicalPath(path.resolve(this.rawRoot));\n if (!root) throw new Error(\"Agent directory is unavailable.\");\n this.root = root;\n this.gate = new PiApplyGate(() => this.validate());\n }\n validate() {\n this.signal.throwIfAborted();\n if (this.disposed || this.closing || clients.get(this.manager) !== this)\n throw new Error(\"Synchronization session was replaced.\");\n // Public context access verifies the SDK runner is still active after awaits.\n this.ctx.isIdle();\n if (getAgentDir() !== this.rawRoot || canonicalPath(path.resolve(this.rawRoot)) !== this.root)\n throw new Error(\"Agent directory changed; reload before synchronization.\");\n }\n private modelBinding(): ClientFacts[\"model\"] {\n const model = this.ctx.model;\n if (!model) return undefined;\n const registry = this.ctx.modelRegistry;\n if (registry.getRegisteredProviderIds().includes(model.provider)) return undefined;\n const source = registry.getProviderAuthStatus(model.provider).source;\n if (\n source !== \"stored\" &&\n source !== \"environment\" &&\n source !== \"models_json_key\" &&\n source !== \"models_json_command\"\n )\n return undefined;\n return { provider: model.provider, id: model.id, signature: modelSignature(model), authSource: source };\n }\n private facts(): ClientFacts {\n const manager = this.ctx.sessionManager;\n return {\n id: this.id,\n generation: this.generation,\n pid: process.pid,\n cwd: this.ctx.cwd,\n mode: this.ctx.mode,\n hasUI: this.ctx.hasUI,\n idle: !this.paused && !this.busy.size && this.ctx.isIdle(),\n ready: this.initialized,\n startupDebug: this.startupDebug,\n sessionFile: canonicalPath(manager.getSessionFile?.()),\n sessionId: manager.getSessionId?.(),\n sessionDir: canonicalPath(sessionDirFromContext(this.ctx)),\n model: this.modelBinding(),\n };\n }\n async configured() {\n this.validate();\n await settingsQueue;\n this.validate();\n const document = await peekLocalConfigDocument();\n this.validate();\n return Boolean(document && validateSettingsDocument(document.parsed).activeSyncSetup);\n }\n async pauseForSessionChange() {\n this.validate();\n this.paused = true;\n this.gate.cancelPending();\n this.pausing ??= (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n if (connection) {\n await connection.pause();\n await this.gate.releaseAfterDrain();\n }\n })();\n return this.pausing;\n }\n async attachExisting() {\n this.validate();\n const address = await findDaemon(this.root);\n this.validate();\n if (address) await this.connect(address);\n this.validate();\n return Boolean(address);\n }\n async finishReattachment() {\n this.validate();\n if (this.connection) {\n await recoverDetachedClients({ paths: this.connection.paths, identity: this.connection.identity });\n this.validate();\n await this.connection.attach();\n this.validate();\n }\n }\n async connect(existing?: Awaited<ReturnType<typeof ensureDaemon>>) {\n this.validate();\n if (this.connection) return this.connection;\n this.connecting ??= (async () => {\n // Only explicit setup/command paths or a configured interactive session call connect.\n if (!existing) await fs.mkdir(this.root, { recursive: true, mode: 0o700 });\n this.validate();\n const daemon = existing ?? (await ensureDaemon(this.root, this.signal));\n this.validate();\n if (daemon.paths.root !== this.root) throw new Error(\"Daemon root changed before attach.\");\n const connection = new DaemonConnection(daemon.paths, daemon.identity, this.facts(), {\n callback: (callback, signal) => this.callback(callback, signal),\n event: (event) => {\n if (event.kind === \"commit\") return;\n if (this.signal.aborted || this.disposed || this.closing || clients.get(this.manager) !== this) return;\n const payload = event.payload as {\n message?: string;\n level?: \"info\" | \"warning\" | \"error\";\n value?: string;\n presentation?: SyncStatusPresentation;\n };\n if (event.kind === \"notify\" && typeof payload?.message === \"string\")\n this.uiContext.ui.notify(safeTerminalText(payload.message), payload.level ?? \"info\");\n if (event.kind === \"timings\" && typeof (event.payload as { report?: unknown })?.report === \"string\") {\n this.publish?.(this.ctx, safeTerminalText((event.payload as { report: string }).report));\n }\n if (event.kind === \"status\")\n setSyncStatus(\n this.uiContext,\n typeof payload?.value === \"string\" ? safeTerminalText(payload.value) : undefined,\n payload.presentation,\n );\n },\n error: () => {\n if (!this.signal.aborted && !this.disposed && !this.closing && clients.get(this.manager) === this)\n setSyncStatus(this.ctx, \"sync service unavailable\", { activity: \"blocked\", reason: \"repair\" });\n },\n });\n this.partialConnection = connection;\n await connection.attach();\n this.validate();\n await recoverDetachedClients(daemon);\n if (this.signal.aborted || this.disposed || this.closing) {\n await connection.dispose();\n this.validate();\n }\n this.connection = connection;\n return connection;\n })().catch((error) => {\n this.connecting = undefined;\n throw error;\n });\n return this.connecting;\n }\n async readSettings(repair = false) {\n this.validate();\n if (!this.connection || this.paused) {\n const document = await peekLocalConfigDocument();\n this.validate();\n if (document && document.bytes.length > MAX_SETTINGS_BYTES)\n throw new Error(\"Settings exceed the local API byte limit; the source document is unchanged.\");\n if (document && !repair) validateSettingsDocument(document.parsed);\n return document;\n }\n return decode(await this.run(repair ? \"settings.repair-read\" : \"settings.read\", {}));\n }\n run(operation: string, payload: unknown, signal?: AbortSignal, ctx = this.ctx, onCommit?: () => void) {\n const result = this.work.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit));\n this.work = result.then(\n () => {},\n () => {},\n );\n return result;\n }\n private async runCurrent(\n operation: string,\n payload: unknown,\n signal?: AbortSignal,\n ctx = this.ctx,\n onCommit?: () => void,\n ) {\n this.validate();\n signal?.throwIfAborted();\n if (this.paused && operation !== \"shutdown\")\n throw new Error(\"Synchronization is paused for a session change; if it was cancelled, use /reload to reattach.\");\n const connection = await this.connect();\n if (this.paused && operation === \"shutdown\") {\n Object.assign(connection.facts, { ...this.facts(), idle: false, ready: false });\n await connection.attach();\n this.validate();\n }\n this.validate();\n signal?.throwIfAborted();\n await connection.update(this.facts());\n this.validate();\n signal?.throwIfAborted();\n this.uiContext = ctx;\n try {\n return await connection.run(\n operation,\n payload,\n signal ? AbortSignal.any([signal, this.signal]) : this.signal,\n onCommit,\n );\n } catch (error) {\n if (error instanceof DaemonError) {\n const prototype =\n error.name === \"RemoteSelectionMismatchError\"\n ? RemoteSelectionMismatchError.prototype\n : error.name === \"SyncDecisionRequiredError\"\n ? SyncDecisionRequiredError.prototype\n : undefined;\n if (prototype) {\n const restored = Object.create(prototype) as Error;\n Object.assign(restored, error.remote.properties, { name: error.name, message: error.message });\n throw restored;\n }\n Object.assign(error, error.remote.properties);\n }\n throw error;\n } finally {\n this.uiContext = this.ctx;\n if (\n this.reloadRequested &&\n !this.signal.aborted &&\n !this.disposed &&\n !this.closing &&\n clients.get(this.manager) === this\n ) {\n this.reloadRequested = false;\n if (\"reload\" in ctx && typeof ctx.reload === \"function\") await ctx.reload();\n }\n }\n }\n async markReady(debug: boolean) {\n this.validate();\n this.startupDebug = debug;\n this.initialized = true;\n await this.update();\n this.validate();\n }\n async setBusy(reason: string, busy: boolean) {\n this.validate();\n if (busy) this.busy.add(reason);\n else this.busy.delete(reason);\n await this.update();\n this.validate();\n }\n async update() {\n if (this.connection && !this.paused && !this.disposed && !this.signal.aborted)\n await this.connection.update(this.facts());\n }\n private async callback(callback: Callback, signal: AbortSignal) {\n const payload = callback.payload as {\n reservation?: string;\n targets?: string[];\n generation?: string;\n title?: string;\n message?: string;\n content?: string;\n confirmationLabel?: string;\n summaryLines?: string[];\n items?: string[];\n helpText?: string;\n background?: boolean;\n };\n if (callback.kind === \"queue-release\") {\n if (typeof payload?.reservation !== \"string\") throw new Error(\"Invalid queue release.\");\n await this.gate.releaseRequest(payload.reservation);\n return true;\n }\n this.validate();\n signal.throwIfAborted();\n if (this.paused) throw new Error(\"Pi session is changing; no new work is authorized.\");\n if (callback.kind === \"queue-acquire\") {\n if (payload.background && !this.facts().idle) throw new Error(\"Pi is busy; background apply was not granted.\");\n if (\n payload.generation !== this.generation ||\n typeof payload.reservation !== \"string\" ||\n !Array.isArray(payload.targets)\n )\n throw new Error(\"Stale file-queue request.\");\n return this.gate.acquire(payload.reservation, payload.targets, AbortSignal.any([signal, this.signal]));\n }\n const ctx = this.uiContext;\n const combined = AbortSignal.any([signal, this.signal]);\n if (callback.kind === \"model-binding\") {\n const facts = this.facts();\n const connection = this.connection ?? this.partialConnection;\n if (connection && JSON.stringify(connection.facts.model) !== JSON.stringify(facts.model)) {\n await connection.update(facts);\n this.validate();\n }\n return payload.background && !facts.idle ? null : (facts.model ?? null);\n }\n if (callback.kind === \"reload\") {\n this.reloadRequested = true;\n return true;\n }\n if (!ctx.hasUI || ![\"tui\", \"rpc\"].includes(ctx.mode)) throw new Error(\"This client cannot present safety reviews.\");\n let result: unknown;\n if (callback.kind === \"merge-review\" && typeof payload.title === \"string\" && typeof payload.content === \"string\") {\n const { confirmMergeReview } = await import(\"../ui/merge-review.js\");\n this.validate();\n combined.throwIfAborted();\n result = await confirmMergeReview(\n ctx,\n payload.title,\n payload.content,\n combined,\n () => !combined.aborted && !this.disposed,\n payload.confirmationLabel,\n payload.summaryLines,\n );\n } else if (\n callback.kind === \"confirm\" &&\n typeof payload.title === \"string\" &&\n typeof payload.message === \"string\"\n ) {\n result = await ctx.ui.confirm(safeTerminalText(payload.title), safeTerminalText(payload.message), {\n signal: combined,\n });\n } else if (\n callback.kind === \"select\" &&\n typeof payload.title === \"string\" &&\n Array.isArray(payload.items) &&\n payload.items.every((item) => typeof item === \"string\")\n ) {\n const labels = payload.items.map(safeTerminalText);\n if (new Set(labels).size !== labels.length) throw new Error(\"Daemon choices have ambiguous terminal labels.\");\n const selected = await ctx.ui.select(safeTerminalText(payload.title), labels, { signal: combined });\n const index = selected === undefined ? -1 : labels.indexOf(selected);\n result = index < 0 ? undefined : payload.items[index];\n } else throw new Error(\"Unsupported daemon UI callback.\");\n this.validate();\n combined.throwIfAborted();\n return result;\n }\n disposeForShutdown(reason: string | undefined, targetFile?: string) {\n const facts = this.connection?.facts ?? this.partialConnection?.facts;\n return this.dispose({\n kind: [\"new\", \"resume\", \"fork\", \"reload\"].includes(reason ?? \"\") ? \"replace\" : \"exit\",\n ...(targetFile !== undefined\n ? { file: canonicalPath(targetFile) }\n : reason === \"reload\"\n ? { file: facts?.sessionFile, sessionId: facts?.sessionId }\n : {}),\n cwd: facts?.cwd,\n });\n }\n async dispose(handoff?: ClientHandoff) {\n if (this.disposing) return this.disposing;\n this.closing = true;\n this.disposing = (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n let confirmed = false;\n try {\n await connection?.dispose(handoff);\n confirmed = Boolean(connection);\n } finally {\n this.disposed = true;\n if (clients.get(this.manager) === this) clients.delete(this.manager);\n const gate = this.gate;\n gate.detach();\n if (connection) {\n if (confirmed) await gate.releaseAfterDrain();\n else quarantineClient(gate, connection.paths.root, connection.identity, connection.facts);\n }\n await this.work;\n }\n })();\n return this.disposing;\n }\n}\n", "import { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport { withTargetQueues } from \"@narumitw/sync-daemon/engine/snapshot/snapshot-mutation-queues\";\n\ninterface Gate {\n token: string;\n paths: readonly string[];\n entered: Promise<string>;\n task: Promise<void>;\n granted: boolean;\n cancelled: boolean;\n reject(error: unknown): void;\n release(): void;\n}\n/**\n * Holds the running Pi's actual public file queues; it does not authorize filesystem writes.\n * The engine owns reviewed destinations, which can differ from every participant's current roots.\n */\nexport class PiApplyGate {\n private gates = new Map<string, Gate>();\n constructor(private validate: () => void) {}\n async acquire(requestId: string, targets: readonly string[], signal?: AbortSignal) {\n this.validate();\n signal?.throwIfAborted();\n if (\n !targets.length ||\n targets.length > 16_384 ||\n targets.some((target) => typeof target !== \"string\" || target.includes(\"\\0\") || !path.isAbsolute(target))\n )\n throw new Error(\"Invalid daemon mutation targets.\");\n const normalized = [...new Set(targets.map((target) => path.resolve(target)))].sort();\n const existing = this.gates.get(requestId);\n if (existing) {\n if (JSON.stringify(existing.paths) !== JSON.stringify(normalized)) throw new Error(\"File-queue request changed.\");\n return existing.entered;\n }\n const token = randomUUID();\n let entered!: (token: string) => void;\n let rejected!: (error: unknown) => void;\n const ready = new Promise<string>((resolve, reject) => {\n entered = resolve;\n rejected = reject;\n });\n let release!: () => void;\n const held = new Promise<void>((resolve) => {\n release = resolve;\n });\n const gate: Gate = {\n token,\n paths: normalized,\n entered: ready,\n task: Promise.resolve(),\n release,\n reject: rejected,\n granted: false,\n cancelled: false,\n };\n this.gates.set(requestId, gate);\n const validate = () => {\n if (gate.cancelled) throw new DOMException(\"File-queue reservation was cancelled\", \"AbortError\");\n this.validate();\n };\n gate.task = withTargetQueues(\n normalized,\n { signal, validateMutation: validate },\n async () => {\n validate();\n signal?.throwIfAborted();\n gate.granted = true;\n entered(token);\n // Prompt cancellation cannot revoke a grant while a remote writer may still run.\n await held;\n },\n { mutate: withFileMutationQueue },\n )\n .catch((error) => {\n rejected(error);\n })\n .finally(() => {\n if (this.gates.get(requestId) === gate) this.gates.delete(requestId);\n });\n const abort = () => {\n if (!gate.granted) {\n gate.cancelled = true;\n rejected(signal?.reason);\n release();\n }\n };\n signal?.addEventListener(\"abort\", abort, { once: true });\n void gate.task.finally(() => signal?.removeEventListener(\"abort\", abort));\n return ready;\n }\n async release(token: string) {\n const gate = [...this.gates.values()].find((value) => value.token === token);\n if (!gate) throw new Error(\"Unknown file-queue grant.\");\n await this.releaseGate(gate);\n }\n private async releaseGate(gate: Gate) {\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(new DOMException(\"File-queue reservation was released\", \"AbortError\"));\n }\n gate.release();\n // A queued, ungranted placeholder cannot write after cancellation and need not\n // wait for another Pi tool to finish before acknowledgement.\n if (gate.granted) await gate.task;\n }\n async releaseRequest(requestId: string) {\n const gate = this.gates.get(requestId);\n if (!gate) return;\n await this.releaseGate(gate);\n }\n detach() {\n const failure = new DOMException(\"Pi session detached\", \"AbortError\");\n this.validate = () => {\n throw failure;\n };\n this.cancelPending(failure);\n }\n cancelPending(failure: unknown = new DOMException(\"Pi session changing\", \"AbortError\")) {\n for (const gate of this.gates.values())\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(failure);\n gate.release();\n }\n }\n get size() {\n return [...this.gates.values()].filter((gate) => gate.granted || !gate.cancelled).length;\n }\n /** Release only after establishing that the associated service cannot still write. */\n async releaseAfterOwnerExit(pid: number) {\n try {\n process.kill(pid, 0);\n throw new Error(\"Daemon owner is still alive; grants remain held.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ESRCH\") throw error;\n }\n await this.releaseAfterDrain();\n }\n /** Caller must first receive an authenticated same-owner detach/drain acknowledgement. */\n async releaseAfterDrain() {\n await Promise.all([...this.gates.values()].map((gate) => this.releaseGate(gate)));\n }\n}\n", "import { type ClientFacts, DaemonConnection, findDaemon, type Identity } from \"@narumitw/sync-daemon\";\nimport type { PiApplyGate } from \"./apply-gate.js\";\n\ntype Address = { paths: DaemonConnection[\"paths\"]; identity: Identity };\ninterface Recovery {\n gate: PiApplyGate;\n root: string;\n identity: Identity;\n facts: ClientFacts;\n timer?: ReturnType<typeof setInterval>;\n attempt?: Promise<boolean>;\n}\nconst recoveries = new Set<Recovery>();\nfunction alive(pid: number) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n }\n}\nfunction finish(record: Recovery) {\n if (record.timer) clearInterval(record.timer);\n recoveries.delete(record);\n}\nfunction attempt(record: Recovery, known?: Address): Promise<boolean> {\n record.attempt ??= (async () => {\n const exited = !alive(record.identity.pid);\n if (exited) await record.gate.releaseAfterOwnerExit(record.identity.pid);\n const address = known ?? (await findDaemon(record.root));\n if (!address || (!exited && address.identity.instance !== record.identity.instance)) return false;\n // Only plain closed-session facts and detached grants cross this recovery boundary.\n // Reclaim the obsolete participant on a compatible owner, reject all new work,\n // and service release callbacks until an authenticated detach confirms drain.\n const connection = new DaemonConnection(\n address.paths,\n address.identity,\n {\n ...record.facts,\n hasUI: false,\n idle: false,\n ready: false,\n },\n {\n callback: async (callback) => {\n const data = callback.payload;\n if (\n callback.kind === \"queue-release\" &&\n data !== null &&\n typeof data === \"object\" &&\n \"reservation\" in data &&\n typeof data.reservation === \"string\"\n ) {\n await record.gate.releaseRequest(data.reservation);\n return true;\n }\n throw new Error(\"Closed Pi participant cannot authorize new work.\");\n },\n },\n );\n try {\n // Cleanup polling does not attach or recreate a retired participant.\n await connection.dispose();\n await record.gate.releaseAfterDrain();\n finish(record);\n return true;\n } finally {\n await connection.dispose();\n }\n })()\n .catch(() => false)\n .finally(() => {\n record.attempt = undefined;\n });\n return record.attempt;\n}\n\n/** Intentionally shared cleanup may outlive a session, but never retains its ctx or UI. */\nexport function quarantineClient(gate: PiApplyGate, root: string, identity: Identity, facts: ClientFacts) {\n gate.detach();\n const record: Recovery = { gate, root, identity: structuredClone(identity), facts: structuredClone(facts) };\n recoveries.add(record);\n record.timer = setInterval(() => {\n void attempt(record);\n }, 1000);\n record.timer.unref();\n void attempt(record);\n}\n\n/** A newly attached client stays unready until obsolete local participants are retired. */\nexport async function recoverDetachedClients(address: Address) {\n const pending = [...recoveries].filter((record) => record.root === address.paths.root);\n const results = await Promise.all(\n pending.map(async (record) => {\n const done = await attempt(record, address);\n return done || !recoveries.has(record) || (await attempt(record, address));\n }),\n );\n if (results.some((done) => !done))\n throw new Error(\n \"Previous Pi cleanup is still uncertain; stop or repair the existing daemon before retrying /reload.\",\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA,SAAS,yBAAyB;AAClC,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,SAAgC,mBAAmB;AACnD;AAAA,EAIE,oBAAAC;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA,cAAAC;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA+B,2BAA2B;AAC1D,SAAmC,+BAA+B;AAClE,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;;;ACtBtC,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AACjB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAgB1B,IAAM,cAAN,MAAkB;AAAA,EAEvB,YAAoB,UAAsB;AAAtB;AAAA,EAAuB;AAAA,EAAvB;AAAA,EADZ,QAAQ,oBAAI,IAAkB;AAAA,EAEtC,MAAM,QAAQ,WAAmB,SAA4B,QAAsB;AACjF,SAAK,SAAS;AACd,YAAQ,eAAe;AACvB,QACE,CAAC,QAAQ,UACT,QAAQ,SAAS,SACjB,QAAQ,KAAK,CAAC,WAAW,OAAO,WAAW,YAAY,OAAO,SAAS,IAAI,KAAK,CAAC,KAAK,WAAW,MAAM,CAAC;AAExG,YAAM,IAAI,MAAM,kCAAkC;AACpD,UAAM,aAAa,CAAC,GAAG,IAAI,IAAI,QAAQ,IAAI,CAAC,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK;AACpF,UAAM,WAAW,KAAK,MAAM,IAAI,SAAS;AACzC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AiB,MAAM,WAAW,MAAM,MAAM,WAAW,UAAU,WAAW,KAAK;AAAA,QAC1F;AACA,cAAM,KAAK;AAAA,MACb;AAAA,IACF,GAAG;AACH,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
|
-
"names": ["randomUUID", "path", "DaemonConnection", "findDaemon", "path", "randomUUID", "findDaemon", "DaemonConnection"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/state/state-directory.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/state/state-directory\";\nexport {\n legacyStateDir,\n migrateLegacyStateDirectory,\n stateDir,\n stateDirectoryMigrationNotice,\n withStateDirectoryAccess,\n} from \"@narumitw/sync-daemon/engine/state/state-directory\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/snapshot/session-paths.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/snapshot/session-paths\";\nexport {\n agentDir,\n configuredSessionDir,\n effectiveSessionRoot,\n expandSessionDir,\n requireStableMergeSessionRoot,\n sessionDirForApply,\n sessionDirFromContext,\n snapshotOptionsForContext,\n} from \"@narumitw/sync-daemon/engine/snapshot/session-paths\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/sync/sync-errors.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/sync/sync-errors\";\nexport {\n errorMessage,\n isSyncDecisionRequiredError,\n SetupPullRequiresUiError,\n SyncDecisionRequiredError,\n} from \"@narumitw/sync-daemon/engine/sync/sync-errors\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/sync/sync-policy.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/sync/sync-policy\";\nexport {\n BUILT_IN_SYNC_ROOTS,\n canonicalSnapshotPathForConfig,\n compareSyncInclude,\n configuredSnapshotPathMatcher,\n customIncludePathsByLower,\n DEFAULT_SYNC_INCLUDE,\n discoverLegacySnapshotInclude,\n extraFilePathsByLower,\n formatRemoteSelectionMismatch,\n includeFromSelectionConfig,\n inspectRemoteSelection,\n isBuiltInTopLevelFile,\n isConfiguredSnapshotPath,\n isPreservableUnmanagedSnapshotPath,\n isSafeCustomIncludePath,\n isSafeExtraFileName,\n normalizeExtraFiles,\n normalizeSyncFiles,\n normalizeSyncInclude,\n portableSnapshotSelection,\n RemoteSelectionMismatchError,\n remoteSelectionMismatch,\n sameSnapshotSelection,\n sameSyncInclude,\n selectedSyncFileSet,\n selectionForSnapshot,\n snapshotSelectionExclude,\n snapshotSelectionInclude,\n syncIncludeSelection,\n syncSessionsSelected,\n validateSnapshotSelection,\n} from \"@narumitw/sync-daemon/engine/sync/sync-policy\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/settings/settings-management.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/settings/settings-management\";\nexport {\n addStorageConnection,\n addSyncSetup,\n removeStorageConnection,\n removeSyncSetup,\n SyncSetupReviewChangedError,\n saveNewV3Settings,\n updateStorageConnection,\n updateSyncSetup,\n} from \"@narumitw/sync-daemon/engine/settings/settings-management\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/settings/settings-validation.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/settings/settings-validation\";\nexport {\n DEFAULT_ON_SWITCH,\n effectiveSyncSetupRemoteIdentity,\n isCloudflareR2Endpoint,\n normalizeOnSwitch,\n normalizeS3Bucket,\n normalizeS3Endpoint,\n normalizeStoragePath,\n optionalString,\n ownObject,\n ownRecord,\n requiredString,\n validateConfigName,\n validateSettingsDocument,\n validateUniqueRemoteSyncSetups,\n} from \"@narumitw/sync-daemon/engine/settings/settings-validation\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/state/sync-state-store.ts", "../../src/ui/sync-attention.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/state/sync-state-store\";\nexport {\n ensureStateDir,\n lockPath,\n readState,\n readStateForConfig,\n statePathForConfig,\n syncStateFingerprint,\n writeState,\n writeStateForConfig,\n} from \"@narumitw/sync-daemon/engine/state/sync-state-store\";\n", "import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { EditorStatusWidgetState } from \"@narumitw/pi-tui-kit/editor-status-widget\";\nimport { syncCheckConfigFingerprint, syncConfigReviewFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { sameSyncExclude } from \"../sync/exclude-policy.js\";\nimport type { StartupObservation } from \"../sync/sync-inspection.js\";\nimport { compareSyncInclude, type RemoteSelectionDecision, sameSyncInclude } from \"../sync/sync-policy.js\";\nimport { setSyncStatus } from \"./sync-status.js\";\nimport { safeTerminalText } from \"./terminal-text.js\";\n\nconst WIDGET_KEY = \"sync:attention\";\n\nexport type SyncAttentionOrigin = \"sync\" | \"pull\" | \"push\";\n\nexport interface SyncAttentionState {\n decision: RemoteSelectionDecision;\n origin: SyncAttentionOrigin;\n offered: boolean;\n}\n\nexport function syncAttentionMatchesConfig(attention: SyncAttentionState, config: AnySyncConfig) {\n return (\n attention.decision.setupName === config.setupName &&\n attention.decision.configIdentity === syncConfigReviewFingerprint(config) &&\n sameSyncInclude(attention.decision.localInclude, config.include) &&\n sameSyncExclude(attention.decision.localExclude, config.exclude)\n );\n}\n\nexport interface SyncAttentionController {\n observe(observation: StartupObservation): void;\n observation(): StartupObservation | undefined;\n clearObservation(): void;\n notifyObservation(ctx: ExtensionContext): void;\n set(decision: RemoteSelectionDecision, origin: SyncAttentionOrigin): void;\n current(): SyncAttentionState | undefined;\n markOffered(): boolean;\n clear(ctx: ExtensionContext): void;\n reset(ctx: ExtensionContext): void;\n expand(): void;\n publish(ctx: ExtensionContext, signal?: AbortSignal): Promise<void>;\n}\n\nexport function createSyncAttentionController(): SyncAttentionController {\n let state: SyncAttentionState | undefined;\n let observation: StartupObservation | undefined;\n let generation = 0;\n let widgetState: EditorStatusWidgetState = { collapsed: false };\n\n return {\n observe(value) {\n generation++;\n observation = value;\n },\n observation() {\n return observation;\n },\n clearObservation() {\n generation++;\n observation = undefined;\n },\n notifyObservation(ctx) {\n if (ctx.hasUI && observation && observationNeedsAttention(observation)) {\n ctx.ui.notify(observationLines(observation).join(\"\\n\"), \"warning\");\n }\n },\n set(decision, origin) {\n generation++;\n state = { decision, origin, offered: false };\n },\n current() {\n return state;\n },\n markOffered() {\n if (!state || state.offered) return false;\n state = { ...state, offered: true };\n return true;\n },\n clear(ctx) {\n generation++;\n state = undefined;\n clearAttentionPresentation(ctx);\n },\n reset(ctx) {\n generation++;\n state = undefined;\n observation = undefined;\n widgetState = { collapsed: false };\n clearAttentionPresentation(ctx);\n },\n expand() {\n widgetState.collapsed = false;\n },\n async publish(ctx, signal) {\n const currentGeneration = ++generation;\n if (signal?.aborted || !ctx.hasUI) return;\n const classification = observation ? classifyObservation(observation) : \"none\";\n if (!state && (classification === \"none\" || classification === \"guidance\")) {\n clearAttentionPresentation(ctx);\n return;\n }\n if (!state && classification === \"status\") {\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n setSyncStatus(ctx, observation?.inspection.remoteChanged ? \"sync \u21E3\" : \"sync \u21E1\", {\n activity: observation?.inspection.remoteChanged ? \"remote-change\" : \"local-change\",\n });\n return;\n }\n const presentation = state\n ? attentionPresentation(state.decision)\n : observationPresentation(observation as StartupObservation);\n if (ctx.mode !== \"tui\") {\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n setSyncStatus(ctx, presentation.status, { activity: \"review\" });\n return;\n }\n // Keep Kit outside the eager startup graph; module loading owns no cancellable resources.\n const { EditorStatusWidget } = await import(\"./attention-widget.js\").catch((error) => {\n if (generation === currentGeneration && !signal?.aborted) clearAttentionPresentation(ctx);\n throw error;\n });\n if (generation !== currentGeneration || signal?.aborted) return;\n setSyncStatus(ctx, presentation.status, { activity: \"review\" });\n const presentationState = widgetState;\n ctx.ui.setWidget(\n WIDGET_KEY,\n (_tui, theme) =>\n new EditorStatusWidget({\n theme,\n name: \"Sync\",\n summary: \"Needs review\",\n state: presentationState,\n renderBody: (width) =>\n presentation.lines.map((line, index) =>\n width === 0 ? \"\" : truncateToWidth(theme.fg(index === 0 ? \"warning\" : \"muted\", line), width, \"\u2026\"),\n ),\n }),\n );\n },\n };\n}\n\nfunction attentionPresentation(decision: RemoteSelectionDecision) {\n const setupName = safeTerminalText(decision.setupName);\n const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);\n return {\n status: \"sync \u21D5\",\n lines: [\n `Setup: ${setupName}`,\n selectionDifference({\n ...comparison,\n excludeChanged: !sameSyncExclude(decision.localExclude, decision.remoteExclude),\n }),\n \"No transfer performed \u00B7 Run /sync to review\",\n ],\n };\n}\n\nfunction selectionDifference(comparison: {\n remoteOnly: readonly string[];\n localOnly: readonly string[];\n excludeChanged?: boolean;\n}) {\n if (comparison.excludeChanged) return \"Selection: excluded paths differ; review needed\";\n return comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0\n ? \"Selection: only list order differs\"\n : `Selection: ${comparison.remoteOnly.length} remote-only \u00B7 ${comparison.localOnly.length} device-only`;\n}\n\nfunction observationPresentation(observation: StartupObservation) {\n const selection = observation.inspection.selectionState;\n return {\n status: \"sync \u21D5\",\n lines: [\n `Setup: ${safeTerminalText(observation.setupName)}`,\n selection?.kind === \"different\" ? selectionDifference(selection) : observationSummary(observation),\n \"No transfer performed \u00B7 Run /sync to review\",\n ],\n };\n}\n\nexport function observationMatchesConfig(observation: StartupObservation, config: AnySyncConfig) {\n return observation.configIdentity === syncCheckConfigFingerprint(config);\n}\n\nexport function observationSummary(observation: StartupObservation) {\n const result = observation.inspection;\n if (result.emptyInclude) return \"No included content selected\";\n if (result.selectionState?.kind === \"different\") return \"Synced-content list differs; review needed\";\n if (result.firstSync)\n return result.head ? \"No sync baseline; review remote and local content\" : \"Remote empty; no sync baseline\";\n if (!result.head) return \"Remote snapshot missing; review needed\";\n if (observation.automaticTransfer && result.selectionState?.kind === \"legacy\")\n return \"Legacy remote has no authoritative content list; review /sync and choose an explicit direction to adopt policy\";\n if (result.localChanged && result.remoteChanged) return \"Local and remote changed since last sync; review needed\";\n if (result.remoteChanged) return \"Remote changed since last sync\";\n if (result.localChanged) return \"Local content changed since last sync\";\n if (result.selectionState?.kind === \"legacy\") return \"Legacy remote has no authoritative content list\";\n return \"No changes detected since last sync\";\n}\n\nexport type ObservationClassification = \"none\" | \"guidance\" | \"status\" | \"review\";\n\n/** Presentation only: never discard an observation or authorize a transfer here. */\nexport function classifyObservation(observation: StartupObservation): ObservationClassification {\n const result = observation.inspection;\n // Sync now exits before reading remote content when nothing is selected.\n if (result.emptyInclude) return \"guidance\";\n // Ordering is part of the existing transfer policy, not merely display order.\n if (result.selectionState?.kind === \"different\") return \"review\";\n if (result.firstSync) return result.head ? \"review\" : \"guidance\";\n if (!result.head || (result.localChanged && result.remoteChanged)) return \"review\";\n if (observation.automaticTransfer && result.selectionState?.kind === \"legacy\") return \"review\";\n if (result.localChanged || result.remoteChanged) return \"status\";\n // Legacy metadata alone requires no scope confirmation in transfer operations.\n return \"none\";\n}\n\nexport function observationNeedsAttention(observation: StartupObservation) {\n return classifyObservation(observation) === \"review\";\n}\n\nfunction observationLines(observation: StartupObservation) {\n return [\n `Pi Sync check \u00B7 ${safeTerminalText(observation.setupName)}`,\n observationSummary(observation),\n \"No startup transfer \u00B7 Run /sync to review\",\n ];\n}\n\nfunction clearAttentionPresentation(ctx: ExtensionContext) {\n if (!ctx.hasUI) return;\n setSyncStatus(ctx, undefined);\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACTP,SAAS,uBAAuB;AAUhC,IAAM,aAAa;AAUZ,SAAS,2BAA2B,WAA+B,QAAuB;AAC/F,SACE,UAAU,SAAS,cAAc,OAAO,aACxC,UAAU,SAAS,mBAAmB,4BAA4B,MAAM,KACxE,gBAAgB,UAAU,SAAS,cAAc,OAAO,OAAO,KAC/D,gBAAgB,UAAU,SAAS,cAAc,OAAO,OAAO;AAEnE;AAgBO,SAAS,gCAAyD;AACvE,MAAI;AACJ,MAAI;AACJ,MAAI,aAAa;AACjB,MAAI,cAAuC,EAAE,WAAW,MAAM;AAE9D,SAAO;AAAA,IACL,QAAQ,OAAO;AACb;AACA,oBAAc;AAAA,IAChB;AAAA,IACA,cAAc;AACZ,aAAO;AAAA,IACT;AAAA,IACA,mBAAmB;AACjB;AACA,oBAAc;AAAA,IAChB;AAAA,IACA,kBAAkB,KAAK;AACrB,UAAI,IAAI,SAAS,eAAe,0BAA0B,WAAW,GAAG;AACtE,YAAI,GAAG,OAAO,iBAAiB,WAAW,EAAE,KAAK,IAAI,GAAG,SAAS;AAAA,MACnE;AAAA,IACF;AAAA,IACA,IAAI,UAAU,QAAQ;AACpB;AACA,cAAQ,EAAE,UAAU,QAAQ,SAAS,MAAM;AAAA,IAC7C;AAAA,IACA,UAAU;AACR,aAAO;AAAA,IACT;AAAA,IACA,cAAc;AACZ,UAAI,CAAC,SAAS,MAAM,QAAS,QAAO;AACpC,cAAQ,EAAE,GAAG,OAAO,SAAS,KAAK;AAClC,aAA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sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/sync/exclude-policy\";\nexport {\n compileSyncExclude,\n normalizeSyncExclude,\n sameSyncExclude,\n} from \"@narumitw/sync-daemon/engine/sync/exclude-policy\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/sync/signals.ts"],
|
|
4
|
-
"sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/sync/signals\";\nexport { combineSignals, throwIfAborted } from \"@narumitw/sync-daemon/engine/sync/signals\";\n"],
|
|
5
|
-
"mappings": ";;;;AACA,SAAS,gBAAgB,sBAAsB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|