pi-archimedes 1.8.1 → 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.
Files changed (2) hide show
  1. package/package.json +9 -9
  2. package/src/index.ts +19 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-archimedes",
3
- "version": "1.8.1",
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.1",
15
- "@pi-archimedes/footer": "1.8.1",
16
- "@pi-archimedes/ask": "1.8.1",
17
- "@pi-archimedes/image-paste": "1.8.1",
18
- "@pi-archimedes/subagent": "1.8.1",
19
- "@pi-archimedes/notify": "1.8.1",
20
- "@pi-archimedes/todo": "1.8.1",
21
- "@pi-archimedes/diff": "1.8.1"
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,15 +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 refs for shutdown (survive hot-reloads)
17
+ // Module-level ref for shutdown (survives session replacements)
18
18
  let imagePasteShutdown: (() => void) | undefined;
19
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.
20
22
  let currentCtx: ExtensionContext | undefined;
21
- // Guard: tracks which lazy-loaded packages have been registered.
22
- // session_start fires for /new, /resume, /fork, /reload — each tears down the
23
- // old runtime and rebuilds, but pi itself stays loaded, so this module is
24
- // evaluated once and these guards prevent handler accumulation on reload.
25
- const registeredLazy = new Set<string>();
26
23
 
27
24
  export default function (pi: ExtensionAPI): void {
28
25
  archResetTimings();
@@ -71,27 +68,28 @@ export default function (pi: ExtensionAPI): void {
71
68
  ]);
72
69
  archTime("3 packages loaded in parallel");
73
70
 
74
- if (diffMod && !registeredLazy.has("diff")) {
75
- // currentCtx is set above before lazy loads, so it's always defined when this runs
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) {
76
79
  diffMod.registerDiffTools(pi, () => currentCtx!.ui.theme, () => loadDiffConfig());
77
- registeredLazy.add("diff");
78
80
  }
79
81
  if (ipMod) {
80
- // initImagePasteSession must run every session_start (it captures the new ctx)
81
- // but the actual handler registration via pi.on("input", ...) must only happen once.
82
- if (!registeredLazy.has("image-paste")) {
83
- ipMod.registerImagePaste(pi);
84
- imagePasteShutdown = ipMod.shutdownImagePaste;
85
- registeredLazy.add("image-paste");
86
- }
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)
87
88
  ipMod.initImagePasteSession(ctx);
88
89
  }
89
90
  if (saMod) {
90
- if (!registeredLazy.has("subagent")) {
91
- saMod.registerSubagent(pi);
92
- saMod.registerAgentsCommand(pi);
93
- registeredLazy.add("subagent");
94
- }
91
+ saMod.registerSubagent(pi);
92
+ saMod.registerAgentsCommand(pi);
95
93
  }
96
94
  });
97
95