mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-18 18:04:26 +00:00
* feat: runtime skill discovery — REST API, MCP server, cache, ranking, Python client (#42) Add runtime skill discovery capabilities enabling agents to autonomously search and retrieve skills on demand, inspired by skyll.app's approach of making skills queryable by intent rather than requiring pre-installation. Core infrastructure: - Pluggable cache backend with LRU + TTL (MemoryCache) - Multi-signal relevance ranker (content 40pts, query 30pts, popularity 15pts, refs 15pts) - Enhanced SKILL.md parser with frontmatter extraction and reference discovery - Runtime skill injector fetching SKILL.md from GitHub with caching REST API server (@skillkit/api): - Hono-based HTTP server on port 3737 - GET/POST /search with ranked results and filters - GET /skills/:source/:id, /trending, /categories, /health, /cache/stats - Sliding-window rate limiting (60 req/min/IP) MCP server (@skillkit/mcp): - 4 tools: search_skills, get_skill, recommend_skills, list_categories - 2 resources: skills://trending, skills://categories - Compatible with Claude Desktop, Cursor, any MCP client CLI serve command: - `skillkit serve` starts the API server - Options: --port, --host, --cors, --cache-ttl Community registry: - registry/SKILLS.md with 26 curated skills across 12 categories - CommunityRegistry class integrated into FederatedSearch Python client (skillkit-client): - Async httpx + pydantic client for the REST API - search, get_skill, trending, categories, cache_stats, health All 856+ tests pass across 24 workspace tasks. * fix: resolve TypeScript errors in API package Add explicit return type to rate limiter middleware and remove stale CategoryCount type annotation in categories route. * fix: address CodeRabbit review findings and version-check CI - Fix version-check: bump docs packages to 1.11.0 - Parse first IP from X-Forwarded-For header in rate limiter - Add try/catch for malformed JSON in POST /search - Use exact source match in skill routes (owner/repo/id pattern) - Fix NaN fallback for invalid limit params in trending/search - Filter empty strings from query words in relevance ranker - Use Map lookups instead of O(n^2) find in MCP resources/tools - URL-encode path params in Python client - Fix -h flag conflict with Clipanion help in serve command - Fix typo: remoti-dev -> remotion-dev in registry SKILLS.md * fix: address Devin review — composite key lookups and Python URL path - Use source+name composite key Map lookups in search GET/POST routes - Use source+name composite key Map lookup in trending route - Fix Python client get_skill to use /skills/:owner/:repo/:id URL pattern - Update Python test to match new 3-segment skill URL
100 lines
2.8 KiB
Python
100 lines
2.8 KiB
Python
import pytest
|
|
import httpx
|
|
import respx
|
|
|
|
from skillkit import SkillKitClient
|
|
|
|
|
|
BASE_URL = "http://localhost:3737"
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_api():
|
|
with respx.mock(base_url=BASE_URL) as respx_mock:
|
|
yield respx_mock
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_health(mock_api):
|
|
mock_api.get("/health").respond(
|
|
json={"status": "ok", "version": "1.11.0", "skillCount": 100, "uptime": 60}
|
|
)
|
|
async with SkillKitClient(BASE_URL) as client:
|
|
health = await client.health()
|
|
assert health.status == "ok"
|
|
assert health.version == "1.11.0"
|
|
assert health.skill_count == 100
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_search(mock_api):
|
|
mock_api.get("/search").respond(
|
|
json={
|
|
"skills": [{"name": "react-perf", "source": "owner/repo"}],
|
|
"total": 1,
|
|
"query": "react",
|
|
"limit": 20,
|
|
}
|
|
)
|
|
async with SkillKitClient(BASE_URL) as client:
|
|
result = await client.search("react")
|
|
assert result.total == 1
|
|
assert result.skills[0].name == "react-perf"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_search_with_filters(mock_api):
|
|
mock_api.post("/search").respond(
|
|
json={
|
|
"skills": [{"name": "nextjs-auth", "source": "other/repo"}],
|
|
"total": 1,
|
|
"query": "auth",
|
|
"limit": 20,
|
|
}
|
|
)
|
|
async with SkillKitClient(BASE_URL) as client:
|
|
result = await client.search_with_filters("auth", tags=["nextjs"])
|
|
assert result.total == 1
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_skill(mock_api):
|
|
mock_api.get("/skills/owner/repo/react-perf").respond(
|
|
json={"name": "react-perf", "description": "React performance", "source": "owner/repo"}
|
|
)
|
|
async with SkillKitClient(BASE_URL) as client:
|
|
skill = await client.get_skill("owner/repo", "react-perf")
|
|
assert skill.name == "react-perf"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_trending(mock_api):
|
|
mock_api.get("/trending").respond(
|
|
json={"skills": [{"name": "a", "source": "x/y"}], "limit": 20}
|
|
)
|
|
async with SkillKitClient(BASE_URL) as client:
|
|
trending = await client.trending()
|
|
assert len(trending) == 1
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_categories(mock_api):
|
|
mock_api.get("/categories").respond(
|
|
json={"categories": [{"name": "react", "count": 5}], "total": 1}
|
|
)
|
|
async with SkillKitClient(BASE_URL) as client:
|
|
cats = await client.categories()
|
|
assert len(cats) == 1
|
|
assert cats[0].name == "react"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_cache_stats(mock_api):
|
|
mock_api.get("/cache/stats").respond(
|
|
json={"hits": 10, "misses": 5, "size": 8, "maxSize": 500, "hitRate": 0.667}
|
|
)
|
|
async with SkillKitClient(BASE_URL) as client:
|
|
stats = await client.cache_stats()
|
|
assert stats.hits == 10
|
|
assert stats.size == 8
|