@@ -1,5 +1,14 @@
1-import type { Api, AuthEvent, AuthPrompt, AuthType, Model, Models } from "@earendil-works/pi-ai";
2-import { saveSelection } from "../config.ts";
1+import {
2+ getSupportedThinkingLevels,
3+ type Api,
4+ type AuthEvent,
5+ type AuthPrompt,
6+ type AuthType,
7+ type Model,
8+ type ModelThinkingLevel,
9+ type Models,
10+} from "@earendil-works/pi-ai";
11+import { saveConfig } from "../config.ts";
312 import { dim, red } from "./styles.ts";
413 import { commonPrefix } from "./complete.ts";
514
@@ -10,6 +19,8 @@ export interface CommandContext {
1019 model: Model<Api>;
1120 /** Switches the running session to `model`. */
1221 select(model: Model<Api>): void;
22+ /** Sets the running session's thinking level. */
23+ setThinking(level: ModelThinkingLevel): void;
1324 /** Aborts when the running command is cancelled (Ctrl+C). */
1425 signal: AbortSignal;
1526 /** Appends already-styled lines to scrollback. */
@@ -125,11 +136,26 @@ const provider: Command = {
125136 });
126137 const chosen = models.find((m) => m.id === modelId);
127138 if (chosen === undefined) throw new Error(`unknown model: ${modelId}`);
128- saveSelection(providerId, modelId);
139+ saveConfig({ provider: providerId, model: modelId });
129140 ctx.select(chosen);
130141 },
131142 };
132143
144+const thinking: Command = {
145+ name: "thinking",
146+ description: "set the thinking level",
147+ async run(ctx): Promise<void> {
148+ const levels = getSupportedThinkingLevels(ctx.model);
149+ const level = (await ctx.prompt({
150+ type: "select",
151+ message: "Select a thinking level",
152+ options: levels.map((l) => ({ id: l, label: l })),
153+ })) as ModelThinkingLevel;
154+ saveConfig({ thinkingEffort: level });
155+ ctx.setThinking(level);
156+ },
157+};
158+
133159 const model: Command = {
134160 name: "model",
135161 description: "choose a model for the current provider",
@@ -145,12 +171,12 @@ const model: Command = {
145171 });
146172 const chosen = models.find((m) => m.id === modelId);
147173 if (chosen === undefined) throw new Error(`unknown model: ${modelId}`);
148- saveSelection(providerId, modelId);
174+ saveConfig({ provider: providerId, model: modelId });
149175 ctx.select(chosen);
150176 },
151177 };
152178
153-const COMMANDS: Command[] = [help, login, provider, model];
179+const COMMANDS: Command[] = [help, login, provider, model, thinking];
154180
155181 /** `/name` for a known `name`, else null; unknown slash text stays a message. */
156182 export function findCommand(text: string): { command: Command; args: string } | null {