mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 08:00:59 +00:00
Update SDK docs for SettingsManager changes
This commit is contained in:
parent
62c64a286b
commit
1e6a23ab3d
1 changed files with 35 additions and 12 deletions
|
|
@ -500,25 +500,48 @@ const { session } = await createAgentSession({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Settings
|
### Settings Management
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { createAgentSession, loadSettings } from "@mariozechner/pi-coding-agent";
|
import { createAgentSession, SettingsManager, SessionManager } from "@mariozechner/pi-coding-agent";
|
||||||
|
|
||||||
// Load current settings
|
// Default: loads from files (global + project merged)
|
||||||
const settings = loadSettings();
|
|
||||||
|
|
||||||
// Override specific settings
|
|
||||||
const { session } = await createAgentSession({
|
const { session } = await createAgentSession({
|
||||||
settings: {
|
settingsManager: SettingsManager.create(),
|
||||||
compaction: { enabled: false },
|
});
|
||||||
retry: { enabled: true, maxRetries: 5, baseDelayMs: 1000 },
|
|
||||||
terminal: { showImages: true },
|
// With overrides
|
||||||
hideThinkingBlock: true,
|
const settingsManager = SettingsManager.create();
|
||||||
},
|
settingsManager.applyOverrides({
|
||||||
|
compaction: { enabled: false },
|
||||||
|
retry: { enabled: true, maxRetries: 5 },
|
||||||
|
});
|
||||||
|
const { session } = await createAgentSession({ settingsManager });
|
||||||
|
|
||||||
|
// In-memory (no file I/O, for testing)
|
||||||
|
const { session } = await createAgentSession({
|
||||||
|
settingsManager: SettingsManager.inMemory({ compaction: { enabled: false } }),
|
||||||
|
sessionManager: SessionManager.inMemory(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Custom directories
|
||||||
|
const { session } = await createAgentSession({
|
||||||
|
settingsManager: SettingsManager.create("/custom/cwd", "/custom/agent"),
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Static factories:**
|
||||||
|
- `SettingsManager.create(cwd?, agentDir?)` - Load from files
|
||||||
|
- `SettingsManager.inMemory(settings?)` - No file I/O
|
||||||
|
|
||||||
|
**Project-specific settings:**
|
||||||
|
|
||||||
|
Settings load from two locations and merge:
|
||||||
|
1. Global: `~/.pi/agent/settings.json`
|
||||||
|
2. Project: `<cwd>/.pi/settings.json`
|
||||||
|
|
||||||
|
Project overrides global. Nested objects merge keys. Setters only modify global (project is read-only for version control).
|
||||||
|
|
||||||
## Discovery Functions
|
## Discovery Functions
|
||||||
|
|
||||||
All discovery functions accept optional `cwd` and `agentDir` parameters.
|
All discovery functions accept optional `cwd` and `agentDir` parameters.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue