Skip to content

Commit 0670844

Browse files
committed
Make instruction structure clearer
1 parent 210a69a commit 0670844

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/core/prompts/sections/__tests__/custom-instructions.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ describe("loadRuleFiles", () => {
149149
})
150150

151151
const result = await loadRuleFiles("/fake/path")
152-
expect(result).toContain("# Rules from /fake/path/.roo/rules")
153-
expect(result).toContain("# Filename: /fake/path/.roo/rules/file1.txt")
152+
expect(result).toContain("# Rules from /fake/path/.roo/rules/file1.txt:")
154153
expect(result).toContain("content of file1")
155-
expect(result).toContain("# Filename: /fake/path/.roo/rules/file2.txt")
154+
expect(result).toContain("# Rules from /fake/path/.roo/rules/file2.txt:")
156155
expect(result).toContain("content of file2")
157156

158157
expect(statMock).toHaveBeenCalledWith("/fake/path/.roo/rules/file1.txt")
@@ -352,9 +351,9 @@ describe("addCustomInstructions", () => {
352351
)
353352

354353
expect(result).toContain("# Rules from /fake/path/.roo/rules-test-mode")
355-
expect(result).toContain("# Filename: /fake/path/.roo/rules-test-mode/rule1.txt")
354+
expect(result).toContain("# Rules from /fake/path/.roo/rules-test-mode/rule1.txt:")
356355
expect(result).toContain("mode specific rule 1")
357-
expect(result).toContain("# Filename: /fake/path/.roo/rules-test-mode/rule2.txt")
356+
expect(result).toContain("# Rules from /fake/path/.roo/rules-test-mode/rule2.txt:")
358357
expect(result).toContain("mode specific rule 2")
359358

360359
expect(statMock).toHaveBeenCalledWith("/fake/path/.roo/rules-test-mode/rule1.txt")
@@ -457,7 +456,7 @@ describe("addCustomInstructions", () => {
457456
)
458457

459458
expect(result).toContain("# Rules from /fake/path/.roo/rules-test-mode")
460-
expect(result).toContain("# Filename: /fake/path/.roo/rules-test-mode/rule1.txt")
459+
expect(result).toContain("# Rules from /fake/path/.roo/rules-test-mode/rule1.txt:")
461460
expect(result).toContain("mode specific rule content")
462461

463462
expect(statCallCount).toBeGreaterThan(0)
@@ -548,12 +547,11 @@ describe("Rules directory reading", () => {
548547

549548
const result = await loadRuleFiles("/fake/path")
550549

551-
expect(result).toContain("# Rules from /fake/path/.roo/rules")
552-
expect(result).toContain("# Filename: /fake/path/.roo/rules/file1.txt")
550+
expect(result).toContain("# Rules from /fake/path/.roo/rules/file1.txt:")
553551
expect(result).toContain("content of file1")
554-
expect(result).toContain("# Filename: /fake/path/.roo/rules/file2.txt")
552+
expect(result).toContain("# Rules from /fake/path/.roo/rules/file2.txt:")
555553
expect(result).toContain("content of file2")
556-
expect(result).toContain("# Filename: /fake/path/.roo/rules/file3.txt")
554+
expect(result).toContain("# Rules from /fake/path/.roo/rules/file3.txt:")
557555
expect(result).toContain("content of file3")
558556
})
559557

src/core/prompts/sections/custom-instructions.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ async function readTextFilesFromDirectory(dirPath: string): Promise<Array<{ file
7070
function formatDirectoryContent(dirPath: string, files: Array<{ filename: string; content: string }>): string {
7171
if (files.length === 0) return ""
7272

73-
const formattedContent = files
74-
.map((file) => {
75-
return `# Filename: ${file.filename}\n${file.content}`
76-
})
77-
.join("\n\n")
78-
79-
return `\n# Rules from ${path.relative(process.cwd(), dirPath)}:\n${formattedContent}\n`
73+
return (
74+
"\n\n" +
75+
files
76+
.map((file) => {
77+
return `# Rules from ${file.filename}:\n${file.content}:`
78+
})
79+
.join("\n\n")
80+
)
8081
}
8182

8283
/**

0 commit comments

Comments
 (0)