mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-08 22:21:23 +00:00
add user input
This commit is contained in:
parent
0ceb370008
commit
679866ca52
3 changed files with 71 additions and 44 deletions
|
|
@ -15,9 +15,21 @@ export const registerTerminalActions = (context: vscode.ExtensionContext) => {
|
|||
|
||||
registerTerminalAction(context, terminalManager, TERMINAL_COMMAND_IDS.ADD_TO_CONTEXT, "TERMINAL_ADD_TO_CONTEXT")
|
||||
|
||||
registerTerminalActionPair(context, terminalManager, TERMINAL_COMMAND_IDS.FIX, "TERMINAL_FIX")
|
||||
registerTerminalActionPair(
|
||||
context,
|
||||
terminalManager,
|
||||
TERMINAL_COMMAND_IDS.FIX,
|
||||
"TERMINAL_FIX",
|
||||
"What would you like Roo to fix?",
|
||||
)
|
||||
|
||||
registerTerminalActionPair(context, terminalManager, TERMINAL_COMMAND_IDS.EXPLAIN, "TERMINAL_EXPLAIN")
|
||||
registerTerminalActionPair(
|
||||
context,
|
||||
terminalManager,
|
||||
TERMINAL_COMMAND_IDS.EXPLAIN,
|
||||
"TERMINAL_EXPLAIN",
|
||||
"What would you like Roo to explain?",
|
||||
)
|
||||
}
|
||||
|
||||
const registerTerminalAction = (
|
||||
|
|
@ -25,6 +37,7 @@ const registerTerminalAction = (
|
|||
terminalManager: TerminalManager,
|
||||
command: string,
|
||||
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
|
||||
inputPrompt?: string,
|
||||
) => {
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand(command, async (args: any) => {
|
||||
|
|
@ -38,7 +51,18 @@ const registerTerminalAction = (
|
|||
return
|
||||
}
|
||||
|
||||
await ClineProvider.handleTerminalAction(command, promptType, content)
|
||||
const params: Record<string, any> = {
|
||||
terminalContent: content,
|
||||
}
|
||||
|
||||
if (inputPrompt) {
|
||||
params.userInput =
|
||||
(await vscode.window.showInputBox({
|
||||
prompt: inputPrompt,
|
||||
})) ?? ""
|
||||
}
|
||||
|
||||
await ClineProvider.handleTerminalAction(command, promptType, params)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
@ -48,9 +72,10 @@ const registerTerminalActionPair = (
|
|||
terminalManager: TerminalManager,
|
||||
baseCommand: string,
|
||||
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
|
||||
inputPrompt?: string,
|
||||
) => {
|
||||
// Register new task version
|
||||
registerTerminalAction(context, terminalManager, baseCommand, promptType)
|
||||
registerTerminalAction(context, terminalManager, baseCommand, promptType, inputPrompt)
|
||||
// Register current task version
|
||||
registerTerminalAction(context, terminalManager, `${baseCommand}InCurrentTask`, promptType)
|
||||
registerTerminalAction(context, terminalManager, `${baseCommand}InCurrentTask`, promptType, inputPrompt)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,42 +132,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||
public static readonly tabPanelId = "roo-cline.TabPanelProvider"
|
||||
private static activeInstances: Set<ClineProvider> = new Set()
|
||||
private disposables: vscode.Disposable[] = []
|
||||
|
||||
public static async handleTerminalAction(
|
||||
command: string,
|
||||
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
|
||||
terminalContent: string,
|
||||
): Promise<void> {
|
||||
const visibleProvider = await ClineProvider.getInstance()
|
||||
if (!visibleProvider) {
|
||||
return
|
||||
}
|
||||
|
||||
const { customSupportPrompts } = await visibleProvider.getState()
|
||||
|
||||
const prompt = supportPrompt.create(promptType, { terminalContent }, customSupportPrompts)
|
||||
|
||||
if (command.endsWith("AddToContext")) {
|
||||
await visibleProvider.postMessageToWebview({
|
||||
type: "invoke",
|
||||
invoke: "setChatBoxMessage",
|
||||
text: prompt,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (visibleProvider.cline && command.endsWith("InCurrentTask")) {
|
||||
await visibleProvider.postMessageToWebview({
|
||||
type: "invoke",
|
||||
invoke: "sendMessage",
|
||||
text: prompt,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await visibleProvider.initClineWithTask(prompt)
|
||||
}
|
||||
|
||||
private view?: vscode.WebviewView | vscode.WebviewPanel
|
||||
private isViewLaunched = false
|
||||
private cline?: Cline
|
||||
|
|
@ -292,6 +256,41 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||
await visibleProvider.initClineWithTask(prompt)
|
||||
}
|
||||
|
||||
public static async handleTerminalAction(
|
||||
command: string,
|
||||
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
|
||||
params: Record<string, string | any[]>,
|
||||
): Promise<void> {
|
||||
const visibleProvider = await ClineProvider.getInstance()
|
||||
if (!visibleProvider) {
|
||||
return
|
||||
}
|
||||
|
||||
const { customSupportPrompts } = await visibleProvider.getState()
|
||||
|
||||
const prompt = supportPrompt.create(promptType, params, customSupportPrompts)
|
||||
|
||||
if (command.endsWith("AddToContext")) {
|
||||
await visibleProvider.postMessageToWebview({
|
||||
type: "invoke",
|
||||
invoke: "setChatBoxMessage",
|
||||
text: prompt,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (visibleProvider.cline && command.endsWith("InCurrentTask")) {
|
||||
await visibleProvider.postMessageToWebview({
|
||||
type: "invoke",
|
||||
invoke: "sendMessage",
|
||||
text: prompt,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await visibleProvider.initClineWithTask(prompt)
|
||||
}
|
||||
|
||||
async resolveWebviewView(webviewView: vscode.WebviewView | vscode.WebviewPanel) {
|
||||
this.outputChannel.appendLine("Resolving webview view")
|
||||
this.view = webviewView
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ Provide the improved code along with explanations for each enhancement.`,
|
|||
label: "Add Terminal Content to Context",
|
||||
description:
|
||||
"Add terminal output to your current task or conversation. Useful for providing command outputs or logs. Available in the terminal context menu (right-click on selected terminal content).",
|
||||
template: `Terminal output:
|
||||
template: `\${userInput}
|
||||
Terminal output:
|
||||
\`\`\`
|
||||
\${terminalContent}
|
||||
\`\`\``,
|
||||
|
|
@ -114,7 +115,8 @@ Provide the improved code along with explanations for each enhancement.`,
|
|||
label: "Fix Terminal Command",
|
||||
description:
|
||||
"Get help fixing terminal commands that failed or need improvement. Available in the terminal context menu (right-click on selected terminal content).",
|
||||
template: `Fix this terminal command:
|
||||
template: `\${userInput}
|
||||
Fix this terminal command:
|
||||
\`\`\`
|
||||
\${terminalContent}
|
||||
\`\`\`
|
||||
|
|
@ -128,7 +130,8 @@ Please:
|
|||
label: "Explain Terminal Command",
|
||||
description:
|
||||
"Get detailed explanations of terminal commands and their outputs. Available in the terminal context menu (right-click on selected terminal content).",
|
||||
template: `Explain this terminal command:
|
||||
template: `\${userInput}
|
||||
Explain this terminal command:
|
||||
\`\`\`
|
||||
\${terminalContent}
|
||||
\`\`\`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue