@juicesharp/rpiv-advisor 2.6.2 → 2.6.3
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 +4 -3
- package/advisor/pi-compat.test.ts +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-advisor",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "Pi extension. A second opinion the model can request from a stronger reviewer model before it acts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"!docs/*.jpg",
|
|
38
38
|
"!docs/*.svg",
|
|
39
39
|
"README.md",
|
|
40
|
-
"LICENSE"
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"!**/*.test.ts"
|
|
41
42
|
],
|
|
42
43
|
"pi": {
|
|
43
44
|
"image": "https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-advisor/docs/cover.png",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
]
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@juicesharp/rpiv-config": "^2.6.
|
|
50
|
+
"@juicesharp/rpiv-config": "^2.6.3",
|
|
50
51
|
"typebox": "^1.1.24"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pi-compat tests — the host-version-tolerant `completeSimple` loader.
|
|
3
|
-
*
|
|
4
|
-
* The consumer test files mock `@earendil-works/pi-ai/compat` to SUCCEED, so
|
|
5
|
-
* the version-tolerance arms the shim exists for are exercised here instead:
|
|
6
|
-
* /compat resolves (host >= 0.80.1), /compat unresolvable → root fallback
|
|
7
|
-
* (host <= 0.79.x), a REAL /compat failure rethrows instead of masking, and a
|
|
8
|
-
* host with neither export fails with a clear error.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
12
|
-
import { getRuntimeCompleteSimple } from "./pi-compat.js";
|
|
13
|
-
|
|
14
|
-
describe("getRuntimeCompleteSimple", () => {
|
|
15
|
-
it("returns a method bound to the host runtime", async () => {
|
|
16
|
-
const runtime = {
|
|
17
|
-
completeSimple: vi.fn(function (this: unknown) {
|
|
18
|
-
expect(this).toBe(runtime);
|
|
19
|
-
return Promise.resolve(undefined as never);
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
const completeSimple = getRuntimeCompleteSimple({ runtime });
|
|
23
|
-
|
|
24
|
-
expect(completeSimple).toBeTypeOf("function");
|
|
25
|
-
if (!completeSimple) throw new Error("expected runtime completion facade");
|
|
26
|
-
await completeSimple(undefined as never, undefined as never);
|
|
27
|
-
expect(runtime.completeSimple).toHaveBeenCalledOnce();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("returns undefined for missing or malformed runtime facades", () => {
|
|
31
|
-
expect(getRuntimeCompleteSimple(undefined)).toBeUndefined();
|
|
32
|
-
expect(getRuntimeCompleteSimple({ runtime: null })).toBeUndefined();
|
|
33
|
-
expect(getRuntimeCompleteSimple({ runtime: { completeSimple: "not-a-function" } })).toBeUndefined();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe("loadCompleteSimple", () => {
|
|
38
|
-
afterEach(() => {
|
|
39
|
-
vi.doUnmock("@earendil-works/pi-ai/compat");
|
|
40
|
-
vi.doUnmock("@earendil-works/pi-ai");
|
|
41
|
-
vi.resetModules();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
/** Import the shim AFTER the per-test doMocks so its dynamic imports resolve
|
|
45
|
-
* against them (vi.resetModules first drops any previously-cached copies). */
|
|
46
|
-
async function load(): Promise<unknown> {
|
|
47
|
-
const mod = await import("./pi-compat.js");
|
|
48
|
-
return mod.loadCompleteSimple();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
it("resolves completeSimple from /compat when the host exposes it (pi >= 0.80.1)", async () => {
|
|
52
|
-
vi.resetModules();
|
|
53
|
-
const compatFn = vi.fn();
|
|
54
|
-
vi.doMock("@earendil-works/pi-ai/compat", () => ({ completeSimple: compatFn }));
|
|
55
|
-
await expect(load()).resolves.toBe(compatFn);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("falls back to the package root when /compat is not exported (host <= 0.79.x)", async () => {
|
|
59
|
-
vi.resetModules();
|
|
60
|
-
vi.doMock("@earendil-works/pi-ai/compat", () => {
|
|
61
|
-
// The code an installed-but-old pi-ai actually produces: the package
|
|
62
|
-
// resolves, but "./compat" is missing from its exports map.
|
|
63
|
-
throw Object.assign(new Error("Package subpath './compat' is not defined"), {
|
|
64
|
-
code: "ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
const rootFn = vi.fn();
|
|
68
|
-
vi.doMock("@earendil-works/pi-ai", () => ({ completeSimple: rootFn }));
|
|
69
|
-
await expect(load()).resolves.toBe(rootFn);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("rethrows a non-resolution /compat failure instead of masking it with the root fallback", async () => {
|
|
73
|
-
vi.resetModules();
|
|
74
|
-
vi.doMock("@earendil-works/pi-ai/compat", () => {
|
|
75
|
-
throw new Error("compat entrypoint exploded at module init");
|
|
76
|
-
});
|
|
77
|
-
// A WORKING root export proves the rejection comes from the rethrow: the
|
|
78
|
-
// old catch-all `.catch` fallback would have resolved here.
|
|
79
|
-
vi.doMock("@earendil-works/pi-ai", () => ({ completeSimple: vi.fn() }));
|
|
80
|
-
await expect(load()).rejects.toThrow();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("fails with a clear error when neither entrypoint exposes completeSimple", async () => {
|
|
84
|
-
vi.resetModules();
|
|
85
|
-
vi.doMock("@earendil-works/pi-ai/compat", () => ({}));
|
|
86
|
-
await expect(load()).rejects.toThrow(/completeSimple/);
|
|
87
|
-
});
|
|
88
|
-
});
|