-
Notifications
You must be signed in to change notification settings - Fork 11
fix(validate): catch unquoted YAML frontmatter that runtime drops (reworks #30) #33
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9b4017a
fix(validate): reject unquoted frontmatter values containing ': '
antongulin a5b69ff
fix(pr-feedback): guard single-char quoted values, add block-scalar a…
antongulin 3e39568
fix(pr-feedback): support block scalar indentation indicators in mark…
antongulin 2e22bec
fix(pr-feedback): also reject unquoted values ending with ':'
antongulin 7638c4d
fix(pr-feedback): treat colon-tab as mapping separator; tighten test …
antongulin 9c2c969
fix(pr-feedback): report file line numbers (not frontmatter-relative)…
antongulin 21c316c
Merge branch 'main' into fix/validate-unquoted-yaml
antongulin 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
There are no files selected for viewing
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "entrypoint": "skill-creator.ts", | ||
| "runtimeEntrypoint": "runtime-entry.ts", | ||
| "sourceHash": "7e988b2130537db9015790ba36e227f7b8a5844bc1200ae7ffeab250cc201368", | ||
| "builtAt": "2026-07-05T23:03:33.548Z" | ||
| "sourceHash": "7ab254f2c22233b0ced8cc832878baacd73f3bd63fa45c81019e9149bf319605", | ||
| "builtAt": "2026-07-05T23:29:06.331Z" | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "fs" | ||
| import { tmpdir } from "os" | ||
| import { join } from "path" | ||
|
|
||
| import { expect, test } from "bun:test" | ||
|
|
||
| import { validateSkill } from "../lib/validate" | ||
|
|
||
| const withSkill = <T>(frontmatter: string, fn: (skillPath: string) => T): T => { | ||
| const dir = mkdtempSync(join(tmpdir(), "skill-creator-validate-")) | ||
| try { | ||
| mkdirSync(dir, { recursive: true }) | ||
| writeFileSync(join(dir, "SKILL.md"), `---\n${frontmatter}\n---\n\n# Test Skill\n`) | ||
| return fn(dir) | ||
| } finally { | ||
| rmSync(dir, { recursive: true, force: true }) | ||
| } | ||
| } | ||
|
|
||
| test("quoted description containing colon-space passes", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: "Use for PDF files: reading, extracting."`, | ||
| (skillPath) => { | ||
| expect(validateSkill(skillPath)).toEqual({ | ||
| valid: true, | ||
| message: "Skill is valid!", | ||
| }) | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("unquoted description without colon-space passes", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: Use for PDF files, reading and extracting.`, | ||
| (skillPath) => { | ||
| expect(validateSkill(skillPath)).toEqual({ | ||
| valid: true, | ||
| message: "Skill is valid!", | ||
| }) | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("bundled skill fixture passes validation", () => { | ||
|
antongulin marked this conversation as resolved.
|
||
| expect(validateSkill(join(import.meta.dir, "..", "skill"))).toEqual({ | ||
| valid: true, | ||
| message: "Skill is valid!", | ||
| }) | ||
| }) | ||
|
|
||
| test("unquoted description with colon-space fails with quote hint", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: Use for PDF files: reading, extracting.`, | ||
| (skillPath) => { | ||
| const result = validateSkill(skillPath) | ||
|
|
||
| expect(result.valid).toBe(false) | ||
| expect(result.message).toContain("description") | ||
| expect(result.message).toContain("line 3") | ||
| expect(result.message).toContain("Hint: quote the value") | ||
| expect(result.message).toContain("description: \"your text here\"") | ||
| expect(result.message).toContain( | ||
| "unquoted values containing ': ' or ending with ':' are invalid YAML", | ||
| ) | ||
| expect(result.message).toContain("runtime will drop this skill") | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("single-quoted description containing colon-space passes", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: 'Use for PDF files: reading, extracting.'`, | ||
| (skillPath) => { | ||
| expect(validateSkill(skillPath)).toEqual({ | ||
| valid: true, | ||
| message: "Skill is valid!", | ||
| }) | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("block scalar content with colon-space passes", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: |2- | ||
| Use for PDF files: reading, extracting.`, | ||
| (skillPath) => { | ||
| expect(validateSkill(skillPath)).toEqual({ | ||
| valid: true, | ||
| message: "Skill is valid!", | ||
| }) | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("unquoted value with colon-space mid-value fails", () => { | ||
|
antongulin marked this conversation as resolved.
|
||
| withSkill( | ||
| `name: pdf-reader | ||
| description: Use when reading docs. | ||
| compatibility: Works with docs: markdown and PDF`, | ||
| (skillPath) => { | ||
| const result = validateSkill(skillPath) | ||
|
|
||
| expect(result.valid).toBe(false) | ||
| expect(result.message).toContain("compatibility") | ||
| expect(result.message).toContain("line 4") | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("unquoted value ending with colon fails", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: Note:`, | ||
| (skillPath) => { | ||
| const result = validateSkill(skillPath) | ||
|
|
||
| expect(result.valid).toBe(false) | ||
| expect(result.message).toContain("description") | ||
| expect(result.message).toContain("line 3") | ||
| expect(result.message).toContain("Hint: quote the value") | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("unquoted value with trailing colon-space fails after trim (ends-with-colon path)", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: Note: `, | ||
| (skillPath) => { | ||
| const result = validateSkill(skillPath) | ||
|
|
||
| expect(result.valid).toBe(false) | ||
| expect(result.message).toContain("description") | ||
| expect(result.message).toContain("line 3") | ||
| expect(result.message).toContain("Hint: quote the value") | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("unquoted value with colon-tab fails", () => { | ||
| withSkill( | ||
| `name: pdf-reader | ||
| description: Use for PDF files:\treading`, | ||
| (skillPath) => { | ||
| const result = validateSkill(skillPath) | ||
|
|
||
| expect(result.valid).toBe(false) | ||
| expect(result.message).toContain("description") | ||
| expect(result.message).toContain("line 3") | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| test("unquoted name with colon-space fails before name validation", () => { | ||
| withSkill( | ||
| `name: pdf: reader | ||
| description: Use when reading docs.`, | ||
| (skillPath) => { | ||
| const result = validateSkill(skillPath) | ||
|
|
||
| expect(result.valid).toBe(false) | ||
| expect(result.message).toContain("name") | ||
| expect(result.message).toContain("line 2") | ||
| expect(result.message).toContain("Hint: quote the value") | ||
| }, | ||
| ) | ||
| }) | ||
|
antongulin marked this conversation as resolved.
antongulin marked this conversation as resolved.
|
||
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.