diff --git a/README.md b/README.md index 59ca6d699f1..f907ea480ee 100644 --- a/README.md +++ b/README.md @@ -115,37 +115,40 @@ Make Roo Code work your way with: ## Local Setup & Development 1. **Clone** the repo: - ```bash - git clone https://github.com/RooVetGit/Roo-Code.git - ``` + +```sh +git clone https://github.com/RooVetGit/Roo-Code.git +``` + 2. **Install dependencies**: - ```bash - npm run install:all - ``` - -if that fails, try: - ```bash - npm run install:ci - ``` - -3. **Build** the extension: - ```bash - npm run build - ``` - - A `.vsix` file will appear in the `bin/` directory. -4. **Install** the `.vsix` manually if desired: - ```bash - code --install-extension bin/roo-code-4.0.0.vsix - ``` -5. **Start the webview (Vite/React app with HMR)**: - ```bash - npm run dev - ``` -6. **Debug**: - - Press `F5` (or **Run** → **Start Debugging**) in VSCode to open a new session with Roo Code loaded. + +```sh +npm run install:all +``` + +3. **Start the webview (Vite/React app with HMR)**: + +```sh +npm run dev +``` + +4. **Debug**: + Press `F5` (or **Run** → **Start Debugging**) in VSCode to open a new session with Roo Code loaded. Changes to the webview will appear immediately. Changes to the core extension will require a restart of the extension host. +Alternatively you can build a .vsix and install it directly in VSCode: + +```sh +npm run build +``` + +A `.vsix` file will appear in the `bin/` directory which can be installed with: + +```sh +code --install-extension bin/roo-cline-.vsix +``` + We use [changesets](https://github.com/changesets/changesets) for versioning and publishing. Check our `CHANGELOG.md` for release notes. --- diff --git a/src/activate/humanRelay.ts b/src/activate/humanRelay.ts new file mode 100644 index 00000000000..ed87026aa73 --- /dev/null +++ b/src/activate/humanRelay.ts @@ -0,0 +1,26 @@ +// Callback mapping of human relay response. +const humanRelayCallbacks = new Map void>() + +/** + * Register a callback function for human relay response. + * @param requestId + * @param callback + */ +export const registerHumanRelayCallback = (requestId: string, callback: (response: string | undefined) => void) => + humanRelayCallbacks.set(requestId, callback) + +export const unregisterHumanRelayCallback = (requestId: string) => humanRelayCallbacks.delete(requestId) + +export const handleHumanRelayResponse = (response: { requestId: string; text?: string; cancelled?: boolean }) => { + const callback = humanRelayCallbacks.get(response.requestId) + + if (callback) { + if (response.cancelled) { + callback(undefined) + } else { + callback(response.text) + } + + humanRelayCallbacks.delete(response.requestId) + } +} diff --git a/src/activate/registerCommands.ts b/src/activate/registerCommands.ts index e1c1ec93c61..1ca7ee96f80 100644 --- a/src/activate/registerCommands.ts +++ b/src/activate/registerCommands.ts @@ -3,6 +3,8 @@ import delay from "delay" import { ClineProvider } from "../core/webview/ClineProvider" +import { registerHumanRelayCallback, unregisterHumanRelayCallback, handleHumanRelayResponse } from "./humanRelay" + // Store panel references in both modes let sidebarPanel: vscode.WebviewView | undefined = undefined let tabPanel: vscode.WebviewPanel | undefined = undefined @@ -43,22 +45,6 @@ export const registerCommands = (options: RegisterCommandOptions) => { for (const [command, callback] of Object.entries(getCommandsMap(options))) { context.subscriptions.push(vscode.commands.registerCommand(command, callback)) } - - // Human Relay Dialog Command - context.subscriptions.push( - vscode.commands.registerCommand( - "roo-cline.showHumanRelayDialog", - (params: { requestId: string; promptText: string }) => { - if (getPanel()) { - getPanel()?.webview.postMessage({ - type: "showHumanRelayDialog", - requestId: params.requestId, - promptText: params.promptText, - }) - } - }, - ), - ) } const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOptions) => { @@ -85,6 +71,20 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt "roo-cline.helpButtonClicked": () => { vscode.env.openExternal(vscode.Uri.parse("https://docs.roocode.com")) }, + "roo-cline.showHumanRelayDialog": (params: { requestId: string; promptText: string }) => { + const panel = getPanel() + + if (panel) { + panel?.webview.postMessage({ + type: "showHumanRelayDialog", + requestId: params.requestId, + promptText: params.promptText, + }) + } + }, + "roo-cline.registerHumanRelayCallback": registerHumanRelayCallback, + "roo-cline.unregisterHumanRelayCallback": unregisterHumanRelayCallback, + "roo-cline.handleHumanRelayResponse": handleHumanRelayResponse, } } diff --git a/src/extension.ts b/src/extension.ts index d88bf2a251d..c85d61053f9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -11,15 +11,17 @@ try { console.warn("Failed to load environment variables:", e) } -import { ClineProvider } from "./core/webview/ClineProvider" -import { createClineAPI } from "./exports" import "./utils/path" // Necessary to have access to String.prototype.toPosix. + +import { createClineAPI } from "./exports" +import { ClineProvider } from "./core/webview/ClineProvider" import { CodeActionProvider } from "./core/CodeActionProvider" import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider" -import { handleUri, registerCommands, registerCodeActions } from "./activate" import { McpServerManager } from "./services/mcp/McpServerManager" import { telemetryService } from "./services/telemetry/TelemetryService" +import { handleUri, registerCommands, registerCodeActions } from "./activate" + /** * Built using https://github.com/microsoft/vscode-webview-ui-toolkit * @@ -31,18 +33,6 @@ import { telemetryService } from "./services/telemetry/TelemetryService" let outputChannel: vscode.OutputChannel let extensionContext: vscode.ExtensionContext -// Callback mapping of human relay response -const humanRelayCallbacks = new Map void>() - -/** - * Register a callback function for human relay response - * @param requestId - * @param callback - */ -export function registerHumanRelayCallback(requestId: string, callback: (response: string | undefined) => void): void { - humanRelayCallbacks.set(requestId, callback) -} - // This method is called when your extension is activated. // Your extension is activated the very first time the command is executed. export function activate(context: vscode.ExtensionContext) { @@ -72,40 +62,6 @@ export function activate(context: vscode.ExtensionContext) { registerCommands({ context, outputChannel, provider: sidebarProvider }) - // Register human relay callback registration command - context.subscriptions.push( - vscode.commands.registerCommand( - "roo-cline.registerHumanRelayCallback", - (requestId: string, callback: (response: string | undefined) => void) => { - registerHumanRelayCallback(requestId, callback) - }, - ), - ) - - // Register human relay response processing command - context.subscriptions.push( - vscode.commands.registerCommand( - "roo-cline.handleHumanRelayResponse", - (response: { requestId: string; text?: string; cancelled?: boolean }) => { - const callback = humanRelayCallbacks.get(response.requestId) - if (callback) { - if (response.cancelled) { - callback(undefined) - } else { - callback(response.text) - } - humanRelayCallbacks.delete(response.requestId) - } - }, - ), - ) - - context.subscriptions.push( - vscode.commands.registerCommand("roo-cline.unregisterHumanRelayCallback", (requestId: string) => { - humanRelayCallbacks.delete(requestId) - }), - ) - /** * We use the text document content provider API to show the left side for diff * view by creating a virtual document for the original content. This makes it