MCPcopy
hub / github.com/continuedev/continue / readFileImpl

Function readFileImpl

core/tools/implementations/readFile.ts:10–44  ·  view source on GitHub ↗
(args, extras)

Source from the content-addressed store, hash-verified

8import { ContinueError, ContinueErrorReason } from "../../util/errors";
9
10export const readFileImpl: ToolImpl = async (args, extras) => {
11 const filepath = getStringArg(args, "filepath");
12
13 // Resolve the path first to get the actual path for security check
14 const resolvedPath = await resolveInputPath(extras.ide, filepath);
15 if (!resolvedPath) {
16 throw new ContinueError(
17 ContinueErrorReason.FileNotFound,
18 `File "${filepath}" does not exist or is not accessible. You might want to check the path and try again.`,
19 );
20 }
21
22 // Security check on the resolved display path
23 throwIfFileIsSecurityConcern(resolvedPath.displayPath);
24
25 const content = await extras.ide.readFile(resolvedPath.uri);
26
27 await throwIfFileExceedsHalfOfContext(
28 resolvedPath.displayPath,
29 content,
30 extras.config.selectedModelByRole.chat,
31 );
32
33 return [
34 {
35 name: getUriPathBasename(resolvedPath.uri),
36 description: resolvedPath.displayPath,
37 content,
38 uri: {
39 type: "file",
40 value: resolvedPath.uri,
41 },
42 },
43 ];
44};

Callers 1

callBuiltInToolFunction · 0.90

Calls 6

getStringArgFunction · 0.90
resolveInputPathFunction · 0.90
getUriPathBasenameFunction · 0.90
readFileMethod · 0.65

Tested by

no test coverage detected