fix(skills): toggling disable-model-invocation on an explicit false value corrupts SKILL.md - #519
Open
hobostay wants to merge 1 commit into
Open
Conversation
The disable-model-invocation toggle detected the frontmatter key with Boolean(frontmatter[key]), so a skill that explicitly declared disable-model-invocation: false was treated as having no key. Disabling it prepended a second disable-model-invocation: true line, and the yaml parser rejects duplicate keys outright — after that one click the file no longer parsed, the skill loader dropped the skill entirely, and the PATCH route itself 500ed, so the damage could not be undone from the UI. Detect the key by presence and update the existing line in place, keep the edit inside the frontmatter block so body lines documenting the key are untouched, and drop the removed line together with its newline. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Problem
PATCH /api/skillsdecides whether thedisable-model-invocationkey already exists withBoolean(frontmatter[key])(app/api/skills/route.ts). A SKILL.md that explicitly declares the key as false:is treated as having no key at all. Clicking "disable model invocation" in the UI then prepends a second
disable-model-invocation: trueline, and things go from bad to worse:yamlparser rejects duplicate keys outright (Map keys must be unique), soparseFrontmatternow throws for the whole file.skill: null— the skill disappears from the agent's skill list (and from the skills panel) after a single UI click.parseFrontmatterbefore editing, so every further toggle attempt on that file returns 500 — the corruption cannot be undone from the UI, only by hand-editing the file.Repro:
Fix
lib/skill-frontmatter.ts(setDisableModelInvocation) with unit tests, and detect the key by presence (hasOwnProperty) instead of truthiness, updating the existing line in place.Tests:
node --experimental-strip-types --test lib/skill-frontmatter.test.mjs(8 cases, including the explicit-falseregression and duplicate-key guards). Full suite 595/595,tsc --noEmitandeslintclean.🤖 Generated with Claude Code