@juicesharp/rpiv-btw 2.0.0 → 2.2.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/README.md +75 -66
- package/btw-budget.ts +403 -0
- package/btw-messages.ts +44 -0
- package/btw-ui.ts +33 -3
- package/btw.ts +159 -78
- package/docs/architecture.md +161 -0
- package/docs/context-model.md +95 -0
- package/package.json +7 -1
- package/pi-compat.ts +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-btw",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Pi extension. The /btw slash command, for putting a one-off side question to the same primary model without polluting the main conversation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -31,9 +31,15 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"index.ts",
|
|
33
33
|
"btw.ts",
|
|
34
|
+
"btw-budget.ts",
|
|
35
|
+
"btw-messages.ts",
|
|
34
36
|
"btw-ui.ts",
|
|
35
37
|
"pi-compat.ts",
|
|
36
38
|
"prompts/",
|
|
39
|
+
"docs/",
|
|
40
|
+
"!docs/*.png",
|
|
41
|
+
"!docs/*.jpg",
|
|
42
|
+
"!docs/*.svg",
|
|
37
43
|
"README.md",
|
|
38
44
|
"LICENSE"
|
|
39
45
|
],
|
package/pi-compat.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
type CompleteSimpleFn = typeof import("@earendil-works/pi-ai/compat").completeSimple;
|
|
20
|
+
type IsContextOverflowFn = typeof import("@earendil-works/pi-ai/compat").isContextOverflow;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Error codes meaning "the /compat entrypoint is not resolvable on this host":
|
|
@@ -62,3 +63,33 @@ export async function loadCompleteSimple(): Promise<CompleteSimpleFn> {
|
|
|
62
63
|
}
|
|
63
64
|
return completeSimple;
|
|
64
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Host-version-tolerant loader for pi-ai's `isContextOverflow` — the overflow
|
|
69
|
+
* detector that gates the /btw single-retry.
|
|
70
|
+
*
|
|
71
|
+
* `isContextOverflow` is re-exported from BOTH the `/compat` entrypoint and the
|
|
72
|
+
* package root (defined in pi-ai's `utils/overflow`), so the resolution path
|
|
73
|
+
* mirrors `loadCompleteSimple`: try `/compat`, fall back to the root only on a
|
|
74
|
+
* module-resolution failure, and rethrow a real `/compat` init failure so it is
|
|
75
|
+
* not masked by the fallback. Unlike `completeSimple`, the export's ABSENCE is
|
|
76
|
+
* an expected host state (older pi-ai, or a host that surfaces it from neither
|
|
77
|
+
* entrypoint), not an unsupported-host error: per the Option-3 refinement the
|
|
78
|
+
* missing-export case returns `undefined` so the caller degrades gracefully
|
|
79
|
+
* (skips the retry) instead of crashing. A non-resolution `/compat` failure
|
|
80
|
+
* still rethrows.
|
|
81
|
+
*/
|
|
82
|
+
export async function loadIsContextOverflow(): Promise<IsContextOverflowFn | undefined> {
|
|
83
|
+
let mod: { isContextOverflow?: IsContextOverflowFn };
|
|
84
|
+
try {
|
|
85
|
+
mod = (await import("@earendil-works/pi-ai/compat")) as { isContextOverflow?: IsContextOverflowFn };
|
|
86
|
+
} catch (err) {
|
|
87
|
+
if (!isModuleNotFound(err)) throw err; // a real /compat failure must surface, not mask as a fallback
|
|
88
|
+
mod = (await import("@earendil-works/pi-ai")) as { isContextOverflow?: IsContextOverflowFn };
|
|
89
|
+
}
|
|
90
|
+
const isContextOverflow = mod.isContextOverflow;
|
|
91
|
+
if (typeof isContextOverflow !== "function") {
|
|
92
|
+
return undefined; // expected absence on a host lacking the export — degrade, don't crash
|
|
93
|
+
}
|
|
94
|
+
return isContextOverflow;
|
|
95
|
+
}
|