Skip to content

fix(cli): isolate release target builds - #10935

Merged
lambertjosh merged 4 commits into
mainfrom
fix/cli-release-build-state
Jun 5, 2026
Merged

fix(cli): isolate release target builds#10935
lambertjosh merged 4 commits into
mainfrom
fix/cli-release-build-state

Conversation

@lambertjosh

@lambertjosh lambertjosh commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Build each CLI release target in a fresh Bun subprocess while preserving minification and code splitting.
  • Keep the parent build responsible for dependency installation, output cleanup, Kilo Console generation, archive creation, and release upload.
  • Gate publishing on executing the exact packaged macOS arm64, Linux x64, and Linux arm64 CLI artifacts on native runners.

Root cause

Incorrect root cause, we will unwind the split build changes but keep the kilo CLI arch --version tests which are valuable.

@lambertjosh
lambertjosh marked this pull request as ready for review June 5, 2026 02:59
return true
})
: allTargets
if (isolated) targets.splice(0, targets.length, allTargets[selection]!) // kilocode_change - select one target in child

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: targets is a direct reference to allTargets when singleFlag is false (line 223: : allTargets), so targets.splice(...) mutates allTargets itself. This doesn't cause a bug today — the child process exits after one build and never reaches allTargets.indexOf(item) — but it's fragile. Consider using a fresh array to avoid the alias:

if (isolated) targets.splice(0, targets.length, allTargets[selection]!)

Could be rewritten as:

const targets = isolated
  ? [allTargets[selection]!]
  : singleFlag
    ? allTargets.filter(...)
    : allTargets

or simply targets.length = 0; targets.push(allTargets[selection]!) if keeping the current structure.


// kilocode_change start - isolate Bun's shared-chunk state between cross-platform targets
if (!isolated && targets.length > 1) {
await $`${process.execPath} run script/build.ts --target=${allTargets.indexOf(item)} --skip-install`

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: The child subprocess only receives --skip-install. Other flags like --sourcemaps and --baseline are not forwarded. For release builds this is intentional (sourcemaps are disabled via Script.release), but if someone invokes build.ts --sourcemaps on a multi-target build (non---single), the child processes will silently ignore it.

Consider forwarding extra flags explicitly or documenting that multi-target builds don't support --sourcemaps:

const extraFlags = sourcemapsFlag ? ["--sourcemaps"] : []
await $`${process.execPath} run script/build.ts --target=${allTargets.indexOf(item)} --skip-install ${extraFlags}`

path: packages/kilo-vscode/out

# kilocode_change start - execute the cross-compiled Apple Silicon binary before publishing it
validate-darwin-arm64:

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: The validate-darwin-arm64 job (and validate-linux below) is missing if: github.repository == 'Kilo-Org/kilocode' that every other job in this file has (version, build-cli, build-vscode, smoke-test, publish). In practice it doesn't matter since this workflow is only triggered from the main repo, but it breaks the established pattern and could cause confusion in forks.

@kilo-code-bot

kilo-code-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 3 Issues Found | Recommendation: Minor suggestions only — safe to merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/script/build.ts 224 targets.splice(...) mutates allTargets (aliased reference when singleFlag=false). Safe today since the child exits immediately, but fragile.
packages/opencode/script/build.ts 250 --sourcemaps and --baseline flags not forwarded to child subprocesses. Silently ignored on multi-target builds — fine for releases, unexpected otherwise.
.github/workflows/publish.yml 165 validate-darwin-arm64 and validate-linux jobs are missing if: github.repository == 'Kilo-Org/kilocode' guards that all other jobs in this file have.
Files Reviewed (3 files)
  • .changeset/fix-darwin-cli-startup.md — no issues
  • .github/workflows/publish.yml — 1 issue
  • packages/opencode/script/build.ts — 2 issues

The core fix is well-reasoned. The root cause analysis in the PR description is solid — process-level state isolation in Bun's bundler is the right approach. The validation gates in CI close a real gap that allowed broken cross-compiled artifacts to ship.

Fix these issues in Kilo Cloud


Reviewed by claude-4.6-sonnet-20260217 · 1,165,457 tokens

Review guidance: REVIEW.md from base branch main

@lambertjosh
lambertjosh enabled auto-merge June 5, 2026 03:09
@lambertjosh
lambertjosh merged commit 62ff916 into main Jun 5, 2026
20 checks passed
@lambertjosh
lambertjosh deleted the fix/cli-release-build-state branch June 5, 2026 03:15
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…-state

fix(cli): isolate release target builds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants