diff --git a/.tmp/Roo-Code b/.tmp/Roo-Code new file mode 160000 index 0000000000..86debeef43 --- /dev/null +++ b/.tmp/Roo-Code @@ -0,0 +1 @@ +Subproject commit 86debeef43acbea9bdc1aa4b38d514541e164c91 diff --git a/src/core/prompts/__tests__/custom-system-prompt.spec.ts b/src/core/prompts/__tests__/custom-system-prompt.spec.ts index b211c2a27c..748defb977 100644 --- a/src/core/prompts/__tests__/custom-system-prompt.spec.ts +++ b/src/core/prompts/__tests__/custom-system-prompt.spec.ts @@ -154,9 +154,9 @@ describe("File-Based Custom System Prompt", () => { expect(prompt).toContain(modes[0].roleDefinition) expect(prompt).toContain(fileCustomSystemPrompt) - // Should not contain any of the default sections - expect(prompt).not.toContain("CAPABILITIES") - expect(prompt).not.toContain("MODES") + // After the fix, should now contain tool sections for proper tool usage + expect(prompt).toContain("TOOL USE") + expect(prompt).toContain("# Tools") }) it("should combine file-based system prompt with role definition and custom instructions", async () => { @@ -200,8 +200,57 @@ describe("File-Based Custom System Prompt", () => { expect(prompt).toContain(customRoleDefinition) expect(prompt).toContain(fileCustomSystemPrompt) - // Should not contain any of the default sections - expect(prompt).not.toContain("CAPABILITIES") - expect(prompt).not.toContain("MODES") + // After the fix, should now contain tool sections for proper tool usage + expect(prompt).toContain("TOOL USE") + expect(prompt).toContain("# Tools") + }) + + it("should include simplified read_file tool for code-supernova model with custom prompt", async () => { + // Mock the readFile to return content from a file + const fileCustomSystemPrompt = "Custom system prompt for code-supernova" + mockedFs.readFile.mockImplementation((filePath, options) => { + if (toPosix(filePath).includes(`.roo/system-prompt-${defaultModeSlug}`) && options === "utf-8") { + return Promise.resolve(fileCustomSystemPrompt) + } + return Promise.reject({ code: "ENOENT" }) + }) + + const prompt = await SYSTEM_PROMPT( + mockContext, + "test/path", + false, // supportsComputerUse + undefined, // mcpHub + undefined, // diffStrategy + undefined, // browserViewportSize + defaultModeSlug, // mode + undefined, // customModePrompts + undefined, // customModes + undefined, // globalCustomInstructions + undefined, // diffEnabled + undefined, // experiments + true, // enableMcpServerCreation + undefined, // language + undefined, // rooIgnoreInstructions + undefined, // partialReadsEnabled + undefined, // settings + undefined, // todoList + "roo/code-supernova", // modelId - this is the key for this test + ) + + // Should contain the custom system prompt + expect(prompt).toContain(fileCustomSystemPrompt) + + // Should contain tool descriptions + expect(prompt).toContain("# Tools") + expect(prompt).toContain("## read_file") + + // Should contain the simplified read_file format for code-supernova + expect(prompt).toContain("") + expect(prompt).toContain("path/to/file") + expect(prompt).toContain("") + + // Should NOT contain the complex multi-file read format + expect(prompt).not.toContain("") + expect(prompt).not.toContain("You can read a maximum of 5 files") }) }) diff --git a/src/core/prompts/system.ts b/src/core/prompts/system.ts index 3cc327c815..5747acc91a 100644 --- a/src/core/prompts/system.ts +++ b/src/core/prompts/system.ts @@ -194,9 +194,47 @@ export const SYSTEM_PROMPT = async ( }, ) - // For file-based prompts, don't include the tool sections + // Get the full mode config to ensure we have the role definition (used for groups, etc.) + const modeConfig = getModeBySlug(mode, customModes) || modes.find((m) => m.slug === mode) || modes[0] + + // Check if MCP functionality should be included + const hasMcpGroup = modeConfig.groups.some((groupEntry) => getGroupName(groupEntry) === "mcp") + const hasMcpServers = mcpHub && mcpHub.getServers().length > 0 + const shouldIncludeMcp = hasMcpGroup && hasMcpServers + + // If diff is disabled, don't pass the diffStrategy + const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined + + const codeIndexManager = CodeIndexManager.getInstance(context, cwd) + + // Always include tool descriptions for file-based custom prompts + // This ensures models like code-supernova get the proper tool format + const toolDescriptions = getToolDescriptionsForMode( + mode, + cwd, + supportsComputerUse, + codeIndexManager, + effectiveDiffStrategy, + browserViewportSize, + shouldIncludeMcp ? mcpHub : undefined, + customModes, + experiments, + partialReadsEnabled, + settings, + enableMcpServerCreation, + modelId, + ) + return `${roleDefinition} +${markdownFormattingSection()} + +${getSharedToolUseSection()} + +${toolDescriptions} + +${getToolUseGuidelinesSection(codeIndexManager)} + ${fileCustomSystemPrompt} ${customInstructions}`