@yeyuan98/opencode-bioresearcher-plugin 1.3.1 → 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.
Files changed (36) hide show
  1. package/README.md +14 -0
  2. package/dist/index.js +4 -1
  3. package/dist/misc-tools/index.d.ts +3 -0
  4. package/dist/misc-tools/index.js +3 -0
  5. package/dist/misc-tools/json-extract.d.ts +13 -0
  6. package/dist/misc-tools/json-extract.js +394 -0
  7. package/dist/misc-tools/json-infer.d.ts +13 -0
  8. package/dist/misc-tools/json-infer.js +199 -0
  9. package/dist/misc-tools/json-tools.d.ts +33 -0
  10. package/dist/misc-tools/json-tools.js +187 -0
  11. package/dist/misc-tools/json-validate.d.ts +13 -0
  12. package/dist/misc-tools/json-validate.js +228 -0
  13. package/dist/skills/bioresearcher-core/README.md +210 -0
  14. package/dist/skills/bioresearcher-core/SKILL.md +128 -0
  15. package/dist/skills/bioresearcher-core/examples/contexts.json +29 -0
  16. package/dist/skills/bioresearcher-core/examples/data-exchange-example.md +303 -0
  17. package/dist/skills/bioresearcher-core/examples/template.md +49 -0
  18. package/dist/skills/bioresearcher-core/patterns/calculator.md +215 -0
  19. package/dist/skills/bioresearcher-core/patterns/data-exchange.md +406 -0
  20. package/dist/skills/bioresearcher-core/patterns/json-tools.md +263 -0
  21. package/dist/skills/bioresearcher-core/patterns/progress.md +127 -0
  22. package/dist/skills/bioresearcher-core/patterns/retry.md +110 -0
  23. package/dist/skills/bioresearcher-core/patterns/shell-commands.md +79 -0
  24. package/dist/skills/bioresearcher-core/patterns/subagent-waves.md +186 -0
  25. package/dist/skills/bioresearcher-core/patterns/table-tools.md +260 -0
  26. package/dist/skills/bioresearcher-core/patterns/user-confirmation.md +187 -0
  27. package/dist/skills/bioresearcher-core/python/template.md +273 -0
  28. package/dist/skills/bioresearcher-core/python/template.py +323 -0
  29. package/dist/skills/long-table-summary/SKILL.md +374 -0
  30. package/dist/skills/long-table-summary/__init__.py +3 -0
  31. package/dist/skills/long-table-summary/combine_outputs.py +345 -0
  32. package/dist/skills/long-table-summary/pyproject.toml +11 -0
  33. package/dist/skills/pubmed-weekly/SKILL.md +329 -329
  34. package/dist/skills/pubmed-weekly/pubmed_weekly.py +411 -411
  35. package/dist/skills/pubmed-weekly/pyproject.toml +8 -8
  36. package/package.json +7 -2
@@ -0,0 +1,128 @@
1
+ ---
2
+ name: bioresearcher-core
3
+ description: Core patterns and utilities for BioResearcher skills
4
+ allowedTools:
5
+ - Read
6
+ - Write
7
+ - Bash
8
+ - jsonExtract
9
+ - jsonValidate
10
+ - jsonInfer
11
+ - blockingTimer
12
+ - calculator
13
+ - tableCreateFile
14
+ - tableAppendRows
15
+ - Question
16
+ - Task
17
+ ---
18
+
19
+ # BioResearcher Core
20
+
21
+ This skill provides reusable patterns and utilities for BioResearcher skills.
22
+
23
+ ## Quick Start
24
+
25
+ ### Step 1: Load This Skill
26
+ ```
27
+ skill bioresearcher-core
28
+ ```
29
+
30
+ ### Step 2: Extract Skill Path
31
+ From the `<skill_files>` section in the skill tool output, extract the `<skill_path>` value.
32
+
33
+ ### Step 3: Use Resources
34
+ - Read pattern: `Read <skill_path>/patterns/retry.md`
35
+ - Run script: `uv run python <skill_path>/python/template.py ...`
36
+
37
+ ## Available Patterns
38
+
39
+ ### Workflow Control
40
+ - `patterns/retry.md` - Retry with backoff using blockingTimer
41
+ - `patterns/progress.md` - Progress tracking
42
+ - `patterns/subagent-waves.md` - Parallel subagent processing
43
+ - `patterns/shell-commands.md` - Unix/Windows command generation
44
+ - `patterns/user-confirmation.md` - User confirmation
45
+
46
+ ### Data Handling
47
+ - `patterns/json-tools.md` - Using jsonExtract/jsonValidate/jsonInfer
48
+ - `patterns/table-tools.md` - Combining outputs with table tools
49
+ - `patterns/data-exchange.md` - Main/subagent data exchange protocol
50
+ - `patterns/calculator.md` - In-workflow calculations
51
+
52
+ ## Python Utilities
53
+ - `python/template.md` - Template generation documentation
54
+
55
+ ## Direct Tools (No Loading Needed)
56
+
57
+ These tools are always available without loading pattern files:
58
+
59
+ ### JSON Tools
60
+ - `jsonExtract` - Extract JSON from files (handles markdown code blocks, raw JSON)
61
+ - `jsonValidate` - Validate JSON against schemas (Draft-4, Draft-7, Draft-2020-12)
62
+ - `jsonInfer` - Infer schemas from JSON data
63
+
64
+ ### Utility Tools
65
+ - `blockingTimer` - Blocking delays (0-300 seconds)
66
+ - `calculator` - Mathematical expressions (+, -, *, /, ^, brackets)
67
+
68
+ ### Table Tools
69
+ - `tableCreateFile` - Create Excel/CSV files from data
70
+ - `tableAppendRows` - Append rows to existing tables
71
+
72
+ ## Tool Signatures
73
+
74
+ ### jsonExtract
75
+ ```
76
+ jsonExtract(file_path: string, return_all: boolean = false)
77
+ Returns: { success, data, metadata: { method, dataType, fileSize } }
78
+ ```
79
+
80
+ ### jsonValidate
81
+ ```
82
+ jsonValidate(data: string, schema: string)
83
+ Returns: { success, valid, errors?, metadata: { errorCount, schemaFeatures } }
84
+ ```
85
+
86
+ ### jsonInfer
87
+ ```
88
+ jsonInfer(data: string, strict: boolean = false)
89
+ Returns: { success, data: JSONSchema, metadata: { inferredType, strictMode } }
90
+ ```
91
+
92
+ ### blockingTimer
93
+ ```
94
+ blockingTimer(delay: number)
95
+ Returns: "Timer completed: waited X seconds (actual elapsed: Ys)"
96
+ ```
97
+
98
+ ### calculator
99
+ ```
100
+ calculator(formula: string, precision: number = 3)
101
+ Returns: { formula, result }
102
+ ```
103
+
104
+ ### tableCreateFile
105
+ ```
106
+ tableCreateFile(file_path: string, sheet_name: string = "Sheet1", data: array)
107
+ Returns: { success, file_path, sheet_name, rows_created }
108
+ ```
109
+
110
+ ### tableAppendRows
111
+ ```
112
+ tableAppendRows(file_path: string, sheet_name: string?, rows: array)
113
+ Returns: { success, rows_appended }
114
+ ```
115
+
116
+ ## When to Use Each Pattern
117
+
118
+ | Use Case | Pattern File |
119
+ |----------|-------------|
120
+ | Network/API failures | `patterns/retry.md` |
121
+ | Batch processing progress | `patterns/progress.md` |
122
+ | Parallel subagent execution | `patterns/subagent-waves.md` |
123
+ | Cross-platform commands | `patterns/shell-commands.md` |
124
+ | Destructive operations | `patterns/user-confirmation.md` |
125
+ | JSON data extraction | `patterns/json-tools.md` |
126
+ | Combining batch outputs | `patterns/table-tools.md` |
127
+ | Subagent communication | `patterns/data-exchange.md` |
128
+ | Progress calculations | `patterns/calculator.md` |
@@ -0,0 +1,29 @@
1
+ [
2
+ {
3
+ "file_path": "/absolute/path/to/data.xlsx",
4
+ "sheet_name": "Sheet1",
5
+ "batch_number": 1,
6
+ "row_start": 2,
7
+ "row_end": 31,
8
+ "output_file": "./outputs/batch001.md",
9
+ "instructions_json": "{\n \"species\": \"Species classification: Tier1/Tier2/NA\",\n \"topic\": \"Main topic: Oncology/Immunology/General Biology/Others\"\n}"
10
+ },
11
+ {
12
+ "file_path": "/absolute/path/to/data.xlsx",
13
+ "sheet_name": "Sheet1",
14
+ "batch_number": 2,
15
+ "row_start": 32,
16
+ "row_end": 61,
17
+ "output_file": "./outputs/batch002.md",
18
+ "instructions_json": "{\n \"species\": \"Species classification: Tier1/Tier2/NA\",\n \"topic\": \"Main topic: Oncology/Immunology/General Biology/Others\"\n}"
19
+ },
20
+ {
21
+ "file_path": "/absolute/path/to/data.xlsx",
22
+ "sheet_name": "Sheet1",
23
+ "batch_number": 3,
24
+ "row_start": 62,
25
+ "row_end": 91,
26
+ "output_file": "./outputs/batch003.md",
27
+ "instructions_json": "{\n \"species\": \"Species classification: Tier1/Tier2/NA\",\n \"topic\": \"Main topic: Oncology/Immunology/General Biology/Others\"\n}"
28
+ }
29
+ ]
@@ -0,0 +1,303 @@
1
+ # Data Exchange Example
2
+
3
+ This example demonstrates the complete main/subagent data exchange workflow.
4
+
5
+ ## Scenario
6
+
7
+ Main agent needs to process a large table (90 rows) in 3 batches of 30 rows each.
8
+
9
+ ## Step 1: Main Agent Creates Prompt Files
10
+
11
+ ### Template (subagent_template.md)
12
+
13
+ ```markdown
14
+ # Batch Processing Task
15
+
16
+ ## Input
17
+ - File: {file_path}
18
+ - Sheet: {sheet_name}
19
+ - Rows: {row_start} to {row_end}
20
+
21
+ ## Output Format
22
+ Write JSON to: {output_file}
23
+
24
+ ```json
25
+ {
26
+ "batch_number": {batch_number},
27
+ "row_count": <integer>,
28
+ "summaries": [
29
+ {
30
+ "row_number": <integer>,
31
+ "status": "<success/failure>",
32
+ "result": "<string>"
33
+ }
34
+ ]
35
+ }
36
+ ```
37
+ ```
38
+
39
+ ### Generate Prompts
40
+
41
+ ```bash
42
+ uv run python <skill_path>/python/template.py generate-batches \
43
+ --template subagent_template.md \
44
+ --contexts batch_contexts.json \
45
+ --output-dir ./prompts \
46
+ --filename-pattern "batch{index:03d}.md"
47
+ ```
48
+
49
+ ### Contexts (batch_contexts.json)
50
+
51
+ ```json
52
+ [
53
+ {
54
+ "file_path": "/data/table.xlsx",
55
+ "sheet_name": "Data",
56
+ "batch_number": 1,
57
+ "row_start": 2,
58
+ "row_end": 31,
59
+ "output_file": "./outputs/batch001.md"
60
+ },
61
+ {
62
+ "file_path": "/data/table.xlsx",
63
+ "sheet_name": "Data",
64
+ "batch_number": 2,
65
+ "row_start": 32,
66
+ "row_end": 61,
67
+ "output_file": "./outputs/batch002.md"
68
+ },
69
+ {
70
+ "file_path": "/data/table.xlsx",
71
+ "sheet_name": "Data",
72
+ "batch_number": 3,
73
+ "row_start": 62,
74
+ "row_end": 91,
75
+ "output_file": "./outputs/batch003.md"
76
+ }
77
+ ]
78
+ ```
79
+
80
+ ## Step 2: Main Agent Launches Subagents
81
+
82
+ ### Wave 1 (All 3 batches)
83
+
84
+ ```
85
+ task(
86
+ subagent_type="general",
87
+ description="Process batch 001",
88
+ prompt="Read your prompt from ./prompts/batch001.md and perform the task exactly as written."
89
+ )
90
+
91
+ task(
92
+ subagent_type="general",
93
+ description="Process batch 002",
94
+ prompt="Read your prompt from ./prompts/batch002.md and perform the task exactly as written."
95
+ )
96
+
97
+ task(
98
+ subagent_type="general",
99
+ description="Process batch 003",
100
+ prompt="Read your prompt from ./prompts/batch003.md and perform the task exactly as written."
101
+ )
102
+ ```
103
+
104
+ ## Step 3: Subagent Processes and Writes Output
105
+
106
+ ### Subagent reads prompt
107
+ ```
108
+ Read ./prompts/batch001.md
109
+ ```
110
+
111
+ ### Subagent processes data
112
+ ```
113
+ tableGetRange(file_path="/data/table.xlsx", sheet_name="Data", range="A2:Z31")
114
+ ```
115
+
116
+ ### Subagent writes output (./outputs/batch001.md)
117
+
118
+ ```json
119
+ {
120
+ "batch_number": 1,
121
+ "row_count": 30,
122
+ "summaries": [
123
+ {"row_number": 2, "status": "success", "result": "Processed OK"},
124
+ {"row_number": 3, "status": "success", "result": "Processed OK"},
125
+ {"row_number": 4, "status": "failure", "result": "Missing data"},
126
+ "..."
127
+ ]
128
+ }
129
+ ```
130
+
131
+ ## Step 4: Main Agent Validates Outputs
132
+
133
+ ### Extract JSON
134
+
135
+ ```
136
+ jsonExtract(file_path="./outputs/batch001.md")
137
+ ```
138
+
139
+ Returns:
140
+ ```json
141
+ {
142
+ "success": true,
143
+ "data": {
144
+ "batch_number": 1,
145
+ "row_count": 30,
146
+ "summaries": [...]
147
+ },
148
+ "metadata": {
149
+ "method": "object",
150
+ "dataType": "object"
151
+ }
152
+ }
153
+ ```
154
+
155
+ ### Infer Schema from First Output
156
+
157
+ ```
158
+ jsonInfer(
159
+ data='{"batch_number": 1, "row_count": 30, "summaries": [{"row_number": 2, "status": "success", "result": "OK"}]}',
160
+ strict=true
161
+ )
162
+ ```
163
+
164
+ Returns:
165
+ ```json
166
+ {
167
+ "success": true,
168
+ "data": {
169
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
170
+ "type": "object",
171
+ "properties": {
172
+ "batch_number": {"type": "integer"},
173
+ "row_count": {"type": "integer"},
174
+ "summaries": {
175
+ "type": "array",
176
+ "items": {
177
+ "type": "object",
178
+ "properties": {
179
+ "row_number": {"type": "integer"},
180
+ "status": {"type": "string"},
181
+ "result": {"type": "string"}
182
+ },
183
+ "required": ["row_number", "status", "result"]
184
+ }
185
+ }
186
+ },
187
+ "required": ["batch_number", "row_count", "summaries"]
188
+ }
189
+ }
190
+ ```
191
+
192
+ ### Validate Other Outputs
193
+
194
+ ```
195
+ jsonValidate(
196
+ data='{"batch_number": 2, "row_count": 30, "summaries": [...]}',
197
+ schema='<inferred_schema>'
198
+ )
199
+ ```
200
+
201
+ Returns:
202
+ ```json
203
+ {
204
+ "success": true,
205
+ "valid": true,
206
+ "data": {...}
207
+ }
208
+ ```
209
+
210
+ ## Step 5: Main Agent Combines Outputs
211
+
212
+ ### Collect All Summaries
213
+
214
+ ```
215
+ all_rows = []
216
+
217
+ for batch in [1, 2, 3]:
218
+ result = jsonExtract(file_path=f"./outputs/batch{batch:03d}.md")
219
+ if result.success:
220
+ all_rows.extend(result.data["summaries"])
221
+ ```
222
+
223
+ ### Create Combined Excel
224
+
225
+ ```
226
+ tableCreateFile(
227
+ file_path="./combined_results.xlsx",
228
+ sheet_name="Results",
229
+ data=all_rows
230
+ )
231
+ ```
232
+
233
+ ## Complete Workflow Summary
234
+
235
+ 1. **Template**: Defines output format with schema
236
+ 2. **Contexts**: Provides batch-specific values
237
+ 3. **Generation**: Creates prompt files from template + contexts
238
+ 4. **Subagents**: Read prompts, process, write JSON outputs
239
+ 5. **Extraction**: jsonExtract parses JSON from outputs
240
+ 6. **Validation**: jsonValidate ensures schema compliance
241
+ 7. **Combination**: tableCreateFile merges all results
242
+
243
+ ## Error Handling Examples
244
+
245
+ ### Missing Output File
246
+
247
+ ```
248
+ jsonExtract(file_path="./outputs/batch002.md")
249
+ ```
250
+
251
+ Returns:
252
+ ```json
253
+ {
254
+ "success": false,
255
+ "error": {
256
+ "code": "FILE_NOT_FOUND",
257
+ "message": "File not found: ./outputs/batch002.md"
258
+ }
259
+ }
260
+ ```
261
+
262
+ ### Invalid JSON in Output
263
+
264
+ ```
265
+ jsonExtract(file_path="./outputs/batch003.md")
266
+ ```
267
+
268
+ Returns:
269
+ ```json
270
+ {
271
+ "success": false,
272
+ "error": {
273
+ "code": "NO_JSON_FOUND",
274
+ "message": "No valid JSON found in file"
275
+ }
276
+ }
277
+ ```
278
+
279
+ ### Schema Validation Failure
280
+
281
+ ```
282
+ jsonValidate(
283
+ data='{"batch_number": "one", "summaries": []}',
284
+ schema='{"properties": {"batch_number": {"type": "integer"}}}'
285
+ )
286
+ ```
287
+
288
+ Returns:
289
+ ```json
290
+ {
291
+ "success": true,
292
+ "valid": false,
293
+ "errors": [
294
+ {
295
+ "path": "batch_number",
296
+ "message": "Expected number, received string",
297
+ "code": "invalid_type",
298
+ "expected": "number",
299
+ "received": "string"
300
+ }
301
+ ]
302
+ }
303
+ ```
@@ -0,0 +1,49 @@
1
+ # Batch Data Summarization Task
2
+
3
+ ## Input File
4
+ - Full path: `{file_path}`
5
+ - Sheet name: `{sheet_name}`
6
+
7
+ ## Row Range
8
+ - Batch number: {batch_number}
9
+ - Start row: {row_start}
10
+ - End row: {row_end}
11
+
12
+ ## Summarization Instructions
13
+
14
+ Extract the following fields from each row:
15
+
16
+ {instructions_json}
17
+
18
+ ## Output Format
19
+
20
+ Your output must be a valid JSON file with this structure:
21
+
22
+ ```json
23
+ {
24
+ "batch_number": {batch_number},
25
+ "row_count": <number_of_rows_processed>,
26
+ "summaries": [
27
+ {
28
+ "row_number": <row_number>,
29
+ <field_1>: "<extracted_value>",
30
+ <field_2>: "<extracted_value>"
31
+ }
32
+ ]
33
+ }
34
+ ```
35
+
36
+ **Important:** The JSON keys for extracted values must match the field names specified in the Summarization Instructions.
37
+
38
+ ## Instructions
39
+
40
+ 1. Read the specified row range from the input file using the `tableGetRange` tool
41
+ 2. For each row, extract the requested fields according to the instructions above
42
+ 3. Map the extracted values to the JSON keys specified in the instructions
43
+ 4. Generate concise summaries based on the extracted data
44
+ 5. Save your output to: `{output_file}`
45
+
46
+ ## Output File Path
47
+ Full path: `{output_file}`
48
+
49
+ **CRITICAL:** Write your final output as a markdown file (.md) containing ONLY the JSON object (no additional text or explanation).