@narumitw/pi-chrome-devtools 0.4.0 → 0.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-chrome-devtools",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Pi extension that exposes Chrome DevTools Protocol tools.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@biomejs/biome": "2.4.14",
36
- "@mariozechner/pi-coding-agent": "0.73.0",
36
+ "@earendil-works/pi-coding-agent": "0.74.0",
37
37
  "typescript": "6.0.3"
38
38
  },
39
39
  "repository": {
@@ -11,7 +11,7 @@ import {
11
11
  type ExtensionCommandContext,
12
12
  type ToolRenderResultOptions,
13
13
  withFileMutationQueue,
14
- } from "@mariozechner/pi-coding-agent";
14
+ } from "@earendil-works/pi-coding-agent";
15
15
  import { Type } from "typebox";
16
16
 
17
17
  const DEFAULT_HOST = "127.0.0.1";
@@ -454,7 +454,7 @@ ${await buildToolStatusMessage(pi)}`, "info");
454
454
  }
455
455
  }
456
456
 
457
- function parseCommand(args: string): CommandAction | "unknown" {
457
+ export function parseCommand(args: string): CommandAction | "unknown" {
458
458
  const command = args.trim().toLowerCase();
459
459
  if (!command) return "menu";
460
460
  if (command === "help") return "help";
@@ -466,7 +466,7 @@ function parseCommand(args: string): CommandAction | "unknown" {
466
466
  return "unknown";
467
467
  }
468
468
 
469
- function commandCompletions(prefix: string) {
469
+ export function commandCompletions(prefix: string) {
470
470
  const normalized = prefix.trim().toLowerCase();
471
471
  if (normalized.includes(" ")) return null;
472
472
 
@@ -735,7 +735,7 @@ function allChromeDevtoolsTools() {
735
735
  return [...CHROME_DEVTOOLS_TOOL_NAMES];
736
736
  }
737
737
 
738
- function orderedChromeDevtoolsTools(selectedTools: ReadonlySet<ChromeDevToolsToolName>) {
738
+ export function orderedChromeDevtoolsTools(selectedTools: ReadonlySet<ChromeDevToolsToolName>) {
739
739
  return CHROME_DEVTOOLS_TOOL_NAMES.filter((toolName) => selectedTools.has(toolName));
740
740
  }
741
741
 
@@ -794,7 +794,7 @@ async function loadSettings(): Promise<
794
794
  }
795
795
  }
796
796
 
797
- function normalizeChromeDevtoolsSettings(value: unknown): ChromeDevToolsSettings | undefined {
797
+ export function normalizeChromeDevtoolsSettings(value: unknown): ChromeDevToolsSettings | undefined {
798
798
  if (!value || typeof value !== "object") return undefined;
799
799
  const settings = value as { tools?: unknown; updatedAt?: unknown };
800
800
  if (typeof settings.updatedAt !== "number") return undefined;
@@ -843,7 +843,7 @@ function unique<T>(values: T[]) {
843
843
  return Array.from(new Set(values));
844
844
  }
845
845
 
846
- function parseConfiguredPort(value: string | undefined) {
846
+ export function parseConfiguredPort(value: string | undefined) {
847
847
  if (value === undefined) return undefined;
848
848
  const trimmedValue = value.trim();
849
849
  if (!/^\d+$/.test(trimmedValue)) return undefined;
@@ -1266,9 +1266,9 @@ function shouldAutoLaunchAfterEndpointError(error: unknown) {
1266
1266
  if (!canAutoLaunchBrowser()) return false;
1267
1267
  if (isLaunchableEndpointError(error)) return true;
1268
1268
 
1269
- // If the user did not pin a port, non-retryable unexpected responses on the
1270
- // default port are conflicts we can avoid with a dynamic DevTools port.
1271
- return !state.portConfigured && error instanceof DevToolsEndpointError && !error.retryable;
1269
+ // After the attach-first attempt (including its retry window, when applicable) fails, treat any
1270
+ // DevTools endpoint error on an unpinned port as a conflict we can avoid with a dynamic port.
1271
+ return !state.portConfigured && error instanceof DevToolsEndpointError;
1272
1272
  }
1273
1273
 
1274
1274
  function canAutoLaunchBrowser() {
@@ -1292,7 +1292,7 @@ function devToolsEndpoint() {
1292
1292
  return `http://${formatHostForUrl(state.host)}:${state.port}`;
1293
1293
  }
1294
1294
 
1295
- function formatHostForUrl(host: string) {
1295
+ export function formatHostForUrl(host: string) {
1296
1296
  if (host.startsWith("[") && host.endsWith("]")) return host;
1297
1297
  return host.includes(":") ? `[${host}]` : host;
1298
1298
  }
@@ -1360,7 +1360,7 @@ function defaultManualBrowserExecutable() {
1360
1360
  : "google-chrome";
1361
1361
  }
1362
1362
 
1363
- function quoteCommandPart(value: string) {
1363
+ export function quoteCommandPart(value: string) {
1364
1364
  return /\s/.test(value) ? `"${value.replaceAll('"', '\\"')}"` : value;
1365
1365
  }
1366
1366
 
@@ -1368,7 +1368,7 @@ function endpointConfigHint() {
1368
1368
  return "Set PI_CHROME_DEVTOOLS_HOST and PI_CHROME_DEVTOOLS_PORT for a manual endpoint, PI_CHROME_DEVTOOLS_BROWSER to choose an executable, or PI_CHROME_DEVTOOLS_AUTO_LAUNCH=0 to disable auto-launch.";
1369
1369
  }
1370
1370
 
1371
- function isLocalDevToolsHost(host: string) {
1371
+ export function isLocalDevToolsHost(host: string) {
1372
1372
  const normalizedHost = host.toLowerCase().replace(/^\[(.*)]$/, "$1");
1373
1373
  return ["localhost", "127.0.0.1", "::1", "0:0:0:0:0:0:0:1"].includes(normalizedHost);
1374
1374
  }
@@ -1604,7 +1604,7 @@ async function saveScreenshot(
1604
1604
  };
1605
1605
  }
1606
1606
 
1607
- function resolveScreenshotPath(savePath: string | undefined, cwd: string): ResolvedScreenshotPath {
1607
+ export function resolveScreenshotPath(savePath: string | undefined, cwd: string): ResolvedScreenshotPath {
1608
1608
  const cwdRoot = resolve(cwd);
1609
1609
  const tempRoot = resolve(tmpdir());
1610
1610
 
@@ -1643,7 +1643,7 @@ function stripLeadingAtPath(path: string) {
1643
1643
  return path.startsWith("@") ? path.slice(1) : path;
1644
1644
  }
1645
1645
 
1646
- function hasParentPathSegment(path: string) {
1646
+ export function hasParentPathSegment(path: string) {
1647
1647
  return path.split(/[\\/]+/).some((part) => part === "..");
1648
1648
  }
1649
1649
 
@@ -1668,7 +1668,7 @@ async function ensureSafeScreenshotParent(resolvedPath: ResolvedScreenshotPath)
1668
1668
  }
1669
1669
  }
1670
1670
 
1671
- function selectAllowedRoot(path: string, roots: readonly string[]) {
1671
+ export function selectAllowedRoot(path: string, roots: readonly string[]) {
1672
1672
  const matchingRoots = roots.filter((root) => isPathInsideRoot(path, root));
1673
1673
  matchingRoots.sort(
1674
1674
  (left, right) =>
@@ -1781,7 +1781,7 @@ async function realpathOrResolvedPath(path: string) {
1781
1781
  return realpath(path).catch(() => resolve(path));
1782
1782
  }
1783
1783
 
1784
- function isPathInsideRoot(path: string, root: string) {
1784
+ export function isPathInsideRoot(path: string, root: string) {
1785
1785
  const normalizedPath = normalizePathForComparison(resolve(path));
1786
1786
  const normalizedRoot = normalizePathForComparison(resolve(root));
1787
1787
  if (normalizedPath === normalizedRoot) return true;