MCPcopy Index your code
hub / github.com/continuedev/continue / lsToolImpl

Function lsToolImpl

core/tools/implementations/lsTool.ts:17–62  ·  view source on GitHub ↗
(args, extras)

Source from the content-addressed store, hash-verified

15const MAX_LS_TOOL_LINES = 200;
16
17export const lsToolImpl: ToolImpl = async (args, extras) => {
18 const dirPath = resolveLsToolDirPath(args?.dirPath);
19 const resolvedPath = await resolveInputPath(extras.ide, dirPath);
20 if (!resolvedPath) {
21 throw new ContinueError(
22 ContinueErrorReason.DirectoryNotFound,
23 `Directory ${args.dirPath} not found or is not accessible. You can use absolute paths, relative paths, or paths starting with ~`,
24 );
25 }
26
27 const entries = await walkDir(resolvedPath.uri, extras.ide, {
28 returnRelativeUrisPaths: true,
29 include: "both",
30 recursive: args?.recursive ?? false,
31 overrideDefaultIgnores: ignore(), // Show all directories including dist/, build/, etc.
32 });
33
34 const lines = entries.slice(0, MAX_LS_TOOL_LINES);
35
36 let content =
37 lines.length > 0
38 ? lines.join("\n")
39 : `No files/folders found in ${resolvedPath.displayPath}`;
40
41 const contextItems = [
42 {
43 name: "File/folder list",
44 description: `Files/folders in ${resolvedPath.displayPath}`,
45 content,
46 },
47 ];
48
49 if (entries.length > MAX_LS_TOOL_LINES) {
50 let warningContent = `${entries.length - MAX_LS_TOOL_LINES} ls entries were truncated`;
51 if (args?.recursive) {
52 warningContent += ". Try using a non-recursive search";
53 }
54 contextItems.push({
55 name: "Truncation warning",
56 description: "",
57 content: warningContent,
58 });
59 }
60
61 return contextItems;
62};

Callers 2

callBuiltInToolFunction · 0.90
lsTool.vitest.tsFile · 0.90

Calls 4

resolveInputPathFunction · 0.90
walkDirFunction · 0.90
resolveLsToolDirPathFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected