@@ -5,6 +5,8 @@ import * as vscode from "vscode"
55import { ClineProvider } from "./core/webview/ClineProvider"
66import { createClineAPI } from "./exports"
77import "./utils/path" // necessary to have access to String.prototype.toPosix
8+ import { CodeActionProvider } from "./core/CodeActionProvider"
9+ import { explainCodePrompt , fixCodePrompt , improveCodePrompt } from "./core/prompts/code-actions"
810import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider"
911
1012/*
@@ -158,6 +160,51 @@ export function activate(context: vscode.ExtensionContext) {
158160 }
159161 context . subscriptions . push ( vscode . window . registerUriHandler ( { handleUri } ) )
160162
163+ // Register code actions provider
164+ context . subscriptions . push (
165+ vscode . languages . registerCodeActionsProvider (
166+ { pattern : "**/*" } ,
167+ new CodeActionProvider ( ) ,
168+ {
169+ providedCodeActionKinds : CodeActionProvider . providedCodeActionKinds
170+ }
171+ )
172+ ) ;
173+
174+ // Register code action commands
175+ context . subscriptions . push (
176+ vscode . commands . registerCommand ( "roo-cline.explainCode" , async ( filePath : string , selectedText : string ) => {
177+ const visibleProvider = ClineProvider . getVisibleInstance ( )
178+ if ( ! visibleProvider ) {
179+ return
180+ }
181+ const prompt = explainCodePrompt ( filePath , selectedText )
182+ await visibleProvider . initClineWithTask ( prompt )
183+ } )
184+ ) ;
185+
186+ context . subscriptions . push (
187+ vscode . commands . registerCommand ( "roo-cline.fixCode" , async ( filePath : string , selectedText : string , diagnostics ?: any [ ] ) => {
188+ const visibleProvider = ClineProvider . getVisibleInstance ( )
189+ if ( ! visibleProvider ) {
190+ return
191+ }
192+ const prompt = fixCodePrompt ( filePath , selectedText , diagnostics )
193+ await visibleProvider . initClineWithTask ( prompt )
194+ } )
195+ ) ;
196+
197+ context . subscriptions . push (
198+ vscode . commands . registerCommand ( "roo-cline.improveCode" , async ( filePath : string , selectedText : string ) => {
199+ const visibleProvider = ClineProvider . getVisibleInstance ( )
200+ if ( ! visibleProvider ) {
201+ return
202+ }
203+ const prompt = improveCodePrompt ( filePath , selectedText )
204+ await visibleProvider . initClineWithTask ( prompt )
205+ } )
206+ ) ;
207+
161208 return createClineAPI ( outputChannel , sidebarProvider )
162209}
163210
0 commit comments