[PR #20] [MERGED] fix: derive User-Agent version from package.json at build time #30

Closed
opened 2026-10-31 22:03:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-typescript-sdk/pull/20
Author: @wei-hai
Created: 7/23/2026
Status: ✅ Merged
Merged: 7/23/2026
Merged by: @wei-hai

Base: main ← Head: fix/ts-user-agent-version


📝 Commits (1)

  • 59ee0f0 fix: derive User-Agent version from package.json at build time

📊 Changes

4 files changed (+22 additions, -7 deletions)

View changed files

📝 package.json (+1 -1)
➕ scripts/gen-version.mjs (+18 -0)
📝 src/low/transport.ts (+1 -6)
➕ src/low/version.ts (+2 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-typescript-sdk/pull/20 **Author:** [@wei-hai](https://github.com/wei-hai) **Created:** 7/23/2026 **Status:** ✅ Merged **Merged:** 7/23/2026 **Merged by:** [@wei-hai](https://github.com/wei-hai) **Base:** `main` ← **Head:** `fix/ts-user-agent-version` --- ### 📝 Commits (1) - [`59ee0f0`](https://github.com/Comfy-Org/comfy-typescript-sdk/commit/59ee0f0d18e7d227e6e860fbcde267efdfc4801d) fix: derive User-Agent version from package.json at build time ### 📊 Changes **4 files changed** (+22 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+1 -1) ➕ `scripts/gen-version.mjs` (+18 -0) 📝 `src/low/transport.ts` (+1 -6) ➕ `src/low/version.ts` (+2 -0) </details> ### 📄 Description ## 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 22:03:57 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-typescript-sdk#30
No description provided.