fix: use importlib.resources for template access (#17)#21
Conversation
Fixes Issue #17 where agentspaces fails to find templates when run from a different directory. Changes: - Move templates/ into src/agentspaces/templates/ as package data - Add resources.py module using importlib.resources for access - Update design.py and skills.py to use new resources module - Configure pyproject.toml to include template files in wheel - Add comprehensive tests for resources module (100% coverage) - Update CLAUDE.md to reflect new template location
Fixes TC003 ruff violations by moving Path imports that are only used in type annotations into TYPE_CHECKING blocks. This avoids unnecessary runtime imports.
Pull Request Review: fix: use importlib.resources for template access (#17)SummaryThis PR successfully fixes Issue #17 by migrating from fragile ✅ Strengths1. Correct Solution Architecture
2. Code Quality
3. Test Coverage
4. Documentation
|
Summary
Fixes Issue #17 where agentspaces fails to find templates when run from a different directory.
The root cause was that
design.pyandskills.pyusedPath(__file__).parent.parent.parent.parentto locate templates, which only works when running from source but fails when the package is installed.Changes
templates/intosrc/agentspaces/templates/as package dataresources.pymodule usingimportlib.resourcesfor package resource accessdesign.pyandskills.pyto use new resources modulepyproject.tomlto include template files in wheelCLAUDE.mdto reflect new template locationTest plan
resources.pyhas 100% test coverageagentspaces docs listworks correctly