diff --git a/packages/ai/src/models.generated.ts b/packages/ai/src/models.generated.ts index ff0da336..2c8e89da 100644 --- a/packages/ai/src/models.generated.ts +++ b/packages/ai/src/models.generated.ts @@ -910,7 +910,7 @@ export const MODELS = { contextWindow: 200000, maxTokens: 100000, } satisfies Model<"openai-responses">, - "o1": { + o1: { id: "o1", name: "o1", api: "openai-responses", @@ -978,7 +978,7 @@ export const MODELS = { contextWindow: 128000, maxTokens: 16384, } satisfies Model<"openai-responses">, - "o3": { + o3: { id: "o3", name: "o3", api: "openai-responses", diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 960dd1e9..2b3764b9 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -5,10 +5,16 @@ ### Added - Automatic changelog viewer on startup in interactive mode. When starting a new session (not continuing/resuming), the agent will display all changelog entries since the last version you used in a scrollable markdown viewer. The last shown version is tracked in `~/.pi/agent/settings.json`. +- OpenRouter Auto Router model support ([#5](https://github.com/badlogic/pi-mono/pull/5)) ### Changed - **BREAKING**: Renamed project context file from `AGENT.md` to `AGENTS.md`. The system now looks for `AGENTS.md` or `CLAUDE.md` (with `AGENTS.md` preferred). Existing `AGENT.md` files will need to be renamed to `AGENTS.md` to continue working. (fixes [#9](https://github.com/badlogic/pi-mono/pull/9)) +- **BREAKING**: Session file format changed to store provider and model ID separately instead of as a single `provider/modelId` string. Existing sessions will not restore the model correctly when resumed - you'll need to manually set the model again using `/model`. (fixes [#4](https://github.com/badlogic/pi-mono/pull/4)) + +### Fixed + +- Fixed markdown list rendering bug where bullets were not displayed when list items contained inline code with cyan color formatting ## [0.7.6] - 2025-11-13 diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.ts index 1b5f83ee..654cad99 100644 --- a/packages/coding-agent/src/main.ts +++ b/packages/coding-agent/src/main.ts @@ -527,21 +527,19 @@ export async function main(args: string[]) { // Load and restore model const savedModel = sessionManager.loadModel(); if (savedModel) { - // Parse provider/modelId from saved model string (format: "provider/modelId") - // Some providers or model IDs may contain slashes, so split only on the first slash. - // For example, "openrouter/x-ai/grok-4-fast" -> provider: "openrouter", modelId: "x-ai/grok-4-fast". - const [savedProvider, savedModelId] = savedModel.split("/", 1); - if (savedProvider && savedModelId) { - try { - const restoredModel = getModel(savedProvider as any, savedModelId); - agent.setModel(restoredModel); - if (shouldPrintMessages) { - console.log(chalk.dim(`Restored model: ${savedModel}`)); - } - } catch (error: any) { - if (shouldPrintMessages) { - console.error(chalk.yellow(`Warning: Could not restore model ${savedModel}: ${error.message}`)); - } + try { + const restoredModel = getModel(savedModel.provider as any, savedModel.modelId); + agent.setModel(restoredModel); + if (shouldPrintMessages) { + console.log(chalk.dim(`Restored model: ${savedModel.provider}/${savedModel.modelId}`)); + } + } catch (error: any) { + if (shouldPrintMessages) { + console.error( + chalk.yellow( + `Warning: Could not restore model ${savedModel.provider}/${savedModel.modelId}: ${error.message}`, + ), + ); } } } diff --git a/packages/coding-agent/src/session-manager.ts b/packages/coding-agent/src/session-manager.ts index 35ad1571..f5490580 100644 --- a/packages/coding-agent/src/session-manager.ts +++ b/packages/coding-agent/src/session-manager.ts @@ -17,7 +17,8 @@ export interface SessionHeader { id: string; timestamp: string; cwd: string; - model: string; + provider: string; + modelId: string; thinkingLevel: string; } @@ -36,7 +37,8 @@ export interface ThinkingLevelChangeEntry { export interface ModelChangeEntry { type: "model_change"; timestamp: string; - model: string; + provider: string; + modelId: string; } export class SessionManager { @@ -139,7 +141,8 @@ export class SessionManager { id: this.sessionId, timestamp: new Date().toISOString(), cwd: process.cwd(), - model: `${state.model.provider}/${state.model.id}`, + provider: state.model.provider, + modelId: state.model.id, thinkingLevel: state.thinkingLevel, }; appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n"); @@ -181,12 +184,13 @@ export class SessionManager { } } - saveModelChange(model: string): void { + saveModelChange(provider: string, modelId: string): void { if (!this.enabled) return; const entry: ModelChangeEntry = { type: "model_change", timestamp: new Date().toISOString(), - model, + provider, + modelId, }; if (!this.sessionInitialized) { @@ -239,27 +243,34 @@ export class SessionManager { return lastThinkingLevel; } - loadModel(): string | null { + loadModel(): { provider: string; modelId: string } | null { if (!existsSync(this.sessionFile)) return null; const lines = readFileSync(this.sessionFile, "utf8").trim().split("\n"); // Find the most recent model (from session header or change event) - let lastModel: string | null = null; + let lastProvider: string | null = null; + let lastModelId: string | null = null; + for (const line of lines) { try { const entry = JSON.parse(line); - if (entry.type === "session" && entry.model) { - lastModel = entry.model; - } else if (entry.type === "model_change" && entry.model) { - lastModel = entry.model; + if (entry.type === "session" && entry.provider && entry.modelId) { + lastProvider = entry.provider; + lastModelId = entry.modelId; + } else if (entry.type === "model_change" && entry.provider && entry.modelId) { + lastProvider = entry.provider; + lastModelId = entry.modelId; } } catch { // Skip malformed lines } } - return lastModel; + if (lastProvider && lastModelId) { + return { provider: lastProvider, modelId: lastModelId }; + } + return null; } getSessionId(): string { diff --git a/packages/coding-agent/src/tui/tui-renderer.ts b/packages/coding-agent/src/tui/tui-renderer.ts index 63e15468..ec90d1db 100644 --- a/packages/coding-agent/src/tui/tui-renderer.ts +++ b/packages/coding-agent/src/tui/tui-renderer.ts @@ -521,7 +521,7 @@ export class TuiRenderer { this.agent.setModel(model); // Save model change to session - this.sessionManager.saveModelChange(`${model.provider}/${model.id}`); + this.sessionManager.saveModelChange(model.provider, model.id); // Show confirmation message with proper spacing this.chatContainer.addChild(new Spacer(1));