From 435cf1d232c6e67ad804ed14b4237ddb46fc01a9 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Mon, 28 Sep 2026 00:16:58 -0400 Subject: [PATCH] fix(ci): reject empty required agent metadata --- scripts/lint-agents.sh | 3 +++ scripts/test-convert-frontmatter.sh | 26 +++++++++++++++++++++++++- scripts/test-convert-outputs.sh | 6 ++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/scripts/lint-agents.sh b/scripts/lint-agents.sh index 086b386c..caf61571 100755 --- a/scripts/lint-agents.sh +++ b/scripts/lint-agents.sh @@ -112,6 +112,9 @@ lint_file() { if ! grep -qE -- "^${field}:" <<<"$frontmatter"; then echo "ERROR $file: missing frontmatter field '${field}'" errors=$((errors + 1)) + elif [[ ! "$(get_field "$field" "$file")" =~ [^[:space:]] ]]; then + echo "ERROR $file: frontmatter field '${field}' must not be empty" + errors=$((errors + 1)) fi done diff --git a/scripts/test-convert-frontmatter.sh b/scripts/test-convert-frontmatter.sh index e7ab068e..ec9348e0 100755 --- a/scripts/test-convert-frontmatter.sh +++ b/scripts/test-convert-frontmatter.sh @@ -36,4 +36,28 @@ assert_quoted \ "$OUTPUT_DIR/qwen/agents/programmatic-display-buyer.md" \ tools -echo "PASS: converted YAML frontmatter keeps scalar values safely quoted" +# A present but empty required field is unusable discovery metadata. Check the +# source linter directly, including YAML's quoted empty-string form. +cat > "$OUTPUT_DIR/agent.md" <<'EOF' +--- +name: Example Agent +description: Builds useful examples +color: red +--- + +## Identity + +## Core Mission + +## Critical Rules + +EOF +for field in name description color; do + sed "s/^${field}:.*/${field}: \"\"/" "$OUTPUT_DIR/agent.md" > "$OUTPUT_DIR/empty-$field.md" + if "$SCRIPT_DIR/lint-agents.sh" "$OUTPUT_DIR/empty-$field.md" > /dev/null; then + printf 'Expected linter to reject empty %s metadata\n' "$field" >&2 + exit 1 + fi +done + +echo "PASS: converted YAML frontmatter stays quoted and required source metadata is nonempty" diff --git a/scripts/test-convert-outputs.sh b/scripts/test-convert-outputs.sh index 5ecdd242..3ef1e2e5 100755 --- a/scripts/test-convert-outputs.sh +++ b/scripts/test-convert-outputs.sh @@ -199,8 +199,10 @@ src_bad = [] for slug, (_gf_desc, _gf_name, path) in list(src.items()): try: data = frontmatter(open(os.path.join(R, path), encoding="utf-8").read()) - assert isinstance(data, dict) and isinstance(data.get("name"), str) \ - and isinstance(data.get("description"), str), "missing name/description" + assert isinstance(data, dict) and all( + isinstance(data.get(field), str) and data[field].strip() + for field in ("name", "description", "color") + ), "missing or empty name/description/color" assert data["description"][:1] not in ('"', "'"), "description starts with a quote character" src[slug] = (data["description"], data["name"], path) except Exception as e: