Skip to content

fix(presets): use _repo_root() for bundled-core source-checkout fallback (#3086)#9

Closed
mnriem wants to merge 1 commit into
mainfrom
mnriem-fix-3086-bundled-core-fallback-repo-root
Closed

fix(presets): use _repo_root() for bundled-core source-checkout fallback (#3086)#9
mnriem wants to merge 1 commit into
mainfrom
mnriem-fix-3086-bundled-core-fallback-repo-root

Conversation

@mnriem

@mnriem mnriem commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

Assessment and fix for github#3086.

The issue claims specify init not copying templates/commands/ into .specify/templates/commands/ causes wrap-strategy presets to fail. That root cause is incorrect: PresetResolver has an explicit Priority‑5 fallback (_find_bundled_core, plus the matching tier‑5 branch in resolve()) specifically designed to locate the core base layer when .specify/templates/commands/ is absent. The missing copy is a layout/cosmetic gap, not a functional one.

However, while verifying, I found a real bug that does break wrap presets — but only in source/editable installs, and for a different reason:

Both fallbacks computed the repo root as Path(__file__).parent.parent.parent. After presets.py was moved to presets/__init__.py (github#2826), that chain is one level short — it resolves to src/ and looks for src/templates/commands/<cmd>.md, which never exists. So the base layer was never found.

Wheel installs were unaffected because they take the core_pack branch.

Fix

Use the shared _repo_root() helper (from _assets.py) in both resolve() and _find_bundled_core() instead of a hand-rolled .parent chain, so the path stays correct regardless of module nesting.

Tests

  • Added two regression tests asserting the bundled-core fallback resolves speckit.implement via both collect_all_layers() and resolve() when .specify/templates/commands/ has no matching file.
  • Full preset suite (312 tests) passes.

Why not the issue's suggested fix

Copying templates/commands/ into .specify/templates/commands/ during specify init touches the core SDD install/manifest/upgrade flow to solve a non-problem (the fallback already covers wheel installs). This PR keeps the change isolated to the preset resolver and does not alter the SDD process.

Refs github#3086

The tier-5 fallback in PresetResolver.resolve() and
_find_bundled_core() computed the repo root as
Path(__file__).parent.parent.parent. After presets.py was moved to
presets/__init__.py (github#2826) that chain is one level short, resolving
to src/ and looking for src/templates/commands/<cmd>.md, which never
exists. As a result, wrap-strategy presets found no core base layer in
source/editable installs.

Use the shared _repo_root() helper so both fallbacks resolve against
the actual repo-root templates/ tree. Wheel installs were unaffected
(core_pack path), so this only impacts source/editable checkouts.

Refs github#3086

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mnriem

mnriem commented Jun 22, 2026

Copy link
Copy Markdown
Owner Author

Reopening against upstream github/spec-kit:main.

@mnriem mnriem closed this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant