mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 18:03:50 +00:00
Add project-specific settings and SettingsManager factories
- 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
This commit is contained in:
parent
05e1f31feb
commit
62c64a286b
8 changed files with 162 additions and 71 deletions
|
|
@ -1,33 +1,38 @@
|
|||
/**
|
||||
* Settings Configuration
|
||||
*
|
||||
* Override settings from agentDir/settings.json.
|
||||
* Override settings using SettingsManager.
|
||||
*/
|
||||
|
||||
import { createAgentSession, loadSettings, SessionManager } from "../../src/index.js";
|
||||
import { createAgentSession, loadSettings, SessionManager, SettingsManager } from "../../src/index.js";
|
||||
|
||||
// Load current settings
|
||||
// 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({
|
||||
settings: {
|
||||
// Disable auto-compaction
|
||||
compaction: { enabled: false },
|
||||
|
||||
// Custom retry behavior
|
||||
retry: {
|
||||
enabled: true,
|
||||
maxRetries: 5,
|
||||
baseDelayMs: 1000,
|
||||
},
|
||||
|
||||
// Terminal options
|
||||
terminal: { showImages: true },
|
||||
hideThinkingBlock: true,
|
||||
},
|
||||
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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue