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
@@ -4,265 +4,232 @@
4
4
  * Converts enforcer-tools.ts functions into MCP server tools
5
5
  * Provides rule enforcement and validation capabilities via MCP protocol
6
6
  */
7
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
8
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
- import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
10
7
  import * as fs from "fs";
11
8
  import { frameworkLogger } from "../core/framework-logger.js";
12
9
  import { getCodexPolicyService } from "../governance/codex-policy.service.js";
13
10
  // Import actual enforcer-tools functions
14
11
  import { ruleValidation as runRuleValidation } from "../enforcement/enforcer-tools.js";
15
- class XrayEnforcerToolsServer {
16
- server;
12
+ import { XrayKnowledgeSkillBase } from "./shared/knowledge-skill-base.js";
13
+ class XrayEnforcerToolsServer extends XrayKnowledgeSkillBase {
17
14
  constructor() {
18
- this.server = new Server({
19
- name: "enforcer", version: "2.0.1",
20
- }, {
21
- capabilities: {
22
- tools: {},
23
- },
24
- });
25
- this.setupToolHandlers();
26
- }
27
- setupToolHandlers() {
28
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
29
- return {
30
- tools: [
31
- {
32
- name: "rule-validation",
33
- description: "Validate operations against the comprehensive rule hierarchy including duplicate code prevention, test requirements, and architectural constraints",
34
- inputSchema: {
15
+ super("enforcer", "2.0.1");
16
+ this.tools = [
17
+ {
18
+ name: "rule-validation",
19
+ description: "Validate operations against the comprehensive rule hierarchy including duplicate code prevention, test requirements, and architectural constraints",
20
+ inputSchema: {
21
+ type: "object",
22
+ properties: {
23
+ operation: {
24
+ type: "string",
25
+ description: "Operation to validate (create, modify, refactor, etc.)",
26
+ },
27
+ files: {
28
+ type: "array",
29
+ items: { type: "string" },
30
+ description: "Files affected by the operation",
31
+ },
32
+ newCode: {
33
+ type: "string",
34
+ description: "New code being added (optional)",
35
+ },
36
+ existingCode: {
35
37
  type: "object",
36
- properties: {
37
- operation: {
38
- type: "string",
39
- description: "Operation to validate (create, modify, refactor, etc.)",
40
- },
41
- files: {
42
- type: "array",
43
- items: { type: "string" },
44
- description: "Files affected by the operation",
45
- },
46
- newCode: {
47
- type: "string",
48
- description: "New code being added (optional)",
49
- },
50
- existingCode: {
51
- type: "object",
52
- description: "Map of existing code for comparison (optional)",
53
- },
54
- dependencies: {
55
- type: "array",
56
- items: { type: "string" },
57
- description: "Dependencies being declared (optional)",
58
- },
59
- tests: {
60
- type: "array",
61
- items: { type: "string" },
62
- description: "Test files for validation (optional)",
63
- },
64
- },
65
- required: ["operation"],
38
+ description: "Map of existing code for comparison (optional)",
39
+ },
40
+ dependencies: {
41
+ type: "array",
42
+ items: { type: "string" },
43
+ description: "Dependencies being declared (optional)",
44
+ },
45
+ tests: {
46
+ type: "array",
47
+ items: { type: "string" },
48
+ description: "Test files for validation (optional)",
66
49
  },
67
50
  },
68
- {
69
- name: "codex-enforcement",
70
- description: "Enforce all Universal Development Codex terms with comprehensive compliance validation and actionable remediation",
71
- inputSchema: {
72
- type: "object",
73
- properties: {
74
- operation: {
75
- type: "string",
76
- description: "Operation to validate against codex",
77
- },
78
- files: {
79
- type: "array",
80
- items: { type: "string" },
81
- description: "Files to check for codex compliance",
82
- },
83
- newCode: {
84
- type: "string",
85
- description: "New code to validate against codex terms",
86
- },
87
- focusAreas: {
88
- type: "array",
89
- items: {
90
- type: "string",
91
- enum: [
92
- "error-handling",
93
- "type-safety",
94
- "performance",
95
- "security",
96
- "architecture",
97
- ],
98
- },
99
- description: "Specific codex areas to focus validation on",
100
- },
51
+ required: ["operation"],
52
+ },
53
+ },
54
+ {
55
+ name: "codex-enforcement",
56
+ description: "Enforce all Universal Development Codex terms with comprehensive compliance validation and actionable remediation",
57
+ inputSchema: {
58
+ type: "object",
59
+ properties: {
60
+ operation: {
61
+ type: "string",
62
+ description: "Operation to validate against codex",
63
+ },
64
+ files: {
65
+ type: "array",
66
+ items: { type: "string" },
67
+ description: "Files to check for codex compliance",
68
+ },
69
+ newCode: {
70
+ type: "string",
71
+ description: "New code to validate against codex terms",
72
+ },
73
+ focusAreas: {
74
+ type: "array",
75
+ items: {
76
+ type: "string",
77
+ enum: [
78
+ "error-handling",
79
+ "type-safety",
80
+ "performance",
81
+ "security",
82
+ "architecture",
83
+ ],
101
84
  },
102
- required: ["operation"],
85
+ description: "Specific codex areas to focus validation on",
103
86
  },
104
87
  },
105
- {
106
- name: "context-analysis-validation",
107
- description: "Validate proper integration of contextual analysis components and architectural patterns",
108
- inputSchema: {
109
- type: "object",
110
- properties: {
111
- files: {
112
- type: "array",
113
- items: { type: "string" },
114
- description: "Files to validate for context integration",
115
- },
116
- operation: {
117
- type: "string",
118
- description: "Operation context for validation",
119
- },
120
- checkPatterns: {
121
- type: "array",
122
- items: {
123
- type: "string",
124
- enum: [
125
- "memory-optimization",
126
- "error-handling",
127
- "type-safety",
128
- "dependency-injection",
129
- ],
130
- },
131
- description: "Specific integration patterns to validate",
132
- },
88
+ required: ["operation"],
89
+ },
90
+ },
91
+ {
92
+ name: "context-analysis-validation",
93
+ description: "Validate proper integration of contextual analysis components and architectural patterns",
94
+ inputSchema: {
95
+ type: "object",
96
+ properties: {
97
+ files: {
98
+ type: "array",
99
+ items: { type: "string" },
100
+ description: "Files to validate for context integration",
101
+ },
102
+ operation: {
103
+ type: "string",
104
+ description: "Operation context for validation",
105
+ },
106
+ checkPatterns: {
107
+ type: "array",
108
+ items: {
109
+ type: "string",
110
+ enum: [
111
+ "memory-optimization",
112
+ "error-handling",
113
+ "type-safety",
114
+ "dependency-injection",
115
+ ],
133
116
  },
134
- required: ["files", "operation"],
117
+ description: "Specific integration patterns to validate",
135
118
  },
136
119
  },
137
- {
138
- name: "quality-gate-check",
139
- description: "Perform comprehensive quality gate validation before commits with automated fixes and blocking decisions",
140
- inputSchema: {
120
+ required: ["files", "operation"],
121
+ },
122
+ },
123
+ {
124
+ name: "quality-gate-check",
125
+ description: "Perform comprehensive quality gate validation before commits with automated fixes and blocking decisions",
126
+ inputSchema: {
127
+ type: "object",
128
+ properties: {
129
+ operation: {
130
+ type: "string",
131
+ description: "Operation to quality-gate check",
132
+ },
133
+ context: {
141
134
  type: "object",
142
135
  properties: {
143
- operation: {
144
- type: "string",
145
- description: "Operation to quality-gate check",
146
- },
147
- context: {
148
- type: "object",
149
- properties: {
150
- files: { type: "array", items: { type: "string" } },
151
- newCode: { type: "string" },
152
- dependencies: { type: "array", items: { type: "string" } },
153
- tests: { type: "array", items: { type: "string" } },
154
- },
155
- description: "Complete operation context for comprehensive validation",
156
- },
157
- strictMode: {
158
- type: "boolean",
159
- default: true,
160
- description: "Enforce strict quality requirements",
161
- },
136
+ files: { type: "array", items: { type: "string" } },
137
+ newCode: { type: "string" },
138
+ dependencies: { type: "array", items: { type: "string" } },
139
+ tests: { type: "array", items: { type: "string" } },
162
140
  },
163
- required: ["operation", "context"],
141
+ description: "Complete operation context for comprehensive validation",
142
+ },
143
+ strictMode: {
144
+ type: "boolean",
145
+ default: true,
146
+ description: "Enforce strict quality requirements",
164
147
  },
165
148
  },
166
- {
167
- name: "get-enforcement-status",
168
- description: "Get comprehensive enforcement statistics and rule compliance metrics",
169
- inputSchema: {
170
- type: "object",
171
- properties: {
172
- includeHistory: {
173
- type: "boolean",
174
- default: false,
175
- description: "Include historical enforcement data",
176
- },
177
- focusAreas: {
178
- type: "array",
179
- items: {
180
- type: "string",
181
- enum: ["rules", "codex", "quality", "performance"],
182
- },
183
- description: "Specific areas to focus status reporting on",
184
- },
149
+ required: ["operation", "context"],
150
+ },
151
+ },
152
+ {
153
+ name: "get-enforcement-status",
154
+ description: "Get comprehensive enforcement statistics and rule compliance metrics",
155
+ inputSchema: {
156
+ type: "object",
157
+ properties: {
158
+ includeHistory: {
159
+ type: "boolean",
160
+ default: false,
161
+ description: "Include historical enforcement data",
162
+ },
163
+ focusAreas: {
164
+ type: "array",
165
+ items: {
166
+ type: "string",
167
+ enum: ["rules", "codex", "quality", "performance"],
185
168
  },
169
+ description: "Specific areas to focus status reporting on",
186
170
  },
187
171
  },
188
- {
189
- name: "run-pre-commit-validation",
190
- description: "Execute comprehensive pre-commit validation with all enforcer tools and automated remediation",
191
- inputSchema: {
192
- type: "object",
193
- properties: {
194
- files: {
195
- type: "array",
196
- items: { type: "string" },
197
- description: "Files to validate before commit",
198
- },
199
- operation: {
200
- type: "string",
201
- default: "commit",
202
- description: "Operation type for validation context",
203
- },
204
- autoFix: {
205
- type: "boolean",
206
- default: true,
207
- description: "Automatically apply safe fixes",
208
- },
209
- strictBlocking: {
210
- type: "boolean",
211
- default: true,
212
- description: "Block commit on any validation error",
213
- },
214
- },
215
- required: ["files"],
172
+ },
173
+ },
174
+ {
175
+ name: "run-pre-commit-validation",
176
+ description: "Execute comprehensive pre-commit validation with all enforcer tools and automated remediation",
177
+ inputSchema: {
178
+ type: "object",
179
+ properties: {
180
+ files: {
181
+ type: "array",
182
+ items: { type: "string" },
183
+ description: "Files to validate before commit",
184
+ },
185
+ operation: {
186
+ type: "string",
187
+ default: "commit",
188
+ description: "Operation type for validation context",
189
+ },
190
+ autoFix: {
191
+ type: "boolean",
192
+ default: true,
193
+ description: "Automatically apply safe fixes",
194
+ },
195
+ strictBlocking: {
196
+ type: "boolean",
197
+ default: true,
198
+ description: "Block commit on any validation error",
216
199
  },
217
200
  },
218
- {
219
- name: "security-scan",
220
- description: "Run security scan using npm audit, Trivy, ESLint security, and OWASP dependency check",
221
- inputSchema: {
222
- type: "object",
223
- properties: {
224
- includePromptValidation: {
225
- type: "boolean",
226
- default: false,
227
- description: "Also validate prompts for injection attacks",
228
- },
229
- promptText: {
230
- type: "string",
231
- description: "Prompt text to validate for injection attacks",
232
- },
233
- },
201
+ required: ["files"],
202
+ },
203
+ },
204
+ {
205
+ name: "security-scan",
206
+ description: "Run security scan using npm audit, Trivy, ESLint security, and OWASP dependency check",
207
+ inputSchema: {
208
+ type: "object",
209
+ properties: {
210
+ includePromptValidation: {
211
+ type: "boolean",
212
+ default: false,
213
+ description: "Also validate prompts for injection attacks",
214
+ },
215
+ promptText: {
216
+ type: "string",
217
+ description: "Prompt text to validate for injection attacks",
234
218
  },
235
219
  },
236
- ],
237
- };
238
- });
239
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
240
- const { name, arguments: args } = request.params;
241
- try {
242
- switch (name) {
243
- case "rule-validation":
244
- return await this.ruleValidation(args);
245
- case "codex-enforcement":
246
- return await this.codexEnforcement(args);
247
- case "context-analysis-validation":
248
- return await this.contextAnalysisValidation(args);
249
- case "quality-gate-check":
250
- return await this.qualityGateCheck(args);
251
- case "get-enforcement-status":
252
- return await this.getEnforcementStatus(args);
253
- case "run-pre-commit-validation":
254
- return await this.runPreCommitValidation(args);
255
- case "security-scan":
256
- return await this.securityScan(args);
257
- default:
258
- throw new Error(`Unknown tool: ${name}`);
259
- }
260
- }
261
- catch (error) {
262
- frameworkLogger.log("mcps/enforcer", "tool", "error", { tool: name, error: String(error) });
263
- throw error;
264
- }
265
- });
220
+ },
221
+ },
222
+ ];
223
+ this.handlers = {
224
+ "rule-validation": async (args) => this.ruleValidation(args),
225
+ "codex-enforcement": async (args) => this.codexEnforcement(args),
226
+ "context-analysis-validation": async (args) => this.contextAnalysisValidation(args),
227
+ "quality-gate-check": async (args) => this.qualityGateCheck(args),
228
+ "get-enforcement-status": async (args) => this.getEnforcementStatus(args),
229
+ "run-pre-commit-validation": async (args) => this.runPreCommitValidation(args),
230
+ "security-scan": async (args) => this.securityScan(args),
231
+ };
232
+ this.setupToolHandlers();
266
233
  }
267
234
  // Tool implementations - wrappers around the original enforcer-tools functions
268
235
  async ruleValidation(args) {
@@ -687,61 +654,11 @@ class XrayEnforcerToolsServer {
687
654
  filesProcessed: files.length,
688
655
  };
689
656
  }
690
- async run() {
691
- const transport = new StdioServerTransport();
692
- await this.server.connect(transport);
693
- // Server started - no startup logging to console
694
- const cleanup = async (signal) => {
695
- // Set a timeout to force exit if graceful shutdown fails
696
- const timeout = setTimeout(() => {
697
- frameworkLogger.log("mcps/enforcer", "shutdown", "error", { message: "Graceful shutdown timeout, forcing exit..." });
698
- process.exit(1);
699
- }, 5000); // 5 second timeout
700
- try {
701
- if (this.server && typeof this.server.close === "function") {
702
- await this.server.close();
703
- }
704
- clearTimeout(timeout);
705
- process.exit(0);
706
- }
707
- catch (error) {
708
- clearTimeout(timeout);
709
- frameworkLogger.log("mcps/enforcer", "shutdown", "error", { message: `Error during server shutdown: ${String(error)}` });
710
- process.exit(1);
711
- }
712
- };
713
- // Handle multiple shutdown signals
714
- process.on("SIGINT", () => cleanup("SIGINT"));
715
- process.on("SIGTERM", () => cleanup("SIGTERM"));
716
- process.on("SIGHUP", () => cleanup("SIGHUP"));
717
- // Monitor parent process (opencode) and shutdown if it dies
718
- const checkParent = () => {
719
- try {
720
- process.kill(process.ppid, 0); // Check if parent is alive
721
- setTimeout(checkParent, 1000); // Check again in 1 second
722
- }
723
- catch (error) {
724
- // Parent process died, shut down gracefully - no logging
725
- cleanup("parent-process-death");
726
- }
727
- };
728
- // Start monitoring parent process
729
- setTimeout(checkParent, 2000); // Start checking after 2 seconds
730
- // Handle uncaught exceptions and unhandled rejections
731
- process.on("uncaughtException", (error) => {
732
- frameworkLogger.log("mcps/enforcer", "uncaughtException", "error", { error: String(error) });
733
- cleanup("uncaughtException");
734
- });
735
- process.on("unhandledRejection", (reason, promise) => {
736
- frameworkLogger.log("mcps/enforcer", "unhandledRejection", "error", { error: String(reason) });
737
- cleanup("unhandledRejection");
738
- });
739
- }
740
657
  async securityScan(args) {
741
658
  const { includePromptValidation, promptText } = args;
742
659
  const results = { tools: {}, summary: {} };
743
660
  try {
744
- const { securityScanner } = await import("../security/security-scanner.js");
661
+ const { securityScanner } = await import("./shared/security-scanner.js");
745
662
  const scanResult = await securityScanner.runSecurityScan();
746
663
  results.tools = scanResult.tools;
747
664
  results.summary = scanResult.summary;
@@ -754,7 +671,7 @@ class XrayEnforcerToolsServer {
754
671
  }
755
672
  if (includePromptValidation && promptText) {
756
673
  try {
757
- const { promptSecurityValidator } = await import("../security/prompt-security-validator.js");
674
+ const { promptSecurityValidator } = await import("./shared/prompt-security-validator.js");
758
675
  const validation = promptSecurityValidator.validatePrompt(promptText);
759
676
  results.promptValidation = {
760
677
  isSafe: validation.isSafe,
@@ -773,6 +690,6 @@ class XrayEnforcerToolsServer {
773
690
  }
774
691
  if (import.meta.url === `file://${process.argv[1]}`) {
775
692
  const server = new XrayEnforcerToolsServer();
776
- server.run().catch((error) => frameworkLogger.log("mcps/enforcer", "run", "error", { error: String(error) }));
693
+ server.run("enforcer").catch((error) => frameworkLogger.log("mcps/enforcer", "run", "error", { error: String(error) }));
777
694
  }
778
695
  export default XrayEnforcerToolsServer;
@@ -3,19 +3,17 @@
3
3
  *
4
4
  * Provides tools for tracking and validating estimates
5
5
  */
6
+ import { XrayKnowledgeSkillBase } from "./shared/knowledge-skill-base.js";
6
7
  /**
7
8
  * Estimation MCP Server
8
9
  * Tracks estimates vs actuals and provides calibrated predictions
9
10
  */
10
- declare class EstimationServer {
11
- private server;
11
+ declare class EstimationServer extends XrayKnowledgeSkillBase {
12
12
  private validator;
13
13
  constructor();
14
- private setupToolHandlers;
15
14
  private handleValidateEstimate;
16
15
  private handleStartTracking;
17
16
  private handleCompleteTracking;
18
17
  private handleGetReport;
19
- start(): Promise<void>;
20
18
  }
21
19
  export { EstimationServer };