0xray 2.1.2 → 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.
- package/.opencode/codex.codex +1 -1
- package/.opencode/commands/dependency-audit.md +3 -3
- package/.opencode/enforcer-config.json +2 -2
- package/AGENTS.md +2 -1
- package/README.md +12 -11
- package/dist/AGENTS.md +2 -1
- package/dist/CHANGELOG.md +26 -0
- package/dist/README.md +12 -11
- package/dist/agents/code-reviewer.js +1 -1
- package/dist/analytics/routing-refiner.js +1 -1
- package/dist/cli/index.js +11 -1
- package/dist/cli/server.js +3 -3
- package/dist/core/activity-logger.d.ts +2 -2
- package/dist/core/activity-logger.js +4 -4
- package/dist/core/boot-orchestrator.d.ts +1 -1
- package/dist/core/boot-orchestrator.js +13 -28
- package/dist/core/bridge.mjs +3 -3
- package/dist/core/codex-formatter.js +2 -2
- package/dist/core/codex-injector.d.ts +0 -1
- package/dist/core/codex-injector.js +2 -3
- package/dist/core/config-loader.d.ts +1 -1
- package/dist/core/config-loader.js +1 -1
- package/dist/core/config-paths.d.ts +0 -2
- package/dist/core/config-paths.js +7 -8
- package/dist/core/context-loader.d.ts +1 -1
- package/dist/core/context-loader.js +1 -1
- package/dist/core/errors.d.ts +3 -0
- package/dist/core/errors.js +10 -0
- package/dist/core/features-config.js +1 -1
- package/dist/core/framework-logger.d.ts +3 -3
- package/dist/core/framework-logger.js +17 -9
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +4 -2
- package/dist/core/logging-config.d.ts +2 -1
- package/dist/core/logging-config.js +7 -7
- package/dist/enforcement/loaders/codex-loader.js +1 -1
- package/dist/execution/opencode-cli-invoker.js +5 -5
- package/dist/governance/governance-service.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/inference/inference-cycle.d.ts +1 -1
- package/dist/inference/inference-cycle.js +10 -10
- package/dist/integrations/base/Integration.js +1 -1
- package/dist/integrations/base/registry.js +19 -19
- package/dist/integrations/grok/grok-cli.js +17 -17
- package/dist/integrations/grok/hooks/pre-tool-use.js +1 -1
- package/dist/integrations/hermes-agent/bridge.mjs +1 -1
- package/dist/integrations/openclaw/api-server.d.ts +0 -1
- package/dist/integrations/openclaw/api-server.js +7 -10
- package/dist/integrations/openclaw/client.d.ts +0 -1
- package/dist/integrations/openclaw/client.js +22 -24
- package/dist/integrations/openclaw/hooks/xray-hooks.d.ts +0 -1
- package/dist/integrations/openclaw/hooks/xray-hooks.js +17 -18
- package/dist/integrations/plugins/plugin-registry.js +5 -5
- package/dist/mcps/architect-tools.server.d.ts +2 -4
- package/dist/mcps/architect-tools.server.js +112 -195
- package/dist/mcps/auto-format.server.d.ts +2 -4
- package/dist/mcps/auto-format.server.js +49 -95
- package/dist/mcps/boot-orchestrator.server.d.ts +2 -4
- package/dist/mcps/boot-orchestrator.server.js +73 -105
- package/dist/mcps/config/server-config-registry.js +3 -3
- package/dist/mcps/enforcer-tools.server.d.ts +2 -4
- package/dist/mcps/enforcer-tools.server.js +202 -285
- package/dist/mcps/estimation.server.d.ts +2 -4
- package/dist/mcps/estimation.server.js +63 -107
- package/dist/mcps/framework-compliance-audit.server.d.ts +2 -4
- package/dist/mcps/framework-compliance-audit.server.js +53 -82
- package/dist/mcps/framework-help.server.d.ts +2 -4
- package/dist/mcps/framework-help.server.js +63 -101
- package/dist/mcps/governance.server.js +2 -2
- package/dist/mcps/knowledge-skills/api-design.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/api-design.server.js +35 -67
- package/dist/mcps/knowledge-skills/architecture-patterns.server.d.ts +2 -10
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js +35 -74
- package/dist/mcps/knowledge-skills/bug-triage-specialist.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +143 -162
- package/dist/mcps/knowledge-skills/code-analyzer.server.d.ts +3 -4
- package/dist/mcps/knowledge-skills/code-analyzer.server.js +20 -45
- package/dist/mcps/knowledge-skills/code-review.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/code-review.server.js +109 -143
- package/dist/mcps/knowledge-skills/content-creator.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/content-creator.server.js +205 -226
- package/dist/mcps/knowledge-skills/database-design.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/database-design.server.js +117 -151
- package/dist/mcps/knowledge-skills/devops-deployment.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/devops-deployment.server.js +71 -160
- package/dist/mcps/knowledge-skills/git-workflow.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/git-workflow.server.js +36 -68
- package/dist/mcps/knowledge-skills/growth-strategist.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/growth-strategist.server.js +303 -324
- package/dist/mcps/knowledge-skills/log-monitor.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/log-monitor.server.js +141 -160
- package/dist/mcps/knowledge-skills/mobile-development.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/mobile-development.server.js +92 -209
- package/dist/mcps/knowledge-skills/multimodal-looker.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/multimodal-looker.server.js +123 -159
- package/dist/mcps/knowledge-skills/performance-optimization.server.d.ts +2 -5
- package/dist/mcps/knowledge-skills/performance-optimization.server.js +155 -296
- package/dist/mcps/knowledge-skills/project-analysis.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/project-analysis.server.js +75 -226
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +63 -156
- package/dist/mcps/knowledge-skills/security-audit.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/security-audit.server.js +102 -136
- package/dist/mcps/knowledge-skills/seo-consultant.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/seo-consultant.server.js +80 -203
- package/dist/mcps/knowledge-skills/session-management.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/session-management.server.js +50 -203
- package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/skill-invocation.server.js +168 -347
- package/dist/mcps/knowledge-skills/strategist.server.d.ts +2 -11
- package/dist/mcps/knowledge-skills/strategist.server.js +72 -122
- package/dist/mcps/knowledge-skills/tech-writer.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/tech-writer.server.js +87 -300
- package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js +147 -182
- package/dist/mcps/knowledge-skills/testing-strategy.server.d.ts +2 -4
- package/dist/mcps/knowledge-skills/testing-strategy.server.js +78 -153
- package/dist/mcps/knowledge-skills/ui-ux-design.server.d.ts +2 -5
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js +90 -399
- package/dist/mcps/lint.server.d.ts +2 -4
- package/dist/mcps/lint.server.js +51 -92
- package/dist/mcps/mcp-client.js +2 -2
- package/dist/mcps/model-health-check.server.d.ts +2 -4
- package/dist/mcps/model-health-check.server.js +32 -60
- package/dist/mcps/performance-analysis.server.d.ts +2 -4
- package/dist/mcps/performance-analysis.server.js +57 -88
- package/dist/mcps/processor-pipeline.server.d.ts +2 -4
- package/dist/mcps/processor-pipeline.server.js +69 -100
- package/dist/mcps/registry.json +1 -1
- package/dist/mcps/researcher.server.d.ts +3 -5
- package/dist/mcps/researcher.server.js +81 -154
- package/dist/mcps/security-scan.server.d.ts +2 -4
- package/dist/mcps/security-scan.server.js +54 -96
- package/dist/mcps/shared/knowledge-skill-base.d.ts +14 -0
- package/dist/mcps/shared/knowledge-skill-base.js +45 -0
- package/dist/{security → mcps/shared}/security-scanner.js +1 -1
- package/dist/mcps/state-manager.server.d.ts +2 -4
- package/dist/mcps/state-manager.server.js +115 -160
- package/dist/orchestrator/orchestrator.d.ts +1 -1
- package/dist/orchestrator/orchestrator.js +1 -1
- package/dist/orchestrator/universal-registry-bridge.js +1 -1
- package/dist/plugin/xray-codex-injection.d.ts +1 -1
- package/dist/plugin/xray-codex-injection.js +1 -1
- package/dist/postprocessor/PostProcessor.d.ts +4 -44
- package/dist/postprocessor/PostProcessor.js +39 -553
- package/dist/postprocessor/analysis/CodeChangeAnalyzer.d.ts +11 -0
- package/dist/postprocessor/analysis/CodeChangeAnalyzer.js +50 -0
- package/dist/postprocessor/compliance/ArchitecturalComplianceChecker.d.ts +11 -0
- package/dist/postprocessor/compliance/ArchitecturalComplianceChecker.js +356 -0
- package/dist/postprocessor/config/ProcessorConfigLoader.d.ts +44 -0
- package/dist/postprocessor/config/ProcessorConfigLoader.js +21 -0
- package/dist/postprocessor/reporting/PostProcessorReporter.d.ts +19 -0
- package/dist/postprocessor/reporting/PostProcessorReporter.js +96 -0
- package/dist/postprocessor/triggers/GitHookTrigger.js +11 -11
- package/dist/processors/implementations/refactoring-logging-processor-wrapper.d.ts +32 -0
- package/dist/processors/implementations/refactoring-logging-processor-wrapper.js +95 -1
- package/dist/processors/processor-manager.js +346 -314
- package/dist/reporting/report-formatter.js +1 -1
- package/dist/security/security-hardener.d.ts +69 -2
- package/dist/security/security-hardener.js +129 -1
- package/dist/skills/registry.json +1 -1
- package/dist/state/index.d.ts +3 -5
- package/dist/state/index.js +1 -7
- package/dist/state/state-manager.d.ts +1 -1
- package/dist/state/state-manager.js +2 -3
- package/package.json +13 -10
- package/scripts/node/universal-version-manager.js +11 -11
- package/src/mcps/architect-tools.server.ts +112 -215
- package/src/mcps/auto-format.server.ts +50 -110
- package/src/mcps/boot-orchestrator.server.ts +75 -121
- package/src/mcps/config/__tests__/server-config-registry.test.ts +21 -12
- package/src/mcps/config/server-config-registry.ts +3 -3
- package/src/mcps/enforcer-tools.server.ts +212 -310
- package/src/mcps/estimation.server.ts +62 -122
- package/src/mcps/framework-compliance-audit.server.ts +52 -97
- package/src/mcps/framework-help.server.ts +64 -114
- package/src/mcps/governance.server.ts +2 -2
- package/src/mcps/knowledge-skills/api-design.server.ts +32 -77
- package/src/mcps/knowledge-skills/architecture-patterns.server.ts +31 -87
- package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +165 -193
- package/src/mcps/knowledge-skills/code-analyzer.server.ts +20 -55
- package/src/mcps/knowledge-skills/code-review.server.ts +114 -161
- package/src/mcps/knowledge-skills/content-creator.server.ts +218 -255
- package/src/mcps/knowledge-skills/database-design.server.ts +118 -165
- package/src/mcps/knowledge-skills/devops-deployment.server.ts +67 -172
- package/src/mcps/knowledge-skills/git-workflow.server.ts +32 -77
- package/src/mcps/knowledge-skills/growth-strategist.server.ts +324 -361
- package/src/mcps/knowledge-skills/log-monitor.server.ts +160 -187
- package/src/mcps/knowledge-skills/mobile-development.server.ts +89 -223
- package/src/mcps/knowledge-skills/multimodal-looker.server.ts +128 -175
- package/src/mcps/knowledge-skills/performance-optimization.server.ts +156 -329
- package/src/mcps/knowledge-skills/project-analysis.server.ts +72 -248
- package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +59 -171
- package/src/mcps/knowledge-skills/security-audit.server.ts +104 -151
- package/src/mcps/knowledge-skills/seo-consultant.server.ts +80 -220
- package/src/mcps/knowledge-skills/session-management.server.ts +51 -232
- package/src/mcps/knowledge-skills/skill-invocation.server.ts +165 -372
- package/src/mcps/knowledge-skills/strategist.server.ts +72 -143
- package/src/mcps/knowledge-skills/tech-writer.server.ts +85 -350
- package/src/mcps/knowledge-skills/testing-best-practices.server.ts +146 -195
- package/src/mcps/knowledge-skills/testing-strategy.server.ts +75 -161
- package/src/mcps/knowledge-skills/ui-ux-design.server.ts +93 -487
- package/src/mcps/lint.server.ts +53 -107
- package/src/mcps/mcp-client.ts +2 -2
- package/src/mcps/model-health-check.server.ts +34 -71
- package/src/mcps/performance-analysis.server.ts +60 -104
- package/src/mcps/processor-pipeline.server.ts +72 -110
- package/src/mcps/registry.json +1 -1
- package/src/mcps/researcher.server.ts +88 -177
- package/src/mcps/security-scan.server.ts +55 -104
- package/src/mcps/shared/knowledge-skill-base.ts +62 -0
- package/src/mcps/shared/prompt-security-validator.ts +199 -0
- package/src/mcps/shared/security-scanner.ts +599 -0
- package/src/mcps/state-manager.server.ts +117 -175
- package/src/opencode/codex.codex +1 -1
- package/src/opencode/commands/dependency-audit.md +3 -3
- package/src/opencode/enforcer-config.json +2 -2
- package/src/skills/registry.json +1 -1
- package/xray/codex.json +1 -1
- package/xray/config.json +1 -1
- package/xray/features.json +1 -1
- package/xray/integrations.json +3 -3
- package/dist/integrations/hermes-agent/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/conftest.cpython-313-pytest-9.0.2.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/schemas.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313-pytest-9.0.2.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/tools.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/conftest.py +0 -14
- package/dist/integrations/hermes-agent/test_plugin.py +0 -1103
- package/dist/processors/implementations/refactoring-logging-processor.d.ts +0 -31
- package/dist/processors/implementations/refactoring-logging-processor.js +0 -96
- package/dist/processors/implementations/session-capture-processor.d.ts +0 -14
- package/dist/processors/implementations/session-capture-processor.js +0 -37
- package/dist/scripts/activate-kernel-pipeline.d.ts +0 -7
- package/dist/scripts/activate-kernel-pipeline.js +0 -101
- package/dist/security/index.d.ts +0 -13
- package/dist/security/index.js +0 -13
- package/dist/security/security-agent-coordinator.d.ts +0 -72
- package/dist/security/security-agent-coordinator.js +0 -204
- package/dist/security/security-auditor.d.ts +0 -56
- package/dist/security/security-auditor.js +0 -584
- package/dist/security/security-hardening-system.d.ts +0 -239
- package/dist/security/security-hardening-system.js +0 -727
- package/dist/security/security-orchestration-layer.d.ts +0 -119
- package/dist/security/security-orchestration-layer.js +0 -496
- /package/dist/{security → mcps/shared}/prompt-security-validator.d.ts +0 -0
- /package/dist/{security → mcps/shared}/prompt-security-validator.js +0 -0
- /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 {
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
313
|
+
const { metrics, hotPaths, functionCallCounts, bottlenecks, recommendations } = result;
|
|
314
|
+
return `📊 Performance Profiling
|
|
353
315
|
|
|
354
|
-
**
|
|
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** (${
|
|
362
|
-
${
|
|
318
|
+
**HOT PATHS** (${hotPaths.length})
|
|
319
|
+
${hotPaths.slice(0, 10).map(p => ` 🔥 ${p}`).join("\n") || " None"}
|
|
363
320
|
|
|
364
|
-
**TOP FUNCTIONS
|
|
365
|
-
${Object.entries(
|
|
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** (${
|
|
372
|
-
${
|
|
324
|
+
**BOTTLENECKS** (${bottlenecks.length})
|
|
325
|
+
${bottlenecks.slice(0, 5).map(b => ` 🚧 ${b}`).join("\n") || " None"}
|
|
373
326
|
|
|
374
327
|
**RECOMMENDATIONS**
|
|
375
|
-
${
|
|
328
|
+
${recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || " None"}
|
|
376
329
|
|
|
377
|
-
**Status
|
|
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
|
-
|
|
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
|
|
513
|
-
duration:
|
|
514
|
-
timestamp: Date.now() - (
|
|
515
|
-
reclaimedBytes:
|
|
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
|
-
|
|
611
|
+
const { heapUsed, heapTotal, external, rss, memoryLeaks, gcEvents, heapBreakdown, allocationsByType, recommendations } = result;
|
|
612
|
+
return `🧠 Memory Analysis
|
|
659
613
|
|
|
660
|
-
**HEAP
|
|
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
|
-
**
|
|
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
|
-
**
|
|
675
|
-
${
|
|
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
|
|
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
|
|
683
|
-
${Object.entries(
|
|
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
|
-
${
|
|
627
|
+
${recommendations.slice(0, 5).map((r, i) => `${i + 1}. ${r}`).join("\n") || " None"}
|
|
691
628
|
|
|
692
|
-
**Status
|
|
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
|
-
|
|
785
|
-
const iterations = Math.max(10, Math.floor(
|
|
786
|
-
let
|
|
787
|
-
|
|
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
|
-
|
|
749
|
+
const { benchmarks, comparison, statistics, recommendations } = result;
|
|
750
|
+
let text = `⚡ Benchmark Results (${benchmarks.length} benchmarks)
|
|
820
751
|
|
|
821
|
-
**
|
|
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
|
-
**
|
|
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 (
|
|
841
|
-
|
|
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
|
-
|
|
1094
|
-
acc[s.category] = [];
|
|
1095
|
-
acc[s.category].push(s);
|
|
1003
|
+
(acc[s.category] ??= []).push(s);
|
|
1096
1004
|
return acc;
|
|
1097
1005
|
}, {});
|
|
1098
|
-
|
|
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
|
-
**
|
|
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()}
|
|
1108
|
-
for (const
|
|
1109
|
-
const icon =
|
|
1110
|
-
|
|
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
|
-
|
|
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
|
|
1482
|
-
text +=
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
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
|
|
1491
|
-
|
|
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
|
|
1502
|
-
|
|
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
|
|
1513
|
-
|
|
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
|
-
|
|
8
|
-
|
|
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;
|