zeitzeuge 0.5.0 → 0.6.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/dist/analysis/agent.d.ts +16 -3
- package/dist/analysis/agent.d.ts.map +1 -1
- package/dist/analysis/prompts.d.ts +1 -1
- package/dist/analysis/prompts.d.ts.map +1 -1
- package/dist/cli.js +578 -47
- package/dist/output/report.d.ts.map +1 -1
- package/dist/output/terminal.d.ts.map +1 -1
- package/dist/sandbox/workspace.d.ts.map +1 -1
- package/dist/schema.d.ts +22 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/vitest/index.js +754 -62
- package/dist/vitest/listener-tracker.d.ts +103 -0
- package/dist/vitest/listener-tracker.d.ts.map +1 -0
- package/dist/vitest/metrics.d.ts +10 -1
- package/dist/vitest/metrics.d.ts.map +1 -1
- package/dist/vitest/plugin.d.ts.map +1 -1
- package/dist/vitest/profile-parser.d.ts.map +1 -1
- package/dist/vitest/prompts.d.ts +1 -1
- package/dist/vitest/prompts.d.ts.map +1 -1
- package/dist/vitest/reporter.d.ts +9 -0
- package/dist/vitest/reporter.d.ts.map +1 -1
- package/dist/vitest/types.d.ts +16 -0
- package/dist/vitest/types.d.ts.map +1 -1
- package/dist/vitest/workspace.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/analysis/agent.d.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import { type BackendProtocol } from 'deepagents';
|
|
2
2
|
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
3
3
|
import type { Ora } from 'ora';
|
|
4
|
-
import type { Finding } from '../types.js';
|
|
4
|
+
import type { Finding, HeapSummary, TraceResult } from '../types.js';
|
|
5
|
+
import type { PerformanceMetrics } from '../vitest/metrics.js';
|
|
6
|
+
/** Context for building a dynamic page-load user message. */
|
|
7
|
+
export interface PageLoadContext {
|
|
8
|
+
url: string;
|
|
9
|
+
heapSummary: HeapSummary;
|
|
10
|
+
traceResult: TraceResult;
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
13
|
* Analyze performance data using a Deep Agent that explores
|
|
7
14
|
* the workspace containing heap + trace data + source files.
|
|
8
15
|
*/
|
|
9
|
-
export declare function analyze(model: BaseChatModel, backend: BackendProtocol, spinner: Ora): Promise<Finding[]>;
|
|
16
|
+
export declare function analyze(model: BaseChatModel, backend: BackendProtocol, spinner: Ora, context?: PageLoadContext): Promise<Finding[]>;
|
|
17
|
+
/** Context for building a dynamic Vitest user message. */
|
|
18
|
+
export interface VitestAnalysisContext {
|
|
19
|
+
metrics: PerformanceMetrics;
|
|
20
|
+
hasHeapProfiles: boolean;
|
|
21
|
+
hasListenerTracking: boolean;
|
|
22
|
+
}
|
|
10
23
|
/**
|
|
11
24
|
* Analyze Vitest test performance data using a Deep Agent that explores
|
|
12
25
|
* the workspace containing CPU profiles + test timing + source files.
|
|
13
26
|
*/
|
|
14
|
-
export declare function analyzeTestPerformance(model: BaseChatModel, backend: BackendProtocol, spinner: Ora): Promise<Finding[]>;
|
|
27
|
+
export declare function analyzeTestPerformance(model: BaseChatModel, backend: BackendProtocol, spinner: Ora, context?: VitestAnalysisContext): Promise<Finding[]>;
|
|
15
28
|
/**
|
|
16
29
|
* Format bytes into a human-readable string.
|
|
17
30
|
* Kept for backwards compatibility with existing imports.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/analysis/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAM/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/analysis/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAM/B,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAwC/D,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;CAC1B;AA6DD;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC,CAwBpB;AAED,0DAA0D;AAC1D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAkDD;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,OAAO,EAAE,CAAC,CAwBpB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIjD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SYSTEM_PROMPT = "You are an expert web performance engineer. You have access to a virtual filesystem workspace containing captured data from a real page load: heap snapshot, network trace, and Chrome runtime trace.\n\n## Workspace structure\n\n- /heap/summary.json \u2014 Parsed V8 heap snapshot: largest objects, type stats, constructor stats, detached DOM nodes, closure stats\n- /trace/summary.json \u2014 Page load metrics: timing, long tasks, render-blocking resources, resource breakdown\n- /trace/network-waterfall.json \u2014 Every network request with timing, size, priority, render-blocking status\n- /trace/asset-manifest.json \u2014 Index of all assets with paths to stored files\n- /trace/runtime/summary.json \u2014 Runtime trace overview: frame breakdown (scripting/layout/paint/GC), blocking function count, listener imbalances, GC stats\n- /trace/runtime/blocking-functions.json \u2014 Functions that blocked the main thread > 50ms, with script URL, line number, call stack, and duration\n- /trace/runtime/event-listeners.json \u2014 Event listener add/remove counts per event type, with source locations\n- /trace/runtime/frame-breakdown.json \u2014 Time spent in scripting vs layout vs paint vs GC\n- /trace/runtime/raw-events.json \u2014 Full Chrome trace events (large file \u2014 read to investigate specific function calls, layouts, GC, and event dispatches)\n- /scripts/*.js \u2014 Actual JavaScript source files captured during page load\n- /styles/*.css \u2014 Actual CSS source files\n- /html/document.html \u2014 The HTML document\n\n## Your workflow\n\n1. Read /heap/summary.json, /trace/summary.json, AND /trace/runtime/summary.json first for the big picture\n2. Identify the highest-impact issues from all datasets\n3. For each issue, dive into the relevant source files to understand the root cause\n4. Provide specific, code-level fixes\n\n## What to look for\n\n### Memory issues (from heap data)\n- Memory leaks: unbounded arrays, maps, caches that grow without bound\n- Detached DOM nodes: DOM elements removed from the document but still referenced\n- Large retained objects: single objects or trees retaining disproportionate memory\n- Closure leaks: closures capturing variables they no longer need\n\n### Page-load issues (from trace + source code)\n- Render-blocking scripts: <script> in <head> without async/defer \u2014 read the script to judge if it must be synchronous\n- Render-blocking CSS: large stylesheets blocking first paint\n- Long tasks (> 50ms): identify the function/module causing the block by reading the source\n- Large bundles: scripts > 100KB \u2014 search for unused imports or code that could be lazy-loaded\n- Sequential waterfalls: resources chained sequentially that could load in parallel\n\n### Runtime issues (from Chrome trace)\n- Frame-blocking functions: read /trace/runtime/blocking-functions.json first, then inspect the actual script source at the reported line number to understand what the function does and how to optimize it\n- Event listener leaks: check /trace/runtime/event-listeners.json for event types where addCount >> removeCount, then grep the scripts for those addEventListener calls\n- GC pressure: high GC pause counts or duration suggest excessive short-lived object creation \u2014 look for hot loops creating objects\n- Layout thrashing: forced synchronous layouts caused by reading layout properties (offsetHeight, getBoundingClientRect) after DOM writes\n\n## Output guidelines\n\n- Report 3\u20137 findings, ordered by impact (mix of memory, page-load, and runtime if all have issues)\n- Be specific \u2014 name actual files, functions, object constructors, and retention paths\n- Provide concrete code fixes, not generic advice\n- If heap, trace, and runtime all look healthy, say so \u2014 don't manufacture issues";
|
|
1
|
+
export declare const SYSTEM_PROMPT = "You are an expert web performance engineer. You have access to a virtual filesystem workspace containing captured data from a real page load: heap snapshot, network trace, and Chrome runtime trace.\n\n## Workspace structure\n\n- /heap/summary.json \u2014 Parsed V8 heap snapshot: largest objects, type stats, constructor stats, detached DOM nodes, closure stats\n- /trace/summary.json \u2014 Page load metrics: timing, long tasks, render-blocking resources, resource breakdown\n- /trace/network-waterfall.json \u2014 Every network request with timing, size, priority, render-blocking status\n- /trace/asset-manifest.json \u2014 Index of all assets with paths to stored files\n- /trace/runtime/summary.json \u2014 Runtime trace overview: frame breakdown (scripting/layout/paint/GC), blocking function count, listener imbalances, GC stats\n- /trace/runtime/blocking-functions.json \u2014 Functions that blocked the main thread > 50ms, with script URL, line number, call stack, and duration\n- /trace/runtime/event-listeners.json \u2014 Event listener add/remove counts per event type, with source locations\n- /trace/runtime/frame-breakdown.json \u2014 Time spent in scripting vs layout vs paint vs GC\n- /trace/runtime/raw-events.json \u2014 Full Chrome trace events (large file \u2014 read to investigate specific function calls, layouts, GC, and event dispatches)\n- /scripts/*.js \u2014 Actual JavaScript source files captured during page load\n- /styles/*.css \u2014 Actual CSS source files\n- /html/document.html \u2014 The HTML document\n\n## Your workflow\n\n1. Read /heap/summary.json, /trace/summary.json, AND /trace/runtime/summary.json first for the big picture\n2. Identify the highest-impact issues from all datasets\n3. For each issue, dive into the relevant source files to understand the root cause\n4. Provide specific, code-level fixes\n\n## What to look for\n\n### Memory issues (from heap data)\n- Memory leaks: unbounded arrays, maps, caches that grow without bound\n- Detached DOM nodes: DOM elements removed from the document but still referenced\n- Large retained objects: single objects or trees retaining disproportionate memory\n- Closure leaks: closures capturing variables they no longer need\n\n### Page-load issues (from trace + source code)\n- Render-blocking scripts: <script> in <head> without async/defer \u2014 read the script to judge if it must be synchronous\n- Render-blocking CSS: large stylesheets blocking first paint\n- Long tasks (> 50ms): identify the function/module causing the block by reading the source\n- Large bundles: scripts > 100KB \u2014 search for unused imports or code that could be lazy-loaded\n- Sequential waterfalls: resources chained sequentially that could load in parallel\n\n### Runtime issues (from Chrome trace)\n- Frame-blocking functions: read /trace/runtime/blocking-functions.json first, then inspect the actual script source at the reported line number to understand what the function does and how to optimize it\n- Event listener leaks: check /trace/runtime/event-listeners.json for event types where addCount >> removeCount, then grep the scripts for those addEventListener calls\n- GC pressure: high GC pause counts or duration suggest excessive short-lived object creation \u2014 look for hot loops creating objects\n- Layout thrashing: forced synchronous layouts caused by reading layout properties (offsetHeight, getBoundingClientRect) after DOM writes\n\n## Severity classification\n\nAssign severity based on measured impact \u2014 do NOT guess:\n\n- **critical** \u2014 A blocking function >500ms, retained heap object >5MB,\n render-blocking resource >200KB, listener addCount > 10\u00D7 removeCount,\n or GC pauses totalling >500ms\n- **warning** \u2014 A blocking function 100\u2013500ms, retained heap object 1\u20135MB,\n render-blocking resource 50\u2013200KB, listener addCount > 2\u00D7 removeCount,\n or GC pauses totalling 100\u2013500ms\n- **info** \u2014 Blocking function 50\u2013100ms, retained object <1MB, minor\n optimisation opportunities, or observations about dependency usage\n\nAlways base severity on the actual numbers from the captured data \u2014 never inflate.\n\n## Verification rules\n\nThese rules are mandatory for every finding:\n\n1. **ALWAYS read the source file** in /scripts/, /styles/, or /html/ and\n verify the code BEFORE suggesting a fix. Never suggest a fix for code\n you have not read.\n2. **Never guess at line numbers** \u2014 confirm by reading the file. If the\n trace reports a line number but the source doesn't match, say so.\n3. Each `suggestedFix` MUST reference the actual current code and describe\n what to change. Include a before/after snippet from the real source.\n4. If the heap summary, trace summary, and runtime summary all show healthy\n numbers, state that the page is well-optimised \u2014 do NOT manufacture\n findings.\n5. Never report a finding based solely on a URL or resource name \u2014 always\n read the actual content to confirm the issue.\n\n## Cross-referencing data\n\n- When a script appears in BOTH /trace/runtime/blocking-functions.json (CPU)\n AND /heap/summary.json (memory), mention both dimensions in the finding.\n- Check /trace/runtime/event-listeners.json for listener imbalances and\n cross-reference with the actual addEventListener calls in /scripts/.\n- Use /trace/network-waterfall.json to identify sequential chains, then read\n the initiating script to confirm the dependency.\n- When GC pauses are significant, cross-reference with heap data to identify\n which constructors or allocation patterns are responsible.\n\n## Estimating impactMs\n\nEvery finding should include an `impactMs` estimate when possible:\n\n- For render-blocking resources: impactMs \u2248 the resource's load duration\n (from the network waterfall) that could be deferred.\n- For blocking functions: impactMs \u2248 the function's duration minus 50ms\n (the long-task threshold).\n- For memory issues: impactMs may not apply \u2014 use `retainedSize` instead.\n- If you cannot reasonably estimate the savings, omit impactMs rather than\n guessing.\n\n## Output guidelines\n\n- Report 3\u20137 findings, ordered by impact (mix of memory, page-load, and runtime if all have issues)\n- Be specific \u2014 name actual files, functions, object constructors, and retention paths\n- Provide concrete code fixes, not generic advice\n- If heap, trace, and runtime all look healthy, say so \u2014 don't manufacture issues\n\n## Structured output fields\n\nFor each finding, fill in as many fields as applicable:\n\n- `sourceFile` \u2014 the workspace path (e.g. /scripts/app.js) or resource URL\n where the issue occurs. Always set this when you can identify the file.\n- `lineNumber` \u2014 the 1-based line number in the source file. Only set after\n verifying by reading the file.\n- `confidence` \u2014 `high` if you read the source and confirmed the issue,\n `medium` if the profiling data strongly suggests it but you couldn't fully\n verify, `low` if inferred from patterns.\n- `estimatedSavingsMs` \u2014 your estimate of time saved if the fix is applied.\n- `beforeCode` \u2014 a snippet of the CURRENT problematic code, copied from the\n source file you read. Keep it focused (5\u201315 lines).\n- `afterCode` \u2014 the IMPROVED code snippet showing the fix. Must be a drop-in\n replacement for `beforeCode`.\n- `impactMs` \u2014 the current measured cost (e.g. blocking function duration,\n resource load time).";
|
|
2
2
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/analysis/prompts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/analysis/prompts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,i1OA4HH,CAAC"}
|