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,13 +5,7 @@
5
5
  * and pattern recognition - provides deep project intelligence
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
- type CallToolResult,
14
- } from "@modelcontextprotocol/sdk/types.js";
8
+ import { XrayKnowledgeSkillBase } from "../shared/knowledge-skill-base.js";
15
9
  import * as fs from "fs";
16
10
  import * as path from "path";
17
11
  import { frameworkLogger } from "../../core/framework-logger.js";
@@ -136,193 +130,86 @@ interface McpToolResponse {
136
130
  content: Array<{ type: "text"; text: string }>;
137
131
  }
138
132
 
139
- class ProjectAnalysisServer {
140
- private server: Server;
133
+ class ProjectAnalysisServer extends XrayKnowledgeSkillBase {
141
134
 
142
135
  constructor() {
143
- this.server = new Server(
136
+ super("project-analysis", "2.0.1");
137
+ this.tools = [
144
138
  {
145
- name: "project-analysis", version: "2.0.1",
139
+ name: "analyze-project-structure",
140
+ description: "Analyze complete project structure including file organization, directory hierarchy, and module distribution",
141
+ inputSchema: {
142
+ type: "object",
143
+ properties: {
144
+ projectRoot: { type: "string", description: "Root directory of the project to analyze" },
145
+ includeMetrics: { type: "boolean", default: true, description: "Include detailed metrics in analysis" },
146
+ maxDepth: { type: "number", default: 10, description: "Maximum directory depth to analyze" },
147
+ },
148
+ required: ["projectRoot"],
149
+ },
146
150
  },
147
151
  {
148
- capabilities: {
149
- tools: {},
152
+ name: "assess-project-complexity",
153
+ description: "Assess overall project complexity including code metrics, maintainability, and technical debt indicators",
154
+ inputSchema: {
155
+ type: "object",
156
+ properties: {
157
+ projectRoot: { type: "string", description: "Root directory of the project" },
158
+ includeBreakdown: { type: "boolean", default: true, description: "Include per-file complexity breakdown" },
159
+ focusAreas: { type: "array", items: { type: "string", enum: ["functions", "classes", "imports", "dependencies"] }, description: "Specific areas to focus complexity analysis on" },
160
+ },
161
+ required: ["projectRoot"],
150
162
  },
151
163
  },
152
- );
153
-
154
- this.setupToolHandlers();
155
- // Server initialization - removed unnecessary startup logging
156
- }
157
-
158
- private setupToolHandlers() {
159
- // List available tools
160
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
161
- return {
162
- tools: [
163
- {
164
- name: "analyze-project-structure",
165
- description:
166
- "Analyze complete project structure including file organization, directory hierarchy, and module distribution",
167
- inputSchema: {
168
- type: "object",
169
- properties: {
170
- projectRoot: {
171
- type: "string",
172
- description: "Root directory of the project to analyze",
173
- },
174
- includeMetrics: {
175
- type: "boolean",
176
- default: true,
177
- description: "Include detailed metrics in analysis",
178
- },
179
- maxDepth: {
180
- type: "number",
181
- default: 10,
182
- description: "Maximum directory depth to analyze",
183
- },
184
- },
185
- required: ["projectRoot"],
186
- },
187
- },
188
- {
189
- name: "assess-project-complexity",
190
- description:
191
- "Assess overall project complexity including code metrics, maintainability, and technical debt indicators",
192
- inputSchema: {
193
- type: "object",
194
- properties: {
195
- projectRoot: {
196
- type: "string",
197
- description: "Root directory of the project",
198
- },
199
- includeBreakdown: {
200
- type: "boolean",
201
- default: true,
202
- description: "Include per-file complexity breakdown",
203
- },
204
- focusAreas: {
205
- type: "array",
206
- items: {
207
- type: "string",
208
- enum: ["functions", "classes", "imports", "dependencies"],
209
- },
210
- description: "Specific areas to focus complexity analysis on",
211
- },
212
- },
213
- required: ["projectRoot"],
214
- },
215
- },
216
- {
217
- name: "identify-project-patterns",
218
- description:
219
- "Identify architectural patterns, code patterns, and structural patterns in the project",
220
- inputSchema: {
221
- type: "object",
222
- properties: {
223
- projectRoot: {
224
- type: "string",
225
- description: "Root directory of the project",
226
- },
227
- patternTypes: {
228
- type: "array",
229
- items: {
230
- type: "string",
231
- enum: [
232
- "architectural",
233
- "code",
234
- "structural",
235
- "anti-patterns",
236
- ],
237
- },
238
- description: "Types of patterns to identify",
239
- },
240
- confidenceThreshold: {
241
- type: "number",
242
- default: 0.7,
243
- description: "Minimum confidence for pattern detection",
244
- },
245
- },
246
- required: ["projectRoot"],
247
- },
164
+ {
165
+ name: "identify-project-patterns",
166
+ description: "Identify architectural patterns, code patterns, and structural patterns in the project",
167
+ inputSchema: {
168
+ type: "object",
169
+ properties: {
170
+ projectRoot: { type: "string", description: "Root directory of the project" },
171
+ patternTypes: { type: "array", items: { type: "string", enum: ["architectural", "code", "structural", "anti-patterns"] }, description: "Types of patterns to identify" },
172
+ confidenceThreshold: { type: "number", default: 0.7, description: "Minimum confidence for pattern detection" },
248
173
  },
249
- {
250
- name: "analyze-project-health",
251
- description:
252
- "Provide comprehensive project health assessment including quality metrics and improvement recommendations",
253
- inputSchema: {
254
- type: "object",
255
- properties: {
256
- projectRoot: {
257
- type: "string",
258
- description: "Root directory of the project",
259
- },
260
- includeTrends: {
261
- type: "boolean",
262
- default: false,
263
- description: "Include historical trend analysis",
264
- },
265
- focusMetrics: {
266
- type: "array",
267
- items: {
268
- type: "string",
269
- enum: [
270
- "complexity",
271
- "coverage",
272
- "maintainability",
273
- "dependencies",
274
- "patterns",
275
- ],
276
- },
277
- description: "Specific health metrics to focus on",
278
- },
279
- },
280
- required: ["projectRoot"],
281
- },
174
+ required: ["projectRoot"],
175
+ },
176
+ },
177
+ {
178
+ name: "analyze-project-health",
179
+ description: "Provide comprehensive project health assessment including quality metrics and improvement recommendations",
180
+ inputSchema: {
181
+ type: "object",
182
+ properties: {
183
+ projectRoot: { type: "string", description: "Root directory of the project" },
184
+ includeTrends: { type: "boolean", default: false, description: "Include historical trend analysis" },
185
+ focusMetrics: { type: "array", items: { type: "string", enum: ["complexity", "coverage", "maintainability", "dependencies", "patterns"] }, description: "Specific health metrics to focus on" },
282
186
  },
283
- {
284
- name: "analyze_proposal",
285
- description:
286
- "Analyze an inference proposal from a research / codebase pattern perspective and return a structured governance decision",
287
- inputSchema: {
288
- type: "object",
289
- properties: {
290
- proposalTitle: { type: "string" },
291
- proposalDescription: { type: "string" },
292
- evidence: { type: "array", items: { type: "string" } },
293
- proposalType: { type: "string" },
294
- },
295
- required: ["proposalTitle", "proposalDescription"],
296
- },
187
+ required: ["projectRoot"],
188
+ },
189
+ },
190
+ {
191
+ name: "analyze_proposal",
192
+ description: "Analyze an inference proposal from a research / codebase pattern perspective and return a structured governance decision",
193
+ inputSchema: {
194
+ type: "object",
195
+ properties: {
196
+ proposalTitle: { type: "string" },
197
+ proposalDescription: { type: "string" },
198
+ evidence: { type: "array", items: { type: "string" } },
199
+ proposalType: { type: "string" },
297
200
  },
298
- ],
299
- };
300
- });
301
-
302
- // Handle tool calls
303
- this.server.setRequestHandler(CallToolRequestSchema, async (request): Promise<CallToolResult> => {
304
- const { name, arguments: args } = request.params;
305
-
306
- try {
307
- switch (name) {
308
- case "analyze-project-structure":
309
- return await this.analyzeProjectStructure(args as unknown as AnalyzeProjectStructureArgs) as CallToolResult;
310
- case "assess-project-complexity":
311
- return await this.assessProjectComplexity(args as unknown as AssessProjectComplexityArgs) as CallToolResult;
312
- case "identify-project-patterns":
313
- return await this.identifyProjectPatterns(args as unknown as IdentifyProjectPatternsArgs) as CallToolResult;
314
- case "analyze-project-health":
315
- return await this.analyzeProjectHealth(args as unknown as AnalyzeProjectHealthArgs) as CallToolResult;
316
- case "analyze_proposal":
317
- return await this.analyzeProposal(args as any) as CallToolResult;
318
- default:
319
- throw new Error(`Unknown tool: ${name}`);
320
- }
321
- } catch (error) {
322
- frameworkLogger.log("mcps/project-analysis", "tool", "error", { tool: name, error: String(error) });
323
- throw error;
324
- }
325
- });
201
+ required: ["proposalTitle", "proposalDescription"],
202
+ },
203
+ },
204
+ ];
205
+ this.handlers = {
206
+ "analyze-project-structure": async (args) => this.analyzeProjectStructure(args as unknown as AnalyzeProjectStructureArgs),
207
+ "assess-project-complexity": async (args) => this.assessProjectComplexity(args as unknown as AssessProjectComplexityArgs),
208
+ "identify-project-patterns": async (args) => this.identifyProjectPatterns(args as unknown as IdentifyProjectPatternsArgs),
209
+ "analyze-project-health": async (args) => this.analyzeProjectHealth(args as unknown as AnalyzeProjectHealthArgs),
210
+ "analyze_proposal": async (args) => this.analyzeProposal(args),
211
+ };
212
+ this.setupToolHandlers();
326
213
  }
327
214
 
328
215
  private async analyzeProjectStructure(args: AnalyzeProjectStructureArgs): Promise<McpToolResponse> {
@@ -1037,75 +924,12 @@ class ProjectAnalysisServer {
1037
924
  };
1038
925
  }
1039
926
 
1040
- async run(): Promise<void> {
1041
- const transport = new StdioServerTransport();
1042
- await this.server.connect(transport);
1043
- await frameworkLogger.log(
1044
- "mcp-project-analysis",
1045
- "server-started",
1046
- "success",
1047
- );
1048
-
1049
- const cleanup = async (signal: string) => {
1050
- frameworkLogger.log("mcps/project-analysis", "shutdown", "info", { signal });
1051
-
1052
- // Set a timeout to force exit if graceful shutdown fails
1053
- const timeout = setTimeout(() => {
1054
- frameworkLogger.log("mcps/project-analysis", "shutdown", "error", { message: "Graceful shutdown timeout, forcing exit..." });
1055
- process.exit(1);
1056
- }, 5000); // 5 second timeout
1057
-
1058
- try {
1059
- if (this.server && typeof this.server.close === "function") {
1060
- await this.server.close();
1061
- }
1062
- clearTimeout(timeout);
1063
- frameworkLogger.log("mcps/project-analysis", "shutdown", "success");
1064
- process.exit(0);
1065
- } catch (error) {
1066
- clearTimeout(timeout);
1067
- frameworkLogger.log("mcps/project-analysis", "shutdown", "error", { message: `Error during server shutdown: ${String(error)}` });
1068
- process.exit(1);
1069
- }
1070
- };
1071
-
1072
- // Handle multiple shutdown signals
1073
- process.on("SIGINT", () => cleanup("SIGINT"));
1074
- process.on("SIGTERM", () => cleanup("SIGTERM"));
1075
- process.on("SIGHUP", () => cleanup("SIGHUP"));
1076
-
1077
- // Monitor parent process (opencode) and shutdown if it dies
1078
- const checkParent = () => {
1079
- try {
1080
- process.kill(process.ppid, 0); // Check if parent is alive
1081
- setTimeout(checkParent, 1000); // Check again in 1 second
1082
- } catch (error) {
1083
- // Parent process died, shut down gracefully
1084
- frameworkLogger.log("mcps/project-analysis", "parent-death", "info");
1085
- cleanup("parent-process-death");
1086
- }
1087
- };
1088
-
1089
- // Start monitoring parent process
1090
- setTimeout(checkParent, 2000); // Start checking after 2 seconds
1091
-
1092
- // Handle uncaught exceptions and unhandled rejections
1093
- process.on("uncaughtException", (error) => {
1094
- frameworkLogger.log("mcps/project-analysis", "uncaughtException", "error", { error: String(error) });
1095
- cleanup("uncaughtException");
1096
- });
1097
-
1098
- process.on("unhandledRejection", (reason, promise) => {
1099
- frameworkLogger.log("mcps/project-analysis", "unhandledRejection", "error", { error: String(reason) });
1100
- cleanup("unhandledRejection");
1101
- });
1102
- }
1103
927
  }
1104
928
 
1105
929
  // Start the server if run directly
1106
930
  if (import.meta.url === `file://${process.argv[1]}`) {
1107
931
  const server = new ProjectAnalysisServer();
1108
- server.run().catch((error: unknown) => frameworkLogger.log("mcps/project-analysis", "run", "error", { error: String(error) }));
932
+ server.run("project-analysis").catch((error: unknown) => frameworkLogger.log("mcps/project-analysis", "run", "error", { error: String(error) }));
1109
933
  }
1110
934
 
1111
935
  export default ProjectAnalysisServer;
@@ -5,15 +5,8 @@
5
5
  * modernization, and code improvement patterns
6
6
  */
7
7
 
8
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
+ import { XrayKnowledgeSkillBase } from "../shared/knowledge-skill-base.js";
10
9
  import { frameworkLogger } from "../../core/framework-logger.js";
11
- import { createGracefulShutdown } from "../../utils/shutdown-handler.js";
12
- import {
13
- CallToolRequestSchema,
14
- ListToolsRequestSchema,
15
- type CallToolResult,
16
- } from "@modelcontextprotocol/sdk/types.js";
17
10
 
18
11
  interface RefactoringOpportunity {
19
12
  type:
@@ -154,167 +147,72 @@ interface RollbackPlan {
154
147
  emergencyProcedures: string[];
155
148
  }
156
149
 
157
- class XrayRefactoringStrategiesServer {
158
- private server: Server;
150
+ class XrayRefactoringStrategiesServer extends XrayKnowledgeSkillBase {
159
151
 
160
152
  constructor() {
161
- this.server = new Server(
153
+ super("refactoring-strategies", "2.0.1");
154
+ this.tools = [
162
155
  {
163
- name: "refactoring-strategies", version: "2.0.1",
156
+ name: "analyze_technical_debt",
157
+ description: "Analyze codebase for technical debt and refactoring opportunities",
158
+ inputSchema: {
159
+ type: "object",
160
+ properties: {
161
+ codePath: { type: "string", description: "Path to code directory to analyze" },
162
+ includeModernization: { type: "boolean", description: "Include technology modernization suggestions", default: true },
163
+ debtThreshold: { type: "number", description: "Minimum debt score to report (0-100)", default: 20 },
164
+ },
165
+ required: ["codePath"],
166
+ },
164
167
  },
165
168
  {
166
- capabilities: {
167
- tools: {},
169
+ name: "suggest_refactoring",
170
+ description: "Suggest specific refactoring opportunities for improved code quality",
171
+ inputSchema: {
172
+ type: "object",
173
+ properties: {
174
+ filePath: { type: "string", description: "Path to specific file to analyze" },
175
+ refactoringTypes: { type: "array", items: { type: "string", enum: ["extract-method", "rename-variable", "remove-duplicate", "simplify-condition", "extract-class", "move-method"] }, description: "Types of refactoring to focus on" },
176
+ maxSuggestions: { type: "number", description: "Maximum number of suggestions to return", default: 10 },
177
+ },
178
+ required: ["filePath"],
168
179
  },
169
180
  },
170
- );
171
-
172
- this.setupToolHandlers();
173
- // Server initialization - removed unnecessary startup logging
174
- }
175
-
176
- private setupToolHandlers() {
177
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
178
- return {
179
- tools: [
180
- {
181
- name: "analyze_technical_debt",
182
- description:
183
- "Analyze codebase for technical debt and refactoring opportunities",
184
- inputSchema: {
185
- type: "object",
186
- properties: {
187
- codePath: {
188
- type: "string",
189
- description: "Path to code directory to analyze",
190
- },
191
- includeModernization: {
192
- type: "boolean",
193
- description: "Include technology modernization suggestions",
194
- default: true,
195
- },
196
- debtThreshold: {
197
- type: "number",
198
- description: "Minimum debt score to report (0-100)",
199
- default: 20,
200
- },
201
- },
202
- required: ["codePath"],
203
- },
204
- },
205
- {
206
- name: "suggest_refactoring",
207
- description:
208
- "Suggest specific refactoring opportunities for improved code quality",
209
- inputSchema: {
210
- type: "object",
211
- properties: {
212
- filePath: {
213
- type: "string",
214
- description: "Path to specific file to analyze",
215
- },
216
- refactoringTypes: {
217
- type: "array",
218
- items: {
219
- type: "string",
220
- enum: [
221
- "extract-method",
222
- "rename-variable",
223
- "remove-duplicate",
224
- "simplify-condition",
225
- "extract-class",
226
- "move-method",
227
- ],
228
- },
229
- description: "Types of refactoring to focus on",
230
- },
231
- maxSuggestions: {
232
- type: "number",
233
- description: "Maximum number of suggestions to return",
234
- default: 10,
235
- },
236
- },
237
- required: ["filePath"],
238
- },
239
- },
240
- {
241
- name: "generate_refactoring_plan",
242
- description:
243
- "Generate a comprehensive refactoring plan with prioritization",
244
- inputSchema: {
245
- type: "object",
246
- properties: {
247
- codePath: {
248
- type: "string",
249
- description: "Path to codebase for refactoring analysis",
250
- },
251
- timeBudget: {
252
- type: "string",
253
- enum: ["1-week", "1-month", "3-months", "6-months"],
254
- description: "Available time for refactoring",
255
- },
256
- riskTolerance: {
257
- type: "string",
258
- enum: ["low", "medium", "high"],
259
- description: "Risk tolerance for changes",
260
- },
261
- priorities: {
262
- type: "array",
263
- items: { type: "string" },
264
- description:
265
- "Specific priorities (performance, maintainability, security)",
266
- default: ["maintainability", "performance"],
267
- },
268
- },
269
- required: ["codePath", "timeBudget"],
270
- },
181
+ {
182
+ name: "generate_refactoring_plan",
183
+ description: "Generate a comprehensive refactoring plan with prioritization",
184
+ inputSchema: {
185
+ type: "object",
186
+ properties: {
187
+ codePath: { type: "string", description: "Path to codebase for refactoring analysis" },
188
+ timeBudget: { type: "string", enum: ["1-week", "1-month", "3-months", "6-months"], description: "Available time for refactoring" },
189
+ riskTolerance: { type: "string", enum: ["low", "medium", "high"], description: "Risk tolerance for changes" },
190
+ priorities: { type: "array", items: { type: "string" }, description: "Specific priorities (performance, maintainability, security)", default: ["maintainability", "performance"] },
271
191
  },
272
- {
273
- name: "modernize_codebase",
274
- description:
275
- "Suggest modernization strategies for outdated code and dependencies",
276
- inputSchema: {
277
- type: "object",
278
- properties: {
279
- codePath: {
280
- type: "string",
281
- description: "Path to codebase to analyze",
282
- },
283
- technologies: {
284
- type: "array",
285
- items: { type: "string" },
286
- description:
287
- "Specific technologies to focus on (node, react, etc.)",
288
- },
289
- safeMode: {
290
- type: "boolean",
291
- description: "Only suggest low-risk modernization options",
292
- default: true,
293
- },
294
- },
295
- required: ["codePath"],
296
- },
192
+ required: ["codePath", "timeBudget"],
193
+ },
194
+ },
195
+ {
196
+ name: "modernize_codebase",
197
+ description: "Suggest modernization strategies for outdated code and dependencies",
198
+ inputSchema: {
199
+ type: "object",
200
+ properties: {
201
+ codePath: { type: "string", description: "Path to codebase to analyze" },
202
+ technologies: { type: "array", items: { type: "string" }, description: "Specific technologies to focus on (node, react, etc.)" },
203
+ safeMode: { type: "boolean", description: "Only suggest low-risk modernization options", default: true },
297
204
  },
298
- ],
299
- };
300
- });
301
-
302
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
303
- const { name, arguments: args } = request.params;
304
-
305
- switch (name) {
306
- case "analyze_technical_debt":
307
- return await this.analyzeTechnicalDebt(args as unknown as AnalyzeTechnicalDebtArgs) as CallToolResult;
308
- case "suggest_refactoring":
309
- return await this.suggestRefactoring(args as unknown as SuggestRefactoringArgs) as CallToolResult;
310
- case "generate_refactoring_plan":
311
- return await this.generateRefactoringPlan(args as unknown as GenerateRefactoringPlanArgs) as CallToolResult;
312
- case "modernize_codebase":
313
- return await this.modernizeCodebase(args as unknown as ModernizeCodebaseArgs) as CallToolResult;
314
- default:
315
- throw new Error(`Unknown tool: ${name}`);
316
- }
317
- });
205
+ required: ["codePath"],
206
+ },
207
+ },
208
+ ];
209
+ this.handlers = {
210
+ "analyze_technical_debt": async (args) => this.analyzeTechnicalDebt(args as unknown as AnalyzeTechnicalDebtArgs),
211
+ "suggest_refactoring": async (args) => this.suggestRefactoring(args as unknown as SuggestRefactoringArgs),
212
+ "generate_refactoring_plan": async (args) => this.generateRefactoringPlan(args as unknown as GenerateRefactoringPlanArgs),
213
+ "modernize_codebase": async (args) => this.modernizeCodebase(args as unknown as ModernizeCodebaseArgs),
214
+ };
215
+ this.setupToolHandlers();
318
216
  }
319
217
 
320
218
  private async analyzeTechnicalDebt(args: AnalyzeTechnicalDebtArgs) {
@@ -1071,22 +969,12 @@ class XrayRefactoringStrategiesServer {
1071
969
  return icons[effort as keyof typeof icons] || "❓";
1072
970
  }
1073
971
 
1074
- async run(): Promise<void> {
1075
- const transport = new StdioServerTransport();
1076
- await this.server.connect(transport);
1077
-
1078
- // Use centralized shutdown handler
1079
- createGracefulShutdown({
1080
- serverName: "refactoring-strategies.server",
1081
- server: this.server,
1082
- });
1083
- }
1084
972
  }
1085
973
 
1086
974
  // Run the server if this file is executed directly
1087
975
  if (import.meta.url === `file://${process.argv[1]}`) {
1088
976
  const server = new XrayRefactoringStrategiesServer();
1089
- server.run().catch(() => {});
977
+ server.run("refactoring-strategies").catch((err) => { frameworkLogger.log("refactoring-strategies", "run", "error", { error: err instanceof Error ? err.message : String(err) }); });
1090
978
  }
1091
979
 
1092
980
  export { XrayRefactoringStrategiesServer };