From 7c7c679b417bf56ef120b350af0bcb06a4514a77 Mon Sep 17 00:00:00 2001 From: Mark IJbema Date: Thu, 12 Feb 2026 16:53:21 +0100 Subject: [PATCH] feat(kilo-vscode): add pnpm update-backend command Adds --force flag to prepare-cli-binary.mjs and a new 'update-backend' pnpm script that rebuilds the CLI binary even when it already exists. --- packages/kilo-vscode/package.json | 3 ++- .../scripts/prepare-cli-binary.mjs | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/kilo-vscode/package.json b/packages/kilo-vscode/package.json index 9228d1721fc..df4c9738572 100644 --- a/packages/kilo-vscode/package.json +++ b/packages/kilo-vscode/package.json @@ -262,7 +262,8 @@ "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint src", - "test": "vscode-test" + "test": "vscode-test", + "update-backend": "node scripts/prepare-cli-binary.mjs --force" }, "devDependencies": { "@types/diff": "^6.0.0", diff --git a/packages/kilo-vscode/scripts/prepare-cli-binary.mjs b/packages/kilo-vscode/scripts/prepare-cli-binary.mjs index 70bd01e21cb..d594875cd99 100644 --- a/packages/kilo-vscode/scripts/prepare-cli-binary.mjs +++ b/packages/kilo-vscode/scripts/prepare-cli-binary.mjs @@ -1,8 +1,10 @@ -import { existsSync, mkdirSync, readdirSync, statSync, copyFileSync, chmodSync } from "node:fs" +import { existsSync, mkdirSync, readdirSync, statSync, copyFileSync, chmodSync, rmSync } from "node:fs" import path from "node:path" import { fileURLToPath } from "node:url" import { execSync } from "node:child_process" +const forceRebuild = process.argv.includes("--force") + /** * Ensures the VS Code extension has a CLI binary at `packages/kilo-vscode/bin/kilo`. * @@ -103,14 +105,25 @@ function ensureBuiltBinary() { } function main() { - if (existsSync(targetBinPath)) { + if (existsSync(targetBinPath) && !forceRebuild) { const st = statSync(targetBinPath) log( - `CLI binary already present at ${path.relative(kiloVscodeDir, targetBinPath)} (${Math.round(st.size / 1024 / 1024)}MB).`, + `CLI binary already present at ${path.relative(kiloVscodeDir, targetBinPath)} (${Math.round(st.size / 1024 / 1024)}MB). Use --force to rebuild.`, ) return } + if (existsSync(targetBinPath) && forceRebuild) { + log(`Removing existing binary (--force).`) + rmSync(targetBinPath) + // Also remove the prebuilt dist so ensureBuiltBinary() triggers a fresh build + const distDir = path.resolve(opencodeDir, "dist") + if (existsSync(distDir)) { + rmSync(distDir, { recursive: true }) + log(`Removed ${path.relative(kiloVscodeDir, distDir)} to force rebuild.`) + } + } + if (!existsSync(opencodeDir)) { throw new Error(`Expected opencode package at ${opencodeDir}, but it does not exist.`) }