forked from earendil-works/pi
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodel-status.ts
More file actions
31 lines (25 loc) · 957 Bytes
/
Copy pathmodel-status.ts
File metadata and controls
31 lines (25 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Model status extension - shows model changes in the status bar.
*
* Demonstrates the `model_select` hook which fires when the model changes
* via /model command, Ctrl+P cycling, or session restore.
*
* Usage: pi -e ./model-status.ts
*/
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export default function (pi: ExtensionAPI) {
pi.on("model_select", async (event, ctx) => {
const { model, previousModel, source } = event;
// Format model identifiers
const next = `${model.provider}/${model.id}`;
const prev = previousModel ? `${previousModel.provider}/${previousModel.id}` : "none";
// Show notification on change
if (source !== "restore") {
ctx.ui.notify(`Model: ${next}`, "info");
}
// Update status bar with current model
ctx.ui.setStatus("model", `🤖 ${model.id}`);
// Log change details (visible in debug output)
console.log(`[model_select] ${prev} → ${next} (${source})`);
});
}