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.
This commit is contained in:
Mark IJbema
2026-02-12 16:53:21 +01:00
parent 9f4af30778
commit 7c7c679b41
2 changed files with 18 additions and 4 deletions
+2 -1
View File
@@ -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",
@@ -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.`)
}