File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
src/core/prompts/sections Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -862,7 +862,7 @@ describe("addCustomInstructions", () => {
862862 expect ( readFileMock ) . toHaveBeenCalledWith ( expect . stringContaining ( "AGENT.md" ) , "utf-8" )
863863 } )
864864
865- it ( "should load both AGENTS.md and AGENT.md when both exist" , async ( ) => {
865+ it ( "should prefer AGENTS.md over AGENT.md when both exist" , async ( ) => {
866866 // Simulate no .roo/rules-test-mode directory
867867 statMock . mockRejectedValueOnce ( { code : "ENOENT" } )
868868
@@ -902,13 +902,11 @@ describe("addCustomInstructions", () => {
902902 } ,
903903 )
904904
905- // Should contain BOTH AGENTS.md and AGENT.md content
905+ // Should contain AGENTS.md content (preferred) and not AGENT.md
906906 expect ( result ) . toContain ( "# Agent Rules Standard (AGENTS.md):" )
907907 expect ( result ) . toContain ( "Agent rules from AGENTS.md file (plural)" )
908- expect ( result ) . toContain ( "# Agent Rules Standard (AGENT.md):" )
909- expect ( result ) . toContain ( "Agent rules from AGENT.md file (singular)" )
908+ expect ( result ) . not . toContain ( "Agent rules from AGENT.md file (singular)" )
910909 expect ( readFileMock ) . toHaveBeenCalledWith ( expect . stringContaining ( "AGENTS.md" ) , "utf-8" )
911- expect ( readFileMock ) . toHaveBeenCalledWith ( expect . stringContaining ( "AGENT.md" ) , "utf-8" )
912910 } )
913911
914912 it ( "should return empty string when no instructions provided" , async ( ) => {
Original file line number Diff line number Diff line change @@ -276,13 +276,12 @@ async function readAgentRulesFile(filePath: string): Promise<string> {
276276}
277277
278278/**
279- * Load agent rules files from a specific directory
280- * Loads ALL of the following files if they exist:
281- * - AGENTS.md (standard agent rules)
282- * - AGENT.md (alternative naming)
283- * - AGENTS.local.md (personal overrides, not checked in to version control)
279+ * Load AGENTS.md or AGENT.md file from a specific directory
280+ * Checks for both AGENTS.md (standard) and AGENT.md (alternative) for compatibility
281+ * Also loads AGENTS.local.md for personal overrides (not checked in to version control)
282+ * AGENTS.local.md can be loaded even if AGENTS.md doesn't exist
284283 *
285- * @param directory - Directory to check for agent rules files
284+ * @param directory - Directory to check for AGENTS.md
286285 * @param showPath - Whether to include the directory path in the header
287286 * @param cwd - Current working directory for computing relative paths (optional)
288287 */
@@ -307,7 +306,9 @@ async function loadAgentRulesFileFromDirectory(
307306 ? `# Agent Rules Standard (${ filename } ) from ${ displayPath } :`
308307 : `# Agent Rules Standard (${ filename } ):`
309308 results . push ( `${ header } \n${ content } ` )
310- // Continue to check for additional agent rules files
309+
310+ // Found a standard file, don't check alternative
311+ break
311312 }
312313 } catch ( err ) {
313314 // Silently ignore errors - agent rules files are optional
You can’t perform that action at this time.
0 commit comments