Skip to content

fix: derive User-Agent version from package.json at build time#20

Merged
wei-hai merged 1 commit into
mainfrom
fix/ts-user-agent-version
Jul 23, 2026
Merged

fix: derive User-Agent version from package.json at build time#20
wei-hai merged 1 commit into
mainfrom
fix/ts-user-agent-version

Conversation

@wei-hai

@wei-hai wei-hai commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

What

Makes the TypeScript SDK's User-Agent report the real published version instead of a stale hardcoded constant.

The bug

Versioning is tag-driven: publish.yml runs npm pkg set version from the release tag before building. But the User-Agent used a hand-kept const SDK_VERSION = "0.1.0" in transport.ts that the workflow never touched — so every published npm build sent User-Agent: comfy-sdk-typescript/0.1.0 regardless of the actual version (0.1.1, 0.1.2, …). That defeats version-level SDK-adoption tracking. (The Python SDK is unaffected — it reads importlib.metadata.version.)

The drift-guard test added earlier couldn't catch this: it compares the constant against package.json's committed placeholder (both 0.1.0); they only diverge at publish time.

Fix

  • Add scripts/gen-version.mjs — writes src/low/version.ts from package.json's version.
  • build now runs it before tsc. Since the publish workflow sets package.json to the tag version before build, the published bundle now carries that version. transport.ts imports SDK_VERSION from the generated file.
  • src/low/version.ts is committed with the placeholder so typecheck/test/lint work without a build; the publish build regenerates it. No change to publish.yml.

Verified

Full CI-mirroring pass locally: format:check, lint, typecheck, 130 tests, build, hygiene. And simulated a release: npm pkg set version 0.1.3 && pnpm build → the built bundle reports User-Agent: comfy-sdk-typescript/0.1.3. Takes effect from the next release (0.1.3+); 0.1.2 already shipped.

🤖 Generated with Claude Code

SDK_VERSION was a hardcoded constant, but versioning is tag-driven: the publish
workflow injects the release version into package.json before build and never
touched the constant, so every published npm build reported the User-Agent
version as the stale placeholder (0.1.0) regardless of the real version.

Generate src/low/version.ts from package.json in `pnpm build` (via
scripts/gen-version.mjs) and import SDK_VERSION from it. The committed
version.ts holds the placeholder so typecheck/test/lint work without a build;
the publish build regenerates it from the tag-injected version. No change to
publish.yml needed. Verified: injecting 0.1.3 then building yields
User-Agent comfy-sdk-typescript/0.1.3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wei-hai
wei-hai requested review from a team as code owners July 23, 2026 16:55
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@wei-hai, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 92673024-66d5-41cf-8a46-888747b5fc78

📥 Commits

Reviewing files that changed from the base of the PR and between 890549a and 59ee0f0.

📒 Files selected for processing (4)
  • package.json
  • scripts/gen-version.mjs
  • src/low/transport.ts
  • src/low/version.ts

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Too big: expected string to have <=250 characters at "tone_instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ts-user-agent-version
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/ts-user-agent-version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wei-hai
wei-hai merged commit 3716a17 into main Jul 23, 2026
7 checks passed
@wei-hai
wei-hai deleted the fix/ts-user-agent-version branch July 23, 2026 19:25
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.

1 participant