fix: report the real version from the released bundle#4
Merged
Conversation
The release asset ships dist/polylane.mjs standalone, but --version (and the update command, User-Agent, and client-version headers) re-read package.json relative to the bundle at runtime. With no package.json next to the downloaded asset, every install reported 0.0.0. build.ts already bakes the version into the bundle via an esbuild define on POLYLANE_CLI_VERSION; route all version lookups through a shared src/version.ts that prefers the baked value and falls back to package.json only in dev mode. The release workflow now also injects the tag version explicitly at build time so the bundle can never drift from the tag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0149UgXkD5n9z2yKrzCMgCTC
boristane
marked this pull request as ready for review
July 24, 2026 02:07
boristane
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by boris · Slack thread
Before / After
polylane --version(curl/brew install of v0.2.1)polylane 0.0.0polylane 0.2.1Also fixes the
User-Agent/x-nominal-client-versionheaders andpolylane update's "Current version", which had the same failure mode.Root cause
The release asset is a standalone
dist/polylane.mjs— nopackage.jsonships next to it. But--version(plussrc/client/http.ts,src/commands/update.ts) resolved the version by reading../package.jsonrelative to the bundle at runtime, hit thecatch, and fell back to'0.0.0'.build.tsalready bakes the version into the bundle via an esbuilddefineonprocess.env.POLYLANE_CLI_VERSION— the runtime code just never used it for--version.Fix
src/version.ts:getCliVersion()prefers the bakedPOLYLANE_CLI_VERSIONdefine and falls back to readingpackage.jsononly in dev mode (tsx src/main.tsfrom a checkout).main.ts,client/http.ts,client/thread-chat.ts,commands/update.ts,telemetry/event.ts) now route through it — removed the duplicated read-package.json helpers.build.tslets an explicitPOLYLANE_CLI_VERSIONenv overridepackage.jsonat bundle time, andrelease.ymlpasses${GITHUB_REF_NAME#v}on the build step, so the bundle always reports the tag version even ifpackage.jsonwere ever out of sync.test/version.test.tscovering baked-value preference, dev fallback, and empty-value handling.Verification
npm run typecheck,npm run lint,npm test(115 pass, incl. 3 new),npm run build— all cleanPOLYLANE_CLI_VERSION=9.9.9-test npm run build && node dist/polylane.mjs --version→polylane 9.9.9-testnpm run build, bundle copied to a directory with nopackage.json→polylane 0.2.1(previously0.0.0)🤖 Generated with Claude Code
https://claude.ai/code/session_0149UgXkD5n9z2yKrzCMgCTC
Generated by Claude Code