From b553630f2aa78e05ab333983dcfbdd97a1817585 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 11 Jun 2025 15:00:03 -0700 Subject: [PATCH] improv: constants --- core/config/markdown/loadCodebaseRules.ts | 3 ++- core/core.ts | 7 ++++--- core/llm/rules/constants.ts | 4 ++++ core/llm/rules/getSystemMessageWithRules.ts | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 core/llm/rules/constants.ts diff --git a/core/config/markdown/loadCodebaseRules.ts b/core/config/markdown/loadCodebaseRules.ts index b7e6b0db4..d3861b7f3 100644 --- a/core/config/markdown/loadCodebaseRules.ts +++ b/core/config/markdown/loadCodebaseRules.ts @@ -1,6 +1,7 @@ import { ConfigValidationError } from "@continuedev/config-yaml"; import { IDE, RuleWithSource } from "../.."; import { walkDirs } from "../../indexing/walkDir"; +import { RULES_MARKDOWN_FILENAME } from "../../llm/rules/constants"; import { getUriPathBasename } from "../../util/uri"; import { convertMarkdownRuleToContinueRule } from "./parseMarkdownRule"; @@ -21,7 +22,7 @@ export async function loadCodebaseRules(ide: IDE): Promise<{ // Filter to just rules.md files const rulesMdFiles = allFiles.filter((file) => { const filename = getUriPathBasename(file); - return filename === "rules.md"; + return filename === RULES_MARKDOWN_FILENAME; }); // Process each rules.md file diff --git a/core/core.ts b/core/core.ts index 6673c7fce..a0de61b5a 100644 --- a/core/core.ts +++ b/core/core.ts @@ -59,6 +59,7 @@ import { streamDiffLines } from "./edit/streamDiffLines"; import { shouldIgnore } from "./indexing/shouldIgnore"; import { walkDirCache } from "./indexing/walkDir"; import { LLMLogger } from "./llm/logger"; +import { RULES_MARKDOWN_FILENAME } from "./llm/rules/constants"; import { llmStreamChat } from "./llm/streamChat"; import type { FromCoreProtocol, ToCoreProtocol } from "./protocol"; import { OnboardingModes } from "./protocol/core"; @@ -583,7 +584,7 @@ export class Core { let rulesFileCreated = false; for (const uri of data.uris) { const filename = getUriPathBasename(uri); - if (filename === "rules.md") { + if (filename === RULES_MARKDOWN_FILENAME) { rulesFileCreated = true; break; } @@ -614,7 +615,7 @@ export class Core { let rulesFileDeleted = false; for (const uri of data.uris) { const filename = getUriPathBasename(uri); - if (filename === "rules.md") { + if (filename === RULES_MARKDOWN_FILENAME) { rulesFileDeleted = true; break; } @@ -850,7 +851,7 @@ export class Core { uri.endsWith(".prompt") || uri.endsWith(SYSTEM_PROMPT_DOT_FILE) || (uri.includes(".continue") && uri.endsWith(".yaml")) || - uri.endsWith("rules.md") + uri.endsWith(RULES_MARKDOWN_FILENAME) ) { await this.configHandler.reloadConfig(); } else if ( diff --git a/core/llm/rules/constants.ts b/core/llm/rules/constants.ts new file mode 100644 index 000000000..59d67ba41 --- /dev/null +++ b/core/llm/rules/constants.ts @@ -0,0 +1,4 @@ +/** + * The filename used for colocated markdown rules + */ +export const RULES_MARKDOWN_FILENAME = "rules.md"; \ No newline at end of file diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 279917b16..2858ada72 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -8,6 +8,7 @@ import { import { renderChatMessage } from "../../util/messageContent"; import { getCleanUriPath } from "../../util/uri"; import { extractPathsFromCodeBlocks } from "../utils/extractPathsFromCodeBlocks"; +import { RULES_MARKDOWN_FILENAME } from "./constants"; /** * Checks if a path matches any of the provided globs @@ -92,7 +93,7 @@ const isRootLevelRule = (rule: RuleWithSource): boolean => { return ( !rule.ruleFile || rule.ruleFile.startsWith(".continue/") || - rule.ruleFile === ".continue/rules.md" + rule.ruleFile === `.continue/${RULES_MARKDOWN_FILENAME}` ); };