opencode-swarm-plugin 0.56.1 → 0.57.1
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 +21 -0
- package/claude-plugin/agents/background-worker.md +1 -0
- package/claude-plugin/agents/coordinator.md +2 -0
- package/claude-plugin/agents/worker.md +1 -0
- package/claude-plugin/bin/swarm-mcp-server.ts +53 -8
- package/claude-plugin/dist/agent-mail.d.ts +480 -0
- package/claude-plugin/dist/agent-mail.d.ts.map +1 -0
- package/claude-plugin/dist/anti-patterns.d.ts +257 -0
- package/claude-plugin/dist/anti-patterns.d.ts.map +1 -0
- package/claude-plugin/dist/bin/swarm.js +373132 -0
- package/claude-plugin/dist/build/mcp-bundle.d.ts +16 -0
- package/claude-plugin/dist/build/mcp-bundle.d.ts.map +1 -0
- package/claude-plugin/dist/cache/claude-plugin-cache.d.ts +41 -0
- package/claude-plugin/dist/cache/claude-plugin-cache.d.ts.map +1 -0
- package/claude-plugin/dist/cass-tools.d.ts +74 -0
- package/claude-plugin/dist/cass-tools.d.ts.map +1 -0
- package/claude-plugin/dist/claude-plugin/claude-plugin-assets.d.ts +10 -0
- package/claude-plugin/dist/claude-plugin/claude-plugin-assets.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-hook.d.ts +178 -0
- package/claude-plugin/dist/compaction-hook.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-observability.d.ts +173 -0
- package/claude-plugin/dist/compaction-observability.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-prompt-scoring.d.ts +125 -0
- package/claude-plugin/dist/compaction-prompt-scoring.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-prompt-scoring.js +139 -0
- package/claude-plugin/dist/contributor-tools.d.ts +42 -0
- package/claude-plugin/dist/contributor-tools.d.ts.map +1 -0
- package/claude-plugin/dist/coordinator-guard.d.ts +79 -0
- package/claude-plugin/dist/coordinator-guard.d.ts.map +1 -0
- package/claude-plugin/dist/dashboard.d.ts +82 -0
- package/claude-plugin/dist/dashboard.d.ts.map +1 -0
- package/claude-plugin/dist/decision-trace-integration.d.ts +204 -0
- package/claude-plugin/dist/decision-trace-integration.d.ts.map +1 -0
- package/claude-plugin/dist/error-enrichment.d.ts +49 -0
- package/claude-plugin/dist/error-enrichment.d.ts.map +1 -0
- package/claude-plugin/dist/eval-capture.d.ts +494 -0
- package/claude-plugin/dist/eval-capture.d.ts.map +1 -0
- package/claude-plugin/dist/eval-capture.js +12844 -0
- package/claude-plugin/dist/eval-gates.d.ts +84 -0
- package/claude-plugin/dist/eval-gates.d.ts.map +1 -0
- package/claude-plugin/dist/eval-history.d.ts +117 -0
- package/claude-plugin/dist/eval-history.d.ts.map +1 -0
- package/claude-plugin/dist/eval-learning.d.ts +216 -0
- package/claude-plugin/dist/eval-learning.d.ts.map +1 -0
- package/claude-plugin/dist/eval-runner.d.ts +134 -0
- package/claude-plugin/dist/eval-runner.d.ts.map +1 -0
- package/claude-plugin/dist/examples/plugin-wrapper-template.ts +3341 -0
- package/claude-plugin/dist/export-tools.d.ts +76 -0
- package/claude-plugin/dist/export-tools.d.ts.map +1 -0
- package/claude-plugin/dist/hive.d.ts +949 -0
- package/claude-plugin/dist/hive.d.ts.map +1 -0
- package/claude-plugin/dist/hive.js +15009 -0
- package/claude-plugin/dist/hivemind-tools.d.ts +479 -0
- package/claude-plugin/dist/hivemind-tools.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/atomic-write.d.ts +21 -0
- package/claude-plugin/dist/hooks/atomic-write.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/constants.d.ts +28 -0
- package/claude-plugin/dist/hooks/constants.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/index.d.ts +16 -0
- package/claude-plugin/dist/hooks/index.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/session-start.d.ts +30 -0
- package/claude-plugin/dist/hooks/session-start.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/tool-complete.d.ts +54 -0
- package/claude-plugin/dist/hooks/tool-complete.d.ts.map +1 -0
- package/claude-plugin/dist/index.d.ts +2017 -0
- package/claude-plugin/dist/index.d.ts.map +1 -0
- package/claude-plugin/dist/index.js +73454 -0
- package/claude-plugin/dist/learning.d.ts +700 -0
- package/claude-plugin/dist/learning.d.ts.map +1 -0
- package/claude-plugin/dist/logger.d.ts +38 -0
- package/claude-plugin/dist/logger.d.ts.map +1 -0
- package/claude-plugin/dist/mandate-promotion.d.ts +93 -0
- package/claude-plugin/dist/mandate-promotion.d.ts.map +1 -0
- package/claude-plugin/dist/mandate-storage.d.ts +209 -0
- package/claude-plugin/dist/mandate-storage.d.ts.map +1 -0
- package/claude-plugin/dist/mandates.d.ts +230 -0
- package/claude-plugin/dist/mandates.d.ts.map +1 -0
- package/claude-plugin/dist/mcp/swarm-mcp-server.js +19675 -0
- package/claude-plugin/dist/memory-tools.d.ts +281 -0
- package/claude-plugin/dist/memory-tools.d.ts.map +1 -0
- package/claude-plugin/dist/memory.d.ts +164 -0
- package/claude-plugin/dist/memory.d.ts.map +1 -0
- package/claude-plugin/dist/model-selection.d.ts +37 -0
- package/claude-plugin/dist/model-selection.d.ts.map +1 -0
- package/claude-plugin/dist/observability-health.d.ts +87 -0
- package/claude-plugin/dist/observability-health.d.ts.map +1 -0
- package/claude-plugin/dist/observability-tools.d.ts +184 -0
- package/claude-plugin/dist/observability-tools.d.ts.map +1 -0
- package/claude-plugin/dist/output-guardrails.d.ts +125 -0
- package/claude-plugin/dist/output-guardrails.d.ts.map +1 -0
- package/claude-plugin/dist/pattern-maturity.d.ts +246 -0
- package/claude-plugin/dist/pattern-maturity.d.ts.map +1 -0
- package/claude-plugin/dist/planning-guardrails.d.ts +183 -0
- package/claude-plugin/dist/planning-guardrails.d.ts.map +1 -0
- package/claude-plugin/dist/plugin.d.ts +22 -0
- package/claude-plugin/dist/plugin.d.ts.map +1 -0
- package/claude-plugin/dist/plugin.js +72296 -0
- package/claude-plugin/dist/post-compaction-tracker.d.ts +133 -0
- package/claude-plugin/dist/post-compaction-tracker.d.ts.map +1 -0
- package/claude-plugin/dist/query-tools.d.ts +90 -0
- package/claude-plugin/dist/query-tools.d.ts.map +1 -0
- package/claude-plugin/dist/rate-limiter.d.ts +218 -0
- package/claude-plugin/dist/rate-limiter.d.ts.map +1 -0
- package/claude-plugin/dist/regression-detection.d.ts +58 -0
- package/claude-plugin/dist/regression-detection.d.ts.map +1 -0
- package/claude-plugin/dist/replay-tools.d.ts +28 -0
- package/claude-plugin/dist/replay-tools.d.ts.map +1 -0
- package/claude-plugin/dist/repo-crawl.d.ts +146 -0
- package/claude-plugin/dist/repo-crawl.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/cell-events.d.ts +1352 -0
- package/claude-plugin/dist/schemas/cell-events.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/cell.d.ts +413 -0
- package/claude-plugin/dist/schemas/cell.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/evaluation.d.ts +161 -0
- package/claude-plugin/dist/schemas/evaluation.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/index.d.ts +46 -0
- package/claude-plugin/dist/schemas/index.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/mandate.d.ts +336 -0
- package/claude-plugin/dist/schemas/mandate.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/swarm-context.d.ts +131 -0
- package/claude-plugin/dist/schemas/swarm-context.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/task.d.ts +189 -0
- package/claude-plugin/dist/schemas/task.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/worker-handoff.d.ts +78 -0
- package/claude-plugin/dist/schemas/worker-handoff.d.ts.map +1 -0
- package/claude-plugin/dist/sessions/agent-discovery.d.ts +59 -0
- package/claude-plugin/dist/sessions/agent-discovery.d.ts.map +1 -0
- package/claude-plugin/dist/sessions/index.d.ts +10 -0
- package/claude-plugin/dist/sessions/index.d.ts.map +1 -0
- package/claude-plugin/dist/skills.d.ts +490 -0
- package/claude-plugin/dist/skills.d.ts.map +1 -0
- package/claude-plugin/dist/storage.d.ts +260 -0
- package/claude-plugin/dist/storage.d.ts.map +1 -0
- package/claude-plugin/dist/structured.d.ts +206 -0
- package/claude-plugin/dist/structured.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-adversarial-review.d.ts +104 -0
- package/claude-plugin/dist/swarm-adversarial-review.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-decompose.d.ts +297 -0
- package/claude-plugin/dist/swarm-decompose.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-insights.d.ts +390 -0
- package/claude-plugin/dist/swarm-insights.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-mail.d.ts +274 -0
- package/claude-plugin/dist/swarm-mail.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-orchestrate.d.ts +924 -0
- package/claude-plugin/dist/swarm-orchestrate.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-prompts.d.ts +467 -0
- package/claude-plugin/dist/swarm-prompts.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-prompts.js +45286 -0
- package/claude-plugin/dist/swarm-research.d.ts +125 -0
- package/claude-plugin/dist/swarm-research.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-review.d.ts +214 -0
- package/claude-plugin/dist/swarm-review.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-signature.d.ts +106 -0
- package/claude-plugin/dist/swarm-signature.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-strategies.d.ts +113 -0
- package/claude-plugin/dist/swarm-strategies.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-validation.d.ts +127 -0
- package/claude-plugin/dist/swarm-validation.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-worktree.d.ts +185 -0
- package/claude-plugin/dist/swarm-worktree.d.ts.map +1 -0
- package/claude-plugin/dist/swarm.d.ts +590 -0
- package/claude-plugin/dist/swarm.d.ts.map +1 -0
- package/claude-plugin/dist/tool-availability.d.ts +91 -0
- package/claude-plugin/dist/tool-availability.d.ts.map +1 -0
- package/claude-plugin/dist/utils/tree-renderer.d.ts +61 -0
- package/claude-plugin/dist/utils/tree-renderer.d.ts.map +1 -0
- package/claude-plugin/dist/validators/index.d.ts +7 -0
- package/claude-plugin/dist/validators/index.d.ts.map +1 -0
- package/claude-plugin/dist/validators/schema-validator.d.ts +58 -0
- package/claude-plugin/dist/validators/schema-validator.d.ts.map +1 -0
- package/claude-plugin/scripts/copyClaudePluginRuntimeAssets.ts +84 -0
- package/claude-plugin/skills/always-on-guidance/SKILL.md +45 -0
- package/claude-plugin/tests/mcp-runtime.test.ts +187 -0
- package/dist/agent-mail.d.ts +4 -4
- package/dist/agent-mail.d.ts.map +1 -1
- package/dist/bin/swarm.js +479 -20
- package/dist/build/mcp-bundle.d.ts +16 -0
- package/dist/build/mcp-bundle.d.ts.map +1 -0
- package/dist/cache/claude-plugin-cache.d.ts +41 -0
- package/dist/cache/claude-plugin-cache.d.ts.map +1 -0
- package/dist/claude-plugin/claude-plugin-assets.d.ts +10 -0
- package/dist/claude-plugin/claude-plugin-assets.d.ts.map +1 -0
- package/dist/compaction-hook.d.ts +1 -1
- package/dist/compaction-hook.d.ts.map +1 -1
- package/dist/index.js +371 -260
- package/dist/mcp/swarm-mcp-server.js +19675 -0
- package/dist/plugin.js +370 -259
- package/dist/skills.d.ts +15 -0
- package/dist/skills.d.ts.map +1 -1
- package/dist/swarm-mail.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts +3 -1
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-prompts.js +88 -8
- package/package.json +4 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Decompose Module - Task decomposition and validation
|
|
3
|
+
*
|
|
4
|
+
* Handles breaking tasks into parallelizable subtasks with file assignments,
|
|
5
|
+
* validates decomposition structure, and detects conflicts.
|
|
6
|
+
*
|
|
7
|
+
* Key responsibilities:
|
|
8
|
+
* - Decomposition prompt generation
|
|
9
|
+
* - CellTree validation
|
|
10
|
+
* - File conflict detection
|
|
11
|
+
* - Instruction conflict detection
|
|
12
|
+
* - Delegation to planner subagents
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
/**
|
|
16
|
+
* A detected conflict between subtask instructions
|
|
17
|
+
*/
|
|
18
|
+
export interface InstructionConflict {
|
|
19
|
+
subtask_a: number;
|
|
20
|
+
subtask_b: number;
|
|
21
|
+
directive_a: string;
|
|
22
|
+
directive_b: string;
|
|
23
|
+
conflict_type: "positive_negative" | "contradictory";
|
|
24
|
+
description: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Detect conflicts between subtask instructions
|
|
28
|
+
*
|
|
29
|
+
* Looks for cases where one subtask says "always use X" and another says "avoid X".
|
|
30
|
+
*
|
|
31
|
+
* @param subtasks - Array of subtask descriptions
|
|
32
|
+
* @returns Array of detected conflicts
|
|
33
|
+
*
|
|
34
|
+
* @see https://github.com/Dicklesworthstone/cass_memory_system/blob/main/src/curate.ts#L36-L89
|
|
35
|
+
*/
|
|
36
|
+
export declare function detectInstructionConflicts(subtasks: Array<{
|
|
37
|
+
title: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
}>): InstructionConflict[];
|
|
40
|
+
/**
|
|
41
|
+
* Detect file conflicts in a bead tree
|
|
42
|
+
*
|
|
43
|
+
* @param subtasks - Array of subtasks with file assignments
|
|
44
|
+
* @returns Array of files that appear in multiple subtasks
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectFileConflicts(subtasks: Array<{
|
|
47
|
+
files: string[];
|
|
48
|
+
}>): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Decompose a task into a bead tree
|
|
51
|
+
*
|
|
52
|
+
* This is a PROMPT tool - it returns a prompt for the agent to respond to.
|
|
53
|
+
* The agent's response (JSON) should be validated with CellTreeSchema.
|
|
54
|
+
*
|
|
55
|
+
* Optionally queries CASS for similar past tasks to inform decomposition.
|
|
56
|
+
*/
|
|
57
|
+
export declare const swarm_decompose: {
|
|
58
|
+
description: string;
|
|
59
|
+
args: {
|
|
60
|
+
task: z.ZodString;
|
|
61
|
+
context: z.ZodOptional<z.ZodString>;
|
|
62
|
+
query_cass: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
cass_limit: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
};
|
|
65
|
+
execute(args: {
|
|
66
|
+
task: string;
|
|
67
|
+
context?: string | undefined;
|
|
68
|
+
query_cass?: boolean | undefined;
|
|
69
|
+
cass_limit?: number | undefined;
|
|
70
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Validate a decomposition response from an agent
|
|
74
|
+
*
|
|
75
|
+
* Use this after the agent responds to swarm:decompose to validate the structure.
|
|
76
|
+
*/
|
|
77
|
+
export declare const swarm_validate_decomposition: {
|
|
78
|
+
description: string;
|
|
79
|
+
args: {
|
|
80
|
+
response: z.ZodString;
|
|
81
|
+
project_path: z.ZodOptional<z.ZodString>;
|
|
82
|
+
task: z.ZodOptional<z.ZodString>;
|
|
83
|
+
context: z.ZodOptional<z.ZodString>;
|
|
84
|
+
strategy: z.ZodOptional<z.ZodEnum<{
|
|
85
|
+
"file-based": "file-based";
|
|
86
|
+
"feature-based": "feature-based";
|
|
87
|
+
"risk-based": "risk-based";
|
|
88
|
+
auto: "auto";
|
|
89
|
+
}>>;
|
|
90
|
+
epic_id: z.ZodOptional<z.ZodString>;
|
|
91
|
+
};
|
|
92
|
+
execute(args: {
|
|
93
|
+
response: string;
|
|
94
|
+
project_path?: string | undefined;
|
|
95
|
+
task?: string | undefined;
|
|
96
|
+
context?: string | undefined;
|
|
97
|
+
strategy?: "file-based" | "feature-based" | "risk-based" | "auto" | undefined;
|
|
98
|
+
epic_id?: string | undefined;
|
|
99
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Delegate task decomposition to a swarm/planner subagent
|
|
103
|
+
*
|
|
104
|
+
* Returns a prompt for spawning a planner agent that will handle all decomposition
|
|
105
|
+
* reasoning. This keeps the coordinator context lean by offloading:
|
|
106
|
+
* - Strategy selection
|
|
107
|
+
* - CASS queries
|
|
108
|
+
* - Skills discovery
|
|
109
|
+
* - File analysis
|
|
110
|
+
* - CellTree generation
|
|
111
|
+
*
|
|
112
|
+
* The planner returns ONLY structured CellTree JSON, which the coordinator
|
|
113
|
+
* validates and uses to create cells.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // Coordinator workflow:
|
|
118
|
+
* const delegateResult = await swarm_delegate_planning({
|
|
119
|
+
* task: "Add user authentication",
|
|
120
|
+
* context: "Next.js 14 app",
|
|
121
|
+
* });
|
|
122
|
+
*
|
|
123
|
+
* // Parse the result
|
|
124
|
+
* const { prompt, subagent_type } = JSON.parse(delegateResult);
|
|
125
|
+
*
|
|
126
|
+
* // Spawn subagent using Task tool
|
|
127
|
+
* const plannerResponse = await Task(prompt, subagent_type);
|
|
128
|
+
*
|
|
129
|
+
* // Validate the response
|
|
130
|
+
* await swarm_validate_decomposition({ response: plannerResponse });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare const swarm_delegate_planning: {
|
|
134
|
+
description: string;
|
|
135
|
+
args: {
|
|
136
|
+
task: z.ZodString;
|
|
137
|
+
context: z.ZodOptional<z.ZodString>;
|
|
138
|
+
strategy: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
139
|
+
"file-based": "file-based";
|
|
140
|
+
"feature-based": "feature-based";
|
|
141
|
+
"risk-based": "risk-based";
|
|
142
|
+
auto: "auto";
|
|
143
|
+
}>>>;
|
|
144
|
+
query_cass: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
145
|
+
};
|
|
146
|
+
execute(args: {
|
|
147
|
+
task: string;
|
|
148
|
+
strategy: "file-based" | "feature-based" | "risk-based" | "auto";
|
|
149
|
+
query_cass: boolean;
|
|
150
|
+
context?: string | undefined;
|
|
151
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
152
|
+
};
|
|
153
|
+
export declare class SwarmError extends Error {
|
|
154
|
+
readonly operation: string;
|
|
155
|
+
readonly details?: unknown | undefined;
|
|
156
|
+
constructor(message: string, operation: string, details?: unknown | undefined);
|
|
157
|
+
}
|
|
158
|
+
export declare class DecompositionError extends SwarmError {
|
|
159
|
+
readonly zodError?: z.ZodError | undefined;
|
|
160
|
+
constructor(message: string, zodError?: z.ZodError | undefined);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Interactive planning tool with Socratic questioning
|
|
164
|
+
*
|
|
165
|
+
* Implements a planning phase BEFORE decomposition that:
|
|
166
|
+
* 1. Gathers context (git, files, semantic memory)
|
|
167
|
+
* 2. Asks clarifying questions (socratic mode)
|
|
168
|
+
* 3. Explores alternatives with tradeoffs
|
|
169
|
+
* 4. Recommends an approach with reasoning
|
|
170
|
+
* 5. Confirms before proceeding to decomposition
|
|
171
|
+
*
|
|
172
|
+
* Modes:
|
|
173
|
+
* - socratic: Full interactive planning with questions, alternatives, recommendations
|
|
174
|
+
* - fast: Skip brainstorming, go straight to decomposition with memory context
|
|
175
|
+
* - auto: Auto-select best approach based on task keywords, minimal interaction
|
|
176
|
+
* - confirm-only: Show decomposition, wait for yes/no confirmation
|
|
177
|
+
*
|
|
178
|
+
* Based on the Socratic Planner Pattern from obra/superpowers.
|
|
179
|
+
*
|
|
180
|
+
* @see docs/analysis-socratic-planner-pattern.md
|
|
181
|
+
*/
|
|
182
|
+
export declare const swarm_plan_interactive: {
|
|
183
|
+
description: string;
|
|
184
|
+
args: {
|
|
185
|
+
task: z.ZodString;
|
|
186
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
187
|
+
auto: "auto";
|
|
188
|
+
socratic: "socratic";
|
|
189
|
+
fast: "fast";
|
|
190
|
+
"confirm-only": "confirm-only";
|
|
191
|
+
}>>;
|
|
192
|
+
context: z.ZodOptional<z.ZodString>;
|
|
193
|
+
user_response: z.ZodOptional<z.ZodString>;
|
|
194
|
+
phase: z.ZodOptional<z.ZodEnum<{
|
|
195
|
+
ready: "ready";
|
|
196
|
+
alternatives: "alternatives";
|
|
197
|
+
questioning: "questioning";
|
|
198
|
+
recommendation: "recommendation";
|
|
199
|
+
}>>;
|
|
200
|
+
};
|
|
201
|
+
execute(args: {
|
|
202
|
+
task: string;
|
|
203
|
+
mode: "auto" | "socratic" | "fast" | "confirm-only";
|
|
204
|
+
context?: string | undefined;
|
|
205
|
+
user_response?: string | undefined;
|
|
206
|
+
phase?: "ready" | "alternatives" | "questioning" | "recommendation" | undefined;
|
|
207
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
208
|
+
};
|
|
209
|
+
export declare const decomposeTools: {
|
|
210
|
+
swarm_decompose: {
|
|
211
|
+
description: string;
|
|
212
|
+
args: {
|
|
213
|
+
task: z.ZodString;
|
|
214
|
+
context: z.ZodOptional<z.ZodString>;
|
|
215
|
+
query_cass: z.ZodOptional<z.ZodBoolean>;
|
|
216
|
+
cass_limit: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
};
|
|
218
|
+
execute(args: {
|
|
219
|
+
task: string;
|
|
220
|
+
context?: string | undefined;
|
|
221
|
+
query_cass?: boolean | undefined;
|
|
222
|
+
cass_limit?: number | undefined;
|
|
223
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
224
|
+
};
|
|
225
|
+
swarm_validate_decomposition: {
|
|
226
|
+
description: string;
|
|
227
|
+
args: {
|
|
228
|
+
response: z.ZodString;
|
|
229
|
+
project_path: z.ZodOptional<z.ZodString>;
|
|
230
|
+
task: z.ZodOptional<z.ZodString>;
|
|
231
|
+
context: z.ZodOptional<z.ZodString>;
|
|
232
|
+
strategy: z.ZodOptional<z.ZodEnum<{
|
|
233
|
+
"file-based": "file-based";
|
|
234
|
+
"feature-based": "feature-based";
|
|
235
|
+
"risk-based": "risk-based";
|
|
236
|
+
auto: "auto";
|
|
237
|
+
}>>;
|
|
238
|
+
epic_id: z.ZodOptional<z.ZodString>;
|
|
239
|
+
};
|
|
240
|
+
execute(args: {
|
|
241
|
+
response: string;
|
|
242
|
+
project_path?: string | undefined;
|
|
243
|
+
task?: string | undefined;
|
|
244
|
+
context?: string | undefined;
|
|
245
|
+
strategy?: "file-based" | "feature-based" | "risk-based" | "auto" | undefined;
|
|
246
|
+
epic_id?: string | undefined;
|
|
247
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
248
|
+
};
|
|
249
|
+
swarm_delegate_planning: {
|
|
250
|
+
description: string;
|
|
251
|
+
args: {
|
|
252
|
+
task: z.ZodString;
|
|
253
|
+
context: z.ZodOptional<z.ZodString>;
|
|
254
|
+
strategy: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
255
|
+
"file-based": "file-based";
|
|
256
|
+
"feature-based": "feature-based";
|
|
257
|
+
"risk-based": "risk-based";
|
|
258
|
+
auto: "auto";
|
|
259
|
+
}>>>;
|
|
260
|
+
query_cass: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
261
|
+
};
|
|
262
|
+
execute(args: {
|
|
263
|
+
task: string;
|
|
264
|
+
strategy: "file-based" | "feature-based" | "risk-based" | "auto";
|
|
265
|
+
query_cass: boolean;
|
|
266
|
+
context?: string | undefined;
|
|
267
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
268
|
+
};
|
|
269
|
+
swarm_plan_interactive: {
|
|
270
|
+
description: string;
|
|
271
|
+
args: {
|
|
272
|
+
task: z.ZodString;
|
|
273
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
274
|
+
auto: "auto";
|
|
275
|
+
socratic: "socratic";
|
|
276
|
+
fast: "fast";
|
|
277
|
+
"confirm-only": "confirm-only";
|
|
278
|
+
}>>;
|
|
279
|
+
context: z.ZodOptional<z.ZodString>;
|
|
280
|
+
user_response: z.ZodOptional<z.ZodString>;
|
|
281
|
+
phase: z.ZodOptional<z.ZodEnum<{
|
|
282
|
+
ready: "ready";
|
|
283
|
+
alternatives: "alternatives";
|
|
284
|
+
questioning: "questioning";
|
|
285
|
+
recommendation: "recommendation";
|
|
286
|
+
}>>;
|
|
287
|
+
};
|
|
288
|
+
execute(args: {
|
|
289
|
+
task: string;
|
|
290
|
+
mode: "auto" | "socratic" | "fast" | "confirm-only";
|
|
291
|
+
context?: string | undefined;
|
|
292
|
+
user_response?: string | undefined;
|
|
293
|
+
phase?: "ready" | "alternatives" | "questioning" | "recommendation" | undefined;
|
|
294
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
//# sourceMappingURL=swarm-decompose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-decompose.d.ts","sourceRoot":"","sources":["../src/swarm-decompose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0JxB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,mBAAmB,GAAG,eAAe,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;CACrB;AA8CD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACvD,mBAAmB,EAAE,CAmDvB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,GACnC,MAAM,EAAE,CAgBV;AA+GD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;CAiG1B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;CAqKvC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;CAkOlC,CAAC;AAMH,qBAAa,UAAW,SAAQ,KAAK;aAGjB,SAAS,EAAE,MAAM;aACjB,OAAO,CAAC,EAAE,OAAO;gBAFjC,OAAO,EAAE,MAAM,EACC,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,OAAO,YAAA;CAKpC;AAED,qBAAa,kBAAmB,SAAQ,UAAU;aAG9B,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ;gBADrC,OAAO,EAAE,MAAM,EACC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,YAAA;CAIxC;AAkCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;CA0RjC,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAK1B,CAAC"}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Insights Data Layer
|
|
3
|
+
*
|
|
4
|
+
* Aggregates insights from swarm coordination for prompt injection.
|
|
5
|
+
* Provides concise, context-efficient summaries for coordinators and workers.
|
|
6
|
+
*
|
|
7
|
+
* Data sources:
|
|
8
|
+
* - Event store (subtask_outcome, eval_finalized)
|
|
9
|
+
* - Semantic memory (file-specific learnings)
|
|
10
|
+
* - Anti-pattern registry
|
|
11
|
+
*/
|
|
12
|
+
import type { SwarmMailAdapter } from "swarm-mail";
|
|
13
|
+
export interface StrategyInsight {
|
|
14
|
+
strategy: string;
|
|
15
|
+
successRate: number;
|
|
16
|
+
totalAttempts: number;
|
|
17
|
+
recommendation: string;
|
|
18
|
+
}
|
|
19
|
+
export interface FileInsight {
|
|
20
|
+
file: string;
|
|
21
|
+
failureCount: number;
|
|
22
|
+
lastFailure: string | null;
|
|
23
|
+
gotchas: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface FileFailureHistory {
|
|
26
|
+
file: string;
|
|
27
|
+
rejectionCount: number;
|
|
28
|
+
topIssues: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface PatternInsight {
|
|
31
|
+
pattern: string;
|
|
32
|
+
frequency: number;
|
|
33
|
+
recommendation: string;
|
|
34
|
+
}
|
|
35
|
+
export interface InsightsBundle {
|
|
36
|
+
strategies?: StrategyInsight[];
|
|
37
|
+
files?: FileInsight[];
|
|
38
|
+
patterns?: PatternInsight[];
|
|
39
|
+
}
|
|
40
|
+
export interface FormatOptions {
|
|
41
|
+
maxTokens?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface RejectionReason {
|
|
44
|
+
category: string;
|
|
45
|
+
count: number;
|
|
46
|
+
percentage: number;
|
|
47
|
+
}
|
|
48
|
+
export interface RejectionAnalytics {
|
|
49
|
+
totalReviews: number;
|
|
50
|
+
approved: number;
|
|
51
|
+
rejected: number;
|
|
52
|
+
approvalRate: number;
|
|
53
|
+
topReasons: RejectionReason[];
|
|
54
|
+
}
|
|
55
|
+
export interface ViolationMetric {
|
|
56
|
+
violationType: string;
|
|
57
|
+
count: number;
|
|
58
|
+
percentage: number;
|
|
59
|
+
}
|
|
60
|
+
export interface ViolationAnalytics {
|
|
61
|
+
totalViolations: number;
|
|
62
|
+
byType: ViolationMetric[];
|
|
63
|
+
violationRate: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get strategy success rates and recommendations for a task.
|
|
67
|
+
*
|
|
68
|
+
* Queries the event store for subtask_outcome events and calculates
|
|
69
|
+
* success rates by strategy. Returns recommendations based on historical data.
|
|
70
|
+
*
|
|
71
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
72
|
+
* @param _task - Task description (currently unused, reserved for future filtering)
|
|
73
|
+
* @returns Promise resolving to array of strategy insights with success rates and recommendations
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const insights = await getStrategyInsights(swarmMail, "Add authentication");
|
|
78
|
+
* // Returns: [
|
|
79
|
+
* // { strategy: "file-based", successRate: 85.5, totalAttempts: 12, recommendation: "..." },
|
|
80
|
+
* // { strategy: "feature-based", successRate: 65.0, totalAttempts: 8, recommendation: "..." }
|
|
81
|
+
* // ]
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function getStrategyInsights(swarmMail: SwarmMailAdapter, _task: string): Promise<StrategyInsight[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Get insights for specific files based on historical outcomes.
|
|
87
|
+
*
|
|
88
|
+
* Queries the event store for failures involving these files and
|
|
89
|
+
* semantic memory for file-specific gotchas.
|
|
90
|
+
*
|
|
91
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
92
|
+
* @param files - Array of file paths to analyze
|
|
93
|
+
* @returns Promise resolving to array of file-specific insights including failure counts and gotchas
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const insights = await getFileInsights(swarmMail, ["src/auth.ts", "src/db.ts"]);
|
|
98
|
+
* // Returns: [
|
|
99
|
+
* // { file: "src/auth.ts", failureCount: 3, lastFailure: "2025-12-20T10:30:00Z", gotchas: [...] }
|
|
100
|
+
* // ]
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function getFileInsights(swarmMail: SwarmMailAdapter, files: string[]): Promise<FileInsight[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Get file-specific gotchas from semantic memory (hivemind).
|
|
106
|
+
*
|
|
107
|
+
* Queries semantic memory for learnings related to a specific file.
|
|
108
|
+
* Used in worker prompts to surface historical issues/warnings.
|
|
109
|
+
*
|
|
110
|
+
* Strategy:
|
|
111
|
+
* 1. Query hivemind with file path + "gotcha pitfall warning" keywords
|
|
112
|
+
* 2. Filter results to only include memories that mention the specific file
|
|
113
|
+
* 3. Return top 3 learnings, truncated to ~100 chars each for context efficiency
|
|
114
|
+
*
|
|
115
|
+
* @param _swarmMail - SwarmMail adapter (unused, kept for API consistency)
|
|
116
|
+
* @param file - File path to query learnings for
|
|
117
|
+
* @returns Promise resolving to array of gotcha strings (max 3)
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const gotchas = await getFileGotchas(swarmMail, "src/auth.ts");
|
|
122
|
+
* // Returns semantic memory learnings like:
|
|
123
|
+
* // ["OAuth tokens need 5min buffer before expiry to avoid race conditions in src/auth.ts", ...]
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function getFileGotchas(_swarmMail: SwarmMailAdapter, file: string): Promise<string[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Get failure history for specific files from review feedback events.
|
|
129
|
+
*
|
|
130
|
+
* Queries the event store for review_feedback events where status="needs_changes"
|
|
131
|
+
* and aggregates rejection reasons by file. Returns top 3 most common issues per file.
|
|
132
|
+
*
|
|
133
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
134
|
+
* @param files - Array of file paths to query history for
|
|
135
|
+
* @returns Promise resolving to array of file failure histories with rejection counts and top issues
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const history = await getFileFailureHistory(swarmMail, ["src/auth.ts", "src/db.ts"]);
|
|
140
|
+
* // Returns: [
|
|
141
|
+
* // { file: "src/auth.ts", rejectionCount: 3, topIssues: ["Missing null checks", "Forgot rate limiting"] }
|
|
142
|
+
* // ]
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export declare function getFileFailureHistory(swarmMail: SwarmMailAdapter, files: string[]): Promise<FileFailureHistory[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Get rejection analytics from review feedback events.
|
|
148
|
+
*
|
|
149
|
+
* Analyzes review_feedback events to calculate approval/rejection rates and
|
|
150
|
+
* categorize common rejection reasons. Returns aggregated analytics suitable
|
|
151
|
+
* for the swarm stats --rejections dashboard.
|
|
152
|
+
*
|
|
153
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
154
|
+
* @returns Promise resolving to rejection analytics with rates and categorized reasons
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const analytics = await getRejectionAnalytics(swarmMail);
|
|
159
|
+
* // Returns: {
|
|
160
|
+
* // totalReviews: 449,
|
|
161
|
+
* // approved: 175,
|
|
162
|
+
* // rejected: 274,
|
|
163
|
+
* // approvalRate: 38.97,
|
|
164
|
+
* // topReasons: [
|
|
165
|
+
* // { category: "Missing tests", count: 89, percentage: 32.48 },
|
|
166
|
+
* // { category: "Type errors", count: 67, percentage: 24.45 }
|
|
167
|
+
* // ]
|
|
168
|
+
* // }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare function getRejectionAnalytics(swarmMail: SwarmMailAdapter): Promise<RejectionAnalytics>;
|
|
172
|
+
/**
|
|
173
|
+
* Get common failure patterns and anti-patterns.
|
|
174
|
+
*
|
|
175
|
+
* Analyzes event store for recurring failure patterns and
|
|
176
|
+
* queries the anti-pattern registry.
|
|
177
|
+
*
|
|
178
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
179
|
+
* @returns Promise resolving to array of pattern insights with frequency and recommendations
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const patterns = await getPatternInsights(swarmMail);
|
|
184
|
+
* // Returns: [
|
|
185
|
+
* // { pattern: "type_error", frequency: 5, recommendation: "Add explicit type annotations and null checks" },
|
|
186
|
+
* // { pattern: "timeout", frequency: 3, recommendation: "Consider breaking into smaller tasks" }
|
|
187
|
+
* // ]
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare function getPatternInsights(swarmMail: SwarmMailAdapter): Promise<PatternInsight[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Format insights bundle for prompt injection.
|
|
193
|
+
*
|
|
194
|
+
* Produces a concise, context-efficient summary suitable for
|
|
195
|
+
* inclusion in coordinator or worker prompts.
|
|
196
|
+
*
|
|
197
|
+
* @param bundle - Insights bundle containing strategies, files, and patterns
|
|
198
|
+
* @param options - Formatting options (maxTokens defaults to 500)
|
|
199
|
+
* @returns Formatted markdown string for prompt injection, or empty string if no insights
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const bundle = {
|
|
204
|
+
* strategies: [{ strategy: "file-based", successRate: 85.5, totalAttempts: 12, recommendation: "..." }],
|
|
205
|
+
* files: [{ file: "src/auth.ts", failureCount: 2, lastFailure: null, gotchas: [] }],
|
|
206
|
+
* patterns: [{ pattern: "type_error", frequency: 3, recommendation: "Add type checks" }]
|
|
207
|
+
* };
|
|
208
|
+
* const formatted = formatInsightsForPrompt(bundle, { maxTokens: 300 });
|
|
209
|
+
* // Returns formatted markdown with top 3 strategies, top 5 files, top 3 patterns
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export declare function formatInsightsForPrompt(bundle: InsightsBundle, options?: FormatOptions): string;
|
|
213
|
+
/**
|
|
214
|
+
* Get cached insights or compute fresh ones.
|
|
215
|
+
*
|
|
216
|
+
* Simple in-memory cache with 5-minute TTL to avoid redundant database queries.
|
|
217
|
+
*
|
|
218
|
+
* @param _swarmMail - SwarmMail adapter (currently unused, reserved for future cache invalidation)
|
|
219
|
+
* @param cacheKey - Unique key for caching (e.g., "strategies:task-name" or "files:src/auth.ts")
|
|
220
|
+
* @param computeFn - Function to compute fresh insights if cache miss
|
|
221
|
+
* @returns Promise resolving to cached or freshly computed insights bundle
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const insights = await getCachedInsights(
|
|
226
|
+
* swarmMail,
|
|
227
|
+
* "strategies:add-auth",
|
|
228
|
+
* async () => ({
|
|
229
|
+
* strategies: await getStrategyInsights(swarmMail, "add auth"),
|
|
230
|
+
* })
|
|
231
|
+
* );
|
|
232
|
+
* // First call: computes and caches. Subsequent calls within 5min: returns cached.
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
export declare function getCachedInsights(_swarmMail: SwarmMailAdapter, cacheKey: string, computeFn: () => Promise<InsightsBundle>): Promise<InsightsBundle>;
|
|
236
|
+
/**
|
|
237
|
+
* Clear the insights cache.
|
|
238
|
+
*
|
|
239
|
+
* Useful for testing or forcing fresh insights computation.
|
|
240
|
+
*
|
|
241
|
+
* @returns void
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* clearInsightsCache();
|
|
246
|
+
* // All cached insights invalidated, next getCachedInsights() will recompute
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export declare function clearInsightsCache(): void;
|
|
250
|
+
/**
|
|
251
|
+
* Track a coordinator violation event in the event store.
|
|
252
|
+
*
|
|
253
|
+
* Records when a coordinator attempts forbidden actions (editing files,
|
|
254
|
+
* running tests, reserving files). These events feed violation analytics
|
|
255
|
+
* for swarm health monitoring.
|
|
256
|
+
*
|
|
257
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
258
|
+
* @param violation - Violation details
|
|
259
|
+
* @returns Promise resolving to event ID
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* import { CoordinatorGuardError } from "./coordinator-guard";
|
|
264
|
+
*
|
|
265
|
+
* try {
|
|
266
|
+
* // Coordinator attempts to edit file
|
|
267
|
+
* } catch (error) {
|
|
268
|
+
* if (error instanceof CoordinatorGuardError) {
|
|
269
|
+
* await trackCoordinatorViolation(swarmMail, {
|
|
270
|
+
* project_key: "/abs/path/to/project",
|
|
271
|
+
* session_id: "session-123",
|
|
272
|
+
* epic_id: "mjudv5mwh66",
|
|
273
|
+
* violation_type: error.violationType,
|
|
274
|
+
* payload: error.payload,
|
|
275
|
+
* });
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
export declare function trackCoordinatorViolation(swarmMail: SwarmMailAdapter, violation: {
|
|
281
|
+
project_key: string;
|
|
282
|
+
session_id: string;
|
|
283
|
+
epic_id: string;
|
|
284
|
+
violation_type: "coordinator_edited_file" | "coordinator_ran_tests" | "coordinator_reserved_files";
|
|
285
|
+
payload: Record<string, unknown>;
|
|
286
|
+
}): Promise<number>;
|
|
287
|
+
/**
|
|
288
|
+
* Get violation analytics from coordinator guard events.
|
|
289
|
+
*
|
|
290
|
+
* Analyzes coordinator_violation events to calculate total violations,
|
|
291
|
+
* breakdown by type, and violation rate relative to total coordination
|
|
292
|
+
* actions. Used in swarm_status output to surface coordinator discipline.
|
|
293
|
+
*
|
|
294
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
295
|
+
* @param projectKey - Optional project key to filter violations
|
|
296
|
+
* @returns Promise resolving to violation analytics
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* const analytics = await getViolationAnalytics(swarmMail);
|
|
301
|
+
* // Returns: {
|
|
302
|
+
* // totalViolations: 12,
|
|
303
|
+
* // byType: [
|
|
304
|
+
* // { violationType: "coordinator_edited_file", count: 8, percentage: 66.67 },
|
|
305
|
+
* // { violationType: "coordinator_ran_tests", count: 3, percentage: 25.00 },
|
|
306
|
+
* // { violationType: "coordinator_reserved_files", count: 1, percentage: 8.33 }
|
|
307
|
+
* // ],
|
|
308
|
+
* // violationRate: 2.4 // 12 violations per 500 coordination actions = 2.4%
|
|
309
|
+
* // }
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
export declare function getViolationAnalytics(swarmMail: SwarmMailAdapter, projectKey?: string): Promise<ViolationAnalytics>;
|
|
313
|
+
export interface CompactionPromptPreview {
|
|
314
|
+
timestamp: string;
|
|
315
|
+
length: number;
|
|
316
|
+
preview?: string;
|
|
317
|
+
confidence?: string;
|
|
318
|
+
}
|
|
319
|
+
export interface CompactionAnalytics {
|
|
320
|
+
totalEvents: number;
|
|
321
|
+
byType: {
|
|
322
|
+
prompt_generated: number;
|
|
323
|
+
detection_complete: number;
|
|
324
|
+
context_injected: number;
|
|
325
|
+
resumption_started: number;
|
|
326
|
+
tool_call_tracked: number;
|
|
327
|
+
[key: string]: number;
|
|
328
|
+
};
|
|
329
|
+
avgPromptSize: number;
|
|
330
|
+
successRate: number;
|
|
331
|
+
recentPrompts: CompactionPromptPreview[];
|
|
332
|
+
byConfidence: {
|
|
333
|
+
high: number;
|
|
334
|
+
medium: number;
|
|
335
|
+
low: number;
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Get analytics for coordinator compaction events.
|
|
340
|
+
*
|
|
341
|
+
* Queries coordinator_compaction events to calculate:
|
|
342
|
+
* - Total compaction attempts by type (prompt_generated vs detection_failed)
|
|
343
|
+
* - Average prompt size for successful compactions
|
|
344
|
+
* - Success/failure rate
|
|
345
|
+
* - Recent prompts with preview (truncated to 200 chars)
|
|
346
|
+
* - Confidence distribution
|
|
347
|
+
*
|
|
348
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
349
|
+
* @returns Promise resolving to compaction analytics
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```typescript
|
|
353
|
+
* const analytics = await getCompactionAnalytics(swarmMail);
|
|
354
|
+
* // Returns: {
|
|
355
|
+
* // totalEvents: 83,
|
|
356
|
+
* // byType: { prompt_generated: 72, detection_failed: 11 },
|
|
357
|
+
* // avgPromptSize: 4800,
|
|
358
|
+
* // successRate: 86.7,
|
|
359
|
+
* // recentPrompts: [
|
|
360
|
+
* // { timestamp: "2025-12-25T10:00:00Z", length: 5200, preview: "Epic bd-123...", confidence: "high" }
|
|
361
|
+
* // ],
|
|
362
|
+
* // byConfidence: { high: 60, medium: 12, low: 11 }
|
|
363
|
+
* // }
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
export declare function getCompactionAnalytics(swarmMail: SwarmMailAdapter): Promise<CompactionAnalytics>;
|
|
367
|
+
/**
|
|
368
|
+
* Format file failure history as warnings for worker prompts.
|
|
369
|
+
*
|
|
370
|
+
* Produces a concise warning section showing which files have caused
|
|
371
|
+
* previous workers to fail review, with the top issues encountered.
|
|
372
|
+
*
|
|
373
|
+
* Limits output to fit context budget (~300 tokens).
|
|
374
|
+
*
|
|
375
|
+
* @param histories - Array of file failure histories
|
|
376
|
+
* @returns Formatted warning section with emoji header, or empty string if no histories
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const histories = [
|
|
381
|
+
* { file: "src/auth.ts", rejectionCount: 3, topIssues: ["Missing null checks", "Forgot rate limiting"] }
|
|
382
|
+
* ];
|
|
383
|
+
* const warnings = formatFileHistoryWarnings(histories);
|
|
384
|
+
* // Returns:
|
|
385
|
+
* // ⚠️ FILE HISTORY WARNINGS:
|
|
386
|
+
* // - src/auth.ts: 3 previous workers rejected for missing null checks, forgot rate limiting
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
export declare function formatFileHistoryWarnings(histories: FileFailureHistory[]): string;
|
|
390
|
+
//# sourceMappingURL=swarm-insights.d.ts.map
|