@progen-labs/spectra 0.4.0 → 0.5.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/README.md CHANGED
@@ -11,10 +11,12 @@ exact function, file and line, the evidence, and a suggested fix.
11
11
  Deep component-level attribution for **React, Next.js, Vue and Angular** (component names, render counts
12
12
  and per-component render/change-detection time; source files too, where the framework exposes them). For
13
13
  **Svelte and any other build**, a source-mapped generic profile still pinpoints the slow files and
14
- functions. A [Progen Labs](https://github.com/progen-labs) project — open source, non-profit, no
15
- telemetry, no account required.
14
+ functions. The framework is detected in the page itself, so it is right wherever you start Spectra from.
15
+ Apps behind a login work too: Spectra [signs in first](#behind-a-login), with every kind of login. A
16
+ [Progen Labs](https://github.com/progen-labs) project — independent, open source, no telemetry, no account
17
+ required.
16
18
 
17
- **Watch the two-minute demo:** [progen-labs.github.io/website/#spectra/demo](https://progen-labs.github.io/website/#spectra/demo).
19
+ **Watch the demo (2½ minutes):** [progen-labs.github.io/website/#spectra/demo](https://progen-labs.github.io/website/#spectra/demo).
18
20
 
19
21
  **Documentation:** the full guide, with annotated screenshots of every screen, is at
20
22
  [progen-labs.github.io/website](https://progen-labs.github.io/website/#spectra/docs/introduction).
@@ -53,7 +55,7 @@ With no `--url`, Spectra:
53
55
  Automation: 8/8 golden paths passed.
54
56
  ```
55
57
 
56
- Then open the visual dashboard — ranked culprits, React re-renders, long tasks, the golden-path matrix,
58
+ Then open the visual dashboard — ranked culprits, component re-renders, long tasks, the golden-path matrix,
57
59
  **PDF export** and **commit-to-commit compare**:
58
60
 
59
61
  ```bash
@@ -87,13 +89,47 @@ spectra --version
87
89
  | `--command "<cmd>"` | Override the dev-server command |
88
90
  | `--boot-timeout <s>` | How long to wait for the dev server (default 60) |
89
91
  | `--headed` | Show the browser window |
90
- | `--sign-in <url>` | Sign-in URL template, e.g. `http://host/login/?redirect={url}` |
92
+ | `--login-url <url>`, `--login-user <name>` | Sign in first: the login page and the username; the password comes from `SPECTRA_LOGIN_PASSWORD` (see [Behind a login](#behind-a-login)) |
93
+ | `--login <method>` | `form`, `link`, `http`, `token` or `manual` (you sign in in the Chrome window); guessed when left out |
91
94
  | `--quick` | One page-load profile instead of the golden-path suite: the fast loop |
92
95
  | `--runs <n>` | Record n times and report the median (with `--quick` or `--mode`) |
93
96
  | `--mode live\|load` | Classic single-page profile instead of the golden-path suite |
94
97
  | `--json` | Print a machine-readable result on stdout (tables go to stderr) |
95
98
  | `--out <file>` | Also write that result to a file (an input for `compare`) |
96
- | `--config <file>` | Budgets file (default: `spectra.config.json` in your project) |
99
+ | `--config <file>` | Budgets and sign-in file (default: `spectra.config.json` in your project) |
100
+
101
+ ## Behind a login
102
+
103
+ Most production frontends sit behind a login, and the Chrome Spectra launches starts signed out. Tell
104
+ Spectra how your app signs in and it signs in before it records, so the login never shows up in a
105
+ measurement:
106
+
107
+ | Method | For |
108
+ | --- | --- |
109
+ | **Login form** (`form`) | A username and password on your app's login page or its identity provider (OAuth, OpenID Connect, SAML): one or two steps, forms that render late, in iframes or web components, behind a "Sign in" button, with **authenticator codes** from a TOTP secret |
110
+ | **I'll sign in myself** (`manual`) | SMS or email codes, push approvals, passkeys, CAPTCHAs: Chrome opens on the login page and Spectra waits for you |
111
+ | **Browser prompt** (`http`) | HTTP Basic or Digest, common on staging servers |
112
+ | **Token or cookie** (`token`) | A header (sent only to your app's origin), cookies or localStorage entries |
113
+ | **Sign-in link** (`link`) | A URL that signs in by itself, such as a dev-only auto-login |
114
+
115
+ In the dashboard, turn on **My app needs a sign-in** under **Page to profile**. On the command line:
116
+
117
+ ```bash
118
+ SPECTRA_LOGIN_PASSWORD="$TEST_PASSWORD" npx spectra performance --login-url http://localhost:3000/login --login-user demo@example.com
119
+ npx spectra performance --login manual --login-url https://staging.example.com/login
120
+ ```
121
+
122
+ Or once, for every command, the VS Code extension, the MCP server and `spectra fix`, in `spectra.config.json`:
123
+
124
+ ```json
125
+ { "signIn": { "method": "form", "url": "http://localhost:3000/login", "username": "demo@example.com" } }
126
+ ```
127
+
128
+ Secrets come only from the dashboard or the environment (`SPECTRA_LOGIN_PASSWORD`, `SPECTRA_LOGIN_TOTP_SECRET`,
129
+ `SPECTRA_LOGIN_HEADER`, `SPECTRA_LOGIN_COOKIES`, `SPECTRA_LOGIN_STORAGE`). They stay in memory: never written
130
+ to disk, a report, a log or an error message, and `spectra.config.json` refuses them. Spectra never solves
131
+ CAPTCHAs. Use a test account where you can. See
132
+ [Signing in](https://progen-labs.github.io/website/#spectra/docs/signing-in), with a short video.
97
133
 
98
134
  ## Measure, change, verify
99
135
 
@@ -235,12 +271,13 @@ The harness, not the agent, makes every decision:
235
271
  - **Proof.** The change is kept only if `spectra compare` says *improved* with medium or high confidence and no new
236
272
  critical finding; with low confidence it measures again.
237
273
  - **A record.** Each kept commit carries its evidence; `.spectra/fix/<time>/report.md` summarises the session, and a
238
- history skips findings that failed before.
274
+ history skips findings that failed before. A finding that an earlier kept fix already cleared is skipped too.
239
275
 
240
276
  By default the agent is Claude Code in headless mode, allowed only to read and edit files (no shell, no web, no MCP),
241
277
  with a spending cap per finding. A test bench (`npm run bench`) checks the harness's decisions in CI: a real fix is
242
278
  kept, a "faster" change that breaks the page is caught, a cosmetic change doesn't count, and an edit to
243
- `package.json` is refused. See [the AI fix harness](https://progen-labs.github.io/website/#spectra/docs/harness).
279
+ `package.json` is refused. With Claude Code on the demo app, it kept two of three fixes and cut JavaScript CPU time
280
+ from 1.51 s to 82.5 ms (−95%) for $0.44. See [the AI fix harness](https://progen-labs.github.io/website/#spectra/docs/harness).
244
281
 
245
282
  ## In VS Code
246
283
 
@@ -267,7 +304,8 @@ See the [VS Code guide](https://progen-labs.github.io/website/#spectra/docs/vsco
267
304
  Auto-exploration never triggers destructive actions. Spectra detects controls that would mutate state —
268
305
  anything labelled delete / pay / checkout / log out, logout links, and `POST`/`PUT`/`DELETE` form submits —
269
306
  and **skips** them unless you explicitly allow them. Form fields are filled with synthetic values; GET
270
- searches and navigations are fair game.
307
+ searches and navigations are fair game. If a session expires and the app sends Spectra back to its login page,
308
+ Spectra signs in again.
271
309
 
272
310
  ## Where results go
273
311
 
@@ -298,4 +336,15 @@ and report generation work.
298
336
 
299
337
  ## License
300
338
 
301
- MIT © Progen Labs
339
+ MIT © 2026 Sourav Debnath (Progen Labs)
340
+
341
+ <p align="center">
342
+ <a href="https://progen-labs.github.io/website/">
343
+ <picture>
344
+ <source media="(prefers-color-scheme: dark)" srcset="https://progen-labs.github.io/website/brand/progen-seed-mark.svg">
345
+ <img alt="Progen Labs" src="https://progen-labs.github.io/website/brand/progen-seed-mark-light.svg" height="72">
346
+ </picture>
347
+ </a>
348
+ <br>
349
+ <sub>Spectra is a <a href="https://progen-labs.github.io/website/">Progen Labs</a> project: independent, open source, always free.</sub>
350
+ </p>
package/bin/spectra.js CHANGED
@@ -21,6 +21,7 @@ import path from 'node:path';
21
21
  import { fileURLToPath } from 'node:url';
22
22
  import { bootDevServer } from '../server/explore/boot.js';
23
23
  import { detectFramework } from '../server/framework.js';
24
+ import { SIGN_IN_HELP } from '../server/signin.js';
24
25
 
25
26
  const here = path.dirname(fileURLToPath(import.meta.url));
26
27
  const PKG_ROOT = path.resolve(here, '..');
@@ -65,7 +66,8 @@ performance options:
65
66
  --command "<cmd>" Override the dev-server command (default: your npm dev script)
66
67
  --boot-timeout <s> How long to wait for the dev server (default 60)
67
68
  --headed Show the browser window
68
- --sign-in <url> Sign-in URL template, e.g. "http://host/login/?redirect={url}"
69
+
70
+ ${SIGN_IN_HELP}
69
71
 
70
72
  quick single-page profile (opt in with --quick, --mode or --scenario):
71
73
  --quick One page-load profile (about 15 s): the fast loop
@@ -80,7 +82,7 @@ output and checks (any performance run):
80
82
  --json Print a machine-readable result on stdout (progress and
81
83
  tables go to stderr)
82
84
  --out <file> Also write that result to a file (input for compare)
83
- --config <file> Budgets file (default: spectra.config.json in the project)
85
+ --config <file> Budgets and sign-in file (default: spectra.config.json)
84
86
 
85
87
  compare options:
86
88
  <before> <after> Each: a report id, a report file, a --out result file,
@@ -88,8 +90,9 @@ compare options:
88
90
  --json, --out <file> As above
89
91
  --fail-on-regression Exit with code 2 when a key metric got worse
90
92
 
91
- Budgets (spectra.config.json in your project root):
92
- { "budgets": { "tbtMs": 200, "lcpMs": 2500, "cls": 0.1, "criticalFindings": 0 } }
93
+ Budgets and sign-in (spectra.config.json in your project root):
94
+ { "budgets": { "tbtMs": 200, "lcpMs": 2500, "cls": 0.1, "criticalFindings": 0 },
95
+ "signIn": { "method": "form", "url": "http://localhost:3000/login", "username": "me@example.com" } }
93
96
 
94
97
  Exit codes: 0 done · 1 could not run · 2 over budget / regression
95
98
 
@@ -102,6 +105,7 @@ Examples:
102
105
  spectra compare before.json after.json # did the change help?
103
106
  spectra fix --max-fixes 3 # let an agent fix them, verified
104
107
  spectra performance --json | jq .summary # pipe it anywhere
108
+ SPECTRA_LOGIN_PASSWORD=… spectra performance --login-url http://localhost:3000/login --login-user me@example.com
105
109
  `;
106
110
 
107
111
  // What a terminate signal must clean up: the running script and a dev server