pi-agent-extensions 0.3.5 → 0.3.6
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 +1 -1
- package/extensions/btw/index.ts +4 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -290,7 +290,7 @@ Ask quick "by the way" side questions without polluting your conversation histor
|
|
|
290
290
|
- ✅ Ephemeral overlay — nothing enters session history
|
|
291
291
|
- ✅ Zero context cost — no tokens wasted
|
|
292
292
|
- ✅ Scrollable answer (↑↓/j/k, PgUp/PgDn)
|
|
293
|
-
- ✅
|
|
293
|
+
- ✅ Uses your currently selected model
|
|
294
294
|
- ✅ Non-UI fallback (prints to stdout)
|
|
295
295
|
|
|
296
296
|
**When to use `/btw` vs normal prompts:**
|
package/extensions/btw/index.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* - Zero context cost — no tokens wasted on history
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { complete, type
|
|
20
|
+
import { complete, type UserMessage } from "@mariozechner/pi-ai";
|
|
21
21
|
import type {
|
|
22
22
|
ExtensionAPI,
|
|
23
23
|
ExtensionCommandContext,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
type TUI,
|
|
39
39
|
} from "@mariozechner/pi-tui";
|
|
40
40
|
|
|
41
|
-
import { getRequestAuth
|
|
41
|
+
import { getRequestAuth } from "../shared/auth.js";
|
|
42
42
|
import {
|
|
43
43
|
BTW_SYSTEM_PROMPT,
|
|
44
44
|
buildBtwUserMessage,
|
|
@@ -46,40 +46,6 @@ import {
|
|
|
46
46
|
extractResponseText,
|
|
47
47
|
} from "./btw.js";
|
|
48
48
|
|
|
49
|
-
const HAIKU_MODEL_ID = "claude-haiku-4-5";
|
|
50
|
-
const CODEX_MODEL_ID = "gpt-5.1-codex-mini";
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Select a cheap/fast model for BTW side questions.
|
|
54
|
-
* Prefers Codex mini → Haiku → current model.
|
|
55
|
-
*/
|
|
56
|
-
async function selectBtwModel(
|
|
57
|
-
currentModel: Model<Api>,
|
|
58
|
-
modelRegistry: {
|
|
59
|
-
find: (provider: string, modelId: string) => Model<Api> | undefined;
|
|
60
|
-
getApiKeyAndHeaders: (
|
|
61
|
-
model: Model<Api>,
|
|
62
|
-
) => Promise<
|
|
63
|
-
| { ok: true; apiKey?: string; headers?: Record<string, string> }
|
|
64
|
-
| { ok: false; error: string }
|
|
65
|
-
>;
|
|
66
|
-
},
|
|
67
|
-
): Promise<Model<Api>> {
|
|
68
|
-
// Try Codex mini first (cheapest)
|
|
69
|
-
const codexModel = modelRegistry.find("openai-codex", CODEX_MODEL_ID);
|
|
70
|
-
if (codexModel && (await hasRequestAuth(modelRegistry, codexModel))) {
|
|
71
|
-
return codexModel;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Try Haiku (fast & cheap)
|
|
75
|
-
const haikuModel = modelRegistry.find("anthropic", HAIKU_MODEL_ID);
|
|
76
|
-
if (haikuModel && (await hasRequestAuth(modelRegistry, haikuModel))) {
|
|
77
|
-
return haikuModel;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Fallback to current model
|
|
81
|
-
return currentModel;
|
|
82
|
-
}
|
|
83
49
|
|
|
84
50
|
/**
|
|
85
51
|
* Overlay component that displays the BTW answer.
|
|
@@ -299,8 +265,8 @@ async function runBtwCommand(
|
|
|
299
265
|
conversationText = serializeConversation(llmMessages);
|
|
300
266
|
}
|
|
301
267
|
|
|
302
|
-
//
|
|
303
|
-
const btwModel =
|
|
268
|
+
// Use the currently selected model
|
|
269
|
+
const btwModel = ctx.model;
|
|
304
270
|
|
|
305
271
|
// Build LLM messages
|
|
306
272
|
const userMessage: UserMessage = {
|