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,144 +4,105 @@
4
4
  * Knowledge skill for performance analysis, optimization recommendations,
5
5
  * profiling, benchmarking, memory analysis, and Core Web Vitals measurement
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";
7
+ import { XrayKnowledgeSkillBase } from "../shared/knowledge-skill-base.js";
10
8
  import { frameworkLogger, generateJobId } from "../../core/framework-logger.js";
11
- import { createGracefulShutdown } from "../../utils/shutdown-handler.js";
12
9
  import fs from "fs";
13
10
  import path from "path";
14
- class XrayPerformanceOptimizationServer {
15
- server;
16
- startTime;
11
+ class XrayPerformanceOptimizationServer extends XrayKnowledgeSkillBase {
17
12
  constructor() {
18
- this.server = new Server({
19
- name: "performance-optimization", version: "2.0.1",
20
- }, {
21
- capabilities: {
22
- tools: {},
13
+ super("performance-optimization", "2.0.1");
14
+ this.tools = [
15
+ {
16
+ name: "profile-application",
17
+ description: "Run comprehensive performance profiling on the codebase to identify bottlenecks and hot paths",
18
+ inputSchema: {
19
+ type: "object",
20
+ properties: {
21
+ projectRoot: { type: "string", description: "Path to the project root directory" },
22
+ scope: {
23
+ type: "string",
24
+ enum: ["full", "runtime", "build", "memory"],
25
+ default: "full",
26
+ description: "Scope of profiling analysis"
27
+ },
28
+ duration: { type: "number", default: 30, description: "Profiling duration in seconds" },
29
+ includeHotPaths: { type: "boolean", default: true, description: "Include hot path analysis" }
30
+ },
31
+ required: ["projectRoot"]
32
+ }
23
33
  },
24
- });
25
- this.startTime = Date.now();
26
- this.setupToolHandlers();
27
- }
28
- setupToolHandlers() {
29
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
30
- return {
31
- tools: [
32
- {
33
- name: "profile-application",
34
- description: "Run comprehensive performance profiling on the codebase to identify bottlenecks and hot paths",
35
- inputSchema: {
36
- type: "object",
37
- properties: {
38
- projectRoot: { type: "string", description: "Path to the project root directory" },
39
- scope: {
40
- type: "string",
41
- enum: ["full", "runtime", "build", "memory"],
42
- default: "full",
43
- description: "Scope of profiling analysis"
44
- },
45
- duration: { type: "number", default: 30, description: "Profiling duration in seconds" },
46
- includeHotPaths: { type: "boolean", default: true, description: "Include hot path analysis" }
47
- },
48
- required: ["projectRoot"]
49
- }
34
+ {
35
+ name: "analyze-memory",
36
+ description: "Perform memory leak detection and heap analysis to identify memory issues",
37
+ inputSchema: {
38
+ type: "object",
39
+ properties: {
40
+ projectRoot: { type: "string", description: "Path to the project root directory" },
41
+ heapSnapshot: { type: "boolean", default: true, description: "Generate heap snapshot analysis" },
42
+ gcAnalysis: { type: "boolean", default: true, description: "Analyze garbage collection patterns" },
43
+ leakDetection: { type: "boolean", default: true, description: "Detect potential memory leaks" }
50
44
  },
51
- {
52
- name: "analyze-memory",
53
- description: "Perform memory leak detection and heap analysis to identify memory issues",
54
- inputSchema: {
55
- type: "object",
56
- properties: {
57
- projectRoot: { type: "string", description: "Path to the project root directory" },
58
- heapSnapshot: { type: "boolean", default: true, description: "Generate heap snapshot analysis" },
59
- gcAnalysis: { type: "boolean", default: true, description: "Analyze garbage collection patterns" },
60
- leakDetection: { type: "boolean", default: true, description: "Detect potential memory leaks" }
61
- },
62
- required: ["projectRoot"]
63
- }
45
+ required: ["projectRoot"]
46
+ }
47
+ },
48
+ {
49
+ name: "benchmark-code",
50
+ description: "Execute and compare benchmark results for code performance measurement",
51
+ inputSchema: {
52
+ type: "object",
53
+ properties: {
54
+ projectRoot: { type: "string", description: "Path to the project root directory" },
55
+ testFile: { type: "string", description: "Specific benchmark test file to run" },
56
+ iterations: { type: "number", default: 100, description: "Number of benchmark iterations" },
57
+ warmupRuns: { type: "number", default: 10, description: "Number of warmup runs" },
58
+ compareBaseline: { type: "boolean", default: false, description: "Compare results against baseline" }
64
59
  },
65
- {
66
- name: "benchmark-code",
67
- description: "Execute and compare benchmark results for code performance measurement",
68
- inputSchema: {
69
- type: "object",
70
- properties: {
71
- projectRoot: { type: "string", description: "Path to the project root directory" },
72
- testFile: { type: "string", description: "Specific benchmark test file to run" },
73
- iterations: { type: "number", default: 100, description: "Number of benchmark iterations" },
74
- warmupRuns: { type: "number", default: 10, description: "Number of warmup runs" },
75
- compareBaseline: { type: "boolean", default: false, description: "Compare results against baseline" }
76
- },
77
- required: ["projectRoot"]
78
- }
60
+ required: ["projectRoot"]
61
+ }
62
+ },
63
+ {
64
+ name: "suggest-optimizations",
65
+ description: "Generate specific, actionable optimization suggestions based on code analysis",
66
+ inputSchema: {
67
+ type: "object",
68
+ properties: {
69
+ projectRoot: { type: "string", description: "Path to the project root directory" },
70
+ focus: {
71
+ type: "string",
72
+ enum: ["cpu", "memory", "network", "io", "all"],
73
+ default: "all",
74
+ description: "Focus area for optimizations"
75
+ },
76
+ threshold: { type: "number", default: 100, description: "Performance threshold in ms" }
79
77
  },
80
- {
81
- name: "suggest-optimizations",
82
- description: "Generate specific, actionable optimization suggestions based on code analysis",
83
- inputSchema: {
84
- type: "object",
85
- properties: {
86
- projectRoot: { type: "string", description: "Path to the project root directory" },
87
- focus: {
88
- type: "string",
89
- enum: ["cpu", "memory", "network", "io", "all"],
90
- default: "all",
91
- description: "Focus area for optimizations"
92
- },
93
- threshold: { type: "number", default: 100, description: "Performance threshold in ms" }
94
- },
95
- required: ["projectRoot"]
96
- }
78
+ required: ["projectRoot"]
79
+ }
80
+ },
81
+ {
82
+ name: "measure-core-web-vitals",
83
+ description: "Analyze Core Web Vitals metrics (LCP, INP, CLS) for web application performance",
84
+ inputSchema: {
85
+ type: "object",
86
+ properties: {
87
+ projectRoot: { type: "string", description: "Path to the project root directory" },
88
+ analyzeBundle: { type: "boolean", default: true, description: "Analyze JavaScript bundle" },
89
+ checkAccessibility: { type: "boolean", default: true, description: "Check accessibility factors affecting CLS" },
90
+ measureLCP: { type: "boolean", default: true, description: "Measure Largest Contentful Paint" },
91
+ measureINP: { type: "boolean", default: true, description: "Measure Interaction to Next Paint" },
92
+ measureCLS: { type: "boolean", default: true, description: "Measure Cumulative Layout Shift" }
97
93
  },
98
- {
99
- name: "measure-core-web-vitals",
100
- description: "Analyze Core Web Vitals metrics (LCP, INP, CLS) for web application performance",
101
- inputSchema: {
102
- type: "object",
103
- properties: {
104
- projectRoot: { type: "string", description: "Path to the project root directory" },
105
- analyzeBundle: { type: "boolean", default: true, description: "Analyze JavaScript bundle" },
106
- checkAccessibility: { type: "boolean", default: true, description: "Check accessibility factors affecting CLS" },
107
- measureLCP: { type: "boolean", default: true, description: "Measure Largest Contentful Paint" },
108
- measureINP: { type: "boolean", default: true, description: "Measure Interaction to Next Paint" },
109
- measureCLS: { type: "boolean", default: true, description: "Measure Cumulative Layout Shift" }
110
- },
111
- required: ["projectRoot"]
112
- }
113
- }
114
- ]
115
- };
116
- });
117
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
118
- const { name, arguments: args } = request.params;
119
- try {
120
- switch (name) {
121
- case "profile-application":
122
- return await this.handleProfileApplication(args);
123
- case "analyze-memory":
124
- return await this.handleAnalyzeMemory(args);
125
- case "benchmark-code":
126
- return await this.handleBenchmarkCode(args);
127
- case "suggest-optimizations":
128
- return await this.handleSuggestOptimizations(args);
129
- case "measure-core-web-vitals":
130
- return await this.handleMeasureCoreWebVitals(args);
131
- default:
132
- throw new Error(`Unknown tool: ${name}`);
94
+ required: ["projectRoot"]
133
95
  }
134
96
  }
135
- catch (error) {
136
- frameworkLogger.log("mcp/performance-optimization", "tool-handler", "error", { tool: name, error: String(error) });
137
- return {
138
- content: [{
139
- type: "text",
140
- text: `Error executing tool "${name}": ${error instanceof Error ? error.message : String(error)}`
141
- }]
142
- };
143
- }
144
- });
97
+ ];
98
+ this.handlers = {
99
+ "profile-application": async (args) => this.handleProfileApplication(args),
100
+ "analyze-memory": async (args) => this.handleAnalyzeMemory(args),
101
+ "benchmark-code": async (args) => this.handleBenchmarkCode(args),
102
+ "suggest-optimizations": async (args) => this.handleSuggestOptimizations(args),
103
+ "measure-core-web-vitals": async (args) => this.handleMeasureCoreWebVitals(args),
104
+ };
105
+ this.setupToolHandlers();
145
106
  }
146
107
  async handleProfileApplication(args) {
147
108
  const { projectRoot, scope = "full", duration = 30, includeHotPaths = true } = args;
@@ -349,32 +310,24 @@ class XrayPerformanceOptimizationServer {
349
310
  return analysis.hotPaths.slice(0, 5);
350
311
  }
351
312
  formatProfilingResult(result) {
352
- return `📊 Performance Profiling Results
313
+ const { metrics, hotPaths, functionCallCounts, bottlenecks, recommendations } = result;
314
+ return `📊 Performance Profiling
353
315
 
354
- **PROFILING METRICS**
355
- - Total Functions Analyzed: ${result.metrics.totalFunctions}
356
- - Hot Functions (>1000 calls): ${result.metrics.hotFunctions}
357
- - Average Execution Time: ${result.metrics.avgExecutionTime}ms
358
- - Peak Memory: ${result.metrics.peakMemory}MB
359
- - GC Pauses: ${result.metrics.gcPauses}
316
+ **METRICS** Functions:${metrics.totalFunctions} Hot:${metrics.hotFunctions} Avg:${metrics.avgExecutionTime}ms Mem:${metrics.peakMemory}MB GC:${metrics.gcPauses}
360
317
 
361
- **HOT PATHS** (${result.hotPaths.length} identified)
362
- ${result.hotPaths.slice(0, 10).map(p => `• 🔥 ${p}`).join("\n") || "None detected"}
318
+ **HOT PATHS** (${hotPaths.length})
319
+ ${hotPaths.slice(0, 10).map(p => ` 🔥 ${p}`).join("\n") || " None"}
363
320
 
364
- **TOP FUNCTIONS BY CALL COUNT**
365
- ${Object.entries(result.functionCallCounts)
366
- .sort(([, a], [, b]) => b - a)
367
- .slice(0, 5)
368
- .map(([name, count]) => `• ${name}: ${count.toLocaleString()} calls`)
369
- .join("\n") || "None"}
321
+ **TOP FUNCTIONS**
322
+ ${Object.entries(functionCallCounts).sort(([, a], [, b]) => b - a).slice(0, 5).map(([n, c]) => ` ${n}: ${c.toLocaleString()} calls`).join("\n") || " None"}
370
323
 
371
- **BOTTLENECKS** (${result.bottlenecks.length} detected)
372
- ${result.bottlenecks.slice(0, 5).map(b => `• 🚧 ${b}`).join("\n") || "None detected"}
324
+ **BOTTLENECKS** (${bottlenecks.length})
325
+ ${bottlenecks.slice(0, 5).map(b => ` 🚧 ${b}`).join("\n") || " None"}
373
326
 
374
327
  **RECOMMENDATIONS**
375
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
328
+ ${recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || " None"}
376
329
 
377
- **Status:** ${result.metrics.hotFunctions > 10 ? "❌ HIGH OPTIMIZATION NEEDED" : result.metrics.hotFunctions > 5 ? "⚠️ MODERATE OPTIMIZATION NEEDED" : "✅ PERFORMANCE ACCEPTABLE"}`;
330
+ **Status** ${metrics.hotFunctions > 10 ? "❌ HIGH OPTIMIZATION NEEDED" : metrics.hotFunctions > 5 ? "⚠️ MODERATE OPTIMIZATION NEEDED" : "✅ ACCEPTABLE"}`;
378
331
  }
379
332
  async handleAnalyzeMemory(args) {
380
333
  const { projectRoot, heapSnapshot = true, gcAnalysis = true, leakDetection = true } = args;
@@ -505,14 +458,14 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
505
458
  return allocations;
506
459
  }
507
460
  analyzeGCActivity(heapUsedMB) {
461
+ const count = Math.min(Math.floor(heapUsedMB / 100), 5);
508
462
  const events = [];
509
- const eventCount = Math.floor(heapUsedMB / 50);
510
- for (let i = 0; i < Math.min(eventCount, 10); i++) {
463
+ for (let i = 0; i < count; i++) {
511
464
  events.push({
512
- type: heapUsedMB > 200 ? (i % 3 === 0 ? "major" : "minor") : "minor",
513
- duration: Math.round(Math.random() * 10 + 2),
514
- timestamp: Date.now() - (eventCount - i) * 60000,
515
- reclaimedBytes: Math.round(Math.random() * 1024 * 1024 * 10)
465
+ type: heapUsedMB > 200 && i % 3 === 0 ? "major" : "minor",
466
+ duration: 3 + i * 2,
467
+ timestamp: Date.now() - (count - i) * 60000,
468
+ reclaimedBytes: 512 * 1024
516
469
  });
517
470
  }
518
471
  return events;
@@ -655,41 +608,25 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
655
608
  }
656
609
  }
657
610
  formatMemoryAnalysis(result) {
658
- return `🧠 Memory Analysis Results
611
+ const { heapUsed, heapTotal, external, rss, memoryLeaks, gcEvents, heapBreakdown, allocationsByType, recommendations } = result;
612
+ return `🧠 Memory Analysis
659
613
 
660
- **HEAP USAGE**
661
- - Heap Used: ${result.heapUsed}MB
662
- - Heap Total: ${result.heapTotal}MB
663
- - External: ${result.external}MB
664
- - RSS: ${result.rss}MB
665
- - Usage: ${((result.heapUsed / result.heapTotal) * 100).toFixed(1)}%
614
+ **HEAP** Used:${heapUsed}MB Total:${heapTotal}MB Ext:${external}MB RSS:${rss}MB (${(heapUsed / heapTotal * 100).toFixed(1)}%)
666
615
 
667
- **HEAP BREAKDOWN**
668
- - Strings: ${(result.heapBreakdown.strings / 1024).toFixed(1)}KB
669
- - Arrays: ${(result.heapBreakdown.arrays / 1024).toFixed(1)}KB
670
- - Objects: ${(result.heapBreakdown.objects / 1024).toFixed(1)}KB
671
- - Functions: ${(result.heapBreakdown.functions / 1024).toFixed(1)}KB
672
- - Closures: ${(result.heapBreakdown.closures / 1024).toFixed(1)}KB
616
+ **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
673
617
 
674
- **MEMORY LEAKS** (${result.memoryLeaks.length} detected)
675
- ${result.memoryLeaks.slice(0, 5).map(leak => `• ${leak.severity === "critical" || leak.severity === "high" ? "🔴" : "🟡"} ${leak.location}\n Cause: ${leak.suspectedCause}\n Fix: ${leak.fixSuggestion}`).join("\n\n") || "None detected"}
618
+ **LEAKS** (${memoryLeaks.length})
619
+ ${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"}
676
620
 
677
- **GC ACTIVITY** (${result.gcEvents.length} events)
678
- - Minor GC: ${result.gcEvents.filter(e => e.type === "minor").length}
679
- - Major GC: ${result.gcEvents.filter(e => e.type === "major").length}
680
- - Full GC: ${result.gcEvents.filter(e => e.type === "full").length}
621
+ **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}
681
622
 
682
- **ALLOCATIONS BY TYPE**
683
- ${Object.entries(result.allocationsByType)
684
- .sort(([, a], [, b]) => b - a)
685
- .slice(0, 5)
686
- .map(([type, count]) => `• ${type}: ${count.toLocaleString()}`)
687
- .join("\n")}
623
+ **ALLOCATIONS**
624
+ ${Object.entries(allocationsByType).sort(([, a], [, b]) => b - a).slice(0, 5).map(([t, c]) => ` ${t}: ${c.toLocaleString()}`).join("\n")}
688
625
 
689
626
  **RECOMMENDATIONS**
690
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
627
+ ${recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || " None"}
691
628
 
692
- **Status:** ${result.memoryLeaks.some(l => l.severity === "critical" || l.severity === "high") ? "❌ CRITICAL MEMORY ISSUES" : result.memoryLeaks.length > 3 ? "⚠️ MEMORY OPTIMIZATION NEEDED" : "✅ MEMORY HEALTH ACCEPTABLE"}`;
629
+ **Status** ${memoryLeaks.some(l => l.severity === "critical" || l.severity === "high") ? "❌ CRITICAL" : memoryLeaks.length > 3 ? "⚠️ OPTIMIZATION NEEDED" : "✅ HEALTHY"}`;
693
630
  }
694
631
  async handleBenchmarkCode(args) {
695
632
  const { projectRoot, testFile, iterations = 100, warmupRuns = 10, compareBaseline = false } = args;
@@ -781,17 +718,10 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
781
718
  };
782
719
  }
783
720
  simulateBenchmarkWorkload(filePath) {
784
- const fileSize = fs.existsSync(filePath) ? fs.statSync(filePath).size : 1000;
785
- const iterations = Math.max(10, Math.floor(fileSize / 100));
786
- let result = 0;
787
- for (let i = 0; i < iterations; i++) {
788
- result += Math.sqrt(i) * Math.log(i + 1);
789
- }
790
- const arr = new Array(100).fill(0).map((_, i) => i * 2);
791
- arr.sort((a, b) => b - a);
792
- const obj = { a: 1, b: 2, c: 3, d: 4 };
793
- const serialized = JSON.stringify(obj);
794
- JSON.parse(serialized);
721
+ // Stub: synthetic math workload for benchmarking
722
+ const iterations = Math.max(10, Math.min(100, Math.floor((fs.existsSync(filePath) ? fs.statSync(filePath).size : 1000) / 100)));
723
+ for (let i = 0; i < iterations; i++)
724
+ Math.sqrt(i) * Math.log(i + 1);
795
725
  }
796
726
  calculateVariance(values) {
797
727
  if (values.length === 0)
@@ -816,40 +746,20 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
816
746
  return recommendations;
817
747
  }
818
748
  formatBenchmarkResult(result) {
819
- let text = `⚡ Benchmark Results (${result.benchmarks.length} benchmarks)
749
+ const { benchmarks, comparison, statistics, recommendations } = result;
750
+ let text = `⚡ Benchmark Results (${benchmarks.length} benchmarks)
820
751
 
821
- **STATISTICS**
822
- - Total Benchmarks: ${result.statistics.totalBenchmarks}
823
- - Fastest: ${result.statistics.fastest}
824
- - Slowest: ${result.statistics.slowest}
825
- - Average Ops/Sec: ${result.statistics.averageOpsPerSecond.toLocaleString()}
826
- - Variance: ${result.statistics.variance.toFixed(2)}
752
+ **STATS** Total:${statistics.totalBenchmarks} Fastest:${statistics.fastest} Slowest:${statistics.slowest} Avg:${statistics.averageOpsPerSecond.toLocaleString()} ops/s Var:${statistics.variance.toFixed(2)}
827
753
 
828
- **BENCHMARK DETAILS**
829
- `;
830
- for (const benchmark of result.benchmarks) {
831
- text += `
832
- 📊 ${benchmark.name}
833
- - Ops/sec: ${benchmark.opsPerSecond.toLocaleString()}
834
- - Mean: ${benchmark.meanMs}ms | Median: ${benchmark.medianMs}ms
835
- - Min: ${benchmark.minMs}ms | Max: ${benchmark.maxMs}ms
836
- - P95: ${benchmark.p95Ms}ms | P99: ${benchmark.p99Ms}ms
837
- - Std Dev: ${benchmark.stdDevMs}ms
754
+ **DETAILS**
838
755
  `;
756
+ for (const b of benchmarks) {
757
+ 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`;
839
758
  }
840
- if (result.comparison) {
841
- const c = result.comparison;
842
- const direction = c.improvement > 0 ? "📈" : "📉";
843
- text += `
844
- **COMPARISON vs BASELINE**
845
- ${direction} Change: ${c.improvement > 0 ? "+" : ""}${c.improvement.toFixed(1)}%
846
- ${c.significant ? "⚠️" : "✓"} Statistically Significant: ${c.significant ? "Yes" : "No"}
847
- `;
759
+ if (comparison) {
760
+ text += `**vs BASELINE** ${comparison.improvement > 0 ? "📈" : "📉"} ${comparison.improvement > 0 ? "+" : ""}${comparison.improvement.toFixed(1)}% ${comparison.significant ? "⚠️ Significant" : "✓ Not significant"}\n`;
848
761
  }
849
- text += `
850
- **RECOMMENDATIONS**
851
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
852
- `;
762
+ text += `**RECOMMENDATIONS**\n${recommendations.slice(0, 5).map((r, i) => ` ${i + 1}. ${r}`).join("\n") || " None"}\n`;
853
763
  return text;
854
764
  }
855
765
  async handleSuggestOptimizations(args) {
@@ -1090,32 +1000,22 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
1090
1000
  }
1091
1001
  formatOptimizationSuggestions(suggestions) {
1092
1002
  const byCategory = suggestions.reduce((acc, s) => {
1093
- if (!acc[s.category])
1094
- acc[s.category] = [];
1095
- acc[s.category].push(s);
1003
+ (acc[s.category] ??= []).push(s);
1096
1004
  return acc;
1097
1005
  }, {});
1098
- let text = `💡 Performance Optimization Suggestions (${suggestions.length} found)
1006
+ const critical = suggestions.filter(s => s.impact === "critical").length;
1007
+ const high = suggestions.filter(s => s.impact === "high").length;
1008
+ const medium = suggestions.filter(s => s.impact === "medium").length;
1009
+ const low = suggestions.filter(s => s.impact === "low").length;
1010
+ let text = `💡 Optimization Suggestions (${suggestions.length})
1099
1011
 
1100
- **SUMMARY BY IMPACT**
1101
- - Critical: ${suggestions.filter(s => s.impact === "critical").length}
1102
- - High: ${suggestions.filter(s => s.impact === "high").length}
1103
- - Medium: ${suggestions.filter(s => s.impact === "medium").length}
1104
- - Low: ${suggestions.filter(s => s.impact === "low").length}
1012
+ **IMPACT** Crit:${critical} High:${high} Med:${medium} Low:${low}
1105
1013
  `;
1106
1014
  for (const [category, items] of Object.entries(byCategory)) {
1107
- text += `\n## ${category.toUpperCase()} Optimizations (${items.length})\n`;
1108
- for (const suggestion of items.slice(0, 5)) {
1109
- const icon = suggestion.impact === "critical" ? "🔴" :
1110
- suggestion.impact === "high" ? "🟠" :
1111
- suggestion.impact === "medium" ? "🟡" : "🟢";
1112
- text += `
1113
- ${icon} **${suggestion.title}** (${suggestion.impact} impact, ${suggestion.effort} effort)
1114
- ${suggestion.description}
1115
- 📁 Files: ${suggestion.files.join(", ")}
1116
- 💡 Fix: ${suggestion.suggestedFix}
1117
- 📈 Expected: ${suggestion.expectedImprovement}
1118
- `;
1015
+ text += `\n## ${category.toUpperCase()} (${items.length})\n`;
1016
+ for (const s of items.slice(0, 5)) {
1017
+ const icon = s.impact === "critical" ? "🔴" : s.impact === "high" ? "🟠" : s.impact === "medium" ? "🟡" : "🟢";
1018
+ text += `${icon} ${s.title} (${s.impact}, ${s.effort})\n ${s.description} | Fix: ${s.suggestedFix}\n`;
1119
1019
  }
1120
1020
  }
1121
1021
  return text;
@@ -1471,58 +1371,28 @@ ${icon} **${suggestion.title}** (${suggestion.impact} impact, ${suggestion.effor
1471
1371
  }
1472
1372
  }
1473
1373
  formatCoreWebVitalsResult(result) {
1474
- const statusIcon = result.status === "good" ? "✅" :
1475
- result.status === "needs-improvement" ? "⚠️" : "❌";
1476
- let text = `${statusIcon} Core Web Vitals Analysis
1477
-
1478
- **OVERALL SCORE:** ${result.score}/100 (${result.status.toUpperCase()})
1479
- `;
1374
+ const statusIcon = result.status === "good" ? "✅" : result.status === "needs-improvement" ? "⚠️" : "❌";
1375
+ let text = `${statusIcon} Core Web Vitals — ${result.score}/100 (${result.status.toUpperCase()})\n`;
1480
1376
  if (result.bundleAnalysis) {
1481
- const bundle = result.bundleAnalysis;
1482
- text += `
1483
- **BUNDLE ANALYSIS**
1484
- - Total Size: ${(bundle.totalSize / 1024 / 1024).toFixed(2)}MB
1485
- - Gzipped Size: ${(bundle.gzippedSize / 1024 / 1024).toFixed(2)}MB
1486
- - Largest Modules: ${bundle.largestModules.slice(0, 3).map(m => `${m.name} (${m.size}KB)`).join(", ") || "None"}
1487
- `;
1377
+ const b = result.bundleAnalysis;
1378
+ text += `**BUNDLE** ${(b.totalSize / 1024 / 1024).toFixed(2)}MB (gz:${(b.gzippedSize / 1024 / 1024).toFixed(2)}MB)\n`;
1379
+ const top = b.largestModules.slice(0, 3).map(m => `${m.name} (${m.size}KB)`).join(", ");
1380
+ if (top)
1381
+ text += ` Largest: ${top}\n`;
1488
1382
  }
1489
1383
  if (result.LCP) {
1490
- const lcp = result.LCP;
1491
- const lcpStatus = lcp.value <= 2500 ? "✅" : lcp.value <= 4000 ? "⚠️" : "❌";
1492
- text += `
1493
- **LCP (Largest Contentful Paint)** ${lcpStatus}
1494
- - Value: ${(lcp.value / 1000).toFixed(2)}s
1495
- - Score: ${lcp.score}/100
1496
- - Resource Load: ${(lcp.resourceLoadTime / 1000).toFixed(2)}s
1497
- - Render Delay: ${(lcp.renderDelay / 1000).toFixed(2)}s
1498
- `;
1384
+ const l = result.LCP;
1385
+ 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`;
1499
1386
  }
1500
1387
  if (result.INP) {
1501
- const inp = result.INP;
1502
- const inpStatus = inp.value <= 200 ? "✅" : inp.value <= 500 ? "⚠️" : "❌";
1503
- text += `
1504
- **INP (Interaction to Next Paint)** ${inpStatus}
1505
- - Value: ${inp.value}ms
1506
- - Score: ${inp.score}/100
1507
- - Processing Time: ${inp.processingTime}ms
1508
- - Presentation Delay: ${inp.presentationDelay}ms
1509
- `;
1388
+ const i = result.INP;
1389
+ text += `**INP** ${i.value <= 200 ? "✅" : i.value <= 500 ? "⚠️" : "❌"} ${i.value}ms (score:${i.score}/100 proc:${i.processingTime}ms delay:${i.presentationDelay}ms)\n`;
1510
1390
  }
1511
1391
  if (result.CLS) {
1512
- const cls = result.CLS;
1513
- const clsStatus = cls.value <= 0.1 ? "✅" : cls.value <= 0.25 ? "⚠️" : "❌";
1514
- text += `
1515
- **CLS (Cumulative Layout Shift)** ${clsStatus}
1516
- - Value: ${cls.value}
1517
- - Score: ${cls.score}/100
1518
- - Layout Shifts: ${cls.layoutShifts}
1519
- - Sources: ${cls.sources.slice(0, 3).join(", ") || "None"}
1520
- `;
1392
+ const c = result.CLS;
1393
+ 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`;
1521
1394
  }
1522
- text += `
1523
- **RECOMMENDATIONS**
1524
- ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || "No specific recommendations"}
1525
- `;
1395
+ text += `**RECOMMENDATIONS**\n${result.recommendations.slice(0, 5).map((r, i) => ` ${i + 1}. ${r}`).join("\n") || " None"}\n`;
1526
1396
  return text;
1527
1397
  }
1528
1398
  findCodeFiles(projectRoot, maxDepth = 10) {
@@ -1566,21 +1436,10 @@ ${result.recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n")
1566
1436
  }
1567
1437
  return files.slice(0, 100);
1568
1438
  }
1569
- async run() {
1570
- const transport = new StdioServerTransport();
1571
- await this.server.connect(transport);
1572
- createGracefulShutdown({
1573
- serverName: "performance-optimization.server",
1574
- server: this.server,
1575
- });
1576
- frameworkLogger.log("mcp/performance-optimization", "server-started", "info", {
1577
- uptime: Date.now() - this.startTime
1578
- });
1579
- }
1580
1439
  }
1581
1440
  if (import.meta.url === `file://${process.argv[1]}`) {
1582
1441
  const server = new XrayPerformanceOptimizationServer();
1583
- server.run().catch((error) => {
1442
+ server.run("performance-optimization.server").catch((error) => {
1584
1443
  frameworkLogger.log("mcp/performance-optimization", "run", "error", { error: String(error) });
1585
1444
  });
1586
1445
  }
@@ -4,10 +4,9 @@
4
4
  * Knowledge skill for project structure analysis, complexity assessment,
5
5
  * and pattern recognition - provides deep project intelligence
6
6
  */
7
- declare class ProjectAnalysisServer {
8
- private server;
7
+ import { XrayKnowledgeSkillBase } from "../shared/knowledge-skill-base.js";
8
+ declare class ProjectAnalysisServer extends XrayKnowledgeSkillBase {
9
9
  constructor();
10
- private setupToolHandlers;
11
10
  private analyzeProjectStructure;
12
11
  private assessProjectComplexity;
13
12
  private identifyProjectPatterns;
@@ -32,6 +31,5 @@ declare class ProjectAnalysisServer {
32
31
  * Governance proposal analysis from a research / codebase pattern perspective.
33
32
  */
34
33
  private analyzeProposal;
35
- run(): Promise<void>;
36
34
  }
37
35
  export default ProjectAnalysisServer;