@openspoon/subtask2 0.1.16 → 0.2.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 +66 -36
- package/dist/commands.d.ts +7 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +66 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +43 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +184 -173
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +18 -0
- package/dist/logger.js.map +1 -0
- package/dist/parser.d.ts +6 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +50 -0
- package/dist/parser.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
# A stronger opencode /command handler
|
|
2
2
|
|
|
3
|
-
### TL:DR -
|
|
3
|
+
### TL:DR - More agency, control and capabilities for commands
|
|
4
4
|
|
|
5
|
-
This
|
|
5
|
+
This plugin affects how opencode handles slash commands with additional frontmatter parameters and enables parallel command execution. It is a set of new command features designed to better orchestrate, steer and keep the agentic loop alive. Compose as simple or complex a workflow as you want.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- `parallel` run multiple subtasks concurrently (accepts arguments)
|
|
7
|
+
### Key features
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- `return` instruct the main session on **command** or **subtask(s)** results - _can be chained, supports `/command` syntax_
|
|
10
|
+
- `parallel` run subtasks concurrently - _only parent's `return` applies when all are done_
|
|
11
|
+
- `command` extra command to run along the main one - _forced into a subtask_
|
|
12
|
+
- `arguments` pass arguments with command frontmatter or `||` message pipe
|
|
13
|
+
- _nested parallels are automatically flattened_ (max depth: 5)
|
|
14
|
+
|
|
15
|
+
#### ⚠️ Pending PR
|
|
16
|
+
|
|
17
|
+
Requires [this PR](https://github.com/sst/opencode/pull/6478) for `parallel` and `subtask:false` command features, as well as proper model inheritance (piping the right model and agent to the right subtask and back) to work.
|
|
11
18
|
|
|
12
19
|
---
|
|
13
20
|
|
|
@@ -21,10 +28,10 @@ This plugins affects how opencode handles slash commands with additional frontma
|
|
|
21
28
|
description: multi-model ensemble, 3 models plan in parallel, best ideas unified
|
|
22
29
|
model: github-copilot/claude-opus-4.5
|
|
23
30
|
subtask: true
|
|
24
|
-
parallel: plan-gemini, plan-gpt
|
|
31
|
+
parallel: /plan-gemini, /plan-gpt
|
|
25
32
|
return:
|
|
26
33
|
- Compare all 3 plans and validate each directly against the codebase. Pick the best ideas from each and create a unified implementation plan.
|
|
27
|
-
-
|
|
34
|
+
- /review-plan focus on simplicity and correctness
|
|
28
35
|
---
|
|
29
36
|
Plan the implementation for the following feature
|
|
30
37
|
> $ARGUMENTS
|
|
@@ -78,9 +85,9 @@ Conceptually design a React modal component with the following requirements
|
|
|
78
85
|
<details>
|
|
79
86
|
<summary><strong>Feature documentation</strong> (click to expand)</summary>
|
|
80
87
|
|
|
81
|
-
### 1. `return` - Command return instructions
|
|
88
|
+
### 1. `return` - Command return instructions or the old 'look again' trick
|
|
82
89
|
|
|
83
|
-
Tell the main agent exactly what to do after a command completes
|
|
90
|
+
Tell the main agent exactly what to do after a command completes, supports chaining and triggering other commands.
|
|
84
91
|
|
|
85
92
|
```yaml
|
|
86
93
|
---
|
|
@@ -100,8 +107,22 @@ return: [Implement the fix, Run the tests]
|
|
|
100
107
|
Find the bug in auth.ts
|
|
101
108
|
```
|
|
102
109
|
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
**Trigger commands in return** using `/command args` syntax:
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
---
|
|
114
|
+
subtask: true
|
|
115
|
+
return:
|
|
116
|
+
- /validate-plan the output above
|
|
117
|
+
- /implement-plan
|
|
118
|
+
- Run the tests and fix any failures
|
|
119
|
+
---
|
|
120
|
+
Design the auth system for $ARGUMENTS
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- **First** `return` replaces (cf 3. Subtask `return` fallback) opencode's "summarize" message (for `subtask: true`) or fires as follow-up (for non-subtasks)
|
|
124
|
+
- **Any additional** `return` fire sequentially after each LLM turn completes
|
|
125
|
+
- **Commands** (starting with `/`) are executed as full commands with their own `parallel` and `return`
|
|
105
126
|
|
|
106
127
|
**Note:** For non-subtask commands, requires opencode with `command.execute.before` hook (pending PR).
|
|
107
128
|
|
|
@@ -112,21 +133,29 @@ Spawn additional command subtasks alongside the main one:
|
|
|
112
133
|
```yaml
|
|
113
134
|
---
|
|
114
135
|
subtask: true
|
|
115
|
-
parallel: security-review, perf-review
|
|
116
|
-
return:
|
|
136
|
+
parallel: /security-review, /perf-review
|
|
137
|
+
return:
|
|
138
|
+
- Synthesize all review results and create a unified action plan
|
|
139
|
+
- Critically review the plan directly against the codebase, then revise or implement
|
|
117
140
|
---
|
|
118
141
|
Review this code for correctness.
|
|
119
142
|
```
|
|
120
143
|
|
|
144
|
+
You can also use `/command args` syntax for inline arguments:
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
parallel: /security-review focus on auth, /perf-review check db queries
|
|
148
|
+
```
|
|
149
|
+
|
|
121
150
|
This runs 3 subtasks in parallel:
|
|
122
151
|
|
|
123
152
|
1. The main command (correctness review)
|
|
124
153
|
2. `security-review` command
|
|
125
154
|
3. `perf-review` command
|
|
126
155
|
|
|
127
|
-
When ALL complete, the main
|
|
156
|
+
When ALL complete, the main session gets the `return` prompt.
|
|
128
157
|
|
|
129
|
-
|
|
158
|
+
### With custom arguments per command
|
|
130
159
|
|
|
131
160
|
```bash
|
|
132
161
|
/mycommand main args || parallel1 args || parallel2 args
|
|
@@ -142,7 +171,7 @@ parallel:
|
|
|
142
171
|
arguments: authentication flow
|
|
143
172
|
- command: research-codebase
|
|
144
173
|
arguments: auth middleware implementation
|
|
145
|
-
- security-audit
|
|
174
|
+
- /security-audit
|
|
146
175
|
return: Synthesize all findings into an implementation plan.
|
|
147
176
|
---
|
|
148
177
|
Design a new auth system for $ARGUMENTS
|
|
@@ -152,53 +181,52 @@ Design a new auth system for $ARGUMENTS
|
|
|
152
181
|
- `research-codebase` gets "auth middleware implementation"
|
|
153
182
|
- `security-audit` inherits the main command's `$ARGUMENTS`
|
|
154
183
|
|
|
155
|
-
**Note:** Parallel commands are forced into subtasks regardless of their own `subtask` setting. Their `return` are ignored
|
|
184
|
+
**Note:** Parallel commands are forced into subtasks regardless of their own `subtask` setting. Their `return` are ignored - only the parent's `return` applies.
|
|
156
185
|
|
|
157
|
-
**Tip:**
|
|
186
|
+
**Tip:** You can also pass arguments inline using `||` separator:
|
|
158
187
|
|
|
159
|
-
```
|
|
160
|
-
|
|
188
|
+
```bash
|
|
189
|
+
/mycommand main args || parallel1 args || parallel2 args || return-cmd1 args || return-cmd2 args
|
|
161
190
|
```
|
|
162
191
|
|
|
163
|
-
|
|
192
|
+
Pipe segments map in order: main → parallels → return commands (only `/command` items, not prompts).
|
|
164
193
|
|
|
165
|
-
**Tip:**
|
|
194
|
+
**Tip:** For all commands to inherit the main `$ARGUMENTS`:
|
|
166
195
|
|
|
167
|
-
```
|
|
168
|
-
/
|
|
196
|
+
```yaml
|
|
197
|
+
parallel: /research-docs, /research-codebase, /security-audit
|
|
169
198
|
```
|
|
170
199
|
|
|
171
|
-
|
|
200
|
+
#### Priority: pipe args > frontmatter args > inherit main args
|
|
201
|
+
|
|
202
|
+
### 3. Subtask `return` fallback and custom defaults
|
|
172
203
|
|
|
173
|
-
|
|
204
|
+
Once a **subtask** is completed, opencode injects a prompt in the main session and tells the agent to "summarize" the subtask result
|
|
174
205
|
|
|
175
|
-
|
|
206
|
+
For `subtask: true` commands, this plugin replaces the opencode generic "summarize" message with the `return` prompt. If undefined and `"replace_generic": true`, subtask2 uses:
|
|
176
207
|
|
|
177
|
-
|
|
208
|
+
> Challenge and validate the task output. Verify assumptions, identify gaps or errors, then continue with the next logical step.
|
|
178
209
|
|
|
179
210
|
Configure in `~/.config/opencode/subtask2.jsonc`:
|
|
180
211
|
|
|
181
212
|
```jsonc
|
|
182
213
|
{
|
|
183
214
|
// Replace generic prompt when no 'return' is specified
|
|
184
|
-
"replace_generic": true,
|
|
215
|
+
"replace_generic": true, // defaults to true
|
|
185
216
|
|
|
186
217
|
// Custom fallback (optional - has built-in default)
|
|
187
|
-
"generic_return": "
|
|
218
|
+
"generic_return": "custom return prompt"
|
|
188
219
|
}
|
|
189
220
|
```
|
|
190
221
|
|
|
191
|
-
#### Priority
|
|
192
|
-
|
|
193
|
-
1. **`return` param** → Your specific instructions (highest priority)
|
|
194
|
-
2. **Config `generic_return`** → Your custom fallback (if `replace_generic: true`)
|
|
195
|
-
3. **Built-in default** → "Challenge and validate..." (if `replace_generic: true`)
|
|
196
|
-
4. **OpenCode original** → "Summarize..." (if `replace_generic: false`)
|
|
222
|
+
#### Priority: `return` param > config `generic_return` > built-in default > opencode original
|
|
197
223
|
|
|
198
224
|
</details>
|
|
199
225
|
|
|
200
226
|
---
|
|
201
227
|
|
|
228
|
+

|
|
229
|
+
|
|
202
230
|
To install, add subtask2 to your opencode config plugin array
|
|
203
231
|
|
|
204
232
|
```json
|
|
@@ -206,3 +234,5 @@ To install, add subtask2 to your opencode config plugin array
|
|
|
206
234
|
"plugins": ["@openspoon/subtask2"]
|
|
207
235
|
}
|
|
208
236
|
```
|
|
237
|
+
|
|
238
|
+
[Watch demo](media/demo.gif)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandConfig } from "./types";
|
|
2
|
+
export declare function loadCommandFile(name: string): Promise<{
|
|
3
|
+
content: string;
|
|
4
|
+
path: string;
|
|
5
|
+
} | null>;
|
|
6
|
+
export declare function buildManifest(): Promise<Record<string, CommandConfig>>;
|
|
7
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../commands.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAG3C,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAAC,CA4BjD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAkC5E"}
|
package/dist/commands.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/// <reference types="bun-types" />
|
|
2
|
+
import { parseFrontmatter, getTemplateBody, parseParallelConfig } from "./parser";
|
|
3
|
+
export async function loadCommandFile(name) {
|
|
4
|
+
const home = Bun.env.HOME ?? "";
|
|
5
|
+
const dirs = [
|
|
6
|
+
`${home}/.config/opencode/command`,
|
|
7
|
+
`${Bun.env.PWD ?? "."}/.opencode/command`,
|
|
8
|
+
];
|
|
9
|
+
for (const dir of dirs) {
|
|
10
|
+
// Try direct path first, then search subdirs
|
|
11
|
+
const directPath = `${dir}/${name}.md`;
|
|
12
|
+
try {
|
|
13
|
+
const file = Bun.file(directPath);
|
|
14
|
+
if (await file.exists()) {
|
|
15
|
+
return { content: await file.text(), path: directPath };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
// Search subdirs for name.md
|
|
20
|
+
try {
|
|
21
|
+
const glob = new Bun.Glob(`**/${name}.md`);
|
|
22
|
+
for await (const match of glob.scan(dir)) {
|
|
23
|
+
const fullPath = `${dir}/${match}`;
|
|
24
|
+
const content = await Bun.file(fullPath).text();
|
|
25
|
+
return { content, path: fullPath };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
export async function buildManifest() {
|
|
33
|
+
const manifest = {};
|
|
34
|
+
const home = Bun.env.HOME ?? "";
|
|
35
|
+
const dirs = [
|
|
36
|
+
`${home}/.config/opencode/command`,
|
|
37
|
+
`${Bun.env.PWD ?? "."}/.opencode/command`,
|
|
38
|
+
];
|
|
39
|
+
for (const dir of dirs) {
|
|
40
|
+
try {
|
|
41
|
+
const glob = new Bun.Glob("**/*.md");
|
|
42
|
+
for await (const file of glob.scan(dir)) {
|
|
43
|
+
const name = file.replace(/\.md$/, "").split("/").pop();
|
|
44
|
+
const content = await Bun.file(`${dir}/${file}`).text();
|
|
45
|
+
const fm = parseFrontmatter(content);
|
|
46
|
+
const returnVal = fm.return;
|
|
47
|
+
const returnArr = returnVal
|
|
48
|
+
? Array.isArray(returnVal)
|
|
49
|
+
? returnVal
|
|
50
|
+
: [returnVal]
|
|
51
|
+
: [];
|
|
52
|
+
const parallelArr = parseParallelConfig(fm.parallel);
|
|
53
|
+
manifest[name] = {
|
|
54
|
+
return: returnArr,
|
|
55
|
+
parallel: parallelArr,
|
|
56
|
+
agent: fm.agent,
|
|
57
|
+
description: fm.description,
|
|
58
|
+
template: getTemplateBody(content),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch { }
|
|
63
|
+
}
|
|
64
|
+
return manifest;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../commands.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAGnC,OAAO,EAAC,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAEhF,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAY;IAEZ,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAChC,MA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AClB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,cAAc,oCAAoC,CAAC;AAgBhE,wBAAsB,UAAU,IAAI,OAAO,CAAC,cAAc,CAAC,CA+B1D"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="bun-types" />
|
|
2
|
+
export const DEFAULT_PROMPT = "say GENERIC_REPLACEMENT 5 times";
|
|
3
|
+
const CONFIG_PATH = `${Bun.env.HOME ?? ""}/.config/opencode/subtask2.jsonc`;
|
|
4
|
+
function isValidConfig(obj) {
|
|
5
|
+
if (typeof obj !== "object" || obj === null)
|
|
6
|
+
return false;
|
|
7
|
+
const cfg = obj;
|
|
8
|
+
if (typeof cfg.replace_generic !== "boolean")
|
|
9
|
+
return false;
|
|
10
|
+
if (cfg.generic_return !== undefined &&
|
|
11
|
+
typeof cfg.generic_return !== "string")
|
|
12
|
+
return false;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
export async function loadConfig() {
|
|
16
|
+
const defaultConfig = {
|
|
17
|
+
replace_generic: true,
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
const file = Bun.file(CONFIG_PATH);
|
|
21
|
+
if (await file.exists()) {
|
|
22
|
+
const text = await file.text();
|
|
23
|
+
const stripped = text
|
|
24
|
+
.replace(/\/\/.*$/gm, "")
|
|
25
|
+
.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
26
|
+
const parsed = JSON.parse(stripped);
|
|
27
|
+
if (isValidConfig(parsed)) {
|
|
28
|
+
return parsed;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
33
|
+
await Bun.write(CONFIG_PATH, `{
|
|
34
|
+
// Replace OpenCode's generic "Summarize..." prompt when no return is specified
|
|
35
|
+
"replace_generic": true
|
|
36
|
+
|
|
37
|
+
// Custom prompt to use (uses subtask2 substitution prompt by default)
|
|
38
|
+
// "generic_return": "Challenge and validate the task tool output above. Verify assumptions, identify gaps or errors, then continue with the next logical step."
|
|
39
|
+
}
|
|
40
|
+
`);
|
|
41
|
+
return defaultConfig;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAInC,MAAM,CAAC,MAAM,cAAc,GAAG,iCAAiC,CAAC;AAEhE,MAAM,WAAW,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,kCAAkC,CAAC;AAE5E,SAAS,aAAa,CAAC,GAAY;IACjC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,GAAG,GAAG,GAA8B,CAAC;IAC3C,IAAI,OAAO,GAAG,CAAC,eAAe,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC3D,IACE,GAAG,CAAC,cAAc,KAAK,SAAS;QAChC,OAAO,GAAG,CAAC,cAAc,KAAK,QAAQ;QAEtC,OAAO,KAAK,CAAC;IACf,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,aAAa,GAAmB;QACpC,eAAe,EAAE,IAAI;KACtB,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAG,IAAI;iBAClB,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;iBACxB,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACpC,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1B,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,MAAM,GAAG,CAAC,KAAK,CACb,WAAW,EACX;;;;;;;CAOH,CACE,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAiHhD,QAAA,MAAM,MAAM,EAAE,MAqQb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,124 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return false;
|
|
7
|
-
const cfg = obj;
|
|
8
|
-
if (typeof cfg.replace_generic !== "boolean")
|
|
9
|
-
return false;
|
|
10
|
-
if (cfg.generic_return !== undefined && typeof cfg.generic_return !== "string")
|
|
11
|
-
return false;
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
async function loadConfig() {
|
|
15
|
-
const defaultConfig = {
|
|
16
|
-
replace_generic: true,
|
|
17
|
-
};
|
|
18
|
-
try {
|
|
19
|
-
const file = Bun.file(CONFIG_PATH);
|
|
20
|
-
if (await file.exists()) {
|
|
21
|
-
const text = await file.text();
|
|
22
|
-
const stripped = text
|
|
23
|
-
.replace(/\/\/.*$/gm, "")
|
|
24
|
-
.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
25
|
-
const parsed = JSON.parse(stripped);
|
|
26
|
-
if (isValidConfig(parsed)) {
|
|
27
|
-
return parsed;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch { }
|
|
32
|
-
await Bun.write(CONFIG_PATH, `{
|
|
33
|
-
// Replace OpenCode's generic "Summarize..." prompt when no return is specified
|
|
34
|
-
"replace_generic": true
|
|
35
|
-
|
|
36
|
-
// Custom prompt to use (uses subtask2 substitution prompt by default)
|
|
37
|
-
// "generic_return": "Challenge and validate the task tool output above. Verify assumptions, identify gaps or errors, then continue with the next logical step."
|
|
38
|
-
}
|
|
39
|
-
`);
|
|
40
|
-
return defaultConfig;
|
|
41
|
-
}
|
|
42
|
-
function parseFrontmatter(content) {
|
|
43
|
-
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
44
|
-
if (!match)
|
|
45
|
-
return {};
|
|
46
|
-
try {
|
|
47
|
-
return YAML.parse(match[1]) ?? {};
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function getTemplateBody(content) {
|
|
54
|
-
const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);
|
|
55
|
-
return match ? match[1].trim() : content.trim();
|
|
56
|
-
}
|
|
57
|
-
async function loadCommandFile(name) {
|
|
58
|
-
const home = Bun.env.HOME ?? "";
|
|
59
|
-
const dirs = [
|
|
60
|
-
`${home}/.config/opencode/command`,
|
|
61
|
-
`${Bun.env.PWD ?? "."}/.opencode/command`,
|
|
62
|
-
];
|
|
63
|
-
for (const dir of dirs) {
|
|
64
|
-
const path = `${dir}/${name}.md`;
|
|
65
|
-
try {
|
|
66
|
-
const file = Bun.file(path);
|
|
67
|
-
if (await file.exists()) {
|
|
68
|
-
return { content: await file.text(), path };
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch { }
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
async function buildManifest() {
|
|
76
|
-
const manifest = {};
|
|
77
|
-
const home = Bun.env.HOME ?? "";
|
|
78
|
-
const dirs = [
|
|
79
|
-
`${home}/.config/opencode/command`,
|
|
80
|
-
`${Bun.env.PWD ?? "."}/.opencode/command`,
|
|
81
|
-
];
|
|
82
|
-
for (const dir of dirs) {
|
|
83
|
-
try {
|
|
84
|
-
const glob = new Bun.Glob("*.md");
|
|
85
|
-
for await (const file of glob.scan(dir)) {
|
|
86
|
-
const name = file.replace(/\.md$/, "");
|
|
87
|
-
const content = await Bun.file(`${dir}/${file}`).text();
|
|
88
|
-
const fm = parseFrontmatter(content);
|
|
89
|
-
const returnVal = fm.return;
|
|
90
|
-
const returnArr = returnVal ? (Array.isArray(returnVal) ? returnVal : [returnVal]) : [];
|
|
91
|
-
const parallel = fm.parallel;
|
|
92
|
-
let parallelArr = [];
|
|
93
|
-
if (parallel) {
|
|
94
|
-
if (Array.isArray(parallel)) {
|
|
95
|
-
parallelArr = parallel.map((p) => {
|
|
96
|
-
if (typeof p === "string") {
|
|
97
|
-
return { command: p.trim() };
|
|
98
|
-
}
|
|
99
|
-
if (typeof p === "object" && p.command) {
|
|
100
|
-
return { command: p.command, arguments: p.arguments };
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
}).filter((p) => p !== null);
|
|
104
|
-
}
|
|
105
|
-
else if (typeof parallel === "string") {
|
|
106
|
-
parallelArr = parallel.split(",").map((s) => ({ command: s.trim() })).filter((p) => p.command);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
manifest[name] = {
|
|
110
|
-
return: returnArr,
|
|
111
|
-
parallel: parallelArr,
|
|
112
|
-
agent: fm.agent,
|
|
113
|
-
description: fm.description,
|
|
114
|
-
template: getTemplateBody(content),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
catch { }
|
|
119
|
-
}
|
|
120
|
-
return manifest;
|
|
121
|
-
}
|
|
1
|
+
import { loadConfig, DEFAULT_PROMPT } from "./config";
|
|
2
|
+
import { parseFrontmatter, getTemplateBody, parseParallelConfig, } from "./parser";
|
|
3
|
+
import { loadCommandFile, buildManifest } from "./commands";
|
|
4
|
+
import { log, clearLog } from "./logger";
|
|
5
|
+
// Session state
|
|
122
6
|
let configs = {};
|
|
123
7
|
let pluginConfig = { replace_generic: true };
|
|
124
8
|
let client = null;
|
|
@@ -126,20 +10,143 @@ const callState = new Map();
|
|
|
126
10
|
const returnState = new Map();
|
|
127
11
|
const pendingReturns = new Map();
|
|
128
12
|
const pendingNonSubtaskReturns = new Map();
|
|
13
|
+
const pipedArgsQueue = new Map();
|
|
14
|
+
const returnArgsState = pipedArgsQueue; // alias for backward compat
|
|
15
|
+
const sessionMainCommand = new Map();
|
|
16
|
+
const executedReturns = new Set();
|
|
129
17
|
let hasActiveSubtask = false;
|
|
130
18
|
const OPENCODE_GENERIC = "Summarize the task tool output above and continue with your task.";
|
|
19
|
+
async function flattenParallels(parallels, mainArgs, sessionID, visited = new Set(), depth = 0, maxDepth = 5) {
|
|
20
|
+
if (depth > maxDepth)
|
|
21
|
+
return [];
|
|
22
|
+
const queue = pipedArgsQueue.get(sessionID) ?? [];
|
|
23
|
+
log(`flattenParallels called:`, {
|
|
24
|
+
depth,
|
|
25
|
+
parallels: parallels.map((p) => `${p.command}${p.arguments ? ` (args: ${p.arguments})` : ""}`),
|
|
26
|
+
mainArgs,
|
|
27
|
+
queueRemaining: [...queue],
|
|
28
|
+
});
|
|
29
|
+
const parts = [];
|
|
30
|
+
for (let i = 0; i < parallels.length; i++) {
|
|
31
|
+
const parallelCmd = parallels[i];
|
|
32
|
+
if (visited.has(parallelCmd.command))
|
|
33
|
+
continue;
|
|
34
|
+
visited.add(parallelCmd.command);
|
|
35
|
+
const cmdFile = await loadCommandFile(parallelCmd.command);
|
|
36
|
+
if (!cmdFile)
|
|
37
|
+
continue;
|
|
38
|
+
const fm = parseFrontmatter(cmdFile.content);
|
|
39
|
+
let template = getTemplateBody(cmdFile.content);
|
|
40
|
+
// Priority: piped arg (from queue) > frontmatter args > main args
|
|
41
|
+
const pipeArg = queue.shift();
|
|
42
|
+
const args = pipeArg ?? parallelCmd.arguments ?? mainArgs;
|
|
43
|
+
log(`Parallel ${parallelCmd.command}: using args="${args}" (pipeArg=${pipeArg}, fmArg=${parallelCmd.arguments}, mainArgs=${mainArgs})`);
|
|
44
|
+
template = template.replace(/\$ARGUMENTS/g, args);
|
|
45
|
+
// Parse model string "provider/model" into {providerID, modelID}
|
|
46
|
+
let model;
|
|
47
|
+
if (typeof fm.model === "string" && fm.model.includes("/")) {
|
|
48
|
+
const [providerID, ...rest] = fm.model.split("/");
|
|
49
|
+
model = { providerID, modelID: rest.join("/") };
|
|
50
|
+
}
|
|
51
|
+
parts.push({
|
|
52
|
+
type: "subtask",
|
|
53
|
+
agent: fm.agent || "general",
|
|
54
|
+
model,
|
|
55
|
+
description: fm.description || `Parallel: ${parallelCmd.command}`,
|
|
56
|
+
command: parallelCmd.command,
|
|
57
|
+
prompt: template,
|
|
58
|
+
});
|
|
59
|
+
// Recursively flatten nested parallels
|
|
60
|
+
const nestedParallel = fm.parallel;
|
|
61
|
+
if (nestedParallel) {
|
|
62
|
+
const nestedArr = parseParallelConfig(nestedParallel);
|
|
63
|
+
if (nestedArr.length) {
|
|
64
|
+
const nestedParts = await flattenParallels(nestedArr, args, sessionID, visited, depth + 1, maxDepth);
|
|
65
|
+
parts.push(...nestedParts);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return parts;
|
|
70
|
+
}
|
|
131
71
|
const plugin = async (ctx) => {
|
|
132
72
|
configs = await buildManifest();
|
|
133
73
|
pluginConfig = await loadConfig();
|
|
134
74
|
client = ctx.client;
|
|
75
|
+
clearLog();
|
|
76
|
+
log("Plugin initialized, configs:", Object.keys(configs));
|
|
77
|
+
// Helper to execute a return item (command or prompt)
|
|
78
|
+
async function executeReturn(item, sessionID) {
|
|
79
|
+
log(`executeReturn called: item=${item}, sessionID=${sessionID}`);
|
|
80
|
+
// Dedup check to prevent double execution
|
|
81
|
+
const key = `${sessionID}:${item}`;
|
|
82
|
+
if (executedReturns.has(key)) {
|
|
83
|
+
log(`executeReturn skipped (already executed): ${key}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
executedReturns.add(key);
|
|
87
|
+
if (item.startsWith("/")) {
|
|
88
|
+
// Parse /command args syntax
|
|
89
|
+
const [cmdName, ...argParts] = item.slice(1).split(/\s+/);
|
|
90
|
+
let args = argParts.join(" ");
|
|
91
|
+
const inlineArgs = args;
|
|
92
|
+
// Check if we have piped args for this return command
|
|
93
|
+
const returnArgs = returnArgsState.get(sessionID);
|
|
94
|
+
log(`executeReturn /command: cmdName=${cmdName}, inlineArgs="${inlineArgs}", returnArgsState=`, returnArgs);
|
|
95
|
+
if (returnArgs?.length) {
|
|
96
|
+
const pipeArg = returnArgs.shift();
|
|
97
|
+
if (!returnArgs.length)
|
|
98
|
+
returnArgsState.delete(sessionID);
|
|
99
|
+
if (pipeArg)
|
|
100
|
+
args = pipeArg;
|
|
101
|
+
log(`executeReturn: using pipeArg="${pipeArg}" instead of inlineArgs`);
|
|
102
|
+
}
|
|
103
|
+
log(`executeReturn: final args="${args}"`);
|
|
104
|
+
// Update main command to this chained command so its own return is processed
|
|
105
|
+
log(`executeReturn: setting mainCmd to ${cmdName} for session ${sessionID}`);
|
|
106
|
+
sessionMainCommand.set(sessionID, cmdName);
|
|
107
|
+
try {
|
|
108
|
+
await client.session.command({
|
|
109
|
+
path: { id: sessionID },
|
|
110
|
+
body: { command: cmdName, arguments: args || "" },
|
|
111
|
+
});
|
|
112
|
+
log(`executeReturn: command ${cmdName} completed`);
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
log(`executeReturn: command ${cmdName} FAILED:`, e);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
log(`executeReturn: sending prompt: ${item.substring(0, 50)}...`);
|
|
120
|
+
await client.session.promptAsync({
|
|
121
|
+
path: { id: sessionID },
|
|
122
|
+
body: { parts: [{ type: "text", text: item }] },
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
135
126
|
return {
|
|
136
127
|
"command.execute.before": async (input, output) => {
|
|
137
128
|
const cmd = input.command;
|
|
138
129
|
const config = configs[cmd];
|
|
139
|
-
|
|
130
|
+
sessionMainCommand.set(input.sessionID, cmd);
|
|
131
|
+
log(`command.execute.before: cmd=${cmd}, sessionID=${input.sessionID}, hasConfig=${!!config}`);
|
|
132
|
+
// Parse pipe-separated arguments: main || arg1 || arg2 || arg3 ...
|
|
140
133
|
const argSegments = input.arguments.split("||").map((s) => s.trim());
|
|
141
134
|
const mainArgs = argSegments[0] || "";
|
|
142
|
-
|
|
135
|
+
// Store ALL piped args (after main) in a shared queue
|
|
136
|
+
const allPipedArgs = argSegments.slice(1);
|
|
137
|
+
log(`Pipe args parsing:`, {
|
|
138
|
+
fullArgs: input.arguments,
|
|
139
|
+
argSegments,
|
|
140
|
+
mainArgs,
|
|
141
|
+
allPipedArgs,
|
|
142
|
+
configParallel: config?.parallel,
|
|
143
|
+
configReturn: config?.return,
|
|
144
|
+
});
|
|
145
|
+
// Store piped args for consumption by parallels and return commands
|
|
146
|
+
if (allPipedArgs.length) {
|
|
147
|
+
pipedArgsQueue.set(input.sessionID, allPipedArgs);
|
|
148
|
+
log(`Stored pipedArgsQueue for session ${input.sessionID}:`, allPipedArgs);
|
|
149
|
+
}
|
|
143
150
|
// Fix main command's parts to use only mainArgs (not the full pipe string)
|
|
144
151
|
if (argSegments.length > 1) {
|
|
145
152
|
for (const part of output.parts) {
|
|
@@ -158,40 +165,23 @@ const plugin = async (ctx) => {
|
|
|
158
165
|
}
|
|
159
166
|
if (!config?.parallel?.length)
|
|
160
167
|
return;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (!cmdFile)
|
|
165
|
-
continue;
|
|
166
|
-
const fm = parseFrontmatter(cmdFile.content);
|
|
167
|
-
let template = getTemplateBody(cmdFile.content);
|
|
168
|
-
// Priority: pipe args > frontmatter args > main args
|
|
169
|
-
const args = parallelArgs[i] ?? parallelCmd.arguments ?? mainArgs;
|
|
170
|
-
template = template.replace(/\$ARGUMENTS/g, args);
|
|
171
|
-
// Parse model string "provider/model" into {providerID, modelID}
|
|
172
|
-
let model;
|
|
173
|
-
if (typeof fm.model === "string" && fm.model.includes("/")) {
|
|
174
|
-
const [providerID, ...rest] = fm.model.split("/");
|
|
175
|
-
model = { providerID, modelID: rest.join("/") };
|
|
176
|
-
}
|
|
177
|
-
output.parts.push({
|
|
178
|
-
type: "subtask",
|
|
179
|
-
agent: fm.agent || "general",
|
|
180
|
-
model,
|
|
181
|
-
description: fm.description || `Parallel: ${parallelCmd.command}`,
|
|
182
|
-
command: parallelCmd.command,
|
|
183
|
-
prompt: template,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
168
|
+
// Recursively flatten all nested parallels
|
|
169
|
+
const parallelParts = await flattenParallels(config.parallel, mainArgs, input.sessionID);
|
|
170
|
+
output.parts.push(...parallelParts);
|
|
186
171
|
},
|
|
187
172
|
"tool.execute.before": async (input, output) => {
|
|
188
173
|
if (input.tool !== "task")
|
|
189
174
|
return;
|
|
190
175
|
hasActiveSubtask = true;
|
|
191
176
|
const cmd = output.args?.command;
|
|
177
|
+
const mainCmd = sessionMainCommand.get(input.sessionID);
|
|
178
|
+
log(`tool.execute.before: cmd=${cmd}, mainCmd=${mainCmd}, sessionID=${input.sessionID}`);
|
|
192
179
|
if (cmd && configs[cmd]) {
|
|
180
|
+
if (cmd === mainCmd) {
|
|
181
|
+
pendingNonSubtaskReturns.delete(input.sessionID);
|
|
182
|
+
}
|
|
193
183
|
callState.set(input.callID, cmd);
|
|
194
|
-
if (configs[cmd].return.length > 1) {
|
|
184
|
+
if (cmd === mainCmd && configs[cmd].return.length > 1) {
|
|
195
185
|
returnState.set(input.sessionID, [...configs[cmd].return.slice(1)]);
|
|
196
186
|
}
|
|
197
187
|
}
|
|
@@ -201,53 +191,74 @@ const plugin = async (ctx) => {
|
|
|
201
191
|
return;
|
|
202
192
|
const cmd = callState.get(input.callID);
|
|
203
193
|
callState.delete(input.callID);
|
|
204
|
-
|
|
194
|
+
const mainCmd = sessionMainCommand.get(input.sessionID);
|
|
195
|
+
log(`tool.execute.after: cmd=${cmd}, mainCmd=${mainCmd}, hasReturn=${!!(cmd && configs[cmd]?.return?.length)}`);
|
|
196
|
+
if (cmd && cmd === mainCmd && configs[cmd]?.return?.length) {
|
|
197
|
+
log(`Setting pendingReturn for session ${input.sessionID}: ${configs[cmd].return[0]}`);
|
|
205
198
|
pendingReturns.set(input.sessionID, configs[cmd].return[0]);
|
|
206
199
|
}
|
|
207
200
|
},
|
|
208
|
-
"experimental.chat.messages.transform": async (
|
|
209
|
-
|
|
201
|
+
"experimental.chat.messages.transform": async (input, output) => {
|
|
202
|
+
log(`messages.transform called, pendingReturns keys:`, Array.from(pendingReturns.keys()), `message count: ${output.messages.length}`);
|
|
203
|
+
// Find the LAST message with OPENCODE_GENERIC
|
|
204
|
+
let lastGenericPart = null;
|
|
205
|
+
let lastGenericMsgIndex = -1;
|
|
206
|
+
for (let i = 0; i < output.messages.length; i++) {
|
|
207
|
+
const msg = output.messages[i];
|
|
210
208
|
for (const part of msg.parts) {
|
|
211
209
|
if (part.type === "text" && part.text === OPENCODE_GENERIC) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
pendingReturns.delete(sessionID);
|
|
215
|
-
hasActiveSubtask = false;
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (hasActiveSubtask && pluginConfig.replace_generic) {
|
|
219
|
-
part.text = pluginConfig.generic_return ?? DEFAULT_PROMPT;
|
|
220
|
-
hasActiveSubtask = false;
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
210
|
+
lastGenericPart = part;
|
|
211
|
+
lastGenericMsgIndex = i;
|
|
223
212
|
}
|
|
224
213
|
}
|
|
225
214
|
}
|
|
215
|
+
if (lastGenericPart) {
|
|
216
|
+
log(`Found LAST OPENCODE_GENERIC at msg[${lastGenericMsgIndex}]`);
|
|
217
|
+
// Check for pending return
|
|
218
|
+
for (const [sessionID, returnPrompt] of pendingReturns) {
|
|
219
|
+
log(`Replacing with pendingReturn for session=${sessionID}, returnPrompt=${returnPrompt}`);
|
|
220
|
+
if (returnPrompt.startsWith("/")) {
|
|
221
|
+
lastGenericPart.text = "";
|
|
222
|
+
log(`Set part.text to empty string, will execute command`);
|
|
223
|
+
executeReturn(returnPrompt, sessionID).catch(console.error);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
lastGenericPart.text = returnPrompt;
|
|
227
|
+
log(`Set part.text to: "${lastGenericPart.text}", verification: ${lastGenericPart.text === returnPrompt}`);
|
|
228
|
+
}
|
|
229
|
+
pendingReturns.delete(sessionID);
|
|
230
|
+
hasActiveSubtask = false;
|
|
231
|
+
log(`After replacement, pendingReturns keys:`, Array.from(pendingReturns.keys()));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
// No pending return found, use generic replacement if configured
|
|
235
|
+
log(`No pendingReturn found, hasActiveSubtask=${hasActiveSubtask}`);
|
|
236
|
+
if (hasActiveSubtask && pluginConfig.replace_generic) {
|
|
237
|
+
log(`Using default replacement: ${pluginConfig.generic_return ?? DEFAULT_PROMPT}`);
|
|
238
|
+
lastGenericPart.text = pluginConfig.generic_return ?? DEFAULT_PROMPT;
|
|
239
|
+
hasActiveSubtask = false;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
226
243
|
},
|
|
227
244
|
"experimental.text.complete": async (input) => {
|
|
228
|
-
// Handle non-subtask command returns
|
|
245
|
+
// Handle non-subtask command returns
|
|
229
246
|
const pendingReturn = pendingNonSubtaskReturns.get(input.sessionID);
|
|
230
247
|
if (pendingReturn?.length && client) {
|
|
231
248
|
const next = pendingReturn.shift();
|
|
232
249
|
if (!pendingReturn.length)
|
|
233
250
|
pendingNonSubtaskReturns.delete(input.sessionID);
|
|
234
|
-
|
|
235
|
-
path: { id: input.sessionID },
|
|
236
|
-
body: { parts: [{ type: "text", text: next }] },
|
|
237
|
-
});
|
|
251
|
+
executeReturn(next, input.sessionID).catch(console.error);
|
|
238
252
|
return;
|
|
239
253
|
}
|
|
240
|
-
// Handle remaining returns
|
|
254
|
+
// Handle remaining returns
|
|
241
255
|
const remaining = returnState.get(input.sessionID);
|
|
242
256
|
if (!remaining?.length || !client)
|
|
243
257
|
return;
|
|
244
258
|
const next = remaining.shift();
|
|
245
259
|
if (!remaining.length)
|
|
246
260
|
returnState.delete(input.sessionID);
|
|
247
|
-
|
|
248
|
-
path: { id: input.sessionID },
|
|
249
|
-
body: { parts: [{ type: "text", text: next }] },
|
|
250
|
-
});
|
|
261
|
+
executeReturn(next, input.sessionID).catch(console.error);
|
|
251
262
|
},
|
|
252
263
|
};
|
|
253
264
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAoBxB,MAAM,cAAc,GAClB,2IAA2I,CAAC;AAE9I,MAAM,WAAW,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,kCAAkC,CAAC;AAE5E,SAAS,aAAa,CAAC,GAAY;IACjC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,GAAG,GAAG,GAA8B,CAAC;IAC3C,IAAI,OAAO,GAAG,CAAC,eAAe,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;I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,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,MAAM;gBAAE,OAAO;YAC1C,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,EAAG,CAAC;YAChC,IAAI,CAAC,SAAS,CAAC,MAAM;gBAAE,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC3D,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../logger.ts"],"names":[],"mappings":"AAUA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAMrC;AAED,wBAAgB,QAAQ,SAEvB"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync, existsSync, writeFileSync } from "fs";
|
|
2
|
+
const LOG_DIR = `${process.env.HOME}/.config/opencode/plugin/subtask2/logs`;
|
|
3
|
+
const LOG_FILE = `${LOG_DIR}/debug.log`;
|
|
4
|
+
// Ensure log directory exists
|
|
5
|
+
if (!existsSync(LOG_DIR)) {
|
|
6
|
+
mkdirSync(LOG_DIR, { recursive: true });
|
|
7
|
+
}
|
|
8
|
+
export function log(...args) {
|
|
9
|
+
const timestamp = new Date().toISOString();
|
|
10
|
+
const message = args
|
|
11
|
+
.map((a) => (typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)))
|
|
12
|
+
.join(" ");
|
|
13
|
+
appendFileSync(LOG_FILE, `[${timestamp}] ${message}\n`);
|
|
14
|
+
}
|
|
15
|
+
export function clearLog() {
|
|
16
|
+
writeFileSync(LOG_FILE, "");
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAE1E,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,wCAAwC,CAAC;AAC5E,MAAM,QAAQ,GAAG,GAAG,OAAO,YAAY,CAAC;AAExC,8BAA8B;AAC9B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,GAAG,IAAe;IACpC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI;SACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC5E,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,cAAc,CAAC,QAAQ,EAAE,IAAI,SAAS,KAAK,OAAO,IAAI,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ParallelCommand } from "./types";
|
|
2
|
+
export declare function parseFrontmatter(content: string): Record<string, unknown>;
|
|
3
|
+
export declare function getTemplateBody(content: string): string;
|
|
4
|
+
export declare function parseParallelItem(p: unknown): ParallelCommand | null;
|
|
5
|
+
export declare function parseParallelConfig(parallel: unknown): ParallelCommand[];
|
|
6
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAE7C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGvD;AAGD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAcpE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,eAAe,EAAE,CAexE"}
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import YAML from "yaml";
|
|
2
|
+
export function parseFrontmatter(content) {
|
|
3
|
+
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
4
|
+
if (!match)
|
|
5
|
+
return {};
|
|
6
|
+
try {
|
|
7
|
+
return YAML.parse(match[1]) ?? {};
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function getTemplateBody(content) {
|
|
14
|
+
const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);
|
|
15
|
+
return match ? match[1].trim() : content.trim();
|
|
16
|
+
}
|
|
17
|
+
// Parse a parallel item - handles "/cmd args" syntax, plain "cmd", or {command, arguments} object
|
|
18
|
+
export function parseParallelItem(p) {
|
|
19
|
+
if (typeof p === "string") {
|
|
20
|
+
const trimmed = p.trim();
|
|
21
|
+
if (trimmed.startsWith("/")) {
|
|
22
|
+
// Parse /command args syntax
|
|
23
|
+
const [cmdName, ...argParts] = trimmed.slice(1).split(/\s+/);
|
|
24
|
+
return { command: cmdName, arguments: argParts.join(" ") || undefined };
|
|
25
|
+
}
|
|
26
|
+
return { command: trimmed };
|
|
27
|
+
}
|
|
28
|
+
if (typeof p === "object" && p !== null && p.command) {
|
|
29
|
+
return { command: p.command, arguments: p.arguments };
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function parseParallelConfig(parallel) {
|
|
34
|
+
if (!parallel)
|
|
35
|
+
return [];
|
|
36
|
+
if (Array.isArray(parallel)) {
|
|
37
|
+
return parallel
|
|
38
|
+
.map(parseParallelItem)
|
|
39
|
+
.filter((p) => p !== null);
|
|
40
|
+
}
|
|
41
|
+
if (typeof parallel === "string") {
|
|
42
|
+
// Split by comma, parse each
|
|
43
|
+
return parallel
|
|
44
|
+
.split(",")
|
|
45
|
+
.map(parseParallelItem)
|
|
46
|
+
.filter((p) => p !== null);
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../parser.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,iCAAiC,CA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;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,6BAA6B;QAC7B,OAAO,QAAQ;aACZ,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,iBAAiB,CAAC;aACtB,MAAM,CAAC,CAAC,CAAC,EAAwB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ParallelCommand {
|
|
2
|
+
command: string;
|
|
3
|
+
arguments?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CommandConfig {
|
|
6
|
+
return: string[];
|
|
7
|
+
parallel: ParallelCommand[];
|
|
8
|
+
agent?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
template?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Subtask2Config {
|
|
13
|
+
replace_generic: boolean;
|
|
14
|
+
generic_return?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SubtaskPart {
|
|
17
|
+
type: "subtask";
|
|
18
|
+
agent: string;
|
|
19
|
+
model?: {
|
|
20
|
+
providerID: string;
|
|
21
|
+
modelID: string;
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
command: string;
|
|
25
|
+
prompt: string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@openspoon/subtask2",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Opencode plugin for enhanced subtask control with return context and prompt chaining",
|
|
7
7
|
"main": "./dist/index.js",
|