mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
refactor(code-actions): implement parameter object pattern for prompt generation
- Extract prompt templates into constants - Add createPrompt utility for template string handling - Consolidate code action handling in ClineProvider - Update tests to use new parameter object pattern
This commit is contained in:
@@ -174,34 +174,23 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
// 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)
|
||||
await ClineProvider.handleCodeAction(explainCodePrompt, { filePath, selectedText })
|
||||
})
|
||||
);
|
||||
|
||||
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)
|
||||
await ClineProvider.handleCodeAction(fixCodePrompt, {
|
||||
filePath,
|
||||
selectedText,
|
||||
...(diagnostics ? { diagnostics } : {})
|
||||
})
|
||||
})
|
||||
);
|
||||
|
||||
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)
|
||||
await ClineProvider.handleCodeAction(improveCodePrompt, { filePath, selectedText })
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user