|
1 | | -# Cline API |
| 1 | +# Roo Code API |
2 | 2 |
|
3 | | -The Cline extension exposes an API that can be used by other extensions. To use this API in your extension: |
| 3 | +The Roo Code extension exposes an API that can be used by other extensions. To use this API in your extension: |
4 | 4 |
|
5 | | -1. Copy `src/extension-api/cline.d.ts` to your extension's source directory. |
6 | | -2. Include `cline.d.ts` in your extension's compilation. |
| 5 | +1. Copy `src/extension-api/roo-code.d.ts` to your extension's source directory. |
| 6 | +2. Include `roo-code.d.ts` in your extension's compilation. |
7 | 7 | 3. Get access to the API with the following code: |
8 | 8 |
|
9 | | - ```ts |
10 | | - const clineExtension = vscode.extensions.getExtension<ClineAPI>("rooveterinaryinc.roo-cline") |
| 9 | +```typescript |
| 10 | +const extension = vscode.extensions.getExtension<RooCodeAPI>("rooveterinaryinc.roo-cline") |
11 | 11 |
|
12 | | - if (!clineExtension?.isActive) { |
13 | | - throw new Error("Cline extension is not activated") |
14 | | - } |
| 12 | +if (!extension?.isActive) { |
| 13 | + throw new Error("Extension is not activated") |
| 14 | +} |
15 | 15 |
|
16 | | - const cline = clineExtension.exports |
| 16 | +const api = extension.exports |
17 | 17 |
|
18 | | - if (cline) { |
19 | | - // Now you can use the API |
| 18 | +if (!api) { |
| 19 | + throw new Error("API is not available") |
| 20 | +} |
20 | 21 |
|
21 | | - // Set custom instructions |
22 | | - await cline.setCustomInstructions("Talk like a pirate") |
| 22 | +// Set custom instructions. |
| 23 | +await api.setCustomInstructions("Talk like a pirate") |
23 | 24 |
|
24 | | - // Get custom instructions |
25 | | - const instructions = await cline.getCustomInstructions() |
26 | | - console.log("Current custom instructions:", instructions) |
| 25 | +// Get custom instructions. |
| 26 | +const instructions = await api.getCustomInstructions() |
| 27 | +console.log("Current custom instructions:", instructions) |
27 | 28 |
|
28 | | - // Start a new task with an initial message |
29 | | - await cline.startNewTask("Hello, Cline! Let's make a new project...") |
| 29 | +// Start a new task with an initial message. |
| 30 | +await api.startNewTask("Hello, Roo Code API! Let's make a new project...") |
30 | 31 |
|
31 | | - // Start a new task with an initial message and images |
32 | | - await cline.startNewTask("Use this design language", ["data:image/webp;base64,..."]) |
| 32 | +// Start a new task with an initial message and images. |
| 33 | +await api.startNewTask("Use this design language", ["data:image/webp;base64,..."]) |
33 | 34 |
|
34 | | - // Send a message to the current task |
35 | | - await cline.sendMessage("Can you fix the @problems?") |
| 35 | +// Send a message to the current task. |
| 36 | +await api.sendMessage("Can you fix the @problems?") |
36 | 37 |
|
37 | | - // Simulate pressing the primary button in the chat interface (e.g. 'Save' or 'Proceed While Running') |
38 | | - await cline.pressPrimaryButton() |
| 38 | +// Simulate pressing the primary button in the chat interface (e.g. 'Save' or 'Proceed While Running'). |
| 39 | +await api.pressPrimaryButton() |
39 | 40 |
|
40 | | - // Simulate pressing the secondary button in the chat interface (e.g. 'Reject') |
41 | | - await cline.pressSecondaryButton() |
42 | | - } else { |
43 | | - console.error("Cline API is not available") |
44 | | - } |
45 | | - ``` |
| 41 | +// Simulate pressing the secondary button in the chat interface (e.g. 'Reject'). |
| 42 | +await api.pressSecondaryButton() |
| 43 | +``` |
46 | 44 |
|
47 | | - **Note:** To ensure that the `rooveterinaryinc.roo-cline` extension is activated before your extension, add it to the `extensionDependencies` in your `package.json`: |
| 45 | +**NOTE:** To ensure that the `rooveterinaryinc.roo-cline` extension is activated before your extension, add it to the `extensionDependencies` in your `package.json`: |
48 | 46 |
|
49 | | - ```json |
50 | | - "extensionDependencies": [ |
51 | | - "rooveterinaryinc.roo-cline" |
52 | | - ] |
53 | | - ``` |
| 47 | +```json |
| 48 | +"extensionDependencies": ["rooveterinaryinc.roo-cline"] |
| 49 | +``` |
54 | 50 |
|
55 | | -For detailed information on the available methods and their usage, refer to the `cline.d.ts` file. |
| 51 | +For detailed information on the available methods and their usage, refer to the `roo-code.d.ts` file. |
0 commit comments