Files
Agentic-OS/backend/tests/test_skill_registry.py
nearxos 0375b20bb4 Enhance MCP development features and introduce skills management
- Added configuration options for requiring human approval before applying LLM-generated MCP patches.
- Updated Docker setup to include skills directory.
- Integrated skills management into the backend, allowing for procedural guides and skill matching.
- Refactored database initialization to apply Alembic migrations.
- Enhanced task approval process to handle MCP patch applications with optional approval.
- Introduced new schemas for skills and updated existing APIs to support skills functionality.

This commit lays the groundwork for improved agent capabilities and better management of MCP development processes.
2026-06-14 22:27:24 +03:00

61 lines
1.7 KiB
Python

"""Tests for agent skill registry."""
from __future__ import annotations
import os
from pathlib import Path
os.environ.setdefault("SECRET_KEY", "test-secret-key-for-unit-tests-only")
_test_dir = Path(__file__).resolve().parent
_backend_root = _test_dir.parent
_skills_dir = _backend_root.parent / "skills"
if not _skills_dir.is_dir():
_skills_dir = _backend_root / "skills"
os.environ["SKILLS_PATH"] = str(_skills_dir)
from app.services.skill_registry import ( # noqa: E402
invalidate_skills_cache,
load_skills,
match_skills,
skill_guidance_block,
)
def test_load_skills_finds_seeded_skills():
invalidate_skills_cache()
skills = load_skills(force=True)
assert "vessel-voip" in skills
assert "vessel-dns-portal" in skills
assert skills["vessel-voip"]["body"]
def test_match_voip_skill_by_keywords():
invalidate_skills_cache()
matched = match_skills("VoIP issue", "one-way audio on SIP calls")
ids = [s.id for s in matched]
assert "vessel-voip" in ids
def test_match_skill_by_rule_id_boost():
invalidate_skills_cache()
matched = match_skills("Mystery", "something vague", matched_rule_id="crew-dns-slow")
ids = [s.id for s in matched]
assert "vessel-dns-portal" in ids
def test_match_respects_max_skills():
invalidate_skills_cache()
matched = match_skills(
"VoIP DNS portal",
"slow dns captive portal sip registration one-way audio",
max_skills=1,
)
assert len(matched) == 1
def test_skill_guidance_block_includes_body():
invalidate_skills_cache()
matched = match_skills("VoIP", "one-way audio rtp")
block = skill_guidance_block(matched)
assert "Agent skills" in block
assert "One-way audio playbook" in block