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,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report types — Zod schemas and TypeScript types for Phase 5.
|
|
3
|
+
*
|
|
4
|
+
* The Report is the final output of PerfGraph: a self-contained JSON document
|
|
5
|
+
* designed for AI consumption. It combines the CausalGraph with remediations,
|
|
6
|
+
* severity scoring, and correlated FeatureSet data.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
export declare const ReportMetaSchema: z.ZodObject<{
|
|
12
|
+
url: z.ZodString;
|
|
13
|
+
analyzedAt: z.ZodString;
|
|
14
|
+
reportVersion: z.ZodString;
|
|
15
|
+
featureCount: z.ZodNumber;
|
|
16
|
+
graphNodeCount: z.ZodNumber;
|
|
17
|
+
graphEdgeCount: z.ZodNumber;
|
|
18
|
+
ruleCount: z.ZodNumber;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type ReportMeta = z.infer<typeof ReportMetaSchema>;
|
|
21
|
+
export declare const ReportScoreSchema: z.ZodEnum<{
|
|
22
|
+
moderate: "moderate";
|
|
23
|
+
good: "good";
|
|
24
|
+
poor: "poor";
|
|
25
|
+
}>;
|
|
26
|
+
export type ReportScore = z.infer<typeof ReportScoreSchema>;
|
|
27
|
+
export declare const TopIssueSchema: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
label: z.ZodString;
|
|
30
|
+
severity: z.ZodString;
|
|
31
|
+
confidence: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type TopIssue = z.infer<typeof TopIssueSchema>;
|
|
34
|
+
export declare const ReportSummarySchema: z.ZodObject<{
|
|
35
|
+
score: z.ZodEnum<{
|
|
36
|
+
moderate: "moderate";
|
|
37
|
+
good: "good";
|
|
38
|
+
poor: "poor";
|
|
39
|
+
}>;
|
|
40
|
+
criticalIssues: z.ZodNumber;
|
|
41
|
+
warnings: z.ZodNumber;
|
|
42
|
+
infos: z.ZodNumber;
|
|
43
|
+
topIssues: z.ZodArray<z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
label: z.ZodString;
|
|
46
|
+
severity: z.ZodString;
|
|
47
|
+
confidence: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
lighthousePerformance: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
scoreExplanation: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type ReportSummary = z.infer<typeof ReportSummarySchema>;
|
|
53
|
+
export declare const ReportIssueSchema: z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
label: z.ZodString;
|
|
56
|
+
type: z.ZodString;
|
|
57
|
+
severity: z.ZodString;
|
|
58
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
60
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
confidence: z.ZodString;
|
|
62
|
+
remediation: z.ZodString;
|
|
63
|
+
chainId: z.ZodString;
|
|
64
|
+
evidence: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
urls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
66
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
67
|
+
lighthouseAuditId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
metric: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
name: z.ZodString;
|
|
70
|
+
value: z.ZodNumber;
|
|
71
|
+
unit: z.ZodString;
|
|
72
|
+
}, z.core.$strip>>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export type ReportIssue = z.infer<typeof ReportIssueSchema>;
|
|
76
|
+
export declare const ChainNodeSchema: z.ZodObject<{
|
|
77
|
+
nodeId: z.ZodString;
|
|
78
|
+
label: z.ZodString;
|
|
79
|
+
type: z.ZodString;
|
|
80
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export type ChainNode = z.infer<typeof ChainNodeSchema>;
|
|
83
|
+
export declare const CausalChainSchema: z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
rootCause: z.ZodString;
|
|
86
|
+
impact: z.ZodString;
|
|
87
|
+
confidence: z.ZodString;
|
|
88
|
+
severity: z.ZodString;
|
|
89
|
+
path: z.ZodArray<z.ZodObject<{
|
|
90
|
+
nodeId: z.ZodString;
|
|
91
|
+
label: z.ZodString;
|
|
92
|
+
type: z.ZodString;
|
|
93
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
length: z.ZodNumber;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export type CausalChain = z.infer<typeof CausalChainSchema>;
|
|
98
|
+
export declare const RecommendationPrioritySchema: z.ZodEnum<{
|
|
99
|
+
high: "high";
|
|
100
|
+
low: "low";
|
|
101
|
+
medium: "medium";
|
|
102
|
+
critical: "critical";
|
|
103
|
+
}>;
|
|
104
|
+
export type RecommendationPriority = z.infer<typeof RecommendationPrioritySchema>;
|
|
105
|
+
export declare const RecommendationSchema: z.ZodObject<{
|
|
106
|
+
priority: z.ZodEnum<{
|
|
107
|
+
high: "high";
|
|
108
|
+
low: "low";
|
|
109
|
+
medium: "medium";
|
|
110
|
+
critical: "critical";
|
|
111
|
+
}>;
|
|
112
|
+
category: z.ZodString;
|
|
113
|
+
title: z.ZodString;
|
|
114
|
+
description: z.ZodString;
|
|
115
|
+
action: z.ZodString;
|
|
116
|
+
expectedImpact: z.ZodString;
|
|
117
|
+
relatedIssues: z.ZodArray<z.ZodString>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
export type Recommendation = z.infer<typeof RecommendationSchema>;
|
|
120
|
+
export declare const ReportSchema: z.ZodObject<{
|
|
121
|
+
meta: z.ZodObject<{
|
|
122
|
+
url: z.ZodString;
|
|
123
|
+
analyzedAt: z.ZodString;
|
|
124
|
+
reportVersion: z.ZodString;
|
|
125
|
+
featureCount: z.ZodNumber;
|
|
126
|
+
graphNodeCount: z.ZodNumber;
|
|
127
|
+
graphEdgeCount: z.ZodNumber;
|
|
128
|
+
ruleCount: z.ZodNumber;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
summary: z.ZodObject<{
|
|
131
|
+
score: z.ZodEnum<{
|
|
132
|
+
moderate: "moderate";
|
|
133
|
+
good: "good";
|
|
134
|
+
poor: "poor";
|
|
135
|
+
}>;
|
|
136
|
+
criticalIssues: z.ZodNumber;
|
|
137
|
+
warnings: z.ZodNumber;
|
|
138
|
+
infos: z.ZodNumber;
|
|
139
|
+
topIssues: z.ZodArray<z.ZodObject<{
|
|
140
|
+
id: z.ZodString;
|
|
141
|
+
label: z.ZodString;
|
|
142
|
+
severity: z.ZodString;
|
|
143
|
+
confidence: z.ZodString;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
lighthousePerformance: z.ZodOptional<z.ZodNumber>;
|
|
146
|
+
scoreExplanation: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
label: z.ZodString;
|
|
151
|
+
type: z.ZodString;
|
|
152
|
+
severity: z.ZodString;
|
|
153
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
155
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
confidence: z.ZodString;
|
|
157
|
+
remediation: z.ZodString;
|
|
158
|
+
chainId: z.ZodString;
|
|
159
|
+
evidence: z.ZodOptional<z.ZodObject<{
|
|
160
|
+
urls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
161
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
162
|
+
lighthouseAuditId: z.ZodOptional<z.ZodString>;
|
|
163
|
+
metric: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
name: z.ZodString;
|
|
165
|
+
value: z.ZodNumber;
|
|
166
|
+
unit: z.ZodString;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
}, z.core.$strip>>;
|
|
169
|
+
}, z.core.$strip>>;
|
|
170
|
+
chains: z.ZodArray<z.ZodObject<{
|
|
171
|
+
id: z.ZodString;
|
|
172
|
+
rootCause: z.ZodString;
|
|
173
|
+
impact: z.ZodString;
|
|
174
|
+
confidence: z.ZodString;
|
|
175
|
+
severity: z.ZodString;
|
|
176
|
+
path: z.ZodArray<z.ZodObject<{
|
|
177
|
+
nodeId: z.ZodString;
|
|
178
|
+
label: z.ZodString;
|
|
179
|
+
type: z.ZodString;
|
|
180
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
length: z.ZodNumber;
|
|
183
|
+
}, z.core.$strip>>;
|
|
184
|
+
recommendations: z.ZodArray<z.ZodObject<{
|
|
185
|
+
priority: z.ZodEnum<{
|
|
186
|
+
high: "high";
|
|
187
|
+
low: "low";
|
|
188
|
+
medium: "medium";
|
|
189
|
+
critical: "critical";
|
|
190
|
+
}>;
|
|
191
|
+
category: z.ZodString;
|
|
192
|
+
title: z.ZodString;
|
|
193
|
+
description: z.ZodString;
|
|
194
|
+
action: z.ZodString;
|
|
195
|
+
expectedImpact: z.ZodString;
|
|
196
|
+
relatedIssues: z.ZodArray<z.ZodString>;
|
|
197
|
+
}, z.core.$strip>>;
|
|
198
|
+
features: z.ZodUnknown;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
export type Report = z.infer<typeof ReportSchema>;
|
|
201
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/report/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,gBAAgB;;;;;;;;iBAe3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAM1D,eAAO,MAAM,iBAAiB;;;;EAAuC,CAAC;AACtE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 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report types — Zod schemas and TypeScript types for Phase 5.
|
|
3
|
+
*
|
|
4
|
+
* The Report is the final output of PerfGraph: a self-contained JSON document
|
|
5
|
+
* designed for AI consumption. It combines the CausalGraph with remediations,
|
|
6
|
+
* severity scoring, and correlated FeatureSet data.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { EvidenceSchema } from '../causal/types.js';
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// ReportMeta
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
export const ReportMetaSchema = z.object({
|
|
16
|
+
/** Target URL that was analyzed */
|
|
17
|
+
url: z.string(),
|
|
18
|
+
/** ISO 8601 timestamp */
|
|
19
|
+
analyzedAt: z.string(),
|
|
20
|
+
/** Semantic version of the report format */
|
|
21
|
+
reportVersion: z.string(),
|
|
22
|
+
/** Number of features that were present in the input */
|
|
23
|
+
featureCount: z.number().nonnegative(),
|
|
24
|
+
/** Number of nodes in the causal graph */
|
|
25
|
+
graphNodeCount: z.number().nonnegative(),
|
|
26
|
+
/** Number of edges in the causal graph */
|
|
27
|
+
graphEdgeCount: z.number().nonnegative(),
|
|
28
|
+
/** Number of causal rules evaluated */
|
|
29
|
+
ruleCount: z.number().nonnegative(),
|
|
30
|
+
});
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// ReportSummary
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
export const ReportScoreSchema = z.enum(['good', 'moderate', 'poor']);
|
|
35
|
+
export const TopIssueSchema = z.object({
|
|
36
|
+
id: z.string().min(1),
|
|
37
|
+
label: z.string().min(1),
|
|
38
|
+
severity: z.string(),
|
|
39
|
+
confidence: z.string(),
|
|
40
|
+
});
|
|
41
|
+
export const ReportSummarySchema = z.object({
|
|
42
|
+
/** Overall performance score */
|
|
43
|
+
score: ReportScoreSchema,
|
|
44
|
+
/** Count of critical-severity issues */
|
|
45
|
+
criticalIssues: z.number().nonnegative(),
|
|
46
|
+
/** Count of warning-severity issues */
|
|
47
|
+
warnings: z.number().nonnegative(),
|
|
48
|
+
/** Count of info-severity issues */
|
|
49
|
+
infos: z.number().nonnegative(),
|
|
50
|
+
/** Top 3-5 most important issues */
|
|
51
|
+
topIssues: z.array(TopIssueSchema),
|
|
52
|
+
/** Optional Lighthouse performance score (0–1) */
|
|
53
|
+
lighthousePerformance: z.number().optional(),
|
|
54
|
+
/** Optional explanation when Lighthouse data influenced the score */
|
|
55
|
+
scoreExplanation: z.string().optional(),
|
|
56
|
+
});
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// ReportIssue — a single detected problem with remediation
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
export const ReportIssueSchema = z.object({
|
|
61
|
+
/** Unique issue identifier (matches CausalNode.id) */
|
|
62
|
+
id: z.string().min(1),
|
|
63
|
+
/** Human-readable label */
|
|
64
|
+
label: z.string().min(1),
|
|
65
|
+
/** Node type: metric, bottleneck, or impact */
|
|
66
|
+
type: z.string(),
|
|
67
|
+
/** Severity level */
|
|
68
|
+
severity: z.string(),
|
|
69
|
+
/** Raw metric value if applicable */
|
|
70
|
+
value: z.number().optional(),
|
|
71
|
+
/** Unit label if applicable */
|
|
72
|
+
unit: z.string().optional(),
|
|
73
|
+
/** Threshold that was exceeded if applicable */
|
|
74
|
+
threshold: z.number().optional(),
|
|
75
|
+
/** Confidence of the causal link leading to this issue */
|
|
76
|
+
confidence: z.string(),
|
|
77
|
+
/** Human-readable remediation recommendation */
|
|
78
|
+
remediation: z.string(),
|
|
79
|
+
/** ID of the causal chain this issue belongs to */
|
|
80
|
+
chainId: z.string(),
|
|
81
|
+
/** Evidence payload from the causal node */
|
|
82
|
+
evidence: EvidenceSchema.optional(),
|
|
83
|
+
});
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// CausalChain — a causal path from root cause to impact
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
export const ChainNodeSchema = z.object({
|
|
88
|
+
nodeId: z.string().min(1),
|
|
89
|
+
label: z.string().min(1),
|
|
90
|
+
type: z.string(),
|
|
91
|
+
severity: z.string().optional(),
|
|
92
|
+
});
|
|
93
|
+
export const CausalChainSchema = z.object({
|
|
94
|
+
/** Unique chain identifier (derived from ruleId) */
|
|
95
|
+
id: z.string().min(1),
|
|
96
|
+
/** Label of the root cause node */
|
|
97
|
+
rootCause: z.string(),
|
|
98
|
+
/** Label of the terminal impact node */
|
|
99
|
+
impact: z.string(),
|
|
100
|
+
/** Overall confidence of the chain */
|
|
101
|
+
confidence: z.string(),
|
|
102
|
+
/** Highest severity in the chain */
|
|
103
|
+
severity: z.string(),
|
|
104
|
+
/** Ordered path from root to impact */
|
|
105
|
+
path: z.array(ChainNodeSchema),
|
|
106
|
+
/** Number of nodes in the path */
|
|
107
|
+
length: z.number().positive(),
|
|
108
|
+
});
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Recommendation — prioritized action item
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
export const RecommendationPrioritySchema = z.enum([
|
|
113
|
+
'critical',
|
|
114
|
+
'high',
|
|
115
|
+
'medium',
|
|
116
|
+
'low',
|
|
117
|
+
]);
|
|
118
|
+
export const RecommendationSchema = z.object({
|
|
119
|
+
/** Priority level */
|
|
120
|
+
priority: RecommendationPrioritySchema,
|
|
121
|
+
/** Category (e.g. "LCP", "JavaScript", "Network", "Layout") */
|
|
122
|
+
category: z.string(),
|
|
123
|
+
/** Short actionable title */
|
|
124
|
+
title: z.string().min(1),
|
|
125
|
+
/** Detailed description */
|
|
126
|
+
description: z.string(),
|
|
127
|
+
/** Concrete action steps */
|
|
128
|
+
action: z.string(),
|
|
129
|
+
/** Expected positive impact */
|
|
130
|
+
expectedImpact: z.string(),
|
|
131
|
+
/** IDs of related issues */
|
|
132
|
+
relatedIssues: z.array(z.string()),
|
|
133
|
+
});
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// Full Report
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
export const ReportSchema = z.object({
|
|
138
|
+
meta: ReportMetaSchema,
|
|
139
|
+
summary: ReportSummarySchema,
|
|
140
|
+
/** All detected issues, sorted by severity (critical first) */
|
|
141
|
+
issues: z.array(ReportIssueSchema),
|
|
142
|
+
/** Causal chains from root causes to impacts */
|
|
143
|
+
chains: z.array(CausalChainSchema),
|
|
144
|
+
/** Prioritized action recommendations */
|
|
145
|
+
recommendations: z.array(RecommendationSchema),
|
|
146
|
+
/** Raw FeatureSet for AI cross-referencing (passthrough) */
|
|
147
|
+
features: z.unknown(),
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/report/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,mCAAmC;IACnC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,yBAAyB;IACzB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,4CAA4C;IAC5C,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,wDAAwD;IACxD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;IACtC,0CAA0C;IAC1C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;IACxC,0CAA0C;IAC1C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAA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AAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,mBAAmB;IAC5B,+DAA+D;IAC/D,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAClC,gDAAgD;IAChD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAClC,yCAAyC;IACzC,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAC9C,4DAA4D;IAC5D,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared filesystem utilities for reading collection run data.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates duplicated readJson / loadRunDir helpers into one module
|
|
5
|
+
* with consistent error handling (most descriptive variant from normalize.ts).
|
|
6
|
+
*/
|
|
7
|
+
import type { RawDataBundle } from '../collect/types.js';
|
|
8
|
+
/** Read a JSON file, returning parsed content or undefined if missing. */
|
|
9
|
+
export declare function readJson(dir: string, filename: string): unknown | undefined;
|
|
10
|
+
/** Assemble a RawDataBundle from a run directory. */
|
|
11
|
+
export declare function loadRunDir(runDir: string): RawDataBundle;
|
|
12
|
+
//# sourceMappingURL=fs-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-utils.d.ts","sourceRoot":"","sources":["../../src/shared/fs-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE1E,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAa3E;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAsBxD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared filesystem utilities for reading collection run data.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates duplicated readJson / loadRunDir helpers into one module
|
|
5
|
+
* with consistent error handling (most descriptive variant from normalize.ts).
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { join, resolve } from 'node:path';
|
|
9
|
+
/** Read a JSON file, returning parsed content or undefined if missing. */
|
|
10
|
+
export function readJson(dir, filename) {
|
|
11
|
+
const filePath = join(dir, filename);
|
|
12
|
+
if (!existsSync(filePath)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const raw = readFileSync(filePath, 'utf-8');
|
|
17
|
+
return JSON.parse(raw);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
throw new Error(`Error: Failed to parse ${join(dir, filename)}: ${err.message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Assemble a RawDataBundle from a run directory. */
|
|
24
|
+
export function loadRunDir(runDir) {
|
|
25
|
+
const dir = resolve(runDir);
|
|
26
|
+
const warningsRaw = readJson(dir, 'warnings.json');
|
|
27
|
+
return {
|
|
28
|
+
trace: readJson(dir, 'trace.json'),
|
|
29
|
+
network: readJson(dir, 'network.json'),
|
|
30
|
+
performance: readJson(dir, 'performance.json'),
|
|
31
|
+
runtime: readJson(dir, 'runtime.json'),
|
|
32
|
+
consoleEntries: readJson(dir, 'console.json'),
|
|
33
|
+
dom: readJson(dir, 'dom.json'),
|
|
34
|
+
lighthouse: readJson(dir, 'lighthouse.json'),
|
|
35
|
+
coverage: readJson(dir, 'coverage.json'),
|
|
36
|
+
warnings: warningsRaw &&
|
|
37
|
+
typeof warningsRaw === 'object' &&
|
|
38
|
+
'warnings' in warningsRaw &&
|
|
39
|
+
Array.isArray(warningsRaw.warnings)
|
|
40
|
+
? warningsRaw.warnings
|
|
41
|
+
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EAAE,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;QACtC,cAAc,EAAE,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;QAC7C,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;QAC9B,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;QAC5C,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAgC;QACvE,QAAQ,EACN,WAAW;YACX,OAAO,WAAW,KAAK,QAAQ;YAC/B,UAAU,IAAI,WAAW;YACzB,KAAK,CAAC,OAAO,CAAE,WAAqC,CAAC,QAAQ,CAAC;YAC5D,CAAC,CAAE,WAAsC,CAAC,QAAQ;YAClD,CAAC,CAAC,SAAS;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types used across the perfgraph codebase.
|
|
3
|
+
*/
|
|
4
|
+
/** Output file paths for a single collection run */
|
|
5
|
+
export interface OutputPaths {
|
|
6
|
+
/** Root output directory */
|
|
7
|
+
dir: string;
|
|
8
|
+
/** Path to trace.json */
|
|
9
|
+
trace: string;
|
|
10
|
+
/** Path to network.json */
|
|
11
|
+
network: string;
|
|
12
|
+
/** Path to metrics.json */
|
|
13
|
+
metrics: string;
|
|
14
|
+
/** Path to runtime.json */
|
|
15
|
+
runtime: string;
|
|
16
|
+
/** Path to coverage.json */
|
|
17
|
+
coverage: string;
|
|
18
|
+
/** Path to console.json */
|
|
19
|
+
console: string;
|
|
20
|
+
/** Path to dom.json */
|
|
21
|
+
dom: string;
|
|
22
|
+
/** Path to lighthouse.json */
|
|
23
|
+
lighthouse: string;
|
|
24
|
+
/** Path to warnings.json */
|
|
25
|
+
warnings: string;
|
|
26
|
+
}
|
|
27
|
+
/** Options for a collection run */
|
|
28
|
+
export interface CollectorRunOptions {
|
|
29
|
+
/** Target URL to collect data from */
|
|
30
|
+
url: string;
|
|
31
|
+
/** Base output directory (default: ./perfgraph-output) */
|
|
32
|
+
output: string;
|
|
33
|
+
/** Number of runs (default: 1) */
|
|
34
|
+
runs: number;
|
|
35
|
+
/** Skip Lighthouse collection */
|
|
36
|
+
noLighthouse: boolean;
|
|
37
|
+
/** Skip Coverage collection */
|
|
38
|
+
noCoverage: boolean;
|
|
39
|
+
/** Skip Console collection */
|
|
40
|
+
noConsole: boolean;
|
|
41
|
+
/** Skip DOM snapshot collection */
|
|
42
|
+
noDom: boolean;
|
|
43
|
+
/** Skip Network collection */
|
|
44
|
+
noNetwork: boolean;
|
|
45
|
+
/** Skip Performance metrics collection */
|
|
46
|
+
noPerformance: boolean;
|
|
47
|
+
/** Skip Runtime collection */
|
|
48
|
+
noRuntime: boolean;
|
|
49
|
+
/** Device name for emulation (e.g. "iPhone 13", "Pixel 7"). Empty = desktop */
|
|
50
|
+
mobile?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Result of a single collection run */
|
|
53
|
+
export interface RunResult {
|
|
54
|
+
/** 1-based run index */
|
|
55
|
+
index: number;
|
|
56
|
+
/** Output directory for this run */
|
|
57
|
+
outputDir: string;
|
|
58
|
+
/** Number of warnings generated */
|
|
59
|
+
warningCount: number;
|
|
60
|
+
/** Files written during this run */
|
|
61
|
+
files: string[];
|
|
62
|
+
/** Whether the run succeeded */
|
|
63
|
+
success: boolean;
|
|
64
|
+
/** Error message if run failed */
|
|
65
|
+
error?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Default values for CollectorRunOptions */
|
|
68
|
+
export declare const DEFAULT_RUN_OPTIONS: CollectorRunOptions;
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,yBAAyB;IACz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AK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,EAAE,mBAYjC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types used across the perfgraph codebase.
|
|
3
|
+
*/
|
|
4
|
+
/** Default values for CollectorRunOptions */
|
|
5
|
+
export const DEFAULT_RUN_OPTIONS = {
|
|
6
|
+
url: '',
|
|
7
|
+
output: './perfgraph-output',
|
|
8
|
+
runs: 1,
|
|
9
|
+
noLighthouse: false,
|
|
10
|
+
noCoverage: false,
|
|
11
|
+
noConsole: false,
|
|
12
|
+
noDom: false,
|
|
13
|
+
noNetwork: false,
|
|
14
|
+
noPerformance: false,
|
|
15
|
+
noRuntime: false,
|
|
16
|
+
mobile: undefined,
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACtD,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,oBAAoB;IAC5B,IAAI,EAAE,CAAC;IACP,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,KAAK;IACpB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,SAAS;CAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGtD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility functions used across the perfgraph codebase.
|
|
3
|
+
*/
|
|
4
|
+
/** Severity ordering helper: critical > warning > info */
|
|
5
|
+
export function severityOrder(severity) {
|
|
6
|
+
const order = { critical: 3, warning: 2, info: 1 };
|
|
7
|
+
return order[severity] ?? 0;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0DAA0D;AAC1D,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,KAAK,GAA2B,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC3E,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "perfgraph",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CDP-powered perf CLI — causal degradation graphs, not just Lighthouse scores",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"bin": {
|
|
18
|
+
"perfgraph": "dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Be1zebub/PerfGraph.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Be1zebub/PerfGraph/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/Be1zebub/PerfGraph#readme",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"web-performance",
|
|
30
|
+
"lighthouse",
|
|
31
|
+
"cdp",
|
|
32
|
+
"core-web-vitals",
|
|
33
|
+
"lcp",
|
|
34
|
+
"cls",
|
|
35
|
+
"mcp",
|
|
36
|
+
"performance",
|
|
37
|
+
"profiler",
|
|
38
|
+
"diagnostics"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc",
|
|
42
|
+
"dev": "tsx watch src/index.ts",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@dagrejs/graphlib": "^4.0.1",
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
51
|
+
"@toon-format/toon": "^2.3.1",
|
|
52
|
+
"lighthouse": "^13.3.0",
|
|
53
|
+
"ow": "^3.1.0",
|
|
54
|
+
"playwright": "^1.58.0",
|
|
55
|
+
"zod": "^4.4.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^24.0.0",
|
|
59
|
+
"devtools-protocol": "^0.0.1638241",
|
|
60
|
+
"tsx": "^4.20.0",
|
|
61
|
+
"typescript": "^5.9.0",
|
|
62
|
+
"vitest": "^4.1.0"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=22.0.0"
|
|
66
|
+
}
|
|
67
|
+
}
|