Files
dev/sdk/python/release_version.py
T
zeekayandHanzo Dev 6cbbea2d03 merge: just-every/code v0.6.169 (e4fe007150) — keep Hanzo identity
Our history is just-every's with author emails rewritten, so the graphs are
disjoint and git finds no merge base. Supplied one by hand: d1f1f51a41, the
just-every commit matching our Oct-2025 fork point (22 files apart). 9618
upstream commits, 7004 files, +1.81M/-159k, 37 conflicts.

Resolution:
- Upstream code where our side was the Oct-2025 prototype of a feature they
  have since reimplemented 3-5x larger (agent_runs, browser_sessions,
  history_cell/{agent,browser}, the vt100 harness and its snapshots).
- Upstream's config.rs module split (builder/defaults/sources/validation)
  kept; zen5-coder and the provider-follows-model rule re-applied on top.
- Ours where the file IS the identity: README, package.json, postinstall,
  release notes pipeline, integration-zed.
- Hybrid where upstream improved a file we had branded: updates.rs (their
  release-repo migration, our hanzoai/dev), release.yml (their fail-fast npm
  auth check, our package name), chatwidget.rs (their turn handling, our
  HANZO_USER_KEY hint), exec human output (their 237 lines, our banner).

Superseded and dropped deliberately: our resume_command_name() coder-alias
hack — upstream's derive_resume_command_name() reads the invocation basename
generically, which yields "dev" for us.

LLM.md now records the real topology and the sync point; AGENTS.md and
CLAUDE.md are symlinks to it again. Single parent on purpose: adopting
jecode/main as a second parent would re-import 13,742 commits carrying the
upstream author emails a prior rewrite deliberately removed.

Version 0.2.188 -> 0.2.189.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-05 23:09:12 -07:00

87 lines
3.0 KiB
Python

#!/usr/bin/env python3
import argparse
import re
import sys
from pathlib import Path
from typing import Sequence
_PYTHON_RUNTIME_VERSION_PATTERN = re.compile(r"[0-9]+\.[0-9]+\.[0-9]+(?:a[0-9]+(?:\.post[0-9]+)?)?")
_NORMALIZED_CODEX_VERSION_PATTERN = re.compile(
r"[0-9]+(?:\.[0-9]+)*(?:(?:a|b|rc)[0-9]+)?(?:\.post[0-9]+)?"
)
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser(
description="Resolve a Python runtime package version to its Codex release tag."
)
parser.add_argument("python_version")
parser.add_argument("--github-output", type=Path, required=True)
args = parser.parse_args(argv)
try:
python_version, release_tag = resolve_python_runtime_release(args.python_version)
except RuntimeError as exc:
print(exc, file=sys.stderr)
return 1
with args.github_output.open("a", encoding="utf-8") as output:
print(f"python_version={python_version}", file=output)
print(f"release_tag={release_tag}", file=output)
return 0
def resolve_python_runtime_release(python_version: str) -> tuple[str, str]:
if _PYTHON_RUNTIME_VERSION_PATTERN.fullmatch(python_version) is None:
raise RuntimeError(
"Python runtime version must be stable, a numbered alpha, or an "
"alpha post-release, for example 0.136.0, 0.136.0a2, or "
f"0.136.0a2.post1; found {python_version}"
)
return python_version, codex_release_tag(python_version)
def codex_release_tag(version: str) -> str:
return f"rust-v{codex_release_version(version)}"
def codex_release_version(version: str) -> str:
normalized = normalize_codex_version(version)
alpha_hotfix = re.fullmatch(
r"([0-9]+(?:\.[0-9]+)*)a([0-9]+)\.post([0-9]+)",
normalized,
)
if alpha_hotfix is not None:
base, alpha, hotfix = alpha_hotfix.groups()
return f"{base}-alpha.{alpha}.{hotfix}"
prerelease = re.fullmatch(r"([0-9]+(?:\.[0-9]+)*)(a|b|rc)([0-9]+)", normalized)
if prerelease is None:
return normalized
base, prerelease_kind, number = prerelease.groups()
prerelease_name = {"a": "alpha", "b": "beta", "rc": "rc"}[prerelease_kind]
return f"{base}-{prerelease_name}.{number}"
def normalize_codex_version(version: str) -> str:
normalized = version.strip()
if normalized.startswith("rust-v"):
normalized = normalized.removeprefix("rust-v")
elif normalized.startswith("v"):
normalized = normalized.removeprefix("v")
normalized = re.sub(r"-alpha\.?([0-9]+)\.([0-9]+)$", r"a\1.post\2", normalized)
normalized = re.sub(r"-alpha\.?([0-9]+)$", r"a\1", normalized)
normalized = re.sub(r"-beta\.?([0-9]+)$", r"b\1", normalized)
normalized = re.sub(r"-rc\.?([0-9]+)$", r"rc\1", normalized)
if _NORMALIZED_CODEX_VERSION_PATTERN.fullmatch(normalized) is None:
raise RuntimeError(f"Could not normalize Codex version {version!r} to a PEP 440 version")
return normalized
if __name__ == "__main__":
raise SystemExit(main())