Changesets · Branches · Tags · Compare
| Changeset | 231ed66cc7ff9bcb884fe457a1bd0ac855da201bfe310dc90cb418253d3f5efc |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-09-22 15:58 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-22 15:58 -07:00 |
| Parents | ba33beacce39 |
6 files changed
modified core/config/markdown/loadMarkdownRules.ts +35 −1
| @@ -3,11 +3,13 @@ | ||
| 3 | 3 | markdownToRule, |
| 4 | 4 | } from "@continuedev/config-yaml"; |
| 5 | 5 | import { IDE, RuleWithSource } from "../.."; |
| 6 | -import { findUriInDirs } from "../../util/uri"; | |
| 6 | +import { findUriInDirs, joinPathsToUri } from "../../util/uri"; | |
| 7 | 7 | import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; |
| 8 | 8 | |
| 9 | +export const SUPPORTED_AGENT_FILES = ["AGENTS.md", "AGENT.md", "CLAUDE.md"]; | |
| 9 | 10 | /** |
| 10 | 11 | * Loads rules from markdown files in the .continue/rules directory |
| 12 | + * and agent files (AGENTS.md, AGENT.md, CLAUDE.md) at workspace root | |
| 11 | 13 | */ |
| 12 | 14 | export async function loadMarkdownRules(ide: IDE): Promise<{ |
| 13 | 15 | rules: RuleWithSource[]; |
| @@ -16,6 +18,38 @@ | ||
| 16 | 18 | const errors: ConfigValidationError[] = []; |
| 17 | 19 | const rules: RuleWithSource[] = []; |
| 18 | 20 | |
| 21 | + // First, try to load agent files from workspace root | |
| 22 | + const workspaceDirs = await ide.getWorkspaceDirs(); | |
| 23 | + | |
| 24 | + for (const workspaceDir of workspaceDirs) { | |
| 25 | + let agentFileFound = false; | |
| 26 | + for (const fileName of SUPPORTED_AGENT_FILES) { | |
| 27 | + try { | |
| 28 | + const agentFilePath = joinPathsToUri(workspaceDir, fileName); | |
| 29 | + const agentContent = await ide.readFile(agentFilePath); | |
| 30 | + | |
| 31 | + const rule = markdownToRule(agentContent, { | |
| 32 | + uriType: "file", | |
| 33 | + fileUri: agentFilePath, | |
| 34 | + }); | |
| 35 | + rules.push({ | |
| 36 | + ...rule, | |
| 37 | + source: "agent-file", | |
| 38 | + ruleFile: agentFilePath, | |
| 39 | + alwaysApply: true, | |
| 40 | + }); | |
| 41 | + agentFileFound = true; | |
| 42 | + break; // Use the first found agent file in this workspace | |
| 43 | + } catch (e) { | |
| 44 | + // File doesn't exist or can't be read, continue to next file | |
| 45 | + } | |
| 46 | + } | |
| 47 | + | |
| 48 | + if (agentFileFound) { | |
| 49 | + break; // Use agent file from first workspace that has one | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 19 | 53 | try { |
| 20 | 54 | // Get all .md files from .continue/rules |
| 21 | 55 | const markdownFiles = await getAllDotContinueDefinitionFiles( |
modified core/core.ts +3 −0
| @@ -1239,6 +1239,9 @@ | ||
| 1239 | 1239 | if ( |
| 1240 | 1240 | uri.endsWith(".continuerc.json") || |
| 1241 | 1241 | uri.endsWith(".prompt") || |
| 1242 | + uri.endsWith("AGENTS.md") || | |
| 1243 | + uri.endsWith("AGENT.md") || | |
| 1244 | + uri.endsWith("CLAUDE.md") || | |
| 1242 | 1245 | uri.endsWith(SYSTEM_PROMPT_DOT_FILE) || |
| 1243 | 1246 | (uri.includes(".continue") && |
| 1244 | 1247 | (uri.endsWith(".yaml") || uri.endsWith("yml"))) || |
modified core/index.d.ts +2 −1
| @@ -1811,7 +1811,8 @@ | ||
| 1811 | 1811 | | "rules-block" |
| 1812 | 1812 | | "colocated-markdown" |
| 1813 | 1813 | | "json-systemMessage" |
| 1814 | - | ".continuerules"; | |
| 1814 | + | ".continuerules" | |
| 1815 | + | "agent-file"; | |
| 1815 | 1816 | |
| 1816 | 1817 | export interface RuleWithSource { |
| 1817 | 1818 | name?: string; |
added core/llm/rules/rules-utils.ts +46 −0
| @@ -0,0 +1,46 @@ | ||
| 1 | +import { RuleWithSource } from "../.."; | |
| 2 | +import { getLastNPathParts } from "../../util/uri"; | |
| 3 | + | |
| 4 | +export function getRuleDisplayName(rule: RuleWithSource): string { | |
| 5 | + if (rule.name) { | |
| 6 | + return rule.name; | |
| 7 | + } | |
| 8 | + return getRuleSourceDisplayName(rule); | |
| 9 | +} | |
| 10 | + | |
| 11 | +export function getRuleSourceDisplayName(rule: RuleWithSource): string { | |
| 12 | + switch (rule.source) { | |
| 13 | + case ".continuerules": | |
| 14 | + return "Project rules"; | |
| 15 | + case "default-chat": | |
| 16 | + return "Default chat system message"; | |
| 17 | + case "default-plan": | |
| 18 | + return "Default plan mode system message"; | |
| 19 | + case "default-agent": | |
| 20 | + return "Default agent system message"; | |
| 21 | + case "json-systemMessage": | |
| 22 | + return "System Message (JSON)"; | |
| 23 | + case "model-options-agent": | |
| 24 | + return "Base System Agent Message"; | |
| 25 | + case "model-options-plan": | |
| 26 | + return "Base System Plan Message"; | |
| 27 | + case "model-options-chat": | |
| 28 | + return "Base System Chat Message"; | |
| 29 | + case "agent-file": | |
| 30 | + if (rule.ruleFile) { | |
| 31 | + return getLastNPathParts(rule.ruleFile, 2); | |
| 32 | + } else { | |
| 33 | + return "Agent file"; | |
| 34 | + } | |
| 35 | + case "colocated-markdown": | |
| 36 | + if (rule.ruleFile) { | |
| 37 | + return getLastNPathParts(rule.ruleFile, 2); | |
| 38 | + } else { | |
| 39 | + return "rules.md"; | |
| 40 | + } | |
| 41 | + case "rules-block": | |
| 42 | + return "Rules Block"; | |
| 43 | + default: | |
| 44 | + return rule.source; | |
| 45 | + } | |
| 46 | +} |
modified gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +2 −32
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import { DocumentTextIcon, GlobeAltIcon } from "@heroicons/react/24/outline"; |
| 2 | 2 | import { RuleWithSource } from "core"; |
| 3 | -import { getLastNPathParts } from "core/util/uri"; | |
| 3 | +import { getRuleSourceDisplayName } from "core/llm/rules/rules-utils"; | |
| 4 | 4 | import { ComponentType, useMemo, useState } from "react"; |
| 5 | 5 | import ToggleDiv from "../../ToggleDiv"; |
| 6 | 6 | |
| @@ -13,36 +13,6 @@ | ||
| 13 | 13 | rule: RuleWithSource; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -// Convert technical source to user-friendly text | |
| 17 | -const getSourceLabel = (rule: RuleWithSource): string => { | |
| 18 | - switch (rule.source) { | |
| 19 | - case "default-chat": | |
| 20 | - return "Default Chat"; | |
| 21 | - case "default-agent": | |
| 22 | - return "Default Agent"; | |
| 23 | - case "model-options-chat": | |
| 24 | - return "Model Chat Options"; | |
| 25 | - case "model-options-plan": | |
| 26 | - return "Model Plan Options"; | |
| 27 | - case "model-options-agent": | |
| 28 | - return "Model Agent Options"; | |
| 29 | - case "rules-block": | |
| 30 | - return "Rules Block"; | |
| 31 | - case "colocated-markdown": | |
| 32 | - if (rule.ruleFile) { | |
| 33 | - return getLastNPathParts(rule.ruleFile, 2); | |
| 34 | - } else { | |
| 35 | - return "rules.md"; | |
| 36 | - } | |
| 37 | - case "json-systemMessage": | |
| 38 | - return "System Message"; | |
| 39 | - case ".continuerules": | |
| 40 | - return "Project Rules"; | |
| 41 | - default: | |
| 42 | - return rule.source; | |
| 43 | - } | |
| 44 | -}; | |
| 45 | - | |
| 46 | 16 | export function RulesPeekItem({ rule }: RulesPeekItemProps) { |
| 47 | 17 | const isGlobal = rule.alwaysApply ?? !rule.globs; |
| 48 | 18 | const [expanded, setExpanded] = useState(false); |
| @@ -102,7 +72,7 @@ | ||
| 102 | 72 | )} |
| 103 | 73 | </div> |
| 104 | 74 | <div className="mt-1 pl-6 pr-2 text-xs text-gray-500"> |
| 105 | - Source: {getSourceLabel(rule)} | |
| 75 | + Source: {getRuleSourceDisplayName(rule)} | |
| 106 | 76 | </div> |
| 107 | 77 | </div> |
| 108 | 78 | ); |
modified gui/src/pages/config/sections/RulesSection.tsx +3 −23
| @@ -4,7 +4,6 @@ | ||
| 4 | 4 | BookmarkIcon as BookmarkOutline, |
| 5 | 5 | EyeIcon, |
| 6 | 6 | PencilIcon, |
| 7 | - PlusIcon, | |
| 8 | 7 | } from "@heroicons/react/24/outline"; |
| 9 | 8 | import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid"; |
| 10 | 9 | import { |
| @@ -19,11 +18,12 @@ | ||
| 19 | 18 | DEFAULT_PLAN_SYSTEM_MESSAGE, |
| 20 | 19 | DEFAULT_SYSTEM_MESSAGES_URL, |
| 21 | 20 | } from "core/llm/defaultSystemMessages"; |
| 21 | +import { getRuleDisplayName } from "core/llm/rules/rules-utils"; | |
| 22 | 22 | import { useContext, useMemo } from "react"; |
| 23 | 23 | import HeaderButtonWithToolTip from "../../../components/gui/HeaderButtonWithToolTip"; |
| 24 | 24 | import Switch from "../../../components/gui/Switch"; |
| 25 | 25 | import { useMainEditor } from "../../../components/mainInput/TipTapEditor"; |
| 26 | -import { Button, Card, EmptyState, useFontSize } from "../../../components/ui"; | |
| 26 | +import { Card, EmptyState, useFontSize } from "../../../components/ui"; | |
| 27 | 27 | import { useAuth } from "../../../context/Auth"; |
| 28 | 28 | import { IdeMessengerContext } from "../../../context/IdeMessenger"; |
| 29 | 29 | import { useBookmarkedSlashCommands } from "../../../hooks/useBookmarkedSlashCommands"; |
| @@ -167,27 +167,7 @@ | ||
| 167 | 167 | }; |
| 168 | 168 | |
| 169 | 169 | const title = useMemo(() => { |
| 170 | - if (rule.name) { | |
| 171 | - return rule.name; | |
| 172 | - } else { | |
| 173 | - if (rule.source === ".continuerules") { | |
| 174 | - return "Project rules"; | |
| 175 | - } else if (rule.source === "default-chat") { | |
| 176 | - return "Default chat system message"; | |
| 177 | - } else if (rule.source === "default-agent") { | |
| 178 | - return "Default agent system message"; | |
| 179 | - } else if (rule.source === "json-systemMessage") { | |
| 180 | - return "JSON systemMessage)"; | |
| 181 | - } else if (rule.source === "model-options-agent") { | |
| 182 | - return "Base System Agent Message"; | |
| 183 | - } else if (rule.source === "model-options-plan") { | |
| 184 | - return "Base System Plan Message"; | |
| 185 | - } else if (rule.source === "model-options-chat") { | |
| 186 | - return "Base System Chat Message"; | |
| 187 | - } else { | |
| 188 | - return "Agent rule"; | |
| 189 | - } | |
| 190 | - } | |
| 170 | + return getRuleDisplayName(rule); | |
| 191 | 171 | }, [rule]); |
| 192 | 172 | |
| 193 | 173 | function onClickExpand() { |