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,14 +5,8 @@
5
5
  * profiling, benchmarking, memory analysis, and Core Web Vitals measurement
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";
8
+ import { XrayKnowledgeSkillBase } from "../shared/knowledge-skill-base.js";
14
9
  import { frameworkLogger, generateJobId } from "../../core/framework-logger.js";
15
- import { createGracefulShutdown } from "../../utils/shutdown-handler.js";
16
10
  import fs from "fs";
17
11
  import path from "path";
18
12
  import os from "os";
@@ -217,144 +211,101 @@ interface McpToolResponse {
217
211
  data?: Record<string, unknown>;
218
212
  }
219
213
 
220
- class XrayPerformanceOptimizationServer {
221
- private server: Server;
222
- private startTime: number;
223
-
214
+ class XrayPerformanceOptimizationServer extends XrayKnowledgeSkillBase {
224
215
  constructor() {
225
- this.server = new Server(
216
+ super("performance-optimization", "2.0.1");
217
+ this.tools = [
226
218
  {
227
- name: "performance-optimization", version: "2.0.1",
219
+ name: "profile-application",
220
+ description: "Run comprehensive performance profiling on the codebase to identify bottlenecks and hot paths",
221
+ inputSchema: {
222
+ type: "object",
223
+ properties: {
224
+ projectRoot: { type: "string", description: "Path to the project root directory" },
225
+ scope: {
226
+ type: "string",
227
+ enum: ["full", "runtime", "build", "memory"],
228
+ default: "full",
229
+ description: "Scope of profiling analysis"
230
+ },
231
+ duration: { type: "number", default: 30, description: "Profiling duration in seconds" },
232
+ includeHotPaths: { type: "boolean", default: true, description: "Include hot path analysis" }
233
+ },
234
+ required: ["projectRoot"]
235
+ }
228
236
  },
229
237
  {
230
- capabilities: {
231
- tools: {},
232
- },
233
- },
234
- );
235
-
236
- this.startTime = Date.now();
237
- this.setupToolHandlers();
238
- }
239
-
240
- private setupToolHandlers() {
241
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
242
- return {
243
- tools: [
244
- {
245
- name: "profile-application",
246
- description: "Run comprehensive performance profiling on the codebase to identify bottlenecks and hot paths",
247
- inputSchema: {
248
- type: "object",
249
- properties: {
250
- projectRoot: { type: "string", description: "Path to the project root directory" },
251
- scope: {
252
- type: "string",
253
- enum: ["full", "runtime", "build", "memory"],
254
- default: "full",
255
- description: "Scope of profiling analysis"
256
- },
257
- duration: { type: "number", default: 30, description: "Profiling duration in seconds" },
258
- includeHotPaths: { type: "boolean", default: true, description: "Include hot path analysis" }
259
- },
260
- required: ["projectRoot"]
261
- }
238
+ name: "analyze-memory",
239
+ description: "Perform memory leak detection and heap analysis to identify memory issues",
240
+ inputSchema: {
241
+ type: "object",
242
+ properties: {
243
+ projectRoot: { type: "string", description: "Path to the project root directory" },
244
+ heapSnapshot: { type: "boolean", default: true, description: "Generate heap snapshot analysis" },
245
+ gcAnalysis: { type: "boolean", default: true, description: "Analyze garbage collection patterns" },
246
+ leakDetection: { type: "boolean", default: true, description: "Detect potential memory leaks" }
262
247
  },
263
- {
264
- name: "analyze-memory",
265
- description: "Perform memory leak detection and heap analysis to identify memory issues",
266
- inputSchema: {
267
- type: "object",
268
- properties: {
269
- projectRoot: { type: "string", description: "Path to the project root directory" },
270
- heapSnapshot: { type: "boolean", default: true, description: "Generate heap snapshot analysis" },
271
- gcAnalysis: { type: "boolean", default: true, description: "Analyze garbage collection patterns" },
272
- leakDetection: { type: "boolean", default: true, description: "Detect potential memory leaks" }
273
- },
274
- required: ["projectRoot"]
275
- }
248
+ required: ["projectRoot"]
249
+ }
250
+ },
251
+ {
252
+ name: "benchmark-code",
253
+ description: "Execute and compare benchmark results for code performance measurement",
254
+ inputSchema: {
255
+ type: "object",
256
+ properties: {
257
+ projectRoot: { type: "string", description: "Path to the project root directory" },
258
+ testFile: { type: "string", description: "Specific benchmark test file to run" },
259
+ iterations: { type: "number", default: 100, description: "Number of benchmark iterations" },
260
+ warmupRuns: { type: "number", default: 10, description: "Number of warmup runs" },
261
+ compareBaseline: { type: "boolean", default: false, description: "Compare results against baseline" }
276
262
  },
277
- {
278
- name: "benchmark-code",
279
- description: "Execute and compare benchmark results for code performance measurement",
280
- inputSchema: {
281
- type: "object",
282
- properties: {
283
- projectRoot: { type: "string", description: "Path to the project root directory" },
284
- testFile: { type: "string", description: "Specific benchmark test file to run" },
285
- iterations: { type: "number", default: 100, description: "Number of benchmark iterations" },
286
- warmupRuns: { type: "number", default: 10, description: "Number of warmup runs" },
287
- compareBaseline: { type: "boolean", default: false, description: "Compare results against baseline" }
288
- },
289
- required: ["projectRoot"]
290
- }
263
+ required: ["projectRoot"]
264
+ }
265
+ },
266
+ {
267
+ name: "suggest-optimizations",
268
+ description: "Generate specific, actionable optimization suggestions based on code analysis",
269
+ inputSchema: {
270
+ type: "object",
271
+ properties: {
272
+ projectRoot: { type: "string", description: "Path to the project root directory" },
273
+ focus: {
274
+ type: "string",
275
+ enum: ["cpu", "memory", "network", "io", "all"],
276
+ default: "all",
277
+ description: "Focus area for optimizations"
278
+ },
279
+ threshold: { type: "number", default: 100, description: "Performance threshold in ms" }
291
280
  },
292
- {
293
- name: "suggest-optimizations",
294
- description: "Generate specific, actionable optimization suggestions based on code analysis",
295
- inputSchema: {
296
- type: "object",
297
- properties: {
298
- projectRoot: { type: "string", description: "Path to the project root directory" },
299
- focus: {
300
- type: "string",
301
- enum: ["cpu", "memory", "network", "io", "all"],
302
- default: "all",
303
- description: "Focus area for optimizations"
304
- },
305
- threshold: { type: "number", default: 100, description: "Performance threshold in ms" }
306
- },
307
- required: ["projectRoot"]
308
- }
281
+ required: ["projectRoot"]
282
+ }
283
+ },
284
+ {
285
+ name: "measure-core-web-vitals",
286
+ description: "Analyze Core Web Vitals metrics (LCP, INP, CLS) for web application performance",
287
+ inputSchema: {
288
+ type: "object",
289
+ properties: {
290
+ projectRoot: { type: "string", description: "Path to the project root directory" },
291
+ analyzeBundle: { type: "boolean", default: true, description: "Analyze JavaScript bundle" },
292
+ checkAccessibility: { type: "boolean", default: true, description: "Check accessibility factors affecting CLS" },
293
+ measureLCP: { type: "boolean", default: true, description: "Measure Largest Contentful Paint" },
294
+ measureINP: { type: "boolean", default: true, description: "Measure Interaction to Next Paint" },
295
+ measureCLS: { type: "boolean", default: true, description: "Measure Cumulative Layout Shift" }
309
296
  },
310
- {
311
- name: "measure-core-web-vitals",
312
- description: "Analyze Core Web Vitals metrics (LCP, INP, CLS) for web application performance",
313
- inputSchema: {
314
- type: "object",
315
- properties: {
316
- projectRoot: { type: "string", description: "Path to the project root directory" },
317
- analyzeBundle: { type: "boolean", default: true, description: "Analyze JavaScript bundle" },
318
- checkAccessibility: { type: "boolean", default: true, description: "Check accessibility factors affecting CLS" },
319
- measureLCP: { type: "boolean", default: true, description: "Measure Largest Contentful Paint" },
320
- measureINP: { type: "boolean", default: true, description: "Measure Interaction to Next Paint" },
321
- measureCLS: { type: "boolean", default: true, description: "Measure Cumulative Layout Shift" }
322
- },
323
- required: ["projectRoot"]
324
- }
325
- }
326
- ]
327
- };
328
- });
329
-
330
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
331
- const { name, arguments: args } = request.params;
332
-
333
- try {
334
- switch (name) {
335
- case "profile-application":
336
- return await this.handleProfileApplication(args as unknown as ProfileApplicationArgs) as never;
337
- case "analyze-memory":
338
- return await this.handleAnalyzeMemory(args as unknown as AnalyzeMemoryArgs) as never;
339
- case "benchmark-code":
340
- return await this.handleBenchmarkCode(args as unknown as BenchmarkCodeArgs) as never;
341
- case "suggest-optimizations":
342
- return await this.handleSuggestOptimizations(args as unknown as SuggestOptimizationsArgs) as never;
343
- case "measure-core-web-vitals":
344
- return await this.handleMeasureCoreWebVitals(args as unknown as MeasureCoreWebVitalsArgs) as never;
345
- default:
346
- throw new Error(`Unknown tool: ${name}`);
297
+ required: ["projectRoot"]
347
298
  }
348
- } catch (error) {
349
- frameworkLogger.log("mcp/performance-optimization", "tool-handler", "error", { tool: name, error: String(error) });
350
- return {
351
- content: [{
352
- type: "text",
353
- text: `Error executing tool "${name}": ${error instanceof Error ? error.message : String(error)}`
354
- }]
355
- };
356
299
  }
357
- });
300
+ ];
301
+ this.handlers = {
302
+ "profile-application": async (args) => this.handleProfileApplication(args as unknown as ProfileApplicationArgs),
303
+ "analyze-memory": async (args) => this.handleAnalyzeMemory(args as unknown as AnalyzeMemoryArgs),
304
+ "benchmark-code": async (args) => this.handleBenchmarkCode(args as unknown as BenchmarkCodeArgs),
305
+ "suggest-optimizations": async (args) => this.handleSuggestOptimizations(args as unknown as SuggestOptimizationsArgs),
306
+ "measure-core-web-vitals": async (args) => this.handleMeasureCoreWebVitals(args as unknown as MeasureCoreWebVitalsArgs),
307
+ };
308
+ this.setupToolHandlers();
358
309
  }
359
310
 
360
311
  private async handleProfileApplication(args: ProfileApplicationArgs): Promise<McpToolResponse> {
@@ -616,32 +567,24 @@ class XrayPerformanceOptimizationServer {
616
567
  }
617
568
 
618
569
  private formatProfilingResult(result: ProfilingResult): string {
619
- return `📊 Performance Profiling Results
570
+ const { metrics, hotPaths, functionCallCounts, bottlenecks, recommendations } = result;
571
+ return `📊 Performance Profiling
620
572
 
621
- **PROFILING METRICS**
622
- - Total Functions Analyzed: ${result.metrics.totalFunctions}
623
- - Hot Functions (>1000 calls): ${result.metrics.hotFunctions}
624
- - Average Execution Time: ${result.metrics.avgExecutionTime}ms
625
- - Peak Memory: ${result.metrics.peakMemory}MB
626
- - GC Pauses: ${result.metrics.gcPauses}
573
+ **METRICS** Functions:${metrics.totalFunctions} Hot:${metrics.hotFunctions} Avg:${metrics.avgExecutionTime}ms Mem:${metrics.peakMemory}MB GC:${metrics.gcPauses}
627
574
 
628
- **HOT PATHS** (${result.hotPaths.length} identified)
629
- ${result.hotPaths.slice(0, 10).map(p => `• 🔥 ${p}`).join("\n") || "None detected"}
575
+ **HOT PATHS** (${hotPaths.length})
576
+ ${hotPaths.slice(0, 10).map(p => ` 🔥 ${p}`).join("\n") || " None"}
630
577
 
631
- **TOP FUNCTIONS BY CALL COUNT**
632
- ${Object.entries(result.functionCallCounts)
633
- .sort(([, a], [, b]) => b - a)
634
- .slice(0, 5)
635
- .map(([name, count]) => `• ${name}: ${count.toLocaleString()} calls`)
636
- .join("\n") || "None"}
578
+ **TOP FUNCTIONS**
579
+ ${Object.entries(functionCallCounts).sort(([, a], [, b]) => b - a).slice(0, 5).map(([n, c]) => ` ${n}: ${c.toLocaleString()} calls`).join("\n") || " None"}
637
580
 
638
- **BOTTLENECKS** (${result.bottlenecks.length} detected)
639
- ${result.bottlenecks.slice(0, 5).map(b => `• 🚧 ${b}`).join("\n") || "None detected"}
581
+ **BOTTLENECKS** (${bottlenecks.length})
582
+ ${bottlenecks.slice(0, 5).map(b => ` 🚧 ${b}`).join("\n") || " None"}
640
583
 
641
584
  **RECOMMENDATIONS**
642
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
585
+ ${recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || " None"}
643
586
 
644
- **Status:** ${result.metrics.hotFunctions > 10 ? "❌ HIGH OPTIMIZATION NEEDED" : result.metrics.hotFunctions > 5 ? "⚠️ MODERATE OPTIMIZATION NEEDED" : "✅ PERFORMANCE ACCEPTABLE"}`;
587
+ **Status** ${metrics.hotFunctions > 10 ? "❌ HIGH OPTIMIZATION NEEDED" : metrics.hotFunctions > 5 ? "⚠️ MODERATE OPTIMIZATION NEEDED" : "✅ ACCEPTABLE"}`;
645
588
  }
646
589
 
647
590
  private async handleAnalyzeMemory(args: AnalyzeMemoryArgs): Promise<McpToolResponse> {
@@ -800,18 +743,16 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
800
743
  }
801
744
 
802
745
  private analyzeGCActivity(heapUsedMB: number): GCEvent[] {
746
+ const count = Math.min(Math.floor(heapUsedMB / 100), 5);
803
747
  const events: GCEvent[] = [];
804
- const eventCount = Math.floor(heapUsedMB / 50);
805
-
806
- for (let i = 0; i < Math.min(eventCount, 10); i++) {
748
+ for (let i = 0; i < count; i++) {
807
749
  events.push({
808
- type: heapUsedMB > 200 ? (i % 3 === 0 ? "major" : "minor") : "minor",
809
- duration: Math.round(Math.random() * 10 + 2),
810
- timestamp: Date.now() - (eventCount - i) * 60000,
811
- reclaimedBytes: Math.round(Math.random() * 1024 * 1024 * 10)
750
+ type: heapUsedMB > 200 && i % 3 === 0 ? "major" : "minor",
751
+ duration: 3 + i * 2,
752
+ timestamp: Date.now() - (count - i) * 60000,
753
+ reclaimedBytes: 512 * 1024
812
754
  });
813
755
  }
814
-
815
756
  return events;
816
757
  }
817
758
 
@@ -986,43 +927,25 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
986
927
  }
987
928
 
988
929
  private formatMemoryAnalysis(result: MemoryAnalysisResult): string {
989
- return `🧠 Memory Analysis Results
990
-
991
- **HEAP USAGE**
992
- - Heap Used: ${result.heapUsed}MB
993
- - Heap Total: ${result.heapTotal}MB
994
- - External: ${result.external}MB
995
- - RSS: ${result.rss}MB
996
- - Usage: ${((result.heapUsed / result.heapTotal) * 100).toFixed(1)}%
997
-
998
- **HEAP BREAKDOWN**
999
- - Strings: ${(result.heapBreakdown.strings / 1024).toFixed(1)}KB
1000
- - Arrays: ${(result.heapBreakdown.arrays / 1024).toFixed(1)}KB
1001
- - Objects: ${(result.heapBreakdown.objects / 1024).toFixed(1)}KB
1002
- - Functions: ${(result.heapBreakdown.functions / 1024).toFixed(1)}KB
1003
- - Closures: ${(result.heapBreakdown.closures / 1024).toFixed(1)}KB
1004
-
1005
- **MEMORY LEAKS** (${result.memoryLeaks.length} detected)
1006
- ${result.memoryLeaks.slice(0, 5).map(leak =>
1007
- `• ${leak.severity === "critical" || leak.severity === "high" ? "🔴" : "🟡"} ${leak.location}\n Cause: ${leak.suspectedCause}\n Fix: ${leak.fixSuggestion}`
1008
- ).join("\n\n") || "None detected"}
1009
-
1010
- **GC ACTIVITY** (${result.gcEvents.length} events)
1011
- - Minor GC: ${result.gcEvents.filter(e => e.type === "minor").length}
1012
- - Major GC: ${result.gcEvents.filter(e => e.type === "major").length}
1013
- - Full GC: ${result.gcEvents.filter(e => e.type === "full").length}
1014
-
1015
- **ALLOCATIONS BY TYPE**
1016
- ${Object.entries(result.allocationsByType)
1017
- .sort(([, a], [, b]) => b - a)
1018
- .slice(0, 5)
1019
- .map(([type, count]) => `• ${type}: ${count.toLocaleString()}`)
1020
- .join("\n")}
930
+ const { heapUsed, heapTotal, external, rss, memoryLeaks, gcEvents, heapBreakdown, allocationsByType, recommendations } = result;
931
+ return `🧠 Memory Analysis
932
+
933
+ **HEAP** Used:${heapUsed}MB Total:${heapTotal}MB Ext:${external}MB RSS:${rss}MB (${(heapUsed / heapTotal * 100).toFixed(1)}%)
934
+
935
+ **BREAKDOWN** Str:${(heapBreakdown.strings / 1024).toFixed(1)}KB Arr:${(heapBreakdown.arrays / 1024).toFixed(1)}KB Obj:${(heapBreakdown.objects / 1024).toFixed(1)}KB Fn:${(heapBreakdown.functions / 1024).toFixed(1)}KB Cls:${(heapBreakdown.closures / 1024).toFixed(1)}KB
936
+
937
+ **LEAKS** (${memoryLeaks.length})
938
+ ${memoryLeaks.slice(0, 5).map(l => ` ${l.severity === "critical" || l.severity === "high" ? "🔴" : "🟡"} ${l.location}\n Cause: ${l.suspectedCause}\n Fix: ${l.fixSuggestion}`).join("\n") || " None"}
939
+
940
+ **GC** (${gcEvents.length}) Minor:${gcEvents.filter(e => e.type === "minor").length} Major:${gcEvents.filter(e => e.type === "major").length} Full:${gcEvents.filter(e => e.type === "full").length}
941
+
942
+ **ALLOCATIONS**
943
+ ${Object.entries(allocationsByType).sort(([, a], [, b]) => b - a).slice(0, 5).map(([t, c]) => ` ${t}: ${c.toLocaleString()}`).join("\n")}
1021
944
 
1022
945
  **RECOMMENDATIONS**
1023
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
946
+ ${recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || " None"}
1024
947
 
1025
- **Status:** ${result.memoryLeaks.some(l => l.severity === "critical" || l.severity === "high") ? "❌ CRITICAL MEMORY ISSUES" : result.memoryLeaks.length > 3 ? "⚠️ MEMORY OPTIMIZATION NEEDED" : "✅ MEMORY HEALTH ACCEPTABLE"}`;
948
+ **Status** ${memoryLeaks.some(l => l.severity === "critical" || l.severity === "high") ? "❌ CRITICAL" : memoryLeaks.length > 3 ? "⚠️ OPTIMIZATION NEEDED" : "✅ HEALTHY"}`;
1026
949
  }
1027
950
 
1028
951
  private async handleBenchmarkCode(args: BenchmarkCodeArgs): Promise<McpToolResponse> {
@@ -1136,20 +1059,9 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
1136
1059
  }
1137
1060
 
1138
1061
  private simulateBenchmarkWorkload(filePath: string): void {
1139
- const fileSize = fs.existsSync(filePath) ? fs.statSync(filePath).size : 1000;
1140
- const iterations = Math.max(10, Math.floor(fileSize / 100));
1141
-
1142
- let result = 0;
1143
- for (let i = 0; i < iterations; i++) {
1144
- result += Math.sqrt(i) * Math.log(i + 1);
1145
- }
1146
-
1147
- const arr = new Array(100).fill(0).map((_, i) => i * 2);
1148
- arr.sort((a, b) => b - a);
1149
-
1150
- const obj = { a: 1, b: 2, c: 3, d: 4 };
1151
- const serialized = JSON.stringify(obj);
1152
- JSON.parse(serialized);
1062
+ // Stub: synthetic math workload for benchmarking
1063
+ const iterations = Math.max(10, Math.min(100, Math.floor((fs.existsSync(filePath) ? fs.statSync(filePath).size : 1000) / 100)));
1064
+ for (let i = 0; i < iterations; i++) Math.sqrt(i) * Math.log(i + 1);
1153
1065
  }
1154
1066
 
1155
1067
  private calculateVariance(values: number[]): number {
@@ -1180,44 +1092,20 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
1180
1092
  }
1181
1093
 
1182
1094
  private formatBenchmarkResult(result: BenchmarkResult): string {
1183
- let text = `⚡ Benchmark Results (${result.benchmarks.length} benchmarks)
1095
+ const { benchmarks, comparison, statistics, recommendations } = result;
1096
+ let text = `⚡ Benchmark Results (${benchmarks.length} benchmarks)
1184
1097
 
1185
- **STATISTICS**
1186
- - Total Benchmarks: ${result.statistics.totalBenchmarks}
1187
- - Fastest: ${result.statistics.fastest}
1188
- - Slowest: ${result.statistics.slowest}
1189
- - Average Ops/Sec: ${result.statistics.averageOpsPerSecond.toLocaleString()}
1190
- - Variance: ${result.statistics.variance.toFixed(2)}
1098
+ **STATS** Total:${statistics.totalBenchmarks} Fastest:${statistics.fastest} Slowest:${statistics.slowest} Avg:${statistics.averageOpsPerSecond.toLocaleString()} ops/s Var:${statistics.variance.toFixed(2)}
1191
1099
 
1192
- **BENCHMARK DETAILS**
1193
- `;
1194
-
1195
- for (const benchmark of result.benchmarks) {
1196
- text += `
1197
- 📊 ${benchmark.name}
1198
- - Ops/sec: ${benchmark.opsPerSecond.toLocaleString()}
1199
- - Mean: ${benchmark.meanMs}ms | Median: ${benchmark.medianMs}ms
1200
- - Min: ${benchmark.minMs}ms | Max: ${benchmark.maxMs}ms
1201
- - P95: ${benchmark.p95Ms}ms | P99: ${benchmark.p99Ms}ms
1202
- - Std Dev: ${benchmark.stdDevMs}ms
1100
+ **DETAILS**
1203
1101
  `;
1102
+ for (const b of benchmarks) {
1103
+ text += ` ${b.name} — ${b.opsPerSecond.toLocaleString()} ops/s | Mean:${b.meanMs}ms Med:${b.medianMs}ms Min:${b.minMs}ms Max:${b.maxMs}ms P95:${b.p95Ms}ms P99:${b.p99Ms}ms SD:${b.stdDevMs}ms\n`;
1204
1104
  }
1205
-
1206
- if (result.comparison) {
1207
- const c = result.comparison;
1208
- const direction = c.improvement > 0 ? "📈" : "📉";
1209
- text += `
1210
- **COMPARISON vs BASELINE**
1211
- ${direction} Change: ${c.improvement > 0 ? "+" : ""}${c.improvement.toFixed(1)}%
1212
- ${c.significant ? "⚠️" : "✓"} Statistically Significant: ${c.significant ? "Yes" : "No"}
1213
- `;
1105
+ if (comparison) {
1106
+ text += `**vs BASELINE** ${comparison.improvement > 0 ? "📈" : "📉"} ${comparison.improvement > 0 ? "+" : ""}${comparison.improvement.toFixed(1)}% ${comparison.significant ? "⚠️ Significant" : "✓ Not significant"}\n`;
1214
1107
  }
1215
-
1216
- text += `
1217
- **RECOMMENDATIONS**
1218
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
1219
- `;
1220
-
1108
+ text += `**RECOMMENDATIONS**\n${recommendations.slice(0, 5).map((r, i) => ` ${i + 1}. ${r}`).join("\n") || " None"}\n`;
1221
1109
  return text;
1222
1110
  }
1223
1111
 
@@ -1489,36 +1377,25 @@ return {
1489
1377
 
1490
1378
  private formatOptimizationSuggestions(suggestions: OptimizationSuggestion[]): string {
1491
1379
  const byCategory = suggestions.reduce((acc, s) => {
1492
- if (!acc[s.category]) acc[s.category] = [];
1493
- acc[s.category]!.push(s);
1380
+ (acc[s.category] ??= []).push(s);
1494
1381
  return acc;
1495
1382
  }, {} as Record<string, OptimizationSuggestion[]>);
1496
1383
 
1497
- let text = `💡 Performance Optimization Suggestions (${suggestions.length} found)
1384
+ const critical = suggestions.filter(s => s.impact === "critical").length;
1385
+ const high = suggestions.filter(s => s.impact === "high").length;
1386
+ const medium = suggestions.filter(s => s.impact === "medium").length;
1387
+ const low = suggestions.filter(s => s.impact === "low").length;
1388
+ let text = `💡 Optimization Suggestions (${suggestions.length})
1498
1389
 
1499
- **SUMMARY BY IMPACT**
1500
- - Critical: ${suggestions.filter(s => s.impact === "critical").length}
1501
- - High: ${suggestions.filter(s => s.impact === "high").length}
1502
- - Medium: ${suggestions.filter(s => s.impact === "medium").length}
1503
- - Low: ${suggestions.filter(s => s.impact === "low").length}
1390
+ **IMPACT** Crit:${critical} High:${high} Med:${medium} Low:${low}
1504
1391
  `;
1505
-
1506
1392
  for (const [category, items] of Object.entries(byCategory)) {
1507
- text += `\n## ${category.toUpperCase()} Optimizations (${items.length})\n`;
1508
- for (const suggestion of items.slice(0, 5)) {
1509
- const icon = suggestion.impact === "critical" ? "🔴" :
1510
- suggestion.impact === "high" ? "🟠" :
1511
- suggestion.impact === "medium" ? "🟡" : "🟢";
1512
- text += `
1513
- ${icon} **${suggestion.title}** (${suggestion.impact} impact, ${suggestion.effort} effort)
1514
- ${suggestion.description}
1515
- 📁 Files: ${suggestion.files.join(", ")}
1516
- 💡 Fix: ${suggestion.suggestedFix}
1517
- 📈 Expected: ${suggestion.expectedImprovement}
1518
- `;
1393
+ text += `\n## ${category.toUpperCase()} (${items.length})\n`;
1394
+ for (const s of items.slice(0, 5)) {
1395
+ const icon = s.impact === "critical" ? "🔴" : s.impact === "high" ? "🟠" : s.impact === "medium" ? "🟡" : "🟢";
1396
+ text += `${icon} ${s.title} (${s.impact}, ${s.effort})\n ${s.description} | Fix: ${s.suggestedFix}\n`;
1519
1397
  }
1520
1398
  }
1521
-
1522
1399
  return text;
1523
1400
  }
1524
1401
 
@@ -1934,65 +1811,28 @@ ${icon} **${suggestion.title}** (${suggestion.impact} impact, ${suggestion.effor
1934
1811
  }
1935
1812
 
1936
1813
  private formatCoreWebVitalsResult(result: CoreWebVitalsResult): string {
1937
- const statusIcon = result.status === "good" ? "✅" :
1938
- result.status === "needs-improvement" ? "⚠️" : "❌";
1939
-
1940
- let text = `${statusIcon} Core Web Vitals Analysis
1941
-
1942
- **OVERALL SCORE:** ${result.score}/100 (${result.status.toUpperCase()})
1943
- `;
1814
+ const statusIcon = result.status === "good" ? "✅" : result.status === "needs-improvement" ? "⚠️" : "❌";
1815
+ let text = `${statusIcon} Core Web Vitals — ${result.score}/100 (${result.status.toUpperCase()})\n`;
1944
1816
 
1945
1817
  if (result.bundleAnalysis) {
1946
- const bundle = result.bundleAnalysis;
1947
- text += `
1948
- **BUNDLE ANALYSIS**
1949
- - Total Size: ${(bundle.totalSize / 1024 / 1024).toFixed(2)}MB
1950
- - Gzipped Size: ${(bundle.gzippedSize / 1024 / 1024).toFixed(2)}MB
1951
- - Largest Modules: ${bundle.largestModules.slice(0, 3).map(m => `${m.name} (${m.size}KB)`).join(", ") || "None"}
1952
- `;
1818
+ const b = result.bundleAnalysis;
1819
+ text += `**BUNDLE** ${(b.totalSize / 1024 / 1024).toFixed(2)}MB (gz:${(b.gzippedSize / 1024 / 1024).toFixed(2)}MB)\n`;
1820
+ const top = b.largestModules.slice(0, 3).map(m => `${m.name} (${m.size}KB)`).join(", ");
1821
+ if (top) text += ` Largest: ${top}\n`;
1953
1822
  }
1954
-
1955
1823
  if (result.LCP) {
1956
- const lcp = result.LCP;
1957
- const lcpStatus = lcp.value <= 2500 ? "✅" : lcp.value <= 4000 ? "⚠️" : "❌";
1958
- text += `
1959
- **LCP (Largest Contentful Paint)** ${lcpStatus}
1960
- - Value: ${(lcp.value / 1000).toFixed(2)}s
1961
- - Score: ${lcp.score}/100
1962
- - Resource Load: ${(lcp.resourceLoadTime / 1000).toFixed(2)}s
1963
- - Render Delay: ${(lcp.renderDelay / 1000).toFixed(2)}s
1964
- `;
1824
+ const l = result.LCP;
1825
+ text += `**LCP** ${l.value <= 2500 ? "✅" : l.value <= 4000 ? "⚠️" : "❌"} ${(l.value / 1000).toFixed(2)}s (score:${l.score}/100 load:${(l.resourceLoadTime / 1000).toFixed(2)}s render:${(l.renderDelay / 1000).toFixed(2)}s)\n`;
1965
1826
  }
1966
-
1967
1827
  if (result.INP) {
1968
- const inp = result.INP;
1969
- const inpStatus = inp.value <= 200 ? "✅" : inp.value <= 500 ? "⚠️" : "❌";
1970
- text += `
1971
- **INP (Interaction to Next Paint)** ${inpStatus}
1972
- - Value: ${inp.value}ms
1973
- - Score: ${inp.score}/100
1974
- - Processing Time: ${inp.processingTime}ms
1975
- - Presentation Delay: ${inp.presentationDelay}ms
1976
- `;
1828
+ const i = result.INP;
1829
+ text += `**INP** ${i.value <= 200 ? "✅" : i.value <= 500 ? "⚠️" : "❌"} ${i.value}ms (score:${i.score}/100 proc:${i.processingTime}ms delay:${i.presentationDelay}ms)\n`;
1977
1830
  }
1978
-
1979
1831
  if (result.CLS) {
1980
- const cls = result.CLS;
1981
- const clsStatus = cls.value <= 0.1 ? "✅" : cls.value <= 0.25 ? "⚠️" : "❌";
1982
- text += `
1983
- **CLS (Cumulative Layout Shift)** ${clsStatus}
1984
- - Value: ${cls.value}
1985
- - Score: ${cls.score}/100
1986
- - Layout Shifts: ${cls.layoutShifts}
1987
- - Sources: ${cls.sources.slice(0, 3).join(", ") || "None"}
1988
- `;
1832
+ const c = result.CLS;
1833
+ text += `**CLS** ${c.value <= 0.1 ? "✅" : c.value <= 0.25 ? "⚠️" : "❌"} ${c.value} (score:${c.score}/100 shifts:${c.layoutShifts} sources:${c.sources.slice(0, 3).join(", ") || "None"})\n`;
1989
1834
  }
1990
-
1991
- text += `
1992
- **RECOMMENDATIONS**
1993
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
1994
- `;
1995
-
1835
+ text += `**RECOMMENDATIONS**\n${result.recommendations.slice(0, 5).map((r, i) => ` ${i + 1}. ${r}`).join("\n") || " None"}\n`;
1996
1836
  return text;
1997
1837
  }
1998
1838
 
@@ -2040,24 +1880,11 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
2040
1880
  return files.slice(0, 100);
2041
1881
  }
2042
1882
 
2043
- async run(): Promise<void> {
2044
- const transport = new StdioServerTransport();
2045
- await this.server.connect(transport);
2046
-
2047
- createGracefulShutdown({
2048
- serverName: "performance-optimization.server",
2049
- server: this.server,
2050
- });
2051
-
2052
- frameworkLogger.log("mcp/performance-optimization", "server-started", "info", {
2053
- uptime: Date.now() - this.startTime
2054
- });
2055
- }
2056
1883
  }
2057
1884
 
2058
1885
  if (import.meta.url === `file://${process.argv[1]}`) {
2059
1886
  const server = new XrayPerformanceOptimizationServer();
2060
- server.run().catch((error) => {
1887
+ server.run("performance-optimization.server").catch((error) => {
2061
1888
  frameworkLogger.log("mcp/performance-optimization", "run", "error", { error: String(error) });
2062
1889
  });
2063
1890
  }