@agent-scope/cli 1.17.0 → 1.17.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/dist/cli.js CHANGED
@@ -1326,7 +1326,7 @@ function createInitCommand() {
1326
1326
 
1327
1327
  // src/instrument/renders.ts
1328
1328
  import { resolve as resolve7 } from "path";
1329
- import { BrowserPool as BrowserPool3 } from "@agent-scope/render";
1329
+ import { BrowserPool as BrowserPool2 } from "@agent-scope/render";
1330
1330
  import { Command as Command5 } from "commander";
1331
1331
 
1332
1332
  // src/manifest-commands.ts
@@ -1507,6 +1507,7 @@ function createManifestCommand() {
1507
1507
 
1508
1508
  // src/instrument/hooks.ts
1509
1509
  import { resolve as resolve4 } from "path";
1510
+ import { getBrowserEntryScript as getBrowserEntryScript2 } from "@agent-scope/playwright";
1510
1511
  import { Command as Cmd } from "commander";
1511
1512
  import { chromium as chromium2 } from "playwright";
1512
1513
  var MANIFEST_PATH2 = ".reactscope/manifest.json";
@@ -1764,6 +1765,7 @@ async function runHooksProfiling(componentName, filePath, props) {
1764
1765
  try {
1765
1766
  const context = await browser.newContext();
1766
1767
  const page = await context.newPage();
1768
+ await page.addInitScript({ content: getBrowserEntryScript2() });
1767
1769
  const htmlHarness = await buildComponentHarness(filePath, componentName, props, 1280);
1768
1770
  await page.setContent(htmlHarness, { waitUntil: "load" });
1769
1771
  await page.waitForFunction(
@@ -2152,30 +2154,12 @@ Available: ${available}`
2152
2154
 
2153
2155
  // src/instrument/tree.ts
2154
2156
  import { resolve as resolve6 } from "path";
2155
- import { getBrowserEntryScript as getBrowserEntryScript2 } from "@agent-scope/playwright";
2156
- import { BrowserPool as BrowserPool2 } from "@agent-scope/render";
2157
+ import { getBrowserEntryScript as getBrowserEntryScript3 } from "@agent-scope/playwright";
2157
2158
  import { Command as Command4 } from "commander";
2159
+ import { chromium as chromium4 } from "playwright";
2158
2160
  var MANIFEST_PATH4 = ".reactscope/manifest.json";
2159
2161
  var DEFAULT_VIEWPORT_WIDTH = 375;
2160
2162
  var DEFAULT_VIEWPORT_HEIGHT = 812;
2161
- var _pool2 = null;
2162
- async function getPool2() {
2163
- if (_pool2 === null) {
2164
- _pool2 = new BrowserPool2({
2165
- size: { browsers: 1, pagesPerBrowser: 1 },
2166
- viewportWidth: DEFAULT_VIEWPORT_WIDTH,
2167
- viewportHeight: DEFAULT_VIEWPORT_HEIGHT
2168
- });
2169
- await _pool2.init();
2170
- }
2171
- return _pool2;
2172
- }
2173
- async function shutdownPool2() {
2174
- if (_pool2 !== null) {
2175
- await _pool2.close();
2176
- _pool2 = null;
2177
- }
2178
- }
2179
2163
  function mapNodeType(node) {
2180
2164
  if (node.type === "forward_ref") return "forwardRef";
2181
2165
  if (node.type === "host") return "host";
@@ -2387,11 +2371,13 @@ function formatInstrumentTree(root, showProviderDepth = false) {
2387
2371
  }
2388
2372
  async function runInstrumentTree(options) {
2389
2373
  const { componentName, filePath } = options;
2390
- const pool = await getPool2();
2391
- const slot = await pool.acquire();
2392
- const { page } = slot;
2374
+ const browser = await chromium4.launch({ headless: true });
2393
2375
  try {
2394
- await page.addInitScript({ content: getBrowserEntryScript2() });
2376
+ const context = await browser.newContext({
2377
+ viewport: { width: DEFAULT_VIEWPORT_WIDTH, height: DEFAULT_VIEWPORT_HEIGHT }
2378
+ });
2379
+ const page = await context.newPage();
2380
+ await page.addInitScript({ content: getBrowserEntryScript3() });
2395
2381
  const htmlHarness = await buildComponentHarness(
2396
2382
  filePath,
2397
2383
  componentName,
@@ -2444,7 +2430,7 @@ async function runInstrumentTree(options) {
2444
2430
  }
2445
2431
  return instrumentRoot;
2446
2432
  } finally {
2447
- pool.release(slot);
2433
+ await browser.close();
2448
2434
  }
2449
2435
  }
2450
2436
  function createInstrumentTreeCommand() {
@@ -2484,7 +2470,6 @@ Available: ${available}`
2484
2470
  providerDepth: opts.providerDepth,
2485
2471
  wastedRenders: opts.wastedRenders
2486
2472
  });
2487
- await shutdownPool2();
2488
2473
  const fmt2 = resolveFormat2(opts.format);
2489
2474
  if (fmt2 === "json") {
2490
2475
  process.stdout.write(`${JSON.stringify(instrumentRoot, null, 2)}
@@ -2495,7 +2480,6 @@ Available: ${available}`
2495
2480
  `);
2496
2481
  }
2497
2482
  } catch (err) {
2498
- await shutdownPool2();
2499
2483
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
2500
2484
  `);
2501
2485
  process.exit(1);
@@ -2815,22 +2799,22 @@ async function replayInteraction2(page, steps) {
2815
2799
  }
2816
2800
  }
2817
2801
  }
2818
- var _pool3 = null;
2819
- async function getPool3() {
2820
- if (_pool3 === null) {
2821
- _pool3 = new BrowserPool3({
2802
+ var _pool2 = null;
2803
+ async function getPool2() {
2804
+ if (_pool2 === null) {
2805
+ _pool2 = new BrowserPool2({
2822
2806
  size: { browsers: 1, pagesPerBrowser: 2 },
2823
2807
  viewportWidth: 1280,
2824
2808
  viewportHeight: 800
2825
2809
  });
2826
- await _pool3.init();
2810
+ await _pool2.init();
2827
2811
  }
2828
- return _pool3;
2812
+ return _pool2;
2829
2813
  }
2830
- async function shutdownPool3() {
2831
- if (_pool3 !== null) {
2832
- await _pool3.close();
2833
- _pool3 = null;
2814
+ async function shutdownPool2() {
2815
+ if (_pool2 !== null) {
2816
+ await _pool2.close();
2817
+ _pool2 = null;
2834
2818
  }
2835
2819
  }
2836
2820
  async function analyzeRenders(options) {
@@ -2847,7 +2831,7 @@ Available: ${available}`
2847
2831
  const rootDir = process.cwd();
2848
2832
  const filePath = resolve7(rootDir, descriptor.filePath);
2849
2833
  const htmlHarness = await buildComponentHarness(filePath, options.componentName, {}, 1280);
2850
- const pool = await getPool3();
2834
+ const pool = await getPool2();
2851
2835
  const slot = await pool.acquire();
2852
2836
  const { page } = slot;
2853
2837
  const startMs = performance.now();
@@ -2955,7 +2939,7 @@ function createInstrumentRendersCommand() {
2955
2939
  interaction,
2956
2940
  manifestPath: opts.manifest
2957
2941
  });
2958
- await shutdownPool3();
2942
+ await shutdownPool2();
2959
2943
  if (opts.json || !isTTY()) {
2960
2944
  process.stdout.write(`${JSON.stringify(result, null, 2)}
2961
2945
  `);
@@ -2964,7 +2948,7 @@ function createInstrumentRendersCommand() {
2964
2948
  `);
2965
2949
  }
2966
2950
  } catch (err) {
2967
- await shutdownPool3();
2951
+ await shutdownPool2();
2968
2952
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
2969
2953
  `);
2970
2954
  process.exit(1);
@@ -2989,7 +2973,7 @@ import { resolve as resolve8 } from "path";
2989
2973
  import {
2990
2974
  ALL_CONTEXT_IDS,
2991
2975
  ALL_STRESS_IDS,
2992
- BrowserPool as BrowserPool4,
2976
+ BrowserPool as BrowserPool3,
2993
2977
  contextAxis,
2994
2978
  RenderMatrix,
2995
2979
  SatoriRenderer,
@@ -2999,22 +2983,22 @@ import {
2999
2983
  import { Command as Command6 } from "commander";
3000
2984
  var MANIFEST_PATH6 = ".reactscope/manifest.json";
3001
2985
  var DEFAULT_OUTPUT_DIR = ".reactscope/renders";
3002
- var _pool4 = null;
3003
- async function getPool4(viewportWidth, viewportHeight) {
3004
- if (_pool4 === null) {
3005
- _pool4 = new BrowserPool4({
2986
+ var _pool3 = null;
2987
+ async function getPool3(viewportWidth, viewportHeight) {
2988
+ if (_pool3 === null) {
2989
+ _pool3 = new BrowserPool3({
3006
2990
  size: { browsers: 1, pagesPerBrowser: 4 },
3007
2991
  viewportWidth,
3008
2992
  viewportHeight
3009
2993
  });
3010
- await _pool4.init();
2994
+ await _pool3.init();
3011
2995
  }
3012
- return _pool4;
2996
+ return _pool3;
3013
2997
  }
3014
- async function shutdownPool4() {
3015
- if (_pool4 !== null) {
3016
- await _pool4.close();
3017
- _pool4 = null;
2998
+ async function shutdownPool3() {
2999
+ if (_pool3 !== null) {
3000
+ await _pool3.close();
3001
+ _pool3 = null;
3018
3002
  }
3019
3003
  }
3020
3004
  function buildRenderer(filePath, componentName, viewportWidth, viewportHeight) {
@@ -3025,7 +3009,7 @@ function buildRenderer(filePath, componentName, viewportWidth, viewportHeight) {
3025
3009
  _satori: satori,
3026
3010
  async renderCell(props, _complexityClass) {
3027
3011
  const startMs = performance.now();
3028
- const pool = await getPool4(viewportWidth, viewportHeight);
3012
+ const pool = await getPool3(viewportWidth, viewportHeight);
3029
3013
  const htmlHarness = await buildComponentHarness(
3030
3014
  filePath,
3031
3015
  componentName,
@@ -3161,7 +3145,7 @@ Available: ${available}`
3161
3145
  }
3162
3146
  }
3163
3147
  );
3164
- await shutdownPool4();
3148
+ await shutdownPool3();
3165
3149
  if (outcome.crashed) {
3166
3150
  process.stderr.write(`\u2717 Render failed: ${outcome.error.message}
3167
3151
  `);
@@ -3209,7 +3193,7 @@ Available: ${available}`
3209
3193
  );
3210
3194
  }
3211
3195
  } catch (err) {
3212
- await shutdownPool4();
3196
+ await shutdownPool3();
3213
3197
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
3214
3198
  `);
3215
3199
  process.exit(1);
@@ -3294,7 +3278,7 @@ Available: ${available}`
3294
3278
  concurrency
3295
3279
  });
3296
3280
  const result = await matrix.render();
3297
- await shutdownPool4();
3281
+ await shutdownPool3();
3298
3282
  process.stderr.write(
3299
3283
  `Done. ${result.stats.totalCells} cells, avg ${result.stats.avgRenderTimeMs.toFixed(1)}ms
3300
3284
  `
@@ -3339,7 +3323,7 @@ Available: ${available}`
3339
3323
  process.stdout.write(formatMatrixCsv(componentName, result));
3340
3324
  }
3341
3325
  } catch (err) {
3342
- await shutdownPool4();
3326
+ await shutdownPool3();
3343
3327
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
3344
3328
  `);
3345
3329
  process.exit(1);
@@ -3436,13 +3420,13 @@ function registerRenderAll(renderCmd) {
3436
3420
  workers.push(worker());
3437
3421
  }
3438
3422
  await Promise.all(workers);
3439
- await shutdownPool4();
3423
+ await shutdownPool3();
3440
3424
  process.stderr.write("\n");
3441
3425
  const summary = formatSummaryText(results, outputDir);
3442
3426
  process.stderr.write(`${summary}
3443
3427
  `);
3444
3428
  } catch (err) {
3445
- await shutdownPool4();
3429
+ await shutdownPool3();
3446
3430
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
3447
3431
  `);
3448
3432
  process.exit(1);
@@ -3488,29 +3472,29 @@ function createRenderCommand() {
3488
3472
  import { existsSync as existsSync6, mkdirSync as mkdirSync4, rmSync, writeFileSync as writeFileSync6 } from "fs";
3489
3473
  import { resolve as resolve9 } from "path";
3490
3474
  import { generateManifest as generateManifest3 } from "@agent-scope/manifest";
3491
- import { BrowserPool as BrowserPool5, safeRender as safeRender3 } from "@agent-scope/render";
3475
+ import { BrowserPool as BrowserPool4, safeRender as safeRender3 } from "@agent-scope/render";
3492
3476
  import { ComplianceEngine as ComplianceEngine2, TokenResolver as TokenResolver2 } from "@agent-scope/tokens";
3493
3477
  var DEFAULT_BASELINE_DIR = ".reactscope/baseline";
3494
- var _pool5 = null;
3495
- async function getPool5(viewportWidth, viewportHeight) {
3496
- if (_pool5 === null) {
3497
- _pool5 = new BrowserPool5({
3478
+ var _pool4 = null;
3479
+ async function getPool4(viewportWidth, viewportHeight) {
3480
+ if (_pool4 === null) {
3481
+ _pool4 = new BrowserPool4({
3498
3482
  size: { browsers: 1, pagesPerBrowser: 4 },
3499
3483
  viewportWidth,
3500
3484
  viewportHeight
3501
3485
  });
3502
- await _pool5.init();
3486
+ await _pool4.init();
3503
3487
  }
3504
- return _pool5;
3488
+ return _pool4;
3505
3489
  }
3506
- async function shutdownPool5() {
3507
- if (_pool5 !== null) {
3508
- await _pool5.close();
3509
- _pool5 = null;
3490
+ async function shutdownPool4() {
3491
+ if (_pool4 !== null) {
3492
+ await _pool4.close();
3493
+ _pool4 = null;
3510
3494
  }
3511
3495
  }
3512
3496
  async function renderComponent2(filePath, componentName, props, viewportWidth, viewportHeight) {
3513
- const pool = await getPool5(viewportWidth, viewportHeight);
3497
+ const pool = await getPool4(viewportWidth, viewportHeight);
3514
3498
  const htmlHarness = await buildComponentHarness(filePath, componentName, props, viewportWidth);
3515
3499
  const slot = await pool.acquire();
3516
3500
  const { page } = slot;
@@ -3760,7 +3744,7 @@ async function runBaseline(options = {}) {
3760
3744
  workers.push(worker());
3761
3745
  }
3762
3746
  await Promise.all(workers);
3763
- await shutdownPool5();
3747
+ await shutdownPool4();
3764
3748
  if (isTTY()) {
3765
3749
  process.stderr.write("\n");
3766
3750
  }
@@ -3814,7 +3798,7 @@ function registerBaselineSubCommand(reportCmd) {
3814
3798
  import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "fs";
3815
3799
  import { resolve as resolve10 } from "path";
3816
3800
  import { generateManifest as generateManifest4 } from "@agent-scope/manifest";
3817
- import { BrowserPool as BrowserPool6, safeRender as safeRender4 } from "@agent-scope/render";
3801
+ import { BrowserPool as BrowserPool5, safeRender as safeRender4 } from "@agent-scope/render";
3818
3802
  import { ComplianceEngine as ComplianceEngine3, TokenResolver as TokenResolver3 } from "@agent-scope/tokens";
3819
3803
  var DEFAULT_BASELINE_DIR2 = ".reactscope/baseline";
3820
3804
  function loadBaselineCompliance(baselineDir) {
@@ -3828,26 +3812,26 @@ function loadBaselineRenderJson2(baselineDir, componentName) {
3828
3812
  if (!existsSync7(jsonPath)) return null;
3829
3813
  return JSON.parse(readFileSync6(jsonPath, "utf-8"));
3830
3814
  }
3831
- var _pool6 = null;
3832
- async function getPool6(viewportWidth, viewportHeight) {
3833
- if (_pool6 === null) {
3834
- _pool6 = new BrowserPool6({
3815
+ var _pool5 = null;
3816
+ async function getPool5(viewportWidth, viewportHeight) {
3817
+ if (_pool5 === null) {
3818
+ _pool5 = new BrowserPool5({
3835
3819
  size: { browsers: 1, pagesPerBrowser: 4 },
3836
3820
  viewportWidth,
3837
3821
  viewportHeight
3838
3822
  });
3839
- await _pool6.init();
3823
+ await _pool5.init();
3840
3824
  }
3841
- return _pool6;
3825
+ return _pool5;
3842
3826
  }
3843
- async function shutdownPool6() {
3844
- if (_pool6 !== null) {
3845
- await _pool6.close();
3846
- _pool6 = null;
3827
+ async function shutdownPool5() {
3828
+ if (_pool5 !== null) {
3829
+ await _pool5.close();
3830
+ _pool5 = null;
3847
3831
  }
3848
3832
  }
3849
3833
  async function renderComponent3(filePath, componentName, props, viewportWidth, viewportHeight) {
3850
- const pool = await getPool6(viewportWidth, viewportHeight);
3834
+ const pool = await getPool5(viewportWidth, viewportHeight);
3851
3835
  const htmlHarness = await buildComponentHarness(filePath, componentName, props, viewportWidth);
3852
3836
  const slot = await pool.acquire();
3853
3837
  const { page } = slot;
@@ -4096,7 +4080,7 @@ async function runDiff(options = {}) {
4096
4080
  }
4097
4081
  await Promise.all(workers);
4098
4082
  }
4099
- await shutdownPool6();
4083
+ await shutdownPool5();
4100
4084
  if (isTTY() && total > 0) {
4101
4085
  process.stderr.write("\n");
4102
4086
  }
@@ -5231,7 +5215,7 @@ ${formatImpactSummary(report)}
5231
5215
  // src/tokens/preview.ts
5232
5216
  import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync10 } from "fs";
5233
5217
  import { resolve as resolve15 } from "path";
5234
- import { BrowserPool as BrowserPool7, SpriteSheetGenerator } from "@agent-scope/render";
5218
+ import { BrowserPool as BrowserPool6, SpriteSheetGenerator } from "@agent-scope/render";
5235
5219
  import { ComplianceEngine as ComplianceEngine6, ImpactAnalyzer as ImpactAnalyzer2, TokenResolver as TokenResolver7 } from "@agent-scope/tokens";
5236
5220
  var DEFAULT_STYLES_PATH3 = ".reactscope/compliance-styles.json";
5237
5221
  var DEFAULT_MANIFEST_PATH = ".reactscope/manifest.json";
@@ -5246,7 +5230,7 @@ async function renderComponentWithCssOverride(filePath, componentName, cssOverri
5246
5230
  cssOverride
5247
5231
  // injected as <style>
5248
5232
  );
5249
- const pool = new BrowserPool7({
5233
+ const pool = new BrowserPool6({
5250
5234
  size: { browsers: 1, pagesPerBrowser: 1 },
5251
5235
  viewportWidth: vpWidth,
5252
5236
  viewportHeight: vpHeight