git clone https://github.com/hueyexe/opencode-ensemble.git
cd opencode-ensemble
bun installThis project follows strict TDD (Red/Green/Refactor):
- Write the test first in
test/. It must fail for the right reason. - Write the minimum implementation in
src/to make it pass. - Refactor without changing behavior. Confirm tests still pass.
Before submitting any change:
bun run typecheck && bun test && bun run buildAll three must pass.
CI enforces a branch-name prefix on every PR via the branch-name check. Your PR's head branch must start with one of:
feature/— new functionality (e.g.feature/verbose-dashboard)bugfix/— fixes (e.g.bugfix/bun-sqlite-scanner)chore/— tooling, docs, deps, refactors (e.g.chore/update-deps)
Common gotcha: opening a PR directly from your fork's
mainbranch fails this check, becausemainhas no valid prefix. Always create a prefixed branch before pushing:git checkout -b bugfix/short-descriptionIf you already committed to
mainon your fork, move the work to a prefixed branch and open the PR from there.
- Fork the repo and create a branch off
mainusing abugfix/,feature/, orchore/prefix (see above) - Make your changes following TDD and the code standards below
- Run
bun run typecheck && bun test && bun run build— all must pass - Open a PR against
main - The
checkCI status must pass on your PR (thebranch-namecheck must pass too) - A maintainer (@hueyexe) will review and merge
All PRs require at least one approval from a code owner before merging. Direct pushes to main are not allowed.
- TypeScript strict mode — no
anytypes - Every exported function has a JSDoc comment
constoverlet, early returns overelsesnake_casefor SQL columns,camelCasefor TypeScript- Functional array methods over
forloops - Zero external dependencies beyond
@opencode-ai/sdkand@opencode-ai/plugin; SQLite goes through the internal adapter (bun:sqliteon Bun,node:sqliteon Node/Electron)
- All tests use in-memory SQLite (
:memory:) — no disk I/O, no cleanup - Mock
OpencodeClientfor integration tests (seetest/helpers.ts) - Race condition tests use
Promise.all()/Promise.allSettled() - No mocking of business logic — test actual SQLite transactions
bun testis the only test runner
src/
├── index.ts # Plugin entry point and tool registration
├── client.ts # SDK wrapper that throws on API errors
├── config.ts # Global/project/env configuration loading
├── dashboard*.ts # Dashboard HTML, JS, and data endpoint
├── db.ts # SQLite connection + init
├── hooks.ts # Event hook + sub-agent isolation
├── log.ts # Plugin logging helpers
├── messaging.ts # Message persistence + delivery helpers
├── notify.ts # TUI notification helpers
├── progress.ts # Progress/stall tracking
├── rate-limit.ts # Token bucket rate limiter
├── recovery.ts # Crash recovery and orphan cleanup
├── result-parser.ts # Teammate result parsing helpers
├── schema.ts # CREATE TABLE migrations
├── state.ts # In-memory registry, descendant tracker, and purge approval state
├── system-prompt.ts # Lead/teammate prompt injection text
├── types.ts # Shared types + helper functions
├── util.ts # ID generation + name validation
├── watchdog.ts # Timeout and stall watchdog
└── tools/ # 14 team tools plus shared/merge helpers
test/
├── helpers.ts # Shared test utilities (setupDb, mockClient, etc.)
├── *.test.ts # Unit tests for each src module
└── tools/ # Tool-specific tests
Unresolved SDK behavior questions are tracked in .opencode/plans/architecture-plan.md Section 9. When you encounter one during implementation:
- Make the conservative choice
- Add
// OQ-<number>: <assumption made>at the call site - Write a test that will fail if the assumption is wrong
The docs/reference/ directory contains PR implementations from the OpenCode core repo. These use internal APIs (Storage, Bus, Lock, SessionPrompt, etc.) that are not available from a plugin. See the Internal API Blocklist in AGENTS.md before referencing them.