opencode-swarm-plugin 0.36.0 → 0.37.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/.hive/issues.jsonl +16 -4
- package/.hive/memories.jsonl +274 -1
- package/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-test.log +318 -318
- package/CHANGELOG.md +113 -0
- package/bin/swarm.test.ts +106 -0
- package/bin/swarm.ts +413 -179
- package/dist/compaction-hook.d.ts +54 -4
- package/dist/compaction-hook.d.ts.map +1 -1
- package/dist/eval-capture.d.ts +122 -17
- package/dist/eval-capture.d.ts.map +1 -1
- package/dist/index.d.ts +1 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1278 -619
- package/dist/planning-guardrails.d.ts +121 -0
- package/dist/planning-guardrails.d.ts.map +1 -1
- package/dist/plugin.d.ts +9 -9
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1283 -329
- package/dist/schemas/task.d.ts +0 -1
- package/dist/schemas/task.d.ts.map +1 -1
- package/dist/swarm-decompose.d.ts +0 -8
- package/dist/swarm-decompose.d.ts.map +1 -1
- package/dist/swarm-orchestrate.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts +0 -4
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-review.d.ts.map +1 -1
- package/dist/swarm.d.ts +0 -6
- package/dist/swarm.d.ts.map +1 -1
- package/evals/README.md +38 -0
- package/evals/coordinator-session.eval.ts +154 -0
- package/evals/fixtures/coordinator-sessions.ts +328 -0
- package/evals/lib/data-loader.ts +69 -0
- package/evals/scorers/coordinator-discipline.evalite-test.ts +536 -0
- package/evals/scorers/coordinator-discipline.ts +315 -0
- package/evals/scorers/index.ts +12 -0
- package/examples/plugin-wrapper-template.ts +303 -4
- package/package.json +2 -2
- package/src/compaction-hook.test.ts +8 -1
- package/src/compaction-hook.ts +31 -21
- package/src/eval-capture.test.ts +390 -0
- package/src/eval-capture.ts +163 -4
- package/src/hive.integration.test.ts +148 -0
- package/src/hive.ts +89 -0
- package/src/index.ts +68 -1
- package/src/planning-guardrails.test.ts +387 -2
- package/src/planning-guardrails.ts +289 -0
- package/src/plugin.ts +10 -10
- package/src/swarm-decompose.test.ts +195 -0
- package/src/swarm-decompose.ts +72 -1
- package/src/swarm-orchestrate.ts +44 -0
- package/src/swarm-prompts.ts +20 -0
- package/src/swarm-review.integration.test.ts +24 -29
- package/src/swarm-review.ts +41 -0
|
@@ -40,4 +40,125 @@ export declare function analyzeTodoWrite(args: {
|
|
|
40
40
|
* @returns Whether this tool should be analyzed
|
|
41
41
|
*/
|
|
42
42
|
export declare function shouldAnalyzeTool(toolName: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Violation patterns for coordinator behavior detection
|
|
45
|
+
*
|
|
46
|
+
* These patterns identify when a coordinator is performing work
|
|
47
|
+
* that should be delegated to worker agents.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* // Bad: Coordinator editing files
|
|
52
|
+
* if (VIOLATION_PATTERNS.FILE_MODIFICATION_TOOLS.includes("edit")) { ... }
|
|
53
|
+
*
|
|
54
|
+
* // Good: Worker editing files
|
|
55
|
+
* // (no violation when agentContext === "worker")
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare const VIOLATION_PATTERNS: {
|
|
59
|
+
/**
|
|
60
|
+
* Tool names that modify files
|
|
61
|
+
*
|
|
62
|
+
* Coordinators should NEVER call these tools directly.
|
|
63
|
+
* Workers reserve files and make modifications.
|
|
64
|
+
*/
|
|
65
|
+
readonly FILE_MODIFICATION_TOOLS: readonly ["edit", "write"];
|
|
66
|
+
/**
|
|
67
|
+
* Tool names for file reservations
|
|
68
|
+
*
|
|
69
|
+
* Coordinators don't reserve files - workers do this
|
|
70
|
+
* before editing to prevent conflicts.
|
|
71
|
+
*/
|
|
72
|
+
readonly RESERVATION_TOOLS: readonly ["swarmmail_reserve", "agentmail_reserve"];
|
|
73
|
+
/**
|
|
74
|
+
* Regex patterns that indicate test execution in bash commands
|
|
75
|
+
*
|
|
76
|
+
* Coordinators review test results, workers run tests.
|
|
77
|
+
* Matches common test runners and test file patterns.
|
|
78
|
+
*/
|
|
79
|
+
readonly TEST_EXECUTION_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Result of violation detection
|
|
83
|
+
*/
|
|
84
|
+
export interface ViolationDetectionResult {
|
|
85
|
+
/** Whether a violation was detected */
|
|
86
|
+
isViolation: boolean;
|
|
87
|
+
/** Type of violation if detected */
|
|
88
|
+
violationType?: "coordinator_edited_file" | "coordinator_ran_tests" | "coordinator_reserved_files" | "no_worker_spawned";
|
|
89
|
+
/** Human-readable message */
|
|
90
|
+
message?: string;
|
|
91
|
+
/** Payload data for the violation */
|
|
92
|
+
payload?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Detect coordinator violations in real-time
|
|
96
|
+
*
|
|
97
|
+
* Checks for patterns that indicate a coordinator is doing work
|
|
98
|
+
* that should be delegated to workers:
|
|
99
|
+
* 1. Edit/Write tool calls (coordinators plan, workers implement)
|
|
100
|
+
* 2. Test execution (workers verify, coordinators review)
|
|
101
|
+
* 3. File reservations (workers reserve before editing)
|
|
102
|
+
* 4. No worker spawned after decomposition (coordinators must delegate)
|
|
103
|
+
*
|
|
104
|
+
* When a violation is detected, captures it via captureCoordinatorEvent().
|
|
105
|
+
*
|
|
106
|
+
* @param params - Detection parameters
|
|
107
|
+
* @returns Violation detection result
|
|
108
|
+
*/
|
|
109
|
+
export declare function detectCoordinatorViolation(params: {
|
|
110
|
+
sessionId: string;
|
|
111
|
+
epicId: string;
|
|
112
|
+
toolName: string;
|
|
113
|
+
toolArgs: Record<string, unknown>;
|
|
114
|
+
agentContext: "coordinator" | "worker";
|
|
115
|
+
checkNoSpawn?: boolean;
|
|
116
|
+
}): ViolationDetectionResult;
|
|
117
|
+
/**
|
|
118
|
+
* Coordinator context state
|
|
119
|
+
*
|
|
120
|
+
* Tracks whether the current session is acting as a swarm coordinator.
|
|
121
|
+
* Set when an epic is created or when swarm tools are used.
|
|
122
|
+
*/
|
|
123
|
+
interface CoordinatorContext {
|
|
124
|
+
/** Whether we're in coordinator mode */
|
|
125
|
+
isCoordinator: boolean;
|
|
126
|
+
/** Active epic ID if any */
|
|
127
|
+
epicId?: string;
|
|
128
|
+
/** Session ID for event capture */
|
|
129
|
+
sessionId?: string;
|
|
130
|
+
/** When coordinator mode was activated */
|
|
131
|
+
activatedAt?: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Set coordinator context
|
|
135
|
+
*
|
|
136
|
+
* Called when swarm coordination begins (e.g., after hive_create_epic or swarm_decompose).
|
|
137
|
+
*
|
|
138
|
+
* @param ctx - Coordinator context to set
|
|
139
|
+
*/
|
|
140
|
+
export declare function setCoordinatorContext(ctx: Partial<CoordinatorContext>): void;
|
|
141
|
+
/**
|
|
142
|
+
* Get current coordinator context
|
|
143
|
+
*
|
|
144
|
+
* @returns Current coordinator context state
|
|
145
|
+
*/
|
|
146
|
+
export declare function getCoordinatorContext(): CoordinatorContext;
|
|
147
|
+
/**
|
|
148
|
+
* Clear coordinator context
|
|
149
|
+
*
|
|
150
|
+
* Called when swarm coordination ends (e.g., epic closed or session ends).
|
|
151
|
+
*/
|
|
152
|
+
export declare function clearCoordinatorContext(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Check if we're in coordinator context
|
|
155
|
+
*
|
|
156
|
+
* Returns true if:
|
|
157
|
+
* 1. Coordinator context was explicitly set
|
|
158
|
+
* 2. Context was set within the last 4 hours (session timeout)
|
|
159
|
+
*
|
|
160
|
+
* @returns Whether we're currently in coordinator mode
|
|
161
|
+
*/
|
|
162
|
+
export declare function isInCoordinatorContext(): boolean;
|
|
163
|
+
export {};
|
|
43
164
|
//# sourceMappingURL=planning-guardrails.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planning-guardrails.d.ts","sourceRoot":"","sources":["../src/planning-guardrails.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"planning-guardrails.d.ts","sourceRoot":"","sources":["../src/planning-guardrails.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA2CH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,qBAAqB,EAAE,OAAO,CAAC;IAE/B,wDAAwD;IACxD,qBAAqB,EAAE,MAAM,CAAC;IAE9B,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IAEnB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,iBAAiB,CA8D/E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;CAcK,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,WAAW,EAAE,OAAO,CAAC;IAErB,oCAAoC;IACpC,aAAa,CAAC,EACV,yBAAyB,GACzB,uBAAuB,GACvB,4BAA4B,GAC5B,mBAAmB,CAAC;IAExB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,YAAY,EAAE,aAAa,GAAG,QAAQ,CAAC;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,wBAAwB,CAwG3B;AAED;;;;;GAKG;AACH,UAAU,kBAAkB;IAC1B,wCAAwC;IACxC,aAAa,EAAE,OAAO,CAAC;IACvB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAOD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAM5E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAI9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAiBhD"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OpenCode Plugin Entry Point
|
|
3
3
|
*
|
|
4
|
-
* CRITICAL: Only export the plugin function from this file.
|
|
4
|
+
* CRITICAL: Only export the plugin function as DEFAULT from this file.
|
|
5
5
|
*
|
|
6
6
|
* OpenCode's plugin loader calls ALL exports as functions during initialization.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* If you export both named AND default pointing to the same function, the plugin
|
|
8
|
+
* gets registered TWICE, causing hooks to fire multiple times.
|
|
9
9
|
*
|
|
10
10
|
* If you need to export utilities for external use, add them to src/index.ts instead.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* // ✅ CORRECT - only export
|
|
13
|
+
* // ✅ CORRECT - only default export
|
|
14
14
|
* export default SwarmPlugin;
|
|
15
15
|
*
|
|
16
|
-
* // ❌ WRONG -
|
|
17
|
-
* export
|
|
18
|
-
* export
|
|
16
|
+
* // ❌ WRONG - causes double registration
|
|
17
|
+
* export { SwarmPlugin };
|
|
18
|
+
* export default SwarmPlugin;
|
|
19
19
|
*/
|
|
20
|
-
import
|
|
21
|
-
export
|
|
20
|
+
import SwarmPlugin from "./index";
|
|
21
|
+
export default SwarmPlugin;
|
|
22
22
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,WAAW,MAAM,SAAS,CAAC;AAGlC,eAAe,WAAW,CAAC"}
|