Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,16 @@ describe("addCustomInstructions", () => {
expect(result).toContain("Rules from .roorules-test-mode:\nmode specific rules")
})

it("should return empty string when no instructions provided", async () => {
it("should show placeholder text when no instructions provided", async () => {
// Simulate no .roo/rules directory
statMock.mockRejectedValueOnce({ code: "ENOENT" })

readFileMock.mockRejectedValue({ code: "ENOENT" })

const result = await addCustomInstructions("", "", "/fake/path", "", {})
expect(result).toBe("")
expect(result).toContain("Global Instructions:\n(No global instructions set)")
expect(result).toContain("Mode-specific Instructions:\n(No mode-specific instructions set)")
expect(result).toContain("USER'S CUSTOM INSTRUCTIONS")
})

it("should handle missing mode-specific rules file", async () => {
Expand Down
10 changes: 6 additions & 4 deletions src/core/prompts/sections/custom-instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,15 @@ export async function addCustomInstructions(
}

// Add global instructions first
if (typeof globalCustomInstructions === "string" && globalCustomInstructions.trim()) {
sections.push(`Global Instructions:\n${globalCustomInstructions.trim()}`)
if (typeof globalCustomInstructions === "string") {
const trimmed = globalCustomInstructions.trim()
sections.push(`Global Instructions:\n${trimmed || "(No global instructions set)"}`)
}

// Add mode-specific instructions after
if (typeof modeCustomInstructions === "string" && modeCustomInstructions.trim()) {
sections.push(`Mode-specific Instructions:\n${modeCustomInstructions.trim()}`)
if (typeof modeCustomInstructions === "string") {
const trimmed = modeCustomInstructions.trim()
sections.push(`Mode-specific Instructions:\n${trimmed || "(No mode-specific instructions set)"}`)
}

// Add rules - include both mode-specific and generic rules if they exist
Expand Down
Loading