mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
feat: integrate code actions into extension activation
This commit is contained in:
@@ -5,6 +5,8 @@ import * as vscode from "vscode"
|
||||
import { ClineProvider } from "./core/webview/ClineProvider"
|
||||
import { createClineAPI } from "./exports"
|
||||
import "./utils/path" // necessary to have access to String.prototype.toPosix
|
||||
import { CodeActionProvider } from "./core/CodeActionProvider"
|
||||
import { explainCodePrompt, fixCodePrompt, improveCodePrompt } from "./core/prompts/code-actions"
|
||||
import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider"
|
||||
|
||||
/*
|
||||
@@ -158,6 +160,51 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
context.subscriptions.push(vscode.window.registerUriHandler({ handleUri }))
|
||||
|
||||
// Register code actions provider
|
||||
context.subscriptions.push(
|
||||
vscode.languages.registerCodeActionsProvider(
|
||||
{ pattern: "**/*" },
|
||||
new CodeActionProvider(),
|
||||
{
|
||||
providedCodeActionKinds: CodeActionProvider.providedCodeActionKinds
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Register code action commands
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("roo-cline.explainCode", async (filePath: string, selectedText: string) => {
|
||||
const visibleProvider = ClineProvider.getVisibleInstance()
|
||||
if (!visibleProvider) {
|
||||
return
|
||||
}
|
||||
const prompt = explainCodePrompt(filePath, selectedText)
|
||||
await visibleProvider.initClineWithTask(prompt)
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("roo-cline.fixCode", async (filePath: string, selectedText: string, diagnostics?: any[]) => {
|
||||
const visibleProvider = ClineProvider.getVisibleInstance()
|
||||
if (!visibleProvider) {
|
||||
return
|
||||
}
|
||||
const prompt = fixCodePrompt(filePath, selectedText, diagnostics)
|
||||
await visibleProvider.initClineWithTask(prompt)
|
||||
})
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("roo-cline.improveCode", async (filePath: string, selectedText: string) => {
|
||||
const visibleProvider = ClineProvider.getVisibleInstance()
|
||||
if (!visibleProvider) {
|
||||
return
|
||||
}
|
||||
const prompt = improveCodePrompt(filePath, selectedText)
|
||||
await visibleProvider.initClineWithTask(prompt)
|
||||
})
|
||||
);
|
||||
|
||||
return createClineAPI(outputChannel, sidebarProvider)
|
||||
}
|
||||
|
||||
|
||||
@@ -117,13 +117,16 @@ suite("Roo Cline Extension Test Suite", () => {
|
||||
|
||||
// Test core commands are registered
|
||||
const expectedCommands = [
|
||||
"roo-cline.plusButtonClicked",
|
||||
"roo-cline.mcpButtonClicked",
|
||||
"roo-cline.historyButtonClicked",
|
||||
"roo-cline.popoutButtonClicked",
|
||||
"roo-cline.settingsButtonClicked",
|
||||
"roo-cline.openInNewTab",
|
||||
]
|
||||
'roo-cline.plusButtonClicked',
|
||||
'roo-cline.mcpButtonClicked',
|
||||
'roo-cline.historyButtonClicked',
|
||||
'roo-cline.popoutButtonClicked',
|
||||
'roo-cline.settingsButtonClicked',
|
||||
'roo-cline.openInNewTab',
|
||||
'roo-cline.explainCode',
|
||||
'roo-cline.fixCode',
|
||||
'roo-cline.improveCode'
|
||||
];
|
||||
|
||||
for (const cmd of expectedCommands) {
|
||||
assert.strictEqual(commands.includes(cmd), true, `Command ${cmd} should be registered`)
|
||||
|
||||
Reference in New Issue
Block a user