@narumitw/pi-sync 0.70.5 → 0.70.7
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 +12 -0
- package/README.md +2 -0
- package/dist/chunks/{chunk-3XN4FR72.ts → chunk-4A34OGXY.ts} +9 -9
- package/dist/chunks/{chunk-7NQ7SFZK.ts → chunk-5BE6LBDC.ts} +15 -15
- package/dist/chunks/chunk-A43CJYG4.ts +26 -0
- package/dist/chunks/chunk-A43CJYG4.ts.map +7 -0
- package/dist/chunks/{chunk-JPTI4HFC.ts → chunk-AXN3B5KC.ts} +22 -22
- package/dist/chunks/{chunk-SPXEDJ2G.ts → chunk-HCXPNKPU.ts} +61 -59
- package/dist/chunks/chunk-HCXPNKPU.ts.map +7 -0
- package/dist/chunks/{chunk-N24HEZSA.ts → chunk-VERMBZGL.ts} +7 -7
- package/dist/chunks/{chunk-LSIUAXE4.ts → chunk-WE3KJ7JS.ts} +8 -8
- package/dist/chunks/{chunk-5T4ZOHYF.ts → chunk-WRS3SUNZ.ts} +4 -18
- package/dist/chunks/chunk-WRS3SUNZ.ts.map +7 -0
- package/dist/chunks/client-debug-F4WFP2YJ.ts +40 -0
- package/dist/chunks/client-debug-F4WFP2YJ.ts.map +7 -0
- package/dist/chunks/{command-handler-PT2KVTLD.ts → command-handler-DWWFIXSC.ts} +34 -32
- package/dist/chunks/{command-handler-PT2KVTLD.ts.map → command-handler-DWWFIXSC.ts.map} +1 -1
- package/dist/chunks/{conflict-review-QI77P7KL.ts → conflict-review-HSERM245.ts} +3 -3
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts +67 -0
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts.map +7 -0
- package/dist/chunks/{diff-review-SOLP33TQ.ts → diff-review-6IUIOYST.ts} +3 -3
- package/dist/chunks/{diff-review-ILRZDQ4S.ts → diff-review-GB4NO53B.ts} +4 -4
- package/dist/chunks/{file-selection-2H3J2HTX.ts → file-selection-DGC5UJVI.ts} +9 -9
- package/dist/chunks/{manager-result-dispatcher-75FS46JP.ts → manager-result-dispatcher-6MOJPLIS.ts} +7 -7
- package/dist/chunks/{manager-ui-HW3ZAEVK.ts → manager-ui-3CQU37XY.ts} +52 -50
- package/dist/chunks/{manager-ui-HW3ZAEVK.ts.map → manager-ui-3CQU37XY.ts.map} +1 -1
- package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts → remote-selection-ui-2V53UBHM.ts} +6 -6
- package/dist/chunks/{setup-switch-LJPEZONY.ts → setup-switch-WSKVGW7L.ts} +4 -4
- package/dist/chunks/{setup-wizard-FBX7RTZ6.ts → setup-wizard-FRIR2EOR.ts} +9 -9
- package/dist/chunks/{sync-inspection-TZ4EMSBN.ts → sync-inspection-CQDNC542.ts} +6 -6
- package/dist/chunks/{sync-operations-QIQ3G66S.ts → sync-operations-IF7LMWK6.ts} +4 -4
- package/dist/chunks/sync-state-store-TZE7XDV5.ts +23 -0
- package/dist/chunks/sync-state-store-TZE7XDV5.ts.map +7 -0
- package/dist/daemon/dist/build-id.json +1 -1
- package/dist/daemon/dist/cli.js +3 -2
- package/dist/daemon/dist/client.js +55 -14
- package/dist/daemon/dist/daemon-startup.js +2 -14
- package/dist/daemon/dist/daemon-upgrade-error.js +14 -0
- package/dist/daemon/dist/index.js +20 -3
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +278 -248
- package/dist/index.ts.map +2 -2
- package/docs/daemon-migration.md +2 -0
- package/package.json +2 -2
- package/src/daemon/client-debug.ts +2 -0
- package/src/daemon/pi-client.ts +60 -22
- package/src/sync/automatic-sync.ts +5 -3
- package/src/sync/debug-tool-execution.ts +66 -0
- package/src/sync/debug-tool.ts +8 -56
- package/src/sync/startup-check.ts +3 -1
- package/src/sync-extension.ts +252 -166
- package/dist/chunks/chunk-5T4ZOHYF.ts.map +0 -7
- package/dist/chunks/chunk-SPXEDJ2G.ts.map +0 -7
- /package/dist/chunks/{chunk-3XN4FR72.ts.map → chunk-4A34OGXY.ts.map} +0 -0
- /package/dist/chunks/{chunk-7NQ7SFZK.ts.map → chunk-5BE6LBDC.ts.map} +0 -0
- /package/dist/chunks/{chunk-JPTI4HFC.ts.map → chunk-AXN3B5KC.ts.map} +0 -0
- /package/dist/chunks/{chunk-N24HEZSA.ts.map → chunk-VERMBZGL.ts.map} +0 -0
- /package/dist/chunks/{chunk-LSIUAXE4.ts.map → chunk-WE3KJ7JS.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-QI77P7KL.ts.map → conflict-review-HSERM245.ts.map} +0 -0
- /package/dist/chunks/{diff-review-SOLP33TQ.ts.map → diff-review-6IUIOYST.ts.map} +0 -0
- /package/dist/chunks/{diff-review-ILRZDQ4S.ts.map → diff-review-GB4NO53B.ts.map} +0 -0
- /package/dist/chunks/{file-selection-2H3J2HTX.ts.map → file-selection-DGC5UJVI.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-75FS46JP.ts.map → manager-result-dispatcher-6MOJPLIS.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts.map → remote-selection-ui-2V53UBHM.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-LJPEZONY.ts.map → setup-switch-WSKVGW7L.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-FBX7RTZ6.ts.map → setup-wizard-FRIR2EOR.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-TZ4EMSBN.ts.map → sync-inspection-CQDNC542.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-QIQ3G66S.ts.map → sync-operations-IF7LMWK6.ts.map} +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { debugCheckFailure, summarizeDebugInspection } from "@narumitw/pi-sync-daemon/engine/debug-check";
|
|
3
|
+
import { readLatestDebugCheck } from "@narumitw/pi-sync-daemon/engine/debug-log";
|
|
4
|
+
import type { PiDaemonClient } from "../daemon/pi-client.js";
|
|
5
|
+
import { configFromSettings, syncCheckConfigFingerprint, syncConfigReviewFingerprint } from "../settings/config.js";
|
|
6
|
+
|
|
7
|
+
const RECHECK_TIMEOUT_MS = 30_000;
|
|
8
|
+
|
|
9
|
+
function toolResult(value: unknown) {
|
|
10
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(value) }], details: {} };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function executeDebugTool(
|
|
14
|
+
action: unknown,
|
|
15
|
+
ctx: ExtensionContext,
|
|
16
|
+
client: PiDaemonClient,
|
|
17
|
+
signal: AbortSignal,
|
|
18
|
+
validate: () => void,
|
|
19
|
+
) {
|
|
20
|
+
async function readSetup() {
|
|
21
|
+
validate();
|
|
22
|
+
try {
|
|
23
|
+
const { settings } = await client.readStartupSettings(signal);
|
|
24
|
+
validate();
|
|
25
|
+
if (settings) return configFromSettings(settings);
|
|
26
|
+
} catch {
|
|
27
|
+
validate();
|
|
28
|
+
}
|
|
29
|
+
throw new Error("The current Pi Sync setup is not available. Review /sync → Settings.");
|
|
30
|
+
}
|
|
31
|
+
const setup = await readSetup();
|
|
32
|
+
validate();
|
|
33
|
+
if (action === "latest") {
|
|
34
|
+
const last = readLatestDebugCheck(client.root, syncConfigReviewFingerprint(setup));
|
|
35
|
+
if (last.kind === "unavailable") throw new Error("The private Pi Sync debug log is unavailable.");
|
|
36
|
+
if (last.kind === "no-record") return toolResult({ kind: "no-record" });
|
|
37
|
+
return toolResult({ kind: "historical", ...last.check });
|
|
38
|
+
}
|
|
39
|
+
if (action !== "recheck") throw new Error("Choose latest or recheck.");
|
|
40
|
+
if (client.ownershipCleanupRequired) throw new Error("Pi Sync needs recovery. Open /sync daemon status.");
|
|
41
|
+
const fingerprint = syncCheckConfigFingerprint(setup);
|
|
42
|
+
const deadline = AbortSignal.timeout(RECHECK_TIMEOUT_MS);
|
|
43
|
+
const recheckSignal = AbortSignal.any([signal, deadline]);
|
|
44
|
+
let result: unknown;
|
|
45
|
+
try {
|
|
46
|
+
result = await client.run(
|
|
47
|
+
"inspect",
|
|
48
|
+
{ setup: setup.setupName, fingerprint, origin: "recheck" },
|
|
49
|
+
recheckSignal,
|
|
50
|
+
ctx,
|
|
51
|
+
);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
validate();
|
|
54
|
+
const { reason } = debugCheckFailure(deadline.aborted ? deadline.reason : error);
|
|
55
|
+
throw new Error(`Pi Sync recheck failed: ${reason}.`);
|
|
56
|
+
}
|
|
57
|
+
validate();
|
|
58
|
+
if (deadline.aborted) throw new Error("Pi Sync recheck failed: timeout.");
|
|
59
|
+
const latest = await readSetup();
|
|
60
|
+
validate();
|
|
61
|
+
if (fingerprint !== syncCheckConfigFingerprint(latest))
|
|
62
|
+
throw new Error("Pi Sync setup changed during recheck. Ask to recheck the new setup.");
|
|
63
|
+
const summary = summarizeDebugInspection(result);
|
|
64
|
+
if (!summary) throw new Error("Pi Sync did not return a valid check result.");
|
|
65
|
+
return toolResult({ kind: "fresh", time: new Date().toISOString(), origin: "recheck", summary });
|
|
66
|
+
}
|
package/src/sync/debug-tool.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { debugCheckFailure, summarizeDebugInspection } from "@narumitw/pi-sync-daemon/engine/debug-check";
|
|
4
|
-
import { readLatestDebugCheck } from "@narumitw/pi-sync-daemon/engine/debug-log";
|
|
5
3
|
import { Type } from "typebox";
|
|
6
|
-
import type
|
|
7
|
-
import { configFromSettings, syncCheckConfigFingerprint, syncConfigReviewFingerprint } from "../settings/config.js";
|
|
4
|
+
import { PI_SYNC_BINDING_UNAVAILABLE, type PiDaemonClient } from "../daemon/pi-client.js";
|
|
8
5
|
|
|
9
6
|
const TOOL_NAME = "pi_sync_debug";
|
|
10
|
-
const RECHECK_TIMEOUT_MS = 30_000;
|
|
11
7
|
type DebugOwner = { client: PiDaemonClient; signal: AbortSignal };
|
|
12
8
|
|
|
13
|
-
function toolResult(value: unknown) {
|
|
14
|
-
return { content: [{ type: "text" as const, text: JSON.stringify(value) }], details: {} };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
export function registerPiSyncDebug(pi: ExtensionAPI, getOwner: (ctx: ExtensionContext) => DebugOwner | undefined) {
|
|
18
10
|
pi.registerTool({
|
|
19
11
|
name: TOOL_NAME,
|
|
@@ -25,9 +17,8 @@ export function registerPiSyncDebug(pi: ExtensionAPI, getOwner: (ctx: ExtensionC
|
|
|
25
17
|
exposure: "direct",
|
|
26
18
|
executionMode: "sequential",
|
|
27
19
|
async execute(_id, { action }, toolSignal, _update, ctx) {
|
|
28
|
-
const owner = getOwner(ctx);
|
|
29
|
-
if (!owner
|
|
30
|
-
throw new Error("Pi Sync debug requires an interactive session started with Debug mode on.");
|
|
20
|
+
const owner = ctx.hasUI && (ctx.mode === "tui" || ctx.mode === "rpc") ? getOwner(ctx) : undefined;
|
|
21
|
+
if (!owner) throw new Error("Pi Sync debug requires an interactive session started with Debug mode on.");
|
|
31
22
|
const { client } = owner;
|
|
32
23
|
const signal = toolSignal ? AbortSignal.any([owner.signal, toolSignal]) : owner.signal;
|
|
33
24
|
const validate = () => {
|
|
@@ -36,55 +27,16 @@ export function registerPiSyncDebug(pi: ExtensionAPI, getOwner: (ctx: ExtensionC
|
|
|
36
27
|
try {
|
|
37
28
|
client.validateDebugTool();
|
|
38
29
|
} catch {
|
|
39
|
-
throw new Error(
|
|
30
|
+
throw new Error(PI_SYNC_BINDING_UNAVAILABLE);
|
|
40
31
|
}
|
|
41
32
|
};
|
|
42
|
-
async function readSetup() {
|
|
43
|
-
validate();
|
|
44
|
-
try {
|
|
45
|
-
const { settings } = await client.readStartupSettings(signal);
|
|
46
|
-
validate();
|
|
47
|
-
if (settings) return configFromSettings(settings);
|
|
48
|
-
} catch {
|
|
49
|
-
validate();
|
|
50
|
-
}
|
|
51
|
-
throw new Error("The current Pi Sync setup is not available. Review /sync → Settings.");
|
|
52
|
-
}
|
|
53
|
-
const setup = await readSetup();
|
|
54
33
|
validate();
|
|
55
|
-
|
|
56
|
-
const last = readLatestDebugCheck(client.root, syncConfigReviewFingerprint(setup));
|
|
57
|
-
if (last.kind === "unavailable") throw new Error("The private Pi Sync debug log is unavailable.");
|
|
58
|
-
if (last.kind === "no-record") return toolResult({ kind: "no-record" });
|
|
59
|
-
return toolResult({ kind: "historical", ...last.check });
|
|
60
|
-
}
|
|
61
|
-
if (action !== "recheck") throw new Error("Choose latest or recheck.");
|
|
62
|
-
if (client.ownershipCleanupRequired) throw new Error("Pi Sync needs recovery. Open /sync daemon status.");
|
|
63
|
-
const fingerprint = syncCheckConfigFingerprint(setup);
|
|
64
|
-
const deadline = AbortSignal.timeout(RECHECK_TIMEOUT_MS);
|
|
65
|
-
const recheckSignal = AbortSignal.any([signal, deadline]);
|
|
66
|
-
let result: unknown;
|
|
67
|
-
try {
|
|
68
|
-
result = await client.run(
|
|
69
|
-
"inspect",
|
|
70
|
-
{ setup: setup.setupName, fingerprint, origin: "recheck" },
|
|
71
|
-
recheckSignal,
|
|
72
|
-
ctx,
|
|
73
|
-
);
|
|
74
|
-
} catch (error) {
|
|
34
|
+
const { executeDebugTool } = await import("./debug-tool-execution.js").catch(() => {
|
|
75
35
|
validate();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
validate();
|
|
80
|
-
if (deadline.aborted) throw new Error("Pi Sync recheck failed: timeout.");
|
|
81
|
-
const latest = await readSetup();
|
|
36
|
+
throw new Error("Pi Sync debug could not load.");
|
|
37
|
+
});
|
|
82
38
|
validate();
|
|
83
|
-
|
|
84
|
-
throw new Error("Pi Sync setup changed during recheck. Ask to recheck the new setup.");
|
|
85
|
-
const summary = summarizeDebugInspection(result);
|
|
86
|
-
if (!summary) throw new Error("Pi Sync did not return a valid check result.");
|
|
87
|
-
return toolResult({ kind: "fresh", time: new Date().toISOString(), origin: "recheck", summary });
|
|
39
|
+
return executeDebugTool(action, ctx, client, signal, validate);
|
|
88
40
|
},
|
|
89
41
|
});
|
|
90
42
|
|
|
@@ -4,7 +4,6 @@ import { isMissingConfigError } from "../settings/config-errors.js";
|
|
|
4
4
|
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
5
5
|
import { snapshotOptionsForContext } from "../snapshot/session-paths.js";
|
|
6
6
|
import { withStateDirectoryAccess } from "../state/state-directory.js";
|
|
7
|
-
import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
|
|
8
7
|
import type { SyncAttentionController } from "../ui/sync-attention.js";
|
|
9
8
|
import { setSyncStatus } from "../ui/sync-status.js";
|
|
10
9
|
import { safeTerminalText } from "../ui/terminal-text.js";
|
|
@@ -101,6 +100,9 @@ export function createStartupCheck(
|
|
|
101
100
|
inspectSync(captured, snapshotOptionsForContext(ctx, captured), signal, undefined, timings),
|
|
102
101
|
);
|
|
103
102
|
throwIfAborted(signal);
|
|
103
|
+
const { readStateForConfig, syncStateFingerprint } = await import("../state/sync-state-store.js");
|
|
104
|
+
throwIfAborted(signal);
|
|
105
|
+
if (!isCurrent()) return;
|
|
104
106
|
const latest = await loadConfigForCheck(undefined, signal);
|
|
105
107
|
throwIfAborted(signal);
|
|
106
108
|
if (syncCheckConfigFingerprint(latest) !== identity) return;
|