The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): completion line reports checkout identity, not pyproject's inert 0.0.0
ethernet4b413254b0ea
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex 2972df64a33..da6876632cf 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -96,7 +96,7 @@ from hermes_cli.update_cmd_git import ( # noqa: F401_sync_with_upstream_if_needed)from hermes_cli.update_cmd_maint import ( # noqa: F401_PRE_UPDATE_SNAPSHOT_KEEP, _PRE_UPDATE_SNAPSHOT_MAX_FILE_SIZE, _clear_stale_sqlite_sidecars,- _ensure_acp_launcher, _ensure_fhs_path_guard, _finish_dashboard_update_cleanup,+ _checkout_version, _ensure_acp_launcher, _ensure_fhs_path_guard, _finish_dashboard_update_cleanup,_format_time_ago, _post_update_sqlite_runtime_status, _print_bundled_skills_sync_report,_print_curator_first_run_notice, _print_curator_recent_run_notice,_print_fts_optimize_available_notice, _print_update_completion, _print_update_summary,@@ -1184,12 +1184,8 @@ class _UpdateOptions:def _resolve_update_options(args, gateway_mode: bool) -> _UpdateOptions:"""Snapshot pre-update state and resolve the flags/config ``_cmd_update_impl`` runs on."""- # Captured before any pull so the completion line can report the transition.- # Snapshot the pre-update version before files are replaced so the completion line can report the- # transition (prime-agent#630 port).- # Snapshot the pre-update version before any code is pulled so the completion line can report the- # transition (prime-agent#630 port).- pre_update_version = _read_project_version()+ # Captured before any pull so the completion line can report the transition (prime-agent#630 port).+ pre_update_version = _checkout_version()gw_input_fn = ((lambda prompt, default="": _gateway_prompt(prompt, default)) if gateway_mode else None)assume_yes = bool(getattr(args, "yes", False))diff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.pyindex f434f9e611c..f930b77e0a0 100644--- a/hermes_cli/update_cmd_maint.py+++ b/hermes_cli/update_cmd_maint.py@@ -331,19 +331,35 @@ def _read_project_version() -> str | None:return None+def _checkout_version() -> str | None:+ """The checkout's runtime identity, computed exactly as ``write_source_stamp`` publishes it.++ pyproject.toml is an inert 0.0.0 on source checkouts; the release a checkout+ runs is derived from its reachable tags.+ """+ from hermes_cli.update_cmd import _m+ from hermes_cli.version_info import _git_version_info+ info = _git_version_info(Path(_m().PROJECT_ROOT), include_untracked=True)+ return info.derived_version if info.commit else None++def _update_complete_message(pre_version: str | None) -> str:"""Completion line with ``vA → vB`` when known; plain when either side is unknown orthe version did not change.Ported from PrimeIntellect-ai/prime-agent#630: after a successful self-update, show both versions(``v0.19.4 → v0.20.0``) so the user can see what they actually got. Falls back to the plain message when- either side is unknown or the version did not change (e.g. several commits landed within one release).+ either side is unknown or the version did not change."""- post_version = _read_project_version()+ def shown(version: str) -> str:+ # A tagless checkout's identity is ``git.<sha>``, not a release number.+ return f"v{version}" if version[:1].isdigit() else version++ post_version = _checkout_version()if pre_version and post_version and pre_version != post_version:- return f"✓ Update complete! (v{pre_version} → v{post_version})"+ return f"✓ Update complete! ({shown(pre_version)} → {shown(post_version)})"if post_version:- return f"✓ Update complete! (v{post_version})"+ return f"✓ Update complete! ({shown(post_version)})"return "✓ Update complete!"diff --git a/tests/hermes_cli/test_update_version_report.py b/tests/hermes_cli/test_update_version_report.pyindex 192bfd79055..e26542ce6c4 100644--- a/tests/hermes_cli/test_update_version_report.py+++ b/tests/hermes_cli/test_update_version_report.py@@ -1,15 +1,19 @@"""Version transition reporting after ``hermes update``.Ported from PrimeIntellect-ai/prime-agent#630: a successful self-update-reports both versions (``v0.19.4 → v0.20.0``) when the pyproject version-changed, and degrades gracefully when either side is unknown.+reports both versions (``v0.19.4 → v0.20.0``). pyproject.toml is an inert+0.0.0 on source checkouts, so the reported versions are the checkout's+runtime identity -- the same one the completion publishes in its stamp."""+import osfrom pathlib import Path+import subprocessimport pytestfrom hermes_cli import update_cmd+from hermes_cli.source_stamp import write_source_stampdef _write_pyproject(root: Path, version: str) -> None:@@ -28,6 +32,12 @@ def fake_root(tmp_path, monkeypatch):return tmp_path+def _git(root: Path, *args: str) -> str:+ env = {**os.environ, "GIT_AUTHOR_NAME": "t", "GIT_AUTHOR_EMAIL": "[email protected]",+ "GIT_COMMITTER_NAME": "t", "GIT_COMMITTER_EMAIL": "[email protected]"}+ return subprocess.run(["git", *args], cwd=root, env=env, check=True, capture_output=True, text=True).stdout.strip()++class TestReadProjectVersion:def test_reads_version(self, fake_root):_write_pyproject(fake_root, "0.20.0")@@ -42,19 +52,27 @@ class TestReadProjectVersion:class TestUpdateCompleteMessage:- def test_reports_transition_when_version_changed(self, fake_root):- _write_pyproject(fake_root, "0.20.0")- msg = update_cmd._update_complete_message("0.19.4")- assert "v0.19.4" in msg and "v0.20.0" in msg-- def test_same_version_reports_single_version(self, fake_root):- _write_pyproject(fake_root, "0.20.0")- assert update_cmd._update_complete_message("0.20.0").count("v0.20.0") == 1-- def test_unknown_pre_version_still_shows_current(self, fake_root):- _write_pyproject(fake_root, "0.20.0")- assert "v0.20.0" in update_cmd._update_complete_message(None)-- def test_unknown_post_version_falls_back_to_plain(self, fake_root):- msg = update_cmd._update_complete_message("0.19.4")- assert msg and "0.19.4" not in msg+ def test_transition_reports_the_identity_the_stamp_publishes(self, fake_root):+ _git(fake_root, "init", "-q")+ _write_pyproject(fake_root, "0.0.0")+ _git(fake_root, "add", "pyproject.toml")+ _git(fake_root, "commit", "-qm", "release")+ _git(fake_root, "tag", "v0.21.4")+ pre = update_cmd._checkout_version()+ _git(fake_root, "commit", "-q", "--allow-empty", "-m", "update")++ message = update_cmd._update_complete_message(pre)+ stamp = write_source_stamp(fake_root)+ assert stamp is not None++ assert message == f"✓ Update complete! (v{pre} → v{stamp['displayVersion']})"++ def test_tagless_checkout_reports_its_commit_identity(self, fake_root):+ _git(fake_root, "init", "-q")+ _git(fake_root, "commit", "-q", "--allow-empty", "-m", "only")++ message = update_cmd._update_complete_message("0.21.4")+ stamp = write_source_stamp(fake_root)+ assert stamp is not None++ assert message == f"✓ Update complete! (v0.21.4 → {stamp['displayVersion']})"