doc first implementation
This commit is contained in:
@@ -1,90 +1,14 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastmcp import FastMCP
|
||||
|
||||
from personal_mcp.skills.document_loader import load_skill_document
|
||||
|
||||
pytest_scaffolding_server = FastMCP("pytest-scaffolding")
|
||||
|
||||
_REFERENCE_PATH = (
|
||||
Path(__file__).resolve().parents[4]
|
||||
/ "skills"
|
||||
/ "pytest-scaffolding"
|
||||
/ "references"
|
||||
/ "pytest-docs.md"
|
||||
)
|
||||
|
||||
|
||||
def _load_reference_text() -> str:
|
||||
return _REFERENCE_PATH.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/overview")
|
||||
def pytest_overview() -> dict:
|
||||
"""Return the high-level intent and boundaries of this pattern module."""
|
||||
return {
|
||||
"id": "pytest-scaffolding",
|
||||
"intent": "Design maintainable pytest structure before deep test implementation.",
|
||||
"focus": [
|
||||
"hierarchical test layout",
|
||||
"dependency-aware fixture boundaries",
|
||||
"fast local feedback loops",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/rules")
|
||||
def pytest_rules() -> dict:
|
||||
"""Return method rules to keep test architecture consistent."""
|
||||
return {
|
||||
"rules": [
|
||||
"Mirror major source package boundaries under tests/.",
|
||||
"Use explicit markers for integration, smoke, and external tests.",
|
||||
"Keep global fixtures lightweight; place expensive fixtures in subtree conftest files.",
|
||||
"Prefer deterministic unit tests and isolate slow or external dependencies.",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/checklist")
|
||||
def pytest_checklist() -> dict:
|
||||
"""Return an execution checklist for first-pass test scaffolding."""
|
||||
return {
|
||||
"checklist": [
|
||||
"Map source modules to initial test modules.",
|
||||
"Classify each module as unit, integration, or smoke.",
|
||||
"Create baseline fixtures in tests/conftest.py.",
|
||||
"Register markers in pyproject.toml.",
|
||||
"Validate collection and run fast path first.",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/references")
|
||||
def pytest_references() -> dict:
|
||||
"""Return canonical reference material for this pattern module."""
|
||||
return {
|
||||
"source": str(_REFERENCE_PATH),
|
||||
"format": "markdown",
|
||||
"content": _load_reference_text(),
|
||||
}
|
||||
|
||||
|
||||
@pytest_scaffolding_server.prompt()
|
||||
def scaffold_pytest_prompt(target_scope: str = "src/") -> str:
|
||||
"""Prompt template for planning pytest scaffolding for a target scope."""
|
||||
return (
|
||||
"Create a minimal pytest scaffold plan. "
|
||||
f"Target scope: {target_scope}. "
|
||||
"Return directory mapping, marker suggestions, and the first three tests to write."
|
||||
)
|
||||
|
||||
|
||||
@pytest_scaffolding_server.tool()
|
||||
def propose_pytest_mvp_tree(target_scope: str = "src/") -> str:
|
||||
"""Return a minimal test scaffold plan for a target scope."""
|
||||
return (
|
||||
f"MVP pytest scaffold for {target_scope}:\n"
|
||||
"1. Mirror the source subtree under tests/.\n"
|
||||
"2. Add one happy-path test and one edge-case test per core module.\n"
|
||||
"3. Keep fast tests isolated from integration/external dependencies.\n"
|
||||
"4. Use uv run pytest as the canonical runner."
|
||||
@pytest_scaffolding_server.resource("resource://skills/pytest-scaffolding/document")
|
||||
def skill_document() -> dict[str, str]:
|
||||
"""Return the canonical Markdown document for this skill."""
|
||||
return load_skill_document(
|
||||
skill_id="pytest-scaffolding",
|
||||
skill_slug="pytest-scaffolding",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user