opencode-orchestrator 0.1.43 → 0.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,21 +1,25 @@
1
- #OpenCode Orchestrator Plugin
1
+ # OpenCode Orchestrator Plugin
2
2
 
3
3
  > **Multi-Agent Plugin for [OpenCode](https://opencode.ai)**
4
4
 
5
- <div align="center">
6
5
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
6
  [![npm](https://img.shields.io/npm/v/opencode-orchestrator.svg)](https://www.npmjs.com/package/opencode-orchestrator)
8
7
  [![npm downloads](https://img.shields.io/npm/dt/opencode-orchestrator.svg)](https://www.npmjs.com/package/opencode-orchestrator)
9
8
  [![OpenCode Plugin](https://img.shields.io/badge/OpenCode-Plugin-purple.svg)](https://opencode.ai)
10
- </div>
9
+
10
+ [English](README.md)
11
11
 
12
12
  ---
13
13
 
14
+ <p align="center">
15
+ <img src="assets/logo.png" width="600" />
16
+ </p>
17
+
14
18
  ## What is this?
15
19
 
16
- A 6-agent collaborative system that turns any LLM into a reliable coding team.
20
+ **OpenCode Orchestrator** is a multi-agent orchestration framework that **abstracts the generative intelligence of LLMs into a structured and reliable computing resource**. It is designed to extract **Ultimate Decision Quality** from affordable, lower-performance models by treating LLM inference as a precision engineering component.
17
21
 
18
- **Core idea**: Break complex tasks into atomic units, verify each step, fix errors automatically.
22
+ **Core Philosophy**: We don't just "chat" with AI. We architect **deterministic execution flows** by decomposing complex missions into atomic, verifiable tasks. By orchestrating specialized agents through a rigorous **PDCA (Plan-Do-Check-Act)** cycle, we maximize the utility of LLM intelligence while ensuring every step is validated by a dedicated Quality Gate.
19
23
 
20
24
  ---
21
25
 
@@ -23,48 +27,50 @@ A 6-agent collaborative system that turns any LLM into a reliable coding team.
23
27
 
24
28
  | Traditional | With Orchestrator |
25
29
  |-------------|-------------------|
26
- | One big prompt Hope it works | Atomic tasks Verified every step |
27
- | Expensive model required | Any model works |
28
- | Errors compound silently | Self-correcting loop |
29
- | Unpredictable results | **Relentless execution until success** |
30
+ | Expensive "Smart" Model required | **Affordable Model + Smart Process** |
31
+ | High Token Costs (Huge Context) | **Token Efficient** (Filtered Context) |
32
+ | Linear, Slow Execution | **Parallel, Fast Execution** |
33
+ | Errors compound silently | **Self-Correcting Verification Loops** |
34
+ | "Hope it works" | **Strategic Micro-Tasking** |
30
35
 
31
36
  ---
32
37
 
33
- ## Features
34
-
35
- - **🦀 Rust Core** — Fast, memory-safe search and analysis tools
36
- - **🧠 Micro-Task Architecture** — Atomic task decomposition for reliability
37
- - **🔄 Self-Correcting Loop** — Every change reviewed, errors auto-fixed
38
- - **👥 6-Agent Team** — Specialized roles working together
39
- - **🛡️ Resilient Execution** — Never stops on errors. Pivots strategy (Plan/Search) until success.
40
- - **⚡ Full Autonomy** — `/auto` is all you need. Relentless execution until 100% complete.
41
- - **🏗️ Rust-Powered Core** — Critical logic written in Rust for **peak performance** and **memory efficiency**.
42
- - **🪶 Thin TS Wrapper** — Minimal JavaScript overhead. The heavy lifting happens in the native binary.
38
+ - **🧩 Strategic Organization** — Maximizing output through intelligent role distribution
39
+ - **📉 Token Economy** — Filtering noise to reduce costs and increase focus
40
+ - **⚡ Parallel DAG** — Concurrent execution for speed and efficiency
41
+ - **🔍 Micro-Tasking** — Atomic decomposition to prevent hallucinations
42
+ - **🛡️ Style Guardian** — Strict AST-based linting and consistency checks
43
+ - **🔄 Self-Healing** — Autonomous pivot strategies for complex errors
44
+ - **🏗️ Rust Core** — Native performance for heavy lifting
43
45
 
44
46
  ---
45
47
 
46
- ## How It Works
48
+ ## How It Works (Parallel DAG)
49
+
50
+ Instead of a linear sequence, we use a **Directed Acyclic Graph (DAG)** to model your mission.
47
51
 
48
52
  ```
49
- User Request
50
-
51
-
52
- ┌─────────┐
53
- PLANNER → Break into atomic tasks
54
- └────┬────┘
55
-
56
-
57
- ┌──────────────────────────────────────────┐
58
- │ For each task: │
59
- │ │
60
- Search Code Review Fix
61
- │ ↑ │ │
62
- └──────────────────────┘
63
- │ (Never gives up) │
64
- └──────────────────────────────────────────┘
65
-
66
-
67
- ✅ Done
53
+ Mission Start (/task)
54
+
55
+
56
+ ┌───────────────┐
57
+ PLANNER (Architect)
58
+ └───────┬───────┘
59
+
60
+ ┌───────┴───────┐
61
+ │ │ (Parallel Streams)
62
+ ▼ ▼
63
+ ┌───────────┐ ┌───────────┐
64
+ Tasks (A) │ │ Tasks (B)
65
+ └─────┬─────┘ └─────┬─────┘
66
+
67
+ └───────┬───────┘
68
+
69
+ ┌───────────────┐
70
+ │ REVIEWER │ (Style Guardian)
71
+ └───────┬───────┘
72
+
73
+ ✅ MISSION COMPLETE
68
74
  ```
69
75
 
70
76
  ---
@@ -87,7 +93,7 @@ bun install -g opencode-orchestrator
87
93
  > The plugin will automatically register itself in `~/.config/opencode/opencode.json` with its absolute path.
88
94
 
89
95
  ### Troubleshooting
90
- If the command `/auto` does not appear:
96
+ If the command `/task` does not appear:
91
97
  1. Uninstall: `npm uninstall -g opencode-orchestrator` (or `bun remove -g`)
92
98
  2. Clear config: `rm -rf ~/.config/opencode` (Warning: resets all plugins)
93
99
  3. Reinstall: `npm install -g opencode-orchestrator`
@@ -95,23 +101,19 @@ If the command `/auto` does not appear:
95
101
 
96
102
  ---
97
103
 
98
- ## Usage
104
+ **The only command you need:**
99
105
 
100
- **Just type one command:**
101
-
102
- ```
103
- /auto "Implement user authentication with JWT"
106
+ ```bash
107
+ /task "Implement user authentication with JWT"
104
108
  ```
105
109
 
106
110
  The Orchestrator will:
107
- 1. **Plan** the architecture
108
- 2. **Search** for context
109
- 3. **Write** the code
110
- 4. **Review** for errors
111
- 5. **Fix** any issues
112
- 6. **Repeat** until 100% verified.
113
-
114
- **This is the only command you need.**
111
+ 1. **Decompose** the mission into a JSON Task DAG
112
+ 2. **Parallel Execute** independent streams
113
+ 3. **Search** proactively for patterns
114
+ 4. **Code** with atomic precision
115
+ 5. **Verify** via the Style Guardian (MANDATORY)
116
+ 6. **Self-Heal** if errors occur
115
117
 
116
118
  ---
117
119
 
@@ -128,10 +130,8 @@ The Orchestrator will:
128
130
 
129
131
  ---
130
132
 
131
- ## Documentation
132
-
133
- - [Architecture](docs/ARCHITECTURE.md) — Detailed workflow
134
- - [Configuration](examples/orchestrator.jsonc) — Customize settings
133
+ - **[System Architecture (Deep Dive)](docs/ARCHITECTURE.md)**: Explore the Distributed Cognitive Architecture (DCA), PDCA Loop, and Actor Model internals.
134
+ - **[Configuration](docs/CONFIGURATION.md)**: `opencode.toml` setup guide.
135
135
 
136
136
  ---
137
137
 
@@ -143,21 +143,59 @@ MIT License. No telemetry. No backdoors.
143
143
 
144
144
  ---
145
145
 
146
- ## Author's Note
146
+ ## License
147
147
 
148
- > My goal is to prove that **affordable models like GLM-4.7** can produce results as good as expensive APIs — when you structure the work right.
149
- >
150
- > Break tasks down, verify every step, fix errors automatically. The model doesn't need to be smart. The process needs to be disciplined.
151
- >
152
- > — [@agnusdei1207](https://github.com/agnusdei1207)
148
+ MIT License. NO WARRANTY.
149
+
150
+ [MIT](LICENSE)
153
151
 
154
152
  ---
155
153
 
156
- ## License
154
+ ## 🏛️ The Architecture: The PDCA & Distributed Cognitive Loop
157
155
 
158
- MIT License. NO WARRANTY.
156
+ We have moved beyond simple "chatbots". **OpenCode Orchestrator** implements a **Deterministic Engineering Layer** built on top of the stochastic nature of LLMs,
157
+ - **Strict PDCA Loop**: Guarantees quality via Plan-Do-Check-Act cycle.
158
+ - **🔍 Micro-tasking**: Atomic decomposition to prevent hallucinations.
159
+ - **🛡️ Style Guardian**: Strict AST-based linting and consistency checks by the Reviewer.
160
+ - **🔄 Self-healing**: Autonomous pivoting strategies for complex errors.
161
+ - **Distributed Cognitive System**: Intelligence layer acting like an OS Kernel.
162
+ - **File-Based State**: Uses physical filesystem as RAM, ignoring context limits.
163
+ We treat agents as **Semantic Compute Units**. By applying rigorous Computer Science principles, we achieve a level of reliability that no single model can match.
159
164
 
160
- [MIT](LICENSE)
165
+ ### 🧬 The "Grand Fusion" of Methodologies
166
+ We explicitly fused three massive domains into one seamless workflow:
167
+
168
+ 1. **PDCA Methodology (Quality Assurance)**:
169
+ * **Plan (Planner)**: Recursively decomposes mission into atomic tasks ($O(log n)$).
170
+ * **Do (Coder)**: Executes the atomic tasks in parallel (Distributed Actions).
171
+ * **Check (Reviewer)**: Acts as a **Byzantine Fault Tolerance** node, strictly validating code against requirements.
172
+ * **Act (Orchestrator)**: Merges successful states or **Pivots** (Dynamic Programming) if failures occur.
173
+
174
+ 2. **Distributed Systems Theory (Actor Model)**:
175
+ * Each agent operates as an independent **Actor** with isolated state.
176
+ * **Context Sharding**: We treat context windows like RAM, paging data in/out via `temp_context` files to simulate **Infinite Context**.
177
+
178
+ 3. **Algorithmic Efficiency**:
179
+ * **Divide & Conquer**: Breaking complex problems into trivial $O(1)$ sub-problems.
180
+ * **Dynamic Programming**: Storing intermediate results (State) to avoid redundant computation and allow for intelligent backtracking.
181
+
182
+ ### 🚀 The Command: `/task`
183
+
184
+ The interface to this system is a single, powerful command:
185
+
186
+ ```bash
187
+ /task "Refactor the authentication middleware and implement JWT rotation"
188
+ ```
189
+
190
+ This triggers the **Distributed Task Loop**. It's not just a chat; it's a mission commitment.
191
+
192
+ ### The 5-Phase Efficiency Workflow
193
+
194
+ 1. **🧠 Phase 1: Filtered Analysis**: The **Searcher** reads docs but filters out noise. We only feed the "critical path" to the Planner.
195
+ 2. **🌲 Phase 2: Strategic Planning**: The **Planner** creates a JSON DAG. This is our roadmap. No token is wasted on aimless wandering.
196
+ 3. **🚀 Phase 3: Parallel Execution**: The **Orchestrator** identifies independent tasks and runs them concurrently.
197
+ 4. **🛡️ Phase 4: Sync & Verify**: The **Reviewer** acts as the gatekeeper. It checks syntax, logic, and *cross-file consistency*.
198
+ 5. **💰 Phase 5: Cost-Effective Completion**: We achieve "Senior Developer" results at "Junior Intern" prices.
161
199
 
162
200
  ---
163
201
 
Binary file
Binary file
Binary file
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { spawn } from "child_process";
5
+ import { join, dirname } from "path";
6
+ import { fileURLToPath } from "url";
7
+ import { platform, arch } from "os";
8
+ import { existsSync } from "fs";
9
+ var __dirname2 = dirname(fileURLToPath(import.meta.url));
10
+ function getBinaryPath() {
11
+ const binDir = join(__dirname2, "..", "bin");
12
+ const os = platform();
13
+ const cpu = arch();
14
+ let binaryName;
15
+ if (os === "win32") {
16
+ binaryName = "orchestrator-windows-x64.exe";
17
+ } else if (os === "darwin") {
18
+ binaryName = cpu === "arm64" ? "orchestrator-macos-arm64" : "orchestrator-macos-x64";
19
+ } else {
20
+ binaryName = cpu === "arm64" ? "orchestrator-linux-arm64" : "orchestrator-linux-x64";
21
+ }
22
+ let binaryPath = join(binDir, binaryName);
23
+ if (!existsSync(binaryPath)) {
24
+ binaryPath = join(binDir, os === "win32" ? "orchestrator.exe" : "orchestrator");
25
+ }
26
+ return binaryPath;
27
+ }
28
+ var binary = getBinaryPath();
29
+ var args = process.argv.slice(2);
30
+ if (!existsSync(binary)) {
31
+ console.error(`Error: Orchestrator binary not found for your platform (${platform()} ${arch()})`);
32
+ console.error(`Expected at: ${binary}`);
33
+ process.exit(1);
34
+ }
35
+ var child = spawn(binary, args, { stdio: "inherit" });
36
+ child.on("close", (code) => {
37
+ process.exit(code || 0);
38
+ });
39
+ child.on("error", (err) => {
40
+ console.error("Failed to start orchestrator binary:", err);
41
+ process.exit(1);
42
+ });
package/dist/index.d.ts CHANGED
@@ -67,6 +67,7 @@ declare const OrchestratorPlugin: (input: PluginInput) => Promise<{
67
67
  tool: string;
68
68
  sessionID: string;
69
69
  callID: string;
70
+ arguments?: any;
70
71
  }, output: {
71
72
  title: string;
72
73
  output: string;
package/dist/index.js CHANGED
@@ -12337,129 +12337,193 @@ function tool(input) {
12337
12337
  return input;
12338
12338
  }
12339
12339
  tool.schema = exports_external;
12340
+ // src/tasks.ts
12341
+ class TaskGraph {
12342
+ tasks = new Map;
12343
+ constructor(tasks) {
12344
+ if (tasks) {
12345
+ tasks.forEach((t) => this.addTask(t));
12346
+ }
12347
+ }
12348
+ addTask(task) {
12349
+ this.tasks.set(task.id, { ...task, status: "pending", retryCount: 0 });
12350
+ }
12351
+ getTask(id) {
12352
+ return this.tasks.get(id);
12353
+ }
12354
+ updateTask(id, updates) {
12355
+ const task = this.tasks.get(id);
12356
+ if (task) {
12357
+ this.tasks.set(id, { ...task, ...updates });
12358
+ }
12359
+ }
12360
+ getReadyTasks() {
12361
+ return Array.from(this.tasks.values()).filter((task) => {
12362
+ if (task.status !== "pending")
12363
+ return false;
12364
+ return task.dependencies.every((depId) => {
12365
+ const dep = this.tasks.get(depId);
12366
+ return dep && dep.status === "completed";
12367
+ });
12368
+ });
12369
+ }
12370
+ isCompleted() {
12371
+ return Array.from(this.tasks.values()).every((t) => t.status === "completed");
12372
+ }
12373
+ hasFailed() {
12374
+ return Array.from(this.tasks.values()).some((t) => t.status === "failed" && t.retryCount >= 3);
12375
+ }
12376
+ getTaskSummary() {
12377
+ const tasks = Array.from(this.tasks.values());
12378
+ const completed = tasks.filter((t) => t.status === "completed");
12379
+ const notCompleted = tasks.filter((t) => t.status !== "completed");
12380
+ let summary = `\uD83D\uDCCB **Mission Status**
12381
+ `;
12382
+ if (completed.length > 0) {
12383
+ summary += `\u2705 Completed: ${completed.length} tasks (Hidden to save tokens)
12384
+ `;
12385
+ }
12386
+ for (const task of notCompleted) {
12387
+ const icon = task.status === "running" ? "\u23F3" : task.status === "failed" ? "\u274C" : "\uD83D\uDCA4";
12388
+ summary += `${icon} [${task.id}] ${task.description}
12389
+ `;
12390
+ }
12391
+ return summary;
12392
+ }
12393
+ toJSON() {
12394
+ return JSON.stringify(Array.from(this.tasks.values()), null, 2);
12395
+ }
12396
+ static fromJSON(json2) {
12397
+ try {
12398
+ const tasks = JSON.parse(json2);
12399
+ return new TaskGraph(tasks);
12400
+ } catch (e) {
12401
+ console.error("Failed to parse TaskGraph JSON:", e);
12402
+ return new TaskGraph;
12403
+ }
12404
+ }
12405
+ }
12406
+
12340
12407
  // src/index.ts
12341
12408
  var __dirname2 = dirname(fileURLToPath(import.meta.url));
12342
12409
  var AGENTS = {
12343
12410
  orchestrator: {
12344
12411
  id: "orchestrator",
12345
- description: "Team leader - delegates atomic tasks, tracks progress, adapts on failure",
12346
- systemPrompt: `You are the Orchestrator - the team leader.
12412
+ description: "Team leader - manages the Mission and parallel work streams",
12413
+ systemPrompt: `You are the Orchestrator - the mission commander.
12347
12414
 
12348
- ## Mission
12349
- Coordinate agents to complete user tasks with ZERO errors.
12350
- Keep iterating until the task is 100% complete and working.
12351
- FAILURE IS NOT AN OPTION. If you get stuck, change strategy.
12415
+ ## Core Philosophy: Micro-Tasking & Quality Gates
12416
+ - Even small models (Phi, Gemma) succeed when tasks are tiny and verified.
12417
+ - Your job is to manage the **Task Mission** (Directed Acyclic Graph).
12418
+ - NEVER proceed to a task if its dependencies are not 100% VERIFIED.
12419
+
12420
+ ## Operational SOP (Standard Operating Procedure)
12421
+ 1. **PHASE 0: TRADE-OFF ANALYSIS**:
12422
+ - **Cost vs. Value**: Is the DAG overhead justified?
12423
+ - **Complexity**: If task is trivial, execute linearly (1-Node DAG).
12424
+ - Only engage full DAG if complexity > 3 or multiple files involved.
12425
+ 2. **ANALYSIS PHASE (THINK FIRST)**:
12426
+ - Call **searcher** to read docs.
12427
+ ## Operational SOP
12428
+ 1. PHASE 0: COMPLEXITY AUDIT. Hotfix (Linear) vs System Overhaul (Flow)?
12429
+ 2. ANALYSIS: MapReduce data. Shard huge context.
12430
+ 3. CONTRACT: Define Interface Agreement (\`_interface_contract.md\`) if parallel dependencies exist.
12431
+ 4. PLAN: Decompose & Alloc. Assign Agents/Tools dynamically.
12432
+ 5. SCHEDULE: Identify ready tasks.
12433
+ 6. EXECUTE: search -> code -> review.
12434
+ 7. GLOBAL SYNC GATE: Reviewer must verify cross-task consistency against Contract.
12435
+ 8. **CLEANUP**: Automatically delete the temporary mission state file (*.mission.md) AND all \`temp_context_*.md\` shards upon completion.
12352
12436
 
12353
- ## Your Team
12354
- - **planner**: Decomposes complex tasks into atomic units
12355
- - **coder**: Implements single atomic task
12356
- - **reviewer**: Quality gate - catches ALL errors
12357
- - **fixer**: Repairs specific errors
12358
- - **searcher**: Finds context before coding
12437
+ ## Verification
12438
+ - Ensure you are not "guessing" libraries.
12439
+ - If a function signature is needed for a parallel task, READ \`_interface_contract.md\`.
12440
+ - If no contract exists, CREATE one.
12359
12441
 
12360
- ## Workflow (Self-Correcting Loop)
12361
- 1. ANALYZE: Understand user request fully
12362
- 2. PLAN: Call planner for complex tasks \u2192 get atomic task list
12363
- 3. FOR EACH atomic task:
12364
- a. CONTEXT: Call searcher if context needed
12365
- b. CODE: Call coder with single atomic task
12366
- c. VERIFY: Call reviewer (MANDATORY after every code change)
12367
- d. FIX: If reviewer finds error \u2192 call fixer \u2192 verify again
12368
- e. LOOP: Repeat fix/verify until PASS.
12369
- 4. NEXT: Move to next task only after current passes
12370
- 5. COMPLETE: All tasks done with all reviews passed
12442
+ ## Global Consistency Rules (Mandatory)
12443
+ - **State Persistence**: Independent nodes MUST communicate via files, not memory.
12444
+ - **Import Sync**: Any export change MUST trigger an update in all importing files.
12445
+ - **Signature Sync**: Function signature changes MUST be propagated to all callers in the same DAG layer.
12446
+ - **Type Sync**: Shared types MUST be modified in isolation before logic implementation.
12447
+ - **Atomic Integrity**: Parallel tasks MUST NOT modify the same line of code in the same file.
12371
12448
 
12372
- ## Atomic Task Examples
12373
- \u2705 "Add validateEmail function to src/utils/validation.ts"
12374
- \u2705 "Fix syntax error in LoginForm.tsx line 42"
12375
- \u2705 "Update import statement in api/routes.ts"
12376
- \u2705 "Add error handling to fetchUser function"
12377
- \u274C "Refactor the entire auth module" (too big)
12378
- \u274C "Fix all bugs" (not atomic)
12449
+ ## Memory Management Strategy (Infinite Context Simulation)
12450
+ - **Sharding**: Never hold raw code in context. Write it to a file, keep the reference.
12451
+ - **Garbage Collection**: If a task is done, summarize its outcome ("Task A: Success, Output at /file/path") and FORGET the details.
12452
+ - **Value Judgment**: Do not summarize "process". Summarize "state changes".
12379
12453
 
12380
- ## Error Recovery Protocol (Resilient Mode)
12381
- - Error from reviewer \u2192 Call fixer with EXACT error details
12382
- - Same error 3 times \u2192 DO NOT STOP.
12383
- - Option A: Call searcher to find better context/examples
12384
- - Option B: Call planner to break task down further
12385
- - Option C: Try a completely different implementation approach
12386
- - Coder confused \u2192 Provide more context from searcher
12454
+ ## Safety & Boundary SOP
12455
+ - **Safety Gate**: Verify alignment with project core before any execution.
12456
+ - **Sync Sentinel**: You are responsible for cross-task logic consistency. If tasks drift, HALT and re-sync.
12387
12457
 
12388
- ## Progress Tracking (show after each step)
12389
- \uD83D\uDCCB Task: [current task]
12390
- \u2705 Completed: [list]
12391
- \u23F3 Remaining: [list]
12392
- \uD83D\uDD04 Retry: [X] (Reset counter if strategy changes)
12458
+ ## Failure Recovery SOP
12459
+ - **Error 1-2**: Call fixer as usual.
12460
+ - **Error 3**: Pivot. Call searcher for similar fixes or planner to split the task further.
12461
+ - **Syntax Error**: Fixer MUST only fix syntax, no logic changes.
12393
12462
 
12394
- ## Critical Rules
12395
- - NEVER skip reviewer after code changes
12396
- - One atomic task at a time
12397
- - NEVER GIVE UP. Find a way.
12398
- - Always show progress`,
12463
+ ## Reliable Execution with Fixed Models
12464
+ - This system is optimized for fixed, low-performance models (Phi, Gemma, etc.).
12465
+ - Performance is achieved through granularity, not model upgrades.
12466
+
12467
+ ## Progress Status
12468
+ Always show the Mission status at the end of your turns:
12469
+ \uD83D\uDCCB Mission Status:
12470
+ [TASK-001] \u2705 Completed
12471
+ [TASK-002] \u23F3 Running
12472
+ [TASK-003] \uD83D\uDCA4 Pending`,
12399
12473
  canWrite: false,
12400
12474
  canBash: false
12401
12475
  },
12402
12476
  planner: {
12403
12477
  id: "planner",
12404
- description: "Task decomposition - creates atomic, verifiable units of work",
12405
- systemPrompt: `You are the Planner - atomic task decomposition expert.
12406
-
12407
- ## Your Job
12408
- Break complex tasks into the SMALLEST possible units that:
12409
- 1. Can be completed independently
12410
- 2. Can be verified by reviewer
12411
- 3. Have clear success criteria
12412
-
12413
- ## Atomic Task Format
12414
- \`\`\`
12415
- [TASK-001] <action verb> + <specific target>
12416
- \u251C\u2500\u2500 File: <exact path>
12417
- \u251C\u2500\u2500 Action: <what to do>
12418
- \u251C\u2500\u2500 Success: <how to verify it worked>
12419
- \u2514\u2500\u2500 Depends: none | TASK-XXX
12420
- \`\`\`
12421
-
12422
- ## What Makes a Task "Atomic"
12423
- - Touches ONE file (or one specific location)
12424
- - Does ONE thing (add function, fix error, update import)
12425
- - Can be reviewed in isolation
12426
- - Has clear pass/fail criteria
12478
+ description: "Architect - decomposes work into a JSON Mission",
12479
+ systemPrompt: `You are the Planner - the master architect.
12427
12480
 
12428
- ## Good Atomic Tasks
12429
- \u2705 "Add validateEmail function to utils/validation.ts"
12430
- \u2705 "Import bcrypt in auth/password.ts"
12431
- \u2705 "Fix missing closing brace in UserForm.tsx line 58"
12432
- \u2705 "Add try-catch to fetchData function in api.ts"
12433
- \u2705 "Update Button component props interface"
12481
+ ## Your Mission
12482
+ 1. **Understand & Filter**: Read documentation, but **FILTER** out irrelevant parts. determine what is truly important.
12483
+ 2. **Hierarchical Decomposition**: Decompose the mission from high-level modules down to sub-atomic micro-tasks.
12484
+ 3. **Mission Generation**: Create a JSON-based Directed Acyclic Graph.
12434
12485
 
12435
- ## Bad Tasks (too large/vague)
12436
- \u274C "Implement authentication" \u2192 break into 5-10 atomic tasks
12437
- \u274C "Fix all errors" \u2192 list specific errors as separate tasks
12438
- \u274C "Refactor module" \u2192 identify specific changes needed
12486
+ ## SOP: Atomic Task Creation
12487
+ - **Thinking Phase**: Summarize *essential* findings only. Discard noise.
12488
+ - **Documentation Alignment**: Read ALL .md files to define project boundaries.
12489
+ - **State Management**: If Task B needs Task A's output, Task A MUST write to a file.
12490
+ - **Single File**: A task should only touch ONE file.
12491
+ - **Single Responsibility**: A task should do ONE thing.
12492
+ - **Verification Ready**: Every task MUST have clear "Success Criteria".
12439
12493
 
12440
- ## Example Decomposition
12441
- Complex task: "Add user login feature"
12494
+ ## Boundary Enforcement
12495
+ - Tasks MUST NOT violate established architectural patterns found in docs.
12496
+ - If a request contradicts documentation, your plan must first address the conflict.
12442
12497
 
12443
- [TASK-001] Create password hashing utility
12444
- \u251C\u2500\u2500 File: src/utils/password.ts
12445
- \u251C\u2500\u2500 Action: Add hashPassword and verifyPassword functions
12446
- \u251C\u2500\u2500 Success: Functions exported and callable
12447
- \u2514\u2500\u2500 Depends: none
12448
-
12449
- [TASK-002] Create User type definition
12450
- \u251C\u2500\u2500 File: src/types/User.ts
12451
- \u251C\u2500\u2500 Action: Add User interface with id, email, passwordHash
12452
- \u251C\u2500\u2500 Success: Type exported and importable
12453
- \u2514\u2500\u2500 Depends: none
12454
-
12455
- [TASK-003] Create login API handler
12456
- \u251C\u2500\u2500 File: src/api/login.ts
12457
- \u251C\u2500\u2500 Action: Add POST handler that validates credentials
12458
- \u251C\u2500\u2500 Success: Handler returns token on valid login
12459
- \u2514\u2500\u2500 Depends: TASK-001, TASK-002
12498
+ ## Output Format (MANDATORY JSON)
12499
+ Produce a JSON array of tasks:
12500
+ \`\`\`json
12501
+ [
12502
+ {
12503
+ "id": "TASK-001",
12504
+ "description": "Create User interface",
12505
+ "action": "Add Interface",
12506
+ "file": "src/types/user.ts",
12507
+ "dependencies": [],
12508
+ "type": "infrastructure",
12509
+ "complexity": 2
12510
+ },
12511
+ {
12512
+ "id": "TASK-002",
12513
+ "description": "Implement User save logic",
12514
+ "action": "Add function saveUser",
12515
+ "file": "src/lib/user.ts",
12516
+ "dependencies": ["TASK-001"],
12517
+ "type": "logic",
12518
+ "complexity": 5
12519
+ }
12520
+ ]
12521
+ \`\`\`
12460
12522
 
12461
- ## Output Format
12462
- List tasks in dependency order. Independent tasks first.`,
12523
+ ## Safety Rules
12524
+ - Break circular dependencies.
12525
+ - Ensure all files are identified by absolute or relative path from project root.
12526
+ - Keep complexity < 7. If higher, split the task.`,
12463
12527
  canWrite: false,
12464
12528
  canBash: false
12465
12529
  },
@@ -12492,6 +12556,7 @@ Provide COMPLETE code that:
12492
12556
  2. Compiles/runs without errors
12493
12557
  3. Matches project style
12494
12558
  4. Includes necessary imports
12559
+ 5. **Persists State**: If this logic is needed by others, ensure it is exposed (exported) or saved to a file.
12495
12560
 
12496
12561
  ## Common Mistakes to Avoid
12497
12562
  - Forgetting closing brackets
@@ -12499,6 +12564,7 @@ Provide COMPLETE code that:
12499
12564
  - Using wrong variable names
12500
12565
  - Type mismatches
12501
12566
  - Breaking existing code
12567
+ - **Silent Failures**: Failing to handle errors in state persistence (file writes).
12502
12568
 
12503
12569
  ## If Unsure
12504
12570
  - Ask for more context
@@ -12516,89 +12582,38 @@ Brief explanation if needed.`,
12516
12582
  },
12517
12583
  reviewer: {
12518
12584
  id: "reviewer",
12519
- description: "Quality gate - comprehensive error detection with specific fix instructions",
12520
- systemPrompt: `You are the Reviewer - quality assurance gate.
12585
+ description: "Style Guardian & Sync Sentinel - ensures total code consistency",
12586
+ systemPrompt: `You are the Reviewer - the Style Guardian and Sync Sentinel.
12521
12587
 
12522
12588
  ## Your Job
12523
- Find ALL issues in the code. Be thorough but specific.
12524
-
12525
- ## Review Checklist
12589
+ 1. **Task Review**: Verify individual code changes (Syntax, Style, Logic).
12590
+ 2. **Global Sync Check**: After parallel changes, verify that all files are in sync.
12591
+ - Do imports match the new exports?
12592
+ - Do function calls match revised signatures?
12593
+ - Is there any logic drift between parallel streams?
12526
12594
 
12527
- ### 1. Syntax (Critical)
12528
- - All brackets paired: { } ( ) [ ]
12529
- - All quotes closed: " ' \`
12530
- - All statements terminated
12531
- - Valid language syntax
12595
+ ## SOP: The 5-Point Check + Sync
12596
+ 1. **SYNTAX**: 100% valid.
12597
+ 2. **STYLE**: Consistent naming and indentation.
12598
+ 3. **LOGIC**: Addresses the task.
12599
+ 4. **INTEGRITY (Sync)**: Cross-file name and signature matching.
12600
+ 5. **DATA FLOW**: Verifies that state persistence (File I/O) is implemented if needed.
12601
+ 6. **SECURITY**: No secrets.
12532
12602
 
12533
- ### 2. Imports & Dependencies
12534
- - All used modules imported
12535
- - Import paths correct
12536
- - No unused imports (warning only)
12537
-
12538
- ### 3. Types (if applicable)
12539
- - Types match declarations
12540
- - No implicit any (warning)
12541
- - Generics correct
12542
-
12543
- ### 4. Logic
12544
- - Code does what task asked
12545
- - Edge cases handled
12546
- - No infinite loops possible
12547
-
12548
- ### 5. Style
12549
- - Matches project conventions
12550
- - Consistent naming
12551
- - Proper indentation
12552
-
12553
- ### 1. Syntax & Formatting (Top Priority)
12554
- - All brackets paired: { } ( ) [ ]
12555
- - Indentation is consistent
12556
- - Semicolons present where needed
12557
- - No obvious syntax typos
12558
-
12559
- ### 2. Consistency & Sync (Critical)
12560
- - Export/Import names match EXACTLY
12561
- - Function signatures match usage (arguments, return types)
12562
-
12563
- ### 7. Security (if applicable)
12564
- - No hardcoded secrets
12565
- - Input validation present
12566
-
12567
- ## Output Format
12568
-
12569
- ### If NO errors:
12603
+ ## Review Results (MANDATORY Format)
12604
+ ### If PASS:
12570
12605
  \`\`\`
12571
- \u2705 PASS
12572
-
12573
- Summary:
12574
- - Checked syntax, types, and imports
12575
- - Verified export/import name consistency
12576
- - Confirmed logic implementation
12577
-
12578
- Status: All checks passed
12606
+ \u2705 PASS (Confidence: 100%)
12607
+ - All individual checks passed.
12608
+ - Global Sync Check: NO drift detected.
12579
12609
  \`\`\`
12580
12610
 
12581
- ### If errors found:
12611
+ ### If FAIL:
12582
12612
  \`\`\`
12583
- \u274C FAIL
12584
-
12585
- [ERROR-001] <category: Syntax | Type | Name Mismatch | Import | Logic>
12586
- \u251C\u2500\u2500 File: <path>
12587
- \u251C\u2500\u2500 Line: <number>
12588
- \u251C\u2500\u2500 Issue: <specific problem>
12589
- \u251C\u2500\u2500 Root Cause: <Typo / Sync Mismatch / Logic Error>
12590
- \u251C\u2500\u2500 Found: \`<problematic code>\`
12591
- \u251C\u2500\u2500 Expected: \`<correct code>\`
12592
- \u2514\u2500\u2500 Fix: <exact fix instruction>
12593
-
12594
- [ERROR-002] ...
12613
+ \u274C FAIL [SYNC-ERROR | STYLE | LOGIC]
12614
+ ...
12595
12615
  \`\`\`
12596
-
12597
- ## Rules
12598
- - Check specifically for 'Name Mismatch' (e.g., export 'foo' vs import 'Foo')
12599
- - Verify function signatures match calls
12600
- - List ALL errors found
12601
- - Be SPECIFIC about location and fix`,
12616
+ `,
12602
12617
  canWrite: false,
12603
12618
  canBash: true
12604
12619
  },
@@ -12619,7 +12634,7 @@ You receive error reports like:
12619
12634
  \u251C\u2500\u2500 Issue: <problem>
12620
12635
  \u251C\u2500\u2500 Found: \`<bad code>\`
12621
12636
  \u251C\u2500\u2500 Expected: \`<good code>\`
12622
- \u2514\u2500\u2500 Fix: <instruction>
12637
+ \u251C\u2500\u2500 Fix: <instruction>
12623
12638
  \`\`\`
12624
12639
 
12625
12640
  ## Fixing Process
@@ -12657,47 +12672,33 @@ You receive error reports like:
12657
12672
  },
12658
12673
  searcher: {
12659
12674
  id: "searcher",
12660
- description: "Context provider - finds patterns, examples, and project conventions",
12661
- systemPrompt: `You are the Searcher - context provider.
12662
-
12663
- ## Your Job
12664
- Find relevant patterns and context BEFORE coder starts working.
12675
+ description: "Context provider - finds documentation and codebase patterns",
12676
+ systemPrompt: `You are the Searcher - the context oracle.
12665
12677
 
12666
- ## Tools
12667
- - grep_search: Find text/code patterns
12668
- - glob_search: Find files by name
12678
+ ## Mission
12679
+ Your primary job is to find the **Truth** in the codebase.
12680
+ In 'Context First' mode, you MUST prioritize reading all .md documentation files.
12669
12681
 
12670
12682
  ## What to Find
12671
- 1. Similar implementations in codebase
12672
- 2. Import patterns and style
12673
- 3. Type definitions being used
12674
- 4. Existing utility functions
12675
- 5. Project conventions
12676
-
12677
- ## Output Format
12678
- \`\`\`
12679
- ### Found Patterns
12680
-
12681
- [PATTERN-1] <name>
12682
- File: <path>
12683
- Relevant code:
12684
- \`\`\`<lang>
12685
- <code snippet>
12686
- \`\`\`
12683
+ 1. **Boundaries**: Read README.md, ARCHITECTURE.md to understand what NOT to do.
12684
+ 2. **Patterns**: Find existing code that solves similar problems.
12685
+ 3. **Types & Interfaces**: Identify the data structures to follow.
12686
+ 4. **Project Style**: Detect naming and formatting conventions.
12687
12687
 
12688
- [PATTERN-2] ...
12688
+ ## SOP
12689
+ 1. Start with \`find_by_name\` for *.md files.
12690
+ 2. Use \`grep_search\` for specific logic patterns.
12691
+ 3. **Value Judgment**: Before reporting, ask "Is this relevant to the CURRENT task step?".
12692
+ 4. **Context Sharding**: If findings are huge, WRITE them to \`temp_context_findings.md\` and only report the path.
12693
+ 5. **Recursive Summarization**: If reading an existing context file, condense it further based on current progress.
12689
12694
 
12690
- ### Recommendations for Coder
12691
- - Use <pattern> from <file>
12692
- - Follow <convention>
12693
- - Import from <path>
12694
- \`\`\`
12695
-
12696
- ## Guidelines
12697
- - Show actual code, not just file paths
12698
- - Focus on most relevant 3-5 findings
12699
- - Note project conventions
12700
- - Warn about gotchas`,
12695
+ ## Output Format
12696
+ Produce a clear summary or a file pointer:
12697
+ "\u26A0\uFE0F Large context detected. Written to \`temp_context_auth_logic.md\`."
12698
+ OR
12699
+ ### 1. Architectural Boundaries (from docs)
12700
+ ### 2. Relevant Patterns (code snippets)
12701
+ ### 3. Recommendations`,
12701
12702
  canWrite: false,
12702
12703
  canBash: false
12703
12704
  }
@@ -12759,8 +12760,8 @@ async function callRustTool(name, args) {
12759
12760
  });
12760
12761
  }
12761
12762
  var state = {
12762
- autoEnabled: false,
12763
- maxIterations: 100,
12763
+ missionActive: false,
12764
+ maxIterations: 1000,
12764
12765
  maxRetries: 3,
12765
12766
  sessions: new Map
12766
12767
  };
@@ -12792,6 +12793,8 @@ var callAgentTool = tool({
12792
12793
  if (!agentDef) {
12793
12794
  return `Error: Unknown agent: ${args.agent}`;
12794
12795
  }
12796
+ const taskIdMatch = args.task.match(/\[(TASK-\d+)\]/i);
12797
+ if (taskIdMatch) {}
12795
12798
  const prompt = `
12796
12799
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
12797
12800
  ${agentDef.id.toUpperCase()} AGENT
@@ -12816,34 +12819,53 @@ Execute according to your role. Be thorough and precise.
12816
12819
  }
12817
12820
  });
12818
12821
  var COMMANDS = {
12819
- auto: {
12820
- description: "Autonomous execution with self-correcting loop",
12821
- template: `\uD83D\uDE80 AUTO MODE - Self-Correcting Agent Loop
12822
+ task: {
12823
+ description: "Execute a mission using Distributed Cognitive Architecture (PDCA Cycle)",
12824
+ template: `\uD83D\uDE80 MISSION: DISTRIBUTED TASK EXECUTION (PDCA Methodology)
12825
+ <command-instruction>
12826
+ You are the **Kernel** of this operation. You employ **Dynamic Programming** and **Divide & Conquer**.
12827
+
12828
+ ## Phase 0: Cost/Benefit & Complexity Analysis
12829
+ - **Assess**: Is this a quick "hotfix" (Linear) or a "System Overhaul" (Distributed Task)?
12830
+ - **Allocating Strategy**: If complex, activate the **Swarm**.
12831
+
12832
+ ## Phase 1: Deep Analysis & State Initialization (Plan)
12833
+ - BEFORE planning, call **searcher** to read all .md docs.
12834
+ - Create a temporary \`.opencode_mission.md\` as your **Shared Memory Segment**.
12835
+ - **State Strategy**: Define how independent nodes will share data (e.g., File I/O, config files).
12836
+
12837
+ ## Phase 1.5: Sync Contract Deal (Interface Agreement)
12838
+ - **CRITICAL**: If parallel tasks interact (e.g., A calls B), you MUST define the **Interface Contract** first.
12839
+ - Create \`_interface_contract.md\` containing:
12840
+ - Exact Function Signatures & Types.
12841
+ - API Routes & Parameter Structures.
12842
+ - File Paths for shared data.
12843
+ - All Agents MUST read this contract before writing code.
12822
12844
 
12823
- ## Protocol
12824
- 1. Call planner to decompose into atomic tasks
12825
- 2. For EACH atomic task:
12826
- - Call searcher if context needed
12827
- - Call coder to implement
12828
- - Call reviewer to verify (MANDATORY)
12829
- - If FAIL: Call fixer \u2192 reviewer again
12830
- - If PASS: Move to next task
12831
- 3. Continue until all tasks complete with PASS
12845
+ ## Phase 2: Hierarchical Planning (Do - Step 1)
12846
+ - Call **planner** to Map the mission into atomic tasks ($O(1)$ complexity).
12847
+ - **Divide & Conquer**: Break down the problem recursively.
12848
+ - **Resource Binding**: Bind specific agents/tools to tasks.
12832
12849
 
12833
- ## Error Recovery (Resilient Strategy)
12834
- - Same error 3x \u2192 DO NOT STOP.
12835
- - Resolve the blocker by finding more context or breaking down the task.
12836
- - Keep iterating until the task is 100% COMPLETE and VERIFIED.
12850
+ ## Phase 3: Parallel Execution & Verification (Do - Step 2 & Check)
12851
+ - Execute READY tasks in parallel. Each agent acts as an independent Actor.
12852
+ - **PDCA Cycle**: Plan -> Do (Code) -> Check (Review) -> Act (Fix/Merge).
12853
+ - Route implementation to the **reviewer** (Byzantine Fault Tolerance check).
12854
+
12855
+ ## Phase 4: Global Sync Gate (Act)
12856
+ - Once all tasks are \u2705 Completed, call **reviewer** for a **Global Consistency Check**.
12857
+ - verify imports, exports, and cross-file logic patterns.
12858
+ - DELETE \`.opencode_mission.md\` after final SUCCESS.
12837
12859
 
12838
12860
  ## Goal
12839
- Complete "$ARGUMENTS" with ZERO errors.
12840
- Relentless execution until absolute success.
12861
+ Achieve **Architectural Superiority**. Complete "$ARGUMENTS" with ZERO regressions.
12862
+ We do NOT stop for time. We stop when it is DONE.
12841
12863
  </command-instruction>
12842
12864
 
12843
12865
  <user-task>
12844
12866
  $ARGUMENTS
12845
12867
  </user-task>`,
12846
- argumentHint: '"task description"'
12868
+ argumentHint: '"mission goal"'
12847
12869
  },
12848
12870
  plan: {
12849
12871
  description: "Decompose task into atomic units",
@@ -12994,7 +13016,7 @@ var OrchestratorPlugin = async (input) => {
12994
13016
  const command = COMMANDS[parsed.command];
12995
13017
  if (command) {
12996
13018
  parts[textPartIndex].text = command.template.replace(/\$ARGUMENTS/g, parsed.args || "continue");
12997
- if (parsed.command === "auto") {
13019
+ if (parsed.command === "task" || parsed.command === "flow" || parsed.command === "dag" || parsed.command === "auto" || parsed.command === "ignite") {
12998
13020
  const sessionID = input2.sessionID;
12999
13021
  state.sessions.set(sessionID, {
13000
13022
  enabled: true,
@@ -13002,21 +13024,28 @@ var OrchestratorPlugin = async (input) => {
13002
13024
  taskRetries: new Map,
13003
13025
  currentTask: ""
13004
13026
  });
13005
- state.autoEnabled = true;
13006
- } else if (parsed.command === "cancel-auto") {
13027
+ state.missionActive = true;
13028
+ } else if (parsed.command === "stop" || parsed.command === "cancel") {
13007
13029
  state.sessions.delete(input2.sessionID);
13008
- state.autoEnabled = false;
13030
+ state.missionActive = false;
13009
13031
  }
13010
13032
  }
13011
13033
  }
13012
13034
  },
13013
13035
  "tool.execute.after": async (input2, output) => {
13014
- if (!state.autoEnabled)
13036
+ if (!state.missionActive)
13015
13037
  return;
13016
13038
  const session = state.sessions.get(input2.sessionID);
13017
13039
  if (!session?.enabled)
13018
13040
  return;
13019
13041
  session.iterations++;
13042
+ if (input2.tool === "call_agent" && input2.arguments?.task) {
13043
+ const taskIdMatch = input2.arguments.task.match(/\[(TASK-\d+)\]/i);
13044
+ if (taskIdMatch) {
13045
+ session.currentTask = taskIdMatch[1].toUpperCase();
13046
+ session.graph?.updateTask(session.currentTask, { status: "running" });
13047
+ }
13048
+ }
13020
13049
  if (session.iterations >= state.maxIterations) {
13021
13050
  session.enabled = false;
13022
13051
  output.output += `
@@ -13026,41 +13055,98 @@ var OrchestratorPlugin = async (input) => {
13026
13055
  Review progress and continue manually.`;
13027
13056
  return;
13028
13057
  }
13029
- const errorMatch = output.output.match(/\[ERROR-(\d+)\]/);
13030
- if (errorMatch) {
13031
- const errorId = `error-${session.currentTask || "unknown"}`;
13032
- const retries = (session.taskRetries.get(errorId) || 0) + 1;
13033
- session.taskRetries.set(errorId, retries);
13034
- if (retries >= state.maxRetries) {
13035
- output.output += `
13058
+ if (output.output.includes("[") && output.output.includes("]") && output.output.includes("{") && input2.tool === "call_agent") {
13059
+ const jsonMatch = output.output.match(/```json\n([\s\S]*?)\n```/) || output.output.match(/\[\s+\{[\s\S]*?\}\s+\]/);
13060
+ if (jsonMatch) {
13061
+ try {
13062
+ const tasks = JSON.parse(jsonMatch[1] || jsonMatch[0]);
13063
+ if (Array.isArray(tasks) && tasks.length > 0) {
13064
+ session.graph = new TaskGraph(tasks);
13065
+ output.output += `
13066
+
13067
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13068
+ \u2705 MISSION INITIALIZED
13069
+ ${session.graph.getTaskSummary()}`;
13070
+ }
13071
+ } catch (e) {}
13072
+ }
13073
+ }
13074
+ if (session.graph) {
13075
+ if (output.output.includes("\u2705 PASS")) {
13076
+ const taskId = session.currentTask;
13077
+ if (taskId) {
13078
+ session.graph.updateTask(taskId, { status: "completed" });
13079
+ session.taskRetries.clear();
13080
+ output.output += `
13081
+
13082
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13083
+ \u2705 TASK ${taskId} VERIFIED
13084
+ ${session.graph.getTaskSummary()}`;
13085
+ }
13086
+ } else if (output.output.includes("\u274C FAIL")) {
13087
+ const taskId = session.currentTask;
13088
+ if (taskId) {
13089
+ const errorId = `error-${taskId}`;
13090
+ const retries = (session.taskRetries.get(errorId) || 0) + 1;
13091
+ session.taskRetries.set(errorId, retries);
13092
+ if (retries >= state.maxRetries) {
13093
+ session.graph.updateTask(taskId, { status: "failed" });
13094
+ output.output += `
13095
+
13096
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13097
+ \u26A0\uFE0F TASK ${taskId} FAILED (Retry Limit)
13098
+ PIVOT REQUIRED: Re-plan or seek context.`;
13099
+ } else {
13100
+ output.output += `
13101
+
13102
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13103
+ \uD83D\uDD04 RETRY ${retries}/${state.maxRetries} for ${taskId}`;
13104
+ }
13105
+ }
13106
+ }
13107
+ } else {
13108
+ const errorMatch = output.output.match(/\[ERROR-(\d+)\]/);
13109
+ if (errorMatch) {
13110
+ const errorId = `error-${session.currentTask || "unknown"}`;
13111
+ const retries = (session.taskRetries.get(errorId) || 0) + 1;
13112
+ session.taskRetries.set(errorId, retries);
13113
+ if (retries >= state.maxRetries) {
13114
+ output.output += `
13036
13115
 
13037
13116
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13038
13117
  \u26A0\uFE0F RETRY LIMIT (${state.maxRetries}x)
13039
- DO NOT GIVE UP.
13040
- SYSTEM ALERT: Stop repeating the same fix.
13041
- REQUIRED: Call 'planner' (break down) or 'searcher' (find context) NOW.`;
13118
+ PIVOT REQUIRED.`;
13119
+ return;
13120
+ }
13121
+ output.output += `
13122
+
13123
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13124
+ \uD83D\uDD04 RETRY ${retries}/${state.maxRetries}`;
13042
13125
  return;
13043
13126
  }
13044
- output.output += `
13127
+ if (output.output.includes("\u2705 PASS")) {
13128
+ session.taskRetries.clear();
13129
+ output.output += `
13045
13130
 
13046
13131
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13047
- \uD83D\uDD04 RETRY ${retries}/${state.maxRetries}
13048
- Apply fix and verify again.`;
13049
- return;
13132
+ \u2705 VERIFIED`;
13133
+ return;
13134
+ }
13050
13135
  }
13051
- if (output.output.includes("\u2705 PASS")) {
13052
- session.taskRetries.clear();
13136
+ if (session.graph) {
13137
+ const readyTasks = session.graph.getReadyTasks();
13138
+ const guidance = readyTasks.length > 0 ? `
13139
+ \uD83D\uDC49 **READY TO EXECUTE**: ${readyTasks.map((t) => `[${t.id}]`).join(", ")}` : `
13140
+ \u26A0\uFE0F NO READY TASKS. Check dependencies or completion.`;
13053
13141
  output.output += `
13054
13142
 
13055
13143
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13056
- \u2705 VERIFIED - Continue to next task
13057
- [${session.iterations}/${state.maxIterations}]`;
13058
- return;
13144
+ ${session.graph.getTaskSummary()}${guidance}`;
13059
13145
  }
13060
13146
  output.output += `
13061
13147
 
13062
13148
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
13063
- [${session.iterations}/${state.maxIterations}]`;
13149
+ [DAG STEP: ${session.iterations}/${state.maxIterations}]`;
13064
13150
  }
13065
13151
  };
13066
13152
  };
@@ -57,7 +57,7 @@ function install() {
57
57
  console.log("\uD83D\uDE80 Ready! Restart OpenCode to use.");
58
58
  console.log("");
59
59
  console.log("Commands:");
60
- console.log(' /auto "task" - Autonomous execution');
60
+ console.log(' /task "goal" - Distributed Cognitive Task (PDCA Cycle)');
61
61
  console.log(' /plan "task" - Decompose into atomic tasks');
62
62
  console.log(" /review - Quality check");
63
63
  console.log("");
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Task management for DAG-based orchestration
3
+ */
4
+ export type TaskStatus = "pending" | "running" | "completed" | "failed";
5
+ export interface Task {
6
+ id: string;
7
+ description: string;
8
+ action: string;
9
+ file: string;
10
+ dependencies: string[];
11
+ status: TaskStatus;
12
+ result?: string;
13
+ retryCount: number;
14
+ complexity: number;
15
+ type: "infrastructure" | "logic" | "integration";
16
+ }
17
+ export declare class TaskGraph {
18
+ private tasks;
19
+ constructor(tasks?: Task[]);
20
+ addTask(task: Task): void;
21
+ getTask(id: string): Task | undefined;
22
+ updateTask(id: string, updates: Partial<Task>): void;
23
+ getReadyTasks(): Task[];
24
+ isCompleted(): boolean;
25
+ hasFailed(): boolean;
26
+ getTaskSummary(): string;
27
+ toJSON(): string;
28
+ static fromJSON(json: string): TaskGraph;
29
+ }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "opencode-orchestrator",
3
- "version": "0.1.43",
4
- "description": "6-Agent collaborative architecture for OpenCode - Make any model reliable",
3
+ "displayName": "OpenCode Orchestrator",
4
+ "description": "Distributed Cognitive Architecture for OpenCode. Turns simple prompts into specialized multi-agent workflows (Planner, Coder, Reviewer).",
5
+ "version": "0.1.48",
5
6
  "author": "agnusdei1207",
6
7
  "license": "MIT",
7
8
  "repository": {
@@ -22,6 +23,9 @@
22
23
  "plugin",
23
24
  "code-generation"
24
25
  ],
26
+ "bin": {
27
+ "orchestrator": "dist/cli.js"
28
+ },
25
29
  "main": "dist/index.js",
26
30
  "types": "dist/index.d.ts",
27
31
  "type": "module",
@@ -38,25 +42,19 @@
38
42
  "LICENSE"
39
43
  ],
40
44
  "scripts": {
41
- "build:rust": "docker compose run --rm dev",
42
- "build:rust:copy": "docker compose run --rm dev sh -c 'cp /app/target/release/orchestrator /app/bin/' && chmod +x bin/orchestrator",
43
- "build:ts": "bun build src/index.ts --outdir dist --target bun --format esm --sourcemap=none && tsc --emitDeclarationOnly",
44
- "build:scripts": "mkdir -p dist/scripts && bun build scripts/postinstall.ts --outdir dist/scripts --target node",
45
- "build": "bun run build:ts && bun run build:scripts",
46
- "build:full": "bun run build:rust && bun run build:rust:copy && bun run build",
45
+ "build:bin:linux-x64": "docker compose run --rm dev sh -c 'cargo build --release && cp target/release/orchestrator bin/orchestrator-linux-x64' && chmod +x bin/orchestrator-linux-x64",
46
+ "build:bin:linux-arm64": "docker compose run --rm dev sh -c 'rustup target add aarch64-unknown-linux-gnu && apt-get update && apt-get install -y gcc-aarch64-linux-gnu && CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu && cp target/aarch64-unknown-linux-gnu/release/orchestrator bin/orchestrator-linux-arm64' && chmod +x bin/orchestrator-linux-arm64",
47
+ "build:bin": "bun run build:bin:linux-x64 && bun run build:bin:linux-arm64",
48
+ "build:js": "bun build src/index.ts --outdir dist --target bun --format esm --sourcemap=none && bun build src/cli.ts --outdir dist --target node --format esm --sourcemap=none && tsc --emitDeclarationOnly && mkdir -p dist/scripts && bun build scripts/postinstall.ts --outdir dist/scripts --target node",
49
+ "build": "bun run build:bin && bun run build:js",
47
50
  "test": "docker compose run --rm test",
48
- "test:local": "cargo test",
49
- "version:patch": "npm version patch --no-git-tag-version",
50
- "version:minor": "npm version minor --no-git-tag-version",
51
- "version:major": "npm version major --no-git-tag-version",
52
- "prepublishOnly": "bun run build",
53
- "publish:npm": "npm publish --access public",
54
- "release:patch": "bun run build:full && bun run test && bun run version:patch && bun run publish:npm && bun run release:git",
55
- "release:minor": "bun run build:full && bun run test && bun run version:minor && bun run publish:npm && bun run release:git",
56
- "release:major": "bun run build:full && bun run test && bun run version:major && bun run publish:npm && bun run release:git",
57
- "release:git": "git add -A && git commit -m \"Release v$(node -p \"require('./package.json').version\")\" && git tag \"v$(node -p \"require('./package.json').version\")\" && git push && git push --tags",
51
+ "release:patch": "bun run build && bun run test && npm version patch --no-git-tag-version && bun run release:ship",
52
+ "release:minor": "bun run build && bun run test && npm version minor --no-git-tag-version && bun run release:ship",
53
+ "release:major": "bun run build && bun run test && npm version major --no-git-tag-version && bun run release:ship",
54
+ "release:ship": "npm publish --access public && git add -A && git commit -m \"v$(node -p \"require('./package.json').version\")\" && git tag \"v$(node -p \"require('./package.json').version\")\" && git push && git push --tags",
58
55
  "postinstall": "node dist/scripts/postinstall.js 2>/dev/null || true",
59
- "stars": "gh api repos/agnusdei1207/opencode-orchestrator/stargazers --jq '.[].login'"
56
+ "prepublishOnly": "bun run build:js",
57
+ "util:stars": "gh api repos/agnusdei1207/opencode-orchestrator/stargazers --jq '.[].login'"
60
58
  },
61
59
  "dependencies": {
62
60
  "@opencode-ai/plugin": "^1.1.1",