mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Refactor exports
This commit is contained in:
@@ -1,46 +1,46 @@
|
|||||||
# Claude Dev API
|
# Cline API
|
||||||
|
|
||||||
The Claude Dev extension exposes an API that can be used by other extensions. To use this API in your extension:
|
The Cline extension exposes an API that can be used by other extensions. To use this API in your extension:
|
||||||
|
|
||||||
1. Copy `src/extension-api/claude-dev.d.ts` to your extension's source directory.
|
1. Copy `src/extension-api/cline.d.ts` to your extension's source directory.
|
||||||
2. Include `claude-dev.d.ts` in your extension's compilation.
|
2. Include `cline.d.ts` in your extension's compilation.
|
||||||
3. Get access to the API with the following code:
|
3. Get access to the API with the following code:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const claudeDevExtension = vscode.extensions.getExtension<ClaudeDevAPI>("saoudrizwan.claude-dev")
|
const clineExtension = vscode.extensions.getExtension<ClineAPI>("saoudrizwan.claude-dev")
|
||||||
|
|
||||||
if (!claudeDevExtension?.isActive) {
|
if (!clineExtension?.isActive) {
|
||||||
throw new Error("Claude Dev extension is not activated")
|
throw new Error("Cline extension is not activated")
|
||||||
}
|
}
|
||||||
|
|
||||||
const claudeDev = claudeDevExtension.exports
|
const cline = clineExtension.exports
|
||||||
|
|
||||||
if (claudeDev) {
|
if (cline) {
|
||||||
// Now you can use the API
|
// Now you can use the API
|
||||||
|
|
||||||
// Set custom instructions
|
// Set custom instructions
|
||||||
await claudeDev.setCustomInstructions("Talk like a pirate")
|
await cline.setCustomInstructions("Talk like a pirate")
|
||||||
|
|
||||||
// Get custom instructions
|
// Get custom instructions
|
||||||
const instructions = await claudeDev.getCustomInstructions()
|
const instructions = await cline.getCustomInstructions()
|
||||||
console.log("Current custom instructions:", instructions)
|
console.log("Current custom instructions:", instructions)
|
||||||
|
|
||||||
// Start a new task with an initial message
|
// Start a new task with an initial message
|
||||||
await claudeDev.startNewTask("Hello, Claude! Let's make a new project...")
|
await cline.startNewTask("Hello, Claude! Let's make a new project...")
|
||||||
|
|
||||||
// Start a new task with an initial message and images
|
// Start a new task with an initial message and images
|
||||||
await claudeDev.startNewTask("Use this design language", ["data:image/webp;base64,..."])
|
await cline.startNewTask("Use this design language", ["data:image/webp;base64,..."])
|
||||||
|
|
||||||
// Send a message to the current task
|
// Send a message to the current task
|
||||||
await claudeDev.sendMessage("Can you fix the @problems?")
|
await cline.sendMessage("Can you fix the @problems?")
|
||||||
|
|
||||||
// Simulate pressing the primary button in the chat interface (e.g. 'Save' or 'Proceed While Running')
|
// Simulate pressing the primary button in the chat interface (e.g. 'Save' or 'Proceed While Running')
|
||||||
await claudeDev.pressPrimaryButton()
|
await cline.pressPrimaryButton()
|
||||||
|
|
||||||
// Simulate pressing the secondary button in the chat interface (e.g. 'Reject')
|
// Simulate pressing the secondary button in the chat interface (e.g. 'Reject')
|
||||||
await claudeDev.pressSecondaryButton()
|
await cline.pressSecondaryButton()
|
||||||
} else {
|
} else {
|
||||||
console.error("Claude Dev API is not available")
|
console.error("Cline API is not available")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -52,4 +52,4 @@ The Claude Dev extension exposes an API that can be used by other extensions. To
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
For detailed information on the available methods and their usage, refer to the `claude-dev.d.ts` file.
|
For detailed information on the available methods and their usage, refer to the `cline.d.ts` file.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface ClaudeDevAPI {
|
export interface ClineAPI {
|
||||||
/**
|
/**
|
||||||
* Sets the custom instructions in the global storage.
|
* Sets the custom instructions in the global storage.
|
||||||
* @param value The custom instructions to be saved.
|
* @param value The custom instructions to be saved.
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import * as vscode from "vscode"
|
import * as vscode from "vscode"
|
||||||
import { ClineProvider } from "../core/webview/ClineProvider"
|
import { ClineProvider } from "../core/webview/ClineProvider"
|
||||||
import { ClaudeDevAPI } from "./claude-dev"
|
import { ClineAPI } from "./cline"
|
||||||
|
|
||||||
export function createClaudeDevAPI(outputChannel: vscode.OutputChannel, sidebarProvider: ClineProvider): ClaudeDevAPI {
|
export function createClineAPI(outputChannel: vscode.OutputChannel, sidebarProvider: ClineProvider): ClineAPI {
|
||||||
const api: ClaudeDevAPI = {
|
const api: ClineAPI = {
|
||||||
setCustomInstructions: async (value: string) => {
|
setCustomInstructions: async (value: string) => {
|
||||||
await sidebarProvider.updateCustomInstructions(value)
|
await sidebarProvider.updateCustomInstructions(value)
|
||||||
outputChannel.appendLine("Custom instructions set")
|
outputChannel.appendLine("Custom instructions set")
|
||||||
|
|||||||
Reference in New Issue
Block a user