Skip to content

Commit f2a7f60

Browse files
authored
Merge pull request #42 from trypear/creator-checkbox
Creator checkbox
2 parents 83c223a + dcc73f6 commit f2a7f60

9 files changed

Lines changed: 109 additions & 59 deletions

File tree

src/activate/registerCommands.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
4141
"roo-cline.helpButtonClicked": () => {
4242
vscode.env.openExternal(vscode.Uri.parse("https://docs.roocode.com"))
4343
},
44+
"roo-cline.createInAgent": async (args: any) => {
45+
const sidebarProvider = ClineProvider.getSidebarInstance()
46+
if (sidebarProvider) {
47+
// Start a new chat in the sidebar
48+
vscode.commands.executeCommand("pearai-roo-cline.SidebarProvider.focus")
49+
await sidebarProvider.clearTask()
50+
await sidebarProvider.handleModeSwitch("code", args.creatorMode)
51+
await sidebarProvider.postStateToWebview()
52+
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
53+
54+
await sidebarProvider.initClineWithTask(args.text, undefined, args.creatorMode)
55+
}
56+
},
4457
"roo-cline.executeCreatorPlan": async (args: any) => {
4558
const sidebarProvider = ClineProvider.getSidebarInstance()
4659
if (sidebarProvider) {
@@ -52,6 +65,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
5265
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
5366

5467
// Create the template message using the args
68+
// Todo: add structure to it i.e. You should have these sections: Architecutre, Features, etc.
5569
let executePlanTemplate = `This file contains detailed plan to my task. please read it and Execute the plan accordingly.
5670
File: ${args.filePath || "No file specified"}`
5771

@@ -66,11 +80,9 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
6680
executePlanTemplate += `Additional context: ${args.context}`
6781
}
6882

69-
await sidebarProvider.postMessageToWebview({
70-
type: "invoke",
71-
invoke: "sendMessage",
72-
text: executePlanTemplate,
73-
})
83+
args.text = executePlanTemplate
84+
85+
await sidebarProvider.initClineWithTask(args.text, undefined, true)
7486
}
7587
},
7688
}

src/core/webview/ClineProvider.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ export class ClineProvider implements vscode.WebviewViewProvider {
7474
private latestAnnouncementId = "jan-21-2025-custom-modes" // update to some unique identifier when we add a new announcement
7575
configManager: ConfigManager
7676
customModesManager: CustomModesManager
77-
private isCreator: boolean = false
77+
private isCreatorView: boolean = false
7878

7979
constructor(
8080
readonly context: vscode.ExtensionContext,
8181
private readonly outputChannel: vscode.OutputChannel,
82-
isCreator: boolean = false,
82+
isCreatorView: boolean = false,
8383
) {
84-
this.outputChannel.appendLine(`creator = ${isCreator}`)
85-
this.isCreator = isCreator
84+
this.outputChannel.appendLine(`creator = ${isCreatorView}`)
85+
this.isCreatorView = isCreatorView
8686
console.dir("CREATOR")
87-
console.dir(this.isCreator)
87+
console.dir(this.isCreatorView)
8888
this.outputChannel.appendLine("ClineProvider instantiated")
8989
ClineProvider.activeInstances.add(this)
9090
this.workspaceTracker = new WorkspaceTracker(this)
@@ -135,7 +135,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
135135
}
136136

137137
public static getSidebarInstance(): ClineProvider | undefined {
138-
const sidebar = Array.from(this.activeInstances).find((instance) => !instance.isCreator)
138+
const sidebar = Array.from(this.activeInstances).find((instance) => !instance.isCreatorView)
139139

140140
if (!sidebar?.view?.visible) {
141141
vscode.commands.executeCommand("pearai-roo-cline.SidebarProvider.focus")
@@ -334,7 +334,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
334334
this.outputChannel.appendLine("Webview view resolved")
335335
}
336336

337-
public async initClineWithTask(task?: string, images?: string[]) {
337+
public async initClineWithTask(task?: string, images?: string[], creatorMode?: boolean) {
338338
await this.clearTask()
339339
const {
340340
apiConfiguration,
@@ -353,7 +353,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
353353
provider: this,
354354
apiConfiguration: {
355355
...apiConfiguration,
356-
creatorMode: mode === "creator",
356+
creatorMode: creatorMode,
357357
},
358358
customInstructions: effectiveInstructions,
359359
enableDiff: diffEnabled,
@@ -365,7 +365,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
365365
})
366366
}
367367

368-
public async initClineWithHistoryItem(historyItem: HistoryItem) {
368+
public async initClineWithHistoryItem(historyItem: HistoryItem, creatorMode?: boolean) {
369369
await this.clearTask()
370370

371371
const {
@@ -386,7 +386,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
386386
provider: this,
387387
apiConfiguration: {
388388
...apiConfiguration,
389-
creatorMode: mode === "creator",
389+
creatorMode: creatorMode,
390390
},
391391
customInstructions: effectiveInstructions,
392392
enableDiff: diffEnabled,
@@ -436,7 +436,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
436436
window.$RefreshReg$ = () => {}
437437
window.$RefreshSig$ = () => (type) => type
438438
window.__vite_plugin_react_preamble_installed__ = true
439-
window.isCreator="${this.isCreator}";
439+
window.isCreator="${this.isCreatorView}";
440440
</script>
441441
`
442442

@@ -450,7 +450,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
450450
]
451451

452452
console.dir("CREATORRRRRR")
453-
console.dir(this.isCreator)
453+
console.dir(this.isCreatorView)
454454
return /*html*/ `
455455
<!DOCTYPE html>
456456
<html lang="en">
@@ -1663,7 +1663,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
16631663
* Handle switching to a new mode, including updating the associated API configuration
16641664
* @param newMode The mode to switch to
16651665
*/
1666-
public async handleModeSwitch(newMode: Mode) {
1666+
public async handleModeSwitch(newMode: Mode, creatorMode?: boolean) {
16671667
await this.updateGlobalState("mode", newMode)
16681668

16691669
// Load the saved API config for the new mode if it exists
@@ -1816,7 +1816,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
18161816
if (this.cline) {
18171817
this.cline.api = buildApiHandler({
18181818
...apiConfiguration,
1819-
creatorMode: mode === "creator",
18201819
})
18211820
}
18221821
}

src/integrations/editor/DiffViewProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class DiffViewProvider {
158158
Getting diagnostics before and after the file edit is a better approach than
159159
automatically tracking problems in real-time. This method ensures we only
160160
report new problems that are a direct result of this specific edit.
161-
Since these are new problems resulting from Roo's edit, we know they're
161+
Since these are new problems resulting from Agent's edit, we know they're
162162
directly related to the work he's doing. This eliminates the risk of Roo
163163
going off-task or getting distracted by unrelated issues, which was a problem
164164
with the previous auto-debug approach. Some users' machines may be slow to
@@ -294,7 +294,7 @@ export class DiffViewProvider {
294294
query: Buffer.from(this.originalContent ?? "").toString("base64"),
295295
}),
296296
uri,
297-
`${fileName}: ${fileExists ? "Original ↔ Roo's Changes" : "New File"} (Editable)`,
297+
`${fileName}: ${fileExists ? "Original ↔ Agent's Changes" : "New File"} (Editable)`,
298298
)
299299
// This may happen on very slow machines ie project idx
300300
setTimeout(() => {

src/shared/creator-mode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.`

src/shared/modes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from "vscode"
22
import { TOOL_GROUPS, ToolGroup, ALWAYS_AVAILABLE_TOOLS } from "./tool-groups"
33
import { addCustomInstructions } from "../core/prompts/sections/custom-instructions"
4+
import { CREATOR_MODE_PLANNING_PROMPT } from "./creator-mode"
45

56
// Mode types
67
export type Mode = string
@@ -80,6 +81,7 @@ export const modes: readonly ModeConfig[] = [
8081
roleDefinition:
8182
"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.",
8283
groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"],
84+
customInstructions: CREATOR_MODE_PLANNING_PROMPT,
8385
},
8486
{
8587
slug: "code",

webview-ui/src/components/mcp/McpEnabledToggle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const McpEnabledToggle = () => {
2525
color: "var(--vscode-descriptionForeground)",
2626
}}>
2727
When enabled, Roo will be able to interact with MCP servers for advanced functionality. If you're not
28-
using MCP, you can disable this to reduce Roo's token usage.
28+
using MCP, you can disable this to reduce Agent's token usage.
2929
</p>
3030
</div>
3131
)

webview-ui/src/components/mcp/McpView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const McpView = ({ onDone }: McpViewProps) => {
6363
Model Context Protocol
6464
</VSCodeLink>{" "}
6565
enables communication with locally running MCP servers that provide additional tools and resources
66-
to extend Roo's capabilities. You can use{" "}
66+
to extend Agent's capabilities. You can use{" "}
6767
<VSCodeLink href="https://github.com/modelcontextprotocol/servers" style={{ display: "inline" }}>
6868
community-made servers
6969
</VSCodeLink>{" "}
@@ -91,7 +91,7 @@ const McpView = ({ onDone }: McpViewProps) => {
9191
color: "var(--vscode-descriptionForeground)",
9292
}}>
9393
When enabled, Roo can help you create new MCP servers via commands like "add a new tool
94-
to...". If you don't need to create MCP servers you can disable this to reduce Roo's
94+
to...". If you don't need to create MCP servers you can disable this to reduce Agent's
9595
token usage.
9696
</p>
9797
</div>

webview-ui/src/components/prompts/PromptsView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
688688
)}
689689
</div>
690690
<div className="text-sm text-vscode-descriptionForeground mb-2">
691-
Define Roo's expertise and personality for this mode. This description shapes how Roo
691+
Define Agent's expertise and personality for this mode. This description shapes how Roo
692692
presents itself and approaches tasks.
693693
</div>
694694
<VSCodeTextArea
@@ -1255,7 +1255,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
12551255
color: "var(--vscode-descriptionForeground)",
12561256
marginBottom: "8px",
12571257
}}>
1258-
Define Roo's expertise and personality for this mode.
1258+
Define Agent's expertise and personality for this mode.
12591259
</div>
12601260
<VSCodeTextArea
12611261
value={newModeRoleDefinition}

0 commit comments

Comments
 (0)