0xray 2.1.1 → 2.1.3

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 (254) 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/AGENTS.md +3 -2
  5. package/README.md +12 -11
  6. package/dist/AGENTS.md +3 -2
  7. package/dist/CHANGELOG.md +26 -0
  8. package/dist/README.md +12 -11
  9. package/dist/agents/code-reviewer.js +1 -1
  10. package/dist/analytics/routing-refiner.js +1 -1
  11. package/dist/cli/index.js +11 -1
  12. package/dist/cli/server.js +3 -3
  13. package/dist/core/activity-logger.d.ts +2 -2
  14. package/dist/core/activity-logger.js +4 -4
  15. package/dist/core/boot-orchestrator.d.ts +1 -1
  16. package/dist/core/boot-orchestrator.js +13 -28
  17. package/dist/core/bridge.mjs +3 -3
  18. package/dist/core/codex-formatter.js +2 -2
  19. package/dist/core/codex-injector.d.ts +0 -1
  20. package/dist/core/codex-injector.js +2 -3
  21. package/dist/core/config-loader.d.ts +1 -1
  22. package/dist/core/config-loader.js +1 -1
  23. package/dist/core/config-paths.d.ts +0 -2
  24. package/dist/core/config-paths.js +7 -8
  25. package/dist/core/context-loader.d.ts +1 -1
  26. package/dist/core/context-loader.js +1 -1
  27. package/dist/core/errors.d.ts +3 -0
  28. package/dist/core/errors.js +10 -0
  29. package/dist/core/features-config.js +1 -1
  30. package/dist/core/framework-logger.d.ts +3 -3
  31. package/dist/core/framework-logger.js +17 -9
  32. package/dist/core/index.d.ts +2 -2
  33. package/dist/core/index.js +4 -2
  34. package/dist/core/logging-config.d.ts +2 -1
  35. package/dist/core/logging-config.js +7 -7
  36. package/dist/enforcement/loaders/codex-loader.js +1 -1
  37. package/dist/execution/opencode-cli-invoker.js +5 -5
  38. package/dist/governance/governance-service.js +1 -1
  39. package/dist/index.d.ts +3 -3
  40. package/dist/index.js +3 -3
  41. package/dist/inference/inference-cycle.d.ts +1 -1
  42. package/dist/inference/inference-cycle.js +10 -10
  43. package/dist/integrations/base/Integration.js +1 -1
  44. package/dist/integrations/base/registry.js +19 -19
  45. package/dist/integrations/grok/grok-cli.js +17 -17
  46. package/dist/integrations/grok/hooks/pre-tool-use.js +1 -1
  47. package/dist/integrations/hermes-agent/bridge.mjs +1 -1
  48. package/dist/integrations/openclaw/api-server.d.ts +0 -1
  49. package/dist/integrations/openclaw/api-server.js +7 -10
  50. package/dist/integrations/openclaw/client.d.ts +0 -1
  51. package/dist/integrations/openclaw/client.js +22 -24
  52. package/dist/integrations/openclaw/hooks/xray-hooks.d.ts +0 -1
  53. package/dist/integrations/openclaw/hooks/xray-hooks.js +17 -18
  54. package/dist/integrations/plugins/plugin-registry.js +5 -5
  55. package/dist/mcps/architect-tools.server.d.ts +2 -4
  56. package/dist/mcps/architect-tools.server.js +112 -195
  57. package/dist/mcps/auto-format.server.d.ts +2 -4
  58. package/dist/mcps/auto-format.server.js +49 -95
  59. package/dist/mcps/boot-orchestrator.server.d.ts +2 -4
  60. package/dist/mcps/boot-orchestrator.server.js +73 -105
  61. package/dist/mcps/config/server-config-registry.js +3 -3
  62. package/dist/mcps/enforcer-tools.server.d.ts +2 -4
  63. package/dist/mcps/enforcer-tools.server.js +202 -285
  64. package/dist/mcps/estimation.server.d.ts +2 -4
  65. package/dist/mcps/estimation.server.js +63 -107
  66. package/dist/mcps/framework-compliance-audit.server.d.ts +2 -4
  67. package/dist/mcps/framework-compliance-audit.server.js +53 -82
  68. package/dist/mcps/framework-help.server.d.ts +2 -4
  69. package/dist/mcps/framework-help.server.js +63 -101
  70. package/dist/mcps/governance.server.js +2 -2
  71. package/dist/mcps/knowledge-skills/api-design.server.d.ts +2 -4
  72. package/dist/mcps/knowledge-skills/api-design.server.js +35 -67
  73. package/dist/mcps/knowledge-skills/architecture-patterns.server.d.ts +2 -10
  74. package/dist/mcps/knowledge-skills/architecture-patterns.server.js +35 -74
  75. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.d.ts +2 -4
  76. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +143 -162
  77. package/dist/mcps/knowledge-skills/code-analyzer.server.d.ts +3 -4
  78. package/dist/mcps/knowledge-skills/code-analyzer.server.js +20 -45
  79. package/dist/mcps/knowledge-skills/code-review.server.d.ts +2 -4
  80. package/dist/mcps/knowledge-skills/code-review.server.js +109 -143
  81. package/dist/mcps/knowledge-skills/content-creator.server.d.ts +2 -4
  82. package/dist/mcps/knowledge-skills/content-creator.server.js +205 -226
  83. package/dist/mcps/knowledge-skills/database-design.server.d.ts +2 -4
  84. package/dist/mcps/knowledge-skills/database-design.server.js +117 -151
  85. package/dist/mcps/knowledge-skills/devops-deployment.server.d.ts +2 -4
  86. package/dist/mcps/knowledge-skills/devops-deployment.server.js +71 -160
  87. package/dist/mcps/knowledge-skills/git-workflow.server.d.ts +2 -4
  88. package/dist/mcps/knowledge-skills/git-workflow.server.js +36 -68
  89. package/dist/mcps/knowledge-skills/growth-strategist.server.d.ts +2 -4
  90. package/dist/mcps/knowledge-skills/growth-strategist.server.js +303 -324
  91. package/dist/mcps/knowledge-skills/log-monitor.server.d.ts +2 -4
  92. package/dist/mcps/knowledge-skills/log-monitor.server.js +141 -160
  93. package/dist/mcps/knowledge-skills/mobile-development.server.d.ts +2 -4
  94. package/dist/mcps/knowledge-skills/mobile-development.server.js +92 -209
  95. package/dist/mcps/knowledge-skills/multimodal-looker.server.d.ts +2 -4
  96. package/dist/mcps/knowledge-skills/multimodal-looker.server.js +123 -159
  97. package/dist/mcps/knowledge-skills/performance-optimization.server.d.ts +2 -5
  98. package/dist/mcps/knowledge-skills/performance-optimization.server.js +155 -296
  99. package/dist/mcps/knowledge-skills/project-analysis.server.d.ts +2 -4
  100. package/dist/mcps/knowledge-skills/project-analysis.server.js +75 -226
  101. package/dist/mcps/knowledge-skills/refactoring-strategies.server.d.ts +2 -4
  102. package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +63 -156
  103. package/dist/mcps/knowledge-skills/security-audit.server.d.ts +2 -4
  104. package/dist/mcps/knowledge-skills/security-audit.server.js +102 -136
  105. package/dist/mcps/knowledge-skills/seo-consultant.server.d.ts +2 -4
  106. package/dist/mcps/knowledge-skills/seo-consultant.server.js +80 -203
  107. package/dist/mcps/knowledge-skills/session-management.server.d.ts +2 -4
  108. package/dist/mcps/knowledge-skills/session-management.server.js +50 -203
  109. package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +2 -4
  110. package/dist/mcps/knowledge-skills/skill-invocation.server.js +168 -347
  111. package/dist/mcps/knowledge-skills/strategist.server.d.ts +2 -11
  112. package/dist/mcps/knowledge-skills/strategist.server.js +72 -122
  113. package/dist/mcps/knowledge-skills/tech-writer.server.d.ts +2 -4
  114. package/dist/mcps/knowledge-skills/tech-writer.server.js +87 -300
  115. package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +2 -4
  116. package/dist/mcps/knowledge-skills/testing-best-practices.server.js +147 -182
  117. package/dist/mcps/knowledge-skills/testing-strategy.server.d.ts +2 -4
  118. package/dist/mcps/knowledge-skills/testing-strategy.server.js +78 -153
  119. package/dist/mcps/knowledge-skills/ui-ux-design.server.d.ts +2 -5
  120. package/dist/mcps/knowledge-skills/ui-ux-design.server.js +90 -399
  121. package/dist/mcps/lint.server.d.ts +2 -4
  122. package/dist/mcps/lint.server.js +51 -92
  123. package/dist/mcps/mcp-client.js +2 -2
  124. package/dist/mcps/model-health-check.server.d.ts +2 -4
  125. package/dist/mcps/model-health-check.server.js +32 -60
  126. package/dist/mcps/performance-analysis.server.d.ts +2 -4
  127. package/dist/mcps/performance-analysis.server.js +57 -88
  128. package/dist/mcps/processor-pipeline.server.d.ts +2 -4
  129. package/dist/mcps/processor-pipeline.server.js +69 -100
  130. package/dist/mcps/registry.json +1 -1
  131. package/dist/mcps/researcher.server.d.ts +3 -5
  132. package/dist/mcps/researcher.server.js +81 -154
  133. package/dist/mcps/security-scan.server.d.ts +2 -4
  134. package/dist/mcps/security-scan.server.js +54 -96
  135. package/dist/mcps/shared/knowledge-skill-base.d.ts +14 -0
  136. package/dist/mcps/shared/knowledge-skill-base.js +45 -0
  137. package/dist/{security → mcps/shared}/security-scanner.js +1 -1
  138. package/dist/mcps/state-manager.server.d.ts +2 -4
  139. package/dist/mcps/state-manager.server.js +115 -160
  140. package/dist/orchestrator/orchestrator.d.ts +1 -1
  141. package/dist/orchestrator/orchestrator.js +1 -1
  142. package/dist/orchestrator/universal-registry-bridge.js +1 -1
  143. package/dist/plugin/xray-codex-injection.d.ts +1 -1
  144. package/dist/plugin/xray-codex-injection.js +1 -1
  145. package/dist/postprocessor/PostProcessor.d.ts +4 -44
  146. package/dist/postprocessor/PostProcessor.js +39 -553
  147. package/dist/postprocessor/analysis/CodeChangeAnalyzer.d.ts +11 -0
  148. package/dist/postprocessor/analysis/CodeChangeAnalyzer.js +50 -0
  149. package/dist/postprocessor/compliance/ArchitecturalComplianceChecker.d.ts +11 -0
  150. package/dist/postprocessor/compliance/ArchitecturalComplianceChecker.js +356 -0
  151. package/dist/postprocessor/config/ProcessorConfigLoader.d.ts +44 -0
  152. package/dist/postprocessor/config/ProcessorConfigLoader.js +21 -0
  153. package/dist/postprocessor/reporting/PostProcessorReporter.d.ts +19 -0
  154. package/dist/postprocessor/reporting/PostProcessorReporter.js +96 -0
  155. package/dist/postprocessor/triggers/GitHookTrigger.js +11 -11
  156. package/dist/processors/implementations/refactoring-logging-processor-wrapper.d.ts +32 -0
  157. package/dist/processors/implementations/refactoring-logging-processor-wrapper.js +95 -1
  158. package/dist/processors/processor-manager.js +346 -314
  159. package/dist/reporting/report-formatter.js +1 -1
  160. package/dist/security/security-hardener.d.ts +69 -2
  161. package/dist/security/security-hardener.js +129 -1
  162. package/dist/skills/registry.json +1 -1
  163. package/dist/state/index.d.ts +3 -5
  164. package/dist/state/index.js +1 -7
  165. package/dist/state/state-manager.d.ts +1 -1
  166. package/dist/state/state-manager.js +2 -3
  167. package/package.json +14 -10
  168. package/scripts/node/setup.cjs +32 -0
  169. package/scripts/node/universal-version-manager.js +11 -11
  170. package/src/mcps/architect-tools.server.ts +112 -215
  171. package/src/mcps/auto-format.server.ts +50 -110
  172. package/src/mcps/boot-orchestrator.server.ts +75 -121
  173. package/src/mcps/config/__tests__/server-config-registry.test.ts +21 -12
  174. package/src/mcps/config/server-config-registry.ts +3 -3
  175. package/src/mcps/enforcer-tools.server.ts +212 -310
  176. package/src/mcps/estimation.server.ts +62 -122
  177. package/src/mcps/framework-compliance-audit.server.ts +52 -97
  178. package/src/mcps/framework-help.server.ts +64 -114
  179. package/src/mcps/governance.server.ts +2 -2
  180. package/src/mcps/knowledge-skills/api-design.server.ts +32 -77
  181. package/src/mcps/knowledge-skills/architecture-patterns.server.ts +31 -87
  182. package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +165 -193
  183. package/src/mcps/knowledge-skills/code-analyzer.server.ts +20 -55
  184. package/src/mcps/knowledge-skills/code-review.server.ts +114 -161
  185. package/src/mcps/knowledge-skills/content-creator.server.ts +218 -255
  186. package/src/mcps/knowledge-skills/database-design.server.ts +118 -165
  187. package/src/mcps/knowledge-skills/devops-deployment.server.ts +67 -172
  188. package/src/mcps/knowledge-skills/git-workflow.server.ts +32 -77
  189. package/src/mcps/knowledge-skills/growth-strategist.server.ts +324 -361
  190. package/src/mcps/knowledge-skills/log-monitor.server.ts +160 -187
  191. package/src/mcps/knowledge-skills/mobile-development.server.ts +89 -223
  192. package/src/mcps/knowledge-skills/multimodal-looker.server.ts +128 -175
  193. package/src/mcps/knowledge-skills/performance-optimization.server.ts +156 -329
  194. package/src/mcps/knowledge-skills/project-analysis.server.ts +72 -248
  195. package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +59 -171
  196. package/src/mcps/knowledge-skills/security-audit.server.ts +104 -151
  197. package/src/mcps/knowledge-skills/seo-consultant.server.ts +80 -220
  198. package/src/mcps/knowledge-skills/session-management.server.ts +51 -232
  199. package/src/mcps/knowledge-skills/skill-invocation.server.ts +165 -372
  200. package/src/mcps/knowledge-skills/strategist.server.ts +72 -143
  201. package/src/mcps/knowledge-skills/tech-writer.server.ts +85 -350
  202. package/src/mcps/knowledge-skills/testing-best-practices.server.ts +146 -195
  203. package/src/mcps/knowledge-skills/testing-strategy.server.ts +75 -161
  204. package/src/mcps/knowledge-skills/ui-ux-design.server.ts +93 -487
  205. package/src/mcps/lint.server.ts +53 -107
  206. package/src/mcps/mcp-client.ts +2 -2
  207. package/src/mcps/model-health-check.server.ts +34 -71
  208. package/src/mcps/performance-analysis.server.ts +60 -104
  209. package/src/mcps/processor-pipeline.server.ts +72 -110
  210. package/src/mcps/registry.json +1 -1
  211. package/src/mcps/researcher.server.ts +88 -177
  212. package/src/mcps/security-scan.server.ts +55 -104
  213. package/src/mcps/shared/knowledge-skill-base.ts +62 -0
  214. package/src/mcps/shared/prompt-security-validator.ts +199 -0
  215. package/src/mcps/shared/security-scanner.ts +599 -0
  216. package/src/mcps/state-manager.server.ts +117 -175
  217. package/src/opencode/codex.codex +1 -1
  218. package/src/opencode/commands/dependency-audit.md +3 -3
  219. package/src/opencode/enforcer-config.json +2 -2
  220. package/src/skills/registry.json +1 -1
  221. package/xray/agents_template.md +109 -0
  222. package/xray/codex.json +598 -0
  223. package/xray/config.json +26 -0
  224. package/xray/features.json +132 -0
  225. package/xray/integrations.json +23 -0
  226. package/xray/routing-mappings.json +752 -0
  227. package/xray/workflow_state.json +28 -0
  228. package/dist/integrations/hermes-agent/__pycache__/__init__.cpython-313.pyc +0 -0
  229. package/dist/integrations/hermes-agent/__pycache__/conftest.cpython-313-pytest-9.0.2.pyc +0 -0
  230. package/dist/integrations/hermes-agent/__pycache__/schemas.cpython-313.pyc +0 -0
  231. package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313-pytest-9.0.2.pyc +0 -0
  232. package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313.pyc +0 -0
  233. package/dist/integrations/hermes-agent/__pycache__/tools.cpython-313.pyc +0 -0
  234. package/dist/integrations/hermes-agent/conftest.py +0 -14
  235. package/dist/integrations/hermes-agent/test_plugin.py +0 -1103
  236. package/dist/processors/implementations/refactoring-logging-processor.d.ts +0 -31
  237. package/dist/processors/implementations/refactoring-logging-processor.js +0 -96
  238. package/dist/processors/implementations/session-capture-processor.d.ts +0 -14
  239. package/dist/processors/implementations/session-capture-processor.js +0 -37
  240. package/dist/scripts/activate-kernel-pipeline.d.ts +0 -7
  241. package/dist/scripts/activate-kernel-pipeline.js +0 -101
  242. package/dist/security/index.d.ts +0 -13
  243. package/dist/security/index.js +0 -13
  244. package/dist/security/security-agent-coordinator.d.ts +0 -72
  245. package/dist/security/security-agent-coordinator.js +0 -204
  246. package/dist/security/security-auditor.d.ts +0 -56
  247. package/dist/security/security-auditor.js +0 -584
  248. package/dist/security/security-hardening-system.d.ts +0 -239
  249. package/dist/security/security-hardening-system.js +0 -727
  250. package/dist/security/security-orchestration-layer.d.ts +0 -119
  251. package/dist/security/security-orchestration-layer.js +0 -496
  252. /package/dist/{security → mcps/shared}/prompt-security-validator.d.ts +0 -0
  253. /package/dist/{security → mcps/shared}/prompt-security-validator.js +0 -0
  254. /package/dist/{security → mcps/shared}/security-scanner.d.ts +0 -0
@@ -5,12 +5,6 @@
5
5
  * Provides rule enforcement and validation capabilities via MCP protocol
6
6
  */
7
7
 
8
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
- import {
11
- CallToolRequestSchema,
12
- ListToolsRequestSchema,
13
- } from "@modelcontextprotocol/sdk/types.js";
14
8
  import * as fs from "fs";
15
9
  import * as path from "path";
16
10
  import { frameworkLogger } from "../core/framework-logger.js";
@@ -20,8 +14,9 @@ import { getCodexPolicyService } from "../governance/codex-policy.service.js";
20
14
  import { ruleValidation as runRuleValidation, getTaskRoutingRecommendation, EnforcementResult } from "../enforcement/enforcer-tools.js";
21
15
  import { RuleValidationContext, ValidationReport } from "../enforcement/rule-enforcer.js";
22
16
  import type { RuleFix } from "../enforcement/types.js";
23
- import type { SecurityReport } from "../security/security-scanner.js";
24
- import type { SecurityValidationResult } from "../security/prompt-security-validator.js";
17
+ import type { SecurityReport } from "./shared/security-scanner.js";
18
+ import type { SecurityValidationResult } from "./shared/prompt-security-validator.js";
19
+ import { XrayKnowledgeSkillBase } from "./shared/knowledge-skill-base.js";
25
20
 
26
21
  interface RuleValidationArgs {
27
22
  operation: string;
@@ -138,273 +133,236 @@ interface SecurityScanResults {
138
133
  promptValidation?: { isSafe: boolean; riskLevel: string; violations: string[] } | { error: string };
139
134
  }
140
135
 
141
- class XrayEnforcerToolsServer {
142
- private server: Server;
136
+ class XrayEnforcerToolsServer extends XrayKnowledgeSkillBase {
143
137
 
144
138
  constructor() {
145
- this.server = new Server(
139
+ super("enforcer", "2.0.1");
140
+ this.tools = [
146
141
  {
147
- name: "enforcer", version: "2.0.1",
148
- },
149
- {
150
- capabilities: {
151
- tools: {},
152
- },
153
- },
154
- );
155
-
156
- this.setupToolHandlers();
157
- }
158
-
159
- private setupToolHandlers() {
160
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
161
- return {
162
- tools: [
163
- {
164
- name: "rule-validation",
165
- description:
166
- "Validate operations against the comprehensive rule hierarchy including duplicate code prevention, test requirements, and architectural constraints",
167
- inputSchema: {
142
+ name: "rule-validation",
143
+ description:
144
+ "Validate operations against the comprehensive rule hierarchy including duplicate code prevention, test requirements, and architectural constraints",
145
+ inputSchema: {
146
+ type: "object",
147
+ properties: {
148
+ operation: {
149
+ type: "string",
150
+ description:
151
+ "Operation to validate (create, modify, refactor, etc.)",
152
+ },
153
+ files: {
154
+ type: "array",
155
+ items: { type: "string" },
156
+ description: "Files affected by the operation",
157
+ },
158
+ newCode: {
159
+ type: "string",
160
+ description: "New code being added (optional)",
161
+ },
162
+ existingCode: {
168
163
  type: "object",
169
- properties: {
170
- operation: {
171
- type: "string",
172
- description:
173
- "Operation to validate (create, modify, refactor, etc.)",
174
- },
175
- files: {
176
- type: "array",
177
- items: { type: "string" },
178
- description: "Files affected by the operation",
179
- },
180
- newCode: {
181
- type: "string",
182
- description: "New code being added (optional)",
183
- },
184
- existingCode: {
185
- type: "object",
186
- description: "Map of existing code for comparison (optional)",
187
- },
188
- dependencies: {
189
- type: "array",
190
- items: { type: "string" },
191
- description: "Dependencies being declared (optional)",
192
- },
193
- tests: {
194
- type: "array",
195
- items: { type: "string" },
196
- description: "Test files for validation (optional)",
197
- },
198
- },
199
- required: ["operation"],
164
+ description: "Map of existing code for comparison (optional)",
165
+ },
166
+ dependencies: {
167
+ type: "array",
168
+ items: { type: "string" },
169
+ description: "Dependencies being declared (optional)",
170
+ },
171
+ tests: {
172
+ type: "array",
173
+ items: { type: "string" },
174
+ description: "Test files for validation (optional)",
200
175
  },
201
176
  },
202
- {
203
- name: "codex-enforcement",
204
- description:
205
- "Enforce all Universal Development Codex terms with comprehensive compliance validation and actionable remediation",
206
- inputSchema: {
207
- type: "object",
208
- properties: {
209
- operation: {
210
- type: "string",
211
- description: "Operation to validate against codex",
212
- },
213
- files: {
214
- type: "array",
215
- items: { type: "string" },
216
- description: "Files to check for codex compliance",
217
- },
218
- newCode: {
219
- type: "string",
220
- description: "New code to validate against codex terms",
221
- },
222
- focusAreas: {
223
- type: "array",
224
- items: {
225
- type: "string",
226
- enum: [
227
- "error-handling",
228
- "type-safety",
229
- "performance",
230
- "security",
231
- "architecture",
232
- ],
233
- },
234
- description: "Specific codex areas to focus validation on",
235
- },
177
+ required: ["operation"],
178
+ },
179
+ },
180
+ {
181
+ name: "codex-enforcement",
182
+ description:
183
+ "Enforce all Universal Development Codex terms with comprehensive compliance validation and actionable remediation",
184
+ inputSchema: {
185
+ type: "object",
186
+ properties: {
187
+ operation: {
188
+ type: "string",
189
+ description: "Operation to validate against codex",
190
+ },
191
+ files: {
192
+ type: "array",
193
+ items: { type: "string" },
194
+ description: "Files to check for codex compliance",
195
+ },
196
+ newCode: {
197
+ type: "string",
198
+ description: "New code to validate against codex terms",
199
+ },
200
+ focusAreas: {
201
+ type: "array",
202
+ items: {
203
+ type: "string",
204
+ enum: [
205
+ "error-handling",
206
+ "type-safety",
207
+ "performance",
208
+ "security",
209
+ "architecture",
210
+ ],
236
211
  },
237
- required: ["operation"],
212
+ description: "Specific codex areas to focus validation on",
238
213
  },
239
214
  },
240
- {
241
- name: "context-analysis-validation",
242
- description:
243
- "Validate proper integration of contextual analysis components and architectural patterns",
244
- inputSchema: {
245
- type: "object",
246
- properties: {
247
- files: {
248
- type: "array",
249
- items: { type: "string" },
250
- description: "Files to validate for context integration",
251
- },
252
- operation: {
253
- type: "string",
254
- description: "Operation context for validation",
255
- },
256
- checkPatterns: {
257
- type: "array",
258
- items: {
259
- type: "string",
260
- enum: [
261
- "memory-optimization",
262
- "error-handling",
263
- "type-safety",
264
- "dependency-injection",
265
- ],
266
- },
267
- description: "Specific integration patterns to validate",
268
- },
215
+ required: ["operation"],
216
+ },
217
+ },
218
+ {
219
+ name: "context-analysis-validation",
220
+ description:
221
+ "Validate proper integration of contextual analysis components and architectural patterns",
222
+ inputSchema: {
223
+ type: "object",
224
+ properties: {
225
+ files: {
226
+ type: "array",
227
+ items: { type: "string" },
228
+ description: "Files to validate for context integration",
229
+ },
230
+ operation: {
231
+ type: "string",
232
+ description: "Operation context for validation",
233
+ },
234
+ checkPatterns: {
235
+ type: "array",
236
+ items: {
237
+ type: "string",
238
+ enum: [
239
+ "memory-optimization",
240
+ "error-handling",
241
+ "type-safety",
242
+ "dependency-injection",
243
+ ],
269
244
  },
270
- required: ["files", "operation"],
245
+ description: "Specific integration patterns to validate",
271
246
  },
272
247
  },
273
- {
274
- name: "quality-gate-check",
275
- description:
276
- "Perform comprehensive quality gate validation before commits with automated fixes and blocking decisions",
277
- inputSchema: {
248
+ required: ["files", "operation"],
249
+ },
250
+ },
251
+ {
252
+ name: "quality-gate-check",
253
+ description:
254
+ "Perform comprehensive quality gate validation before commits with automated fixes and blocking decisions",
255
+ inputSchema: {
256
+ type: "object",
257
+ properties: {
258
+ operation: {
259
+ type: "string",
260
+ description: "Operation to quality-gate check",
261
+ },
262
+ context: {
278
263
  type: "object",
279
264
  properties: {
280
- operation: {
281
- type: "string",
282
- description: "Operation to quality-gate check",
283
- },
284
- context: {
285
- type: "object",
286
- properties: {
287
- files: { type: "array", items: { type: "string" } },
288
- newCode: { type: "string" },
289
- dependencies: { type: "array", items: { type: "string" } },
290
- tests: { type: "array", items: { type: "string" } },
291
- },
292
- description:
293
- "Complete operation context for comprehensive validation",
294
- },
295
- strictMode: {
296
- type: "boolean",
297
- default: true,
298
- description: "Enforce strict quality requirements",
299
- },
265
+ files: { type: "array", items: { type: "string" } },
266
+ newCode: { type: "string" },
267
+ dependencies: { type: "array", items: { type: "string" } },
268
+ tests: { type: "array", items: { type: "string" } },
300
269
  },
301
- required: ["operation", "context"],
270
+ description:
271
+ "Complete operation context for comprehensive validation",
272
+ },
273
+ strictMode: {
274
+ type: "boolean",
275
+ default: true,
276
+ description: "Enforce strict quality requirements",
302
277
  },
303
278
  },
304
- {
305
- name: "get-enforcement-status",
306
- description:
307
- "Get comprehensive enforcement statistics and rule compliance metrics",
308
- inputSchema: {
309
- type: "object",
310
- properties: {
311
- includeHistory: {
312
- type: "boolean",
313
- default: false,
314
- description: "Include historical enforcement data",
315
- },
316
- focusAreas: {
317
- type: "array",
318
- items: {
319
- type: "string",
320
- enum: ["rules", "codex", "quality", "performance"],
321
- },
322
- description: "Specific areas to focus status reporting on",
323
- },
279
+ required: ["operation", "context"],
280
+ },
281
+ },
282
+ {
283
+ name: "get-enforcement-status",
284
+ description:
285
+ "Get comprehensive enforcement statistics and rule compliance metrics",
286
+ inputSchema: {
287
+ type: "object",
288
+ properties: {
289
+ includeHistory: {
290
+ type: "boolean",
291
+ default: false,
292
+ description: "Include historical enforcement data",
293
+ },
294
+ focusAreas: {
295
+ type: "array",
296
+ items: {
297
+ type: "string",
298
+ enum: ["rules", "codex", "quality", "performance"],
324
299
  },
300
+ description: "Specific areas to focus status reporting on",
325
301
  },
326
302
  },
327
- {
328
- name: "run-pre-commit-validation",
329
- description:
330
- "Execute comprehensive pre-commit validation with all enforcer tools and automated remediation",
331
- inputSchema: {
332
- type: "object",
333
- properties: {
334
- files: {
335
- type: "array",
336
- items: { type: "string" },
337
- description: "Files to validate before commit",
338
- },
339
- operation: {
340
- type: "string",
341
- default: "commit",
342
- description: "Operation type for validation context",
343
- },
344
- autoFix: {
345
- type: "boolean",
346
- default: true,
347
- description: "Automatically apply safe fixes",
348
- },
349
- strictBlocking: {
350
- type: "boolean",
351
- default: true,
352
- description: "Block commit on any validation error",
353
- },
354
- },
355
- required: ["files"],
303
+ },
304
+ },
305
+ {
306
+ name: "run-pre-commit-validation",
307
+ description:
308
+ "Execute comprehensive pre-commit validation with all enforcer tools and automated remediation",
309
+ inputSchema: {
310
+ type: "object",
311
+ properties: {
312
+ files: {
313
+ type: "array",
314
+ items: { type: "string" },
315
+ description: "Files to validate before commit",
316
+ },
317
+ operation: {
318
+ type: "string",
319
+ default: "commit",
320
+ description: "Operation type for validation context",
321
+ },
322
+ autoFix: {
323
+ type: "boolean",
324
+ default: true,
325
+ description: "Automatically apply safe fixes",
326
+ },
327
+ strictBlocking: {
328
+ type: "boolean",
329
+ default: true,
330
+ description: "Block commit on any validation error",
356
331
  },
357
332
  },
358
- {
359
- name: "security-scan",
360
- description:
361
- "Run security scan using npm audit, Trivy, ESLint security, and OWASP dependency check",
362
- inputSchema: {
363
- type: "object",
364
- properties: {
365
- includePromptValidation: {
366
- type: "boolean",
367
- default: false,
368
- description: "Also validate prompts for injection attacks",
369
- },
370
- promptText: {
371
- type: "string",
372
- description: "Prompt text to validate for injection attacks",
373
- },
374
- },
333
+ required: ["files"],
334
+ },
335
+ },
336
+ {
337
+ name: "security-scan",
338
+ description:
339
+ "Run security scan using npm audit, Trivy, ESLint security, and OWASP dependency check",
340
+ inputSchema: {
341
+ type: "object",
342
+ properties: {
343
+ includePromptValidation: {
344
+ type: "boolean",
345
+ default: false,
346
+ description: "Also validate prompts for injection attacks",
347
+ },
348
+ promptText: {
349
+ type: "string",
350
+ description: "Prompt text to validate for injection attacks",
375
351
  },
376
352
  },
377
- ],
378
- };
379
- });
380
-
381
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
382
- const { name, arguments: args } = request.params;
383
-
384
- try {
385
- switch (name) {
386
- case "rule-validation":
387
- return await this.ruleValidation(args);
388
- case "codex-enforcement":
389
- return await this.codexEnforcement(args);
390
- case "context-analysis-validation":
391
- return await this.contextAnalysisValidation(args);
392
- case "quality-gate-check":
393
- return await this.qualityGateCheck(args);
394
- case "get-enforcement-status":
395
- return await this.getEnforcementStatus(args);
396
- case "run-pre-commit-validation":
397
- return await this.runPreCommitValidation(args);
398
- case "security-scan":
399
- return await this.securityScan(args);
400
- default:
401
- throw new Error(`Unknown tool: ${name}`);
402
- }
403
- } catch (error) {
404
- frameworkLogger.log("mcps/enforcer", "tool", "error", { tool: name, error: String(error) });
405
- throw error;
406
- }
407
- });
353
+ },
354
+ },
355
+ ];
356
+ this.handlers = {
357
+ "rule-validation": async (args) => this.ruleValidation(args),
358
+ "codex-enforcement": async (args) => this.codexEnforcement(args),
359
+ "context-analysis-validation": async (args) => this.contextAnalysisValidation(args),
360
+ "quality-gate-check": async (args) => this.qualityGateCheck(args),
361
+ "get-enforcement-status": async (args) => this.getEnforcementStatus(args),
362
+ "run-pre-commit-validation": async (args) => this.runPreCommitValidation(args),
363
+ "security-scan": async (args) => this.securityScan(args),
364
+ };
365
+ this.setupToolHandlers();
408
366
  }
409
367
 
410
368
  // Tool implementations - wrappers around the original enforcer-tools functions
@@ -1006,68 +964,12 @@ class XrayEnforcerToolsServer {
1006
964
  };
1007
965
  }
1008
966
 
1009
- async run(): Promise<void> {
1010
- const transport = new StdioServerTransport();
1011
- await this.server.connect(transport);
1012
- // Server started - no startup logging to console
1013
-
1014
- const cleanup = async (signal: string) => {
1015
- // Set a timeout to force exit if graceful shutdown fails
1016
- const timeout = setTimeout(() => {
1017
- frameworkLogger.log("mcps/enforcer", "shutdown", "error", { message: "Graceful shutdown timeout, forcing exit..." });
1018
- process.exit(1);
1019
- }, 5000); // 5 second timeout
1020
-
1021
- try {
1022
- if (this.server && typeof this.server.close === "function") {
1023
- await this.server.close();
1024
- }
1025
- clearTimeout(timeout);
1026
- process.exit(0);
1027
- } catch (error) {
1028
- clearTimeout(timeout);
1029
- frameworkLogger.log("mcps/enforcer", "shutdown", "error", { message: `Error during server shutdown: ${String(error)}` });
1030
- process.exit(1);
1031
- }
1032
- };
1033
-
1034
- // Handle multiple shutdown signals
1035
- process.on("SIGINT", () => cleanup("SIGINT"));
1036
- process.on("SIGTERM", () => cleanup("SIGTERM"));
1037
- process.on("SIGHUP", () => cleanup("SIGHUP"));
1038
-
1039
- // Monitor parent process (opencode) and shutdown if it dies
1040
- const checkParent = () => {
1041
- try {
1042
- process.kill(process.ppid, 0); // Check if parent is alive
1043
- setTimeout(checkParent, 1000); // Check again in 1 second
1044
- } catch (error) {
1045
- // Parent process died, shut down gracefully - no logging
1046
- cleanup("parent-process-death");
1047
- }
1048
- };
1049
-
1050
- // Start monitoring parent process
1051
- setTimeout(checkParent, 2000); // Start checking after 2 seconds
1052
-
1053
- // Handle uncaught exceptions and unhandled rejections
1054
- process.on("uncaughtException", (error) => {
1055
- frameworkLogger.log("mcps/enforcer", "uncaughtException", "error", { error: String(error) });
1056
- cleanup("uncaughtException");
1057
- });
1058
-
1059
- process.on("unhandledRejection", (reason, promise) => {
1060
- frameworkLogger.log("mcps/enforcer", "unhandledRejection", "error", { error: String(reason) });
1061
- cleanup("unhandledRejection");
1062
- });
1063
- }
1064
-
1065
967
  private async securityScan(args: unknown) {
1066
968
  const { includePromptValidation, promptText } = args as unknown as SecurityScanArgs;
1067
969
  const results: SecurityScanResults = { tools: {} as SecurityReport["tools"], summary: {} as SecurityReport["summary"] };
1068
970
 
1069
971
  try {
1070
- const { securityScanner } = await import("../security/security-scanner.js");
972
+ const { securityScanner } = await import("./shared/security-scanner.js");
1071
973
  const scanResult = await securityScanner.runSecurityScan();
1072
974
  results.tools = scanResult.tools;
1073
975
  results.summary = scanResult.summary;
@@ -1080,7 +982,7 @@ class XrayEnforcerToolsServer {
1080
982
 
1081
983
  if (includePromptValidation && promptText) {
1082
984
  try {
1083
- const { promptSecurityValidator } = await import("../security/prompt-security-validator.js");
985
+ const { promptSecurityValidator } = await import("./shared/prompt-security-validator.js");
1084
986
  const validation = promptSecurityValidator.validatePrompt(promptText);
1085
987
  results.promptValidation = {
1086
988
  isSafe: validation.isSafe,
@@ -1100,7 +1002,7 @@ class XrayEnforcerToolsServer {
1100
1002
 
1101
1003
  if (import.meta.url === `file://${process.argv[1]}`) {
1102
1004
  const server = new XrayEnforcerToolsServer();
1103
- server.run().catch((error) => frameworkLogger.log("mcps/enforcer", "run", "error", { error: String(error) }));
1005
+ server.run("enforcer").catch((error) => frameworkLogger.log("mcps/enforcer", "run", "error", { error: String(error) }));
1104
1006
  }
1105
1007
 
1106
1008
  export default XrayEnforcerToolsServer;