mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 10:02:23 +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
|
|
@ -910,7 +910,7 @@ export const MODELS = {
|
||||||
contextWindow: 200000,
|
contextWindow: 200000,
|
||||||
maxTokens: 100000,
|
maxTokens: 100000,
|
||||||
} satisfies Model<"openai-responses">,
|
} satisfies Model<"openai-responses">,
|
||||||
"o1": {
|
o1: {
|
||||||
id: "o1",
|
id: "o1",
|
||||||
name: "o1",
|
name: "o1",
|
||||||
api: "openai-responses",
|
api: "openai-responses",
|
||||||
|
|
@ -978,7 +978,7 @@ export const MODELS = {
|
||||||
contextWindow: 128000,
|
contextWindow: 128000,
|
||||||
maxTokens: 16384,
|
maxTokens: 16384,
|
||||||
} satisfies Model<"openai-responses">,
|
} satisfies Model<"openai-responses">,
|
||||||
"o3": {
|
o3: {
|
||||||
id: "o3",
|
id: "o3",
|
||||||
name: "o3",
|
name: "o3",
|
||||||
api: "openai-responses",
|
api: "openai-responses",
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,16 @@
|
||||||
### Added
|
### 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`.
|
- 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
|
### 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**: 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
|
## [0.7.6] - 2025-11-13
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -527,21 +527,19 @@ export async function main(args: string[]) {
|
||||||
// Load and restore model
|
// Load and restore model
|
||||||
const savedModel = sessionManager.loadModel();
|
const savedModel = sessionManager.loadModel();
|
||||||
if (savedModel) {
|
if (savedModel) {
|
||||||
// Parse provider/modelId from saved model string (format: "provider/modelId")
|
try {
|
||||||
// Some providers or model IDs may contain slashes, so split only on the first slash.
|
const restoredModel = getModel(savedModel.provider as any, savedModel.modelId);
|
||||||
// For example, "openrouter/x-ai/grok-4-fast" -> provider: "openrouter", modelId: "x-ai/grok-4-fast".
|
agent.setModel(restoredModel);
|
||||||
const [savedProvider, savedModelId] = savedModel.split("/", 1);
|
if (shouldPrintMessages) {
|
||||||
if (savedProvider && savedModelId) {
|
console.log(chalk.dim(`Restored model: ${savedModel.provider}/${savedModel.modelId}`));
|
||||||
try {
|
}
|
||||||
const restoredModel = getModel(savedProvider as any, savedModelId);
|
} catch (error: any) {
|
||||||
agent.setModel(restoredModel);
|
if (shouldPrintMessages) {
|
||||||
if (shouldPrintMessages) {
|
console.error(
|
||||||
console.log(chalk.dim(`Restored model: ${savedModel}`));
|
chalk.yellow(
|
||||||
}
|
`Warning: Could not restore model ${savedModel.provider}/${savedModel.modelId}: ${error.message}`,
|
||||||
} catch (error: any) {
|
),
|
||||||
if (shouldPrintMessages) {
|
);
|
||||||
console.error(chalk.yellow(`Warning: Could not restore model ${savedModel}: ${error.message}`));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ export interface SessionHeader {
|
||||||
id: string;
|
id: string;
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
cwd: string;
|
cwd: string;
|
||||||
model: string;
|
provider: string;
|
||||||
|
modelId: string;
|
||||||
thinkingLevel: string;
|
thinkingLevel: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +37,8 @@ export interface ThinkingLevelChangeEntry {
|
||||||
export interface ModelChangeEntry {
|
export interface ModelChangeEntry {
|
||||||
type: "model_change";
|
type: "model_change";
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
model: string;
|
provider: string;
|
||||||
|
modelId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SessionManager {
|
export class SessionManager {
|
||||||
|
|
@ -139,7 +141,8 @@ export class SessionManager {
|
||||||
id: this.sessionId,
|
id: this.sessionId,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
model: `${state.model.provider}/${state.model.id}`,
|
provider: state.model.provider,
|
||||||
|
modelId: state.model.id,
|
||||||
thinkingLevel: state.thinkingLevel,
|
thinkingLevel: state.thinkingLevel,
|
||||||
};
|
};
|
||||||
appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n");
|
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;
|
if (!this.enabled) return;
|
||||||
const entry: ModelChangeEntry = {
|
const entry: ModelChangeEntry = {
|
||||||
type: "model_change",
|
type: "model_change",
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
model,
|
provider,
|
||||||
|
modelId,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.sessionInitialized) {
|
if (!this.sessionInitialized) {
|
||||||
|
|
@ -239,27 +243,34 @@ export class SessionManager {
|
||||||
return lastThinkingLevel;
|
return lastThinkingLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadModel(): string | null {
|
loadModel(): { provider: string; modelId: string } | null {
|
||||||
if (!existsSync(this.sessionFile)) return null;
|
if (!existsSync(this.sessionFile)) return null;
|
||||||
|
|
||||||
const lines = readFileSync(this.sessionFile, "utf8").trim().split("\n");
|
const lines = readFileSync(this.sessionFile, "utf8").trim().split("\n");
|
||||||
|
|
||||||
// Find the most recent model (from session header or change event)
|
// 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) {
|
for (const line of lines) {
|
||||||
try {
|
try {
|
||||||
const entry = JSON.parse(line);
|
const entry = JSON.parse(line);
|
||||||
if (entry.type === "session" && entry.model) {
|
if (entry.type === "session" && entry.provider && entry.modelId) {
|
||||||
lastModel = entry.model;
|
lastProvider = entry.provider;
|
||||||
} else if (entry.type === "model_change" && entry.model) {
|
lastModelId = entry.modelId;
|
||||||
lastModel = entry.model;
|
} else if (entry.type === "model_change" && entry.provider && entry.modelId) {
|
||||||
|
lastProvider = entry.provider;
|
||||||
|
lastModelId = entry.modelId;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Skip malformed lines
|
// Skip malformed lines
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lastModel;
|
if (lastProvider && lastModelId) {
|
||||||
|
return { provider: lastProvider, modelId: lastModelId };
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSessionId(): string {
|
getSessionId(): string {
|
||||||
|
|
|
||||||
|
|
@ -521,7 +521,7 @@ export class TuiRenderer {
|
||||||
this.agent.setModel(model);
|
this.agent.setModel(model);
|
||||||
|
|
||||||
// Save model change to session
|
// 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
|
// Show confirmation message with proper spacing
|
||||||
this.chatContainer.addChild(new Spacer(1));
|
this.chatContainer.addChild(new Spacer(1));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue