Test Suite Overview
OpenCode Agents has 893 tests across three test harnesses:- 560 Node.js tests — CLI, TUI, registry, installer, lock files
- 310 Python tests — Agent quality scoring, sync scripts, manifest validation
- 23 Plugin tests — OpenCode plugin tools (requires Bun)
- Python: 3.10, 3.12, 3.13
- Node.js: 20, 22, 23
Running Tests
All Tests
Specific Test Suites
Node.js Tests
Python Tests
Plugin Tests
Test Organization
Node.js Tests (tests/*.test.mjs)
cli.test.mjs (200+ tests)
- CLI argument parsing
- Agent installation (single, multiple, packs, categories)
- Search functionality
- List operations
- Dry-run mode
- Force overwrite
- Error handling
tui.test.mjs (300+ tests)
- Screen rendering
- Input handling (keyboard navigation)
- State machine transitions
- Category browsing
- Search mode
- Pack detail views
- Installation flow
- ANSI escape code generation
lock.test.mjs (60+ tests)
- Lock file creation
- Version tracking
- Agent installation state
- Lock file updates
- Integrity verification
Python Tests (tests/*.py)
test_agents.py (100+ tests)
- YAML frontmatter validation
- Agent file structure
- Required fields (description, mode, permission)
- Permission format validation
- Markdown syntax checks
test_quality_scorer.py (80+ tests)
- 8-dimension scoring logic
- Frontmatter scoring
- Identity paragraph word count
- Decision tree detection (IF/THEN)
- Code block counting
- Quality gate validation
- Conciseness scoring
- Version pinning detection
- Pass/fail criteria
test_sync_script.py (60+ tests)
- HTTP fetching with ETag caching
- Upstream agent discovery
- Frontmatter parsing
- Permission conversion (tools → permission)
- Dry-run mode
- Error handling
test_update_manifest.py (40+ tests)
- Manifest merging
- Agent deduplication
- Category organization
- NEEDS_REVIEW prefix handling
- JSON schema validation
test_sync_common.py (30+ tests)
- Shared HTTP utilities
- ETag caching
- Frontmatter extraction
- YAML parsing
- Error handling
Plugin Tests (tests/plugin/*.test.ts)
search_agents.test.ts
- Search by name
- Search by description
- Search by category
- Search by tags
- Fuzzy matching
list_agents.test.ts
- List all agents
- Filter by category
- Filter by pack
- Group by category
get_agent.test.ts
- Get agent by ID
- Agent not found handling
- Typo suggestions
- Installation status
check_health.test.ts
- Registry health report
- Installed agent detection
- Missing agent detection
- Outdated agent detection
Quality Validation
Score a Single Agent
Regenerate README Scores
- Scans all agents in
agents/directory - Runs quality scorer on each agent
- Calculates average score, pass rate, label distribution
- Updates
<!-- SCORES:BEGIN -->…<!-- SCORES:END -->section in both READMEs - Generates markdown table with scores, labels, token estimates, line counts
Linting and Validation
Syntax Checking
Frontmatter Validation
Manifest Validation
Deprecated Field Detection
CI Workflow Tests
The GitHub Actions CI runs automatically on every push and PR. You can replicate the CI locally:Test Job (Python)
Test-CLI Job (Node.js)
Lint Job
Validate-Agents Job
Test Coverage
Node.js Coverage
Node.js built-in test runner doesn’t have native coverage. Usec8 for coverage:
Python Coverage
Plugin Coverage (Bun)
Pre-Commit Checklist
Before committing, ensure:- All Node.js tests pass:
npm test - All Python tests pass:
python3 tests/run_tests.py - Plugin tests pass (if Bun installed):
bun test tests/plugin/ - Quality scores updated:
python3 scripts/generate_readme_scores.py - README scores are current:
python3 scripts/generate_readme_scores.py --check - No syntax errors:
node --check bin/cli.mjs src/*.mjs src/tui/*.mjs - Python syntax valid:
python3 -c "import ast; ast.parse(open('scripts/quality_scorer.py').read())" - No deprecated
tools:field in agents - Manifest.json is valid JSON
- Frontmatter is valid YAML in all agents
Debugging Test Failures
Node.js Test Debugging
Python Test Debugging
Plugin Test Debugging
Common Test Failures
README scores out of date
README scores out of date
Error:
generate_readme_scores.py --check failsFix:Deprecated tools: field detected
Deprecated tools: field detected
Error: Agent uses
tools: instead of permission:Fix: Update frontmatter in the agent file:Quality score too low
Quality score too low
Error: Agent scores < 3.5 or has dimension < 2Fix:
Frontmatter YAML invalid
Frontmatter YAML invalid
Error: YAML parsing failsFix: Validate YAML syntax:Common mistakes:
- Missing closing
--- - Incorrect indentation (use 2 spaces)
- Unquoted strings with special characters
Manifest file mismatch
Manifest file mismatch
Error:
manifest.json references non-existent filesFix: Regenerate scores to update manifest:Performance Testing
While there are no formal performance tests, you can benchmark key operations:CLI Performance
Quality Scorer Performance
- Single agent score: ~50ms
- Full README regeneration: ~3-5 seconds
- CLI list: ~100ms
- Pack installation (dry-run): ~200ms
Next Steps
Adding Agents
Create high-quality agents with the 4-section format
Contributing Overview
Understand the development workflow and CI/CD