feat: support registry collections and docker publishing
This commit is contained in:
@@ -76,6 +76,27 @@ class SelectorTests(unittest.TestCase):
|
||||
with self.assertRaisesRegex(SystemExit, "超出外部仓库"):
|
||||
external_skill_path("unsafe-skill", entry)
|
||||
|
||||
def test_collection_discovery_ignores_symlinked_skill(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
checkout = root / "checkout"
|
||||
collection = checkout / "skills"
|
||||
outside = root / "outside"
|
||||
collection.mkdir(parents=True)
|
||||
outside.mkdir()
|
||||
outside.joinpath("SKILL.md").write_text("---\n", encoding="utf-8")
|
||||
collection.joinpath("escaped").symlink_to(outside, target_is_directory=True)
|
||||
entry = {
|
||||
"repo": "https://example.test/skills.git",
|
||||
"ref": "main",
|
||||
"path": "skills",
|
||||
}
|
||||
|
||||
with patch("skiff.registry.external_checkout_path", return_value=checkout):
|
||||
from skiff.registry import discover_external_skills
|
||||
|
||||
self.assertEqual(discover_external_skills("unsafe", entry), {})
|
||||
|
||||
|
||||
class SelectCommandTests(unittest.TestCase):
|
||||
def test_non_tty_exits_with_add_guidance(self) -> None:
|
||||
@@ -101,6 +122,9 @@ class SelectCommandTests(unittest.TestCase):
|
||||
def test_project_selection_installs_new_and_records_all_selected(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
project = Path(temp)
|
||||
external = project / "external-one"
|
||||
external.mkdir()
|
||||
external.joinpath("SKILL.md").write_text("---\n", encoding="utf-8")
|
||||
args = argparse.Namespace(
|
||||
agents=[["codex"]],
|
||||
global_scope=False,
|
||||
@@ -130,7 +154,14 @@ class SelectCommandTests(unittest.TestCase):
|
||||
}
|
||||
},
|
||||
),
|
||||
patch.object(cli, "_registry_skill_names", return_value=["external-one"]),
|
||||
patch.object(cli, "external_skill_path", return_value=external),
|
||||
patch.object(cli, "_list_fully_installed_names", return_value=["owned-one"]),
|
||||
patch.object(
|
||||
cli,
|
||||
"_is_fully_installed",
|
||||
side_effect=lambda name, expected, project_root, targets: name == "owned-one",
|
||||
),
|
||||
patch.object(
|
||||
cli,
|
||||
"select_skills",
|
||||
@@ -182,6 +213,61 @@ class SelectCommandTests(unittest.TestCase):
|
||||
|
||||
selector.assert_not_called()
|
||||
|
||||
def test_select_expands_registry_collection_choices(self) -> None:
|
||||
args = argparse.Namespace(
|
||||
agents=[["codex"]],
|
||||
global_scope=True,
|
||||
project=None,
|
||||
yes=False,
|
||||
)
|
||||
stdin = Mock()
|
||||
stdout = Mock()
|
||||
stdin.isatty.return_value = True
|
||||
stdout.isatty.return_value = True
|
||||
selected_choices: list[SkillChoice] = []
|
||||
installed: list[tuple[str, str | None]] = []
|
||||
|
||||
def choose(choices: list[SkillChoice]) -> set[str]:
|
||||
selected_choices.extend(choices)
|
||||
return {"waza/think"}
|
||||
|
||||
with (
|
||||
patch.object(cli.sys, "stdin", stdin),
|
||||
patch.object(cli.sys, "stdout", stdout),
|
||||
patch.object(cli, "ensure_skills_home"),
|
||||
patch.object(cli, "list_owned_skills", return_value=[]),
|
||||
patch.object(
|
||||
cli,
|
||||
"load_registry",
|
||||
return_value={
|
||||
"waza": {
|
||||
"repo": "https://example.test/waza.git",
|
||||
"ref": "main",
|
||||
"path": "skills",
|
||||
}
|
||||
},
|
||||
),
|
||||
patch.object(
|
||||
cli,
|
||||
"_registry_skill_names",
|
||||
return_value=["think", "ui"],
|
||||
),
|
||||
patch.object(cli, "_list_fully_installed_names", return_value=[]),
|
||||
patch.object(cli, "_is_fully_installed", return_value=False),
|
||||
patch.object(cli, "select_skills", side_effect=choose),
|
||||
patch.object(
|
||||
cli,
|
||||
"_install_skill",
|
||||
side_effect=lambda name, targets, project_root, **kwargs: installed.append(
|
||||
(name, kwargs.get("source"))
|
||||
),
|
||||
),
|
||||
):
|
||||
cli.cmd_select(args)
|
||||
|
||||
self.assertEqual([choice.name for choice in selected_choices], ["waza/think", "waza/ui"])
|
||||
self.assertEqual(installed, [("think", "registry:waza")])
|
||||
|
||||
def test_install_rolls_back_earlier_target_when_later_target_fails(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
|
||||
Reference in New Issue
Block a user