Skip to content

Commit 9056a59

Browse files
authored
Merge pull request #624 from RooVetGit/v3.3.5
V3.3.5
2 parents 6dc1a03 + 93f43be commit 9056a59

File tree

11 files changed

+67
-78
lines changed

11 files changed

+67
-78
lines changed

.changeset/khaki-zoos-share.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
v3.3.5

src/core/Cline.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ export class Cline {
10101010
return `[${block.name} for '${block.params.regex}'${
10111011
block.params.file_pattern ? ` in '${block.params.file_pattern}'` : ""
10121012
}]`
1013-
case "insert_code_block":
1013+
case "insert_content":
10141014
return `[${block.name} for '${block.params.path}']`
10151015
case "search_and_replace":
10161016
return `[${block.name} for '${block.params.path}']`
@@ -1486,7 +1486,7 @@ export class Cline {
14861486
}
14871487
}
14881488

1489-
case "insert_code_block": {
1489+
case "insert_content": {
14901490
const relPath: string | undefined = block.params.path
14911491
const operations: string | undefined = block.params.operations
14921492

@@ -1505,15 +1505,13 @@ export class Cline {
15051505
// Validate required parameters
15061506
if (!relPath) {
15071507
this.consecutiveMistakeCount++
1508-
pushToolResult(await this.sayAndCreateMissingParamError("insert_code_block", "path"))
1508+
pushToolResult(await this.sayAndCreateMissingParamError("insert_content", "path"))
15091509
break
15101510
}
15111511

15121512
if (!operations) {
15131513
this.consecutiveMistakeCount++
1514-
pushToolResult(
1515-
await this.sayAndCreateMissingParamError("insert_code_block", "operations"),
1516-
)
1514+
pushToolResult(await this.sayAndCreateMissingParamError("insert_content", "operations"))
15171515
break
15181516
}
15191517

@@ -1603,7 +1601,7 @@ export class Cline {
16031601

16041602
if (!userEdits) {
16051603
pushToolResult(
1606-
`The code block was successfully inserted in ${relPath.toPosix()}.${newProblemsMessage}`,
1604+
`The content was successfully inserted in ${relPath.toPosix()}.${newProblemsMessage}`,
16071605
)
16081606
await this.diffViewProvider.reset()
16091607
break
@@ -1629,7 +1627,7 @@ export class Cline {
16291627
)
16301628
await this.diffViewProvider.reset()
16311629
} catch (error) {
1632-
handleError("insert block", error)
1630+
handleError("insert content", error)
16331631
await this.diffViewProvider.reset()
16341632
}
16351633
break

src/core/assistant-message/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const toolUseNames = [
1313
"read_file",
1414
"write_to_file",
1515
"apply_diff",
16-
"insert_code_block",
16+
"insert_content",
1717
"search_and_replace",
1818
"search_files",
1919
"list_files",
@@ -82,7 +82,7 @@ export interface WriteToFileToolUse extends ToolUse {
8282
}
8383

8484
export interface InsertCodeBlockToolUse extends ToolUse {
85-
name: "insert_code_block"
85+
name: "insert_content"
8686
params: Partial<Pick<Record<ToolParamName, string>, "path" | "operations">>
8787
}
8888

src/core/prompts/__tests__/system.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ describe("SYSTEM_PROMPT", () => {
544544
// Verify base instruction lists all available tools
545545
expect(prompt).toContain("apply_diff (for replacing lines in existing files)")
546546
expect(prompt).toContain("write_to_file (for creating new files or complete file rewrites)")
547-
expect(prompt).toContain("insert_code_block (for adding sections to existing files)")
547+
expect(prompt).toContain("insert_content (for adding lines to existing files)")
548548
expect(prompt).toContain("search_and_replace (for finding and replacing individual pieces of text)")
549549
})
550550

@@ -574,7 +574,7 @@ describe("SYSTEM_PROMPT", () => {
574574
expect(prompt).toContain(
575575
"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.",
576576
)
577-
expect(prompt).toContain("The insert_code_block tool adds code snippets or content blocks to files")
577+
expect(prompt).toContain("The insert_content tool adds lines of text to files")
578578
expect(prompt).toContain("The search_and_replace tool finds and replaces text or regex in files")
579579
})
580580
})

src/core/prompts/sections/rules.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Recor
1111
if (diffStrategy) {
1212
availableTools.push("apply_diff (for replacing lines in existing files)")
1313
}
14-
if (experiments?.["insert_code_block"]) {
15-
availableTools.push("insert_code_block (for adding sections to existing files)")
14+
if (experiments?.["insert_content"]) {
15+
availableTools.push("insert_content (for adding lines to existing files)")
1616
}
1717
if (experiments?.["search_and_replace"]) {
1818
availableTools.push("search_and_replace (for finding and replacing individual pieces of text)")
@@ -24,9 +24,9 @@ function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Recor
2424
}
2525

2626
// Additional details for experimental features
27-
if (experiments?.["insert_code_block"]) {
27+
if (experiments?.["insert_content"]) {
2828
instructions.push(
29-
"- 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.",
29+
"- 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.",
3030
)
3131
}
3232

src/core/prompts/tools/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getReadFileDescription } from "./read-file"
33
import { getWriteToFileDescription } from "./write-to-file"
44
import { getSearchFilesDescription } from "./search-files"
55
import { getListFilesDescription } from "./list-files"
6-
import { getInsertCodeBlockDescription } from "./insert-code-block"
6+
import { getInsertContentDescription } from "./insert-content"
77
import { getSearchAndReplaceDescription } from "./search-and-replace"
88
import { getListCodeDefinitionNamesDescription } from "./list-code-definition-names"
99
import { getBrowserActionDescription } from "./browser-action"
@@ -15,7 +15,7 @@ import { getSwitchModeDescription } from "./switch-mode"
1515
import { DiffStrategy } from "../../diff/DiffStrategy"
1616
import { McpHub } from "../../../services/mcp/McpHub"
1717
import { Mode, ModeConfig, getModeConfig, isToolAllowedForMode, getGroupName } from "../../../shared/modes"
18-
import { ToolName, getToolName, getToolOptions, TOOL_GROUPS, ALWAYS_AVAILABLE_TOOLS } from "../../../shared/tool-groups"
18+
import { ToolName, TOOL_GROUPS, ALWAYS_AVAILABLE_TOOLS } from "../../../shared/tool-groups"
1919
import { ToolArgs } from "./types"
2020

2121
// Map of tool names to their description functions
@@ -32,7 +32,7 @@ const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined>
3232
use_mcp_tool: (args) => getUseMcpToolDescription(args),
3333
access_mcp_resource: (args) => getAccessMcpResourceDescription(args),
3434
switch_mode: () => getSwitchModeDescription(),
35-
insert_code_block: (args) => getInsertCodeBlockDescription(args),
35+
insert_content: (args) => getInsertContentDescription(args),
3636
search_and_replace: (args) => getSearchAndReplaceDescription(args),
3737
apply_diff: (args) =>
3838
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
@@ -105,6 +105,6 @@ export {
105105
getUseMcpToolDescription,
106106
getAccessMcpResourceDescription,
107107
getSwitchModeDescription,
108-
getInsertCodeBlockDescription,
108+
getInsertContentDescription,
109109
getSearchAndReplaceDescription,
110110
}

src/core/prompts/tools/insert-code-block.ts

-35
This file was deleted.
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { ToolArgs } from "./types"
2+
3+
export function getInsertContentDescription(args: ToolArgs): string {
4+
return `## insert_content
5+
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.
6+
Parameters:
7+
- path: (required) The path of the file to insert content into (relative to the current working directory ${args.cwd.toPosix()})
8+
- operations: (required) A JSON array of insertion operations. Each operation is an object with:
9+
* 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.
10+
* 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.
11+
Usage:
12+
<insert_content>
13+
<path>File path here</path>
14+
<operations>[
15+
{
16+
"start_line": 10,
17+
"content": "Your content here"
18+
}
19+
]</operations>
20+
</insert_content>
21+
Example: Insert a new function and its import statement
22+
<insert_content>
23+
<path>File path here</path>
24+
<operations>[
25+
{
26+
"start_line": 1,
27+
"content": "import { sum } from './utils';"
28+
},
29+
{
30+
"start_line": 10,
31+
"content": "function calculateTotal(items: number[]): number {\n return items.reduce((sum, item) => sum + item, 0);\n}"
32+
}
33+
]</operations>
34+
</insert_content>`
35+
}

src/shared/__tests__/modes.test.ts

+5-19
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe("isToolAllowedForMode", () => {
251251
it("disables tools when experiment is disabled", () => {
252252
const experiments = {
253253
search_and_replace: false,
254-
insert_code_block: false,
254+
insert_content: false,
255255
}
256256

257257
expect(
@@ -266,21 +266,14 @@ describe("isToolAllowedForMode", () => {
266266
).toBe(false)
267267

268268
expect(
269-
isToolAllowedForMode(
270-
"insert_code_block",
271-
"test-exp-mode",
272-
customModes,
273-
undefined,
274-
undefined,
275-
experiments,
276-
),
269+
isToolAllowedForMode("insert_content", "test-exp-mode", customModes, undefined, undefined, experiments),
277270
).toBe(false)
278271
})
279272

280273
it("allows tools when experiment is enabled", () => {
281274
const experiments = {
282275
search_and_replace: true,
283-
insert_code_block: true,
276+
insert_content: true,
284277
}
285278

286279
expect(
@@ -295,21 +288,14 @@ describe("isToolAllowedForMode", () => {
295288
).toBe(true)
296289

297290
expect(
298-
isToolAllowedForMode(
299-
"insert_code_block",
300-
"test-exp-mode",
301-
customModes,
302-
undefined,
303-
undefined,
304-
experiments,
305-
),
291+
isToolAllowedForMode("insert_content", "test-exp-mode", customModes, undefined, undefined, experiments),
306292
).toBe(true)
307293
})
308294

309295
it("allows non-experimental tools when experiments are disabled", () => {
310296
const experiments = {
311297
search_and_replace: false,
312-
insert_code_block: false,
298+
insert_content: false,
313299
}
314300

315301
expect(

src/shared/experiments.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const EXPERIMENT_IDS = {
22
DIFF_STRATEGY: "experimentalDiffStrategy",
33
SEARCH_AND_REPLACE: "search_and_replace",
4-
INSERT_BLOCK: "insert_code_block",
4+
INSERT_BLOCK: "insert_content",
55
} as const
66

77
export type ExperimentKey = keyof typeof EXPERIMENT_IDS
@@ -29,10 +29,10 @@ export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
2929
enabled: false,
3030
},
3131
INSERT_BLOCK: {
32-
name: "Use experimental insert block tool",
32+
name: "Use experimental insert content tool",
3333

3434
description:
35-
"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.",
35+
"Enable the experimental insert content tool, allowing Roo to insert content at specific line numbers without needing to create a diff.",
3636
enabled: false,
3737
},
3838
}

src/shared/tool-groups.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const TOOL_DISPLAY_NAMES = {
2121
// Define available tool groups
2222
export const TOOL_GROUPS: Record<string, ToolGroupValues> = {
2323
read: ["read_file", "search_files", "list_files", "list_code_definition_names"],
24-
edit: ["write_to_file", "apply_diff", "insert_code_block", "search_and_replace"],
24+
edit: ["write_to_file", "apply_diff", "insert_content", "search_and_replace"],
2525
browser: ["browser_action"],
2626
command: ["execute_command"],
2727
mcp: ["use_mcp_tool", "access_mcp_resource"],

0 commit comments

Comments
 (0)