fix(install): stamp .graphify_version only for the platform being installed (#2694)
install() called _refresh_all_version_stamps(), which stamped every installed platform's .graphify_version with the current version WITHOUT rewriting that platform's skill content — so a genuinely stale platform was stamped current and its staleness warning was suppressed. Removes that bogus refresh; each platform's stamp now advances only when its own content is (re)written via _copy_skill_file, so a not-reinstalled stale platform correctly still warns. Completes #2694 (part 1 shipped in 0.9.44 via #2753). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
safishamsi
co-authored by
Claude Opus 4.8
parent
0524982346
commit
a59a4e812e
@@ -71,7 +71,6 @@ from graphify.install import ( # noqa: E402,F401
|
||||
_project_scope_root,
|
||||
_project_uninstall,
|
||||
_project_uninstall_all,
|
||||
_refresh_all_version_stamps,
|
||||
_remove_claude_skill_registration,
|
||||
_remove_skill_file,
|
||||
_replace_or_append_section,
|
||||
|
||||
@@ -55,17 +55,6 @@ def _always_on(basename: str) -> str:
|
||||
f"graphify install is incomplete: missing always-on block '{basename}' "
|
||||
f"at {path}. Reinstall graphifyy (e.g. `uv tool install --reinstall graphifyy`)."
|
||||
) from exc
|
||||
def _refresh_all_version_stamps() -> None:
|
||||
"""After a successful install, update .graphify_version in all other known skill dirs.
|
||||
|
||||
Prevents stale-version warnings from platforms that were installed previously
|
||||
but not explicitly re-installed during this upgrade.
|
||||
"""
|
||||
for name in _PLATFORM_CONFIG:
|
||||
skill_dst = _platform_skill_destination(name)
|
||||
vf = skill_dst.parent / ".graphify_version"
|
||||
if skill_dst.exists():
|
||||
vf.write_text(__version__, encoding="utf-8")
|
||||
def _platform_skill_destination(platform_name: str, *, project: bool = False, project_dir: Path | None = None) -> Path:
|
||||
"""Return the skill destination for a platform and scope."""
|
||||
if platform_name == "gemini":
|
||||
@@ -679,12 +668,8 @@ def install(platform: str = "claude", *, project: bool = False, project_dir: Pat
|
||||
if platform == "opencode":
|
||||
_install_opencode_plugin(project_dir if project else Path("."))
|
||||
|
||||
# Refresh version stamps in all other previously-installed skill dirs so
|
||||
# stale-version warnings don't fire for platforms not explicitly re-installed.
|
||||
if project:
|
||||
_print_project_git_add_hint([_project_scope_root(skill_dst, project_dir)])
|
||||
else:
|
||||
_refresh_all_version_stamps()
|
||||
|
||||
print()
|
||||
print("Done. Open your AI coding assistant and type:")
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
"""Regression test for #2694 (version-stamp half).
|
||||
|
||||
`graphify install --platform X` must only advance `.graphify_version` for the
|
||||
platform whose skill content it actually (re)writes. Previously it also bumped
|
||||
the stamp of every *other* already-installed platform, so a platform whose
|
||||
SKILL.md was left untouched carried a current stamp and its "skill is from
|
||||
graphify A, package is B" staleness warning was suppressed even though the
|
||||
content really was stale.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import graphify.__main__ as mainmod
|
||||
|
||||
# A prior graphify version stamped into an unrelated, not-reinstalled platform.
|
||||
_STALE_STAMP = "0.0.1-old"
|
||||
|
||||
|
||||
def test_install_does_not_bump_other_platforms_stamp(tmp_path, monkeypatch):
|
||||
"""Installing one platform must leave a different, already-installed
|
||||
platform's `.graphify_version` untouched, so its staleness warning stays
|
||||
truthful (#2694)."""
|
||||
home = tmp_path / "home"
|
||||
home.mkdir()
|
||||
monkeypatch.chdir(tmp_path)
|
||||
monkeypatch.setattr(mainmod, "_check_skill_version", lambda _: None)
|
||||
|
||||
with patch("graphify.__main__.Path.home", return_value=home):
|
||||
# Simulate "codex" installed earlier at a stale version: its SKILL.md
|
||||
# content is old, and its stamp reflects that old version.
|
||||
codex_skill = mainmod._platform_skill_destination("codex", project=False)
|
||||
codex_skill.parent.mkdir(parents=True, exist_ok=True)
|
||||
codex_skill.write_text("stale skill body", encoding="utf-8")
|
||||
codex_stamp = codex_skill.parent / ".graphify_version"
|
||||
codex_stamp.write_text(_STALE_STAMP, encoding="utf-8")
|
||||
|
||||
# Upgrade only the claude platform.
|
||||
mainmod.install("claude")
|
||||
|
||||
# The platform we installed is stamped at the current version...
|
||||
claude_skill = mainmod._platform_skill_destination("claude", project=False)
|
||||
assert (claude_skill.parent / ".graphify_version").read_text() == mainmod.__version__
|
||||
|
||||
# ...but the untouched codex platform keeps its stale stamp, so its
|
||||
# refresh warning still fires.
|
||||
assert codex_stamp.read_text() == _STALE_STAMP, (
|
||||
"installing claude must not advance codex's version stamp (#2694)"
|
||||
)
|
||||
Reference in New Issue
Block a user