fix(install): give gemini its own global skill dir on Windows (#2800)
On Windows the gemini user-global skill went to ~/.agents/skills/graphify,
the same path the `agents` platform installs to. The two ship different
SKILL.md files, so installing either one overwrote the other, and
uninstalling either one deleted the other's skill, references/ and stamp.
The Windows branch came from #368 on the belief that Gemini CLI prefers
~/.agents/skills there. Gemini CLI reads both ~/.gemini/skills and the
~/.agents/skills alias on every OS (docs/cli/skills.md), with the alias
winning a name clash, so the branch bought nothing and caused the clash.
gemini now uses ~/.gemini/skills/graphify everywhere.
Because the alias wins, a copy an older Windows gemini install left in
~/.agents/skills would hide the new one. gemini install now prints a note
naming that folder instead of deleting it, since it may be a real
`agents` install.
(cherry picked from commit 037fc62cd9)
This commit is contained in:
1 parent
193c9f36b3
commit
2859f5b9b0
4 files changed
+48
-13
No files matched your search
+15
-2
@@ -208,8 +208,9 @@ def _platform_skill_destination(platform_name: str, *, project: bool = False, pr
|
||||
if platform_name == "gemini":
|
||||
if project:
|
||||
return (project_dir or Path(".")) / ".gemini" / "skills" / "graphify" / "SKILL.md"
|
||||
if platform.system() == "Windows":
|
||||
return Path.home() / ".agents" / "skills" / "graphify" / "SKILL.md"
|
||||
# Gemini CLI reads ~/.gemini/skills on every OS. ~/.agents/skills is the
|
||||
# `agents` platform's destination, and sharing it let each platform
|
||||
# overwrite and uninstall the other's skill (#2800).
|
||||
return Path.home() / ".gemini" / "skills" / "graphify" / "SKILL.md"
|
||||
|
||||
if platform_name == "opencode":
|
||||
@@ -1054,10 +1055,22 @@ def _gemini_hook(project: bool = False) -> dict:
|
||||
"matcher": "read_file|list_directory",
|
||||
"hooks": [{"type": "command", "command": f"{exe} hook-guard gemini"}],
|
||||
}
|
||||
def _warn_shadowing_agents_skill() -> None:
|
||||
"""Gemini CLI prefers ~/.agents/skills over ~/.gemini/skills for a skill of
|
||||
the same name. Before #2800 a Windows gemini install wrote there, so an old
|
||||
copy can hide the one just installed. It may belong to the `agents`
|
||||
platform, so point at it rather than delete it."""
|
||||
shadow = _platform_skill_destination("agents")
|
||||
if shadow.exists():
|
||||
print(f" note: Gemini CLI loads {shadow} ahead of this install. If an older")
|
||||
print(" `graphify install --platform gemini` wrote it, delete that folder;")
|
||||
print(" if you use the `agents` platform, keep it.")
|
||||
def gemini_install(project_dir: Path | None = None, *, project: bool = False) -> None:
|
||||
"""Copy skill file, write GEMINI.md section, and install BeforeTool hook."""
|
||||
project_dir = project_dir or Path(".")
|
||||
skill_dst = _copy_skill_file("gemini", project=project, project_dir=project_dir)
|
||||
if not project:
|
||||
_warn_shadowing_agents_skill()
|
||||
|
||||
target = project_dir / "GEMINI.md"
|
||||
|
||||
|
||||
@@ -606,6 +606,6 @@ import pytest as _pytest_posix
|
||||
|
||||
@_pytest_posix.fixture(autouse=True)
|
||||
def _posix_skill_layout(monkeypatch):
|
||||
"""gemini and hermes install to different directories on Windows; these tests
|
||||
"""hermes installs to a different directory on Windows; these tests
|
||||
assert the POSIX layout, so pin it."""
|
||||
monkeypatch.setattr("platform.system", lambda: "Linux")
|
||||
@@ -156,15 +156,14 @@ def test_the_copilot_dir_shared_with_vscode_is_not_guessed():
|
||||
assert dst.read_text(encoding="utf-8") == OLD_BODY
|
||||
|
||||
|
||||
def test_a_directory_shared_by_two_platforms_is_not_guessed(monkeypatch):
|
||||
"""On Windows gemini and agents both install into ~/.agents/skills (#2800)."""
|
||||
monkeypatch.setattr(mainmod.platform, "system", lambda: "Windows")
|
||||
assert _platform_skill_destination("gemini") == _platform_skill_destination("agents")
|
||||
dst = _stale("agents")
|
||||
|
||||
mainmod._refresh_stale_skills()
|
||||
|
||||
assert _stamp(dst) == OLD
|
||||
@pytest.mark.parametrize("system", ["Linux", "Darwin", "Windows"])
|
||||
def test_gemini_and_agents_own_separate_skill_dirs(monkeypatch, system):
|
||||
"""gemini and agents ship different SKILL.md files, so one shared dir let
|
||||
each overwrite and uninstall the other's skill on Windows (#2800)."""
|
||||
monkeypatch.setattr(mainmod.platform, "system", lambda: system)
|
||||
gemini = _platform_skill_destination("gemini")
|
||||
assert gemini == Path.home() / ".gemini" / "skills" / "graphify" / "SKILL.md"
|
||||
assert gemini.parent != _platform_skill_destination("agents").parent
|
||||
|
||||
|
||||
def test_a_directory_shared_through_a_symlink_is_not_guessed(requires_symlinks):
|
||||
|
||||
@@ -118,6 +118,29 @@ import pytest as _pytest_posix
|
||||
|
||||
@_pytest_posix.fixture(autouse=True)
|
||||
def _posix_skill_layout(monkeypatch):
|
||||
"""gemini and hermes install to different directories on Windows; these tests
|
||||
"""hermes installs to a different directory on Windows; these tests
|
||||
assert the POSIX layout, so pin it."""
|
||||
monkeypatch.setattr("platform.system", lambda: "Linux")
|
||||
|
||||
|
||||
def test_windows_gemini_install_and_uninstall_leave_the_agents_skill(tmp_path, monkeypatch, capsys):
|
||||
"""On Windows gemini used to install into ~/.agents/skills, the `agents`
|
||||
platform's dir, so a gemini uninstall deleted the agents skill (#2800)."""
|
||||
from graphify.install import gemini_install
|
||||
|
||||
monkeypatch.setattr("platform.system", lambda: "Windows")
|
||||
agents_tree = _plant_skill_tree(Path.home(), ".agents")
|
||||
proj_dir = tmp_path / "proj"
|
||||
proj_dir.mkdir()
|
||||
monkeypatch.chdir(proj_dir)
|
||||
|
||||
gemini_install(proj_dir)
|
||||
assert (Path.home() / ".gemini" / "skills" / "graphify" / "SKILL.md").exists()
|
||||
assert (agents_tree / "SKILL.md").read_text(encoding="utf-8") == "# graphify skill\n"
|
||||
assert "loads" in capsys.readouterr().out # the ~/.agents copy shadows this install
|
||||
|
||||
gemini_uninstall()
|
||||
assert not (Path.home() / ".gemini" / "skills" / "graphify").exists()
|
||||
assert (agents_tree / "SKILL.md").exists()
|
||||
assert (agents_tree / "references" / "x.md").exists()
|
||||
assert (agents_tree / ".graphify_version").exists()
|
||||
Reference in new issue
Block a user