fix(skills): handle single-line descriptions in SKILL.md frontmatter#28042
fix(skills): handle single-line descriptions in SKILL.md frontmatter#28042saiteja00743 wants to merge 1 commit into
Conversation
Prior to this fix, the skill discovery logic failed to correctly parse SKILL.md frontmatter when the 'description' field was written on a single line (i.e., no trailing newline before the closing '---' marker). This caused affected skills to be silently dropped from the skills registry. Changes: - Updated FRONTMATTER_REGEX to handle UTF-8 BOMs and trailing whitespace on the '---' delimiter lines. - Refactored parseSimpleFrontmatter to be case-insensitive, support optional spaces before colons, and use a negative lookahead to prevent incorrectly splitting descriptions when subsequent lines contain 'name:' or 'description:'. - Added isRecord() type guard to replace an unsafe 'as' type assertion, satisfying @typescript-eslint/no-unsafe-type-assertion. - Added comprehensive regression tests covering: single-line descriptions, UTF-8 BOM presence, trailing spaces after delimiters, case-insensitive keys, and indented description edge cases. Fixes google-gemini#25693
|
📊 PR Size: size/M
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a bug where skills with single-line descriptions in their Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances frontmatter parsing in skillLoader.ts by supporting UTF-8 BOM, trailing spaces, case-insensitive keys, and non-string YAML values. It also adds a safe isRecord type guard and prevents the fallback parser from swallowing subsequent keys. A comprehensive suite of unit tests has been added to verify these improvements. No review comments were provided, so there is no additional feedback.
Summary
Fix skill discovery silently failing when the
descriptionfield inSKILL.mdfrontmatter is written on a single line (i.e., the closing---marker immediately follows the description with no blank line). Affected skills were completely invisible in/skills list.Details
The root cause was two-fold:
FRONTMATTER_REGEXdid not account for UTF-8 BOMs (\uFEFF) at the start of files, or trailing whitespace on---delimiter lines, causing the regex to fail to match valid frontmatter blocks.parseSimpleFrontmatter(the fallback YAML parser) incorrectly split single-line descriptions when subsequent lines containedname:ordescription:. It also was not case-insensitive and required exact colon formatting.Changes to
skillLoader.ts:FRONTMATTER_REGEXto strip UTF-8 BOMs and tolerate trailing spaces/tabs on---lines.parseSimpleFrontmatterto be case-insensitive, support optional spaces before colons, and use a negative lookahead to prevent misidentifying value lines as new keys.as Record<string, unknown>type assertion with a properisRecord()type guard to satisfy@typescript-eslint/no-unsafe-type-assertion.Changes to
skillLoader.test.ts:Related Issues
Fixes #25693
How to Validate
~/.gemini/skills/my-test-skill/SKILL.mdnpm run build && npm run start/skills listmy-test-skillappears with its descriptionAlternatively, run the unit tests:
npm test -w @google/gemini-cli-core -- src/skills/skillLoader.test.tsAll 21 tests should pass.
Pre-Merge Checklist