diff --git a/src/activate/registerCommands.ts b/src/activate/registerCommands.ts index 4a48fbb9b65..1875c55e4ed 100644 --- a/src/activate/registerCommands.ts +++ b/src/activate/registerCommands.ts @@ -41,6 +41,19 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt "roo-cline.helpButtonClicked": () => { vscode.env.openExternal(vscode.Uri.parse("https://docs.roocode.com")) }, + "roo-cline.createInAgent": async (args: any) => { + const sidebarProvider = ClineProvider.getSidebarInstance() + if (sidebarProvider) { + // Start a new chat in the sidebar + vscode.commands.executeCommand("pearai-roo-cline.SidebarProvider.focus") + await sidebarProvider.clearTask() + await sidebarProvider.handleModeSwitch("code", args.creatorMode) + await sidebarProvider.postStateToWebview() + await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" }) + + await sidebarProvider.initClineWithTask(args.text, undefined, args.creatorMode) + } + }, "roo-cline.executeCreatorPlan": async (args: any) => { const sidebarProvider = ClineProvider.getSidebarInstance() if (sidebarProvider) { @@ -52,6 +65,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" }) // Create the template message using the args + // Todo: add structure to it i.e. You should have these sections: Architecutre, Features, etc. let executePlanTemplate = `This file contains detailed plan to my task. please read it and Execute the plan accordingly. File: ${args.filePath || "No file specified"}` @@ -66,11 +80,9 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt executePlanTemplate += `Additional context: ${args.context}` } - await sidebarProvider.postMessageToWebview({ - type: "invoke", - invoke: "sendMessage", - text: executePlanTemplate, - }) + args.text = executePlanTemplate + + await sidebarProvider.initClineWithTask(args.text, undefined, true) } }, } diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index af40475129e..9ac96e2332b 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -74,17 +74,17 @@ export class ClineProvider implements vscode.WebviewViewProvider { private latestAnnouncementId = "jan-21-2025-custom-modes" // update to some unique identifier when we add a new announcement configManager: ConfigManager customModesManager: CustomModesManager - private isCreator: boolean = false + private isCreatorView: boolean = false constructor( readonly context: vscode.ExtensionContext, private readonly outputChannel: vscode.OutputChannel, - isCreator: boolean = false, + isCreatorView: boolean = false, ) { - this.outputChannel.appendLine(`creator = ${isCreator}`) - this.isCreator = isCreator + this.outputChannel.appendLine(`creator = ${isCreatorView}`) + this.isCreatorView = isCreatorView console.dir("CREATOR") - console.dir(this.isCreator) + console.dir(this.isCreatorView) this.outputChannel.appendLine("ClineProvider instantiated") ClineProvider.activeInstances.add(this) this.workspaceTracker = new WorkspaceTracker(this) @@ -135,7 +135,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { } public static getSidebarInstance(): ClineProvider | undefined { - const sidebar = Array.from(this.activeInstances).find((instance) => !instance.isCreator) + const sidebar = Array.from(this.activeInstances).find((instance) => !instance.isCreatorView) if (!sidebar?.view?.visible) { vscode.commands.executeCommand("pearai-roo-cline.SidebarProvider.focus") @@ -334,7 +334,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { this.outputChannel.appendLine("Webview view resolved") } - public async initClineWithTask(task?: string, images?: string[]) { + public async initClineWithTask(task?: string, images?: string[], creatorMode?: boolean) { await this.clearTask() const { apiConfiguration, @@ -353,7 +353,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { provider: this, apiConfiguration: { ...apiConfiguration, - creatorMode: mode === "creator", + creatorMode: creatorMode, }, customInstructions: effectiveInstructions, enableDiff: diffEnabled, @@ -365,7 +365,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { }) } - public async initClineWithHistoryItem(historyItem: HistoryItem) { + public async initClineWithHistoryItem(historyItem: HistoryItem, creatorMode?: boolean) { await this.clearTask() const { @@ -386,7 +386,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { provider: this, apiConfiguration: { ...apiConfiguration, - creatorMode: mode === "creator", + creatorMode: creatorMode, }, customInstructions: effectiveInstructions, enableDiff: diffEnabled, @@ -436,7 +436,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { window.$RefreshReg$ = () => {} window.$RefreshSig$ = () => (type) => type window.__vite_plugin_react_preamble_installed__ = true - window.isCreator="${this.isCreator}"; + window.isCreator="${this.isCreatorView}"; ` @@ -450,7 +450,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { ] console.dir("CREATORRRRRR") - console.dir(this.isCreator) + console.dir(this.isCreatorView) return /*html*/ ` @@ -1663,7 +1663,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { * Handle switching to a new mode, including updating the associated API configuration * @param newMode The mode to switch to */ - public async handleModeSwitch(newMode: Mode) { + public async handleModeSwitch(newMode: Mode, creatorMode?: boolean) { await this.updateGlobalState("mode", newMode) // Load the saved API config for the new mode if it exists @@ -1816,7 +1816,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { if (this.cline) { this.cline.api = buildApiHandler({ ...apiConfiguration, - creatorMode: mode === "creator", }) } } diff --git a/src/integrations/editor/DiffViewProvider.ts b/src/integrations/editor/DiffViewProvider.ts index ee24d7db4ee..56d20cf630f 100644 --- a/src/integrations/editor/DiffViewProvider.ts +++ b/src/integrations/editor/DiffViewProvider.ts @@ -158,7 +158,7 @@ export class DiffViewProvider { Getting diagnostics before and after the file edit is a better approach than automatically tracking problems in real-time. This method ensures we only report new problems that are a direct result of this specific edit. - Since these are new problems resulting from Roo's edit, we know they're + Since these are new problems resulting from Agent's edit, we know they're directly related to the work he's doing. This eliminates the risk of Roo going off-task or getting distracted by unrelated issues, which was a problem with the previous auto-debug approach. Some users' machines may be slow to @@ -294,7 +294,7 @@ export class DiffViewProvider { query: Buffer.from(this.originalContent ?? "").toString("base64"), }), uri, - `${fileName}: ${fileExists ? "Original ↔ Roo's Changes" : "New File"} (Editable)`, + `${fileName}: ${fileExists ? "Original ↔ Agent's Changes" : "New File"} (Editable)`, ) // This may happen on very slow machines ie project idx setTimeout(() => { diff --git a/src/shared/creator-mode.ts b/src/shared/creator-mode.ts new file mode 100644 index 00000000000..7a4c1568702 --- /dev/null +++ b/src/shared/creator-mode.ts @@ -0,0 +1 @@ +export const CREATOR_MODE_PLANNING_PROMPT = `Depending on the user's request, you may need to do some information gathering (for example using read_file or search_files) to get more context about the task. You may also ask the user clarifying questions to get a better understanding of the task. Once you've gained more context about the user's request, you should create a detailed plan for how to accomplish the task. Focus on breaking down complex tasks into manageable steps, considering technical requirements, potential challenges, and best practices. The plan should be clear enough that it can be directly implemented by switching to Code mode afterward. (Directly write the plan to a markdown file instead of showing it as normal response.)\n\nOnce you create and write the plan, you mark the task as completed. You only make plans and you should not ask or switch to any other mode.` \ No newline at end of file diff --git a/src/shared/modes.ts b/src/shared/modes.ts index 4bc586d9774..649c5447cd8 100644 --- a/src/shared/modes.ts +++ b/src/shared/modes.ts @@ -1,6 +1,7 @@ import * as vscode from "vscode" import { TOOL_GROUPS, ToolGroup, ALWAYS_AVAILABLE_TOOLS } from "./tool-groups" import { addCustomInstructions } from "../core/prompts/sections/custom-instructions" +import { CREATOR_MODE_PLANNING_PROMPT } from "./creator-mode" // Mode types export type Mode = string @@ -80,6 +81,7 @@ export const modes: readonly ModeConfig[] = [ roleDefinition: "You are PearAI Agent (Powered by Roo Code / Cline), a creative and systematic software architect focused on turning high-level ideas into actionable plans. Your primary goal is to help users transform their ideas into structured action plans.", groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"], + customInstructions: CREATOR_MODE_PLANNING_PROMPT, }, { slug: "code", diff --git a/webview-ui/src/components/mcp/McpEnabledToggle.tsx b/webview-ui/src/components/mcp/McpEnabledToggle.tsx index 9e7831ea2ba..74fa9bce0e2 100644 --- a/webview-ui/src/components/mcp/McpEnabledToggle.tsx +++ b/webview-ui/src/components/mcp/McpEnabledToggle.tsx @@ -25,7 +25,7 @@ const McpEnabledToggle = () => { color: "var(--vscode-descriptionForeground)", }}> When enabled, Roo will be able to interact with MCP servers for advanced functionality. If you're not - using MCP, you can disable this to reduce Roo's token usage. + using MCP, you can disable this to reduce Agent's token usage.

) diff --git a/webview-ui/src/components/mcp/McpView.tsx b/webview-ui/src/components/mcp/McpView.tsx index adb6b47343d..778555f94e9 100644 --- a/webview-ui/src/components/mcp/McpView.tsx +++ b/webview-ui/src/components/mcp/McpView.tsx @@ -63,7 +63,7 @@ const McpView = ({ onDone }: McpViewProps) => { Model Context Protocol {" "} enables communication with locally running MCP servers that provide additional tools and resources - to extend Roo's capabilities. You can use{" "} + to extend Agent's capabilities. You can use{" "} community-made servers {" "} @@ -91,7 +91,7 @@ const McpView = ({ onDone }: McpViewProps) => { color: "var(--vscode-descriptionForeground)", }}> When enabled, Roo can help you create new MCP servers via commands like "add a new tool - to...". If you don't need to create MCP servers you can disable this to reduce Roo's + to...". If you don't need to create MCP servers you can disable this to reduce Agent's token usage.

diff --git a/webview-ui/src/components/prompts/PromptsView.tsx b/webview-ui/src/components/prompts/PromptsView.tsx index 061fa789de4..31a7dd5b115 100644 --- a/webview-ui/src/components/prompts/PromptsView.tsx +++ b/webview-ui/src/components/prompts/PromptsView.tsx @@ -688,7 +688,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { )}
- Define Roo's expertise and personality for this mode. This description shapes how Roo + Define Agent's expertise and personality for this mode. This description shapes how Roo presents itself and approaches tasks.
{ color: "var(--vscode-descriptionForeground)", marginBottom: "8px", }}> - Define Roo's expertise and personality for this mode. + Define Agent's expertise and personality for this mode. (false) - const [editingFilePath, setEditingFilePath] = useState(null) + const [editingFilePath, setEditingFilePath] = useState(() => { + return null + }) + const [includePlanningPhase, setIncludePlanningPhase] = useState(true) // UI layout depends on the last 2 messages // (since it relies on the content of these messages, we are deep comparing. i.e. the button state after hitting button sets enableButtons to false, and this effect otherwise would have to true again even if messages didn't change @@ -195,7 +199,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie setTextAreaDisabled(isPartial) setClineAsk("completion_result") setEnableButtons(!isPartial) - setPrimaryButtonText("Create in Agent") + setPrimaryButtonText("Create!") setSecondaryButtonText(undefined) break case "resume_task": @@ -210,7 +214,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie setTextAreaDisabled(false) setClineAsk("resume_completed_task") setEnableButtons(true) - setPrimaryButtonText("Create in Agent") + setPrimaryButtonText("Create!") setSecondaryButtonText(undefined) setDidClickCancel(false) break @@ -312,7 +316,22 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie text = text.trim() if (text || images.length > 0) { if (messages.length === 0) { - vscode.postMessage({ type: "newTask", text, images }) + if (includePlanningPhase) { + console.log("Starting new task with planning phase") + vscode.postMessage({ type: "newTask", text, images }) + } else { + console.log("Skipping planning phase, sending directly to agent") + vscode.postMessage({ + type: "invoke", + invoke: "executeCommand", + command: "roo-cline.createInAgent", + args: { + text, + mode: "code", + creatorMode: true, + }, + }) + } } else if (clineAsk) { switch (clineAsk) { case "followup": @@ -347,7 +366,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie disableAutoScrollRef.current = false } }, - [messages.length, clineAsk, setMode], + [messages.length, clineAsk, setMode, includePlanningPhase], ) const handleSetChatBoxMessage = useCallback( @@ -403,16 +422,17 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie break case "completion_result": case "resume_completed_task": - vscode.postMessage({ - type: "invoke", - invoke: "executeCommand", - command: "roo-cline.executeCreatorPlan", - args: { - filePath: editingFilePath, - // code: 'function test() { return true; }', - // context: 'This is a test context' - }, - }) + if (includePlanningPhase) { + vscode.postMessage({ + type: "invoke", + invoke: "executeCommand", + command: "roo-cline.executeCreatorPlan", + args: { + filePath: editingFilePath, + includePlanning: true, + }, + }) + } break } setTextAreaDisabled(true) @@ -420,7 +440,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie setEnableButtons(false) disableAutoScrollRef.current = false }, - [clineAsk, editingFilePath], + [clineAsk, editingFilePath, includePlanningPhase], ) const handleSecondaryButtonClick = useCallback( @@ -1019,12 +1039,16 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie }} className={`min-w-2xl ${task ? "max-w-2xl" : "max-w-5xl"} mx-auto flex justify-center borderr border-solid`}> {!task && ( -
-
-
-
-
-
+ <> +
+
+
+
+
+
+ )} {task && ( - )} {task && ( <> @@ -1238,8 +1253,29 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie setMode={setMode} isNewTask={taskHistory.length === 0} /> +
+
+ { + const newValue = !includePlanningPhase + setIncludePlanningPhase(newValue) + }}> + Include Planning Phase + +
+
+ {!task && ( + + )}
- {editingFilePath && setEditingFilePath(null)} />} + {editingFilePath && {}} />}
) }