Skip to content

Commit ee175d9

Browse files
committed
fix: handle fork package names in version detection
1 parent 59bdc0c commit ee175d9

3 files changed

Lines changed: 34 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to the Specify CLI and templates are documented here.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to to [Semantic Versioning](https://semver.org/spec/v2.0.0/).
77

8+
## [0.1.18] - 2026-03-21
9+
10+
### Fixed
11+
12+
- **Version detection for fork packages**: `specify init` now correctly resolves the CLI version when the package is installed under `agentic-sdlc-specify-cli` (e.g., via `uv tool install`). Previously it only tried `specify-cli`, causing preset compatibility checks to fail with `Invalid version: 'unknown'` for bundled presets like `agentic-sdlc`.
13+
814
## [0.1.17] - 2026-03-20
915

1016
### Changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "agentic-sdlc-specify-cli"
3-
version = "0.1.17"
3+
version = "0.1.18"
44
description = "Specify CLI, part of GitHub Spec Kit. A tool to bootstrap your projects for Spec-Driven Development (SDD)."
55
requires-python = ">=3.11"
66
dependencies = [

src/specify_cli/__init__.py

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@
6969

7070
TEAM_DIRECTIVES_DIRNAME = "team-ai-directives"
7171

72+
_PKG_NAMES = ("specify-cli", "agentic-sdlc-specify-cli")
73+
74+
75+
def _get_cli_version() -> str:
76+
"""Try to get the CLI version from package metadata, trying known package names."""
77+
import importlib.metadata
78+
79+
for pkg_name in _PKG_NAMES:
80+
try:
81+
return importlib.metadata.version(pkg_name)
82+
except Exception:
83+
pass
84+
85+
try:
86+
import tomllib
87+
88+
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
89+
if pyproject_path.exists():
90+
with open(pyproject_path, "rb") as f:
91+
data = tomllib.load(f)
92+
return data.get("project", {}).get("version", "unknown")
93+
except Exception:
94+
pass
95+
return "unknown"
96+
7297

7398
def _github_token(cli_token: str | None = None) -> str | None:
7499
"""Return sanitized GitHub token (cli arg takes precedence) or None."""
@@ -4272,26 +4297,10 @@ def check():
42724297
def version():
42734298
"""Display version and system information."""
42744299
import platform
4275-
import importlib.metadata
42764300

42774301
show_banner()
42784302

4279-
# Get CLI version from package metadata
4280-
cli_version = "unknown"
4281-
try:
4282-
cli_version = importlib.metadata.version("specify-cli")
4283-
except Exception:
4284-
# Fallback: try reading from pyproject.toml if running from source
4285-
try:
4286-
import tomllib
4287-
4288-
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
4289-
if pyproject_path.exists():
4290-
with open(pyproject_path, "rb") as f:
4291-
data = tomllib.load(f)
4292-
cli_version = data.get("project", {}).get("version", "unknown")
4293-
except Exception:
4294-
pass
4303+
cli_version = _get_cli_version()
42954304

42964305
# Fetch latest template release version
42974306
repo_owner = "github"
@@ -4382,25 +4391,7 @@ def version():
43824391

43834392
def get_speckit_version() -> str:
43844393
"""Get current spec-kit version."""
4385-
import importlib.metadata
4386-
4387-
try:
4388-
return importlib.metadata.version("specify-cli")
4389-
except Exception:
4390-
# Fallback: try reading from pyproject.toml
4391-
try:
4392-
import tomllib
4393-
4394-
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
4395-
if pyproject_path.exists():
4396-
with open(pyproject_path, "rb") as f:
4397-
data = tomllib.load(f)
4398-
return data.get("project", {}).get("version", "unknown")
4399-
except Exception:
4400-
# Intentionally ignore any errors while reading/parsing pyproject.toml.
4401-
# If this lookup fails for any reason, we fall back to returning "unknown" below.
4402-
pass
4403-
return "unknown"
4394+
return _get_cli_version()
44044395

44054396

44064397
# ===== Preset Commands =====

0 commit comments

Comments
 (0)