Skip to content

Commit 25d3542

Browse files
committed
Adjust searching outside of the workspace to respect the auto-approve checkbox
1 parent ec9b27d commit 25d3542

File tree

37 files changed

+65
-384
lines changed

37 files changed

+65
-384
lines changed

src/core/tools/__tests__/searchFilesTool.spec.ts

Lines changed: 0 additions & 300 deletions
This file was deleted.

src/core/tools/searchFilesTool.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { ClineSayTool } from "../../shared/ExtensionMessage"
66
import { getReadablePath } from "../../utils/path"
77
import { isPathOutsideWorkspace } from "../../utils/pathUtils"
88
import { regexSearchFiles } from "../../services/ripgrep"
9-
import { t } from "../../i18n"
109

1110
export async function searchFilesTool(
1211
cline: Task,
@@ -20,11 +19,15 @@ export async function searchFilesTool(
2019
const regex: string | undefined = block.params.regex
2120
const filePattern: string | undefined = block.params.file_pattern
2221

22+
const absolutePath = relDirPath ? path.resolve(cline.cwd, relDirPath) : cline.cwd
23+
const isOutsideWorkspace = isPathOutsideWorkspace(absolutePath)
24+
2325
const sharedMessageProps: ClineSayTool = {
2426
tool: "searchFiles",
2527
path: getReadablePath(cline.cwd, removeClosingTag("path", relDirPath)),
2628
regex: removeClosingTag("regex", regex),
2729
filePattern: removeClosingTag("file_pattern", filePattern),
30+
isOutsideWorkspace,
2831
}
2932

3033
try {
@@ -49,19 +52,6 @@ export async function searchFilesTool(
4952

5053
cline.consecutiveMistakeCount = 0
5154

52-
const absolutePath = path.resolve(cline.cwd, relDirPath)
53-
54-
// Check if path is outside workspace
55-
if (isPathOutsideWorkspace(absolutePath)) {
56-
const userErrorMessage = t("tools:searchFiles.workspaceBoundaryError", { path: relDirPath })
57-
const llmErrorMessage = `Cannot search outside workspace. Path '${relDirPath}' is outside the current workspace.`
58-
cline.consecutiveMistakeCount++
59-
cline.recordToolError("search_files")
60-
await cline.say("error", userErrorMessage)
61-
pushToolResult(llmErrorMessage)
62-
return
63-
}
64-
6555
const results = await regexSearchFiles(
6656
cline.cwd,
6757
absolutePath,

src/i18n/locales/ca/tools.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"toolRepetitionLimitReached": "Roo sembla estar atrapat en un bucle, intentant la mateixa acció ({{toolName}}) repetidament. Això podria indicar un problema amb la seva estratègia actual. Considera reformular la tasca, proporcionar instruccions més específiques o guiar-lo cap a un enfocament diferent.",
88
"codebaseSearch": {
99
"approval": "Cercant '{{query}}' a la base de codi..."
10-
},
11-
"searchFiles": {
12-
"workspaceBoundaryError": "No es pot cercar fora de l'espai de treball. El camí '{{path}}' està fora de l'espai de treball actual."
1310
}
1411
}

src/i18n/locales/de/tools.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"toolRepetitionLimitReached": "Roo scheint in einer Schleife festzustecken und versucht wiederholt dieselbe Aktion ({{toolName}}). Dies könnte auf ein Problem mit der aktuellen Strategie hindeuten. Überlege dir, die Aufgabe umzuformulieren, genauere Anweisungen zu geben oder Roo zu einem anderen Ansatz zu führen.",
88
"codebaseSearch": {
99
"approval": "Suche nach '{{query}}' im Codebase..."
10-
},
11-
"searchFiles": {
12-
"workspaceBoundaryError": "Kann nicht außerhalb des Arbeitsbereichs suchen. Pfad '{{path}}' liegt außerhalb des aktuellen Arbeitsbereichs."
1310
}
1411
}

src/i18n/locales/en/tools.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"toolRepetitionLimitReached": "Roo appears to be stuck in a loop, attempting the same action ({{toolName}}) repeatedly. This might indicate a problem with its current strategy. Consider rephrasing the task, providing more specific instructions, or guiding it towards a different approach.",
88
"codebaseSearch": {
99
"approval": "Searching for '{{query}}' in codebase..."
10-
},
11-
"searchFiles": {
12-
"workspaceBoundaryError": "Cannot search outside workspace. Path '{{path}}' is outside the current workspace."
1310
}
1411
}

src/i18n/locales/es/tools.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"toolRepetitionLimitReached": "Roo parece estar atrapado en un bucle, intentando la misma acción ({{toolName}}) repetidamente. Esto podría indicar un problema con su estrategia actual. Considera reformular la tarea, proporcionar instrucciones más específicas o guiarlo hacia un enfoque diferente.",
88
"codebaseSearch": {
99
"approval": "Buscando '{{query}}' en la base de código..."
10-
},
11-
"searchFiles": {
12-
"workspaceBoundaryError": "No se puede buscar fuera del espacio de trabajo. La ruta '{{path}}' está fuera del espacio de trabajo actual."
1310
}
1411
}

src/i18n/locales/fr/tools.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"toolRepetitionLimitReached": "Roo semble être bloqué dans une boucle, tentant la même action ({{toolName}}) de façon répétée. Cela pourrait indiquer un problème avec sa stratégie actuelle. Envisage de reformuler la tâche, de fournir des instructions plus spécifiques ou de le guider vers une approche différente.",
88
"codebaseSearch": {
99
"approval": "Recherche de '{{query}}' dans la base de code..."
10-
},
11-
"searchFiles": {
12-
"workspaceBoundaryError": "Impossible de rechercher en dehors de l'espace de travail. Le chemin '{{path}}' est en dehors de l'espace de travail actuel."
1310
}
1411
}

src/i18n/locales/hi/tools.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"toolRepetitionLimitReached": "Roo एक लूप में फंसा हुआ लगता है, बार-बार एक ही क्रिया ({{toolName}}) को दोहरा रहा है। यह उसकी वर्तमान रणनीति में किसी समस्या का संकेत हो सकता है। कार्य को पुनः परिभाषित करने, अधिक विशिष्ट निर्देश देने, या उसे एक अलग दृष्टिकोण की ओर मार्गदर्शित करने पर विचार करें।",
88
"codebaseSearch": {
99
"approval": "कोडबेस में '{{query}}' खोज रहा है..."
10-
},
11-
"searchFiles": {
12-
"workspaceBoundaryError": "वर्कस्पेस के बाहर खोज नहीं की जा सकती। पथ '{{path}}' वर्तमान वर्कस्पेस के बाहर है।"
1310
}
1411
}

0 commit comments

Comments
 (0)