Get current spec-kit version.
()
| 102 | |
| 103 | |
| 104 | def get_speckit_version() -> str: |
| 105 | """Get current spec-kit version.""" |
| 106 | try: |
| 107 | return importlib.metadata.version("specify-cli") |
| 108 | except Exception: |
| 109 | # Fallback: try reading from pyproject.toml |
| 110 | try: |
| 111 | import tomllib |
| 112 | pyproject_path = _repo_root() / "pyproject.toml" |
| 113 | if pyproject_path.exists(): |
| 114 | with open(pyproject_path, "rb") as f: |
| 115 | data = tomllib.load(f) |
| 116 | return data.get("project", {}).get("version", "unknown") |
| 117 | except Exception: |
| 118 | # Intentionally ignore any errors while reading/parsing pyproject.toml. |
| 119 | # If this lookup fails for any reason, we fall back to returning "unknown" below. |
| 120 | pass |
| 121 | return "unknown" |