https://github.com/agnusdei1207/opencode-orchestrator
Opencode Plugin for AI-Agent Orchestration
https://github.com/agnusdei1207/opencode-orchestrator
ai-orchestration opencode rust
Last synced: 2 days ago
JSON representation
Opencode Plugin for AI-Agent Orchestration
- Host: GitHub
- URL: https://github.com/agnusdei1207/opencode-orchestrator
- Owner: agnusdei1207
- License: mit
- Created: 2026-01-13T01:25:07.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-01-29T02:59:48.000Z (4 months ago)
- Last Synced: 2026-02-26T16:50:53.606Z (3 months ago)
- Topics: ai-orchestration, opencode, rust
- Language: TypeScript
- Homepage: https://rdot.agnusdei.kr/
- Size: 42.9 MB
- Stars: 91
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-AI-driven-development - OpenCode Orchestrator - Production-Grade Multi-Agent Orchestration Engine for High-Integrity Software Engineering (Multi-Agent & Orchestration / Other IDEs)
README
---
OpenCode Orchestrator
Production-Grade Multi-Agent Orchestration Engine for High-Integrity Software Engineering
[](LICENSE)
[](https://www.npmjs.com/package/opencode-orchestrator)
**Version:** `1.3.1`
---
## β‘ Quick Start
```bash
npm install -g opencode-orchestrator
```
Install hooks are source-checkout safe, prefer `opencode.jsonc` when present, preserve sibling plugin entries, and skip automatic config mutation in CI environments.
To remove the plugin safely later, run:
```bash
npm explore -g opencode-orchestrator -- npm run cleanup:plugin
npm uninstall -g opencode-orchestrator
```
`npm uninstall -g` does not run dependency uninstall hooks in the npm 11 flow verified for this repo, so config cleanup is explicit.
Inside an OpenCode environment:
```bash
/task "Implement a new authentication module with JWT and audit logs"
```
---
## π Engine Workflow
**Hub-and-Spoke Architecture** with Work-Stealing Queues for parallel, context-isolated task execution.
```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER INPUT /task "..." β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β C O M M A N D E R β β
β β [ Mission Analysis & Delegation ] β β
β β β β
β β β’ Interprets user intent β’ Coordinates multi-agent workflow β β
β β β’ Monitors progress β’ Manages work-stealing queues β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββΌββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β P L A N N E R β β W O R K E R β β W O R K E R β
β [Architect] β β [Implementer] β β [Implementer] β
β β β β β β
β β’ Dependency β β β’ File coding β β β’ File coding β
β analysis β β β’ TDD workflow β β β’ TDD workflow β
β β’ Roadmap gen β β β’ Documentationβ β β’ Documentationβ
β β’ TODO.md β β β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β ββββββββββββββββΌββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββ
β SESSION POOL (MVCC Sync) β
β βββββββββββββββββββββββββββββββββββ β
β β Object Pool β Buffer Pool β β
β β String Pool β Connection Pool β β
β βββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββ
β MSVP MONITOR / REVIEWER β
β βββββββββββββββββββββββββββββββββββ β
β β β’ Adaptive polling (500ms-5s) β β
β β β’ Stability detection β β
β β β’ Unit test verification β β
β βββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββ
β β¨ COMPLETED β
ββββββββββββββββββ
```
---
## ποΈ Architecture Layers
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PRESENTATION LAYER β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β
β β Task Toast β β Progress β β Notificationβ β Mission Summary β β
β β Manager β β Notifier β β Manager β β Display β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BUSINESS LOGIC LAYER β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Parallel Agent Orchestration β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββββββ β β
β β β Commander β β Planner β β Worker β β Reviewer β β β
β β β Agent β β Agent β β Agent β β Agent β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β β Concurrency β β Task Store β β Hook System ββ
β β Controller β β (In-Memory) β β [Early/Normal/Late Phases] ββ
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β INFRASTRUCTURE LAYER β
β ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β Session Pool β β Work-Stealing β β Memory Pools β β
β β [5 per agent] β β [Chase-Lev] β β ββββββββ ββββββββ ββββββββ β
β β [10 reuse max] β β [LIFO/FIFO] β β βObjectβ βStringβ βBufferββ β
β ββββββββββββββββββ ββββββββββββββββββ β β 200 β β internβ β 4KB ββ β
β β ββββββββ ββββββββ ββββββββ β
β ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β MVCC State β β Circuit Breaker β ββββββββββββββββββββββββββββββ β
β β [Atomic Sync] β β [5 failuresβopenβ β Rust Connection Pool β β
β β β β [2 successβcloseβ β [4 processes, 30s idle] β β
β ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SAFETY LAYER β
β ββββββββββββββββββ ββββββββββββββββββ βββββββββββββββββββββββββββββββ β
β β RAII Pattern β β Shutdown β β Auto-Recovery β β
β β [Zero Leaks] β β Manager β β [Exponential Backoff] β β
β β β β [5s timeout] β β [Rate limit handling] β β
β ββββββββββββββββββ ββββββββββββββββββ βββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## π§ͺ Test Utilities
Reusable test helpers keep filesystem, task, and process-heavy flows deterministic:
```
tests/harness/
βββ fixture.ts Disposable tmpdir utilities
β βββ tmpdir() async disposable with cleanup
β βββ tmpdirSync() sync disposable with cleanup
β βββ createMockFs() In-memory fs mock
β βββ waitFor() Async condition waiter
β
βββ builders.ts Factory functions for test objects
β βββ createParallelTask() Build ParallelTask instances
β βββ createBackgroundTask() Build BackgroundTask instances
β βββ createTodo() Build Todo instances
β
βββ mocks.ts Mock utilities
β βββ mockConsole() Spy on console.log/error
β βββ mockProcessExit() Mock process.exit
β βββ useFakeTimers() Time manipulation
β βββ createMockEmitter() EventEmitter spy
β
βββ index.ts Unified exports
```
### Usage Example
```typescript
import { tmpdir, createParallelTask, mockConsole } from "@/tests/harness";
describe("My test", () => {
let consoleMock;
beforeEach(() => {
consoleMock = mockConsole();
consoleMock.setup();
});
afterEach(() => {
consoleMock.restore();
});
it("should work", async () => {
await using tmp = await tmpdir({ git: true });
const task = createParallelTask({ description: "Test" });
expect(task.status).toBe("pending");
});
});
```
---
## β‘ Elite Multi-Agent Swarm
| Agent | Role | Core Responsibilities |
|:------|:-----|:------------------------|
| **Commander** | Mission Hub | Task decomposition, agent coordination, work-stealing orchestration, final mission seal |
| **Planner** | Architect | Dependency analysis, roadmap generation, TODO.md creation via MVCC, file-level planning |
| **Worker** | Implementer | High-throughput coding, TDD workflow, documentation, isolated file execution |
| **Reviewer** | Auditor | Unit test verification, LSP/Lint validation, integration testing, quality gate |
---
## π οΈ Core Capabilities
### π Atomic MVCC State Synchronization
Solves the "Concurrent TODO Update" problem using **MVCC + Mutex**. Agents safely mark tasks complete in parallel without data loss or race conditions. Every state change is cryptographically hashed and logged.
### π§© Advanced Hook Orchestration
Execution flows governed by a **Priority-Phase Hook Registry**. Hooks are grouped into phases (`early`, `normal`, `late`) and executed via **Topological Sort** for predictable, dependency-aware ordering.
### π‘οΈ Autonomous Recovery
- **Self-healing loops** with adaptive stagnation detection
- **Proactive Agency**: Smart monitoring that audits logs and plans ahead during background tasks
- **Auto-retry with backoff**: Exponential backoff for transient failures
### π― State-Level Session Isolation
Reused sessions in the **SessionPool** are explicitly reset via server-side compaction, ensuring previous task context never leaks into new tasks.
### π Zero-Payload Turbo Mode
Leverages `system.transform` to unshift agent instruction sets server-side, reducing initial message payloads by **90%+** and preventing context fragmentation.
### π§ Hierarchical Memory System
Maintains focus across thousands of conversation turns using a 4-tier memory structure with **EMA-based Context Gating** to preserve architectural truth while pruning noise.
### π Adaptive Intelligence Loop
- **Stagnation Detection**: Senses when no progress is made across iterations
- **Diagnostic Intervention**: Forces "Diagnostic Mode" mandating log audits and strategy pivots
- **Proactive Agency**: Mandates Speculative Planning during background task execution
### 𧬠Knowledge Graph RAG (Second Brain)
An autonomous **Obsidian-style evolutionary memory system** that gives agents persistent, searchable knowledge across sessions.
```
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β π Ingest ββββββΆβ π Search ββββββΆβ π§ Recall β
β ββββββββββ β β ββββββββββ β β ββββββββββ β
β YAML Parser β β BM25 Lexicalβ β RRF-Ranked β
β Tag HashMap β β Tag Index β β Top-K Notes β
β Wiki-Links β β 2-Hop Graph β β β Context β
ββββββββ¬ββββββββ ββββββββββββββββ ββββββββββββββββ
β
βΌ
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β π Evolve ββββββΆβ π‘οΈ Guard ββββββΆβ π¦ Archive β
β ββββββββββ β β ββββββββββ β β ββββββββββ β
β Fission β β Cycle DFS β β Orphan GC β
β Fusion β β Write FIFO β β MOC Hubs β
β (Auto-Split β β Keep-Pin β β MD Export β
β & Merge) β β Shield β β β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
```
**Six integrated modules** power the knowledge pipeline:
| Module | Purpose |
|:-------|:--------|
| **TagIndexer** | O(1) YAML frontmatter parsing β tag-to-file HashMap |
| **GraphParser** | `[[wiki-link]]` extraction, bi-directional adjacency graph |
| **HybridSearch** | BM25 + Tag + 2-Hop Graph β **Reciprocal Rank Fusion** (k=60) |
| **Scratchpad** | LRU register cache (64 slots, 4KB max) with markdown persistence |
| **SafetyGuards** | Circular link DFS, async FIFO write queue, keep-pin shield |
| **MemoryConsolidation** | Fission/Fusion/GC/MOC β pure functional analysis |
---
## βοΈ Performance Benchmarks
| Metric | Improvement |
|:-------|:------------|
| CPU Utilization | 90%+ (up from 50-70%) |
| Tool Call Speed | 10x faster (5-10ms vs 50-100ms) via Rust pool |
| Session Creation | 90% faster (50ms vs 500ms) via session pooling |
| Memory Usage | 60% reduction via object/string/buffer pooling |
| GC Pressure | 80% reduction |
| Token Efficiency | 40% reduction via Incremental State & System Transform |
| Sync Accuracy | 99.95% via MVCC+Mutex |
| Parallel Efficiency | 80% improvement (50% β 90%+) |
---
## ποΈ Infrastructure & Reliability
### Resource Safety
- **RAII Pattern**: Guaranteed resource cleanup with zero leaks
- **ShutdownManager**: Priority-based graceful shutdown (5s timeout per handler)
- **Atomic File Operations**: Temp file + rename for corruption-proof writes
- **Automatic Backups**: Timestamped config backups with rollback support
### Safety Features
- **Circuit Breaker**: Auto-recovery from API failures (5 failures β open)
- **Resource Pressure Detection**: Rejects low-priority tasks when memory > 80%
- **Terminal Node Guard**: Prevents infinite recursion via depth limit
- **Auto-Scaling**: Concurrency slots adjust based on success/failure rate
### Technical Stack
- **Runtime**: Node.js 18+ (TypeScript)
- **Tools**: Rust-based CLI tools (grep, glob, ast) via connection pool
- **Concurrency**: Chase-Lev work-stealing deque + priority queues
- **Memory**: Object pooling + string interning + buffer pooling
- **State Management**: MVCC + Mutex
- **Safety**: RAII + circuit breaker + resource pressure detection
- **Knowledge**: In-memory graph RAG with BM25/Tag/Graph search fusion
---
## π§ Installation & Configuration
### Safe Installation
The installation process is **production-safe** with multiple protection layers:
1. β
**Never overwrites** β always merges with existing config
2. β
**Automatic backups** β timestamped, last 5 kept
3. β
**Atomic writes** β temp file + rename (OS-level atomic)
4. β
**Automatic rollback** β restores from backup on any failure
5. β
**Cross-platform** β Windows (native, Git Bash, WSL2), macOS, Linux
6. β
**CI-aware** β skips non-essential operations in CI environments
7. β
**Timeout protection** β 30s timeout prevents hanging
8. β
**Graceful degradation** β exits 0 on non-critical failures
### Safe Removal
OpenCode config cleanup is provided as an explicit command because global package uninstall does not invoke dependency uninstall hooks in the npm flow validated for this package.
```bash
npm explore -g opencode-orchestrator -- npm run cleanup:plugin
npm uninstall -g opencode-orchestrator
```
Manual fallback:
- Open `~/.config/opencode/opencode.json` or `opencode.jsonc`
- Remove `"opencode-orchestrator"` from the `plugin` array
### Configuration Logs
- Unix: `/tmp/opencode-orchestrator.log`
- Windows: `%TEMP%\opencode-orchestrator.log`
---
## π§ͺ Testing & Stability
### Test Utilities
Reusable helpers under `tests/harness/` provide:
- **Disposable tmpdir**: Automatic cleanup with `Symbol.asyncDispose` / `Symbol.dispose`
- **Test builders**: Factory functions for `ParallelTask`, `BackgroundTask`, `Todo`
- **Mock utilities**: Console, process, timers, file system, event emitter mocks
```typescript
import { tmpdir, createParallelTask, mockConsole } from "@/tests/harness";
await using tmp = await tmpdir({ git: true });
const task = createParallelTask({ description: "Test" });
```
### TUI Stability
- **Cleanup guarantees**: `initToastClient()` returns a cleanup function
- **Timeout protection**: AbortController-based 2-10s timeout for async toast operations
- **Error isolation**: Try/catch around all toast operations prevents cascade failures
### Cross-Platform Reliability
- **Windows guard**: Proper handling of WSL2, Git Bash, native Windows paths
- **Signal handling**: Graceful shutdown on SIGINT/SIGTERM
- **Process isolation**: Child process cleanup with timeout
---
## π Documentation
- [System Architecture Deep-Dive β](docs/SYSTEM_ARCHITECTURE.md)
- [Developer Notes β](docs/DEVELOPERS_NOTE.md)
- [Knowledge RAG Roadmap β](docs/histories/2026/05/31/PLAN_SecondBrainOrchestration_2026-05-31.md)
---
## π License
MIT License β see [LICENSE](LICENSE) for details.
---
Built with β‘ for production-grade autonomous software engineering