mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 22:03:45 +00:00
Fix AGENTS.md support, changelog viewer, and session model storage
- BREAKING: Renamed AGENT.md to AGENTS.md for project context files - Added automatic changelog viewer on startup for new sessions - Added settings manager to track last shown changelog version - BREAKING: Store provider and modelId separately in session files (fixes #4) - Fixed markdown list rendering when items contain inline code with cyan formatting - Added dynamic border component for TUI - Updated changelog with entries for #4 and #5
This commit is contained in:
parent
c23f1576dc
commit
fede1303b1
5 changed files with 45 additions and 30 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue