opencode-swarm-plugin 0.56.0 → 0.57.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 (186) hide show
  1. package/README.md +21 -0
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -4
  3. package/claude-plugin/agents/background-worker.md +1 -0
  4. package/claude-plugin/agents/coordinator.md +1 -0
  5. package/claude-plugin/agents/worker.md +1 -0
  6. package/claude-plugin/bin/swarm-mcp-server.ts +47 -8
  7. package/claude-plugin/commands/hive.md +1 -1
  8. package/claude-plugin/commands/swarm.md +5 -1
  9. package/claude-plugin/dist/agent-mail.d.ts +480 -0
  10. package/claude-plugin/dist/agent-mail.d.ts.map +1 -0
  11. package/claude-plugin/dist/anti-patterns.d.ts +257 -0
  12. package/claude-plugin/dist/anti-patterns.d.ts.map +1 -0
  13. package/claude-plugin/dist/bin/swarm.js +373128 -0
  14. package/claude-plugin/dist/cass-tools.d.ts +74 -0
  15. package/claude-plugin/dist/cass-tools.d.ts.map +1 -0
  16. package/claude-plugin/dist/claude-plugin/claude-plugin-assets.d.ts +10 -0
  17. package/claude-plugin/dist/claude-plugin/claude-plugin-assets.d.ts.map +1 -0
  18. package/claude-plugin/dist/compaction-hook.d.ts +178 -0
  19. package/claude-plugin/dist/compaction-hook.d.ts.map +1 -0
  20. package/claude-plugin/dist/compaction-observability.d.ts +173 -0
  21. package/claude-plugin/dist/compaction-observability.d.ts.map +1 -0
  22. package/claude-plugin/dist/compaction-prompt-scoring.d.ts +125 -0
  23. package/claude-plugin/dist/compaction-prompt-scoring.d.ts.map +1 -0
  24. package/claude-plugin/dist/compaction-prompt-scoring.js +139 -0
  25. package/claude-plugin/dist/contributor-tools.d.ts +42 -0
  26. package/claude-plugin/dist/contributor-tools.d.ts.map +1 -0
  27. package/claude-plugin/dist/coordinator-guard.d.ts +79 -0
  28. package/claude-plugin/dist/coordinator-guard.d.ts.map +1 -0
  29. package/claude-plugin/dist/dashboard.d.ts +82 -0
  30. package/claude-plugin/dist/dashboard.d.ts.map +1 -0
  31. package/claude-plugin/dist/decision-trace-integration.d.ts +204 -0
  32. package/claude-plugin/dist/decision-trace-integration.d.ts.map +1 -0
  33. package/claude-plugin/dist/error-enrichment.d.ts +49 -0
  34. package/claude-plugin/dist/error-enrichment.d.ts.map +1 -0
  35. package/claude-plugin/dist/eval-capture.d.ts +494 -0
  36. package/claude-plugin/dist/eval-capture.d.ts.map +1 -0
  37. package/claude-plugin/dist/eval-capture.js +12844 -0
  38. package/claude-plugin/dist/eval-gates.d.ts +84 -0
  39. package/claude-plugin/dist/eval-gates.d.ts.map +1 -0
  40. package/claude-plugin/dist/eval-history.d.ts +117 -0
  41. package/claude-plugin/dist/eval-history.d.ts.map +1 -0
  42. package/claude-plugin/dist/eval-learning.d.ts +216 -0
  43. package/claude-plugin/dist/eval-learning.d.ts.map +1 -0
  44. package/claude-plugin/dist/eval-runner.d.ts +134 -0
  45. package/claude-plugin/dist/eval-runner.d.ts.map +1 -0
  46. package/claude-plugin/dist/examples/plugin-wrapper-template.ts +3341 -0
  47. package/claude-plugin/dist/export-tools.d.ts +76 -0
  48. package/claude-plugin/dist/export-tools.d.ts.map +1 -0
  49. package/claude-plugin/dist/hive.d.ts +949 -0
  50. package/claude-plugin/dist/hive.d.ts.map +1 -0
  51. package/claude-plugin/dist/hive.js +15009 -0
  52. package/claude-plugin/dist/hivemind-tools.d.ts +479 -0
  53. package/claude-plugin/dist/hivemind-tools.d.ts.map +1 -0
  54. package/claude-plugin/dist/hooks/atomic-write.d.ts +21 -0
  55. package/claude-plugin/dist/hooks/atomic-write.d.ts.map +1 -0
  56. package/claude-plugin/dist/hooks/constants.d.ts +28 -0
  57. package/claude-plugin/dist/hooks/constants.d.ts.map +1 -0
  58. package/claude-plugin/dist/hooks/index.d.ts +16 -0
  59. package/claude-plugin/dist/hooks/index.d.ts.map +1 -0
  60. package/claude-plugin/dist/hooks/session-start.d.ts +30 -0
  61. package/claude-plugin/dist/hooks/session-start.d.ts.map +1 -0
  62. package/claude-plugin/dist/hooks/tool-complete.d.ts +54 -0
  63. package/claude-plugin/dist/hooks/tool-complete.d.ts.map +1 -0
  64. package/claude-plugin/dist/index.d.ts +2017 -0
  65. package/claude-plugin/dist/index.d.ts.map +1 -0
  66. package/claude-plugin/dist/index.js +73453 -0
  67. package/claude-plugin/dist/learning.d.ts +700 -0
  68. package/claude-plugin/dist/learning.d.ts.map +1 -0
  69. package/claude-plugin/dist/logger.d.ts +38 -0
  70. package/claude-plugin/dist/logger.d.ts.map +1 -0
  71. package/claude-plugin/dist/mandate-promotion.d.ts +93 -0
  72. package/claude-plugin/dist/mandate-promotion.d.ts.map +1 -0
  73. package/claude-plugin/dist/mandate-storage.d.ts +209 -0
  74. package/claude-plugin/dist/mandate-storage.d.ts.map +1 -0
  75. package/claude-plugin/dist/mandates.d.ts +230 -0
  76. package/claude-plugin/dist/mandates.d.ts.map +1 -0
  77. package/claude-plugin/dist/memory-tools.d.ts +281 -0
  78. package/claude-plugin/dist/memory-tools.d.ts.map +1 -0
  79. package/claude-plugin/dist/memory.d.ts +164 -0
  80. package/claude-plugin/dist/memory.d.ts.map +1 -0
  81. package/claude-plugin/dist/model-selection.d.ts +37 -0
  82. package/claude-plugin/dist/model-selection.d.ts.map +1 -0
  83. package/claude-plugin/dist/observability-health.d.ts +87 -0
  84. package/claude-plugin/dist/observability-health.d.ts.map +1 -0
  85. package/claude-plugin/dist/observability-tools.d.ts +184 -0
  86. package/claude-plugin/dist/observability-tools.d.ts.map +1 -0
  87. package/claude-plugin/dist/output-guardrails.d.ts +125 -0
  88. package/claude-plugin/dist/output-guardrails.d.ts.map +1 -0
  89. package/claude-plugin/dist/pattern-maturity.d.ts +246 -0
  90. package/claude-plugin/dist/pattern-maturity.d.ts.map +1 -0
  91. package/claude-plugin/dist/planning-guardrails.d.ts +183 -0
  92. package/claude-plugin/dist/planning-guardrails.d.ts.map +1 -0
  93. package/claude-plugin/dist/plugin.d.ts +22 -0
  94. package/claude-plugin/dist/plugin.d.ts.map +1 -0
  95. package/claude-plugin/dist/plugin.js +72295 -0
  96. package/claude-plugin/dist/post-compaction-tracker.d.ts +133 -0
  97. package/claude-plugin/dist/post-compaction-tracker.d.ts.map +1 -0
  98. package/claude-plugin/dist/query-tools.d.ts +90 -0
  99. package/claude-plugin/dist/query-tools.d.ts.map +1 -0
  100. package/claude-plugin/dist/rate-limiter.d.ts +218 -0
  101. package/claude-plugin/dist/rate-limiter.d.ts.map +1 -0
  102. package/claude-plugin/dist/regression-detection.d.ts +58 -0
  103. package/claude-plugin/dist/regression-detection.d.ts.map +1 -0
  104. package/claude-plugin/dist/replay-tools.d.ts +28 -0
  105. package/claude-plugin/dist/replay-tools.d.ts.map +1 -0
  106. package/claude-plugin/dist/repo-crawl.d.ts +146 -0
  107. package/claude-plugin/dist/repo-crawl.d.ts.map +1 -0
  108. package/claude-plugin/dist/schemas/cell-events.d.ts +1352 -0
  109. package/claude-plugin/dist/schemas/cell-events.d.ts.map +1 -0
  110. package/claude-plugin/dist/schemas/cell.d.ts +413 -0
  111. package/claude-plugin/dist/schemas/cell.d.ts.map +1 -0
  112. package/claude-plugin/dist/schemas/evaluation.d.ts +161 -0
  113. package/claude-plugin/dist/schemas/evaluation.d.ts.map +1 -0
  114. package/claude-plugin/dist/schemas/index.d.ts +46 -0
  115. package/claude-plugin/dist/schemas/index.d.ts.map +1 -0
  116. package/claude-plugin/dist/schemas/mandate.d.ts +336 -0
  117. package/claude-plugin/dist/schemas/mandate.d.ts.map +1 -0
  118. package/claude-plugin/dist/schemas/swarm-context.d.ts +131 -0
  119. package/claude-plugin/dist/schemas/swarm-context.d.ts.map +1 -0
  120. package/claude-plugin/dist/schemas/task.d.ts +189 -0
  121. package/claude-plugin/dist/schemas/task.d.ts.map +1 -0
  122. package/claude-plugin/dist/schemas/worker-handoff.d.ts +78 -0
  123. package/claude-plugin/dist/schemas/worker-handoff.d.ts.map +1 -0
  124. package/claude-plugin/dist/sessions/agent-discovery.d.ts +59 -0
  125. package/claude-plugin/dist/sessions/agent-discovery.d.ts.map +1 -0
  126. package/claude-plugin/dist/sessions/index.d.ts +10 -0
  127. package/claude-plugin/dist/sessions/index.d.ts.map +1 -0
  128. package/claude-plugin/dist/skills.d.ts +490 -0
  129. package/claude-plugin/dist/skills.d.ts.map +1 -0
  130. package/claude-plugin/dist/storage.d.ts +260 -0
  131. package/claude-plugin/dist/storage.d.ts.map +1 -0
  132. package/claude-plugin/dist/structured.d.ts +206 -0
  133. package/claude-plugin/dist/structured.d.ts.map +1 -0
  134. package/claude-plugin/dist/swarm-adversarial-review.d.ts +104 -0
  135. package/claude-plugin/dist/swarm-adversarial-review.d.ts.map +1 -0
  136. package/claude-plugin/dist/swarm-decompose.d.ts +297 -0
  137. package/claude-plugin/dist/swarm-decompose.d.ts.map +1 -0
  138. package/claude-plugin/dist/swarm-insights.d.ts +390 -0
  139. package/claude-plugin/dist/swarm-insights.d.ts.map +1 -0
  140. package/claude-plugin/dist/swarm-mail.d.ts +274 -0
  141. package/claude-plugin/dist/swarm-mail.d.ts.map +1 -0
  142. package/claude-plugin/dist/swarm-orchestrate.d.ts +924 -0
  143. package/claude-plugin/dist/swarm-orchestrate.d.ts.map +1 -0
  144. package/claude-plugin/dist/swarm-prompts.d.ts +467 -0
  145. package/claude-plugin/dist/swarm-prompts.d.ts.map +1 -0
  146. package/claude-plugin/dist/swarm-prompts.js +45283 -0
  147. package/claude-plugin/dist/swarm-research.d.ts +125 -0
  148. package/claude-plugin/dist/swarm-research.d.ts.map +1 -0
  149. package/claude-plugin/dist/swarm-review.d.ts +214 -0
  150. package/claude-plugin/dist/swarm-review.d.ts.map +1 -0
  151. package/claude-plugin/dist/swarm-signature.d.ts +106 -0
  152. package/claude-plugin/dist/swarm-signature.d.ts.map +1 -0
  153. package/claude-plugin/dist/swarm-strategies.d.ts +113 -0
  154. package/claude-plugin/dist/swarm-strategies.d.ts.map +1 -0
  155. package/claude-plugin/dist/swarm-validation.d.ts +127 -0
  156. package/claude-plugin/dist/swarm-validation.d.ts.map +1 -0
  157. package/claude-plugin/dist/swarm-worktree.d.ts +185 -0
  158. package/claude-plugin/dist/swarm-worktree.d.ts.map +1 -0
  159. package/claude-plugin/dist/swarm.d.ts +590 -0
  160. package/claude-plugin/dist/swarm.d.ts.map +1 -0
  161. package/claude-plugin/dist/tool-availability.d.ts +91 -0
  162. package/claude-plugin/dist/tool-availability.d.ts.map +1 -0
  163. package/claude-plugin/dist/utils/tree-renderer.d.ts +61 -0
  164. package/claude-plugin/dist/utils/tree-renderer.d.ts.map +1 -0
  165. package/claude-plugin/dist/validators/index.d.ts +7 -0
  166. package/claude-plugin/dist/validators/index.d.ts.map +1 -0
  167. package/claude-plugin/dist/validators/schema-validator.d.ts +58 -0
  168. package/claude-plugin/dist/validators/schema-validator.d.ts.map +1 -0
  169. package/claude-plugin/skills/always-on-guidance/SKILL.md +44 -0
  170. package/dist/agent-mail.d.ts +4 -4
  171. package/dist/agent-mail.d.ts.map +1 -1
  172. package/dist/bin/swarm.js +477 -22
  173. package/dist/claude-plugin/claude-plugin-assets.d.ts +10 -0
  174. package/dist/claude-plugin/claude-plugin-assets.d.ts.map +1 -0
  175. package/dist/compaction-hook.d.ts +1 -1
  176. package/dist/compaction-hook.d.ts.map +1 -1
  177. package/dist/index.js +375 -265
  178. package/dist/plugin.js +374 -264
  179. package/dist/skills.d.ts +15 -0
  180. package/dist/skills.d.ts.map +1 -1
  181. package/dist/swarm-mail.d.ts.map +1 -1
  182. package/dist/swarm-prompts.d.ts +4 -2
  183. package/dist/swarm-prompts.d.ts.map +1 -1
  184. package/dist/swarm-prompts.js +84 -7
  185. package/global-skills/swarm-coordination/SKILL.md +21 -20
  186. package/package.json +2 -1
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Result from a gate check
3
+ */
4
+ export interface GateResult {
5
+ /** Whether the gate passed */
6
+ passed: boolean;
7
+ /** Current phase */
8
+ phase: "bootstrap" | "stabilization" | "production";
9
+ /** Human-readable message */
10
+ message: string;
11
+ /** Baseline score (mean of history) */
12
+ baseline?: number;
13
+ /** Current score */
14
+ currentScore: number;
15
+ /** Regression percentage (negative = improvement) */
16
+ regressionPercent?: number;
17
+ }
18
+ /**
19
+ * Configuration for gate thresholds
20
+ */
21
+ export interface GateConfig {
22
+ /** Regression threshold for stabilization phase (default: 0.1 = 10%) */
23
+ stabilizationThreshold?: number;
24
+ /** Regression threshold for production phase (default: 0.05 = 5%) */
25
+ productionThreshold?: number;
26
+ }
27
+ /**
28
+ * Default regression thresholds by phase
29
+ */
30
+ export declare const DEFAULT_THRESHOLDS: {
31
+ readonly stabilization: 0.1;
32
+ readonly production: 0.05;
33
+ };
34
+ /**
35
+ * Check if the current eval score passes the quality gate
36
+ *
37
+ * Progressive gates adapt based on data maturity:
38
+ * - **Bootstrap (<10 runs)**: Always pass, focus on collecting baseline data
39
+ * - **Stabilization (10-50 runs)**: Warn on >10% regression (default), but pass
40
+ * - **Production (>50 runs + variance <0.1)**: Fail on >5% regression (default)
41
+ *
42
+ * **Baseline calculation**: Mean of all historical scores for this eval (not just last run).
43
+ *
44
+ * **Regression formula**: `(baseline - current) / baseline`
45
+ * - Positive = regression (score dropped)
46
+ * - Negative = improvement
47
+ * - Returns 0 if baseline is 0 (avoids division by zero)
48
+ *
49
+ * **Variance threshold (0.1)**: High variance keeps eval in stabilization phase even with >50 runs.
50
+ * This prevents premature production gates when scores are still unstable.
51
+ *
52
+ * **CI Integration**: Production gates can fail PRs. Use `swarm eval status` to check phase before merging.
53
+ *
54
+ * @param projectPath - Absolute path to project root (contains `.opencode/eval-history.jsonl`)
55
+ * @param evalName - Name of the eval (e.g., "swarm-decomposition", "coordinator-behavior")
56
+ * @param currentScore - Current score to check (typically 0-1 range)
57
+ * @param config - Optional threshold configuration (defaults: stabilization=0.1, production=0.05)
58
+ * @returns Gate check result with pass/fail, phase, baseline, regression details
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { checkGate } from "./eval-gates.js";
63
+ *
64
+ * const result = checkGate("/path/to/project", "swarm-decomposition", 0.89);
65
+ *
66
+ * if (!result.passed) {
67
+ * console.error(`❌ Gate FAILED: ${result.message}`);
68
+ * process.exit(1); // Fail CI
69
+ * }
70
+ *
71
+ * console.log(`✅ ${result.phase} phase: ${result.message}`);
72
+ * ```
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // Custom thresholds for sensitive eval
77
+ * const result = checkGate("/path", "critical-eval", 0.92, {
78
+ * stabilizationThreshold: 0.05, // 5% threshold in stabilization
79
+ * productionThreshold: 0.02, // 2% threshold in production
80
+ * });
81
+ * ```
82
+ */
83
+ export declare function checkGate(projectPath: string, evalName: string, currentScore: number, config?: GateConfig): GateResult;
84
+ //# sourceMappingURL=eval-gates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-gates.d.ts","sourceRoot":"","sources":["../src/eval-gates.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,8BAA8B;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,oBAAoB;IACpB,KAAK,EAAE,WAAW,GAAG,eAAe,GAAG,YAAY,CAAC;IACpD,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,wEAAwE;IACxE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,qEAAqE;IACrE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAoCX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,SAAS,CACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,UAAU,GACjB,UAAU,CAiFZ"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Progressive phases based on run count and variance
3
+ */
4
+ export type Phase = "bootstrap" | "stabilization" | "production";
5
+ /**
6
+ * Single eval run record
7
+ */
8
+ export interface EvalRunRecord {
9
+ /** ISO-8601 timestamp */
10
+ timestamp: string;
11
+ /** Name of the eval (e.g., "swarm-decomposition") */
12
+ eval_name: string;
13
+ /** Score (0-1 range typically) */
14
+ score: number;
15
+ /** Run count (monotonically increasing per eval) */
16
+ run_count: number;
17
+ }
18
+ /**
19
+ * Default path for eval history
20
+ */
21
+ export declare const DEFAULT_EVAL_HISTORY_PATH = ".opencode/eval-history.jsonl";
22
+ /**
23
+ * Variance threshold for production phase
24
+ */
25
+ export declare const VARIANCE_THRESHOLD = 0.1;
26
+ /**
27
+ * Run count thresholds for phase transitions
28
+ */
29
+ export declare const BOOTSTRAP_THRESHOLD = 10;
30
+ export declare const STABILIZATION_THRESHOLD = 50;
31
+ /**
32
+ * Get the eval history file path
33
+ */
34
+ export declare function getEvalHistoryPath(projectPath: string): string;
35
+ /**
36
+ * Ensure the eval history directory exists
37
+ */
38
+ export declare function ensureEvalHistoryDir(projectPath: string): void;
39
+ /**
40
+ * Record an eval run to JSONL history
41
+ *
42
+ * Appends atomically to `.opencode/eval-history.jsonl`. Each line is a complete JSON object
43
+ * representing one eval run (timestamp, eval name, score, run count).
44
+ *
45
+ * **Auto-creates directory** if `.opencode/` doesn't exist.
46
+ *
47
+ * **Thread-safe**: Uses `appendFileSync` for atomic writes (safe for concurrent eval runs).
48
+ *
49
+ * **Integration**: Called automatically by evalite runner after each eval completes.
50
+ * Also callable manually for custom eval tracking.
51
+ *
52
+ * @param projectPath - Absolute path to project root
53
+ * @param run - Eval run record with timestamp, eval_name, score, run_count
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * import { recordEvalRun } from "./eval-history.js";
58
+ *
59
+ * recordEvalRun("/path/to/project", {
60
+ * timestamp: new Date().toISOString(),
61
+ * eval_name: "swarm-decomposition",
62
+ * score: 0.92,
63
+ * run_count: 15,
64
+ * });
65
+ * ```
66
+ */
67
+ export declare function recordEvalRun(projectPath: string, run: EvalRunRecord): void;
68
+ /**
69
+ * Get score history for a specific eval
70
+ *
71
+ * Returns runs in chronological order (oldest first)
72
+ */
73
+ export declare function getScoreHistory(projectPath: string, evalName: string): EvalRunRecord[];
74
+ /**
75
+ * Calculate statistical variance of scores
76
+ *
77
+ * Variance = mean of squared deviations from the mean
78
+ * Formula: Σ((x - μ)²) / n
79
+ */
80
+ export declare function calculateVariance(scores: number[]): number;
81
+ /**
82
+ * Get the current phase for an eval based on run count and score variance
83
+ *
84
+ * Progressive phase logic ensures quality gates adapt to data maturity:
85
+ *
86
+ * - **Bootstrap (<10 runs)**: No gates, just collect baseline data
87
+ * - **Stabilization (10-50 runs)**: Warn on >10% regression (but pass)
88
+ * - **Production (>50 runs AND variance <0.1)**: Fail on >5% regression
89
+ *
90
+ * **Variance check**: If >50 runs but variance ≥0.1, stays in stabilization.
91
+ * This prevents premature production gates when scores are still unstable.
92
+ *
93
+ * **Why variance matters**: An eval with wildly fluctuating scores isn't ready for
94
+ * strict gates. Variance threshold (0.1) ensures the eval is consistent before
95
+ * enforcing production-level quality control.
96
+ *
97
+ * @param projectPath - Absolute path to project root (contains `.opencode/eval-history.jsonl`)
98
+ * @param evalName - Name of the eval (e.g., "swarm-decomposition")
99
+ * @returns Current phase: "bootstrap" | "stabilization" | "production"
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * import { getPhase } from "./eval-history.js";
104
+ *
105
+ * const phase = getPhase("/path/to/project", "swarm-decomposition");
106
+ *
107
+ * if (phase === "production") {
108
+ * console.log("🚀 Production phase - strict gates enabled");
109
+ * } else if (phase === "stabilization") {
110
+ * console.log("⚙️ Stabilization phase - warnings only");
111
+ * } else {
112
+ * console.log("🌱 Bootstrap phase - collecting data");
113
+ * }
114
+ * ```
115
+ */
116
+ export declare function getPhase(projectPath: string, evalName: string): Phase;
117
+ //# sourceMappingURL=eval-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-history.d.ts","sourceRoot":"","sources":["../src/eval-history.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,eAAe,GAAG,YAAY,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,iCAAiC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAM9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,aAAa,GACjB,IAAI,CAKN;AAoBD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,aAAa,EAAE,CAIjB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAa1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAqBrE"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Eval-to-Learning Feedback Loop
3
+ *
4
+ * Automatically stores eval failures to semantic memory for learning.
5
+ * When eval scores drop significantly from rolling average (default >15%),
6
+ * stores context to semantic-memory with tags for future prompt generation.
7
+ *
8
+ * ## Usage
9
+ *
10
+ * ```typescript
11
+ * import { learnFromEvalFailure } from "./eval-learning";
12
+ * import { getHivemindAdapter } from "./hivemind-tools";
13
+ * import { getScoreHistory } from "./eval-history";
14
+ *
15
+ * const memoryAdapter = await getHivemindAdapter();
16
+ * const history = getScoreHistory(projectPath, "compaction-test");
17
+ *
18
+ * const result = await learnFromEvalFailure(
19
+ * "compaction-test",
20
+ * currentScore,
21
+ * history,
22
+ * memoryAdapter
23
+ * );
24
+ *
25
+ * if (result.triggered) {
26
+ * console.log(`📉 Regression detected: ${(result.drop_percentage * 100).toFixed(1)}% drop`);
27
+ * console.log(`Memory ID: ${result.memory_id}`);
28
+ * }
29
+ * ```
30
+ *
31
+ * ## Integration Points
32
+ *
33
+ * - **After each eval run**: Call to detect regressions automatically
34
+ * - **Memory tags**: `eval-failure`, `{eval-name}`, `regression`
35
+ * - **Future prompts**: Query memories with these tags for context
36
+ * - **Scorer context**: Optional detail about which scorer failed
37
+ *
38
+ * ## Customization
39
+ *
40
+ * ```typescript
41
+ * const customConfig = {
42
+ * dropThreshold: 0.10, // 10% threshold (more sensitive)
43
+ * windowSize: 10, // Last 10 runs for baseline
44
+ * };
45
+ *
46
+ * await learnFromEvalFailure(
47
+ * "test",
48
+ * score,
49
+ * history,
50
+ * adapter,
51
+ * { config: customConfig }
52
+ * );
53
+ * ```
54
+ *
55
+ * @module eval-learning
56
+ */
57
+ import type { EvalRunRecord } from "./eval-history";
58
+ import type { MemoryAdapter } from "./hivemind-tools";
59
+ /**
60
+ * Configuration for eval-to-learning feedback
61
+ */
62
+ export interface EvalLearningConfig {
63
+ /** Threshold for significant drop (0-1, default 0.15 = 15%) */
64
+ dropThreshold: number;
65
+ /** Rolling average window size (default 5 runs) */
66
+ windowSize: number;
67
+ }
68
+ /**
69
+ * Default configuration
70
+ */
71
+ export declare const DEFAULT_EVAL_LEARNING_CONFIG: EvalLearningConfig;
72
+ /**
73
+ * Result from learning check
74
+ */
75
+ export interface LearningResult {
76
+ /** Whether the check triggered memory storage */
77
+ triggered: boolean;
78
+ /** Baseline score from rolling average */
79
+ baseline: number;
80
+ /** Current score */
81
+ current: number;
82
+ /** Drop percentage (0-1, e.g., 0.20 = 20% drop) */
83
+ drop_percentage: number;
84
+ /** Memory ID if stored */
85
+ memory_id?: string;
86
+ }
87
+ /**
88
+ * Calculate rolling average of recent scores
89
+ *
90
+ * Uses last N runs (default 5) to establish baseline.
91
+ * If history shorter than window, uses all available.
92
+ *
93
+ * @param history - Score history (chronological order)
94
+ * @param windowSize - Number of recent runs to average (default 5)
95
+ * @returns Average score (0 if empty)
96
+ */
97
+ export declare function calculateRollingAverage(history: EvalRunRecord[], windowSize?: number): number;
98
+ /**
99
+ * Check if current score is a significant drop from baseline
100
+ *
101
+ * Significant = drop exceeds threshold (default 15%).
102
+ * Formula: (baseline - current) / baseline >= threshold
103
+ *
104
+ * @param currentScore - Current eval score
105
+ * @param baseline - Baseline score (rolling average)
106
+ * @param threshold - Drop threshold (default 0.15 = 15%)
107
+ * @returns True if drop is significant
108
+ */
109
+ export declare function isSignificantDrop(currentScore: number, baseline: number, threshold?: number): boolean;
110
+ /**
111
+ * Format failure context for semantic memory storage
112
+ *
113
+ * Creates human-readable description of the failure with
114
+ * quantified metrics and optional scorer context.
115
+ *
116
+ * @param evalName - Name of eval that failed
117
+ * @param currentScore - Current score
118
+ * @param baseline - Baseline score
119
+ * @param scorerContext - Optional context about which scorer failed
120
+ * @returns Formatted context string
121
+ */
122
+ export declare function formatFailureContext(evalName: string, currentScore: number, baseline: number, scorerContext?: string): string;
123
+ /**
124
+ * Main learning function - automatically stores eval failures to semantic memory
125
+ *
126
+ * **Closed-loop learning**: When eval scores drop significantly from baseline,
127
+ * this function stores failure context to semantic memory. Future prompt generation
128
+ * queries these memories for context, preventing repeated mistakes.
129
+ *
130
+ * **Trigger condition**: Score drops >15% (default) from rolling average baseline.
131
+ * Uses last 5 runs (default) to establish baseline, not just previous run.
132
+ *
133
+ * **What gets stored**:
134
+ * - Eval name, baseline score, current score, drop percentage
135
+ * - Scorer-specific context (which scorer failed, why)
136
+ * - Timestamp and metadata for querying
137
+ * - Tags: `eval-failure`, `{eval-name}`, `regression`
138
+ *
139
+ * **Future use**: Before generating prompts for the same eval, query semantic memory
140
+ * with tags to inject learnings from past failures.
141
+ *
142
+ * **Integration points**:
143
+ * - After each eval run (in evalite runner or CI)
144
+ * - In `checkGate()` when regression detected
145
+ * - Manual calls for custom eval tracking
146
+ *
147
+ * @param evalName - Name of eval (e.g., "compaction-test", "coordinator-behavior")
148
+ * @param currentScore - Current eval score (typically 0-1 range)
149
+ * @param history - Score history in chronological order (oldest first)
150
+ * @param memoryAdapter - Semantic memory adapter (from `getMemoryAdapter()`)
151
+ * @param options - Optional config (thresholds, window size) and scorer context
152
+ * @param options.config - Custom thresholds (dropThreshold, windowSize)
153
+ * @param options.scorerContext - Details about which scorer failed (for context)
154
+ * @returns Learning result with trigger status, baseline, drop percentage, memory ID
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * import { learnFromEvalFailure } from "./eval-learning.js";
159
+ * import { getHivemindAdapter } from "./hivemind-tools.js";
160
+ * import { getScoreHistory } from "./eval-history.js";
161
+ *
162
+ * const memoryAdapter = await getHivemindAdapter();
163
+ * const history = getScoreHistory("/path/to/project", "coordinator-behavior");
164
+ *
165
+ * const result = await learnFromEvalFailure(
166
+ * "coordinator-behavior",
167
+ * 0.68, // Current score
168
+ * history,
169
+ * memoryAdapter,
170
+ * { scorerContext: "violationCount: 5 violations (coordinator edited files)" }
171
+ * );
172
+ *
173
+ * if (result.triggered) {
174
+ * console.log(`📉 Regression detected: ${(result.drop_percentage * 100).toFixed(1)}% drop`);
175
+ * console.log(`Stored to memory: ${result.memory_id}`);
176
+ * }
177
+ * ```
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * // Custom threshold (more sensitive)
182
+ * const result = await learnFromEvalFailure(
183
+ * "critical-eval",
184
+ * 0.85,
185
+ * history,
186
+ * memoryAdapter,
187
+ * {
188
+ * config: {
189
+ * dropThreshold: 0.10, // 10% threshold (default is 15%)
190
+ * windowSize: 10, // Last 10 runs for baseline (default is 5)
191
+ * },
192
+ * }
193
+ * );
194
+ * ```
195
+ */
196
+ export declare function learnFromEvalFailure(evalName: string, currentScore: number, history: EvalRunRecord[], memoryAdapter: MemoryAdapter, options?: {
197
+ config?: EvalLearningConfig;
198
+ scorerContext?: string;
199
+ }): Promise<LearningResult>;
200
+ /**
201
+ * Create custom learning config with specific threshold
202
+ *
203
+ * Helper for common use case: custom drop threshold.
204
+ *
205
+ * @param dropThreshold - Drop threshold (0-1)
206
+ * @param windowSize - Optional window size (default 5)
207
+ * @returns Custom config
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * const config = createLearningConfig(0.10); // 10% threshold
212
+ * await learnFromEvalFailure("test", score, history, adapter, { config });
213
+ * ```
214
+ */
215
+ export declare function createLearningConfig(dropThreshold: number, windowSize?: number): EvalLearningConfig;
216
+ //# sourceMappingURL=eval-learning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-learning.d.ts","sourceRoot":"","sources":["../src/eval-learning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,+DAA+D;IAC/D,a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BAAoB,CACnC,aAAa,EAAE,MAAM,EACrB,UAAU,CAAC,EAAE,MAAM,GACjB,kBAAkB,CAKpB"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Programmatic Evalite Runner
3
+ *
4
+ * Provides a type-safe API for running evalite evals programmatically.
5
+ * Wraps evalite's runEvalite function with structured result parsing.
6
+ *
7
+ * @module eval-runner
8
+ */
9
+ /**
10
+ * Options for running evals programmatically
11
+ */
12
+ export interface RunEvalsOptions {
13
+ /**
14
+ * Working directory containing eval files (defaults to process.cwd())
15
+ */
16
+ cwd?: string;
17
+ /**
18
+ * Optional filter to run specific eval suites (e.g., "coordinator", "compaction")
19
+ * Matches against eval file paths using substring matching
20
+ */
21
+ suiteFilter?: string;
22
+ /**
23
+ * Minimum average score threshold (0-100)
24
+ * If average score falls below this, result.success will be false
25
+ */
26
+ scoreThreshold?: number;
27
+ /**
28
+ * Optional path to write raw evalite JSON output
29
+ */
30
+ outputPath?: string;
31
+ }
32
+ /**
33
+ * Structured suite result with scores
34
+ */
35
+ export interface SuiteResult {
36
+ /** Suite name from evalite() call */
37
+ name: string;
38
+ /** Absolute path to eval file */
39
+ filepath: string;
40
+ /** Suite status: success, fail, or running */
41
+ status: "success" | "fail" | "running";
42
+ /** Total duration in milliseconds */
43
+ duration: number;
44
+ /** Average score across all evals in suite (0-1 scale) */
45
+ averageScore: number;
46
+ /** Number of evals in this suite */
47
+ evalCount: number;
48
+ /** Individual eval results (optional, can be large) */
49
+ evals?: Array<{
50
+ input: unknown;
51
+ output: unknown;
52
+ expected?: unknown;
53
+ scores: Array<{
54
+ name: string;
55
+ score: number;
56
+ description?: string;
57
+ }>;
58
+ }>;
59
+ }
60
+ /**
61
+ * Structured result from running evals
62
+ */
63
+ export interface RunEvalsResult {
64
+ /** Whether the run succeeded (all evals passed threshold) */
65
+ success: boolean;
66
+ /** Total number of suites executed */
67
+ totalSuites: number;
68
+ /** Total number of individual evals executed */
69
+ totalEvals: number;
70
+ /** Average score across all suites (0-1 scale) */
71
+ averageScore: number;
72
+ /** Individual suite results */
73
+ suites: SuiteResult[];
74
+ /** Error message if run failed */
75
+ error?: string;
76
+ /** Gate check results per suite */
77
+ gateResults?: Array<{
78
+ suite: string;
79
+ passed: boolean;
80
+ phase: string;
81
+ message: string;
82
+ baseline?: number;
83
+ currentScore: number;
84
+ regressionPercent?: number;
85
+ }>;
86
+ }
87
+ /**
88
+ * Run evalite evals programmatically
89
+ *
90
+ * @param options - Configuration for eval run
91
+ * @returns Structured results with scores per suite
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * // Run all evals
96
+ * const result = await runEvals({ cwd: "/path/to/project" });
97
+ * console.log(`Average score: ${result.averageScore}`);
98
+ *
99
+ * // Run specific suite
100
+ * const coordResult = await runEvals({
101
+ * cwd: "/path/to/project",
102
+ * suiteFilter: "coordinator"
103
+ * });
104
+ *
105
+ * // Enforce score threshold
106
+ * const gatedResult = await runEvals({
107
+ * cwd: "/path/to/project",
108
+ * scoreThreshold: 80
109
+ * });
110
+ * if (!gatedResult.success) {
111
+ * throw new Error(`Evals failed threshold: ${gatedResult.averageScore}`);
112
+ * }
113
+ * ```
114
+ */
115
+ export declare function runEvals(options?: RunEvalsOptions): Promise<RunEvalsResult>;
116
+ /**
117
+ * All eval tools exported for registration
118
+ */
119
+ export declare const evalTools: {
120
+ readonly eval_run: {
121
+ description: string;
122
+ args: {
123
+ suiteFilter: import("zod").ZodOptional<import("zod").ZodString>;
124
+ scoreThreshold: import("zod").ZodOptional<import("zod").ZodNumber>;
125
+ includeDetailedResults: import("zod").ZodOptional<import("zod").ZodBoolean>;
126
+ };
127
+ execute(args: {
128
+ suiteFilter?: string | undefined;
129
+ scoreThreshold?: number | undefined;
130
+ includeDetailedResults?: boolean | undefined;
131
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
132
+ };
133
+ };
134
+ //# sourceMappingURL=eval-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-runner.d.ts","sourceRoot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