opencode-swarm-plugin 0.36.1 → 0.38.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/dist/index.js CHANGED
@@ -22178,6 +22178,357 @@ Codebase context considered: ${args.codebase_context.slice(0, 200)}...`;
22178
22178
  };
22179
22179
  });
22180
22180
 
22181
+ // src/eval-capture.ts
22182
+ var exports_eval_capture = {};
22183
+ __export(exports_eval_capture, {
22184
+ updateEvalRecord: () => updateEvalRecord,
22185
+ saveSession: () => saveSession,
22186
+ readSessionEvents: () => readSessionEvents,
22187
+ readPartialRecords: () => readPartialRecords,
22188
+ readEvalRecords: () => readEvalRecords,
22189
+ getSessionPath: () => getSessionPath,
22190
+ getSessionDir: () => getSessionDir,
22191
+ getEvalDataStats: () => getEvalDataStats,
22192
+ getEvalDataPath: () => getEvalDataPath,
22193
+ finalizeEvalRecord: () => finalizeEvalRecord,
22194
+ exportForEvalite: () => exportForEvalite,
22195
+ ensureSessionDir: () => ensureSessionDir,
22196
+ ensureEvalDataDir: () => ensureEvalDataDir,
22197
+ captureSubtaskOutcome: () => captureSubtaskOutcome,
22198
+ captureHumanFeedback: () => captureHumanFeedback,
22199
+ captureDecomposition: () => captureDecomposition,
22200
+ captureCoordinatorEvent: () => captureCoordinatorEvent,
22201
+ appendEvalRecord: () => appendEvalRecord,
22202
+ SubtaskOutcomeSchema: () => SubtaskOutcomeSchema,
22203
+ EvalRecordSchema: () => EvalRecordSchema,
22204
+ DEFAULT_EVAL_DATA_PATH: () => DEFAULT_EVAL_DATA_PATH,
22205
+ CoordinatorSessionSchema: () => CoordinatorSessionSchema,
22206
+ CoordinatorEventSchema: () => CoordinatorEventSchema
22207
+ });
22208
+ import * as fs from "node:fs";
22209
+ import * as os from "node:os";
22210
+ import * as path from "node:path";
22211
+ function getEvalDataPath(projectPath) {
22212
+ return path.join(projectPath, DEFAULT_EVAL_DATA_PATH);
22213
+ }
22214
+ function ensureEvalDataDir(projectPath) {
22215
+ const evalPath = getEvalDataPath(projectPath);
22216
+ const dir = path.dirname(evalPath);
22217
+ if (!fs.existsSync(dir)) {
22218
+ fs.mkdirSync(dir, { recursive: true });
22219
+ }
22220
+ }
22221
+ function appendEvalRecord(projectPath, record2) {
22222
+ ensureEvalDataDir(projectPath);
22223
+ const evalPath = getEvalDataPath(projectPath);
22224
+ const line = `${JSON.stringify(record2)}
22225
+ `;
22226
+ fs.appendFileSync(evalPath, line, "utf-8");
22227
+ }
22228
+ function readEvalRecords(projectPath) {
22229
+ const evalPath = getEvalDataPath(projectPath);
22230
+ if (!fs.existsSync(evalPath)) {
22231
+ return [];
22232
+ }
22233
+ const content = fs.readFileSync(evalPath, "utf-8");
22234
+ const lines = content.trim().split(`
22235
+ `).filter(Boolean);
22236
+ return lines.map((line) => {
22237
+ const parsed = JSON.parse(line);
22238
+ return EvalRecordSchema.parse(parsed);
22239
+ });
22240
+ }
22241
+ function readPartialRecords(projectPath) {
22242
+ const evalPath = getEvalDataPath(projectPath);
22243
+ if (!fs.existsSync(evalPath)) {
22244
+ return [];
22245
+ }
22246
+ const content = fs.readFileSync(evalPath, "utf-8");
22247
+ const lines = content.trim().split(`
22248
+ `).filter(Boolean);
22249
+ return lines.map((line) => JSON.parse(line));
22250
+ }
22251
+ function updateEvalRecord(projectPath, id, updates) {
22252
+ const records = readPartialRecords(projectPath);
22253
+ const index = records.findIndex((r) => r.id === id);
22254
+ if (index === -1) {
22255
+ return false;
22256
+ }
22257
+ records[index] = { ...records[index], ...updates };
22258
+ const evalPath = getEvalDataPath(projectPath);
22259
+ const content = `${records.map((r) => JSON.stringify(r)).join(`
22260
+ `)}
22261
+ `;
22262
+ fs.writeFileSync(evalPath, content, "utf-8");
22263
+ return true;
22264
+ }
22265
+ function captureDecomposition(params) {
22266
+ const record2 = {
22267
+ id: params.epicId,
22268
+ timestamp: new Date().toISOString(),
22269
+ project_path: params.projectPath,
22270
+ task: params.task,
22271
+ context: params.context,
22272
+ strategy: params.strategy,
22273
+ subtask_count: params.subtasks.length,
22274
+ epic_title: params.epicTitle,
22275
+ epic_description: params.epicDescription,
22276
+ subtasks: params.subtasks,
22277
+ outcomes: []
22278
+ };
22279
+ inProgressRecords.set(params.epicId, record2);
22280
+ appendEvalRecord(params.projectPath, record2);
22281
+ return record2;
22282
+ }
22283
+ function captureSubtaskOutcome(params) {
22284
+ const outcome = {
22285
+ bead_id: params.beadId,
22286
+ title: params.title,
22287
+ planned_files: params.plannedFiles,
22288
+ actual_files: params.actualFiles,
22289
+ duration_ms: params.durationMs,
22290
+ error_count: params.errorCount,
22291
+ retry_count: params.retryCount,
22292
+ success: params.success,
22293
+ failure_mode: params.failureMode
22294
+ };
22295
+ const record2 = inProgressRecords.get(params.epicId);
22296
+ if (record2) {
22297
+ record2.outcomes = record2.outcomes || [];
22298
+ record2.outcomes.push(outcome);
22299
+ }
22300
+ updateEvalRecord(params.projectPath, params.epicId, {
22301
+ outcomes: record2?.outcomes
22302
+ });
22303
+ }
22304
+ function finalizeEvalRecord(params) {
22305
+ const record2 = inProgressRecords.get(params.epicId);
22306
+ if (!record2 || !record2.outcomes || record2.outcomes.length === 0) {
22307
+ return null;
22308
+ }
22309
+ const outcomes = record2.outcomes;
22310
+ const overallSuccess = outcomes.every((o) => o.success);
22311
+ const totalDurationMs = outcomes.reduce((sum, o) => sum + o.duration_ms, 0);
22312
+ const totalErrors = outcomes.reduce((sum, o) => sum + o.error_count, 0);
22313
+ const allPlannedFiles = record2.subtasks?.flatMap((s) => s.files) || [];
22314
+ const fileOccurrences = new Map;
22315
+ for (const file2 of allPlannedFiles) {
22316
+ fileOccurrences.set(file2, (fileOccurrences.get(file2) || 0) + 1);
22317
+ }
22318
+ const fileOverlapCount = Array.from(fileOccurrences.values()).filter((count) => count > 1).length;
22319
+ const plannedFileSet = new Set(allPlannedFiles);
22320
+ const actualFileSet = new Set(outcomes.flatMap((o) => o.actual_files));
22321
+ const scopeAccuracy = plannedFileSet.size > 0 ? actualFileSet.size / plannedFileSet.size : 1;
22322
+ const durations = outcomes.map((o) => o.duration_ms).filter((d) => d > 0);
22323
+ const timeBalanceRatio = durations.length > 1 ? Math.max(...durations) / Math.min(...durations) : 1;
22324
+ const finalRecord = {
22325
+ ...record2,
22326
+ overall_success: overallSuccess,
22327
+ total_duration_ms: totalDurationMs,
22328
+ total_errors: totalErrors,
22329
+ file_overlap_count: fileOverlapCount,
22330
+ scope_accuracy: scopeAccuracy,
22331
+ time_balance_ratio: timeBalanceRatio
22332
+ };
22333
+ updateEvalRecord(params.projectPath, params.epicId, finalRecord);
22334
+ inProgressRecords.delete(params.epicId);
22335
+ return finalRecord;
22336
+ }
22337
+ function captureHumanFeedback(params) {
22338
+ updateEvalRecord(params.projectPath, params.epicId, {
22339
+ human_accepted: params.accepted,
22340
+ human_modified: params.modified,
22341
+ human_notes: params.notes
22342
+ });
22343
+ }
22344
+ function exportForEvalite(projectPath) {
22345
+ const records = readEvalRecords(projectPath);
22346
+ return records.filter((r) => r.outcomes && r.outcomes.length > 0).map((record2) => ({
22347
+ input: {
22348
+ task: record2.task,
22349
+ context: record2.context
22350
+ },
22351
+ expected: {
22352
+ minSubtasks: 2,
22353
+ subtaskCount: record2.subtask_count,
22354
+ requiredFiles: record2.subtasks.flatMap((s) => s.files),
22355
+ overallSuccess: record2.overall_success
22356
+ },
22357
+ actual: record2
22358
+ }));
22359
+ }
22360
+ function getEvalDataStats(projectPath) {
22361
+ const records = readEvalRecords(projectPath);
22362
+ const complete = records.filter((r) => r.outcomes && r.outcomes.length > 0);
22363
+ if (complete.length === 0) {
22364
+ return {
22365
+ totalRecords: records.length,
22366
+ completeRecords: 0,
22367
+ successRate: 0,
22368
+ avgSubtasks: 0,
22369
+ avgDurationMs: 0,
22370
+ avgScopeAccuracy: 0,
22371
+ avgTimeBalance: 0
22372
+ };
22373
+ }
22374
+ const successCount = complete.filter((r) => r.overall_success).length;
22375
+ const avgSubtasks = complete.reduce((sum, r) => sum + (r.outcomes?.length || 0), 0) / complete.length;
22376
+ const avgDurationMs = complete.reduce((sum, r) => sum + (r.total_duration_ms || 0), 0) / complete.length;
22377
+ const avgScopeAccuracy = complete.reduce((sum, r) => sum + (r.scope_accuracy || 1), 0) / complete.length;
22378
+ const avgTimeBalance = complete.reduce((sum, r) => sum + (r.time_balance_ratio || 1), 0) / complete.length;
22379
+ return {
22380
+ totalRecords: records.length,
22381
+ completeRecords: complete.length,
22382
+ successRate: successCount / complete.length,
22383
+ avgSubtasks,
22384
+ avgDurationMs,
22385
+ avgScopeAccuracy,
22386
+ avgTimeBalance
22387
+ };
22388
+ }
22389
+ function getSessionDir() {
22390
+ return path.join(os.homedir(), ".config", "swarm-tools", "sessions");
22391
+ }
22392
+ function getSessionPath(sessionId) {
22393
+ return path.join(getSessionDir(), `${sessionId}.jsonl`);
22394
+ }
22395
+ function ensureSessionDir() {
22396
+ const sessionDir = getSessionDir();
22397
+ if (!fs.existsSync(sessionDir)) {
22398
+ fs.mkdirSync(sessionDir, { recursive: true });
22399
+ }
22400
+ }
22401
+ function captureCoordinatorEvent(event) {
22402
+ CoordinatorEventSchema.parse(event);
22403
+ ensureSessionDir();
22404
+ const sessionPath = getSessionPath(event.session_id);
22405
+ const line = `${JSON.stringify(event)}
22406
+ `;
22407
+ fs.appendFileSync(sessionPath, line, "utf-8");
22408
+ }
22409
+ function readSessionEvents(sessionId) {
22410
+ const sessionPath = getSessionPath(sessionId);
22411
+ if (!fs.existsSync(sessionPath)) {
22412
+ return [];
22413
+ }
22414
+ const content = fs.readFileSync(sessionPath, "utf-8");
22415
+ const lines = content.trim().split(`
22416
+ `).filter(Boolean);
22417
+ return lines.map((line) => {
22418
+ const parsed = JSON.parse(line);
22419
+ return CoordinatorEventSchema.parse(parsed);
22420
+ });
22421
+ }
22422
+ function saveSession(params) {
22423
+ const events = readSessionEvents(params.session_id);
22424
+ if (events.length === 0) {
22425
+ return null;
22426
+ }
22427
+ const timestamps = events.map((e) => new Date(e.timestamp).getTime());
22428
+ const startTime = new Date(Math.min(...timestamps)).toISOString();
22429
+ const endTime = new Date(Math.max(...timestamps)).toISOString();
22430
+ const session = {
22431
+ session_id: params.session_id,
22432
+ epic_id: params.epic_id,
22433
+ start_time: startTime,
22434
+ end_time: endTime,
22435
+ events
22436
+ };
22437
+ return session;
22438
+ }
22439
+ var SubtaskOutcomeSchema, EvalRecordSchema, CoordinatorEventSchema, CoordinatorSessionSchema, DEFAULT_EVAL_DATA_PATH = ".opencode/eval-data.jsonl", inProgressRecords;
22440
+ var init_eval_capture = __esm(() => {
22441
+ init_zod();
22442
+ SubtaskOutcomeSchema = exports_external.object({
22443
+ bead_id: exports_external.string(),
22444
+ title: exports_external.string(),
22445
+ planned_files: exports_external.array(exports_external.string()),
22446
+ actual_files: exports_external.array(exports_external.string()),
22447
+ duration_ms: exports_external.number().int().min(0),
22448
+ error_count: exports_external.number().int().min(0),
22449
+ retry_count: exports_external.number().int().min(0),
22450
+ success: exports_external.boolean(),
22451
+ failure_mode: exports_external.string().optional()
22452
+ });
22453
+ EvalRecordSchema = exports_external.object({
22454
+ id: exports_external.string(),
22455
+ timestamp: exports_external.string(),
22456
+ project_path: exports_external.string(),
22457
+ task: exports_external.string(),
22458
+ context: exports_external.string().optional(),
22459
+ strategy: exports_external.enum(["file-based", "feature-based", "risk-based", "auto"]),
22460
+ subtask_count: exports_external.number().int().min(1),
22461
+ epic_title: exports_external.string(),
22462
+ epic_description: exports_external.string().optional(),
22463
+ subtasks: exports_external.array(exports_external.object({
22464
+ title: exports_external.string(),
22465
+ description: exports_external.string().optional(),
22466
+ files: exports_external.array(exports_external.string()),
22467
+ dependencies: exports_external.array(exports_external.number()).optional(),
22468
+ estimated_complexity: exports_external.number().int().min(1).max(5).optional()
22469
+ })),
22470
+ outcomes: exports_external.array(SubtaskOutcomeSchema).optional(),
22471
+ overall_success: exports_external.boolean().optional(),
22472
+ total_duration_ms: exports_external.number().int().min(0).optional(),
22473
+ total_errors: exports_external.number().int().min(0).optional(),
22474
+ human_accepted: exports_external.boolean().optional(),
22475
+ human_modified: exports_external.boolean().optional(),
22476
+ human_notes: exports_external.string().optional(),
22477
+ file_overlap_count: exports_external.number().int().min(0).optional(),
22478
+ scope_accuracy: exports_external.number().min(0).max(2).optional(),
22479
+ time_balance_ratio: exports_external.number().min(1).optional()
22480
+ });
22481
+ CoordinatorEventSchema = exports_external.discriminatedUnion("event_type", [
22482
+ exports_external.object({
22483
+ session_id: exports_external.string(),
22484
+ epic_id: exports_external.string(),
22485
+ timestamp: exports_external.string(),
22486
+ event_type: exports_external.literal("DECISION"),
22487
+ decision_type: exports_external.enum([
22488
+ "strategy_selected",
22489
+ "worker_spawned",
22490
+ "review_completed",
22491
+ "decomposition_complete"
22492
+ ]),
22493
+ payload: exports_external.any()
22494
+ }),
22495
+ exports_external.object({
22496
+ session_id: exports_external.string(),
22497
+ epic_id: exports_external.string(),
22498
+ timestamp: exports_external.string(),
22499
+ event_type: exports_external.literal("VIOLATION"),
22500
+ violation_type: exports_external.enum([
22501
+ "coordinator_edited_file",
22502
+ "coordinator_ran_tests",
22503
+ "coordinator_reserved_files",
22504
+ "no_worker_spawned"
22505
+ ]),
22506
+ payload: exports_external.any()
22507
+ }),
22508
+ exports_external.object({
22509
+ session_id: exports_external.string(),
22510
+ epic_id: exports_external.string(),
22511
+ timestamp: exports_external.string(),
22512
+ event_type: exports_external.literal("OUTCOME"),
22513
+ outcome_type: exports_external.enum([
22514
+ "subtask_success",
22515
+ "subtask_retry",
22516
+ "subtask_failed",
22517
+ "epic_complete"
22518
+ ]),
22519
+ payload: exports_external.any()
22520
+ })
22521
+ ]);
22522
+ CoordinatorSessionSchema = exports_external.object({
22523
+ session_id: exports_external.string(),
22524
+ epic_id: exports_external.string(),
22525
+ start_time: exports_external.string(),
22526
+ end_time: exports_external.string().optional(),
22527
+ events: exports_external.array(CoordinatorEventSchema)
22528
+ });
22529
+ inProgressRecords = new Map;
22530
+ });
22531
+
22181
22532
  // src/learning.ts
22182
22533
  var exports_learning = {};
22183
22534
  __export(exports_learning, {
@@ -39409,6 +39760,71 @@ var hive_ready = tool({
39409
39760
  }
39410
39761
  }
39411
39762
  });
39763
+ var hive_cells = tool({
39764
+ description: `Query cells from the hive database with flexible filtering.
39765
+
39766
+ USE THIS TOOL TO:
39767
+ - List all open cells: hive_cells()
39768
+ - Find cells by status: hive_cells({ status: "in_progress" })
39769
+ - Find cells by type: hive_cells({ type: "bug" })
39770
+ - Get a specific cell by partial ID: hive_cells({ id: "mjkmd" })
39771
+ - Get the next ready (unblocked) cell: hive_cells({ ready: true })
39772
+ - Combine filters: hive_cells({ status: "open", type: "task" })
39773
+
39774
+ RETURNS: Array of cells with id, title, status, priority, type, parent_id, created_at, updated_at
39775
+
39776
+ PREFER THIS OVER hive_query when you need to:
39777
+ - See what work is available
39778
+ - Check status of multiple cells
39779
+ - Find cells matching criteria
39780
+ - Look up a cell by partial ID`,
39781
+ args: {
39782
+ id: tool.schema.string().optional().describe("Partial or full cell ID to look up"),
39783
+ status: tool.schema.enum(["open", "in_progress", "blocked", "closed"]).optional().describe("Filter by status"),
39784
+ type: tool.schema.enum(["task", "bug", "feature", "epic", "chore"]).optional().describe("Filter by type"),
39785
+ ready: tool.schema.boolean().optional().describe("If true, return only the next unblocked cell"),
39786
+ limit: tool.schema.number().optional().describe("Max cells to return (default 20)")
39787
+ },
39788
+ async execute(args, ctx) {
39789
+ const projectKey = getHiveWorkingDirectory();
39790
+ const adapter = await getHiveAdapter(projectKey);
39791
+ try {
39792
+ if (args.id) {
39793
+ const fullId = await resolvePartialId(adapter, projectKey, args.id) || args.id;
39794
+ const cell = await adapter.getCell(projectKey, fullId);
39795
+ if (!cell) {
39796
+ throw new HiveError(`No cell found matching ID '${args.id}'`, "hive_cells");
39797
+ }
39798
+ const formatted2 = formatCellForOutput(cell);
39799
+ return JSON.stringify([formatted2], null, 2);
39800
+ }
39801
+ if (args.ready) {
39802
+ const ready = await adapter.getNextReadyCell(projectKey);
39803
+ if (!ready) {
39804
+ return JSON.stringify([], null, 2);
39805
+ }
39806
+ const formatted2 = formatCellForOutput(ready);
39807
+ return JSON.stringify([formatted2], null, 2);
39808
+ }
39809
+ const cells = await adapter.queryCells(projectKey, {
39810
+ status: args.status,
39811
+ type: args.type,
39812
+ limit: args.limit || 20
39813
+ });
39814
+ const formatted = cells.map((c) => formatCellForOutput(c));
39815
+ return JSON.stringify(formatted, null, 2);
39816
+ } catch (error45) {
39817
+ const message = error45 instanceof Error ? error45.message : String(error45);
39818
+ if (message.includes("Ambiguous hash")) {
39819
+ throw new HiveError(`Ambiguous ID '${args.id}': multiple cells match. Please provide more characters.`, "hive_cells");
39820
+ }
39821
+ if (message.includes("Bead not found") || message.includes("Cell not found")) {
39822
+ throw new HiveError(`No cell found matching ID '${args.id || "unknown"}'`, "hive_cells");
39823
+ }
39824
+ throw new HiveError(`Failed to query cells: ${message}`, "hive_cells");
39825
+ }
39826
+ }
39827
+ });
39412
39828
  var hive_sync = tool({
39413
39829
  description: "Sync hive to git and push (MANDATORY at session end)",
39414
39830
  args: {
@@ -39550,6 +39966,7 @@ var hiveTools = {
39550
39966
  hive_close,
39551
39967
  hive_start,
39552
39968
  hive_ready,
39969
+ hive_cells,
39553
39970
  hive_sync,
39554
39971
  hive_link_thread
39555
39972
  };
@@ -41846,122 +42263,7 @@ init_swarm_strategies();
41846
42263
  init_dist();
41847
42264
  init_zod();
41848
42265
  init_swarm_strategies();
41849
-
41850
- // src/eval-capture.ts
41851
- init_zod();
41852
- import * as fs from "node:fs";
41853
- import * as os from "node:os";
41854
- import * as path from "node:path";
41855
- var SubtaskOutcomeSchema = exports_external.object({
41856
- bead_id: exports_external.string(),
41857
- title: exports_external.string(),
41858
- planned_files: exports_external.array(exports_external.string()),
41859
- actual_files: exports_external.array(exports_external.string()),
41860
- duration_ms: exports_external.number().int().min(0),
41861
- error_count: exports_external.number().int().min(0),
41862
- retry_count: exports_external.number().int().min(0),
41863
- success: exports_external.boolean(),
41864
- failure_mode: exports_external.string().optional()
41865
- });
41866
- var EvalRecordSchema = exports_external.object({
41867
- id: exports_external.string(),
41868
- timestamp: exports_external.string(),
41869
- project_path: exports_external.string(),
41870
- task: exports_external.string(),
41871
- context: exports_external.string().optional(),
41872
- strategy: exports_external.enum(["file-based", "feature-based", "risk-based", "auto"]),
41873
- subtask_count: exports_external.number().int().min(1),
41874
- epic_title: exports_external.string(),
41875
- epic_description: exports_external.string().optional(),
41876
- subtasks: exports_external.array(exports_external.object({
41877
- title: exports_external.string(),
41878
- description: exports_external.string().optional(),
41879
- files: exports_external.array(exports_external.string()),
41880
- dependencies: exports_external.array(exports_external.number()).optional(),
41881
- estimated_complexity: exports_external.number().int().min(1).max(5).optional()
41882
- })),
41883
- outcomes: exports_external.array(SubtaskOutcomeSchema).optional(),
41884
- overall_success: exports_external.boolean().optional(),
41885
- total_duration_ms: exports_external.number().int().min(0).optional(),
41886
- total_errors: exports_external.number().int().min(0).optional(),
41887
- human_accepted: exports_external.boolean().optional(),
41888
- human_modified: exports_external.boolean().optional(),
41889
- human_notes: exports_external.string().optional(),
41890
- file_overlap_count: exports_external.number().int().min(0).optional(),
41891
- scope_accuracy: exports_external.number().min(0).max(2).optional(),
41892
- time_balance_ratio: exports_external.number().min(1).optional()
41893
- });
41894
- var CoordinatorEventSchema = exports_external.discriminatedUnion("event_type", [
41895
- exports_external.object({
41896
- session_id: exports_external.string(),
41897
- epic_id: exports_external.string(),
41898
- timestamp: exports_external.string(),
41899
- event_type: exports_external.literal("DECISION"),
41900
- decision_type: exports_external.enum([
41901
- "strategy_selected",
41902
- "worker_spawned",
41903
- "review_completed",
41904
- "decomposition_complete"
41905
- ]),
41906
- payload: exports_external.any()
41907
- }),
41908
- exports_external.object({
41909
- session_id: exports_external.string(),
41910
- epic_id: exports_external.string(),
41911
- timestamp: exports_external.string(),
41912
- event_type: exports_external.literal("VIOLATION"),
41913
- violation_type: exports_external.enum([
41914
- "coordinator_edited_file",
41915
- "coordinator_ran_tests",
41916
- "coordinator_reserved_files",
41917
- "no_worker_spawned"
41918
- ]),
41919
- payload: exports_external.any()
41920
- }),
41921
- exports_external.object({
41922
- session_id: exports_external.string(),
41923
- epic_id: exports_external.string(),
41924
- timestamp: exports_external.string(),
41925
- event_type: exports_external.literal("OUTCOME"),
41926
- outcome_type: exports_external.enum([
41927
- "subtask_success",
41928
- "subtask_retry",
41929
- "subtask_failed",
41930
- "epic_complete"
41931
- ]),
41932
- payload: exports_external.any()
41933
- })
41934
- ]);
41935
- var CoordinatorSessionSchema = exports_external.object({
41936
- session_id: exports_external.string(),
41937
- epic_id: exports_external.string(),
41938
- start_time: exports_external.string(),
41939
- end_time: exports_external.string().optional(),
41940
- events: exports_external.array(CoordinatorEventSchema)
41941
- });
41942
- var inProgressRecords = new Map;
41943
- function getSessionDir() {
41944
- return path.join(os.homedir(), ".config", "swarm-tools", "sessions");
41945
- }
41946
- function getSessionPath(sessionId) {
41947
- return path.join(getSessionDir(), `${sessionId}.jsonl`);
41948
- }
41949
- function ensureSessionDir() {
41950
- const sessionDir = getSessionDir();
41951
- if (!fs.existsSync(sessionDir)) {
41952
- fs.mkdirSync(sessionDir, { recursive: true });
41953
- }
41954
- }
41955
- function captureCoordinatorEvent(event) {
41956
- CoordinatorEventSchema.parse(event);
41957
- ensureSessionDir();
41958
- const sessionPath = getSessionPath(event.session_id);
41959
- const line = `${JSON.stringify(event)}
41960
- `;
41961
- fs.appendFileSync(sessionPath, line, "utf-8");
41962
- }
41963
-
41964
- // src/swarm-decompose.ts
42266
+ init_eval_capture();
41965
42267
  var DECOMPOSITION_PROMPT = `You are decomposing a task into parallelizable subtasks for a swarm of agents.
41966
42268
 
41967
42269
  ## Task
@@ -42279,9 +42581,14 @@ ${fullContext}` : `## Additional Context
42279
42581
  }
42280
42582
  });
42281
42583
  var swarm_validate_decomposition = tool({
42282
- description: "Validate a decomposition response against CellTreeSchema",
42584
+ description: "Validate a decomposition response against CellTreeSchema and capture for eval",
42283
42585
  args: {
42284
- response: tool.schema.string().describe("JSON response from agent (CellTree format)")
42586
+ response: tool.schema.string().describe("JSON response from agent (CellTree format)"),
42587
+ project_path: tool.schema.string().optional().describe("Project path for eval capture"),
42588
+ task: tool.schema.string().optional().describe("Original task description for eval capture"),
42589
+ context: tool.schema.string().optional().describe("Context provided for decomposition"),
42590
+ strategy: tool.schema.enum(["file-based", "feature-based", "risk-based", "auto"]).optional().describe("Decomposition strategy used"),
42591
+ epic_id: tool.schema.string().optional().describe("Epic ID for eval capture")
42285
42592
  },
42286
42593
  async execute(args) {
42287
42594
  try {
@@ -42315,6 +42622,29 @@ var swarm_validate_decomposition = tool({
42315
42622
  }
42316
42623
  }
42317
42624
  const instructionConflicts = detectInstructionConflicts(validated.subtasks);
42625
+ if (args.project_path && args.task && args.strategy && args.epic_id) {
42626
+ try {
42627
+ const { captureDecomposition: captureDecomposition2 } = await Promise.resolve().then(() => (init_eval_capture(), exports_eval_capture));
42628
+ captureDecomposition2({
42629
+ epicId: args.epic_id,
42630
+ projectPath: args.project_path,
42631
+ task: args.task,
42632
+ context: args.context,
42633
+ strategy: args.strategy,
42634
+ epicTitle: validated.epic.title,
42635
+ epicDescription: validated.epic.description,
42636
+ subtasks: validated.subtasks.map((s) => ({
42637
+ title: s.title,
42638
+ description: s.description,
42639
+ files: s.files,
42640
+ dependencies: s.dependencies,
42641
+ estimated_complexity: s.estimated_complexity
42642
+ }))
42643
+ });
42644
+ } catch (error45) {
42645
+ console.warn("[swarm_validate_decomposition] Failed to capture decomposition:", error45);
42646
+ }
42647
+ }
42318
42648
  return JSON.stringify({
42319
42649
  valid: true,
42320
42650
  cell_tree: validated,
@@ -44481,6 +44811,7 @@ var worktreeTools = {
44481
44811
  init_dist();
44482
44812
  init_zod();
44483
44813
  import { sendSwarmMessage as sendSwarmMessage2 } from "swarm-mail";
44814
+ init_eval_capture();
44484
44815
  var ReviewIssueSchema = exports_external.object({
44485
44816
  file: exports_external.string(),
44486
44817
  line: exports_external.number().optional(),
@@ -44837,6 +45168,7 @@ var reviewTools = {
44837
45168
  };
44838
45169
 
44839
45170
  // src/swarm-orchestrate.ts
45171
+ init_eval_capture();
44840
45172
  function generateWorkerHandoff(params) {
44841
45173
  const handoff = {
44842
45174
  contract: {
@@ -46425,6 +46757,7 @@ var orchestrateTools = {
46425
46757
  };
46426
46758
 
46427
46759
  // src/swarm-prompts.ts
46760
+ init_eval_capture();
46428
46761
  var STRATEGY_DECOMPOSITION_PROMPT2 = `You are decomposing a task into parallelizable subtasks for a swarm of agents.
46429
46762
 
46430
46763
  ## Task
@@ -63171,6 +63504,7 @@ function createMetrics(result, toolName) {
63171
63504
  }
63172
63505
 
63173
63506
  // src/planning-guardrails.ts
63507
+ init_eval_capture();
63174
63508
  var FILE_MODIFICATION_PATTERNS = [
63175
63509
  /\bimplement\b/i,
63176
63510
  /\bcreate\b.*\.(ts|js|tsx|jsx|py|rs|go|java|rb|swift|kt)/i,
@@ -64668,6 +65002,7 @@ export {
64668
65002
  hive_create_epic,
64669
65003
  hive_create,
64670
65004
  hive_close,
65005
+ hive_cells,
64671
65006
  hiveTools,
64672
65007
  guardrailOutput,
64673
65008
  groupByTransition,