Repository navigation
fix(skills): use full YAML parser for frontmatter to support block scalars #4870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1fcaa50
fix(skills): use full YAML parser for frontmatter to support block sc…
yiliang114 6ddda28
fix(skills): address review feedback — explicit dep, null guard, shar…
yiliang114 fab586e
chore: make parseSimple private, remove stale yaml-dep comment
yiliang114 1b307d0
test: add comprehensive edge-case tests, use YAML 1.2 core schema
yiliang114 3d9e270
fix: use loose null check for optional frontmatter fields
yiliang114 1a734c1
refactor: normalize null values in yaml parser instead of caller-side…
yiliang114 9cdc128
fix(yaml-parser): address review round 2 — security hardening and dedup
yiliang114 bad7f19
fix(yaml-parser): apply stripNullValues to parseSimple fallback path
yiliang114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
116 changes: 116 additions & 0 deletions
116
packages/core/src/skills/skill-load.real-parser.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
| import { parseSkillContent } from './skill-load.js'; | ||
|
|
||
| describe('parseSkillContent with real YAML parser', () => { | ||
| const testPath = '/test/extension/skills/test-skill/SKILL.md'; | ||
|
|
||
| it('parses folded block scalar descriptions (>)', () => { | ||
| const markdown = `--- | ||
| name: test-skill | ||
| description: > | ||
| This is a folded | ||
| multiline description. | ||
| --- | ||
|
|
||
| Body. | ||
| `; | ||
| const config = parseSkillContent(markdown, testPath); | ||
| expect(config.name).toBe('test-skill'); | ||
| expect(config.description).toBe( | ||
| 'This is a folded multiline description.\n', | ||
| ); | ||
| }); | ||
|
|
||
| it('parses literal block scalar descriptions (|)', () => { | ||
| const markdown = `--- | ||
| name: test-skill | ||
| description: | | ||
| Line one. | ||
| Line two. | ||
| --- | ||
| Body. | ||
| `; | ||
| const config = parseSkillContent(markdown, testPath); | ||
| expect(config.description).toBe('Line one.\nLine two.\n'); | ||
| }); | ||
|
|
||
| it('parses strip-chomped folded block scalar (>-)', () => { | ||
| const markdown = `--- | ||
| name: test-skill | ||
| description: >- | ||
| No trailing newline. | ||
| --- | ||
| Body. | ||
| `; | ||
| const config = parseSkillContent(markdown, testPath); | ||
| expect(config.description).toBe('No trailing newline.'); | ||
| }); | ||
|
|
||
| it('does not coerce date-like values to Date objects', () => { | ||
| const markdown = `--- | ||
| name: test-skill | ||
| description: A skill created on 2024-01-01 | ||
| --- | ||
| Body. | ||
| `; | ||
| const config = parseSkillContent(markdown, testPath); | ||
| expect(typeof config.description).toBe('string'); | ||
| }); | ||
|
|
||
| it('handles allowedTools array correctly', () => { | ||
| const markdown = `--- | ||
| name: test-skill | ||
| description: A test skill | ||
| allowedTools: | ||
| - read_file | ||
| - write_file | ||
| --- | ||
| Body. | ||
| `; | ||
| const config = parseSkillContent(markdown, testPath); | ||
| expect(config.allowedTools).toEqual(['read_file', 'write_file']); | ||
| }); | ||
|
|
||
| it('handles complex frontmatter with mixed field types', () => { | ||
| const markdown = `--- | ||
| name: test-skill | ||
| description: > | ||
| Manage the full lifecycle of | ||
| cloud resources. | ||
| allowedTools: | ||
| - read_file | ||
| - write_file | ||
| model: qwen-max | ||
| argument-hint: "[resource-type]" | ||
| priority: 10 | ||
| disable-model-invocation: true | ||
| --- | ||
| Body content here. | ||
| `; | ||
| const config = parseSkillContent(markdown, testPath); | ||
| expect(config.name).toBe('test-skill'); | ||
| expect(config.description).toContain('Manage the full lifecycle'); | ||
| expect(config.allowedTools).toEqual(['read_file', 'write_file']); | ||
| expect(config.model).toBe('qwen-max'); | ||
| expect(config.argumentHint).toBe('[resource-type]'); | ||
| expect(config.priority).toBe(10); | ||
| expect(config.disableModelInvocation).toBe(true); | ||
| }); | ||
|
|
||
| it('falls back gracefully for malformed YAML', () => { | ||
| const markdown = `--- | ||
| name: test-skill | ||
| description: value with unmatched "quote | ||
| --- | ||
| Body. | ||
| `; | ||
| const config = parseSkillContent(markdown, testPath); | ||
| expect(config.name).toBe('test-skill'); | ||
| }); | ||
| }); |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.