Skip to content

Commit 77d4505

Browse files
committed
feat: use dynamic version in User-Agent header
- Replace hardcoded version '3.22.6' with Package.version from shared/package.ts - Update tests to use dynamic version instead of hardcoded values - Ensures User-Agent version stays in sync with package.json automatically Addresses feedback from @cte in PR #5492 comment: #5492 (comment)
1 parent 2818d40 commit 77d4505

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/api/providers/__tests__/constants.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { describe, it, expect } from "vitest"
44
import { DEFAULT_HEADERS } from "../constants"
5+
import { Package } from "../../../shared/package"
56

67
describe("DEFAULT_HEADERS", () => {
78
it("should contain all required headers", () => {
@@ -20,7 +21,7 @@ describe("DEFAULT_HEADERS", () => {
2021

2122
it("should have correct User-Agent format", () => {
2223
const userAgent = DEFAULT_HEADERS["User-Agent"]
23-
expect(userAgent).toBe("roo-cline/3.22.6")
24+
expect(userAgent).toBe(`roo-cline/${Package.version}`)
2425

2526
// Verify it follows the tool_name/version pattern
2627
expect(userAgent).toMatch(/^[a-z-]+\/\d+\.\d+\.\d+$/)
@@ -38,8 +39,8 @@ describe("DEFAULT_HEADERS", () => {
3839
// Check semantic version format (major.minor.patch)
3940
expect(version).toMatch(/^\d+\.\d+\.\d+$/)
4041

41-
// Verify current version
42-
expect(version).toBe("3.22.6")
42+
// Verify current version matches package version
43+
expect(version).toBe(Package.version)
4344
})
4445

4546
it("should be an object with string values", () => {

src/api/providers/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { Package } from "../../shared/package"
2+
13
export const DEFAULT_HEADERS = {
24
"HTTP-Referer": "https://github.com/RooVetGit/Roo-Cline",
35
"X-Title": "Roo Code",
4-
"User-Agent": "roo-cline/3.22.6",
6+
"User-Agent": `roo-cline/${Package.version}`,
57
}

0 commit comments

Comments
 (0)