mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-07 21:08:34 +03:00
feat(webui): add skills marketplace
This commit is contained in:
@@ -388,6 +388,35 @@ class TestBuildMessages:
|
||||
assert "user-only runtime context" not in messages[-1]["content"]
|
||||
assert "_meta" not in messages[-1]
|
||||
|
||||
def test_explicit_skill_reference_loads_full_instructions_for_this_turn(self, tmp_path):
|
||||
skill_dir = tmp_path / "skills" / "review"
|
||||
skill_dir.mkdir(parents=True)
|
||||
(skill_dir / "SKILL.md").write_text(
|
||||
"---\n"
|
||||
"name: review\n"
|
||||
"description: Review changes.\n"
|
||||
"---\n\n"
|
||||
"# Review workflow\n\nFollow the unique review checklist.",
|
||||
encoding="utf-8",
|
||||
)
|
||||
builder = _builder(tmp_path)
|
||||
|
||||
messages = builder.build_messages([], "Please $review this patch and use $review carefully.")
|
||||
|
||||
system_prompt = messages[0]["content"]
|
||||
assert "# Active Skills" in system_prompt
|
||||
assert "### Skill: review" in system_prompt
|
||||
assert "Follow the unique review checklist." in system_prompt
|
||||
assert system_prompt.count("### Skill: review") == 1
|
||||
assert messages[-1]["content"] == (
|
||||
"Please $review this patch and use $review carefully."
|
||||
)
|
||||
|
||||
def test_unknown_skill_reference_does_not_change_active_skills(self, tmp_path):
|
||||
messages = _builder(tmp_path).build_messages([], "Keep the shell literal $HOME.")
|
||||
|
||||
assert "# Active Skills" not in messages[0]["content"]
|
||||
|
||||
def test_runtime_context_is_not_injected_by_default(self, tmp_path):
|
||||
builder = _builder(tmp_path)
|
||||
messages = builder.build_messages([], "hello", channel="cli")
|
||||
|
||||
@@ -351,6 +351,37 @@ def test_disabled_skills_excluded_from_get_always_skills(tmp_path: Path) -> None
|
||||
assert "beta" in always
|
||||
|
||||
|
||||
def test_explicit_skill_references_resolve_available_enabled_names_in_order(
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
workspace = tmp_path / "ws"
|
||||
skills_root = workspace / "skills"
|
||||
skills_root.mkdir(parents=True)
|
||||
_write_skill(skills_root, "alpha", body="# Alpha")
|
||||
_write_skill(skills_root, "beta", body="# Beta")
|
||||
_write_skill(
|
||||
skills_root,
|
||||
"blocked",
|
||||
metadata_json={"requires": {"env": ["MISSING_SKILL_TEST_ENV"]}},
|
||||
body="# Blocked",
|
||||
)
|
||||
builtin = tmp_path / "builtin"
|
||||
builtin.mkdir()
|
||||
monkeypatch.delenv("MISSING_SKILL_TEST_ENV", raising=False)
|
||||
loader = SkillsLoader(
|
||||
workspace,
|
||||
builtin_skills_dir=builtin,
|
||||
disabled_skills={"beta"},
|
||||
)
|
||||
|
||||
invoked = loader.get_explicitly_invoked_skills(
|
||||
"Use $alpha, then $unknown, $alpha again, $beta, and $blocked."
|
||||
)
|
||||
|
||||
assert invoked == ["alpha"]
|
||||
|
||||
|
||||
# -- multiline description tests (YAML folded > and literal |) -----------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user