fix: derive User-Agent version from package.json at build time#20
Conversation
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>
|
Warning Review limit reached
Next review available in: 37 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Warning
|
What
Makes the TypeScript SDK's
User-Agentreport the real published version instead of a stale hardcoded constant.The bug
Versioning is tag-driven:
publish.ymlrunsnpm pkg set versionfrom the release tag before building. But the User-Agent used a hand-keptconst SDK_VERSION = "0.1.0"intransport.tsthat the workflow never touched — so every published npm build sentUser-Agent: comfy-sdk-typescript/0.1.0regardless of the actual version (0.1.1, 0.1.2, …). That defeats version-level SDK-adoption tracking. (The Python SDK is unaffected — it readsimportlib.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
scripts/gen-version.mjs— writessrc/low/version.tsfrompackage.json'sversion.buildnow runs it beforetsc. Since the publish workflow setspackage.jsonto the tag version before build, the published bundle now carries that version.transport.tsimportsSDK_VERSIONfrom the generated file.src/low/version.tsis committed with the placeholder so typecheck/test/lint work without a build; the publish build regenerates it. No change topublish.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 reportsUser-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