feat: add deterministic MCP context CLI#199
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces several new 'Skill' documentation files to define workflows for artifact validation, documentation positioning, Git PR management, and MCP context layer development. Additionally, it adds a new CLI tool in scripts/mcp_context_cli.py for generating deterministic MCP context-layer outputs, along with updated documentation and new tests. Feedback was provided to enhance the CLI's error handling by explicitly catching JSON decoding errors and utilizing repository-relative paths in error messages.
| def _load_json(path: Path) -> dict[str, Any]: | ||
| try: | ||
| payload = json.loads(path.read_text(encoding="utf-8")) | ||
| except FileNotFoundError as exc: | ||
| raise RuntimeError(f"missing required fixture file: {path.as_posix()}") from exc | ||
| if not isinstance(payload, dict): | ||
| raise RuntimeError(f"fixture file must contain a JSON object: {path.as_posix()}") | ||
| return payload |
There was a problem hiding this comment.
The _load_json function should handle json.JSONDecodeError and use repo-relative paths in error messages to align with the repository's general rules for JSON processing.
| def _load_json(path: Path) -> dict[str, Any]: | |
| try: | |
| payload = json.loads(path.read_text(encoding="utf-8")) | |
| except FileNotFoundError as exc: | |
| raise RuntimeError(f"missing required fixture file: {path.as_posix()}") from exc | |
| if not isinstance(payload, dict): | |
| raise RuntimeError(f"fixture file must contain a JSON object: {path.as_posix()}") | |
| return payload | |
| def _load_json(path: Path) -> dict[str, Any]: | |
| rel_path = _repo_relative(path) | |
| try: | |
| payload = json.loads(path.read_text(encoding="utf-8")) | |
| except FileNotFoundError as exc: | |
| raise RuntimeError(f"missing required fixture file: {rel_path}") from exc | |
| except json.JSONDecodeError as exc: | |
| raise RuntimeError(f"failed to decode JSON in fixture file: {rel_path}") from exc | |
| if not isinstance(payload, dict): | |
| raise RuntimeError(f"fixture file must contain a JSON object: {rel_path}") | |
| return payload |
References
- JSON loading should handle both FileNotFoundError and JSONDecodeError by raising a RuntimeError with a repo-relative path, and validate the payload type.
Summary
Adds a minimal deterministic CLI/tool entrypoint for the MCP context layer and repo-local Codex workflow skill docs.
This introduces:
scripts/mcp_context_cli.pydocs/codex_skills/Scope
This is intentionally not:
Validation
python -m compileall -q src/comptext_v7/mcppytest tests/test_mcp_context_layer.py -qNotes
The CLI is the first practical interface layer on top of the deterministic MCP context primitives. It keeps output deterministic, replay-safe, and fixture-bound while enabling local/client usage without adding runtime orchestration.