diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap index d67156ab98..ced0ede463 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -353,7 +340,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap index 5deea1465d..90bbc1ae34 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -250,7 +237,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap index f6cd169723..9fdf29df77 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -352,7 +339,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap index 5a88719371..3594c8054f 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -402,7 +389,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap index 6d43d30e9a..00e7d3f5db 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -358,7 +345,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap index d67156ab98..ced0ede463 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -353,7 +340,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap index 6aec1a0651..72e208ee6a 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -406,7 +393,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap index d67156ab98..ced0ede463 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -353,7 +340,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap index a8165dc4f2..72aa071ce6 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -441,7 +428,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap index d67156ab98..ced0ede463 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -353,7 +340,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap index b0408f01b8..83271f47ad 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -406,7 +393,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap index 5a88719371..3594c8054f 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -402,7 +389,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap index d67156ab98..ced0ede463 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap @@ -22,19 +22,6 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -353,7 +340,7 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application diff --git a/src/core/prompts/sections/tool-use.ts b/src/core/prompts/sections/tool-use.ts index 434d2f8785..c598fabae3 100644 --- a/src/core/prompts/sections/tool-use.ts +++ b/src/core/prompts/sections/tool-use.ts @@ -15,18 +15,5 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X ... -For example, to use the new_task tool: - - -code -Implement a new feature for the application. - -[ ] Design the feature architecture -[ ] Implement core functionality -[ ] Add error handling -[ ] Write tests - - - Always use the actual tool name as the XML tag name for proper parsing and execution.` } diff --git a/src/core/prompts/tools/__tests__/new-task.spec.ts b/src/core/prompts/tools/__tests__/new-task.spec.ts index b6379384d0..94dfaf1d79 100644 --- a/src/core/prompts/tools/__tests__/new-task.spec.ts +++ b/src/core/prompts/tools/__tests__/new-task.spec.ts @@ -3,7 +3,7 @@ import { getNewTaskDescription } from "../new-task" import { ToolArgs } from "../types" describe("getNewTaskDescription", () => { - it("should not show todos parameter at all when setting is disabled", () => { + it("should NOT show todos parameter at all when setting is disabled", () => { const args: ToolArgs = { cwd: "/test", supportsComputerUse: false, @@ -14,15 +14,18 @@ describe("getNewTaskDescription", () => { const description = getNewTaskDescription(args) - // Check that todos parameter is not mentioned at all + // Check that todos parameter is NOT shown at all expect(description).not.toContain("todos:") - expect(description).not.toContain("todo list") - expect(description).not.toContain("") - expect(description).not.toContain("") + expect(description).not.toContain("todos parameter") + expect(description).not.toContain("The initial todo list in markdown checklist format") // Should have a simple example without todos expect(description).toContain("Implement a new feature for the application") + // Should NOT have any todos tags in examples + expect(description).not.toContain("") + expect(description).not.toContain("") + // Should still have mode and message as required expect(description).toContain("mode: (required)") expect(description).toContain("message: (required)") @@ -42,6 +45,7 @@ describe("getNewTaskDescription", () => { // Check that todos is marked as required expect(description).toContain("todos: (required)") expect(description).toContain("and initial todo list") + expect(description).toContain("The initial todo list in markdown checklist format") // Should not contain any mention of optional for todos expect(description).not.toContain("todos: (optional)") @@ -53,7 +57,7 @@ describe("getNewTaskDescription", () => { expect(description).toContain("Set up auth middleware") }) - it("should not show todos parameter when settings is undefined", () => { + it("should NOT show todos parameter when settings is undefined", () => { const args: ToolArgs = { cwd: "/test", supportsComputerUse: false, @@ -62,14 +66,14 @@ describe("getNewTaskDescription", () => { const description = getNewTaskDescription(args) - // Check that todos parameter is not shown by default + // Check that todos parameter is NOT shown by default expect(description).not.toContain("todos:") - expect(description).not.toContain("todo list") + expect(description).not.toContain("The initial todo list in markdown checklist format") expect(description).not.toContain("") expect(description).not.toContain("") }) - it("should not show todos parameter when newTaskRequireTodos is undefined", () => { + it("should NOT show todos parameter when newTaskRequireTodos is undefined", () => { const args: ToolArgs = { cwd: "/test", supportsComputerUse: false, @@ -78,14 +82,14 @@ describe("getNewTaskDescription", () => { const description = getNewTaskDescription(args) - // Check that todos parameter is not shown by default + // Check that todos parameter is NOT shown by default expect(description).not.toContain("todos:") - expect(description).not.toContain("todo list") + expect(description).not.toContain("The initial todo list in markdown checklist format") expect(description).not.toContain("") expect(description).not.toContain("") }) - it("should only include todos in example when setting is enabled", () => { + it("should include todos in examples only when setting is enabled", () => { const argsWithSettingOff: ToolArgs = { cwd: "/test", supportsComputerUse: false, @@ -105,13 +109,20 @@ describe("getNewTaskDescription", () => { const descriptionOff = getNewTaskDescription(argsWithSettingOff) const descriptionOn = getNewTaskDescription(argsWithSettingOn) - // When setting is off, should NOT include todos in example - const todosPattern = /\s*\[\s*\]\s*Set up auth middleware/s - expect(descriptionOff).not.toMatch(todosPattern) + // When setting is on, should include todos in main example + expect(descriptionOn).toContain("Implement user authentication") + expect(descriptionOn).toContain("[ ] Set up auth middleware") + expect(descriptionOn).toContain("") + expect(descriptionOn).toContain("") + + // When setting is off, should NOT include any todos references expect(descriptionOff).not.toContain("") + expect(descriptionOff).not.toContain("") + expect(descriptionOff).not.toContain("[ ] Set up auth middleware") + expect(descriptionOff).not.toContain("[ ] First task to complete") - // When setting is on, should include todos in example - expect(descriptionOn).toMatch(todosPattern) - expect(descriptionOn).toContain("") + // When setting is off, main example should be simple + const usagePattern = /\s*.*<\/mode>\s*.*<\/message>\s*<\/new_task>/s + expect(descriptionOff).toMatch(usagePattern) }) }) diff --git a/src/core/prompts/tools/new-task.ts b/src/core/prompts/tools/new-task.ts index 0b15bc0ad9..bba6c6250f 100644 --- a/src/core/prompts/tools/new-task.ts +++ b/src/core/prompts/tools/new-task.ts @@ -1,11 +1,9 @@ import { ToolArgs } from "./types" -export function getNewTaskDescription(args: ToolArgs): string { - const todosRequired = args.settings?.newTaskRequireTodos === true - - // When setting is disabled, don't show todos parameter at all - if (!todosRequired) { - return `## new_task +/** + * Prompt when todos are NOT required (default) + */ +const PROMPT_WITHOUT_TODOS = `## new_task Description: This will let you create a new task instance in the chosen mode using your provided message. Parameters: @@ -21,13 +19,14 @@ Usage: Example: code -Implement a new feature for the application. +Implement a new feature for the application ` - } - // When setting is enabled, show todos as required - return `## new_task +/** + * Prompt when todos ARE required + */ +const PROMPT_WITH_TODOS = `## new_task Description: This will let you create a new task instance in the chosen mode using your provided message and initial todo list. Parameters: @@ -57,5 +56,12 @@ Example: [ ] Write tests + ` + +export function getNewTaskDescription(args: ToolArgs): string { + const todosRequired = args.settings?.newTaskRequireTodos === true + + // Simply return the appropriate prompt based on the setting + return todosRequired ? PROMPT_WITH_TODOS : PROMPT_WITHOUT_TODOS } diff --git a/src/core/tools/__tests__/newTaskTool.spec.ts b/src/core/tools/__tests__/newTaskTool.spec.ts index 1c883c6fe5..ac43f9f887 100644 --- a/src/core/tools/__tests__/newTaskTool.spec.ts +++ b/src/core/tools/__tests__/newTaskTool.spec.ts @@ -11,6 +11,16 @@ vi.mock("vscode", () => ({ }, })) +// Mock Package module +vi.mock("../../../shared/package", () => ({ + Package: { + name: "roo-cline", + publisher: "RooVeterinaryInc", + version: "1.0.0", + outputChannel: "Roo-Code", + }, +})) + // Mock other modules first - these are hoisted to the top vi.mock("../../../shared/modes", () => ({ getModeBySlug: vi.fn(), @@ -589,7 +599,7 @@ describe("newTaskTool", () => { expect(mockPushToolResult).toHaveBeenCalledWith(expect.stringContaining("Successfully created new task")) }) - it("should check VSCode setting with correct configuration key", async () => { + it("should check VSCode setting with Package.name configuration key", async () => { const mockGet = vi.fn().mockReturnValue(false) const mockGetConfiguration = vi.fn().mockReturnValue({ get: mockGet, @@ -615,10 +625,46 @@ describe("newTaskTool", () => { mockRemoveClosingTag, ) - // Verify that VSCode configuration was accessed correctly + // Verify that VSCode configuration was accessed with Package.name expect(mockGetConfiguration).toHaveBeenCalledWith("roo-cline") expect(mockGet).toHaveBeenCalledWith("newTaskRequireTodos", false) }) + + it("should use current Package.name value (roo-code-nightly) when accessing VSCode configuration", async () => { + // Arrange: capture calls to VSCode configuration and ensure we can assert the namespace + const mockGet = vi.fn().mockReturnValue(false) + const mockGetConfiguration = vi.fn().mockReturnValue({ + get: mockGet, + } as any) + vi.mocked(vscode.workspace.getConfiguration).mockImplementation(mockGetConfiguration) + + // Mutate the mocked Package.name dynamically to simulate a different build variant + const pkg = await import("../../../shared/package") + ;(pkg.Package as any).name = "roo-code-nightly" + + const block: ToolUse = { + type: "tool_use", + name: "new_task", + params: { + mode: "code", + message: "Test message", + }, + partial: false, + } + + await newTaskTool( + mockCline as any, + block, + mockAskApproval, + mockHandleError, + mockPushToolResult, + mockRemoveClosingTag, + ) + + // Assert: configuration was read using the dynamic nightly namespace + expect(mockGetConfiguration).toHaveBeenCalledWith("roo-code-nightly") + expect(mockGet).toHaveBeenCalledWith("newTaskRequireTodos", false) + }) }) // Add more tests for error handling (invalid mode, approval denied) if needed diff --git a/src/core/tools/newTaskTool.ts b/src/core/tools/newTaskTool.ts index 2a3ab293b6..6b650cb94e 100644 --- a/src/core/tools/newTaskTool.ts +++ b/src/core/tools/newTaskTool.ts @@ -9,6 +9,7 @@ import { defaultModeSlug, getModeBySlug } from "../../shared/modes" import { formatResponse } from "../prompts/responses" import { t } from "../../i18n" import { parseMarkdownChecklist } from "./updateTodoListTool" +import { Package } from "../../shared/package" export async function newTaskTool( cline: Task, @@ -56,8 +57,11 @@ export async function newTaskTool( return } const state = await provider.getState() + + // Use Package.name (dynamic at build time) as the VSCode configuration namespace. + // Supports multiple extension variants (e.g., stable/nightly) without hardcoded strings. const requireTodos = vscode.workspace - .getConfiguration("roo-cline") + .getConfiguration(Package.name) .get("newTaskRequireTodos", false) // Check if todos are required based on VSCode setting