A deeply customized harness for the OpenCode 2 coding agent: one primary agent, 31 specialists, 11 lifecycle command menus, a local memory and retrieval plane, and a test suite that checks behaviour instead of prose.
This repository is the operator's entire agent environment. It is the layer between a model and a
repository: which agent runs, what it may read, what it remembers, how work is routed, and what
counts as done. The configuration is main. The older V1 setup is frozen on branch v1 and
mirrored to Thomashighbaugh/opencode-v1; opencode2 does not load it.
If you are reviewing this as a work sample, read Architecture first, then the three decisions in Engineering decisions.
| Primary agent | 1 (hubs) |
| Subagents | 31 specialists across planning, implementation, review, research, and workflow |
| Command menus | 11 lifecycle hubs, 56 subcommands, 171 modes |
| Skills | 74 global, plus the skills bundled by the hubs, hooks, command-hooks, and design-system plugins |
| Tools | 30 TypeScript tools registered through the V2 plugin API |
| Plugins | 9 packages |
| Retrieval | 1,482 context chunks and 4,283 code chunks, plus a 6,528-node knowledge graph |
| Memory | local SQLite with per-turn injection |
| Tests | 998 Node tests, 143 Bun tests, CI on every push |
An agent harness is policy, routing, memory, and verification around a model. Most prompt collections stop at instructions. This one turns the instructions into things that run:
- a routing table that returns a full subcommand spec in one call,
- hooks that enforce shell, HTTP, and file rules,
- a local memory store that survives sessions,
- a retrieval plane that indexes the config and the code without a daemon or a network call,
- tests that fail when a rule is present but no longer wired to anything.
The prompts still exist. They are not the mechanism.
Off-the-shelf coding agents handle one task well and drift over a working week. Decisions get re-litigated, the same files get re-read, and rules decay into suggestions. The harness encodes the operating rules once, then makes them executable and testable:
- Routing: 56 subcommands across 11 lifecycle menus (
hubs-00-bootstraptohubs-10-observe), each with tools, rules, related skills, examples, and warnings. A direct selection returns the whole spec; a vague request returns a slim index to route from. - Memory: decisions, gotchas, and preferences are stored locally, embedded, reranked, and injected into the next turn.
- Verification: every rule, agent, skill, and delegation target has a test that fails when it stops resolving.
- Budget: the prompt is measured, not guessed. Rules that only some workflows need are loaded on demand.
hubMenu route returns the full subcommand spec in one response: detailed description, inlined
rules, resolved skill pointers, examples, and warnings. hubMenu menu returns an identity slice for
the case where the model has to choose. The specs live in plugins/hubs/data/hubs/<hub>/ and are
compiled into a registry that the router and the tests share. The TUI picker submits a selection as
synthetic context followed by the task, so a routed spec reaches the model without filling the
transcript.
A skill shipped by a plugin lives inside that plugin and is registered by it with
ctx.skill.transform. skills/ holds only skills that no plugin owns. The hubs plugin owns 64,
command-hooks and hooks own one each, and design-system owns its copy of antislop-ui. This is
enforced, not documented and forgotten.
The standalone rio plugin was folded into plugins/hubs/runtime and split into two labels:
memory (memory_learn, memory_recall, memory_get, memory_forget, per-turn injection) and
token efficiency (fill, quality, request accounting, mechanical alternatives, shell compression).
The memory database is shared with the knowledge commands, so a fact learned by either is visible to
both.
Two vector stores live under .opencode/state/vector/: markdown sources for context and declaration
chunks for code. Embeddings and reranking run in process with ONNX models, so queries cost no
provider tokens and need no daemon. A knowledge graph sits beside them for structural questions
(what touches what, what breaks if this changes).
The tests assert on behaviour: a subcommand resolves to a real file, a skill has frontmatter the
loader can see, an on-demand rule is named by something that can load it, a plugin-owned skill is
not duplicated in skills/, and the graph has no edgeless leaves. The suite runs in CI on every
push, in two jobs: the global config and a provisioned sample project.
The hosted provider rejects a messages payload above 200,000 characters. The models declared
200,000 to 1,000,000 token windows, so the client's automatic compaction could not see the limit:
it compared tokens against a window four to twenty times larger than the real ceiling.
A logging proxy established the exact rule: the cap applies to messages only, and tool
definitions are not counted. The system prompt was 145,996 characters, leaving 54,004 for
conversation, about one file read.
The fixed cost came down in three moves:
| Change | Effect |
|---|---|
| Moved six lookup-table rules on demand, left a 2 KB always-on digest | 43 KB out of every turn |
Rewrote AGENTS.md as pointers plus the counts that matter |
21,706 to 9,582 bytes |
| Rewrote 89 skill descriptions to 100 characters or fewer, keeping trigger words | 22,582 to 8,497 bytes |
Measured result: system prompt 119,715 characters, 80,285 characters of headroom. Verified with live multi-turn runs that load 20 to 75 KB of files and execute tools.
A duplicated skill is a skill that drifts. Fifty-six skills existed twice, once in skills/ and
once inside the hubs plugin, and five had already diverged. The fix was ownership plus a guard:
- plugin-owned skills live only in the plugin,
- no symlinks under
skills/and none between plugins, - two plugins that genuinely need the same skill keep real copies, declared in
rules/drift-guard.md, - the feature test fails on a duplicate, a symlink, or a drifted pair.
The same principle retired the standalone menu plugin. Its memory and token-efficiency code moved
into hubs, kept its behaviour, and lost its old name. The /rio route keys remain as legacy
aliases so old invocations still resolve, but nothing user-facing is called rio any more.
| Check | Result |
|---|---|
| Node test suite | 998 passed |
| Bun plugin suite | 143 passed |
| TypeScript | tsc --noEmit clean |
| CI | 2 jobs, about 30 seconds, green on main |
| Vector stores | 96 context files, 379 code files, 0 errors |
| Knowledge graph | 6,528 nodes, 41,428 edges, 0 edgeless leaves |
| Live provider runs | single turn, 5-turn session, 22 to 75 KB context loads |
- This is a personal harness tuned to one operator's workflow. It is not packaged for general installation.
- Model availability depends on the upstream provider. Some models return errors that no client change can fix.
- Long sessions still need manual compaction. Automatic compaction at a window small enough for the character cap proved unstable.
- Tested on Linux with Bun and Node. Windows is untested.
- The tests are config-level. This is not a hosted service, and there is no uptime claim.
bun run test:run # 998 Node tests
bun run test:bun # 143 Bun tests
npx tsc --noEmit # typecheck config, plugins, tools, tests
node skills/vectorize-context/scripts/vectorize.ts --all
node plugins/hubs/data/skills/graph-context/scripts/graph.ts stats --dir .The embeddings and reranker are local. Fetch the model weights once:
npx tsx skills/vectorize-context/scripts/prefetch-models.ts| Page | Covers |
|---|---|
| Architecture | Layers, data flow, extension points |
| Knowledge plane | Graph and vector stores |
| Memory system | Storage, recall, injection |
| Rules and skills | What loads when, and why |
| Hooks | Lifecycle, modes, telemetry |
| Command hooks | Event-driven shell validation |
| ONNX runtime | Local embeddings and reranking |
| Request efficiency | Budget measurement and prompt trimming |
| Hub library | Captured documents and retrieval |
GitHub: @Thomashighbaugh