POC: runnable VS Code extension on @cline/sdk (Feature #2) #3

Merged
benstull merged 5 commits from poc/cline-sdk-extension into main 2026-06-10 06:56:34 +00:00
2 changed files with 49 additions and 0 deletions
Showing only changes of commit 33bff2b130 - Show all commits
+34
View File
@@ -0,0 +1,34 @@
/**
* vscode-free driver for @cline/sdk.
*
* @cline/sdk is ESM-only (Node >=22) and uses createRequire(import.meta.url),
* so it must NOT be bundled into the CJS extension. We load it at runtime via
* dynamic import(); the bundler keeps it external (see esbuild.mjs).
*/
export interface ClineTool {
id: string;
description: string;
}
export interface SdkSummary {
version: string;
tools: ClineTool[];
}
/**
* Drive @cline/sdk with pure, key-free calls and return a renderable summary:
* the SDK build version and the agent's builtin tool catalog. Proves the SDK
* is linked and callable from the extension host.
*/
export async function fetchSdkSummary(): Promise<SdkSummary> {
const sdk = await import("@cline/sdk");
const catalog = sdk.getCoreBuiltinToolCatalog();
return {
version: sdk.CORE_BUILD_VERSION,
tools: catalog.map((entry) => ({
id: entry.id,
description: entry.description,
})),
};
}
+15
View File
@@ -0,0 +1,15 @@
import { describe, it, expect } from "vitest";
import { fetchSdkSummary } from "../src/cline";
describe("fetchSdkSummary", () => {
it("loads @cline/sdk and returns its version and builtin tool catalog", async () => {
const summary = await fetchSdkSummary();
expect(summary.version).toMatch(/^\d+\.\d+\.\d+/);
expect(summary.tools.length).toBeGreaterThan(0);
expect(summary.tools.map((t) => t.id)).toContain("read_files");
for (const tool of summary.tools) {
expect(typeof tool.id).toBe("string");
expect(typeof tool.description).toBe("string");
}
});
});