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

Function getPromptFilesFromDir

core/promptFiles/getPromptFiles.ts:13–39  ·  view source on GitHub ↗
(
  ide: IDE,
  dir: string,
)

Source from the content-addressed store, hash-verified

11import { joinPathsToUri } from "../util/uri";
12
13export async function getPromptFilesFromDir(
14 ide: IDE,
15 dir: string,
16): Promise<{ path: string; content: string }[]> {
17 try {
18 const exists = await ide.fileExists(dir);
19
20 if (!exists) {
21 return [];
22 }
23
24 const uris = await walkDir(dir, ide, {
25 source: "get dir prompt files",
26 });
27 const promptFilePaths = uris.filter(
28 (p) => p.endsWith(".prompt") || p.endsWith(".md"),
29 );
30 const results = promptFilePaths.map(async (uri) => {
31 const content = await ide.readFile(uri); // make a try catch
32 return { path: uri, content };
33 });
34 return Promise.all(results);
35 } catch (e) {
36 console.error(e);
37 return [];
38 }
39}
40
41export async function getAllPromptFiles(
42 ide: IDE,

Callers 1

getAllPromptFilesFunction · 0.85

Calls 4

walkDirFunction · 0.90
errorMethod · 0.80
fileExistsMethod · 0.65
readFileMethod · 0.65

Tested by

no test coverage detected