mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Cline API
The Cline extension exposes an API that can be used by other extensions. To use this API in your extension:
-
Copy
src/extension-api/cline.d.tsto your extension's source directory. -
Include
cline.d.tsin your extension's compilation. -
Get access to the API with the following code:
const clineExtension = vscode.extensions.getExtension<ClineAPI>("saoudrizwan.claude-dev") if (!clineExtension?.isActive) { throw new Error("Cline extension is not activated") } const cline = clineExtension.exports if (cline) { // Now you can use the API // Set custom instructions await cline.setCustomInstructions("Talk like a pirate") // Get custom instructions const instructions = await cline.getCustomInstructions() console.log("Current custom instructions:", instructions) // Start a new task with an initial message await cline.startNewTask("Hello, Cline! Let's make a new project...") // Start a new task with an initial message and images await cline.startNewTask("Use this design language", ["data:image/webp;base64,..."]) // Send a message to the current task await cline.sendMessage("Can you fix the @problems?") // Simulate pressing the primary button in the chat interface (e.g. 'Save' or 'Proceed While Running') await cline.pressPrimaryButton() // Simulate pressing the secondary button in the chat interface (e.g. 'Reject') await cline.pressSecondaryButton() } else { console.error("Cline API is not available") }Note: To ensure that the
saoudrizwan.claude-devextension is activated before your extension, add it to theextensionDependenciesin yourpackage.json:"extensionDependencies": [ "saoudrizwan.claude-dev" ]
For detailed information on the available methods and their usage, refer to the cline.d.ts file.