diff --git a/CHANGELOG.md b/CHANGELOG.md
index e13f8a8..209577e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Roo Cline Changelog
+## [2.1.15]
+
+- Incorporate dbasclpy's [PR](https://github.com/RooVetGit/Roo-Cline/pull/54) to add support for gemini-exp-1206
+- Make it clear that diff editing is very experimental
+
## [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)
diff --git a/README.md b/README.md
index 13eebb0..0bda342 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,11 @@ A fork of Cline, an autonomous coding agent, with some added experimental config
- Auto-approval capabilities for commands, write, and browser operations
- Support for .clinerules per-project custom instructions
- Ability to run side-by-side with Cline
+- Code is unit-tested
- Support for playing sound effects
- Support for OpenRouter compression
-- Support for editing through diffs
+- Support for editing through diffs (very experimental)
+- Support for gemini-exp-1206
Here's an example of Roo-Cline autonomously creating a snake game with "Always approve write operations" and "Always approve browser actions" turned on:
diff --git a/package-lock.json b/package-lock.json
index 7309b5d..a5b69a4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "roo-cline",
- "version": "2.1.14",
+ "version": "2.1.15",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "roo-cline",
- "version": "2.1.14",
+ "version": "2.1.15",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
"@anthropic-ai/sdk": "^0.26.0",
diff --git a/package.json b/package.json
index d147892..4692459 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"displayName": "Roo Cline",
"description": "A fork of Cline, an autonomous coding agent, with some added experimental configuration and automation features.",
"publisher": "RooVeterinaryInc",
- "version": "2.1.14",
+ "version": "2.1.15",
"icon": "assets/icons/rocket.png",
"galleryBanner": {
"color": "#617A91",
@@ -147,7 +147,7 @@
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"check-types": "tsc --noEmit",
"lint": "eslint src --ext ts",
- "test": "vscode-test",
+ "test": "jest",
"install:all": "npm install && cd webview-ui && npm install",
"start:webview": "cd webview-ui && npm run start",
"build:webview": "cd webview-ui && npm run build",
diff --git a/src/api/providers/__tests__/openrouter.test.ts b/src/api/providers/__tests__/openrouter.test.ts
index fa3fcfa..d2df3ee 100644
--- a/src/api/providers/__tests__/openrouter.test.ts
+++ b/src/api/providers/__tests__/openrouter.test.ts
@@ -35,8 +35,8 @@ describe('OpenRouterHandler', () => {
baseURL: 'https://openrouter.ai/api/v1',
apiKey: mockOptions.openRouterApiKey,
defaultHeaders: {
- 'HTTP-Referer': 'https://cline.bot',
- 'X-Title': 'Cline',
+ 'HTTP-Referer': 'https://github.com/RooVetGit/Roo-Cline',
+ 'X-Title': 'Roo-Cline',
},
})
})
diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts
index acb01f7..c2c34d8 100644
--- a/src/api/providers/openrouter.ts
+++ b/src/api/providers/openrouter.ts
@@ -27,8 +27,8 @@ export class OpenRouterHandler implements ApiHandler {
baseURL: "https://openrouter.ai/api/v1",
apiKey: this.options.openRouterApiKey,
defaultHeaders: {
- "HTTP-Referer": "https://cline.bot", // Optional, for including your app on openrouter.ai rankings.
- "X-Title": "Cline", // Optional. Shows in rankings on openrouter.ai.
+ "HTTP-Referer": "https://github.com/RooVetGit/Roo-Cline", // Optional, for including your app on openrouter.ai rankings.
+ "X-Title": "Roo-Cline", // Optional. Shows in rankings on openrouter.ai.
},
})
}
diff --git a/src/core/Cline.ts b/src/core/Cline.ts
index 3c32a35..4e747d9 100644
--- a/src/core/Cline.ts
+++ b/src/core/Cline.ts
@@ -1,6 +1,6 @@
import { Anthropic } from "@anthropic-ai/sdk"
-import * as diff from "diff"
import cloneDeep from "clone-deep"
+import { DiffStrategy, getDiffStrategy, UnifiedDiffStrategy } from "./diff/DiffStrategy"
import delay from "delay"
import fs from "fs/promises"
import os from "os"
@@ -65,7 +65,7 @@ export class Cline {
private browserSession: BrowserSession
private didEditFile: boolean = false
customInstructions?: string
- diffEnabled?: boolean
+ diffStrategy?: DiffStrategy
apiConversationHistory: Anthropic.MessageParam[] = []
clineMessages: ClineMessage[] = []
@@ -107,7 +107,9 @@ export class Cline {
this.browserSession = new BrowserSession(provider.context)
this.diffViewProvider = new DiffViewProvider(cwd)
this.customInstructions = customInstructions
- this.diffEnabled = diffEnabled
+ if (diffEnabled && this.api.getModel().id) {
+ this.diffStrategy = getDiffStrategy(this.api.getModel().id)
+ }
if (historyItem) {
this.taskId = historyItem.id
this.resumeTaskFromHistory()
@@ -752,7 +754,7 @@ export class Cline {
}
async *attemptApiRequest(previousApiReqIndex: number): ApiStream {
- const systemPrompt = await SYSTEM_PROMPT(cwd, this.api.getModel().info.supportsComputerUse ?? false, !!this.diffEnabled) + await addCustomInstructions(this.customInstructions ?? '', cwd)
+ const systemPrompt = await SYSTEM_PROMPT(cwd, this.api.getModel().info.supportsComputerUse ?? false, this.diffStrategy) + await addCustomInstructions(this.customInstructions ?? '', cwd)
// If the previous API request's total token usage is close to the context window, truncate the conversation history to free up space for the new request
if (previousApiReqIndex >= 0) {
@@ -1104,7 +1106,7 @@ export class Cline {
// Check for code omissions before proceeding
if (detectCodeOmission(this.diffViewProvider.originalContent || "", newContent)) {
- if (this.diffEnabled) {
+ if (this.diffStrategy) {
await this.diffViewProvider.revertChanges()
pushToolResult(formatResponse.toolError(
"Content appears to be truncated. 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."
@@ -1220,25 +1222,13 @@ export class Cline {
const originalContent = await fs.readFile(absolutePath, "utf-8")
// Apply the diff to the original content
- let newContent = diff.applyPatch(originalContent, diffContent) as string | false
+ let newContent = this.diffStrategy?.applyDiff(originalContent, diffContent) ?? false
if (newContent === false) {
await this.say("error", `Error applying diff to file: ${absolutePath}`)
pushToolResult(`Error applying diff to file: ${absolutePath}`)
break
}
- // Create a diff for display purposes
- const diffRepresentation = diff
- .diffLines(originalContent, newContent)
- .map((part) => {
- const prefix = part.added ? "+" : part.removed ? "-" : " "
- return (part.value || "")
- .split("\n")
- .map((line) => (line ? prefix + line : ""))
- .join("\n")
- })
- .join("")
-
// Show diff view before asking for approval
this.diffViewProvider.editType = "modify"
await this.diffViewProvider.open(relPath);
@@ -1247,7 +1237,7 @@ export class Cline {
const completeMessage = JSON.stringify({
...sharedMessageProps,
- diff: diffRepresentation,
+ diff: diffContent,
} satisfies ClineSayTool)
const didApprove = await askApproval("tool", completeMessage)
@@ -2287,5 +2277,4 @@ export class Cline {
return `\n${details.trim()}\n`
}
-}
-
+}
\ No newline at end of file
diff --git a/src/core/diff/DiffStrategy.ts b/src/core/diff/DiffStrategy.ts
new file mode 100644
index 0000000..439c719
--- /dev/null
+++ b/src/core/diff/DiffStrategy.ts
@@ -0,0 +1,16 @@
+import type { DiffStrategy } from './types'
+import { UnifiedDiffStrategy } from './strategies/unified'
+
+/**
+ * Get the appropriate diff strategy for the given model
+ * @param model The name of the model being used (e.g., 'gpt-4', 'claude-3-opus')
+ * @returns The appropriate diff strategy for the model
+ */
+export function getDiffStrategy(model: string): DiffStrategy {
+ // For now, return UnifiedDiffStrategy for all models
+ // This architecture allows for future optimizations based on model capabilities
+ return new UnifiedDiffStrategy()
+}
+
+export type { DiffStrategy }
+export { UnifiedDiffStrategy }
diff --git a/src/core/diff/strategies/__tests__/unified.test.ts b/src/core/diff/strategies/__tests__/unified.test.ts
new file mode 100644
index 0000000..4e6c449
--- /dev/null
+++ b/src/core/diff/strategies/__tests__/unified.test.ts
@@ -0,0 +1,214 @@
+import { UnifiedDiffStrategy } from '../unified'
+
+describe('UnifiedDiffStrategy', () => {
+ let strategy: UnifiedDiffStrategy
+
+ beforeEach(() => {
+ strategy = new UnifiedDiffStrategy()
+ })
+
+ describe('getToolDescription', () => {
+ it('should return tool description with correct cwd', () => {
+ const cwd = '/test/path'
+ const description = strategy.getToolDescription(cwd)
+
+ expect(description).toContain('apply_diff')
+ expect(description).toContain(cwd)
+ expect(description).toContain('Parameters:')
+ expect(description).toContain('Format Requirements:')
+ })
+ })
+
+ describe('applyDiff', () => {
+ it('should successfully apply a function modification diff', () => {
+ const originalContent = `import { Logger } from '../logger';
+
+function calculateTotal(items: number[]): number {
+ return items.reduce((sum, item) => {
+ return sum + item;
+ }, 0);
+}
+
+export { calculateTotal };`
+
+ const diffContent = `--- src/utils/helper.ts
++++ src/utils/helper.ts
+@@ -1,9 +1,10 @@
+ import { Logger } from '../logger';
+
+ function calculateTotal(items: number[]): number {
+- return items.reduce((sum, item) => {
+- return sum + item;
++ const total = items.reduce((sum, item) => {
++ return sum + item * 1.1; // Add 10% markup
+ }, 0);
++ return Math.round(total * 100) / 100; // Round to 2 decimal places
+ }
+
+ export { calculateTotal };`
+
+ const expected = `import { Logger } from '../logger';
+
+function calculateTotal(items: number[]): number {
+ const total = items.reduce((sum, item) => {
+ return sum + item * 1.1; // Add 10% markup
+ }, 0);
+ return Math.round(total * 100) / 100; // Round to 2 decimal places
+}
+
+export { calculateTotal };`
+
+ const result = strategy.applyDiff(originalContent, diffContent)
+ expect(result).toBe(expected)
+ })
+
+ it('should successfully apply a diff adding a new method', () => {
+ const originalContent = `class Calculator {
+ add(a: number, b: number): number {
+ return a + b;
+ }
+}`
+
+ const diffContent = `--- src/Calculator.ts
++++ src/Calculator.ts
+@@ -1,5 +1,9 @@
+ class Calculator {
+ add(a: number, b: number): number {
+ return a + b;
+ }
++
++ multiply(a: number, b: number): number {
++ return a * b;
++ }
+ }`
+
+ const expected = `class Calculator {
+ add(a: number, b: number): number {
+ return a + b;
+ }
+
+ multiply(a: number, b: number): number {
+ return a * b;
+ }
+}`
+
+ const result = strategy.applyDiff(originalContent, diffContent)
+ expect(result).toBe(expected)
+ })
+
+ it('should successfully apply a diff modifying imports', () => {
+ const originalContent = `import { useState } from 'react';
+import { Button } from './components';
+
+function App() {
+ const [count, setCount] = useState(0);
+ return ;
+}`
+
+ const diffContent = `--- src/App.tsx
++++ src/App.tsx
+@@ -1,7 +1,8 @@
+-import { useState } from 'react';
++import { useState, useEffect } from 'react';
+ import { Button } from './components';
+
+ function App() {
+ const [count, setCount] = useState(0);
++ useEffect(() => { document.title = \`Count: \${count}\` }, [count]);
+ return ;
+ }`
+
+ const expected = `import { useState, useEffect } from 'react';
+import { Button } from './components';
+
+function App() {
+ const [count, setCount] = useState(0);
+ useEffect(() => { document.title = \`Count: \${count}\` }, [count]);
+ return ;
+}`
+
+ const result = strategy.applyDiff(originalContent, diffContent)
+ expect(result).toBe(expected)
+ })
+
+ it('should successfully apply a diff with multiple hunks', () => {
+ const originalContent = `import { readFile, writeFile } from 'fs';
+
+function processFile(path: string) {
+ readFile(path, 'utf8', (err, data) => {
+ if (err) throw err;
+ const processed = data.toUpperCase();
+ writeFile(path, processed, (err) => {
+ if (err) throw err;
+ });
+ });
+}
+
+export { processFile };`
+
+ const diffContent = `--- src/file-processor.ts
++++ src/file-processor.ts
+@@ -1,12 +1,14 @@
+-import { readFile, writeFile } from 'fs';
++import { promises as fs } from 'fs';
++import { join } from 'path';
+
+-function processFile(path: string) {
+- readFile(path, 'utf8', (err, data) => {
+- if (err) throw err;
++async function processFile(path: string) {
++ try {
++ const data = await fs.readFile(join(__dirname, path), 'utf8');
+ const processed = data.toUpperCase();
+- writeFile(path, processed, (err) => {
+- if (err) throw err;
+- });
+- });
++ await fs.writeFile(join(__dirname, path), processed);
++ } catch (error) {
++ console.error('Failed to process file:', error);
++ throw error;
++ }
+ }
+
+ export { processFile };`
+
+ const expected = `import { promises as fs } from 'fs';
+import { join } from 'path';
+
+async function processFile(path: string) {
+ try {
+ const data = await fs.readFile(join(__dirname, path), 'utf8');
+ const processed = data.toUpperCase();
+ await fs.writeFile(join(__dirname, path), processed);
+ } catch (error) {
+ console.error('Failed to process file:', error);
+ throw error;
+ }
+}
+
+export { processFile };`
+
+ const result = strategy.applyDiff(originalContent, diffContent)
+ expect(result).toBe(expected)
+ })
+
+ it('should handle empty original content', () => {
+ const originalContent = ''
+ const diffContent = `--- empty.ts
++++ empty.ts
+@@ -0,0 +1,3 @@
++export function greet(name: string): string {
++ return \`Hello, \${name}!\`;
++}`
+
+ const expected = `export function greet(name: string): string {
+ return \`Hello, \${name}!\`;
+}\n`
+
+ const result = strategy.applyDiff(originalContent, diffContent)
+ expect(result).toBe(expected)
+ })
+ })
+})
+
diff --git a/src/core/diff/strategies/unified.ts b/src/core/diff/strategies/unified.ts
new file mode 100644
index 0000000..9e95e09
--- /dev/null
+++ b/src/core/diff/strategies/unified.ts
@@ -0,0 +1,114 @@
+import { applyPatch } from "diff"
+import { DiffStrategy } from "../types"
+
+export class UnifiedDiffStrategy implements DiffStrategy {
+ getToolDescription(cwd: string): string {
+ 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:
+- path: (required) The path of the file to apply the diff to (relative to the current working directory ${cwd})
+- diff: (required) The diff content in unified format to apply to the file.
+
+Format Requirements:
+
+1. Header (REQUIRED):
+ \`\`\`
+ --- path/to/original/file
+ +++ path/to/modified/file
+ \`\`\`
+ - Must include both lines exactly as shown
+ - Use actual file paths
+ - NO timestamps after paths
+
+2. Hunks:
+ \`\`\`
+ @@ -lineStart,lineCount +lineStart,lineCount @@
+ -removed line
+ +added line
+ \`\`\`
+ - Each hunk starts with @@ showing line numbers for changes
+ - Format: @@ -originalStart,originalCount +newStart,newCount @@
+ - Use - for removed/changed lines
+ - Use + for new/modified lines
+ - Indentation must match exactly
+
+Complete Example:
+
+Original file (with line numbers):
+\`\`\`
+1 | import { Logger } from '../logger';
+2 |
+3 | function calculateTotal(items: number[]): number {
+4 | return items.reduce((sum, item) => {
+5 | return sum + item;
+6 | }, 0);
+7 | }
+8 |
+9 | export { calculateTotal };
+\`\`\`
+
+After applying the diff, the file would look like:
+\`\`\`
+1 | import { Logger } from '../logger';
+2 |
+3 | function calculateTotal(items: number[]): number {
+4 | const total = items.reduce((sum, item) => {
+5 | return sum + item * 1.1; // Add 10% markup
+6 | }, 0);
+7 | return Math.round(total * 100) / 100; // Round to 2 decimal places
+8 | }
+9 |
+10 | export { calculateTotal };
+\`\`\`
+
+Diff to modify the file:
+\`\`\`
+--- src/utils/helper.ts
++++ src/utils/helper.ts
+@@ -1,9 +1,10 @@
+ import { Logger } from '../logger';
+
+ function calculateTotal(items: number[]): number {
+- return items.reduce((sum, item) => {
+- return sum + item;
++ const total = items.reduce((sum, item) => {
++ return sum + item * 1.1; // Add 10% markup
+ }, 0);
++ return Math.round(total * 100) / 100; // Round to 2 decimal places
+ }
+
+ export { calculateTotal };
+\`\`\`
+
+Common Pitfalls:
+1. Missing or incorrect header lines
+2. Incorrect line numbers in @@ lines
+3. Wrong indentation in changed lines
+4. Incomplete context (missing lines that need changing)
+5. Not marking all modified lines with - and +
+
+Best Practices:
+1. Replace entire code blocks:
+ - Remove complete old version with - lines
+ - Add complete new version with + lines
+ - Include correct line numbers
+2. Moving code requires two hunks:
+ - First hunk: Remove from old location
+ - Second hunk: Add to new location
+3. One hunk per logical change
+4. Verify line numbers match the line numbers you have in the file
+
+Usage:
+
+File path here
+
+Your diff here
+
+`
+ }
+
+ applyDiff(originalContent: string, diffContent: string): string | false {
+ return applyPatch(originalContent, diffContent) as string | false
+ }
+}
diff --git a/src/core/diff/types.ts b/src/core/diff/types.ts
new file mode 100644
index 0000000..f4cdf17
--- /dev/null
+++ b/src/core/diff/types.ts
@@ -0,0 +1,19 @@
+/**
+ * Interface for implementing different diff strategies
+ */
+export interface DiffStrategy {
+ /**
+ * Get the tool description for this diff strategy
+ * @param cwd The current working directory
+ * @returns The complete tool description including format requirements and examples
+ */
+ getToolDescription(cwd: string): string
+
+ /**
+ * Apply a diff to the original content
+ * @param originalContent The original file content
+ * @param diffContent The diff content in the strategy's format
+ * @returns The new content after applying the diff, or false if the diff could not be applied
+ */
+ applyDiff(originalContent: string, diffContent: string): string | false
+}
diff --git a/src/core/prompts/system.ts b/src/core/prompts/system.ts
index b1672eb..531f215 100644
--- a/src/core/prompts/system.ts
+++ b/src/core/prompts/system.ts
@@ -1,4 +1,5 @@
import osName from "os-name"
+import { DiffStrategy } from "../diff/DiffStrategy"
import defaultShell from "default-shell"
import os from "os"
import fs from 'fs/promises'
@@ -7,7 +8,7 @@ import path from 'path'
export const SYSTEM_PROMPT = async (
cwd: string,
supportsComputerUse: boolean,
- diffEnabled: boolean
+ diffStrategy?: DiffStrategy
) => `You are Cline, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
====
@@ -67,77 +68,7 @@ Your file content here
-${diffEnabled ? `
-## apply_diff
-Description: Apply a diff to a file at the specified path. The diff should be in unified format ('diff -U0') and can be used to apply changes to a file. This tool is useful when you need to make specific modifications to a file based on a set of changes provided in a diff.
-
-Diff Format Requirements:
-
-1. Header (REQUIRED):
- \`\`\`
- --- path/to/original/file
- +++ path/to/modified/file
- \`\`\`
- - Must include both lines exactly as shown
- - Use actual file paths
- - NO timestamps after paths
-
-2. Hunks:
- \`\`\`
- @@ -lineStart,lineCount +lineStart,lineCount @@
- -removed line
- +added line
- \`\`\`
- - Each hunk starts with @@ showing line numbers for changes
- - Format: @@ -originalStart,originalCount +newStart,newCount @@
- - Use - for removed/changed lines
- - Use + for new/modified lines
- - Indentation must match exactly
-
-Complete Example:
-\`\`\`
---- src/utils/helper.ts
-+++ src/utils/helper.ts
-@@ -10,3 +10,4 @@
--function oldFunction(x: number): number {
-- return x + 1;
--}
-+function newFunction(x: number): number {
-+ const result = x + 2;
-+ return result;
-+}
-\`\`\`
-
-Common Pitfalls:
-1. Missing or incorrect header lines
-2. Incorrect line numbers in @@ lines
-3. Wrong indentation in changed lines
-4. Incomplete context (missing lines that need changing)
-5. Not marking all modified lines with - and +
-
-Best Practices:
-1. Replace entire code blocks:
- - Remove complete old version with - lines
- - Add complete new version with + lines
- - Include correct line numbers
-2. Moving code requires two hunks:
- - First hunk: Remove from old location
- - Second hunk: Add to new location
-3. One hunk per logical change
-4. Verify line numbers match the file
-
-Parameters:
-- path: (required) The path of the file to apply the diff to (relative to the current working directory ${cwd.toPosix()})
-- diff: (required) The diff in unified format (diff -U0) to apply to the file.
-Usage:
-
-File path here
-
-Your diff here
-
-`
- : ""
-}
+${diffStrategy ? diffStrategy.getToolDescription(cwd.toPosix()) : ""}
## search_files
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
@@ -294,7 +225,7 @@ CAPABILITIES
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('${cwd.toPosix()}') 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 ${diffEnabled ? "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 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."
@@ -311,7 +242,7 @@ RULES
- 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 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.
-${diffEnabled ? "- Prefer to use apply_diff over write_to_file when making changes to existing files, particularly when editing files more than 200 lines of code, as it allows you to apply specific modifications based on a set of changes provided in a diff. This is particularly useful when you need to make targeted edits or updates to a file without overwriting the entire content." : ""}
+${diffStrategy ? "- Prefer to use apply_diff over write_to_file when making changes to existing files, particularly when editing files more than 200 lines of code, as it allows you to apply specific modifications based on a set of changes provided in a diff. This is particularly useful when you need to make targeted edits or updates to a file without overwriting the entire content." : ""}
- 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.
- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
- When you want to modify a file, use the write_to_file tool directly with the desired content. You do not need to display the content before using the tool.
@@ -398,4 +329,3 @@ The following additional instructions are provided by the user, and should be fo
${joinedInstructions}`
: ""
}
-
diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx
index 2c95176..0aaae53 100644
--- a/webview-ui/src/components/settings/SettingsView.tsx
+++ b/webview-ui/src/components/settings/SettingsView.tsx
@@ -292,31 +292,35 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
)}
- setDiffEnabled(e.target.checked)}>
- Enable editing through diffs
-
-
- When enabled, Cline will be able to apply diffs to make changes to files and will automatically reject truncated full-file edits.
-