trace-engine-cli 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.
- package/LICENSE +202 -0
- package/README.md +342 -2
- package/dist/bin/trace-cli.d.ts +2 -0
- package/dist/bin/trace-cli.js +19 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +477 -0
- package/dist/src/engine/adapter.d.ts +13 -0
- package/dist/src/engine/adapter.js +51 -0
- package/dist/src/engine/extractors/diff.d.ts +12 -0
- package/dist/src/engine/extractors/diff.js +100 -0
- package/dist/src/engine/extractors/events.d.ts +27 -0
- package/dist/src/engine/extractors/events.js +84 -0
- package/dist/src/engine/extractors/find.d.ts +12 -0
- package/dist/src/engine/extractors/find.js +100 -0
- package/dist/src/engine/extractors/insights.d.ts +15 -0
- package/dist/src/engine/extractors/insights.js +153 -0
- package/dist/src/engine/extractors/interactions.d.ts +7 -0
- package/dist/src/engine/extractors/interactions.js +55 -0
- package/dist/src/engine/extractors/navigations.d.ts +10 -0
- package/dist/src/engine/extractors/navigations.js +82 -0
- package/dist/src/engine/extractors/network.d.ts +10 -0
- package/dist/src/engine/extractors/network.js +105 -0
- package/dist/src/engine/extractors/overview.d.ts +11 -0
- package/dist/src/engine/extractors/overview.js +232 -0
- package/dist/src/engine/extractors/profile.d.ts +12 -0
- package/dist/src/engine/extractors/profile.js +83 -0
- package/dist/src/engine/extractors/scan.d.ts +37 -0
- package/dist/src/engine/extractors/scan.js +218 -0
- package/dist/src/engine/extractors/scheduling.d.ts +10 -0
- package/dist/src/engine/extractors/scheduling.js +89 -0
- package/dist/src/engine/extractors/shifts.d.ts +11 -0
- package/dist/src/engine/extractors/shifts.js +118 -0
- package/dist/src/engine/extractors/tasks.d.ts +13 -0
- package/dist/src/engine/extractors/tasks.js +156 -0
- package/dist/src/engine/helpers.d.ts +157 -0
- package/dist/src/engine/helpers.js +95 -0
- package/dist/src/engine/loader.d.ts +34 -0
- package/dist/src/engine/loader.js +142 -0
- package/dist/src/engine/types.d.ts +452 -0
- package/dist/src/engine/types.js +14 -0
- package/dist/src/formatters/index.d.ts +6 -0
- package/dist/src/formatters/index.js +66 -0
- package/dist/src/formatters/markdown.d.ts +15 -0
- package/dist/src/formatters/markdown.js +474 -0
- package/dist/src/formatters/toon.d.ts +1 -0
- package/dist/src/formatters/toon.js +17 -0
- package/dist/src/utils/filter.d.ts +47 -0
- package/dist/src/utils/filter.js +136 -0
- package/dist/src/utils/units.d.ts +24 -0
- package/dist/src/utils/units.js +57 -0
- package/package.json +45 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,343 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Trace Engine CLI (`trace-cli`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A fast, standalone, token-efficient command-line tool built on top of Chrome DevTools Trace Engine. It inspects Chromium performance traces (`.json` or `.json.gz`) and converts them into structured, high-signal summaries optimized for LLM context windows, AI coding agents, and developer performance diagnostics.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Why `trace-cli`?
|
|
8
|
+
|
|
9
|
+
Raw Chromium performance traces are massive (often 20MB–200MB+ uncompressed), containing millions of low-level JSON events. Feeding raw traces directly to an LLM quickly exhausts token limits, incurs high costs, and drowns the model in noise.
|
|
10
|
+
|
|
11
|
+
`trace-cli` solves this by:
|
|
12
|
+
- **Token Compression**: Reduces trace context sizes by up to **95%+** through domain-specific extractors and tabular **TOON** (Token-Oriented Object Notation) serialization.
|
|
13
|
+
- **Chrome DevTools Trace Engine Integration**: Uses Chrome DevTools' battle-tested Trace Engine (`@paulirish/trace_engine`) to compute exact Core Web Vitals, task trees, and insight models.
|
|
14
|
+
- **Relative Timeline Model**: Defaults to elapsed time from trace start (`0ms`), matching the DevTools Performance panel timeline ruler and eliminating timestamp calculation errors.
|
|
15
|
+
- **Progressive Drill-Down**: Guides agents and humans from high-level summaries (`overview`) down into specific performance bottlenecks (`insights`, `tasks`, `find`, `profile`, `diff`, `scheduling`, `network`, `interactions`, `shifts`, `events`, `navigations`, `scan`).
|
|
16
|
+
- **Flexible Engine Resolution**: Uses `@paulirish/trace_engine` by default, or bundles single-file trace engine artifacts directly from local `devtools-frontend` checkouts.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Install [`trace-engine-cli`](https://www.npmjs.com/package/trace-engine-cli) globally from npm to add `trace-cli` to your `$PATH`:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g trace-engine-cli
|
|
26
|
+
trace-cli /path/to/trace.json.gz
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or run it directly with `npx`:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx trace-engine-cli /path/to/trace.json.gz
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Pointing AI Agents at `trace-cli`
|
|
38
|
+
|
|
39
|
+
To equip an AI assistant (or agent in your workspace) to analyze performance traces, add the following instruction to the agent's prompt or project rules:
|
|
40
|
+
|
|
41
|
+
> "To inspect Chromium performance traces (`.json` or `.json.gz`), run `trace-cli <file>`. Inspect the default overview, then use the suggested drill-down commands (`insights`, `tasks`, `find`, `profile`, `diff`, `scheduling`, `network`, `interactions`, `shifts`, `events`, `navigations`) for targeted diagnostics, or `scan <dir-or-glob>` to search across multiple fixtures."
|
|
42
|
+
|
|
43
|
+
Agents receive dense, token-efficient TOON tables that minimize prompt context consumption while providing structured metrics and actionable next steps.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
Invoking `trace-cli` with just a trace file path runs the `overview` command and prints recommended drill-down next steps:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Default overview in TOON format (optimized for LLMs)
|
|
53
|
+
trace-cli trace.json.gz
|
|
54
|
+
|
|
55
|
+
# Overview in Markdown format (optimized for humans & GitHub)
|
|
56
|
+
trace-cli trace.json.gz --format md
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Global Options
|
|
60
|
+
|
|
61
|
+
| Option | Type | Default | Description |
|
|
62
|
+
| :--- | :--- | :--- | :--- |
|
|
63
|
+
| `-f, --format` | `'toon' \| 'md'` | `'toon'` | Output serialization format (`toon` or `md`) |
|
|
64
|
+
| `--time-range` | `string` | — | Filter window relative to trace start (e.g. `"3500,4200"`, `"3.5s,4.2s"`, `"100ms-500ms"`) |
|
|
65
|
+
| `--absolute-timestamps` | `boolean` | `false` | Treat time ranges as raw absolute trace timestamps rather than relative to trace start |
|
|
66
|
+
| `--trace-engine`| `string` | — | Path to a custom DevTools trace engine bundle |
|
|
67
|
+
| `--help` | `boolean` | — | Show help and synopsis |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Relative vs. Absolute Timestamps & Units
|
|
72
|
+
|
|
73
|
+
All time-range inputs (`--time-range`, `--window-a`, `--window-b`, `--bucket`) support:
|
|
74
|
+
- **Relative timestamps by default**: `0` or `0ms` represents trace start (`bounds.minMs`). `3500` or `3.5s` represents `bounds.minMs + 3500ms`.
|
|
75
|
+
- **Unit suffixes**:
|
|
76
|
+
- `s` (seconds): e.g. `3.5s`, `4.2s`
|
|
77
|
+
- `ms` (milliseconds, default): e.g. `3500ms`, `500`
|
|
78
|
+
- `us` / `µs` (microseconds): e.g. `3500000us`
|
|
79
|
+
- **Range formats**: Comma (`"3.5s,4.2s"`), colon (`"3.5s:4.2s"`), range dots (`"3500ms..4200ms"`), or hyphen (`"100ms-500ms"`).
|
|
80
|
+
- **Absolute mode**: Pass `--absolute-timestamps` to specify raw trace timestamps.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Subcommands
|
|
85
|
+
|
|
86
|
+
### 1. `overview`
|
|
87
|
+
High-level trace metadata, Core Web Vitals (FCP, LCP, CLS, INP), non-overlapping main-thread category breakdown (Scripting, Layout, Rendering, GC, System, Idle), and diagnostic warnings.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
trace-cli overview trace.json.gz
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Example TOON Output:**
|
|
94
|
+
```yaml
|
|
95
|
+
bounds:
|
|
96
|
+
minMs: 122410994.89
|
|
97
|
+
maxMs: 122416385.85
|
|
98
|
+
durationMs: 5390.96
|
|
99
|
+
mainUrl: "https://web.dev/"
|
|
100
|
+
navigationStartMs: 122410996.89
|
|
101
|
+
coreWebVitals:
|
|
102
|
+
fcp:
|
|
103
|
+
valueMs: 129.21
|
|
104
|
+
rating: good
|
|
105
|
+
lcp:
|
|
106
|
+
valueMs: 129.21
|
|
107
|
+
rating: good
|
|
108
|
+
url: "https://web-dev.imgix.net/image/example.svg"
|
|
109
|
+
cls:
|
|
110
|
+
value: 0
|
|
111
|
+
rating: good
|
|
112
|
+
worstClusterScore: null
|
|
113
|
+
inp: null
|
|
114
|
+
mainThreadBreakdown:
|
|
115
|
+
scriptingMs: 1.69
|
|
116
|
+
layoutMs: 80.13
|
|
117
|
+
renderingMs: 17.9
|
|
118
|
+
gcMs: 0.07
|
|
119
|
+
systemMs: 233.52
|
|
120
|
+
idleMs: 5057.64
|
|
121
|
+
totalMs: 5390.96
|
|
122
|
+
warnings[1]: 1 render-blocking resource(s) detected.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### 2. `insights`
|
|
128
|
+
Extracts actionable diagnostic insight cards generated by Chrome DevTools Insight models.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# All insights
|
|
132
|
+
trace-cli insights trace.json.gz
|
|
133
|
+
|
|
134
|
+
# Filter by diagnostic category
|
|
135
|
+
trace-cli insights trace.json.gz --category lcp
|
|
136
|
+
trace-cli insights trace.json.gz --category inp
|
|
137
|
+
trace-cli insights trace.json.gz --category cls
|
|
138
|
+
trace-cli insights trace.json.gz --category render-blocking
|
|
139
|
+
trace-cli insights trace.json.gz --category third-parties
|
|
140
|
+
|
|
141
|
+
# Target a specific navigation ID or InsightSet ID
|
|
142
|
+
trace-cli insights trace.json.gz --navigation NAVIGATION_0
|
|
143
|
+
trace-cli insights trace.json.gz --navigation 9E74B39B7C378297071F6E3618C4BC14
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### 3. `tasks`
|
|
149
|
+
Main thread task execution, long tasks, and aggregated call trees.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# List long tasks above 50ms (default)
|
|
153
|
+
trace-cli tasks trace.json.gz
|
|
154
|
+
|
|
155
|
+
# Custom duration threshold and limit within relative window
|
|
156
|
+
trace-cli tasks trace.json.gz --min-duration 20 --time-range "1s,4s" --top 10
|
|
157
|
+
|
|
158
|
+
# Bottom-up call tree (aggregated and sorted by self-time)
|
|
159
|
+
trace-cli tasks trace.json.gz --tree bottom-up --top 20
|
|
160
|
+
|
|
161
|
+
# Top-down call tree (aggregated and sorted by total duration)
|
|
162
|
+
trace-cli tasks trace.json.gz --tree top-down --top 20
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### 4. `find`
|
|
168
|
+
Search for executions of a specific function name or pattern to verify call frequency, duration, or confirm starvation (0 calls in window).
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Search for invocations of a function across the whole trace
|
|
172
|
+
trace-cli find trace.json.gz --function "drawEventTiles"
|
|
173
|
+
|
|
174
|
+
# Query within a specific relative time window
|
|
175
|
+
trace-cli find trace.json.gz --function "drawEventTiles" --time-range "3.5s,4.2s"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### 5. `profile`
|
|
181
|
+
Time-bucketed CPU profiling progression across discrete slices (e.g. 50ms buckets) to analyze temporal shifts in CPU consumption during gestures.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Profile with automatic bucket sizing
|
|
185
|
+
trace-cli profile trace.json.gz --time-range "3.5s,4.1s"
|
|
186
|
+
|
|
187
|
+
# Specify 50ms bucket slices and top 5 functions per slice
|
|
188
|
+
trace-cli profile trace.json.gz --time-range "3500ms,4100ms" --bucket 50ms --top 5
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### 6. `diff`
|
|
194
|
+
Differential CPU profiling comparing non-overlapping time windows in the trace (e.g. stalled gesture window vs healthy recovery window).
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
trace-cli diff trace.json.gz --window-a "3.55s,4.0s" --window-b "4.0s,4.45s" --top 10
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### 7. `scheduling`
|
|
203
|
+
Inspects async task and animation frame scheduling lifecycle (`requestAnimationFrame`, `setTimeout`), detecting cancellation rates and rAF/timer thrashing.
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Async task metrics for the full trace
|
|
207
|
+
trace-cli scheduling trace.json.gz
|
|
208
|
+
|
|
209
|
+
# Narrow to a specific relative interaction window
|
|
210
|
+
trace-cli scheduling trace.json.gz --time-range "3.5s,4.1s"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### 8. `network`
|
|
216
|
+
Network request waterfall, priority, timings (Queueing, DNS, SSL, TTFB, Download), and request initiator chains.
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Top 20 slowest requests
|
|
220
|
+
trace-cli network trace.json.gz --slowest 20
|
|
221
|
+
|
|
222
|
+
# Filter render-blocking resources only
|
|
223
|
+
trace-cli network trace.json.gz --render-blocking
|
|
224
|
+
|
|
225
|
+
# Inspect the upstream initiator chain for a request (by requestId or URL)
|
|
226
|
+
trace-cli network trace.json.gz --initiator-chain "analytics.js"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### 9. `interactions`
|
|
232
|
+
Inspects user interaction latencies (Interaction to Next Paint - INP), broken down into input delay, processing duration, and presentation delay with target DOM node selectors.
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
trace-cli interactions trace.json.gz
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
### 10. `shifts`
|
|
241
|
+
Cumulative Layout Shift (CLS) session window clusters, cumulative scores, and culprit DOM elements causing visual instability. Pass `--events` to include individual shift event payloads, navigation IDs, and impacted DOM nodes.
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Cluster summary
|
|
245
|
+
trace-cli shifts trace.json.gz
|
|
246
|
+
|
|
247
|
+
# Include individual shift events and impacted node debug names
|
|
248
|
+
trace-cli shifts trace.json.gz --events
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### 11. `events`
|
|
254
|
+
Inspect and filter raw trace events directly without custom parsing scripts. Supports filtering by event name, category, phase, time range, and projecting arbitrary nested payload fields via dot-notation:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Match specific event names
|
|
258
|
+
trace-cli events trace.json.gz --name LayoutShift,navigationStart
|
|
259
|
+
|
|
260
|
+
# Extract specific dot-notation payload fields
|
|
261
|
+
trace-cli events trace.json.gz --name LayoutShift --fields args.data.navigationId,args.data.is_main_frame
|
|
262
|
+
|
|
263
|
+
# Filter by category and phase
|
|
264
|
+
trace-cli events trace.json.gz --cat devtools.timeline --phase X --top 20
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### 12. `navigations` (alias: `navs`)
|
|
270
|
+
Inspect all navigations in the trace, their primary main frame status, and their mapped Chrome DevTools Trace Engine `InsightSet` IDs:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
trace-cli navigations trace.json.gz
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
### 13. `scan`
|
|
279
|
+
Scan multiple trace files, directories, or glob patterns for specific events, categories, phases, raw text substrings, or payload property existence. Uses fast string pre-filtering before JSON parsing for rapid discovery across hundreds of test fixtures without loading heavy trace engine pipelines:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
# Scan a directory for a specific event name
|
|
283
|
+
trace-cli scan front_end/panels/timeline/fixtures/traces/ --name LayoutShift
|
|
284
|
+
|
|
285
|
+
# Find which fixture contains a specific string in event payloads
|
|
286
|
+
trace-cli scan test/fixtures/ --grep "LayerTreeHostImpl:snapshot"
|
|
287
|
+
|
|
288
|
+
# Scan multiple glob patterns for composite categories
|
|
289
|
+
trace-cli scan "traces/*.json.gz" --cat devtools.timeline --top 10
|
|
290
|
+
|
|
291
|
+
# Find traces containing specific payload fields
|
|
292
|
+
trace-cli scan fixtures/ --name TracingStartedInBrowser --fields args.data.frames
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Output Formats
|
|
298
|
+
|
|
299
|
+
### TOON (Default)
|
|
300
|
+
[TOON (Token-Oriented Object Notation)](https://github.com/toon-format/toon) is a compact, uniform tabular format designed to maximize information density for LLMs. It avoids verbose JSON syntax delimiters while preserving structured typing.
|
|
301
|
+
|
|
302
|
+
### Markdown (`--format md`)
|
|
303
|
+
Generates standard GitHub Flavored Markdown (GFM) tables and summary headings, ideal for terminal viewing or pasting into PR descriptions.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Bundling Local DevTools Trace Engine
|
|
308
|
+
|
|
309
|
+
To run `trace-cli` against the latest Chrome DevTools Trace Engine changes from a local `devtools-frontend` repository without needing Ninja:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
DEVTOOLS_PATH=/path/to/devtools-frontend npm run bundle:engine
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
This compiles a zero-dependency bundle into `src/engine/vendor/trace_engine.js`. `trace-cli` will automatically detect and prioritize this local vendor file over the npm module.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Development & Testing
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Install dependencies, build, and link locally
|
|
323
|
+
npm install
|
|
324
|
+
npm run build
|
|
325
|
+
npm link
|
|
326
|
+
|
|
327
|
+
# Run test suite (118+ unit tests via node:test)
|
|
328
|
+
npm test
|
|
329
|
+
|
|
330
|
+
# Run linter and type-checking (Biome & tsc)
|
|
331
|
+
npm run check
|
|
332
|
+
|
|
333
|
+
# Auto-format codebase
|
|
334
|
+
npm run format
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## License
|
|
340
|
+
|
|
341
|
+
Apache-2.0
|
|
342
|
+
|
|
343
|
+
Eligibility for the [Google Open Source Software Vulnerability Rewards Program](https://bughunters.google.com/open-source-security) is determined by the [Google Open Source Software Vulnerability Reward Program Rules](https://bughunters.google.com/about/rules/open-source/google-open-source-software-vulnerability-reward-program-rules).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 Google LLC
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
import { runCli } from '../src/cli.js';
|
|
16
|
+
runCli(process.argv).catch((err) => {
|
|
17
|
+
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCli(argv: string[]): Promise<void>;
|