@elyracode/swarm 0.5.9

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/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## [0.5.9] - 2026-05-15
4
+
5
+ ## [0.5.8] - 2026-05-15
6
+
7
+ ### Added
8
+ - Initial release
9
+ - Three automated pipelines: build (plan -> code -> test -> review -> fix), review (analyze -> correctness -> security -> tests -> synthesize), refactor (analyze -> plan -> implement -> verify)
10
+ - `/swarm` command for running pipelines from the editor
11
+ - `swarm` tool for LLM-driven pipeline selection
12
+ - Skill file for automatic delegation when user describes multi-step tasks
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @elyracode/swarm
2
+
3
+ Multi-agent swarm orchestration for Elyra. Automated pipelines where planner, coder, tester, and reviewer agents collaborate on a task with visual progress tracking.
4
+
5
+ ## Install
6
+
7
+ ```
8
+ elyra install npm:@elyracode/swarm
9
+ ```
10
+
11
+ ## Pipelines
12
+
13
+ ### Build (`/swarm build <task>`)
14
+
15
+ Full feature development pipeline:
16
+
17
+ ```
18
+ plan -> code -> test -> review -> fix
19
+ ```
20
+
21
+ 1. **Plan**: Analyzes codebase, creates implementation plan with file paths
22
+ 2. **Code**: Implements the plan, edits files
23
+ 3. **Test**: Writes and runs tests for the implementation
24
+ 4. **Review**: Reviews all changes for correctness, security, edge cases
25
+ 5. **Fix**: Addresses review findings
26
+
27
+ ### Review (`/swarm review <target>`)
28
+
29
+ Deep multi-pass code review:
30
+
31
+ ```
32
+ analyze -> correctness -> security -> tests -> synthesize
33
+ ```
34
+
35
+ 1. **Analyze**: Maps the code structure and data flow
36
+ 2. **Correctness**: Reviews logic, error handling, edge cases
37
+ 3. **Security**: Checks for vulnerabilities, input validation, auth issues
38
+ 4. **Tests**: Evaluates test coverage and quality
39
+ 5. **Synthesize**: Prioritizes all findings into actionable list
40
+
41
+ ### Refactor (`/swarm refactor <target>`)
42
+
43
+ Structured refactoring:
44
+
45
+ ```
46
+ analyze -> plan -> implement -> verify
47
+ ```
48
+
49
+ 1. **Analyze**: Understands current structure, identifies issues
50
+ 2. **Plan**: Creates refactoring plan preserving behavior
51
+ 3. **Implement**: Executes the refactoring
52
+ 4. **Verify**: Confirms behavior is preserved, no regressions
53
+
54
+ ## Usage
55
+
56
+ ### Commands
57
+
58
+ ```
59
+ /swarm build add a notification system with email and in-app channels
60
+ /swarm review the authentication module
61
+ /swarm refactor the database query layer
62
+ /swarm # lists available pipelines
63
+ ```
64
+
65
+ ### Natural Language
66
+
67
+ Just describe what you want and mention "swarm":
68
+
69
+ ```
70
+ Use swarm to build a REST API for user profiles
71
+ Run a swarm review on the checkout flow
72
+ ```
73
+
74
+ ## How It Works
75
+
76
+ Each pipeline stage runs as a focused agent turn with specific instructions. Results from each stage are passed to the next as context. The agent sees a progress indicator showing which stage is active.
77
+
78
+ Stages marked as read-only (analyze, review, synthesize) cannot edit files. Only implementation stages (code, fix, implement) can write.
@@ -0,0 +1,374 @@
1
+ import type { ExtensionAPI } from "@elyracode/coding-agent";
2
+ import { Type } from "typebox";
3
+
4
+ // ── Pipeline Definitions ────────────────────────────────────────────────────
5
+
6
+ interface Stage {
7
+ name: string;
8
+ label: string;
9
+ readOnly: boolean;
10
+ instructions: string;
11
+ }
12
+
13
+ interface Pipeline {
14
+ name: string;
15
+ description: string;
16
+ stages: Stage[];
17
+ }
18
+
19
+ const PIPELINES: Record<string, Pipeline> = {
20
+ build: {
21
+ name: "Build",
22
+ description: "Full feature development: plan, code, test, review, fix",
23
+ stages: [
24
+ {
25
+ name: "plan",
26
+ label: "Planning",
27
+ readOnly: true,
28
+ instructions:
29
+ "You are the PLANNER. Analyze the codebase to understand the existing architecture, " +
30
+ "then create a concrete implementation plan.\n\n" +
31
+ "Deliverables:\n" +
32
+ "- Step-by-step plan with file paths\n" +
33
+ "- Files to create, modify, or delete\n" +
34
+ "- Dependencies and order of operations\n" +
35
+ "- Database/migration changes if needed\n" +
36
+ "- Test strategy\n\n" +
37
+ "Rules: Read files to understand the codebase. Do NOT edit files. Be specific with paths and function names.",
38
+ },
39
+ {
40
+ name: "code",
41
+ label: "Coding",
42
+ readOnly: false,
43
+ instructions:
44
+ "You are the CODER. Implement the plan from the previous stage.\n\n" +
45
+ "Rules:\n" +
46
+ "- Follow the plan precisely\n" +
47
+ "- Edit files, create new files as specified\n" +
48
+ "- Keep changes minimal and focused\n" +
49
+ "- If something is unclear, make a reasonable choice and note it\n" +
50
+ "- Do not write tests yet (next stage handles that)",
51
+ },
52
+ {
53
+ name: "test",
54
+ label: "Testing",
55
+ readOnly: false,
56
+ instructions:
57
+ "You are the TESTER. Write tests for the implementation from the previous stages.\n\n" +
58
+ "Rules:\n" +
59
+ "- Read the implemented code to understand what was built\n" +
60
+ "- Write tests covering happy path, edge cases, and error cases\n" +
61
+ "- Follow the project's existing test patterns and framework\n" +
62
+ "- Run the tests if possible to verify they pass\n" +
63
+ "- Do not modify implementation code unless a test reveals a clear bug",
64
+ },
65
+ {
66
+ name: "review",
67
+ label: "Reviewing",
68
+ readOnly: true,
69
+ instructions:
70
+ "You are the REVIEWER. Review all changes made by the coder and tester.\n\n" +
71
+ "Check for:\n" +
72
+ "- Correctness: does it do what was planned?\n" +
73
+ "- Security: SQL injection, XSS, auth bypasses, data leaks\n" +
74
+ "- Edge cases: null handling, empty inputs, concurrent access\n" +
75
+ "- Test quality: coverage, meaningful assertions\n" +
76
+ "- Simplicity: unnecessary complexity?\n\n" +
77
+ "Rules: Do NOT edit files. Categorize issues as critical/warning/suggestion. Be specific with file paths and line numbers.",
78
+ },
79
+ {
80
+ name: "fix",
81
+ label: "Fixing",
82
+ readOnly: false,
83
+ instructions:
84
+ "You are the FIXER. Address the issues found by the reviewer.\n\n" +
85
+ "Rules:\n" +
86
+ "- Fix critical issues first\n" +
87
+ "- Apply warning fixes if they are clearly beneficial\n" +
88
+ "- Skip pure style suggestions unless trivial\n" +
89
+ "- Run tests after fixes to ensure nothing broke\n" +
90
+ "- Summarize what was fixed and what was left as-is",
91
+ },
92
+ ],
93
+ },
94
+ review: {
95
+ name: "Review",
96
+ description: "Deep multi-pass code review: analyze, correctness, security, tests, synthesize",
97
+ stages: [
98
+ {
99
+ name: "analyze",
100
+ label: "Analyzing",
101
+ readOnly: true,
102
+ instructions:
103
+ "You are the ANALYZER. Map the code structure for the target area.\n\n" +
104
+ "Deliverables:\n" +
105
+ "- Key files and their responsibilities\n" +
106
+ "- Data flow and control flow\n" +
107
+ "- Entry points and external dependencies\n" +
108
+ "- Architecture patterns used\n\n" +
109
+ "Rules: Read only. Be concise. Focus on what matters for a review.",
110
+ },
111
+ {
112
+ name: "correctness",
113
+ label: "Correctness Review",
114
+ readOnly: true,
115
+ instructions:
116
+ "You are the CORRECTNESS REVIEWER. Focus exclusively on logical correctness.\n\n" +
117
+ "Check:\n" +
118
+ "- Logic errors, off-by-one, wrong conditions\n" +
119
+ "- Data handling: null, undefined, type coercion\n" +
120
+ "- Error handling: uncaught exceptions, missing fallbacks\n" +
121
+ "- Edge cases: empty arrays, zero values, concurrent access\n\n" +
122
+ "Rules: Do NOT check style, tests, or security (other reviewers handle those). Read only.",
123
+ },
124
+ {
125
+ name: "security",
126
+ label: "Security Review",
127
+ readOnly: true,
128
+ instructions:
129
+ "You are the SECURITY REVIEWER. Focus exclusively on security.\n\n" +
130
+ "Check:\n" +
131
+ "- SQL injection, XSS, CSRF\n" +
132
+ "- Authentication and authorization bypasses\n" +
133
+ "- Data leaks, insecure defaults\n" +
134
+ "- Input validation and sanitization\n" +
135
+ "- Secrets in code, insecure storage\n\n" +
136
+ "Rules: Do NOT check style or correctness. Read only. Rate findings by severity.",
137
+ },
138
+ {
139
+ name: "tests",
140
+ label: "Test Review",
141
+ readOnly: true,
142
+ instructions:
143
+ "You are the TEST REVIEWER. Focus exclusively on test quality.\n\n" +
144
+ "Check:\n" +
145
+ "- Coverage: what is tested and what is missing\n" +
146
+ "- Assertion quality: meaningful checks vs trivial\n" +
147
+ "- Edge case coverage: boundaries, errors, empty inputs\n" +
148
+ "- Test isolation: shared state, flaky patterns\n" +
149
+ "- Missing test categories: unit, integration, e2e\n\n" +
150
+ "Rules: Do NOT check implementation code quality. Read only.",
151
+ },
152
+ {
153
+ name: "synthesize",
154
+ label: "Synthesizing",
155
+ readOnly: true,
156
+ instructions:
157
+ "You are the SYNTHESIZER. Combine all review findings into a single actionable report.\n\n" +
158
+ "Deliverables:\n" +
159
+ "- Prioritized list of findings by severity (critical > warning > suggestion)\n" +
160
+ "- For each finding: what, where, why, and how to fix\n" +
161
+ "- Overall assessment: ship / fix first / redesign\n" +
162
+ "- Recommended fix order\n\n" +
163
+ "Rules: Read only. Be direct. No fluff.",
164
+ },
165
+ ],
166
+ },
167
+ refactor: {
168
+ name: "Refactor",
169
+ description: "Structured refactoring: analyze, plan, implement, verify",
170
+ stages: [
171
+ {
172
+ name: "analyze",
173
+ label: "Analyzing",
174
+ readOnly: true,
175
+ instructions:
176
+ "You are the ANALYZER. Understand the current code structure before refactoring.\n\n" +
177
+ "Deliverables:\n" +
178
+ "- Current architecture and patterns\n" +
179
+ "- Pain points and code smells\n" +
180
+ "- Dependencies and coupling\n" +
181
+ "- Existing test coverage\n\n" +
182
+ "Rules: Read only. Identify what needs to change and why.",
183
+ },
184
+ {
185
+ name: "plan",
186
+ label: "Planning",
187
+ readOnly: true,
188
+ instructions:
189
+ "You are the PLANNER. Create a refactoring plan that preserves behavior.\n\n" +
190
+ "Deliverables:\n" +
191
+ "- Step-by-step refactoring plan\n" +
192
+ "- Which files change and how\n" +
193
+ "- Migration strategy if APIs change\n" +
194
+ "- Risk assessment\n\n" +
195
+ "Rules: Read only. The plan must ensure no behavior changes (unless explicitly requested).",
196
+ },
197
+ {
198
+ name: "implement",
199
+ label: "Implementing",
200
+ readOnly: false,
201
+ instructions:
202
+ "You are the IMPLEMENTER. Execute the refactoring plan.\n\n" +
203
+ "Rules:\n" +
204
+ "- Follow the plan step by step\n" +
205
+ "- Preserve all existing behavior\n" +
206
+ "- Update tests to reflect structural changes\n" +
207
+ "- Run tests after changes if possible\n" +
208
+ "- Note any deviations from the plan",
209
+ },
210
+ {
211
+ name: "verify",
212
+ label: "Verifying",
213
+ readOnly: true,
214
+ instructions:
215
+ "You are the VERIFIER. Confirm the refactoring preserved behavior.\n\n" +
216
+ "Check:\n" +
217
+ "- All original functionality still works\n" +
218
+ "- Tests pass (run them if possible)\n" +
219
+ "- No regressions introduced\n" +
220
+ "- Code is actually simpler/better after refactoring\n" +
221
+ "- No leftover dead code from the old implementation\n\n" +
222
+ "Rules: Read only. Report any issues found.",
223
+ },
224
+ ],
225
+ },
226
+ };
227
+
228
+ // ── Visual Progress ─────────────────────────────────────────────────────────
229
+
230
+ function renderPipeline(pipeline: Pipeline, activeIndex: number, completedIndices: Set<number>): string {
231
+ const lines: string[] = [];
232
+ const stages = pipeline.stages;
233
+
234
+ // Header
235
+ lines.push(`## Swarm: ${pipeline.name}`);
236
+ lines.push("");
237
+
238
+ // Pipeline visualization
239
+ const stageLabels = stages.map((stage, i) => {
240
+ if (completedIndices.has(i)) return `[${stage.label}]`;
241
+ if (i === activeIndex) return `> ${stage.label} <`;
242
+ return ` ${stage.label} `;
243
+ });
244
+
245
+ // Flow line
246
+ lines.push("```");
247
+ lines.push(stageLabels.join(" -> "));
248
+ lines.push("```");
249
+ lines.push("");
250
+
251
+ return lines.join("\n");
252
+ }
253
+
254
+ function renderStageHeader(pipeline: Pipeline, stageIndex: number, task: string): string {
255
+ const stage = pipeline.stages[stageIndex]!;
256
+ const progress = `[${stageIndex + 1}/${pipeline.stages.length}]`;
257
+ const readOnly = stage.readOnly ? " (read-only)" : "";
258
+
259
+ return (
260
+ `---\n\n` +
261
+ `### ${progress} ${stage.label}${readOnly}\n\n`
262
+ );
263
+ }
264
+
265
+ // ── Extension ───────────────────────────────────────────────────────────────
266
+
267
+ export default function (elyra: ExtensionAPI): void {
268
+ // -- Tool: swarm --
269
+ elyra.registerTool({
270
+ name: "swarm",
271
+ label: "Run Swarm Pipeline",
272
+ description:
273
+ "Run an automated multi-agent swarm pipeline. Available pipelines: " +
274
+ "build (plan -> code -> test -> review -> fix), " +
275
+ "review (analyze -> correctness -> security -> tests -> synthesize), " +
276
+ "refactor (analyze -> plan -> implement -> verify). " +
277
+ "Each stage runs as a focused agent with specific instructions. " +
278
+ "Results pass automatically between stages.",
279
+ parameters: Type.Object({
280
+ pipeline: Type.String({
281
+ description: "Pipeline name: build, review, refactor",
282
+ }),
283
+ task: Type.String({
284
+ description: "The task or target to work on",
285
+ }),
286
+ }),
287
+ execute: async (_toolCallId, params) => {
288
+ const pipeline = PIPELINES[params.pipeline];
289
+ if (!pipeline) {
290
+ const available = Object.entries(PIPELINES)
291
+ .map(([id, p]) => ` ${id}: ${p.description}`)
292
+ .join("\n");
293
+ return {
294
+ content: [{ type: "text", text: `Unknown pipeline: ${params.pipeline}\n\nAvailable:\n${available}` }],
295
+ details: {},
296
+ };
297
+ }
298
+
299
+ const completedIndices = new Set<number>();
300
+ const parts: string[] = [];
301
+
302
+ // Render initial pipeline view
303
+ parts.push(renderPipeline(pipeline, 0, completedIndices));
304
+
305
+ // Generate instructions for all stages
306
+ for (let i = 0; i < pipeline.stages.length; i++) {
307
+ const stage = pipeline.stages[i]!;
308
+ parts.push(renderStageHeader(pipeline, i, params.task));
309
+
310
+ parts.push(`**Task**: ${params.task}\n\n`);
311
+ parts.push(`**Instructions**:\n${stage.instructions}\n\n`);
312
+
313
+ if (stage.readOnly) {
314
+ parts.push(`**Constraint**: This is a read-only stage. Do NOT edit any files.\n\n`);
315
+ }
316
+
317
+ if (i < pipeline.stages.length - 1) {
318
+ parts.push(`When done, write your output under a "#### ${stage.label} Output" heading, then proceed to the next stage.\n\n`);
319
+ } else {
320
+ parts.push(`This is the final stage. Write your output under a "#### ${stage.label} Output" heading, then provide a "## Swarm Summary" with the overall result.\n\n`);
321
+ }
322
+
323
+ completedIndices.add(i);
324
+ }
325
+
326
+ // Final pipeline view (all complete)
327
+ parts.push("---\n\n");
328
+ parts.push(renderPipeline(pipeline, -1, completedIndices));
329
+
330
+ return {
331
+ content: [{ type: "text", text: parts.join("") }],
332
+ details: {
333
+ pipeline: pipeline.name,
334
+ stages: pipeline.stages.length,
335
+ task: params.task,
336
+ },
337
+ };
338
+ },
339
+ });
340
+
341
+ // -- Command: /swarm --
342
+ elyra.registerCommand("swarm", {
343
+ description: "Run a multi-agent swarm pipeline: /swarm <pipeline> <task>",
344
+ handler: async (args, ctx) => {
345
+ const parts = args.trim().split(/\s+/);
346
+ const pipelineName = parts[0];
347
+ const task = parts.slice(1).join(" ");
348
+
349
+ if (!pipelineName) {
350
+ const pipelineList = Object.entries(PIPELINES)
351
+ .map(([id, p]) => {
352
+ const stages = p.stages.map((s) => s.name).join(" -> ");
353
+ return ` **${id}**: ${p.description}\n ${stages}`;
354
+ })
355
+ .join("\n\n");
356
+ ctx.ui.notify(`Available swarm pipelines:\n\n${pipelineList}\n\nUsage: /swarm <pipeline> <task>`);
357
+ return;
358
+ }
359
+
360
+ if (!PIPELINES[pipelineName]) {
361
+ const available = Object.keys(PIPELINES).join(", ");
362
+ ctx.ui.notify(`Unknown pipeline: ${pipelineName}. Available: ${available}`, "error");
363
+ return;
364
+ }
365
+
366
+ if (!task) {
367
+ ctx.ui.notify(`Usage: /swarm ${pipelineName} <task description>`, "error");
368
+ return;
369
+ }
370
+
371
+ elyra.sendUserMessage(`Run the ${pipelineName} swarm pipeline: ${task}`);
372
+ },
373
+ });
374
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@elyracode/swarm",
3
+ "version": "0.5.9",
4
+ "description": "Multi-agent swarm orchestration for Elyra -- automated pipelines with visual progress tracking",
5
+ "type": "module",
6
+ "keywords": [
7
+ "elyra-package",
8
+ "swarm",
9
+ "multi-agent",
10
+ "orchestration",
11
+ "pipeline"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "Knut W. Horne",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/kwhorne/elyra.git",
18
+ "directory": "packages/swarm"
19
+ },
20
+ "elyra": {
21
+ "extensions": [
22
+ "./extensions/index.ts"
23
+ ],
24
+ "skills": [
25
+ "./skills"
26
+ ]
27
+ },
28
+ "peerDependencies": {
29
+ "@elyracode/coding-agent": "*",
30
+ "typebox": "*"
31
+ },
32
+ "scripts": {
33
+ "clean": "echo 'nothing to clean'",
34
+ "build": "echo 'nothing to build'",
35
+ "check": "echo 'nothing to check'"
36
+ }
37
+ }
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: elyra-swarm
3
+ description: Multi-agent swarm orchestration. Use when the user asks to build a feature, run a pipeline, or wants multiple agents to collaborate on a task automatically.
4
+ ---
5
+
6
+ # Swarm Orchestration
7
+
8
+ ## When to Use
9
+
10
+ Use the `swarm` tool when the user asks to:
11
+ - Build a complete feature end-to-end
12
+ - Run a multi-step development pipeline
13
+ - Have multiple agents collaborate automatically
14
+ - Orchestrate planning, implementation, testing, and review
15
+
16
+ ## Available Pipelines
17
+
18
+ | Pipeline | Stages | Use when |
19
+ |----------|--------|----------|
20
+ | `build` | plan -> code -> test -> review -> fix | Building a new feature or component |
21
+ | `review` | analyze -> correctness -> security -> tests -> synthesize | Deep review of existing code |
22
+ | `refactor` | analyze -> plan -> implement -> verify | Restructuring existing code |
23
+
24
+ ## How It Works
25
+
26
+ 1. User describes the task
27
+ 2. Swarm selects a pipeline (or user specifies one)
28
+ 3. Each stage runs with focused instructions and passes results to the next
29
+ 4. Progress is shown as a visual pipeline in the TUI
30
+ 5. Final summary collects all results
31
+
32
+ ## Usage
33
+
34
+ Natural language:
35
+ ```
36
+ Swarm: build user registration with email verification
37
+ Run a review swarm on the payment module
38
+ Refactor the auth system using swarm
39
+ ```
40
+
41
+ Commands:
42
+ ```
43
+ /swarm build user registration with email verification
44
+ /swarm review src/payments/
45
+ /swarm refactor the notification system
46
+ ```