Просмотр исходного кода

Check rooignore for insert_content and search_and_replace (#4094)

Matt Rubens 8 месяцев назад
Родитель
Сommit
4cf240f3db
2 измененных файлов с 16 добавлено и 0 удалено
  1. 8 0
      src/core/tools/insertContentTool.ts
  2. 8 0
      src/core/tools/searchAndReplaceTool.ts

+ 8 - 0
src/core/tools/insertContentTool.ts

@@ -58,6 +58,14 @@ export async function insertContentTool(
 			return
 		}
 
+		const accessAllowed = cline.rooIgnoreController?.validateAccess(relPath)
+
+		if (!accessAllowed) {
+			await cline.say("rooignore_error", relPath)
+			pushToolResult(formatResponse.toolError(formatResponse.rooIgnoreError(relPath)))
+			return
+		}
+
 		const absolutePath = path.resolve(cline.cwd, relPath)
 		const fileExists = await fileExistsAtPath(absolutePath)
 

+ 8 - 0
src/core/tools/searchAndReplaceTool.ts

@@ -115,6 +115,14 @@ export async function searchAndReplaceTool(
 			endLine: endLine,
 		}
 
+		const accessAllowed = cline.rooIgnoreController?.validateAccess(validRelPath)
+
+		if (!accessAllowed) {
+			await cline.say("rooignore_error", validRelPath)
+			pushToolResult(formatResponse.toolError(formatResponse.rooIgnoreError(validRelPath)))
+			return
+		}
+
 		const absolutePath = path.resolve(cline.cwd, validRelPath)
 		const fileExists = await fileExistsAtPath(absolutePath)