rrce-workflow 0.2.97 → 0.2.98

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
@@ -86,7 +86,7 @@ The easiest way to connect is via the TUI (`npx rrce-workflow mcp` -> **Install*
86
86
 
87
87
  #### OpenCode
88
88
 
89
- RRCE-Workflow integrates with OpenCode both as an MCP server and by providing **Custom Primary Agents**.
89
+ RRCE-Workflow integrates with OpenCode both as an MCP server and by providing a **Primary Orchestrator Agent** plus specialized subagents.
90
90
 
91
91
  1. **Register MCP Server**: Add the following to `~/.config/opencode/opencode.json`:
92
92
  ```json
@@ -102,7 +102,17 @@ RRCE-Workflow integrates with OpenCode both as an MCP server and by providing **
102
102
  }
103
103
  ```
104
104
 
105
- 2. **Install Agents**: Run `npx rrce-workflow` and select **OpenCode** as a tool. This will generate specialized primary agents (Research, Planning, etc.) in `.opencode/agent/` that you can cycle through using the **Tab** key in the OpenCode TUI.
105
+ 2. **Install Agents**: Run `npx rrce-workflow` and select **OpenCode** as a tool. This generates:
106
+ - **Primary Agent (`rrce`)**: Orchestrates the complete workflow lifecycle (tab-switchable)
107
+ - **Subagents** (`@rrce_*`): Specialized agents for each phase (expert mode)
108
+ - **Auto-configuration**: Hides OpenCode's native plan agent to avoid confusion
109
+
110
+ 3. **Usage**:
111
+ - Press `Tab` to cycle to the RRCE agent for structured workflows
112
+ - Build agent can automatically delegate to RRCE for complex tasks
113
+ - Direct subagent access via `@rrce_init`, `@rrce_research`, etc.
114
+
115
+ See [OpenCode Guide](docs/opencode-guide.md) for detailed usage instructions.
106
116
 
107
117
  #### VSCode (with MCP Extension)
108
118
  Add to `.vscode/mcp.json`:
@@ -171,25 +181,43 @@ Stores everything in a `.rrce-workflow` folder inside your project root.
171
181
 
172
182
  ## The Agent Pipeline
173
183
 
174
- Once installed, you gain access to 7 specialized agent workflows. Invoke them via your AI assistant's chat interface or through MCP tools.
184
+ RRCE provides two ways to work with agents, depending on your workflow needs:
185
+
186
+ ### Primary Orchestrator (Recommended for OpenCode)
187
+
188
+ The **RRCE Orchestrator** is a primary agent that manages the complete workflow lifecycle:
189
+
190
+ - **Access**: Press `Tab` in OpenCode to cycle to the RRCE agent
191
+ - **Purpose**: Automatically coordinate research → planning → execution → documentation
192
+ - **Delegation**: Build agent can delegate to RRCE for complex tasks
193
+ - **Benefits**: Results flow back to calling agents, preventing hallucination
194
+
195
+ ### Specialized Subagents
196
+
197
+ For expert control, invoke subagents directly via your AI assistant or MCP tools:
198
+
199
+ | Agent | Invoke With | Purpose | Key Arguments |
200
+ |-------|-------------|---------|---------------|
201
+ | **Init** | `@rrce_init` | Analyze codebase, establish project context and semantic index | `PROJECT_NAME` (optional) |
202
+ | **Research** | `@rrce_research_discussion` | Interactive requirements clarification through dialogue | `TASK_SLUG`, `REQUEST` |
203
+ | **Planning** | `@rrce_planning_discussion` | Transform research into actionable execution plan | `TASK_SLUG` |
204
+ | **Executor** | `@rrce_executor` | Implement the plan - the ONLY agent authorized to modify code | `TASK_SLUG`, `BRANCH` |
205
+ | **Docs** | `@rrce_documentation` | Generate project documentation (API, architecture, changelog) | `DOC_TYPE`, `TASK_SLUG` |
206
+ | **Sync** | `@rrce_sync` | Reconcile knowledge base with current codebase state | `SCOPE` (optional) |
207
+ | **Doctor** | `@rrce_doctor` | Analyze codebase health, identify issues, recommend improvements | `PROJECT_NAME`, `FOCUS_AREA` |
208
+
209
+ ### Workflow Comparison
175
210
 
176
- | Agent | ID | Purpose | Key Arguments |
177
- |-------|----|---------|---------------|
178
- | **Init** | `init` | Analyze codebase, establish project context and semantic index | `PROJECT_NAME` (optional) |
179
- | **Research** | `research_discussion` | Interactive requirements clarification through dialogue | `TASK_SLUG`, `REQUEST` |
180
- | **Planning** | `planning_discussion` | Transform research into actionable execution plan | `TASK_SLUG` |
181
- | **Executor** | `executor` | Implement the plan - the ONLY agent authorized to modify code | `TASK_SLUG`, `BRANCH` |
182
- | **Docs** | `documentation` | Generate project documentation (API, architecture, changelog) | `DOC_TYPE`, `TASK_SLUG` |
183
- | **Sync** | `sync` | Reconcile knowledge base with current codebase state | `SCOPE` (optional) |
184
- | **Doctor** | `doctor` | Analyze codebase health, identify issues, recommend improvements | `PROJECT_NAME`, `FOCUS_AREA` |
211
+ | Approach | When to Use | Example |
212
+ |----------|-------------|---------|
213
+ | **Orchestrator** | Complex features, want automatic flow | Switch to RRCE agent: "Add user authentication" Auto-orchestrates all phases |
214
+ | **Subagents** | Expert control, specific phase needed | `@rrce_executor TASK_SLUG=user-auth` → Direct execution |
215
+ | **Build Delegation** | Want build's help but need structure | Stay in build: "Implement caching" Build delegates to RRCE |
185
216
 
186
217
  ### Recommended Workflow
187
- 1. **`init`**: "Analyze this codebase." → Creates `project-context.md` and semantic index.
188
- 2. **`research_discussion`**: "I need to add user auth." → Interactive requirements gathering.
189
- 3. **`planning_discussion`**: "Create a plan for user auth." Generates implementation checklist.
190
- 4. **`executor`**: "Implement the auth plan." → Writes code, runs tests.
191
- 5. **`documentation`**: "Generate API docs." → Produces release-ready documentation.
192
- 6. **`sync`**: "Update knowledge." → Refreshes context for the next task.
218
+ 1. **`@rrce_init`** (or orchestrator): "Analyze this codebase." → Creates `project-context.md` and semantic index.
219
+ 2. **RRCE Orchestrator**: "I need to add user auth." → Runs research, planning, execution phases automatically.
220
+ 3. **`@rrce_sync`**: "Update knowledge." Refreshes context for the next task.
193
221
 
194
222
  ---
195
223
 
@@ -0,0 +1,350 @@
1
+ ---
2
+ name: RRCE
3
+ description: Orchestrates RRCE workflow lifecycle - initialization, research, planning, execution, and documentation.
4
+ argument-hint: "[PHASE=<init|research|plan|execute|docs>] [TASK_SLUG=<slug>]"
5
+ tools: ['search_knowledge', 'search_code', 'find_related_files', 'get_project_context', 'list_projects', 'list_agents', 'get_agent_prompt', 'list_tasks', 'get_task', 'create_task', 'update_task', 'delete_task', 'index_knowledge', 'resolve_path', 'read', 'write', 'edit', 'bash', 'glob', 'grep', 'task', 'webfetch']
6
+ mode: primary
7
+ required-args: []
8
+ optional-args:
9
+ - name: PHASE
10
+ default: ""
11
+ - name: TASK_SLUG
12
+ default: ""
13
+ auto-identity:
14
+ user: "$GIT_USER"
15
+ model: "$AGENT_MODEL"
16
+ ---
17
+
18
+ You are the RRCE Orchestrator - a primary agent that manages the complete RRCE workflow lifecycle. You delegate work to specialized subagents and coordinate their outputs to deliver comprehensive results.
19
+
20
+ ## Your Role
21
+
22
+ You are **NOT** a subagent. You are a **primary agent** that:
23
+ - Receives requests from users or other agents (like build)
24
+ - Analyzes what phase of work is needed
25
+ - Delegates to specialized RRCE subagents via the Task tool
26
+ - Monitors completion via meta.json and task artifacts
27
+ - Returns synthesized results to the caller
28
+
29
+ ## RRCE Workflow Phases
30
+
31
+ The RRCE workflow has 5 distinct phases, each handled by a specialized subagent:
32
+
33
+ ### 1. **Init** (`@rrce_init`)
34
+ - **When**: First-time project setup or major architecture changes
35
+ - **Output**: `knowledge/project-context.md` + semantic search index
36
+ - **Completion Signal**: File exists and is populated
37
+
38
+ ### 2. **Research** (`@rrce_research_discussion`)
39
+ - **When**: New feature/task needs requirements clarification
40
+ - **Output**: `tasks/{slug}/research/{slug}-research.md`
41
+ - **Completion Signal**: `meta.json → agents.research.status = "complete"`
42
+
43
+ ### 3. **Planning** (`@rrce_planning_discussion`)
44
+ - **When**: After research, need to break down into executable tasks
45
+ - **Requires**: Research must be complete
46
+ - **Output**: `tasks/{slug}/planning/{slug}-plan.md`
47
+ - **Completion Signal**: `meta.json → agents.planning.status = "complete"`
48
+
49
+ ### 4. **Execution** (`@rrce_executor`)
50
+ - **When**: After planning, ready to write code
51
+ - **Requires**: Planning must be complete
52
+ - **Output**: Code changes + `tasks/{slug}/execution/{slug}-execution.md`
53
+ - **Completion Signal**: `meta.json → agents.executor.status = "complete"`
54
+
55
+ ### 5. **Documentation** (`@rrce_documentation`)
56
+ - **When**: After execution, need to document changes
57
+ - **Requires**: Execution complete
58
+ - **Output**: `tasks/{slug}/docs/{slug}-docs.md`
59
+ - **Completion Signal**: `meta.json → agents.documentation.status = "complete"`
60
+
61
+ ## How to Orchestrate
62
+
63
+ ### Step 1: Determine Current State
64
+
65
+ Use MCP tools to understand the current project state:
66
+
67
+ ```
68
+ Tool: rrce_get_project_context
69
+ Args: { "project": "<workspace-name>" }
70
+ ```
71
+
72
+ If project context doesn't exist, you need to run Init first.
73
+
74
+ ### Step 2: Understand the Request
75
+
76
+ Ask yourself:
77
+ - Is this a **new project** needing initialization? → Init
78
+ - Is this a **new feature/task** needing research? → Research
79
+ - Is there **completed research** needing a plan? → Planning
80
+ - Is there a **plan ready** for implementation? → Execution
81
+ - Is there **completed code** needing docs? → Documentation
82
+
83
+ ### Step 3: Check Existing Task State
84
+
85
+ If a TASK_SLUG is provided or implied:
86
+
87
+ ```
88
+ Tool: rrce_get_task
89
+ Args: { "project": "<workspace-name>", "task_slug": "<slug>" }
90
+ ```
91
+
92
+ This returns the meta.json which shows:
93
+ - Which phases are complete (`agents.<phase>.status`)
94
+ - What artifacts exist (`agents.<phase>.artifact`)
95
+ - Any blockers or errors
96
+
97
+ ### Step 4: Delegate to Subagent
98
+
99
+ Use the **Task tool** to invoke the appropriate subagent:
100
+
101
+ ```
102
+ Tool: task
103
+ Args: {
104
+ "description": "Research user authentication feature",
105
+ "prompt": "TASK_SLUG=user-auth REQUEST=\"Add JWT-based auth\" <full context>",
106
+ "subagent_type": "rrce_research_discussion"
107
+ }
108
+ ```
109
+
110
+ **Available subagent types:**
111
+ - `rrce_init` - Project initialization
112
+ - `rrce_research_discussion` - Requirements research
113
+ - `rrce_planning_discussion` - Task planning
114
+ - `rrce_executor` - Code implementation
115
+ - `rrce_documentation` - Documentation generation
116
+
117
+ ### Step 5: Wait for Completion
118
+
119
+ The Task tool will:
120
+ 1. Invoke the subagent in a separate session
121
+ 2. Wait for it to complete
122
+ 3. Return the final summary/result
123
+
124
+ You should also verify completion by checking meta.json:
125
+
126
+ ```
127
+ Tool: rrce_get_task
128
+ Args: { "project": "<workspace-name>", "task_slug": "<slug>" }
129
+ ```
130
+
131
+ Check that `agents.<phase>.status` is now `"complete"`.
132
+
133
+ ### Step 6: Read Artifacts
134
+
135
+ After the subagent completes, read its output artifact:
136
+
137
+ ```
138
+ Tool: read
139
+ Args: { "filePath": "<rrce-data>/tasks/<slug>/<phase>/<slug>-<phase>.md" }
140
+ ```
141
+
142
+ The artifact path is available in meta.json at `agents.<phase>.artifact`.
143
+
144
+ ### Step 7: Return Results
145
+
146
+ Synthesize the results for the caller:
147
+ - Summarize what was accomplished
148
+ - Highlight key findings or decisions
149
+ - Suggest next steps (if any)
150
+ - Provide file references for detailed review
151
+
152
+ ## Example Workflows
153
+
154
+ ### Example 1: User Asks to "Add a new feature"
155
+
156
+ ```
157
+ User: "I need to add user authentication to my app"
158
+
159
+ You (Orchestrator):
160
+ 1. Check if project-context.md exists (rrce_get_project_context)
161
+ 2. Assume no existing task, so this is a new feature
162
+ 3. Create task slug: "user-auth"
163
+ 4. Delegate to Research:
164
+ Task(
165
+ description: "Research user auth requirements",
166
+ prompt: "TASK_SLUG=user-auth REQUEST=\"Add user authentication\" ...",
167
+ subagent_type: "rrce_research_discussion"
168
+ )
169
+ 5. Wait for research to complete
170
+ 6. Read research artifact
171
+ 7. Ask user: "Research complete. Ready to proceed to planning? (This will create an execution plan)"
172
+ 8. If yes, delegate to Planning:
173
+ Task(
174
+ description: "Plan user auth implementation",
175
+ prompt: "TASK_SLUG=user-auth",
176
+ subagent_type: "rrce_planning_discussion"
177
+ )
178
+ 9. Return summary to user with next steps
179
+ ```
180
+
181
+ ### Example 2: Build Agent Delegates "Help implement feature X"
182
+
183
+ ```
184
+ Build Agent: Delegates to you with context about feature X
185
+
186
+ You (Orchestrator):
187
+ 1. Check if feature already has a task
188
+ 2. If no task exists, start with Research
189
+ 3. If research exists but no plan, start Planning
190
+ 4. If plan exists, start Execution
191
+ 5. Return results to build agent with context
192
+ ```
193
+
194
+ ### Example 3: User Asks "What's the status of task Y?"
195
+
196
+ ```
197
+ User: "What's the status of the user-auth task?"
198
+
199
+ You (Orchestrator):
200
+ 1. Use rrce_get_task to retrieve meta.json
201
+ 2. Check agents.*.status for each phase
202
+ 3. Report current state:
203
+ - Research: complete ✓
204
+ - Planning: complete ✓
205
+ - Execution: in_progress (started 2 hours ago)
206
+ - Documentation: pending
207
+ 4. Optionally read execution artifact to see progress details
208
+ ```
209
+
210
+ ## Critical Rules
211
+
212
+ ### 1. **Always Check Prerequisites**
213
+ Before delegating to a phase, verify its prerequisites are met:
214
+ - Planning requires Research complete
215
+ - Execution requires Planning complete
216
+ - Documentation requires Execution complete
217
+
218
+ If prerequisites aren't met, either:
219
+ - Run the prerequisite phase first
220
+ - Ask the user if they want to skip (not recommended)
221
+
222
+ ### 2. **Never Modify Code Directly**
223
+ You are an orchestrator, not an implementer. Code changes are **only** done by the Executor subagent.
224
+
225
+ If you're asked to "implement X", you should:
226
+ - Delegate to Executor if a plan exists
227
+ - Delegate to Research/Planning first if no plan exists
228
+ - Never use edit/write tools on workspace code yourself
229
+
230
+ ### 3. **Track State via meta.json**
231
+ Always use meta.json as the source of truth:
232
+ - Which phases are complete
233
+ - Where artifacts are stored
234
+ - Any errors or blockers
235
+
236
+ ### 4. **Communicate Progress**
237
+ Since you're orchestrating potentially long-running operations:
238
+ - Tell the user/caller what phase you're starting
239
+ - Provide updates if a phase takes time
240
+ - Summarize results when complete
241
+
242
+ ### 5. **Handle Errors Gracefully**
243
+ If a subagent fails:
244
+ - Read the error from meta.json or task result
245
+ - Explain the error to the caller
246
+ - Suggest remediation (e.g., "Research needs more clarification")
247
+ - Don't proceed to next phase if current one failed
248
+
249
+ ### 6. **Respect User Intent**
250
+ If the user explicitly asks for a specific phase (e.g., "just do research"), don't auto-proceed to planning without asking.
251
+
252
+ ## Tool Usage Patterns
253
+
254
+ ### Checking if Init is needed:
255
+ ```typescript
256
+ const context = await rrce_get_project_context({ project: "myproject" });
257
+ if (context.error || !context.content) {
258
+ // Need to run init first
259
+ }
260
+ ```
261
+
262
+ ### Creating a new task:
263
+ ```typescript
264
+ await rrce_create_task({
265
+ project: "myproject",
266
+ task_slug: "feature-slug",
267
+ title: "Feature Title",
268
+ summary: "Brief description"
269
+ });
270
+ ```
271
+
272
+ ### Delegating to subagent:
273
+ ```typescript
274
+ const result = await task({
275
+ description: "Research feature requirements",
276
+ prompt: `TASK_SLUG=feature-slug REQUEST="User's request"
277
+
278
+ Additional context...`,
279
+ subagent_type: "rrce_research_discussion"
280
+ });
281
+ ```
282
+
283
+ ### Checking completion:
284
+ ```typescript
285
+ const taskData = await rrce_get_task({
286
+ project: "myproject",
287
+ task_slug: "feature-slug"
288
+ });
289
+
290
+ if (taskData.agents?.research?.status === "complete") {
291
+ // Research done, can proceed to planning
292
+ }
293
+ ```
294
+
295
+ ## When NOT to Orchestrate
296
+
297
+ You should **decline** and suggest direct invocation when:
298
+ - User wants to manually work with a specific subagent (e.g., "@rrce_research")
299
+ - User is debugging/testing a specific phase
300
+ - Request is outside RRCE's scope (general coding help, questions, etc.)
301
+
302
+ In these cases, explain:
303
+ > "For direct control, you can invoke specific agents: @rrce_init, @rrce_research, @rrce_planning, @rrce_executor, @rrce_documentation. I'm best used for coordinating the full workflow."
304
+
305
+ ## Completion Checklist
306
+
307
+ Before returning results to the caller, ensure:
308
+ - [ ] Appropriate phase(s) completed successfully
309
+ - [ ] Artifacts are written and readable
310
+ - [ ] meta.json reflects completion status
311
+ - [ ] User/caller receives clear summary of what was done
312
+ - [ ] Next steps are communicated (if applicable)
313
+
314
+ ## Knowledge Integration
315
+
316
+ Use semantic search to leverage project knowledge:
317
+ ```
318
+ Tool: rrce_search_knowledge
319
+ Args: { "query": "authentication patterns", "project": "myproject" }
320
+ ```
321
+
322
+ This helps you:
323
+ - Understand existing patterns before delegating
324
+ - Provide better context to subagents
325
+ - Avoid duplicate work
326
+
327
+ ## Your Personality
328
+
329
+ You are:
330
+ - **Organized**: You manage complex workflows systematically
331
+ - **Transparent**: You explain what phase you're running and why
332
+ - **Efficient**: You don't run unnecessary phases
333
+ - **Helpful**: You guide users through the RRCE workflow
334
+ - **Delegative**: You trust subagents to do their specialized work
335
+
336
+ You are NOT:
337
+ - Implementing code yourself
338
+ - Guessing - you check state via MCP tools
339
+ - Proceeding blindly - you verify prerequisites
340
+
341
+ ## Final Notes
342
+
343
+ Remember: You are the **conductor**, not the **musician**. Each RRCE subagent is a specialist. Your job is to:
344
+ 1. Understand what needs to be done
345
+ 2. Invoke the right specialist at the right time
346
+ 3. Monitor their work
347
+ 4. Synthesize results
348
+ 5. Communicate clearly
349
+
350
+ When in doubt, check the state via MCP tools rather than assuming.
@@ -0,0 +1,51 @@
1
+ # RRCE Orchestration Summary
2
+
3
+ **Generated**: {{TIMESTAMP}}
4
+ **Orchestrator**: RRCE Workflow Orchestrator
5
+ **Phases Executed**: {{PHASES_EXECUTED}}
6
+
7
+ ---
8
+
9
+ ## Workflow Execution Summary
10
+
11
+ ### Requested Work
12
+ {{USER_REQUEST}}
13
+
14
+ ### Phases Completed
15
+
16
+ {{#each PHASES}}
17
+ #### {{PHASE_NAME}}
18
+
19
+ **Status**: {{STATUS}}
20
+ **Artifact**: `{{ARTIFACT_PATH}}`
21
+ **Duration**: {{DURATION}}
22
+
23
+ **Key Outcomes:**
24
+ {{OUTCOMES}}
25
+
26
+ **Next Steps:**
27
+ {{NEXT_STEPS}}
28
+
29
+ ---
30
+
31
+ {{/each}}
32
+
33
+ ## Overall Status
34
+
35
+ **Completion**: {{COMPLETION_PERCENTAGE}}%
36
+ **Ready for Next Phase**: {{READY_FOR_NEXT}}
37
+
38
+ ### Artifacts Generated
39
+
40
+ {{#each ARTIFACTS}}
41
+ - [`{{PATH}}`]({{PATH}}) - {{DESCRIPTION}}
42
+ {{/each}}
43
+
44
+ ### Recommendations
45
+
46
+ {{RECOMMENDATIONS}}
47
+
48
+ ---
49
+
50
+ **Session Complete**: {{SESSION_COMPLETE}}
51
+ **Return Summary**: {{RETURN_SUMMARY}}
package/dist/index.js CHANGED
@@ -1031,6 +1031,7 @@ var init_prompt = __esm({
1031
1031
  description: z.string(),
1032
1032
  "argument-hint": z.union([z.string(), z.array(z.string())]).optional(),
1033
1033
  tools: z.array(z.string()).optional(),
1034
+ mode: z.enum(["primary", "subagent"]).optional(),
1034
1035
  "required-args": z.array(PromptArgSchema).optional(),
1035
1036
  "optional-args": z.array(PromptArgSchema).optional(),
1036
1037
  "auto-identity": AutoIdentitySchema.optional()
@@ -5315,7 +5316,7 @@ function copyPromptsToDir(prompts, targetDir, extension) {
5315
5316
  function convertToOpenCodeAgent(prompt, useFileReference = false, promptFilePath) {
5316
5317
  const { frontmatter, content } = prompt;
5317
5318
  const tools = {};
5318
- const hostTools = ["read", "write", "edit", "bash", "grep", "glob", "webfetch", "terminalLastCommand"];
5319
+ const hostTools = ["read", "write", "edit", "bash", "grep", "glob", "webfetch", "terminalLastCommand", "task"];
5319
5320
  if (frontmatter.tools) {
5320
5321
  for (const tool of frontmatter.tools) {
5321
5322
  if (hostTools.includes(tool)) {
@@ -5326,10 +5327,11 @@ function convertToOpenCodeAgent(prompt, useFileReference = false, promptFilePath
5326
5327
  }
5327
5328
  }
5328
5329
  tools["webfetch"] = true;
5329
- const invocationHint = " (Invoke via @rrce_*)";
5330
+ const mode = frontmatter.mode || "subagent";
5331
+ const invocationHint = mode === "primary" ? "" : " (Invoke via @rrce_*)";
5330
5332
  return {
5331
5333
  description: `${frontmatter.description}${invocationHint}`,
5332
- mode: "subagent",
5334
+ mode,
5333
5335
  prompt: useFileReference && promptFilePath ? `{file:${promptFilePath}}` : content,
5334
5336
  tools
5335
5337
  };
@@ -5491,6 +5493,9 @@ async function installAgentPrompts(config, workspacePath, dataPaths) {
5491
5493
  const agentConfig = convertToOpenCodeAgent(prompt, true, `./prompts/${promptFileName}`);
5492
5494
  opencodeConfig.agent[agentId] = agentConfig;
5493
5495
  }
5496
+ if (!opencodeConfig.agent) opencodeConfig.agent = {};
5497
+ if (!opencodeConfig.agent.plan) opencodeConfig.agent.plan = {};
5498
+ opencodeConfig.agent.plan.disable = true;
5494
5499
  fs10.writeFileSync(OPENCODE_CONFIG, JSON.stringify(opencodeConfig, null, 2) + "\n");
5495
5500
  } catch (e) {
5496
5501
  console.error("Failed to update global OpenCode config with agents:", e);
@@ -6131,6 +6136,8 @@ function updateOpenCodeAgents(prompts, mode, primaryDataPath) {
6131
6136
  const agentConfig = convertToOpenCodeAgent(prompt, true, `./prompts/${promptFileName}`);
6132
6137
  opencodeConfig.agent[agentId] = agentConfig;
6133
6138
  }
6139
+ if (!opencodeConfig.agent.plan) opencodeConfig.agent.plan = {};
6140
+ opencodeConfig.agent.plan.disable = true;
6134
6141
  fs21.writeFileSync(OPENCODE_CONFIG, JSON.stringify(opencodeConfig, null, 2) + "\n");
6135
6142
  } catch (e) {
6136
6143
  console.error("Failed to update global OpenCode config with agents:", e);
@@ -0,0 +1,631 @@
1
+ # Using RRCE with OpenCode
2
+
3
+ This guide explains how to use the RRCE workflow orchestrator with OpenCode to build features systematically through research, planning, and execution.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Installation](#installation)
9
+ - [Agent Architecture](#agent-architecture)
10
+ - [Using the RRCE Orchestrator](#using-the-rrce-orchestrator)
11
+ - [Workflow Phases](#workflow-phases)
12
+ - [Common Workflows](#common-workflows)
13
+ - [Advanced Usage](#advanced-usage)
14
+ - [Troubleshooting](#troubleshooting)
15
+
16
+ ---
17
+
18
+ ## Overview
19
+
20
+ RRCE (Research-Research-Code-Execute) workflow integrates with OpenCode as:
21
+ 1. **MCP Server**: Provides project knowledge and semantic search
22
+ 2. **Primary Agent** (`rrce`): Orchestrates the complete workflow lifecycle
23
+ 3. **Subagents**: Specialized agents for each phase (init, research, planning, execution, documentation)
24
+
25
+ ### Why RRCE?
26
+
27
+ Traditional AI coding assistants jump straight to implementation. RRCE enforces a systematic approach:
28
+ 1. **Research** requirements and clarify intent
29
+ 2. **Plan** the implementation with acceptance criteria
30
+ 3. **Execute** the code changes following the plan
31
+ 4. **Document** what was built
32
+
33
+ This reduces hallucinations, improves code quality, and maintains project context.
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ### Prerequisites
40
+
41
+ - Node.js 18+ installed
42
+ - OpenCode installed (`npm install -g opencode`)
43
+
44
+ ### Quick Start
45
+
46
+ ```bash
47
+ # Run the RRCE setup wizard
48
+ npx rrce-workflow
49
+
50
+ # When prompted:
51
+ # 1. Choose your storage mode (Global recommended for OpenCode)
52
+ # 2. Select "OpenCode" as a tool
53
+ # 3. Complete setup
54
+
55
+ # Restart OpenCode
56
+ opencode
57
+ ```
58
+
59
+ ### Verify Installation
60
+
61
+ Check `~/.config/opencode/opencode.json`:
62
+
63
+ ```json
64
+ {
65
+ "$schema": "https://opencode.ai/config.json",
66
+ "mcp": {
67
+ "rrce": {
68
+ "type": "local",
69
+ "command": ["npx", "-y", "rrce-workflow", "mcp", "start"],
70
+ "enabled": true
71
+ }
72
+ },
73
+ "agent": {
74
+ "rrce_orchestrator": {
75
+ "description": "Orchestrates RRCE workflow lifecycle...",
76
+ "mode": "primary",
77
+ "prompt": "{file:./prompts/rrce-orchestrator.md}",
78
+ "tools": { ... }
79
+ },
80
+ "plan": {
81
+ "disable": true // OpenCode's plan agent is hidden
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Agent Architecture
90
+
91
+ ### Primary Agent: RRCE Orchestrator
92
+
93
+ **Agent Name**: `rrce`
94
+ **Mode**: Primary (tab-switchable)
95
+ **Purpose**: Coordinate the full workflow
96
+
97
+ **When to Use:**
98
+ - Starting a new feature or task
99
+ - Want systematic research → planning → execution
100
+ - Need to check task status
101
+ - Building something complex that needs structure
102
+
103
+ **Access**: Press `Tab` to cycle to RRCE agent
104
+
105
+ ### Subagents (Expert Mode)
106
+
107
+ These run automatically via the orchestrator, but you can invoke them directly:
108
+
109
+ | Agent | Invoke With | Purpose |
110
+ |-------|-------------|---------|
111
+ | **Init** | `@rrce_init` | Create project context & semantic index |
112
+ | **Research** | `@rrce_research_discussion` | Clarify requirements, ask questions |
113
+ | **Planning** | `@rrce_planning_discussion` | Break work into tasks with acceptance criteria |
114
+ | **Executor** | `@rrce_executor` | Write code following the plan |
115
+ | **Documentation** | `@rrce_documentation` | Generate docs for completed work |
116
+ | **Doctor** | `@rrce_doctor` | Analyze codebase health |
117
+ | **Sync** | `@rrce_sync` | Update project context |
118
+
119
+ ---
120
+
121
+ ## Using the RRCE Orchestrator
122
+
123
+ ### Method 1: Direct Usage (Switch to RRCE Agent)
124
+
125
+ ```
126
+ 1. Press Tab to switch to RRCE agent
127
+ 2. Type your request:
128
+ "I need to add user authentication with JWT tokens"
129
+ 3. RRCE will:
130
+ ✓ Check if project is initialized
131
+ ✓ Start research phase
132
+ ✓ Ask clarifying questions
133
+ ✓ Generate research brief
134
+ ✓ Ask if you want to proceed to planning
135
+ ✓ Create execution plan
136
+ ✓ Ask if you want to execute
137
+ ✓ Implement the code
138
+ ```
139
+
140
+ ### Method 2: Build Agent Delegation (Automatic)
141
+
142
+ ```
143
+ 1. Stay in Build agent (default)
144
+ 2. Ask: "Help me implement feature X"
145
+ 3. Build will automatically delegate to RRCE
146
+ 4. RRCE orchestrates the workflow
147
+ 5. Results flow back to Build
148
+ 6. Build continues with context
149
+ ```
150
+
151
+ ### What the Orchestrator Does
152
+
153
+ ```mermaid
154
+ graph TD
155
+ A[User Request] --> B{Project Initialized?}
156
+ B -->|No| C[Run Init]
157
+ B -->|Yes| D{Task Exists?}
158
+ D -->|No| E[Create Task<br/>Start Research]
159
+ D -->|Yes| F{Check Phase Status}
160
+ F --> G{Research Complete?}
161
+ G -->|No| E
162
+ G -->|Yes| H{Plan Complete?}
163
+ H -->|No| I[Start Planning]
164
+ H -->|Yes| J{Code Complete?}
165
+ J -->|No| K[Start Execution]
166
+ J -->|Yes| L[Optionally Generate Docs]
167
+
168
+ C --> E
169
+ E --> M[Return Summary]
170
+ I --> M
171
+ K --> M
172
+ L --> M
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Workflow Phases
178
+
179
+ ### Phase 1: Init (First Time Only)
180
+
181
+ **Purpose**: Analyze your codebase and create project context
182
+
183
+ **When**:
184
+ - New project
185
+ - First time using RRCE
186
+ - Major architecture changes
187
+
188
+ **Output**:
189
+ - `knowledge/project-context.md` - Tech stack, patterns, conventions
190
+ - Semantic search index for fast knowledge retrieval
191
+
192
+ **Example**:
193
+ ```
194
+ You: @rrce_init
195
+ RRCE Init: Analyzing codebase...
196
+ Found: TypeScript, React, Express
197
+ Conventions: ESLint, Prettier
198
+ Testing: Vitest
199
+ ✓ Project context saved
200
+ ✓ Semantic index built (342 files)
201
+ ```
202
+
203
+ ### Phase 2: Research
204
+
205
+ **Purpose**: Clarify requirements before coding
206
+
207
+ **When**: Starting any new feature or task
208
+
209
+ **Output**: `tasks/{slug}/research/{slug}-research.md`
210
+
211
+ **What It Does**:
212
+ 1. Asks clarifying questions
213
+ 2. Exposes assumptions and edge cases
214
+ 3. Searches existing knowledge
215
+ 4. Documents requirements and acceptance criteria
216
+
217
+ **Example**:
218
+ ```
219
+ You: I need to add authentication
220
+ RRCE: Starting research phase...
221
+
222
+ Questions:
223
+ 1. What type of auth? (JWT, OAuth, Session-based)
224
+ 2. What's the user model? (email/password, social login)
225
+ 3. Password requirements? (complexity, reset flow)
226
+
227
+ [Interactive Q&A follows]
228
+
229
+ ✓ Research complete
230
+ Artifact: tasks/user-auth/research/user-auth-research.md
231
+
232
+ Ready to proceed to planning?
233
+ ```
234
+
235
+ ### Phase 3: Planning
236
+
237
+ **Purpose**: Break requirements into executable tasks
238
+
239
+ **Requires**: Research complete
240
+
241
+ **Output**: `tasks/{slug}/planning/{slug}-plan.md`
242
+
243
+ **What It Does**:
244
+ 1. Proposes task breakdown
245
+ 2. Defines acceptance criteria per task
246
+ 3. Maps dependencies
247
+ 4. Estimates effort
248
+
249
+ **Example**:
250
+ ```
251
+ RRCE: Planning user-auth implementation...
252
+
253
+ Proposed Tasks:
254
+ 1. Create User model & migration (M) - No dependencies
255
+ 2. Implement JWT service (S) - Requires Task 1
256
+ 3. Add auth middleware (M) - Requires Task 2
257
+ 4. Create login/register endpoints (L) - Requires Task 2,3
258
+ 5. Write integration tests (M) - Requires Task 4
259
+
260
+ Validation Strategy:
261
+ - Unit tests for JWT service
262
+ - Integration tests for auth flow
263
+ - Manual: Try login with valid/invalid credentials
264
+
265
+ Looks good? Any tasks to split or merge?
266
+ ```
267
+
268
+ ### Phase 4: Execution
269
+
270
+ **Purpose**: Implement the code following the plan
271
+
272
+ **Requires**: Planning complete
273
+
274
+ **Output**: Code changes + `tasks/{slug}/execution/{slug}-execution.md`
275
+
276
+ **What It Does**:
277
+ 1. Executes tasks in order
278
+ 2. Runs validation after each task
279
+ 3. Documents what was built
280
+ 4. Captures test results
281
+
282
+ **Example**:
283
+ ```
284
+ RRCE: Starting execution for user-auth...
285
+
286
+ Task 1/5: Create User model & migration
287
+ ✓ Created src/models/User.ts
288
+ ✓ Created migrations/001_create_users.sql
289
+ ✓ Tests pass (3/3)
290
+
291
+ Task 2/5: Implement JWT service
292
+ ✓ Created src/services/jwt.ts
293
+ ✓ Added tests
294
+ ✓ Tests pass (5/5)
295
+
296
+ [Continues through all tasks...]
297
+
298
+ Execution complete!
299
+ Files changed: 8 files (+342 lines)
300
+ Tests: 18/18 passing
301
+ ```
302
+
303
+ ### Phase 5: Documentation (Optional)
304
+
305
+ **Purpose**: Document what was built
306
+
307
+ **Requires**: Execution complete
308
+
309
+ **Output**: `tasks/{slug}/docs/{slug}-docs.md`
310
+
311
+ **What It Does**:
312
+ 1. Generates API documentation
313
+ 2. Updates README if needed
314
+ 3. Creates usage examples
315
+
316
+ ---
317
+
318
+ ## Common Workflows
319
+
320
+ ### Workflow 1: New Feature End-to-End
321
+
322
+ ```
323
+ # Switch to RRCE agent
324
+ Tab → RRCE
325
+
326
+ # Request
327
+ "Add rate limiting to the API"
328
+
329
+ # RRCE will guide you through:
330
+ Research → "Which endpoints? What limits? Per user or global?"
331
+ Planning → "3 tasks: middleware, config, tests"
332
+ Execution → "Implementing... all tests pass ✓"
333
+
334
+ # Result: Feature fully implemented with docs
335
+ ```
336
+
337
+ ### Workflow 2: Build Agent Auto-Delegation
338
+
339
+ ```
340
+ # Stay in Build agent
341
+ Build
342
+
343
+ # Request
344
+ "I need to add caching"
345
+
346
+ # Behind the scenes:
347
+ Build: "This needs structured workflow..."
348
+ → Delegates to RRCE
349
+ RRCE: → Runs research
350
+ → Creates plan
351
+ → Executes code
352
+ → Returns summary to Build
353
+ Build: "Done! I've added Redis caching with these configurations..."
354
+ ```
355
+
356
+ ### Workflow 3: Check Task Status
357
+
358
+ ```
359
+ # Switch to RRCE
360
+ Tab → RRCE
361
+
362
+ # Ask
363
+ "What's the status of user-auth?"
364
+
365
+ # Response
366
+ Task: user-auth
367
+ ✓ Research: Complete (2 days ago)
368
+ ✓ Planning: Complete (1 day ago)
369
+ ⏳ Execution: In progress (started 2 hours ago)
370
+ - Tasks: 3/5 complete
371
+ - Next: Implement auth middleware
372
+ ❌ Documentation: Not started
373
+ ```
374
+
375
+ ### Workflow 4: Resume Interrupted Work
376
+
377
+ ```
378
+ # You left off mid-execution yesterday
379
+ RRCE
380
+
381
+ "Continue the user-auth task"
382
+
383
+ # RRCE checks state:
384
+ "I see user-auth is 60% complete (3/5 tasks done).
385
+ Resuming with Task 4: Create login endpoints..."
386
+ ```
387
+
388
+ ### Workflow 5: Expert Mode (Direct Subagent)
389
+
390
+ ```
391
+ # When you know exactly what phase you need
392
+ @rrce_executor TASK_SLUG=user-auth
393
+
394
+ # Skips orchestration, goes straight to execution
395
+ # (Requires plan to exist)
396
+ ```
397
+
398
+ ---
399
+
400
+ ## Advanced Usage
401
+
402
+ ### Custom Task Creation
403
+
404
+ ```
405
+ RRCE
406
+
407
+ "Create a task called 'optimize-queries' for improving database performance"
408
+
409
+ # RRCE creates task structure:
410
+ tasks/
411
+ optimize-queries/
412
+ meta.json # Task metadata
413
+ research/ # Will be populated
414
+ planning/ # Will be populated
415
+ execution/ # Will be populated
416
+ ```
417
+
418
+ ### Parallel Task Execution
419
+
420
+ ```
421
+ # Start multiple research phases in parallel
422
+ @rrce_research_discussion TASK_SLUG=feature-a REQUEST="..."
423
+ @rrce_research_discussion TASK_SLUG=feature-b REQUEST="..."
424
+
425
+ # Then use orchestrator to manage execution order
426
+ ```
427
+
428
+ ### Knowledge Search Integration
429
+
430
+ RRCE automatically searches your project knowledge:
431
+
432
+ ```
433
+ RRCE: "I found existing auth patterns in your codebase:
434
+ - OAuth integration in src/auth/oauth.ts
435
+ - Session management in src/middleware/session.ts
436
+
437
+ Should we follow these patterns or implement something new?"
438
+ ```
439
+
440
+ ### MCP Tool Access
441
+
442
+ RRCE orchestrator has access to all MCP tools:
443
+
444
+ ```typescript
445
+ // These work automatically:
446
+ rrce_search_knowledge("authentication patterns")
447
+ rrce_get_project_context()
448
+ rrce_list_tasks()
449
+ rrce_get_task("user-auth")
450
+ rrce_search_code("JWT implementation")
451
+ ```
452
+
453
+ ---
454
+
455
+ ## Troubleshooting
456
+
457
+ ### "RRCE agent not showing when I press Tab"
458
+
459
+ **Check**:
460
+ ```bash
461
+ cat ~/.config/opencode/opencode.json | grep rrce_orchestrator
462
+ ```
463
+
464
+ **Fix**:
465
+ ```bash
466
+ npx rrce-workflow # Re-run setup
467
+ ```
468
+
469
+ ### "Build agent still hallucinating agents"
470
+
471
+ **Possible causes**:
472
+ 1. Old OpenCode config cached
473
+ 2. RRCE orchestrator not in primary mode
474
+
475
+ **Fix**:
476
+ ```bash
477
+ # Restart OpenCode completely
478
+ pkill opencode
479
+ opencode
480
+
481
+ # Verify in config:
482
+ # agent.rrce_orchestrator.mode should be "primary"
483
+ ```
484
+
485
+ ### "Can't find project-context.md"
486
+
487
+ **Solution**: Run Init first:
488
+ ```
489
+ @rrce_init
490
+ ```
491
+
492
+ ### "Planning says 'Research not found'"
493
+
494
+ **Issue**: You skipped research phase
495
+
496
+ **Solution**: Complete research first:
497
+ ```
498
+ RRCE → "I need feature X"
499
+ # Let it run research before planning
500
+ ```
501
+
502
+ ### "Execution fails with 'Plan not found'"
503
+
504
+ **Issue**: Skipped planning
505
+
506
+ **Solution**: Run planning phase:
507
+ ```
508
+ @rrce_planning_discussion TASK_SLUG=your-task
509
+ ```
510
+
511
+ ### "Subagent output not reflected in build"
512
+
513
+ **Old behavior** (before orchestrator): This was the bug!
514
+
515
+ **New behavior**: Use RRCE orchestrator (primary agent), not direct subagent invocation. The orchestrator properly returns results to build.
516
+
517
+ ---
518
+
519
+ ## Best Practices
520
+
521
+ ### 1. Always Initialize First
522
+ ```
523
+ New project? Run @rrce_init before anything else
524
+ ```
525
+
526
+ ### 2. Don't Skip Phases
527
+ ```
528
+ ✓ Research → Planning → Execution
529
+ ✗ Jump straight to Execution
530
+ ```
531
+
532
+ ### 3. Use Orchestrator for Workflows
533
+ ```
534
+ ✓ Switch to RRCE agent for full features
535
+ ✗ Manually invoke each subagent
536
+ ```
537
+
538
+ ### 4. Let Build Delegate
539
+ ```
540
+ ✓ Ask build for help, let it delegate to RRCE
541
+ ✓ Build stays in control but uses RRCE's structure
542
+ ```
543
+
544
+ ### 5. Check Status Regularly
545
+ ```
546
+ "What's the status of {task}?"
547
+ # Keeps you informed of progress
548
+ ```
549
+
550
+ ### 6. Review Artifacts
551
+ ```
552
+ # After each phase, read the artifact:
553
+ tasks/{slug}/research/{slug}-research.md
554
+ tasks/{slug}/planning/{slug}-plan.md
555
+ tasks/{slug}/execution/{slug}-execution.md
556
+ ```
557
+
558
+ ---
559
+
560
+ ## Keybindings
561
+
562
+ | Key | Action |
563
+ |-----|--------|
564
+ | `Tab` | Cycle to next primary agent (build → **rrce** → general → explore) |
565
+ | `Shift+Tab` | Cycle to previous primary agent |
566
+ | `Ctrl+X, A` | List all agents (including subagents) |
567
+
568
+ ---
569
+
570
+ ## File Structure
571
+
572
+ After using RRCE, your workspace will have:
573
+
574
+ ```
575
+ .rrce-workflow/ # RRCE data (global or local)
576
+ ├── knowledge/
577
+ │ ├── project-context.md # Generated by Init
578
+ │ └── embeddings.json # Semantic search index
579
+ ├── tasks/
580
+ │ └── {task-slug}/
581
+ │ ├── meta.json # Task metadata & status
582
+ │ ├── research/
583
+ │ │ └── {slug}-research.md
584
+ │ ├── planning/
585
+ │ │ └── {slug}-plan.md
586
+ │ └── execution/
587
+ │ └── {slug}-execution.md
588
+ └── config.yaml # RRCE configuration
589
+
590
+ ~/.config/opencode/
591
+ ├── opencode.json # OpenCode config (agents + MCP)
592
+ └── prompts/
593
+ ├── rrce-orchestrator.md # Primary orchestrator
594
+ ├── rrce-init.md # Subagent prompts
595
+ ├── rrce-research.md
596
+ └── ...
597
+ ```
598
+
599
+ ---
600
+
601
+ ## FAQ
602
+
603
+ **Q: Do I have to use RRCE for everything?**
604
+ A: No! Use build/general for quick tasks. Use RRCE for complex features.
605
+
606
+ **Q: Can I skip research/planning?**
607
+ A: Technically yes (direct subagent), but not recommended. The workflow exists to prevent bugs.
608
+
609
+ **Q: What if I disagree with the plan?**
610
+ A: Tell RRCE! The planning agent will revise based on your feedback.
611
+
612
+ **Q: Can I use RRCE with other agents?**
613
+ A: Yes! Build can delegate to RRCE. You can switch between agents freely.
614
+
615
+ **Q: Does this replace OpenCode's plan agent?**
616
+ A: Yes. RRCE's planning is more comprehensive. OpenCode's plan is auto-disabled.
617
+
618
+ **Q: What's the difference between RRCE primary vs subagents?**
619
+ A: Primary (`rrce`) orchestrates workflows. Subagents (`@rrce_*`) are specialists you can invoke directly.
620
+
621
+ ---
622
+
623
+ ## Support
624
+
625
+ - **Issues**: https://github.com/rryando/rrce-workflow/issues
626
+ - **Docs**: https://github.com/rryando/rrce-workflow/tree/main/docs
627
+ - **MCP Spec**: https://spec.modelcontextprotocol.io
628
+
629
+ ---
630
+
631
+ **Happy building with structured workflows!** 🚀
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rrce-workflow",
3
- "version": "0.2.97",
3
+ "version": "0.2.98",
4
4
  "description": "RRCE-Workflow TUI - Agentic code workflow generator for AI-assisted development",
5
5
  "author": "RRCE Team",
6
6
  "license": "MIT",