mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 20:03:05 +00:00
Breaking changes: - Settings: 'hooks' and 'customTools' arrays replaced with 'extensions' - CLI: '--hook' and '--tool' flags replaced with '--extension' / '-e' - API: HookMessage renamed to CustomMessage, role 'hookMessage' to 'custom' - API: FileSlashCommand renamed to PromptTemplate - API: discoverSlashCommands() renamed to discoverPromptTemplates() - Directories: commands/ renamed to prompts/ for prompt templates Migration: - Session version bumped to 3 (auto-migrates v2 sessions) - Old 'hookMessage' role entries converted to 'custom' Structural changes: - src/core/hooks/ and src/core/custom-tools/ merged into src/core/extensions/ - src/core/slash-commands.ts renamed to src/core/prompt-templates.ts - examples/hooks/ and examples/custom-tools/ merged into examples/extensions/ - docs/hooks.md and docs/custom-tools.md merged into docs/extensions.md New test coverage: - test/extensions-runner.test.ts (10 tests) - test/extensions-discovery.test.ts (26 tests) - test/prompt-templates.test.ts
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
/**
|
|
* Tools Configuration
|
|
*
|
|
* Use built-in tool sets or individual tools.
|
|
*
|
|
* IMPORTANT: When using a custom `cwd`, you must use the tool factory functions
|
|
* (createCodingTools, createReadOnlyTools, createReadTool, etc.) to ensure
|
|
* tools resolve paths relative to your cwd, not process.cwd().
|
|
*
|
|
* For custom tools, see 06-extensions.ts - custom tools are now registered
|
|
* via the extensions system using pi.registerTool().
|
|
*/
|
|
|
|
import {
|
|
bashTool,
|
|
createAgentSession,
|
|
createBashTool,
|
|
createCodingTools,
|
|
createGrepTool,
|
|
createReadTool,
|
|
grepTool,
|
|
readOnlyTools,
|
|
readTool,
|
|
SessionManager,
|
|
} from "@mariozechner/pi-coding-agent";
|
|
|
|
// Read-only mode (no edit/write) - uses process.cwd()
|
|
await createAgentSession({
|
|
tools: readOnlyTools,
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
console.log("Read-only session created");
|
|
|
|
// Custom tool selection - uses process.cwd()
|
|
await createAgentSession({
|
|
tools: [readTool, bashTool, grepTool],
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
console.log("Custom tools session created");
|
|
|
|
// With custom cwd - MUST use factory functions!
|
|
const customCwd = "/path/to/project";
|
|
await createAgentSession({
|
|
cwd: customCwd,
|
|
tools: createCodingTools(customCwd), // Tools resolve paths relative to customCwd
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
console.log("Custom cwd session created");
|
|
|
|
// Or pick specific tools for custom cwd
|
|
await createAgentSession({
|
|
cwd: customCwd,
|
|
tools: [createReadTool(customCwd), createBashTool(customCwd), createGrepTool(customCwd)],
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
console.log("Specific tools with custom cwd session created");
|