opencode-hive 1.0.0 → 1.0.1

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.
@@ -0,0 +1,286 @@
1
+ ---
2
+ name: parallel-exploration
3
+ description: Use when you need parallel, read-only exploration via hive_hive_background_task (Scout fan-out)
4
+ ---
5
+
6
+ # Parallel Exploration (Background Scout Fan-Out)
7
+
8
+ ## Overview
9
+
10
+ When you need to answer "where/how does X work?" across multiple domains (codebase, tests, docs, OSS), investigating sequentially wastes time. Each investigation is independent and can happen in parallel.
11
+
12
+ **Core principle:** Decompose into independent sub-questions, spawn one `hive_hive_background_task` per sub-question, collect results asynchronously.
13
+
14
+ **Safe in Planning mode:** This is read-only exploration. It is OK to use during exploratory research even when there is no feature, no plan, and no approved tasks.
15
+
16
+ **This skill is for read-only research.** For parallel implementation work, use `hive_skill("dispatching-parallel-agents")` with `hive_exec_start`.
17
+
18
+ ## When to Use
19
+
20
+ **Default to this skill when:**
21
+ **Use when:**
22
+ - Investigation spans multiple domains (code + tests + docs)
23
+ - User asks **2+ questions across different domains** (e.g., code + tests, code + docs/OSS, code + config/runtime)
24
+ - Questions are independent (answer to A doesn't affect B)
25
+ - User asks **3+ independent questions** (often as a numbered list or separate bullets)
26
+ - No edits needed (read-only exploration)
27
+ - User asks for an explorationthat likely spans multiple files/packages
28
+ - The work is read-only and the questions can be investigated independently
29
+
30
+ **Only skip this skill when:**
31
+ - Investigation requires shared state or context between questions
32
+ - It's a single focused question that is genuinely answerable with **one quick grep + one file read**
33
+ - Questions are dependent (answer A materially changes what to ask for B)
34
+ - Work involves file edits (use Hive tasks / Forager instead)
35
+
36
+ **Important:** Do not treat "this is exploratory" as a reason to avoid delegation. This skill is specifically for exploratory research when fan-out makes it faster and cleaner.
37
+
38
+ ## The Pattern
39
+
40
+ ### 1. Decompose Into Independent Questions
41
+
42
+ Split your investigation into 2-4 independent sub-questions. Good decomposition:
43
+
44
+ | Domain | Question Example |
45
+ |--------|------------------|
46
+ | Codebase | "Where is X implemented? What files define it?" |
47
+ | Tests | "How is X tested? What test patterns exist?" |
48
+ | Docs/OSS | "How do other projects implement X? What's the recommended pattern?" |
49
+ | Config | "How is X configured? What environment variables affect it?" |
50
+
51
+ **Bad decomposition (dependent questions):**
52
+ - "What is X?" then "How is X used?" (second depends on first)
53
+ - "Find the bug" then "Fix the bug" (not read-only)
54
+
55
+ ### 2. Spawn Background Tasks (Fan-Out)
56
+
57
+ Launch all tasks before waiting for any results:
58
+
59
+ ```typescript
60
+ // Fan-out: spawn all tasks first
61
+ hive_background_task({
62
+ agent: "scout-researcher",
63
+ description: "Find hive_background_task implementation",
64
+ prompt: `Where is hive_background_task implemented and registered?
65
+ - Find the tool definition
66
+ - Find the plugin registration
67
+ - Return file paths with line numbers`,
68
+ sync: false
69
+ })
70
+
71
+ hive_background_task({
72
+ agent: "scout-researcher",
73
+ description: "Analyze background task concurrency",
74
+ prompt: `How does background task concurrency/queueing work?
75
+ - Find the manager/scheduler code
76
+ - Document the concurrency model
77
+ - Return file paths with evidence`,
78
+ sync: false
79
+ })
80
+
81
+ hive_background_task({
82
+ agent: "scout-researcher",
83
+ description: "Find parent notification mechanism",
84
+ prompt: `How does parent notification work for background tasks?
85
+ - Where is the notification built?
86
+ - How is it sent to the parent session?
87
+ - Return file paths with evidence`,
88
+ sync: false
89
+ })
90
+ ```
91
+
92
+ **Key points:**
93
+ - Use `agent: "scout-researcher"` for read-only exploration
94
+ - Use `sync: false` to return immediately (non-blocking)
95
+ - Give each task a clear, focused `description`
96
+ - Make prompts specific about what evidence to return
97
+
98
+ ### 3. Continue Working (Optional)
99
+
100
+ While tasks run, you can:
101
+ - Work on other aspects of the problem
102
+ - Prepare synthesis structure
103
+ - Start drafting based on what you already know
104
+
105
+ You'll receive a `<system-reminder>` notification when each task completes.
106
+
107
+ ### 4. Collect Results
108
+
109
+ When notified of completion, retrieve results:
110
+
111
+ ```typescript
112
+ // Get output from completed task
113
+ hive_background_output({
114
+ task_id: "task-abc123",
115
+ block: false // Don't wait, task already done
116
+ })
117
+ ```
118
+
119
+ **For incremental output (long-running tasks):**
120
+
121
+ ```typescript
122
+ // First call - get initial output
123
+ hive_background_output({
124
+ task_id: "task-abc123",
125
+ block: true, // Wait for output
126
+ timeout: 30000 // 30 second timeout
127
+ })
128
+ // Returns: { output: "...", cursor: "5" }
129
+
130
+ // Later call - get new output since cursor
131
+ hive_background_output({
132
+ task_id: "task-abc123",
133
+ cursor: "5", // Resume from message 5
134
+ block: true
135
+ })
136
+ ```
137
+
138
+ ### 5. Synthesize Findings
139
+
140
+ Combine results from all tasks:
141
+ - Cross-reference findings (file X mentioned by tasks A and B)
142
+ - Identify gaps (task C found nothing, need different approach)
143
+ - Build coherent answer from parallel evidence
144
+
145
+ ### 6. Cleanup (If Needed)
146
+
147
+ Cancel tasks that are no longer needed:
148
+
149
+ ```typescript
150
+ // Cancel specific task
151
+ hive_background_cancel({ task_id: "task-abc123" })
152
+
153
+ // Cancel all your background tasks
154
+ hive_background_cancel({ all: true })
155
+ ```
156
+
157
+ ## Prompt Templates
158
+
159
+ ### Codebase Slice
160
+
161
+ ```
162
+ Investigate [TOPIC] in the codebase:
163
+ - Where is [X] defined/implemented?
164
+ - What files contain [X]?
165
+ - How does [X] interact with [Y]?
166
+
167
+ Return:
168
+ - File paths with line numbers
169
+ - Brief code snippets as evidence
170
+ - Key patterns observed
171
+ ```
172
+
173
+ ### Tests Slice
174
+
175
+ ```
176
+ Investigate how [TOPIC] is tested:
177
+ - What test files cover [X]?
178
+ - What testing patterns are used?
179
+ - What edge cases are tested?
180
+
181
+ Return:
182
+ - Test file paths
183
+ - Example test patterns
184
+ - Coverage gaps if obvious
185
+ ```
186
+
187
+ ### Docs/OSS Slice
188
+
189
+ ```
190
+ Research [TOPIC] in external sources:
191
+ - How do other projects implement [X]?
192
+ - What does the official documentation say?
193
+ - What are common patterns/anti-patterns?
194
+
195
+ Return:
196
+ - Links to relevant docs/repos
197
+ - Key recommendations
198
+ - Patterns that apply to our codebase
199
+ ```
200
+
201
+ ## Real Example
202
+
203
+ **Investigation:** "How does the background task system work?"
204
+
205
+ **Decomposition:**
206
+ 1. Implementation: Where is `hive_background_task` tool defined?
207
+ 2. Concurrency: How does task scheduling/queueing work?
208
+ 3. Notifications: How does parent session get notified?
209
+
210
+ **Fan-out:**
211
+ ```typescript
212
+ // Task 1: Implementation
213
+ hive_background_task({
214
+ agent: "scout-researcher",
215
+ description: "Find hive_background_task implementation",
216
+ prompt: "Where is hive_background_task implemented? Find tool definition and registration.",
217
+ sync: false
218
+ })
219
+
220
+ // Task 2: Concurrency
221
+ hive_background_task({
222
+ agent: "scout-researcher",
223
+ description: "Analyze concurrency model",
224
+ prompt: "How does background task concurrency work? Find the manager/scheduler.",
225
+ sync: false
226
+ })
227
+
228
+ // Task 3: Notifications
229
+ hive_background_task({
230
+ agent: "scout-researcher",
231
+ description: "Find notification mechanism",
232
+ prompt: "How are parent sessions notified of task completion?",
233
+ sync: false
234
+ })
235
+ ```
236
+
237
+ **Results:**
238
+ - Task 1: Found `background-tools.ts` (tool definition), `index.ts` (registration)
239
+ - Task 2: Found `manager.ts` with concurrency=3 default, queue-based scheduling
240
+ - Task 3: Found `session.prompt()` call in manager for parent notification
241
+
242
+ **Synthesis:** Complete picture of background task lifecycle in ~1/3 the time of sequential investigation.
243
+
244
+ ## Common Mistakes
245
+
246
+ **Spawning sequentially (defeats the purpose):**
247
+ ```typescript
248
+ // BAD: Wait for each before spawning next
249
+ const result1 = await hive_background_task({ ..., sync: true })
250
+ const result2 = await hive_background_task({ ..., sync: true })
251
+ ```
252
+
253
+ ```typescript
254
+ // GOOD: Spawn all, then collect
255
+ hive_background_task({ ..., sync: false }) // Returns immediately
256
+ hive_background_task({ ..., sync: false }) // Returns immediately
257
+ hive_background_task({ ..., sync: false }) // Returns immediately
258
+ // ... later, collect results with hive_background_output
259
+ ```
260
+
261
+ **Too many tasks (diminishing returns):**
262
+ - 2-4 tasks: Good parallelization
263
+ - 5+ tasks: Overhead exceeds benefit, harder to synthesize
264
+
265
+ **Dependent questions:**
266
+ - Don't spawn task B if it needs task A's answer
267
+ - Either make them independent or run sequentially
268
+
269
+ **Using for edits:**
270
+ - Scout is read-only; use Forager for implementation
271
+ - This skill is for exploration, not execution
272
+
273
+ ## Key Benefits
274
+
275
+ 1. **Speed** - 3 investigations in time of 1
276
+ 2. **Focus** - Each Scout has narrow scope
277
+ 3. **Independence** - No interference between tasks
278
+ 4. **Flexibility** - Cancel unneeded tasks, add new ones
279
+
280
+ ## Verification
281
+
282
+ After using this pattern, verify:
283
+ - [ ] All tasks spawned before collecting any results (true fan-out)
284
+ - [ ] Received notifications for completed tasks
285
+ - [ ] Successfully retrieved output with `hive_background_output`
286
+ - [ ] Synthesized findings into coherent answer