Files
agency-agents/scripts/test-convert-frontmatter.sh
Hotragn PettuganiandClaude Opus 5.5 d3f71c4bb8 fix(qwen): translate Claude Code tool names so Qwen grants Read, Write and Bash (#965)
From @Hotragn. 17 agents list Claude Code tool names (Read, Write, Bash...). Qwen Code resolves subagent tools by exact name or display name, so those three matched nothing and were never granted. Traced in Qwen Code 0.24.7: resolveToolNames preserves unknown names, and getTool() is a plain lookup with no alias translation. Now mapped to read_file, write_file and run_shell_command; other names pass through unchanged. The manifest moves exactly those 17 agents.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 14:35:39 -05:00

93 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Regression coverage for YAML frontmatter emitted by convert.sh.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
OUTPUT_DIR="$(mktemp -d "${TMPDIR:-/tmp}/agency-convert-frontmatter.XXXXXX")"
trap 'rm -rf "$OUTPUT_DIR"' EXIT
# Body separators are Markdown content, not additional frontmatter fences.
# get_body feeds the bodies used by the integration converters below.
. "$SCRIPT_DIR/lib.sh"
cat > "$OUTPUT_DIR/body-with-separator.md" <<'EOF'
---
name: Example
---
# Example
---
Important body text.
EOF
separator_count="$(get_body "$OUTPUT_DIR/body-with-separator.md" | grep -cx -- '---' || true)"
[[ "$separator_count" == 1 ]] || {
printf 'Expected Markdown separator in agent body, got %s\n' "$separator_count" >&2
exit 1
}
for tool in gemini-cli opencode qwen; do
"$SCRIPT_DIR/convert.sh" --tool "$tool" --out "$OUTPUT_DIR" >/dev/null
done
assert_quoted() {
local file="$1" field="$2" line prefix
line="$(awk -v key="$field" '$0 ~ "^" key ":" { print; exit }' "$file")"
prefix="$field: '"
[[ "$line" == "$prefix"*"'" ]] || {
printf 'Expected %s in %s to be a single-quoted YAML scalar, got: %s\n' \
"$field" "$file" "$line" >&2
return 1
}
}
assert_quoted \
"$OUTPUT_DIR/gemini-cli/agents/developer-tooling-engineer.md" \
description
assert_quoted \
"$OUTPUT_DIR/opencode/agents/developer-tooling-engineer.md" \
name
assert_quoted \
"$OUTPUT_DIR/opencode/agents/developer-tooling-engineer.md" \
description
assert_quoted \
"$OUTPUT_DIR/qwen/agents/programmatic-display-buyer.md" \
tools
# Qwen resolves tools by its own names and silently keeps one it does not know,
# so Claude Code's Read/Write/Bash have to arrive as read_file/write_file/
# run_shell_command or the agent cannot read, create files, or run a shell.
qwen_tools_line="$(grep -m1 '^tools:' "$OUTPUT_DIR/qwen/agents/programmatic-display-buyer.md")"
[[ "$qwen_tools_line" == "tools: 'web_fetch, web_search, read_file, write_file, edit, run_shell_command'" ]] || {
printf 'Expected Qwen tool names in programmatic-display-buyer, got: %s\n' "$qwen_tools_line" >&2
exit 1
}
# 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"