fix(presets): resolve() honors manifest-declared file: for installed presets
Description
PresetResolver.resolve()'s tier-2 (installed presets) loop is convention-only — it checks <pack>/templates/<name>.md and <pack>/<name>.md, ignoring a preset manifest that declares the template with an explicit file: path:
for subdir in subdirs:
candidate = pack_dir / subdir / f"{template_name}{ext}"
if candidate.exists():
return candidate
So when a preset's preset.yml declares e.g. {type: template, name: spec-template, file: custom/spec.md}, resolve() returns the core template and resolve_with_source() misattributes source='core' — while collect_all_layers() and resolve_content() in the same class correctly honor the declared file. It can also return a stray templates/spec-template.md the manifest deliberately points away from.
Reproduced on main @ bba473c: with a pack declaring file: custom/spec.md, resolve('spec-template') returned the core path, not the pack's.
Fix
Mirror collect_all_layers()'s manifest-first logic in the tier-2 loop: read the manifest, and if it lists the template with a file:, resolve to pack_dir/file when it exists (and skip the convention fallback when it's missing, to avoid masking typos — exactly as collect_all_layers does); only fall back to the convention subdir walk when the manifest is absent or doesn't list the template. resolve_with_source() is fixed for free since it delegates to resolve().
Testing
Two new tests in TestPresetResolver (both fail-before / pass-after, source-stash verified):
test_resolve_uses_manifest_declared_file_path: a pack declaringfile: custom/spec.md→resolve()returns that file,resolve_with_source()['source']names the pack, and it equalscollect_all_layers()[0]['path'];test_resolve_manifest_file_wins_over_undeclared_convention_file: an undeclaredtemplates/spec-template.mdin the pack does not shadow the manifest'sfile:.
Full tests/test_presets.py: 328 passed (no regressions — convention-following presets unaffected). uvx ruff check clean.
AI Disclosure
- [x] I did use AI assistance (describe below)
Found and fixed with Claude Code (Claude Fable 5) under my direction. AI identified the tier-2 convention-only divergence from collect_all_layers; I reproduced the wrong resolution, mirrored the authoritative logic, verified fail-before/pass-after and the full suite, and reviewed the diff.
Please address Copilot feedback
Please address Copilot feedback. And address test & lint errors
Thank you!