Skip to content

fix(lockfile): regenerate bun.lock and guard workspace version drift - #14625

Open
maphew wants to merge 21 commits into
Kilo-Org:mainfrom
maphew:kilo/cool-dew-jf0
Open

maphew wants to merge 21 commits into
Kilo-Org:mainfrom
maphew:kilo/cool-dew-jf0

Conversation

@maphew

@maphew maphew commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14616.

Summary

recorded a stale version for the workspace package (7.7.9 on disk vs 7.8.1 in ). bun install v1.3.14 (0d9b296a)
HUSKY=0 skip install
Checked 2052 installs across 2274 packages (no changes) [467.00ms] validates external deps but not workspace fields, so the drift was invisible to CI and every local bun install v1.3.14 (0d9b296a)
HUSKY=0 skip install
Checked 2052 installs across 2274 packages (no changes) [260.00ms] left a dirty tree.

  • Regenerate so the workspace entry matches .
  • Add , which runs bun install v1.3.14 (0d9b296a)

Saved bun.lock (2274 packages) [312.00ms], diffs the result against the committed lockfile, and fails on any difference. The committed lockfile is always restored so the working tree stays clean.

  • Wire it into so it runs on every install path in CI.

Verification

  • passes on the clean tree and leaves unchanged.
  • Simulated drift (lockfile entry set to 7.7.9) is detected, exits non-zero, and restores the committed lockfile.

Adversarial review

  • Replaced the initial JSONC-regex parser with a regenerate-and-diff approach to avoid corrupting string values that literally contain or .
  • The check runs after every , including Windows; it does not depend on the node-gyp step and only needs Bun is a fast JavaScript runtime, package manager, bundler, and test runner. (1.3.14+0d9b296af)

Usage: bun [...flags] [...args]

Commands:
run ./my-script.ts Execute a file with Bun
lint Run a package.json script
test Run unit tests with Bun
x eslint Execute a package binary (CLI), installing if needed (bunx)
repl Start a REPL session with Bun
exec Run a shell script directly with Bun

install Install dependencies for a package.json (bun i)
add @zarfjs/zarf Add a dependency to package.json (bun a)
remove babel-core Remove a dependency from package.json (bun rm)
update zod Update outdated dependencies
audit Check installed packages for vulnerabilities
outdated Display latest versions of outdated dependencies
link [] Register or link a local npm package
unlink Unregister a local npm package
publish Publish a package to the npm registry
patch Prepare a package for patching
pm Additional package management utilities
info tailwindcss Display package metadata from the registry
why elysia Explain why a package is installed

build ./a.ts ./b.jsx Bundle TypeScript & JavaScript into a single file

init Start an empty Bun project from a built-in template
create next-app Create a new project from a template (bun c)
upgrade Upgrade to latest version of Bun.
feedback ./file1 ./file2 Provide feedback to the Bun team.

--help Print help text for command.

Learn more about Bun: https://bun.com/docs
Join our Discord community: https://bun.com/discord on PATH.

  • Consider scoping the check to PRs only rather than every job that uses setup-bun.

@maphew
maphew marked this pull request as ready for review September 28, 2026 04:38
console.error("Failed to run lockfile check:", err)
process.exit(1)
} finally {
// Always restore the committed lockfile so the working tree stays clean.

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: process.exit(1) skips the finally block

process.exit() terminates the process synchronously without unwinding the stack, so Node/Bun do not run finally blocks on exit. On the drift path (line 39) and the error path (line 43), the finally that restores the committed lockfile therefore never runs, leaving a regenerated bun.lock on disk. That contradicts the "always restore the committed lockfile" guarantee in the comment above and the PR's verification note that the working tree stays clean. Consider recording a failure flag and letting the finally run before calling process.exit.


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

"@kilocode/kilo-jetbrains": patch
---

Regenerate bun.lock so the workspace entry for @kilocode/kilo-jetbrains matches package.json, and add a CI guard that fails when workspace package versions drift from bun.lock. No newline at end of file

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: Changeset reads as implementation notes

Changeset descriptions appear directly in release notes for end users, but this one describes the mechanics ("Regenerate bun.lock ... add a CI guard ..."). Consider a user-facing phrasing focused on the effect, for example: "Keep the JetBrains plugin building against the correct CLI version by keeping the lockfile workspace version in sync." If this change is purely internal tooling with no user-visible behavior, a changeset may not be needed at all.


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

@kilo-code-bot

kilo-code-bot Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The previous findings are resolved on 1a9892ec: the lockfile guard now skips when install: false, bun.lock:366 records 7.8.15 matching packages/kilo-jetbrains/package.json:11 (and the other workspace entries checked), and pushLock now reads the blob to a temp file via gh api --output before base64-encoding, so the byte-for-byte comparison in the guard is not affected by shell trailing-newline normalization.

Files Reviewed (5 files)
  • .changeset/fix-bun-lock-workspace-version.md - 0 issues
  • .github/actions/setup-bun/action.yml - 0 issues
  • .kilo/skills/release-jetbrains/script/set-pin.ts - 0 issues
  • bun.lock - 0 issues
  • script/check-bun-lock-workspace.ts - 0 issues
Previous Review Summaries (7 snapshots, latest commit 18bb6c6)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 18bb6c6)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1

The earlier blocking issues are resolved: bun.lock:366 now records 7.8.15, matching packages/kilo-jetbrains/package.json:11, so the new guard has a consistent baseline; script/check-bun-lock-workspace.ts now uses process.exitCode so the finally restore actually runs; and pushLock now reads with the raw media type and anchors on the workspace entry instead of origin/main's version, so an already-stale lockfile heals.

Issue Details (click to expand)

WARNING

File Line Issue
.kilo/skills/release-jetbrains/script/set-pin.ts 134 The lockfile is read through gh api stdout and Bun's $...text() and written back as base64. Neither step is byte-faithful for trailing newlines, and the new guard compares the committed lockfile byte-for-byte against regeneration — a one-byte difference still fails the pin-bump PR and, downstream, the JetBrains release jobs that also call setup-bun. Read the blob to a file (gh api ... --output <path>) and encode that instead.

SUGGESTION

File Line Issue
.github/actions/setup-bun/action.yml 105 The new guard step ignores the install input that gates every other dependency step. The twelve workflows passing install: false now run bun install --lockfile-only on every event, including issue-triggered automations. Consider gating it the same way or moving it to a dedicated job.
Files Reviewed (5 files)
  • .changeset/fix-bun-lock-workspace-version.md - 0 issues
  • .github/actions/setup-bun/action.yml - 1 issue
  • .kilo/skills/release-jetbrains/script/set-pin.ts - 1 issue
  • bun.lock - 0 issues
  • script/check-bun-lock-workspace.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 21d755b)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

The two earlier findings in set-pin.ts are addressed: the raw media type removes the 1 MB content cap, and the version anchor is now a regex over the workspace entry, so an already-stale lockfile heals instead of silently skipping. The prior blocking comment on the setup-bun guard is also resolved: packages/kilo-jetbrains/package.json and bun.lock:365 both read 7.8.15, and script/check-bun-lock-workspace.ts now uses process.exitCode so the finally restore actually runs.

Issue Details (click to expand)

WARNING

File Line Issue
.kilo/skills/release-jetbrains/script/set-pin.ts 134 The lockfile is read through gh api stdout and Bun's $.text() and written back as base64. Neither step is byte-faithful for trailing newlines, and the new guard compares the committed lockfile byte-for-byte against regeneration — a one-byte difference still fails the pin-bump PR. Read the blob to a file and encode that instead.
Files Reviewed (5 files)
  • .changeset/fix-bun-lock-workspace-version.md - 0 issues
  • .github/actions/setup-bun/action.yml - 0 issues
  • .kilo/skills/release-jetbrains/script/set-pin.ts - 1 issue
  • bun.lock - 0 issues
  • script/check-bun-lock-workspace.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 12afaea)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1

No blocking issues remain: the regenerated bun.lock now matches the workspace (@kilocode/kilo-jetbrains 7.8.14 in both), so the new setup-bun lockfile guard passes. The two remaining items are robustness gaps in the pin-bump automation added by this PR.

Issue Details (click to expand)

WARNING

File Line Issue
.kilo/skills/release-jetbrains/script/set-pin.ts 133 pushLock anchors on previous, read from origin/main's package.json. If the lockfile entry is not already at that exact version, patched === text, the update silently skips, and the pin-bump PR is then rejected by the new lockfile guard. Anchoring on the workspace path and name and replacing whatever version follows is robust to an already-stale lockfile.

SUGGESTION

File Line Issue
.kilo/skills/release-jetbrains/script/set-pin.ts 131 The GitHub Contents API returns an empty content once a file exceeds 1 MB; bun.lock is already ~672 KB, so the update will silently skip on the same path. Fetch the blob via the Git Data API or the raw media type.
Files Reviewed (5 files)
  • .changeset/fix-bun-lock-workspace-version.md - 0 issues
  • .github/actions/setup-bun/action.yml - 0 issues
  • .kilo/skills/release-jetbrains/script/set-pin.ts - 2 issues
  • bun.lock - 0 issues
  • script/check-bun-lock-workspace.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 2bddf4a)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

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

CRITICAL

File Line Issue
.github/actions/setup-bun/action.yml 112 New lockfile guard fails on this PR: bun.lock still records 7.8.8 for @kilocode/kilo-jetbrains while package.json is 7.8.9, and the PR does not regenerate bun.lock.

WARNING

File Line Issue
.kilo/skills/release-jetbrains/script/set-pin.ts 133 pushLock anchors on origin/main's package.json version; on an already-drifted main the anchor misses and the lockfile update silently skips.

SUGGESTION

File Line Issue
.kilo/skills/release-jetbrains/script/set-pin.ts 131 GitHub Contents API returns empty content above 1 MB; bun.lock is ~672 KB and growing, which would trigger the same silent skip.
Files Reviewed (4 files)
  • .changeset/fix-bun-lock-workspace-version.md - 0 issues
  • .github/actions/setup-bun/action.yml - 1 issue
  • .kilo/skills/release-jetbrains/script/set-pin.ts - 2 issues
  • script/check-bun-lock-workspace.ts - 0 issues

The previous two findings (process.exit(1) skipping finally, changeset wording) remain resolved at HEAD.

Previous review (commit 62efc79)

Status: No Issues Found | Recommendation: Merge

Both findings from the previous review are resolved at HEAD, and the new set-pin.ts bump automation added since then checks out.

Files Reviewed (5 files)
  • .changeset/fix-bun-lock-workspace-version.md
  • .github/actions/setup-bun/action.yml
  • .kilo/skills/release-jetbrains/script/set-pin.ts
  • bun.lock
  • script/check-bun-lock-workspace.ts

Previous review (commit 50eef33)

Status: No Issues Found | Recommendation: Merge

Both findings from the previous review were addressed in commit 50eef33a:

  • script/check-bun-lock-workspace.ts now sets process.exitCode = 1 instead of calling process.exit(1), so the finally block runs and the committed bun.lock is restored on both the drift and error paths.
  • .changeset/fix-bun-lock-workspace-version.md was rewritten as a user-facing release note.
Files Reviewed (4 files)
  • .changeset/fix-bun-lock-workspace-version.md
  • .github/actions/setup-bun/action.yml
  • bun.lock
  • script/check-bun-lock-workspace.ts

Previous review (commit 64f218a)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
script/check-bun-lock-workspace.ts 45 process.exit(1) on the drift/error paths skips the finally that restores bun.lock, contradicting the "always restore" guarantee.

SUGGESTION

File Line Issue
.changeset/fix-bun-lock-workspace-version.md 5 Changeset is written as implementation notes rather than a user-facing release note.
Files Reviewed (4 files)
  • .changeset/fix-bun-lock-workspace-version.md - 1 issue
  • .github/actions/setup-bun/action.yml - 0 issues
  • bun.lock - 0 issues
  • script/check-bun-lock-workspace.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 61.1K · Output: 11.4K · Cached: 540.3K

Review guidance: REVIEW.md from base branch main

@github-actions github-actions Bot added community Opened by someone outside the Kilo team needs-triage Waiting for a maintainer to look labels Oct 8, 2026
@WebReflection

Copy link
Copy Markdown
Contributor

Counter-validation found one integration fix before merge: the new setup-bun guard will reject the automated JetBrains CLI pin-bump PRs. script/publish.ts calls set-pin.ts --pr after each CLI release, but .kilo/skills/release-jetbrains/script/set-pin.ts:82–86 updates only packages/kilo-jetbrains/package.json, not bun.lock.

Please update the pin-bump automation to regenerate and include bun.lock alongside the manifest change. Keeping the guard is the right approach; its producer just needs to satisfy it.

Reproduced with the actual PR manifests and CI-pinned Bun 1.3.14: a manifest-only pin bump passes the frozen install, then fails the new guard. Clean-workspace, drift-detection, and error-path restoration checks otherwise passed; no other blockers found.

@maphew
maphew force-pushed the kilo/cool-dew-jf0 branch from 720ff84 to 62efc79 Compare October 11, 2026 04:47
@github-actions github-actions Bot added needs-review and removed needs-triage Waiting for a maintainer to look labels Oct 12, 2026
@maphew
maphew force-pushed the kilo/cool-dew-jf0 branch from 62efc79 to 2bddf4a Compare October 13, 2026 20:16
# from the workspace, so version drift cannot land silently. # kilocode_change
- name: Verify lockfile matches workspace
shell: bash
run: bun script/check-bun-lock-workspace.ts

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.

CRITICAL: This guard fails on the PR as it stands

packages/kilo-jetbrains/package.json is at 7.8.9, but the committed bun.lock workspace entry still records 7.8.8 (bun.lock:365). This PR's diff does not include a regenerated bun.lock, despite the title, so the workspace version drift from #14616 is still present on the branch.

Because this step runs bun install --lockfile-only and fails on any byte difference, CI goes red immediately on this guard. Regenerate and commit bun.lock in this PR (bun install --lockfile-only) so the guard has something consistent to verify.


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

async function pushLock(version: string, previous: string, branch: string) {
const entry = (await $`gh api ${`repos/${repo}/contents/bun.lock?ref=${branch}`} --jq .content`.text()).trim()
const text = Buffer.from(entry, "base64").toString("utf8")
const anchor = `"packages/kilo-jetbrains": {\n "name": "@kilocode/kilo-jetbrains",\n "version": "${previous}",`

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: Anchor assumes the lockfile still holds the previous version

The anchor interpolates previous, which is read from origin/main's package.json, as the value expected in bun.lock. If origin/main is already drifted (it currently is: package.json 7.8.9 vs bun.lock 7.8.8), the anchor does not match, patched === text, and this function silently skips with a warning — leaving the automated pin-bump PR to be rejected by the new guard. Anchoring on the workspace path and name and replacing whatever version follows would be robust to an already-stale lockfile.


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

// by regenerating locally), so patch that line directly through the API
// instead of cloning the repo and re-running install.
async function pushLock(version: string, previous: string, branch: string) {
const entry = (await $`gh api ${`repos/${repo}/contents/bun.lock?ref=${branch}`} --jq .content`.text()).trim()

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: Contents API omits content for files over 1 MB

gh api .../contents/bun.lock --jq .content returns an empty value once the file exceeds 1 MB, and bun.lock is already around 672 KB. When it crosses that size, this call yields an empty string, the anchor is not found, and the update silently skips — again leaving the guard to fail the pin PR. Fetching the blob via the Git Data API (or the raw media type) avoids the size cap.


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

@github-actions github-actions Bot added needs-triage Waiting for a maintainer to look priority:p1 High: fixes and regressions. Set from the title. Change by hand. labels Oct 16, 2026
@maphew

maphew commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Review findings addressed in 21d755b:

  • pushLock now patches the packages/kilo-jetbrains workspace entry by regex on the entry itself, replacing whatever version is currently recorded instead of anchoring on previous from origin/main. An already-stale lockfile now heals instead of silently skipping the update.
  • The lockfile is read through the raw media type (Accept: application/vnd.github.raw), so the ~672 KB file no longer depends on the Contents API JSON content field that is empty above 1 MB.
  • Regenerated and committed bun.lock for the current pin (7.8.14 -> 7.8.15); bun script/check-bun-lock-workspace.ts now exits 0. Removed the unused script imports and added the missing changeset newline.

const path = `repos/${repo}/contents/bun.lock`
// The JSON `content` field is empty for files above 1 MB, which bun.lock is
// approaching. The raw media type returns the bytes regardless of size.
const text = await $`gh api ${`${path}?ref=${branch}`} -H "Accept: application/vnd.github.raw"`.text()

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: Raw read can change the file's bytes, which the guard compares exactly

The lockfile now round-trips through gh api stdout and Bun's $.text(). Neither is a byte-faithful file read: gh api terminates its output with a newline, and Bun shell text output normalizes trailing newlines. If either drops or adds one, the base64 written back on line 147 differs from the branch blob by a trailing newline only, and script/check-bun-lock-workspace.ts compares the committed lockfile byte-for-byte against bun install --lockfile-only output — so the pin-bump PR once again trips the guard this code is meant to satisfy. Reading the blob to a temp file (gh api ... --output <path>) and base64-encoding that file keeps the bytes intact.


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

# fields, so a stale workspace entry in bun.lock (e.g. a JetBrains pin bump that
# forgot to re-run install) passes silently. Fail CI when the lockfile drifts
# from the workspace, so version drift cannot land silently. # kilocode_change
- name: Verify lockfile matches workspace

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: This guard ignores the install input

Every other dependency step above is gated with if: inputs.install != 'false', but this new step is not. Twelve workflows pass install: false (for example check-forbidden-strings.yml, community-label.yml, stale-bot-notify.yml, and test-jetbrains.yml), so they now all run bun install --lockfile-only on every event, including issue-triggered automations that deliberately skip dependency work. That adds a lockfile-resolution pass and a new failure mode to jobs that opted out of it. Consider adding if: inputs.install != 'false' like the neighbouring steps, or moving the check into a dedicated job.

@maphew

maphew commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Both findings addressed in 1a9892e:

  • pushLock now downloads bun.lock with gh api --output to a temp file and reads it with readFile before patching, so the bytes sent back are exactly the file GitHub stores; the guard remains byte-identical. Temp file is removed in finally.
  • The lockfile guard step is now gated by if: inputs.install != 'false', matching the other dependency steps so lightweight jobs no longer run bun install --lockfile-only.

Verified with bun build --target=bun and bun script/check-bun-lock-workspace.ts (exit 0).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Opened by someone outside the Kilo team needs-triage Waiting for a maintainer to look priority:p1 High: fixes and regressions. Set from the title. Change by hand.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bun.lock records a stale version for @kilocode/kilo-jetbrains, and --frozen-lockfile does not catch it

3 participants