From 7dbe255376245f2de81bb350b1fb57c94f72a032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Catriel=20M=C3=BCller?= Date: Mon, 16 Mar 2026 15:21:16 -0300 Subject: [PATCH] fix: fix build and publish scripts --- packages/opencode/script/build.ts | 43 +++++++++++++++-- packages/opencode/script/publish.ts | 73 +++++++++++++++++------------ 2 files changed, 80 insertions(+), 36 deletions(-) diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index c73583130f1..6bde9ff754e 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -179,8 +179,8 @@ for (const item of targets) { autoloadTsconfig: true, autoloadPackageJson: true, target: name.replace(pkg.name, "bun") as any, - outfile: `dist/${name}/bin/opencode`, - execArgv: [`--user-agent=opencode/${Script.version}`, "--use-system-ca", "--"], + outfile: `dist/${name}/bin/kilo`, + execArgv: [`--user-agent=kilo/${Script.version}`, "--use-system-ca", "--"], windows: {}, }, entrypoints: ["./src/index.ts", parserWorker, workerPath], @@ -194,6 +194,27 @@ for (const item of targets) { }, }) + // kilocode_change start - fix Nix-specific ELF interpreter paths for Linux binaries + if (item.os === "linux") { + const interpreters: Record = { + x64: "/lib64/ld-linux-x86-64.so.2", + arm64: "/lib/ld-linux-aarch64.so.1", + "x64-musl": "/lib/ld-musl-x86_64.so.1", + "arm64-musl": "/lib/ld-musl-aarch64.so.1", + } + const key = item.abi === "musl" ? `${item.arch}-musl` : item.arch + const interpreter = interpreters[key] + if (interpreter) { + try { + await $`patchelf --set-interpreter ${interpreter} dist/${name}/bin/kilo` + console.log(`patched interpreter for ${name} -> ${interpreter}`) + } catch { + console.warn(`patchelf not available, skipping interpreter fix for ${name}`) + } + } + } + // kilocode_change end + await $`rm -rf ./dist/${name}/bin/tui` await Bun.file(`dist/${name}/package.json`).write( JSON.stringify( @@ -202,6 +223,12 @@ for (const item of targets) { version: Script.version, os: [item.os], cpu: [item.arch], + // kilocode_change start + repository: { + type: "git", + url: "https://github.com/Kilo-Org/kilocode", + }, + // kilocode_change end }, null, 2, @@ -211,14 +238,20 @@ for (const item of targets) { } if (Script.release) { + const archives: string[] = [] // kilocode_change for (const key of Object.keys(binaries)) { + const archive = key.replace(pkg.name, "kilo") // kilocode_change if (key.includes("linux")) { - await $`tar -czf ../../${key}.tar.gz *`.cwd(`dist/${key}/bin`) + const out = path.resolve("dist", `${archive}.tar.gz`) // kilocode_change + await $`tar -czf ${out} *`.cwd(`dist/${key}/bin`) // kilocode_change + archives.push(out) // kilocode_change } else { - await $`zip -r ../../${key}.zip *`.cwd(`dist/${key}/bin`) + const out = path.resolve("dist", `${archive}.zip`) // kilocode_change + await $`zip -r ${out} *`.cwd(`dist/${key}/bin`) // kilocode_change + archives.push(out) // kilocode_change } } - await $`gh release upload v${Script.version} ./dist/*.zip ./dist/*.tar.gz --clobber --repo ${process.env.GH_REPO}` + await $`gh release upload v${Script.version} ${archives} --clobber` // kilocode_change } export { binaries } diff --git a/packages/opencode/script/publish.ts b/packages/opencode/script/publish.ts index e12cf6e1058..1fdf3ab08de 100755 --- a/packages/opencode/script/publish.ts +++ b/packages/opencode/script/publish.ts @@ -8,7 +8,9 @@ const dir = fileURLToPath(new URL("..", import.meta.url)) process.chdir(dir) const binaries: Record = {} -for (const filepath of new Bun.Glob("*/package.json").scanSync({ cwd: "./dist" })) { +// kilocode_change start +for (const filepath of new Bun.Glob("*/*/package.json").scanSync({ cwd: "./dist" })) { + // kilocode_change end const pkg = await Bun.file(`./dist/${filepath}`).json() binaries[pkg.name] = pkg.version } @@ -19,13 +21,17 @@ await $`mkdir -p ./dist/${pkg.name}` await $`cp -r ./bin ./dist/${pkg.name}/bin` await $`cp ./script/postinstall.mjs ./dist/${pkg.name}/postinstall.mjs` await Bun.file(`./dist/${pkg.name}/LICENSE`).write(await Bun.file("../../LICENSE").text()) +await Bun.file(`./dist/${pkg.name}/README.md`).write(await Bun.file("./README.md").text()) // kilocode_change await Bun.file(`./dist/${pkg.name}/package.json`).write( JSON.stringify( { - name: pkg.name + "-ai", + name: pkg.name, // kilocode_change bin: { - [pkg.name]: `./bin/${pkg.name}`, + // kilocode_change start + kilo: `./bin/kilo`, + kilocode: `./bin/kilo`, + // kilocode_change end }, scripts: { postinstall: "bun ./postinstall.mjs || node ./postinstall.mjs", @@ -33,6 +39,12 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( version: version, license: pkg.license, optionalDependencies: binaries, + // kilocode_change start + repository: { + type: "git", + url: "https://github.com/Kilo-Org/kilocode", + }, + // kilocode_change end }, null, 2, @@ -47,9 +59,9 @@ const tasks = Object.entries(binaries).map(async ([name]) => { await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(`./dist/${name}`) }) await Promise.all(tasks) -await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${Script.channel}` +await $`npm publish *.tgz --access public --tag ${Script.channel} --provenance`.cwd(`./dist/${name}`) // kilocode_change -const image = "ghcr.io/Kilo-Org/kilocode" +const image = "ghcr.io/kilo-org/kilo" // kilocode_change const platforms = "linux/amd64,linux/arm64" const tags = [`${image}:${version}`, `${image}:${Script.channel}`] const tagFlags = tags.flatMap((t) => ["-t", t]) @@ -58,19 +70,18 @@ await $`docker buildx build --platform ${platforms} ${tagFlags} --push .` // registries if (!Script.preview) { // Calculate SHA values - const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim()) - const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim()) - const macX64Sha = await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) - const macArm64Sha = await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) + const arm64Sha = await $`sha256sum ./dist/kilo-linux-arm64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim()) + const x64Sha = await $`sha256sum ./dist/kilo-linux-x64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim()) + const macX64Sha = await $`sha256sum ./dist/kilo-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) + const macArm64Sha = await $`sha256sum ./dist/kilo-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) const [pkgver, _subver = ""] = Script.version.split(/(-.*)/, 2) // arch const binaryPkgbuild = [ - "# Maintainer: dax", - "# Maintainer: adam", + "# Maintainer: kilo", // kilocode_change "", - "pkgname='opencode-bin'", + "pkgname='kilo-bin'", `pkgver=${pkgver}`, `_subver=${_subver}`, "options=('!debug' '!strip')", @@ -79,23 +90,23 @@ if (!Script.preview) { "url='https://github.com/Kilo-Org/kilocode'", "arch=('aarch64' 'x86_64')", "license=('MIT')", - "provides=('opencode')", - "conflicts=('opencode')", + "provides=('kilo')", + "conflicts=('kilo')", "depends=('ripgrep')", "", - `source_aarch64=("\${pkgname}_\${pkgver}_aarch64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/opencode-linux-arm64.tar.gz")`, + `source_aarch64=("\${pkgname}_\${pkgver}_aarch64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/kilo-linux-arm64.tar.gz")`, `sha256sums_aarch64=('${arm64Sha}')`, - `source_x86_64=("\${pkgname}_\${pkgver}_x86_64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/opencode-linux-x64.tar.gz")`, + `source_x86_64=("\${pkgname}_\${pkgver}_x86_64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/kilo-linux-x64.tar.gz")`, `sha256sums_x86_64=('${x64Sha}')`, "", "package() {", - ' install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode"', + ' install -Dm755 ./kilo "${pkgdir}/usr/bin/kilo"', "}", "", ].join("\n") - for (const [pkg, pkgbuild] of [["opencode-bin", binaryPkgbuild]]) { + for (const [pkg, pkgbuild] of [["kilo-bin", binaryPkgbuild]]) { for (let i = 0; i < 30; i++) { try { await $`rm -rf ./dist/aur-${pkg}` @@ -119,45 +130,45 @@ if (!Script.preview) { "# frozen_string_literal: true", "", "# This file was generated by GoReleaser. DO NOT EDIT.", - "class Opencode < Formula", + "class Kilo < Formula", // kilocode_change ` desc "The AI coding agent built for the terminal."`, - ` homepage "https://github.com/Kilo-Org/kilocode"`, + ` homepage "https://kilo.ai"`, // kilocode_change ` version "${Script.version.split("-")[0]}"`, "", ` depends_on "ripgrep"`, "", " on_macos do", " if Hardware::CPU.intel?", - ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-darwin-x64.zip"`, + ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-darwin-x64.zip"`, ` sha256 "${macX64Sha}"`, "", " def install", - ' bin.install "opencode"', + ' bin.install "kilo"', " end", " end", " if Hardware::CPU.arm?", - ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-darwin-arm64.zip"`, + ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-darwin-arm64.zip"`, ` sha256 "${macArm64Sha}"`, "", " def install", - ' bin.install "opencode"', + ' bin.install "kilo"', " end", " end", " end", "", " on_linux do", " if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?", - ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-linux-x64.tar.gz"`, + ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-linux-x64.tar.gz"`, ` sha256 "${x64Sha}"`, " def install", - ' bin.install "opencode"', + ' bin.install "kilo"', " end", " end", " if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?", - ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-linux-arm64.tar.gz"`, + ` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-linux-arm64.tar.gz"`, ` sha256 "${arm64Sha}"`, " def install", - ' bin.install "opencode"', + ' bin.install "kilo"', " end", " end", " end", @@ -171,11 +182,11 @@ if (!Script.preview) { console.error("GITHUB_TOKEN is required to update homebrew tap") process.exit(1) } - const tap = `https://x-access-token:${token}@github.com/anomalyco/homebrew-tap.git` + const tap = `https://x-access-token:${token}@github.com/Kilo-Org/homebrew-tap.git` // kilocode_change await $`rm -rf ./dist/homebrew-tap` await $`git clone ${tap} ./dist/homebrew-tap` - await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula) - await $`cd ./dist/homebrew-tap && git add opencode.rb` + await Bun.file("./dist/homebrew-tap/kilo.rb").write(homebrewFormula) // kilocode_change + await $`cd ./dist/homebrew-tap && git add kilo.rb` // kilocode_change await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"` await $`cd ./dist/homebrew-tap && git push` }