continue-custom/core/config/getSystemPromptDotFile.ts
2024-11-13 16:56:56 -08:00

27 lines
669 B
TypeScript

import { IDE } from "..";
export const SYSTEM_PROMPT_DOT_FILE = ".continuerules";
export async function getSystemPromptDotFile(ide: IDE): Promise<string | null> {
const dirs = await ide.getWorkspaceDirs();
let prompts: string[] = [];
const pathSep = await ide.pathSep();
for (const dir of dirs) {
const dotFile = `${dir}${pathSep}${SYSTEM_PROMPT_DOT_FILE}`;
if (await ide.fileExists(dotFile)) {
try {
const content = await ide.readFile(dotFile);
prompts.push(content);
} catch (e) {
// ignore if file doesn't exist
}
}
}
if (!prompts.length) {
return null;
}
return prompts.join("\n\n");
}