rrce-workflow 0.3.7 → 0.3.9

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.
@@ -1,427 +0,0 @@
1
- # RRCE Workflow v2.0 Migration Guide
2
-
3
- **From:** v1.x (Original)
4
- **To:** v2.0 (Token-Optimized)
5
- **Date:** January 2026
6
-
7
- This guide helps you migrate from RRCE v1.x to v2.0, which introduces major token usage optimizations.
8
-
9
- ---
10
-
11
- ## 📋 Migration Checklist
12
-
13
- - [ ] Backup current `agent-core/prompts/` directory
14
- - [ ] Review breaking changes below
15
- - [ ] Update `opencode.json` with new agent configuration
16
- - [ ] Test with a simple workflow
17
- - [ ] Update team documentation
18
-
19
- **Estimated migration time:** 15-30 minutes
20
-
21
- ---
22
-
23
- ## 🔥 Breaking Changes
24
-
25
- ### 1. Prompt Structure Changes
26
-
27
- **What changed:** All subagent prompts significantly reduced in size (70% reduction)
28
-
29
- **Impact:** Agents may behave slightly differently due to streamlined instructions
30
-
31
- | Agent | Old Lines | New Lines | Change |
32
- |-------|-----------|-----------|--------|
33
- | Research | 332 | 80 | -76% |
34
- | Planning | 307 | 80 | -74% |
35
- | Executor | 300+ | 100 | -67% |
36
-
37
- **Migration action:** None required (prompts are backward compatible)
38
-
39
- ---
40
-
41
- ### 2. Hybrid Research Approach
42
-
43
- **What changed:** Research agent now uses "hybrid" clarification:
44
- - Asks only **critical** questions that can't be inferred
45
- - Documents other items as **assumptions**
46
- - Max **2 question rounds** (down from 4)
47
-
48
- **Old behavior:**
49
- ```
50
- Agent: 12 questions across 4 rounds
51
- User: Answers all 12 questions
52
- ```
53
-
54
- **New behavior:**
55
- ```
56
- Agent: 6 critical questions across 2 rounds
57
- Agent: Documents 6 other items as assumptions (with confidence levels)
58
- ```
59
-
60
- **Migration action:**
61
- - Review generated research briefs
62
- - Check "Assumptions" section for documented inferences
63
- - If too aggressive, edit `agent-core/prompts/research_discussion.md` line 52:
64
- ```markdown
65
- **STOP after 3 rounds.** (increase from 2 to 3)
66
- ```
67
-
68
- ---
69
-
70
- ### 3. Auto-Progression in Orchestrator
71
-
72
- **What changed:** Orchestrator now auto-progresses through phases based on user intent (no confirmation prompts)
73
-
74
- **Old behavior:**
75
- ```
76
- Orchestrator: Research complete! Ready to proceed to planning? (Y/n)
77
- User: yes
78
- Orchestrator: Starting planning...
79
- ```
80
-
81
- **New behavior:**
82
- ```
83
- Orchestrator: (Detects user wants implementation, auto-proceeds to planning → execution)
84
- ```
85
-
86
- **Migration action:**
87
- - If you prefer manual control, use direct subagent invocation:
88
- ```
89
- @rrce_research_discussion TASK_SLUG=x REQUEST="..."
90
- @rrce_planning_discussion TASK_SLUG=x
91
- @rrce_executor TASK_SLUG=x
92
- ```
93
- - Orchestrator is now recommended **only** for full automation
94
-
95
- ---
96
-
97
- ### 4. Provider Caching Configuration (Model-Agnostic)
98
-
99
- **What changed:** RRCE now enables provider caching for ALL providers, but does NOT force specific models
100
-
101
- **New behavior:**
102
- - `setCacheKey: true` enabled for Anthropic, OpenAI, OpenRouter, Google
103
- - **No hardcoded models** - you choose what model to use
104
- - Prompt caching activates automatically for any model that supports it
105
-
106
- **Recommended models** (optional, for cost optimization):
107
-
108
- | Agent | Recommendation | Rationale |
109
- |-------|----------------|-----------|
110
- | Research | Haiku/Mini | Q&A doesn't need heavy reasoning |
111
- | Planning | Sonnet/GPT-4o | Task breakdown needs reasoning |
112
- | Executor | Sonnet/GPT-4o | Code generation needs power |
113
-
114
- **To set models per agent (optional):**
115
- ```json
116
- {
117
- "agent": {
118
- "rrce_research_discussion": {
119
- "model": "anthropic/claude-haiku-4-20250514"
120
- }
121
- }
122
- }
123
- ```
124
-
125
- **Migration action:** None required - caching is automatic
126
-
127
- ---
128
-
129
- ### 5. Session State Management
130
-
131
- **What changed:** Agents now cache knowledge searches across conversation turns
132
-
133
- **Old behavior:**
134
- ```
135
- Turn 1: Search knowledge for "auth patterns"
136
- Turn 2: Search knowledge for "auth patterns" AGAIN
137
- Turn 3: Search knowledge for "auth patterns" AGAIN
138
- ```
139
-
140
- **New behavior:**
141
- ```
142
- Turn 1: Search knowledge for "auth patterns" ONCE, store results
143
- Turn 2: Reference cached results
144
- Turn 3: Reference cached results
145
- ```
146
-
147
- **Impact:** ~5K tokens saved per session
148
-
149
- **Migration action:** None required (automatic optimization)
150
-
151
- **Note:** Agents will only re-search if you introduce **completely new scope**
152
-
153
- ---
154
-
155
- ## ✅ What's Preserved (Non-Breaking)
156
-
157
- ### No Changes to These Areas:
158
-
159
- 1. **MCP Server Interface:** All MCP tools (`rrce_search_knowledge`, `rrce_get_task`, etc.) unchanged
160
- 2. **Task Structure:** `meta.json` format and artifact locations unchanged
161
- 3. **File Paths:** `{{RRCE_DATA}}`, `{{WORKSPACE_ROOT}}` resolution unchanged
162
- 4. **Agent Names:** `@rrce_research_discussion`, `@rrce_planning_discussion`, etc. unchanged
163
- 5. **Workflow Phases:** Research → Planning → Execution sequence unchanged
164
- 6. **Artifact Templates:** Research brief, planning doc, execution log formats unchanged
165
-
166
- ---
167
-
168
- ## 🚀 Migration Steps
169
-
170
- ### Step 1: Backup Current Configuration
171
-
172
- ```bash
173
- # Backup prompts
174
- cp -r agent-core/prompts agent-core/prompts.backup
175
-
176
- # Backup OpenCode config (if you have custom settings)
177
- cp ~/.config/opencode/opencode.json ~/.config/opencode/opencode.json.backup
178
- ```
179
-
180
- ### Step 2: Pull Latest Changes
181
-
182
- ```bash
183
- cd /path/to/rrce-workflow
184
- git pull origin main
185
- ```
186
-
187
- **Or install via npm:**
188
- ```bash
189
- npm install -g rrce-workflow@latest
190
- ```
191
-
192
- ### Step 3: Update OpenCode Configuration
193
-
194
- Add to `~/.config/opencode/opencode.json` or project `opencode.json`:
195
-
196
- ```json
197
- {
198
- "agent": {
199
- "rrce_research_discussion": {
200
- "description": "Interactive research and requirements clarification (optimized for direct invocation)",
201
- "mode": "subagent",
202
- "model": "anthropic/claude-haiku-4-20250514",
203
- "temperature": 0.2
204
- },
205
- "rrce_planning_discussion": {
206
- "description": "Transform research into actionable execution plan (balanced reasoning)",
207
- "mode": "subagent",
208
- "model": "anthropic/claude-sonnet-4-20250514",
209
- "temperature": 0.1
210
- },
211
- "rrce_executor": {
212
- "description": "Execute planned tasks - ONLY agent authorized to modify source code",
213
- "mode": "subagent",
214
- "model": "anthropic/claude-sonnet-4-20250514",
215
- "temperature": 0.3
216
- }
217
- }
218
- }
219
- ```
220
-
221
- **Note:** Copy the full configuration from `opencode.json` in this repo
222
-
223
- ### Step 4: Restart OpenCode
224
-
225
- ```bash
226
- # Kill existing OpenCode processes
227
- pkill opencode
228
-
229
- # Start OpenCode
230
- opencode
231
- ```
232
-
233
- ### Step 5: Test Migration
234
-
235
- Run a simple research workflow:
236
-
237
- ```
238
- @rrce_research_discussion TASK_SLUG=test-migration REQUEST="Test the migration by researching a simple feature"
239
- ```
240
-
241
- **Verify:**
242
- - Agent asks fewer questions (2 rounds max)
243
- - Agent uses Haiku model (check logs: should show `claude-haiku`)
244
- - Token usage is significantly lower (check API logs)
245
-
246
- ### Step 6: Review and Adjust
247
-
248
- **If research is too brief:**
249
- Edit `agent-core/prompts/research_discussion.md`:
250
- ```markdown
251
- **STOP after 3 rounds.** (increase from default 2)
252
- ```
253
-
254
- **If research is using wrong model:**
255
- Check `opencode.json` - verify Haiku is configured
256
-
257
- **If orchestrator auto-progresses too aggressively:**
258
- Use direct subagent invocation instead:
259
- ```
260
- @rrce_research_discussion (manual control)
261
- @rrce_planning_discussion (manual control)
262
- @rrce_executor (manual control)
263
- ```
264
-
265
- ---
266
-
267
- ## 🔍 Validation Tests
268
-
269
- ### Test 1: Token Usage Reduction
270
-
271
- **Run:**
272
- ```
273
- @rrce_research_discussion TASK_SLUG=token-test REQUEST="Research adding a new API endpoint"
274
- ```
275
-
276
- **Check token usage** (in provider dashboard or OpenCode logs)
277
-
278
- **Expected:**
279
- - First turn: ~5K tokens (down from ~20K)
280
- - Second turn: ~2K tokens (cached!)
281
- - Third turn: ~2K tokens (cached!)
282
-
283
- ### Test 2: Knowledge Caching
284
-
285
- **Verify** agent doesn't re-search on subsequent turns:
286
-
287
- 1. Start research
288
- 2. On first turn, note what knowledge agent found
289
- 3. On second turn, agent should **reference** findings (not re-search)
290
- 4. Check logs: `rrce_search_knowledge` should appear only once
291
-
292
- ### Test 3: Hybrid Clarification
293
-
294
- **Verify** agent asks fewer questions:
295
-
296
- **v1.0 behavior:** 10-12 questions across 4 rounds
297
- **v2.0 behavior:** 6-8 questions across 2 rounds + documented assumptions
298
-
299
- **Check:** Research brief should have "Assumptions" section with confidence levels
300
-
301
- ---
302
-
303
- ## 📊 Expected Performance Improvements
304
-
305
- | Metric | v1.0 | v2.0 | Improvement |
306
- |--------|------|------|-------------|
307
- | Research tokens (3 rounds) | 66K | 16K | **76%** |
308
- | Research cost | $0.20 | $0.004 | **98%** |
309
- | Planning tokens | 44K | 19K | **57%** |
310
- | Full workflow tokens | 150K | 53K | **65%** |
311
- | Full workflow cost | $0.45 | $0.16 | **64%** |
312
- | Latency | ~120s | ~70s | **42%** |
313
-
314
- ---
315
-
316
- ## 🐛 Troubleshooting
317
-
318
- ### "Agent still using Sonnet for research"
319
-
320
- **Cause:** OpenCode config not loaded
321
-
322
- **Fix:**
323
- 1. Verify `opencode.json` exists in project root OR global config
324
- 2. Restart OpenCode completely: `pkill opencode && opencode`
325
- 3. Check logs for model selection
326
-
327
- ---
328
-
329
- ### "Token usage not reduced"
330
-
331
- **Possible causes:**
332
- 1. **Not continuing in same session:** Each new chat = no cache benefit
333
- 2. **Using orchestrator:** Orchestrator has overhead, use direct invocation
334
- 3. **Modified prompts:** Custom edits may increase token usage
335
-
336
- **Fix:**
337
- - Continue conversations in same session (don't start new chat)
338
- - Use `@rrce_*` directly instead of orchestrator
339
- - Compare your prompts with v2.0 defaults
340
-
341
- ---
342
-
343
- ### "Research too brief, missing important questions"
344
-
345
- **Cause:** Hybrid approach may be too aggressive for your use case
346
-
347
- **Fix:**
348
- Increase question rounds in `agent-core/prompts/research_discussion.md`:
349
-
350
- ```markdown
351
- ### 2. Focused Clarification (Hybrid Approach - Max 3 Rounds) # Change from 2 to 3
352
-
353
- ...
354
-
355
- **STOP after 3 rounds.** # Change from 2 to 3
356
- ```
357
-
358
- Or switch to "ask-first" mode:
359
-
360
- ```markdown
361
- **Ask ALL critical questions** that can't be inferred from knowledge.
362
- Document only obvious assumptions.
363
- ```
364
-
365
- ---
366
-
367
- ### "Orchestrator still prompting for confirmation"
368
-
369
- **Cause:** Old prompt cached in OpenCode
370
-
371
- **Fix:**
372
- 1. Clear OpenCode cache: `rm -rf ~/.cache/opencode`
373
- 2. Restart OpenCode
374
- 3. Verify updated `orchestrator.md` is being used
375
-
376
- ---
377
-
378
- ## 🔄 Rollback Instructions
379
-
380
- If you need to revert to v1.0:
381
-
382
- ### Step 1: Restore Backups
383
-
384
- ```bash
385
- # Restore prompts
386
- rm -rf agent-core/prompts
387
- mv agent-core/prompts.backup agent-core/prompts
388
-
389
- # Restore OpenCode config
390
- mv ~/.config/opencode/opencode.json.backup ~/.config/opencode/opencode.json
391
- ```
392
-
393
- ### Step 2: Downgrade Package
394
-
395
- ```bash
396
- npm install -g rrce-workflow@1.x
397
- ```
398
-
399
- ### Step 3: Restart OpenCode
400
-
401
- ```bash
402
- pkill opencode && opencode
403
- ```
404
-
405
- ---
406
-
407
- ## 📚 Additional Resources
408
-
409
- - [Token Optimization Guide](./opencode-guide-optimization-addendum.md)
410
- - [Main RRCE Guide](./opencode-guide.md)
411
- - [Architecture Documentation](./architecture.md)
412
- - [OpenCode Documentation](https://opencode.ai/docs)
413
-
414
- ---
415
-
416
- ## 🤝 Support
417
-
418
- **Issues or questions?**
419
- - GitHub Issues: https://github.com/rryando/rrce-workflow/issues
420
- - Discord: (if available)
421
-
422
- ---
423
-
424
- **Migration completed?** Mark the checklist at the top ✓
425
-
426
- **Last Updated:** January 2026
427
- **Version:** 2.0
@@ -1,231 +0,0 @@
1
- # RRCE Token Optimization - Quick Start
2
-
3
- **Version:** 2.0
4
- **Status:** Production Ready
5
- **Last Updated:** January 2026
6
-
7
- ---
8
-
9
- ## 🎯 What This Is
10
-
11
- Major token optimization update for RRCE workflow that reduces token usage by **65%** while maintaining quality.
12
-
13
- **Key improvements:**
14
- - ✅ Prompt sizes reduced by 70-93%
15
- - ✅ Session reuse with prompt caching (90% reduction on turn 2+)
16
- - ✅ Smart RAG caching (no redundant searches)
17
- - ✅ Cost-optimized models (Haiku for research, Sonnet for execution)
18
- - ✅ Auto-progression (eliminates confirmation prompts)
19
-
20
- ---
21
-
22
- ## 📊 Quick Stats
23
-
24
- | Metric | Before | After | Improvement |
25
- |--------|--------|-------|-------------|
26
- | **Prompt Size** | ~15K tokens | ~4K tokens | **73%** |
27
- | **Full Workflow** | 150K tokens | 53K tokens | **65%** |
28
- | **Cost** | $0.45 | $0.16 | **64%** |
29
- | **Latency** | ~120s | ~70s | **42%** |
30
-
31
- ---
32
-
33
- ## 🚀 Quick Start
34
-
35
- ### For New Users
36
-
37
- 1. **Install RRCE:**
38
- ```bash
39
- npx rrce-workflow
40
- ```
41
-
42
- 2. **The optimization is already included!** No extra steps needed.
43
-
44
- 3. **Use direct subagent invocation** (most efficient):
45
- ```
46
- @rrce_research_discussion TASK_SLUG=my-feature REQUEST="..."
47
- @rrce_planning_discussion TASK_SLUG=my-feature
48
- @rrce_executor TASK_SLUG=my-feature
49
- ```
50
-
51
- ---
52
-
53
- ### For Existing Users
54
-
55
- 1. **Read the migration guide:**
56
- - [`docs/MIGRATION-v2.md`](./MIGRATION-v2.md)
57
-
58
- 2. **Update your configuration:**
59
- - Copy `opencode.json` settings (model configuration)
60
-
61
- 3. **Test with a simple workflow:**
62
- - Verify token reduction in your provider dashboard
63
-
64
- 4. **Adopt new usage patterns:**
65
- - Prefer direct invocation over orchestrator
66
- - Continue conversations in same session for caching
67
-
68
- ---
69
-
70
- ## 📚 Documentation
71
-
72
- | Document | Purpose |
73
- |----------|---------|
74
- | **[OPTIMIZATION-SUMMARY.md](../OPTIMIZATION-SUMMARY.md)** | Comprehensive technical details |
75
- | **[MIGRATION-v2.md](./MIGRATION-v2.md)** | Step-by-step migration guide |
76
- | **[opencode-guide-optimization-addendum.md](./opencode-guide-optimization-addendum.md)** | Usage best practices |
77
- | **[opencode-guide.md](./opencode-guide.md)** | Main RRCE guide |
78
-
79
- ---
80
-
81
- ## 💡 Best Practices
82
-
83
- ### ✅ Do This (Efficient)
84
-
85
- 1. **Use direct subagent invocation:**
86
- ```
87
- @rrce_research_discussion TASK_SLUG=x REQUEST="..."
88
- ```
89
-
90
- 2. **Continue in same session** (for caching):
91
- - Don't start new chat for each answer
92
- - Let prompt cache activate on turn 2+
93
-
94
- 3. **Trust hybrid approach:**
95
- - Agent asks critical questions
96
- - Documents rest as assumptions
97
- - You can always ask for more detail
98
-
99
- 4. **Reserve orchestrator for full automation:**
100
- ```
101
- @rrce_orchestrator "Implement feature X end-to-end"
102
- ```
103
-
104
- ### ❌ Avoid This (Inefficient)
105
-
106
- 1. **Don't use orchestrator for single phases:**
107
- ```
108
- ❌ @rrce_orchestrator "Just do research on X"
109
- ✅ @rrce_research_discussion TASK_SLUG=x REQUEST="Research X"
110
- ```
111
-
112
- 2. **Don't start new chats unnecessarily:**
113
- - Each new chat = no caching
114
- - Continue in same session whenever possible
115
-
116
- 3. **Don't ask agent to "re-search":**
117
- - Agent caches knowledge on first turn
118
- - References findings thereafter
119
- - Only re-searches for new scope
120
-
121
- ---
122
-
123
- ## 🔧 Configuration
124
-
125
- ### Model Settings (opencode.json)
126
-
127
- ```json
128
- {
129
- "agent": {
130
- "rrce_research_discussion": {
131
- "model": "anthropic/claude-haiku-4-20250514"
132
- },
133
- "rrce_planning_discussion": {
134
- "model": "anthropic/claude-sonnet-4-20250514"
135
- },
136
- "rrce_executor": {
137
- "model": "anthropic/claude-sonnet-4-20250514"
138
- }
139
- }
140
- }
141
- ```
142
-
143
- **Why these models?**
144
- - **Haiku for research:** 12x cheaper, quality is sufficient for Q&A
145
- - **Sonnet for planning/execution:** Needs reasoning power and code generation
146
-
147
- ---
148
-
149
- ## 🐛 Troubleshooting
150
-
151
- ### "Token usage still high"
152
-
153
- **Check:**
154
- 1. Are you using direct invocation (`@rrce_*`)?
155
- 2. Are you continuing in same session?
156
- 3. Is caching enabled? (Check provider logs for cache hits)
157
-
158
- ### "Research too brief"
159
-
160
- **Adjust:** Edit `agent-core/prompts/research_discussion.md`
161
- ```markdown
162
- **STOP after 3 rounds.** (increase from 2)
163
- ```
164
-
165
- ### "Wrong model being used"
166
-
167
- **Verify:**
168
- 1. `opencode.json` exists and has model config
169
- 2. Restart OpenCode: `pkill opencode && opencode`
170
- 3. Check logs for model selection
171
-
172
- ---
173
-
174
- ## 📈 Measuring Success
175
-
176
- ### Check Token Usage
177
-
178
- **Via Provider Dashboard:**
179
- - Anthropic: https://console.anthropic.com → Usage
180
- - OpenAI: https://platform.openai.com/usage
181
-
182
- **Look for:**
183
- - Input tokens (should be ~4K on first turn)
184
- - Cache read tokens (should be ~3.6K on turn 2+)
185
- - Overall reduction of 60-70% compared to before
186
-
187
- ---
188
-
189
- ## 🎓 Learn More
190
-
191
- ### Core Concepts
192
-
193
- 1. **Session Reuse:** Reusing same session enables prompt caching
194
- 2. **Smart Caching:** Agents cache knowledge searches, reference thereafter
195
- 3. **Hybrid Clarification:** Ask critical questions, document rest as assumptions
196
- 4. **Auto-Progression:** Orchestrator auto-proceeds based on user intent
197
-
198
- ### Advanced Topics
199
-
200
- - **Session naming convention:** `research-${TASK_SLUG}`, `planning-${TASK_SLUG}`
201
- - **Prompt cache keys:** Automatic via OpenCode (`promptCacheKey = sessionID`)
202
- - **Model selection:** Cost-optimized per agent type
203
- - **Knowledge integration:** Pre-fetch context to avoid subagent re-searching
204
-
205
- ---
206
-
207
- ## 🤝 Contributing
208
-
209
- Found additional optimizations? Submit a PR:
210
- - GitHub: https://github.com/rryando/rrce-workflow
211
-
212
- ---
213
-
214
- ## 📞 Support
215
-
216
- **Questions?**
217
- - GitHub Issues: https://github.com/rryando/rrce-workflow/issues
218
- - Documentation: `docs/` directory
219
-
220
- ---
221
-
222
- **Quick Links:**
223
- - [Full Technical Summary](../OPTIMIZATION-SUMMARY.md)
224
- - [Migration Guide](./MIGRATION-v2.md)
225
- - [Usage Best Practices](./opencode-guide-optimization-addendum.md)
226
- - [Test Suite](../src/__tests__/rrce-optimization.test.ts)
227
-
228
- ---
229
-
230
- **Version:** 2.0
231
- **Status:** ✅ Production Ready