@mizchi/vlmkit-core 0.22.0 → 0.23.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.
@@ -1,12 +1,6 @@
1
+ import { UsageError } from "@mizchi/vlmkit-judge/errors.ts";
2
+
1
3
  //#region src/cli-error.d.ts
2
- /**
3
- * A bad flag or missing argument — the caller's typo, not a defect. Thrown by
4
- * `arg-reader` and printed as one line, because a stack trace for
5
- * `--concurrency abc` buries the one sentence that fixes it.
6
- */
7
- declare class UsageError extends Error {
8
- readonly name = "UsageError";
9
- }
10
4
  /**
11
5
  * The `playwright` peer range. Duplicated from this package's own
12
6
  * `peerDependencies` because the shipped bundle has no reliable path back to
@@ -2,6 +2,7 @@ import { createRequire } from "node:module";
2
2
  import { existsSync, readFileSync, statSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
+ import { UsageError } from "@mizchi/vlmkit-judge/errors.ts";
5
6
  //#region src/cli-error.ts
6
7
  /**
7
8
  * Shared CLI error-prettifier. Recognizes common error shapes that
@@ -19,14 +20,6 @@ import { fileURLToPath } from "node:url";
19
20
  * `tests/playwright-peer-contract.test.mjs` guards that.
20
21
  */
21
22
  /**
22
- * A bad flag or missing argument — the caller's typo, not a defect. Thrown by
23
- * `arg-reader` and printed as one line, because a stack trace for
24
- * `--concurrency abc` buries the one sentence that fixes it.
25
- */
26
- var UsageError = class extends Error {
27
- name = "UsageError";
28
- };
29
- /**
30
23
  * The `playwright` peer range. Duplicated from this package's own
31
24
  * `peerDependencies` because the shipped bundle has no reliable path back to
32
25
  * its manifest (tsdown flattens `dist/`, and the root CLI bundle inlines this
@@ -38,7 +38,18 @@ declare const isUrlSource: (source: string) => boolean;
38
38
  * the caller nothing about what actually went wrong.
39
39
  */
40
40
  declare function resolveSource(source: string): string;
41
- /** File path or URL → a URL Playwright can navigate to. */
41
+ /**
42
+ * File path or URL → a URL Playwright can navigate to.
43
+ *
44
+ * A local page is also opened in a STATE — `page.html?theme=dark`, `index.html?step=2`,
45
+ * `article.html#note-2` — and that suffix belongs to the page, not to the filename.
46
+ * `pathToFileURL` escapes `?` and `#` into the name (`index.html%3Ftheme=dark`), so every gate
47
+ * reported `error: file not found: index.html?theme=dark`; three of the six agents building demo
48
+ * sites (2026-09-23) hit it asking for a second theme or step, and worked around it with an
49
+ * absolute `file://` URL. The suffix is split off only when the whole string is not itself a
50
+ * file and the part before the `?` / `#` is, so a file that really has `?` in its name still
51
+ * opens as that file.
52
+ */
42
53
  declare function sourceToUrl(source: string): string;
43
54
  /**
44
55
  * Wait for the page to stop moving: bounded network idle, then webfonts, then
@@ -1,6 +1,6 @@
1
1
  import { withAuthState } from "./auth-state.mjs";
2
2
  import { describeRedirect } from "./navigation-redirect.mjs";
3
- import { readFileSync } from "node:fs";
3
+ import { existsSync, readFileSync } from "node:fs";
4
4
  import { resolve } from "node:path";
5
5
  import { pathToFileURL } from "node:url";
6
6
  //#region src/page-open.ts
@@ -71,9 +71,27 @@ const isUrlSource = (source) => /^(https?|file):\/\//.test(source);
71
71
  function resolveSource(source) {
72
72
  return isUrlSource(source) ? source : resolve(source);
73
73
  }
74
- /** File path or URL → a URL Playwright can navigate to. */
74
+ /**
75
+ * File path or URL → a URL Playwright can navigate to.
76
+ *
77
+ * A local page is also opened in a STATE — `page.html?theme=dark`, `index.html?step=2`,
78
+ * `article.html#note-2` — and that suffix belongs to the page, not to the filename.
79
+ * `pathToFileURL` escapes `?` and `#` into the name (`index.html%3Ftheme=dark`), so every gate
80
+ * reported `error: file not found: index.html?theme=dark`; three of the six agents building demo
81
+ * sites (2026-09-23) hit it asking for a second theme or step, and worked around it with an
82
+ * absolute `file://` URL. The suffix is split off only when the whole string is not itself a
83
+ * file and the part before the `?` / `#` is, so a file that really has `?` in its name still
84
+ * opens as that file.
85
+ */
75
86
  function sourceToUrl(source) {
76
- return isUrlSource(source) ? source : pathToFileURL(resolve(source)).href;
87
+ if (isUrlSource(source)) return source;
88
+ const whole = resolve(source);
89
+ const cut = source.search(/[?#]/);
90
+ if (cut > 0 && !existsSync(whole)) {
91
+ const file = resolve(source.slice(0, cut));
92
+ if (existsSync(file)) return pathToFileURL(file).href + source.slice(cut);
93
+ }
94
+ return pathToFileURL(whole).href;
77
95
  }
78
96
  /**
79
97
  * Wait for the page to stop moving: bounded network idle, then webfonts, then
@@ -15,6 +15,6 @@
15
15
  * every `package.json` and that the CHANGELOG has a section for it, so the literal cannot drift
16
16
  * from the release either.
17
17
  */
18
- declare const VLMKIT_VERSION = "0.22.0";
18
+ declare const VLMKIT_VERSION = "0.23.0";
19
19
  //#endregion
20
20
  export { VLMKIT_VERSION };
package/dist/version.mjs CHANGED
@@ -15,6 +15,6 @@
15
15
  * every `package.json` and that the CHANGELOG has a section for it, so the literal cannot drift
16
16
  * from the release either.
17
17
  */
18
- const VLMKIT_VERSION = "0.22.0";
18
+ const VLMKIT_VERSION = "0.23.0";
19
19
  //#endregion
20
20
  export { VLMKIT_VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mizchi/vlmkit-core",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "VRT diff engine + shared types — pure image / DOM / a11y / visual comparison primitives.",
5
5
  "license": "MIT",
6
6
  "author": "mizchi",
@@ -45,7 +45,8 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "pixelmatch": "^7.1.0",
48
- "pngjs": "^7.0.0"
48
+ "pngjs": "^7.0.0",
49
+ "@mizchi/vlmkit-judge": "0.23.0"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "playwright": ">=1.61 <2",