Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<version>.vsix
```

We use [changesets](https://github.com/changesets/changesets) for versioning and publishing. Check our `CHANGELOG.md` for release notes.

---
Expand Down
26 changes: 26 additions & 0 deletions src/activate/humanRelay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Callback mapping of human relay response.
const humanRelayCallbacks = new Map<string, (response: string | undefined) => 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)
}
}
32 changes: 16 additions & 16 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) => {
Expand All @@ -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,
}
}

Expand Down
54 changes: 5 additions & 49 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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<string, (response: string | undefined) => 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) {
Expand Down Expand Up @@ -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
Expand Down