@elyracode/subagents 0.9.56 → 0.9.58

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.
Files changed (2) hide show
  1. package/extensions/index.ts +147 -80
  2. package/package.json +1 -1
@@ -1,9 +1,20 @@
1
- import type { ExtensionAPI } from "@elyracode/coding-agent";
1
+ import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
2
2
  import { Type } from "typebox";
3
- import { BUILTIN_AGENTS, type AgentDefinition } from "./agents.js";
3
+ import { type AgentDefinition, BUILTIN_AGENTS } from "./agents.js";
4
4
 
5
- export default function (elyra: ExtensionAPI): void {
5
+ /** Details reported by the subagent tool. */
6
+ interface SubagentDetails {
7
+ agent?: string;
8
+ readOnly?: boolean;
9
+ }
10
+
11
+ /** Details reported by orchestrate_workflow. */
12
+ interface OrchestrateDetails {
13
+ workflow?: string;
14
+ steps?: number;
15
+ }
6
16
 
17
+ export default function (elyra: ExtensionAPI): void {
7
18
  // -- Tool: subagent --
8
19
  elyra.registerTool({
9
20
  name: "subagent",
@@ -28,7 +39,7 @@ export default function (elyra: ExtensionAPI): void {
28
39
  }),
29
40
  ),
30
41
  }),
31
- execute: async (_toolCallId, params) => {
42
+ execute: async (_toolCallId, params): Promise<AgentToolResult<SubagentDetails>> => {
32
43
  const agentDef = BUILTIN_AGENTS[params.agent];
33
44
  if (!agentDef) {
34
45
  const available = Object.keys(BUILTIN_AGENTS).join(", ");
@@ -41,17 +52,20 @@ export default function (elyra: ExtensionAPI): void {
41
52
  const subagentPrompt = formatSubagentPrompt(agentDef, params.task, params.context);
42
53
 
43
54
  return {
44
- content: [{
45
- type: "text",
46
- text: `## Subagent: ${agentDef.name}\n\n` +
47
- `**Role**: ${agentDef.description}\n\n` +
48
- `**Task**: ${params.task}\n\n` +
49
- `**Instructions**: Execute this task following the subagent's role and rules:\n\n` +
50
- `${subagentPrompt}\n\n` +
51
- `**Allowed tools**: ${agentDef.tools?.join(", ") ?? "all"}\n` +
52
- `**Read-only**: ${agentDef.readOnly ? "Yes -- do not edit files" : "No -- can edit files"}\n\n` +
53
- `When done, provide a clear summary of findings/results under a "## ${agentDef.name} Report" heading.`,
54
- }],
55
+ content: [
56
+ {
57
+ type: "text",
58
+ text:
59
+ `## Subagent: ${agentDef.name}\n\n` +
60
+ `**Role**: ${agentDef.description}\n\n` +
61
+ `**Task**: ${params.task}\n\n` +
62
+ `**Instructions**: Execute this task following the subagent's role and rules:\n\n` +
63
+ `${subagentPrompt}\n\n` +
64
+ `**Allowed tools**: ${agentDef.tools?.join(", ") ?? "all"}\n` +
65
+ `**Read-only**: ${agentDef.readOnly ? "Yes -- do not edit files" : "No -- can edit files"}\n\n` +
66
+ `When done, provide a clear summary of findings/results under a "## ${agentDef.name} Report" heading.`,
67
+ },
68
+ ],
55
69
  details: {
56
70
  agent: agentDef.name,
57
71
  readOnly: agentDef.readOnly ?? false,
@@ -79,10 +93,7 @@ export default function (elyra: ExtensionAPI): void {
79
93
  ),
80
94
  }),
81
95
  execute: async (_toolCallId, params) => {
82
- const results: string[] = [
83
- `# Parallel Subagent Execution (${params.tasks.length} agents)`,
84
- "",
85
- ];
96
+ const results: string[] = [`# Parallel Subagent Execution (${params.tasks.length} agents)`, ""];
86
97
 
87
98
  for (const [index, taskDef] of params.tasks.entries()) {
88
99
  const agentDef = BUILTIN_AGENTS[taskDef.agent];
@@ -110,7 +121,9 @@ export default function (elyra: ExtensionAPI): void {
110
121
  results.push("");
111
122
  }
112
123
 
113
- results.push("Execute each agent's task. For read-only agents, do not edit files. Synthesize all findings at the end under a ## Summary heading.");
124
+ results.push(
125
+ "Execute each agent's task. For read-only agents, do not edit files. Synthesize all findings at the end under a ## Summary heading.",
126
+ );
114
127
 
115
128
  return {
116
129
  content: [{ type: "text", text: results.join("\n") }],
@@ -136,7 +149,9 @@ export default function (elyra: ExtensionAPI): void {
136
149
  }
137
150
 
138
151
  if (!task) {
139
- elyra.sendUserMessage(`/run ${agentName}: please provide a task. Example: /run ${agentName} analyze the auth flow`);
152
+ elyra.sendUserMessage(
153
+ `/run ${agentName}: please provide a task. Example: /run ${agentName} analyze the auth flow`,
154
+ );
140
155
  return;
141
156
  }
142
157
 
@@ -151,7 +166,7 @@ export default function (elyra: ExtensionAPI): void {
151
166
  if (!args.trim()) {
152
167
  elyra.sendUserMessage(
153
168
  "Usage: /parallel agent1 'task1' -> agent2 'task2'\n\n" +
154
- "Example: /parallel reviewer 'check correctness' -> reviewer 'check tests' -> reviewer 'check complexity'",
169
+ "Example: /parallel reviewer 'check correctness' -> reviewer 'check tests' -> reviewer 'check complexity'",
155
170
  );
156
171
  return;
157
172
  }
@@ -182,13 +197,12 @@ export default function (elyra: ExtensionAPI): void {
182
197
  "'deep-review' (parallel reviewers for correctness, tests, security, then synthesis). " +
183
198
  "Use this for complex tasks that benefit from structured multi-agent orchestration.",
184
199
  parameters: Type.Object({
185
- workflow: Type.Union(
186
- [Type.Literal("build-feature"), Type.Literal("ui-review"), Type.Literal("deep-review")],
187
- { description: "The workflow to run" },
188
- ),
200
+ workflow: Type.Union([Type.Literal("build-feature"), Type.Literal("ui-review"), Type.Literal("deep-review")], {
201
+ description: "The workflow to run",
202
+ }),
189
203
  task: Type.String({ description: "Description of the feature or task" }),
190
204
  }),
191
- execute: async (_toolCallId, params) => {
205
+ execute: async (_toolCallId, params): Promise<AgentToolResult<OrchestrateDetails>> => {
192
206
  const workflow = WORKFLOWS[params.workflow];
193
207
  if (!workflow) {
194
208
  return {
@@ -197,27 +211,34 @@ export default function (elyra: ExtensionAPI): void {
197
211
  };
198
212
  }
199
213
 
200
- const instructions = workflow.steps.map((step, i) => {
201
- const agent = BUILTIN_AGENTS[step.agent];
202
- const agentDesc = agent ? `(${agent.description})` : "";
203
- const readOnly = agent?.readOnly ? " [READ-ONLY]" : "";
204
- const stepTask = step.task.replace("{task}", params.task).replace("{previous}", "the previous step's output");
205
- return `### Step ${i + 1}: ${step.agent}${readOnly} ${agentDesc}\n${stepTask}`;
206
- }).join("\n\n");
214
+ const instructions = workflow.steps
215
+ .map((step, i) => {
216
+ const agent = BUILTIN_AGENTS[step.agent];
217
+ const agentDesc = agent ? `(${agent.description})` : "";
218
+ const readOnly = agent?.readOnly ? " [READ-ONLY]" : "";
219
+ const stepTask = step.task
220
+ .replace("{task}", params.task)
221
+ .replace("{previous}", "the previous step's output");
222
+ return `### Step ${i + 1}: ${step.agent}${readOnly} ${agentDesc}\n${stepTask}`;
223
+ })
224
+ .join("\n\n");
207
225
 
208
226
  return {
209
- content: [{
210
- type: "text",
211
- text: `# Workflow: ${workflow.name}\n\n` +
212
- `${workflow.description}\n\n` +
213
- `Task: ${params.task}\n\n` +
214
- `## Execution Plan\n\n${instructions}\n\n` +
215
- `## Rules\n` +
216
- `- Execute each step in order\n` +
217
- `- Read-only steps must NOT edit files\n` +
218
- `- Pass results from each step to the next\n` +
219
- `- After the final step, provide a summary of everything done`,
220
- }],
227
+ content: [
228
+ {
229
+ type: "text",
230
+ text:
231
+ `# Workflow: ${workflow.name}\n\n` +
232
+ `${workflow.description}\n\n` +
233
+ `Task: ${params.task}\n\n` +
234
+ `## Execution Plan\n\n${instructions}\n\n` +
235
+ `## Rules\n` +
236
+ `- Execute each step in order\n` +
237
+ `- Read-only steps must NOT edit files\n` +
238
+ `- Pass results from each step to the next\n` +
239
+ `- After the final step, provide a summary of everything done`,
240
+ },
241
+ ],
221
242
  details: { workflow: params.workflow, steps: workflow.steps.length },
222
243
  };
223
244
  },
@@ -228,7 +249,9 @@ export default function (elyra: ExtensionAPI): void {
228
249
  description: "Orchestrated feature development: scout -> planner -> worker -> reviewer -> fix",
229
250
  handler: async (args, _ctx) => {
230
251
  if (!args.trim()) {
231
- elyra.sendUserMessage("Usage: /build-feature <description>\n\nExample: /build-feature add a wallet system with balance tracking and transaction history");
252
+ elyra.sendUserMessage(
253
+ "Usage: /build-feature <description>\n\nExample: /build-feature add a wallet system with balance tracking and transaction history",
254
+ );
232
255
  return;
233
256
  }
234
257
  elyra.sendUserMessage(`Run the build-feature workflow: ${args}`);
@@ -240,7 +263,9 @@ export default function (elyra: ExtensionAPI): void {
240
263
  description: "Adversarial UI testing: build UI, then screenshot + visual QA + accessibility check",
241
264
  handler: async (args, _ctx) => {
242
265
  if (!args.trim()) {
243
- elyra.sendUserMessage("Usage: /ui-review <description>\n\nExample: /ui-review build a registration form with validation");
266
+ elyra.sendUserMessage(
267
+ "Usage: /ui-review <description>\n\nExample: /ui-review build a registration form with validation",
268
+ );
244
269
  return;
245
270
  }
246
271
  elyra.sendUserMessage(`Run the ui-review workflow: ${args}`);
@@ -252,7 +277,9 @@ export default function (elyra: ExtensionAPI): void {
252
277
  description: "Parallel deep review: correctness + tests + security + synthesis",
253
278
  handler: async (args, _ctx) => {
254
279
  if (!args.trim()) {
255
- elyra.sendUserMessage("Usage: /deep-review <what to review>\n\nExample: /deep-review the authentication system");
280
+ elyra.sendUserMessage(
281
+ "Usage: /deep-review <what to review>\n\nExample: /deep-review the authentication system",
282
+ );
256
283
  return;
257
284
  }
258
285
  elyra.sendUserMessage(`Run the deep-review workflow: ${args}`);
@@ -265,11 +292,11 @@ export default function (elyra: ExtensionAPI): void {
265
292
  handler: async (_args, _ctx) => {
266
293
  elyra.sendUserMessage(
267
294
  "Run the git-review workflow on my current changes. " +
268
- "Get the git diff of staged and unstaged changes, then review for: " +
269
- "correctness, security issues, missing tests, code debt (TODO/FIXME), " +
270
- "and Tailwind design consistency (if UI files changed). " +
271
- "If design_system_check is available, run it on modified frontend files. " +
272
- "Summarize findings as a go/no-go for pushing.",
295
+ "Get the git diff of staged and unstaged changes, then review for: " +
296
+ "correctness, security issues, missing tests, code debt (TODO/FIXME), " +
297
+ "and Tailwind design consistency (if UI files changed). " +
298
+ "If design_system_check is available, run it on modified frontend files. " +
299
+ "Summarize findings as a go/no-go for pushing.",
273
300
  );
274
301
  },
275
302
  });
@@ -277,7 +304,7 @@ export default function (elyra: ExtensionAPI): void {
277
304
  // -- Command: /setup-git-hook --
278
305
  elyra.registerCommand("setup-git-hook", {
279
306
  description: "Install a git pre-push hook that runs elyra review",
280
- handler: async (_args, ctx) => {
307
+ handler: async (_args, _ctx) => {
281
308
  const hookScript = `#!/bin/sh
282
309
  # Elyra pre-push review hook
283
310
  # Runs a quick code review before pushing
@@ -298,22 +325,19 @@ exit 0
298
325
 
299
326
  elyra.sendUserMessage(
300
327
  "Set up the Elyra pre-push git hook. Write this script to `.git/hooks/pre-push` and make it executable:\n\n" +
301
- "```bash\n" + hookScript + "```\n\n" +
302
- "Commands:\n" +
303
- "```bash\nmkdir -p .git/hooks\n" +
304
- "# Write the hook file\nchmod +x .git/hooks/pre-push\n```",
328
+ "```bash\n" +
329
+ hookScript +
330
+ "```\n\n" +
331
+ "Commands:\n" +
332
+ "```bash\nmkdir -p .git/hooks\n" +
333
+ "# Write the hook file\nchmod +x .git/hooks/pre-push\n```",
305
334
  );
306
335
  },
307
336
  });
308
337
  }
309
338
 
310
339
  function formatSubagentPrompt(agent: AgentDefinition, task: string, context?: string): string {
311
- const parts: string[] = [
312
- agent.systemPrompt,
313
- "",
314
- "## Task",
315
- task,
316
- ];
340
+ const parts: string[] = [agent.systemPrompt, "", "## Task", task];
317
341
 
318
342
  if (context) {
319
343
  parts.push("", "## Additional Context", context);
@@ -340,32 +364,75 @@ const WORKFLOWS: Record<string, Workflow> = {
340
364
  name: "Build Feature",
341
365
  description: "Full orchestrated feature development: understand the codebase, plan, implement, review, and fix.",
342
366
  steps: [
343
- { agent: "scout", task: "Analyze the codebase to understand the existing architecture, relevant files, data models, and how {task} should fit in. Report file paths, patterns, and risks." },
344
- { agent: "planner", task: "Based on the scout's findings, create a detailed implementation plan for {task}. Include file paths, function signatures, database changes, and test strategy." },
345
- { agent: "oracle", task: "Review the planner's implementation plan for {task}. Challenge assumptions, identify risks, edge cases, and security concerns. Recommend the safest approach." },
346
- { agent: "worker", task: "Implement {task} following the approved plan. Edit files, create migrations, write code. Validate changes compile and make sense." },
347
- { agent: "reviewer", task: "Review the worker's implementation of {task}. Check correctness, tests, security, simplicity. List issues as critical/warning/suggestion." },
348
- { agent: "worker", task: "Fix the issues found by the reviewer. Apply only the changes that are critical or clearly beneficial." },
367
+ {
368
+ agent: "scout",
369
+ task: "Analyze the codebase to understand the existing architecture, relevant files, data models, and how {task} should fit in. Report file paths, patterns, and risks.",
370
+ },
371
+ {
372
+ agent: "planner",
373
+ task: "Based on the scout's findings, create a detailed implementation plan for {task}. Include file paths, function signatures, database changes, and test strategy.",
374
+ },
375
+ {
376
+ agent: "oracle",
377
+ task: "Review the planner's implementation plan for {task}. Challenge assumptions, identify risks, edge cases, and security concerns. Recommend the safest approach.",
378
+ },
379
+ {
380
+ agent: "worker",
381
+ task: "Implement {task} following the approved plan. Edit files, create migrations, write code. Validate changes compile and make sense.",
382
+ },
383
+ {
384
+ agent: "reviewer",
385
+ task: "Review the worker's implementation of {task}. Check correctness, tests, security, simplicity. List issues as critical/warning/suggestion.",
386
+ },
387
+ {
388
+ agent: "worker",
389
+ task: "Fix the issues found by the reviewer. Apply only the changes that are critical or clearly beneficial.",
390
+ },
349
391
  ],
350
392
  },
351
393
  "ui-review": {
352
394
  name: "Adversarial UI Review",
353
- description: "Build UI, then visually inspect it with screenshots and check for accessibility, design consistency, and responsive issues.",
395
+ description:
396
+ "Build UI, then visually inspect it with screenshots and check for accessibility, design consistency, and responsive issues.",
354
397
  steps: [
355
- { agent: "worker", task: "Build the UI for {task}. Use the project's component library and Tailwind CSS. Make it responsive and accessible." },
356
- { agent: "reviewer", task: "Review the UI code for {task}. If design_preview or screenshot_url tools are available, use them to visually inspect the result. Check: visual alignment, spacing consistency, color contrast (WCAG), responsive layout (test mobile viewport), hover/focus states, dark mode support. If design_system_check is available, run it on the modified files. Report visual issues with specific Tailwind class fixes." },
357
- { agent: "worker", task: "Fix the visual and accessibility issues found by the reviewer. Apply the Tailwind class changes recommended." },
358
- { agent: "reviewer", task: "Final visual check of {task}. Verify all issues are resolved. Use screenshot_url if available to confirm." },
398
+ {
399
+ agent: "worker",
400
+ task: "Build the UI for {task}. Use the project's component library and Tailwind CSS. Make it responsive and accessible.",
401
+ },
402
+ {
403
+ agent: "reviewer",
404
+ task: "Review the UI code for {task}. If design_preview or screenshot_url tools are available, use them to visually inspect the result. Check: visual alignment, spacing consistency, color contrast (WCAG), responsive layout (test mobile viewport), hover/focus states, dark mode support. If design_system_check is available, run it on the modified files. Report visual issues with specific Tailwind class fixes.",
405
+ },
406
+ {
407
+ agent: "worker",
408
+ task: "Fix the visual and accessibility issues found by the reviewer. Apply the Tailwind class changes recommended.",
409
+ },
410
+ {
411
+ agent: "reviewer",
412
+ task: "Final visual check of {task}. Verify all issues are resolved. Use screenshot_url if available to confirm.",
413
+ },
359
414
  ],
360
415
  },
361
416
  "deep-review": {
362
417
  name: "Deep Parallel Review",
363
418
  description: "Run three focused review passes in sequence, then synthesize findings.",
364
419
  steps: [
365
- { agent: "reviewer", task: "CORRECTNESS REVIEW of {task}: Focus exclusively on logical correctness, data handling, error handling, and edge cases. Ignore style and tests." },
366
- { agent: "reviewer", task: "TEST REVIEW of {task}: Focus exclusively on test coverage, missing test cases, test quality, and edge case testing. Ignore implementation style." },
367
- { agent: "reviewer", task: "SECURITY REVIEW of {task}: Focus exclusively on security: SQL injection, XSS, CSRF, auth bypasses, data leaks, insecure defaults, input validation. Ignore style and tests." },
368
- { agent: "oracle", task: "Synthesize all three review reports for {task}. Prioritize findings by impact. Create a single actionable fix list ordered by severity. Recommend which fixes to apply now vs later." },
420
+ {
421
+ agent: "reviewer",
422
+ task: "CORRECTNESS REVIEW of {task}: Focus exclusively on logical correctness, data handling, error handling, and edge cases. Ignore style and tests.",
423
+ },
424
+ {
425
+ agent: "reviewer",
426
+ task: "TEST REVIEW of {task}: Focus exclusively on test coverage, missing test cases, test quality, and edge case testing. Ignore implementation style.",
427
+ },
428
+ {
429
+ agent: "reviewer",
430
+ task: "SECURITY REVIEW of {task}: Focus exclusively on security: SQL injection, XSS, CSRF, auth bypasses, data leaks, insecure defaults, input validation. Ignore style and tests.",
431
+ },
432
+ {
433
+ agent: "oracle",
434
+ task: "Synthesize all three review reports for {task}. Prioritize findings by impact. Create a single actionable fix list ordered by severity. Recommend which fixes to apply now vs later.",
435
+ },
369
436
  ],
370
437
  },
371
438
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/subagents",
3
- "version": "0.9.56",
3
+ "version": "0.9.58",
4
4
  "description": "Elyra extension for subagent delegation -- scout, reviewer, planner, worker, oracle, and parallel execution",
5
5
  "type": "module",
6
6
  "keywords": [