opencode-swarm-plugin 0.44.1 → 0.45.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/README.md +277 -54
- package/bin/swarm.ts +3 -3
- package/dist/decision-trace-integration.d.ts +204 -0
- package/dist/decision-trace-integration.d.ts.map +1 -0
- package/dist/hive.d.ts.map +1 -1
- package/dist/hive.js +14834 -0
- package/dist/index.d.ts +50 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +640 -27
- package/dist/plugin.js +395 -27
- package/dist/query-tools.d.ts +20 -12
- package/dist/query-tools.d.ts.map +1 -1
- package/dist/swarm-decompose.d.ts +4 -4
- package/dist/swarm-decompose.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-prompts.js +39605 -0
- package/dist/swarm-review.d.ts.map +1 -1
- package/dist/swarm-signature.d.ts +106 -0
- package/dist/swarm-signature.d.ts.map +1 -0
- package/dist/swarm-strategies.d.ts +16 -3
- package/dist/swarm-strategies.d.ts.map +1 -1
- package/dist/swarm-validation.d.ts +127 -0
- package/dist/swarm-validation.d.ts.map +1 -0
- package/dist/swarm.d.ts +4 -2
- package/dist/swarm.d.ts.map +1 -1
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/schema-validator.d.ts +58 -0
- package/dist/validators/schema-validator.d.ts.map +1 -0
- package/examples/commands/swarm.md +745 -0
- package/examples/plugin-wrapper-template.ts +2611 -0
- package/examples/skills/hive-workflow/SKILL.md +212 -0
- package/examples/skills/skill-creator/SKILL.md +223 -0
- package/examples/skills/swarm-coordination/SKILL.md +292 -0
- package/global-skills/cli-builder/SKILL.md +344 -0
- package/global-skills/cli-builder/references/advanced-patterns.md +244 -0
- package/global-skills/learning-systems/SKILL.md +644 -0
- package/global-skills/skill-creator/LICENSE.txt +202 -0
- package/global-skills/skill-creator/SKILL.md +352 -0
- package/global-skills/skill-creator/references/output-patterns.md +82 -0
- package/global-skills/skill-creator/references/workflows.md +28 -0
- package/global-skills/swarm-coordination/SKILL.md +995 -0
- package/global-skills/swarm-coordination/references/coordinator-patterns.md +235 -0
- package/global-skills/swarm-coordination/references/strategies.md +138 -0
- package/global-skills/system-design/SKILL.md +213 -0
- package/global-skills/testing-patterns/SKILL.md +430 -0
- package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +586 -0
- package/package.json +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-review.d.ts","sourceRoot":"","sources":["../src/swarm-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"swarm-review.d.ts","sourceRoot":"","sources":["../src/swarm-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB;;;;;iBAK5B,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,UAAU,GAAG,eAAe,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;iBAkB5B,CAAC;AAEJ;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;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kB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEvD;AAMD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGvB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Signature Detection
|
|
3
|
+
*
|
|
4
|
+
* Deterministic, algorithmic detection of swarm coordination from session events.
|
|
5
|
+
* No heuristics, no confidence levels - a swarm either exists or it doesn't.
|
|
6
|
+
*
|
|
7
|
+
* A SWARM is defined by this event sequence:
|
|
8
|
+
* 1. hive_create_epic(epic_title, subtasks[]) → epic_id
|
|
9
|
+
* 2. swarm_spawn_subtask(bead_id, epic_id, ...) → prompt (at least one)
|
|
10
|
+
*
|
|
11
|
+
* The projection folds over events to produce ground truth state:
|
|
12
|
+
* - Which epic is being coordinated
|
|
13
|
+
* - Which subtasks exist and their lifecycle status
|
|
14
|
+
* - What files are assigned to each subtask
|
|
15
|
+
*
|
|
16
|
+
* @module swarm-signature
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Subtask lifecycle status derived from events
|
|
20
|
+
*/
|
|
21
|
+
export type SubtaskStatus = "created" | "spawned" | "in_progress" | "completed" | "closed";
|
|
22
|
+
/**
|
|
23
|
+
* Subtask state projected from events
|
|
24
|
+
*/
|
|
25
|
+
export interface SubtaskState {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
status: SubtaskStatus;
|
|
29
|
+
files: string[];
|
|
30
|
+
worker?: string;
|
|
31
|
+
spawnedAt?: number;
|
|
32
|
+
completedAt?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Epic state projected from events
|
|
36
|
+
*/
|
|
37
|
+
export interface EpicState {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
status: "open" | "in_progress" | "closed";
|
|
41
|
+
createdAt: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Complete swarm state projected from session events
|
|
45
|
+
*/
|
|
46
|
+
export interface SwarmProjection {
|
|
47
|
+
/** Whether a valid swarm signature was detected */
|
|
48
|
+
isSwarm: boolean;
|
|
49
|
+
/** Epic being coordinated (if any) */
|
|
50
|
+
epic?: EpicState;
|
|
51
|
+
/** Subtasks by ID */
|
|
52
|
+
subtasks: Map<string, SubtaskState>;
|
|
53
|
+
/** Project path from swarmmail_init */
|
|
54
|
+
projectPath?: string;
|
|
55
|
+
/** Coordinator agent name from swarmmail_init */
|
|
56
|
+
coordinatorName?: string;
|
|
57
|
+
/** Last event timestamp */
|
|
58
|
+
lastEventAt?: number;
|
|
59
|
+
/** Summary counts for quick access */
|
|
60
|
+
counts: {
|
|
61
|
+
total: number;
|
|
62
|
+
created: number;
|
|
63
|
+
spawned: number;
|
|
64
|
+
inProgress: number;
|
|
65
|
+
completed: number;
|
|
66
|
+
closed: number;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Tool call event extracted from session messages
|
|
71
|
+
*/
|
|
72
|
+
export interface ToolCallEvent {
|
|
73
|
+
tool: string;
|
|
74
|
+
input: Record<string, unknown>;
|
|
75
|
+
output: string;
|
|
76
|
+
timestamp: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Project swarm state from session tool call events
|
|
80
|
+
*
|
|
81
|
+
* This is a pure fold over events - deterministic and side-effect free.
|
|
82
|
+
* The resulting state is the ground truth for swarm coordination.
|
|
83
|
+
*
|
|
84
|
+
* @param events - Tool call events from session messages (chronological order)
|
|
85
|
+
* @returns Projected swarm state
|
|
86
|
+
*/
|
|
87
|
+
export declare function projectSwarmState(events: ToolCallEvent[]): SwarmProjection;
|
|
88
|
+
/**
|
|
89
|
+
* Check if events contain a valid swarm signature
|
|
90
|
+
*
|
|
91
|
+
* A swarm signature requires:
|
|
92
|
+
* 1. hive_create_epic call
|
|
93
|
+
* 2. At least one swarm_spawn_subtask call
|
|
94
|
+
*
|
|
95
|
+
* This is a quick check without full projection.
|
|
96
|
+
*/
|
|
97
|
+
export declare function hasSwarmSignature(events: ToolCallEvent[]): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Check if swarm is still active (has pending work)
|
|
100
|
+
*/
|
|
101
|
+
export declare function isSwarmActive(projection: SwarmProjection): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Get human-readable swarm status summary
|
|
104
|
+
*/
|
|
105
|
+
export declare function getSwarmSummary(projection: SwarmProjection): string;
|
|
106
|
+
//# sourceMappingURL=swarm-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-signature.d.ts","sourceRoot":"","sources":["../src/swarm-signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,SAAS,GACT,aAAa,GACb,WAAW,GACX,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC;IAEjB,sCAAsC;IACtC,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB,qBAAqB;IACrB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAEpC,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,sCAAsC;IACtC,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,eAAe,CAiO1E;AA0CD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAkBlE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAYlE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,eAAe,GAAG,MAAM,CAuBnE"}
|
|
@@ -52,9 +52,10 @@ export declare const STRATEGIES: Record<Exclude<DecompositionStrategy, "auto">,
|
|
|
52
52
|
* Analyze task description and select best decomposition strategy
|
|
53
53
|
*
|
|
54
54
|
* @param task - Task description
|
|
55
|
-
* @
|
|
55
|
+
* @param projectKey - Optional project path for precedent-aware selection
|
|
56
|
+
* @returns Selected strategy with reasoning and optional precedent data
|
|
56
57
|
*/
|
|
57
|
-
export declare function selectStrategy(task: string): {
|
|
58
|
+
export declare function selectStrategy(task: string, projectKey?: string): Promise<{
|
|
58
59
|
strategy: Exclude<DecompositionStrategy, "auto">;
|
|
59
60
|
confidence: number;
|
|
60
61
|
reasoning: string;
|
|
@@ -62,7 +63,12 @@ export declare function selectStrategy(task: string): {
|
|
|
62
63
|
strategy: Exclude<DecompositionStrategy, "auto">;
|
|
63
64
|
score: number;
|
|
64
65
|
}>;
|
|
65
|
-
|
|
66
|
+
precedent?: {
|
|
67
|
+
similar_decisions: number;
|
|
68
|
+
strategy_success_rate?: number;
|
|
69
|
+
cited_epics?: string[];
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
66
72
|
/**
|
|
67
73
|
* Format strategy-specific guidelines for the decomposition prompt
|
|
68
74
|
*/
|
|
@@ -72,16 +78,21 @@ export declare function formatStrategyGuidelines(strategy: Exclude<Decomposition
|
|
|
72
78
|
*
|
|
73
79
|
* Analyzes task description and recommends a strategy with reasoning.
|
|
74
80
|
* Use this before swarm_plan_prompt to understand the recommended approach.
|
|
81
|
+
*
|
|
82
|
+
* When projectKey is provided, queries past strategy decisions and success rates
|
|
83
|
+
* to provide precedent-aware recommendations with adjusted confidence.
|
|
75
84
|
*/
|
|
76
85
|
export declare const swarm_select_strategy: {
|
|
77
86
|
description: string;
|
|
78
87
|
args: {
|
|
79
88
|
task: z.ZodString;
|
|
80
89
|
codebase_context: z.ZodOptional<z.ZodString>;
|
|
90
|
+
projectKey: z.ZodOptional<z.ZodString>;
|
|
81
91
|
};
|
|
82
92
|
execute(args: {
|
|
83
93
|
task: string;
|
|
84
94
|
codebase_context?: string | undefined;
|
|
95
|
+
projectKey?: string | undefined;
|
|
85
96
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
86
97
|
};
|
|
87
98
|
export declare const strategyTools: {
|
|
@@ -90,10 +101,12 @@ export declare const strategyTools: {
|
|
|
90
101
|
args: {
|
|
91
102
|
task: z.ZodString;
|
|
92
103
|
codebase_context: z.ZodOptional<z.ZodString>;
|
|
104
|
+
projectKey: z.ZodOptional<z.ZodString>;
|
|
93
105
|
};
|
|
94
106
|
execute(args: {
|
|
95
107
|
task: string;
|
|
96
108
|
codebase_context?: string | undefined;
|
|
109
|
+
projectKey?: string | undefined;
|
|
97
110
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
98
111
|
};
|
|
99
112
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-strategies.d.ts","sourceRoot":"","sources":["../src/swarm-strategies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,gBAAgB,GAChB,MAAM,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;EAMtC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAO5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAQ5B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,EACtC,kBAAkB,CAgKnB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"swarm-strategies.d.ts","sourceRoot":"","sources":["../src/swarm-strategies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,MAA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AAqB,EAAE,MAAM,CAAC,GAC/C,MAAM,CAmBR;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;CA0ChC,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;CAEzB,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Validation Hook Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Provides validation event types and hooks for post-swarm validation.
|
|
5
|
+
* Integrates with swarm-mail event sourcing to emit validation events.
|
|
6
|
+
*
|
|
7
|
+
* @module swarm-validation
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
/**
|
|
11
|
+
* Agent event type for validation events
|
|
12
|
+
*
|
|
13
|
+
* This is a minimal type that matches the swarm-mail AgentEvent interface
|
|
14
|
+
* for the validation events we emit.
|
|
15
|
+
*/
|
|
16
|
+
type AgentEvent = {
|
|
17
|
+
type: "validation_started";
|
|
18
|
+
project_key: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
epic_id: string;
|
|
21
|
+
swarm_id: string;
|
|
22
|
+
started_at: number;
|
|
23
|
+
} | {
|
|
24
|
+
type: "validation_issue";
|
|
25
|
+
project_key: string;
|
|
26
|
+
timestamp: string | number;
|
|
27
|
+
epic_id: string;
|
|
28
|
+
severity: "error" | "warning" | "info";
|
|
29
|
+
category: "schema_mismatch" | "missing_event" | "undefined_value" | "dashboard_render" | "websocket_delivery";
|
|
30
|
+
message: string;
|
|
31
|
+
location?: {
|
|
32
|
+
event_type?: string;
|
|
33
|
+
field?: string;
|
|
34
|
+
component?: string;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
type: "validation_completed";
|
|
38
|
+
project_key: string;
|
|
39
|
+
timestamp: number;
|
|
40
|
+
epic_id: string;
|
|
41
|
+
swarm_id: string;
|
|
42
|
+
passed: boolean;
|
|
43
|
+
issue_count: number;
|
|
44
|
+
duration_ms: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Severity levels for validation issues
|
|
48
|
+
*/
|
|
49
|
+
export declare const ValidationIssueSeverity: z.ZodEnum<{
|
|
50
|
+
error: "error";
|
|
51
|
+
info: "info";
|
|
52
|
+
warning: "warning";
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Categories of validation issues
|
|
56
|
+
*/
|
|
57
|
+
export declare const ValidationIssueCategory: z.ZodEnum<{
|
|
58
|
+
schema_mismatch: "schema_mismatch";
|
|
59
|
+
missing_event: "missing_event";
|
|
60
|
+
undefined_value: "undefined_value";
|
|
61
|
+
dashboard_render: "dashboard_render";
|
|
62
|
+
websocket_delivery: "websocket_delivery";
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Validation issue with location context
|
|
66
|
+
*/
|
|
67
|
+
export declare const ValidationIssueSchema: z.ZodObject<{
|
|
68
|
+
severity: z.ZodEnum<{
|
|
69
|
+
error: "error";
|
|
70
|
+
info: "info";
|
|
71
|
+
warning: "warning";
|
|
72
|
+
}>;
|
|
73
|
+
category: z.ZodEnum<{
|
|
74
|
+
schema_mismatch: "schema_mismatch";
|
|
75
|
+
missing_event: "missing_event";
|
|
76
|
+
undefined_value: "undefined_value";
|
|
77
|
+
dashboard_render: "dashboard_render";
|
|
78
|
+
websocket_delivery: "websocket_delivery";
|
|
79
|
+
}>;
|
|
80
|
+
message: z.ZodString;
|
|
81
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
82
|
+
event_type: z.ZodOptional<z.ZodString>;
|
|
83
|
+
field: z.ZodOptional<z.ZodString>;
|
|
84
|
+
component: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export type ValidationIssue = z.infer<typeof ValidationIssueSchema>;
|
|
88
|
+
/**
|
|
89
|
+
* Context for validation execution
|
|
90
|
+
*/
|
|
91
|
+
export interface ValidationContext {
|
|
92
|
+
/** Project key (path) */
|
|
93
|
+
project_key: string;
|
|
94
|
+
/** Epic ID being validated */
|
|
95
|
+
epic_id: string;
|
|
96
|
+
/** Swarm ID being validated */
|
|
97
|
+
swarm_id: string;
|
|
98
|
+
/** Validation start time */
|
|
99
|
+
started_at: Date;
|
|
100
|
+
/** Event emitter function */
|
|
101
|
+
emit: (event: AgentEvent) => Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Run post-swarm validation
|
|
105
|
+
*
|
|
106
|
+
* Emits validation_started, runs validators, emits validation_issue for each issue,
|
|
107
|
+
* and emits validation_completed with summary.
|
|
108
|
+
*
|
|
109
|
+
* @param ctx - Validation context
|
|
110
|
+
* @param events - Events to validate
|
|
111
|
+
* @returns Validation result with passed flag and issues
|
|
112
|
+
*/
|
|
113
|
+
export declare function runPostSwarmValidation(ctx: ValidationContext, events: unknown[]): Promise<{
|
|
114
|
+
passed: boolean;
|
|
115
|
+
issues: ValidationIssue[];
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Report a validation issue
|
|
119
|
+
*
|
|
120
|
+
* Emits a validation_issue event with the provided issue details.
|
|
121
|
+
*
|
|
122
|
+
* @param ctx - Validation context
|
|
123
|
+
* @param issue - Validation issue to report
|
|
124
|
+
*/
|
|
125
|
+
export declare function reportIssue(ctx: ValidationContext, issue: ValidationIssue): Promise<void>;
|
|
126
|
+
export {};
|
|
127
|
+
//# sourceMappingURL=swarm-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-validation.d.ts","sourceRoot":"","sources":["../src/swarm-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,KAAK,UAAU,GACX;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAA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EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,UAAU,EAAE,IAAI,CAAC;IACjB,6BAA6B;IAC7B,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAMD;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,OAAO,EAAE,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC,CA+BzD;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
package/dist/swarm.d.ts
CHANGED
|
@@ -546,8 +546,8 @@ export declare const swarmTools: {
|
|
|
546
546
|
user_response: import("zod").ZodOptional<import("zod").ZodString>;
|
|
547
547
|
phase: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
548
548
|
ready: "ready";
|
|
549
|
-
questioning: "questioning";
|
|
550
549
|
alternatives: "alternatives";
|
|
550
|
+
questioning: "questioning";
|
|
551
551
|
recommendation: "recommendation";
|
|
552
552
|
}>>;
|
|
553
553
|
};
|
|
@@ -556,7 +556,7 @@ export declare const swarmTools: {
|
|
|
556
556
|
mode: "auto" | "socratic" | "fast" | "confirm-only";
|
|
557
557
|
context?: string | undefined;
|
|
558
558
|
user_response?: string | undefined;
|
|
559
|
-
phase?: "ready" | "
|
|
559
|
+
phase?: "ready" | "alternatives" | "questioning" | "recommendation" | undefined;
|
|
560
560
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
561
561
|
};
|
|
562
562
|
swarm_select_strategy: {
|
|
@@ -564,10 +564,12 @@ export declare const swarmTools: {
|
|
|
564
564
|
args: {
|
|
565
565
|
task: import("zod").ZodString;
|
|
566
566
|
codebase_context: import("zod").ZodOptional<import("zod").ZodString>;
|
|
567
|
+
projectKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
567
568
|
};
|
|
568
569
|
execute(args: {
|
|
569
570
|
task: string;
|
|
570
571
|
codebase_context?: string | undefined;
|
|
572
|
+
projectKey?: string | undefined;
|
|
571
573
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
572
574
|
};
|
|
573
575
|
};
|
package/dist/swarm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../src/swarm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AASjC;;;GAGG;AACH,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../src/swarm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AASjC;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Schema Validator
|
|
3
|
+
*
|
|
4
|
+
* Validates emitted events against their Zod schemas.
|
|
5
|
+
* Catches:
|
|
6
|
+
* - Type mismatches
|
|
7
|
+
* - Missing required fields
|
|
8
|
+
* - Undefined values that could break UI rendering
|
|
9
|
+
* - Schema violations
|
|
10
|
+
*
|
|
11
|
+
* Used by:
|
|
12
|
+
* - Swarm event emission (validateEvent before emit)
|
|
13
|
+
* - Post-run validation (validateSwarmEvents for all events)
|
|
14
|
+
* - Debug tooling (identify schema drift)
|
|
15
|
+
*/
|
|
16
|
+
import type { ZodError } from "zod";
|
|
17
|
+
export interface ValidationIssue {
|
|
18
|
+
severity: "error" | "warning";
|
|
19
|
+
category: "schema_mismatch" | "undefined_value" | "missing_field" | "type_error";
|
|
20
|
+
message: string;
|
|
21
|
+
location?: {
|
|
22
|
+
event_type?: string;
|
|
23
|
+
field?: string;
|
|
24
|
+
};
|
|
25
|
+
zodError?: ZodError;
|
|
26
|
+
}
|
|
27
|
+
export interface SchemaValidationResult {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
issues: ValidationIssue[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validate a single event against its schema
|
|
33
|
+
*
|
|
34
|
+
* Usage:
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const result = validateEvent(event);
|
|
37
|
+
* if (!result.valid) {
|
|
38
|
+
* console.error("Schema validation failed:", result.issues);
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function validateEvent(event: unknown): SchemaValidationResult;
|
|
43
|
+
/**
|
|
44
|
+
* Validate all events from a swarm run
|
|
45
|
+
*
|
|
46
|
+
* Usage:
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const { passed, issueCount } = await validateSwarmEvents(events);
|
|
49
|
+
* if (!passed) {
|
|
50
|
+
* console.error(`Found ${issueCount} validation issues`);
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function validateSwarmEvents(events: unknown[]): Promise<{
|
|
55
|
+
passed: boolean;
|
|
56
|
+
issueCount: number;
|
|
57
|
+
}>;
|
|
58
|
+
//# sourceMappingURL=schema-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-validator.d.ts","sourceRoot":"","sources":["../../src/validators/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,QAAQ,EACJ,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,YAAY,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,CAkDpE;AAgCD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,OAAO,EAAE,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAWlD"}
|