diff --git a/packages/kilo-vscode/README.md b/packages/kilo-vscode/README.md index 17ee739bb1e..8b636361149 100644 --- a/packages/kilo-vscode/README.md +++ b/packages/kilo-vscode/README.md @@ -46,6 +46,19 @@ If you want to contribute or modify the extension locally, see the [DEVELOPMENT.md](/DEVELOPMENT.md) file for build and setup instructions. +### Snapshot Builds + +To build and share a development snapshot of the extension: + +```bash +# Build only (outputs VSIX to system temp dir) +bun run snapshot:build + +# Build and install directly into VS Code +bun run snapshot:install +``` + + ## Contributing We welcome contributions from developers, writers, and enthusiasts! diff --git a/packages/kilo-vscode/package.json b/packages/kilo-vscode/package.json index e6325d4377b..efa67d7afbf 100644 --- a/packages/kilo-vscode/package.json +++ b/packages/kilo-vscode/package.json @@ -692,6 +692,8 @@ }, "scripts": { "prepare:cli-binary": "bun script/local-bin.ts", + "snapshot:build": "bun script/dev-snapshot.ts build", + "snapshot:install": "bun script/dev-snapshot.ts install", "compile": "bun run prepare:cli-binary && bun run rebuild-sdk && bun run typecheck && bun run lint && node esbuild.js", "watch": "bun run rebuild-sdk && bun run --parallel watch:esbuild watch:tsc", "watch:esbuild": "bun run prepare:cli-binary && node esbuild.js --watch", diff --git a/packages/kilo-vscode/script/dev-snapshot.ts b/packages/kilo-vscode/script/dev-snapshot.ts new file mode 100755 index 00000000000..e5953ce0092 --- /dev/null +++ b/packages/kilo-vscode/script/dev-snapshot.ts @@ -0,0 +1,68 @@ +#!/usr/bin/env bun +import { $ } from "bun" +import { join } from "node:path" +import { tmpdir } from "node:os" +import { rmSync, mkdirSync, existsSync } from "node:fs" + +const mode = process.argv[2] ?? "install" +const shouldInstall = mode === "install" + +const root = join(import.meta.dir, "..") +const pkgPath = join(root, "package.json") + +const pkg = await Bun.file(pkgPath).json() +const sha = (await $`git rev-parse --short HEAD`.text()).trim() +const user = (await $`git config user.name`.text()).trim().toLowerCase().replace(/\s+/g, "-") +const snapshotVersion = `${pkg.version}-snapshot+${sha}.${user}` + +console.log(`Building snapshot version: ${snapshotVersion}`) +console.log(`Base version: ${pkg.version}`) +console.log(`Commit: ${sha}`) +console.log(`Mode: ${mode}\n`) + +console.log("๐Ÿงน Cleaning build directories...") +for (const dir of ["bin", "dist"]) { + const dirPath = join(root, dir) + if (existsSync(dirPath)) { + rmSync(dirPath, { recursive: true, force: true }) + console.log(` โœ“ Cleaned ${dir}/`) + } +} + +const outDir = join(tmpdir(), "kilo-vscode-snapshots") +mkdirSync(outDir, { recursive: true }) + +console.log("\n๐Ÿ“ฆ Rebuilding SDK...") +await $`bun run --cwd ../sdk/js build`.cwd(root) + +console.log("\n๐Ÿ”ง Preparing CLI binary...") +await $`bun script/local-bin.ts`.cwd(root) + +console.log("\nโœ… Type-checking...") +await $`bun run check-types`.cwd(root) + +console.log("\n๐Ÿ” Linting...") +await $`bun run lint`.cwd(root) + +console.log("\n๐Ÿ—๏ธ Building extension...") +await $`node ${join(root, "esbuild.js")} --production`.cwd(root) + +console.log("\n๐Ÿ“ฆ Packaging VSIX...") +const vsixPath = join(outDir, `kilo-vscode-snapshot-${sha}.vsix`) +await $`bunx vsce package ${snapshotVersion} --no-update-package-json --no-dependencies --skip-license -o ${vsixPath}`.cwd( + root, +) + +console.log(`\nโœ… VSIX created: ${vsixPath}`) + +if (shouldInstall) { + const execPath = process.env.VSCODE_EXEC_PATH ?? "" + const cli = execPath.toLowerCase().includes("insiders") ? "code-insiders" : "code" + console.log(`\n๐Ÿš€ Installing to ${cli}...`) + await $`${cli} --force --install-extension ${vsixPath}` + + console.log(`\nโœจ Successfully installed snapshot extension!`) + console.log(` Version: ${snapshotVersion}`) +} else { + console.log(`\n๐Ÿ“ VSIX path: ${vsixPath}`) +}