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,163 +0,0 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import { resolveConfigPath } from "../core/config-paths.js";
4
- export class TokenManager {
5
- config;
6
- constructor(configPath = resolveConfigPath("config.json") || path.join(process.cwd(), ".xray", "config.json")) {
7
- this.config = this.loadConfig(configPath);
8
- }
9
- loadConfig(configPath) {
10
- try {
11
- const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
12
- return (config.token_management || {
13
- maxPromptTokens: 20000,
14
- warningThreshold: 15000,
15
- modelLimits: {},
16
- contextPruning: {
17
- enabled: true,
18
- aggressivePruning: true,
19
- preserveCriticalContext: true,
20
- },
21
- });
22
- }
23
- catch (error) {
24
- // Fallback defaults if config loading fails
25
- return {
26
- maxPromptTokens: 20000,
27
- warningThreshold: 15000,
28
- modelLimits: {},
29
- contextPruning: {
30
- enabled: true,
31
- aggressivePruning: true,
32
- preserveCriticalContext: true,
33
- },
34
- };
35
- }
36
- }
37
- /**
38
- * Estimate token count for text (rough approximation)
39
- * Uses 4 characters per token as a conservative estimate
40
- */
41
- estimateTokens(text) {
42
- return Math.ceil(text.length / 4);
43
- }
44
- /**
45
- * Check if prompt exceeds limits
46
- */
47
- checkLimits(prompt, modelName) {
48
- const currentTokens = this.estimateTokens(prompt);
49
- const maxTokens = modelName
50
- ? this.config.modelLimits[modelName] || this.config.maxPromptTokens
51
- : this.config.maxPromptTokens;
52
- const withinLimit = currentTokens <= maxTokens;
53
- const needsPruning = currentTokens > this.config.maxPromptTokens;
54
- const warning = currentTokens > this.config.warningThreshold;
55
- return {
56
- withinLimit,
57
- currentTokens,
58
- maxTokens,
59
- needsPruning,
60
- warning,
61
- };
62
- }
63
- /**
64
- * Prune context to fit within token limits
65
- */
66
- pruneContext(context, targetTokens = this.config.maxPromptTokens) {
67
- if (!this.config.contextPruning.enabled) {
68
- return context;
69
- }
70
- const currentTokens = this.estimateTokens(context);
71
- if (currentTokens <= targetTokens) {
72
- return context; // No pruning needed
73
- }
74
- // Preserve critical sections (AGENTS.md header, codex terms, etc.)
75
- const criticalSections = this.extractCriticalSections(context);
76
- const criticalTokens = this.estimateTokens(criticalSections.join("\n"));
77
- // Calculate available tokens for non-critical content
78
- const availableTokens = Math.max(targetTokens - criticalTokens, targetTokens * 0.3); // Reserve at least 30%
79
- const nonCriticalContent = this.extractNonCriticalContent(context);
80
- const prunedNonCritical = this.pruneNonCriticalContent(nonCriticalContent, availableTokens);
81
- return `${criticalSections.join("\n")}\n\n${prunedNonCritical}`;
82
- }
83
- extractCriticalSections(context) {
84
- const lines = context.split("\n");
85
- const criticalSections = [];
86
- // Always preserve codex terms and framework overview
87
- const codexSection = this.extractSection(lines, "Universal Development Codex");
88
- const frameworkSection = this.extractSection(lines, "0xRay Framework");
89
- if (codexSection)
90
- criticalSections.push(codexSection);
91
- if (frameworkSection)
92
- criticalSections.push(frameworkSection);
93
- return criticalSections;
94
- }
95
- extractSection(lines, sectionTitle) {
96
- const startIndex = lines.findIndex((line) => line.includes(sectionTitle));
97
- if (startIndex === -1)
98
- return null;
99
- let endIndex = lines.length;
100
- for (let i = startIndex + 1; i < lines.length; i++) {
101
- const currentLine = lines[i];
102
- if (currentLine &&
103
- currentLine.startsWith("#") &&
104
- currentLine !== lines[startIndex]) {
105
- endIndex = i;
106
- break;
107
- }
108
- }
109
- return lines.slice(startIndex, endIndex).join("\n");
110
- }
111
- extractNonCriticalContent(context) {
112
- const criticalSections = this.extractCriticalSections(context);
113
- let result = context;
114
- for (const section of criticalSections) {
115
- result = result.replace(section, "");
116
- }
117
- return result.trim();
118
- }
119
- pruneNonCriticalContent(content, maxTokens) {
120
- const lines = content.split("\n");
121
- const result = [];
122
- let currentTokens = 0;
123
- for (const line of lines) {
124
- const lineTokens = this.estimateTokens(line);
125
- if (currentTokens + lineTokens <= maxTokens) {
126
- result.push(line);
127
- currentTokens += lineTokens;
128
- }
129
- else {
130
- // Truncate line if too long
131
- if (lineTokens > maxTokens * 0.1) {
132
- // If single line is >10% of limit
133
- const maxChars = maxTokens * 4 * 0.1; // Convert tokens to chars
134
- result.push(line.substring(0, maxChars) + "...[truncated]");
135
- }
136
- break;
137
- }
138
- }
139
- return result.join("\n");
140
- }
141
- /**
142
- * Generate warning message for token limits
143
- */
144
- generateWarning(limitCheck) {
145
- if (limitCheck.withinLimit && !limitCheck.warning)
146
- return "";
147
- const messages = [];
148
- if (limitCheck.warning) {
149
- messages.push(`⚠️ Token usage warning: ${limitCheck.currentTokens.toLocaleString()} tokens (${((limitCheck.currentTokens / limitCheck.maxTokens) * 100).toFixed(1)}% of limit)`);
150
- }
151
- if (!limitCheck.withinLimit) {
152
- messages.push(`🚨 Token limit exceeded: ${limitCheck.currentTokens.toLocaleString()} > ${limitCheck.maxTokens.toLocaleString()} tokens`);
153
- messages.push("Context will be automatically pruned to fit within limits.");
154
- }
155
- return messages.join("\n");
156
- }
157
- /**
158
- * Get current configuration
159
- */
160
- getConfig() {
161
- return { ...this.config };
162
- }
163
- }
@@ -1,136 +0,0 @@
1
- /**
2
- * Integration tests for Testing Best Practices MCP Server
3
- */
4
-
5
- import { describe, it, expect, beforeEach } from "vitest";
6
- import { XrayTestingBestPracticesServer } from "./testing-best-practices.server";
7
- import * as fs from "fs";
8
- import * as path from "path";
9
-
10
- describe("testing-best-practices.server integration", () => {
11
- describe("module exports", () => {
12
- it("should export server class", () => {
13
- expect(XrayTestingBestPracticesServer).toBeDefined();
14
- expect(typeof XrayTestingBestPracticesServer).toBe("function");
15
- });
16
-
17
- it("should be able to instantiate the server", () => {
18
- const server = new XrayTestingBestPracticesServer();
19
- expect(server).toBeDefined();
20
- });
21
-
22
- it("should have run method", () => {
23
- const server = new XrayTestingBestPracticesServer();
24
- expect(typeof server.run).toBe("function");
25
- });
26
- });
27
-
28
- describe("server structure", () => {
29
- let server: XrayTestingBestPracticesServer;
30
-
31
- beforeEach(() => {
32
- server = new XrayTestingBestPracticesServer();
33
- });
34
-
35
- it("should instantiate correctly", () => {
36
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
37
- });
38
-
39
- it("should have run async method", () => {
40
- expect(server.run).toBeInstanceOf(Function);
41
- });
42
- });
43
-
44
- describe("test analysis capabilities", () => {
45
- let server: XrayTestingBestPracticesServer;
46
-
47
- beforeEach(() => {
48
- server = new XrayTestingBestPracticesServer();
49
- });
50
-
51
- it("should analyze test coverage", () => {
52
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
53
- });
54
-
55
- it("should identify test gaps", () => {
56
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
57
- });
58
-
59
- it("should provide recommendations", () => {
60
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
61
- });
62
- });
63
-
64
- describe("test strategy types", () => {
65
- let server: XrayTestingBestPracticesServer;
66
-
67
- beforeEach(() => {
68
- server = new XrayTestingBestPracticesServer();
69
- });
70
-
71
- it("should support unit tests", () => {
72
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
73
- });
74
-
75
- it("should support integration tests", () => {
76
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
77
- });
78
-
79
- it("should support e2e tests", () => {
80
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
81
- });
82
-
83
- it("should support performance tests", () => {
84
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
85
- });
86
-
87
- it("should support security tests", () => {
88
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
89
- });
90
- });
91
-
92
- describe("TDD/BDD implementation", () => {
93
- let server: XrayTestingBestPracticesServer;
94
-
95
- beforeEach(() => {
96
- server = new XrayTestingBestPracticesServer();
97
- });
98
-
99
- it("should provide TDD guidance", () => {
100
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
101
- });
102
-
103
- it("should provide BDD guidance", () => {
104
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
105
- });
106
-
107
- it("should suggest test frameworks", () => {
108
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
109
- });
110
- });
111
-
112
- describe("automation workflows", () => {
113
- let server: XrayTestingBestPracticesServer;
114
-
115
- beforeEach(() => {
116
- server = new XrayTestingBestPracticesServer();
117
- });
118
-
119
- it("should calculate automation potential", () => {
120
- expect(server).toBeInstanceOf(XrayTestingBestPracticesServer);
121
- });
122
-
123
- it("should analyze test frameworks", () => {
124
- const projectRoot = process.cwd();
125
- const exists = fs.existsSync(projectRoot);
126
- expect(exists).toBe(true);
127
- });
128
-
129
- it("should work with vitest", () => {
130
- const projectRoot = process.cwd();
131
- const packageJsonPath = path.join(projectRoot, "package.json");
132
- const hasPackageJson = fs.existsSync(packageJsonPath);
133
- expect(hasPackageJson).toBe(true);
134
- });
135
- });
136
- });