mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 02:01:29 +00:00
feat(coding-agent): add tool override support via extensions
- Add setActiveTools() to ExtensionAPI for dynamic tool management - Extensions can now override, wrap, or disable built-in tools - Add tool-override.ts example demonstrating the pattern - Update documentation for tool override capabilities
This commit is contained in:
parent
7a2c19cdf0
commit
e3dd4f21d1
10 changed files with 211 additions and 61 deletions
|
|
@ -514,7 +514,10 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|||
}
|
||||
|
||||
// Initially active tools = active built-in + extension tools
|
||||
let activeToolsArray: Tool[] = [...initialActiveBuiltInTools, ...wrappedExtensionTools];
|
||||
// Extension tools can override built-in tools with the same name
|
||||
const extensionToolNames = new Set(wrappedExtensionTools.map((t) => t.name));
|
||||
const nonOverriddenBuiltInTools = initialActiveBuiltInTools.filter((t) => !extensionToolNames.has(t.name));
|
||||
let activeToolsArray: Tool[] = [...nonOverriddenBuiltInTools, ...wrappedExtensionTools];
|
||||
time("combineTools");
|
||||
|
||||
// Wrap tools with extensions if available
|
||||
|
|
|
|||
|
|
@ -222,12 +222,6 @@ export function buildSystemPrompt(options: BuildSystemPromptOptions = {}): strin
|
|||
const hasLs = tools.includes("ls");
|
||||
const hasRead = tools.includes("read");
|
||||
|
||||
// Read-only mode notice (only if we have some read-only tools but no write tools)
|
||||
// Skip this if there are no built-in tools at all (extensions may provide write capabilities)
|
||||
if (tools.length > 0 && !hasBash && !hasEdit && !hasWrite) {
|
||||
guidelinesList.push("You are in READ-ONLY mode - you cannot modify files or execute arbitrary commands");
|
||||
}
|
||||
|
||||
// Bash without edit/write = read-only bash mode
|
||||
if (hasBash && !hasEdit && !hasWrite) {
|
||||
guidelinesList.push(
|
||||
|
|
@ -266,9 +260,7 @@ export function buildSystemPrompt(options: BuildSystemPromptOptions = {}): strin
|
|||
|
||||
// Always include these
|
||||
guidelinesList.push("Be concise in your responses");
|
||||
if (tools.length > 0) {
|
||||
guidelinesList.push("Show file paths clearly when working with files");
|
||||
}
|
||||
guidelinesList.push("Show file paths clearly when working with files");
|
||||
|
||||
const guidelines = guidelinesList.map((g) => `- ${g}`).join("\n");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue