Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/kilo-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1191,23 +1191,29 @@
},
"scripts": {
"prepare:cli-binary": "bun script/local-bin.ts",
"compile": "bun run prepare:cli-binary -- --force && bun run rebuild-sdk && bun run typecheck && bun run lint && node esbuild.js",
"prepare:sdk": "bun script/prepare-sdk.ts",
"build:launch": "bun run prepare:cli-binary && bun run prepare:sdk && bun run build:check:production",
"compile": "bun run prepare:cli-binary -- --force && bun run rebuild-sdk && bun run build:check",
"watch": "bun run rebuild-sdk && bun run --parallel watch:esbuild watch:tsc",
"watch:esbuild": "bun run prepare:cli-binary && node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"watch:cli": "bun script/watch-cli.ts",
"package": "bun run prepare:cli-binary && bun run rebuild-sdk && bun run typecheck && bun run lint && node esbuild.js --production",
"package": "bun run prepare:cli-binary && bun run rebuild-sdk && bun run build:check:production",
"build:check": "bun run --parallel check-types check-types:webview lint bundle",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Verify that bun run --parallel propagates a non-zero exit code when one of the parallel scripts fails

build:check, build:check:production, and typecheck are now the only gates for type and lint errors in this package (turbo typecheck in CI runs typecheck, and release validation runs package). Before this PR the && chain guaranteed that a tsc/eslint failure aborted the whole command. --parallel was previously only used for watch, where exit codes are irrelevant, so this is the first time correctness depends on it. If Bun aggregates only the last (or the first-finishing) script's status, type and lint errors will silently pass CI. Worth adding a one-off check (e.g. temporarily introduce a type error and confirm bun run typecheck exits non-zero).

Secondary point that holds regardless: with parallel execution bundle/bundle:production now writes dist/ even when check-types or lint fail, so a failed compile/package leaves behind a bundle that looks valid. script/launch.ts is safe because $ throws, but anything that inspects dist/ after a failed build (e.g. --mode vsix reruns, cached CI steps) can now pick up artifacts that never passed validation.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

"build:check:production": "bun run --parallel check-types check-types:webview lint bundle:production",
"bundle": "bun esbuild.js",
"bundle:production": "bun esbuild.js --production",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "bun run compile-tests && bun run compile && bun run lint",
"check-types": "tsc --noEmit",
"check-types:webview": "tsc --noEmit --project webview-ui/tsconfig.json",
"typecheck": "bun run check-types && bun run check-types:webview",
"check-types": "tsgo --noEmit",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: tsgo is invoked but @typescript/native-preview is not a dependency of this package

Every other package in the monorepo that runs tsgo declares @typescript/native-preview: "catalog:" (packages/opencode, packages/sdk/js, packages/server, packages/ui, ...). packages/kilo-vscode only declares typescript: ^5.9.3, so tsgo resolves purely through Bun's root node_modules/.bin hoisting. That works today but breaks on an isolated/package-local install or if the last root consumer of the catalog entry is removed, and the failure mode is a confusing command not found in the build gate. Suggest adding @typescript/native-preview: "catalog:" to this package's devDependencies.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

"check-types:webview": "tsgo --noEmit --project webview-ui/tsconfig.json",
"typecheck": "bun run --parallel check-types check-types:webview",
"format": "prettier --write .",
"format:check": "prettier --check .",
"knip": "knip",
"check-kilocode-change": "! grep -rIn 'kilocode_change' . ../kilo-ui/ --exclude='package.json' --exclude='*.md' --exclude-dir='node_modules' --exclude-dir='dist' | grep -v '`kilocode_change`'",
"lint": "eslint src webview-ui",
"lint": "eslint --cache --cache-strategy content --cache-location node_modules/.cache/eslint src webview-ui",
"test": "vscode-test",
"test:unit": "bun test tests/unit/ --dots",
"rebuild-sdk": "bun run --cwd ../sdk/js build",
Expand Down
2 changes: 1 addition & 1 deletion packages/kilo-vscode/script/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ async function compile() {
}

console.log("[launch] Building extension...")
await $`bun run package`.cwd(root).env(cleanEnv(process.env))
await $`bun run build:launch`.cwd(root).env(cleanEnv(process.env))
console.log("[launch] Build complete")
}

Expand Down
84 changes: 84 additions & 0 deletions packages/kilo-vscode/script/prepare-sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bun
import { $ } from "bun"
import { createHash } from "node:crypto"
import { existsSync, mkdirSync } from "node:fs"
import { dirname, join } from "node:path"

const root = join(import.meta.dir, "..")
const repo = join(root, "..", "..")
const sdk = join(repo, "packages", "sdk", "js")
const cache = join(root, "node_modules", ".cache", "sdk-build.json")
const inputs = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: The hand-maintained input allowlist omits packages that are in the OpenAPI generation module graph, so the cache can silently serve a stale SDK

packages/sdk/js/script/build.ts produces the spec via bun dev generate in packages/opencode, which imports src/server/server and transitively most of the CLI. That graph includes at least packages/uipackages/opencode/src/kilocode/provider/metadata.ts:1 imports @opencode-ai/ui/icons/provider, and provider metadata feeds the generated types. packages/http-recorder, packages/script, and packages/tui are also direct workspace dependencies of packages/opencode and are absent from this list.

Because a missed input produces a cache hit, the failure is silent: bun run extension links an SDK client that doesn't match the server routes, and the developer debugs a phantom API mismatch. The list will also drift every time a new workspace package is added upstream.

Suggest making this fail-safe rather than fail-open — e.g. fingerprint packages/ as a whole and exclude only the paths that provably cannot affect generation (kilo-vscode, kilo-docs, kilo-jetbrains), or derive the set from packages/opencode/package.json's workspace:* dependencies. The cache-hit path is already 0.14s, so a slightly wider git ls-tree/git diff is cheap compared to shipping a stale client.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

"package.json",
"bun.lock",
"packages/opencode",
"packages/core",
"packages/effect-drizzle-sqlite",
"packages/effect-sqlite-node",
"packages/kilo-gateway",
"packages/kilo-indexing",
"packages/kilo-memory",
"packages/kilo-sandbox",
"packages/kilo-telemetry",
"packages/llm",
"packages/plugin",
"packages/plugin-atomic-chat",
"packages/server",
"packages/util",
"packages/sdk/js/package.json",
"packages/sdk/js/tsconfig.json",
"packages/sdk/js/script",
"packages/kilo-vscode/script/prepare-sdk.ts",
]
const outputs = ["packages/sdk/js/src"]

function log(msg: string) {
console.log(`[prepare-sdk] ${msg}`)
}

async function fingerprint(paths: string[]) {
const [tree, diff, extra] = await Promise.all([
$`git ls-tree -r HEAD -- ${paths}`.cwd(repo).quiet(),
$`git diff --binary HEAD -- ${paths}`.cwd(repo).quiet(),
$`git ls-files --others --exclude-standard -z -- ${paths}`.cwd(repo).quiet(),
])
const hash = createHash("sha256").update(tree.text()).update(diff.text())
const files = extra.text().split("\0").filter(Boolean).sort()

for (const file of files) {
hash.update(file)
hash.update(new Uint8Array(await Bun.file(join(repo, file)).arrayBuffer()))
}

return hash.digest("hex")
}

async function load() {
const file = Bun.file(cache)
if (!(await file.exists())) return

try {
const value: unknown = await file.json()
if (!value || typeof value !== "object") return
const input = Reflect.get(value, "input")
const output = Reflect.get(value, "output")
if (typeof input === "string" && typeof output === "string") return { input, output }
} catch (err) {
log(`Ignoring invalid cache: ${err instanceof Error ? err.message : String(err)}`)
}
}

const input = await fingerprint(inputs)
const prior = await load()
const ready = existsSync(join(sdk, "dist", "index.js")) && existsSync(join(sdk, "dist", "v2", "index.js"))

if (prior?.input === input && prior.output === (await fingerprint(outputs)) && ready) {
log("SDK inputs and generated output are unchanged")
process.exit(0)
}

log("SDK inputs changed, rebuilding generated client")
await $`bun run build`.cwd(sdk)

mkdirSync(dirname(cache), { recursive: true })
await Bun.write(cache, JSON.stringify({ input, output: await fingerprint(outputs) }) + "\n")
3 changes: 3 additions & 0 deletions packages/kilo-vscode/webview-ui/src/assets.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ declare module "*.svg" {
export default src
}

declare module "*.css"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: These shorthand ambient declarations resolve to any and permanently silence resolution errors for the specifiers

declare module "*.css" with no body makes every .css specifier any, and declare module "@kilocode/kilo-ui/styles" shadows whatever that subpath export actually resolves to — if kilo-ui ever exports typed values from ./styles, the webview typecheck will keep seeing any instead of the real types, with no error to reveal it.

Since these are side-effect-only imports (import "@kilocode/kilo-ui/styles" in webview-ui/src/index.tsx), a narrower fix keeps the type surface intact: either set allowArbitraryExtensions: true in webview-ui/tsconfig.json, or give the declarations a body so the shape is explicit rather than any. Also worth noting the divergence this introduces — watch:tsc, compile-tests, and watch-tests still run tsc, so watch-mode diagnostics no longer match the tsgo build gate that required these declarations.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

declare module "@kilocode/kilo-ui/styles"

declare module "*?worker&url" {
const src: string
export default src
Expand Down
Loading