Two OpenCode plugins for multi-agent collaboration in software development.
| Plugin | Agents | Philosophy | Best For |
|---|---|---|---|
| Emperor (ไธ็ๅ ญ้จ) | 11 | Governance โ checks & balances | Tasks needing rigorous review |
| Commander | 4 | Engineering โ fast iteration | Most development tasks |
A lightweight, adaptive multi-agent plugin with 4 agents and a single orchestrator pattern. Optimized for speed and tight feedback loops.
graph TD
User["User Task"] --> Lead["Lead<br/>Analyze & Plan"]
Lead -->|trivial| Lead2["Lead handles directly"]
Lead -->|simple/standard/complex| Dispatch["Dispatch Waves"]
Dispatch --> Coder["Coder<br/>Implement"]
Coder --> Tester["Tester<br/>Verify"]
Tester -->|โ fail| Coder
Tester -->|โ
pass| Done["Wave Complete"]
Done -->|complex only| Reviewer["Reviewer<br/>Code Audit"]
Reviewer --> Report["Lead<br/>Final Report"]
Done -->|not complex| Report
| Agent | Role | Responsibility |
|---|---|---|
| Lead | Orchestrator | Explores codebase, creates plans, classifies complexity, summarizes results |
| Coder | Implementer | Writes code based on subtask specs from Lead |
| Tester | Verifier | Runs tests, build verification; triggers fix loop on failure |
| Reviewer | Auditor | Code review for complex tasks only (security, architecture, quality) |
Lead classifies each task automatically:
| Complexity | Condition | Flow |
|---|---|---|
| trivial | No subtasks | Lead handles directly |
| simple | 1 low-effort subtask | Coder โ Tester |
| standard | Multiple subtasks | Parallel waves of Coder โ Tester |
| complex | High-effort or risky | Parallel waves + Reviewer audit |
The core quality mechanism. When Tester fails verification:
- Coder gets failure context (same session โ context accumulates)
- Coder fixes โ Tester re-verifies (same session)
- Repeat up to
maxFixLoops(default: 3) - If still failing โ mark subtask as failed
| Tool | Description |
|---|---|
cmd_task |
Create a task for the Commander team |
cmd_status |
View task status and history |
cmd_halt |
Emergency stop an active task |
Create .opencode/commander.json (optional โ all settings have defaults):
{
"agents": {
"lead": { "model": "anthropic/claude-sonnet-4-20250514" },
"coder": { "model": "anthropic/claude-sonnet-4-20250514" },
"tester": { "model": "anthropic/claude-sonnet-4-20250514" },
"reviewer": { "model": "anthropic/claude-sonnet-4-20250514" }
},
"pipeline": {
"maxFixLoops": 3,
"enableReviewer": true,
"sensitivePatterns": ["ๅ ้ค|remove|delete", "production|deploy", "ๅฏ้ฅ|secret|credential"]
},
"store": {
"dataDir": ".commander"
}
}Switch to the lead agent in OpenCode:
@lead Add user authentication with JWT tokens, refresh mechanism, and role-based access control
Or use the task tool from any agent:
Use cmd_task tool:
title: "User Authentication"
content: "Implement JWT auth, token refresh, RBAC"
priority: "high"
Maps ancient China's Three Departments and Six Ministries governance system into a multi-agent architecture. 11 agents with checks and balances for rigorous task execution.
graph TD
User["User's Edict"] --> Taizi["Crown Prince<br/>Task Triage"]
Taizi --> Jinyiwei["Jinyiwei<br/>Project Reconnaissance"]
Jinyiwei --> Zhongshu["Zhongshu Province<br/>Planning"]
Zhongshu --> Menxia["Menxia Province<br/>Review & Veto"]
Menxia -->|Reject| Zhongshu
Menxia -->|Approve| Shangshu["Shangshu Province<br/>Execution Dispatch"]
Shangshu --> Libu["Libu<br/>Architecture"]
Shangshu --> Hubu["Hubu<br/>Testing"]
Shangshu --> Libu2["Libu2<br/>API Docs"]
Shangshu --> Bingbu["Bingbu<br/>Security Testing"]
Shangshu --> Xingbu["Xingbu<br/>Security Audit"]
Shangshu --> Gongbu["Gongbu<br/>Infrastructure"]
Libu --> Memorial["Memorial Summary"]
Hubu --> Memorial
Libu2 --> Memorial
Bingbu --> Memorial
Xingbu --> Memorial
Gongbu --> Memorial
Memorial --> Taizi
| Agent | Role | Responsibility |
|---|---|---|
| Crown Prince (taizi) | Triage | Receives requests, communicates only with Three Provinces |
| Jinyiwei (jinyiwei) | Reconnaissance | Scans project code, generates architecture reports |
| Zhongshu Province (zhongshu) | Planner | Breaks down tasks, outputs structured JSON plans |
| Menxia Province (menxia) | Reviewer | Reviews plans, can veto and send back |
| Shangshu Province (shangshu) | Dispatcher | Parallel execution dispatch, progress monitoring |
| Libu (libu) | Architect | Code architecture, refactoring, type systems |
| Hubu (hubu) | Tester | Testing and verification (mandatory) |
| Libu2 (libu2) | API Officer | API design, documentation |
| Bingbu (bingbu) | Security Officer | Security testing, performance |
| Xingbu (xingbu) | Auditor | Security audit, compliance (read-only) |
| Gongbu (gongbu) | Engineer | Build tools, CI/CD, infrastructure |
| Tool | Description |
|---|---|
emperor_create_edict |
Create an edict and start the workflow |
emperor_view_memorial |
View execution history and results |
emperor_halt_edict |
Emergency halt an active edict |
See .opencode/emperor.json for configuration options. Key settings:
- reviewMode:
auto/manual/mixed(recommended) - sensitivePatterns: Keywords triggering manual review
- mandatoryDepartments: Departments required in every plan (default:
["hubu"]) - maxPlanningRetries: Max retries when Menxia rejects a plan
@taizi Add user authentication with JWT tokens and role-based access control
| Skill | Description |
|---|---|
taizi-reloaded |
Enhanced Crown Prince with judgment-execution separation |
quick-verify |
Forced pre-delivery verification |
hubu-tester |
Complete verification report template |
menxia-reviewer |
Code security review |
Add plugin paths in .opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"./plugins/emperor/index.ts",
"./plugins/commander/index.ts"
]
}You can enable one or both plugins.
.opencode/
โโโ opencode.json # Plugin registration
โโโ emperor.json # Emperor config (optional)
โโโ commander.json # Commander config (optional)
โโโ plugins/
โโโ emperor/ # Emperor plugin (11 agents)
โ โโโ index.ts
โ โโโ types.ts
โ โโโ config.ts
โ โโโ store.ts
โ โโโ agents/prompts.ts
โ โโโ skills/
โ โโโ engine/
โ โ โโโ pipeline.ts
โ โ โโโ recon.ts
โ โ โโโ reviewer.ts
โ โ โโโ dispatcher.ts
โ โโโ tools/
โ โโโ edict.ts
โ โโโ memorial.ts
โ โโโ halt.ts
โโโ commander/ # Commander plugin (4 agents)
โโโ index.ts
โโโ types.ts
โโโ config.ts
โโโ store.ts
โโโ agents/
โ โโโ lead.ts
โ โโโ coder.ts
โ โโโ tester.ts
โ โโโ reviewer.ts
โโโ engine/
โ โโโ pipeline.ts
โ โโโ classifier.ts
โ โโโ dispatcher.ts
โโโ tools/
โโโ task.ts
โโโ status.ts
โโโ halt.ts
- Runtime: Bun
- Language: TypeScript (strict mode)
- Plugin SDK: @opencode-ai/plugin
- Data Persistence: JSON file storage
Each plugin is published independently to npm:
# Emperor release
git tag emperor-v0.5.1 && git push --tags
# Commander release
git tag commander-v0.1.0 && git push --tagsTag pattern triggers CI to build and publish only the corresponding package.
| Package | npm |
|---|---|
opencode-plugin-emperor |
Emperor plugin |
opencode-plugin-commander |
Commander plugin |