@pi-archimedes/ask 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 +2 -2
- package/src/default-export.test.ts +23 -0
- package/src/index.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-archimedes/ask",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "./src/index.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@pi-archimedes/core": "2.
|
|
14
|
+
"@pi-archimedes/core": "2.4.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@earendil-works/pi-coding-agent": ">=0.1.0",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import defaultExport from "./index.js";
|
|
3
|
+
|
|
4
|
+
describe("ask default export (standalone factory)", () => {
|
|
5
|
+
it("is a function that registers the ask extension (registerAsk subscribes its own session events)", () => {
|
|
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
|
+
// ask tool registered
|
|
15
|
+
expect(registerTool).toHaveBeenCalled();
|
|
16
|
+
|
|
17
|
+
// registerAsk wires its own session lifecycle internally
|
|
18
|
+
const events = on.mock.calls.map((c: Array<unknown>) => c[0]);
|
|
19
|
+
expect(events).toEqual(
|
|
20
|
+
expect.arrayContaining(["session_start", "turn_start", "session_shutdown"]),
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -26,3 +26,12 @@ export function registerAsk(pi: ExtensionAPI) {
|
|
|
26
26
|
unsubscribes.length = 0;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
// ── Default export (for standalone pi.extensions loading) ─────────────────
|
|
31
|
+
|
|
32
|
+
// registerAsk already subscribes its own session_start/turn_start/
|
|
33
|
+
// session_shutdown handlers internally, so the default factory just
|
|
34
|
+
// registers it.
|
|
35
|
+
export default function (pi: ExtensionAPI): void {
|
|
36
|
+
registerAsk(pi);
|
|
37
|
+
}
|