Skip to content

fix: report the real version from the released bundle#4

Merged
boristane merged 1 commit into
mainfrom
fix/version-report-in-bundle
Jul 24, 2026
Merged

fix: report the real version from the released bundle#4
boristane merged 1 commit into
mainfrom
fix/version-report-in-bundle

Conversation

@claude

@claude claude Bot commented Jul 24, 2026

Copy link
Copy Markdown

Requested by boris · Slack thread

Before / After

polylane --version (curl/brew install of v0.2.1)
Before polylane 0.0.0
After polylane 0.2.1

Also fixes the User-Agent / x-nominal-client-version headers and polylane update's "Current version", which had the same failure mode.

Root cause

The release asset is a standalone dist/polylane.mjs — no package.json ships next to it. But --version (plus src/client/http.ts, src/commands/update.ts) resolved the version by reading ../package.json relative to the bundle at runtime, hit the catch, and fell back to '0.0.0'.

build.ts already bakes the version into the bundle via an esbuild define on process.env.POLYLANE_CLI_VERSION — the runtime code just never used it for --version.

Fix

  • New src/version.ts: getCliVersion() prefers the baked POLYLANE_CLI_VERSION define and falls back to reading package.json only in dev mode (tsx src/main.ts from a checkout).
  • All five version lookups (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.ts lets an explicit POLYLANE_CLI_VERSION env override package.json at bundle time, and release.yml passes ${GITHUB_REF_NAME#v} on the build step, so the bundle always reports the tag version even if package.json were ever out of sync.
  • Added test/version.test.ts covering 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 clean
  • POLYLANE_CLI_VERSION=9.9.9-test npm run build && node dist/polylane.mjs --versionpolylane 9.9.9-test
  • Plain npm run build, bundle copied to a directory with no package.jsonpolylane 0.2.1 (previously 0.0.0)

🤖 Generated with Claude Code

https://claude.ai/code/session_0149UgXkD5n9z2yKrzCMgCTC


Generated by Claude Code

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
boristane marked this pull request as ready for review July 24, 2026 02:07
@boristane
boristane merged commit ba1aef9 into main Jul 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants