From 9dd1c2e980453745edd73c601a20b0a5eab0662d Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sun, 31 May 2026 09:36:57 -0400 Subject: [PATCH 1/2] fix(python): derive __version__ from package metadata with dev sentinel The Python SDK hardcoded __version__ = "0.1.0" in copilot/__init__.py and version = "0.1.0" in pyproject.toml. The publish workflow only rewrites pyproject.toml at release time, so the public runtime __version__ drifted and always reported a stale version regardless of what was published. Derive __version__ from installed package metadata via importlib.metadata, falling back to a 0.0.0.dev0 sentinel (instead of a real-looking version) when no metadata is present. Set the committed pyproject.toml version to the same dev sentinel, matching the .NET and Rust SDKs; CI injects the real version at publish time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- python/copilot/__init__.py | 11 ++++++++++- python/pyproject.toml | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/python/copilot/__init__.py b/python/copilot/__init__.py index 5f51cf021..ed71b7cc3 100644 --- a/python/copilot/__init__.py +++ b/python/copilot/__init__.py @@ -4,6 +4,9 @@ JSON-RPC based SDK for programmatic control of GitHub Copilot CLI """ +from importlib.metadata import PackageNotFoundError +from importlib.metadata import version as _pkg_version + from ._mode import ( BUILTIN_TOOLS_ISOLATED, CopilotClientMode, @@ -145,7 +148,13 @@ define_tool, ) -__version__ = "0.1.0" +try: + __version__ = _pkg_version("github-copilot-sdk") +except PackageNotFoundError: + # No installed package metadata (e.g. running from a source checkout that + # was never installed). Use a sentinel that can never masquerade as a real + # release rather than a hardcoded version that would silently go stale. + __version__ = "0.0.0.dev0" __all__ = [ "AutoModeSwitchHandler", diff --git a/python/pyproject.toml b/python/pyproject.toml index 897c5466d..596e07be2 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -4,7 +4,10 @@ build-backend = "setuptools.build_meta" [project] name = "github-copilot-sdk" -version = "0.1.0" +# Placeholder; the real version is injected at publish time (see +# .github/workflows/publish.yml). Kept as a dev sentinel so source/editable +# installs never report a stale real version, matching the .NET and Rust SDKs. +version = "0.0.0.dev0" description = "Python SDK for GitHub Copilot CLI" readme = "README.md" requires-python = ">=3.11" From d5c6fd550fe963941a037441fb5e4a2f846e2b7e Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sun, 31 May 2026 09:36:58 -0400 Subject: [PATCH 2/2] chore(nodejs): use 0.0.0-dev version sentinel for consistency The Node SDK committed a real-looking version (0.1.8) in package.json and reset to 0.1.0 in the package script, unlike the .NET and Rust SDKs which use a 0.0.0-dev sentinel. CI injects the real version at publish via set-version.js, so the committed value should be an unmistakable dev placeholder rather than a stale real version. Align package.json, the package script, set-version.js default, and the package-lock.json files (including nodejs/samples) to 0.0.0-dev. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- nodejs/package-lock.json | 4 ++-- nodejs/package.json | 4 ++-- nodejs/samples/package-lock.json | 2 +- nodejs/scripts/set-version.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nodejs/package-lock.json b/nodejs/package-lock.json index 1b3d8535c..b18907204 100644 --- a/nodejs/package-lock.json +++ b/nodejs/package-lock.json @@ -1,12 +1,12 @@ { "name": "@github/copilot-sdk", - "version": "0.1.8", + "version": "0.0.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@github/copilot-sdk", - "version": "0.1.8", + "version": "0.0.0-dev", "license": "MIT", "dependencies": { "@github/copilot": "^1.0.57-3", diff --git a/nodejs/package.json b/nodejs/package.json index 35abb6156..a88fc9021 100644 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -4,7 +4,7 @@ "type": "git", "url": "https://github.com/github/copilot-sdk.git" }, - "version": "0.1.8", + "version": "0.0.0-dev", "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC", "main": "./dist/cjs/index.js", "types": "./dist/index.d.ts", @@ -44,7 +44,7 @@ "generate": "cd ../scripts/codegen && npm run generate", "update:protocol-version": "tsx scripts/update-protocol-version.ts", "prepublishOnly": "npm run build", - "package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.1.0 --no-git-tag-version --allow-same-version" + "package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.0.0-dev --no-git-tag-version --allow-same-version" }, "keywords": [ "github", diff --git a/nodejs/samples/package-lock.json b/nodejs/samples/package-lock.json index d4c84bc31..44e290a09 100644 --- a/nodejs/samples/package-lock.json +++ b/nodejs/samples/package-lock.json @@ -15,7 +15,7 @@ }, "..": { "name": "@github/copilot-sdk", - "version": "0.1.8", + "version": "0.0.0-dev", "license": "MIT", "dependencies": { "@github/copilot": "^1.0.57-3", diff --git a/nodejs/scripts/set-version.js b/nodejs/scripts/set-version.js index 4d952f501..16969631f 100644 --- a/nodejs/scripts/set-version.js +++ b/nodejs/scripts/set-version.js @@ -3,7 +3,7 @@ import { readFileSync, writeFileSync } from "fs"; import { dirname, join } from "path"; import { fileURLToPath } from "url"; -const version = process.env.VERSION || "0.1.0-dev"; +const version = process.env.VERSION || "0.0.0-dev"; const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"); const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));