From 39715f13e1f7078f11701d52a2a1d23fba8a93ea Mon Sep 17 00:00:00 2001
From: Catalin Lupuleti
Date: Mon, 24 Feb 2025 19:05:05 +0000
Subject: [PATCH 001/145] Added support for Claude sonnet 3.7 via VertexAI
---
src/shared/api.ts | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 9ecb12c1403..5bcf60138ef 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -396,6 +396,15 @@ export const openRouterDefaultModelInfo: ModelInfo = {
export type VertexModelId = keyof typeof vertexModels
export const vertexDefaultModelId: VertexModelId = "claude-3-5-sonnet-v2@20241022"
export const vertexModels = {
+ "claude-3-7-sonnet@20250219": {
+ maxTokens: 8192,
+ contextWindow: 200_000,
+ supportsImages: true,
+ supportsComputerUse: true,
+ supportsPromptCache: false,
+ inputPrice: 3.0,
+ outputPrice: 15.0,
+ },
"claude-3-5-sonnet-v2@20241022": {
maxTokens: 8192,
contextWindow: 200_000,
From 92ac610366ca4c21e3d237325c8bf3239888b30d Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 11:14:08 -0800
Subject: [PATCH 002/145] Add Claude 3.7
---
src/api/providers/anthropic.ts | 2 ++
src/api/providers/openrouter.ts | 1 +
src/shared/api.ts | 11 +++++++++++
3 files changed, 14 insertions(+)
diff --git a/src/api/providers/anthropic.ts b/src/api/providers/anthropic.ts
index 9a14756f5d2..4c62238f461 100644
--- a/src/api/providers/anthropic.ts
+++ b/src/api/providers/anthropic.ts
@@ -27,8 +27,10 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
let stream: AnthropicStream
const modelId = this.getModel().id
+
switch (modelId) {
// 'latest' alias does not support cache_control
+ case "claude-3-7-sonnet-20250219":
case "claude-3-5-sonnet-20241022":
case "claude-3-5-haiku-20241022":
case "claude-3-opus-20240229":
diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts
index 1fcf25260ef..af087226ebd 100644
--- a/src/api/providers/openrouter.ts
+++ b/src/api/providers/openrouter.ts
@@ -55,6 +55,7 @@ export class OpenRouterHandler implements ApiHandler, SingleCompletionHandler {
// prompt caching: https://openrouter.ai/docs/prompt-caching
// this is specifically for claude models (some models may 'support prompt caching' automatically without this)
switch (this.getModel().id) {
+ case "anthropic/claude-3.7-sonnet":
case "anthropic/claude-3.5-sonnet":
case "anthropic/claude-3.5-sonnet:beta":
case "anthropic/claude-3.5-sonnet-20240620":
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 9ecb12c1403..3598eb16ac9 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -95,6 +95,17 @@ export interface ModelInfo {
export type AnthropicModelId = keyof typeof anthropicModels
export const anthropicDefaultModelId: AnthropicModelId = "claude-3-5-sonnet-20241022"
export const anthropicModels = {
+ "claude-3-7-sonnet-20250219": {
+ maxTokens: 128_000,
+ contextWindow: 200_000,
+ supportsImages: true,
+ supportsComputerUse: true,
+ supportsPromptCache: true,
+ inputPrice: 3.0, // $3 per million input tokens
+ outputPrice: 15.0, // $15 per million output tokens
+ cacheWritesPrice: 3.75, // $3.75 per million tokens
+ cacheReadsPrice: 0.3, // $0.30 per million tokens
+ },
"claude-3-5-sonnet-20241022": {
maxTokens: 8192,
contextWindow: 200_000,
From 08aa911e138a771d54f16a443074ca635f68bf90 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 13:25:33 -0600
Subject: [PATCH 003/145] Revert "Merge pull request #1125 from
hannesrudolph/change_order_apply_diff"
This reverts commit dddac90721719c5e54100e80205e30f3a4738b96, reversing
changes made to 1c9dcaddc417b3ce48c2c39bf7ecc8484e1aa063.
---
CHANGELOG.md | 2 +-
src/core/Cline.ts | 34 +--
src/core/__tests__/mode-validator.test.ts | 40 +--
src/core/assistant-message/index.ts | 6 +-
.../parse-assistant-message.ts | 4 +-
.../strategies/__tests__/new-unified.test.ts | 2 +-
.../__tests__/search-replace.test.ts | 4 +-
.../diff/strategies/__tests__/unified.test.ts | 2 +-
src/core/diff/strategies/new-unified/index.ts | 6 +-
src/core/diff/strategies/search-replace.ts | 6 +-
src/core/diff/strategies/unified.ts | 6 +-
.../__snapshots__/system.test.ts.snap | 284 +++++++++---------
src/core/prompts/__tests__/sections.test.ts | 16 +-
src/core/prompts/__tests__/system.test.ts | 12 +-
src/core/prompts/sections/capabilities.ts | 2 +-
src/core/prompts/sections/mcp-servers.ts | 2 +-
src/core/prompts/sections/modes.ts | 2 +-
src/core/prompts/sections/rules.ts | 23 +-
src/core/prompts/tools/index.ts | 4 +-
src/core/prompts/tools/write-to-file.ts | 10 +-
.../webview/__tests__/ClineProvider.test.ts | 2 +-
src/shared/ExtensionMessage.ts | 2 +-
src/shared/__tests__/modes.test.ts | 66 ++--
src/shared/tool-groups.ts | 6 +-
24 files changed, 269 insertions(+), 274 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff8cfdc3e85..748f8c78f88 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -479,7 +479,7 @@ Join us at https://www.reddit.com/r/RooCode to share your custom modes and be pa
## [2.1.14]
- Fix bug where diffs were not being applied correctly and try Aider's [unified diff prompt](https://github.com/Aider-AI/aider/blob/3995accd0ca71cea90ef76d516837f8c2731b9fe/aider/coders/udiff_prompts.py#L75-L105)
-- If diffs are enabled, automatically reject create_file commands that lead to truncated output
+- If diffs are enabled, automatically reject write_to_file commands that lead to truncated output
## [2.1.13]
diff --git a/src/core/Cline.ts b/src/core/Cline.ts
index 522af873274..12cf062406b 100644
--- a/src/core/Cline.ts
+++ b/src/core/Cline.ts
@@ -733,7 +733,7 @@ export class Cline {
text:
`[TASK RESUMPTION] This task was interrupted ${agoText}. It may or may not be complete, so please reassess the task context. Be aware that the project state may have changed since then. The current working directory is now '${cwd.toPosix()}'. If the task has not been completed, retry the last step before interruption and proceed with completing the task.\n\nNote: If you previously attempted a tool use that the user did not provide a result for, you should assume the tool use was not successful and assess whether you should retry. If the last tool was a browser_action, the browser has been closed and you must launch a new browser if needed.${
wasRecent
- ? "\n\nIMPORTANT: If the last tool use was a create_file that was interrupted, the file was reverted back to its original state before the interrupted edit, and you do NOT need to re-read the file as you already have its up-to-date contents."
+ ? "\n\nIMPORTANT: If the last tool use was a write_to_file that was interrupted, the file was reverted back to its original state before the interrupted edit, and you do NOT need to re-read the file as you already have its up-to-date contents."
: ""
}` +
(responseText
@@ -1141,9 +1141,9 @@ export class Cline {
return `[${block.name} for '${block.params.command}']`
case "read_file":
return `[${block.name} for '${block.params.path}']`
- case "create_file":
+ case "write_to_file":
return `[${block.name} for '${block.params.path}']`
- case "edit_file":
+ case "apply_diff":
return `[${block.name} for '${block.params.path}']`
case "search_files":
return `[${block.name} for '${block.params.regex}'${
@@ -1295,7 +1295,7 @@ export class Cline {
mode ?? defaultModeSlug,
customModes ?? [],
{
- edit_file: this.diffEnabled,
+ apply_diff: this.diffEnabled,
},
block.params,
)
@@ -1306,7 +1306,7 @@ export class Cline {
}
switch (block.name) {
- case "create_file": {
+ case "write_to_file": {
const relPath: string | undefined = block.params.path
let newContent: string | undefined = block.params.content
let predictedLineCount: number | undefined = parseInt(block.params.line_count ?? "0")
@@ -1371,20 +1371,20 @@ export class Cline {
} else {
if (!relPath) {
this.consecutiveMistakeCount++
- pushToolResult(await this.sayAndCreateMissingParamError("create_file", "path"))
+ pushToolResult(await this.sayAndCreateMissingParamError("write_to_file", "path"))
await this.diffViewProvider.reset()
break
}
if (!newContent) {
this.consecutiveMistakeCount++
- pushToolResult(await this.sayAndCreateMissingParamError("create_file", "content"))
+ pushToolResult(await this.sayAndCreateMissingParamError("write_to_file", "content"))
await this.diffViewProvider.reset()
break
}
if (!predictedLineCount) {
this.consecutiveMistakeCount++
pushToolResult(
- await this.sayAndCreateMissingParamError("create_file", "line_count"),
+ await this.sayAndCreateMissingParamError("write_to_file", "line_count"),
)
await this.diffViewProvider.reset()
break
@@ -1421,7 +1421,7 @@ export class Cline {
formatResponse.toolError(
`Content appears to be truncated (file has ${
newContent.split("\n").length
- } lines but was predicted to have ${predictedLineCount} lines), and found comments indicating omitted code (e.g., '// rest of code unchanged', '/* previous code */'). Please provide the complete file content without any omissions if possible, or otherwise use the 'edit_file' tool to apply the diff to the original file.`,
+ } lines but was predicted to have ${predictedLineCount} lines), and found comments indicating omitted code (e.g., '// rest of code unchanged', '/* previous code */'). Please provide the complete file content without any omissions if possible, or otherwise use the 'apply_diff' tool to apply the diff to the original file.`,
),
)
break
@@ -1497,7 +1497,7 @@ export class Cline {
break
}
}
- case "edit_file": {
+ case "apply_diff": {
const relPath: string | undefined = block.params.path
const diffContent: string | undefined = block.params.diff
@@ -1515,12 +1515,12 @@ export class Cline {
} else {
if (!relPath) {
this.consecutiveMistakeCount++
- pushToolResult(await this.sayAndCreateMissingParamError("edit_file", "path"))
+ pushToolResult(await this.sayAndCreateMissingParamError("apply_diff", "path"))
break
}
if (!diffContent) {
this.consecutiveMistakeCount++
- pushToolResult(await this.sayAndCreateMissingParamError("edit_file", "diff"))
+ pushToolResult(await this.sayAndCreateMissingParamError("apply_diff", "diff"))
break
}
@@ -2233,7 +2233,7 @@ export class Cline {
formatResponse.toolResult(
`The browser action has been executed. The console logs and screenshot have been captured for your analysis.\n\nConsole logs:\n${
browserActionResult.logs || "(No new logs)"
- }\n\n(REMEMBER: if you need to proceed to using non-\`browser_action\` tools or launch a new browser, you MUST first close this browser. For example, if after analyzing the logs and screenshot you need to edit a file, you must first close the browser before you can use the create_file tool.)`,
+ }\n\n(REMEMBER: if you need to proceed to using non-\`browser_action\` tools or launch a new browser, you MUST first close this browser. For example, if after analyzing the logs and screenshot you need to edit a file, you must first close the browser before you can use the write_to_file tool.)`,
browserActionResult.screenshot ? [browserActionResult.screenshot] : [],
),
)
@@ -2750,7 +2750,7 @@ export class Cline {
/*
Seeing out of bounds is fine, it means that the next too call is being built up and ready to add to assistantMessageContent to present.
- When you see the UI inactive during this, it means that a tool is breaking without presenting any UI. For example the create_file tool was breaking when relpath was undefined, and for invalid relpath it never presented UI.
+ When you see the UI inactive during this, it means that a tool is breaking without presenting any UI. For example the write_to_file tool was breaking when relpath was undefined, and for invalid relpath it never presented UI.
*/
this.presentAssistantMessageLocked = false // this needs to be placed here, if not then calling this.presentAssistantMessage below would fail (sometimes) since it's locked
// NOTE: when tool is rejected, iterator stream is interrupted and it waits for userMessageContentReady to be true. Future calls to present will skip execution since didRejectTool and iterate until contentIndex is set to message length and it sets userMessageContentReady to true itself (instead of preemptively doing it in iterator)
@@ -3300,10 +3300,10 @@ export class Cline {
// Add warning if not in code mode
if (
- !isToolAllowedForMode("create_file", currentMode, customModes ?? [], {
- edit_file: this.diffEnabled,
+ !isToolAllowedForMode("write_to_file", currentMode, customModes ?? [], {
+ apply_diff: this.diffEnabled,
}) &&
- !isToolAllowedForMode("edit_file", currentMode, customModes ?? [], { edit_file: this.diffEnabled })
+ !isToolAllowedForMode("apply_diff", currentMode, customModes ?? [], { apply_diff: this.diffEnabled })
) {
const currentModeName = getModeBySlug(currentMode, customModes)?.name ?? currentMode
const defaultModeName = getModeBySlug(defaultModeSlug, customModes)?.name ?? defaultModeSlug
diff --git a/src/core/__tests__/mode-validator.test.ts b/src/core/__tests__/mode-validator.test.ts
index 4efcd06e3e7..632ca8a8ab0 100644
--- a/src/core/__tests__/mode-validator.test.ts
+++ b/src/core/__tests__/mode-validator.test.ts
@@ -59,7 +59,7 @@ describe("mode-validator", () => {
]
// Should allow tools from read and edit groups
expect(isToolAllowedForMode("read_file", "custom-mode", customModes)).toBe(true)
- expect(isToolAllowedForMode("create_file", "custom-mode", customModes)).toBe(true)
+ expect(isToolAllowedForMode("write_to_file", "custom-mode", customModes)).toBe(true)
// Should not allow tools from other groups
expect(isToolAllowedForMode("execute_command", "custom-mode", customModes)).toBe(false)
})
@@ -76,7 +76,7 @@ describe("mode-validator", () => {
// Should allow tools from read group
expect(isToolAllowedForMode("read_file", codeMode, customModes)).toBe(true)
// Should not allow tools from other groups
- expect(isToolAllowedForMode("create_file", codeMode, customModes)).toBe(false)
+ expect(isToolAllowedForMode("write_to_file", codeMode, customModes)).toBe(false)
})
it("respects tool requirements in custom modes", () => {
@@ -88,39 +88,39 @@ describe("mode-validator", () => {
groups: ["edit"] as const,
},
]
- const requirements = { edit_file: false }
+ const requirements = { apply_diff: false }
// Should respect disabled requirement even if tool group is allowed
- expect(isToolAllowedForMode("edit_file", "custom-mode", customModes, requirements)).toBe(false)
+ expect(isToolAllowedForMode("apply_diff", "custom-mode", customModes, requirements)).toBe(false)
// Should allow other edit tools
- expect(isToolAllowedForMode("create_file", "custom-mode", customModes, requirements)).toBe(true)
+ expect(isToolAllowedForMode("write_to_file", "custom-mode", customModes, requirements)).toBe(true)
})
})
describe("tool requirements", () => {
it("respects tool requirements when provided", () => {
- const requirements = { edit_file: false }
- expect(isToolAllowedForMode("edit_file", codeMode, [], requirements)).toBe(false)
+ const requirements = { apply_diff: false }
+ expect(isToolAllowedForMode("apply_diff", codeMode, [], requirements)).toBe(false)
- const enabledRequirements = { edit_file: true }
- expect(isToolAllowedForMode("edit_file", codeMode, [], enabledRequirements)).toBe(true)
+ const enabledRequirements = { apply_diff: true }
+ expect(isToolAllowedForMode("apply_diff", codeMode, [], enabledRequirements)).toBe(true)
})
it("allows tools when their requirements are not specified", () => {
const requirements = { some_other_tool: true }
- expect(isToolAllowedForMode("edit_file", codeMode, [], requirements)).toBe(true)
+ expect(isToolAllowedForMode("apply_diff", codeMode, [], requirements)).toBe(true)
})
it("handles undefined and empty requirements", () => {
- expect(isToolAllowedForMode("edit_file", codeMode, [], undefined)).toBe(true)
- expect(isToolAllowedForMode("edit_file", codeMode, [], {})).toBe(true)
+ expect(isToolAllowedForMode("apply_diff", codeMode, [], undefined)).toBe(true)
+ expect(isToolAllowedForMode("apply_diff", codeMode, [], {})).toBe(true)
})
it("prioritizes requirements over mode configuration", () => {
- const requirements = { edit_file: false }
+ const requirements = { apply_diff: false }
// Even in code mode which allows all tools, disabled requirement should take precedence
- expect(isToolAllowedForMode("edit_file", codeMode, [], requirements)).toBe(false)
+ expect(isToolAllowedForMode("apply_diff", codeMode, [], requirements)).toBe(false)
})
})
})
@@ -137,19 +137,19 @@ describe("mode-validator", () => {
})
it("throws error when tool requirement is not met", () => {
- const requirements = { edit_file: false }
- expect(() => validateToolUse("edit_file", codeMode, [], requirements)).toThrow(
- 'Tool "edit_file" is not allowed in code mode.',
+ const requirements = { apply_diff: false }
+ expect(() => validateToolUse("apply_diff", codeMode, [], requirements)).toThrow(
+ 'Tool "apply_diff" is not allowed in code mode.',
)
})
it("does not throw when tool requirement is met", () => {
- const requirements = { edit_file: true }
- expect(() => validateToolUse("edit_file", codeMode, [], requirements)).not.toThrow()
+ const requirements = { apply_diff: true }
+ expect(() => validateToolUse("apply_diff", codeMode, [], requirements)).not.toThrow()
})
it("handles undefined requirements gracefully", () => {
- expect(() => validateToolUse("edit_file", codeMode, [], undefined)).not.toThrow()
+ expect(() => validateToolUse("apply_diff", codeMode, [], undefined)).not.toThrow()
})
})
})
diff --git a/src/core/assistant-message/index.ts b/src/core/assistant-message/index.ts
index 46b29a703db..f1c49f85ab7 100644
--- a/src/core/assistant-message/index.ts
+++ b/src/core/assistant-message/index.ts
@@ -11,8 +11,8 @@ export interface TextContent {
export const toolUseNames = [
"execute_command",
"read_file",
- "create_file",
- "edit_file",
+ "write_to_file",
+ "apply_diff",
"insert_content",
"search_and_replace",
"search_files",
@@ -80,7 +80,7 @@ export interface ReadFileToolUse extends ToolUse {
}
export interface WriteToFileToolUse extends ToolUse {
- name: "create_file"
+ name: "write_to_file"
params: Partial, "path" | "content" | "line_count">>
}
diff --git a/src/core/assistant-message/parse-assistant-message.ts b/src/core/assistant-message/parse-assistant-message.ts
index 9b1cea70a9b..e38e8f6458e 100644
--- a/src/core/assistant-message/parse-assistant-message.ts
+++ b/src/core/assistant-message/parse-assistant-message.ts
@@ -61,9 +61,9 @@ export function parseAssistantMessage(assistantMessage: string) {
// there's no current param, and not starting a new param
- // special case for create_file where file contents could contain the closing tag, in which case the param would have closed and we end up with the rest of the file contents here. To work around this, we get the string between the starting content tag and the LAST content tag.
+ // special case for write_to_file where file contents could contain the closing tag, in which case the param would have closed and we end up with the rest of the file contents here. To work around this, we get the string between the starting content tag and the LAST content tag.
const contentParamName: ToolParamName = "content"
- if (currentToolUse.name === "create_file" && accumulator.endsWith(`${contentParamName}>`)) {
+ if (currentToolUse.name === "write_to_file" && accumulator.endsWith(`${contentParamName}>`)) {
const toolContent = accumulator.slice(currentToolUseStartIndex)
const contentStartTag = `<${contentParamName}>`
const contentEndTag = `${contentParamName}>`
diff --git a/src/core/diff/strategies/__tests__/new-unified.test.ts b/src/core/diff/strategies/__tests__/new-unified.test.ts
index 9d30cece7e4..8832f9e7c08 100644
--- a/src/core/diff/strategies/__tests__/new-unified.test.ts
+++ b/src/core/diff/strategies/__tests__/new-unified.test.ts
@@ -29,7 +29,7 @@ describe("main", () => {
const cwd = "/test/path"
const description = strategy.getToolDescription({ cwd })
- expect(description).toContain("edit_file Tool - Generate Precise Code Changes")
+ expect(description).toContain("apply_diff Tool - Generate Precise Code Changes")
expect(description).toContain(cwd)
expect(description).toContain("Step-by-Step Instructions")
expect(description).toContain("Requirements")
diff --git a/src/core/diff/strategies/__tests__/search-replace.test.ts b/src/core/diff/strategies/__tests__/search-replace.test.ts
index 723beee23a7..cd71edac475 100644
--- a/src/core/diff/strategies/__tests__/search-replace.test.ts
+++ b/src/core/diff/strategies/__tests__/search-replace.test.ts
@@ -1544,8 +1544,8 @@ function two() {
expect(description).toContain("<<<<<<< SEARCH")
expect(description).toContain("=======")
expect(description).toContain(">>>>>>> REPLACE")
- expect(description).toContain("")
- expect(description).toContain("")
+ expect(description).toContain("")
+ expect(description).toContain("")
})
it("should document start_line and end_line parameters", async () => {
diff --git a/src/core/diff/strategies/__tests__/unified.test.ts b/src/core/diff/strategies/__tests__/unified.test.ts
index ae7860869bb..1d9847b3c51 100644
--- a/src/core/diff/strategies/__tests__/unified.test.ts
+++ b/src/core/diff/strategies/__tests__/unified.test.ts
@@ -12,7 +12,7 @@ describe("UnifiedDiffStrategy", () => {
const cwd = "/test/path"
const description = strategy.getToolDescription({ cwd })
- expect(description).toContain("edit_file")
+ expect(description).toContain("apply_diff")
expect(description).toContain(cwd)
expect(description).toContain("Parameters:")
expect(description).toContain("Format Requirements:")
diff --git a/src/core/diff/strategies/new-unified/index.ts b/src/core/diff/strategies/new-unified/index.ts
index df130ffaca6..d82a05a1045 100644
--- a/src/core/diff/strategies/new-unified/index.ts
+++ b/src/core/diff/strategies/new-unified/index.ts
@@ -108,7 +108,7 @@ export class NewUnifiedDiffStrategy implements DiffStrategy {
}
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
- return `# edit_file Tool - Generate Precise Code Changes
+ return `# apply_diff Tool - Generate Precise Code Changes
Generate a unified diff that can be cleanly applied to modify code files.
@@ -168,12 +168,12 @@ Parameters:
- diff: (required) Unified diff content in unified format to apply to the file.
Usage:
-
+path/to/file.ext
Your diff here
-`
+`
}
// Helper function to split a hunk into smaller hunks based on contiguous changes
diff --git a/src/core/diff/strategies/search-replace.ts b/src/core/diff/strategies/search-replace.ts
index c8d4f22c8d1..a9bf46758de 100644
--- a/src/core/diff/strategies/search-replace.ts
+++ b/src/core/diff/strategies/search-replace.ts
@@ -40,7 +40,7 @@ export class SearchReplaceDiffStrategy implements DiffStrategy {
}
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
- return `## edit_file
+ return `## apply_diff
Description: Request to replace existing code using a search and replace block.
This tool allows for precise, surgical replaces to files by specifying exactly what content to search for and what to replace it with.
The tool will maintain proper indentation and formatting while making changes.
@@ -91,14 +91,14 @@ def calculate_total(items):
\`\`\`
Usage:
-
+File path here
Your search/replace content here
15
-`
+`
}
async applyDiff(
diff --git a/src/core/diff/strategies/unified.ts b/src/core/diff/strategies/unified.ts
index 5947391df69..f1cdb3b5849 100644
--- a/src/core/diff/strategies/unified.ts
+++ b/src/core/diff/strategies/unified.ts
@@ -3,7 +3,7 @@ import { DiffStrategy, DiffResult } from "../types"
export class UnifiedDiffStrategy implements DiffStrategy {
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
- return `## edit_file
+ return `## apply_diff
Description: Apply a unified diff to a file at the specified path. This tool is useful when you need to make specific modifications to a file based on a set of changes provided in unified diff format (diff -U3).
Parameters:
@@ -100,12 +100,12 @@ Best Practices:
4. Verify line numbers match the line numbers you have in the file
Usage:
-
+File path here
Your diff here
-`
+`
}
async applyDiff(originalContent: string, diffContent: string): Promise {
diff --git a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
index e4447d31eef..2abc6138619 100644
--- a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
@@ -94,23 +94,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -129,7 +129,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -249,7 +249,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -266,9 +266,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -417,23 +417,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -452,7 +452,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -572,7 +572,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -589,9 +589,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -740,23 +740,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -775,7 +775,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -895,7 +895,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -912,9 +912,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -1063,23 +1063,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -1098,7 +1098,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## browser_action
Description: Request to interact with a Puppeteer-controlled browser. Every action, except \`close\`, will be responded to with a screenshot of the browser's current state, along with any new console logs. You may only perform one browser action per message, and wait for the user's response including a screenshot and logs to determine the next action.
@@ -1264,7 +1264,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
- You can use the browser_action tool to interact with websites (including html files and locally running development servers) through a Puppeteer-controlled browser when you feel it is necessary in accomplishing the user's task. This tool is particularly useful for web development tasks as it allows you to launch a browser, navigate to pages, interact with elements through clicks and keyboard input, and capture the results through screenshots and console logs. This tool may be useful at key stages of web development tasks-such as after implementing new features, making substantial changes, when troubleshooting issues, or to verify the result of your work. You can analyze the provided screenshots to ensure correct rendering or identify errors, and review console logs for runtime issues.
- For example, if asked to add a component to a react website, you might create the necessary files, use execute_command to run the site locally, then use browser_action to launch the browser, navigate to the local server, and verify the component renders & functions correctly before closing the browser.
@@ -1283,9 +1283,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -1435,23 +1435,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -1470,7 +1470,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -1983,7 +1983,7 @@ IMPORTANT: Regardless of what else you see in the MCP settings file, you must de
## Editing MCP Servers
-The user may ask to add tools or resources that may make sense to add to an existing MCP server (listed under 'Connected MCP Servers' above: (None running currently), e.g. if it would use the same API. This would be possible if you can locate the MCP server repository on the user's system by looking at the server arguments for a filepath. You might then use list_files and read_file to explore the files in the repository, and use create_file to make changes to the files.
+The user may ask to add tools or resources that may make sense to add to an existing MCP server (listed under 'Connected MCP Servers' above: (None running currently), e.g. if it would use the same API. This would be possible if you can locate the MCP server repository on the user's system by looking at the server arguments for a filepath. You might then use list_files and read_file to explore the files in the repository, and use write_to_file to make changes to the files.
However some MCP servers may be running from installed packages rather than a local repository, in which case it may make more sense to create a new MCP server.
@@ -2001,7 +2001,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
- You have access to MCP servers that may provide additional tools and resources. Each server may provide different capabilities that you can use to accomplish tasks more effectively.
@@ -2020,9 +2020,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -2171,23 +2171,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -2206,7 +2206,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## browser_action
Description: Request to interact with a Puppeteer-controlled browser. Every action, except \`close\`, will be responded to with a screenshot of the browser's current state, along with any new console logs. You may only perform one browser action per message, and wait for the user's response including a screenshot and logs to determine the next action.
@@ -2372,7 +2372,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
- You can use the browser_action tool to interact with websites (including html files and locally running development servers) through a Puppeteer-controlled browser when you feel it is necessary in accomplishing the user's task. This tool is particularly useful for web development tasks as it allows you to launch a browser, navigate to pages, interact with elements through clicks and keyboard input, and capture the results through screenshots and console logs. This tool may be useful at key stages of web development tasks-such as after implementing new features, making substantial changes, when troubleshooting issues, or to verify the result of your work. You can analyze the provided screenshots to ensure correct rendering or identify errors, and review console logs for runtime issues.
- For example, if asked to add a component to a react website, you might create the necessary files, use execute_command to run the site locally, then use browser_action to launch the browser, navigate to the local server, and verify the component renders & functions correctly before closing the browser.
@@ -2391,9 +2391,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -2543,7 +2543,44 @@ Example: Requesting to list all top level source code definitions in the current
.
-## edit_file
+## write_to_file
+Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
+Parameters:
+- path: (required) The path of the file to write to (relative to the current working directory /test/path)
+- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
+- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
+Usage:
+
+File path here
+
+Your file content here
+
+total number of lines in the file, including empty lines
+
+
+Example: Requesting to write to frontend-config.json
+
+frontend-config.json
+
+{
+ "apiEndpoint": "https://api.example.com",
+ "theme": {
+ "primaryColor": "#007bff",
+ "secondaryColor": "#6c757d",
+ "fontFamily": "Arial, sans-serif"
+ },
+ "features": {
+ "darkMode": true,
+ "notifications": true,
+ "analytics": false
+ },
+ "version": "1.0.0"
+}
+
+14
+
+
+## apply_diff
Description: Request to replace existing code using a search and replace block.
This tool allows for precise, surgical replaces to files by specifying exactly what content to search for and what to replace it with.
The tool will maintain proper indentation and formatting while making changes.
@@ -2594,51 +2631,14 @@ def calculate_total(items):
\`\`\`
Usage:
-
+File path here
Your search/replace content here
15
-
-
-## create_file
-Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
-Parameters:
-- path: (required) The path of the file to write to (relative to the current working directory /test/path)
-- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
-- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
-Usage:
-
-File path here
-
-Your file content here
-
-total number of lines in the file, including empty lines
-
-
-Example: Requesting to write to frontend-config.json
-
-frontend-config.json
-
-{
- "apiEndpoint": "https://api.example.com",
- "theme": {
- "primaryColor": "#007bff",
- "secondaryColor": "#6c757d",
- "fontFamily": "Arial, sans-serif"
- },
- "features": {
- "darkMode": true,
- "notifications": true,
- "analytics": false
- },
- "version": "1.0.0"
-}
-
-14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -2758,7 +2758,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the edit_file or create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file or apply_diff tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -2775,11 +2775,11 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using edit_file or create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- For editing files, you have access to these tools: edit_file (for replacing lines in existing files), create_file (for creating new files or complete file rewrites).
-- You should always prefer using other editing tools over create_file when making changes to existing files since create_file is much slower and cannot handle large files.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), apply_diff (for replacing lines in existing files).
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- 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.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -2928,23 +2928,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -2963,7 +2963,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -3083,7 +3083,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -3100,9 +3100,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -3293,23 +3293,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -3328,7 +3328,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -3505,7 +3505,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
- You have access to MCP servers that may provide additional tools and resources. Each server may provide different capabilities that you can use to accomplish tasks more effectively.
@@ -3524,9 +3524,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -3690,23 +3690,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -3725,7 +3725,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## ask_followup_question
Description: Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.
@@ -3831,7 +3831,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -3848,9 +3848,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -4108,7 +4108,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -4125,9 +4125,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
@@ -4309,23 +4309,23 @@ Example: Requesting to list all top level source code definitions in the current
.
-## create_file
+## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -4344,7 +4344,7 @@ Example: Requesting to write to frontend-config.json
}
14
-
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
@@ -4857,7 +4857,7 @@ IMPORTANT: Regardless of what else you see in the MCP settings file, you must de
## Editing MCP Servers
-The user may ask to add tools or resources that may make sense to add to an existing MCP server (listed under 'Connected MCP Servers' above: (None running currently), e.g. if it would use the same API. This would be possible if you can locate the MCP server repository on the user's system by looking at the server arguments for a filepath. You might then use list_files and read_file to explore the files in the repository, and use create_file to make changes to the files.
+The user may ask to add tools or resources that may make sense to add to an existing MCP server (listed under 'Connected MCP Servers' above: (None running currently), e.g. if it would use the same API. This would be possible if you can locate the MCP server repository on the user's system by looking at the server arguments for a filepath. You might then use list_files and read_file to explore the files in the repository, and use write_to_file to make changes to the files.
However some MCP servers may be running from installed packages rather than a local repository, in which case it may make more sense to create a new MCP server.
@@ -4875,7 +4875,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the create_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
- You have access to MCP servers that may provide additional tools and resources. Each server may provide different capabilities that you can use to accomplish tasks more effectively.
@@ -4894,9 +4894,9 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using create_file to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
diff --git a/src/core/prompts/__tests__/sections.test.ts b/src/core/prompts/__tests__/sections.test.ts
index 75af4ce6a6b..2100016e467 100644
--- a/src/core/prompts/__tests__/sections.test.ts
+++ b/src/core/prompts/__tests__/sections.test.ts
@@ -33,24 +33,24 @@ describe("getCapabilitiesSection", () => {
const cwd = "/test/path"
const mcpHub = undefined
const mockDiffStrategy: DiffStrategy = {
- getToolDescription: () => "edit_file tool description",
+ getToolDescription: () => "apply_diff tool description",
applyDiff: async (originalContent: string, diffContent: string): Promise => {
return { success: true, content: "mock result" }
},
}
- test("includes edit_file in capabilities when diffStrategy is provided", () => {
+ test("includes apply_diff in capabilities when diffStrategy is provided", () => {
const result = getCapabilitiesSection(cwd, false, mcpHub, mockDiffStrategy)
- expect(result).toContain("or create_file")
- expect(result).toContain("then use the edit_file or create_file tool")
+ expect(result).toContain("or apply_diff")
+ expect(result).toContain("then use the write_to_file or apply_diff tool")
})
- test("excludes edit_file from capabilities when diffStrategy is undefined", () => {
+ test("excludes apply_diff from capabilities when diffStrategy is undefined", () => {
const result = getCapabilitiesSection(cwd, false, mcpHub, undefined)
- expect(result).not.toContain("or edit_file")
- expect(result).toContain("then use the create_file tool")
- expect(result).not.toContain("create_file or edit_file")
+ expect(result).not.toContain("or apply_diff")
+ expect(result).toContain("then use the write_to_file tool")
+ expect(result).not.toContain("write_to_file or apply_diff")
})
})
diff --git a/src/core/prompts/__tests__/system.test.ts b/src/core/prompts/__tests__/system.test.ts
index 5f936fd4058..2adfa927eb6 100644
--- a/src/core/prompts/__tests__/system.test.ts
+++ b/src/core/prompts/__tests__/system.test.ts
@@ -288,7 +288,7 @@ describe("SYSTEM_PROMPT", () => {
true, // enableMcpServerCreation
)
- expect(prompt).toContain("edit_file")
+ expect(prompt).toContain("apply_diff")
expect(prompt).toMatchSnapshot()
})
@@ -310,7 +310,7 @@ describe("SYSTEM_PROMPT", () => {
true, // enableMcpServerCreation
)
- expect(prompt).not.toContain("edit_file")
+ expect(prompt).not.toContain("apply_diff")
expect(prompt).toMatchSnapshot()
})
@@ -332,7 +332,7 @@ describe("SYSTEM_PROMPT", () => {
true, // enableMcpServerCreation
)
- expect(prompt).not.toContain("edit_file")
+ expect(prompt).not.toContain("apply_diff")
expect(prompt).toMatchSnapshot()
})
@@ -562,8 +562,8 @@ describe("SYSTEM_PROMPT", () => {
)
// Verify base instruction lists all available tools
- expect(prompt).toContain("edit_file (for replacing lines in existing files)")
- expect(prompt).toContain("create_file (for creating new files or complete file rewrites)")
+ 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("insert_content (for adding lines to existing files)")
expect(prompt).toContain("search_and_replace (for finding and replacing individual pieces of text)")
})
@@ -593,7 +593,7 @@ describe("SYSTEM_PROMPT", () => {
// Verify detailed instructions for each tool
expect(prompt).toContain(
- "You should always prefer using other editing tools over create_file when making changes to existing files since create_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_content tool adds lines of text to files")
expect(prompt).toContain("The search_and_replace tool finds and replaces text or regex in files")
diff --git a/src/core/prompts/sections/capabilities.ts b/src/core/prompts/sections/capabilities.ts
index 9cd39bde580..c292eeffbc3 100644
--- a/src/core/prompts/sections/capabilities.ts
+++ b/src/core/prompts/sections/capabilities.ts
@@ -17,7 +17,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('${cwd}') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use ${diffStrategy ? "the edit_file or create_file" : "the create_file"} tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file${diffStrategy ? " or apply_diff" : ""} tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.${
supportsComputerUse
? "\n- You can use the browser_action tool to interact with websites (including html files and locally running development servers) through a Puppeteer-controlled browser when you feel it is necessary in accomplishing the user's task. This tool is particularly useful for web development tasks as it allows you to launch a browser, navigate to pages, interact with elements through clicks and keyboard input, and capture the results through screenshots and console logs. This tool may be useful at key stages of web development tasks-such as after implementing new features, making substantial changes, when troubleshooting issues, or to verify the result of your work. You can analyze the provided screenshots to ensure correct rendering or identify errors, and review console logs for runtime issues.\n - For example, if asked to add a component to a react website, you might create the necessary files, use execute_command to run the site locally, then use browser_action to launch the browser, navigate to the local server, and verify the component renders & functions correctly before closing the browser."
diff --git a/src/core/prompts/sections/mcp-servers.ts b/src/core/prompts/sections/mcp-servers.ts
index fd7f520ddd9..3f7ec88297c 100644
--- a/src/core/prompts/sections/mcp-servers.ts
+++ b/src/core/prompts/sections/mcp-servers.ts
@@ -414,7 +414,7 @@ The user may ask to add tools or resources that may make sense to add to an exis
.getServers()
.map((server) => server.name)
.join(", ") || "(None running currently)"
- }, e.g. if it would use the same API. This would be possible if you can locate the MCP server repository on the user's system by looking at the server arguments for a filepath. You might then use list_files and read_file to explore the files in the repository, and use create_file${diffStrategy ? " or edit_file" : ""} to make changes to the files.
+ }, e.g. if it would use the same API. This would be possible if you can locate the MCP server repository on the user's system by looking at the server arguments for a filepath. You might then use list_files and read_file to explore the files in the repository, and use write_to_file${diffStrategy ? " or apply_diff" : ""} to make changes to the files.
However some MCP servers may be running from installed packages rather than a local repository, in which case it may make more sense to create a new MCP server.
diff --git a/src/core/prompts/sections/modes.ts b/src/core/prompts/sections/modes.ts
index de3cac9c947..eff950c2c2f 100644
--- a/src/core/prompts/sections/modes.ts
+++ b/src/core/prompts/sections/modes.ts
@@ -45,7 +45,7 @@ Both files should follow this structure:
"roleDefinition": "You are Roo, a UI/UX expert specializing in design systems and frontend development. Your expertise includes:\\n- Creating and maintaining design systems\\n- Implementing responsive and accessible web interfaces\\n- Working with CSS, HTML, and modern frontend frameworks\\n- Ensuring consistent user experiences across platforms", // Required: non-empty
"groups": [ // Required: array of tool groups (can be empty)
"read", // Read files group (read_file, search_files, list_files, list_code_definition_names)
- "edit", // Edit files group (edit_file, create_file) - allows editing any file
+ "edit", // Edit files group (write_to_file, apply_diff) - allows editing any file
// Or with file restrictions:
// ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], // Edit group that only allows editing markdown files
"browser", // Browser group (browser_action)
diff --git a/src/core/prompts/sections/rules.ts b/src/core/prompts/sections/rules.ts
index e0d65976182..b6e19eb08c9 100644
--- a/src/core/prompts/sections/rules.ts
+++ b/src/core/prompts/sections/rules.ts
@@ -5,16 +5,11 @@ import * as path from "path"
function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Record): string {
const instructions: string[] = []
- const availableTools: string[] = []
+ const availableTools: string[] = ["write_to_file (for creating new files or complete file rewrites)"]
// Collect available editing tools
if (diffStrategy) {
- availableTools.push(
- "edit_file (for replacing lines in existing files)",
- "create_file (for creating new files or complete file rewrites)",
- )
- } else {
- availableTools.push("create_file (for creating new files or complete file rewrites)")
+ availableTools.push("apply_diff (for replacing lines in existing files)")
}
if (experiments?.["insert_content"]) {
availableTools.push("insert_content (for adding lines to existing files)")
@@ -41,16 +36,16 @@ function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Recor
)
}
+ instructions.push(
+ "- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.",
+ )
+
if (availableTools.length > 1) {
instructions.push(
- "- You should always prefer using other editing tools over create_file when making changes to existing files since create_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.",
)
}
- instructions.push(
- "- When using the create_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.",
- )
-
return instructions.join("\n")
}
@@ -68,8 +63,8 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '${cwd.toPosix()}', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '${cwd.toPosix()}', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '${cwd.toPosix()}'). For example, if you needed to run \`npm install\` in a project outside of '${cwd.toPosix()}', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using ${diffStrategy ? "edit_file or create_file" : "create_file"} to make informed changes.
-- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the create_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
${getEditingInstructions(diffStrategy, experiments)}
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
diff --git a/src/core/prompts/tools/index.ts b/src/core/prompts/tools/index.ts
index 6310620aac9..1b9b9a43d9d 100644
--- a/src/core/prompts/tools/index.ts
+++ b/src/core/prompts/tools/index.ts
@@ -23,7 +23,7 @@ import { ToolArgs } from "./types"
const toolDescriptionMap: Record string | undefined> = {
execute_command: (args) => getExecuteCommandDescription(args),
read_file: (args) => getReadFileDescription(args),
- create_file: (args) => getWriteToFileDescription(args),
+ write_to_file: (args) => getWriteToFileDescription(args),
search_files: (args) => getSearchFilesDescription(args),
list_files: (args) => getListFilesDescription(args),
list_code_definition_names: (args) => getListCodeDefinitionNamesDescription(args),
@@ -36,7 +36,7 @@ const toolDescriptionMap: Record string | undefined>
new_task: (args) => getNewTaskDescription(args),
insert_content: (args) => getInsertContentDescription(args),
search_and_replace: (args) => getSearchAndReplaceDescription(args),
- edit_file: (args) =>
+ apply_diff: (args) =>
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
}
diff --git a/src/core/prompts/tools/write-to-file.ts b/src/core/prompts/tools/write-to-file.ts
index 7a20e9b3f4f..c2a311cf361 100644
--- a/src/core/prompts/tools/write-to-file.ts
+++ b/src/core/prompts/tools/write-to-file.ts
@@ -1,23 +1,23 @@
import { ToolArgs } from "./types"
export function getWriteToFileDescription(args: ToolArgs): string {
- return `## create_file
+ return `## write_to_file
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
- path: (required) The path of the file to write to (relative to the current working directory ${args.cwd})
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
Usage:
-
+File path here
Your file content here
total number of lines in the file, including empty lines
-
+
Example: Requesting to write to frontend-config.json
-
+frontend-config.json
{
@@ -36,5 +36,5 @@ Example: Requesting to write to frontend-config.json
}
14
-`
+`
}
diff --git a/src/core/webview/__tests__/ClineProvider.test.ts b/src/core/webview/__tests__/ClineProvider.test.ts
index f8df84721da..6449cc93bec 100644
--- a/src/core/webview/__tests__/ClineProvider.test.ts
+++ b/src/core/webview/__tests__/ClineProvider.test.ts
@@ -107,7 +107,7 @@ jest.mock(
// Mock DiffStrategy
jest.mock("../../diff/DiffStrategy", () => ({
getDiffStrategy: jest.fn().mockImplementation(() => ({
- getToolDescription: jest.fn().mockReturnValue("edit_file tool description"),
+ getToolDescription: jest.fn().mockReturnValue("apply_diff tool description"),
})),
}))
diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts
index 5d0e16e39cd..fe9fa394270 100644
--- a/src/shared/ExtensionMessage.ts
+++ b/src/shared/ExtensionMessage.ts
@@ -127,7 +127,7 @@ export interface ExtensionState {
experiments: Record // Map of experiment IDs to their enabled state
autoApprovalEnabled?: boolean
customModes: ModeConfig[]
- toolRequirements?: Record // Map of tool names to their requirements (e.g. {"edit_file": true} if diffEnabled)
+ toolRequirements?: Record // Map of tool names to their requirements (e.g. {"apply_diff": true} if diffEnabled)
maxOpenTabsContext: number // Maximum number of VSCode open tabs to include in context (0-500)
}
diff --git a/src/shared/__tests__/modes.test.ts b/src/shared/__tests__/modes.test.ts
index 52d26735a9e..3bd89c4ecb5 100644
--- a/src/shared/__tests__/modes.test.ts
+++ b/src/shared/__tests__/modes.test.ts
@@ -44,14 +44,14 @@ describe("isToolAllowedForMode", () => {
describe("file restrictions", () => {
it("allows editing matching files", () => {
// Test markdown editor mode
- const mdResult = isToolAllowedForMode("create_file", "markdown-editor", customModes, undefined, {
+ const mdResult = isToolAllowedForMode("write_to_file", "markdown-editor", customModes, undefined, {
path: "test.md",
content: "# Test",
})
expect(mdResult).toBe(true)
// Test CSS editor mode
- const cssResult = isToolAllowedForMode("create_file", "css-editor", customModes, undefined, {
+ const cssResult = isToolAllowedForMode("write_to_file", "css-editor", customModes, undefined, {
path: "styles.css",
content: ".test { color: red; }",
})
@@ -61,13 +61,13 @@ describe("isToolAllowedForMode", () => {
it("rejects editing non-matching files", () => {
// Test markdown editor mode with non-markdown file
expect(() =>
- isToolAllowedForMode("create_file", "markdown-editor", customModes, undefined, {
+ isToolAllowedForMode("write_to_file", "markdown-editor", customModes, undefined, {
path: "test.js",
content: "console.log('test')",
}),
).toThrow(FileRestrictionError)
expect(() =>
- isToolAllowedForMode("create_file", "markdown-editor", customModes, undefined, {
+ isToolAllowedForMode("write_to_file", "markdown-editor", customModes, undefined, {
path: "test.js",
content: "console.log('test')",
}),
@@ -75,13 +75,13 @@ describe("isToolAllowedForMode", () => {
// Test CSS editor mode with non-CSS file
expect(() =>
- isToolAllowedForMode("create_file", "css-editor", customModes, undefined, {
+ isToolAllowedForMode("write_to_file", "css-editor", customModes, undefined, {
path: "test.js",
content: "console.log('test')",
}),
).toThrow(FileRestrictionError)
expect(() =>
- isToolAllowedForMode("create_file", "css-editor", customModes, undefined, {
+ isToolAllowedForMode("write_to_file", "css-editor", customModes, undefined, {
path: "test.js",
content: "console.log('test')",
}),
@@ -91,35 +91,35 @@ describe("isToolAllowedForMode", () => {
it("handles partial streaming cases (path only, no content/diff)", () => {
// Should allow path-only for matching files (no validation yet since content/diff not provided)
expect(
- isToolAllowedForMode("create_file", "markdown-editor", customModes, undefined, {
+ isToolAllowedForMode("write_to_file", "markdown-editor", customModes, undefined, {
path: "test.js",
}),
).toBe(true)
expect(
- isToolAllowedForMode("edit_file", "markdown-editor", customModes, undefined, {
+ isToolAllowedForMode("apply_diff", "markdown-editor", customModes, undefined, {
path: "test.js",
}),
).toBe(true)
// Should allow path-only for architect mode too
expect(
- isToolAllowedForMode("create_file", "architect", [], undefined, {
+ isToolAllowedForMode("write_to_file", "architect", [], undefined, {
path: "test.js",
}),
).toBe(true)
})
- it("applies restrictions to both create_file and edit_file", () => {
- // Test create_file
- const writeResult = isToolAllowedForMode("create_file", "markdown-editor", customModes, undefined, {
+ it("applies restrictions to both write_to_file and apply_diff", () => {
+ // Test write_to_file
+ const writeResult = isToolAllowedForMode("write_to_file", "markdown-editor", customModes, undefined, {
path: "test.md",
content: "# Test",
})
expect(writeResult).toBe(true)
- // Test edit_file
- const diffResult = isToolAllowedForMode("edit_file", "markdown-editor", customModes, undefined, {
+ // Test apply_diff
+ const diffResult = isToolAllowedForMode("apply_diff", "markdown-editor", customModes, undefined, {
path: "test.md",
diff: "- old\n+ new",
})
@@ -127,14 +127,14 @@ describe("isToolAllowedForMode", () => {
// Test both with non-matching file
expect(() =>
- isToolAllowedForMode("create_file", "markdown-editor", customModes, undefined, {
+ isToolAllowedForMode("write_to_file", "markdown-editor", customModes, undefined, {
path: "test.js",
content: "console.log('test')",
}),
).toThrow(FileRestrictionError)
expect(() =>
- isToolAllowedForMode("edit_file", "markdown-editor", customModes, undefined, {
+ isToolAllowedForMode("apply_diff", "markdown-editor", customModes, undefined, {
path: "test.js",
diff: "- old\n+ new",
}),
@@ -155,29 +155,29 @@ describe("isToolAllowedForMode", () => {
},
]
- // Test create_file with non-matching file
+ // Test write_to_file with non-matching file
expect(() =>
- isToolAllowedForMode("create_file", "docs-editor", customModesWithDescription, undefined, {
+ isToolAllowedForMode("write_to_file", "docs-editor", customModesWithDescription, undefined, {
path: "test.js",
content: "console.log('test')",
}),
).toThrow(FileRestrictionError)
expect(() =>
- isToolAllowedForMode("create_file", "docs-editor", customModesWithDescription, undefined, {
+ isToolAllowedForMode("write_to_file", "docs-editor", customModesWithDescription, undefined, {
path: "test.js",
content: "console.log('test')",
}),
).toThrow(/Documentation files only/)
- // Test edit_file with non-matching file
+ // Test apply_diff with non-matching file
expect(() =>
- isToolAllowedForMode("edit_file", "docs-editor", customModesWithDescription, undefined, {
+ isToolAllowedForMode("apply_diff", "docs-editor", customModesWithDescription, undefined, {
path: "test.js",
diff: "- old\n+ new",
}),
).toThrow(FileRestrictionError)
expect(() =>
- isToolAllowedForMode("edit_file", "docs-editor", customModesWithDescription, undefined, {
+ isToolAllowedForMode("apply_diff", "docs-editor", customModesWithDescription, undefined, {
path: "test.js",
diff: "- old\n+ new",
}),
@@ -185,14 +185,14 @@ describe("isToolAllowedForMode", () => {
// Test that matching files are allowed
expect(
- isToolAllowedForMode("create_file", "docs-editor", customModesWithDescription, undefined, {
+ isToolAllowedForMode("write_to_file", "docs-editor", customModesWithDescription, undefined, {
path: "test.md",
content: "# Test",
}),
).toBe(true)
expect(
- isToolAllowedForMode("create_file", "docs-editor", customModesWithDescription, undefined, {
+ isToolAllowedForMode("write_to_file", "docs-editor", customModesWithDescription, undefined, {
path: "test.txt",
content: "Test content",
}),
@@ -200,7 +200,7 @@ describe("isToolAllowedForMode", () => {
// Test partial streaming cases
expect(
- isToolAllowedForMode("create_file", "docs-editor", customModesWithDescription, undefined, {
+ isToolAllowedForMode("write_to_file", "docs-editor", customModesWithDescription, undefined, {
path: "test.js",
}),
).toBe(true)
@@ -209,7 +209,7 @@ describe("isToolAllowedForMode", () => {
it("allows architect mode to edit markdown files only", () => {
// Should allow editing markdown files
expect(
- isToolAllowedForMode("create_file", "architect", [], undefined, {
+ isToolAllowedForMode("write_to_file", "architect", [], undefined, {
path: "test.md",
content: "# Test",
}),
@@ -217,7 +217,7 @@ describe("isToolAllowedForMode", () => {
// Should allow applying diffs to markdown files
expect(
- isToolAllowedForMode("edit_file", "architect", [], undefined, {
+ isToolAllowedForMode("apply_diff", "architect", [], undefined, {
path: "readme.md",
diff: "- old\n+ new",
}),
@@ -225,13 +225,13 @@ describe("isToolAllowedForMode", () => {
// Should reject non-markdown files
expect(() =>
- isToolAllowedForMode("create_file", "architect", [], undefined, {
+ isToolAllowedForMode("write_to_file", "architect", [], undefined, {
path: "test.js",
content: "console.log('test')",
}),
).toThrow(FileRestrictionError)
expect(() =>
- isToolAllowedForMode("create_file", "architect", [], undefined, {
+ isToolAllowedForMode("write_to_file", "architect", [], undefined, {
path: "test.js",
content: "console.log('test')",
}),
@@ -245,15 +245,15 @@ describe("isToolAllowedForMode", () => {
})
it("handles non-existent modes", () => {
- expect(isToolAllowedForMode("create_file", "non-existent", customModes)).toBe(false)
+ expect(isToolAllowedForMode("write_to_file", "non-existent", customModes)).toBe(false)
})
it("respects tool requirements", () => {
const toolRequirements = {
- create_file: false,
+ write_to_file: false,
}
- expect(isToolAllowedForMode("create_file", "markdown-editor", customModes, toolRequirements)).toBe(false)
+ expect(isToolAllowedForMode("write_to_file", "markdown-editor", customModes, toolRequirements)).toBe(false)
})
describe("experimental tools", () => {
@@ -312,7 +312,7 @@ describe("isToolAllowedForMode", () => {
).toBe(true)
expect(
isToolAllowedForMode(
- "create_file",
+ "write_to_file",
"markdown-editor",
customModes,
undefined,
diff --git a/src/shared/tool-groups.ts b/src/shared/tool-groups.ts
index 8a25e1400ee..2728d42319d 100644
--- a/src/shared/tool-groups.ts
+++ b/src/shared/tool-groups.ts
@@ -8,8 +8,8 @@ export type ToolGroupConfig = {
export const TOOL_DISPLAY_NAMES = {
execute_command: "run commands",
read_file: "read files",
- create_file: "write files",
- edit_file: "apply changes",
+ write_to_file: "write files",
+ apply_diff: "apply changes",
search_files: "search files",
list_files: "list files",
list_code_definition_names: "list definitions",
@@ -28,7 +28,7 @@ export const TOOL_GROUPS: Record = {
tools: ["read_file", "search_files", "list_files", "list_code_definition_names"],
},
edit: {
- tools: ["edit_file", "create_file", "insert_content", "search_and_replace"],
+ tools: ["write_to_file", "apply_diff", "insert_content", "search_and_replace"],
},
browser: {
tools: ["browser_action"],
From c677a450d197bb9b7ee856d2c7353e00abe35b2c Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 11:30:15 -0800
Subject: [PATCH 004/145] Fix maxTokens
---
src/shared/api.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 3598eb16ac9..129704ace26 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -96,7 +96,7 @@ export type AnthropicModelId = keyof typeof anthropicModels
export const anthropicDefaultModelId: AnthropicModelId = "claude-3-5-sonnet-20241022"
export const anthropicModels = {
"claude-3-7-sonnet-20250219": {
- maxTokens: 128_000,
+ maxTokens: 64_000,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
From 30b10c4e266c5ff10710fa697f5a4c989b96215a Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 13:39:08 -0600
Subject: [PATCH 005/145] 3.7
---
.changeset/warm-kangaroos-give.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/warm-kangaroos-give.md
diff --git a/.changeset/warm-kangaroos-give.md b/.changeset/warm-kangaroos-give.md
new file mode 100644
index 00000000000..a95f6a1cf89
--- /dev/null
+++ b/.changeset/warm-kangaroos-give.md
@@ -0,0 +1,5 @@
+---
+"roo-cline": minor
+---
+
+3.7
From 158b9d4659fd8d48dccf02c1a81915dff0b8b667 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 24 Feb 2025 19:42:40 +0000
Subject: [PATCH 006/145] changeset version bump
---
.changeset/warm-kangaroos-give.md | 5 -----
CHANGELOG.md | 6 ++++++
package-lock.json | 4 ++--
package.json | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
delete mode 100644 .changeset/warm-kangaroos-give.md
diff --git a/.changeset/warm-kangaroos-give.md b/.changeset/warm-kangaroos-give.md
deleted file mode 100644
index a95f6a1cf89..00000000000
--- a/.changeset/warm-kangaroos-give.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"roo-cline": minor
----
-
-3.7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 748f8c78f88..6b85eed8cac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Roo Code Changelog
+## 3.4.0
+
+### Minor Changes
+
+- 3.7
+
## [3.3.26]
- Adjust the default prompt for Debug mode to focus more on diagnosis and to require user confirmation before moving on to implementation
diff --git a/package-lock.json b/package-lock.json
index 9822548678d..f5648649b52 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "roo-cline",
- "version": "3.3.26",
+ "version": "3.4.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "roo-cline",
- "version": "3.3.26",
+ "version": "3.4.0",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
"@anthropic-ai/sdk": "^0.26.0",
diff --git a/package.json b/package.json
index c4c38e78571..d64f0c7b021 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"displayName": "Roo Code (prev. Roo Cline)",
"description": "An AI-powered autonomous coding agent that lives in your editor.",
"publisher": "RooVeterinaryInc",
- "version": "3.3.26",
+ "version": "3.4.0",
"icon": "assets/icons/rocket.png",
"galleryBanner": {
"color": "#617A91",
From 9a41763dbbde56256102deb691a1039bc040a1dc Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 13:47:55 -0600
Subject: [PATCH 007/145] Update CHANGELOG.md
---
CHANGELOG.md | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6b85eed8cac..2d4546a2e14 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,8 @@
# Roo Code Changelog
-## 3.4.0
+## [3.7.0]
-### Minor Changes
-
-- 3.7
+- Introducing Roo Code 3.7, with support for the new Claude Sonnet 3.7. Because who cares about skipping version numbers anymore? Thanks @lupuletic and @cte for the PRs!
## [3.3.26]
From 8b28189850959d86b961c045fb9fb7ed84e821f2 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 13:48:10 -0600
Subject: [PATCH 008/145] Update package.json
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index d64f0c7b021..0d9e545090c 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"displayName": "Roo Code (prev. Roo Cline)",
"description": "An AI-powered autonomous coding agent that lives in your editor.",
"publisher": "RooVeterinaryInc",
- "version": "3.4.0",
+ "version": "3.7.0",
"icon": "assets/icons/rocket.png",
"galleryBanner": {
"color": "#617A91",
From 3845338702500630c0ade45ddcee50c65667f412 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 13:48:53 -0600
Subject: [PATCH 009/145] Update package-lock.json
---
package-lock.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index f5648649b52..7650f96ea58 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "roo-cline",
- "version": "3.4.0",
+ "version": "3.7.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "roo-cline",
- "version": "3.4.0",
+ "version": "3.7.0",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
"@anthropic-ai/sdk": "^0.26.0",
From 35a56a991854e03f317e93e0390bc5556ef5814c Mon Sep 17 00:00:00 2001
From: Roo Code
Date: Sat, 22 Feb 2025 16:38:46 -0700
Subject: [PATCH 010/145] Reorder tool groups and update tool usage
instructions to always mention apply_diff before write_to_file
---
src/core/prompts/sections/capabilities.ts | 2 +-
src/core/prompts/sections/modes.ts | 2 +-
src/core/prompts/sections/rules.ts | 19 ++++++++++++-------
src/shared/tool-groups.ts | 2 +-
4 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/core/prompts/sections/capabilities.ts b/src/core/prompts/sections/capabilities.ts
index c292eeffbc3..983d07bf761 100644
--- a/src/core/prompts/sections/capabilities.ts
+++ b/src/core/prompts/sections/capabilities.ts
@@ -17,7 +17,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('${cwd}') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file${diffStrategy ? " or apply_diff" : ""} tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use ${diffStrategy ? "the apply_diff or write_to_file" : "the write_to_file"} tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.${
supportsComputerUse
? "\n- You can use the browser_action tool to interact with websites (including html files and locally running development servers) through a Puppeteer-controlled browser when you feel it is necessary in accomplishing the user's task. This tool is particularly useful for web development tasks as it allows you to launch a browser, navigate to pages, interact with elements through clicks and keyboard input, and capture the results through screenshots and console logs. This tool may be useful at key stages of web development tasks-such as after implementing new features, making substantial changes, when troubleshooting issues, or to verify the result of your work. You can analyze the provided screenshots to ensure correct rendering or identify errors, and review console logs for runtime issues.\n - For example, if asked to add a component to a react website, you might create the necessary files, use execute_command to run the site locally, then use browser_action to launch the browser, navigate to the local server, and verify the component renders & functions correctly before closing the browser."
diff --git a/src/core/prompts/sections/modes.ts b/src/core/prompts/sections/modes.ts
index eff950c2c2f..f3863870dbc 100644
--- a/src/core/prompts/sections/modes.ts
+++ b/src/core/prompts/sections/modes.ts
@@ -45,7 +45,7 @@ Both files should follow this structure:
"roleDefinition": "You are Roo, a UI/UX expert specializing in design systems and frontend development. Your expertise includes:\\n- Creating and maintaining design systems\\n- Implementing responsive and accessible web interfaces\\n- Working with CSS, HTML, and modern frontend frameworks\\n- Ensuring consistent user experiences across platforms", // Required: non-empty
"groups": [ // Required: array of tool groups (can be empty)
"read", // Read files group (read_file, search_files, list_files, list_code_definition_names)
- "edit", // Edit files group (write_to_file, apply_diff) - allows editing any file
+ "edit", // Edit files group (apply_diff, write_to_file) - allows editing any file
// Or with file restrictions:
// ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], // Edit group that only allows editing markdown files
"browser", // Browser group (browser_action)
diff --git a/src/core/prompts/sections/rules.ts b/src/core/prompts/sections/rules.ts
index b6e19eb08c9..86e554a157e 100644
--- a/src/core/prompts/sections/rules.ts
+++ b/src/core/prompts/sections/rules.ts
@@ -5,11 +5,16 @@ import * as path from "path"
function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Record): string {
const instructions: string[] = []
- const availableTools: string[] = ["write_to_file (for creating new files or complete file rewrites)"]
+ const availableTools: string[] = []
// Collect available editing tools
if (diffStrategy) {
- availableTools.push("apply_diff (for replacing lines in existing files)")
+ availableTools.push(
+ "apply_diff (for replacing lines in existing files)",
+ "write_to_file (for creating new files or complete file rewrites)",
+ )
+ } else {
+ availableTools.push("write_to_file (for creating new files or complete file rewrites)")
}
if (experiments?.["insert_content"]) {
availableTools.push("insert_content (for adding lines to existing files)")
@@ -36,16 +41,16 @@ function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Recor
)
}
- instructions.push(
- "- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.",
- )
-
if (availableTools.length > 1) {
instructions.push(
"- 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.",
)
}
+ instructions.push(
+ "- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.",
+ )
+
return instructions.join("\n")
}
@@ -63,7 +68,7 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '${cwd.toPosix()}', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '${cwd.toPosix()}', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '${cwd.toPosix()}'). For example, if you needed to run \`npm install\` in a project outside of '${cwd.toPosix()}', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using ${diffStrategy ? "apply_diff or write_to_file" : "write_to_file"} to make informed changes.
- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
${getEditingInstructions(diffStrategy, experiments)}
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
diff --git a/src/shared/tool-groups.ts b/src/shared/tool-groups.ts
index 2728d42319d..50c7b80ca9e 100644
--- a/src/shared/tool-groups.ts
+++ b/src/shared/tool-groups.ts
@@ -28,7 +28,7 @@ export const TOOL_GROUPS: Record = {
tools: ["read_file", "search_files", "list_files", "list_code_definition_names"],
},
edit: {
- tools: ["write_to_file", "apply_diff", "insert_content", "search_and_replace"],
+ tools: ["apply_diff", "write_to_file", "insert_content", "search_and_replace"],
},
browser: {
tools: ["browser_action"],
From 0e644f102ff0b9e74213f502c9c41cda7e7776e5 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 12:48:55 -0800
Subject: [PATCH 011/145] Default to Claude 3.7 where appropriate
---
.github/ISSUE_TEMPLATE/bug_report.yml | 2 +-
src/core/Cline.ts | 2 +-
src/core/webview/ClineProvider.ts | 50 +++----------------
src/shared/api.ts | 24 +++++----
src/test/suite/index.ts | 2 +-
.../components/settings/GlamaModelPicker.tsx | 2 +-
.../settings/OpenRouterModelPicker.tsx | 2 +-
.../settings/RequestyModelPicker.tsx | 2 +-
.../src/components/settings/SettingsView.tsx | 2 +-
9 files changed, 26 insertions(+), 62 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 501180c3d53..dc66b4f390b 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -33,7 +33,7 @@ body:
id: model
attributes:
label: Which Model are you using?
- description: Please specify the model you're using (e.g. Claude 3.5 Sonnet)
+ description: Please specify the model you're using (e.g. Claude 3.7 Sonnet)
validations:
required: true
- type: textarea
diff --git a/src/core/Cline.ts b/src/core/Cline.ts
index 12cf062406b..f1f5e41b331 100644
--- a/src/core/Cline.ts
+++ b/src/core/Cline.ts
@@ -2792,7 +2792,7 @@ export class Cline {
"mistake_limit_reached",
this.api.getModel().id.includes("claude")
? `This may indicate a failure in his thought process or inability to use a tool properly, which can be mitigated with some user guidance (e.g. "Try breaking down the task into smaller steps").`
- : "Roo Code uses complex prompts and iterative task execution that may be challenging for less capable models. For best results, it's recommended to use Claude 3.5 Sonnet for its advanced agentic coding capabilities.",
+ : "Roo Code uses complex prompts and iterative task execution that may be challenging for less capable models. For best results, it's recommended to use Claude 3.7 Sonnet for its advanced agentic coding capabilities.",
)
if (response === "messageResponse") {
userContent.push(
diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts
index 6790224ecae..b4819d96833 100644
--- a/src/core/webview/ClineProvider.ts
+++ b/src/core/webview/ClineProvider.ts
@@ -1900,23 +1900,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
const response = await axios.get("https://router.requesty.ai/v1/models", config)
- /*
- {
- "id": "anthropic/claude-3-5-sonnet-20240620",
- "object": "model",
- "created": 1738243330,
- "owned_by": "system",
- "input_price": 0.000003,
- "caching_price": 0.00000375,
- "cached_price": 3E-7,
- "output_price": 0.000015,
- "max_output_tokens": 8192,
- "context_window": 200000,
- "supports_caching": true,
- "description": "Anthropic's most intelligent model. Highest level of intelligence and capability"
- },
- }
- */
+
if (response.data) {
const rawModels = response.data.data
const parsePrice = (price: any) => {
@@ -2116,34 +2100,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
)
const models: Record = {}
+
try {
const response = await axios.get("https://openrouter.ai/api/v1/models")
- /*
- {
- "id": "anthropic/claude-3.5-sonnet",
- "name": "Anthropic: Claude 3.5 Sonnet",
- "created": 1718841600,
- "description": "Claude 3.5 Sonnet delivers better-than-Opus capabilities, faster-than-Sonnet speeds, at the same Sonnet prices. Sonnet is particularly good at:\n\n- Coding: Autonomously writes, edits, and runs code with reasoning and troubleshooting\n- Data science: Augments human data science expertise; navigates unstructured data while using multiple tools for insights\n- Visual processing: excelling at interpreting charts, graphs, and images, accurately transcribing text to derive insights beyond just the text alone\n- Agentic tasks: exceptional tool use, making it great at agentic tasks (i.e. complex, multi-step problem solving tasks that require engaging with other systems)\n\n#multimodal",
- "context_length": 200000,
- "architecture": {
- "modality": "text+image-\u003Etext",
- "tokenizer": "Claude",
- "instruct_type": null
- },
- "pricing": {
- "prompt": "0.000003",
- "completion": "0.000015",
- "image": "0.0048",
- "request": "0"
- },
- "top_provider": {
- "context_length": 200000,
- "max_completion_tokens": 8192,
- "is_moderated": true
- },
- "per_request_limits": null
- },
- */
+
if (response.data?.data) {
const rawModels = response.data.data
const parsePrice = (price: any) => {
@@ -2152,6 +2112,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
return undefined
}
+
for (const rawModel of rawModels) {
const modelInfo: ModelInfo = {
maxTokens: rawModel.top_provider?.max_completion_tokens,
@@ -2164,9 +2125,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
switch (rawModel.id) {
+ case "anthropic/claude-3.7-sonnet":
case "anthropic/claude-3.5-sonnet":
case "anthropic/claude-3.5-sonnet:beta":
- // NOTE: this needs to be synced with api.ts/openrouter default model info
+ // NOTE: this needs to be synced with api.ts/openrouter default model info.
modelInfo.supportsComputerUse = true
modelInfo.supportsPromptCache = true
modelInfo.cacheWritesPrice = 3.75
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 23fe60696c9..4619d2930dc 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -93,7 +93,7 @@ export interface ModelInfo {
// Anthropic
// https://docs.anthropic.com/en/docs/about-claude/models
export type AnthropicModelId = keyof typeof anthropicModels
-export const anthropicDefaultModelId: AnthropicModelId = "claude-3-5-sonnet-20241022"
+export const anthropicDefaultModelId: AnthropicModelId = "claude-3-7-sonnet-20250219"
export const anthropicModels = {
"claude-3-7-sonnet-20250219": {
maxTokens: 64_000,
@@ -355,9 +355,9 @@ export const bedrockModels = {
// Glama
// https://glama.ai/models
-export const glamaDefaultModelId = "anthropic/claude-3-5-sonnet"
+export const glamaDefaultModelId = "anthropic/claude-3-7-sonnet"
export const glamaDefaultModelInfo: ModelInfo = {
- maxTokens: 8192,
+ maxTokens: 64_000,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
@@ -367,11 +367,14 @@ export const glamaDefaultModelInfo: ModelInfo = {
cacheWritesPrice: 3.75,
cacheReadsPrice: 0.3,
description:
- "The new Claude 3.5 Sonnet delivers better-than-Opus capabilities, faster-than-Sonnet speeds, at the same Sonnet prices. Sonnet is particularly good at:\n\n- Coding: New Sonnet scores ~49% on SWE-Bench Verified, higher than the last best score, and without any fancy prompt scaffolding\n- Data science: Augments human data science expertise; navigates unstructured data while using multiple tools for insights\n- Visual processing: excelling at interpreting charts, graphs, and images, accurately transcribing text to derive insights beyond just the text alone\n- Agentic tasks: exceptional tool use, making it great at agentic tasks (i.e. complex, multi-step problem solving tasks that require engaging with other systems)\n\n#multimodal\n\n_This is a faster endpoint, made available in collaboration with Anthropic, that is self-moderated: response moderation happens on the provider's side instead of OpenRouter's. For requests that pass moderation, it's identical to the [Standard](/anthropic/claude-3.5-sonnet) variant._",
+ "Claude 3.7 Sonnet is an advanced large language model with improved reasoning, coding, and problem-solving capabilities. It introduces a hybrid reasoning approach, allowing users to choose between rapid responses and extended, step-by-step processing for complex tasks. The model demonstrates notable improvements in coding, particularly in front-end development and full-stack updates, and excels in agentic workflows, where it can autonomously navigate multi-step processes. Claude 3.7 Sonnet maintains performance parity with its predecessor in standard mode while offering an extended reasoning mode for enhanced accuracy in math, coding, and instruction-following tasks. Read more at the [blog post here](https://www.anthropic.com/news/claude-3-7-sonnet)",
}
+// Requesty
+// https://requesty.ai/router-2
+export const requestyDefaultModelId = "anthropic/claude-3-7-sonnet-latest"
export const requestyDefaultModelInfo: ModelInfo = {
- maxTokens: 8192,
+ maxTokens: 64_000,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
@@ -381,15 +384,14 @@ export const requestyDefaultModelInfo: ModelInfo = {
cacheWritesPrice: 3.75,
cacheReadsPrice: 0.3,
description:
- "The new Claude 3.5 Sonnet delivers better-than-Opus capabilities, faster-than-Sonnet speeds, at the same Sonnet prices. Sonnet is particularly good at:\n\n- Coding: New Sonnet scores ~49% on SWE-Bench Verified, higher than the last best score, and without any fancy prompt scaffolding\n- Data science: Augments human data science expertise; navigates unstructured data while using multiple tools for insights\n- Visual processing: excelling at interpreting charts, graphs, and images, accurately transcribing text to derive insights beyond just the text alone\n- Agentic tasks: exceptional tool use, making it great at agentic tasks (i.e. complex, multi-step problem solving tasks that require engaging with other systems)\n\n#multimodal\n\n_This is a faster endpoint, made available in collaboration with Anthropic, that is self-moderated: response moderation happens on the provider's side instead of OpenRouter's. For requests that pass moderation, it's identical to the [Standard](/anthropic/claude-3.5-sonnet) variant._",
+ "Claude 3.7 Sonnet is an advanced large language model with improved reasoning, coding, and problem-solving capabilities. It introduces a hybrid reasoning approach, allowing users to choose between rapid responses and extended, step-by-step processing for complex tasks. The model demonstrates notable improvements in coding, particularly in front-end development and full-stack updates, and excels in agentic workflows, where it can autonomously navigate multi-step processes. Claude 3.7 Sonnet maintains performance parity with its predecessor in standard mode while offering an extended reasoning mode for enhanced accuracy in math, coding, and instruction-following tasks. Read more at the [blog post here](https://www.anthropic.com/news/claude-3-7-sonnet)",
}
-export const requestyDefaultModelId = "anthropic/claude-3-5-sonnet"
// OpenRouter
// https://openrouter.ai/models?order=newest&supported_parameters=tools
-export const openRouterDefaultModelId = "anthropic/claude-3.5-sonnet:beta" // will always exist in openRouterModels
+export const openRouterDefaultModelId = "anthropic/claude-3.7-sonnet"
export const openRouterDefaultModelInfo: ModelInfo = {
- maxTokens: 8192,
+ maxTokens: 64_000,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
@@ -399,13 +401,13 @@ export const openRouterDefaultModelInfo: ModelInfo = {
cacheWritesPrice: 3.75,
cacheReadsPrice: 0.3,
description:
- "The new Claude 3.5 Sonnet delivers better-than-Opus capabilities, faster-than-Sonnet speeds, at the same Sonnet prices. Sonnet is particularly good at:\n\n- Coding: New Sonnet scores ~49% on SWE-Bench Verified, higher than the last best score, and without any fancy prompt scaffolding\n- Data science: Augments human data science expertise; navigates unstructured data while using multiple tools for insights\n- Visual processing: excelling at interpreting charts, graphs, and images, accurately transcribing text to derive insights beyond just the text alone\n- Agentic tasks: exceptional tool use, making it great at agentic tasks (i.e. complex, multi-step problem solving tasks that require engaging with other systems)\n\n#multimodal\n\n_This is a faster endpoint, made available in collaboration with Anthropic, that is self-moderated: response moderation happens on the provider's side instead of OpenRouter's. For requests that pass moderation, it's identical to the [Standard](/anthropic/claude-3.5-sonnet) variant._",
+ "Claude 3.7 Sonnet is an advanced large language model with improved reasoning, coding, and problem-solving capabilities. It introduces a hybrid reasoning approach, allowing users to choose between rapid responses and extended, step-by-step processing for complex tasks. The model demonstrates notable improvements in coding, particularly in front-end development and full-stack updates, and excels in agentic workflows, where it can autonomously navigate multi-step processes. Claude 3.7 Sonnet maintains performance parity with its predecessor in standard mode while offering an extended reasoning mode for enhanced accuracy in math, coding, and instruction-following tasks. Read more at the [blog post here](https://www.anthropic.com/news/claude-3-7-sonnet)",
}
// Vertex AI
// https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude
export type VertexModelId = keyof typeof vertexModels
-export const vertexDefaultModelId: VertexModelId = "claude-3-5-sonnet-v2@20241022"
+export const vertexDefaultModelId: VertexModelId = "claude-3-7-sonnet@20250219"
export const vertexModels = {
"claude-3-7-sonnet@20250219": {
maxTokens: 8192,
diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts
index ffb8de7473e..540be7cef83 100644
--- a/src/test/suite/index.ts
+++ b/src/test/suite/index.ts
@@ -39,7 +39,7 @@ export async function run(): Promise {
: await globalThis.extension.activate()
globalThis.provider = globalThis.api.sidebarProvider
await globalThis.provider.updateGlobalState("apiProvider", "openrouter")
- await globalThis.provider.updateGlobalState("openRouterModelId", "anthropic/claude-3.5-sonnet")
+ await globalThis.provider.updateGlobalState("openRouterModelId", "anthropic/claude-3.7-sonnet")
await globalThis.provider.storeSecret(
"openRouterApiKey",
process.env.OPENROUTER_API_KEY || "sk-or-v1-fake-api-key",
diff --git a/webview-ui/src/components/settings/GlamaModelPicker.tsx b/webview-ui/src/components/settings/GlamaModelPicker.tsx
index cb813a0d058..37e326d8f87 100644
--- a/webview-ui/src/components/settings/GlamaModelPicker.tsx
+++ b/webview-ui/src/components/settings/GlamaModelPicker.tsx
@@ -10,6 +10,6 @@ export const GlamaModelPicker = () => (
refreshMessageType="refreshGlamaModels"
serviceName="Glama"
serviceUrl="https://glama.ai/models"
- recommendedModel="anthropic/claude-3-5-sonnet"
+ recommendedModel="anthropic/claude-3-7-sonnet"
/>
)
diff --git a/webview-ui/src/components/settings/OpenRouterModelPicker.tsx b/webview-ui/src/components/settings/OpenRouterModelPicker.tsx
index 9111407cd61..c773478e542 100644
--- a/webview-ui/src/components/settings/OpenRouterModelPicker.tsx
+++ b/webview-ui/src/components/settings/OpenRouterModelPicker.tsx
@@ -10,6 +10,6 @@ export const OpenRouterModelPicker = () => (
refreshMessageType="refreshOpenRouterModels"
serviceName="OpenRouter"
serviceUrl="https://openrouter.ai/models"
- recommendedModel="anthropic/claude-3.5-sonnet:beta"
+ recommendedModel="anthropic/claude-3.7-sonnet"
/>
)
diff --git a/webview-ui/src/components/settings/RequestyModelPicker.tsx b/webview-ui/src/components/settings/RequestyModelPicker.tsx
index e0759a43ba1..c65067068aa 100644
--- a/webview-ui/src/components/settings/RequestyModelPicker.tsx
+++ b/webview-ui/src/components/settings/RequestyModelPicker.tsx
@@ -16,7 +16,7 @@ export const RequestyModelPicker = () => {
}}
serviceName="Requesty"
serviceUrl="https://requesty.ai"
- recommendedModel="anthropic/claude-3-5-sonnet-latest"
+ recommendedModel="anthropic/claude-3-7-sonnet-latest"
/>
)
}
diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx
index 495bf49bd77..0d80580b491 100644
--- a/webview-ui/src/components/settings/SettingsView.tsx
+++ b/webview-ui/src/components/settings/SettingsView.tsx
@@ -765,7 +765,7 @@ const SettingsView = forwardRef(({ onDone },
color: "var(--vscode-descriptionForeground)",
}}>
When enabled, Roo will be able to edit files more quickly and will automatically reject
- truncated full-file writes. Works best with the latest Claude 3.5 Sonnet model.
+ truncated full-file writes. Works best with the latest Claude 3.7 Sonnet model.
{diffEnabled && (
From d94067aba8b375fa14b76b04a0bb2e5774a43a06 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 12:54:05 -0800
Subject: [PATCH 012/145] Revert maxTokens change for now
---
src/api/providers/openrouter.ts | 1 +
src/shared/api.ts | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts
index af087226ebd..eb9e819d772 100644
--- a/src/api/providers/openrouter.ts
+++ b/src/api/providers/openrouter.ts
@@ -107,6 +107,7 @@ export class OpenRouterHandler implements ApiHandler, SingleCompletionHandler {
// (models usually default to max tokens allowed)
let maxTokens: number | undefined
switch (this.getModel().id) {
+ case "anthropic/claude-3.7-sonnet":
case "anthropic/claude-3.5-sonnet":
case "anthropic/claude-3.5-sonnet:beta":
case "anthropic/claude-3.5-sonnet-20240620":
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 4619d2930dc..056a40c49ef 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -96,7 +96,7 @@ export type AnthropicModelId = keyof typeof anthropicModels
export const anthropicDefaultModelId: AnthropicModelId = "claude-3-7-sonnet-20250219"
export const anthropicModels = {
"claude-3-7-sonnet-20250219": {
- maxTokens: 64_000,
+ maxTokens: 8192,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
@@ -357,7 +357,7 @@ export const bedrockModels = {
// https://glama.ai/models
export const glamaDefaultModelId = "anthropic/claude-3-7-sonnet"
export const glamaDefaultModelInfo: ModelInfo = {
- maxTokens: 64_000,
+ maxTokens: 8192,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
@@ -374,7 +374,7 @@ export const glamaDefaultModelInfo: ModelInfo = {
// https://requesty.ai/router-2
export const requestyDefaultModelId = "anthropic/claude-3-7-sonnet-latest"
export const requestyDefaultModelInfo: ModelInfo = {
- maxTokens: 64_000,
+ maxTokens: 8192,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
@@ -391,7 +391,7 @@ export const requestyDefaultModelInfo: ModelInfo = {
// https://openrouter.ai/models?order=newest&supported_parameters=tools
export const openRouterDefaultModelId = "anthropic/claude-3.7-sonnet"
export const openRouterDefaultModelInfo: ModelInfo = {
- maxTokens: 64_000,
+ maxTokens: 8192,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
From a130e656f1ecf7e04cb5af2352b844d2f80e4908 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 13:07:00 -0800
Subject: [PATCH 013/145] Fix tests
---
src/api/providers/__tests__/glama.test.ts | 12 +++++++-----
src/api/providers/__tests__/openrouter.test.ts | 4 +++-
src/api/providers/__tests__/vertex.test.ts | 7 +++++--
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/api/providers/__tests__/glama.test.ts b/src/api/providers/__tests__/glama.test.ts
index c3fc90e32b4..5e017ccd0ad 100644
--- a/src/api/providers/__tests__/glama.test.ts
+++ b/src/api/providers/__tests__/glama.test.ts
@@ -1,9 +1,11 @@
-import { GlamaHandler } from "../glama"
-import { ApiHandlerOptions } from "../../../shared/api"
-import OpenAI from "openai"
+// npx jest src/api/providers/__tests__/glama.test.ts
+
import { Anthropic } from "@anthropic-ai/sdk"
import axios from "axios"
+import { GlamaHandler } from "../glama"
+import { ApiHandlerOptions } from "../../../shared/api"
+
// Mock OpenAI client
const mockCreate = jest.fn()
const mockWithResponse = jest.fn()
@@ -71,8 +73,8 @@ describe("GlamaHandler", () => {
beforeEach(() => {
mockOptions = {
- apiModelId: "anthropic/claude-3-5-sonnet",
- glamaModelId: "anthropic/claude-3-5-sonnet",
+ apiModelId: "anthropic/claude-3-7-sonnet",
+ glamaModelId: "anthropic/claude-3-7-sonnet",
glamaApiKey: "test-api-key",
}
handler = new GlamaHandler(mockOptions)
diff --git a/src/api/providers/__tests__/openrouter.test.ts b/src/api/providers/__tests__/openrouter.test.ts
index 18f81ce2fdf..aabd7f71a84 100644
--- a/src/api/providers/__tests__/openrouter.test.ts
+++ b/src/api/providers/__tests__/openrouter.test.ts
@@ -1,3 +1,5 @@
+// npx jest src/api/providers/__tests__/openrouter.test.ts
+
import { OpenRouterHandler } from "../openrouter"
import { ApiHandlerOptions, ModelInfo } from "../../../shared/api"
import OpenAI from "openai"
@@ -55,7 +57,7 @@ describe("OpenRouterHandler", () => {
const handler = new OpenRouterHandler({})
const result = handler.getModel()
- expect(result.id).toBe("anthropic/claude-3.5-sonnet:beta")
+ expect(result.id).toBe("anthropic/claude-3.7-sonnet")
expect(result.info.supportsPromptCache).toBe(true)
})
diff --git a/src/api/providers/__tests__/vertex.test.ts b/src/api/providers/__tests__/vertex.test.ts
index a51033af2d6..ebe60ba0c68 100644
--- a/src/api/providers/__tests__/vertex.test.ts
+++ b/src/api/providers/__tests__/vertex.test.ts
@@ -1,7 +1,10 @@
-import { VertexHandler } from "../vertex"
+// npx jest src/api/providers/__tests__/vertex.test.ts
+
import { Anthropic } from "@anthropic-ai/sdk"
import { AnthropicVertex } from "@anthropic-ai/vertex-sdk"
+import { VertexHandler } from "../vertex"
+
// Mock Vertex SDK
jest.mock("@anthropic-ai/vertex-sdk", () => ({
AnthropicVertex: jest.fn().mockImplementation(() => ({
@@ -289,7 +292,7 @@ describe("VertexHandler", () => {
vertexRegion: "us-central1",
})
const modelInfo = invalidHandler.getModel()
- expect(modelInfo.id).toBe("claude-3-5-sonnet-v2@20241022") // Default model
+ expect(modelInfo.id).toBe("claude-3-7-sonnet@20250219") // Default model
})
})
})
From 92131adc6d4abed404e0292db1e12a1761e733a2 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 15:35:00 -0600
Subject: [PATCH 014/145] Add Claude 3.7 to Bedrock
---
src/shared/api.ts | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 23fe60696c9..4d68ea2b87b 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -173,7 +173,7 @@ export interface MessageContent {
}
export type BedrockModelId = keyof typeof bedrockModels
-export const bedrockDefaultModelId: BedrockModelId = "anthropic.claude-3-5-sonnet-20241022-v2:0"
+export const bedrockDefaultModelId: BedrockModelId = "anthropic.claude-3-7-sonnet-20250219-v1:0"
export const bedrockModels = {
"amazon.nova-pro-v1:0": {
maxTokens: 5000,
@@ -208,6 +208,17 @@ export const bedrockModels = {
cacheWritesPrice: 0.035, // per million tokens
cacheReadsPrice: 0.00875, // per million tokens
},
+ "anthropic.claude-3-7-sonnet-20250219-v1:0": {
+ maxTokens: 8192,
+ contextWindow: 200_000,
+ supportsImages: true,
+ supportsComputerUse: true,
+ supportsPromptCache: true,
+ inputPrice: 3.0,
+ outputPrice: 15.0,
+ cacheWritesPrice: 3.75,
+ cacheReadsPrice: 0.3,
+ },
"anthropic.claude-3-5-sonnet-20241022-v2:0": {
maxTokens: 8192,
contextWindow: 200_000,
@@ -216,8 +227,8 @@ export const bedrockModels = {
supportsPromptCache: false,
inputPrice: 3.0,
outputPrice: 15.0,
- cacheWritesPrice: 3.75, // per million tokens
- cacheReadsPrice: 0.3, // per million tokens
+ cacheWritesPrice: 3.75,
+ cacheReadsPrice: 0.3,
},
"anthropic.claude-3-5-haiku-20241022-v1:0": {
maxTokens: 8192,
From 1d1f5c9c3b4e5523f483ef16187c92df48bdb254 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 13:43:47 -0800
Subject: [PATCH 015/145] Integration test cleanup
---
src/test/suite/index.ts | 17 ++--
src/test/suite/modes.test.ts | 152 ++++++++++++++++++-----------------
src/test/suite/task.test.ts | 58 ++++++-------
3 files changed, 114 insertions(+), 113 deletions(-)
diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts
index 540be7cef83..cc487b0bf78 100644
--- a/src/test/suite/index.ts
+++ b/src/test/suite/index.ts
@@ -13,23 +13,23 @@ declare global {
}
export async function run(): Promise {
- // Create the mocha test
const mocha = new Mocha({
ui: "tdd",
- timeout: 600000, // 10 minutes to compensate for time communicating with LLM while running in GHA
+ timeout: 600000, // 10 minutes to compensate for time communicating with LLM while running in GHA.
})
const testsRoot = path.resolve(__dirname, "..")
try {
- // Find all test files
+ // Find all test files.
const files = await glob("**/**.test.js", { cwd: testsRoot })
- // Add files to the test suite
+ // Add files to the test suite.
files.forEach((f: string) => mocha.addFile(path.resolve(testsRoot, f)))
- //Set up global extension, api, provider, and panel
+ // Set up global extension, api, provider, and panel.
globalThis.extension = vscode.extensions.getExtension("RooVeterinaryInc.roo-cline")
+
if (!globalThis.extension) {
throw new Error("Extension not found")
}
@@ -37,9 +37,12 @@ export async function run(): Promise {
globalThis.api = globalThis.extension.isActive
? globalThis.extension.exports
: await globalThis.extension.activate()
+
globalThis.provider = globalThis.api.sidebarProvider
+
await globalThis.provider.updateGlobalState("apiProvider", "openrouter")
- await globalThis.provider.updateGlobalState("openRouterModelId", "anthropic/claude-3.7-sonnet")
+ await globalThis.provider.updateGlobalState("openRouterModelId", "anthropic/claude-3.5-sonnet")
+
await globalThis.provider.storeSecret(
"openRouterApiKey",
process.env.OPENROUTER_API_KEY || "sk-or-v1-fake-api-key",
@@ -71,7 +74,7 @@ export async function run(): Promise {
await new Promise((resolve) => setTimeout(resolve, interval))
}
- // Run the mocha test
+ // Run the mocha test.
return new Promise((resolve, reject) => {
try {
mocha.run((failures: number) => {
diff --git a/src/test/suite/modes.test.ts b/src/test/suite/modes.test.ts
index 2fe0eaa597f..b94e71d1106 100644
--- a/src/test/suite/modes.test.ts
+++ b/src/test/suite/modes.test.ts
@@ -1,101 +1,105 @@
import * as assert from "assert"
-import * as vscode from "vscode"
suite("Roo Code Modes", () => {
test("Should handle switching modes correctly", async function () {
const timeout = 30000
const interval = 1000
+
const testPrompt =
"For each mode (Code, Architect, Ask) respond with the mode name and what it specializes in after switching to that mode, do not start with the current mode, be sure to say 'I AM DONE' after the task is complete"
+
if (!globalThis.extension) {
assert.fail("Extension not found")
}
- try {
- let startTime = Date.now()
-
- // Ensure the webview is launched.
- while (Date.now() - startTime < timeout) {
- if (globalThis.provider.viewLaunched) {
- break
- }
+ let startTime = Date.now()
- await new Promise((resolve) => setTimeout(resolve, interval))
+ // Ensure the webview is launched.
+ while (Date.now() - startTime < timeout) {
+ if (globalThis.provider.viewLaunched) {
+ break
}
- await globalThis.provider.updateGlobalState("mode", "Ask")
- await globalThis.provider.updateGlobalState("alwaysAllowModeSwitch", true)
- await globalThis.provider.updateGlobalState("autoApprovalEnabled", true)
+ await new Promise((resolve) => setTimeout(resolve, interval))
+ }
- // Start a new task.
- await globalThis.api.startNewTask(testPrompt)
+ await globalThis.provider.updateGlobalState("mode", "Ask")
+ await globalThis.provider.updateGlobalState("alwaysAllowModeSwitch", true)
+ await globalThis.provider.updateGlobalState("autoApprovalEnabled", true)
- // Wait for task to appear in history with tokens.
- startTime = Date.now()
+ // Start a new task.
+ await globalThis.api.startNewTask(testPrompt)
- while (Date.now() - startTime < timeout) {
- const messages = globalThis.provider.messages
+ // Wait for task to appear in history with tokens.
+ startTime = Date.now()
- if (
- messages.some(
- ({ type, text }) =>
- type === "say" && text?.includes("I AM DONE") && !text?.includes("be sure to say"),
- )
- ) {
- break
- }
+ while (Date.now() - startTime < timeout) {
+ const messages = globalThis.provider.messages
- await new Promise((resolve) => setTimeout(resolve, interval))
- }
- if (globalThis.provider.messages.length === 0) {
- assert.fail("No messages received")
+ if (
+ messages.some(
+ ({ type, text }) =>
+ type === "say" && text?.includes("I AM DONE") && !text?.includes("be sure to say"),
+ )
+ ) {
+ break
}
- //Log the messages to the console
- globalThis.provider.messages.forEach(({ type, text }) => {
- if (type === "say") {
- console.log(text)
- }
- })
-
- //Start Grading Portion of test to grade the response from 1 to 10
- await globalThis.provider.updateGlobalState("mode", "Ask")
- let output = globalThis.provider.messages.map(({ type, text }) => (type === "say" ? text : "")).join("\n")
- await globalThis.api.startNewTask(
- `Given this prompt: ${testPrompt} grade the response from 1 to 10 in the format of "Grade: (1-10)": ${output} \n Be sure to say 'I AM DONE GRADING' after the task is complete`,
- )
-
- startTime = Date.now()
-
- while (Date.now() - startTime < timeout) {
- const messages = globalThis.provider.messages
-
- if (
- messages.some(
- ({ type, text }) =>
- type === "say" && text?.includes("I AM DONE GRADING") && !text?.includes("be sure to say"),
- )
- ) {
- break
- }
-
- await new Promise((resolve) => setTimeout(resolve, interval))
+ await new Promise((resolve) => setTimeout(resolve, interval))
+ }
+
+ if (globalThis.provider.messages.length === 0) {
+ assert.fail("No messages received")
+ }
+
+ // Log the messages to the console.
+ globalThis.provider.messages.forEach(({ type, text }) => {
+ if (type === "say") {
+ console.log(text)
}
- if (globalThis.provider.messages.length === 0) {
- assert.fail("No messages received")
+ })
+
+ // Start Grading Portion of test to grade the response from 1 to 10.
+ await globalThis.provider.updateGlobalState("mode", "Ask")
+ let output = globalThis.provider.messages.map(({ type, text }) => (type === "say" ? text : "")).join("\n")
+
+ await globalThis.api.startNewTask(
+ `Given this prompt: ${testPrompt} grade the response from 1 to 10 in the format of "Grade: (1-10)": ${output} \n Be sure to say 'I AM DONE GRADING' after the task is complete`,
+ )
+
+ startTime = Date.now()
+
+ while (Date.now() - startTime < timeout) {
+ const messages = globalThis.provider.messages
+
+ if (
+ messages.some(
+ ({ type, text }) =>
+ type === "say" && text?.includes("I AM DONE GRADING") && !text?.includes("be sure to say"),
+ )
+ ) {
+ break
}
- globalThis.provider.messages.forEach(({ type, text }) => {
- if (type === "say" && text?.includes("Grade:")) {
- console.log(text)
- }
- })
- const gradeMessage = globalThis.provider.messages.find(
- ({ type, text }) => type === "say" && !text?.includes("Grade: (1-10)") && text?.includes("Grade:"),
- )?.text
- const gradeMatch = gradeMessage?.match(/Grade: (\d+)/)
- const gradeNum = gradeMatch ? parseInt(gradeMatch[1]) : undefined
- assert.ok(gradeNum !== undefined && gradeNum >= 7 && gradeNum <= 10, "Grade must be between 7 and 10")
- } finally {
+
+ await new Promise((resolve) => setTimeout(resolve, interval))
+ }
+
+ if (globalThis.provider.messages.length === 0) {
+ assert.fail("No messages received")
}
+
+ globalThis.provider.messages.forEach(({ type, text }) => {
+ if (type === "say" && text?.includes("Grade:")) {
+ console.log(text)
+ }
+ })
+
+ const gradeMessage = globalThis.provider.messages.find(
+ ({ type, text }) => type === "say" && !text?.includes("Grade: (1-10)") && text?.includes("Grade:"),
+ )?.text
+
+ const gradeMatch = gradeMessage?.match(/Grade: (\d+)/)
+ const gradeNum = gradeMatch ? parseInt(gradeMatch[1]) : undefined
+ assert.ok(gradeNum !== undefined && gradeNum >= 7 && gradeNum <= 10, "Grade must be between 7 and 10")
})
})
diff --git a/src/test/suite/task.test.ts b/src/test/suite/task.test.ts
index 2d34bc78ff3..6bdedcde002 100644
--- a/src/test/suite/task.test.ts
+++ b/src/test/suite/task.test.ts
@@ -1,5 +1,4 @@
import * as assert from "assert"
-import * as vscode from "vscode"
suite("Roo Code Task", () => {
test("Should handle prompt and response correctly", async function () {
@@ -10,48 +9,43 @@ suite("Roo Code Task", () => {
assert.fail("Extension not found")
}
- try {
- // Ensure the webview is launched.
- let startTime = Date.now()
+ // Ensure the webview is launched.
+ let startTime = Date.now()
- while (Date.now() - startTime < timeout) {
- if (globalThis.provider.viewLaunched) {
- break
- }
-
- await new Promise((resolve) => setTimeout(resolve, interval))
+ while (Date.now() - startTime < timeout) {
+ if (globalThis.provider.viewLaunched) {
+ break
}
- await globalThis.provider.updateGlobalState("mode", "Code")
- await globalThis.provider.updateGlobalState("alwaysAllowModeSwitch", true)
- await globalThis.provider.updateGlobalState("autoApprovalEnabled", true)
+ await new Promise((resolve) => setTimeout(resolve, interval))
+ }
- await globalThis.api.startNewTask("Hello world, what is your name? Respond with 'My name is ...'")
+ await globalThis.provider.updateGlobalState("mode", "Code")
+ await globalThis.provider.updateGlobalState("alwaysAllowModeSwitch", true)
+ await globalThis.provider.updateGlobalState("autoApprovalEnabled", true)
- // Wait for task to appear in history with tokens.
- startTime = Date.now()
+ await globalThis.api.startNewTask("Hello world, what is your name? Respond with 'My name is ...'")
- while (Date.now() - startTime < timeout) {
- const messages = globalThis.provider.messages
+ // Wait for task to appear in history with tokens.
+ startTime = Date.now()
- if (messages.some(({ type, text }) => type === "say" && text?.includes("My name is Roo"))) {
- break
- }
+ while (Date.now() - startTime < timeout) {
+ const messages = globalThis.provider.messages
- await new Promise((resolve) => setTimeout(resolve, interval))
+ if (messages.some(({ type, text }) => type === "say" && text?.includes("My name is Roo"))) {
+ break
}
- if (globalThis.provider.messages.length === 0) {
- assert.fail("No messages received")
- }
+ await new Promise((resolve) => setTimeout(resolve, interval))
+ }
- assert.ok(
- globalThis.provider.messages.some(
- ({ type, text }) => type === "say" && text?.includes("My name is Roo"),
- ),
- "Did not receive expected response containing 'My name is Roo'",
- )
- } finally {
+ if (globalThis.provider.messages.length === 0) {
+ assert.fail("No messages received")
}
+
+ assert.ok(
+ globalThis.provider.messages.some(({ type, text }) => type === "say" && text?.includes("My name is Roo")),
+ "Did not receive expected response containing 'My name is Roo'",
+ )
})
})
From b24a3355036f6f6e25bdfe01c26133110ede725e Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 13:48:47 -0800
Subject: [PATCH 016/145] Set maxTokens to 64K for Anthropic / 3.7 Sonnet
---
src/shared/api.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 056a40c49ef..3a550891f52 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -96,7 +96,7 @@ export type AnthropicModelId = keyof typeof anthropicModels
export const anthropicDefaultModelId: AnthropicModelId = "claude-3-7-sonnet-20250219"
export const anthropicModels = {
"claude-3-7-sonnet-20250219": {
- maxTokens: 8192,
+ maxTokens: 64_000,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
From cb9077f7dc851a9b4102f1c28e054d89acf08e40 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 15:47:54 -0600
Subject: [PATCH 017/145] README updates
---
README.md | 220 ++++++++++++------------------------------------------
1 file changed, 47 insertions(+), 173 deletions(-)
diff --git a/README.md b/README.md
index 53f29e07259..60161110e26 100644
--- a/README.md
+++ b/README.md
@@ -34,204 +34,78 @@ Check out the [CHANGELOG](CHANGELOG.md) for detailed updates and fixes.
---
-## New in 3.3: Code Actions, More Powerful Modes, and a new Discord! 🚀
+## New in 3.7: Claude 3.7 Sonnet Support 🚀
-This release brings significant improvements to how you interact with Roo Code:
+We're excited to announce support for Anthropic's latest model, Claude 3.7 Sonnet! The model shows notable improvements in:
-### Code Actions
+- Front-end development and full-stack updates
+- Agentic workflows for multi-step processes
+- More accurate math, coding, and instruction-following
-Roo Code now integrates directly with VS Code's native code actions system, providing quick fixes and refactoring options right in your editor. Look for the lightbulb 💡 to access Roo Code's capabilities without switching context.
-
-### Enhanced Mode Capabilities
-
-- **Markdown Editing**: Addressing one of the most requested features, Ask and Architect modes can now create and edit markdown files!
-- **Custom File Restrictions**: In general, custom modes can now be restricted to specific file patterns (for example, a technical writer who can only edit markdown files 👋). There's no UI for this yet, but who needs that when you can just ask Roo to set it up for you?
-- **Self-Initiated Mode Switching**: Modes can intelligently request to switch between each other based on the task at hand. For instance, Code mode might request to switch to Test Engineer mode once it's ready to write tests.
-
-### Join Our Discord!
-
-We've launched a new Discord community! Join us at [https://roocode.com/discord](https://roocode.com/discord) to:
-
-- Share your custom modes
-- Get help and support
-- Connect with other Roo Code users
-- Stay updated on the latest features
-
-## New in 3.2: Introducing Custom Modes, plus rebranding from Roo Cline → Roo Code! 🚀
-
-### Introducing Roo Code
-
-Our biggest update yet is here - we're officially changing our name from Roo Cline to Roo Code! After growing beyond 50,000 installations across VS Marketplace and Open VSX, we're ready to chart our own course. Our heartfelt thanks to everyone in the Cline community who helped us reach this milestone.
-
-### Custom Modes
-
-To mark this new chapter, we're introducing the power to shape Roo Code into any role you need. You can now create an entire team of agents with deeply customized prompts:
-
-- QA Engineers who write thorough test cases and catch edge cases
-- Product Managers who excel at user stories and feature prioritization
-- UI/UX Designers who craft beautiful, accessible interfaces
-- Code Reviewers who ensure quality and maintainability
-
-The best part is that Roo can help you create these new modes! Just type "Create a new mode for " in the chat to get started, and go into the Prompts tab or (carefully) edit the JSON representation to customize the prompt and allowed tools to your liking.
-
-We can't wait to hear more about what you build and how we can continue to evolve the Roo Code platform to support you. Please join us in our new https://www.reddit.com/r/RooCode subreddit to share your custom modes and be part of our next chapter. 🚀
-
-## New in 3.1: Chat Mode Prompt Customization & Prompt Enhancements
-
-Hot off the heels of **v3.0** introducing Code, Architect, and Ask chat modes, one of the most requested features has arrived: **customizable prompts for each mode**! 🎉
-
-You can now tailor the **role definition** and **custom instructions** for every chat mode to perfectly fit your workflow. Want to adjust Architect mode to focus more on system scalability? Or tweak Ask mode for deeper research queries? Done. Plus, you can define these via **mode-specific `.clinerules-[mode]` files**. You’ll find all of this in the new **Prompts** tab in the top menu.
-
-The second big feature in this release is a complete revamp of **prompt enhancements**. This feature helps you craft messages to get even better results from Cline. Here’s what’s new:
-
-- Works with **any provider** and API configuration, not just OpenRouter.
-- Fully customizable prompts to match your unique needs.
-- Same simple workflow: just hit the ✨ **Enhance Prompt** button in the chat input to try it out.
-
-Whether you’re using GPT-4, other APIs, or switching configurations, this gives you total control over how your prompts are optimized.
-
-As always, we’d love to hear your thoughts and ideas! What features do you want to see in **v3.2**? Drop by https://www.reddit.com/r/roocline and join the discussion - we're building Roo Cline together. 🚀
-
-## New in 3.0 - Chat Modes!
-
-You can now choose between different prompts for Roo Cline to better suit your workflow. Here’s what’s available:
-
-- **Code:** (existing behavior) The default mode where Cline helps you write code and execute tasks.
-
-- **Architect:** "You are Cline, a software architecture expert..." Ideal for thinking through high-level technical design and system architecture. Can’t write code or run commands.
-
-- **Ask:** "You are Cline, a knowledgeable technical assistant..." Perfect for asking questions about the codebase or digging into concepts. Also can’t write code or run commands.
-
-**Switching Modes:**
-It’s super simple! There’s a dropdown in the bottom left of the chat input to switch modes. Right next to it, you’ll find a way to switch between the API configuration profiles associated with the current mode (configured on the settings screen).
-
-**Why Add This?**
-
-- It keeps Cline from being overly eager to jump into solving problems when you just want to think or ask questions.
-- Each mode remembers the API configuration you last used with it. For example, you can use more thoughtful models like OpenAI o1 for Architect and Ask, while sticking with Sonnet or DeepSeek for coding tasks.
-- It builds on research suggesting better results when separating "thinking" from "coding," explained well in this very thoughtful [article](https://aider.chat/2024/09/26/architect.html) from aider.
-
-Right now, switching modes is a manual process. In the future, we’d love to give Cline the ability to suggest mode switches based on context. For now, we’d really appreciate your feedback on this feature.
+Try it today in your provider of choice!
---
-## Key Features
-
-### Adaptive Autonomy
+## What Can Roo Code Do?
-Roo Code communicates in **natural language** and proposes actions—file edits, terminal commands, browser tests, etc. You choose how it behaves:
+- 🚀 **Generate Code** from natural language descriptions
+- 🔧 **Refactor & Debug** existing code
+- 📝 **Write & Update** documentation
+- 🤔 **Answer Questions** about your codebase
+- 🔄 **Automate** repetitive tasks
+- 🏗️ **Create** new files and projects
-- **Manual Approval**: Review and approve every step to keep total control.
-- **Autonomous/Auto-Approve**: Grant Roo Code the ability to run tasks without interruption, speeding up routine workflows.
-- **Hybrid**: Auto-approve specific actions (e.g., file writes) but require confirmation for riskier tasks (like deploying code).
+## Quick Start
-No matter your preference, you always have the final say on what Roo Code does.
-
----
+1. [Install Roo Code](https://docs.roocode.com/getting-started/installing)
+2. [Connect Your AI Provider](https://docs.roocode.com/getting-started/connecting-api-provider)
+3. [Try Your First Task](https://docs.roocode.com/getting-started/your-first-task)
-### Supports Any API or Model
-
-Use Roo Code with:
-
-- **OpenRouter**, Anthropic, Glama, OpenAI, Google Gemini, AWS Bedrock, Azure, GCP Vertex, or local models (LM Studio/Ollama)—anything **OpenAI-compatible**.
-- Different models per mode. For instance, an advanced model for architecture vs. a cheaper model for daily coding tasks.
-- **Usage Tracking**: Roo Code monitors token and cost usage for each session.
-
----
-
-### Custom Modes
-
-**Custom Modes** let you shape Roo Code’s persona, instructions, and permissions:
-
-- **Built-in**:
- - **Code** – Default, multi-purpose coding assistant
- - **Architect** – High-level system and design insights
- - **Ask** – Research and Q&A for deeper exploration
-- **User-Created**: Type `Create a new mode for ` and Roo Code generates a brand-new persona for that role—complete with tailored prompts and optional tool restrictions.
-
-Modes can each have unique instructions and skill sets. Manage them in the **Prompts** tab.
-
-**Advanced Mode Features:**
-
-- **File Restrictions**: Modes can be restricted to specific file types (e.g., Ask and Architect modes can edit markdown files)
-- **Custom File Rules**: Define your own file access patterns (e.g., `.test.ts` for test files only)
-- **Direct Mode Switching**: Modes can request to switch to other modes when needed (e.g., switching to Code mode for implementation)
-- **Self-Creation**: Roo Code can help create new modes, complete with role definitions and file restrictions
-
----
-
-### File & Editor Operations
-
-Roo Code can:
-
-- **Create and edit** files in your project (showing you diffs).
-- **React** to linting or compile-time errors automatically (missing imports, syntax errors, etc.).
-- **Track changes** via your editor’s timeline so you can review or revert if needed.
-
----
-
-### Command Line Integration
-
-Easily run commands in your terminal—Roo Code:
-
-- Installs packages, runs builds, or executes tests.
-- Monitors output and adapts if it detects errors.
-- Lets you keep dev servers running in the background while continuing to work.
-
-You approve or decline each command, or set auto-approval for routine operations.
-
----
-
-### Browser Automation
-
-Roo Code can also open a **browser** session to:
-
-- Launch your local or remote web app.
-- Click, type, scroll, and capture screenshots.
-- Collect console logs to debug runtime or UI/UX issues.
-
-Ideal for **end-to-end testing** or visually verifying changes without constant copy-pasting.
-
----
+## Key Features
-### Adding Tools with MCP
+### Multiple Modes
-Extend Roo Code with the **Model Context Protocol (MCP)**:
+Roo Code adapts to your needs with specialized [modes](https://docs.roocode.com/basic-usage/modes):
-- “Add a tool that manages AWS EC2 resources.”
-- “Add a tool that queries the company Jira.”
-- “Add a tool that pulls the latest PagerDuty incidents.”
+- **Code Mode:** For general-purpose coding tasks
+- **Architect Mode:** For planning and technical leadership
+- **Ask Mode:** For answering questions and providing information
+- **Debug Mode:** For systematic problem diagnosis
+- **[Custom Modes](https://docs.roocode.com/advanced-usage/custom-modes):** Create unlimited specialized personas for security auditing, performance optimization, documentation, or any other task
-Roo Code can build and configure new tools autonomously (with your approval) to expand its capabilities instantly.
+### Smart Tools
----
+Roo Code comes with powerful [tools](https://docs.roocode.com/basic-usage/using-tools) that can:
-### Context Mentions
+- Read and write files in your project
+- Execute commands in your VS Code terminal
+- Control a web browser
+- Use external tools via [MCP (Model Context Protocol)](https://docs.roocode.com/advanced-usage/mcp)
-When you need to provide extra context:
+MCP extends Roo Code's capabilities by allowing you to add unlimited custom tools. Integrate with external APIs, connect to databases, or create specialized development tools - MCP provides the framework to expand Roo Code's functionality to meet your specific needs.
-- **@file** – Embed a file’s contents in the conversation.
-- **@folder** – Include entire folder structures.
-- **@problems** – Pull in workspace errors/warnings for Roo Code to fix.
-- **@url** – Fetch docs from a URL, converting them to markdown.
-- **@git** – Supply a list of Git commits or diffs for Roo Code to analyze code history.
+### Customization
-Help Roo Code focus on the most relevant details without blowing the token budget.
+Make Roo Code work your way with:
----
+- [Custom Instructions](https://docs.roocode.com/advanced-usage/custom-instructions) for personalized behavior
+- [Custom Modes](https://docs.roocode.com/advanced-usage/custom-modes) for specialized tasks
+- [Local Models](https://docs.roocode.com/advanced-usage/local-models) for offline use
+- [Auto-Approval Settings](https://docs.roocode.com/advanced-usage/auto-approving-actions) for faster workflows
-## Installation
+## Resources
-Roo Code is available on:
+### Documentation
-- **[VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=RooVeterinaryInc.roo-cline)**
-- **[Open-VSX](https://open-vsx.org/extension/RooVeterinaryInc/roo-cline)**
+- [Basic Usage Guide](https://docs.roocode.com/basic-usage/the-chat-interface)
+- [Advanced Features](https://docs.roocode.com/advanced-usage/auto-approving-actions)
+- [Frequently Asked Questions](https://docs.roocode.com/faq)
-1. **Search “Roo Code”** in your editor’s Extensions panel to install directly.
-2. Or grab the `.vsix` file from Marketplace / Open-VSX and **drag-and-drop** into your editor.
-3. **Open** Roo Code from the Activity Bar or Command Palette to start chatting.
+### Community
-> **Tip**: Use `Cmd/Ctrl + Shift + P` → “Roo Code: Open in New Tab” to dock the AI assistant alongside your file explorer.
+- **Discord:** [Join our Discord server](https://discord.gg/roocode) for real-time help and discussions
+- **Reddit:** [Visit our subreddit](https://www.reddit.com/r/RooCode) to share experiences and tips
+- **GitHub:** Report [issues](https://github.com/RooVetGit/Roo-Code/issues) or request [features](https://github.com/RooVetGit/Roo-Code/discussions/categories/feature-requests?discussions_q=is%3Aopen+category%3A%22Feature+Requests%22+sort%3Atop)
---
From 3f68a9c3c6554538c9b715611d143028a44988f0 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 15:56:29 -0600
Subject: [PATCH 018/145] v3.7.1
---
.changeset/large-ladybugs-behave.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/large-ladybugs-behave.md
diff --git a/.changeset/large-ladybugs-behave.md b/.changeset/large-ladybugs-behave.md
new file mode 100644
index 00000000000..330255b6a37
--- /dev/null
+++ b/.changeset/large-ladybugs-behave.md
@@ -0,0 +1,5 @@
+---
+"roo-cline": patch
+---
+
+v3.7.1
From a890d3d131ee481bef5cdf4406592a92fb42c0c4 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 24 Feb 2025 21:58:10 +0000
Subject: [PATCH 019/145] changeset version bump
---
.changeset/large-ladybugs-behave.md | 5 -----
CHANGELOG.md | 6 ++++++
package-lock.json | 4 ++--
package.json | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
delete mode 100644 .changeset/large-ladybugs-behave.md
diff --git a/.changeset/large-ladybugs-behave.md b/.changeset/large-ladybugs-behave.md
deleted file mode 100644
index 330255b6a37..00000000000
--- a/.changeset/large-ladybugs-behave.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"roo-cline": patch
----
-
-v3.7.1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2d4546a2e14..0acca15cb46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Roo Code Changelog
+## 3.7.1
+
+### Patch Changes
+
+- v3.7.1
+
## [3.7.0]
- Introducing Roo Code 3.7, with support for the new Claude Sonnet 3.7. Because who cares about skipping version numbers anymore? Thanks @lupuletic and @cte for the PRs!
diff --git a/package-lock.json b/package-lock.json
index 7650f96ea58..b8c65fd8e8d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "roo-cline",
- "version": "3.7.0",
+ "version": "3.7.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "roo-cline",
- "version": "3.7.0",
+ "version": "3.7.1",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
"@anthropic-ai/sdk": "^0.26.0",
diff --git a/package.json b/package.json
index 0d9e545090c..76d1273e5c8 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"displayName": "Roo Code (prev. Roo Cline)",
"description": "An AI-powered autonomous coding agent that lives in your editor.",
"publisher": "RooVeterinaryInc",
- "version": "3.7.0",
+ "version": "3.7.1",
"icon": "assets/icons/rocket.png",
"galleryBanner": {
"color": "#617A91",
From d01370370e3c1efcaf9332c9a91d854e9fe595ce Mon Sep 17 00:00:00 2001
From: R00-B0T
Date: Mon, 24 Feb 2025 21:58:34 +0000
Subject: [PATCH 020/145] Updating CHANGELOG.md format
---
CHANGELOG.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0acca15cb46..7081d366d57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,6 @@
# Roo Code Changelog
-## 3.7.1
-
-### Patch Changes
+## [3.7.1]
- v3.7.1
From 076861f8de6a81d03f19379c0a22bd4358b5cae0 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 15:59:22 -0600
Subject: [PATCH 021/145] Update CHANGELOG.md
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7081d366d57..83b84e1d413 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
## [3.7.1]
-- v3.7.1
+- Add AWS Bedrock support for Sonnet 3.7 and update some defaults to Sonnet 3.7 instead of 3.5
## [3.7.0]
From de54a55d2245065611c82724a64e9caa70e510d4 Mon Sep 17 00:00:00 2001
From: Roo Code
Date: Mon, 24 Feb 2025 15:15:48 -0700
Subject: [PATCH 022/145] Update test cases for capabilities section to match
new tool order
---
.../__snapshots__/system.test.ts.snap | 82 +++++++++----------
src/core/prompts/__tests__/sections.test.ts | 8 +-
2 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
index 2abc6138619..b8050adb77a 100644
--- a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
@@ -2543,43 +2543,6 @@ Example: Requesting to list all top level source code definitions in the current
.
-## write_to_file
-Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
-Parameters:
-- path: (required) The path of the file to write to (relative to the current working directory /test/path)
-- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
-- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
-Usage:
-
-File path here
-
-Your file content here
-
-total number of lines in the file, including empty lines
-
-
-Example: Requesting to write to frontend-config.json
-
-frontend-config.json
-
-{
- "apiEndpoint": "https://api.example.com",
- "theme": {
- "primaryColor": "#007bff",
- "secondaryColor": "#6c757d",
- "fontFamily": "Arial, sans-serif"
- },
- "features": {
- "darkMode": true,
- "notifications": true,
- "analytics": false
- },
- "version": "1.0.0"
-}
-
-14
-
-
## apply_diff
Description: Request to replace existing code using a search and replace block.
This tool allows for precise, surgical replaces to files by specifying exactly what content to search for and what to replace it with.
@@ -2640,6 +2603,43 @@ Your search/replace content here
5
+## write_to_file
+Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
+Parameters:
+- path: (required) The path of the file to write to (relative to the current working directory /test/path)
+- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
+- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
+Usage:
+
+File path here
+
+Your file content here
+
+total number of lines in the file, including empty lines
+
+
+Example: Requesting to write to frontend-config.json
+
+frontend-config.json
+
+{
+ "apiEndpoint": "https://api.example.com",
+ "theme": {
+ "primaryColor": "#007bff",
+ "secondaryColor": "#6c757d",
+ "fontFamily": "Arial, sans-serif"
+ },
+ "features": {
+ "darkMode": true,
+ "notifications": true,
+ "analytics": false
+ },
+ "version": "1.0.0"
+}
+
+14
+
+
## execute_command
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
Parameters:
@@ -2758,7 +2758,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
- - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file or apply_diff tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
+ - For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the apply_diff or write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
====
@@ -2775,11 +2775,11 @@ RULES
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
- Do not use the ~ character or $HOME to refer to the home directory.
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
-- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
+- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using apply_diff or write_to_file to make informed changes.
- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
-- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), apply_diff (for replacing lines in existing files).
-- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
+- For editing files, you have access to these tools: apply_diff (for replacing lines in existing files), write_to_file (for creating new files or complete file rewrites).
- 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.
+- When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"
diff --git a/src/core/prompts/__tests__/sections.test.ts b/src/core/prompts/__tests__/sections.test.ts
index 2100016e467..fe92e63f92e 100644
--- a/src/core/prompts/__tests__/sections.test.ts
+++ b/src/core/prompts/__tests__/sections.test.ts
@@ -42,15 +42,15 @@ describe("getCapabilitiesSection", () => {
test("includes apply_diff in capabilities when diffStrategy is provided", () => {
const result = getCapabilitiesSection(cwd, false, mcpHub, mockDiffStrategy)
- expect(result).toContain("or apply_diff")
- expect(result).toContain("then use the write_to_file or apply_diff tool")
+ expect(result).toContain("apply_diff or")
+ expect(result).toContain("then use the apply_diff or write_to_file tool")
})
test("excludes apply_diff from capabilities when diffStrategy is undefined", () => {
const result = getCapabilitiesSection(cwd, false, mcpHub, undefined)
- expect(result).not.toContain("or apply_diff")
+ expect(result).not.toContain("apply_diff or")
expect(result).toContain("then use the write_to_file tool")
- expect(result).not.toContain("write_to_file or apply_diff")
+ expect(result).not.toContain("apply_diff or write_to_file")
})
})
From 1d67f88aba2ccd1ab77343202c57799353a6f082 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 15:09:46 -0800
Subject: [PATCH 023/145] Sliding window fix
---
src/core/sliding-window/index.ts | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/core/sliding-window/index.ts b/src/core/sliding-window/index.ts
index ee4a1543e77..c84f308387c 100644
--- a/src/core/sliding-window/index.ts
+++ b/src/core/sliding-window/index.ts
@@ -55,13 +55,15 @@ export function truncateConversationIfNeeded(
/**
* Calculates the maximum allowed tokens for models that support prompt caching.
*
- * The maximum is computed as the greater of (contextWindow - 40000) and 80% of the contextWindow.
+ * The maximum is computed as the greater of (contextWindow - buffer) and 80% of the contextWindow.
*
* @param {ModelInfo} modelInfo - The model information containing the context window size.
* @returns {number} The maximum number of tokens allowed for prompt caching models.
*/
function getMaxTokensForPromptCachingModels(modelInfo: ModelInfo): number {
- return Math.max(modelInfo.contextWindow - 40_000, modelInfo.contextWindow * 0.8)
+ // The buffer needs to be at least as large as `modelInfo.maxTokens`.
+ const buffer = modelInfo.maxTokens ? Math.max(40_000, modelInfo.maxTokens) : 40_000
+ return Math.max(modelInfo.contextWindow - buffer, modelInfo.contextWindow * 0.8)
}
/**
From c9713ea40a64b761d91e610fdf37212c3ef3211a Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 15:10:53 -0800
Subject: [PATCH 024/145] Fix labels for anthropic/claude-3.7-sonnet:beta
---
src/core/webview/ClineProvider.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts
index b4819d96833..12beecb9765 100644
--- a/src/core/webview/ClineProvider.ts
+++ b/src/core/webview/ClineProvider.ts
@@ -2126,6 +2126,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
switch (rawModel.id) {
case "anthropic/claude-3.7-sonnet":
+ case "anthropic/claude-3.7-sonnet:beta":
case "anthropic/claude-3.5-sonnet":
case "anthropic/claude-3.5-sonnet:beta":
// NOTE: this needs to be synced with api.ts/openrouter default model info.
From 6245aa7629abe365b50d4550287b1d79853b4b5d Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 15:40:31 -0800
Subject: [PATCH 025/145] Add tests
---
.../__tests__/sliding-window.test.ts | 130 ++++++++++++++++++
src/core/sliding-window/index.ts | 5 +-
2 files changed, 134 insertions(+), 1 deletion(-)
create mode 100644 src/core/sliding-window/__tests__/sliding-window.test.ts
diff --git a/src/core/sliding-window/__tests__/sliding-window.test.ts b/src/core/sliding-window/__tests__/sliding-window.test.ts
new file mode 100644
index 00000000000..182dea67f5d
--- /dev/null
+++ b/src/core/sliding-window/__tests__/sliding-window.test.ts
@@ -0,0 +1,130 @@
+// npx jest src/core/sliding-window/__tests__/sliding-window.test.ts
+
+import { Anthropic } from "@anthropic-ai/sdk"
+
+import { ModelInfo } from "../../../shared/api"
+import { truncateConversation, truncateConversationIfNeeded } from "../index"
+
+describe("truncateConversation", () => {
+ it("should retain the first message", () => {
+ const messages: Anthropic.Messages.MessageParam[] = [
+ { role: "user", content: "First message" },
+ { role: "assistant", content: "Second message" },
+ { role: "user", content: "Third message" },
+ ]
+
+ const result = truncateConversation(messages, 0.5)
+
+ // With 2 messages after the first, 0.5 fraction means remove 1 message
+ // But 1 is odd, so it rounds down to 0 (to make it even)
+ expect(result.length).toBe(3) // First message + 2 remaining messages
+ expect(result[0]).toEqual(messages[0])
+ expect(result[1]).toEqual(messages[1])
+ expect(result[2]).toEqual(messages[2])
+ })
+
+ it("should remove the specified fraction of messages (rounded to even number)", () => {
+ const messages: Anthropic.Messages.MessageParam[] = [
+ { role: "user", content: "First message" },
+ { role: "assistant", content: "Second message" },
+ { role: "user", content: "Third message" },
+ { role: "assistant", content: "Fourth message" },
+ { role: "user", content: "Fifth message" },
+ ]
+
+ // 4 messages excluding first, 0.5 fraction = 2 messages to remove
+ // 2 is already even, so no rounding needed
+ const result = truncateConversation(messages, 0.5)
+
+ expect(result.length).toBe(3)
+ expect(result[0]).toEqual(messages[0])
+ expect(result[1]).toEqual(messages[3])
+ expect(result[2]).toEqual(messages[4])
+ })
+
+ it("should round to an even number of messages to remove", () => {
+ const messages: Anthropic.Messages.MessageParam[] = [
+ { role: "user", content: "First message" },
+ { role: "assistant", content: "Second message" },
+ { role: "user", content: "Third message" },
+ { role: "assistant", content: "Fourth message" },
+ { role: "user", content: "Fifth message" },
+ { role: "assistant", content: "Sixth message" },
+ { role: "user", content: "Seventh message" },
+ ]
+
+ // 6 messages excluding first, 0.3 fraction = 1.8 messages to remove
+ // 1.8 rounds down to 1, then to 0 to make it even
+ const result = truncateConversation(messages, 0.3)
+
+ expect(result.length).toBe(7) // No messages removed
+ expect(result).toEqual(messages)
+ })
+
+ it("should handle edge case with fracToRemove = 0", () => {
+ const messages: Anthropic.Messages.MessageParam[] = [
+ { role: "user", content: "First message" },
+ { role: "assistant", content: "Second message" },
+ { role: "user", content: "Third message" },
+ ]
+
+ const result = truncateConversation(messages, 0)
+
+ expect(result).toEqual(messages)
+ })
+
+ it("should handle edge case with fracToRemove = 1", () => {
+ const messages: Anthropic.Messages.MessageParam[] = [
+ { role: "user", content: "First message" },
+ { role: "assistant", content: "Second message" },
+ { role: "user", content: "Third message" },
+ { role: "assistant", content: "Fourth message" },
+ ]
+
+ // 3 messages excluding first, 1.0 fraction = 3 messages to remove
+ // But 3 is odd, so it rounds down to 2 to make it even
+ const result = truncateConversation(messages, 1)
+
+ expect(result.length).toBe(2)
+ expect(result[0]).toEqual(messages[0])
+ expect(result[1]).toEqual(messages[3])
+ })
+})
+
+describe("truncateConversationIfNeeded", () => {
+ const createModelInfo = (contextWindow: number, supportsPromptCache: boolean, maxTokens?: number): ModelInfo => ({
+ contextWindow,
+ supportsPromptCache,
+ maxTokens,
+ })
+
+ const messages: Anthropic.Messages.MessageParam[] = [
+ { role: "user", content: "First message" },
+ { role: "assistant", content: "Second message" },
+ { role: "user", content: "Third message" },
+ { role: "assistant", content: "Fourth message" },
+ { role: "user", content: "Fifth message" },
+ ]
+
+ it("should not truncate if tokens are below threshold for prompt caching models", () => {
+ const modelInfo = createModelInfo(200000, true, 50000)
+ const totalTokens = 100000 // Below threshold
+ const result = truncateConversationIfNeeded(messages, totalTokens, modelInfo)
+ expect(result).toEqual(messages)
+ })
+
+ it("should not truncate if tokens are below threshold for non-prompt caching models", () => {
+ const modelInfo = createModelInfo(200000, false)
+ const totalTokens = 100000 // Below threshold
+ const result = truncateConversationIfNeeded(messages, totalTokens, modelInfo)
+ expect(result).toEqual(messages)
+ })
+
+ it("should use 80% of context window as threshold if it's greater than (contextWindow - buffer)", () => {
+ const modelInfo = createModelInfo(50000, true) // Small context window
+ const totalTokens = 40001 // Above 80% threshold (40000)
+ const mockResult = [messages[0], messages[3], messages[4]]
+ const result = truncateConversationIfNeeded(messages, totalTokens, modelInfo)
+ expect(result).toEqual(mockResult)
+ })
+})
diff --git a/src/core/sliding-window/index.ts b/src/core/sliding-window/index.ts
index c84f308387c..d213f069f18 100644
--- a/src/core/sliding-window/index.ts
+++ b/src/core/sliding-window/index.ts
@@ -1,4 +1,5 @@
import { Anthropic } from "@anthropic-ai/sdk"
+
import { ModelInfo } from "../../shared/api"
/**
@@ -85,7 +86,9 @@ function getTruncFractionForPromptCachingModels(modelInfo: ModelInfo): number {
* @returns {number} The maximum number of tokens allowed for non-prompt caching models.
*/
function getMaxTokensForNonPromptCachingModels(modelInfo: ModelInfo): number {
- return Math.max(modelInfo.contextWindow - 40_000, modelInfo.contextWindow * 0.8)
+ // The buffer needs to be at least as large as `modelInfo.maxTokens`.
+ const buffer = modelInfo.maxTokens ? Math.max(40_000, modelInfo.maxTokens) : 40_000
+ return Math.max(modelInfo.contextWindow - buffer, modelInfo.contextWindow * 0.8)
}
/**
From aa98734cba4e8000ef54d32dd49803acc3d2af3f Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 17:44:45 -0600
Subject: [PATCH 026/145] v3.7.2
---
.changeset/fifty-files-jog.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/fifty-files-jog.md
diff --git a/.changeset/fifty-files-jog.md b/.changeset/fifty-files-jog.md
new file mode 100644
index 00000000000..6a166a5b611
--- /dev/null
+++ b/.changeset/fifty-files-jog.md
@@ -0,0 +1,5 @@
+---
+"roo-cline": patch
+---
+
+v3.7.2
From b2b135c05c47b46cb223c1e448741a67a262a04e Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 15:45:26 -0800
Subject: [PATCH 027/145] [WIP] Claude 3.7 Sonnet (Thinking)
---
package-lock.json | 9 ++---
package.json | 2 +-
src/api/providers/anthropic.ts | 65 +++++++++++++++++++++-------------
src/shared/api.ts | 1 +
4 files changed, 47 insertions(+), 30 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index b8c65fd8e8d..52b1e0bcb46 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"version": "3.7.1",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
- "@anthropic-ai/sdk": "^0.26.0",
+ "@anthropic-ai/sdk": "^0.37.0",
"@anthropic-ai/vertex-sdk": "^0.4.1",
"@aws-sdk/client-bedrock-runtime": "^3.706.0",
"@google/generative-ai": "^0.18.0",
@@ -122,9 +122,10 @@
}
},
"node_modules/@anthropic-ai/sdk": {
- "version": "0.26.1",
- "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.26.1.tgz",
- "integrity": "sha512-HeMJP1bDFfQPQS3XTJAmfXkFBdZ88wvfkE05+vsoA9zGn5dHqEaHOPsqkazf/i0gXYg2XlLxxZrf6rUAarSqzw==",
+ "version": "0.37.0",
+ "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.37.0.tgz",
+ "integrity": "sha512-tHjX2YbkUBwEgg0JZU3EFSSAQPoK4qQR/NFYa8Vtzd5UAyXzZksCw2In69Rml4R/TyHPBfRYaLK35XiOe33pjw==",
+ "license": "MIT",
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
diff --git a/package.json b/package.json
index 76d1273e5c8..ced42da9f0b 100644
--- a/package.json
+++ b/package.json
@@ -304,7 +304,7 @@
},
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
- "@anthropic-ai/sdk": "^0.26.0",
+ "@anthropic-ai/sdk": "^0.37.0",
"@anthropic-ai/vertex-sdk": "^0.4.1",
"@aws-sdk/client-bedrock-runtime": "^3.706.0",
"@google/generative-ai": "^0.18.0",
diff --git a/src/api/providers/anthropic.ts b/src/api/providers/anthropic.ts
index 4c62238f461..4bde475e80d 100644
--- a/src/api/providers/anthropic.ts
+++ b/src/api/providers/anthropic.ts
@@ -1,5 +1,7 @@
import { Anthropic } from "@anthropic-ai/sdk"
import { Stream as AnthropicStream } from "@anthropic-ai/sdk/streaming"
+import { CacheControlEphemeral } from "@anthropic-ai/sdk/resources"
+import { BetaThinkingConfigParam } from "@anthropic-ai/sdk/resources/beta"
import {
anthropicDefaultModelId,
AnthropicModelId,
@@ -12,12 +14,15 @@ import { ApiStream } from "../transform/stream"
const ANTHROPIC_DEFAULT_TEMPERATURE = 0
+const THINKING_MODELS = ["claude-3-7-sonnet-20250219"]
+
export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
private options: ApiHandlerOptions
private client: Anthropic
constructor(options: ApiHandlerOptions) {
this.options = options
+
this.client = new Anthropic({
apiKey: this.options.apiKey,
baseURL: this.options.anthropicBaseUrl || undefined,
@@ -25,26 +30,36 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
}
async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
- let stream: AnthropicStream
+ let stream: AnthropicStream
+ const cacheControl: CacheControlEphemeral = { type: "ephemeral" }
const modelId = this.getModel().id
+ let thinking: BetaThinkingConfigParam | undefined = undefined
+
+ if (THINKING_MODELS.includes(modelId)) {
+ thinking = this.options.anthropicThinking
+ ? { type: "enabled", budget_tokens: this.options.anthropicThinking }
+ : { type: "disabled" }
+ }
switch (modelId) {
- // 'latest' alias does not support cache_control
case "claude-3-7-sonnet-20250219":
case "claude-3-5-sonnet-20241022":
case "claude-3-5-haiku-20241022":
case "claude-3-opus-20240229":
case "claude-3-haiku-20240307": {
- /*
- The latest message will be the new user message, one before will be the assistant message from a previous request, and the user message before that will be a previously cached user message. So we need to mark the latest user message as ephemeral to cache it for the next request, and mark the second to last user message as ephemeral to let the server know the last message to retrieve from the cache for the current request..
- */
+ /**
+ * The latest message will be the new user message, one before will
+ * be the assistant message from a previous request, and the user message before that will be a previously cached user message. So we need to mark the latest user message as ephemeral to cache it for the next request, and mark the second to last user message as ephemeral to let the server know the last message to retrieve from the cache for the current request..
+ */
const userMsgIndices = messages.reduce(
(acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc),
[] as number[],
)
+
const lastUserMsgIndex = userMsgIndices[userMsgIndices.length - 1] ?? -1
const secondLastMsgUserIndex = userMsgIndices[userMsgIndices.length - 2] ?? -1
- stream = await this.client.beta.promptCaching.messages.create(
+
+ stream = await this.client.messages.create(
{
model: modelId,
max_tokens: this.getModel().info.maxTokens || 8192,
@@ -60,12 +75,12 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
{
type: "text",
text: message.content,
- cache_control: { type: "ephemeral" },
+ cache_control: cacheControl,
},
]
: message.content.map((content, contentIndex) =>
contentIndex === message.content.length - 1
- ? { ...content, cache_control: { type: "ephemeral" } }
+ ? { ...content, cache_control: cacheControl }
: content,
),
}
@@ -76,6 +91,7 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
// tool_choice: { type: "auto" },
// tools: tools,
stream: true,
+ thinking,
},
(() => {
// prompt caching: https://x.com/alexalbert__/status/1823751995901272068
@@ -114,8 +130,9 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
for await (const chunk of stream) {
switch (chunk.type) {
case "message_start":
- // tells us cache reads/writes/input/output
+ // Tells us cache reads/writes/input/output.
const usage = chunk.message.usage
+
yield {
type: "usage",
inputTokens: usage.input_tokens || 0,
@@ -123,43 +140,41 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
cacheWriteTokens: usage.cache_creation_input_tokens || undefined,
cacheReadTokens: usage.cache_read_input_tokens || undefined,
}
+
break
case "message_delta":
- // tells us stop_reason, stop_sequence, and output tokens along the way and at the end of the message
-
+ // Tells us stop_reason, stop_sequence, and output tokens
+ // along the way and at the end of the message.
yield {
type: "usage",
inputTokens: 0,
outputTokens: chunk.usage.output_tokens || 0,
}
+
break
case "message_stop":
- // no usage data, just an indicator that the message is done
+ // No usage data, just an indicator that the message is done.
break
case "content_block_start":
switch (chunk.content_block.type) {
+ case "thinking":
+ yield { type: "reasoning", text: chunk.content_block.thinking }
+ break
case "text":
- // we may receive multiple text blocks, in which case just insert a line break between them
+ // We may receive multiple text blocks, in which
+ // case just insert a line break between them.
if (chunk.index > 0) {
- yield {
- type: "text",
- text: "\n",
- }
- }
- yield {
- type: "text",
- text: chunk.content_block.text,
+ yield { type: "text", text: "\n" }
}
+
+ yield { type: "text", text: chunk.content_block.text }
break
}
break
case "content_block_delta":
switch (chunk.delta.type) {
case "text_delta":
- yield {
- type: "text",
- text: chunk.delta.text,
- }
+ yield { type: "text", text: chunk.delta.text }
break
}
break
diff --git a/src/shared/api.ts b/src/shared/api.ts
index 9c91f8b76dd..cea760c7760 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -21,6 +21,7 @@ export interface ApiHandlerOptions {
apiModelId?: string
apiKey?: string // anthropic
anthropicBaseUrl?: string
+ anthropicThinking?: number
vsCodeLmModelSelector?: vscode.LanguageModelChatSelector
glamaModelId?: string
glamaModelInfo?: ModelInfo
From 972b5424ec9d3bd5ead7557cae81e1a54eaa7e18 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 24 Feb 2025 23:53:22 +0000
Subject: [PATCH 028/145] changeset version bump
---
.changeset/fifty-files-jog.md | 5 -----
CHANGELOG.md | 6 ++++++
package-lock.json | 4 ++--
package.json | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
delete mode 100644 .changeset/fifty-files-jog.md
diff --git a/.changeset/fifty-files-jog.md b/.changeset/fifty-files-jog.md
deleted file mode 100644
index 6a166a5b611..00000000000
--- a/.changeset/fifty-files-jog.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"roo-cline": patch
----
-
-v3.7.2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83b84e1d413..2c688be8cb8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Roo Code Changelog
+## 3.7.2
+
+### Patch Changes
+
+- v3.7.2
+
## [3.7.1]
- Add AWS Bedrock support for Sonnet 3.7 and update some defaults to Sonnet 3.7 instead of 3.5
diff --git a/package-lock.json b/package-lock.json
index b8c65fd8e8d..f2c9c75aad4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "roo-cline",
- "version": "3.7.1",
+ "version": "3.7.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "roo-cline",
- "version": "3.7.1",
+ "version": "3.7.2",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
"@anthropic-ai/sdk": "^0.26.0",
diff --git a/package.json b/package.json
index 76d1273e5c8..5b4eef2813a 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"displayName": "Roo Code (prev. Roo Cline)",
"description": "An AI-powered autonomous coding agent that lives in your editor.",
"publisher": "RooVeterinaryInc",
- "version": "3.7.1",
+ "version": "3.7.2",
"icon": "assets/icons/rocket.png",
"galleryBanner": {
"color": "#617A91",
From 6a4e4ec8b2aefc07f428236b34b2a7e59103fb51 Mon Sep 17 00:00:00 2001
From: R00-B0T
Date: Mon, 24 Feb 2025 23:53:47 +0000
Subject: [PATCH 029/145] Updating CHANGELOG.md format
---
CHANGELOG.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c688be8cb8..372c15181e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,6 @@
# Roo Code Changelog
-## 3.7.2
-
-### Patch Changes
+## [3.7.2]
- v3.7.2
From 22391e5011c3dfbcfaa4dc1d5620e63fa9b2bdd3 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 15:55:04 -0800
Subject: [PATCH 030/145] Fix type errors
---
src/api/transform/bedrock-converse-format.ts | 4 +++-
src/api/transform/gemini-format.ts | 15 ++++-----------
src/api/transform/openai-format.ts | 3 +++
src/api/transform/simple-format.ts | 11 +----------
src/api/transform/vscode-lm-format.ts | 3 +++
src/core/Cline.ts | 4 +---
src/integrations/misc/export-markdown.ts | 9 +--------
7 files changed, 16 insertions(+), 33 deletions(-)
diff --git a/src/api/transform/bedrock-converse-format.ts b/src/api/transform/bedrock-converse-format.ts
index 07529db1bc0..e4dc9eecc85 100644
--- a/src/api/transform/bedrock-converse-format.ts
+++ b/src/api/transform/bedrock-converse-format.ts
@@ -193,6 +193,8 @@ export function convertToAnthropicMessage(
usage: {
input_tokens: streamEvent.metadata.usage.inputTokens || 0,
output_tokens: streamEvent.metadata.usage.outputTokens || 0,
+ cache_creation_input_tokens: null,
+ cache_read_input_tokens: null,
},
}
}
@@ -203,7 +205,7 @@ export function convertToAnthropicMessage(
return {
type: "message",
role: "assistant",
- content: [{ type: "text", text: text }],
+ content: [{ type: "text", text: text, citations: null }],
model: modelId,
}
}
diff --git a/src/api/transform/gemini-format.ts b/src/api/transform/gemini-format.ts
index 935e47147aa..3a149dc149b 100644
--- a/src/api/transform/gemini-format.ts
+++ b/src/api/transform/gemini-format.ts
@@ -11,16 +11,7 @@ import {
TextPart,
} from "@google/generative-ai"
-export function convertAnthropicContentToGemini(
- content:
- | string
- | Array<
- | Anthropic.Messages.TextBlockParam
- | Anthropic.Messages.ImageBlockParam
- | Anthropic.Messages.ToolUseBlockParam
- | Anthropic.Messages.ToolResultBlockParam
- >,
-): Part[] {
+export function convertAnthropicContentToGemini(content: Anthropic.Messages.MessageParam["content"]): Part[] {
if (typeof content === "string") {
return [{ text: content } as TextPart]
}
@@ -140,7 +131,7 @@ export function convertGeminiResponseToAnthropic(
// Add the main text response
const text = response.text()
if (text) {
- content.push({ type: "text", text })
+ content.push({ type: "text", text, citations: null })
}
// Add function calls as tool_use blocks
@@ -190,6 +181,8 @@ export function convertGeminiResponseToAnthropic(
usage: {
input_tokens: response.usageMetadata?.promptTokenCount ?? 0,
output_tokens: response.usageMetadata?.candidatesTokenCount ?? 0,
+ cache_creation_input_tokens: null,
+ cache_read_input_tokens: null,
},
}
}
diff --git a/src/api/transform/openai-format.ts b/src/api/transform/openai-format.ts
index fe23b9b2ff4..f421769054f 100644
--- a/src/api/transform/openai-format.ts
+++ b/src/api/transform/openai-format.ts
@@ -158,6 +158,7 @@ export function convertToAnthropicMessage(
{
type: "text",
text: openAiMessage.content || "",
+ citations: null,
},
],
model: completion.model,
@@ -178,6 +179,8 @@ export function convertToAnthropicMessage(
usage: {
input_tokens: completion.usage?.prompt_tokens || 0,
output_tokens: completion.usage?.completion_tokens || 0,
+ cache_creation_input_tokens: null,
+ cache_read_input_tokens: null,
},
}
diff --git a/src/api/transform/simple-format.ts b/src/api/transform/simple-format.ts
index c1e4895bba9..39049f76c27 100644
--- a/src/api/transform/simple-format.ts
+++ b/src/api/transform/simple-format.ts
@@ -3,16 +3,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
/**
* Convert complex content blocks to simple string content
*/
-export function convertToSimpleContent(
- content:
- | string
- | Array<
- | Anthropic.Messages.TextBlockParam
- | Anthropic.Messages.ImageBlockParam
- | Anthropic.Messages.ToolUseBlockParam
- | Anthropic.Messages.ToolResultBlockParam
- >,
-): string {
+export function convertToSimpleContent(content: Anthropic.Messages.MessageParam["content"]): string {
if (typeof content === "string") {
return content
}
diff --git a/src/api/transform/vscode-lm-format.ts b/src/api/transform/vscode-lm-format.ts
index 6d7bea92bad..f258dd17328 100644
--- a/src/api/transform/vscode-lm-format.ts
+++ b/src/api/transform/vscode-lm-format.ts
@@ -175,6 +175,7 @@ export async function convertToAnthropicMessage(
return {
type: "text",
text: part.value,
+ citations: null,
}
}
@@ -195,6 +196,8 @@ export async function convertToAnthropicMessage(
usage: {
input_tokens: 0,
output_tokens: 0,
+ cache_creation_input_tokens: null,
+ cache_read_input_tokens: null,
},
}
}
diff --git a/src/core/Cline.ts b/src/core/Cline.ts
index f1f5e41b331..549cec5eea9 100644
--- a/src/core/Cline.ts
+++ b/src/core/Cline.ts
@@ -69,9 +69,7 @@ const cwd =
vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution
type ToolResponse = string | Array
-type UserContent = Array<
- Anthropic.TextBlockParam | Anthropic.ImageBlockParam | Anthropic.ToolUseBlockParam | Anthropic.ToolResultBlockParam
->
+type UserContent = Array
export type ClineOptions = {
provider: ClineProvider
diff --git a/src/integrations/misc/export-markdown.ts b/src/integrations/misc/export-markdown.ts
index 2aa9d7b6edc..05b31671d85 100644
--- a/src/integrations/misc/export-markdown.ts
+++ b/src/integrations/misc/export-markdown.ts
@@ -41,14 +41,7 @@ export async function downloadTask(dateTs: number, conversationHistory: Anthropi
}
}
-export function formatContentBlockToMarkdown(
- block:
- | Anthropic.TextBlockParam
- | Anthropic.ImageBlockParam
- | Anthropic.ToolUseBlockParam
- | Anthropic.ToolResultBlockParam,
- // messages: Anthropic.MessageParam[]
-): string {
+export function formatContentBlockToMarkdown(block: Anthropic.Messages.ContentBlockParam): string {
switch (block.type) {
case "text":
return block.text
From f69e9c16b3252d7637c8ee0e26a3ceb9308dea13 Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 17:58:48 -0600
Subject: [PATCH 031/145] Update CHANGELOG.md
---
CHANGELOG.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 372c15181e7..b30e77534e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,9 @@
## [3.7.2]
-- v3.7.2
+- Fix computer use and prompt caching for OpenRouter's `anthropic:claude-3.7-sonnet:beta` (thanks @cte!)
+- Fix sliding window calculations for Sonnet 3.7 that were causing a context window overflow (thanks @cte!)
+- Encourage diff editing more strongly in the system prompt (thanks @hannesrudolph!)
## [3.7.1]
From 83a909713657b65f0e203ce552dd2bdf006f2e4f Mon Sep 17 00:00:00 2001
From: Matt Rubens
Date: Mon, 24 Feb 2025 18:00:03 -0600
Subject: [PATCH 032/145] Update CHANGELOG.md
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b30e77534e3..381e0907eb1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
## [3.7.2]
-- Fix computer use and prompt caching for OpenRouter's `anthropic:claude-3.7-sonnet:beta` (thanks @cte!)
+- Fix computer use and prompt caching for OpenRouter's `anthropic/claude-3.7-sonnet:beta` (thanks @cte!)
- Fix sliding window calculations for Sonnet 3.7 that were causing a context window overflow (thanks @cte!)
- Encourage diff editing more strongly in the system prompt (thanks @hannesrudolph!)
From 543b68f785f98f62976655d5f4510bccfd0ffb42 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 16:09:31 -0800
Subject: [PATCH 033/145] Fix tests
---
src/api/providers/__tests__/anthropic.test.ts | 76 +++++--------------
.../__tests__/bedrock-converse-format.test.ts | 8 +-
.../transform/__tests__/openai-format.test.ts | 6 ++
.../__tests__/vscode-lm-format.test.ts | 3 +
4 files changed, 33 insertions(+), 60 deletions(-)
diff --git a/src/api/providers/__tests__/anthropic.test.ts b/src/api/providers/__tests__/anthropic.test.ts
index df0050ab9cd..ff7bdb40549 100644
--- a/src/api/providers/__tests__/anthropic.test.ts
+++ b/src/api/providers/__tests__/anthropic.test.ts
@@ -1,50 +1,13 @@
+// npx jest src/api/providers/__tests__/anthropic.test.ts
+
import { AnthropicHandler } from "../anthropic"
import { ApiHandlerOptions } from "../../../shared/api"
-import { ApiStream } from "../../transform/stream"
-import { Anthropic } from "@anthropic-ai/sdk"
-// Mock Anthropic client
-const mockBetaCreate = jest.fn()
const mockCreate = jest.fn()
+
jest.mock("@anthropic-ai/sdk", () => {
return {
Anthropic: jest.fn().mockImplementation(() => ({
- beta: {
- promptCaching: {
- messages: {
- create: mockBetaCreate.mockImplementation(async () => ({
- async *[Symbol.asyncIterator]() {
- yield {
- type: "message_start",
- message: {
- usage: {
- input_tokens: 100,
- output_tokens: 50,
- cache_creation_input_tokens: 20,
- cache_read_input_tokens: 10,
- },
- },
- }
- yield {
- type: "content_block_start",
- index: 0,
- content_block: {
- type: "text",
- text: "Hello",
- },
- }
- yield {
- type: "content_block_delta",
- delta: {
- type: "text_delta",
- text: " world",
- },
- }
- },
- })),
- },
- },
- },
messages: {
create: mockCreate.mockImplementation(async (options) => {
if (!options.stream) {
@@ -65,16 +28,26 @@ jest.mock("@anthropic-ai/sdk", () => {
type: "message_start",
message: {
usage: {
- input_tokens: 10,
- output_tokens: 5,
+ input_tokens: 100,
+ output_tokens: 50,
+ cache_creation_input_tokens: 20,
+ cache_read_input_tokens: 10,
},
},
}
yield {
type: "content_block_start",
+ index: 0,
content_block: {
type: "text",
- text: "Test response",
+ text: "Hello",
+ },
+ }
+ yield {
+ type: "content_block_delta",
+ delta: {
+ type: "text_delta",
+ text: " world",
},
}
},
@@ -95,7 +68,6 @@ describe("AnthropicHandler", () => {
apiModelId: "claude-3-5-sonnet-20241022",
}
handler = new AnthropicHandler(mockOptions)
- mockBetaCreate.mockClear()
mockCreate.mockClear()
})
@@ -126,17 +98,6 @@ describe("AnthropicHandler", () => {
describe("createMessage", () => {
const systemPrompt = "You are a helpful assistant."
- const messages: Anthropic.Messages.MessageParam[] = [
- {
- role: "user",
- content: [
- {
- type: "text" as const,
- text: "Hello!",
- },
- ],
- },
- ]
it("should handle prompt caching for supported models", async () => {
const stream = handler.createMessage(systemPrompt, [
@@ -173,9 +134,8 @@ describe("AnthropicHandler", () => {
expect(textChunks[0].text).toBe("Hello")
expect(textChunks[1].text).toBe(" world")
- // Verify beta API was used
- expect(mockBetaCreate).toHaveBeenCalled()
- expect(mockCreate).not.toHaveBeenCalled()
+ // Verify API
+ expect(mockCreate).toHaveBeenCalled()
})
})
diff --git a/src/api/transform/__tests__/bedrock-converse-format.test.ts b/src/api/transform/__tests__/bedrock-converse-format.test.ts
index c46eb94a2e0..fdd29c75bf2 100644
--- a/src/api/transform/__tests__/bedrock-converse-format.test.ts
+++ b/src/api/transform/__tests__/bedrock-converse-format.test.ts
@@ -1,3 +1,5 @@
+// npx jest src/api/transform/__tests__/bedrock-converse-format.test.ts
+
import { convertToBedrockConverseMessages, convertToAnthropicMessage } from "../bedrock-converse-format"
import { Anthropic } from "@anthropic-ai/sdk"
import { ContentBlock, ToolResultContentBlock } from "@aws-sdk/client-bedrock-runtime"
@@ -187,6 +189,8 @@ describe("bedrock-converse-format", () => {
usage: {
input_tokens: 10,
output_tokens: 20,
+ cache_creation_input_tokens: null,
+ cache_read_input_tokens: null,
},
})
})
@@ -205,7 +209,7 @@ describe("bedrock-converse-format", () => {
expect(result).toEqual({
type: "message",
role: "assistant",
- content: [{ type: "text", text: "Hello" }],
+ content: [{ type: "text", text: "Hello", citations: null }],
model: "test-model",
})
})
@@ -224,7 +228,7 @@ describe("bedrock-converse-format", () => {
expect(result).toEqual({
type: "message",
role: "assistant",
- content: [{ type: "text", text: " world" }],
+ content: [{ type: "text", text: " world", citations: null }],
model: "test-model",
})
})
diff --git a/src/api/transform/__tests__/openai-format.test.ts b/src/api/transform/__tests__/openai-format.test.ts
index f37d369d701..812208acd1e 100644
--- a/src/api/transform/__tests__/openai-format.test.ts
+++ b/src/api/transform/__tests__/openai-format.test.ts
@@ -1,3 +1,5 @@
+// npx jest src/api/transform/__tests__/openai-format.test.ts
+
import { convertToOpenAiMessages, convertToAnthropicMessage } from "../openai-format"
import { Anthropic } from "@anthropic-ai/sdk"
import OpenAI from "openai"
@@ -172,11 +174,14 @@ describe("OpenAI Format Transformations", () => {
expect(anthropicMessage.content[0]).toEqual({
type: "text",
text: "Hello there!",
+ citations: null,
})
expect(anthropicMessage.stop_reason).toBe("end_turn")
expect(anthropicMessage.usage).toEqual({
input_tokens: 10,
output_tokens: 5,
+ cache_creation_input_tokens: null,
+ cache_read_input_tokens: null,
})
})
@@ -221,6 +226,7 @@ describe("OpenAI Format Transformations", () => {
expect(anthropicMessage.content[0]).toEqual({
type: "text",
text: "Let me check the weather.",
+ citations: null,
})
expect(anthropicMessage.content[1]).toEqual({
type: "tool_use",
diff --git a/src/api/transform/__tests__/vscode-lm-format.test.ts b/src/api/transform/__tests__/vscode-lm-format.test.ts
index b27097fd17e..eb800e2b7a8 100644
--- a/src/api/transform/__tests__/vscode-lm-format.test.ts
+++ b/src/api/transform/__tests__/vscode-lm-format.test.ts
@@ -1,3 +1,5 @@
+// npx jest src/api/transform/__tests__/vscode-lm-format.test.ts
+
import { Anthropic } from "@anthropic-ai/sdk"
import * as vscode from "vscode"
import { convertToVsCodeLmMessages, convertToAnthropicRole, convertToAnthropicMessage } from "../vscode-lm-format"
@@ -216,6 +218,7 @@ describe("vscode-lm-format", () => {
expect(result.content[0]).toEqual({
type: "text",
text: "Hello",
+ citations: null,
})
expect(result.id).toBe("test-uuid")
})
From bf1aa4c7b266325d7dee86dd290dbff39f32f608 Mon Sep 17 00:00:00 2001
From: cte
Date: Mon, 24 Feb 2025 16:47:27 -0800
Subject: [PATCH 034/145] Add settings
---
src/api/providers/anthropic.ts | 37 +++++++++++++------
.../src/components/settings/ApiOptions.tsx | 31 +++++++++++++++-
2 files changed, 55 insertions(+), 13 deletions(-)
diff --git a/src/api/providers/anthropic.ts b/src/api/providers/anthropic.ts
index 4bde475e80d..0d4b67b0678 100644
--- a/src/api/providers/anthropic.ts
+++ b/src/api/providers/anthropic.ts
@@ -33,12 +33,16 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
let stream: AnthropicStream
const cacheControl: CacheControlEphemeral = { type: "ephemeral" }
const modelId = this.getModel().id
+ const maxTokens = this.getModel().info.maxTokens || 8192
+ let temperature = this.options.modelTemperature ?? ANTHROPIC_DEFAULT_TEMPERATURE
let thinking: BetaThinkingConfigParam | undefined = undefined
if (THINKING_MODELS.includes(modelId)) {
thinking = this.options.anthropicThinking
? { type: "enabled", budget_tokens: this.options.anthropicThinking }
: { type: "disabled" }
+
+ temperature = 1.0
}
switch (modelId) {
@@ -62,22 +66,18 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
stream = await this.client.messages.create(
{
model: modelId,
- max_tokens: this.getModel().info.maxTokens || 8192,
- temperature: this.options.modelTemperature ?? ANTHROPIC_DEFAULT_TEMPERATURE,
- system: [{ text: systemPrompt, type: "text", cache_control: { type: "ephemeral" } }], // setting cache breakpoint for system prompt so new tasks can reuse it
+ max_tokens: maxTokens,
+ temperature,
+ thinking,
+ // Setting cache breakpoint for system prompt so new tasks can reuse it.
+ system: [{ text: systemPrompt, type: "text", cache_control: cacheControl }],
messages: messages.map((message, index) => {
if (index === lastUserMsgIndex || index === secondLastMsgUserIndex) {
return {
...message,
content:
typeof message.content === "string"
- ? [
- {
- type: "text",
- text: message.content,
- cache_control: cacheControl,
- },
- ]
+ ? [{ type: "text", text: message.content, cache_control: cacheControl }]
: message.content.map((content, contentIndex) =>
contentIndex === message.content.length - 1
? { ...content, cache_control: cacheControl }
@@ -91,7 +91,6 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
// tool_choice: { type: "auto" },
// tools: tools,
stream: true,
- thinking,
},
(() => {
// prompt caching: https://x.com/alexalbert__/status/1823751995901272068
@@ -132,6 +131,7 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
case "message_start":
// Tells us cache reads/writes/input/output.
const usage = chunk.message.usage
+ console.log("usage", usage)
yield {
type: "usage",
@@ -158,6 +158,12 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
case "content_block_start":
switch (chunk.content_block.type) {
case "thinking":
+ // We may receive multiple text blocks, in which
+ // case just insert a line break between them.
+ if (chunk.index > 0) {
+ yield { type: "reasoning", text: "\n" }
+ }
+
yield { type: "reasoning", text: chunk.content_block.thinking }
break
case "text":
@@ -173,10 +179,14 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
break
case "content_block_delta":
switch (chunk.delta.type) {
+ case "thinking_delta":
+ yield { type: "reasoning", text: chunk.delta.thinking }
+ break
case "text_delta":
yield { type: "text", text: chunk.delta.text }
break
}
+
break
case "content_block_stop":
break
@@ -186,10 +196,12 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
getModel(): { id: AnthropicModelId; info: ModelInfo } {
const modelId = this.options.apiModelId
+
if (modelId && modelId in anthropicModels) {
const id = modelId as AnthropicModelId
return { id, info: anthropicModels[id] }
}
+
return { id: anthropicDefaultModelId, info: anthropicModels[anthropicDefaultModelId] }
}
@@ -204,14 +216,17 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
})
const content = response.content[0]
+
if (content.type === "text") {
return content.text
}
+
return ""
} catch (error) {
if (error instanceof Error) {
throw new Error(`Anthropic completion error: ${error.message}`)
}
+
throw error
}
}
diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx
index 1303e79c7ab..48529d48527 100644
--- a/webview-ui/src/components/settings/ApiOptions.tsx
+++ b/webview-ui/src/components/settings/ApiOptions.tsx
@@ -43,6 +43,7 @@ import { UnboundModelPicker } from "./UnboundModelPicker"
import { ModelInfoView } from "./ModelInfoView"
import { DROPDOWN_Z_INDEX } from "./styles"
import { RequestyModelPicker } from "./RequestyModelPicker"
+import { Slider } from "../ui"
interface ApiOptionsProps {
uriScheme: string | undefined
@@ -65,6 +66,8 @@ const ApiOptions = ({
const [lmStudioModels, setLmStudioModels] = useState([])
const [vsCodeLmModels, setVsCodeLmModels] = useState([])
const [anthropicBaseUrlSelected, setAnthropicBaseUrlSelected] = useState(!!apiConfiguration?.anthropicBaseUrl)
+ const [anthropicThinkingEnabled, setAnthropicThinkingEnabled] = useState(!!apiConfiguration?.anthropicThinking)
+ const [anthropicThinkingBudget, setAnthropicThinkingBudget] = useState(apiConfiguration?.anthropicThinking ?? 1024)
const [azureApiVersionSelected, setAzureApiVersionSelected] = useState(!!apiConfiguration?.azureApiVersion)
const [openRouterBaseUrlSelected, setOpenRouterBaseUrlSelected] = useState(!!apiConfiguration?.openRouterBaseUrl)
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false)
@@ -1224,7 +1227,6 @@ const ApiOptions = ({
)}
{selectedProvider === "glama" && }
-
{selectedProvider === "openrouter" && }
{selectedProvider === "requesty" && }
@@ -1258,8 +1260,33 @@ const ApiOptions = ({
>
)}
+ {selectedProvider === "anthropic" && (
+