@agent-scope/cli 1.10.0 → 1.12.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/cli.js +1305 -179
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1341 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +264 -1
- package/dist/index.d.ts +264 -1
- package/dist/index.js +1340 -243
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -89,6 +89,224 @@ declare function runInit(options: InitOptions): Promise<InitResult>;
|
|
|
89
89
|
|
|
90
90
|
declare function createInitCommand(): Command;
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @agent-scope/cli — instrument hooks command
|
|
94
|
+
*
|
|
95
|
+
* Implements `scope instrument hooks <component>`.
|
|
96
|
+
*
|
|
97
|
+
* Renders the component via a Playwright page (same harness as render-commands),
|
|
98
|
+
* then extracts per-hook-instance profiling data from the live React fiber tree.
|
|
99
|
+
*
|
|
100
|
+
* Per-hook tracking (React Instrumentation Spec §4):
|
|
101
|
+
* useState: currentValue, updateCount, updateOrigins
|
|
102
|
+
* useEffect: dependencyValues, fireCount, lastDuration, cleanupPresence
|
|
103
|
+
* useMemo: dependencyValues, recomputeCount, cacheHitRate
|
|
104
|
+
* useCallback: dependencyValues, recreationCount, cacheHitRate
|
|
105
|
+
* useRef: currentValue, readCountDuringRender
|
|
106
|
+
* useContext: contextType, valueAccessFrequency
|
|
107
|
+
* useReducer: actionTypesDispatched, stateTransitions
|
|
108
|
+
*
|
|
109
|
+
* Output: per-component hook inventory JSON, plus heuristic flags from §6.1.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Heuristic flags from §6.1 that apply to hook-level analysis.
|
|
114
|
+
*/
|
|
115
|
+
type HookHeuristicFlag = "WASTED_RENDER" | "MEMO_INEFFECTIVE" | "EFFECT_EVERY_RENDER" | "MISSING_CLEANUP" | "STALE_CLOSURE" | "STATE_UPDATE_LOOP";
|
|
116
|
+
/** Per-hook-instance profiling record. */
|
|
117
|
+
interface HookProfile {
|
|
118
|
+
/** 0-based call-order index within the component. */
|
|
119
|
+
index: number;
|
|
120
|
+
/** Hook type inferred from fiber shape. */
|
|
121
|
+
type: string;
|
|
122
|
+
/** useState / useReducer: current state value (serialised). */
|
|
123
|
+
currentValue?: unknown;
|
|
124
|
+
/** useState / useReducer: number of state updates observed. */
|
|
125
|
+
updateCount?: number;
|
|
126
|
+
/** useEffect / useLayoutEffect: number of times the effect fired. */
|
|
127
|
+
fireCount?: number;
|
|
128
|
+
/** useEffect / useLayoutEffect: last measured run duration in ms (null when unavailable). */
|
|
129
|
+
lastDuration?: number | null;
|
|
130
|
+
/** useEffect / useLayoutEffect: whether a cleanup function was returned. */
|
|
131
|
+
cleanupPresence?: boolean;
|
|
132
|
+
/** useMemo / useCallback: number of times value was recomputed (deps changed). */
|
|
133
|
+
recomputeCount?: number;
|
|
134
|
+
/** useMemo / useCallback: ratio of cache hits to total checks (0-1). */
|
|
135
|
+
cacheHitRate?: number;
|
|
136
|
+
/** useRef: current value. */
|
|
137
|
+
currentRefValue?: unknown;
|
|
138
|
+
/** useRef: number of times .current was read during render (heuristic). */
|
|
139
|
+
readCountDuringRender?: number;
|
|
140
|
+
/** useContext: serialised context value. */
|
|
141
|
+
contextValue?: unknown;
|
|
142
|
+
/** useReducer: action type strings dispatched so far. */
|
|
143
|
+
actionTypesDispatched?: string[];
|
|
144
|
+
/** Dependency values serialised (for hooks that accept deps). */
|
|
145
|
+
dependencyValues?: unknown[] | null;
|
|
146
|
+
}
|
|
147
|
+
/** Profiling result for a single component. */
|
|
148
|
+
interface ComponentHookProfile {
|
|
149
|
+
/** Component display name. */
|
|
150
|
+
name: string;
|
|
151
|
+
/** Source location (if available). */
|
|
152
|
+
source?: {
|
|
153
|
+
file: string;
|
|
154
|
+
line: number;
|
|
155
|
+
} | null;
|
|
156
|
+
/** Ordered list of hook profiles (one per hook call site). */
|
|
157
|
+
hooks: HookProfile[];
|
|
158
|
+
/** Heuristic flags detected for this component. */
|
|
159
|
+
flags: HookHeuristicFlag[];
|
|
160
|
+
}
|
|
161
|
+
/** Top-level result returned by runHooksProfiling(). */
|
|
162
|
+
interface HooksProfilingResult {
|
|
163
|
+
/** Profiled component name passed on the CLI. */
|
|
164
|
+
component: string;
|
|
165
|
+
/** Per-component hook inventory. */
|
|
166
|
+
components: ComponentHookProfile[];
|
|
167
|
+
/** Global heuristic flags (union of all component flags). */
|
|
168
|
+
flags: HookHeuristicFlag[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @agent-scope/cli — instrument profile command
|
|
173
|
+
*
|
|
174
|
+
* Implements `scope instrument profile <component> --interaction '...'`.
|
|
175
|
+
*
|
|
176
|
+
* Renders the component via a Playwright page, replays a structured interaction
|
|
177
|
+
* sequence, and captures a full interaction profile per React Instrumentation
|
|
178
|
+
* Spec §5:
|
|
179
|
+
*
|
|
180
|
+
* - totalRenders — total commit count during the interaction window
|
|
181
|
+
* - uniqueComponents — distinct component names that re-rendered
|
|
182
|
+
* - wastedRenders — re-renders where output was identical (heuristic)
|
|
183
|
+
* - timing.js — JS execution time (ms) measured via Performance API
|
|
184
|
+
* - timing.layout — Layout/reflow time (ms) measured via PerformanceObserver
|
|
185
|
+
* - timing.paint — Paint time (ms) measured via PerformanceObserver
|
|
186
|
+
* - layoutShifts — { count, cumulativeScore } via Layout Instability API
|
|
187
|
+
*
|
|
188
|
+
* Heuristic flags from §6.1 catalog: WASTED_RENDER, MEMO_INEFFECTIVE,
|
|
189
|
+
* EFFECT_EVERY_RENDER, etc.
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/** An interaction step definition (JSON format per spec). */
|
|
193
|
+
interface InteractionStep$1 {
|
|
194
|
+
/** Playwright action: click, fill, hover, press, wait */
|
|
195
|
+
action: "click" | "fill" | "hover" | "press" | "wait";
|
|
196
|
+
/** CSS selector or descriptive target for the element */
|
|
197
|
+
target?: string;
|
|
198
|
+
/** Value to type (for fill) or key to press (for press) */
|
|
199
|
+
value?: string;
|
|
200
|
+
/** Delay in ms (for wait action) */
|
|
201
|
+
delay?: number;
|
|
202
|
+
}
|
|
203
|
+
/** Performance timing captured during the interaction window. */
|
|
204
|
+
interface InteractionTiming {
|
|
205
|
+
/** JS execution time in ms (from performance.now() around interactions). */
|
|
206
|
+
js: number;
|
|
207
|
+
/** Layout time in ms (from PerformanceObserver layout entries). */
|
|
208
|
+
layout: number;
|
|
209
|
+
/** Paint time in ms (from PerformanceObserver paint entries). */
|
|
210
|
+
paint: number;
|
|
211
|
+
}
|
|
212
|
+
/** Layout shift data (Cumulative Layout Shift). */
|
|
213
|
+
interface LayoutShiftData {
|
|
214
|
+
/** Number of layout shift events observed. */
|
|
215
|
+
count: number;
|
|
216
|
+
/** Cumulative layout shift score. */
|
|
217
|
+
cumulativeScore: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Heuristic flags from §6.1 catalog applicable to interaction profiling.
|
|
221
|
+
*/
|
|
222
|
+
type ProfileHeuristicFlag = "WASTED_RENDER" | "MEMO_INEFFECTIVE" | "EFFECT_EVERY_RENDER" | "MISSING_CLEANUP" | "HIGH_RENDER_COUNT" | "LAYOUT_SHIFT_DETECTED" | "SLOW_INTERACTION";
|
|
223
|
+
/** Full interaction profile result per Spec §5. */
|
|
224
|
+
interface InteractionProfile {
|
|
225
|
+
/** Component name profiled. */
|
|
226
|
+
component: string;
|
|
227
|
+
/** Total number of React commits (renders) during the interaction window. */
|
|
228
|
+
totalRenders: number;
|
|
229
|
+
/** Number of distinct component names that re-rendered during the window. */
|
|
230
|
+
uniqueComponents: number;
|
|
231
|
+
/** Estimated number of "wasted" renders (components that re-rendered without output change). */
|
|
232
|
+
wastedRenders: number;
|
|
233
|
+
/** Timing breakdown in ms. */
|
|
234
|
+
timing: InteractionTiming;
|
|
235
|
+
/** Layout shift metrics. */
|
|
236
|
+
layoutShifts: LayoutShiftData;
|
|
237
|
+
/** Heuristic flags from §6.1 catalog. */
|
|
238
|
+
flags: ProfileHeuristicFlag[];
|
|
239
|
+
/** Interaction steps that were replayed. */
|
|
240
|
+
interaction: InteractionStep$1[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Root cause categories per Instrumentation Spec §2.1 */
|
|
244
|
+
type RenderTrigger = "state_change" | "props_change" | "context_change" | "parent_rerender" | "force_update" | "hook_dependency";
|
|
245
|
+
/** A single link in the causality chain from root cause to this render */
|
|
246
|
+
interface CausalityLink {
|
|
247
|
+
component: string;
|
|
248
|
+
trigger: RenderTrigger;
|
|
249
|
+
propsChanged?: boolean;
|
|
250
|
+
stateChanged?: boolean;
|
|
251
|
+
contextChanged?: boolean;
|
|
252
|
+
origin?: string;
|
|
253
|
+
stateKey?: string;
|
|
254
|
+
}
|
|
255
|
+
/** Per-component render event with causality chain */
|
|
256
|
+
interface RenderEvent {
|
|
257
|
+
component: string;
|
|
258
|
+
renderIndex: number;
|
|
259
|
+
trigger: RenderTrigger;
|
|
260
|
+
propsChanged: boolean;
|
|
261
|
+
stateChanged: boolean;
|
|
262
|
+
contextChanged: boolean;
|
|
263
|
+
memoized: boolean;
|
|
264
|
+
/** Wasted render: re-rendered with no changed inputs and not memoized */
|
|
265
|
+
wasted: boolean;
|
|
266
|
+
chain: CausalityLink[];
|
|
267
|
+
cascade: {
|
|
268
|
+
totalRendersTriggered: number;
|
|
269
|
+
uniqueComponents: number;
|
|
270
|
+
unchangedPropRenders: number;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/** Heuristic flag from Instrumentation Spec §6.1 */
|
|
274
|
+
interface InstrumentFlag {
|
|
275
|
+
id: string;
|
|
276
|
+
severity: "error" | "warning" | "info";
|
|
277
|
+
component: string;
|
|
278
|
+
detail: string;
|
|
279
|
+
data: Record<string, unknown>;
|
|
280
|
+
}
|
|
281
|
+
/** Full output of the renders analysis */
|
|
282
|
+
interface RendersAnalysisResult {
|
|
283
|
+
component: string;
|
|
284
|
+
interaction: InteractionStep[];
|
|
285
|
+
summary: {
|
|
286
|
+
totalRenders: number;
|
|
287
|
+
uniqueComponents: number;
|
|
288
|
+
wastedRenders: number;
|
|
289
|
+
interactionDurationMs: number;
|
|
290
|
+
};
|
|
291
|
+
renders: RenderEvent[];
|
|
292
|
+
flags: InstrumentFlag[];
|
|
293
|
+
}
|
|
294
|
+
/** Interaction step definition per Instrumentation Spec §5.1 */
|
|
295
|
+
interface InteractionStep {
|
|
296
|
+
action: "click" | "type" | "wait" | "hover" | "blur" | "focus" | "scroll";
|
|
297
|
+
target?: string;
|
|
298
|
+
text?: string;
|
|
299
|
+
condition?: string;
|
|
300
|
+
timeout?: number;
|
|
301
|
+
x?: number;
|
|
302
|
+
y?: number;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Creates the `scope instrument` command group.
|
|
306
|
+
* Contains: `scope instrument renders`, `scope instrument hooks`, `scope instrument profile`
|
|
307
|
+
*/
|
|
308
|
+
declare function createInstrumentCommand(): Command;
|
|
309
|
+
|
|
92
310
|
/**
|
|
93
311
|
* @agent-scope/cli — manifest sub-commands
|
|
94
312
|
*
|
|
@@ -155,4 +373,49 @@ declare function createProgram(options?: ScopeCLIOptions): Command;
|
|
|
155
373
|
*/
|
|
156
374
|
declare function createTokensCommand(): Command;
|
|
157
375
|
|
|
158
|
-
|
|
376
|
+
/**
|
|
377
|
+
* @agent-scope/cli — tokens export sub-command
|
|
378
|
+
*
|
|
379
|
+
* Implements `scope tokens export --format <fmt>` which converts a resolved
|
|
380
|
+
* token set into one of six downstream formats:
|
|
381
|
+
*
|
|
382
|
+
* css — CSS custom properties (:root { --color-primary-500: … })
|
|
383
|
+
* ts — TypeScript const exports (export const colorPrimary500 = …)
|
|
384
|
+
* scss — SCSS variable declarations ($color-primary-500: …)
|
|
385
|
+
* tailwind — Tailwind CSS theme.extend object (module.exports = { … })
|
|
386
|
+
* flat-json — Flat key→value JSON { "color.primary.500": "#3B82F6" }
|
|
387
|
+
* figma — Figma Tokens JSON (nested value+type objects)
|
|
388
|
+
*
|
|
389
|
+
* Token file resolution priority:
|
|
390
|
+
* 1. `--file` flag
|
|
391
|
+
* 2. `tokens.file` field in `reactscope.config.json`
|
|
392
|
+
* 3. `reactscope.tokens.json` in cwd (default)
|
|
393
|
+
*
|
|
394
|
+
* Output defaults to stdout (pipe-friendly). Use `--out <path>` to write to
|
|
395
|
+
* a file instead.
|
|
396
|
+
*
|
|
397
|
+
* Theme-aware export: if the token file contains a `themes` block and
|
|
398
|
+
* `--theme <name>` is passed, theme overrides are included in formats that
|
|
399
|
+
* support them (css, ts, scss, tailwind, figma).
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Resolve the path to the token file.
|
|
404
|
+
*
|
|
405
|
+
* Priority:
|
|
406
|
+
* 1. Explicit `--file` flag value
|
|
407
|
+
* 2. `tokens.file` in `reactscope.config.json`
|
|
408
|
+
* 3. `reactscope.tokens.json` in cwd
|
|
409
|
+
*/
|
|
410
|
+
declare function resolveTokenFilePath(fileFlag?: string): string;
|
|
411
|
+
/**
|
|
412
|
+
* Create and return the `tokens export` sub-command.
|
|
413
|
+
*
|
|
414
|
+
* Intended to be registered on the parent `tokens` Command:
|
|
415
|
+
* ```ts
|
|
416
|
+
* tokensCmd.addCommand(createTokensExportCommand());
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
declare function createTokensExportCommand(): Command;
|
|
420
|
+
|
|
421
|
+
export { type CausalityLink, type ComponentHookProfile, type HookHeuristicFlag, type HookProfile, type HooksProfilingResult, type InitOptions, type InitResult, type InteractionProfile, type InteractionStep$1 as InteractionStep, type InteractionTiming, type LayoutShiftData, type ListRow, type ProfileHeuristicFlag, type QueryRow, type ReactScopeConfig, type RenderEvent, type RenderTrigger, type RendersAnalysisResult, type ScopeCLIOptions, createInitCommand, createInstrumentCommand, createManifestCommand, createProgram, createTokensCommand, createTokensExportCommand, isTTY, matchGlob, resolveTokenFilePath, runInit };
|
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,224 @@ declare function runInit(options: InitOptions): Promise<InitResult>;
|
|
|
89
89
|
|
|
90
90
|
declare function createInitCommand(): Command;
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @agent-scope/cli — instrument hooks command
|
|
94
|
+
*
|
|
95
|
+
* Implements `scope instrument hooks <component>`.
|
|
96
|
+
*
|
|
97
|
+
* Renders the component via a Playwright page (same harness as render-commands),
|
|
98
|
+
* then extracts per-hook-instance profiling data from the live React fiber tree.
|
|
99
|
+
*
|
|
100
|
+
* Per-hook tracking (React Instrumentation Spec §4):
|
|
101
|
+
* useState: currentValue, updateCount, updateOrigins
|
|
102
|
+
* useEffect: dependencyValues, fireCount, lastDuration, cleanupPresence
|
|
103
|
+
* useMemo: dependencyValues, recomputeCount, cacheHitRate
|
|
104
|
+
* useCallback: dependencyValues, recreationCount, cacheHitRate
|
|
105
|
+
* useRef: currentValue, readCountDuringRender
|
|
106
|
+
* useContext: contextType, valueAccessFrequency
|
|
107
|
+
* useReducer: actionTypesDispatched, stateTransitions
|
|
108
|
+
*
|
|
109
|
+
* Output: per-component hook inventory JSON, plus heuristic flags from §6.1.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Heuristic flags from §6.1 that apply to hook-level analysis.
|
|
114
|
+
*/
|
|
115
|
+
type HookHeuristicFlag = "WASTED_RENDER" | "MEMO_INEFFECTIVE" | "EFFECT_EVERY_RENDER" | "MISSING_CLEANUP" | "STALE_CLOSURE" | "STATE_UPDATE_LOOP";
|
|
116
|
+
/** Per-hook-instance profiling record. */
|
|
117
|
+
interface HookProfile {
|
|
118
|
+
/** 0-based call-order index within the component. */
|
|
119
|
+
index: number;
|
|
120
|
+
/** Hook type inferred from fiber shape. */
|
|
121
|
+
type: string;
|
|
122
|
+
/** useState / useReducer: current state value (serialised). */
|
|
123
|
+
currentValue?: unknown;
|
|
124
|
+
/** useState / useReducer: number of state updates observed. */
|
|
125
|
+
updateCount?: number;
|
|
126
|
+
/** useEffect / useLayoutEffect: number of times the effect fired. */
|
|
127
|
+
fireCount?: number;
|
|
128
|
+
/** useEffect / useLayoutEffect: last measured run duration in ms (null when unavailable). */
|
|
129
|
+
lastDuration?: number | null;
|
|
130
|
+
/** useEffect / useLayoutEffect: whether a cleanup function was returned. */
|
|
131
|
+
cleanupPresence?: boolean;
|
|
132
|
+
/** useMemo / useCallback: number of times value was recomputed (deps changed). */
|
|
133
|
+
recomputeCount?: number;
|
|
134
|
+
/** useMemo / useCallback: ratio of cache hits to total checks (0-1). */
|
|
135
|
+
cacheHitRate?: number;
|
|
136
|
+
/** useRef: current value. */
|
|
137
|
+
currentRefValue?: unknown;
|
|
138
|
+
/** useRef: number of times .current was read during render (heuristic). */
|
|
139
|
+
readCountDuringRender?: number;
|
|
140
|
+
/** useContext: serialised context value. */
|
|
141
|
+
contextValue?: unknown;
|
|
142
|
+
/** useReducer: action type strings dispatched so far. */
|
|
143
|
+
actionTypesDispatched?: string[];
|
|
144
|
+
/** Dependency values serialised (for hooks that accept deps). */
|
|
145
|
+
dependencyValues?: unknown[] | null;
|
|
146
|
+
}
|
|
147
|
+
/** Profiling result for a single component. */
|
|
148
|
+
interface ComponentHookProfile {
|
|
149
|
+
/** Component display name. */
|
|
150
|
+
name: string;
|
|
151
|
+
/** Source location (if available). */
|
|
152
|
+
source?: {
|
|
153
|
+
file: string;
|
|
154
|
+
line: number;
|
|
155
|
+
} | null;
|
|
156
|
+
/** Ordered list of hook profiles (one per hook call site). */
|
|
157
|
+
hooks: HookProfile[];
|
|
158
|
+
/** Heuristic flags detected for this component. */
|
|
159
|
+
flags: HookHeuristicFlag[];
|
|
160
|
+
}
|
|
161
|
+
/** Top-level result returned by runHooksProfiling(). */
|
|
162
|
+
interface HooksProfilingResult {
|
|
163
|
+
/** Profiled component name passed on the CLI. */
|
|
164
|
+
component: string;
|
|
165
|
+
/** Per-component hook inventory. */
|
|
166
|
+
components: ComponentHookProfile[];
|
|
167
|
+
/** Global heuristic flags (union of all component flags). */
|
|
168
|
+
flags: HookHeuristicFlag[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @agent-scope/cli — instrument profile command
|
|
173
|
+
*
|
|
174
|
+
* Implements `scope instrument profile <component> --interaction '...'`.
|
|
175
|
+
*
|
|
176
|
+
* Renders the component via a Playwright page, replays a structured interaction
|
|
177
|
+
* sequence, and captures a full interaction profile per React Instrumentation
|
|
178
|
+
* Spec §5:
|
|
179
|
+
*
|
|
180
|
+
* - totalRenders — total commit count during the interaction window
|
|
181
|
+
* - uniqueComponents — distinct component names that re-rendered
|
|
182
|
+
* - wastedRenders — re-renders where output was identical (heuristic)
|
|
183
|
+
* - timing.js — JS execution time (ms) measured via Performance API
|
|
184
|
+
* - timing.layout — Layout/reflow time (ms) measured via PerformanceObserver
|
|
185
|
+
* - timing.paint — Paint time (ms) measured via PerformanceObserver
|
|
186
|
+
* - layoutShifts — { count, cumulativeScore } via Layout Instability API
|
|
187
|
+
*
|
|
188
|
+
* Heuristic flags from §6.1 catalog: WASTED_RENDER, MEMO_INEFFECTIVE,
|
|
189
|
+
* EFFECT_EVERY_RENDER, etc.
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/** An interaction step definition (JSON format per spec). */
|
|
193
|
+
interface InteractionStep$1 {
|
|
194
|
+
/** Playwright action: click, fill, hover, press, wait */
|
|
195
|
+
action: "click" | "fill" | "hover" | "press" | "wait";
|
|
196
|
+
/** CSS selector or descriptive target for the element */
|
|
197
|
+
target?: string;
|
|
198
|
+
/** Value to type (for fill) or key to press (for press) */
|
|
199
|
+
value?: string;
|
|
200
|
+
/** Delay in ms (for wait action) */
|
|
201
|
+
delay?: number;
|
|
202
|
+
}
|
|
203
|
+
/** Performance timing captured during the interaction window. */
|
|
204
|
+
interface InteractionTiming {
|
|
205
|
+
/** JS execution time in ms (from performance.now() around interactions). */
|
|
206
|
+
js: number;
|
|
207
|
+
/** Layout time in ms (from PerformanceObserver layout entries). */
|
|
208
|
+
layout: number;
|
|
209
|
+
/** Paint time in ms (from PerformanceObserver paint entries). */
|
|
210
|
+
paint: number;
|
|
211
|
+
}
|
|
212
|
+
/** Layout shift data (Cumulative Layout Shift). */
|
|
213
|
+
interface LayoutShiftData {
|
|
214
|
+
/** Number of layout shift events observed. */
|
|
215
|
+
count: number;
|
|
216
|
+
/** Cumulative layout shift score. */
|
|
217
|
+
cumulativeScore: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Heuristic flags from §6.1 catalog applicable to interaction profiling.
|
|
221
|
+
*/
|
|
222
|
+
type ProfileHeuristicFlag = "WASTED_RENDER" | "MEMO_INEFFECTIVE" | "EFFECT_EVERY_RENDER" | "MISSING_CLEANUP" | "HIGH_RENDER_COUNT" | "LAYOUT_SHIFT_DETECTED" | "SLOW_INTERACTION";
|
|
223
|
+
/** Full interaction profile result per Spec §5. */
|
|
224
|
+
interface InteractionProfile {
|
|
225
|
+
/** Component name profiled. */
|
|
226
|
+
component: string;
|
|
227
|
+
/** Total number of React commits (renders) during the interaction window. */
|
|
228
|
+
totalRenders: number;
|
|
229
|
+
/** Number of distinct component names that re-rendered during the window. */
|
|
230
|
+
uniqueComponents: number;
|
|
231
|
+
/** Estimated number of "wasted" renders (components that re-rendered without output change). */
|
|
232
|
+
wastedRenders: number;
|
|
233
|
+
/** Timing breakdown in ms. */
|
|
234
|
+
timing: InteractionTiming;
|
|
235
|
+
/** Layout shift metrics. */
|
|
236
|
+
layoutShifts: LayoutShiftData;
|
|
237
|
+
/** Heuristic flags from §6.1 catalog. */
|
|
238
|
+
flags: ProfileHeuristicFlag[];
|
|
239
|
+
/** Interaction steps that were replayed. */
|
|
240
|
+
interaction: InteractionStep$1[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Root cause categories per Instrumentation Spec §2.1 */
|
|
244
|
+
type RenderTrigger = "state_change" | "props_change" | "context_change" | "parent_rerender" | "force_update" | "hook_dependency";
|
|
245
|
+
/** A single link in the causality chain from root cause to this render */
|
|
246
|
+
interface CausalityLink {
|
|
247
|
+
component: string;
|
|
248
|
+
trigger: RenderTrigger;
|
|
249
|
+
propsChanged?: boolean;
|
|
250
|
+
stateChanged?: boolean;
|
|
251
|
+
contextChanged?: boolean;
|
|
252
|
+
origin?: string;
|
|
253
|
+
stateKey?: string;
|
|
254
|
+
}
|
|
255
|
+
/** Per-component render event with causality chain */
|
|
256
|
+
interface RenderEvent {
|
|
257
|
+
component: string;
|
|
258
|
+
renderIndex: number;
|
|
259
|
+
trigger: RenderTrigger;
|
|
260
|
+
propsChanged: boolean;
|
|
261
|
+
stateChanged: boolean;
|
|
262
|
+
contextChanged: boolean;
|
|
263
|
+
memoized: boolean;
|
|
264
|
+
/** Wasted render: re-rendered with no changed inputs and not memoized */
|
|
265
|
+
wasted: boolean;
|
|
266
|
+
chain: CausalityLink[];
|
|
267
|
+
cascade: {
|
|
268
|
+
totalRendersTriggered: number;
|
|
269
|
+
uniqueComponents: number;
|
|
270
|
+
unchangedPropRenders: number;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/** Heuristic flag from Instrumentation Spec §6.1 */
|
|
274
|
+
interface InstrumentFlag {
|
|
275
|
+
id: string;
|
|
276
|
+
severity: "error" | "warning" | "info";
|
|
277
|
+
component: string;
|
|
278
|
+
detail: string;
|
|
279
|
+
data: Record<string, unknown>;
|
|
280
|
+
}
|
|
281
|
+
/** Full output of the renders analysis */
|
|
282
|
+
interface RendersAnalysisResult {
|
|
283
|
+
component: string;
|
|
284
|
+
interaction: InteractionStep[];
|
|
285
|
+
summary: {
|
|
286
|
+
totalRenders: number;
|
|
287
|
+
uniqueComponents: number;
|
|
288
|
+
wastedRenders: number;
|
|
289
|
+
interactionDurationMs: number;
|
|
290
|
+
};
|
|
291
|
+
renders: RenderEvent[];
|
|
292
|
+
flags: InstrumentFlag[];
|
|
293
|
+
}
|
|
294
|
+
/** Interaction step definition per Instrumentation Spec §5.1 */
|
|
295
|
+
interface InteractionStep {
|
|
296
|
+
action: "click" | "type" | "wait" | "hover" | "blur" | "focus" | "scroll";
|
|
297
|
+
target?: string;
|
|
298
|
+
text?: string;
|
|
299
|
+
condition?: string;
|
|
300
|
+
timeout?: number;
|
|
301
|
+
x?: number;
|
|
302
|
+
y?: number;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Creates the `scope instrument` command group.
|
|
306
|
+
* Contains: `scope instrument renders`, `scope instrument hooks`, `scope instrument profile`
|
|
307
|
+
*/
|
|
308
|
+
declare function createInstrumentCommand(): Command;
|
|
309
|
+
|
|
92
310
|
/**
|
|
93
311
|
* @agent-scope/cli — manifest sub-commands
|
|
94
312
|
*
|
|
@@ -155,4 +373,49 @@ declare function createProgram(options?: ScopeCLIOptions): Command;
|
|
|
155
373
|
*/
|
|
156
374
|
declare function createTokensCommand(): Command;
|
|
157
375
|
|
|
158
|
-
|
|
376
|
+
/**
|
|
377
|
+
* @agent-scope/cli — tokens export sub-command
|
|
378
|
+
*
|
|
379
|
+
* Implements `scope tokens export --format <fmt>` which converts a resolved
|
|
380
|
+
* token set into one of six downstream formats:
|
|
381
|
+
*
|
|
382
|
+
* css — CSS custom properties (:root { --color-primary-500: … })
|
|
383
|
+
* ts — TypeScript const exports (export const colorPrimary500 = …)
|
|
384
|
+
* scss — SCSS variable declarations ($color-primary-500: …)
|
|
385
|
+
* tailwind — Tailwind CSS theme.extend object (module.exports = { … })
|
|
386
|
+
* flat-json — Flat key→value JSON { "color.primary.500": "#3B82F6" }
|
|
387
|
+
* figma — Figma Tokens JSON (nested value+type objects)
|
|
388
|
+
*
|
|
389
|
+
* Token file resolution priority:
|
|
390
|
+
* 1. `--file` flag
|
|
391
|
+
* 2. `tokens.file` field in `reactscope.config.json`
|
|
392
|
+
* 3. `reactscope.tokens.json` in cwd (default)
|
|
393
|
+
*
|
|
394
|
+
* Output defaults to stdout (pipe-friendly). Use `--out <path>` to write to
|
|
395
|
+
* a file instead.
|
|
396
|
+
*
|
|
397
|
+
* Theme-aware export: if the token file contains a `themes` block and
|
|
398
|
+
* `--theme <name>` is passed, theme overrides are included in formats that
|
|
399
|
+
* support them (css, ts, scss, tailwind, figma).
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Resolve the path to the token file.
|
|
404
|
+
*
|
|
405
|
+
* Priority:
|
|
406
|
+
* 1. Explicit `--file` flag value
|
|
407
|
+
* 2. `tokens.file` in `reactscope.config.json`
|
|
408
|
+
* 3. `reactscope.tokens.json` in cwd
|
|
409
|
+
*/
|
|
410
|
+
declare function resolveTokenFilePath(fileFlag?: string): string;
|
|
411
|
+
/**
|
|
412
|
+
* Create and return the `tokens export` sub-command.
|
|
413
|
+
*
|
|
414
|
+
* Intended to be registered on the parent `tokens` Command:
|
|
415
|
+
* ```ts
|
|
416
|
+
* tokensCmd.addCommand(createTokensExportCommand());
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
declare function createTokensExportCommand(): Command;
|
|
420
|
+
|
|
421
|
+
export { type CausalityLink, type ComponentHookProfile, type HookHeuristicFlag, type HookProfile, type HooksProfilingResult, type InitOptions, type InitResult, type InteractionProfile, type InteractionStep$1 as InteractionStep, type InteractionTiming, type LayoutShiftData, type ListRow, type ProfileHeuristicFlag, type QueryRow, type ReactScopeConfig, type RenderEvent, type RenderTrigger, type RendersAnalysisResult, type ScopeCLIOptions, createInitCommand, createInstrumentCommand, createManifestCommand, createProgram, createTokensCommand, createTokensExportCommand, isTTY, matchGlob, resolveTokenFilePath, runInit };
|