mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 23:01:30 +00:00
- SettingsManager now loads .pi/settings.json from cwd (project settings) - Project settings merge with global settings (deep merge for objects) - Setters only modify global settings, project settings are read-only - Add static factories: SettingsManager.create(cwd?, agentDir?), SettingsManager.inMemory(settings?) - Add applyOverrides() for programmatic overrides - Replace 'settings' option with 'settingsManager' in CreateAgentSessionOptions - Update examples to use new pattern Incorporates PR #276 approach
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
/**
|
|
* Settings Configuration
|
|
*
|
|
* Override settings using SettingsManager.
|
|
*/
|
|
|
|
import { createAgentSession, loadSettings, SessionManager, SettingsManager } from "../../src/index.js";
|
|
|
|
// Load current settings (merged global + project)
|
|
const settings = loadSettings();
|
|
console.log("Current settings:", JSON.stringify(settings, null, 2));
|
|
|
|
// Override specific settings
|
|
const settingsManager = SettingsManager.create();
|
|
settingsManager.applyOverrides({
|
|
compaction: { enabled: false },
|
|
retry: { enabled: true, maxRetries: 5, baseDelayMs: 1000 },
|
|
});
|
|
|
|
const { session } = await createAgentSession({
|
|
settingsManager,
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
|
|
console.log("Session created with custom settings");
|
|
|
|
// For testing without file I/O:
|
|
const inMemorySettings = SettingsManager.inMemory({
|
|
compaction: { enabled: false },
|
|
retry: { enabled: false },
|
|
});
|
|
|
|
const { session: testSession } = await createAgentSession({
|
|
settingsManager: inMemorySettings,
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
|
|
console.log("Test session created with in-memory settings");
|