@yeyuan98/opencode-bioresearcher-plugin 1.4.0 → 1.5.0-alpha.0
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 +35 -20
- package/dist/db-tools/backends/index.d.ts +11 -0
- package/dist/db-tools/backends/index.js +48 -0
- package/dist/db-tools/backends/mongodb/backend.d.ts +15 -0
- package/dist/db-tools/backends/mongodb/backend.js +76 -0
- package/dist/db-tools/backends/mongodb/connection.d.ts +27 -0
- package/dist/db-tools/backends/mongodb/connection.js +107 -0
- package/dist/db-tools/backends/mongodb/index.d.ts +4 -0
- package/dist/db-tools/backends/mongodb/index.js +3 -0
- package/dist/db-tools/backends/mongodb/translator.d.ts +30 -0
- package/dist/db-tools/backends/mongodb/translator.js +407 -0
- package/dist/db-tools/backends/mysql/backend.d.ts +15 -0
- package/dist/db-tools/backends/mysql/backend.js +57 -0
- package/dist/db-tools/backends/mysql/connection.d.ts +25 -0
- package/dist/db-tools/backends/mysql/connection.js +83 -0
- package/dist/db-tools/backends/mysql/index.d.ts +3 -0
- package/dist/db-tools/backends/mysql/index.js +2 -0
- package/dist/db-tools/backends/mysql/translator.d.ts +7 -0
- package/dist/db-tools/backends/mysql/translator.js +67 -0
- package/dist/db-tools/core/base.d.ts +17 -0
- package/dist/db-tools/core/base.js +51 -0
- package/dist/db-tools/core/config-loader.d.ts +3 -0
- package/dist/db-tools/core/config-loader.js +46 -0
- package/dist/db-tools/core/index.d.ts +2 -0
- package/dist/db-tools/core/index.js +2 -0
- package/dist/db-tools/core/jsonc-parser.d.ts +2 -0
- package/dist/db-tools/core/jsonc-parser.js +77 -0
- package/dist/db-tools/core/validator.d.ts +16 -0
- package/dist/db-tools/core/validator.js +118 -0
- package/dist/db-tools/executor.d.ts +13 -0
- package/dist/db-tools/executor.js +54 -0
- package/dist/db-tools/index.d.ts +51 -0
- package/dist/db-tools/index.js +27 -0
- package/dist/db-tools/interface/backend.d.ts +24 -0
- package/dist/db-tools/interface/backend.js +1 -0
- package/dist/db-tools/interface/connection.d.ts +21 -0
- package/dist/db-tools/interface/connection.js +11 -0
- package/dist/db-tools/interface/index.d.ts +4 -0
- package/dist/db-tools/interface/index.js +4 -0
- package/dist/db-tools/interface/query.d.ts +60 -0
- package/dist/db-tools/interface/query.js +1 -0
- package/dist/db-tools/interface/schema.d.ts +22 -0
- package/dist/db-tools/interface/schema.js +1 -0
- package/dist/db-tools/pool.d.ts +8 -0
- package/dist/db-tools/pool.js +49 -0
- package/dist/db-tools/tools/index.d.ts +27 -0
- package/dist/db-tools/tools/index.js +191 -0
- package/dist/db-tools/tools.d.ts +27 -0
- package/dist/db-tools/tools.js +111 -0
- package/dist/db-tools/types.d.ts +94 -0
- package/dist/db-tools/types.js +40 -0
- package/dist/db-tools/utils.d.ts +33 -0
- package/dist/db-tools/utils.js +94 -0
- package/dist/index.js +2 -0
- package/dist/skills/bioresearcher-core/README.md +210 -210
- package/dist/skills/bioresearcher-core/SKILL.md +128 -128
- package/dist/skills/bioresearcher-core/examples/contexts.json +29 -29
- package/dist/skills/bioresearcher-core/examples/data-exchange-example.md +303 -303
- package/dist/skills/bioresearcher-core/examples/template.md +49 -49
- package/dist/skills/bioresearcher-core/patterns/calculator.md +215 -215
- package/dist/skills/bioresearcher-core/patterns/data-exchange.md +406 -406
- package/dist/skills/bioresearcher-core/patterns/json-tools.md +263 -263
- package/dist/skills/bioresearcher-core/patterns/progress.md +127 -127
- package/dist/skills/bioresearcher-core/patterns/retry.md +110 -110
- package/dist/skills/bioresearcher-core/patterns/shell-commands.md +79 -79
- package/dist/skills/bioresearcher-core/patterns/subagent-waves.md +186 -186
- package/dist/skills/bioresearcher-core/patterns/table-tools.md +260 -260
- package/dist/skills/bioresearcher-core/patterns/user-confirmation.md +187 -187
- package/dist/skills/bioresearcher-core/python/template.md +273 -273
- package/dist/skills/bioresearcher-core/python/template.py +323 -323
- package/dist/skills/env-jsonc-setup/SKILL.md +206 -0
- package/package.json +3 -1
|
@@ -1,29 +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
|
-
]
|
|
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
|
+
]
|
|
@@ -1,303 +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
|
-
```
|
|
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
|
+
```
|