opencode-swarm-plugin 0.18.0 → 0.20.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/.beads/issues.jsonl +74 -61
- package/.github/workflows/ci.yml +5 -1
- package/README.md +48 -4
- package/dist/index.js +6643 -6326
- package/dist/plugin.js +2726 -2404
- package/package.json +1 -1
- package/src/agent-mail.ts +20 -7
- package/src/anti-patterns.test.ts +1167 -0
- package/src/anti-patterns.ts +29 -11
- package/src/index.ts +8 -0
- package/src/pattern-maturity.test.ts +1160 -0
- package/src/pattern-maturity.ts +51 -13
- package/src/plugin.ts +15 -3
- package/src/schemas/bead.ts +35 -4
- package/src/schemas/evaluation.ts +18 -6
- package/src/schemas/index.ts +25 -2
- package/src/schemas/task.ts +49 -21
- package/src/streams/debug.ts +101 -3
- package/src/streams/events.ts +22 -0
- package/src/streams/index.ts +58 -1
- package/src/streams/migrations.ts +46 -4
- package/src/streams/store.integration.test.ts +110 -0
- package/src/streams/store.ts +311 -126
- package/src/structured.test.ts +1046 -0
- package/src/structured.ts +74 -27
- package/src/swarm-decompose.ts +912 -0
- package/src/swarm-mail.ts +7 -7
- package/src/swarm-orchestrate.ts +1869 -0
- package/src/swarm-prompts.ts +756 -0
- package/src/swarm-strategies.ts +407 -0
- package/src/swarm.ts +23 -3876
- package/src/tool-availability.ts +29 -6
- package/test-bug-fixes.ts +86 -0
package/src/anti-patterns.ts
CHANGED
|
@@ -19,10 +19,15 @@ export const PatternKindSchema = z.enum(["pattern", "anti_pattern"]);
|
|
|
19
19
|
export type PatternKind = z.infer<typeof PatternKindSchema>;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Decomposition pattern with success/failure tracking.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* Field relationships:
|
|
25
|
+
* - `kind`: Tracks pattern lifecycle ("pattern" → "anti_pattern" when failure rate exceeds threshold)
|
|
26
|
+
* - `is_negative`: Derived boolean flag for quick filtering (true when kind === "anti_pattern")
|
|
27
|
+
*
|
|
28
|
+
* Both fields exist because:
|
|
29
|
+
* - `kind` is the source of truth for pattern status
|
|
30
|
+
* - `is_negative` enables efficient filtering without string comparison
|
|
26
31
|
*/
|
|
27
32
|
export const DecompositionPatternSchema = z.object({
|
|
28
33
|
/** Unique ID for this pattern */
|
|
@@ -69,6 +74,9 @@ export type PatternInversionResult = z.infer<
|
|
|
69
74
|
// Configuration
|
|
70
75
|
// ============================================================================
|
|
71
76
|
|
|
77
|
+
/** Maximum number of example beads to keep per pattern */
|
|
78
|
+
const MAX_EXAMPLE_BEADS = 10;
|
|
79
|
+
|
|
72
80
|
/**
|
|
73
81
|
* Configuration for anti-pattern detection
|
|
74
82
|
*/
|
|
@@ -186,7 +194,7 @@ export function recordPatternObservation(
|
|
|
186
194
|
failure_count: success ? pattern.failure_count : pattern.failure_count + 1,
|
|
187
195
|
updated_at: new Date().toISOString(),
|
|
188
196
|
example_beads: beadId
|
|
189
|
-
? [...pattern.example_beads.slice(-
|
|
197
|
+
? [...pattern.example_beads.slice(-(MAX_EXAMPLE_BEADS - 1)), beadId]
|
|
190
198
|
: pattern.example_beads,
|
|
191
199
|
};
|
|
192
200
|
|
|
@@ -216,8 +224,16 @@ export function recordPatternObservation(
|
|
|
216
224
|
export function extractPatternsFromDescription(description: string): string[] {
|
|
217
225
|
const patterns: string[] = [];
|
|
218
226
|
|
|
219
|
-
|
|
220
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Regex patterns for detecting common decomposition strategies.
|
|
229
|
+
*
|
|
230
|
+
* Detection is keyword-based and not exhaustive - patterns can be
|
|
231
|
+
* manually created for novel strategies not covered here.
|
|
232
|
+
*
|
|
233
|
+
* Each pattern maps a regex to a strategy name that will be extracted
|
|
234
|
+
* from task descriptions during pattern observation.
|
|
235
|
+
*/
|
|
236
|
+
const strategyPatterns: Array<{ regex: RegExp; pattern: string }> = [
|
|
221
237
|
{
|
|
222
238
|
regex: /split(?:ting)?\s+by\s+file\s+type/i,
|
|
223
239
|
pattern: "Split by file type",
|
|
@@ -322,15 +338,17 @@ export function formatAntiPatternsForPrompt(
|
|
|
322
338
|
}
|
|
323
339
|
|
|
324
340
|
/**
|
|
325
|
-
* Format successful patterns for inclusion in
|
|
341
|
+
* Format successful patterns for inclusion in prompts.
|
|
326
342
|
*
|
|
327
|
-
* @param patterns -
|
|
328
|
-
* @param minSuccessRate - Minimum success rate to include (0
|
|
329
|
-
*
|
|
343
|
+
* @param patterns - Array of decomposition patterns to filter and format
|
|
344
|
+
* @param minSuccessRate - Minimum success rate to include (default 0.7 = 70%).
|
|
345
|
+
* Chosen to filter out patterns with marginal track records - only patterns
|
|
346
|
+
* that succeed at least 70% of the time are recommended.
|
|
347
|
+
* @returns Formatted string of successful patterns for prompt injection
|
|
330
348
|
*/
|
|
331
349
|
export function formatSuccessfulPatternsForPrompt(
|
|
332
350
|
patterns: DecompositionPattern[],
|
|
333
|
-
minSuccessRate
|
|
351
|
+
minSuccessRate = 0.7,
|
|
334
352
|
): string {
|
|
335
353
|
const successful = patterns.filter((p) => {
|
|
336
354
|
if (p.kind === "anti_pattern") return false;
|
package/src/index.ts
CHANGED
|
@@ -301,6 +301,14 @@ export {
|
|
|
301
301
|
type SwarmMailState,
|
|
302
302
|
} from "./swarm-mail";
|
|
303
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Re-export shared types from streams/events
|
|
306
|
+
*
|
|
307
|
+
* Includes:
|
|
308
|
+
* - MailSessionState - Shared session state type for Agent Mail and Swarm Mail
|
|
309
|
+
*/
|
|
310
|
+
export { type MailSessionState } from "./streams/events";
|
|
311
|
+
|
|
304
312
|
/**
|
|
305
313
|
* Re-export structured module
|
|
306
314
|
*
|