fix(presets): restore core skills instead of deleting them on preset remove - #3929
Open
chelsealong wants to merge 1 commit into
Open
fix(presets): restore core skills instead of deleting them on preset remove#3929chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
…remove Skill restoration looked for core command templates under .specify/templates/commands, a directory specify init never populates in real projects. Since that lookup always missed, presets overriding a core command (e.g. speckit.plan) had their skill deleted outright on removal instead of restored — the actual core templates live in the bundled core_pack (wheel install) or the repo-root templates/ tree. Restoration now falls back to that bundled location, gated behind a restore_from_bundled_core flag so the existing "retire a stale skill superseded by a command-mode winner" path keeps deleting rather than resurrecting a duplicate skill. Fixes github#3928
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3928
Bug
When a preset that overrides core commands/skills is removed, the corresponding
core skills are deleted instead of being restored — the only way to get them
back is to re-scaffold with
specify init.Root cause
PresetManager._unregister_skills_in_dirlooks for the original core commandtemplate at
self.project_root / ".specify" / "templates" / "commands". Thatdirectory is never populated by
specify initin a real project — the actualcore command templates live in the bundled
core_pack/commands/directory(wheel install) or the repo-root
templates/commands/tree (source checkout),exactly like
PresetResolver.resolve_core()already falls back to via_locate_core_pack()/_repo_root().Because the lookup always missed, every preset-removal restoration fell
through to the "no core template found" branch and deleted the skill outright.
Fix
Restoration now falls back to the bundled core_pack/repo-root templates when
the project-local override directory doesn't have the file. This fallback is
gated behind a new
restore_from_bundled_coreflag so the pre-existing "retirea stale skill because its command now renders as a command file elsewhere"
path (triggered by
ai_skillsmode toggles) keeps its original deletebehavior — it must not resurrect a duplicate skill that a command file has
already superseded.
Repro (before the fix)
After the fix, all 10 skills are present again, restored with core content
after
specify preset remove lean.Testing
Added
test_skill_restored_on_preset_remove_without_project_core_templates,which (unlike the existing
test_skill_restored_on_preset_remove) does notpre-seed
.specify/templates/commandswith a fake core file, matching what areal
specify initproject looks like. Confirmed it fails without the fix(
AssertionError: Core skill must be restored, not deleted) viagit checkout HEAD~1 -- src/specify_cli/presets/__init__.py, then passes withthe fix restored.
AI disclosure
This PR was authored primarily by an AI coding agent (Claude Code): it
diagnosed the root cause, implemented the fix, and wrote/verified the
regression test. I reviewed the diff and test output before submitting.