Skip to content

Commit 4f17daf

Browse files
author
Eric Wheeler
committed
fix: clarify difference between workspace directory and terminal working directory
This commit addresses confusion between the VS Code workspace directory and terminal working directory. Roo was not properly distinguishing between these concepts, leading to issues when terminal commands changed directories. - Renamed 'Current Working Directory' to 'Current Workspace Directory' throughout - Added clearer notice when a command changes the working directory in a terminal - Added explanation about the difference between workspace and working directories - Updated all tool descriptions to reference 'workspace directory' References: https://www.reddit.com/r/RooCode/s/6L19EvsFbF Signed-off-by: Eric Wheeler <[email protected]>
1 parent 9f724bd commit 4f17daf

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

src/core/Cline.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ export class Cline extends EventEmitter<ClineEvents> {
845845
newUserContent.push({
846846
type: "text",
847847
text:
848-
`[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 '${this.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.${
848+
`[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. 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.${
849849
wasRecent
850850
? "\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."
851851
: ""
@@ -1059,7 +1059,7 @@ export class Cline extends EventEmitter<ClineEvents> {
10591059
const newWorkingDir = terminalInfo.getCurrentWorkingDirectory()
10601060

10611061
if (newWorkingDir !== workingDir) {
1062-
workingDirInfo += `; command changed working directory for this terminal to '${newWorkingDir.toPosix()} so be aware that future commands will be executed from this directory`
1062+
workingDirInfo += `\nNOTICE: Your command changed the working directory for this terminal to '${newWorkingDir.toPosix()}' so you MUST adjust future commands accordingly because they will be executed in this directory`
10631063
}
10641064

10651065
const outputInfo = `\nOutput:\n${result}`
@@ -2321,7 +2321,7 @@ export class Cline extends EventEmitter<ClineEvents> {
23212321
}
23222322

23232323
if (includeFileDetails) {
2324-
details += `\n\n# Current Working Directory (${this.cwd.toPosix()}) Files\n`
2324+
details += `\n\n# Current Workspace Directory (${this.cwd.toPosix()}) Files\n`
23252325
const isDesktop = arePathsEqual(this.cwd, path.join(os.homedir(), "Desktop"))
23262326
if (isDesktop) {
23272327
// don't want to immediately access desktop since it would show permission popup

src/core/diff/strategies/multi-search-replace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ When applying the diffs, be extra careful to remember to change any closing brac
5757
ALWAYS make as many changes in a single 'apply_diff' request as possible using multiple SEARCH/REPLACE blocks
5858
5959
Parameters:
60-
- path: (required) The path of the file to modify (relative to the current working directory ${args.cwd})
60+
- path: (required) The path of the file to modify (relative to the current workspace directory ${args.cwd})
6161
- diff: (required) The search/replace block defining the changes.
6262
6363
Diff format:

src/core/prompts/sections/capabilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CAPABILITIES
1414
- You have access to tools that let you execute CLI commands on the user's computer, list files, view source code definitions, regex search${
1515
supportsComputerUse ? ", use the browser" : ""
1616
}, read and write files, and ask follow-up questions. These tools help you effectively accomplish a wide range of tasks, such as writing code, making edits or improvements to existing files, understanding the current state of a project, performing system operations, and much more.
17-
- 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.
17+
- When the user initially gives you a task, a recursive list of all filepaths in the current workspace 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 workspace 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.
1818
- 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.
1919
- 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.
2020
- 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.

src/core/prompts/sections/system-info.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ SYSTEM INFORMATION
1717
Operating System: ${osName()}
1818
Default Shell: ${getShell()}
1919
Home Directory: ${os.homedir().toPosix()}
20-
Current Working Directory: ${cwd.toPosix()}
20+
Current Workspace Directory: ${cwd.toPosix()}
2121
22-
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.`
22+
The Current Workspace Directory is the active VS Code project directory, and is therefore the default directory for all tool operations. New terminals will be created in the current workspace directory, however if you change directories in a terminal it will then have a different working directory; changing directories in a terminal does not modify the workspace directory, because you do not have access to change the workspace directory. When the user initially gives you a task, a recursive list of all filepaths in the current workspace 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 workspace 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.`
2323

2424
return details
2525
}

src/core/prompts/tools/insert-content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getInsertContentDescription(args: ToolArgs): string {
44
return `## insert_content
55
Description: Inserts content at specific line positions in a file. This is the primary tool for adding new content and code (functions/methods/classes, imports, attributes etc.) as it allows for precise insertions without overwriting existing content. The tool uses an efficient line-based insertion system that maintains file integrity and proper ordering of multiple insertions. Beware to use the proper indentation. This tool is the preferred way to add new content and code to files.
66
Parameters:
7-
- path: (required) The path of the file to insert content into (relative to the current working directory ${args.cwd.toPosix()})
7+
- path: (required) The path of the file to insert content into (relative to the current workspace directory ${args.cwd.toPosix()})
88
- operations: (required) A JSON array of insertion operations. Each operation is an object with:
99
* start_line: (required) The line number where the content should be inserted. The content currently at that line will end up below the inserted content.
1010
* content: (required) The content to insert at the specified position. IMPORTANT NOTE: If the content is a single line, it can be a string. If it's a multi-line content, it should be a string with newline characters (\n) for line breaks. Make sure to include the correct indentation for the content.

src/core/prompts/tools/list-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getListFilesDescription(args: ToolArgs): string {
44
return `## list_files
55
Description: Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.
66
Parameters:
7-
- path: (required) The path of the directory to list contents for (relative to the current working directory ${args.cwd})
7+
- path: (required) The path of the directory to list contents for (relative to the current workspace directory ${args.cwd})
88
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
99
Usage:
1010
<list_files>

src/core/prompts/tools/read-file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getReadFileDescription(args: ToolArgs): string {
44
return `## read_file
55
Description: Request to read the contents of a file at the specified path. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. The output includes line numbers prefixed to each line (e.g. "1 | const x = 1"), making it easier to reference specific lines when creating diffs or discussing code. By specifying start_line and end_line parameters, you can efficiently read specific portions of large files without loading the entire file into memory. Automatically extracts raw text from PDF and DOCX files. May not be suitable for other types of binary files, as it returns the raw content as a string.
66
Parameters:
7-
- path: (required) The path of the file to read (relative to the current working directory ${args.cwd})
7+
- path: (required) The path of the file to read (relative to the current workspace directory ${args.cwd})
88
- start_line: (optional) The starting line number to read from (1-based). If not provided, it starts from the beginning of the file.
99
- end_line: (optional) The ending line number to read to (1-based, inclusive). If not provided, it reads to the end of the file.
1010
Usage:

src/core/prompts/tools/search-and-replace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getSearchAndReplaceDescription(args: ToolArgs): string {
44
return `## search_and_replace
55
Description: Request to perform search and replace operations on a file. Each operation can specify a search pattern (string or regex) and replacement text, with optional line range restrictions and regex flags. Shows a diff preview before applying changes.
66
Parameters:
7-
- path: (required) The path of the file to modify (relative to the current working directory ${args.cwd.toPosix()})
7+
- path: (required) The path of the file to modify (relative to the current workspace directory ${args.cwd.toPosix()})
88
- operations: (required) A JSON array of search/replace operations. Each operation is an object with:
99
* search: (required) The text or pattern to search for
1010
* replace: (required) The text to replace matches with. If multiple lines need to be replaced, use "\n" for newlines

src/core/prompts/tools/search-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getSearchFilesDescription(args: ToolArgs): string {
44
return `## search_files
55
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.
66
Parameters:
7-
- path: (required) The path of the directory to search in (relative to the current working directory ${args.cwd}). This directory will be recursively searched.
7+
- path: (required) The path of the directory to search in (relative to the current workspace directory ${args.cwd}). This directory will be recursively searched.
88
- regex: (required) The regular expression pattern to search for. Uses Rust regex syntax.
99
- file_pattern: (optional) Glob pattern to filter files (e.g., '*.ts' for TypeScript files). If not provided, it will search all files (*).
1010
Usage:

src/core/prompts/tools/write-to-file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getWriteToFileDescription(args: ToolArgs): string {
44
return `## write_to_file
55
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.
66
Parameters:
7-
- path: (required) The path of the file to write to (relative to the current working directory ${args.cwd})
7+
- path: (required) The path of the file to write to (relative to the current workspace directory ${args.cwd})
88
- 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.
99
- 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.
1010
Usage:

0 commit comments

Comments
 (0)