perfgraph 0.1.0
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/LICENSE +21 -0
- package/README.md +280 -0
- package/dist/causal/builder.d.ts +34 -0
- package/dist/causal/builder.d.ts.map +1 -0
- package/dist/causal/builder.js +132 -0
- package/dist/causal/builder.js.map +1 -0
- package/dist/causal/index.d.ts +11 -0
- package/dist/causal/index.d.ts.map +1 -0
- package/dist/causal/index.js +10 -0
- package/dist/causal/index.js.map +1 -0
- package/dist/causal/rules/js.d.ts +49 -0
- package/dist/causal/rules/js.d.ts.map +1 -0
- package/dist/causal/rules/js.js +209 -0
- package/dist/causal/rules/js.js.map +1 -0
- package/dist/causal/rules/layout.d.ts +39 -0
- package/dist/causal/rules/layout.d.ts.map +1 -0
- package/dist/causal/rules/layout.js +169 -0
- package/dist/causal/rules/layout.js.map +1 -0
- package/dist/causal/rules/lcp.d.ts +49 -0
- package/dist/causal/rules/lcp.d.ts.map +1 -0
- package/dist/causal/rules/lcp.js +250 -0
- package/dist/causal/rules/lcp.js.map +1 -0
- package/dist/causal/rules/network.d.ts +39 -0
- package/dist/causal/rules/network.d.ts.map +1 -0
- package/dist/causal/rules/network.js +140 -0
- package/dist/causal/rules/network.js.map +1 -0
- package/dist/causal/types.d.ts +142 -0
- package/dist/causal/types.d.ts.map +1 -0
- package/dist/causal/types.js +88 -0
- package/dist/causal/types.js.map +1 -0
- package/dist/cli/analyze.d.ts +33 -0
- package/dist/cli/analyze.d.ts.map +1 -0
- package/dist/cli/analyze.js +137 -0
- package/dist/cli/analyze.js.map +1 -0
- package/dist/cli/collect.d.ts +28 -0
- package/dist/cli/collect.d.ts.map +1 -0
- package/dist/cli/collect.js +125 -0
- package/dist/cli/collect.js.map +1 -0
- package/dist/cli/extract.d.ts +31 -0
- package/dist/cli/extract.d.ts.map +1 -0
- package/dist/cli/extract.js +135 -0
- package/dist/cli/extract.js.map +1 -0
- package/dist/cli/mcp.d.ts +14 -0
- package/dist/cli/mcp.d.ts.map +1 -0
- package/dist/cli/mcp.js +53 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/cli/normalize.d.ts +58 -0
- package/dist/cli/normalize.d.ts.map +1 -0
- package/dist/cli/normalize.js +179 -0
- package/dist/cli/normalize.js.map +1 -0
- package/dist/cli/report.d.ts +33 -0
- package/dist/cli/report.d.ts.map +1 -0
- package/dist/cli/report.js +137 -0
- package/dist/cli/report.js.map +1 -0
- package/dist/cli/run.d.ts +49 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +243 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/collect/buffer-monitor.d.ts +25 -0
- package/dist/collect/buffer-monitor.d.ts.map +1 -0
- package/dist/collect/buffer-monitor.js +69 -0
- package/dist/collect/buffer-monitor.js.map +1 -0
- package/dist/collect/console.d.ts +25 -0
- package/dist/collect/console.d.ts.map +1 -0
- package/dist/collect/console.js +82 -0
- package/dist/collect/console.js.map +1 -0
- package/dist/collect/coverage.d.ts +26 -0
- package/dist/collect/coverage.d.ts.map +1 -0
- package/dist/collect/coverage.js +99 -0
- package/dist/collect/coverage.js.map +1 -0
- package/dist/collect/dom.d.ts +37 -0
- package/dist/collect/dom.d.ts.map +1 -0
- package/dist/collect/dom.js +118 -0
- package/dist/collect/dom.js.map +1 -0
- package/dist/collect/lighthouse.d.ts +41 -0
- package/dist/collect/lighthouse.d.ts.map +1 -0
- package/dist/collect/lighthouse.js +111 -0
- package/dist/collect/lighthouse.js.map +1 -0
- package/dist/collect/network.d.ts +32 -0
- package/dist/collect/network.d.ts.map +1 -0
- package/dist/collect/network.js +236 -0
- package/dist/collect/network.js.map +1 -0
- package/dist/collect/orchestrator.d.ts +23 -0
- package/dist/collect/orchestrator.d.ts.map +1 -0
- package/dist/collect/orchestrator.js +350 -0
- package/dist/collect/orchestrator.js.map +1 -0
- package/dist/collect/performance.d.ts +28 -0
- package/dist/collect/performance.d.ts.map +1 -0
- package/dist/collect/performance.js +108 -0
- package/dist/collect/performance.js.map +1 -0
- package/dist/collect/runtime.d.ts +26 -0
- package/dist/collect/runtime.d.ts.map +1 -0
- package/dist/collect/runtime.js +81 -0
- package/dist/collect/runtime.js.map +1 -0
- package/dist/collect/session.d.ts +58 -0
- package/dist/collect/session.d.ts.map +1 -0
- package/dist/collect/session.js +162 -0
- package/dist/collect/session.js.map +1 -0
- package/dist/collect/trace.d.ts +40 -0
- package/dist/collect/trace.d.ts.map +1 -0
- package/dist/collect/trace.js +127 -0
- package/dist/collect/trace.js.map +1 -0
- package/dist/collect/types.d.ts +317 -0
- package/dist/collect/types.d.ts.map +1 -0
- package/dist/collect/types.js +12 -0
- package/dist/collect/types.js.map +1 -0
- package/dist/distill/insights.d.ts +67 -0
- package/dist/distill/insights.d.ts.map +1 -0
- package/dist/distill/insights.js +317 -0
- package/dist/distill/insights.js.map +1 -0
- package/dist/distill/summaries.d.ts +71 -0
- package/dist/distill/summaries.d.ts.map +1 -0
- package/dist/distill/summaries.js +165 -0
- package/dist/distill/summaries.js.map +1 -0
- package/dist/extract/critical-path.d.ts +17 -0
- package/dist/extract/critical-path.d.ts.map +1 -0
- package/dist/extract/critical-path.js +95 -0
- package/dist/extract/critical-path.js.map +1 -0
- package/dist/extract/index.d.ts +16 -0
- package/dist/extract/index.d.ts.map +1 -0
- package/dist/extract/index.js +32 -0
- package/dist/extract/index.js.map +1 -0
- package/dist/extract/js-hotspots.d.ts +15 -0
- package/dist/extract/js-hotspots.d.ts.map +1 -0
- package/dist/extract/js-hotspots.js +22 -0
- package/dist/extract/js-hotspots.js.map +1 -0
- package/dist/extract/layout-shifts.d.ts +19 -0
- package/dist/extract/layout-shifts.d.ts.map +1 -0
- package/dist/extract/layout-shifts.js +47 -0
- package/dist/extract/layout-shifts.js.map +1 -0
- package/dist/extract/lcp-breakdown.d.ts +19 -0
- package/dist/extract/lcp-breakdown.d.ts.map +1 -0
- package/dist/extract/lcp-breakdown.js +110 -0
- package/dist/extract/lcp-breakdown.js.map +1 -0
- package/dist/extract/main-thread.d.ts +16 -0
- package/dist/extract/main-thread.d.ts.map +1 -0
- package/dist/extract/main-thread.js +41 -0
- package/dist/extract/main-thread.js.map +1 -0
- package/dist/extract/render-blocking.d.ts +16 -0
- package/dist/extract/render-blocking.d.ts.map +1 -0
- package/dist/extract/render-blocking.js +79 -0
- package/dist/extract/render-blocking.js.map +1 -0
- package/dist/extract/third-party.d.ts +15 -0
- package/dist/extract/third-party.d.ts.map +1 -0
- package/dist/extract/third-party.js +127 -0
- package/dist/extract/third-party.js.map +1 -0
- package/dist/extract/types.d.ts +183 -0
- package/dist/extract/types.d.ts.map +1 -0
- package/dist/extract/types.js +118 -0
- package/dist/extract/types.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +188 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/handlers.d.ts +72 -0
- package/dist/mcp/handlers.d.ts.map +1 -0
- package/dist/mcp/handlers.js +285 -0
- package/dist/mcp/handlers.js.map +1 -0
- package/dist/mcp/progress.d.ts +37 -0
- package/dist/mcp/progress.d.ts.map +1 -0
- package/dist/mcp/progress.js +51 -0
- package/dist/mcp/progress.js.map +1 -0
- package/dist/mcp/prompts.d.ts +57 -0
- package/dist/mcp/prompts.d.ts.map +1 -0
- package/dist/mcp/prompts.js +225 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +48 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +149 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +34 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +452 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/types.d.ts +47 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +67 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/normalize/clock.d.ts +40 -0
- package/dist/normalize/clock.d.ts.map +1 -0
- package/dist/normalize/clock.js +96 -0
- package/dist/normalize/clock.js.map +1 -0
- package/dist/normalize/dom-ir.d.ts +16 -0
- package/dist/normalize/dom-ir.d.ts.map +1 -0
- package/dist/normalize/dom-ir.js +48 -0
- package/dist/normalize/dom-ir.js.map +1 -0
- package/dist/normalize/index.d.ts +23 -0
- package/dist/normalize/index.d.ts.map +1 -0
- package/dist/normalize/index.js +118 -0
- package/dist/normalize/index.js.map +1 -0
- package/dist/normalize/lighthouse-insights.d.ts +27 -0
- package/dist/normalize/lighthouse-insights.d.ts.map +1 -0
- package/dist/normalize/lighthouse-insights.js +318 -0
- package/dist/normalize/lighthouse-insights.js.map +1 -0
- package/dist/normalize/lighthouse-ir.d.ts +25 -0
- package/dist/normalize/lighthouse-ir.d.ts.map +1 -0
- package/dist/normalize/lighthouse-ir.js +151 -0
- package/dist/normalize/lighthouse-ir.js.map +1 -0
- package/dist/normalize/network-ir.d.ts +23 -0
- package/dist/normalize/network-ir.d.ts.map +1 -0
- package/dist/normalize/network-ir.js +180 -0
- package/dist/normalize/network-ir.js.map +1 -0
- package/dist/normalize/runtime-ir.d.ts +18 -0
- package/dist/normalize/runtime-ir.d.ts.map +1 -0
- package/dist/normalize/runtime-ir.js +114 -0
- package/dist/normalize/runtime-ir.js.map +1 -0
- package/dist/normalize/trace-ir.d.ts +20 -0
- package/dist/normalize/trace-ir.d.ts.map +1 -0
- package/dist/normalize/trace-ir.js +224 -0
- package/dist/normalize/trace-ir.js.map +1 -0
- package/dist/normalize/types.d.ts +536 -0
- package/dist/normalize/types.d.ts.map +1 -0
- package/dist/normalize/types.js +242 -0
- package/dist/normalize/types.js.map +1 -0
- package/dist/output/manifest.d.ts +44 -0
- package/dist/output/manifest.d.ts.map +1 -0
- package/dist/output/manifest.js +232 -0
- package/dist/output/manifest.js.map +1 -0
- package/dist/output/toon.d.ts +19 -0
- package/dist/output/toon.d.ts.map +1 -0
- package/dist/output/toon.js +22 -0
- package/dist/output/toon.js.map +1 -0
- package/dist/output/writer.d.ts +31 -0
- package/dist/output/writer.d.ts.map +1 -0
- package/dist/output/writer.js +51 -0
- package/dist/output/writer.js.map +1 -0
- package/dist/report/analyzer.d.ts +29 -0
- package/dist/report/analyzer.d.ts.map +1 -0
- package/dist/report/analyzer.js +330 -0
- package/dist/report/analyzer.js.map +1 -0
- package/dist/report/index.d.ts +13 -0
- package/dist/report/index.d.ts.map +1 -0
- package/dist/report/index.js +12 -0
- package/dist/report/index.js.map +1 -0
- package/dist/report/markdown.d.ts +21 -0
- package/dist/report/markdown.d.ts.map +1 -0
- package/dist/report/markdown.js +182 -0
- package/dist/report/markdown.js.map +1 -0
- package/dist/report/remediations.d.ts +42 -0
- package/dist/report/remediations.d.ts.map +1 -0
- package/dist/report/remediations.js +179 -0
- package/dist/report/remediations.js.map +1 -0
- package/dist/report/scorer.d.ts +35 -0
- package/dist/report/scorer.d.ts.map +1 -0
- package/dist/report/scorer.js +72 -0
- package/dist/report/scorer.js.map +1 -0
- package/dist/report/types.d.ts +201 -0
- package/dist/report/types.d.ts.map +1 -0
- package/dist/report/types.js +149 -0
- package/dist/report/types.js.map +1 -0
- package/dist/shared/fs-utils.d.ts +12 -0
- package/dist/shared/fs-utils.d.ts.map +1 -0
- package/dist/shared/fs-utils.js +44 -0
- package/dist/shared/fs-utils.js.map +1 -0
- package/dist/shared/types.d.ts +69 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +18 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/utils.d.ts +6 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +9 -0
- package/dist/shared/utils.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP diagnostic prompt templates.
|
|
3
|
+
*
|
|
4
|
+
* Prompts provide guided starting points for common diagnostic workflows.
|
|
5
|
+
* When an AI client invokes a prompt, it receives structured messages that
|
|
6
|
+
* guide it through the analysis process using PerfGraph tools.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Shared: base diagnostic instructions
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
/**
|
|
15
|
+
* Instructions injected into every diagnostic prompt to ensure the AI
|
|
16
|
+
* agent uses PerfGraph effectively.
|
|
17
|
+
*/
|
|
18
|
+
const SYSTEM_CONTEXT = `You are a web performance diagnostician powered by PerfGraph.
|
|
19
|
+
|
|
20
|
+
WORKFLOW:
|
|
21
|
+
1. Call \`perfgraph_run\` with the target URL to collect and analyze performance data.
|
|
22
|
+
2. Read the results — the tool returns a summary with score, issue counts, and resource URIs.
|
|
23
|
+
3. Read the full report via the \`perfgraph://\` resource URIs returned in the response.
|
|
24
|
+
4. Analyze the findings and provide actionable recommendations.
|
|
25
|
+
|
|
26
|
+
The report contains:
|
|
27
|
+
- **meta**: URL, analysis timestamp, feature/graph/rule counts
|
|
28
|
+
- **summary**: overall score (good/moderate/poor), issue counts, top issues
|
|
29
|
+
- **issues**: each detected problem with severity (critical/warning/info), confidence (strong/medium/weak), metric values, and remediation text
|
|
30
|
+
- **chains**: causal paths from root cause to impact
|
|
31
|
+
- **recommendations**: prioritized actions with expected impact
|
|
32
|
+
- **features**: raw diagnostic features for cross-referencing
|
|
33
|
+
|
|
34
|
+
RESPONSE FORMAT:
|
|
35
|
+
Always structure your analysis with:
|
|
36
|
+
1. **Executive Summary** — score, critical count, system status
|
|
37
|
+
2. **Key Findings** — top issues by severity with metrics
|
|
38
|
+
3. **Causal Chains** — root cause → impact paths
|
|
39
|
+
4. **Recommendations** — prioritized actions
|
|
40
|
+
5. **Next Steps** — what to investigate further`;
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Prompt: LCP Performance Analysis
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
export const LcpAnalysisArgsSchema = z.object({
|
|
45
|
+
/** Target URL to analyze */
|
|
46
|
+
url: z.string().min(1, 'url is required'),
|
|
47
|
+
/** Optional: existing report URI to analyze instead of running a new collection */
|
|
48
|
+
reportUri: z.string().optional(),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Guided LCP (Largest Contentful Paint) performance analysis.
|
|
52
|
+
*
|
|
53
|
+
* The prompt instructs the AI to run a focused analysis on LCP performance,
|
|
54
|
+
* examining the LCP breakdown (TTFB, resource delay, render delay, element
|
|
55
|
+
* render time) and all contributing factors.
|
|
56
|
+
*/
|
|
57
|
+
export function buildLcpAnalysisPrompt(args) {
|
|
58
|
+
const { url, reportUri } = args;
|
|
59
|
+
const userMessage = reportUri
|
|
60
|
+
? `Analyze the LCP performance from the existing report at ${reportUri}.
|
|
61
|
+
|
|
62
|
+
Focus specifically on:
|
|
63
|
+
1. **LCP Breakdown** — TTFB, resource load delay, render delay, element render time
|
|
64
|
+
2. **Render-blocking resources** — CSS, JS, scripts blocking the LCP element
|
|
65
|
+
3. **Causal chain** — follow the path from root cause to LCP impact
|
|
66
|
+
4. **Remediations** — what specific actions would improve LCP
|
|
67
|
+
|
|
68
|
+
Read the report from ${reportUri} and provide a focused LCP analysis with specific metrics and recommendations.`
|
|
69
|
+
: `Perform a detailed LCP (Largest Contentful Paint) analysis on ${url}.
|
|
70
|
+
|
|
71
|
+
Follow this workflow:
|
|
72
|
+
1. Call \`perfgraph_run\` with url="${url}" to collect and analyze performance data
|
|
73
|
+
2. Read the report via the returned resource URIs
|
|
74
|
+
3. Focus your analysis specifically on LCP performance:
|
|
75
|
+
|
|
76
|
+
a. **LCP Breakdown**: Examine TTFB, resource load delay, render delay, and element render time
|
|
77
|
+
b. **Contributing Factors**: Check render-blocking resources, critical path depth, JS execution hotspots, and third-party scripts
|
|
78
|
+
c. **Causal Chain**: Trace the degradation path from root causes to LCP impact
|
|
79
|
+
d. **Remediations**: Prioritize actions that would most improve LCP
|
|
80
|
+
|
|
81
|
+
4. For each finding, include:
|
|
82
|
+
- The metric value and threshold
|
|
83
|
+
- Severity (critical/warning/info)
|
|
84
|
+
- Confidence (strong/medium/weak)
|
|
85
|
+
- Specific remediation action
|
|
86
|
+
|
|
87
|
+
Provide a structured LCP diagnostic report.`;
|
|
88
|
+
return {
|
|
89
|
+
description: `LCP performance analysis for ${url}`,
|
|
90
|
+
messages: [
|
|
91
|
+
{
|
|
92
|
+
role: 'user',
|
|
93
|
+
content: {
|
|
94
|
+
type: 'text',
|
|
95
|
+
text: `${SYSTEM_CONTEXT}\n\n${userMessage}`,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Prompt: Full Site Audit
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
export const AuditArgsSchema = z.object({
|
|
105
|
+
/** Target URL to audit */
|
|
106
|
+
url: z.string().min(1, 'url is required'),
|
|
107
|
+
/** Number of collection runs (default: 1) */
|
|
108
|
+
runs: z.number().int().min(1).max(5).optional(),
|
|
109
|
+
/** Whether to focus on a specific category (lcp, js, network, layout) */
|
|
110
|
+
focus: z.enum(['all', 'lcp', 'js', 'network', 'layout']).optional(),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Comprehensive full-site performance audit.
|
|
114
|
+
*
|
|
115
|
+
* Instructs the AI to perform a thorough analysis across all performance
|
|
116
|
+
* dimensions and produce a complete diagnostic report.
|
|
117
|
+
*/
|
|
118
|
+
export function buildAuditPrompt(args) {
|
|
119
|
+
const { url, runs, focus } = args;
|
|
120
|
+
const focusHint = focus && focus !== 'all'
|
|
121
|
+
? `\nFOCUS AREA: ${focus.toUpperCase()}`
|
|
122
|
+
: '';
|
|
123
|
+
const userMessage = `Perform a comprehensive performance audit of ${url}${focusHint}.
|
|
124
|
+
|
|
125
|
+
Workflow:
|
|
126
|
+
1. Call \`perfgraph_run\` with url="${url}"${runs ? `, runs=${runs}` : ''}
|
|
127
|
+
2. Read the full report from the returned resource URIs
|
|
128
|
+
3. Analyze ALL of the following dimensions${focus && focus !== 'all' ? ` (with primary focus on ${focus})` : ''}:
|
|
129
|
+
|
|
130
|
+
${focus === 'all' || !focus ? `
|
|
131
|
+
a. **LCP (Largest Contentful Paint)** — TTFB, resource delay, render delay, element timing
|
|
132
|
+
b. **JavaScript** — long tasks, TBT, execution hotspots, parse/compile/evaluate cost
|
|
133
|
+
c. **Network** — request waterfall, critical path depth, cascade delay, bandwidth contention
|
|
134
|
+
d. **Layout** — CLS, layout shift clusters, DOM complexity, forced reflows
|
|
135
|
+
e. **Third-party** — origin attribution, transfer size ratio, blocking scripts` : ''}
|
|
136
|
+
${focus === 'lcp' ? `a. **LCP Breakdown** — TTFB, resource delay, render delay, element render time
|
|
137
|
+
b. **Render-blocking** — CSS/JS/scripts blocking LCP
|
|
138
|
+
c. **Critical path** — request chain depth to LCP element` : ''}
|
|
139
|
+
${focus === 'js' ? `a. **Long tasks** — count, duration, attribution
|
|
140
|
+
b. **TBT (Total Blocking Time)** — score and contributors
|
|
141
|
+
c. **Execution hotspots** — top JS files by parse/compile/evaluate time
|
|
142
|
+
d. **Third-party JS** — overhead from external scripts` : ''}
|
|
143
|
+
${focus === 'network' ? `a. **Waterfall depth** — critical chain length and serial requests
|
|
144
|
+
b. **Cascade delay** — sequential dependency delays
|
|
145
|
+
c. **Bandwidth contention** — multiplexing opportunities
|
|
146
|
+
d. **Render-blocking** — blocking request analysis` : ''}
|
|
147
|
+
${focus === 'layout' ? `a. **CLS score** — cumulative and individual shifts
|
|
148
|
+
b. **Layout shift clusters** — timing and affected elements
|
|
149
|
+
c. **DOM complexity** — total nodes, depth, max children
|
|
150
|
+
d. **Forced reflows** — layout thrashing patterns` : ''}
|
|
151
|
+
|
|
152
|
+
4. For every critical and warning issue found, provide:
|
|
153
|
+
- The metric value and threshold exceeded
|
|
154
|
+
- Causal chain from root cause to impact
|
|
155
|
+
- Concrete remediation steps
|
|
156
|
+
- Expected impact of the fix
|
|
157
|
+
|
|
158
|
+
5. Prioritize issues by severity and provide an overall site health assessment.
|
|
159
|
+
|
|
160
|
+
Format the audit as a structured report with clear sections and actionable findings.`;
|
|
161
|
+
return {
|
|
162
|
+
description: `Full performance audit of ${url}${focus && focus !== 'all' ? ` (focus: ${focus})` : ''}`,
|
|
163
|
+
messages: [
|
|
164
|
+
{
|
|
165
|
+
role: 'user',
|
|
166
|
+
content: {
|
|
167
|
+
type: 'text',
|
|
168
|
+
text: `${SYSTEM_CONTEXT}\n\n${userMessage}`,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
// Prompt: Summarize Report
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
export const SummarizeArgsSchema = z.object({
|
|
178
|
+
/** Resource URI of the report to summarize (e.g., perfgraph://artifacts/<path>/report.toon) */
|
|
179
|
+
reportUri: z.string().min(1, 'reportUri is required'),
|
|
180
|
+
/** Detail level for the summary */
|
|
181
|
+
detail: z.enum(['brief', 'normal', 'detailed']).optional(),
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Summarize an existing PerfGraph report in natural language.
|
|
185
|
+
*
|
|
186
|
+
* Takes a report resource URI (as returned by perfgraph_run) and produces
|
|
187
|
+
* a human-readable summary of the findings.
|
|
188
|
+
*/
|
|
189
|
+
export function buildSummarizePrompt(args) {
|
|
190
|
+
const { reportUri, detail } = args;
|
|
191
|
+
const verbosity = detail ?? 'normal';
|
|
192
|
+
const userMessage = `Read and summarize the PerfGraph performance report at ${reportUri}.
|
|
193
|
+
|
|
194
|
+
Read the report and provide a ${verbosity === 'brief' ? 'concise (3-5 bullet points)' : verbosity === 'detailed' ? 'comprehensive, section-by-section' : 'balanced'} summary.
|
|
195
|
+
|
|
196
|
+
Include:
|
|
197
|
+
${verbosity === 'brief' ? `
|
|
198
|
+
- Overall score and critical issue count
|
|
199
|
+
- Top 3 most important findings
|
|
200
|
+
- Single most impactful recommendation` : verbosity === 'detailed' ? `
|
|
201
|
+
- **Executive Summary**: overall score, critical/warning/info counts, system status
|
|
202
|
+
- **All Critical Issues**: full details with metrics, thresholds, and remediations
|
|
203
|
+
- **Causal Chains**: every chain from root cause to impact with confidence levels
|
|
204
|
+
- **All Recommendations**: prioritized with expected impact
|
|
205
|
+
- **Raw Features Summary**: key metric values for LCP, TBT, CLS, etc.` : `
|
|
206
|
+
- Overall score, critical/warning/info breakdown
|
|
207
|
+
- Top 5 issues with severity and confidence
|
|
208
|
+
- Key causal chains
|
|
209
|
+
- Top 3 recommendations with expected impact`}
|
|
210
|
+
|
|
211
|
+
Base your summary solely on the report data — do not add information not present in the report. Use natural language, not JSON.`;
|
|
212
|
+
return {
|
|
213
|
+
description: `Summarize PerfGraph report at ${reportUri}`,
|
|
214
|
+
messages: [
|
|
215
|
+
{
|
|
216
|
+
role: 'user',
|
|
217
|
+
content: {
|
|
218
|
+
type: 'text',
|
|
219
|
+
text: `${SYSTEM_CONTEXT}\n\n${userMessage}`,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/mcp/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,8EAA8E;AAC9E,uCAAuC;AACvC,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;gDAsByB,CAAC;AAEjD,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5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ph.
|
|
3
|
+
*
|
|
4
|
+
* Registers resource templates and static resources that allow AI agents
|
|
5
|
+
* to read collected data and diagnostic reports via MCP.
|
|
6
|
+
*
|
|
7
|
+
* Resource URI scheme:
|
|
8
|
+
* perfgraph://artifacts/{encoded-path}/{filename}
|
|
9
|
+
*
|
|
10
|
+
* Where {encoded-path} is the run directory path encoded with `/` → `_` substitution.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
export interface ResourceContent {
|
|
15
|
+
uri: string;
|
|
16
|
+
text: string;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read a resource by its PerfGraph URI.
|
|
21
|
+
*
|
|
22
|
+
* Format: perfgraph://artifacts/{encoded-path}/{filename}
|
|
23
|
+
*
|
|
24
|
+
* The encoded-path uses `_` as path separator (safe for URIs).
|
|
25
|
+
*/
|
|
26
|
+
export declare function readResource(uri: string): ResourceContent;
|
|
27
|
+
/**
|
|
28
|
+
* List known artifacts in a PerfGraph run directory.
|
|
29
|
+
*/
|
|
30
|
+
export declare function listArtifacts(uri: string): ResourceContent[];
|
|
31
|
+
/**
|
|
32
|
+
* Encode a filesystem path for use in a perfgraph:// URI.
|
|
33
|
+
*
|
|
34
|
+
* Replaces path separators with `_` to produce a valid URI segment.
|
|
35
|
+
*/
|
|
36
|
+
export declare function encodePath(filePath: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a webtr:// resource URI and return its content in TOON format.
|
|
39
|
+
*
|
|
40
|
+
* URI scheme: webtr://runs/{runRef}/toon
|
|
41
|
+
*
|
|
42
|
+
* The {runRef} is the run directory path with `_` as separator (same
|
|
43
|
+
* encoding as perfgraph://artifacts/ URIs). Reads the run's report
|
|
44
|
+
* and features JSON, then encodes them as TOON for token-efficient
|
|
45
|
+
* LLM consumption.
|
|
46
|
+
*/
|
|
47
|
+
export declare function toon(uri: string): ResourceContent;
|
|
48
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/mcp/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CA+BzD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,EAAE,CAmD5D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAyCjD"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP resources for PerfGraph.
|
|
3
|
+
*
|
|
4
|
+
* Registers resource templates and static resources that allow AI agents
|
|
5
|
+
* to read collected data and diagnostic reports via MCP.
|
|
6
|
+
*
|
|
7
|
+
* Resource URI scheme:
|
|
8
|
+
* perfgraph://artifacts/{encoded-path}/{filename}
|
|
9
|
+
*
|
|
10
|
+
* Where {encoded-path} is the run directory path encoded with `/` → `_` substitution.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
15
|
+
import { resolve } from 'node:path';
|
|
16
|
+
import { encode } from '@toon-format/toon';
|
|
17
|
+
/**
|
|
18
|
+
* Read a resource by its PerfGraph URI.
|
|
19
|
+
*
|
|
20
|
+
* Format: perfgraph://artifacts/{encoded-path}/{filename}
|
|
21
|
+
*
|
|
22
|
+
* The encoded-path uses `_` as path separator (safe for URIs).
|
|
23
|
+
*/
|
|
24
|
+
export function readResource(uri) {
|
|
25
|
+
const parsed = /^perfgraph:\/\/artifacts\/(.+?)\/(.+)$/.exec(uri);
|
|
26
|
+
if (!parsed) {
|
|
27
|
+
throw new Error(`Invalid resource URI: ${uri}`);
|
|
28
|
+
}
|
|
29
|
+
const encodedPath = parsed[1];
|
|
30
|
+
const filename = parsed[2];
|
|
31
|
+
// Decode: `_` → `\` (Windows) or `/` (standard separator)
|
|
32
|
+
const decodedPath = encodedPath.split('_').join('/');
|
|
33
|
+
const filePath = resolve(decodedPath, filename);
|
|
34
|
+
if (!existsSync(filePath)) {
|
|
35
|
+
throw new Error(`Resource not found: ${filePath}`);
|
|
36
|
+
}
|
|
37
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
38
|
+
// Determine mimeType from filename
|
|
39
|
+
let mimeType = 'application/octet-stream';
|
|
40
|
+
if (filename.endsWith('.json') || filename.endsWith('.toon')) {
|
|
41
|
+
mimeType = 'application/json';
|
|
42
|
+
}
|
|
43
|
+
else if (filename.endsWith('.json.gz')) {
|
|
44
|
+
mimeType = 'application/gzip';
|
|
45
|
+
}
|
|
46
|
+
else if (filename.endsWith('.txt')) {
|
|
47
|
+
mimeType = 'text/plain';
|
|
48
|
+
}
|
|
49
|
+
return { uri, text: content, mimeType };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* List known artifacts in a PerfGraph run directory.
|
|
53
|
+
*/
|
|
54
|
+
export function listArtifacts(uri) {
|
|
55
|
+
const parsed = /^perfgraph:\/\/artifacts\/(.+)$/.exec(uri);
|
|
56
|
+
if (!parsed) {
|
|
57
|
+
throw new Error(`Invalid resource URI: ${uri}`);
|
|
58
|
+
}
|
|
59
|
+
const encodedPath = parsed[1];
|
|
60
|
+
const decodedPath = encodedPath.split('_').join('/');
|
|
61
|
+
const dirPath = resolve(decodedPath);
|
|
62
|
+
if (!existsSync(dirPath)) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
// Common PerfGraph artifacts
|
|
66
|
+
const artifacts = [
|
|
67
|
+
'report.toon',
|
|
68
|
+
'features.toon',
|
|
69
|
+
'graph.toon',
|
|
70
|
+
'ir.json',
|
|
71
|
+
'insights.toon',
|
|
72
|
+
'manifest.toon',
|
|
73
|
+
'trace.json',
|
|
74
|
+
'network.json',
|
|
75
|
+
'performance.json',
|
|
76
|
+
'lighthouse.json',
|
|
77
|
+
'runtime.json',
|
|
78
|
+
'console.json',
|
|
79
|
+
'dom.json',
|
|
80
|
+
'coverage.json',
|
|
81
|
+
'warnings.json',
|
|
82
|
+
'network-summary.toon',
|
|
83
|
+
'lighthouse-summary.toon',
|
|
84
|
+
'coverage-summary.toon',
|
|
85
|
+
];
|
|
86
|
+
const results = [];
|
|
87
|
+
for (const artifact of artifacts) {
|
|
88
|
+
const filePath = resolve(dirPath, artifact);
|
|
89
|
+
if (existsSync(filePath)) {
|
|
90
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
91
|
+
results.push({
|
|
92
|
+
uri: `perfgraph://artifacts/${encodedPath}/${artifact}`,
|
|
93
|
+
text: content,
|
|
94
|
+
mimeType: 'application/json',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return results;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Encode a filesystem path for use in a perfgraph:// URI.
|
|
102
|
+
*
|
|
103
|
+
* Replaces path separators with `_` to produce a valid URI segment.
|
|
104
|
+
*/
|
|
105
|
+
export function encodePath(filePath) {
|
|
106
|
+
return filePath.replace(/[\\/]/g, '_');
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a webtr:// resource URI and return its content in TOON format.
|
|
110
|
+
*
|
|
111
|
+
* URI scheme: webtr://runs/{runRef}/toon
|
|
112
|
+
*
|
|
113
|
+
* The {runRef} is the run directory path with `_` as separator (same
|
|
114
|
+
* encoding as perfgraph://artifacts/ URIs). Reads the run's report
|
|
115
|
+
* and features JSON, then encodes them as TOON for token-efficient
|
|
116
|
+
* LLM consumption.
|
|
117
|
+
*/
|
|
118
|
+
export function toon(uri) {
|
|
119
|
+
const parsed = /^webtr:\/\/runs\/(.+?)\/toon$/.exec(uri);
|
|
120
|
+
if (!parsed) {
|
|
121
|
+
throw new Error(`Invalid TOON resource URI: ${uri}`);
|
|
122
|
+
}
|
|
123
|
+
const runRef = parsed[1];
|
|
124
|
+
const decodedPath = runRef.split('_').join('/');
|
|
125
|
+
const dirPath = resolve(decodedPath);
|
|
126
|
+
if (!existsSync(dirPath)) {
|
|
127
|
+
throw new Error(`Run directory not found: ${dirPath}`);
|
|
128
|
+
}
|
|
129
|
+
// Load report and/or features from the run directory
|
|
130
|
+
const reportFile = resolve(dirPath, 'report.toon');
|
|
131
|
+
const featuresFile = resolve(dirPath, 'features.toon');
|
|
132
|
+
const graphFile = resolve(dirPath, 'graph.toon');
|
|
133
|
+
const data = {};
|
|
134
|
+
if (existsSync(reportFile)) {
|
|
135
|
+
data.report = JSON.parse(readFileSync(reportFile, 'utf-8'));
|
|
136
|
+
}
|
|
137
|
+
if (existsSync(featuresFile)) {
|
|
138
|
+
data.features = JSON.parse(readFileSync(featuresFile, 'utf-8'));
|
|
139
|
+
}
|
|
140
|
+
if (existsSync(graphFile)) {
|
|
141
|
+
data.graph = JSON.parse(readFileSync(graphFile, 'utf-8'));
|
|
142
|
+
}
|
|
143
|
+
if (Object.keys(data).length === 0) {
|
|
144
|
+
throw new Error(`No run data found in: ${dirPath}`);
|
|
145
|
+
}
|
|
146
|
+
const text = encode(data);
|
|
147
|
+
return { uri, text, mimeType: 'text/plain' };
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/mcp/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,O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,CAAC;IAC9D,CAAC;IAED,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PerfGraph MCP Server.
|
|
3
|
+
*
|
|
4
|
+
* Exposes PerfGraph's full performance diagnostic pipeline through
|
|
5
|
+
* the Model Context Protocol. Primary usage is the `perfgraph_run` tool
|
|
6
|
+
* (one-shot URL → report). Advanced users can invoke individual pipeline
|
|
7
|
+
* steps via dedicated tools.
|
|
8
|
+
*
|
|
9
|
+
* Resources are available at `perfgraph://artifacts/{encoded-path}/{filename}`
|
|
10
|
+
* for reading collected data and generated reports.
|
|
11
|
+
*
|
|
12
|
+
* Usage (AI client config):
|
|
13
|
+
* ```json
|
|
14
|
+
* {
|
|
15
|
+
* "mcpServers": {
|
|
16
|
+
* "perfgraph": {
|
|
17
|
+
* "command": "node",
|
|
18
|
+
* "args": ["dist/index.js", "mcp"]
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Start the MCP stdio server.
|
|
28
|
+
*
|
|
29
|
+
* Registers all tools and resources, then listens for JSON-RPC messages
|
|
30
|
+
* on stdin/stdout. Never resolves — the server runs until the process
|
|
31
|
+
* is killed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function startMcpServer(): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA6CH;;;;;;GAMG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CA0gBpD"}
|