import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent"; import { DISPLAY_LEVELS, getSupportedLevels, displayToPi, piToDisplay } from "./shared.js"; export default function (pi: ExtensionAPI) { pi.registerCommand("thinking", { description: "Select thinking level for current model", async handler(_args: string, ctx: ExtensionCommandContext) { const model = ctx.model; if (!model) { ctx.ui.notify("No active model", "error"); return; } const levels = getSupportedLevels(model); const currentDisplay = piToDisplay(pi.getThinkingLevel()); const labels = levels.map((l) => l === currentDisplay ? `${l} ✓` : l); const chosen = await ctx.ui.select(`Thinking level — ${model.id}`, labels); if (!chosen) return; const displayLevel = chosen.replace(" ✓", ""); if (!levels.includes(displayLevel)) return; pi.setThinkingLevel(displayToPi(displayLevel) as any); ctx.ui.notify(`✓ Thinking: ${displayLevel}`, "info"); }, }); }