pi-archimedes 1.8.0 → 1.8.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/package.json +9 -9
- package/src/index.ts +25 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-archimedes",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "./src/index.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@pi-archimedes/core": "1.8.
|
|
15
|
-
"@pi-archimedes/
|
|
16
|
-
"@pi-archimedes/ask": "1.8.
|
|
17
|
-
"@pi-archimedes/
|
|
18
|
-
"@pi-archimedes/
|
|
19
|
-
"@pi-archimedes/
|
|
20
|
-
"@pi-archimedes/
|
|
21
|
-
"@pi-archimedes/
|
|
14
|
+
"@pi-archimedes/core": "1.8.2",
|
|
15
|
+
"@pi-archimedes/footer": "1.8.2",
|
|
16
|
+
"@pi-archimedes/ask": "1.8.2",
|
|
17
|
+
"@pi-archimedes/diff": "1.8.2",
|
|
18
|
+
"@pi-archimedes/image-paste": "1.8.2",
|
|
19
|
+
"@pi-archimedes/subagent": "1.8.2",
|
|
20
|
+
"@pi-archimedes/todo": "1.8.2",
|
|
21
|
+
"@pi-archimedes/notify": "1.8.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@earendil-works/pi-coding-agent": ">=0.1.0",
|
package/src/index.ts
CHANGED
|
@@ -14,13 +14,12 @@ import { registerNotify } from "@pi-archimedes/notify";
|
|
|
14
14
|
import { loadDiffConfig } from "./config.js";
|
|
15
15
|
import { openSettings } from "./settings.js"
|
|
16
16
|
|
|
17
|
-
// Module-level
|
|
17
|
+
// Module-level ref for shutdown (survives session replacements)
|
|
18
18
|
let imagePasteShutdown: (() => void) | undefined;
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
const registeredLazy = new Set<string>();
|
|
19
|
+
// Module-level ref for current session context (survives /reload, /new, /fork)
|
|
20
|
+
// Used by diff's theme getter callback — updated every session_start so the
|
|
21
|
+
// getter always returns the latest ctx's theme even after session replacement.
|
|
22
|
+
let currentCtx: ExtensionContext | undefined;
|
|
24
23
|
|
|
25
24
|
export default function (pi: ExtensionAPI): void {
|
|
26
25
|
archResetTimings();
|
|
@@ -58,6 +57,9 @@ export default function (pi: ExtensionAPI): void {
|
|
|
58
57
|
pi.on("session_start", async (_event, ctx: ExtensionContext) => {
|
|
59
58
|
archTime(`session_start (factory was ${Date.now() - _moduleEvalAt}ms ago)`);
|
|
60
59
|
|
|
60
|
+
// Update module-level context ref so lazy-loaded callbacks always see current session
|
|
61
|
+
currentCtx = ctx;
|
|
62
|
+
|
|
61
63
|
// ── Parallel lazy-load all three packages (saves ~100ms vs sequential) ──
|
|
62
64
|
const [diffMod, ipMod, saMod] = await Promise.all([
|
|
63
65
|
import("@pi-archimedes/diff").catch((e) => { console.error("[archimedes] diff load failed:", e); return null; }),
|
|
@@ -66,26 +68,28 @@ export default function (pi: ExtensionAPI): void {
|
|
|
66
68
|
]);
|
|
67
69
|
archTime("3 packages loaded in parallel");
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
// Each session_start fires on a fresh Extension (pi creates a new
|
|
72
|
+
// ExtensionRunner per session). Registration is safe to — and must —
|
|
73
|
+
// run every time. The registeredLazy guard was removed because it
|
|
74
|
+
// prevented subagent/diff/image-paste from being registered after
|
|
75
|
+
// /new, /fork, /resume: jiti caches the compiled module, so the guard
|
|
76
|
+
// persisted across sessions while each new session creates a fresh
|
|
77
|
+
// Extension with empty tools/commands maps.
|
|
78
|
+
if (diffMod) {
|
|
79
|
+
diffMod.registerDiffTools(pi, () => currentCtx!.ui.theme, () => loadDiffConfig());
|
|
72
80
|
}
|
|
73
81
|
if (ipMod) {
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
82
|
+
// registerImagePaste calls pi.on("input", ...) and pi.registerShortcut()
|
|
83
|
+
// on the current Extension. Since each session replacement creates a
|
|
84
|
+
// new Extension with its own handler list, there is no accumulation.
|
|
85
|
+
ipMod.registerImagePaste(pi);
|
|
86
|
+
imagePasteShutdown = ipMod.shutdownImagePaste;
|
|
87
|
+
// initImagePasteSession must run every session_start (captures fresh ctx)
|
|
81
88
|
ipMod.initImagePasteSession(ctx);
|
|
82
89
|
}
|
|
83
90
|
if (saMod) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
saMod.registerAgentsCommand(pi);
|
|
87
|
-
registeredLazy.add("subagent");
|
|
88
|
-
}
|
|
91
|
+
saMod.registerSubagent(pi);
|
|
92
|
+
saMod.registerAgentsCommand(pi);
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
95
|
|