* fix(#2876): yamlQuote description in Copilot/Antigravity/Trae/CodeBuddy SKILL.md A description starting with `[BETA]` (or any YAML flow indicator — `{`, `*`, `&`, `!`, `|`, `>`, `%`, `@`, backtick) is parsed as a flow sequence/mapping by YAML 1.2-strict loaders. gh-copilot's frontmatter loader fails closed: ✖ ~/.copilot/skills/gsd-ultraplan-phase/SKILL.md: failed to parse YAML frontmatter: Unexpected scalar at node end at line 2, column 21: description: [BETA] Offload plan phase to Claude Code's ultraplan… Six emission sites in `bin/install.js` re-wrote the description without quoting, while the Claude variant (`convertClaudeCommandToClaudeSkill`) already routed it through `yamlQuote`. Brought all six in line: - convertClaudeCommandToCopilotSkill - convertClaudeAgentToCopilotAgent - convertClaudeCommandToAntigravitySkill - convertClaudeAgentToAntigravityAgent - convertClaudeCommandToTraeSkill - convertClaudeCommandToCodebuddySkill Each now wraps the value in `yamlQuote(...)` so any leading character is parser-safe. Regression test (tests/bug-2876-skill-frontmatter-quote.test.cjs) drives the four command converters and two agent converters through the reporter's exact "[BETA] …" description plus a grab-bag of YAML flow indicators, asserting the emitted `description:` value is a quoted YAML scalar. Also round-trips the value through `JSON.parse` for converters that don't apply runtime-name substitution to confirm fidelity. Updated 7 pre-existing substring assertions in copilot-install.test.cjs and antigravity-install.test.cjs that hard-coded the unquoted form. Round trip: 5893/5893 pass on `npm test`. Closes #2876 * test(#2876): structurally parse frontmatter instead of substring-grep Addresses CodeRabbit's two nitpicks on PR #2881: the pre-existing substring assertions in copilot-install.test.cjs (4 sites) and antigravity-install.test.cjs (3 sites) only got bumped from the unquoted form (`description: Diagnose...`) to the quoted-prefix form (`description: "Diagnose...`). Both are still raw-string checks against rendered YAML and drift on any quoting/order change — exactly what the project's CONTRIBUTING.md "no-source-grep" testing standard exists to prevent. Add `parseFrontmatter()` to tests/helpers.cjs — a small parser that handles the YAML scalar forms the install converters emit (double-quoted JSON, single-quoted with `''` escape, bare). Throws if the content has no closed `---` block so a regression in the emitter shape fails loudly rather than silently returning {}. Refactor the 7 description-substring sites to compare on parsed values: the assertion now reads as `fm.description === 'Diagnose planning directory health'` rather than `result.includes('description: "Diagnose planning directory health')`. Same coverage of the #2876 quoting behavior, no coupling to byte-level quote style. `npm test`: 5893/5893 pass. Closes #2876 * test(#2876): make parseFrontmatter delimiter check CRLF/whitespace tolerant CR nitpick on PR #2881 (review at 03:08:08Z): parseFrontmatter() splits on '\n' and compares each line strictly to '---'. A Windows-authored skill file (CRLF endings) leaves a trailing '\r' on every line, so '---\r' fails the equality check, and the helper throws "no closed --- block" on perfectly valid input. Same problem with whitespace-padded delimiter lines. Switch to splitting on /\r?\n/ and comparing the trimmed line. Helper is used by tests/copilot-install.test.cjs and tests/antigravity-install.test.cjs, so this also de-flakes those suites on Windows runners. 5893/5893 on `npm test`.
This commit is contained in:
@@ -20,6 +20,7 @@ const assert = require('node:assert/strict');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const { parseFrontmatter } = require('./helpers.cjs');
|
||||
|
||||
const {
|
||||
getDirName,
|
||||
@@ -368,9 +369,10 @@ allowed-tools:
|
||||
Body content here referencing ~/.claude/foo and gsd:health.`;
|
||||
|
||||
const result = convertClaudeCommandToCopilotSkill(input, 'gsd-health');
|
||||
assert.ok(result.startsWith('---\nname: gsd-health\n'), 'name uses param');
|
||||
assert.ok(result.includes('description: Diagnose planning directory health'), 'description preserved');
|
||||
assert.ok(result.includes('argument-hint: "[--repair]"'), 'argument-hint double-quoted');
|
||||
const fm = parseFrontmatter(result);
|
||||
assert.equal(fm.name, 'gsd-health', 'name uses param');
|
||||
assert.equal(fm.description, 'Diagnose planning directory health', 'description preserved (quoted per #2876)');
|
||||
assert.equal(fm['argument-hint'], '[--repair]', 'argument-hint round-trips');
|
||||
assert.ok(result.includes('allowed-tools: Read, Bash, Write, AskUserQuestion'), 'tools comma-separated');
|
||||
assert.ok(result.includes('.github/foo'), 'CONV-06 applied to body (local mode default)');
|
||||
assert.ok(result.includes('gsd-health'), 'CONV-07 applied to body');
|
||||
@@ -386,9 +388,10 @@ description: Show available GSD commands
|
||||
Help content.`;
|
||||
|
||||
const result = convertClaudeCommandToCopilotSkill(input, 'gsd-help');
|
||||
assert.ok(result.includes('name: gsd-help'), 'name set');
|
||||
assert.ok(result.includes('description: Show available GSD commands'), 'description preserved');
|
||||
assert.ok(!result.includes('allowed-tools:'), 'no allowed-tools line');
|
||||
const fm = parseFrontmatter(result);
|
||||
assert.equal(fm.name, 'gsd-help', 'name set');
|
||||
assert.equal(fm.description, 'Show available GSD commands', 'description preserved');
|
||||
assert.ok(!('allowed-tools' in fm), 'no allowed-tools line');
|
||||
});
|
||||
|
||||
test('handles skill without argument-hint', () => {
|
||||
@@ -530,9 +533,10 @@ color: yellow
|
||||
Body.`;
|
||||
|
||||
const result = convertClaudeAgentToCopilotAgent(input);
|
||||
assert.ok(result.includes('name: gsd-executor'), 'name preserved');
|
||||
assert.ok(result.includes('description: Executes GSD plans with atomic commits'), 'description preserved');
|
||||
assert.ok(result.includes('color: yellow'), 'color preserved');
|
||||
const fm = parseFrontmatter(result);
|
||||
assert.equal(fm.name, 'gsd-executor', 'name preserved');
|
||||
assert.equal(fm.description, 'Executes GSD plans with atomic commits', 'description preserved');
|
||||
assert.equal(fm.color, 'yellow', 'color preserved');
|
||||
});
|
||||
|
||||
test('handles mcp__context7__ tools', () => {
|
||||
@@ -659,13 +663,17 @@ describe('copyCommandsAsCopilotSkills', () => {
|
||||
assert.ok(fs.existsSync(path.join(tempDir, 'gsd-autonomous', 'SKILL.md')), 'gsd-autonomous/SKILL.md exists');
|
||||
|
||||
const skillContent = fs.readFileSync(path.join(tempDir, 'gsd-autonomous', 'SKILL.md'), 'utf8');
|
||||
const fm = parseFrontmatter(skillContent);
|
||||
|
||||
// Frontmatter: name converted from gsd:autonomous to gsd-autonomous
|
||||
assert.ok(skillContent.startsWith('---\nname: gsd-autonomous\n'), 'name is gsd-autonomous');
|
||||
assert.ok(skillContent.includes('description: Run all remaining phases autonomously'),
|
||||
'description preserved');
|
||||
// argument-hint present and double-quoted
|
||||
assert.ok(skillContent.includes('argument-hint: "[--from N] [--to N] [--only N] [--interactive]"'), 'argument-hint present and quoted');
|
||||
assert.equal(fm.name, 'gsd-autonomous', 'name is gsd-autonomous');
|
||||
assert.equal(
|
||||
fm.description,
|
||||
'Run all remaining phases autonomously — discuss→plan→execute per phase',
|
||||
'description preserved (round-trips through #2876 yamlQuote)',
|
||||
);
|
||||
// argument-hint round-trips
|
||||
assert.equal(fm['argument-hint'], '[--from N] [--to N] [--only N] [--interactive]', 'argument-hint round-trips');
|
||||
// allowed-tools comma-separated
|
||||
assert.ok(skillContent.includes('allowed-tools: Read, Write, Bash, Glob, Grep, AskUserQuestion, Task'),
|
||||
'allowed-tools is comma-separated');
|
||||
|
||||
Reference in New Issue
Block a user