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
5 changes: 5 additions & 0 deletions .changeset/restore-bun-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Restore reliable CLI terminal startup across release targets.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The Kilo Community is [on Discord](https://kilo.ai/discord).

## Prerequisites

- **Bun 1.4.0+** — required for all packages.
- **Bun 1.3.14+** — required for all packages.
- **Java 21** — required by the JetBrains plugin. The root `bun turbo typecheck` and `bun turbo test:ci` commands include `@kilocode/kilo-jetbrains` and will fail without Java 21.

The preferred way to install Java is via [SDKMAN](https://sdkman.io/install):
Expand All @@ -41,7 +41,7 @@ The Kilo Community is [on Discord](https://kilo.ai/discord).

## Developing Kilo CLI

- **Requirements:** Bun 1.4.0+, Java 21 (see [Prerequisites](#prerequisites) above)
- **Requirements:** Bun 1.3.14+, Java 21 (see [Prerequisites](#prerequisites) above)
- Install dependencies and start the CLI from the repo root:

```bash
Expand Down
6 changes: 3 additions & 3 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bunfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
exact = true
# Keep Kilo's longer supply-chain quarantine while allowing packages that must track coordinated releases.
minimumReleaseAge = 410520 # seconds (~4.75 days / ~114 hours)
minimumReleaseAgeExcludes = ["mermaid", "@mermaid-js/parser", "@ai-sdk/amazon-bedrock", "@ai-sdk/anthropic", "@opentui/core", "@opentui/core-darwin-arm64", "@opentui/core-darwin-x64", "@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@opentui/core-win32-arm64", "@opentui/core-win32-x64", "@opentui/keymap", "@opentui/solid", "opentui-spinner", "gitlab-ai-provider", "opencode-gitlab-auth", "@ff-labs/fff-node", "@ff-labs/fff-bun", "@ff-labs/fff-bin-darwin-arm64", "@ff-labs/fff-bin-darwin-x64", "@ff-labs/fff-bin-linux-arm64-gnu", "@ff-labs/fff-bin-linux-arm64-musl", "@ff-labs/fff-bin-linux-x64-gnu", "@ff-labs/fff-bin-linux-x64-musl", "@ff-labs/fff-bin-win32-arm64", "@ff-labs/fff-bin-win32-x64", "@pierre/diffs", "@pierre/theming", "app-builder-lib", "dmg-builder", "electron-builder", "electron-publish", "@types/bun", "bun-types"] # kilocode_change
minimumReleaseAgeExcludes = ["mermaid", "@mermaid-js/parser", "@ai-sdk/amazon-bedrock", "@ai-sdk/anthropic", "@opentui/core", "@opentui/core-darwin-arm64", "@opentui/core-darwin-x64", "@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@opentui/core-win32-arm64", "@opentui/core-win32-x64", "@opentui/keymap", "@opentui/solid", "opentui-spinner", "gitlab-ai-provider", "opencode-gitlab-auth", "@ff-labs/fff-node", "@ff-labs/fff-bun", "@ff-labs/fff-bin-darwin-arm64", "@ff-labs/fff-bin-darwin-x64", "@ff-labs/fff-bin-linux-arm64-gnu", "@ff-labs/fff-bin-linux-arm64-musl", "@ff-labs/fff-bin-linux-x64-gnu", "@ff-labs/fff-bin-linux-x64-musl", "@ff-labs/fff-bin-win32-arm64", "@ff-labs/fff-bin-win32-x64", "@pierre/diffs", "@pierre/theming", "app-builder-lib", "dmg-builder", "electron-builder", "electron-publish"]

[test]
root = "./do-not-run-tests-from-root"
8 changes: 4 additions & 4 deletions nix/bun.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ let
sources = {
"aarch64-linux" = {
name = "bun-linux-aarch64";
hash = "sha256-SxozLuhhmD65O8/m93D/+U4+MbLDiL2uo8jtNeWO7Q4=";
hash = "sha256-on/7Y6gxA3WDbg1vZorhf6jY0YuIw3yCHGUzGXOhmjs=";
};
"x86_64-linux" = {
name = "bun-linux-x64";
hash = "sha256-LQP7X7g6yLVnrKCigbLOGhoZ1Ij1bClo2Iw/Jekv5FI=";
hash = "sha256-lR7iruhV8IWVruxiJSJqKY0/6oOj3NZGXAnLzN9+hI8=";
};
"aarch64-darwin" = {
name = "bun-darwin-aarch64";
hash = "sha256-xmnpf2Fk4cluBwF0jbmN+ndJKQjL2DlMdVcTSnNd44E=";
hash = "sha256-2LliIYKK1vl6x6wKt+lYcjQa92MAHogD6CZ2UsJlJiA=";
};
"x86_64-darwin" = {
name = "bun-darwin-x64";
hash = "sha256-HQIRuPHcmRGCNEaHrRXnLuhvFUhFpff6R3mUzTQd2bA=";
hash = "sha256-QYPfM3RiPlurMVxUfPoJdFM81FfYa3O2OfeoeXTNZjM=";
};
};
source =
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "AI-powered development tool",
"private": true,
"type": "module",
"packageManager": "bun@1.4.0",
"packageManager": "bun@1.3.14",
"scripts": {
"dev": "KILO_CLIENT=cli bun run --cwd packages/opencode --conditions=node src/index.ts",
"dev:stats": "bun sst shell --stage=production -- bun run --cwd packages/stats/app dev",
Expand Down Expand Up @@ -35,7 +35,7 @@
"@effect/platform-node": "4.0.0-beta.83",
"@anthropic-ai/sandbox-runtime": "0.0.63",
"@npmcli/arborist": "9.4.0",
"@types/bun": "1.4.0",
"@types/bun": "1.3.14",
"@types/cross-spawn": "6.0.6",
"@octokit/rest": "22.0.0",
"@opentui/core": "0.4.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/containers/bun-node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM ${REGISTRY}/build/base:24.04
SHELL ["/bin/bash", "-lc"]

ARG NODE_VERSION=24.4.0
ARG BUN_VERSION=1.4.0
ARG BUN_VERSION=1.3.14

ENV BUN_INSTALL=/opt/bun
ENV PATH=/opt/bun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Expand Down
68 changes: 2 additions & 66 deletions packages/core/src/kilocode/pty/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,6 @@ import { KiloPtyTermination } from "./termination"
import { spawn } from "#pty"

const TIMEOUT = 15_000
const RENDER_TIMEOUT = 60_000

export function marker(output: string) {
const text = output
.replace(/\x1b\](?:[^\x07\x1b]|\x1b(?!\\))*(?:\x07|\x1b\\)/g, "")
.replace(/\x1b[P^_](?:[^\x1b]|\x1b(?!\\))*\x1b\\/g, "")
.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "")
.replace(/\x1b[@-_]/g, "")
return text.split(/\r?\n/).some((line) => line.trim() === "KILO_PTY_READY")
}

async function render() {
const proc = spawn(process.execPath, ["--pure"], {
name: "xterm-256color",
cwd: process.cwd(),
env: {
...process.env,
TERM: "xterm-256color",
KILO_TERMINAL: "1",
KILO_NO_DAEMON: "1",
KILO_DISABLE_AUTOUPDATE: "1",
KILO_DISABLE_MODELS_FETCH: "1",
KILO_DISABLE_PROJECT_CONFIG: "1",
KILO_DISABLE_DEFAULT_PLUGINS: "1",
KILO_DISABLE_TERMINAL_TITLE: "0",
KILO_CONFIG_CONTENT: "{}",
KILO_AUTH_CONTENT: "{}",
} as Record<string, string>,
cols: 100,
rows: 40,
})
const state = { output: "", exited: false }
const ready = Promise.withResolvers<void>()
const data = proc.onData((chunk) => {
state.output = (state.output + chunk).slice(-20_000)
if (state.output.includes("Ask anything...")) ready.resolve()
})
const exit = proc.onExit((event) => {
state.exited = true
ready.reject(new Error(`TUI exited before rendering (code ${event.exitCode}): ${JSON.stringify(state.output)}`))
})
const timeout = AbortSignal.timeout(RENDER_TIMEOUT)

try {
await Promise.race([
ready.promise,
new Promise<never>((_, reject) =>
timeout.addEventListener(
"abort",
() =>
reject(
new Error(`TUI produced no rendered frame within ${RENDER_TIMEOUT}ms: ${JSON.stringify(state.output)}`),
),
{ once: true },
),
),
])
} finally {
data.dispose()
exit.dispose()
if (!state.exited) await KiloPtyTermination.terminate(proc)
}
}

export async function smoke() {
const proc = spawn(Shell.preferred(), [], {
Expand All @@ -80,7 +17,8 @@ export async function smoke() {
const exited = Promise.withResolvers<number>()
const data = proc.onData((chunk) => {
state.output += chunk
if (marker(state.output)) output.resolve()
const lines = state.output.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").split(/\r?\n/)
if (lines.some((line) => line.trim() === "KILO_PTY_READY")) output.resolve()
})
const exit = proc.onExit((event) => {
state.exited = true
Expand Down Expand Up @@ -129,8 +67,6 @@ export async function smoke() {
} finally {
if (!stopped) active.kill()
}

await render()
}

export * as PtySmoke from "./smoke"
8 changes: 1 addition & 7 deletions packages/core/test/kilocode/pty-durability.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,7 @@ describe("durable PTY registry", () => {
const info = yield* Effect.scoped(
Effect.gen(function* () {
const pty = yield* Pty.Service
return yield* pty.create({ command: "/bin/sh", cwd: dir.path })
}).pipe(Effect.provide(locations.get(target))),
)
yield* Effect.scoped(
Effect.gen(function* () {
const pty = yield* Pty.Service
yield* pty.write(info.id, "exit 7\r")
return yield* pty.create({ command: "/bin/sh", args: ["-c", "exit 7"], cwd: dir.path })
}).pipe(Effect.provide(locations.get(target))),
)
const exited = yield* Queue.take(queue).pipe(Effect.timeout("5 seconds"))
Expand Down
21 changes: 0 additions & 21 deletions packages/core/test/kilocode/pty-smoke.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This document will help you set up your development environment and understand h
Before you begin, make sure you have the following installed:

1. **Git** - For version control
2. **Bun 1.4.0+** - Required for installing dependencies and running scripts
2. **Bun 1.3.14+** - Required for installing dependencies and running scripts
3. **Visual Studio Code** - Our recommended IDE for development
4. **Java 21** - Required only when running JetBrains plugin checks or repo-level checks that include `@kilocode/kilo-jetbrains`

Expand Down
2 changes: 1 addition & 1 deletion packages/kilo-vscode/docs/mercury-next-edit-testing.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ <h3>Prerequisites</h3>
<ul>
<li><strong>VSCode</strong> ≥ 1.105.1 (matches kilocode's <code>engines.vscode</code>)</li>
<li>
<strong>Bun</strong> ≥ 1.4.0 (the build script checks the version) &mdash; install via
<strong>Bun</strong> ≥ 1.3.14 (the build script checks the version) &mdash; install via
<code>brew install bun</code> or <a href="https://bun.sh">bun.sh</a>
</li>
<li><strong>GitHub CLI</strong> (<code>gh</code>) &mdash; optional but makes the PR checkout one command</li>
Expand Down
12 changes: 7 additions & 5 deletions packages/opencode/script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { stageBubblewrap } from "./kilocode/bubblewrap"
import { LanceDBRuntime } from "../src/kilocode/lancedb"
import { KiloSandboxWorker } from "./kilocode/kilo-sandbox-worker"
import { KiloSandboxNetwork } from "./kilocode/kilo-sandbox-network"
import { KiloCliSmoke } from "./kilocode/cli-smoke"
// kilocode_change end

const singleFlag = process.argv.includes("--single")
Expand Down Expand Up @@ -313,7 +312,13 @@ for (const item of targets) {
// kilocode_change end
format: "esm",
minify: true,
// kilocode_change start - keep the compiled OpenTUI/Solid graph in one chunk to avoid blank startup frames.
// kilocode_change start - disable code-splitting to avoid a Bun 1.3.14 codegen bug.
// With splitting:true Bun emits cross-chunk re-exports like `import{vn as G9}` whose
// binding isn't top-level, so the compiled binary crashes at startup on the baseline
// target: "SyntaxError: Exported binding 'G9' needs to refer to a top-level declared
// variable." (Bun oven-sh/bun#25621, #5344, #7265; also opencode#23349). Fixed upstream
// in Bun#26089, post-1.3.14. Splitting only deduped shared code between the entrypoints;
// turning it off inlines per entrypoint and produces a valid binary.
splitting: false,
// kilocode_change end
compile: {
Expand Down Expand Up @@ -396,9 +401,6 @@ for (const item of targets) {
console.log("Models snapshot smoke test passed")
await KiloSandboxWorker.smoke(binaryPath)
console.log("Kilo sandbox mutation worker smoke test passed")
console.log(`Running smoke test: ${binaryPath} --pure __pty-smoke`)
await KiloCliSmoke.pty(binaryPath)
console.log("Packaged TUI smoke test passed")
// kilocode_change end
// kilocode_change start
} catch (e) {
Expand Down
40 changes: 0 additions & 40 deletions packages/opencode/script/kilocode/cli-smoke.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/opencode/src/bun-compat.d.ts

This file was deleted.

Loading
Loading