feat v0.2.0: phronesis <skill> --uninstall - remove installed skills
- --uninstall [--project] removes the harness target skill directory and drops the matching state entry; --install/--uninstall exclusive - safety guard (SPEC 6.6): the directory must hold a parseable SKILL.md whose front-matter name equals the directory, else refused, exit 2; unbundled (retired) skill names can still be removed by name - SPEC section 6 items 6.6-6.7, section 3 table/3.2, item 8.4 rewritten; README command block; 8 new tests (76 total, all checks green) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
"""CLI tests: list, filter, install, prompt, force, and update (SPEC sections 3, 6, 7)."""
|
||||
import json
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from phronesis import cli
|
||||
from phronesis import harnesses
|
||||
from phronesis import registry
|
||||
from phronesis import state
|
||||
|
||||
|
||||
@@ -213,3 +215,84 @@ def test_installed_json_is_plain_json(config, capsys):
|
||||
assert set(data) == {"skills"}
|
||||
assert set(data["skills"][0]) == {"name", "version", "harness", "scope",
|
||||
"path", "installed"}
|
||||
|
||||
|
||||
# --- uninstall (SPEC items 6.6, 6.7, 8.4)
|
||||
|
||||
|
||||
def test_uninstall_removes_skill_and_state(config, capsys):
|
||||
run(capsys, "python-tdd", "--install")
|
||||
target = config.parent / "home" / ".vibe" / "skills" / "python-tdd"
|
||||
code, out, _ = run(capsys, "python-tdd", "--uninstall")
|
||||
assert code == 0
|
||||
assert "removed python-tdd 1.2.0 (vibe, global)" in out
|
||||
assert not target.exists()
|
||||
assert state.load(state.state_path()) == []
|
||||
|
||||
|
||||
def test_uninstall_project_scoped(config, capsys, tmp_path, monkeypatch):
|
||||
work = tmp_path / "work"
|
||||
work.mkdir()
|
||||
monkeypatch.chdir(work)
|
||||
run(capsys, "python-tdd", "--project")
|
||||
code, _, _ = run(capsys, "python-tdd", "--uninstall", "--project")
|
||||
assert code == 0
|
||||
assert not (work / ".vibe" / "skills" / "python-tdd").exists()
|
||||
assert state.load(state.state_path()) == []
|
||||
|
||||
|
||||
def test_uninstall_needs_the_skill_installed(config, capsys):
|
||||
code, _, err = run(capsys, "python-tdd", "--uninstall")
|
||||
assert code == 2
|
||||
assert "not installed" in err
|
||||
|
||||
|
||||
def test_uninstall_refuses_a_non_skill_directory(config, capsys):
|
||||
target = config.parent / "home" / ".vibe" / "skills" / "not-a-skill"
|
||||
target.mkdir(parents=True)
|
||||
(target / "SKILL.md").write_text("random notes, no front matter",
|
||||
encoding="utf-8")
|
||||
code, _, err = run(capsys, "not-a-skill", "--uninstall")
|
||||
assert code == 2
|
||||
assert "refusing to remove" in err
|
||||
assert (target / "SKILL.md").is_file()
|
||||
|
||||
|
||||
def test_uninstall_refuses_a_name_mismatch(config, capsys):
|
||||
skill_md_run = run(capsys, "python-tdd", "--install")
|
||||
target_dir = config.parent / "home" / ".vibe" / "skills" / "python-tdd"
|
||||
other = target_dir.parent / "other-name"
|
||||
other.mkdir()
|
||||
shutil.copytree(target_dir, other, dirs_exist_ok=True)
|
||||
code, _, err = run(capsys, "other-name", "--uninstall")
|
||||
assert code == 2
|
||||
assert "does not match the directory" in err
|
||||
assert (other / "SKILL.md").is_file()
|
||||
|
||||
|
||||
def test_uninstall_works_without_a_state_entry(config, capsys):
|
||||
target = config.parent / "home" / ".vibe" / "skills" / "python-tdd"
|
||||
target.mkdir(parents=True)
|
||||
body = registry.SKILLS["python-tdd"].skill_md.read_text(encoding="utf-8")
|
||||
(target / "SKILL.md").write_text(body, encoding="utf-8")
|
||||
code, out, _ = run(capsys, "python-tdd", "--uninstall")
|
||||
assert code == 0
|
||||
assert "removed" in out
|
||||
assert not target.exists()
|
||||
|
||||
|
||||
def test_install_and_uninstall_are_exclusive(config, capsys):
|
||||
code, _, err = run(capsys, "python-tdd", "--install", "--uninstall")
|
||||
assert code == 2
|
||||
assert "pick one of --install or --uninstall" in err
|
||||
|
||||
|
||||
def test_uninstall_of_unbundled_name_is_allowed(config, capsys):
|
||||
target = config.parent / "home" / ".vibe" / "skills" / "retired-skill"
|
||||
target.mkdir(parents=True)
|
||||
(target / "SKILL.md").write_text(
|
||||
"---\nname: retired-skill\nversion: 0.9.0\ndescription: gone\n"
|
||||
"category: misc\n---\n", encoding="utf-8")
|
||||
code, out, _ = run(capsys, "retired-skill", "--uninstall")
|
||||
assert code == 0
|
||||
assert not target.exists()
|
||||
|
||||
Reference in New Issue
Block a user