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/update-bun-1-4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Build the CLI with Bun 1.4 to reduce compiled binary size and build time.
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.3.14+** — required for all packages.
- **Bun 1.4.0+** — 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.3.14+, Java 21 (see [Prerequisites](#prerequisites) above)
- **Requirements:** Bun 1.4.0+, 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"]
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

[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-on/7Y6gxA3WDbg1vZorhf6jY0YuIw3yCHGUzGXOhmjs=";
hash = "sha256-SxozLuhhmD65O8/m93D/+U4+MbLDiL2uo8jtNeWO7Q4=";
};
"x86_64-linux" = {
name = "bun-linux-x64";
hash = "sha256-lR7iruhV8IWVruxiJSJqKY0/6oOj3NZGXAnLzN9+hI8=";
hash = "sha256-LQP7X7g6yLVnrKCigbLOGhoZ1Ij1bClo2Iw/Jekv5FI=";
};
"aarch64-darwin" = {
name = "bun-darwin-aarch64";
hash = "sha256-2LliIYKK1vl6x6wKt+lYcjQa92MAHogD6CZ2UsJlJiA=";
hash = "sha256-xmnpf2Fk4cluBwF0jbmN+ndJKQjL2DlMdVcTSnNd44E=";
};
"x86_64-darwin" = {
name = "bun-darwin-x64";
hash = "sha256-QYPfM3RiPlurMVxUfPoJdFM81FfYa3O2OfeoeXTNZjM=";
hash = "sha256-HQIRuPHcmRGCNEaHrRXnLuhvFUhFpff6R3mUzTQd2bA=";
};
};
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.3.14",
"packageManager": "bun@1.4.0",
"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.3.14",
"@types/bun": "1.4.0",
"@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.3.14
ARG BUN_VERSION=1.4.0

ENV BUN_INSTALL=/opt/bun
ENV PATH=/opt/bun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/aisdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function wrapSSE(res: Response, ms: number, ctl: AbortController) {
const id = setTimeout(() => {
const err = new Error("SSE read timed out")
ctl.abort(err)
void reader.cancel(err)
void reader.cancel(err).catch(() => undefined) // kilocode_change - handle Bun 1.4 cancellation rejection
reject(err)
}, ms)

Expand Down
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.3.14+** - Required for installing dependencies and running scripts
2. **Bun 1.4.0+** - 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.3.14 (the build script checks the version) &mdash; install via
<strong>Bun</strong> ≥ 1.4.0 (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
11 changes: 2 additions & 9 deletions packages/opencode/script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,8 @@ for (const item of targets) {
// kilocode_change end
format: "esm",
minify: true,
// 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
// Bun 1.4 fixes the cross-chunk re-export codegen bug from Bun 1.3.14.
splitting: true, // kilocode_change
compile: {
autoloadBunfig: false,
autoloadDotenv: false,
Expand Down
12 changes: 12 additions & 0 deletions packages/opencode/src/bun-compat.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// kilocode_change - new file
// Bun 1.4 narrows NodeJS.Process event overloads.
declare global {
namespace NodeJS {
interface Process {
on(event: string | symbol, listener: (...args: never[]) => void): this
off(event: string | symbol, listener: (...args: never[]) => void): this
}
}
}

export {}
2 changes: 1 addition & 1 deletion packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function wrapSSE(res: Response, ms: number, ctl: AbortController) {
const id = setTimeout(() => {
const err = new ProviderError.ResponseStreamError("SSE read timed out")
ctl.abort(err)
void reader.cancel(err)
void reader.cancel(err).catch(() => undefined) // kilocode_change - handle Bun 1.4 cancellation rejection
Comment thread
marius-kilocode marked this conversation as resolved.
reject(err)
}, ms)

Expand Down
106 changes: 106 additions & 0 deletions patches/@ff-labs%2Ffff-bun@0.9.4.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,109 @@ index 3454256..6dca25a 100644

if (existsSync(binaryPath)) {
return binaryPath;
diff --git a/src/ffi.ts b/src/ffi.ts
--- a/src/ffi.ts
+++ b/src/ffi.ts
@@ -328,6 +328,10 @@
return new TextEncoder().encode(`${s}\0`);
}
-
+
+function asResult(value: Pointer | bigint | null): Pointer | null {
+ return value as unknown as Pointer | null;
+}
+
/**
* Convert snake_case keys to camelCase recursively
*/
@@ -1121,4 +1126,4 @@
minComboCount,
);
- return parseSearchResult(resultPtr);
+ return parseSearchResult(asResult(resultPtr));
}
@@ -1145,4 +1150,4 @@
pageSize,
);
- return parseSearchResult(resultPtr);
+ return parseSearchResult(asResult(resultPtr));
}
@@ -1168,4 +1173,4 @@
pageSize,
);
- return parseDirSearchResult(resultPtr);
+ return parseDirSearchResult(asResult(resultPtr));
}
@@ -1195,4 +1200,4 @@
minComboCount,
);
- return parseMixedSearchResult(resultPtr);
+ return parseMixedSearchResult(asResult(resultPtr));
}
@@ -1230,4 +1235,4 @@
classifyDefinitions,
);
- return parseGrepResult(resultPtr);
+ return parseGrepResult(asResult(resultPtr));
}
@@ -1265,4 +1270,4 @@
classifyDefinitions,
);
- return parseGrepResult(resultPtr);
+ return parseGrepResult(asResult(resultPtr));
}
@@ -1274,4 +1279,4 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_scan_files(handle);
- return parseVoidResult(resultPtr);
+ return parseVoidResult(asResult(resultPtr));
}
@@ -1291,4 +1296,4 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_get_base_path(handle);
- return parseStringResult(resultPtr);
+ return parseStringResult(asResult(resultPtr));
}
@@ -1336,4 +1341,4 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_wait_for_scan(handle, BigInt(timeoutMs));
- return parseBoolResult(resultPtr);
+ return parseBoolResult(asResult(resultPtr));
}
@@ -1351,4 +1356,4 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_restart_index(handle, ptr(encodeString(newPath)));
- return parseVoidResult(resultPtr);
+ return parseVoidResult(asResult(resultPtr));
}
@@ -1360,4 +1365,4 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_refresh_git_status(handle);
- return parseIntResult(resultPtr);
+ return parseIntResult(asResult(resultPtr));
}
@@ -1377,4 +1382,4 @@
ptr(encodeString(filePath)),
);
- return parseBoolResult(resultPtr);
+ return parseBoolResult(asResult(resultPtr));
}
@@ -1392,4 +1397,4 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_get_historical_query(handle, BigInt(offset));
- return parseStringResult(resultPtr);
+ return parseStringResult(asResult(resultPtr));
}
@@ -1306,3 +1311,3 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_get_scan_progress(handle);
- const envelope = readResultEnvelope(resultPtr);
+ const envelope = readResultEnvelope(asResult(resultPtr));
@@ -1406,6 +1411,6 @@
const library = loadLibrary();
const resultPtr = library.symbols.fff_health_check(
handle ?? (0 as unknown as Pointer),
ptr(encodeString(testPath)),
);
- return parseJsonResult<unknown>(resultPtr);
+ return parseJsonResult<unknown>(asResult(resultPtr));
2 changes: 1 addition & 1 deletion script/upstream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ts-morph": "^24.0.0"
},
"devDependencies": {
"@types/bun": "1.3.14"
"@types/bun": "1.4.0"
},
"peerDependencies": {}
}
Loading