@yeyuan98/opencode-bioresearcher-plugin 1.4.0 → 1.4.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.
@@ -1,186 +1,186 @@
1
- # Subagent Waves Pattern
2
-
3
- Process multiple items with parallel subagents organized in waves.
4
-
5
- ## Overview
6
-
7
- Use this pattern when you need to process many items in parallel while controlling concurrency.
8
-
9
- ## Requirements
10
-
11
- > **CRITICAL:** This pattern requires the `Task` tool to be available in your environment.
12
- >
13
- > - If the Task tool is not available, **subagent waves are not possible**
14
- > - Alternative: Process items sequentially or use external batch processing
15
- > - Check tool availability before implementing this pattern
16
- >
17
- > To verify Task tool availability, check your environment's tool list.
18
-
19
- ## Pattern Algorithm
20
-
21
- ```
22
- 1. Calculate total items and wave_size
23
- 2. Group items into waves of wave_size items each
24
- 3. For each wave:
25
- a. Launch wave_size subagents in parallel via Task tool
26
- b. Wait for all subagents to complete
27
- c. Track progress (use progress pattern)
28
- d. Validate outputs using jsonExtract + jsonValidate
29
- e. Collect validated outputs
30
- 4. Handle failed items (use retry pattern)
31
- 5. Combine all outputs using jsonExtract or table tools
32
- ```
33
-
34
- ## Parameters
35
-
36
- | Parameter | Default | Description |
37
- |-----------|---------|-------------|
38
- | `wave_size` | 3 | Number of parallel subagents per wave |
39
- | `subagent_type` | "general" | Type of subagent to launch |
40
-
41
- ## Key Principles
42
-
43
- 1. **File-based prompts**: Subagents read prompt files, not inline prompts
44
- 2. **File-based outputs**: Subagents write to output files as JSON
45
- 3. **Schema validation**: Every output validated before processing
46
- 4. **Wave coordination**: Wait for entire wave before starting next
47
- 5. **Progress tracking**: Report after each wave completes
48
-
49
- ## Tool: Task
50
-
51
- ```
52
- task(
53
- subagent_type: string,
54
- description: string,
55
- prompt: string
56
- )
57
- ```
58
-
59
- ## Example: Launch Wave of 3 Subagents
60
-
61
- ```typescript
62
- // Wave 1 - Launch 3 subagents in parallel
63
- task(
64
- subagent_type="general",
65
- description="Process batch 001",
66
- prompt="Read your prompt from ./.work/batch001.md and perform the task described there exactly as written."
67
- )
68
- task(
69
- subagent_type="general",
70
- description="Process batch 002",
71
- prompt="Read your prompt from ./.work/batch002.md and perform the task described there exactly as written."
72
- )
73
- task(
74
- subagent_type="general",
75
- description="Process batch 003",
76
- prompt="Read your prompt from ./.work/batch003.md and perform the task described there exactly as written."
77
- )
78
- // Wait for all 3 to complete before Wave 2
79
- ```
80
-
81
- ## Example: Full Wave Processing Workflow
82
-
83
- ```
84
- # Configuration
85
- total_items = 12
86
- wave_size = 3
87
- total_waves = ceil(total_items / wave_size) # 4 waves
88
-
89
- # Create prompt files first (using template.py)
90
- uv run python <skill_path>/python/template.py generate-batches \
91
- --template template.md \
92
- --contexts contexts.json \
93
- --output-dir ./prompts
94
-
95
- # Process in waves
96
- for wave_num in range(1, total_waves + 1):
97
- # Launch wave
98
- start_idx = (wave_num - 1) * wave_size + 1
99
- end_idx = min(wave_num * wave_size, total_items)
100
-
101
- for batch_num in range(start_idx, end_idx + 1):
102
- task(
103
- subagent_type="general",
104
- description=f"Process batch {batch_num:03d}",
105
- prompt=f"Read your prompt from ./prompts/batch{batch_num:03d}.md and perform the task."
106
- )
107
-
108
- # Wait for wave completion
109
- # (Task tool handles this - next task call waits)
110
-
111
- # Report progress
112
- completed = end_idx
113
- percent = calculator(formula=f"({completed} / {total_items}) * 100")
114
- report(f"Progress: {completed}/{total_items} batches ({percent}%)")
115
- ```
116
-
117
- ## Output Validation
118
-
119
- After each wave, validate outputs:
120
-
121
- ```
122
- # For each output file
123
- result = jsonExtract(file_path="./outputs/batch001.md")
124
- if not result.success:
125
- log_error("Failed to extract JSON from batch001.md")
126
- continue
127
-
128
- # Validate against schema
129
- validation = jsonValidate(
130
- data=json.dumps(result.data),
131
- schema=expected_schema
132
- )
133
- if not validation.valid:
134
- log_error(f"Schema validation failed for batch001.md: {validation.errors}")
135
- continue
136
-
137
- # Collect valid output
138
- valid_outputs.append(result.data)
139
- ```
140
-
141
- ## Handling Failed Batches
142
-
143
- After all waves complete:
144
-
145
- ```
146
- # Check for missing outputs
147
- expected_files = [f"batch{i:03d}.md" for i in range(1, total_items + 1)]
148
- missing = [f for f in expected_files if not exists(f"./outputs/{f}")]
149
-
150
- if missing:
151
- # Use retry pattern
152
- for batch_file in missing:
153
- retry_subagent(batch_file, max_attempts=3, delay=2)
154
- ```
155
-
156
- ## Combining Outputs
157
-
158
- For small batches (<10 files), use table tools:
159
-
160
- ```
161
- # Extract all JSON
162
- all_data = []
163
- for file in output_files:
164
- result = jsonExtract(file_path=file)
165
- if result.success:
166
- all_data.extend(result.data["summaries"])
167
-
168
- # Create combined Excel
169
- tableCreateFile(
170
- file_path="./combined.xlsx",
171
- sheet_name="Results",
172
- data=all_data
173
- )
174
- ```
175
-
176
- For large batches (>10 files), use Python script for efficiency.
177
-
178
- ## Best Practices
179
-
180
- 1. **Verify Task tool availability** before implementing this pattern
181
- 2. **Keep wave_size reasonable**: 3-5 subagents per wave
182
- 3. **Use descriptive descriptions**: "Process batch 001" not "Batch 1"
183
- 4. **Always use file-based prompts**: Never inline large prompts
184
- 5. **Validate every output**: Don't skip schema validation
185
- 6. **Report progress after waves**: Not during individual completions
186
- 7. **Have fallback plan**: If Task tool unavailable, use sequential processing
1
+ # Subagent Waves Pattern
2
+
3
+ Process multiple items with parallel subagents organized in waves.
4
+
5
+ ## Overview
6
+
7
+ Use this pattern when you need to process many items in parallel while controlling concurrency.
8
+
9
+ ## Requirements
10
+
11
+ > **CRITICAL:** This pattern requires the `Task` tool to be available in your environment.
12
+ >
13
+ > - If the Task tool is not available, **subagent waves are not possible**
14
+ > - Alternative: Process items sequentially or use external batch processing
15
+ > - Check tool availability before implementing this pattern
16
+ >
17
+ > To verify Task tool availability, check your environment's tool list.
18
+
19
+ ## Pattern Algorithm
20
+
21
+ ```
22
+ 1. Calculate total items and wave_size
23
+ 2. Group items into waves of wave_size items each
24
+ 3. For each wave:
25
+ a. Launch wave_size subagents in parallel via Task tool
26
+ b. Wait for all subagents to complete
27
+ c. Track progress (use progress pattern)
28
+ d. Validate outputs using jsonExtract + jsonValidate
29
+ e. Collect validated outputs
30
+ 4. Handle failed items (use retry pattern)
31
+ 5. Combine all outputs using jsonExtract or table tools
32
+ ```
33
+
34
+ ## Parameters
35
+
36
+ | Parameter | Default | Description |
37
+ |-----------|---------|-------------|
38
+ | `wave_size` | 3 | Number of parallel subagents per wave |
39
+ | `subagent_type` | "general" | Type of subagent to launch |
40
+
41
+ ## Key Principles
42
+
43
+ 1. **File-based prompts**: Subagents read prompt files, not inline prompts
44
+ 2. **File-based outputs**: Subagents write to output files as JSON
45
+ 3. **Schema validation**: Every output validated before processing
46
+ 4. **Wave coordination**: Wait for entire wave before starting next
47
+ 5. **Progress tracking**: Report after each wave completes
48
+
49
+ ## Tool: Task
50
+
51
+ ```
52
+ task(
53
+ subagent_type: string,
54
+ description: string,
55
+ prompt: string
56
+ )
57
+ ```
58
+
59
+ ## Example: Launch Wave of 3 Subagents
60
+
61
+ ```typescript
62
+ // Wave 1 - Launch 3 subagents in parallel
63
+ task(
64
+ subagent_type="general",
65
+ description="Process batch 001",
66
+ prompt="Read your prompt from ./.work/batch001.md and perform the task described there exactly as written."
67
+ )
68
+ task(
69
+ subagent_type="general",
70
+ description="Process batch 002",
71
+ prompt="Read your prompt from ./.work/batch002.md and perform the task described there exactly as written."
72
+ )
73
+ task(
74
+ subagent_type="general",
75
+ description="Process batch 003",
76
+ prompt="Read your prompt from ./.work/batch003.md and perform the task described there exactly as written."
77
+ )
78
+ // Wait for all 3 to complete before Wave 2
79
+ ```
80
+
81
+ ## Example: Full Wave Processing Workflow
82
+
83
+ ```
84
+ # Configuration
85
+ total_items = 12
86
+ wave_size = 3
87
+ total_waves = ceil(total_items / wave_size) # 4 waves
88
+
89
+ # Create prompt files first (using template.py)
90
+ uv run python <skill_path>/python/template.py generate-batches \
91
+ --template template.md \
92
+ --contexts contexts.json \
93
+ --output-dir ./prompts
94
+
95
+ # Process in waves
96
+ for wave_num in range(1, total_waves + 1):
97
+ # Launch wave
98
+ start_idx = (wave_num - 1) * wave_size + 1
99
+ end_idx = min(wave_num * wave_size, total_items)
100
+
101
+ for batch_num in range(start_idx, end_idx + 1):
102
+ task(
103
+ subagent_type="general",
104
+ description=f"Process batch {batch_num:03d}",
105
+ prompt=f"Read your prompt from ./prompts/batch{batch_num:03d}.md and perform the task."
106
+ )
107
+
108
+ # Wait for wave completion
109
+ # (Task tool handles this - next task call waits)
110
+
111
+ # Report progress
112
+ completed = end_idx
113
+ percent = calculator(formula=f"({completed} / {total_items}) * 100")
114
+ report(f"Progress: {completed}/{total_items} batches ({percent}%)")
115
+ ```
116
+
117
+ ## Output Validation
118
+
119
+ After each wave, validate outputs:
120
+
121
+ ```
122
+ # For each output file
123
+ result = jsonExtract(file_path="./outputs/batch001.md")
124
+ if not result.success:
125
+ log_error("Failed to extract JSON from batch001.md")
126
+ continue
127
+
128
+ # Validate against schema
129
+ validation = jsonValidate(
130
+ data=json.dumps(result.data),
131
+ schema=expected_schema
132
+ )
133
+ if not validation.valid:
134
+ log_error(f"Schema validation failed for batch001.md: {validation.errors}")
135
+ continue
136
+
137
+ # Collect valid output
138
+ valid_outputs.append(result.data)
139
+ ```
140
+
141
+ ## Handling Failed Batches
142
+
143
+ After all waves complete:
144
+
145
+ ```
146
+ # Check for missing outputs
147
+ expected_files = [f"batch{i:03d}.md" for i in range(1, total_items + 1)]
148
+ missing = [f for f in expected_files if not exists(f"./outputs/{f}")]
149
+
150
+ if missing:
151
+ # Use retry pattern
152
+ for batch_file in missing:
153
+ retry_subagent(batch_file, max_attempts=3, delay=2)
154
+ ```
155
+
156
+ ## Combining Outputs
157
+
158
+ For small batches (<10 files), use table tools:
159
+
160
+ ```
161
+ # Extract all JSON
162
+ all_data = []
163
+ for file in output_files:
164
+ result = jsonExtract(file_path=file)
165
+ if result.success:
166
+ all_data.extend(result.data["summaries"])
167
+
168
+ # Create combined Excel
169
+ tableCreateFile(
170
+ file_path="./combined.xlsx",
171
+ sheet_name="Results",
172
+ data=all_data
173
+ )
174
+ ```
175
+
176
+ For large batches (>10 files), use Python script for efficiency.
177
+
178
+ ## Best Practices
179
+
180
+ 1. **Verify Task tool availability** before implementing this pattern
181
+ 2. **Keep wave_size reasonable**: 3-5 subagents per wave
182
+ 3. **Use descriptive descriptions**: "Process batch 001" not "Batch 1"
183
+ 4. **Always use file-based prompts**: Never inline large prompts
184
+ 5. **Validate every output**: Don't skip schema validation
185
+ 6. **Report progress after waves**: Not during individual completions
186
+ 7. **Have fallback plan**: If Task tool unavailable, use sequential processing