zeitzeuge 0.6.6 → 0.7.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 +1 -1
- package/README.md +22 -160
- package/dist/cli.js +2685 -2296
- package/package.json +9 -28
- package/dist/analysis/agent.d.ts +0 -33
- package/dist/analysis/agent.d.ts.map +0 -1
- package/dist/analysis/parser.d.ts +0 -3
- package/dist/analysis/parser.d.ts.map +0 -1
- package/dist/analysis/prompts.d.ts +0 -2
- package/dist/analysis/prompts.d.ts.map +0 -1
- package/dist/browser/capture.d.ts +0 -14
- package/dist/browser/capture.d.ts.map +0 -1
- package/dist/browser/launch.d.ts +0 -6
- package/dist/browser/launch.d.ts.map +0 -1
- package/dist/browser/runtime-trace.d.ts +0 -52
- package/dist/browser/runtime-trace.d.ts.map +0 -1
- package/dist/browser/trace.d.ts +0 -8
- package/dist/browser/trace.d.ts.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/models/init.d.ts +0 -3
- package/dist/models/init.d.ts.map +0 -1
- package/dist/output/progress.d.ts +0 -30
- package/dist/output/progress.d.ts.map +0 -1
- package/dist/output/report.d.ts +0 -40
- package/dist/output/report.d.ts.map +0 -1
- package/dist/output/terminal.d.ts +0 -40
- package/dist/output/terminal.d.ts.map +0 -1
- package/dist/sandbox/workspace.d.ts +0 -33
- package/dist/sandbox/workspace.d.ts.map +0 -1
- package/dist/schema.d.ts +0 -86
- package/dist/schema.d.ts.map +0 -1
- package/dist/types.d.ts +0 -245
- package/dist/types.d.ts.map +0 -1
- package/dist/vitest/classify.d.ts +0 -19
- package/dist/vitest/classify.d.ts.map +0 -1
- package/dist/vitest/heap-profile-parser.d.ts +0 -12
- package/dist/vitest/heap-profile-parser.d.ts.map +0 -1
- package/dist/vitest/index.d.ts +0 -19
- package/dist/vitest/index.d.ts.map +0 -1
- package/dist/vitest/index.js +0 -3014
- package/dist/vitest/listener-tracker.d.ts +0 -110
- package/dist/vitest/listener-tracker.d.ts.map +0 -1
- package/dist/vitest/metrics.d.ts +0 -91
- package/dist/vitest/metrics.d.ts.map +0 -1
- package/dist/vitest/plugin.d.ts +0 -17
- package/dist/vitest/plugin.d.ts.map +0 -1
- package/dist/vitest/profile-parser.d.ts +0 -13
- package/dist/vitest/profile-parser.d.ts.map +0 -1
- package/dist/vitest/prompts.d.ts +0 -10
- package/dist/vitest/prompts.d.ts.map +0 -1
- package/dist/vitest/reporter.d.ts +0 -94
- package/dist/vitest/reporter.d.ts.map +0 -1
- package/dist/vitest/types.d.ts +0 -249
- package/dist/vitest/types.d.ts.map +0 -1
- package/dist/vitest/workspace.d.ts +0 -25
- package/dist/vitest/workspace.d.ts.map +0 -1
- package/vitest.d.ts +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,168 +1,46 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src=".github/assets/zeitzeuge.png" alt="ZeitZeuge mascot: a detective stopwatch with a magnifying glass witnessing slowdowns" width="220" />
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
1
|
# zeitzeuge
|
|
6
2
|
|
|
7
|
-
AI-powered performance analysis for frontend page loads
|
|
8
|
-
|
|
9
|
-
> _"Zeuge" = witness — the tool "witnesses" slowdowns in your page loads and test runs._
|
|
3
|
+
AI-powered performance analysis for frontend page loads. Launches Chrome, captures V8 heap snapshots, performance traces, and Chrome runtime traces in a single page load, then hands everything to a Deep Agent that investigates bottlenecks and provides code-level fixes.
|
|
10
4
|
|
|
11
|
-
|
|
5
|
+
> _"Zeuge" = witness -- the tool "witnesses" slowdowns in your page loads._
|
|
12
6
|
|
|
13
|
-
|
|
7
|
+
## Install
|
|
14
8
|
|
|
15
9
|
```bash
|
|
16
|
-
|
|
17
|
-
export OPENAI_API_KEY=sk-... # or ANTHROPIC_API_KEY
|
|
18
|
-
|
|
19
|
-
# Analyze any URL
|
|
20
|
-
npx zeitzeuge http://localhost:3000
|
|
10
|
+
npm install -g zeitzeuge
|
|
21
11
|
```
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Add the plugin to your `vitest.config.ts` to profile your test suite and get AI-powered analysis of your **application code** performance:
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import { defineConfig } from 'vitest/config';
|
|
29
|
-
import { zeitzeuge } from 'zeitzeuge/vitest';
|
|
13
|
+
Requires an LLM API key:
|
|
30
14
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
15
|
+
```bash
|
|
16
|
+
export OPENAI_API_KEY=sk-... # or ANTHROPIC_API_KEY
|
|
34
17
|
```
|
|
35
18
|
|
|
36
|
-
|
|
19
|
+
## Usage
|
|
37
20
|
|
|
38
21
|
```bash
|
|
39
|
-
|
|
22
|
+
zeitzeuge http://localhost:3000
|
|
40
23
|
```
|
|
41
24
|
|
|
42
25
|
A Markdown report is written to `zeitzeuge-report.md` with findings and suggested fixes.
|
|
43
26
|
|
|
44
27
|
## How it works
|
|
45
28
|
|
|
46
|
-
### Page-load mode (`npx zeitzeuge <url>`)
|
|
47
|
-
|
|
48
29
|
1. **Launches Chrome** via WebdriverIO with DevTools Protocol access
|
|
49
30
|
2. **Captures everything in one page load:**
|
|
50
31
|
- V8 heap snapshot (memory analysis)
|
|
51
32
|
- Performance trace (network waterfall, long tasks, paint timing)
|
|
52
|
-
-
|
|
33
|
+
- Chrome runtime trace via the [Tracing domain](https://chromedevtools.github.io/devtools-protocol/tot/Tracing/) -- every function call, event dispatch, layout, paint, and GC event on the main thread
|
|
53
34
|
- All network assets (scripts, CSS, HTML source code)
|
|
54
|
-
3. **Builds a VFS workspace** using `@langchain/node-vfs`
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- `/trace/runtime/blocking-functions.json` — functions blocking the main thread > 50ms
|
|
58
|
-
- `/trace/runtime/event-listeners.json` — event listener add/remove imbalances
|
|
59
|
-
- `/trace/runtime/frame-breakdown.json` — time breakdown: scripting vs layout vs paint vs GC
|
|
60
|
-
- `/scripts/`, `/styles/`, `/html/` — actual source files
|
|
61
|
-
4. **Deep Agent explores** — a LangChain Deep Agent (`deepagents`) autonomously browses the workspace, reads actual source code, greps for patterns, and correlates heap data with trace data and runtime analysis
|
|
62
|
-
5. **Reports findings** — memory leaks, frame-blocking functions, listener leaks, render-blocking scripts, GC pressure — with code-level fixes
|
|
63
|
-
|
|
64
|
-
### Vitest mode (`zeitzeuge/vitest` plugin)
|
|
65
|
-
|
|
66
|
-
1. **Instruments Vitest** — injects `--cpu-prof` into worker process args, forces `pool: 'forks'` for reliable profiling, disables file parallelism for clean per-file profiles
|
|
67
|
-
2. **Captures V8 CPU profiles** for each test file during the test run
|
|
68
|
-
3. **Classifies hot functions** — every profiled function is categorized as `application`, `dependency`, `test`, or `framework` based on its file path relative to your project root
|
|
69
|
-
4. **Builds a VFS workspace** containing:
|
|
70
|
-
- `/hot-functions/application.json` — hotspots in **your** code (primary focus)
|
|
71
|
-
- `/hot-functions/dependencies.json` — hotspots in third-party code
|
|
72
|
-
- `/scripts/application.json` — per-file CPU time for your source files
|
|
73
|
-
- `/scripts/dependencies.json` — per-file CPU time for dependencies
|
|
74
|
-
- `/profiles/*.json` — full CPU profile summaries with call trees
|
|
75
|
-
- `/timing/overview.json` — per-test timing data
|
|
76
|
-
- `/src/`, `/tests/` — actual source files referenced by hot functions
|
|
77
|
-
5. **Deep Agent analyzes your application code** — focuses on bottlenecks in the code you wrote, not test infrastructure overhead. Reports dependency issues when your code makes expensive calls into libraries.
|
|
35
|
+
3. **Builds a VFS workspace** using `@langchain/node-vfs` containing parsed heap data, trace summaries, runtime analysis, and actual source files
|
|
36
|
+
4. **Deep Agent explores** -- a LangChain Deep Agent autonomously browses the workspace, reads source code, and correlates heap data with trace and runtime data
|
|
37
|
+
5. **Reports findings** -- memory leaks, frame-blocking functions, listener leaks, render-blocking scripts, GC pressure -- with code-level fixes
|
|
78
38
|
|
|
79
39
|
## What it finds
|
|
80
40
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
**
|
|
84
|
-
|
|
85
|
-
- Memory leaks (unbounded caches, growing arrays/maps)
|
|
86
|
-
- Detached DOM nodes still referenced in JavaScript
|
|
87
|
-
- Large retained objects and closure leaks
|
|
88
|
-
|
|
89
|
-
**Page-load issues:**
|
|
90
|
-
|
|
91
|
-
- Render-blocking scripts (`<script>` without `async`/`defer`)
|
|
92
|
-
- Render-blocking stylesheets
|
|
93
|
-
- Long main-thread tasks (> 50ms)
|
|
94
|
-
- Oversized bundles and unused code
|
|
95
|
-
- Sequential waterfall bottlenecks
|
|
96
|
-
|
|
97
|
-
**Runtime issues:**
|
|
98
|
-
|
|
99
|
-
- **Frame-blocking functions** — exact function name, script URL, line number, and call stack for any function blocking the main thread > 50ms
|
|
100
|
-
- **Event listener leaks** — `addEventListener` calls without matching `removeEventListener`, growing listener counts
|
|
101
|
-
- **GC pressure** — frequent or long garbage collection pauses indicating memory churn
|
|
102
|
-
- **Layout thrashing** — forced synchronous layouts from reading layout properties after DOM mutations
|
|
103
|
-
|
|
104
|
-
### Vitest analysis
|
|
105
|
-
|
|
106
|
-
**Application code bottlenecks:**
|
|
107
|
-
|
|
108
|
-
- Hot functions with high self time in your source code
|
|
109
|
-
- Expensive algorithms (O(n^2) loops, redundant computation, unnecessary sorting)
|
|
110
|
-
- Object allocation hotspots driving GC pressure
|
|
111
|
-
- Synchronous blocking in hot paths (file I/O, crypto, JSON serialization)
|
|
112
|
-
|
|
113
|
-
**Dependency bottlenecks:**
|
|
114
|
-
|
|
115
|
-
- Third-party libraries consuming disproportionate CPU
|
|
116
|
-
- Unnecessary calls to expensive dependency APIs in hot paths
|
|
117
|
-
- Suggestions for alternative libraries or configuration changes
|
|
118
|
-
|
|
119
|
-
**GC pressure:**
|
|
120
|
-
|
|
121
|
-
- Functions creating many short-lived objects in tight loops
|
|
122
|
-
- Large allocations that could be pooled or reused
|
|
123
|
-
|
|
124
|
-
## Vitest plugin options
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
zeitzeuge({
|
|
128
|
-
// Enable/disable the plugin (default: true)
|
|
129
|
-
enabled: true,
|
|
130
|
-
|
|
131
|
-
// Path for the Markdown report (default: 'zeitzeuge-report.md')
|
|
132
|
-
output: 'zeitzeuge-report.md',
|
|
133
|
-
|
|
134
|
-
// Directory for temporary .cpuprofile files (default: '.zeitzeuge-profiles')
|
|
135
|
-
profileDir: '.zeitzeuge-profiles',
|
|
136
|
-
|
|
137
|
-
// Also write V8 heap profiles (.heapprofile) for workers (default: false)
|
|
138
|
-
// Uses: --heap-prof + --heap-prof-dir=<profileDir>
|
|
139
|
-
heapProf: false,
|
|
140
|
-
|
|
141
|
-
// Run Deep Agent analysis after tests finish (default: true)
|
|
142
|
-
analyzeOnFinish: true,
|
|
143
|
-
|
|
144
|
-
// Project root for classifying application vs dependency code (default: process.cwd())
|
|
145
|
-
projectRoot: process.cwd(),
|
|
146
|
-
|
|
147
|
-
// Enable debug logging (default: false)
|
|
148
|
-
verbose: false,
|
|
149
|
-
});
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### Heap profiling (`heapProf`) — when to enable it
|
|
153
|
-
|
|
154
|
-
`heapProf` captures **allocation sampling** (written as `.heapprofile` files) and can help you find:
|
|
155
|
-
|
|
156
|
-
- Allocation hotspots (functions / modules allocating lots of bytes)
|
|
157
|
-
- High GC pressure caused by excessive short-lived objects
|
|
158
|
-
|
|
159
|
-
It defaults to **`false`** because it can be a net negative for everyday runs:
|
|
160
|
-
|
|
161
|
-
- **Overhead**: allocation sampling adds runtime overhead and can skew timings/CPU profiles
|
|
162
|
-
- **Artifact size / IO**: `.heapprofile` files can be large, increasing IO and CI flakiness
|
|
163
|
-
- **Noise**: test runners allocate a lot in setup/framework code; heap data can be less actionable unless you’re specifically chasing allocations/GC
|
|
164
|
-
|
|
165
|
-
Recommendation: keep it off by default and enable it when you suspect **allocation/GC issues** or when CPU hotspots alone aren’t explaining slow tests.
|
|
41
|
+
- **Memory issues** -- leaks, detached DOM nodes, large retained objects, closure leaks
|
|
42
|
+
- **Page-load issues** -- render-blocking scripts/stylesheets, long tasks, oversized bundles, sequential waterfalls
|
|
43
|
+
- **Runtime issues** -- frame-blocking functions (with exact source location and call stack), event listener leaks, GC pressure, layout thrashing
|
|
166
44
|
|
|
167
45
|
## CLI options
|
|
168
46
|
|
|
@@ -173,6 +51,7 @@ Options:
|
|
|
173
51
|
--verbose, -v Enable verbose/debug logging [boolean] [default: false]
|
|
174
52
|
--headless Run Chrome in headless mode [boolean] [default: true]
|
|
175
53
|
--timeout Page load timeout in milliseconds [number] [default: 30000]
|
|
54
|
+
--output, -o Output path for the Markdown report [string] [default: "zeitzeuge-report.md"]
|
|
176
55
|
--help, -h Show help [boolean]
|
|
177
56
|
--version Show version number [boolean]
|
|
178
57
|
```
|
|
@@ -185,28 +64,11 @@ Options:
|
|
|
185
64
|
| `ANTHROPIC_API_KEY` | Anthropic API key (fallback) |
|
|
186
65
|
| `ZEITZEUGE_MODEL` | Override model name (e.g. `gpt-4o`, `claude-sonnet-4-20250514`) |
|
|
187
66
|
|
|
188
|
-
##
|
|
67
|
+
## Related packages
|
|
189
68
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
bun install
|
|
193
|
-
|
|
194
|
-
# Run in development
|
|
195
|
-
bun run dev -- http://localhost:3000
|
|
196
|
-
|
|
197
|
-
# Run tests
|
|
198
|
-
bun test
|
|
199
|
-
|
|
200
|
-
# Build for distribution
|
|
201
|
-
bun run build
|
|
202
|
-
```
|
|
69
|
+
- [`@zeitzeuge/vitest`](../vitest/) -- Vitest plugin for test suite performance analysis
|
|
70
|
+
- [`@zeitzeuge/utils`](../utils/) -- Shared internals (private, not published)
|
|
203
71
|
|
|
204
|
-
##
|
|
72
|
+
## License
|
|
205
73
|
|
|
206
|
-
|
|
207
|
-
- **Browser automation:** [WebdriverIO](https://webdriver.io) + Chrome DevTools Protocol
|
|
208
|
-
- **Runtime tracing:** [CDP Tracing domain](https://chromedevtools.github.io/devtools-protocol/tot/Tracing/) for function-level main-thread analysis
|
|
209
|
-
- **V8 CPU profiling:** `--cpu-prof` for per-function timing in test suites
|
|
210
|
-
- **AI analysis:** [Deep Agents](https://docs.langchain.com/oss/javascript/deepagents/overview) + [LangChain](https://langchain.com)
|
|
211
|
-
- **Virtual filesystem:** [@langchain/node-vfs](https://docs.langchain.com/oss/javascript/integrations/providers/node-vfs) — in-memory VFS sandbox
|
|
212
|
-
- **LLM providers:** OpenAI, Anthropic (auto-detected from environment)
|
|
74
|
+
MIT
|