resource pattern

This commit is contained in:
John Lancaster
2026-06-18 19:38:57 -05:00
parent dbaaad8df8
commit d54f427112
11 changed files with 290 additions and 0 deletions
@@ -1,7 +1,82 @@
from pathlib import Path
from fastmcp import FastMCP
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: