opencode-orchestra 0.0.0-stage → 1.0.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 +73 -2
- package/dist/board.d.ts +47 -0
- package/dist/board.js +89 -0
- package/dist/context.d.ts +22 -0
- package/dist/context.js +120 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +634 -0
- package/dist/parser.d.ts +63 -0
- package/dist/parser.js +411 -0
- package/dist/pipeline.d.ts +74 -0
- package/dist/pipeline.js +188 -0
- package/dist/prompts.d.ts +7 -0
- package/dist/prompts.js +175 -0
- package/dist/session-registry.d.ts +75 -0
- package/dist/session-registry.js +199 -0
- package/dist/swarm.d.ts +61 -0
- package/dist/swarm.js +369 -0
- package/dist/teamwork.d.ts +45 -0
- package/dist/teamwork.js +545 -0
- package/package.json +28 -4
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type BoostMode = "auto" | "coder" | "investigate";
|
|
2
|
+
export type ResolvedBoostMode = "coder" | "investigate";
|
|
3
|
+
export interface ModelRef {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly providerID: string;
|
|
6
|
+
readonly variant?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ParsedBoostArgs {
|
|
9
|
+
mode: BoostMode;
|
|
10
|
+
rounds?: number;
|
|
11
|
+
modelOverride?: ModelRef;
|
|
12
|
+
task: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AssistantPartLike {
|
|
15
|
+
type: string;
|
|
16
|
+
text?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SessionMessageLike {
|
|
19
|
+
type: string;
|
|
20
|
+
content?: readonly AssistantPartLike[];
|
|
21
|
+
error?: {
|
|
22
|
+
message?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
} | unknown;
|
|
25
|
+
}
|
|
26
|
+
export declare function parseModelRef(spec: string | undefined): ModelRef | undefined;
|
|
27
|
+
export declare function parseBoostArgs(raw: string): ParsedBoostArgs;
|
|
28
|
+
export declare function extractAssistantText(messages: readonly SessionMessageLike[]): {
|
|
29
|
+
text: string;
|
|
30
|
+
error?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function heuristicClassifyTask(task: string): ResolvedBoostMode;
|
|
33
|
+
export declare function parseClassifierDecision(output: string, fallbackTask: string): ResolvedBoostMode;
|
|
34
|
+
export declare function parseVerificationDecision(output: string): {
|
|
35
|
+
passed: boolean;
|
|
36
|
+
reason: string;
|
|
37
|
+
};
|
|
38
|
+
export type TeamworkMode = "auto" | "swe" | "review" | "colosseum" | "discover" | "audit";
|
|
39
|
+
export type ResolvedTeamworkMode = "swe" | "review" | "colosseum" | "discover" | "audit";
|
|
40
|
+
export interface ParsedTeamworkArgs {
|
|
41
|
+
mode: TeamworkMode;
|
|
42
|
+
qaRounds?: number;
|
|
43
|
+
workers?: number;
|
|
44
|
+
skipInterview: boolean;
|
|
45
|
+
modelOverride?: ModelRef;
|
|
46
|
+
task: string;
|
|
47
|
+
}
|
|
48
|
+
export declare function parseTeamworkArgs(raw: string): ParsedTeamworkArgs;
|
|
49
|
+
export declare function heuristicClassifyTeamwork(task: string): ResolvedTeamworkMode;
|
|
50
|
+
export declare function parseTeamworkClassifierDecision(output: string, fallbackTask: string): ResolvedTeamworkMode;
|
|
51
|
+
export type SwarmMode = "auto" | "fanout" | "pipeline";
|
|
52
|
+
export type ResolvedSwarmMode = "fanout" | "pipeline";
|
|
53
|
+
export interface ParsedSwarmArgs {
|
|
54
|
+
mode: SwarmMode;
|
|
55
|
+
workers?: number;
|
|
56
|
+
useWorktree: boolean;
|
|
57
|
+
modelOverride?: ModelRef;
|
|
58
|
+
task: string;
|
|
59
|
+
}
|
|
60
|
+
export declare function parseSwarmArgs(raw: string): ParsedSwarmArgs;
|
|
61
|
+
export declare function heuristicClassifySwarm(task: string): ResolvedSwarmMode;
|
|
62
|
+
export declare function parseSwarmClassifierDecision(output: string, fallbackTask: string): ResolvedSwarmMode;
|
|
63
|
+
export declare function parseSwarmSlices(output: string, count: number, task: string): string[];
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
export function parseModelRef(spec) {
|
|
2
|
+
if (!spec)
|
|
3
|
+
return undefined;
|
|
4
|
+
const trimmed = spec.trim();
|
|
5
|
+
const slash = trimmed.indexOf("/");
|
|
6
|
+
if (slash <= 0 || slash === trimmed.length - 1)
|
|
7
|
+
return undefined;
|
|
8
|
+
return {
|
|
9
|
+
providerID: trimmed.slice(0, slash),
|
|
10
|
+
id: trimmed.slice(slash + 1),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function parseStrictInt(raw) {
|
|
14
|
+
if (!/^\d+$/.test(raw))
|
|
15
|
+
return undefined;
|
|
16
|
+
const n = Number.parseInt(raw, 10);
|
|
17
|
+
return Number.isSafeInteger(n) ? n : undefined;
|
|
18
|
+
}
|
|
19
|
+
function consumeLeadingFlags(raw, onFlag) {
|
|
20
|
+
const len = raw.length;
|
|
21
|
+
const skipWs = (i) => {
|
|
22
|
+
let idx = i;
|
|
23
|
+
while (idx < len && /\s/.test(raw[idx]))
|
|
24
|
+
idx++;
|
|
25
|
+
return idx;
|
|
26
|
+
};
|
|
27
|
+
const readToken = (i) => {
|
|
28
|
+
const start = skipWs(i);
|
|
29
|
+
if (start >= len)
|
|
30
|
+
return undefined;
|
|
31
|
+
let end = start;
|
|
32
|
+
while (end < len && !/\s/.test(raw[end]))
|
|
33
|
+
end++;
|
|
34
|
+
return { token: raw.slice(start, end), start, end };
|
|
35
|
+
};
|
|
36
|
+
let pos = 0;
|
|
37
|
+
while (pos < len) {
|
|
38
|
+
const cur = readToken(pos);
|
|
39
|
+
if (!cur)
|
|
40
|
+
return "";
|
|
41
|
+
if (cur.token === "--") {
|
|
42
|
+
pos = cur.end;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
let nextPos = cur.end;
|
|
46
|
+
const peekNext = () => readToken(nextPos)?.token;
|
|
47
|
+
const consumeNext = () => {
|
|
48
|
+
const next = readToken(nextPos);
|
|
49
|
+
nextPos = next.end;
|
|
50
|
+
return next.token;
|
|
51
|
+
};
|
|
52
|
+
if (onFlag(cur.token, peekNext, consumeNext)) {
|
|
53
|
+
pos = nextPos;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
pos = cur.start;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
return raw.slice(pos).trim();
|
|
60
|
+
}
|
|
61
|
+
export function parseBoostArgs(raw) {
|
|
62
|
+
let mode = "auto";
|
|
63
|
+
let rounds;
|
|
64
|
+
let modelOverride;
|
|
65
|
+
const task = consumeLeadingFlags(raw, (tok, peekNext, consumeNext) => {
|
|
66
|
+
if (tok === "--investigate" || tok === "-i") {
|
|
67
|
+
mode = "investigate";
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (tok === "--coder" || tok === "-c") {
|
|
71
|
+
mode = "coder";
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (tok.startsWith("--rounds=")) {
|
|
75
|
+
const n = parseStrictInt(tok.slice("--rounds=".length));
|
|
76
|
+
if (n !== undefined && n >= 0 && n <= 5)
|
|
77
|
+
rounds = n;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if ((tok === "--rounds" || tok === "-r") && peekNext() !== undefined) {
|
|
81
|
+
const n = parseStrictInt(consumeNext());
|
|
82
|
+
if (n !== undefined && n >= 0 && n <= 5)
|
|
83
|
+
rounds = n;
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (tok.startsWith("--model=")) {
|
|
87
|
+
const parsed = parseModelRef(tok.slice("--model=".length));
|
|
88
|
+
if (parsed)
|
|
89
|
+
modelOverride = parsed;
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if ((tok === "--model" || tok === "-m") && peekNext() !== undefined) {
|
|
93
|
+
const parsed = parseModelRef(consumeNext());
|
|
94
|
+
if (parsed)
|
|
95
|
+
modelOverride = parsed;
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
mode,
|
|
102
|
+
rounds,
|
|
103
|
+
modelOverride,
|
|
104
|
+
task,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export function extractAssistantText(messages) {
|
|
108
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
109
|
+
const msg = messages[i];
|
|
110
|
+
if (msg.type !== "assistant")
|
|
111
|
+
continue;
|
|
112
|
+
const textParts = (msg.content ?? [])
|
|
113
|
+
.filter((p) => p.type === "text" && typeof p.text === "string")
|
|
114
|
+
.map((p) => p.text.trim())
|
|
115
|
+
.filter(Boolean);
|
|
116
|
+
let errorText;
|
|
117
|
+
if (msg.error) {
|
|
118
|
+
if (typeof msg.error === "object" && msg.error !== null && "message" in msg.error) {
|
|
119
|
+
errorText = String(msg.error.message ?? "Unknown assistant error");
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
errorText = String(msg.error);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (textParts.length === 0 && !errorText) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
text: textParts.join("\n\n"),
|
|
130
|
+
...(errorText ? { error: errorText } : {}),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return { text: "" };
|
|
134
|
+
}
|
|
135
|
+
const INVESTIGATE_KEYWORDS = /\b(investigate|trace|explain|why|how does|root cause|find out|without modifying|read-only|analyze|audit|diagnose|cari tahu|jelaskan|kenapa|mengapa|analisis|telusuri)\b/i;
|
|
136
|
+
const CODER_KEYWORDS = /\b(implement|fix|refactor|optimize|add|create|write|build|update|migrate|patch|remove|delete|buat|perbaiki|ubah|tambah|optimasi)\b/i;
|
|
137
|
+
export function heuristicClassifyTask(task) {
|
|
138
|
+
const hasInvestigate = INVESTIGATE_KEYWORDS.test(task);
|
|
139
|
+
const hasCoder = CODER_KEYWORDS.test(task);
|
|
140
|
+
if (hasInvestigate && !hasCoder)
|
|
141
|
+
return "investigate";
|
|
142
|
+
return "coder";
|
|
143
|
+
}
|
|
144
|
+
export function parseClassifierDecision(output, fallbackTask) {
|
|
145
|
+
const normalized = output.trim().toLowerCase();
|
|
146
|
+
if (normalized.includes("investigate") || normalized.includes("deepinvestigator")) {
|
|
147
|
+
return "investigate";
|
|
148
|
+
}
|
|
149
|
+
if (normalized.includes("coder") || normalized.includes("deepcoder")) {
|
|
150
|
+
return "coder";
|
|
151
|
+
}
|
|
152
|
+
return heuristicClassifyTask(fallbackTask);
|
|
153
|
+
}
|
|
154
|
+
export function parseVerificationDecision(output) {
|
|
155
|
+
const trimmed = output.trim();
|
|
156
|
+
const firstLine = trimmed.split(/\r?\n/, 1)[0] ?? "";
|
|
157
|
+
const firstLineClean = firstLine.replace(/[*`_]/g, "").trim();
|
|
158
|
+
const cleaned = trimmed.replace(/[*`_]/g, "");
|
|
159
|
+
if (/\bVERDICT:\s*FAIL\b/i.test(firstLineClean)) {
|
|
160
|
+
return { passed: false, reason: trimmed };
|
|
161
|
+
}
|
|
162
|
+
if (/\bVERDICT:\s*PASS\b/i.test(firstLineClean)) {
|
|
163
|
+
return { passed: true, reason: trimmed };
|
|
164
|
+
}
|
|
165
|
+
if (/\bVERDICT:\s*FAIL\b/i.test(cleaned)) {
|
|
166
|
+
return { passed: false, reason: trimmed };
|
|
167
|
+
}
|
|
168
|
+
if (/\bVERDICT:\s*PASS\b/i.test(cleaned)) {
|
|
169
|
+
return { passed: true, reason: trimmed };
|
|
170
|
+
}
|
|
171
|
+
if (/\bFAIL\b/i.test(firstLineClean) && !/\bPASS\b/i.test(firstLineClean)) {
|
|
172
|
+
return { passed: false, reason: trimmed };
|
|
173
|
+
}
|
|
174
|
+
if (/\bPASS\b/i.test(firstLineClean) && !/\bFAIL\b/i.test(firstLineClean)) {
|
|
175
|
+
return { passed: true, reason: trimmed };
|
|
176
|
+
}
|
|
177
|
+
return { passed: false, reason: trimmed };
|
|
178
|
+
}
|
|
179
|
+
export function parseTeamworkArgs(raw) {
|
|
180
|
+
let mode = "auto";
|
|
181
|
+
let qaRounds;
|
|
182
|
+
let workers;
|
|
183
|
+
let skipInterview = false;
|
|
184
|
+
let modelOverride;
|
|
185
|
+
const rawTask = consumeLeadingFlags(raw, (tok, peekNext, consumeNext) => {
|
|
186
|
+
if (tok.toLowerCase() === "[skip-interview]") {
|
|
187
|
+
skipInterview = true;
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
if (tok === "--swe" || tok === "-s") {
|
|
191
|
+
mode = "swe";
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
if (tok === "--review" || tok === "-r") {
|
|
195
|
+
mode = "review";
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
if (tok === "--colosseum" || tok === "-c") {
|
|
199
|
+
mode = "colosseum";
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (tok === "--discover" || tok === "-d") {
|
|
203
|
+
mode = "discover";
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
if (tok === "--audit" || tok === "-a") {
|
|
207
|
+
mode = "audit";
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
if (tok.startsWith("--mode=")) {
|
|
211
|
+
const m = tok.slice("--mode=".length).toLowerCase();
|
|
212
|
+
if (m === "auto" ||
|
|
213
|
+
m === "swe" ||
|
|
214
|
+
m === "review" ||
|
|
215
|
+
m === "colosseum" ||
|
|
216
|
+
m === "discover" ||
|
|
217
|
+
m === "audit") {
|
|
218
|
+
mode = m;
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
if (tok.startsWith("--qa-rounds=")) {
|
|
223
|
+
const n = parseStrictInt(tok.slice("--qa-rounds=".length));
|
|
224
|
+
if (n !== undefined && n >= 0 && n <= 3)
|
|
225
|
+
qaRounds = n;
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
if (tok === "--qa-rounds" && peekNext() !== undefined) {
|
|
229
|
+
const n = parseStrictInt(consumeNext());
|
|
230
|
+
if (n !== undefined && n >= 0 && n <= 3)
|
|
231
|
+
qaRounds = n;
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
if (tok.startsWith("--workers=")) {
|
|
235
|
+
const n = parseStrictInt(tok.slice("--workers=".length));
|
|
236
|
+
if (n !== undefined && n >= 2 && n <= 5)
|
|
237
|
+
workers = n;
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
if ((tok === "--workers" || tok === "-w") && peekNext() !== undefined) {
|
|
241
|
+
const n = parseStrictInt(consumeNext());
|
|
242
|
+
if (n !== undefined && n >= 2 && n <= 5)
|
|
243
|
+
workers = n;
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
if (tok.startsWith("--model=")) {
|
|
247
|
+
const parsed = parseModelRef(tok.slice("--model=".length));
|
|
248
|
+
if (parsed)
|
|
249
|
+
modelOverride = parsed;
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
if (tok === "--no-interview" || tok === "--skip-interview") {
|
|
253
|
+
skipInterview = true;
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
if ((tok === "--model" || tok === "-m") && peekNext() !== undefined) {
|
|
257
|
+
const parsed = parseModelRef(consumeNext());
|
|
258
|
+
if (parsed)
|
|
259
|
+
modelOverride = parsed;
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
});
|
|
264
|
+
let task = rawTask;
|
|
265
|
+
const skipPrefixMatch = task.match(/^\[skip-interview\]\s*/i);
|
|
266
|
+
if (skipPrefixMatch) {
|
|
267
|
+
skipInterview = true;
|
|
268
|
+
task = task.slice(skipPrefixMatch[0].length);
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
mode,
|
|
272
|
+
qaRounds,
|
|
273
|
+
workers,
|
|
274
|
+
skipInterview,
|
|
275
|
+
modelOverride,
|
|
276
|
+
task,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const COLOSSEUM_KEYWORDS = /\b(compare|versus|vs\.?|trade-?off|competing|alternatives|architecture options|benchmark approaches|colosseum|bandingkan)\b/i;
|
|
280
|
+
const AUDIT_KEYWORDS = /\b(audit|forensic|compliance|security audit|vulnerability|hardening|post-?mortem|verify claims|deep audit)\b/i;
|
|
281
|
+
const DISCOVER_KEYWORDS = /\b(discover|explore|investigate|trace|understand|root cause|how does|map out|deep dive|research)\b/i;
|
|
282
|
+
const REVIEW_KEYWORDS = /\b(review|critique|evaluate|assess|inspect|document review|pr review|code review|tinjau|evaluasi)\b/i;
|
|
283
|
+
export function heuristicClassifyTeamwork(task) {
|
|
284
|
+
if (COLOSSEUM_KEYWORDS.test(task))
|
|
285
|
+
return "colosseum";
|
|
286
|
+
if (AUDIT_KEYWORDS.test(task) && !CODER_KEYWORDS.test(task))
|
|
287
|
+
return "audit";
|
|
288
|
+
if (DISCOVER_KEYWORDS.test(task) && !CODER_KEYWORDS.test(task))
|
|
289
|
+
return "discover";
|
|
290
|
+
if (REVIEW_KEYWORDS.test(task) && !CODER_KEYWORDS.test(task))
|
|
291
|
+
return "review";
|
|
292
|
+
return "swe";
|
|
293
|
+
}
|
|
294
|
+
export function parseTeamworkClassifierDecision(output, fallbackTask) {
|
|
295
|
+
const normalized = output.trim().toLowerCase();
|
|
296
|
+
if (normalized.includes("colosseum"))
|
|
297
|
+
return "colosseum";
|
|
298
|
+
if (normalized.includes("discover"))
|
|
299
|
+
return "discover";
|
|
300
|
+
if (normalized.includes("audit"))
|
|
301
|
+
return "audit";
|
|
302
|
+
if (normalized.includes("review"))
|
|
303
|
+
return "review";
|
|
304
|
+
if (normalized.includes("swe"))
|
|
305
|
+
return "swe";
|
|
306
|
+
return heuristicClassifyTeamwork(fallbackTask);
|
|
307
|
+
}
|
|
308
|
+
export function parseSwarmArgs(raw) {
|
|
309
|
+
let mode = "auto";
|
|
310
|
+
let workers;
|
|
311
|
+
let useWorktree = false;
|
|
312
|
+
let modelOverride;
|
|
313
|
+
const task = consumeLeadingFlags(raw, (tok, peekNext, consumeNext) => {
|
|
314
|
+
if (tok === "--fanout" || tok === "-f") {
|
|
315
|
+
mode = "fanout";
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
if (tok === "--pipeline" || tok === "-p") {
|
|
319
|
+
mode = "pipeline";
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
if (tok.startsWith("--mode=")) {
|
|
323
|
+
const m = tok.slice("--mode=".length).toLowerCase();
|
|
324
|
+
if (m === "auto" || m === "fanout" || m === "pipeline") {
|
|
325
|
+
mode = m;
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
if (tok.startsWith("--workers=")) {
|
|
330
|
+
const n = parseStrictInt(tok.slice("--workers=".length));
|
|
331
|
+
if (n !== undefined && n >= 2 && n <= 6)
|
|
332
|
+
workers = n;
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
if ((tok === "--workers" || tok === "-w") && peekNext() !== undefined) {
|
|
336
|
+
const n = parseStrictInt(consumeNext());
|
|
337
|
+
if (n !== undefined && n >= 2 && n <= 6)
|
|
338
|
+
workers = n;
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
if (tok === "--worktree" || tok === "--share") {
|
|
342
|
+
useWorktree = true;
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
if (tok.startsWith("--model=")) {
|
|
346
|
+
const parsed = parseModelRef(tok.slice("--model=".length));
|
|
347
|
+
if (parsed)
|
|
348
|
+
modelOverride = parsed;
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
if ((tok === "--model" || tok === "-m") && peekNext() !== undefined) {
|
|
352
|
+
const parsed = parseModelRef(consumeNext());
|
|
353
|
+
if (parsed)
|
|
354
|
+
modelOverride = parsed;
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
});
|
|
359
|
+
return {
|
|
360
|
+
mode,
|
|
361
|
+
workers,
|
|
362
|
+
useWorktree,
|
|
363
|
+
modelOverride,
|
|
364
|
+
task,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
const PIPELINE_KEYWORDS = /\b(multi-stage|pipeline|end-to-end|design and verify|generate and critique|full audit|comprehensive|migrate|redesign|build and test)\b/i;
|
|
368
|
+
export function heuristicClassifySwarm(task) {
|
|
369
|
+
if (PIPELINE_KEYWORDS.test(task))
|
|
370
|
+
return "pipeline";
|
|
371
|
+
return "fanout";
|
|
372
|
+
}
|
|
373
|
+
export function parseSwarmClassifierDecision(output, fallbackTask) {
|
|
374
|
+
const normalized = output.trim().toLowerCase();
|
|
375
|
+
if (normalized.includes("pipeline"))
|
|
376
|
+
return "pipeline";
|
|
377
|
+
if (normalized.includes("fanout") || normalized.includes("simple"))
|
|
378
|
+
return "fanout";
|
|
379
|
+
return heuristicClassifySwarm(fallbackTask);
|
|
380
|
+
}
|
|
381
|
+
export function parseSwarmSlices(output, count, task) {
|
|
382
|
+
const rawLines = output.split(/\r?\n/);
|
|
383
|
+
const listMarker = /^\s*(?:[-*+]|\d+[.)])\s+/;
|
|
384
|
+
const listLines = rawLines
|
|
385
|
+
.filter((line) => listMarker.test(line))
|
|
386
|
+
.map((line) => line.replace(listMarker, "").trim())
|
|
387
|
+
.filter((line) => line.length >= 6);
|
|
388
|
+
const lines = listLines.length > 0
|
|
389
|
+
? listLines
|
|
390
|
+
: rawLines
|
|
391
|
+
.map((line) => line.trim())
|
|
392
|
+
.filter((line) => line.length >= 6);
|
|
393
|
+
if (lines.length >= count) {
|
|
394
|
+
return lines.slice(0, count);
|
|
395
|
+
}
|
|
396
|
+
const defaults = [
|
|
397
|
+
`Core architecture, primary code paths, and direct requirements for: ${task}`,
|
|
398
|
+
`Edge cases, error handling, failure modes, and hidden assumptions for: ${task}`,
|
|
399
|
+
`Testing, verification strategy, performance, and integration impact for: ${task}`,
|
|
400
|
+
`Security, concurrency, and backward-compatibility implications for: ${task}`,
|
|
401
|
+
`Alternative designs, maintainability, and simplification opportunities for: ${task}`,
|
|
402
|
+
`Documentation, developer experience, and operational readiness for: ${task}`,
|
|
403
|
+
];
|
|
404
|
+
const merged = [...lines];
|
|
405
|
+
for (const fallback of defaults) {
|
|
406
|
+
if (merged.length >= count)
|
|
407
|
+
break;
|
|
408
|
+
merged.push(fallback);
|
|
409
|
+
}
|
|
410
|
+
return merged.slice(0, count);
|
|
411
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type BoostMode, type ModelRef, type ResolvedBoostMode, type SessionMessageLike } from "./parser.js";
|
|
2
|
+
export interface WorkerRuntimeMeta {
|
|
3
|
+
readOnly?: boolean;
|
|
4
|
+
swarmWorker?: {
|
|
5
|
+
boardId: string;
|
|
6
|
+
workerId: string;
|
|
7
|
+
initialSeenSeq?: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface BoostSessionClient {
|
|
11
|
+
get?(input: {
|
|
12
|
+
sessionID: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
model?: ModelRef;
|
|
15
|
+
projectID?: string;
|
|
16
|
+
}>;
|
|
17
|
+
create(input: {
|
|
18
|
+
parentID?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
model?: ModelRef;
|
|
21
|
+
location?: {
|
|
22
|
+
directory: string;
|
|
23
|
+
};
|
|
24
|
+
}): Promise<{
|
|
25
|
+
id: string;
|
|
26
|
+
}>;
|
|
27
|
+
prompt(input: {
|
|
28
|
+
sessionID: string;
|
|
29
|
+
text: string;
|
|
30
|
+
}): Promise<unknown>;
|
|
31
|
+
wait(input: {
|
|
32
|
+
sessionID: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
interrupt?(input: {
|
|
35
|
+
sessionID: string;
|
|
36
|
+
}): Promise<unknown>;
|
|
37
|
+
context(input: {
|
|
38
|
+
sessionID: string;
|
|
39
|
+
}): Promise<readonly SessionMessageLike[]>;
|
|
40
|
+
generate(input: {
|
|
41
|
+
sessionID: string;
|
|
42
|
+
prompt: string;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
text: string;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
export interface BoostPipelineOptions {
|
|
48
|
+
sessionID: string;
|
|
49
|
+
task: string;
|
|
50
|
+
additionalContext?: string;
|
|
51
|
+
continueSessionID?: string;
|
|
52
|
+
mode?: BoostMode;
|
|
53
|
+
improvementRounds?: number;
|
|
54
|
+
maxExtraVerificationRounds?: number;
|
|
55
|
+
modelOverride?: ModelRef;
|
|
56
|
+
onProgress?: (status: string) => void | Promise<void>;
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}
|
|
59
|
+
export interface BoostPipelineResult {
|
|
60
|
+
mode: ResolvedBoostMode;
|
|
61
|
+
roundsExecuted: number;
|
|
62
|
+
childSessionIDs: string[];
|
|
63
|
+
report: string;
|
|
64
|
+
verificationVerdict: "PASS" | "FAIL" | "SKIPPED";
|
|
65
|
+
verificationNote: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function throwIfAborted(signal?: AbortSignal, label?: string): void;
|
|
68
|
+
export declare function runIsolatedWorker(sessionClient: BoostSessionClient, parentID: string, title: string, promptText: string, modelOverride?: ModelRef, signal?: AbortSignal, location?: {
|
|
69
|
+
directory: string;
|
|
70
|
+
}, continueSessionID?: string, runtimeMeta?: WorkerRuntimeMeta): Promise<{
|
|
71
|
+
sessionID: string;
|
|
72
|
+
text: string;
|
|
73
|
+
}>;
|
|
74
|
+
export declare function runBoostPipeline(sessionClient: BoostSessionClient, options: BoostPipelineOptions): Promise<BoostPipelineResult>;
|