Files
research-workbench/tests/test_researcher_agent.sh
Ken 2c3cfdbedc fix: resolve code review issues — schema mismatch, test fixes, pop-out render
- Fix a2ui-format.md schema to match renderer: rename 'options' → 'filters' in
  filters block, replace 'active: boolean' with 'value: string' in filter options,
  update form select options from string[] to {label, value}[] objects (Critical #1)
- Fix 3 failing tests in test_researcher_agent.sh to use @mention paths without .md
  extension (Important #2)
- Complete pop-out feature in VisualBlock.handlePopOut() by posting render message
  to popup window after 500ms initialization delay (Important #3)
- Update test_context_files.sh to match new a2ui-format.md schema (filters array
  key check, value field check)
2026-05-26 20:54:58 +00:00

160 lines
5.8 KiB
Bash
Executable File

#!/bin/bash
# test_researcher_agent.sh - Verify bundle/agents/researcher.md meets spec (task-3)
# RED: Run before file is created (should fail)
# GREEN: Run after file is created (should pass)
REPO=/home/ken/workspace/research-workbench
AGENT_FILE="$REPO/bundle/agents/researcher.md"
PASS=0
FAIL=0
check_file_exists() {
if [ -f "$AGENT_FILE" ]; then
echo "PASS: 'bundle/agents/researcher.md' exists"
((PASS++))
else
echo "FAIL: 'bundle/agents/researcher.md' should exist but is missing"
((FAIL++))
fi
}
check_contains() {
local description="$1"
local pattern="$2"
if grep -qF -- "$pattern" "$AGENT_FILE" 2>/dev/null; then
echo "PASS: researcher.md contains '$description'"
((PASS++))
else
echo "FAIL: researcher.md is missing '$description'"
((FAIL++))
fi
}
check_regex() {
local description="$1"
local pattern="$2"
if grep -qE "$pattern" "$AGENT_FILE" 2>/dev/null; then
echo "PASS: researcher.md matches '$description'"
((PASS++))
else
echo "FAIL: researcher.md is missing '$description'"
((FAIL++))
fi
}
echo "=== Checking file exists ==="
check_file_exists
echo ""
echo "=== Checking YAML frontmatter: meta.name ==="
check_contains "meta.name: researcher" "name: researcher"
echo ""
echo "=== Checking YAML frontmatter: model_role includes research ==="
check_contains "model_role includes research" "research"
check_regex "model_role list format" "model_role:.*\[.*\]|model_role:"
echo ""
echo "=== Checking YAML frontmatter: model_role includes general ==="
check_contains "model_role includes general" "general"
echo ""
echo "=== Checking meta.description WHY/WHEN/WHAT/HOW pattern ==="
# The description must have delegation examples
check_contains "WHY/WHEN delegation example structure" "<example>"
check_contains "delegation example closing tag" "</example>"
echo ""
echo "=== Checking delegation examples (4 required) ==="
check_contains "hybrid cars under \$10K example" "hybrid cars"
check_contains "Woodinville WA location" "Woodinville"
check_contains "project management tools example" "project management"
check_contains "Seattle to Tokyo flights example" "Tokyo"
check_contains "flights under \$800 example" "800"
check_contains "mechanical keyboards example" "mechanical keyboard"
check_contains "programming keyboards example" "programming"
echo ""
echo "=== Checking body: intro paragraph ==="
check_contains "research assistant intro" "research assistant"
check_regex "live web browser mention" "live.*browser|browser.*live|web browser"
echo ""
echo "=== Checking body: Browser Control section ==="
check_contains "Browser Control section header" "Browser Control"
check_contains "playwright-cli section" "playwright-cli"
check_contains "-s=research persistent session" "-s=research"
echo ""
echo "=== Checking playwright-cli command table (11 actions) ==="
# Action 1: Open a URL
check_contains "open URL command" "playwright-cli -s=research open https://example.com"
# Action 2: Take a snapshot
check_contains "snapshot command" "playwright-cli -s=research snapshot"
# Action 3: Compact snapshot
check_contains "compact snapshot command" "playwright-cli -s=research snapshot -ic"
# Action 4: Click an element
check_contains "click command" "playwright-cli -s=research click @e5"
# Action 5: Type text
check_contains "type command" 'playwright-cli -s=research type @e3'
# Action 6: Press a key
check_contains "press key command" "playwright-cli -s=research press Enter"
# Action 7: Scroll down
check_contains "scroll command" "playwright-cli -s=research scroll down"
# Action 8: Go back
check_contains "back command" "playwright-cli -s=research back"
# Action 9: New tab
check_contains "new tab command" "playwright-cli -s=research open https://other-site.com"
# Action 10: List tabs
check_contains "list tabs command" "playwright-cli -s=research tabs"
# Action 11: Switch tab
check_contains "switch tab command" "playwright-cli -s=research tab 2"
echo ""
echo "=== Checking body: Snapshot Refs subsection ==="
check_contains "Snapshot Refs section" "Snapshot Refs"
check_contains "@e1 ref example" "@e1"
check_contains "@e2 ref example" "@e2"
check_regex "snapshot after navigation guidance" "snapshot after|after.*navigation|navigate.*snapshot"
echo ""
echo "=== Checking body: Best Practices subsection ==="
check_contains "Best Practices section" "Best Practices"
check_contains "compact snapshot after open/click" "compact snapshot"
check_contains "refs change after navigation" "refs change"
check_regex "open new sites in new tabs" "new.*tab|tab.*new"
check_regex "user can take over via VNC" "VNC|vnc"
echo ""
echo "=== Checking body: A2UI section ==="
check_contains "A2UI section header" "A2UI"
check_contains "a2ui-format @mention" "bundle/context/a2ui-format"
echo ""
echo "=== Checking body: Artifacts section ==="
check_contains "Artifacts section header" "Artifacts"
check_contains "artifact-conventions @mention" "bundle/context/artifact-conventions"
echo ""
echo "=== Checking body: Inline Visuals section ==="
check_contains "Inline Visuals section header" "Inline Visuals"
check_contains "visual-artifacts @mention" "bundle/context/visual-artifacts"
check_regex "proactive visual generation mention" "proactive|visual.*generation|comparison.*table|chart"
echo ""
echo "=== Checking body: Research Workflow section ==="
check_contains "Research Workflow section header" "Research Workflow"
check_regex "Understand request step" "[Uu]nderstand"
check_regex "Plan step" "[Pp]lan"
check_regex "Browse/extract step" "[Bb]rowse|[Ee]xtract"
check_regex "Present step" "[Pp]resent"
check_regex "Generate artifacts step" "[Gg]enerate.*artifact|[Aa]rtifact.*generat"
check_regex "Iterate step" "[Ii]terat"
echo ""
echo "=============================="
echo "Results: $PASS passed, $FAIL failed"
echo "=============================="
[ $FAIL -eq 0 ] && exit 0 || exit 1