opencode-swarm-plugin 0.44.1 → 0.44.2
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/bin/swarm.ts +2 -2
- package/dist/hive.d.ts.map +1 -1
- package/dist/hive.js +14834 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -0
- package/dist/plugin.js +100 -0
- package/dist/swarm-prompts.js +39407 -0
- package/dist/swarm-validation.d.ts +127 -0
- package/dist/swarm-validation.d.ts.map +1 -0
- 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/package.json +2 -2
|
@@ -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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EG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAWhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMpE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,QAAQ,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"}
|
|
@@ -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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm-plugin",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.2",
|
|
4
4
|
"description": "Multi-agent swarm coordination for OpenCode with learning capabilities, beads integration, and Agent Mail",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"registry": "https://registry.npmjs.org/"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
|
-
"build": "bun
|
|
39
|
+
"build": "bun run scripts/build.ts",
|
|
40
40
|
"dev": "bun --watch src/index.ts",
|
|
41
41
|
"test": "bun test --timeout 10000 src/anti-patterns.test.ts src/mandate-promotion.test.ts src/mandate-storage.test.ts src/output-guardrails.test.ts src/pattern-maturity.test.ts src/skills.test.ts src/structured.test.ts src/schemas/",
|
|
42
42
|
"test:integration": "bun test --timeout 60000 src/*.integration.test.ts",
|