MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / executeLegacy

Method executeLegacy

src/core/tools/ReadFileTool.ts:667–813  ·  view source on GitHub ↗

* Execute legacy multi-file format for backward compatibility. * This handles the old format: { files: [{ path: string, lineRanges?: [...] }] }

(fileEntries: FileEntry[], task: Task, callbacks: ToolCallbacks)

Source from the content-addressed store, hash-verified

665 * This handles the old format: { files: [{ path: string, lineRanges?: [...] }] }
666 */
667 private async executeLegacy(fileEntries: FileEntry[], task: Task, callbacks: ToolCallbacks): Promise<void> {
668 const { pushToolResult } = callbacks
669 const modelInfo = task.api.getModel().info
670
671 if (!fileEntries || fileEntries.length === 0) {
672 task.consecutiveMistakeCount++
673 task.recordToolError("read_file")
674 const errorMsg = await task.sayAndCreateMissingParamError("read_file", "files")
675 pushToolResult(`Error: ${errorMsg}`)
676 return
677 }
678
679 const supportsImages = modelInfo.supportsImages ?? false
680
681 // Process each file sequentially (legacy behavior)
682 const results: string[] = []
683
684 for (const entry of fileEntries) {
685 const relPath = entry.path
686 const fullPath = path.resolve(task.cwd, relPath)
687
688 // RooIgnore validation
689 const accessAllowed = task.rooIgnoreController?.validateAccess(relPath)
690 if (!accessAllowed) {
691 await task.say("rooignore_error", relPath)
692 const errorMsg = formatResponse.rooIgnoreError(relPath)
693 results.push(`File: ${relPath}\nError: ${errorMsg}`)
694 // Mirror the native path: a blocked file marks the tool turn as failed.
695 task.didToolFailInCurrentTurn = true
696 continue
697 }
698
699 // Request approval for single file
700 const isOutsideWorkspace = isPathOutsideWorkspace(fullPath)
701 let lineSnippet = ""
702 if (entry.lineRanges && entry.lineRanges.length > 0) {
703 const ranges = entry.lineRanges.map((range: LineRange) => `(lines ${range.start}-${range.end})`)
704 lineSnippet = ranges.join(", ")
705 }
706
707 const completeMessage = JSON.stringify({
708 tool: "readFile",
709 path: getReadablePath(task.cwd, relPath),
710 isOutsideWorkspace,
711 content: fullPath,
712 reason: lineSnippet || undefined,
713 } satisfies ClineSayTool)
714
715 const { response, text, images } = await task.ask("tool", completeMessage, false)
716
717 if (response !== "yesButtonClicked") {
718 if (text) await task.say("user_feedback", text, images)
719 task.didRejectTool = true
720 results.push(`File: ${relPath}\nStatus: Denied by user`)
721 continue
722 }
723
724 if (text) await task.say("user_feedback", text, images)

Callers 1

executeMethod · 0.95

Calls 15

isPathOutsideWorkspaceFunction · 0.90
getReadablePathFunction · 0.90
isSupportedImageFormatFunction · 0.90
processImageFileFunction · 0.90
readWithSliceFunction · 0.90
pushToolResultFunction · 0.85
recordToolErrorMethod · 0.80
sayMethod · 0.80
askMethod · 0.80
statMethod · 0.80

Tested by

no test coverage detected