frontend-audit 0.0.0-stage → 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -3
  3. package/dist/cli.mjs +3078 -0
  4. package/package.json +63 -6
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 redjonsulaj
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,192 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # frontend-audit
2
+
3
+ One command for the company. Point it at a frontend repo and it detects the stack, reports performance and client-side security issues, and writes a remediation plan plus a visual HTML report. Cursor, Claude Code, Claude Desktop, and GitHub Copilot in VS Code use the same install as an MCP server. The checks are not a dependency of the app, and source stays on the machine.
4
+
5
+ ```bash
6
+ frontend-audit audit --dir ../ --fix
7
+ frontend-audit --audit --dir ../ --fix
8
+ ```
9
+
10
+ `--fix` adds `rel="noopener noreferrer"` on `target="_blank"` links and removes leftover `debugger` statements, then scans those files again. Everything else is a suggestion with a fix, a doc link, and a short plan. Security findings are never auto-edited.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -g frontend-audit
16
+ ```
17
+
18
+ Or run it without installing:
19
+
20
+ ```bash
21
+ npx frontend-audit audit --dir .
22
+ ```
23
+
24
+ Node 20 or newer. Lighthouse is an optional dependency and needs Node 22.19 or newer. On older Node the report says Lighthouse was skipped, and everything else still runs.
25
+
26
+ ## Audit modes
27
+
28
+ | Mode | Command | What runs | Edits files |
29
+ |------|---------|-----------|-------------|
30
+ | Full | `frontend-audit audit --dir <path>` | Every detected app, plus the open Chrome tab if one is attached. 5 minute budget. | Only with `--fix` |
31
+ | Quick | `frontend-audit audit --dir <path> --quick` | Source only, 1 minute budget, smaller file cap. Good for one component, route, or folder. | Only with `--fix` |
32
+ | Live | `frontend-audit audit --dir <path> --live [url]` | The open Chrome tab and Lighthouse. Source is read only to match slow requests to files. | Never |
33
+
34
+ ## Commands
35
+
36
+ - `frontend-audit audit --dir <path> --focus performance|security|all` narrows the scan.
37
+ - `frontend-audit audit --dir <path> --fix --dry-run` lists the safe edits and writes nothing.
38
+ - `frontend-audit audit --dir <path> --lighthouse [url]` adds Lighthouse to a full audit.
39
+ - `frontend-audit audit "find performance problems for src/app/checkout"` reads the sentence and scans that folder.
40
+ - `frontend-audit watch --dir <path>` reads the open Chrome tab without Lighthouse.
41
+ - `frontend-audit export --dir <path> --format html|md|json|pdf` prints a report path. PDF is written only on request.
42
+ - `frontend-audit guide` prints the playbook. An audit does not need this.
43
+ - `frontend-audit mcp [--root <workspace>]` starts the MCP server.
44
+
45
+ `--budget 5m` changes the time budget. When it runs out, the report includes whatever finished.
46
+
47
+ ## Reports
48
+
49
+ `<repo>/.frontend-audit/` is gitignored:
50
+
51
+ - `report.html` is a single file with no external assets: severity counts, filters, findings by app, applied fixes, checks that came back clean, and items to review by hand.
52
+ - `report.md` is the same report in markdown.
53
+ - `plan.md` is the ordered remediation plan.
54
+ - `report.json` is the same data for scripts.
55
+ - `report.pdf` is created only by `export --format pdf`.
56
+
57
+ Secret values are not written anywhere. A finding records the file, the line, and the kind of secret, and the value is `[redacted]`.
58
+
59
+ ## MCP clients
60
+
61
+ The server speaks stdio, so any MCP client can run it. Clients differ in one way that matters: whether they tell the server which folder is open.
62
+
63
+ The server picks the folder in this order:
64
+
65
+ 1. The `path` in the tool call. A relative path is resolved against the next item.
66
+ 2. The workspace root the client shares. Cursor and VS Code share it.
67
+ 3. `--root` on the server command, or the `FRONTEND_AUDIT_ROOT` environment variable.
68
+
69
+ If none of those exist, the tool asks for an absolute path. It never scans its own install folder.
70
+
71
+ The configs below use `npx`, so nothing needs to be installed first. With a global install, use `"command": "frontend-audit"` and drop `"-y", "frontend-audit"` from `args`.
72
+
73
+ On Windows, if a client cannot start `npx`, use `"command": "cmd"` with `"args": ["/c", "npx", "-y", "frontend-audit", "mcp"]`.
74
+
75
+ ### Cursor
76
+
77
+ `.cursor/mcp.json` in the project, or `~/.cursor/mcp.json` for every project:
78
+
79
+ ```json
80
+ {
81
+ "mcpServers": {
82
+ "frontend-audit": {
83
+ "command": "npx",
84
+ "args": ["-y", "frontend-audit", "mcp"]
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### GitHub Copilot in VS Code
91
+
92
+ `.vscode/mcp.json`:
93
+
94
+ ```json
95
+ {
96
+ "servers": {
97
+ "frontend-audit": {
98
+ "type": "stdio",
99
+ "command": "npx",
100
+ "args": ["-y", "frontend-audit", "mcp", "--root", "${workspaceFolder}"]
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ Use Copilot Chat in agent mode. The prompts below show up as `/mcp.frontend-audit.quick_audit` and similar.
107
+
108
+ ### Claude Code
109
+
110
+ From the project folder:
111
+
112
+ ```bash
113
+ claude mcp add frontend-audit -- npx -y frontend-audit mcp --root .
114
+ ```
115
+
116
+ Add `--scope project` to write a shared `.mcp.json` for the team. The prompts show up as `/mcp__frontend-audit__quick_audit` and similar.
117
+
118
+ ### Claude Desktop
119
+
120
+ Claude Desktop does not share a workspace, so give the server a root in `claude_desktop_config.json`:
121
+
122
+ ```json
123
+ {
124
+ "mcpServers": {
125
+ "frontend-audit": {
126
+ "command": "npx",
127
+ "args": ["-y", "frontend-audit", "mcp", "--root", "C:\\work\\shop"]
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ Or leave `--root` out and give an absolute path in the request.
134
+
135
+ ### Tools and prompts
136
+
137
+ Tools: `audit_path` (with `mode` full, quick, or live), `audit_request`, `watch_page`, `export_report`, and `guide`. None of them take a framework name.
138
+
139
+ Prompts: `full_audit`, `quick_audit`, `live_audit`, and `safe_fix`. `safe_fix` previews the edits and applies them only after the user confirms.
140
+
141
+ ## How apps are detected
142
+
143
+ A single `package.json` with a framework dependency is one app. A monorepo is several: npm/pnpm/nx workspaces, `angular.json` projects, and `apps/*`, `packages/*`, `projects/*`. The root package is skipped when it has no framework. Each app is named in the report, including the installed version. Angular 17 and newer is told to use `@for` and `track`. Older Angular keeps `trackBy`. React 19 is told to check the React Compiler before adding manual `memo`.
144
+
145
+ ## What it looks for
146
+
147
+ Shipped chapters: React, Next.js, Angular, Vue, Nuxt, Svelte, React Native, RxJS, NgRx, Redux Toolkit, TanStack Query, lodash, and Moment.
148
+
149
+ The scan is heuristic. It flags effect/state loops, render-time fetches, missing list identity, subscriptions that never tear down, full lodash or Moment imports, DOM sinks, `eval`, Angular `bypassSecurityTrust*`, hardcoded secrets, `postMessage` without an origin check, and open redirects.
150
+
151
+ Tests, Storybook, Cypress, e2e, and generated files are skipped. A committed `frontend-audit.ignore` at the repo root dismisses a rule, or a rule plus a path:
152
+
153
+ ```text
154
+ security.eval
155
+ react.missing-key apps/web/src/legacy/**
156
+ ```
157
+
158
+ ## Chrome and Lighthouse
159
+
160
+ Start Chrome yourself:
161
+
162
+ ```bash
163
+ chrome --remote-debugging-port=9222
164
+ ```
165
+
166
+ On Windows that executable is usually `C:\Program Files\Google\Chrome\Application\chrome.exe`.
167
+
168
+ Full and live audits read the open tab when that port accepts a connection. If it does not, the report says Chrome was not attached, and a full audit still returns the source findings. The tool does not launch a second browser. Lighthouse uses that same Chrome.
169
+
170
+ ## What this version does not do
171
+
172
+ - It does not check known-vulnerable npm packages.
173
+ - It does not time backend APIs except for calls visible on the open Chrome tab.
174
+ - It does not find memory leaks that are not an obvious missed teardown.
175
+ - It does not find security bugs outside the known browser sinks in the playbook.
176
+ - It does not fail CI on new findings.
177
+ - It does not review UX, layout, or visual design.
178
+
179
+ ## Develop
180
+
181
+ ```bash
182
+ git clone git@github.com:redjonsulaj/frontend-audit-mcp.git
183
+ cd frontend-audit-mcp
184
+ npm install
185
+ npm test
186
+ npm run build
187
+ node dist/cli.mjs audit --dir <path>
188
+ ```
189
+
190
+ `npm run build` compiles the workspaces and bundles them into `dist/cli.mjs`, which is the only code file published to npm.
191
+
192
+ To release, bump `version` in `package.json`, then run `npm publish`. `prepublishOnly` runs the tests and the build first.