opencode-swarm-plugin 0.26.0 → 0.27.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.
Files changed (78) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +37 -0
  3. package/README.md +43 -46
  4. package/bin/swarm.ts +8 -8
  5. package/dist/compaction-hook.d.ts +57 -0
  6. package/dist/compaction-hook.d.ts.map +1 -0
  7. package/dist/hive.d.ts +741 -0
  8. package/dist/hive.d.ts.map +1 -0
  9. package/dist/index.d.ts +139 -23
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1418 -387
  12. package/dist/learning.d.ts +9 -9
  13. package/dist/plugin.js +1240 -386
  14. package/dist/schemas/cell-events.d.ts +1352 -0
  15. package/dist/schemas/{bead-events.d.ts.map → cell-events.d.ts.map} +1 -1
  16. package/dist/schemas/{bead.d.ts → cell.d.ts} +173 -29
  17. package/dist/schemas/cell.d.ts.map +1 -0
  18. package/dist/schemas/index.d.ts +11 -7
  19. package/dist/schemas/index.d.ts.map +1 -1
  20. package/dist/structured.d.ts +17 -7
  21. package/dist/structured.d.ts.map +1 -1
  22. package/dist/swarm-decompose.d.ts +5 -5
  23. package/dist/swarm-orchestrate.d.ts +16 -2
  24. package/dist/swarm-orchestrate.d.ts.map +1 -1
  25. package/dist/swarm-prompts.d.ts +9 -9
  26. package/dist/swarm-prompts.d.ts.map +1 -1
  27. package/dist/swarm-review.d.ts +210 -0
  28. package/dist/swarm-review.d.ts.map +1 -0
  29. package/dist/swarm-worktree.d.ts +185 -0
  30. package/dist/swarm-worktree.d.ts.map +1 -0
  31. package/dist/swarm.d.ts +7 -0
  32. package/dist/swarm.d.ts.map +1 -1
  33. package/dist/tool-availability.d.ts +3 -2
  34. package/dist/tool-availability.d.ts.map +1 -1
  35. package/docs/analysis-socratic-planner-pattern.md +1 -1
  36. package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +168 -0
  37. package/docs/testing/context-recovery-test.md +2 -2
  38. package/evals/README.md +2 -2
  39. package/evals/scorers/index.ts +7 -7
  40. package/examples/commands/swarm.md +21 -23
  41. package/examples/plugin-wrapper-template.ts +310 -44
  42. package/examples/skills/{beads-workflow → hive-workflow}/SKILL.md +40 -40
  43. package/examples/skills/swarm-coordination/SKILL.md +1 -1
  44. package/global-skills/swarm-coordination/SKILL.md +14 -14
  45. package/global-skills/swarm-coordination/references/coordinator-patterns.md +3 -3
  46. package/package.json +2 -2
  47. package/src/compaction-hook.ts +161 -0
  48. package/src/{beads.integration.test.ts → hive.integration.test.ts} +92 -80
  49. package/src/hive.ts +1017 -0
  50. package/src/index.ts +57 -20
  51. package/src/learning.ts +9 -9
  52. package/src/output-guardrails.test.ts +4 -4
  53. package/src/output-guardrails.ts +9 -9
  54. package/src/planning-guardrails.test.ts +1 -1
  55. package/src/planning-guardrails.ts +1 -1
  56. package/src/schemas/{bead-events.test.ts → cell-events.test.ts} +83 -77
  57. package/src/schemas/cell-events.ts +807 -0
  58. package/src/schemas/{bead.ts → cell.ts} +95 -41
  59. package/src/schemas/evaluation.ts +1 -1
  60. package/src/schemas/index.ts +90 -18
  61. package/src/schemas/swarm-context.ts +2 -2
  62. package/src/structured.test.ts +15 -15
  63. package/src/structured.ts +18 -11
  64. package/src/swarm-decompose.ts +23 -23
  65. package/src/swarm-orchestrate.ts +135 -21
  66. package/src/swarm-prompts.ts +43 -43
  67. package/src/swarm-review.test.ts +702 -0
  68. package/src/swarm-review.ts +696 -0
  69. package/src/swarm-worktree.test.ts +501 -0
  70. package/src/swarm-worktree.ts +575 -0
  71. package/src/swarm.integration.test.ts +12 -12
  72. package/src/tool-availability.ts +36 -3
  73. package/dist/beads.d.ts +0 -383
  74. package/dist/beads.d.ts.map +0 -1
  75. package/dist/schemas/bead-events.d.ts +0 -698
  76. package/dist/schemas/bead.d.ts.map +0 -1
  77. package/src/beads.ts +0 -800
  78. package/src/schemas/bead-events.ts +0 -583
@@ -0,0 +1,807 @@
1
+ /**
2
+ * Event Types for Cells Event Sourcing
3
+ *
4
+ * These events form an audit trail for all cell operations.
5
+ * Events are NOT replayed for state reconstruction (cells uses hybrid CRUD + audit trail).
6
+ * Events enable:
7
+ * - Full audit history
8
+ * - Debugging distributed swarm operations
9
+ * - Learning from cell lifecycle patterns
10
+ * - Integration with swarm-mail coordination
11
+ *
12
+ * Design notes:
13
+ * - 75% reusable infrastructure from swarm-mail
14
+ * - Events stay local (PGLite/SQLite), not written to JSONL
15
+ * - JSONL export happens from projection snapshots (proven git merge driver)
16
+ * - Follows same BaseEventSchema pattern as swarm-mail
17
+ */
18
+ import { z } from "zod";
19
+ import {
20
+ CellDependencySchema,
21
+ CellStatusSchema,
22
+ CellTypeSchema,
23
+ } from "./cell.js";
24
+
25
+ // ============================================================================
26
+ // Base Event Schema (mirrors swarm-mail pattern)
27
+ // ============================================================================
28
+
29
+ /**
30
+ * Base fields present on all cell events
31
+ */
32
+ export const BaseCellEventSchema = z.object({
33
+ /** Auto-generated event ID */
34
+ id: z.number().optional(),
35
+ /** Event type discriminator */
36
+ type: z.string(),
37
+ /** Project key (usually absolute path) */
38
+ project_key: z.string(),
39
+ /** Timestamp when event occurred */
40
+ timestamp: z.number(), // Unix ms
41
+ /** Sequence number for ordering */
42
+ sequence: z.number().optional(),
43
+ });
44
+
45
+ // ============================================================================
46
+ // Issue Lifecycle Events
47
+ // ============================================================================
48
+
49
+ /**
50
+ * Cell created
51
+ *
52
+ * Emitted when:
53
+ * - User calls `hive create`
54
+ * - Swarm epic decomposition creates subtasks
55
+ * - Agent spawns new cells during work
56
+ */
57
+ export const CellCreatedEventSchema = BaseCellEventSchema.extend({
58
+ type: z.literal("cell_created"),
59
+ cell_id: z.string(),
60
+ title: z.string(),
61
+ description: z.string().optional(),
62
+ issue_type: CellTypeSchema,
63
+ priority: z.number().int().min(0).max(3),
64
+ parent_id: z.string().optional(),
65
+ /** Agent/user who created the cell */
66
+ created_by: z.string().optional(),
67
+ /** Metadata for tracking (e.g., epic context, swarm strategy) */
68
+ metadata: z.record(z.string(), z.unknown()).optional(),
69
+ });
70
+
71
+ /**
72
+ * Cell updated (generic field changes)
73
+ *
74
+ * Emitted for non-status field updates: title, description, priority
75
+ */
76
+ export const CellUpdatedEventSchema = BaseCellEventSchema.extend({
77
+ type: z.literal("cell_updated"),
78
+ cell_id: z.string(),
79
+ /** Agent/user who made the update */
80
+ updated_by: z.string().optional(),
81
+ /** Changed fields with old and new values */
82
+ changes: z.object({
83
+ title: z
84
+ .object({
85
+ old: z.string(),
86
+ new: z.string(),
87
+ })
88
+ .optional(),
89
+ description: z
90
+ .object({
91
+ old: z.string(),
92
+ new: z.string(),
93
+ })
94
+ .optional(),
95
+ priority: z
96
+ .object({
97
+ old: z.number(),
98
+ new: z.number(),
99
+ })
100
+ .optional(),
101
+ }),
102
+ });
103
+
104
+ /**
105
+ * Cell status changed
106
+ *
107
+ * Separate event for status transitions to enable workflow analysis.
108
+ * Tracks state machine: open → in_progress → (blocked | closed)
109
+ */
110
+ export const CellStatusChangedEventSchema = BaseCellEventSchema.extend({
111
+ type: z.literal("cell_status_changed"),
112
+ cell_id: z.string(),
113
+ from_status: CellStatusSchema,
114
+ to_status: CellStatusSchema,
115
+ /** Agent/user who changed status */
116
+ changed_by: z.string().optional(),
117
+ /** Optional reason (required for closed status) */
118
+ reason: z.string().optional(),
119
+ });
120
+
121
+ /**
122
+ * Cell closed
123
+ *
124
+ * Explicit close event (subset of status_changed for convenience).
125
+ * Includes closure reason for audit trail.
126
+ */
127
+ export const CellClosedEventSchema = BaseCellEventSchema.extend({
128
+ type: z.literal("cell_closed"),
129
+ cell_id: z.string(),
130
+ reason: z.string(),
131
+ /** Agent/user who closed */
132
+ closed_by: z.string().optional(),
133
+ /** Files touched during work (from swarm completion) */
134
+ files_touched: z.array(z.string()).optional(),
135
+ /** Duration in ms (if tracked by agent) */
136
+ duration_ms: z.number().optional(),
137
+ });
138
+
139
+ /**
140
+ * Cell reopened
141
+ *
142
+ * Emitted when closed cell is reopened.
143
+ */
144
+ export const CellReopenedEventSchema = BaseCellEventSchema.extend({
145
+ type: z.literal("cell_reopened"),
146
+ cell_id: z.string(),
147
+ reason: z.string().optional(),
148
+ /** Agent/user who reopened */
149
+ reopened_by: z.string().optional(),
150
+ });
151
+
152
+ /**
153
+ * Cell deleted
154
+ *
155
+ * Hard delete event (rare - cells are usually closed, not deleted).
156
+ * Useful for cleaning up spurious/duplicate cells.
157
+ */
158
+ export const CellDeletedEventSchema = BaseCellEventSchema.extend({
159
+ type: z.literal("cell_deleted"),
160
+ cell_id: z.string(),
161
+ reason: z.string().optional(),
162
+ /** Agent/user who deleted */
163
+ deleted_by: z.string().optional(),
164
+ });
165
+
166
+ // ============================================================================
167
+ // Dependency Events
168
+ // ============================================================================
169
+
170
+ /**
171
+ * Dependency added between cells
172
+ *
173
+ * Supports 4 relationship types:
174
+ * - blocks: This cell blocks the target
175
+ * - blocked-by: This cell is blocked by the target
176
+ * - related: Informational link
177
+ * - discovered-from: Cell spawned from investigation of target
178
+ */
179
+ export const CellDependencyAddedEventSchema = BaseCellEventSchema.extend({
180
+ type: z.literal("cell_dependency_added"),
181
+ cell_id: z.string(),
182
+ /** Dependency relationship */
183
+ dependency: CellDependencySchema,
184
+ /** Agent/user who added dependency */
185
+ added_by: z.string().optional(),
186
+ /** Optional reason (e.g., "needs auth service before OAuth implementation") */
187
+ reason: z.string().optional(),
188
+ });
189
+
190
+ /**
191
+ * Dependency removed
192
+ *
193
+ * Emitted when dependency is no longer relevant or was added in error.
194
+ */
195
+ export const CellDependencyRemovedEventSchema = BaseCellEventSchema.extend({
196
+ type: z.literal("cell_dependency_removed"),
197
+ cell_id: z.string(),
198
+ /** Dependency being removed */
199
+ dependency: CellDependencySchema,
200
+ /** Agent/user who removed */
201
+ removed_by: z.string().optional(),
202
+ reason: z.string().optional(),
203
+ });
204
+
205
+ // ============================================================================
206
+ // Label Events
207
+ // ============================================================================
208
+
209
+ /**
210
+ * Label added to cell
211
+ *
212
+ * Labels are string tags for categorization/filtering.
213
+ * Common labels: "p0", "needs-review", "blocked-external", "tech-debt"
214
+ */
215
+ export const CellLabelAddedEventSchema = BaseCellEventSchema.extend({
216
+ type: z.literal("cell_label_added"),
217
+ cell_id: z.string(),
218
+ label: z.string(),
219
+ /** Agent/user who added label */
220
+ added_by: z.string().optional(),
221
+ });
222
+
223
+ /**
224
+ * Label removed from cell
225
+ */
226
+ export const CellLabelRemovedEventSchema = BaseCellEventSchema.extend({
227
+ type: z.literal("cell_label_removed"),
228
+ cell_id: z.string(),
229
+ label: z.string(),
230
+ /** Agent/user who removed label */
231
+ removed_by: z.string().optional(),
232
+ });
233
+
234
+ // ============================================================================
235
+ // Comment Events
236
+ // ============================================================================
237
+
238
+ /**
239
+ * Comment added to cell
240
+ *
241
+ * Supports agent-to-agent communication, human notes, and progress updates.
242
+ */
243
+ export const CellCommentAddedEventSchema = BaseCellEventSchema.extend({
244
+ type: z.literal("cell_comment_added"),
245
+ cell_id: z.string(),
246
+ /** Auto-generated comment ID */
247
+ comment_id: z.number().optional(),
248
+ author: z.string(),
249
+ body: z.string(),
250
+ /** Optional parent comment ID for threading */
251
+ parent_comment_id: z.number().optional(),
252
+ /** Comment metadata (e.g., attachments, mentions) */
253
+ metadata: z.record(z.string(), z.unknown()).optional(),
254
+ });
255
+
256
+ /**
257
+ * Comment updated (edit)
258
+ */
259
+ export const CellCommentUpdatedEventSchema = BaseCellEventSchema.extend({
260
+ type: z.literal("cell_comment_updated"),
261
+ cell_id: z.string(),
262
+ comment_id: z.number(),
263
+ old_body: z.string(),
264
+ new_body: z.string(),
265
+ updated_by: z.string(),
266
+ });
267
+
268
+ /**
269
+ * Comment deleted
270
+ */
271
+ export const CellCommentDeletedEventSchema = BaseCellEventSchema.extend({
272
+ type: z.literal("cell_comment_deleted"),
273
+ cell_id: z.string(),
274
+ comment_id: z.number(),
275
+ deleted_by: z.string(),
276
+ reason: z.string().optional(),
277
+ });
278
+
279
+ // ============================================================================
280
+ // Epic Events
281
+ // ============================================================================
282
+
283
+ /**
284
+ * Child cell added to epic
285
+ *
286
+ * Emitted when:
287
+ * - Epic created with subtasks (batch event for each child)
288
+ * - User manually adds child via `hive add-child`
289
+ * - Agent spawns additional subtask during work
290
+ */
291
+ export const CellEpicChildAddedEventSchema = BaseCellEventSchema.extend({
292
+ type: z.literal("cell_epic_child_added"),
293
+ /** Epic ID */
294
+ cell_id: z.string(),
295
+ /** Child cell ID */
296
+ child_id: z.string(),
297
+ /** Optional index for ordering */
298
+ child_index: z.number().optional(),
299
+ added_by: z.string().optional(),
300
+ });
301
+
302
+ /**
303
+ * Child cell removed from epic
304
+ *
305
+ * Rare - usually happens when subtask is merged/consolidated.
306
+ */
307
+ export const CellEpicChildRemovedEventSchema = BaseCellEventSchema.extend({
308
+ type: z.literal("cell_epic_child_removed"),
309
+ /** Epic ID */
310
+ cell_id: z.string(),
311
+ /** Child cell ID */
312
+ child_id: z.string(),
313
+ removed_by: z.string().optional(),
314
+ reason: z.string().optional(),
315
+ });
316
+
317
+ /**
318
+ * Epic eligible for closure
319
+ *
320
+ * Emitted when all child cells are closed.
321
+ * Triggers coordinator review for epic closure.
322
+ */
323
+ export const CellEpicClosureEligibleEventSchema = BaseCellEventSchema.extend({
324
+ type: z.literal("cell_epic_closure_eligible"),
325
+ cell_id: z.string(),
326
+ /** Child cell IDs (all closed) */
327
+ child_ids: z.array(z.string()),
328
+ /** Total duration across all children */
329
+ total_duration_ms: z.number().optional(),
330
+ /** Aggregate file changes */
331
+ all_files_touched: z.array(z.string()).optional(),
332
+ });
333
+
334
+ // ============================================================================
335
+ // Swarm Integration Events (bridge to swarm-mail)
336
+ // ============================================================================
337
+
338
+ /**
339
+ * Cell assigned to agent
340
+ *
341
+ * Links cells to swarm-mail's agent tracking.
342
+ * Emitted when agent calls `cells_start` or swarm spawns worker.
343
+ */
344
+ export const CellAssignedEventSchema = BaseCellEventSchema.extend({
345
+ type: z.literal("cell_assigned"),
346
+ cell_id: z.string(),
347
+ agent_name: z.string(),
348
+ /** Agent's task description for context */
349
+ task_description: z.string().optional(),
350
+ });
351
+
352
+ /**
353
+ * Cell work started
354
+ *
355
+ * Separate from status change to track actual work start time.
356
+ * Useful for duration/velocity metrics.
357
+ */
358
+ export const CellWorkStartedEventSchema = BaseCellEventSchema.extend({
359
+ type: z.literal("cell_work_started"),
360
+ cell_id: z.string(),
361
+ agent_name: z.string(),
362
+ /** Files reserved for this work */
363
+ reserved_files: z.array(z.string()).optional(),
364
+ });
365
+
366
+ /**
367
+ * Cell compacted
368
+ *
369
+ * Emitted when cell's event history is compressed (rare).
370
+ * Follows steveyegge/beads pattern - old events archived, projection preserved.
371
+ */
372
+ export const CellCompactedEventSchema = BaseCellEventSchema.extend({
373
+ type: z.literal("cell_compacted"),
374
+ cell_id: z.string(),
375
+ /** Number of events archived */
376
+ events_archived: z.number(),
377
+ /** New event store start sequence */
378
+ new_start_sequence: z.number(),
379
+ });
380
+
381
+ // ============================================================================
382
+ // Union Type
383
+ // ============================================================================
384
+
385
+ export const CellEventSchema = z.discriminatedUnion("type", [
386
+ // Lifecycle
387
+ CellCreatedEventSchema,
388
+ CellUpdatedEventSchema,
389
+ CellStatusChangedEventSchema,
390
+ CellClosedEventSchema,
391
+ CellReopenedEventSchema,
392
+ CellDeletedEventSchema,
393
+
394
+ // Dependencies
395
+ CellDependencyAddedEventSchema,
396
+ CellDependencyRemovedEventSchema,
397
+
398
+ // Labels
399
+ CellLabelAddedEventSchema,
400
+ CellLabelRemovedEventSchema,
401
+
402
+ // Comments
403
+ CellCommentAddedEventSchema,
404
+ CellCommentUpdatedEventSchema,
405
+ CellCommentDeletedEventSchema,
406
+
407
+ // Epic
408
+ CellEpicChildAddedEventSchema,
409
+ CellEpicChildRemovedEventSchema,
410
+ CellEpicClosureEligibleEventSchema,
411
+
412
+ // Swarm Integration
413
+ CellAssignedEventSchema,
414
+ CellWorkStartedEventSchema,
415
+
416
+ // Maintenance
417
+ CellCompactedEventSchema,
418
+ ]);
419
+
420
+ export type CellEvent = z.infer<typeof CellEventSchema>;
421
+
422
+ // ============================================================================
423
+ // Individual event types for convenience
424
+ // ============================================================================
425
+
426
+ export type CellCreatedEvent = z.infer<typeof CellCreatedEventSchema>;
427
+ export type CellUpdatedEvent = z.infer<typeof CellUpdatedEventSchema>;
428
+ export type CellStatusChangedEvent = z.infer<
429
+ typeof CellStatusChangedEventSchema
430
+ >;
431
+ export type CellClosedEvent = z.infer<typeof CellClosedEventSchema>;
432
+ export type CellReopenedEvent = z.infer<typeof CellReopenedEventSchema>;
433
+ export type CellDeletedEvent = z.infer<typeof CellDeletedEventSchema>;
434
+ export type CellDependencyAddedEvent = z.infer<
435
+ typeof CellDependencyAddedEventSchema
436
+ >;
437
+ export type CellDependencyRemovedEvent = z.infer<
438
+ typeof CellDependencyRemovedEventSchema
439
+ >;
440
+ export type CellLabelAddedEvent = z.infer<typeof CellLabelAddedEventSchema>;
441
+ export type CellLabelRemovedEvent = z.infer<typeof CellLabelRemovedEventSchema>;
442
+ export type CellCommentAddedEvent = z.infer<typeof CellCommentAddedEventSchema>;
443
+ export type CellCommentUpdatedEvent = z.infer<
444
+ typeof CellCommentUpdatedEventSchema
445
+ >;
446
+ export type CellCommentDeletedEvent = z.infer<
447
+ typeof CellCommentDeletedEventSchema
448
+ >;
449
+ export type CellEpicChildAddedEvent = z.infer<
450
+ typeof CellEpicChildAddedEventSchema
451
+ >;
452
+ export type CellEpicChildRemovedEvent = z.infer<
453
+ typeof CellEpicChildRemovedEventSchema
454
+ >;
455
+ export type CellEpicClosureEligibleEvent = z.infer<
456
+ typeof CellEpicClosureEligibleEventSchema
457
+ >;
458
+ export type CellAssignedEvent = z.infer<typeof CellAssignedEventSchema>;
459
+ export type CellWorkStartedEvent = z.infer<typeof CellWorkStartedEventSchema>;
460
+ export type CellCompactedEvent = z.infer<typeof CellCompactedEventSchema>;
461
+
462
+ // ============================================================================
463
+ // Event Helpers
464
+ // ============================================================================
465
+
466
+ /**
467
+ * Create a cell event with timestamp and validate
468
+ *
469
+ * Usage:
470
+ * ```typescript
471
+ * const event = createCellEvent("cell_created", {
472
+ * project_key: "/path/to/repo",
473
+ * cell_id: "bd-123",
474
+ * title: "Add auth",
475
+ * issue_type: "feature",
476
+ * priority: 2
477
+ * });
478
+ * ```
479
+ */
480
+ export function createCellEvent<T extends CellEvent["type"]>(
481
+ type: T,
482
+ data: Omit<
483
+ Extract<CellEvent, { type: T }>,
484
+ "type" | "timestamp" | "id" | "sequence"
485
+ >,
486
+ ): Extract<CellEvent, { type: T }> {
487
+ const event = {
488
+ type,
489
+ timestamp: Date.now(),
490
+ ...data,
491
+ } as Extract<CellEvent, { type: T }>;
492
+
493
+ // Validate
494
+ const result = CellEventSchema.safeParse(event);
495
+ if (!result.success) {
496
+ throw new Error(`Invalid cell event: ${result.error.message}`);
497
+ }
498
+
499
+ return result.data as Extract<CellEvent, { type: T }>;
500
+ }
501
+
502
+ /**
503
+ * Type guard for specific cell event types
504
+ *
505
+ * Usage:
506
+ * ```typescript
507
+ * if (isCellEventType(event, "cell_closed")) {
508
+ * console.log(event.reason); // TypeScript knows this is CellClosedEvent
509
+ * }
510
+ * ```
511
+ */
512
+ export function isCellEventType<T extends CellEvent["type"]>(
513
+ event: CellEvent,
514
+ type: T,
515
+ ): event is Extract<CellEvent, { type: T }> {
516
+ return event.type === type;
517
+ }
518
+
519
+ /**
520
+ * Extract cell ID from event (convenience helper)
521
+ *
522
+ * All cell events have cell_id field (or it's the epic's cell_id for epic events).
523
+ */
524
+ export function getCellIdFromEvent(event: CellEvent): string {
525
+ return event.cell_id;
526
+ }
527
+
528
+ /**
529
+ * Check if event represents a state transition
530
+ */
531
+ export function isStateTransitionEvent(
532
+ event: CellEvent,
533
+ ): event is CellStatusChangedEvent | CellClosedEvent | CellReopenedEvent {
534
+ return (
535
+ event.type === "cell_status_changed" ||
536
+ event.type === "cell_closed" ||
537
+ event.type === "cell_reopened"
538
+ );
539
+ }
540
+
541
+ /**
542
+ * Check if event represents an epic operation
543
+ */
544
+ export function isEpicEvent(
545
+ event: CellEvent,
546
+ ): event is
547
+ | CellEpicChildAddedEvent
548
+ | CellEpicChildRemovedEvent
549
+ | CellEpicClosureEligibleEvent {
550
+ return (
551
+ event.type === "cell_epic_child_added" ||
552
+ event.type === "cell_epic_child_removed" ||
553
+ event.type === "cell_epic_closure_eligible"
554
+ );
555
+ }
556
+
557
+ /**
558
+ * Check if event was triggered by an agent (vs human user)
559
+ */
560
+ export function isAgentEvent(event: CellEvent): boolean {
561
+ // Agent events have agent_name field or *_by field containing agent signature
562
+ if ("agent_name" in event) return true;
563
+
564
+ const actorFields = [
565
+ "created_by",
566
+ "updated_by",
567
+ "changed_by",
568
+ "closed_by",
569
+ "deleted_by",
570
+ "added_by",
571
+ "removed_by",
572
+ "reopened_by",
573
+ ] as const;
574
+
575
+ return actorFields.some((field) => {
576
+ if (field in event) {
577
+ const value = (event as Record<string, unknown>)[field];
578
+ // Agent names are typically lowercase or have specific patterns
579
+ return typeof value === "string" && /^[a-z]+$/i.test(value);
580
+ }
581
+ return false;
582
+ });
583
+ }
584
+
585
+ // ============================================================================
586
+ // Backward Compatibility Aliases
587
+ // ============================================================================
588
+
589
+ /**
590
+ * @deprecated Use BaseCellEventSchema instead
591
+ */
592
+ export const BaseBeadEventSchema = BaseCellEventSchema;
593
+
594
+ /**
595
+ * @deprecated Use CellCreatedEventSchema instead
596
+ */
597
+ export const BeadCreatedEventSchema = CellCreatedEventSchema;
598
+
599
+ /**
600
+ * @deprecated Use CellUpdatedEventSchema instead
601
+ */
602
+ export const BeadUpdatedEventSchema = CellUpdatedEventSchema;
603
+
604
+ /**
605
+ * @deprecated Use CellStatusChangedEventSchema instead
606
+ */
607
+ export const BeadStatusChangedEventSchema = CellStatusChangedEventSchema;
608
+
609
+ /**
610
+ * @deprecated Use CellClosedEventSchema instead
611
+ */
612
+ export const BeadClosedEventSchema = CellClosedEventSchema;
613
+
614
+ /**
615
+ * @deprecated Use CellReopenedEventSchema instead
616
+ */
617
+ export const BeadReopenedEventSchema = CellReopenedEventSchema;
618
+
619
+ /**
620
+ * @deprecated Use CellDeletedEventSchema instead
621
+ */
622
+ export const BeadDeletedEventSchema = CellDeletedEventSchema;
623
+
624
+ /**
625
+ * @deprecated Use CellDependencyAddedEventSchema instead
626
+ */
627
+ export const BeadDependencyAddedEventSchema = CellDependencyAddedEventSchema;
628
+
629
+ /**
630
+ * @deprecated Use CellDependencyRemovedEventSchema instead
631
+ */
632
+ export const BeadDependencyRemovedEventSchema = CellDependencyRemovedEventSchema;
633
+
634
+ /**
635
+ * @deprecated Use CellLabelAddedEventSchema instead
636
+ */
637
+ export const BeadLabelAddedEventSchema = CellLabelAddedEventSchema;
638
+
639
+ /**
640
+ * @deprecated Use CellLabelRemovedEventSchema instead
641
+ */
642
+ export const BeadLabelRemovedEventSchema = CellLabelRemovedEventSchema;
643
+
644
+ /**
645
+ * @deprecated Use CellCommentAddedEventSchema instead
646
+ */
647
+ export const BeadCommentAddedEventSchema = CellCommentAddedEventSchema;
648
+
649
+ /**
650
+ * @deprecated Use CellCommentUpdatedEventSchema instead
651
+ */
652
+ export const BeadCommentUpdatedEventSchema = CellCommentUpdatedEventSchema;
653
+
654
+ /**
655
+ * @deprecated Use CellCommentDeletedEventSchema instead
656
+ */
657
+ export const BeadCommentDeletedEventSchema = CellCommentDeletedEventSchema;
658
+
659
+ /**
660
+ * @deprecated Use CellEpicChildAddedEventSchema instead
661
+ */
662
+ export const BeadEpicChildAddedEventSchema = CellEpicChildAddedEventSchema;
663
+
664
+ /**
665
+ * @deprecated Use CellEpicChildRemovedEventSchema instead
666
+ */
667
+ export const BeadEpicChildRemovedEventSchema = CellEpicChildRemovedEventSchema;
668
+
669
+ /**
670
+ * @deprecated Use CellEpicClosureEligibleEventSchema instead
671
+ */
672
+ export const BeadEpicClosureEligibleEventSchema = CellEpicClosureEligibleEventSchema;
673
+
674
+ /**
675
+ * @deprecated Use CellAssignedEventSchema instead
676
+ */
677
+ export const BeadAssignedEventSchema = CellAssignedEventSchema;
678
+
679
+ /**
680
+ * @deprecated Use CellWorkStartedEventSchema instead
681
+ */
682
+ export const BeadWorkStartedEventSchema = CellWorkStartedEventSchema;
683
+
684
+ /**
685
+ * @deprecated Use CellCompactedEventSchema instead
686
+ */
687
+ export const BeadCompactedEventSchema = CellCompactedEventSchema;
688
+
689
+ /**
690
+ * @deprecated Use CellEventSchema instead
691
+ */
692
+ export const BeadEventSchema = CellEventSchema;
693
+
694
+ /**
695
+ * @deprecated Use CellEvent instead
696
+ */
697
+ export type BeadEvent = CellEvent;
698
+
699
+ /**
700
+ * @deprecated Use CellCreatedEvent instead
701
+ */
702
+ export type BeadCreatedEvent = CellCreatedEvent;
703
+
704
+ /**
705
+ * @deprecated Use CellUpdatedEvent instead
706
+ */
707
+ export type BeadUpdatedEvent = CellUpdatedEvent;
708
+
709
+ /**
710
+ * @deprecated Use CellStatusChangedEvent instead
711
+ */
712
+ export type BeadStatusChangedEvent = CellStatusChangedEvent;
713
+
714
+ /**
715
+ * @deprecated Use CellClosedEvent instead
716
+ */
717
+ export type BeadClosedEvent = CellClosedEvent;
718
+
719
+ /**
720
+ * @deprecated Use CellReopenedEvent instead
721
+ */
722
+ export type BeadReopenedEvent = CellReopenedEvent;
723
+
724
+ /**
725
+ * @deprecated Use CellDeletedEvent instead
726
+ */
727
+ export type BeadDeletedEvent = CellDeletedEvent;
728
+
729
+ /**
730
+ * @deprecated Use CellDependencyAddedEvent instead
731
+ */
732
+ export type BeadDependencyAddedEvent = CellDependencyAddedEvent;
733
+
734
+ /**
735
+ * @deprecated Use CellDependencyRemovedEvent instead
736
+ */
737
+ export type BeadDependencyRemovedEvent = CellDependencyRemovedEvent;
738
+
739
+ /**
740
+ * @deprecated Use CellLabelAddedEvent instead
741
+ */
742
+ export type BeadLabelAddedEvent = CellLabelAddedEvent;
743
+
744
+ /**
745
+ * @deprecated Use CellLabelRemovedEvent instead
746
+ */
747
+ export type BeadLabelRemovedEvent = CellLabelRemovedEvent;
748
+
749
+ /**
750
+ * @deprecated Use CellCommentAddedEvent instead
751
+ */
752
+ export type BeadCommentAddedEvent = CellCommentAddedEvent;
753
+
754
+ /**
755
+ * @deprecated Use CellCommentUpdatedEvent instead
756
+ */
757
+ export type BeadCommentUpdatedEvent = CellCommentUpdatedEvent;
758
+
759
+ /**
760
+ * @deprecated Use CellCommentDeletedEvent instead
761
+ */
762
+ export type BeadCommentDeletedEvent = CellCommentDeletedEvent;
763
+
764
+ /**
765
+ * @deprecated Use CellEpicChildAddedEvent instead
766
+ */
767
+ export type BeadEpicChildAddedEvent = CellEpicChildAddedEvent;
768
+
769
+ /**
770
+ * @deprecated Use CellEpicChildRemovedEvent instead
771
+ */
772
+ export type BeadEpicChildRemovedEvent = CellEpicChildRemovedEvent;
773
+
774
+ /**
775
+ * @deprecated Use CellEpicClosureEligibleEvent instead
776
+ */
777
+ export type BeadEpicClosureEligibleEvent = CellEpicClosureEligibleEvent;
778
+
779
+ /**
780
+ * @deprecated Use CellAssignedEvent instead
781
+ */
782
+ export type BeadAssignedEvent = CellAssignedEvent;
783
+
784
+ /**
785
+ * @deprecated Use CellWorkStartedEvent instead
786
+ */
787
+ export type BeadWorkStartedEvent = CellWorkStartedEvent;
788
+
789
+ /**
790
+ * @deprecated Use CellCompactedEvent instead
791
+ */
792
+ export type BeadCompactedEvent = CellCompactedEvent;
793
+
794
+ /**
795
+ * @deprecated Use createCellEvent instead
796
+ */
797
+ export const createBeadEvent = createCellEvent;
798
+
799
+ /**
800
+ * @deprecated Use isCellEventType instead
801
+ */
802
+ export const isBeadEventType = isCellEventType;
803
+
804
+ /**
805
+ * @deprecated Use getCellIdFromEvent instead
806
+ */
807
+ export const getBeadIdFromEvent = getCellIdFromEvent;