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

Function getDefinitionFilesInDir

core/config/loadLocalAssistants.ts:50–96  ·  view source on GitHub ↗
(
  ide: IDE,
  dir: string,
  fileExtType?: "yaml" | "markdown",
)

Source from the content-addressed store, hash-verified

48}
49
50async function getDefinitionFilesInDir(
51 ide: IDE,
52 dir: string,
53 fileExtType?: "yaml" | "markdown",
54): Promise<{ path: string; content: string }[]> {
55 try {
56 const exists = await ide.fileExists(dir);
57
58 if (!exists) {
59 return [];
60 }
61
62 const overrideDefaultIgnores = ignore()
63 .add(
64 DEFAULT_IGNORE_FILETYPES.filter(
65 (t) => t !== "config.yaml" && t !== "config.yml",
66 ),
67 )
68 .add(DEFAULT_IGNORE_DIRS);
69
70 const uris = await walkDir(dir, ide, {
71 overrideDefaultIgnores,
72 source: "get assistant files",
73 });
74 let assistantFilePaths: string[];
75 if (fileExtType === "yaml") {
76 assistantFilePaths = uris.filter(
77 (p) => p.endsWith(".yaml") || p.endsWith(".yml"),
78 );
79 } else if (fileExtType === "markdown") {
80 assistantFilePaths = uris.filter((p) => p.endsWith(".md"));
81 } else {
82 assistantFilePaths = uris.filter(
83 (p) => p.endsWith(".yaml") || p.endsWith(".yml") || p.endsWith(".md"),
84 );
85 }
86
87 const results = assistantFilePaths.map(async (uri) => {
88 const content = await ide.readFile(uri); // make a try catch
89 return { path: uri, content };
90 });
91 return Promise.all(results);
92 } catch (e) {
93 console.error(e);
94 return [];
95 }
96}
97
98export interface LoadAssistantFilesOptions {
99 includeGlobal: boolean;

Callers 1

Calls 5

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

Tested by

no test coverage detected