From 0914c069af7016fd5d663dbde484aa6ea8c6ba62 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Sat, 5 Oct 2024 23:27:51 -0400 Subject: [PATCH] Refactor exports --- src/exports/README.md | 36 ++++++++++----------- src/exports/{claude-dev.d.ts => cline.d.ts} | 2 +- src/exports/index.ts | 6 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) rename src/exports/{claude-dev.d.ts => cline.d.ts} (97%) diff --git a/src/exports/README.md b/src/exports/README.md index fba8d2e..0187cf9 100644 --- a/src/exports/README.md +++ b/src/exports/README.md @@ -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. -2. Include `claude-dev.d.ts` in your extension's compilation. +1. Copy `src/extension-api/cline.d.ts` to your extension's source directory. +2. Include `cline.d.ts` in your extension's compilation. 3. Get access to the API with the following code: ```ts - const claudeDevExtension = vscode.extensions.getExtension("saoudrizwan.claude-dev") + const clineExtension = vscode.extensions.getExtension("saoudrizwan.claude-dev") - if (!claudeDevExtension?.isActive) { - throw new Error("Claude Dev extension is not activated") + if (!clineExtension?.isActive) { + 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 // Set custom instructions - await claudeDev.setCustomInstructions("Talk like a pirate") + await cline.setCustomInstructions("Talk like a pirate") // Get custom instructions - const instructions = await claudeDev.getCustomInstructions() + const instructions = await cline.getCustomInstructions() console.log("Current custom instructions:", instructions) // 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 - 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 - 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') - await claudeDev.pressPrimaryButton() + await cline.pressPrimaryButton() // Simulate pressing the secondary button in the chat interface (e.g. 'Reject') - await claudeDev.pressSecondaryButton() + await cline.pressSecondaryButton() } 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. diff --git a/src/exports/claude-dev.d.ts b/src/exports/cline.d.ts similarity index 97% rename from src/exports/claude-dev.d.ts rename to src/exports/cline.d.ts index 679a323..1ae285f 100644 --- a/src/exports/claude-dev.d.ts +++ b/src/exports/cline.d.ts @@ -1,4 +1,4 @@ -export interface ClaudeDevAPI { +export interface ClineAPI { /** * Sets the custom instructions in the global storage. * @param value The custom instructions to be saved. diff --git a/src/exports/index.ts b/src/exports/index.ts index 7de637c..7633f8d 100644 --- a/src/exports/index.ts +++ b/src/exports/index.ts @@ -1,9 +1,9 @@ import * as vscode from "vscode" import { ClineProvider } from "../core/webview/ClineProvider" -import { ClaudeDevAPI } from "./claude-dev" +import { ClineAPI } from "./cline" -export function createClaudeDevAPI(outputChannel: vscode.OutputChannel, sidebarProvider: ClineProvider): ClaudeDevAPI { - const api: ClaudeDevAPI = { +export function createClineAPI(outputChannel: vscode.OutputChannel, sidebarProvider: ClineProvider): ClineAPI { + const api: ClineAPI = { setCustomInstructions: async (value: string) => { await sidebarProvider.updateCustomInstructions(value) outputChannel.appendLine("Custom instructions set")