@perf-engineer/web 0.0.0-stage → 0.1.1
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 +210 -2
- package/dist/cli.js +6443 -0
- package/package.json +47 -4
- package/playbooks/first-screen-sop.md +118 -0
- package/playbooks/guidance.lock.json +17 -0
- package/templates/antigravity/README.md +3 -0
- package/templates/antigravity/agents/perf-engineer.md +64 -0
- package/templates/antigravity/hooks/readonly-guard.mjs +142 -0
- package/templates/antigravity/hooks.json +16 -0
- package/templates/antigravity/mcp_config.json +14 -0
- package/templates/antigravity/plugin.json +11 -0
- package/templates/antigravity/rules/AGENTS.md +12 -0
- package/templates/antigravity/skills/perf-diagnose/SKILL.md +66 -0
- package/templates/codex/AGENTS.md +49 -0
- package/templates/codex/mcp-config.json +14 -0
- package/templates/codex/skills/perf-diagnose/SKILL.md +64 -0
- package/templates/cursor/.cursor/mcp.json +14 -0
- package/templates/cursor/.cursor/rules/perf-engineer.mdc +76 -0
- package/templates/vscode/.vscode/mcp.json +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Perf Engineer Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,211 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Perf Engineer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** | [简体中文](https://github.com/perf-engineer/perf-engineer/blob/main/README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@perf-engineer/web)
|
|
6
|
+
[](https://github.com/perf-engineer/perf-engineer/actions/workflows/ci.yml)
|
|
7
|
+
[](#requirements)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
A read-only MCP server for diagnosing initial page-load performance in AI coding clients such as Antigravity, Cursor, Claude Code, Codex, and VS Code. It combines repeated measurements from real Chrome and Lighthouse 12 with source-code analysis to produce a diagnostic report (`report.md`) and an optimization task list (`perf-tasks.md`) for developers or AI assistants to work through.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Repeated Chrome and Lighthouse 12 measurements, using median values to identify resource, image, script, and API bottlenecks that affect initial loading
|
|
15
|
+
- Read-only diagnostic tools that do not modify application source code or run builds, dependency installation, or Git commands
|
|
16
|
+
- Checks linking deployed artifacts to local source code, with separate tasks for production operations, deployment, and local code changes when versions differ
|
|
17
|
+
- A built-in diagnostic guide covering six areas of initial page-load performance, with support for team-specific guidance
|
|
18
|
+
- Retests using the same device, network, and login conditions after changes are deployed, with before-and-after metric comparisons
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- [Node.js](https://nodejs.org/) `>= 22.13.0`
|
|
23
|
+
- Chrome or Chromium installed locally
|
|
24
|
+
|
|
25
|
+
## Quick start
|
|
26
|
+
|
|
27
|
+
Add the following configuration to an MCP-compatible client. You do not need to clone the repository:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"perf-engineer": {
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": ["-y", "@perf-engineer/web"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
You can also use the built-in installers to add client configuration and, where supported, read-only rules:
|
|
41
|
+
|
|
42
|
+
<details>
|
|
43
|
+
<summary>Antigravity (includes a hook to prevent accidental writes)</summary>
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx -y @perf-engineer/web install antigravity
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The installer writes the plugin to `~/.gemini/config/plugins/perf-engineer`. Restart or reload the Antigravity plugin to apply it.
|
|
50
|
+
|
|
51
|
+
</details>
|
|
52
|
+
|
|
53
|
+
<details>
|
|
54
|
+
<summary>Cursor</summary>
|
|
55
|
+
|
|
56
|
+
Run this command from the root of the project you want to diagnose:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx -y @perf-engineer/web install cursor
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The installer merges the MCP configuration into `.cursor/mcp.json`, preserving existing settings, and writes `.cursor/rules/perf-engineer.mdc`. Add `--global` to install the MCP configuration in `~/.cursor/mcp.json`.
|
|
63
|
+
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
<details>
|
|
67
|
+
<summary>Claude Code</summary>
|
|
68
|
+
|
|
69
|
+
Use the Claude CLI to add the MCP server:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
claude mcp add perf-engineer -- npx -y @perf-engineer/web
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Alternatively, run `npx -y @perf-engineer/web install claude-code` from the project root to generate `.mcp.json`.
|
|
76
|
+
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
<details>
|
|
80
|
+
<summary>Codex</summary>
|
|
81
|
+
|
|
82
|
+
Run this command from the project root:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx -y @perf-engineer/web install codex
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
For a global configuration in `~/.codex/config.toml`, add:
|
|
89
|
+
|
|
90
|
+
```toml
|
|
91
|
+
[mcp_servers.perf-engineer]
|
|
92
|
+
command = "npx"
|
|
93
|
+
args = ["-y", "@perf-engineer/web"]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
</details>
|
|
97
|
+
|
|
98
|
+
<details>
|
|
99
|
+
<summary>VS Code</summary>
|
|
100
|
+
|
|
101
|
+
Run this command from the project root:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx -y @perf-engineer/web install vscode
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or configure `.vscode/mcp.json` manually:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"servers": {
|
|
112
|
+
"perf-engineer": {
|
|
113
|
+
"type": "stdio",
|
|
114
|
+
"command": "npx",
|
|
115
|
+
"args": ["-y", "@perf-engineer/web"]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
</details>
|
|
122
|
+
|
|
123
|
+
## Usage
|
|
124
|
+
|
|
125
|
+
### Diagnose a public page
|
|
126
|
+
|
|
127
|
+
> Use perf-engineer to diagnose `https://shop.example.com/`. The local repository is at `/path/to/storefront`. No login is required.
|
|
128
|
+
|
|
129
|
+
### Diagnose a page that requires login
|
|
130
|
+
|
|
131
|
+
> Use perf-engineer to diagnose `https://app.example.com/dashboard`. The local repository is at `/path/to/app`. Login is required.
|
|
132
|
+
|
|
133
|
+
At the login step, Perf Engineer opens an isolated Chrome window for you to sign in manually, including QR codes, verification codes, or two-factor authentication. Once you are signed in, ask the AI assistant to continue measuring. The diagnostic tools do not read or record passwords, cookies, local storage, or tokens.
|
|
134
|
+
|
|
135
|
+
### Work through the task list
|
|
136
|
+
|
|
137
|
+
When diagnosis finishes, Perf Engineer returns the path to `perf-tasks.md`. You can work through the tasks in priority order or pass the file to an AI assistant:
|
|
138
|
+
|
|
139
|
+
> Complete the optimizations in this `perf-tasks.md` one at a time. Run each task's acceptance checks after completing it.
|
|
140
|
+
|
|
141
|
+
### Retest after deployment
|
|
142
|
+
|
|
143
|
+
After deploying the changes, repeat the measurements under the same conditions and compare the results:
|
|
144
|
+
|
|
145
|
+
> Use perf-engineer to retest `https://shop.example.com/` and compare it with the previous diagnosis.
|
|
146
|
+
|
|
147
|
+
## Output files
|
|
148
|
+
|
|
149
|
+
Each run writes its results to `~/.perf-engineer/data/runs/<run-id>/`:
|
|
150
|
+
|
|
151
|
+
```text
|
|
152
|
+
~/.perf-engineer/data/runs/<run-id>/
|
|
153
|
+
├── report.md # Findings, measurements, production/local issues, and analysis coverage
|
|
154
|
+
├── perf-tasks.md # Change scope, implementation steps, acceptance checks, and rollback guidance
|
|
155
|
+
├── manifest.json # Run metadata
|
|
156
|
+
└── evidence/ # Initial viewport screenshot, network requests, and Lighthouse diagnostics
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The following results come from a real storefront homepage diagnosis, with identifying details removed. The full report and task list are available in `examples/`:
|
|
160
|
+
|
|
161
|
+
| Metric | Measured median | Reference threshold | Status |
|
|
162
|
+
| --- | ---: | ---: | --- |
|
|
163
|
+
| Performance score | 42 | ≥ 85 | ❌ Low |
|
|
164
|
+
| First Contentful Paint (FCP) | 1.5 s | ≤ 1.8 s | ✅ Within threshold |
|
|
165
|
+
| Largest Contentful Paint (LCP) | 12.2 s | ≤ 2.5 s | ❌ Slow |
|
|
166
|
+
| Speed Index | 9.8 s | ≤ 3.4 s | ❌ Very slow |
|
|
167
|
+
| Total Blocking Time (TBT) | 429 ms | ≤ 200 ms | ⚠️ High |
|
|
168
|
+
| Cumulative Layout Shift (CLS) | 0.01 | ≤ 0.10 | ✅ Within threshold |
|
|
169
|
+
|
|
170
|
+
- [Full diagnostic report example (Chinese)](examples/storefront-report.md)
|
|
171
|
+
- [Full optimization task list example (Chinese)](examples/storefront-tasks.md)
|
|
172
|
+
|
|
173
|
+
## Diagnostic coverage and customization
|
|
174
|
+
|
|
175
|
+
The built-in guide covers six areas of initial page-load performance and does not require an external skill library:
|
|
176
|
+
|
|
177
|
+
| Area | What the guide covers |
|
|
178
|
+
| --- | --- |
|
|
179
|
+
| Bundle size and code splitting | On-demand UI and utility imports, moving heavy dependencies out of the initial bundle, duplicate libraries, and legacy polyfills |
|
|
180
|
+
| Network resource scheduling | Critical cross-origin `preconnect` and `dns-prefetch`, incorrect `preload` or `prefetch` usage, and duplicate downloads |
|
|
181
|
+
| Images | CDN resizing and WebP/AVIF conversion, `loading="lazy"` for below-the-fold images and inactive carousel slides, and compression of large local images |
|
|
182
|
+
| Rendering and execution timing | Eagerly mounted hidden dialogs, lazy loading lower sections of long pages, deferred analytics and payment SDKs, and animations that delay initial content visibility |
|
|
183
|
+
| Caching and delivery | Long-lived caching for hashed assets, cache revalidation for entry HTML, `br`/`gzip`/`zstd` compression, and HTTP/2 |
|
|
184
|
+
| API waterfalls and main-thread work | Duplicate startup requests, sequential API chains, request fan-out, and excessive DOM size |
|
|
185
|
+
|
|
186
|
+
To add team-specific guidance, edit [the initial page-load diagnostic guide](packages/guidance/playbooks/first-screen-sop.md) and rebuild the package.
|
|
187
|
+
|
|
188
|
+
## Security and scope
|
|
189
|
+
|
|
190
|
+
- Diagnostic tools do not modify files in the target repository or run build, installation, or Git commands against it.
|
|
191
|
+
- They do not read, record, or request browser cookies, `localStorage`/`sessionStorage`, passwords, or tokens.
|
|
192
|
+
- An initial read-only diagnosis does not claim that performance has improved. Before-and-after comparisons require a subsequent retest under the same conditions after changes are deployed.
|
|
193
|
+
|
|
194
|
+
## Local development
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
git clone https://github.com/perf-engineer/perf-engineer.git
|
|
198
|
+
cd perf-engineer
|
|
199
|
+
npm install
|
|
200
|
+
npm run build
|
|
201
|
+
npm run build:web
|
|
202
|
+
npm run check
|
|
203
|
+
npm test
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Documentation and license
|
|
207
|
+
|
|
208
|
+
- [Architecture (Chinese)](docs/ARCHITECTURE.md)
|
|
209
|
+
- [Contributing](CONTRIBUTING.md)
|
|
210
|
+
- [Security policy](SECURITY.md)
|
|
211
|
+
- Released under the [MIT License](LICENSE)
|