From 266c0864fe3129a1545b7f5246271e3666dd3d52 Mon Sep 17 00:00:00 2001 From: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> Date: Wed, 30 Sep 2026 21:38:48 -0400 Subject: [PATCH] fix(lint): reject unsupported folded YAML frontmatter Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> --- .github/workflows/lint-agents.yml | 4 ++++ scripts/lint-agents.sh | 9 +++++++++ scripts/test-folded-frontmatter.sh | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100755 scripts/test-folded-frontmatter.sh diff --git a/.github/workflows/lint-agents.yml b/.github/workflows/lint-agents.yml index c253839d..7eea6dfc 100644 --- a/.github/workflows/lint-agents.yml +++ b/.github/workflows/lint-agents.yml @@ -104,3 +104,7 @@ jobs: run: | chmod +x scripts/lint-agents.sh ./scripts/lint-agents.sh + + - name: Reject folded frontmatter fixtures + if: steps.rules.outputs.changed == 'true' + run: bash scripts/test-folded-frontmatter.sh diff --git a/scripts/lint-agents.sh b/scripts/lint-agents.sh index 442e6e31..15358839 100755 --- a/scripts/lint-agents.sh +++ b/scripts/lint-agents.sh @@ -112,6 +112,15 @@ lint_file() { return fi + # The lightweight converters read plain or quoted scalar fields. A folded + # block otherwise passes presence checks but leaks its YAML indicator into + # the generated value. + if grep -qE '^[[:space:]]*[[:alnum:]_-]+:[[:space:]]*>([-+][1-9]?|[1-9][-+]?)?([[:space:]]+#.*)?[[:space:]]*$' <<<"$frontmatter"; then + echo "ERROR $file: folded YAML frontmatter is unsupported — use a single-line scalar" + errors=$((errors + 1)) + return + fi + # 2. Check required frontmatter fields for field in "${REQUIRED_FRONTMATTER[@]}"; do if ! grep -qE -- "^${field}:" <<<"$frontmatter"; then diff --git a/scripts/test-folded-frontmatter.sh b/scripts/test-folded-frontmatter.sh new file mode 100755 index 00000000..04cdb176 --- /dev/null +++ b/scripts/test-folded-frontmatter.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +scratch="$(mktemp -d)" +trap 'rm -rf "$scratch"' EXIT +for indicator in '>' '>-' '>+' '>2' '>2-' '>-2' '>+2' '>2+ # comment'; do + printf '%s\n' '---' 'name: Example Agent' "description: $indicator" ' First line' ' Second line' 'color: blue' '---' '## Identity' '## Core Mission' '## Critical Rules' > "$scratch/agent.md" + if bash "$SCRIPT_DIR/lint-agents.sh" "$scratch/agent.md" > "$scratch/result.log" 2>&1; then + echo "FAIL: linter accepted folded frontmatter $indicator" >&2; exit 1 + fi + grep -q 'folded YAML frontmatter is unsupported' "$scratch/result.log" +done +for description in '"A > B"' "'A > B'" 'Ordinary description'; do + printf '%s\n' '---' 'name: Example Agent' "description: $description" 'color: blue' '---' '## Identity' '## Core Mission' '## Critical Rules' '> Body quotation' > "$scratch/agent.md" + bash "$SCRIPT_DIR/lint-agents.sh" "$scratch/agent.md" > "$scratch/result.log" 2>&1 +done +echo 'PASS: folded frontmatter is rejected while quoted scalars and body quotations pass'