@pi-archimedes/diff 2.3.0 → 2.4.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-archimedes/diff",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -0,0 +1,24 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import defaultExport from "./index.js";
3
+
4
+ describe("diff default export (standalone factory)", () => {
5
+ it("is a function that registers diff tools on session_start with a per-session theme", () => {
6
+ expect(typeof defaultExport).toBe("function");
7
+
8
+ const on = vi.fn();
9
+ const registerTool = vi.fn();
10
+ const pi = { on, registerTool } as any;
11
+
12
+ defaultExport(pi);
13
+
14
+ const startHandler = on.mock.calls.find((c: Array<unknown>) => c[0] === "session_start")?.[1];
15
+ expect(typeof startHandler).toBe("function");
16
+
17
+ // Mirror of meta's wiring: registerDiffTools(pi, getTheme, readConfig)
18
+ // runs per session with the session's ctx.theme.
19
+ startHandler!({}, { ui: { theme: {} } });
20
+
21
+ // write/edit tool overrides registered when the SDK loaded
22
+ expect(registerTool).toHaveBeenCalled();
23
+ });
24
+ });
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Adapted from pi-ui-hephaestus diff renderer.
5
5
  */
6
6
 
7
- import type { ExtensionAPI, Theme } from "@earendil-works/pi-coding-agent";
7
+ import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
8
8
  import type { SettingItem } from "@earendil-works/pi-tui";
9
9
 
10
10
  import { setConfigGetter as setShikiConfig } from "./shiki.js";
@@ -122,3 +122,15 @@ export function registerDiffTools(
122
122
  // Register edit tool override
123
123
  registerEditTool(pi, cwd, home, _sdk.createEditTool);
124
124
  }
125
+
126
+ // ── Default export (for standalone pi.extensions loading) ─────────────────
127
+
128
+ // Diff tools need a per-session theme, so registration runs on session_start
129
+ // (mirroring meta's wiring: registerDiffTools with a theme getter + config
130
+ // reader). Meta supplies a settings-backed config loader; standalone uses the
131
+ // package defaults.
132
+ export default function (pi: ExtensionAPI): void {
133
+ pi.on("session_start", (_event, ctx: ExtensionContext) => {
134
+ registerDiffTools(pi, () => ctx.ui.theme, () => DEFAULT_DIFF_CONFIG);
135
+ });
136
+ }