@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,49 +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).
|
|
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).
|
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
# Calculator Pattern
|
|
2
|
-
|
|
3
|
-
In-workflow calculations using the calculator tool.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Use the calculator tool for arithmetic operations in workflows. It's more reliable than manual calculations and provides consistent precision.
|
|
8
|
-
|
|
9
|
-
## Tool: calculator
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
calculator(formula: string, precision: number = 3)
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Parameters
|
|
16
|
-
- `formula`: Mathematical expression (string)
|
|
17
|
-
- `precision`: Decimal places for result (0-15, default 3)
|
|
18
|
-
|
|
19
|
-
### Return Format
|
|
20
|
-
```json
|
|
21
|
-
{
|
|
22
|
-
"formula": "(45 / 100) * 100",
|
|
23
|
-
"result": 45
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Supported Operations
|
|
28
|
-
|
|
29
|
-
| Operation | Symbol | Example |
|
|
30
|
-
|-----------|--------|---------|
|
|
31
|
-
| Addition | + | `2 + 3` |
|
|
32
|
-
| Subtraction | - | `5 - 2` |
|
|
33
|
-
| Multiplication | * | `3 * 4` |
|
|
34
|
-
| Division | / | `10 / 2` |
|
|
35
|
-
| Power | ^ | `2 ^ 3` |
|
|
36
|
-
| Brackets | () | `(2 + 3) * 4` |
|
|
37
|
-
| Scientific | e/E | `1e5`, `1.5e-3` |
|
|
38
|
-
|
|
39
|
-
### Important Rules
|
|
40
|
-
|
|
41
|
-
1. **MUST use explicit * for multiplication**: `2*(3)` NOT `2(3)`
|
|
42
|
-
2. **Maximum precision**: 15 decimal places
|
|
43
|
-
3. **Default precision**: 3 decimal places
|
|
44
|
-
4. **No functions**: ceil, floor, sqrt not supported
|
|
45
|
-
|
|
46
|
-
## Common Use Cases
|
|
47
|
-
|
|
48
|
-
### Batch Calculations
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
# Calculate number of batches needed
|
|
52
|
-
calculator(formula="ceil(100 / 30)", precision=0)
|
|
53
|
-
# Note: ceil not supported, use workaround:
|
|
54
|
-
calculator(formula="(100 + 30 - 1) / 30", precision=0)
|
|
55
|
-
# Result: 4.333 -> Use ceiling logic in agent
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Progress Percentages
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
# Calculate completion percentage
|
|
62
|
-
calculator(formula="(45 / 100) * 100", precision=1)
|
|
63
|
-
# Result: 45
|
|
64
|
-
|
|
65
|
-
# With variables in workflow
|
|
66
|
-
completed = 67
|
|
67
|
-
total = 120
|
|
68
|
-
calculator(formula="({completed} / {total}) * 100", precision=1)
|
|
69
|
-
# Result: 55.8
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Time Estimates
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
# Estimate remaining time
|
|
76
|
-
remaining_items = 50
|
|
77
|
-
items_per_minute = 10
|
|
78
|
-
calculator(formula="50 / 10", precision=0)
|
|
79
|
-
# Result: 5 minutes
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Data Size Calculations
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
# Calculate total rows across batches
|
|
86
|
-
batch_size = 30
|
|
87
|
-
num_batches = 4
|
|
88
|
-
calculator(formula="30 * 4", precision=0)
|
|
89
|
-
# Result: 120
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Ceiling/Floor Workarounds
|
|
93
|
-
|
|
94
|
-
Since ceil/floor are not supported:
|
|
95
|
-
|
|
96
|
-
### Ceiling
|
|
97
|
-
```
|
|
98
|
-
# ceil(a / b) = (a + b - 1) / b (for positive integers)
|
|
99
|
-
# ceil(100 / 30)
|
|
100
|
-
calculator(formula="(100 + 30 - 1) / 30", precision=0)
|
|
101
|
-
# Result: 4.333 -> Agent interprets as 5
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Floor
|
|
105
|
-
```
|
|
106
|
-
# floor(a / b) = a / b (truncate decimal)
|
|
107
|
-
# floor(100 / 30)
|
|
108
|
-
calculator(formula="100 / 30", precision=0)
|
|
109
|
-
# Result: 3.333 -> Agent interprets as 3
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Example Workflow
|
|
113
|
-
|
|
114
|
-
### Calculate Batch Configuration
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
# Given
|
|
118
|
-
total_rows = 250
|
|
119
|
-
batch_size = 30
|
|
120
|
-
|
|
121
|
-
# Calculate batches needed
|
|
122
|
-
# ceil(250 / 30) = 9 batches
|
|
123
|
-
batches_needed = calculator(
|
|
124
|
-
formula="(250 + 30 - 1) / 30",
|
|
125
|
-
precision=0
|
|
126
|
-
)
|
|
127
|
-
# Result: 9.3 -> Agent rounds up to 10
|
|
128
|
-
|
|
129
|
-
# Calculate rows in last batch
|
|
130
|
-
# 250 - (9 * 30) = 250 - 270 = -20 -> use 30
|
|
131
|
-
# Actually: 250 - (8 * 30) = 250 - 240 = 10
|
|
132
|
-
last_batch_rows = calculator(
|
|
133
|
-
formula="250 - (8 * 30)",
|
|
134
|
-
precision=0
|
|
135
|
-
)
|
|
136
|
-
# Result: 10
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Progress Tracking
|
|
140
|
-
|
|
141
|
-
```
|
|
142
|
-
# During batch processing
|
|
143
|
-
completed = 0
|
|
144
|
-
total = 10
|
|
145
|
-
|
|
146
|
-
for batch in batches:
|
|
147
|
-
process(batch)
|
|
148
|
-
completed += 1
|
|
149
|
-
|
|
150
|
-
# Calculate and report progress
|
|
151
|
-
percent = calculator(
|
|
152
|
-
formula="({completed} / {total}) * 100",
|
|
153
|
-
precision=0
|
|
154
|
-
)
|
|
155
|
-
report(f"Progress: {completed}/{total} ({percent}%)")
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Wave Timing
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
# Calculate expected completion time
|
|
162
|
-
waves_remaining = 3
|
|
163
|
-
seconds_per_wave = 45
|
|
164
|
-
|
|
165
|
-
estimated_seconds = calculator(
|
|
166
|
-
formula="3 * 45",
|
|
167
|
-
precision=0
|
|
168
|
-
)
|
|
169
|
-
# Result: 135 seconds
|
|
170
|
-
|
|
171
|
-
# Convert to minutes
|
|
172
|
-
estimated_minutes = calculator(
|
|
173
|
-
formula="135 / 60",
|
|
174
|
-
precision=1
|
|
175
|
-
)
|
|
176
|
-
# Result: 2.3 minutes
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Error Handling
|
|
180
|
-
|
|
181
|
-
### Invalid Formula
|
|
182
|
-
```
|
|
183
|
-
# Missing explicit multiplication
|
|
184
|
-
calculator(formula="2(3)")
|
|
185
|
-
# Error: "CALCULATOR ERROR: Invalid syntax: parentheses-less multiplication not allowed"
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Division by Zero
|
|
189
|
-
```
|
|
190
|
-
calculator(formula="10 / 0")
|
|
191
|
-
# Error: "CALCULATOR ERROR: Division by zero"
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Invalid Characters
|
|
195
|
-
```
|
|
196
|
-
calculator(formula="2 + abc")
|
|
197
|
-
# Error: "CALCULATOR ERROR: Formula contains invalid characters: a b c"
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## Integration with Other Patterns
|
|
201
|
-
|
|
202
|
-
| Pattern | Calculator Usage |
|
|
203
|
-
|---------|-----------------|
|
|
204
|
-
| `progress.md` | Calculate percentages |
|
|
205
|
-
| `retry.md` | Calculate backoff delays |
|
|
206
|
-
| `subagent-waves.md` | Calculate wave counts |
|
|
207
|
-
| `table-tools.md` | Calculate row counts |
|
|
208
|
-
|
|
209
|
-
## Best Practices
|
|
210
|
-
|
|
211
|
-
1. **Use precision=0 for counts**: Integer results
|
|
212
|
-
2. **Use precision=1 for percentages**: One decimal place
|
|
213
|
-
3. **Always use explicit ***: Never implicit multiplication
|
|
214
|
-
4. **Check for division by zero**: Validate divisors
|
|
215
|
-
5. **Document formulas**: Explain what calculation does
|
|
1
|
+
# Calculator Pattern
|
|
2
|
+
|
|
3
|
+
In-workflow calculations using the calculator tool.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Use the calculator tool for arithmetic operations in workflows. It's more reliable than manual calculations and provides consistent precision.
|
|
8
|
+
|
|
9
|
+
## Tool: calculator
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
calculator(formula: string, precision: number = 3)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Parameters
|
|
16
|
+
- `formula`: Mathematical expression (string)
|
|
17
|
+
- `precision`: Decimal places for result (0-15, default 3)
|
|
18
|
+
|
|
19
|
+
### Return Format
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"formula": "(45 / 100) * 100",
|
|
23
|
+
"result": 45
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Supported Operations
|
|
28
|
+
|
|
29
|
+
| Operation | Symbol | Example |
|
|
30
|
+
|-----------|--------|---------|
|
|
31
|
+
| Addition | + | `2 + 3` |
|
|
32
|
+
| Subtraction | - | `5 - 2` |
|
|
33
|
+
| Multiplication | * | `3 * 4` |
|
|
34
|
+
| Division | / | `10 / 2` |
|
|
35
|
+
| Power | ^ | `2 ^ 3` |
|
|
36
|
+
| Brackets | () | `(2 + 3) * 4` |
|
|
37
|
+
| Scientific | e/E | `1e5`, `1.5e-3` |
|
|
38
|
+
|
|
39
|
+
### Important Rules
|
|
40
|
+
|
|
41
|
+
1. **MUST use explicit * for multiplication**: `2*(3)` NOT `2(3)`
|
|
42
|
+
2. **Maximum precision**: 15 decimal places
|
|
43
|
+
3. **Default precision**: 3 decimal places
|
|
44
|
+
4. **No functions**: ceil, floor, sqrt not supported
|
|
45
|
+
|
|
46
|
+
## Common Use Cases
|
|
47
|
+
|
|
48
|
+
### Batch Calculations
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
# Calculate number of batches needed
|
|
52
|
+
calculator(formula="ceil(100 / 30)", precision=0)
|
|
53
|
+
# Note: ceil not supported, use workaround:
|
|
54
|
+
calculator(formula="(100 + 30 - 1) / 30", precision=0)
|
|
55
|
+
# Result: 4.333 -> Use ceiling logic in agent
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Progress Percentages
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
# Calculate completion percentage
|
|
62
|
+
calculator(formula="(45 / 100) * 100", precision=1)
|
|
63
|
+
# Result: 45
|
|
64
|
+
|
|
65
|
+
# With variables in workflow
|
|
66
|
+
completed = 67
|
|
67
|
+
total = 120
|
|
68
|
+
calculator(formula="({completed} / {total}) * 100", precision=1)
|
|
69
|
+
# Result: 55.8
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Time Estimates
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
# Estimate remaining time
|
|
76
|
+
remaining_items = 50
|
|
77
|
+
items_per_minute = 10
|
|
78
|
+
calculator(formula="50 / 10", precision=0)
|
|
79
|
+
# Result: 5 minutes
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Data Size Calculations
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
# Calculate total rows across batches
|
|
86
|
+
batch_size = 30
|
|
87
|
+
num_batches = 4
|
|
88
|
+
calculator(formula="30 * 4", precision=0)
|
|
89
|
+
# Result: 120
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Ceiling/Floor Workarounds
|
|
93
|
+
|
|
94
|
+
Since ceil/floor are not supported:
|
|
95
|
+
|
|
96
|
+
### Ceiling
|
|
97
|
+
```
|
|
98
|
+
# ceil(a / b) = (a + b - 1) / b (for positive integers)
|
|
99
|
+
# ceil(100 / 30)
|
|
100
|
+
calculator(formula="(100 + 30 - 1) / 30", precision=0)
|
|
101
|
+
# Result: 4.333 -> Agent interprets as 5
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Floor
|
|
105
|
+
```
|
|
106
|
+
# floor(a / b) = a / b (truncate decimal)
|
|
107
|
+
# floor(100 / 30)
|
|
108
|
+
calculator(formula="100 / 30", precision=0)
|
|
109
|
+
# Result: 3.333 -> Agent interprets as 3
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Example Workflow
|
|
113
|
+
|
|
114
|
+
### Calculate Batch Configuration
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
# Given
|
|
118
|
+
total_rows = 250
|
|
119
|
+
batch_size = 30
|
|
120
|
+
|
|
121
|
+
# Calculate batches needed
|
|
122
|
+
# ceil(250 / 30) = 9 batches
|
|
123
|
+
batches_needed = calculator(
|
|
124
|
+
formula="(250 + 30 - 1) / 30",
|
|
125
|
+
precision=0
|
|
126
|
+
)
|
|
127
|
+
# Result: 9.3 -> Agent rounds up to 10
|
|
128
|
+
|
|
129
|
+
# Calculate rows in last batch
|
|
130
|
+
# 250 - (9 * 30) = 250 - 270 = -20 -> use 30
|
|
131
|
+
# Actually: 250 - (8 * 30) = 250 - 240 = 10
|
|
132
|
+
last_batch_rows = calculator(
|
|
133
|
+
formula="250 - (8 * 30)",
|
|
134
|
+
precision=0
|
|
135
|
+
)
|
|
136
|
+
# Result: 10
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Progress Tracking
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
# During batch processing
|
|
143
|
+
completed = 0
|
|
144
|
+
total = 10
|
|
145
|
+
|
|
146
|
+
for batch in batches:
|
|
147
|
+
process(batch)
|
|
148
|
+
completed += 1
|
|
149
|
+
|
|
150
|
+
# Calculate and report progress
|
|
151
|
+
percent = calculator(
|
|
152
|
+
formula="({completed} / {total}) * 100",
|
|
153
|
+
precision=0
|
|
154
|
+
)
|
|
155
|
+
report(f"Progress: {completed}/{total} ({percent}%)")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Wave Timing
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
# Calculate expected completion time
|
|
162
|
+
waves_remaining = 3
|
|
163
|
+
seconds_per_wave = 45
|
|
164
|
+
|
|
165
|
+
estimated_seconds = calculator(
|
|
166
|
+
formula="3 * 45",
|
|
167
|
+
precision=0
|
|
168
|
+
)
|
|
169
|
+
# Result: 135 seconds
|
|
170
|
+
|
|
171
|
+
# Convert to minutes
|
|
172
|
+
estimated_minutes = calculator(
|
|
173
|
+
formula="135 / 60",
|
|
174
|
+
precision=1
|
|
175
|
+
)
|
|
176
|
+
# Result: 2.3 minutes
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Error Handling
|
|
180
|
+
|
|
181
|
+
### Invalid Formula
|
|
182
|
+
```
|
|
183
|
+
# Missing explicit multiplication
|
|
184
|
+
calculator(formula="2(3)")
|
|
185
|
+
# Error: "CALCULATOR ERROR: Invalid syntax: parentheses-less multiplication not allowed"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Division by Zero
|
|
189
|
+
```
|
|
190
|
+
calculator(formula="10 / 0")
|
|
191
|
+
# Error: "CALCULATOR ERROR: Division by zero"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Invalid Characters
|
|
195
|
+
```
|
|
196
|
+
calculator(formula="2 + abc")
|
|
197
|
+
# Error: "CALCULATOR ERROR: Formula contains invalid characters: a b c"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Integration with Other Patterns
|
|
201
|
+
|
|
202
|
+
| Pattern | Calculator Usage |
|
|
203
|
+
|---------|-----------------|
|
|
204
|
+
| `progress.md` | Calculate percentages |
|
|
205
|
+
| `retry.md` | Calculate backoff delays |
|
|
206
|
+
| `subagent-waves.md` | Calculate wave counts |
|
|
207
|
+
| `table-tools.md` | Calculate row counts |
|
|
208
|
+
|
|
209
|
+
## Best Practices
|
|
210
|
+
|
|
211
|
+
1. **Use precision=0 for counts**: Integer results
|
|
212
|
+
2. **Use precision=1 for percentages**: One decimal place
|
|
213
|
+
3. **Always use explicit ***: Never implicit multiplication
|
|
214
|
+
4. **Check for division by zero**: Validate divisors
|
|
215
|
+
5. **Document formulas**: Explain what calculation does
|