mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
insert_code_block -> insert_content
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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">>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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.",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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) => getInsertCodeBlockDescription(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 }) : "",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ToolArgs } from "./types"
|
import { ToolArgs } from "./types"
|
||||||
|
|
||||||
export function getInsertCodeBlockDescription(args: ToolArgs): string {
|
export function getInsertCodeBlockDescription(args: ToolArgs): string {
|
||||||
return `## insert_code_block
|
return `## insert_content
|
||||||
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.
|
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:
|
Parameters:
|
||||||
- path: (required) The path of the file to insert code into (relative to the current working directory ${args.cwd.toPosix()})
|
- path: (required) The path of the file to insert code into (relative to the current working directory ${args.cwd.toPosix()})
|
||||||
@@ -9,7 +9,7 @@ Parameters:
|
|||||||
* 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.
|
* 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.
|
* 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:
|
Usage:
|
||||||
<insert_code_block>
|
<insert_content>
|
||||||
<path>File path here</path>
|
<path>File path here</path>
|
||||||
<operations>[
|
<operations>[
|
||||||
{
|
{
|
||||||
@@ -17,9 +17,9 @@ Usage:
|
|||||||
"content": "Your code block here"
|
"content": "Your code block here"
|
||||||
}
|
}
|
||||||
]</operations>
|
]</operations>
|
||||||
</insert_code_block>
|
</insert_content>
|
||||||
Example: Insert a new function and its import statement
|
Example: Insert a new function and its import statement
|
||||||
<insert_code_block>
|
<insert_content>
|
||||||
<path>src/app.ts</path>
|
<path>src/app.ts</path>
|
||||||
<operations>[
|
<operations>[
|
||||||
{
|
{
|
||||||
@@ -31,5 +31,5 @@ Example: Insert a new function and its import statement
|
|||||||
"content": "function calculateTotal(items: number[]): number {\n return items.reduce((sum, item) => sum + item, 0);\n}"
|
"content": "function calculateTotal(items: number[]): number {\n return items.reduce((sum, item) => sum + item, 0);\n}"
|
||||||
}
|
}
|
||||||
]</operations>
|
]</operations>
|
||||||
</insert_code_block>`
|
</insert_content>`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"],
|
||||||
|
|||||||
Reference in New Issue
Block a user