POC: runnable VS Code extension on @cline/sdk (Feature #2) #3
+27
@@ -0,0 +1,27 @@
|
||||
import { build, context } from "esbuild";
|
||||
|
||||
const watch = process.argv.includes("--watch");
|
||||
|
||||
/** @type {import('esbuild').BuildOptions} */
|
||||
const options = {
|
||||
entryPoints: ["src/extension.ts"],
|
||||
outfile: "out/extension.cjs",
|
||||
bundle: true,
|
||||
platform: "node",
|
||||
format: "cjs",
|
||||
target: "node20",
|
||||
sourcemap: true,
|
||||
// vscode is provided by the host; @cline/sdk is ESM-only and is loaded at
|
||||
// runtime via dynamic import() from node_modules, so keep both external.
|
||||
external: ["vscode", "@cline/sdk"],
|
||||
logLevel: "info",
|
||||
};
|
||||
|
||||
if (watch) {
|
||||
const ctx = await context(options);
|
||||
await ctx.watch();
|
||||
console.log("esbuild: watching…");
|
||||
} else {
|
||||
await build(options);
|
||||
console.log("esbuild: build complete → out/extension.cjs");
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import * as vscode from "vscode";
|
||||
import { fetchSdkSummary } from "./cline";
|
||||
|
||||
const CHANNEL_NAME = "Cowriting (Cline SDK)";
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): void {
|
||||
const output = vscode.window.createOutputChannel(CHANNEL_NAME);
|
||||
context.subscriptions.push(output);
|
||||
|
||||
const command = vscode.commands.registerCommand(
|
||||
"cowriting.showClineSdkInfo",
|
||||
async () => {
|
||||
try {
|
||||
const summary = await fetchSdkSummary();
|
||||
output.clear();
|
||||
output.appendLine(`@cline/sdk version: ${summary.version}`);
|
||||
output.appendLine(`Builtin tools (${summary.tools.length}):`);
|
||||
for (const tool of summary.tools) {
|
||||
output.appendLine(` • ${tool.id} — ${tool.description}`);
|
||||
}
|
||||
output.show(true);
|
||||
await vscode.window.showInformationMessage(
|
||||
`Cline SDK ${summary.version} loaded — ${summary.tools.length} builtin tools. See the "${CHANNEL_NAME}" output channel.`
|
||||
);
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
output.appendLine(`Failed to drive @cline/sdk: ${message}`);
|
||||
output.show(true);
|
||||
await vscode.window.showErrorMessage(
|
||||
`Cowriting: failed to load @cline/sdk — ${message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
context.subscriptions.push(command);
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
// Nothing to clean up beyond the disposables registered on the context.
|
||||
}
|
||||
Reference in New Issue
Block a user