@elyracode/swarm 0.9.56 → 0.9.57
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 +2 -0
- package/extensions/index.ts +28 -12
- package/extensions/worktree.ts +14 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/extensions/index.ts
CHANGED
|
@@ -260,15 +260,12 @@ function renderPipeline(pipeline: Pipeline, activeIndex: number, completedIndice
|
|
|
260
260
|
return lines.join("\n");
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
function renderStageHeader(pipeline: Pipeline, stageIndex: number,
|
|
263
|
+
function renderStageHeader(pipeline: Pipeline, stageIndex: number, _task: string): string {
|
|
264
264
|
const stage = pipeline.stages[stageIndex]!;
|
|
265
265
|
const progress = `[${stageIndex + 1}/${pipeline.stages.length}]`;
|
|
266
266
|
const readOnly = stage.readOnly ? " (read-only)" : "";
|
|
267
267
|
|
|
268
|
-
return
|
|
269
|
-
`---\n\n` +
|
|
270
|
-
`### ${progress} ${stage.label}${readOnly}\n\n`
|
|
271
|
-
);
|
|
268
|
+
return `---\n\n### ${progress} ${stage.label}${readOnly}\n\n`;
|
|
272
269
|
}
|
|
273
270
|
|
|
274
271
|
// ── Extension ───────────────────────────────────────────────────────────────
|
|
@@ -296,9 +293,13 @@ function buildInlineResult(pipeline: Pipeline, task: string, note?: string) {
|
|
|
296
293
|
}
|
|
297
294
|
|
|
298
295
|
if (i < pipeline.stages.length - 1) {
|
|
299
|
-
parts.push(
|
|
296
|
+
parts.push(
|
|
297
|
+
`When done, write your output under a "#### ${stage.label} Output" heading, then proceed to the next stage.\n\n`,
|
|
298
|
+
);
|
|
300
299
|
} else {
|
|
301
|
-
parts.push(
|
|
300
|
+
parts.push(
|
|
301
|
+
`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`,
|
|
302
|
+
);
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
completedIndices.add(i);
|
|
@@ -335,7 +336,9 @@ function buildStagePrompt(pipeline: Pipeline, stageIndex: number, task: string,
|
|
|
335
336
|
if (previousOutputs.length > 0) {
|
|
336
337
|
parts.push(`\n\n**Output from previous stages**:\n\n${previousOutputs.join("\n\n---\n\n")}`);
|
|
337
338
|
}
|
|
338
|
-
parts.push(
|
|
339
|
+
parts.push(
|
|
340
|
+
`\n\nWork directly in the current directory. When done, end with a concise summary of what you did/found.`,
|
|
341
|
+
);
|
|
339
342
|
return parts.join("");
|
|
340
343
|
}
|
|
341
344
|
|
|
@@ -345,19 +348,29 @@ async function runWorktreePipeline(
|
|
|
345
348
|
task: string,
|
|
346
349
|
ctx: ExtensionContext,
|
|
347
350
|
signal: AbortSignal | undefined,
|
|
348
|
-
onUpdate:
|
|
351
|
+
onUpdate:
|
|
352
|
+
| ((partial: { content: Array<{ type: "text"; text: string }>; details: Record<string, unknown> }) => void)
|
|
353
|
+
| undefined,
|
|
349
354
|
) {
|
|
350
355
|
const cwd = ctx.cwd;
|
|
351
356
|
const exec = elyra.exec.bind(elyra);
|
|
352
357
|
|
|
353
358
|
if (!(await isGitRepo(exec, cwd))) {
|
|
354
|
-
return buildInlineResult(
|
|
359
|
+
return buildInlineResult(
|
|
360
|
+
pipeline,
|
|
361
|
+
task,
|
|
362
|
+
"Worktree mode requested but this is not a git repository — running inline instead.",
|
|
363
|
+
);
|
|
355
364
|
}
|
|
356
365
|
|
|
357
366
|
const mainBefore = await changedFiles(exec, cwd);
|
|
358
367
|
const worktree = await createWorktree(exec, cwd);
|
|
359
368
|
if ("error" in worktree) {
|
|
360
|
-
return buildInlineResult(
|
|
369
|
+
return buildInlineResult(
|
|
370
|
+
pipeline,
|
|
371
|
+
task,
|
|
372
|
+
`Worktree mode requested but worktree creation failed (${worktree.error}) — running inline instead.`,
|
|
373
|
+
);
|
|
361
374
|
}
|
|
362
375
|
|
|
363
376
|
const modelArgs = ctx.model ? ["--model", `${ctx.model.provider}/${ctx.model.id}`] : [];
|
|
@@ -553,7 +566,10 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
553
566
|
elyra.registerCommand("swarm", {
|
|
554
567
|
description: "Run a multi-agent swarm pipeline: /swarm [--worktrees] <pipeline> <task>",
|
|
555
568
|
handler: async (args, ctx) => {
|
|
556
|
-
const tokens = args
|
|
569
|
+
const tokens = args
|
|
570
|
+
.trim()
|
|
571
|
+
.split(/\s+/)
|
|
572
|
+
.filter((t) => t.length > 0);
|
|
557
573
|
const worktrees = tokens.includes("--worktrees");
|
|
558
574
|
const parts = tokens.filter((t) => t !== "--worktrees");
|
|
559
575
|
const pipelineName = parts[0];
|
package/extensions/worktree.ts
CHANGED
|
@@ -11,17 +11,23 @@ import { mkdtempSync, writeFileSync } from "node:fs";
|
|
|
11
11
|
import { tmpdir } from "node:os";
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
export type ExecFn = (
|
|
15
|
+
command: string,
|
|
16
|
+
args: string[],
|
|
17
|
+
options?: { cwd?: string; timeout?: number; signal?: AbortSignal },
|
|
18
|
+
) => Promise<{
|
|
19
|
+
stdout: string;
|
|
20
|
+
stderr: string;
|
|
21
|
+
code: number;
|
|
22
|
+
}>;
|
|
21
23
|
|
|
22
24
|
const GIT_TIMEOUT = 30_000;
|
|
23
25
|
|
|
24
|
-
async function git(
|
|
26
|
+
async function git(
|
|
27
|
+
exec: ExecFn,
|
|
28
|
+
cwd: string,
|
|
29
|
+
args: string[],
|
|
30
|
+
): Promise<{ stdout: string; code: number; stderr: string }> {
|
|
25
31
|
const result = await exec("git", args, { cwd, timeout: GIT_TIMEOUT });
|
|
26
32
|
return { stdout: result.stdout, code: result.code, stderr: result.stderr };
|
|
27
33
|
}
|