#!/bin/bash # test_context_files.sh - Verify bundle/context/{a2ui-format,artifact-conventions,researcher-instructions}.md (task-4) # RED: Run before files are created (should fail) # GREEN: Run after files are created (should pass) REPO=/home/ken/workspace/research-workbench PASS=0 FAIL=0 check_file_exists() { local path="$1" if [ -f "$REPO/$path" ]; then echo "PASS: '$path' exists" ((PASS++)) else echo "FAIL: '$path' should exist but is missing" ((FAIL++)) fi } check_contains() { local file="$1" local description="$2" local pattern="$3" if grep -qF -- "$pattern" "$REPO/$file" 2>/dev/null; then echo "PASS: $file contains '$description'" ((PASS++)) else echo "FAIL: $file is missing '$description'" ((FAIL++)) fi } check_regex() { local file="$1" local description="$2" local pattern="$3" if grep -qE "$pattern" "$REPO/$file" 2>/dev/null; then echo "PASS: $file matches '$description'" ((PASS++)) else echo "FAIL: $file is missing '$description' (pattern: $pattern)" ((FAIL++)) fi } # ───────────────────────────────────────────────────────────── # a2ui-format.md # ───────────────────────────────────────────────────────────── A2UI="bundle/context/a2ui-format.md" echo "=== Checking $A2UI exists ===" check_file_exists "$A2UI" echo "" echo "=== Checking a2ui-format.md: fenced code block with language 'a2ui' ===" check_contains "$A2UI" "a2ui fenced code block" '```a2ui' echo "" echo "=== Checking a2ui-format.md: block type 'filters' ===" check_contains "$A2UI" "filters type" '"type": "filters"' check_contains "$A2UI" "filters array key" '"filters"' check_contains "$A2UI" "Toyota option" '"Toyota"' check_contains "$A2UI" "Honda option" '"Honda"' check_contains "$A2UI" "Hyundai option" '"Hyundai"' check_contains "$A2UI" "Under \$5K option" '"Under $5K"' check_contains "$A2UI" "value field" '"value"' echo "" echo "=== Checking a2ui-format.md: block type 'table' ===" check_contains "$A2UI" "table type" '"type": "table"' check_contains "$A2UI" "table headers" '"headers"' check_contains "$A2UI" "table rows" '"rows"' echo "" echo "=== Checking a2ui-format.md: block type 'cards' ===" check_contains "$A2UI" "cards type" '"type": "cards"' check_contains "$A2UI" "cards items" '"items"' check_contains "$A2UI" "card title field" '"title"' check_contains "$A2UI" "card description field" '"description"' check_contains "$A2UI" "card price field" '"price"' check_contains "$A2UI" "card url field" '"url"' check_contains "$A2UI" "Prius listing" 'Prius' echo "" echo "=== Checking a2ui-format.md: block type 'form' ===" check_contains "$A2UI" "form type" '"type": "form"' check_contains "$A2UI" "form fields" '"fields"' check_contains "$A2UI" "submitLabel field" '"submitLabel"' check_contains "$A2UI" "max_price field name" '"max_price"' check_contains "$A2UI" "radius field name" '"radius"' check_contains "$A2UI" "fuel_type field name" '"fuel_type"' check_contains "$A2UI" "select field type for fuel_type" '"select"' check_contains "$A2UI" "hybrid option" '"hybrid"' check_contains "$A2UI" "electric option" '"electric"' check_contains "$A2UI" "any option" '"any"' echo "" echo "=== Checking a2ui-format.md: Rules section ===" check_regex "$A2UI" "Rules section" "^## Rules|^# Rules|Rules" check_contains "$A2UI" "always use a2ui language tag" 'a2ui' check_regex "$A2UI" "JSON must be single object with type field" 'type.*field|\"type\"' check_regex "$A2UI" "generate when user benefits" 'benefit|interactive' check_regex "$A2UI" "don't overuse" "overuse|don.t overuse|sparingly" # ───────────────────────────────────────────────────────────── # artifact-conventions.md # ───────────────────────────────────────────────────────────── ARTIFACT="bundle/context/artifact-conventions.md" echo "" echo "=== Checking $ARTIFACT exists ===" check_file_exists "$ARTIFACT" echo "" echo "=== Checking artifact-conventions.md: write_file tool usage ===" check_contains "$ARTIFACT" "write_file tool call" 'write_file' check_regex "$ARTIFACT" "artifacts/ path pattern" 'artifacts/.*session' echo "" echo "=== Checking artifact-conventions.md: file naming conventions ===" check_regex "$ARTIFACT" "kebab-case naming" 'kebab.case|kebab-case' check_contains "$ARTIFACT" ".md extension" '.md' echo "" echo "=== Checking artifact-conventions.md: content format ===" check_regex "$ARTIFACT" "H1 title requirement" 'H1|# title|heading' check_regex "$ARTIFACT" "markdown tables for comparisons" '[Mm]arkdown.*table|table.*comparison|comparison.*table' check_regex "$ARTIFACT" "bullet points for recommendations" 'bullet|recommendation' check_regex "$ARTIFACT" "source URLs" '[Ss]ource.*URL|URL.*source|source url' check_regex "$ARTIFACT" "Next Steps or Summary ending" 'Next Steps|Summary' echo "" echo "=== Checking artifact-conventions.md: when to create ===" check_regex "$ARTIFACT" "guides/reports/summaries" 'guide|report|summar' check_regex "$ARTIFACT" "comparison tables" 'comparison' check_regex "$ARTIFACT" "actionable recommendations" 'actionable|recommendation' check_regex "$ARTIFACT" "printable/shareable" 'printable|shareable' echo "" echo "=== Checking artifact-conventions.md: when NOT to create ===" check_regex "$ARTIFACT" "not for simple answers" '[Ss]imple answer|not.*simple|simple.*answer' check_regex "$ARTIFACT" "not for intermediate research" 'intermediate|research step|status update' # ───────────────────────────────────────────────────────────── # researcher-instructions.md # ───────────────────────────────────────────────────────────── RESEARCHER="bundle/context/researcher-instructions.md" echo "" echo "=== Checking $RESEARCHER exists ===" check_file_exists "$RESEARCHER" echo "" echo "=== Checking researcher-instructions.md: Research Workbench context ===" check_regex "$RESEARCHER" "Research Workbench mention" '[Rr]esearch [Ww]orkbench' echo "" echo "=== Checking researcher-instructions.md: Browser capability ===" check_regex "$RESEARCHER" "Browser with Playwright/Chromium" '[Bb]rowser|playwright|Chromium' check_contains "$RESEARCHER" "playwright-cli session flag" '-s=research' check_regex "$RESEARCHER" "VNC mention" 'VNC|vnc|noVNC' echo "" echo "=== Checking researcher-instructions.md: Artifacts capability ===" check_regex "$RESEARCHER" "Artifacts capability" '[Aa]rtifact' check_regex "$RESEARCHER" "artifacts/ path" 'artifacts/.*session|session.*artifacts' echo "" echo "=== Checking researcher-instructions.md: A2UI capability ===" check_regex "$RESEARCHER" "A2UI capability" 'A2UI|a2ui' check_regex "$RESEARCHER" "inline a2ui code blocks" 'inline|code block' echo "" echo "=== Checking researcher-instructions.md: Inline Visuals capability ===" check_regex "$RESEARCHER" "Inline Visuals" '[Ii]nline [Vv]isual|visual.*block' check_regex "$RESEARCHER" "visual code blocks" 'visual.*block|code.*block.*visual' echo "" echo "=== Checking researcher-instructions.md: pointer to researcher agent ===" check_regex "$RESEARCHER" "pointer to researcher agent" 'researcher.*agent|researcher.*command|full.*command|command.*reference' echo "" echo "==============================" echo "Results: $PASS passed, $FAIL failed" echo "==============================" [ $FAIL -eq 0 ] && exit 0 || exit 1