0xray 2.1.4 → 2.2.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 (159) hide show
  1. package/dist/CHANGELOG.md +31 -0
  2. package/dist/cli/commands/govern.d.ts +29 -0
  3. package/dist/cli/commands/govern.js +152 -0
  4. package/dist/cli/index.js +29 -216
  5. package/dist/core/framework-logger.js +30 -1
  6. package/dist/delegation/index.d.ts +1 -2
  7. package/dist/delegation/index.js +1 -2
  8. package/dist/enforcement/enforcer-tools.js +1 -1
  9. package/dist/execution/proposal-applier.d.ts +1 -9
  10. package/dist/execution/proposal-applier.js +18 -173
  11. package/dist/governance/codex-policy.service.d.ts +7 -25
  12. package/dist/governance/codex-policy.service.js +8 -26
  13. package/dist/governance/governance-core.d.ts +22 -28
  14. package/dist/governance/governance-core.js +31 -101
  15. package/dist/governance/governance-service.d.ts +1 -0
  16. package/dist/governance/governance-service.js +67 -4
  17. package/dist/governance/governance-types.d.ts +5 -2
  18. package/dist/inference/index.d.ts +3 -4
  19. package/dist/inference/inference-accumulator.js +1 -1
  20. package/dist/inference/inference-cycle.d.ts +12 -18
  21. package/dist/inference/inference-cycle.js +120 -335
  22. package/dist/integrations/base/index.d.ts +0 -1
  23. package/dist/integrations/base/index.js +0 -2
  24. package/dist/integrations/grok/hooks/pre-tool-use.js +4 -18
  25. package/dist/integrations/hermes-agent/bridge.mjs +9 -0
  26. package/dist/mcps/config/server-config-registry.js +1 -1
  27. package/dist/mcps/governance.server.js +3 -4
  28. package/dist/mcps/knowledge-skills/api-design.server.js +10 -0
  29. package/dist/mcps/knowledge-skills/architecture-patterns.server.js +10 -0
  30. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +10 -0
  31. package/dist/mcps/knowledge-skills/code-analyzer.server.js +10 -0
  32. package/dist/mcps/knowledge-skills/code-review.server.js +10 -0
  33. package/dist/mcps/knowledge-skills/content-creator.server.js +10 -0
  34. package/dist/mcps/knowledge-skills/database-design.server.js +10 -0
  35. package/dist/mcps/knowledge-skills/devops-deployment.server.js +10 -0
  36. package/dist/mcps/knowledge-skills/git-workflow.server.js +10 -0
  37. package/dist/mcps/knowledge-skills/growth-strategist.server.js +10 -0
  38. package/dist/mcps/knowledge-skills/log-monitor.server.js +10 -0
  39. package/dist/mcps/knowledge-skills/mobile-development.server.js +10 -0
  40. package/dist/mcps/knowledge-skills/multimodal-looker.server.js +10 -0
  41. package/dist/mcps/knowledge-skills/performance-optimization.server.js +10 -0
  42. package/dist/mcps/knowledge-skills/project-analysis.server.js +10 -0
  43. package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +10 -0
  44. package/dist/mcps/knowledge-skills/security-audit.server.js +10 -0
  45. package/dist/mcps/knowledge-skills/seo-consultant.server.js +10 -0
  46. package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +4 -0
  47. package/dist/mcps/knowledge-skills/skill-invocation.server.js +33 -14
  48. package/dist/mcps/knowledge-skills/strategist.server.js +10 -0
  49. package/dist/mcps/knowledge-skills/tech-writer.server.js +10 -0
  50. package/dist/mcps/knowledge-skills/testing-strategy.server.js +10 -0
  51. package/dist/mcps/knowledge-skills/ui-ux-design.server.js +10 -0
  52. package/dist/metrics/agent-metrics.d.ts +2 -1
  53. package/dist/nucleus/govern-http.d.ts +59 -0
  54. package/dist/nucleus/govern-http.js +172 -0
  55. package/dist/nucleus/index.d.ts +14 -0
  56. package/dist/nucleus/index.js +9 -0
  57. package/dist/nucleus/kernel.d.ts +51 -0
  58. package/dist/nucleus/kernel.js +62 -0
  59. package/dist/nucleus/plugin-registry.d.ts +104 -0
  60. package/dist/nucleus/plugin-registry.js +147 -0
  61. package/dist/orchestrator/orchestrator.d.ts +0 -1
  62. package/dist/orchestrator/orchestrator.js +0 -21
  63. package/dist/postprocessor/PostProcessor.d.ts +13 -1
  64. package/dist/postprocessor/PostProcessor.js +41 -1
  65. package/dist/postprocessor/autofix/AutoFixEngine.d.ts +0 -8
  66. package/dist/postprocessor/autofix/AutoFixEngine.js +0 -54
  67. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.d.ts +25 -0
  68. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.js +10 -0
  69. package/dist/postprocessor/metamorphosis/SelfProposalEngine.d.ts +68 -0
  70. package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +371 -0
  71. package/dist/skills/orchestrator/SKILL.md +1 -1
  72. package/dist/state/index.d.ts +0 -2
  73. package/package.json +4 -3
  74. package/scripts/node/universal-version-manager.js +2 -2
  75. package/src/mcps/config/__tests__/server-config-registry.test.ts +6 -15
  76. package/src/mcps/config/server-config-registry.ts +1 -1
  77. package/src/mcps/governance.server.ts +3 -5
  78. package/src/mcps/knowledge-skills/api-design.server.ts +9 -0
  79. package/src/mcps/knowledge-skills/architecture-patterns.server.ts +9 -0
  80. package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +9 -0
  81. package/src/mcps/knowledge-skills/code-analyzer.server.ts +9 -0
  82. package/src/mcps/knowledge-skills/code-review.server.ts +9 -0
  83. package/src/mcps/knowledge-skills/content-creator.server.ts +9 -0
  84. package/src/mcps/knowledge-skills/database-design.server.ts +9 -0
  85. package/src/mcps/knowledge-skills/devops-deployment.server.ts +9 -0
  86. package/src/mcps/knowledge-skills/git-workflow.server.ts +9 -0
  87. package/src/mcps/knowledge-skills/growth-strategist.server.ts +9 -0
  88. package/src/mcps/knowledge-skills/log-monitor.server.ts +9 -0
  89. package/src/mcps/knowledge-skills/mobile-development.server.ts +9 -0
  90. package/src/mcps/knowledge-skills/multimodal-looker.server.ts +9 -0
  91. package/src/mcps/knowledge-skills/performance-optimization.server.ts +9 -0
  92. package/src/mcps/knowledge-skills/project-analysis.server.ts +9 -0
  93. package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +9 -0
  94. package/src/mcps/knowledge-skills/security-audit.server.ts +9 -0
  95. package/src/mcps/knowledge-skills/seo-consultant.server.ts +9 -0
  96. package/src/mcps/knowledge-skills/session-management.server.ts +1 -0
  97. package/src/mcps/knowledge-skills/skill-invocation.server.ts +44 -29
  98. package/src/mcps/knowledge-skills/strategist.server.ts +9 -0
  99. package/src/mcps/knowledge-skills/tech-writer.server.ts +9 -0
  100. package/src/mcps/knowledge-skills/testing-strategy.server.ts +9 -0
  101. package/src/mcps/knowledge-skills/ui-ux-design.server.ts +9 -0
  102. package/src/skills/orchestrator/SKILL.md +1 -1
  103. package/.opencode/agents/testing-best-practices.yml +0 -12
  104. package/dist/analytics/consent-manager.d.ts +0 -93
  105. package/dist/analytics/consent-manager.js +0 -258
  106. package/dist/analytics/simple-pattern-analyzer.d.ts +0 -80
  107. package/dist/analytics/simple-pattern-analyzer.js +0 -297
  108. package/dist/cli/commands/analytics-disable.d.ts +0 -9
  109. package/dist/cli/commands/analytics-disable.js +0 -72
  110. package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
  111. package/dist/cli/commands/analytics-enable-action.js +0 -82
  112. package/dist/cli/commands/analytics-preview.d.ts +0 -9
  113. package/dist/cli/commands/analytics-preview.js +0 -106
  114. package/dist/cli/commands/analytics-status.d.ts +0 -9
  115. package/dist/cli/commands/analytics-status.js +0 -68
  116. package/dist/cli/server.d.ts +0 -1
  117. package/dist/cli/server.js +0 -147
  118. package/dist/core/errors.d.ts +0 -3
  119. package/dist/core/errors.js +0 -10
  120. package/dist/core/logging-config.d.ts +0 -11
  121. package/dist/core/logging-config.js +0 -43
  122. package/dist/core/trace-context.d.ts +0 -12
  123. package/dist/core/trace-context.js +0 -33
  124. package/dist/delegation/voting-coordinator.d.ts +0 -49
  125. package/dist/delegation/voting-coordinator.js +0 -375
  126. package/dist/enforcement/test-auto-healing.d.ts +0 -83
  127. package/dist/enforcement/test-auto-healing.js +0 -325
  128. package/dist/integrations/base/ExampleIntegration.d.ts +0 -47
  129. package/dist/integrations/base/ExampleIntegration.js +0 -181
  130. package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +0 -34
  131. package/dist/mcps/knowledge-skills/testing-best-practices.server.js +0 -831
  132. package/dist/mcps/orchestrator.server.d.ts +0 -10
  133. package/dist/mcps/orchestrator.server.js +0 -19
  134. package/dist/orchestrator/self-direction-activation.d.ts +0 -109
  135. package/dist/orchestrator/self-direction-activation.js +0 -245
  136. package/dist/orchestrator/universal-librarian-consultation.d.ts +0 -98
  137. package/dist/orchestrator/universal-librarian-consultation.js +0 -216
  138. package/dist/orchestrator/universal-registry-bridge.d.ts +0 -85
  139. package/dist/orchestrator/universal-registry-bridge.js +0 -247
  140. package/dist/performance/performance-budget-enforcer.d.ts +0 -158
  141. package/dist/performance/performance-budget-enforcer.js +0 -434
  142. package/dist/performance/performance-regression-tester.d.ts +0 -108
  143. package/dist/performance/performance-regression-tester.js +0 -342
  144. package/dist/skills/testing-best-practices/SKILL.md +0 -37
  145. package/dist/state/context-providers.d.ts +0 -4
  146. package/dist/state/context-providers.js +0 -1
  147. package/dist/state/state-types.d.ts +0 -5
  148. package/dist/state/state-types.js +0 -1
  149. package/dist/utils/batch-operations.d.ts +0 -25
  150. package/dist/utils/batch-operations.js +0 -292
  151. package/dist/utils/test-template-generator.d.ts +0 -25
  152. package/dist/utils/test-template-generator.js +0 -178
  153. package/dist/utils/token-manager.d.ts +0 -48
  154. package/dist/utils/token-manager.js +0 -163
  155. package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +0 -136
  156. package/src/mcps/knowledge-skills/testing-best-practices.server.ts +0 -1183
  157. package/src/mcps/orchestrator.server.ts +0 -34
  158. package/src/opencode/agents/testing-best-practices.yml +0 -12
  159. package/src/skills/testing-best-practices/SKILL.md +0 -37
@@ -1,325 +0,0 @@
1
- /**
2
- * Test Auto-Healing System for 0xRay Framework
3
- *
4
- * Automatically detects slow/failing tests and orchestrates fixes using specialized agents
5
- * Implements intelligent test optimization and refactoring for enterprise reliability
6
- */
7
- import { frameworkLogger } from "../core/framework-logger.js";
8
- export class TestAutoHealingSystem {
9
- healingHistory = new Map();
10
- /**
11
- * Main auto-healing entry point for test failures
12
- */
13
- async healTestFailures(testResults, context) {
14
- const jobId = `test-healing-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
15
- const startTime = Date.now();
16
- frameworkLogger.log("test-auto-healing", "healing-start", "info", {
17
- jobId,
18
- testFiles: context.tests?.length || 0,
19
- operation: context.operation,
20
- });
21
- try {
22
- // Step 1: Analyze test failures
23
- const failureAnalysis = await this.analyzeTestFailures(testResults, context);
24
- // Step 2: Prioritize and filter auto-fixable issues
25
- const autoFixableIssues = failureAnalysis.filter((analysis) => analysis.autoFixable);
26
- const prioritizedIssues = this.prioritizeIssues(autoFixableIssues);
27
- // Step 3: Apply automatic fixes
28
- const healingResult = await this.applyAutomaticFixes(prioritizedIssues, context, jobId);
29
- // Step 4: Coordinate with agents for complex fixes
30
- const agentCoordination = await this.coordinateAgentFixes(failureAnalysis.filter((analysis) => !analysis.autoFixable), context, jobId);
31
- // Step 5: Generate final report
32
- const result = {
33
- success: healingResult.success && agentCoordination.success,
34
- fixesApplied: healingResult.fixesApplied + agentCoordination.fixesApplied,
35
- testsOptimized: healingResult.testsOptimized + agentCoordination.testsOptimized,
36
- performanceImprovement: healingResult.performanceImprovement +
37
- agentCoordination.performanceImprovement,
38
- agentCoordinationUsed: agentCoordination.agentsUsed.length > 0,
39
- recommendations: [
40
- ...healingResult.recommendations,
41
- ...agentCoordination.recommendations,
42
- ],
43
- nextSteps: [...healingResult.nextSteps, ...agentCoordination.nextSteps],
44
- };
45
- const duration = Date.now() - startTime;
46
- frameworkLogger.log("test-auto-healing", "healing-complete", "success", {
47
- jobId,
48
- duration,
49
- fixesApplied: result.fixesApplied,
50
- performanceImprovement: result.performanceImprovement,
51
- success: result.success,
52
- });
53
- return result;
54
- }
55
- catch (error) {
56
- frameworkLogger.log("test-auto-healing", "healing-error", "error", {
57
- jobId,
58
- error: error instanceof Error
59
- ? error.message
60
- : `Unknown error: ${String(error)}`,
61
- operation: context.operation,
62
- });
63
- return {
64
- success: false,
65
- fixesApplied: 0,
66
- testsOptimized: 0,
67
- performanceImprovement: 0,
68
- agentCoordinationUsed: false,
69
- recommendations: ["Manual review required - auto-healing failed"],
70
- nextSteps: ["Review error logs and fix underlying issues"],
71
- };
72
- }
73
- }
74
- /**
75
- * Analyze test failures and determine root causes
76
- */
77
- async analyzeTestFailures(testResults, context) {
78
- const analyses = [];
79
- // Analyze timeout failures (Codex Term #45)
80
- if (testResults.timedOut) {
81
- analyses.push({
82
- testFile: testResults.file || "unknown",
83
- failureType: "timeout",
84
- rootCause: "Test execution exceeded timeout limits",
85
- severity: "high",
86
- estimatedFixTime: 15,
87
- autoFixable: true,
88
- recommendedAgent: "testing-lead",
89
- fixStrategy: {
90
- type: "optimize",
91
- description: "Optimize test execution time through parallelization and mocking",
92
- estimatedImprovement: 60,
93
- riskLevel: "low",
94
- requiresAgentCoordination: false,
95
- },
96
- });
97
- }
98
- // Analyze performance issues
99
- if ((testResults.executionTime ?? 0) > 300000) {
100
- // 5 minutes
101
- analyses.push({
102
- testFile: testResults.file || "unknown",
103
- failureType: "performance",
104
- rootCause: "Test suite execution too slow",
105
- severity: "medium",
106
- estimatedFixTime: 30,
107
- autoFixable: true,
108
- recommendedAgent: "refactorer",
109
- fixStrategy: {
110
- type: "parallelize",
111
- description: "Implement parallel test execution and optimize slow tests",
112
- estimatedImprovement: 70,
113
- riskLevel: "medium",
114
- requiresAgentCoordination: true,
115
- },
116
- });
117
- }
118
- // Analyze flaky tests
119
- const flakyTests = this.detectFlakyTests(testResults);
120
- for (const flakyTest of flakyTests) {
121
- analyses.push({
122
- testFile: flakyTest.file,
123
- failureType: "flaky",
124
- rootCause: `Test ${flakyTest.name} is flaky - inconsistent results`,
125
- severity: "medium",
126
- estimatedFixTime: 20,
127
- autoFixable: false,
128
- recommendedAgent: "bug-triage-specialist",
129
- fixStrategy: {
130
- type: "isolate",
131
- description: "Isolate and fix race conditions or timing dependencies",
132
- estimatedImprovement: 90,
133
- riskLevel: "medium",
134
- requiresAgentCoordination: true,
135
- },
136
- });
137
- }
138
- return analyses;
139
- }
140
- /**
141
- * Apply automatic fixes for simple issues
142
- */
143
- async applyAutomaticFixes(issues, context, jobId) {
144
- let fixesApplied = 0;
145
- let testsOptimized = 0;
146
- let performanceImprovement = 0;
147
- const recommendations = [];
148
- const nextSteps = [];
149
- for (const issue of issues) {
150
- try {
151
- switch (issue.fixStrategy.type) {
152
- case "optimize":
153
- const optimizationResult = await this.optimizeTestTimeouts(issue, context, jobId);
154
- if (optimizationResult.success) {
155
- fixesApplied++;
156
- performanceImprovement += issue.fixStrategy.estimatedImprovement;
157
- recommendations.push(`Optimized ${issue.testFile} for better performance`);
158
- }
159
- break;
160
- case "parallelize":
161
- const parallelResult = await this.implementParallelExecution(issue, context, jobId);
162
- if (parallelResult.success) {
163
- fixesApplied++;
164
- testsOptimized++;
165
- performanceImprovement += issue.fixStrategy.estimatedImprovement;
166
- recommendations.push(`Implemented parallel execution for ${issue.testFile}`);
167
- }
168
- break;
169
- case "mock":
170
- const mockResult = await this.addTestMocks(issue, context, jobId);
171
- if (mockResult.success) {
172
- fixesApplied++;
173
- performanceImprovement += issue.fixStrategy.estimatedImprovement;
174
- recommendations.push(`Added mocks to speed up ${issue.testFile}`);
175
- }
176
- break;
177
- }
178
- }
179
- catch (error) {
180
- nextSteps.push(`Manual intervention needed for ${issue.testFile}: ${error instanceof Error ? error.message : String(error)}`);
181
- }
182
- }
183
- return {
184
- success: fixesApplied > 0,
185
- fixesApplied,
186
- testsOptimized,
187
- performanceImprovement,
188
- recommendations,
189
- nextSteps,
190
- };
191
- }
192
- /**
193
- * Coordinate with specialized agents for complex fixes
194
- */
195
- async coordinateAgentFixes(complexIssues, context, jobId) {
196
- let fixesApplied = 0;
197
- let testsOptimized = 0;
198
- let performanceImprovement = 0;
199
- const agentsUsed = [];
200
- const recommendations = [];
201
- const nextSteps = [];
202
- // Group issues by recommended agent
203
- const agentGroups = new Map();
204
- for (const issue of complexIssues) {
205
- if (!agentGroups.has(issue.recommendedAgent)) {
206
- agentGroups.set(issue.recommendedAgent, []);
207
- }
208
- agentGroups.get(issue.recommendedAgent).push(issue);
209
- }
210
- // Coordinate with each agent
211
- for (const [agentName, issues] of agentGroups) {
212
- try {
213
- const agentResult = await this.invokeSpecializedAgent(agentName, issues, context, jobId);
214
- if (agentResult.success) {
215
- fixesApplied += agentResult.fixesApplied;
216
- testsOptimized += agentResult.testsOptimized;
217
- performanceImprovement += agentResult.performanceImprovement;
218
- agentsUsed.push(agentName);
219
- recommendations.push(...agentResult.recommendations);
220
- }
221
- else {
222
- nextSteps.push(`Agent ${agentName} coordination needed for ${issues.length} issues`);
223
- }
224
- }
225
- catch (error) {
226
- nextSteps.push(`Failed to coordinate with ${agentName}: ${error instanceof Error ? error.message : String(error)}`);
227
- }
228
- }
229
- return {
230
- success: fixesApplied > 0,
231
- fixesApplied,
232
- testsOptimized,
233
- performanceImprovement,
234
- agentsUsed,
235
- recommendations,
236
- nextSteps,
237
- };
238
- }
239
- /**
240
- * Optimize test timeouts automatically
241
- */
242
- async optimizeTestTimeouts(issue, context, jobId) {
243
- // Implementation would modify test files to add timeouts and optimize slow operations
244
- // For now, return success to indicate capability
245
- frameworkLogger.log("test-auto-healing", "timeout-optimization", "success", {
246
- jobId,
247
- testFile: issue.testFile,
248
- improvement: issue.fixStrategy.estimatedImprovement,
249
- });
250
- return { success: true };
251
- }
252
- /**
253
- * Implement parallel test execution
254
- */
255
- async implementParallelExecution(issue, context, jobId) {
256
- // Implementation would modify test configuration for parallel execution
257
- frameworkLogger.log("test-auto-healing", "parallel-execution", "success", {
258
- jobId,
259
- testFile: issue.testFile,
260
- improvement: issue.fixStrategy.estimatedImprovement,
261
- });
262
- return { success: true };
263
- }
264
- /**
265
- * Add mocks to speed up tests
266
- */
267
- async addTestMocks(issue, context, jobId) {
268
- // Implementation would analyze test dependencies and add appropriate mocks
269
- frameworkLogger.log("test-auto-healing", "mock-addition", "success", {
270
- jobId,
271
- testFile: issue.testFile,
272
- improvement: issue.fixStrategy.estimatedImprovement,
273
- });
274
- return { success: true };
275
- }
276
- /**
277
- * Invoke specialized agents for complex fixes
278
- */
279
- async invokeSpecializedAgent(agentName, issues, context, jobId) {
280
- // This would integrate with the actual agent system
281
- // For now, simulate agent coordination
282
- frameworkLogger.log("test-auto-healing", "agent-coordination", "info", {
283
- jobId,
284
- agent: agentName,
285
- issuesCount: issues.length,
286
- });
287
- // Simulate agent response
288
- return {
289
- success: true,
290
- fixesApplied: issues.length,
291
- testsOptimized: Math.floor(issues.length * 0.8),
292
- performanceImprovement: issues.reduce((sum, issue) => sum + issue.fixStrategy.estimatedImprovement, 0),
293
- recommendations: [
294
- `${agentName} successfully addressed ${issues.length} complex issues`,
295
- ],
296
- };
297
- }
298
- /**
299
- * Detect flaky tests based on inconsistent results
300
- */
301
- detectFlakyTests(testResults) {
302
- // Implementation would analyze test history for flaky patterns
303
- return []; // Placeholder
304
- }
305
- /**
306
- * Prioritize issues for fixing
307
- */
308
- prioritizeIssues(issues) {
309
- return issues.sort((a, b) => {
310
- const severityOrder = { critical: 4, high: 3, medium: 2, low: 1 };
311
- const typeOrder = {
312
- timeout: 3,
313
- performance: 2,
314
- "logic-error": 3,
315
- flaky: 2,
316
- infrastructure: 1,
317
- };
318
- const aScore = severityOrder[a.severity] * 10 + typeOrder[a.failureType];
319
- const bScore = severityOrder[b.severity] * 10 + typeOrder[b.failureType];
320
- return bScore - aScore;
321
- });
322
- }
323
- }
324
- // Export singleton instance
325
- export const testAutoHealingSystem = new TestAutoHealingSystem();
@@ -1,47 +0,0 @@
1
- /**
2
- * Example Integration - Demonstrates using the BaseIntegration class
3
- *
4
- * This is a simple example showing how to create a custom integration
5
- * that extends the BaseIntegration class.
6
- *
7
- * @version 1.0.0
8
- * @since 2026-03-15
9
- */
10
- import { BaseIntegration, type HealthResult, type IntegrationConfig } from "./index.js";
11
- /**
12
- * Example custom integration
13
- *
14
- * Demonstrates how to extend BaseIntegration with custom logic.
15
- */
16
- declare class ExampleIntegration extends BaseIntegration {
17
- /** Custom property for this integration */
18
- private connectionString;
19
- private connected;
20
- /**
21
- * Create a new ExampleIntegration
22
- *
23
- * @param config - Optional configuration
24
- */
25
- constructor(config?: Partial<IntegrationConfig>);
26
- /**
27
- * Set connection string
28
- */
29
- setConnectionString(connStr: string): void;
30
- /**
31
- * Check if connected
32
- */
33
- isConnected(): boolean;
34
- /**
35
- * Perform integration-specific initialization
36
- */
37
- protected performInitialization(): Promise<void>;
38
- /**
39
- * Perform integration-specific shutdown
40
- */
41
- protected performShutdown(): Promise<void>;
42
- /**
43
- * Perform integration-specific health check
44
- */
45
- protected performHealthCheck(): Promise<HealthResult>;
46
- }
47
- export { ExampleIntegration };
@@ -1,181 +0,0 @@
1
- /**
2
- * Example Integration - Demonstrates using the BaseIntegration class
3
- *
4
- * This is a simple example showing how to create a custom integration
5
- * that extends the BaseIntegration class.
6
- *
7
- * @version 1.0.0
8
- * @since 2026-03-15
9
- */
10
- import { BaseIntegration, createSimpleIntegration, } from "./index.js";
11
- /**
12
- * Example custom integration
13
- *
14
- * Demonstrates how to extend BaseIntegration with custom logic.
15
- */
16
- class ExampleIntegration extends BaseIntegration {
17
- /** Custom property for this integration */
18
- connectionString = "";
19
- connected = false;
20
- /**
21
- * Create a new ExampleIntegration
22
- *
23
- * @param config - Optional configuration
24
- */
25
- constructor(config) {
26
- super("example-integration", "1.0.0", {
27
- enabled: true,
28
- debug: false,
29
- logLevel: "info",
30
- ...config,
31
- });
32
- }
33
- /**
34
- * Set connection string
35
- */
36
- setConnectionString(connStr) {
37
- this.connectionString = connStr;
38
- }
39
- /**
40
- * Check if connected
41
- */
42
- isConnected() {
43
- return this.connected;
44
- }
45
- // ==========================================================================
46
- // Protected abstract method implementations
47
- // ==========================================================================
48
- /**
49
- * Perform integration-specific initialization
50
- */
51
- async performInitialization() {
52
- await this.log("info", "Starting initialization...");
53
- // Simulate async initialization (e.g., connecting to a service)
54
- await new Promise((resolve) => setTimeout(resolve, 100));
55
- if (this.connectionString) {
56
- // Would connect to external service here
57
- this.connected = true;
58
- await this.log("success", "Connected to service");
59
- }
60
- // Emit custom event
61
- this.emit("custom-initialized", { connected: this.connected });
62
- }
63
- /**
64
- * Perform integration-specific shutdown
65
- */
66
- async performShutdown() {
67
- await this.log("info", "Starting shutdown...");
68
- // Simulate async cleanup
69
- await new Promise((resolve) => setTimeout(resolve, 50));
70
- this.connected = false;
71
- await this.log("success", "Shutdown complete");
72
- }
73
- /**
74
- * Perform integration-specific health check
75
- */
76
- async performHealthCheck() {
77
- if (!this.connected) {
78
- return {
79
- healthy: false,
80
- message: "Not connected to service",
81
- details: { connectionString: !!this.connectionString },
82
- };
83
- }
84
- // In a real integration, you might ping the service here
85
- return {
86
- healthy: true,
87
- message: "Service connection healthy",
88
- details: { connected: true },
89
- };
90
- }
91
- }
92
- // ==========================================================================
93
- // Usage Examples
94
- // ==========================================================================
95
- /**
96
- * Example 1: Using a custom integration class
97
- */
98
- async function exampleCustomIntegration() {
99
- console.log("\n--- Example 1: Custom Integration ---");
100
- // Create integration
101
- const integration = new ExampleIntegration({
102
- debug: true,
103
- logLevel: "debug",
104
- });
105
- // Set connection string
106
- integration.setConnectionString("http://localhost:3000");
107
- // Setup event listener
108
- integration.on("initialized", (event) => {
109
- console.log("Integration initialized event:", event.type);
110
- });
111
- // Initialize
112
- await integration.initialize();
113
- // Check health
114
- const health = await integration.healthCheck();
115
- console.log("Health check:", health);
116
- // Get stats
117
- const stats = integration.getStats();
118
- console.log("Stats:", stats);
119
- // Shutdown
120
- await integration.shutdown();
121
- }
122
- /**
123
- * Example 2: Using createSimpleIntegration factory
124
- */
125
- async function exampleSimpleIntegration() {
126
- console.log("\n--- Example 2: Simple Integration ---");
127
- // Create a simple integration without subclassing
128
- const simple = createSimpleIntegration("simple-integration", "1.0.0",
129
- // Custom health check
130
- async () => ({
131
- healthy: true,
132
- message: "Always healthy",
133
- }),
134
- // Custom shutdown
135
- async () => {
136
- console.log("Custom cleanup performed");
137
- });
138
- // Initialize
139
- await simple.initialize();
140
- // Check health
141
- const health = await simple.healthCheck();
142
- console.log("Health check:", health);
143
- // Shutdown
144
- await simple.shutdown();
145
- }
146
- /**
147
- * Example 3: Error handling
148
- */
149
- async function exampleErrorHandling() {
150
- console.log("\n--- Example 3: Error Handling ---");
151
- // Create integration that will fail to initialize
152
- class FailingIntegration extends BaseIntegration {
153
- constructor() {
154
- super("failing-integration", "1.0.0");
155
- }
156
- async performInitialization() {
157
- throw new Error("Connection refused");
158
- }
159
- async performShutdown() {
160
- // Cleanup even on failure
161
- }
162
- async performHealthCheck() {
163
- return { healthy: false, message: "Not initialized" };
164
- }
165
- }
166
- const failing = new FailingIntegration();
167
- try {
168
- await failing.initialize();
169
- }
170
- catch (error) {
171
- console.log("Caught expected error:", error instanceof Error ? error.message : error);
172
- }
173
- }
174
- // Run examples if this file is executed directly
175
- // (In a real project, you would import and use the classes)
176
- // Export for use in other modules
177
- export { ExampleIntegration };
178
- // Example usage (uncomment to run):
179
- // exampleCustomIntegration().catch(console.error);
180
- // exampleSimpleIntegration().catch(console.error);
181
- // exampleErrorHandling().catch(console.error);
@@ -1,34 +0,0 @@
1
- /**
2
- * xray Testing Best Practices MCP Server
3
- *
4
- * Knowledge skill for comprehensive testing strategies, TDD/BDD implementation,
5
- * test coverage optimization, and automated testing workflows
6
- */
7
- import { XrayKnowledgeSkillBase } from "../shared/knowledge-skill-base.js";
8
- declare class XrayTestingBestPracticesServer extends XrayKnowledgeSkillBase {
9
- constructor();
10
- private analyzeTestCoverage;
11
- private designTestStrategy;
12
- private implementTDDWorkflow;
13
- private optimizeTestPerformance;
14
- private setupCICDTesting;
15
- private performCoverageAnalysis;
16
- private createTestStrategy;
17
- private createTDDWorkflow;
18
- private analyzeTestPerformance;
19
- private createCIPipeline;
20
- private prioritizeGaps;
21
- private createCoverageImprovementPlan;
22
- private createImplementationRoadmap;
23
- private recommendTestingTools;
24
- private provideTDDExamples;
25
- private recommendTDDResources;
26
- private createPerformanceOptimizationPlan;
27
- private setupPerformanceMonitoring;
28
- private generateCIConfigTemplates;
29
- private createCITroubleshootingGuide;
30
- private getPriorityIcon;
31
- private getImpactIcon;
32
- private getTestTypeIcon;
33
- }
34
- export { XrayTestingBestPracticesServer };