Changesets · Branches · Tags · Compare
| Changeset | 6c2aba15fe9965aef6a1251a81cd5c87cb58c5257ca7a6eabc3958985fd5fd9b |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-22 19:40 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-22 19:40 -07:00 |
| Parents | 54e630386bd7 |
17 files changed
modified extensions/cli/src/permissions/permissionChecker.test.ts +9 −3
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { vi, describe, it, expect, beforeEach, afterEach } from "vitest"; | |
| 1 | +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | |
| 2 | 2 | |
| 3 | 3 | import * as toolsModule from "../tools/index.js"; |
| 4 | 4 | |
| @@ -604,7 +604,10 @@ | ||
| 604 | 604 | name: "Bash", |
| 605 | 605 | displayName: "Bash", |
| 606 | 606 | description: "Execute bash commands", |
| 607 | - parameters: {}, | |
| 607 | + parameters: { | |
| 608 | + type: "object" as const, | |
| 609 | + properties: {}, | |
| 610 | + }, | |
| 608 | 611 | isBuiltIn: true, |
| 609 | 612 | evaluateToolCallPolicy: vi.fn(), |
| 610 | 613 | run: vi.fn(), |
| @@ -882,7 +885,10 @@ | ||
| 882 | 885 | name: "Read", |
| 883 | 886 | displayName: "Read", |
| 884 | 887 | description: "Read files", |
| 885 | - parameters: {}, | |
| 888 | + parameters: { | |
| 889 | + type: "object" as const, | |
| 890 | + properties: {}, | |
| 891 | + }, | |
| 886 | 892 | isBuiltIn: true, |
| 887 | 893 | run: vi.fn(), |
| 888 | 894 | // No evaluateToolCallPolicy |
modified extensions/cli/src/stream/handleToolCalls.ts +2 −13
| @@ -233,19 +233,8 @@ | ||
| 233 | 233 | description: tool.description, |
| 234 | 234 | parameters: { |
| 235 | 235 | type: "object", |
| 236 | - properties: Object.fromEntries( | |
| 237 | - Object.entries(tool.parameters).map(([key, param]) => [ | |
| 238 | - key, | |
| 239 | - { | |
| 240 | - type: param.type, | |
| 241 | - description: param.description, | |
| 242 | - items: param.items, | |
| 243 | - }, | |
| 244 | - ]), | |
| 245 | - ), | |
| 246 | - required: Object.entries(tool.parameters) | |
| 247 | - .filter(([_, param]) => param.required) | |
| 248 | - .map(([key, _]) => key), | |
| 236 | + required: tool.parameters.required, | |
| 237 | + properties: tool.parameters.properties, | |
| 249 | 238 | }, |
| 250 | 239 | }, |
| 251 | 240 | })); |
modified extensions/cli/src/tools/edit.ts +22 −21
| @@ -79,27 +79,28 @@ | ||
| 79 | 79 | - When not using \`replace_all\`, the edit will FAIL if \`old_string\` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use \`replace_all\` to change every instance of \`old_string\`. |
| 80 | 80 | - The edit will FAIL if you have not recently used the \`${readFileTool.name}\` tool to view up-to-date file contents.`, |
| 81 | 81 | parameters: { |
| 82 | - file_path: { | |
| 83 | - type: "string", | |
| 84 | - description: "The absolute path to the file to modify", | |
| 85 | - required: true, | |
| 86 | - }, | |
| 87 | - old_string: { | |
| 88 | - type: "string", | |
| 89 | - description: | |
| 90 | - "The text to replace - must be exact including whitespace/indentation", | |
| 91 | - required: true, | |
| 92 | - }, | |
| 93 | - new_string: { | |
| 94 | - type: "string", | |
| 95 | - description: | |
| 96 | - "The text to replace it with (MUST be different from old_string)", | |
| 97 | - required: true, | |
| 98 | - }, | |
| 99 | - replace_all: { | |
| 100 | - type: "boolean", | |
| 101 | - description: "Replace all occurences of old_string (default false)", | |
| 102 | - required: false, | |
| 82 | + type: "object", | |
| 83 | + required: ["file_path", "old_string", "new_string"], | |
| 84 | + properties: { | |
| 85 | + file_path: { | |
| 86 | + type: "string", | |
| 87 | + description: | |
| 88 | + "Absolute or relative path to the file to modify. Absolute preferred", | |
| 89 | + }, | |
| 90 | + old_string: { | |
| 91 | + type: "string", | |
| 92 | + description: | |
| 93 | + "The text to replace - must be exact including whitespace/indentation", | |
| 94 | + }, | |
| 95 | + new_string: { | |
| 96 | + type: "string", | |
| 97 | + description: | |
| 98 | + "The text to replace it with (MUST be different from old_string)", | |
| 99 | + }, | |
| 100 | + replace_all: { | |
| 101 | + type: "boolean", | |
| 102 | + description: "Replace all occurrences of old_string (default false)", | |
| 103 | + }, | |
| 103 | 104 | }, |
| 104 | 105 | }, |
| 105 | 106 | preprocess: async (args) => { |
modified extensions/cli/src/tools/exit.ts +4 −1
| @@ -5,7 +5,10 @@ | ||
| 5 | 5 | displayName: "Exit", |
| 6 | 6 | description: |
| 7 | 7 | "Exit the current process with status code 1, indicating a failure or error", |
| 8 | - parameters: {}, | |
| 8 | + parameters: { | |
| 9 | + type: "object", | |
| 10 | + properties: {}, | |
| 11 | + }, | |
| 9 | 12 | readonly: false, |
| 10 | 13 | isBuiltIn: true, |
| 11 | 14 | run: async (): Promise<string> => { |
modified extensions/cli/src/tools/fetch.test.ts +7 −4
| @@ -144,10 +144,13 @@ | ||
| 144 | 144 | expect(fetchTool.readonly).toBe(true); |
| 145 | 145 | expect(fetchTool.isBuiltIn).toBe(true); |
| 146 | 146 | expect(fetchTool.parameters).toEqual({ |
| 147 | - url: { | |
| 148 | - type: "string", | |
| 149 | - description: "The URL to fetch content from", | |
| 150 | - required: true, | |
| 147 | + type: "object", | |
| 148 | + required: ["url"], | |
| 149 | + properties: { | |
| 150 | + url: { | |
| 151 | + type: "string", | |
| 152 | + description: "The URL to fetch content from", | |
| 153 | + }, | |
| 151 | 154 | }, |
| 152 | 155 | }); |
| 153 | 156 | }); |
modified extensions/cli/src/tools/fetch.ts +7 −4
| @@ -9,10 +9,13 @@ | ||
| 9 | 9 | description: |
| 10 | 10 | "Fetches content from a URL, converts to markdown, and handles long content with truncation", |
| 11 | 11 | parameters: { |
| 12 | - url: { | |
| 13 | - type: "string", | |
| 14 | - description: "The URL to fetch content from", | |
| 15 | - required: true, | |
| 12 | + type: "object", | |
| 13 | + required: ["url"], | |
| 14 | + properties: { | |
| 15 | + url: { | |
| 16 | + type: "string", | |
| 17 | + description: "The URL to fetch content from", | |
| 18 | + }, | |
| 16 | 19 | }, |
| 17 | 20 | }, |
| 18 | 21 | readonly: true, |
modified extensions/cli/src/tools/index.tsx +15 −21
| @@ -26,13 +26,14 @@ | ||
| 26 | 26 | import { |
| 27 | 27 | type Tool, |
| 28 | 28 | type ToolCall, |
| 29 | - type ToolParameters, | |
| 29 | + type ToolParametersSchema, | |
| 30 | + ParameterSchema, | |
| 30 | 31 | PreprocessedToolCall, |
| 31 | 32 | } from "./types.js"; |
| 32 | 33 | import { writeChecklistTool } from "./writeChecklist.js"; |
| 33 | 34 | import { writeFileTool } from "./writeFile.js"; |
| 34 | 35 | |
| 35 | -export type { Tool, ToolCall, ToolParameters }; | |
| 36 | +export type { Tool, ToolCall, ToolParametersSchema }; | |
| 36 | 37 | |
| 37 | 38 | // Base tools that are always available |
| 38 | 39 | const BASE_BUILTIN_TOOLS: Tool[] = [ |
| @@ -152,22 +153,6 @@ | ||
| 152 | 153 | return toolCalls; |
| 153 | 154 | } |
| 154 | 155 | |
| 155 | -function convertInputSchemaToParameters(inputSchema: any): ToolParameters { | |
| 156 | - const parameters: Record< | |
| 157 | - string, | |
| 158 | - { type: string; description: string; required: boolean } | |
| 159 | - > = {}; | |
| 160 | - for (const [key, value] of Object.entries(inputSchema.properties)) { | |
| 161 | - const val = value as any; | |
| 162 | - parameters[key] = { | |
| 163 | - type: val.type, | |
| 164 | - description: val.description || "", | |
| 165 | - required: inputSchema.required?.includes(key) || false, | |
| 166 | - }; | |
| 167 | - } | |
| 168 | - return parameters; | |
| 169 | -} | |
| 170 | - | |
| 171 | 156 | export async function getAvailableTools() { |
| 172 | 157 | // Load MCP tools |
| 173 | 158 | const mcpState = await serviceContainer.get<MCPServiceState>( |
| @@ -179,7 +164,14 @@ | ||
| 179 | 164 | name: t.name, |
| 180 | 165 | displayName: t.name.replace("mcp__", "").replace("ide__", ""), |
| 181 | 166 | description: t.description ?? "", |
| 182 | - parameters: convertInputSchemaToParameters(t.inputSchema), | |
| 167 | + parameters: { | |
| 168 | + type: "object", | |
| 169 | + properties: (t.inputSchema.properties ?? {}) as Record< | |
| 170 | + string, | |
| 171 | + ParameterSchema | |
| 172 | + >, | |
| 173 | + required: t.inputSchema.required, | |
| 174 | + }, | |
| 183 | 175 | readonly: undefined, // MCP tools don't have readonly property |
| 184 | 176 | isBuiltIn: false, |
| 185 | 177 | run: async (args: any) => { |
| @@ -255,10 +247,12 @@ | ||
| 255 | 247 | } |
| 256 | 248 | } |
| 257 | 249 | |
| 250 | +// Only checks top-level required | |
| 258 | 251 | export function validateToolCallArgsPresent(toolCall: ToolCall, tool: Tool) { |
| 259 | - for (const [paramName, paramDef] of Object.entries(tool.parameters)) { | |
| 252 | + const requiredParams = tool.parameters.required ?? []; | |
| 253 | + for (const [paramName] of Object.entries(tool.parameters)) { | |
| 260 | 254 | if ( |
| 261 | - paramDef.required && | |
| 255 | + requiredParams.includes(paramName) && | |
| 262 | 256 | (toolCall.arguments[paramName] === undefined || |
| 263 | 257 | toolCall.arguments[paramName] === null) |
| 264 | 258 | ) { |
modified extensions/cli/src/tools/listFiles.ts +7 −4
| @@ -10,10 +10,13 @@ | ||
| 10 | 10 | displayName: "List", |
| 11 | 11 | description: "List files in a directory", |
| 12 | 12 | parameters: { |
| 13 | - dirpath: { | |
| 14 | - type: "string", | |
| 15 | - description: "The path to the directory to list", | |
| 16 | - required: true, | |
| 13 | + type: "object", | |
| 14 | + required: ["dirpath"], | |
| 15 | + properties: { | |
| 16 | + dirpath: { | |
| 17 | + type: "string", | |
| 18 | + description: "The path to the directory to list", | |
| 19 | + }, | |
| 17 | 20 | }, |
| 18 | 21 | }, |
| 19 | 22 | readonly: true, |
modified extensions/cli/src/tools/multiEdit.ts +35 −14
| @@ -35,11 +35,11 @@ | ||
| 35 | 35 | This tool is ideal when you need to make multiple edits to the same file. |
| 36 | 36 | |
| 37 | 37 | To make multiple edits to a file, provide the following: |
| 38 | -1. file_path: The absolute path to the file to modify (must be absolute, not relative) | |
| 38 | +1. file_path: The absolute path to the file to modify. Relative paths can also be used (resolved against cwd) but absolute is preferred | |
| 39 | 39 | 2. edits: An array of edit operations to perform, where each edit contains: |
| 40 | 40 | - old_string: The text to replace (must match the file contents exactly, including all whitespace/indentation) |
| 41 | 41 | - new_string: The edited text to replace the old_string |
| 42 | - - replace_all: Replace all occurences of old_string. This parameter is optional and defaults to false. | |
| 42 | + - replace_all: Replace all occurrences of old_string. This parameter is optional and defaults to false. | |
| 43 | 43 | |
| 44 | 44 | IMPORTANT: |
| 45 | 45 | - All edits are applied in sequence, in the order they are provided |
| @@ -65,18 +65,39 @@ | ||
| 65 | 65 | - The tool will fail if the file does not exist - it cannot create new files |
| 66 | 66 | - This tool cannot create new files - the file must already exist`, |
| 67 | 67 | parameters: { |
| 68 | - file_path: { | |
| 69 | - type: "string", | |
| 70 | - description: "The absolute path to the file to modify", | |
| 71 | - required: true, | |
| 72 | - }, | |
| 73 | - edits: { | |
| 74 | - type: "array", | |
| 75 | - description: | |
| 76 | - "Array of edit operations to perform sequentially on the file", | |
| 77 | - required: true, | |
| 78 | - items: { | |
| 79 | - type: "object", | |
| 68 | + type: "object", | |
| 69 | + required: ["file_path", "edits"], | |
| 70 | + properties: { | |
| 71 | + file_path: { | |
| 72 | + type: "string", | |
| 73 | + description: | |
| 74 | + "Absolute or relative path to the file to modify. Absolute preferred", | |
| 75 | + }, | |
| 76 | + edits: { | |
| 77 | + type: "array", | |
| 78 | + description: | |
| 79 | + "Array of edit operations to perform sequentially on the file", | |
| 80 | + items: { | |
| 81 | + type: "object", | |
| 82 | + required: ["old_string", "new_string"], | |
| 83 | + properties: { | |
| 84 | + old_string: { | |
| 85 | + type: "string", | |
| 86 | + description: | |
| 87 | + "The text to replace (exact match including whitespace/indentation)", | |
| 88 | + }, | |
| 89 | + new_string: { | |
| 90 | + type: "string", | |
| 91 | + description: | |
| 92 | + "The text to replace it with. MUST be different than old_string.", | |
| 93 | + }, | |
| 94 | + replace_all: { | |
| 95 | + type: "boolean", | |
| 96 | + description: | |
| 97 | + "Replace all occurrences of old_string (default false) in the file", | |
| 98 | + }, | |
| 99 | + }, | |
| 100 | + }, | |
| 80 | 101 | }, |
| 81 | 102 | }, |
| 82 | 103 | }, |
modified extensions/cli/src/tools/readFile.ts +7 −4
| @@ -16,10 +16,13 @@ | ||
| 16 | 16 | displayName: "Read", |
| 17 | 17 | description: "Read the contents of a file at the specified path", |
| 18 | 18 | parameters: { |
| 19 | - filepath: { | |
| 20 | - type: "string", | |
| 21 | - description: "The path to the file to read", | |
| 22 | - required: true, | |
| 19 | + type: "object", | |
| 20 | + required: ["filepath"], | |
| 21 | + properties: { | |
| 22 | + filepath: { | |
| 23 | + type: "string", | |
| 24 | + description: "The path to the file to read", | |
| 25 | + }, | |
| 23 | 26 | }, |
| 24 | 27 | }, |
| 25 | 28 | readonly: true, |
modified extensions/cli/src/tools/runTerminalCommand.ts +7 −4
| @@ -36,10 +36,13 @@ | ||
| 36 | 36 | Commands are automatically executed from the current working directory (${process.cwd()}), so there's no need to change directories with 'cd' commands. |
| 37 | 37 | `, |
| 38 | 38 | parameters: { |
| 39 | - command: { | |
| 40 | - type: "string", | |
| 41 | - description: "The command to execute in the terminal.", | |
| 42 | - required: true, | |
| 39 | + type: "object", | |
| 40 | + required: ["command"], | |
| 41 | + properties: { | |
| 42 | + command: { | |
| 43 | + type: "string", | |
| 44 | + description: "The command to execute in the terminal.", | |
| 45 | + }, | |
| 43 | 46 | }, |
| 44 | 47 | }, |
| 45 | 48 | readonly: false, |
modified extensions/cli/src/tools/searchCode.ts +15 −14
| @@ -14,20 +14,21 @@ | ||
| 14 | 14 | displayName: "Search", |
| 15 | 15 | description: "Search the codebase using ripgrep (rg) for a specific pattern", |
| 16 | 16 | parameters: { |
| 17 | - pattern: { | |
| 18 | - type: "string", | |
| 19 | - description: "The search pattern to look for", | |
| 20 | - required: true, | |
| 21 | - }, | |
| 22 | - path: { | |
| 23 | - type: "string", | |
| 24 | - description: "The path to search in (defaults to current directory)", | |
| 25 | - required: false, | |
| 26 | - }, | |
| 27 | - file_pattern: { | |
| 28 | - type: "string", | |
| 29 | - description: "Optional file pattern to filter results (e.g., '*.ts')", | |
| 30 | - required: false, | |
| 17 | + type: "object", | |
| 18 | + required: ["pattern"], | |
| 19 | + properties: { | |
| 20 | + pattern: { | |
| 21 | + type: "string", | |
| 22 | + description: "The search pattern to look for", | |
| 23 | + }, | |
| 24 | + path: { | |
| 25 | + type: "string", | |
| 26 | + description: "The path to search in (defaults to current directory)", | |
| 27 | + }, | |
| 28 | + file_pattern: { | |
| 29 | + type: "string", | |
| 30 | + description: "Optional file pattern to filter results (e.g., '*.ts')", | |
| 31 | + }, | |
| 31 | 32 | }, |
| 32 | 33 | }, |
| 33 | 34 | readonly: true, |
modified extensions/cli/src/tools/types.ts +18 −11
| @@ -1,16 +1,23 @@ | ||
| 1 | 1 | import type { ToolPolicy } from "@continuedev/terminal-security"; |
| 2 | 2 | |
| 3 | -export type ToolParameters = Record< | |
| 4 | - string, | |
| 5 | - { | |
| 3 | +// JSON Schema compatible parameter definition | |
| 4 | +export interface ParameterSchema { | |
| 5 | + type: string; | |
| 6 | + description: string; | |
| 7 | + required?: string[]; | |
| 8 | + properties?: Record<string, ParameterSchema>; | |
| 9 | + items?: { | |
| 6 | 10 | type: string; |
| 7 | - description: string; | |
| 8 | - required: boolean; | |
| 9 | - items?: { | |
| 10 | - type: string; | |
| 11 | - }; | |
| 12 | - } | |
| 13 | ->; | |
| 11 | + properties?: Record<string, ParameterSchema>; | |
| 12 | + required?: string[]; | |
| 13 | + }; | |
| 14 | +} | |
| 15 | + | |
| 16 | +export interface ToolParametersSchema { | |
| 17 | + type: "object"; | |
| 18 | + required?: string[]; | |
| 19 | + properties: Record<string, ParameterSchema>; | |
| 20 | +} | |
| 14 | 21 | |
| 15 | 22 | export interface ToolCallPreview { |
| 16 | 23 | type: "text" | "diff" | "checklist"; |
| @@ -28,7 +35,7 @@ | ||
| 28 | 35 | name: string; |
| 29 | 36 | displayName: string; |
| 30 | 37 | description: string; |
| 31 | - parameters: ToolParameters; | |
| 38 | + parameters: ToolParametersSchema; | |
| 32 | 39 | preprocess?: (args: any) => Promise<PreprocessToolCallResult>; |
| 33 | 40 | run: (args: any) => Promise<string>; |
| 34 | 41 | readonly?: boolean; // Indicates if the tool is readonly |
modified extensions/cli/src/tools/viewDiff.ts +7 −5
| @@ -11,11 +11,13 @@ | ||
| 11 | 11 | displayName: "Diff", |
| 12 | 12 | description: "View all uncommitted changes in the git repository", |
| 13 | 13 | parameters: { |
| 14 | - path: { | |
| 15 | - type: "string", | |
| 16 | - description: | |
| 17 | - "The path to the git repository (defaults to current directory)", | |
| 18 | - required: false, | |
| 14 | + type: "object", | |
| 15 | + properties: { | |
| 16 | + path: { | |
| 17 | + type: "string", | |
| 18 | + description: | |
| 19 | + "The path to the git repository (defaults to current directory)", | |
| 20 | + }, | |
| 19 | 21 | }, |
| 20 | 22 | }, |
| 21 | 23 | readonly: true, |
modified extensions/cli/src/tools/writeChecklist.test.ts +3 −2
| @@ -16,7 +16,8 @@ | ||
| 16 | 16 | expect(writeChecklistTool.displayName).toBe("Checklist"); |
| 17 | 17 | expect(writeChecklistTool.readonly).toBe(false); |
| 18 | 18 | expect(writeChecklistTool.isBuiltIn).toBe(true); |
| 19 | - expect(writeChecklistTool.parameters.checklist.required).toBe(true); | |
| 20 | - expect(writeChecklistTool.parameters.checklist.type).toBe("string"); | |
| 19 | + expect(writeChecklistTool.parameters.required?.includes("checklist")).toBe( | |
| 20 | + true, | |
| 21 | + ); | |
| 21 | 22 | }); |
| 22 | 23 | }); |
modified extensions/cli/src/tools/writeChecklist.ts +8 −5
| @@ -8,11 +8,14 @@ | ||
| 8 | 8 | readonly: false, |
| 9 | 9 | isBuiltIn: true, |
| 10 | 10 | parameters: { |
| 11 | - checklist: { | |
| 12 | - type: "string", | |
| 13 | - description: | |
| 14 | - "The complete checklist in markdown format using - [ ] for incomplete tasks and - [x] for completed tasks. Avoid headers and additional content unless specifically being used to group checkboxes. Try to keep the list short, and make each item specific and actionable.", | |
| 15 | - required: true, | |
| 11 | + type: "object", | |
| 12 | + required: ["checklist"], | |
| 13 | + properties: { | |
| 14 | + checklist: { | |
| 15 | + type: "string", | |
| 16 | + description: | |
| 17 | + "The complete checklist in markdown format using - [ ] for incomplete tasks and - [x] for completed tasks. Avoid headers and additional content unless specifically being used to group checkboxes. Try to keep the list short, and make each item specific and actionable.", | |
| 18 | + }, | |
| 16 | 19 | }, |
| 17 | 20 | }, |
| 18 | 21 | preprocess: async (args: { checklist: string }) => { |
modified extensions/cli/src/tools/writeFile.ts +11 −9
| @@ -32,15 +32,17 @@ | ||
| 32 | 32 | displayName: "Write", |
| 33 | 33 | description: "Write content to a file at the specified path", |
| 34 | 34 | parameters: { |
| 35 | - filepath: { | |
| 36 | - type: "string", | |
| 37 | - description: "The path to the file to write", | |
| 38 | - required: true, | |
| 39 | - }, | |
| 40 | - content: { | |
| 41 | - type: "string", | |
| 42 | - description: "The content to write to the file", | |
| 43 | - required: true, | |
| 35 | + type: "object", | |
| 36 | + required: ["filepath", "content"], | |
| 37 | + properties: { | |
| 38 | + filepath: { | |
| 39 | + type: "string", | |
| 40 | + description: "The path to the file to write", | |
| 41 | + }, | |
| 42 | + content: { | |
| 43 | + type: "string", | |
| 44 | + description: "The content to write to the file", | |
| 45 | + }, | |
| 44 | 46 | }, |
| 45 | 47 | }, |
| 46 | 48 | readonly: false, |