Skip to content

Commit 615255e

Browse files
committed
[WIP] Deep Research
1 parent e81726a commit 615255e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+6463
-795
lines changed

package.json

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,20 @@
7575
"icon": "$(add)"
7676
},
7777
{
78-
"command": "roo-cline.mcpButtonClicked",
79-
"title": "MCP Servers",
80-
"icon": "$(server)"
78+
"command": "roo-cline.researchButtonClicked",
79+
"title": "Research",
80+
"icon": "$(telescope)"
8181
},
8282
{
8383
"command": "roo-cline.promptsButtonClicked",
8484
"title": "Prompts",
8585
"icon": "$(notebook)"
8686
},
87+
{
88+
"command": "roo-cline.mcpButtonClicked",
89+
"title": "MCP Servers",
90+
"icon": "$(server)"
91+
},
8792
{
8893
"command": "roo-cline.historyButtonClicked",
8994
"title": "History",
@@ -202,29 +207,34 @@
202207
"when": "view == roo-cline.SidebarProvider"
203208
},
204209
{
205-
"command": "roo-cline.promptsButtonClicked",
210+
"command": "roo-cline.researchButtonClicked",
206211
"group": "navigation@2",
207212
"when": "view == roo-cline.SidebarProvider"
208213
},
209214
{
210-
"command": "roo-cline.mcpButtonClicked",
215+
"command": "roo-cline.promptsButtonClicked",
211216
"group": "navigation@3",
212217
"when": "view == roo-cline.SidebarProvider"
213218
},
214219
{
215-
"command": "roo-cline.historyButtonClicked",
220+
"command": "roo-cline.mcpButtonClicked",
216221
"group": "navigation@4",
217222
"when": "view == roo-cline.SidebarProvider"
218223
},
219224
{
220-
"command": "roo-cline.popoutButtonClicked",
225+
"command": "roo-cline.historyButtonClicked",
221226
"group": "navigation@5",
222227
"when": "view == roo-cline.SidebarProvider"
223228
},
224229
{
225-
"command": "roo-cline.settingsButtonClicked",
230+
"command": "roo-cline.popoutButtonClicked",
226231
"group": "navigation@6",
227232
"when": "view == roo-cline.SidebarProvider"
233+
},
234+
{
235+
"command": "roo-cline.settingsButtonClicked",
236+
"group": "navigation@7",
237+
"when": "view == roo-cline.SidebarProvider"
228238
}
229239
]
230240
},

src/activate/registerCommands.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,37 @@ export type RegisterCommandOptions = {
1010
}
1111

1212
export const registerCommands = (options: RegisterCommandOptions) => {
13-
const { context, outputChannel } = options
13+
const { context } = options
1414

1515
for (const [command, callback] of Object.entries(getCommandsMap(options))) {
1616
context.subscriptions.push(vscode.commands.registerCommand(command, callback))
1717
}
1818
}
1919

20-
const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOptions) => {
21-
return {
22-
"roo-cline.plusButtonClicked": async () => {
23-
await provider.clearTask()
24-
await provider.postStateToWebview()
25-
await provider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
26-
},
27-
"roo-cline.mcpButtonClicked": () => {
28-
provider.postMessageToWebview({ type: "action", action: "mcpButtonClicked" })
29-
},
30-
"roo-cline.promptsButtonClicked": () => {
31-
provider.postMessageToWebview({ type: "action", action: "promptsButtonClicked" })
32-
},
33-
"roo-cline.popoutButtonClicked": () => openClineInNewTab({ context, outputChannel }),
34-
"roo-cline.openInNewTab": () => openClineInNewTab({ context, outputChannel }),
35-
"roo-cline.settingsButtonClicked": () => {
36-
provider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
37-
},
38-
"roo-cline.historyButtonClicked": () => {
39-
provider.postMessageToWebview({ type: "action", action: "historyButtonClicked" })
40-
},
41-
}
42-
}
20+
const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOptions) => ({
21+
"roo-cline.plusButtonClicked": async () => {
22+
await provider.clearTask()
23+
await provider.postStateToWebview()
24+
await provider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
25+
},
26+
"roo-cline.researchButtonClicked": () => {
27+
provider.postMessageToWebview({ type: "action", action: "researchButtonClicked" })
28+
},
29+
"roo-cline.promptsButtonClicked": () => {
30+
provider.postMessageToWebview({ type: "action", action: "promptsButtonClicked" })
31+
},
32+
"roo-cline.mcpButtonClicked": () => {
33+
provider.postMessageToWebview({ type: "action", action: "mcpButtonClicked" })
34+
},
35+
"roo-cline.historyButtonClicked": () => {
36+
provider.postMessageToWebview({ type: "action", action: "historyButtonClicked" })
37+
},
38+
"roo-cline.popoutButtonClicked": () => openClineInNewTab({ context, outputChannel }),
39+
"roo-cline.settingsButtonClicked": () => {
40+
provider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
41+
},
42+
"roo-cline.openInNewTab": () => openClineInNewTab({ context, outputChannel }),
43+
})
4344

4445
const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
4546
outputChannel.appendLine("Opening Roo Code in new tab")

src/core/webview/ClineProvider.ts

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ import { ApiConfiguration, ApiProvider, ModelInfo } from "../../shared/api"
2020
import { findLast } from "../../shared/array"
2121
import { ApiConfigMeta, ExtensionMessage } from "../../shared/ExtensionMessage"
2222
import { HistoryItem } from "../../shared/HistoryItem"
23-
import { checkoutDiffPayloadSchema, checkoutRestorePayloadSchema, WebviewMessage } from "../../shared/WebviewMessage"
23+
import {
24+
checkoutDiffPayloadSchema,
25+
checkoutRestorePayloadSchema,
26+
researchAppendPayloadSchema,
27+
WebviewMessage,
28+
} from "../../shared/WebviewMessage"
2429
import { Mode, CustomModePrompts, PromptComponent, defaultModeSlug } from "../../shared/modes"
2530
import { SYSTEM_PROMPT } from "../prompts/system"
2631
import { fileExistsAtPath } from "../../utils/fs"
2732
import { Cline } from "../Cline"
33+
import { DeepResearchService } from "../../services/deep-research/DeepResearchService"
2834
import { openMention } from "../mentions"
2935
import { getNonce } from "./getNonce"
3036
import { getUri } from "./getUri"
@@ -40,11 +46,10 @@ import { CustomSupportPrompts, supportPrompt } from "../../shared/support-prompt
4046
import { ACTION_NAMES } from "../CodeActionProvider"
4147
import { McpServerManager } from "../../services/mcp/McpServerManager"
4248

43-
/*
44-
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
45-
46-
https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
47-
*/
49+
/**
50+
* https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
51+
* https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
52+
*/
4853

4954
type SecretKey =
5055
| "apiKey"
@@ -60,6 +65,7 @@ type SecretKey =
6065
| "mistralApiKey"
6166
| "unboundApiKey"
6267
| "requestyApiKey"
68+
6369
type GlobalStateKey =
6470
| "apiProvider"
6571
| "apiModelId"
@@ -146,6 +152,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
146152
private view?: vscode.WebviewView | vscode.WebviewPanel
147153
private isViewLaunched = false
148154
private cline?: Cline
155+
private deepResearchService?: DeepResearchService
149156
private workspaceTracker?: WorkspaceTracker
150157
protected mcpHub?: McpHub // Change from private to protected
151158
private latestAnnouncementId = "jan-21-2025-custom-modes" // update to some unique identifier when we add a new announcement
@@ -158,6 +165,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
158165
) {
159166
this.outputChannel.appendLine("ClineProvider instantiated")
160167
ClineProvider.activeInstances.add(this)
168+
161169
this.workspaceTracker = new WorkspaceTracker(this)
162170
this.configManager = new ConfigManager(this.context)
163171
this.customModesManager = new CustomModesManager(this.context, async () => {
@@ -1515,10 +1523,43 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15151523
}
15161524

15171525
await this.customModesManager.deleteCustomMode(message.slug)
1518-
// Switch back to default mode after deletion
1526+
// Switch back to default mode after deletion.
15191527
await this.updateGlobalState("mode", defaultModeSlug)
15201528
await this.postStateToWebview()
15211529
}
1530+
break
1531+
1532+
case "research.start": {
1533+
const result = researchAppendPayloadSchema.safeParse(message.payload)
1534+
console.log("[ClineProvider] research.start", result)
1535+
1536+
if (result.success) {
1537+
if (this.deepResearchService) {
1538+
await this.deepResearchService.abort()
1539+
}
1540+
1541+
this.deepResearchService = new DeepResearchService(this, "o3-mini", 4, 2, 2)
1542+
this.deepResearchService.start(result.data.message.content)
1543+
}
1544+
1545+
break
1546+
}
1547+
case "research.append": {
1548+
const result = researchAppendPayloadSchema.safeParse(message.payload)
1549+
console.log("[ClineProvider] research.append", result)
1550+
1551+
if (result.success && this.deepResearchService) {
1552+
this.deepResearchService.append(result.data.message.content)
1553+
}
1554+
1555+
break
1556+
}
1557+
case "research.reload":
1558+
console.log("[ClineProvider] research.reload", message)
1559+
break
1560+
case "research.stop":
1561+
console.log("[ClineProvider] research.stop", message)
1562+
break
15221563
}
15231564
},
15241565
null,

0 commit comments

Comments
 (0)