0xray 2.1.3 → 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 (178) hide show
  1. package/.opencode/codex.codex +1 -1
  2. package/.opencode/commands/dependency-audit.md +3 -3
  3. package/.opencode/enforcer-config.json +2 -2
  4. package/README.md +3 -3
  5. package/dist/CHANGELOG.md +43 -0
  6. package/dist/README.md +3 -3
  7. package/dist/analytics/routing-refiner.js +1 -1
  8. package/dist/cli/commands/govern.d.ts +29 -0
  9. package/dist/cli/commands/govern.js +152 -0
  10. package/dist/cli/index.js +29 -216
  11. package/dist/core/boot-orchestrator.js +1 -1
  12. package/dist/core/features-config.js +1 -1
  13. package/dist/core/framework-logger.js +30 -1
  14. package/dist/delegation/index.d.ts +1 -2
  15. package/dist/delegation/index.js +1 -2
  16. package/dist/enforcement/enforcer-tools.js +1 -1
  17. package/dist/execution/proposal-applier.d.ts +1 -9
  18. package/dist/execution/proposal-applier.js +18 -173
  19. package/dist/governance/codex-policy.service.d.ts +7 -25
  20. package/dist/governance/codex-policy.service.js +8 -26
  21. package/dist/governance/governance-core.d.ts +22 -28
  22. package/dist/governance/governance-core.js +31 -101
  23. package/dist/governance/governance-service.d.ts +1 -0
  24. package/dist/governance/governance-service.js +67 -4
  25. package/dist/governance/governance-types.d.ts +5 -2
  26. package/dist/inference/index.d.ts +3 -4
  27. package/dist/inference/inference-accumulator.js +1 -1
  28. package/dist/inference/inference-cycle.d.ts +12 -18
  29. package/dist/inference/inference-cycle.js +120 -335
  30. package/dist/integrations/base/index.d.ts +0 -1
  31. package/dist/integrations/base/index.js +0 -2
  32. package/dist/integrations/grok/hooks/pre-tool-use.js +4 -18
  33. package/dist/integrations/hermes-agent/bridge.mjs +10 -1
  34. package/dist/mcps/config/server-config-registry.js +1 -1
  35. package/dist/mcps/governance.server.js +4 -5
  36. package/dist/mcps/knowledge-skills/api-design.server.js +10 -0
  37. package/dist/mcps/knowledge-skills/architecture-patterns.server.js +10 -0
  38. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +10 -0
  39. package/dist/mcps/knowledge-skills/code-analyzer.server.js +10 -0
  40. package/dist/mcps/knowledge-skills/code-review.server.js +10 -0
  41. package/dist/mcps/knowledge-skills/content-creator.server.js +10 -0
  42. package/dist/mcps/knowledge-skills/database-design.server.js +10 -0
  43. package/dist/mcps/knowledge-skills/devops-deployment.server.js +10 -0
  44. package/dist/mcps/knowledge-skills/git-workflow.server.js +10 -0
  45. package/dist/mcps/knowledge-skills/growth-strategist.server.js +10 -0
  46. package/dist/mcps/knowledge-skills/log-monitor.server.js +10 -0
  47. package/dist/mcps/knowledge-skills/mobile-development.server.js +10 -0
  48. package/dist/mcps/knowledge-skills/multimodal-looker.server.js +10 -0
  49. package/dist/mcps/knowledge-skills/performance-optimization.server.js +10 -0
  50. package/dist/mcps/knowledge-skills/project-analysis.server.js +10 -0
  51. package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +10 -0
  52. package/dist/mcps/knowledge-skills/security-audit.server.js +10 -0
  53. package/dist/mcps/knowledge-skills/seo-consultant.server.js +10 -0
  54. package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +4 -0
  55. package/dist/mcps/knowledge-skills/skill-invocation.server.js +33 -14
  56. package/dist/mcps/knowledge-skills/strategist.server.js +10 -0
  57. package/dist/mcps/knowledge-skills/tech-writer.server.js +11 -1
  58. package/dist/mcps/knowledge-skills/testing-strategy.server.js +10 -0
  59. package/dist/mcps/knowledge-skills/ui-ux-design.server.js +10 -0
  60. package/dist/mcps/registry.json +1 -1
  61. package/dist/metrics/agent-metrics.d.ts +2 -1
  62. package/dist/nucleus/govern-http.d.ts +59 -0
  63. package/dist/nucleus/govern-http.js +172 -0
  64. package/dist/nucleus/index.d.ts +14 -0
  65. package/dist/nucleus/index.js +9 -0
  66. package/dist/nucleus/kernel.d.ts +51 -0
  67. package/dist/nucleus/kernel.js +62 -0
  68. package/dist/nucleus/plugin-registry.d.ts +104 -0
  69. package/dist/nucleus/plugin-registry.js +147 -0
  70. package/dist/orchestrator/orchestrator.d.ts +0 -1
  71. package/dist/orchestrator/orchestrator.js +0 -21
  72. package/dist/postprocessor/PostProcessor.d.ts +13 -1
  73. package/dist/postprocessor/PostProcessor.js +41 -1
  74. package/dist/postprocessor/autofix/AutoFixEngine.d.ts +0 -8
  75. package/dist/postprocessor/autofix/AutoFixEngine.js +0 -54
  76. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.d.ts +25 -0
  77. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.js +10 -0
  78. package/dist/postprocessor/metamorphosis/SelfProposalEngine.d.ts +68 -0
  79. package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +371 -0
  80. package/dist/skills/orchestrator/SKILL.md +1 -1
  81. package/dist/skills/registry.json +1 -1
  82. package/dist/state/index.d.ts +0 -2
  83. package/package.json +4 -3
  84. package/scripts/node/universal-version-manager.js +3 -3
  85. package/src/mcps/config/__tests__/server-config-registry.test.ts +6 -15
  86. package/src/mcps/config/server-config-registry.ts +1 -1
  87. package/src/mcps/governance.server.ts +4 -6
  88. package/src/mcps/knowledge-skills/api-design.server.ts +9 -0
  89. package/src/mcps/knowledge-skills/architecture-patterns.server.ts +9 -0
  90. package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +9 -0
  91. package/src/mcps/knowledge-skills/code-analyzer.server.ts +9 -0
  92. package/src/mcps/knowledge-skills/code-review.server.ts +9 -0
  93. package/src/mcps/knowledge-skills/content-creator.server.ts +9 -0
  94. package/src/mcps/knowledge-skills/database-design.server.ts +9 -0
  95. package/src/mcps/knowledge-skills/devops-deployment.server.ts +9 -0
  96. package/src/mcps/knowledge-skills/git-workflow.server.ts +9 -0
  97. package/src/mcps/knowledge-skills/growth-strategist.server.ts +9 -0
  98. package/src/mcps/knowledge-skills/log-monitor.server.ts +9 -0
  99. package/src/mcps/knowledge-skills/mobile-development.server.ts +9 -0
  100. package/src/mcps/knowledge-skills/multimodal-looker.server.ts +9 -0
  101. package/src/mcps/knowledge-skills/performance-optimization.server.ts +9 -0
  102. package/src/mcps/knowledge-skills/project-analysis.server.ts +9 -0
  103. package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +9 -0
  104. package/src/mcps/knowledge-skills/security-audit.server.ts +9 -0
  105. package/src/mcps/knowledge-skills/seo-consultant.server.ts +9 -0
  106. package/src/mcps/knowledge-skills/session-management.server.ts +1 -0
  107. package/src/mcps/knowledge-skills/skill-invocation.server.ts +44 -29
  108. package/src/mcps/knowledge-skills/strategist.server.ts +9 -0
  109. package/src/mcps/knowledge-skills/tech-writer.server.ts +10 -1
  110. package/src/mcps/knowledge-skills/testing-strategy.server.ts +9 -0
  111. package/src/mcps/knowledge-skills/ui-ux-design.server.ts +9 -0
  112. package/src/mcps/registry.json +1 -1
  113. package/src/opencode/codex.codex +1 -1
  114. package/src/opencode/commands/dependency-audit.md +3 -3
  115. package/src/opencode/enforcer-config.json +2 -2
  116. package/src/skills/orchestrator/SKILL.md +1 -1
  117. package/src/skills/registry.json +1 -1
  118. package/xray/codex.json +1 -1
  119. package/xray/config.json +1 -1
  120. package/xray/features.json +1 -1
  121. package/xray/integrations.json +3 -3
  122. package/.opencode/agents/testing-best-practices.yml +0 -12
  123. package/dist/analytics/consent-manager.d.ts +0 -93
  124. package/dist/analytics/consent-manager.js +0 -258
  125. package/dist/analytics/simple-pattern-analyzer.d.ts +0 -80
  126. package/dist/analytics/simple-pattern-analyzer.js +0 -297
  127. package/dist/cli/commands/analytics-disable.d.ts +0 -9
  128. package/dist/cli/commands/analytics-disable.js +0 -72
  129. package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
  130. package/dist/cli/commands/analytics-enable-action.js +0 -82
  131. package/dist/cli/commands/analytics-preview.d.ts +0 -9
  132. package/dist/cli/commands/analytics-preview.js +0 -106
  133. package/dist/cli/commands/analytics-status.d.ts +0 -9
  134. package/dist/cli/commands/analytics-status.js +0 -68
  135. package/dist/cli/server.d.ts +0 -1
  136. package/dist/cli/server.js +0 -147
  137. package/dist/core/errors.d.ts +0 -3
  138. package/dist/core/errors.js +0 -10
  139. package/dist/core/logging-config.d.ts +0 -11
  140. package/dist/core/logging-config.js +0 -43
  141. package/dist/core/trace-context.d.ts +0 -12
  142. package/dist/core/trace-context.js +0 -33
  143. package/dist/delegation/voting-coordinator.d.ts +0 -49
  144. package/dist/delegation/voting-coordinator.js +0 -375
  145. package/dist/enforcement/test-auto-healing.d.ts +0 -83
  146. package/dist/enforcement/test-auto-healing.js +0 -325
  147. package/dist/integrations/base/ExampleIntegration.d.ts +0 -47
  148. package/dist/integrations/base/ExampleIntegration.js +0 -181
  149. package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +0 -34
  150. package/dist/mcps/knowledge-skills/testing-best-practices.server.js +0 -831
  151. package/dist/mcps/orchestrator.server.d.ts +0 -10
  152. package/dist/mcps/orchestrator.server.js +0 -19
  153. package/dist/orchestrator/self-direction-activation.d.ts +0 -109
  154. package/dist/orchestrator/self-direction-activation.js +0 -245
  155. package/dist/orchestrator/universal-librarian-consultation.d.ts +0 -98
  156. package/dist/orchestrator/universal-librarian-consultation.js +0 -216
  157. package/dist/orchestrator/universal-registry-bridge.d.ts +0 -85
  158. package/dist/orchestrator/universal-registry-bridge.js +0 -247
  159. package/dist/performance/performance-budget-enforcer.d.ts +0 -158
  160. package/dist/performance/performance-budget-enforcer.js +0 -434
  161. package/dist/performance/performance-regression-tester.d.ts +0 -108
  162. package/dist/performance/performance-regression-tester.js +0 -342
  163. package/dist/skills/testing-best-practices/SKILL.md +0 -37
  164. package/dist/state/context-providers.d.ts +0 -4
  165. package/dist/state/context-providers.js +0 -1
  166. package/dist/state/state-types.d.ts +0 -5
  167. package/dist/state/state-types.js +0 -1
  168. package/dist/utils/batch-operations.d.ts +0 -25
  169. package/dist/utils/batch-operations.js +0 -292
  170. package/dist/utils/test-template-generator.d.ts +0 -25
  171. package/dist/utils/test-template-generator.js +0 -178
  172. package/dist/utils/token-manager.d.ts +0 -48
  173. package/dist/utils/token-manager.js +0 -163
  174. package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +0 -136
  175. package/src/mcps/knowledge-skills/testing-best-practices.server.ts +0 -1183
  176. package/src/mcps/orchestrator.server.ts +0 -34
  177. package/src/opencode/agents/testing-best-practices.yml +0 -12
  178. 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
- });