diff --git a/core/config/markdown/loadMarkdownRules.ts b/core/config/markdown/loadMarkdownRules.ts index 4a2cd4051..f890ef80a 100644 --- a/core/config/markdown/loadMarkdownRules.ts +++ b/core/config/markdown/loadMarkdownRules.ts @@ -8,7 +8,7 @@ import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; export const SUPPORTED_AGENT_FILES = ["AGENTS.md", "AGENT.md", "CLAUDE.md"]; /** - * Loads rules from markdown files in the .continue/rules directory + * Loads rules from markdown files in the .continue/rules and .continue/prompts directories * and agent files (AGENTS.md, AGENT.md, CLAUDE.md) at workspace root */ export async function loadMarkdownRules(ide: IDE): Promise<{ @@ -53,37 +53,41 @@ export async function loadMarkdownRules(ide: IDE): Promise<{ } } - try { - // Get all .md files from .continue/rules - const markdownFiles = await getAllDotContinueDefinitionFiles( - ide, - { includeGlobal: true, includeWorkspace: true, fileExtType: "markdown" }, - "rules", - ); + // Load markdown files from both .continue/rules and .continue/prompts + const dirsToCheck = ["rules", "prompts"]; - // Filter to just .md files - const mdFiles = markdownFiles.filter((file) => file.path.endsWith(".md")); + for (const dirName of dirsToCheck) { + try { + const markdownFiles = await getAllDotContinueDefinitionFiles( + ide, + { includeGlobal: true, includeWorkspace: true, fileExtType: "markdown" }, + dirName, + ); - // Process each markdown file - for (const file of mdFiles) { - try { - const rule = markdownToRule(file.content, { - uriType: "file", - fileUri: file.path, - }); - rules.push({ ...rule, source: "rules-block", sourceFile: file.path }); - } catch (e) { - errors.push({ - fatal: false, - message: `Failed to parse markdown rule file ${file.path}: ${e instanceof Error ? e.message : e}`, - }); + // Filter to just .md files + const mdFiles = markdownFiles.filter((file) => file.path.endsWith(".md")); + + // Process each markdown file + for (const file of mdFiles) { + try { + const rule = markdownToRule(file.content, { + uriType: "file", + fileUri: file.path, + }); + rules.push({ ...rule, source: "rules-block", sourceFile: file.path }); + } catch (e) { + errors.push({ + fatal: false, + message: `Failed to parse markdown rule file ${file.path}: ${e instanceof Error ? e.message : e}`, + }); + } } + } catch (e) { + errors.push({ + fatal: false, + message: `Error loading markdown rule files from ${dirName}: ${e instanceof Error ? e.message : e}`, + }); } - } catch (e) { - errors.push({ - fatal: false, - message: `Error loading markdown rule files: ${e instanceof Error ? e.message : e}`, - }); } return { rules, errors }; diff --git a/core/promptFiles/getPromptFiles.ts b/core/promptFiles/getPromptFiles.ts index 59c0151d4..c1111d77a 100644 --- a/core/promptFiles/getPromptFiles.ts +++ b/core/promptFiles/getPromptFiles.ts @@ -1,7 +1,8 @@ +import path from "path"; import { DEFAULT_PROMPTS_FOLDER_V1 } from "."; import { IDE } from ".."; import { walkDir } from "../indexing/walkDir"; -import { readAllGlobalPromptFiles } from "../util/paths"; +import { getContinueGlobalPath, readAllGlobalPromptFiles } from "../util/paths"; import { joinPathsToUri } from "../util/uri"; export const DEFAULT_PROMPTS_FOLDER_V2 = ".continue/prompts"; @@ -40,7 +41,7 @@ export async function getAllPromptFiles( const workspaceDirs = await ide.getWorkspaceDirs(); let promptFiles: { path: string; content: string }[] = []; - let dirsToCheck = [DEFAULT_PROMPTS_FOLDER_V2]; + let dirsToCheck = [DEFAULT_PROMPTS_FOLDER_V2, ".continue/rules"]; if (checkV1DefaultFolder) { dirsToCheck.push(DEFAULT_PROMPTS_FOLDER_V1); } @@ -56,9 +57,14 @@ export async function getAllPromptFiles( await Promise.all(fullDirs.map((dir) => getPromptFilesFromDir(ide, dir))) ).flat(); - // Also read from ~/.continue/prompts + // Also read from ~/.continue/prompts and ~/.continue/rules promptFiles.push(...readAllGlobalPromptFiles()); + const globalRulesPath = readAllGlobalPromptFiles( + path.join(getContinueGlobalPath(), "rules"), + ); + promptFiles.push(...globalRulesPath); + return await Promise.all( promptFiles.map(async (file) => { const content = await ide.readFile(file.path);