Merge pull request #624 from RooVetGit/v3.3.5

V3.3.5
This commit is contained in:
Matt Rubens
2025-01-28 15:32:14 -05:00
committed by GitHub
11 changed files with 67 additions and 78 deletions

View File

@@ -0,0 +1,5 @@
---
"roo-cline": patch
---
v3.3.5

View File

@@ -1010,7 +1010,7 @@ export class Cline {
return `[${block.name} for '${block.params.regex}'${ return `[${block.name} for '${block.params.regex}'${
block.params.file_pattern ? ` in '${block.params.file_pattern}'` : "" block.params.file_pattern ? ` in '${block.params.file_pattern}'` : ""
}]` }]`
case "insert_code_block": case "insert_content":
return `[${block.name} for '${block.params.path}']` return `[${block.name} for '${block.params.path}']`
case "search_and_replace": case "search_and_replace":
return `[${block.name} for '${block.params.path}']` return `[${block.name} for '${block.params.path}']`
@@ -1486,7 +1486,7 @@ export class Cline {
} }
} }
case "insert_code_block": { case "insert_content": {
const relPath: string | undefined = block.params.path const relPath: string | undefined = block.params.path
const operations: string | undefined = block.params.operations const operations: string | undefined = block.params.operations
@@ -1505,15 +1505,13 @@ export class Cline {
// Validate required parameters // Validate required parameters
if (!relPath) { if (!relPath) {
this.consecutiveMistakeCount++ this.consecutiveMistakeCount++
pushToolResult(await this.sayAndCreateMissingParamError("insert_code_block", "path")) pushToolResult(await this.sayAndCreateMissingParamError("insert_content", "path"))
break break
} }
if (!operations) { if (!operations) {
this.consecutiveMistakeCount++ this.consecutiveMistakeCount++
pushToolResult( pushToolResult(await this.sayAndCreateMissingParamError("insert_content", "operations"))
await this.sayAndCreateMissingParamError("insert_code_block", "operations"),
)
break break
} }
@@ -1603,7 +1601,7 @@ export class Cline {
if (!userEdits) { if (!userEdits) {
pushToolResult( pushToolResult(
`The code block was successfully inserted in ${relPath.toPosix()}.${newProblemsMessage}`, `The content was successfully inserted in ${relPath.toPosix()}.${newProblemsMessage}`,
) )
await this.diffViewProvider.reset() await this.diffViewProvider.reset()
break break
@@ -1629,7 +1627,7 @@ export class Cline {
) )
await this.diffViewProvider.reset() await this.diffViewProvider.reset()
} catch (error) { } catch (error) {
handleError("insert block", error) handleError("insert content", error)
await this.diffViewProvider.reset() await this.diffViewProvider.reset()
} }
break break

View File

@@ -13,7 +13,7 @@ export const toolUseNames = [
"read_file", "read_file",
"write_to_file", "write_to_file",
"apply_diff", "apply_diff",
"insert_code_block", "insert_content",
"search_and_replace", "search_and_replace",
"search_files", "search_files",
"list_files", "list_files",
@@ -82,7 +82,7 @@ export interface WriteToFileToolUse extends ToolUse {
} }
export interface InsertCodeBlockToolUse extends ToolUse { export interface InsertCodeBlockToolUse extends ToolUse {
name: "insert_code_block" name: "insert_content"
params: Partial<Pick<Record<ToolParamName, string>, "path" | "operations">> params: Partial<Pick<Record<ToolParamName, string>, "path" | "operations">>
} }

View File

@@ -544,7 +544,7 @@ describe("SYSTEM_PROMPT", () => {
// Verify base instruction lists all available tools // Verify base instruction lists all available tools
expect(prompt).toContain("apply_diff (for replacing lines in existing files)") expect(prompt).toContain("apply_diff (for replacing lines in existing files)")
expect(prompt).toContain("write_to_file (for creating new files or complete file rewrites)") expect(prompt).toContain("write_to_file (for creating new files or complete file rewrites)")
expect(prompt).toContain("insert_code_block (for adding sections to existing files)") expect(prompt).toContain("insert_content (for adding lines to existing files)")
expect(prompt).toContain("search_and_replace (for finding and replacing individual pieces of text)") expect(prompt).toContain("search_and_replace (for finding and replacing individual pieces of text)")
}) })
@@ -574,7 +574,7 @@ describe("SYSTEM_PROMPT", () => {
expect(prompt).toContain( expect(prompt).toContain(
"You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files.", "You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files.",
) )
expect(prompt).toContain("The insert_code_block tool adds code snippets or content blocks to files") expect(prompt).toContain("The insert_content tool adds lines of text to files")
expect(prompt).toContain("The search_and_replace tool finds and replaces text or regex in files") expect(prompt).toContain("The search_and_replace tool finds and replaces text or regex in files")
}) })
}) })

View File

@@ -11,8 +11,8 @@ function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Recor
if (diffStrategy) { if (diffStrategy) {
availableTools.push("apply_diff (for replacing lines in existing files)") availableTools.push("apply_diff (for replacing lines in existing files)")
} }
if (experiments?.["insert_code_block"]) { if (experiments?.["insert_content"]) {
availableTools.push("insert_code_block (for adding sections to existing files)") availableTools.push("insert_content (for adding lines to existing files)")
} }
if (experiments?.["search_and_replace"]) { if (experiments?.["search_and_replace"]) {
availableTools.push("search_and_replace (for finding and replacing individual pieces of text)") availableTools.push("search_and_replace (for finding and replacing individual pieces of text)")
@@ -24,9 +24,9 @@ function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Recor
} }
// Additional details for experimental features // Additional details for experimental features
if (experiments?.["insert_code_block"]) { if (experiments?.["insert_content"]) {
instructions.push( instructions.push(
"- The insert_code_block tool adds code snippets or content blocks to files, such as adding a new function to a JavaScript file or inserting a new route in a Python file. This tool will insert it at the specified line location. It can support multiple operations at once.", "- The insert_content tool adds lines of text to files, such as adding a new function to a JavaScript file or inserting a new route in a Python file. This tool will insert it at the specified line location. It can support multiple operations at once.",
) )
} }

View File

@@ -3,7 +3,7 @@ import { getReadFileDescription } from "./read-file"
import { getWriteToFileDescription } from "./write-to-file" import { getWriteToFileDescription } from "./write-to-file"
import { getSearchFilesDescription } from "./search-files" import { getSearchFilesDescription } from "./search-files"
import { getListFilesDescription } from "./list-files" import { getListFilesDescription } from "./list-files"
import { getInsertCodeBlockDescription } from "./insert-code-block" import { getInsertContentDescription } from "./insert-content"
import { getSearchAndReplaceDescription } from "./search-and-replace" import { getSearchAndReplaceDescription } from "./search-and-replace"
import { getListCodeDefinitionNamesDescription } from "./list-code-definition-names" import { getListCodeDefinitionNamesDescription } from "./list-code-definition-names"
import { getBrowserActionDescription } from "./browser-action" import { getBrowserActionDescription } from "./browser-action"
@@ -15,7 +15,7 @@ import { getSwitchModeDescription } from "./switch-mode"
import { DiffStrategy } from "../../diff/DiffStrategy" import { DiffStrategy } from "../../diff/DiffStrategy"
import { McpHub } from "../../../services/mcp/McpHub" import { McpHub } from "../../../services/mcp/McpHub"
import { Mode, ModeConfig, getModeConfig, isToolAllowedForMode, getGroupName } from "../../../shared/modes" import { Mode, ModeConfig, getModeConfig, isToolAllowedForMode, getGroupName } from "../../../shared/modes"
import { ToolName, getToolName, getToolOptions, TOOL_GROUPS, ALWAYS_AVAILABLE_TOOLS } from "../../../shared/tool-groups" import { ToolName, TOOL_GROUPS, ALWAYS_AVAILABLE_TOOLS } from "../../../shared/tool-groups"
import { ToolArgs } from "./types" import { ToolArgs } from "./types"
// Map of tool names to their description functions // Map of tool names to their description functions
@@ -32,7 +32,7 @@ const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined>
use_mcp_tool: (args) => getUseMcpToolDescription(args), use_mcp_tool: (args) => getUseMcpToolDescription(args),
access_mcp_resource: (args) => getAccessMcpResourceDescription(args), access_mcp_resource: (args) => getAccessMcpResourceDescription(args),
switch_mode: () => getSwitchModeDescription(), switch_mode: () => getSwitchModeDescription(),
insert_code_block: (args) => getInsertCodeBlockDescription(args), insert_content: (args) => getInsertContentDescription(args),
search_and_replace: (args) => getSearchAndReplaceDescription(args), search_and_replace: (args) => getSearchAndReplaceDescription(args),
apply_diff: (args) => apply_diff: (args) =>
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "", args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
@@ -105,6 +105,6 @@ export {
getUseMcpToolDescription, getUseMcpToolDescription,
getAccessMcpResourceDescription, getAccessMcpResourceDescription,
getSwitchModeDescription, getSwitchModeDescription,
getInsertCodeBlockDescription, getInsertContentDescription,
getSearchAndReplaceDescription, getSearchAndReplaceDescription,
} }

View File

@@ -1,35 +0,0 @@
import { ToolArgs } from "./types"
export function getInsertCodeBlockDescription(args: ToolArgs): string {
return `## insert_code_block
Description: Inserts code blocks at specific line positions in a file. This is the primary tool for adding new code (functions/methods/classes, imports, attributes etc.) as it allows for precise insertions without overwriting existing content. The tool uses an efficient line-based insertion system that maintains file integrity and proper ordering of multiple insertions. Beware to use the proper indentation. This tool is the preferred way to add new code to files.
Parameters:
- path: (required) The path of the file to insert code into (relative to the current working directory ${args.cwd.toPosix()})
- operations: (required) A JSON array of insertion operations. Each operation is an object with:
* start_line: (required) The line number where the code block should be inserted. The content currently at that line will end up below the inserted code block.
* content: (required) The code block to insert at the specified position. IMPORTANT NOTE: If the content is a single line, it can be a string. If it's a multi-line content, it should be a string with newline characters (\n) for line breaks.
Usage:
<insert_code_block>
<path>File path here</path>
<operations>[
{
"start_line": 10,
"content": "Your code block here"
}
]</operations>
</insert_code_block>
Example: Insert a new function and its import statement
<insert_code_block>
<path>src/app.ts</path>
<operations>[
{
"start_line": 1,
"content": "import { sum } from './utils';"
},
{
"start_line": 10,
"content": "function calculateTotal(items: number[]): number {\n return items.reduce((sum, item) => sum + item, 0);\n}"
}
]</operations>
</insert_code_block>`
}

View File

@@ -0,0 +1,35 @@
import { ToolArgs } from "./types"
export function getInsertContentDescription(args: ToolArgs): string {
return `## insert_content
Description: Inserts content at specific line positions in a file. This is the primary tool for adding new content and code (functions/methods/classes, imports, attributes etc.) as it allows for precise insertions without overwriting existing content. The tool uses an efficient line-based insertion system that maintains file integrity and proper ordering of multiple insertions. Beware to use the proper indentation. This tool is the preferred way to add new content and code to files.
Parameters:
- path: (required) The path of the file to insert content into (relative to the current working directory ${args.cwd.toPosix()})
- operations: (required) A JSON array of insertion operations. Each operation is an object with:
* start_line: (required) The line number where the content should be inserted. The content currently at that line will end up below the inserted content.
* content: (required) The content to insert at the specified position. IMPORTANT NOTE: If the content is a single line, it can be a string. If it's a multi-line content, it should be a string with newline characters (\n) for line breaks. Make sure to include the correct indentation for the content.
Usage:
<insert_content>
<path>File path here</path>
<operations>[
{
"start_line": 10,
"content": "Your content here"
}
]</operations>
</insert_content>
Example: Insert a new function and its import statement
<insert_content>
<path>File path here</path>
<operations>[
{
"start_line": 1,
"content": "import { sum } from './utils';"
},
{
"start_line": 10,
"content": "function calculateTotal(items: number[]): number {\n return items.reduce((sum, item) => sum + item, 0);\n}"
}
]</operations>
</insert_content>`
}

View File

@@ -251,7 +251,7 @@ describe("isToolAllowedForMode", () => {
it("disables tools when experiment is disabled", () => { it("disables tools when experiment is disabled", () => {
const experiments = { const experiments = {
search_and_replace: false, search_and_replace: false,
insert_code_block: false, insert_content: false,
} }
expect( expect(
@@ -266,21 +266,14 @@ describe("isToolAllowedForMode", () => {
).toBe(false) ).toBe(false)
expect( expect(
isToolAllowedForMode( isToolAllowedForMode("insert_content", "test-exp-mode", customModes, undefined, undefined, experiments),
"insert_code_block",
"test-exp-mode",
customModes,
undefined,
undefined,
experiments,
),
).toBe(false) ).toBe(false)
}) })
it("allows tools when experiment is enabled", () => { it("allows tools when experiment is enabled", () => {
const experiments = { const experiments = {
search_and_replace: true, search_and_replace: true,
insert_code_block: true, insert_content: true,
} }
expect( expect(
@@ -295,21 +288,14 @@ describe("isToolAllowedForMode", () => {
).toBe(true) ).toBe(true)
expect( expect(
isToolAllowedForMode( isToolAllowedForMode("insert_content", "test-exp-mode", customModes, undefined, undefined, experiments),
"insert_code_block",
"test-exp-mode",
customModes,
undefined,
undefined,
experiments,
),
).toBe(true) ).toBe(true)
}) })
it("allows non-experimental tools when experiments are disabled", () => { it("allows non-experimental tools when experiments are disabled", () => {
const experiments = { const experiments = {
search_and_replace: false, search_and_replace: false,
insert_code_block: false, insert_content: false,
} }
expect( expect(

View File

@@ -1,7 +1,7 @@
export const EXPERIMENT_IDS = { export const EXPERIMENT_IDS = {
DIFF_STRATEGY: "experimentalDiffStrategy", DIFF_STRATEGY: "experimentalDiffStrategy",
SEARCH_AND_REPLACE: "search_and_replace", SEARCH_AND_REPLACE: "search_and_replace",
INSERT_BLOCK: "insert_code_block", INSERT_BLOCK: "insert_content",
} as const } as const
export type ExperimentKey = keyof typeof EXPERIMENT_IDS export type ExperimentKey = keyof typeof EXPERIMENT_IDS
@@ -29,10 +29,10 @@ export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
enabled: false, enabled: false,
}, },
INSERT_BLOCK: { INSERT_BLOCK: {
name: "Use experimental insert block tool", name: "Use experimental insert content tool",
description: description:
"Enable the experimental insert block tool, allowing Roo to insert multiple code blocks at once at specific line numbers without needing to create a diff.", "Enable the experimental insert content tool, allowing Roo to insert content at specific line numbers without needing to create a diff.",
enabled: false, enabled: false,
}, },
} }

View File

@@ -21,7 +21,7 @@ export const TOOL_DISPLAY_NAMES = {
// Define available tool groups // Define available tool groups
export const TOOL_GROUPS: Record<string, ToolGroupValues> = { export const TOOL_GROUPS: Record<string, ToolGroupValues> = {
read: ["read_file", "search_files", "list_files", "list_code_definition_names"], read: ["read_file", "search_files", "list_files", "list_code_definition_names"],
edit: ["write_to_file", "apply_diff", "insert_code_block", "search_and_replace"], edit: ["write_to_file", "apply_diff", "insert_content", "search_and_replace"],
browser: ["browser_action"], browser: ["browser_action"],
command: ["execute_command"], command: ["execute_command"],
mcp: ["use_mcp_tool", "access_mcp_resource"], mcp: ["use_mcp_tool", "access_mcp_resource"],