@mizchi/vlmkit-core 0.23.2 → 0.28.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/a11y-semantic.d.mts +6 -10
- package/dist/a11y-semantic.mjs +3 -4
- package/dist/animated-image.d.mts +27 -0
- package/dist/animated-image.mjs +112 -0
- package/dist/apng.d.mts +5 -9
- package/dist/apng.mjs +6 -7
- package/dist/arg-reader.d.mts +9 -12
- package/dist/arg-reader.mjs +1 -2
- package/dist/auth-state.d.mts +6 -9
- package/dist/auth-state.mjs +1 -2
- package/dist/authored-style-capture.d.mts +7 -10
- package/dist/authored-style-capture.mjs +1 -2
- package/dist/authored-style-diff.d.mts +8 -12
- package/dist/authored-style-diff.mjs +1 -2
- package/dist/bitmap-font.d.mts +7 -10
- package/dist/bitmap-font.mjs +1 -2
- package/dist/browser-launch.d.mts +7 -11
- package/dist/browser-launch.mjs +1 -2
- package/dist/cli-args.d.mts +8 -11
- package/dist/cli-args.mjs +1 -2
- package/dist/cli-error.d.mts +10 -13
- package/dist/cli-error.mjs +2 -3
- package/dist/computed-style-capture.d.mts +20 -23
- package/dist/computed-style-capture.mjs +4 -5
- package/dist/computed-style-diff.d.mts +8 -11
- package/dist/computed-style-diff.mjs +2 -3
- package/dist/diff-regions.d.mts +3 -7
- package/dist/diff-regions.mjs +1 -2
- package/dist/dom-equivalence.d.mts +5 -8
- package/dist/dom-equivalence.mjs +1 -2
- package/dist/dom-position-styles.d.mts +14 -15
- package/dist/dom-position-styles.mjs +4 -5
- package/dist/element-compare.d.mts +8 -9
- package/dist/element-compare.mjs +5 -5
- package/dist/filmstrip.d.mts +60 -9
- package/dist/filmstrip.mjs +83 -12
- package/dist/gate-config.d.mts +18 -22
- package/dist/gate-config.mjs +8 -4
- package/dist/gate-exit.d.mts +5 -8
- package/dist/gate-exit.mjs +1 -2
- package/dist/gif.d.mts +41 -0
- package/dist/gif.mjs +73 -0
- package/dist/heatmap-regions.d.mts +4 -7
- package/dist/heatmap-regions.mjs +1 -2
- package/dist/heatmap.d.mts +21 -17
- package/dist/heatmap.mjs +23 -11
- package/dist/image-resize.d.mts +9 -12
- package/dist/image-resize.mjs +1 -2
- package/dist/image-timing.d.mts +57 -0
- package/dist/image-timing.mjs +166 -0
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +11 -11
- package/dist/mask.d.mts +5 -9
- package/dist/mask.mjs +1 -2
- package/dist/motion-spec.d.mts +97 -0
- package/dist/motion-spec.mjs +145 -0
- package/dist/navigation-redirect.d.mts +1 -4
- package/dist/navigation-redirect.mjs +1 -2
- package/dist/page-load.d.mts +40 -16
- package/dist/page-load.mjs +34 -5
- package/dist/page-open.d.mts +15 -15
- package/dist/page-open.mjs +4 -3
- package/dist/plugin/args.d.mts +16 -12
- package/dist/plugin/args.mjs +15 -4
- package/dist/plugin/browser.d.mts +3 -3
- package/dist/plugin/browser.mjs +2 -2
- package/dist/plugin/cli-entry.d.mts +1 -4
- package/dist/plugin/cli-entry.mjs +1 -2
- package/dist/plugin/contract.d.mts +17 -21
- package/dist/plugin/contract.mjs +1 -2
- package/dist/plugin/index.d.mts +6 -9
- package/dist/plugin/index.mjs +7 -8
- package/dist/plugin/load.d.mts +7 -11
- package/dist/plugin/load.mjs +1 -2
- package/dist/plugin/registry.d.mts +8 -12
- package/dist/plugin/registry.mjs +1 -2
- package/dist/plugin/rule-prose.d.mts +4 -8
- package/dist/plugin/rule-prose.mjs +1 -2
- package/dist/plugin/rule-tier.d.mts +7 -11
- package/dist/plugin/rule-tier.mjs +1 -2
- package/dist/plugin/rules.d.mts +18 -22
- package/dist/plugin/rules.mjs +1 -2
- package/dist/plugin/runner.d.mts +18 -21
- package/dist/plugin/runner.mjs +55 -6
- package/dist/png-decode.d.mts +17 -0
- package/dist/png-decode.mjs +160 -0
- package/dist/png-utils.d.mts +7 -10
- package/dist/png-utils.mjs +3 -3
- package/dist/project-config.d.mts +7 -10
- package/dist/project-config.mjs +1 -2
- package/dist/rect-overlap.d.mts +3 -6
- package/dist/rect-overlap.mjs +1 -2
- package/dist/region-shift.d.mts +3 -6
- package/dist/region-shift.mjs +1 -2
- package/dist/run-ledger.d.mts +10 -13
- package/dist/run-ledger.mjs +4 -4
- package/dist/stable-selector.d.mts +1 -4
- package/dist/stable-selector.mjs +1 -2
- package/dist/terminal-colors.d.mts +8 -11
- package/dist/terminal-colors.mjs +1 -2
- package/dist/text-rows.d.mts +10 -13
- package/dist/text-rows.mjs +1 -2
- package/dist/types.d.mts +87 -64
- package/dist/version.d.mts +1 -4
- package/dist/version.mjs +2 -3
- package/dist/video-decode.d.mts +144 -0
- package/dist/video-decode.mjs +939 -0
- package/dist/video-frames.d.mts +310 -0
- package/dist/video-frames.mjs +576 -0
- package/dist/webp.d.mts +7 -11
- package/dist/webp.mjs +3 -3
- package/package.json +7 -7
package/dist/plugin/runner.d.mts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { LedgerWrite } from "../run-ledger.mjs";
|
|
2
2
|
import { AnyGateDefinition, Finding, GateDefinition } from "./contract.mjs";
|
|
3
3
|
import { AppliedRules, FindingCounts, RuleSettings } from "./rules.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/plugin/runner.d.ts
|
|
6
4
|
/** Flags the runner owns. A gate's `parse` never sees these as its own. */
|
|
7
|
-
declare const SHARED_GATE_FLAGS: readonly ["--json", "--advisory", "--fail-on-suspect", "--rule", "--rules", "--timing", "--ledger", "--no-ledger", "--help", "-h"];
|
|
8
|
-
interface SharedFlags {
|
|
5
|
+
export declare const SHARED_GATE_FLAGS: readonly ["--json", "--advisory", "--fail-on-suspect", "--rule", "--rules", "--timing", "--ledger", "--no-ledger", "--help", "-h"];
|
|
6
|
+
export interface SharedFlags {
|
|
9
7
|
json: boolean;
|
|
10
8
|
advisory: boolean;
|
|
11
9
|
help: boolean;
|
|
@@ -35,9 +33,9 @@ interface SharedFlags {
|
|
|
35
33
|
* does nothing: it was the documented way to opt *into* failing before
|
|
36
34
|
* failing became the default, and scripts in the wild still pass it.
|
|
37
35
|
*/
|
|
38
|
-
declare function parseSharedFlags(argv: readonly string[]): SharedFlags;
|
|
36
|
+
export declare function parseSharedFlags(argv: readonly string[]): SharedFlags;
|
|
39
37
|
/** Drop the runner-owned flags so a gate's parser never has to know them. */
|
|
40
|
-
declare function stripSharedFlags(argv: readonly string[]): string[];
|
|
38
|
+
export declare function stripSharedFlags(argv: readonly string[]): string[];
|
|
41
39
|
/**
|
|
42
40
|
* Wall-clock ms per contract phase.
|
|
43
41
|
*
|
|
@@ -53,7 +51,7 @@ declare function stripSharedFlags(argv: readonly string[]): string[];
|
|
|
53
51
|
* floor of a browser launch. Reported only when asked, because a timing field
|
|
54
52
|
* is nondeterministic and `--json` has to stay byte-stable for equal inputs.
|
|
55
53
|
*/
|
|
56
|
-
interface GateTiming {
|
|
54
|
+
export interface GateTiming {
|
|
57
55
|
parseMs: number;
|
|
58
56
|
runMs: number;
|
|
59
57
|
/** `gate.findings` — the projection. Per-rule work lives here. */
|
|
@@ -66,7 +64,7 @@ interface GateTiming {
|
|
|
66
64
|
/** Everything above plus the runner's own overhead. */
|
|
67
65
|
totalMs: number;
|
|
68
66
|
}
|
|
69
|
-
interface GateOutcome<Report = unknown> {
|
|
67
|
+
export interface GateOutcome<Report = unknown> {
|
|
70
68
|
gateId: string;
|
|
71
69
|
command: string;
|
|
72
70
|
/** `fail` when a suspect survived rule settings; `--advisory` does not change it. */
|
|
@@ -87,7 +85,7 @@ interface GateOutcome<Report = unknown> {
|
|
|
87
85
|
*/
|
|
88
86
|
ledgerWrite: LedgerWrite | null;
|
|
89
87
|
}
|
|
90
|
-
interface RunGateOptions {
|
|
88
|
+
export interface RunGateOptions {
|
|
91
89
|
cwd?: string;
|
|
92
90
|
/** Project-level rule settings; `--rule` overrides win over these. */
|
|
93
91
|
rules?: RuleSettings;
|
|
@@ -99,7 +97,7 @@ interface RunGateOptions {
|
|
|
99
97
|
* print or set `process.exitCode` — `runGateCli` does that, and tests get to
|
|
100
98
|
* assert on an object instead of scraping stdout.
|
|
101
99
|
*/
|
|
102
|
-
declare function runGate<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions): Promise<GateOutcome<Report>>;
|
|
100
|
+
export declare function runGate<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions): Promise<GateOutcome<Report>>;
|
|
103
101
|
/**
|
|
104
102
|
* Suppression and re-tuning are reported, never silent — the same reason
|
|
105
103
|
* `check integrity` prints its exemptions and `gates suppressions` exists.
|
|
@@ -127,16 +125,16 @@ declare function runGate<Report, Options>(gate: GateDefinition<Report, Options>,
|
|
|
127
125
|
* deliberate: this one is the runner's accounting, tied to the exit code, and a formatter that
|
|
128
126
|
* forgets to render its own note must not be able to make the suppression invisible.
|
|
129
127
|
*/
|
|
130
|
-
declare function formatRuleNotes(gate: AnyGateDefinition, applied: AppliedRules): string;
|
|
128
|
+
export declare function formatRuleNotes(gate: AnyGateDefinition, applied: AppliedRules): string;
|
|
131
129
|
/** `vlmkit <gate> --rules` — the tunable surface, without measuring anything. */
|
|
132
|
-
declare function formatRuleTable(gate: AnyGateDefinition): string;
|
|
130
|
+
export declare function formatRuleTable(gate: AnyGateDefinition): string;
|
|
133
131
|
/**
|
|
134
132
|
* Help text, composed from the definition. The shared-flag block is appended
|
|
135
133
|
* here rather than copied into every gate's usage string, which is how the
|
|
136
134
|
* `--advisory` contract drifted out of `check integrity` in the first place.
|
|
137
135
|
*/
|
|
138
|
-
declare function formatGateHelp(gate: AnyGateDefinition): string;
|
|
139
|
-
interface GateCliIo {
|
|
136
|
+
export declare function formatGateHelp(gate: AnyGateDefinition): string;
|
|
137
|
+
export interface GateCliIo {
|
|
140
138
|
out?: (text: string) => void;
|
|
141
139
|
err?: (text: string) => void;
|
|
142
140
|
}
|
|
@@ -148,7 +146,7 @@ interface GateCliIo {
|
|
|
148
146
|
* the one place the runner touches gate-owned prose, which is why it is a single
|
|
149
147
|
* insertion at a documented anchor rather than a rewrite.
|
|
150
148
|
*/
|
|
151
|
-
declare function withExitIntent(text: string, line: string): string;
|
|
149
|
+
export declare function withExitIntent(text: string, line: string): string;
|
|
152
150
|
/**
|
|
153
151
|
* Is this run measuring a live URL that nothing has pinned?
|
|
154
152
|
*
|
|
@@ -163,7 +161,8 @@ declare function withExitIntent(text: string, line: string): string;
|
|
|
163
161
|
* but the question it was actually answering is "could this differ", and that is
|
|
164
162
|
* decidable without running anything twice.
|
|
165
163
|
*/
|
|
166
|
-
declare function unpinnedLiveInput(gate: AnyGateDefinition, argv: readonly string[]): string | null;
|
|
164
|
+
export declare function unpinnedLiveInput(gate: AnyGateDefinition, argv: readonly string[]): string | null;
|
|
165
|
+
export declare function unknownGateFlags(gate: AnyGateDefinition, argv: readonly string[]): string[];
|
|
167
166
|
/**
|
|
168
167
|
* Announce a file this run brought into existence in an un-ignored spot.
|
|
169
168
|
*
|
|
@@ -179,12 +178,12 @@ declare function unpinnedLiveInput(gate: AnyGateDefinition, argv: readonly strin
|
|
|
179
178
|
* every run would be noise on a file that gets one appended line per gate, and
|
|
180
179
|
* the moment worth reporting is the moment the repo changed shape.
|
|
181
180
|
*/
|
|
182
|
-
declare function newOutputNotice(write: LedgerWrite | null, cwd: string): string | null;
|
|
181
|
+
export declare function newOutputNotice(write: LedgerWrite | null, cwd: string): string | null;
|
|
183
182
|
/**
|
|
184
183
|
* CLI adapter: handle `--help` / `--rules`, run the gate, write the output,
|
|
185
184
|
* return the exit code. A migrated gate's whole `main()` becomes one call.
|
|
186
185
|
*/
|
|
187
|
-
declare function runGateCli<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions & GateCliIo): Promise<0 | 1>;
|
|
186
|
+
export declare function runGateCli<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions & GateCliIo): Promise<0 | 1>;
|
|
188
187
|
/**
|
|
189
188
|
* The phase breakdown as one block.
|
|
190
189
|
*
|
|
@@ -193,6 +192,4 @@ declare function runGateCli<Report, Options>(gate: GateDefinition<Report, Option
|
|
|
193
192
|
* but the page) or slow at everything else (a formatter doing real work — the
|
|
194
193
|
* defect `formatA11yTouchReport` had, where a "formatter" ran a policy).
|
|
195
194
|
*/
|
|
196
|
-
declare function formatGateTiming(outcome: GateOutcome): string;
|
|
197
|
-
//#endregion
|
|
198
|
-
export { GateCliIo, GateOutcome, GateTiming, RunGateOptions, SHARED_GATE_FLAGS, SharedFlags, formatGateHelp, formatGateTiming, formatRuleNotes, formatRuleTable, newOutputNotice, parseSharedFlags, runGate, runGateCli, stripSharedFlags, unpinnedLiveInput, withExitIntent };
|
|
195
|
+
export declare function formatGateTiming(outcome: GateOutcome): string;
|
package/dist/plugin/runner.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { UsageError } from "../cli-error.mjs";
|
|
2
|
+
import { GATE_EXIT_HELP } from "../gate-exit.mjs";
|
|
2
3
|
import { authStateNotice, resetAuthStateNotice } from "../auth-state.mjs";
|
|
4
|
+
import { LEDGER_RELATIVE_PATH, VLMKIT_IGNORE_ENTRIES, appendRunLedger, configureRunLedger, firstLedgerWrite, isGitIgnored, isGitRepo } from "../run-ledger.mjs";
|
|
3
5
|
import { BOLD, CYAN, DIM, RED, RESET, YELLOW } from "../terminal-colors.mjs";
|
|
4
6
|
import { gateCommandString } from "./contract.mjs";
|
|
5
7
|
import { RULE_SETTINGS, applyRuleSettings, countFindings, resolveRules } from "./rules.mjs";
|
|
6
|
-
import { GATE_EXIT_HELP } from "../gate-exit.mjs";
|
|
7
|
-
import { LEDGER_RELATIVE_PATH, VLMKIT_IGNORE_ENTRIES, appendRunLedger, configureRunLedger, firstLedgerWrite, isGitIgnored, isGitRepo } from "../run-ledger.mjs";
|
|
8
8
|
import { relative } from "node:path";
|
|
9
|
-
|
|
9
|
+
// src/plugin/runner.ts
|
|
10
10
|
/**
|
|
11
11
|
* The core gate runner — the part every gate stopped having to write.
|
|
12
12
|
*
|
|
@@ -355,6 +355,35 @@ function unpinnedLiveInput(gate, argv) {
|
|
|
355
355
|
return `${DIM} ${url} is live and not pinned — a re-run may measure different data. Pin it: vlmkit snapshot record-har ${url} --out app.har, then --har app.har${RESET}`;
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
|
+
* Flags on the command line that neither the runner nor the gate declares. They were ignored
|
|
359
|
+
* without a word: an agent passed `verify markup --manifest copy.txt` and could not tell
|
|
360
|
+
* whether the copy was checked (it was not; `check copy --manifest` is the gate that does).
|
|
361
|
+
* Said, not refused: a gate whose `inputs` missed a flag it reads would otherwise break.
|
|
362
|
+
*/
|
|
363
|
+
/** Levenshtein distance, for "did you mean" on a mistyped option. */
|
|
364
|
+
function editDistance(a, b) {
|
|
365
|
+
const row = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
366
|
+
for (let i = 1; i <= a.length; i++) {
|
|
367
|
+
let prev = row[0];
|
|
368
|
+
row[0] = i;
|
|
369
|
+
for (let j = 1; j <= b.length; j++) {
|
|
370
|
+
const cur = row[j];
|
|
371
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
372
|
+
prev = cur;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return row[b.length];
|
|
376
|
+
}
|
|
377
|
+
function unknownGateFlags(gate, argv) {
|
|
378
|
+
const known = /* @__PURE__ */ new Set([...SHARED_GATE_FLAGS, "--har"]);
|
|
379
|
+
for (const input of gate.inputs ?? []) {
|
|
380
|
+
known.add(`--${input.name}`);
|
|
381
|
+
known.add(`--no-${input.name}`);
|
|
382
|
+
}
|
|
383
|
+
const unknown = argv.filter((arg) => arg.startsWith("--") && arg.length > 2).map((arg) => arg.split("=")[0]).filter((flag) => !known.has(flag));
|
|
384
|
+
return [...new Set(unknown)];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
358
387
|
* Announce a file this run brought into existence in an un-ignored spot.
|
|
359
388
|
*
|
|
360
389
|
* The run ledger has always been written to `.vlmkit/run-ledger.jsonl` with no
|
|
@@ -371,8 +400,9 @@ function unpinnedLiveInput(gate, argv) {
|
|
|
371
400
|
*/
|
|
372
401
|
function newOutputNotice(write, cwd) {
|
|
373
402
|
if (!write?.created) return null;
|
|
374
|
-
if (!isGitRepo(cwd) || isGitIgnored(cwd, write.path)) return null;
|
|
375
403
|
const rel = relative(cwd, write.path).split("\\").join("/") || write.path;
|
|
404
|
+
if (!isGitRepo(cwd)) return `${DIM} created ${rel} — an append-only record of every gate run (--no-ledger turns it off)${RESET}`;
|
|
405
|
+
if (isGitIgnored(cwd, write.path)) return null;
|
|
376
406
|
const entries = rel === LEDGER_RELATIVE_PATH.split("\\").join("/") ? [...VLMKIT_IGNORE_ENTRIES] : [rel];
|
|
377
407
|
return [
|
|
378
408
|
`${DIM} created ${rel} — an append-only record of every gate run, one line each.${RESET}`,
|
|
@@ -396,6 +426,26 @@ async function runGateCli(gate, argv, options = {}) {
|
|
|
396
426
|
out(formatRuleTable(gate));
|
|
397
427
|
return 0;
|
|
398
428
|
}
|
|
429
|
+
const unknown = unknownGateFlags(gate, argv);
|
|
430
|
+
if (unknown.length > 0) {
|
|
431
|
+
const names = (gate.inputs ?? []).map((i) => `--${i.name}`);
|
|
432
|
+
const outputs = [
|
|
433
|
+
"--out",
|
|
434
|
+
"--output",
|
|
435
|
+
"--out-dir",
|
|
436
|
+
"--outdir"
|
|
437
|
+
];
|
|
438
|
+
const near = unknown.flatMap((flag) => {
|
|
439
|
+
if (outputs.includes(flag) && names.includes("--frames")) return [`${flag} → --frames`];
|
|
440
|
+
const best = names.map((name) => ({
|
|
441
|
+
name,
|
|
442
|
+
d: editDistance(flag, name)
|
|
443
|
+
})).sort((x, y) => x.d - y.d)[0];
|
|
444
|
+
const word = flag.replace(/^--/, "").length;
|
|
445
|
+
return best && best.d <= Math.min(2, Math.max(1, Math.floor(word / 3))) ? [`${flag} → ${best.name}`] : [];
|
|
446
|
+
});
|
|
447
|
+
(options.err ?? ((text) => console.error(text)))(`warn: ${unknown.join(", ")} ${unknown.length === 1 ? "is not an option" : "are not options"} of vlmkit ${gateCommandString(gate)} and ${unknown.length === 1 ? "was" : "were"} ignored (--help lists its options)${near.length > 0 ? `; did you mean ${near.join(", ")}?` : ""}`);
|
|
448
|
+
}
|
|
399
449
|
const outcome = await runGate(gate, argv, options);
|
|
400
450
|
if (outcome.exitCode === 0 && outcome.counts.warn > 0 && !shared.json) {
|
|
401
451
|
const ids = [...new Set(outcome.findings.filter((f) => f.severity === "warn").map((f) => f.rule))];
|
|
@@ -436,5 +486,4 @@ function formatGateTiming(outcome) {
|
|
|
436
486
|
` ${BOLD}${"total".padEnd(10)}${`${t.totalMs.toFixed(1)}ms`.padStart(9)}${RESET}`
|
|
437
487
|
].join("\n");
|
|
438
488
|
}
|
|
439
|
-
|
|
440
|
-
export { SHARED_GATE_FLAGS, formatGateHelp, formatGateTiming, formatRuleNotes, formatRuleTable, newOutputNotice, parseSharedFlags, runGate, runGateCli, stripSharedFlags, unpinnedLiveInput, withExitIntent };
|
|
489
|
+
export { SHARED_GATE_FLAGS, formatGateHelp, formatGateTiming, formatRuleNotes, formatRuleTable, newOutputNotice, parseSharedFlags, runGate, runGateCli, stripSharedFlags, unknownGateFlags, unpinnedLiveInput, withExitIntent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PngData } from "./png-utils.mjs";
|
|
2
|
+
/** Decoded pixels as they were stored: 3 (RGB) or 4 (RGBA) bytes a pixel, rows packed. */
|
|
3
|
+
export interface PngPixels {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
channels: 3 | 4;
|
|
7
|
+
data: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* CRC-32 (ISO 3309, the one PNG chunks carry), by a 256-entry table. Only for a Node without
|
|
11
|
+
* `zlib.crc32` (before 22.2 / 20.15); exported so a test holds it to zlib's.
|
|
12
|
+
*/
|
|
13
|
+
export declare function tableCrc32(bytes: Uint8Array): number;
|
|
14
|
+
/** A PNG as RGBA. */
|
|
15
|
+
export declare function decodePngBuffer(buffer: Uint8Array): PngData;
|
|
16
|
+
/** A PNG's pixels without widening RGB to RGBA: a screenshot is RGB, and the copy is a third of the decode. */
|
|
17
|
+
export declare function decodePngPixels(buffer: Uint8Array): PngPixels;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as zlib from "node:zlib";
|
|
2
|
+
import { PNG } from "pngjs";
|
|
3
|
+
// src/png-decode.ts
|
|
4
|
+
/**
|
|
5
|
+
* A PNG decoder for the one shape a browser screenshot has — 8-bit RGB or RGBA, not interlaced —
|
|
6
|
+
* in a tight loop over typed arrays, falling back to pngjs for anything else.
|
|
7
|
+
*
|
|
8
|
+
* Why: `check flash` decodes every 60fps frame of a sweep, 181 frames for a 3-second window at
|
|
9
|
+
* 1280x720, and pngjs's generic unfilter and bitmapper took 19 of the 24 seconds of judging one.
|
|
10
|
+
* The inflate is zlib's either way; only the unfilter and the copy to RGBA are done here.
|
|
11
|
+
*
|
|
12
|
+
* Pixels come back only for a file whose header and data agree. Before either decoder sees it,
|
|
13
|
+
* the IHDR must be the first chunk, exactly 13 bytes, of a non-zero size and pass its CRC, and
|
|
14
|
+
* every chunk must lie inside the file up to an IEND. On the fast path the inflated data must
|
|
15
|
+
* then be exactly `height * (1 + width * channels)` bytes; zlib's own adler-32 vouches for the
|
|
16
|
+
* IDAT bytes, so their CRCs are not recomputed. A file that breaks one of these throws instead of
|
|
17
|
+
* going to pngjs, because pngjs 7 does not refuse all of them: measured, it decodes a 14-byte
|
|
18
|
+
* IHDR and a zero width without a word, and reads the last row of a stream one row short from
|
|
19
|
+
* memory it never filled (some runs return the image, some throw on a filter byte). What is only
|
|
20
|
+
* not the fast path's shape (another depth or colour type, interlacing, a `tRNS` colour key) goes
|
|
21
|
+
* to pngjs.
|
|
22
|
+
*/
|
|
23
|
+
const SIGNATURE = [
|
|
24
|
+
137,
|
|
25
|
+
80,
|
|
26
|
+
78,
|
|
27
|
+
71,
|
|
28
|
+
13,
|
|
29
|
+
10,
|
|
30
|
+
26,
|
|
31
|
+
10
|
|
32
|
+
];
|
|
33
|
+
let crcTable;
|
|
34
|
+
/**
|
|
35
|
+
* CRC-32 (ISO 3309, the one PNG chunks carry), by a 256-entry table. Only for a Node without
|
|
36
|
+
* `zlib.crc32` (before 22.2 / 20.15); exported so a test holds it to zlib's.
|
|
37
|
+
*/
|
|
38
|
+
function tableCrc32(bytes) {
|
|
39
|
+
if (!crcTable) {
|
|
40
|
+
crcTable = /* @__PURE__ */ new Uint32Array(256);
|
|
41
|
+
for (let n = 0; n < 256; n++) {
|
|
42
|
+
let c = n;
|
|
43
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
44
|
+
crcTable[n] = c >>> 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let c = 4294967295;
|
|
48
|
+
for (let i = 0; i < bytes.length; i++) c = crcTable[(c ^ bytes[i]) & 255] ^ c >>> 8;
|
|
49
|
+
return (c ^ 4294967295) >>> 0;
|
|
50
|
+
}
|
|
51
|
+
const nativeCrc32 = zlib.crc32;
|
|
52
|
+
const crc32 = (bytes) => nativeCrc32 ? nativeCrc32(bytes) >>> 0 : tableCrc32(bytes);
|
|
53
|
+
/** A PNG as RGBA. */
|
|
54
|
+
function decodePngBuffer(buffer) {
|
|
55
|
+
const px = decodePngPixels(buffer);
|
|
56
|
+
if (px.channels === 4) return {
|
|
57
|
+
width: px.width,
|
|
58
|
+
height: px.height,
|
|
59
|
+
data: px.data
|
|
60
|
+
};
|
|
61
|
+
const out = new Uint8Array(px.width * px.height * 4);
|
|
62
|
+
for (let p = 0, i = 0; i < px.data.length; p += 4, i += 3) {
|
|
63
|
+
out[p] = px.data[i];
|
|
64
|
+
out[p + 1] = px.data[i + 1];
|
|
65
|
+
out[p + 2] = px.data[i + 2];
|
|
66
|
+
out[p + 3] = 255;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
width: px.width,
|
|
70
|
+
height: px.height,
|
|
71
|
+
data: out
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** A PNG's pixels without widening RGB to RGBA: a screenshot is RGB, and the copy is a third of the decode. */
|
|
75
|
+
function decodePngPixels(buffer) {
|
|
76
|
+
for (let i = 0; i < 8; i++) if (buffer[i] !== SIGNATURE[i]) throw new Error("not a PNG");
|
|
77
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
78
|
+
if (buffer.length < 33) throw new Error("PNG is truncated inside its IHDR chunk");
|
|
79
|
+
if (String.fromCharCode(...buffer.subarray(12, 16)) !== "IHDR") throw new Error("PNG does not begin with IHDR");
|
|
80
|
+
if (view.getUint32(8) !== 13) throw new Error(`PNG IHDR is ${view.getUint32(8)} bytes, not 13`);
|
|
81
|
+
if (crc32(buffer.subarray(12, 29)) !== view.getUint32(29)) throw new Error("PNG IHDR fails its CRC");
|
|
82
|
+
const width = view.getUint32(16);
|
|
83
|
+
const height = view.getUint32(20);
|
|
84
|
+
if (width === 0 || height === 0) throw new Error(`PNG IHDR gives a ${width}x${height} image`);
|
|
85
|
+
const depth = buffer[24];
|
|
86
|
+
const colour = buffer[25];
|
|
87
|
+
const method = buffer[26] | buffer[27];
|
|
88
|
+
const interlace = buffer[28];
|
|
89
|
+
let at = 33;
|
|
90
|
+
let ended = false;
|
|
91
|
+
let keyed = false;
|
|
92
|
+
const idat = [];
|
|
93
|
+
while (at + 12 <= buffer.length) {
|
|
94
|
+
const length = view.getUint32(at);
|
|
95
|
+
if (at + 12 + length > buffer.length) break;
|
|
96
|
+
const type = String.fromCharCode(buffer[at + 4], buffer[at + 5], buffer[at + 6], buffer[at + 7]);
|
|
97
|
+
if (type === "IDAT") idat.push(buffer.subarray(at + 8, at + 8 + length));
|
|
98
|
+
else if (type === "IEND") {
|
|
99
|
+
ended = true;
|
|
100
|
+
break;
|
|
101
|
+
} else if (type === "tRNS") keyed = true;
|
|
102
|
+
at += 12 + length;
|
|
103
|
+
}
|
|
104
|
+
if (!ended) throw new Error("PNG is truncated: it ends before its IEND chunk");
|
|
105
|
+
if (idat.length === 0) throw new Error("PNG has no image data");
|
|
106
|
+
const channels = colour === 6 ? 4 : colour === 2 ? 3 : 0;
|
|
107
|
+
if (depth !== 8 || channels === 0 || method !== 0 || interlace !== 0 || keyed) return {
|
|
108
|
+
...viaPngjs(buffer),
|
|
109
|
+
channels: 4
|
|
110
|
+
};
|
|
111
|
+
const inflated = zlib.inflateSync(idat.length === 1 ? idat[0] : Buffer.concat(idat));
|
|
112
|
+
const raw = new Uint8Array(inflated.buffer, inflated.byteOffset, inflated.byteLength);
|
|
113
|
+
const stride = width * channels;
|
|
114
|
+
const expected = (stride + 1) * height;
|
|
115
|
+
if (raw.length !== expected) throw new Error(`PNG data is ${raw.length} bytes; its ${width}x${height} IHDR needs ${expected}`);
|
|
116
|
+
const out = new Uint8Array(width * height * channels);
|
|
117
|
+
const zero = new Uint8Array(stride);
|
|
118
|
+
for (let y = 0; y < height; y++) {
|
|
119
|
+
const filter = raw[y * (stride + 1)];
|
|
120
|
+
const cur = y * (stride + 1) + 1;
|
|
121
|
+
const up = y === 0 ? -1 : cur - (stride + 1);
|
|
122
|
+
const above = up < 0 ? zero : raw;
|
|
123
|
+
const ua = up < 0 ? 0 : up;
|
|
124
|
+
const c = channels;
|
|
125
|
+
if (filter === 1) for (let i = c; i < stride; i++) raw[cur + i] = raw[cur + i] + raw[cur + i - c] & 255;
|
|
126
|
+
else if (filter === 2) for (let i = 0; i < stride; i++) raw[cur + i] = raw[cur + i] + above[ua + i] & 255;
|
|
127
|
+
else if (filter === 3) {
|
|
128
|
+
for (let i = 0; i < c; i++) raw[cur + i] = raw[cur + i] + (above[ua + i] >> 1) & 255;
|
|
129
|
+
for (let i = c; i < stride; i++) raw[cur + i] = raw[cur + i] + (raw[cur + i - c] + above[ua + i] >> 1) & 255;
|
|
130
|
+
} else if (filter === 4) {
|
|
131
|
+
for (let i = 0; i < c; i++) raw[cur + i] = raw[cur + i] + above[ua + i] & 255;
|
|
132
|
+
for (let i = c; i < stride; i++) {
|
|
133
|
+
const a = raw[cur + i - c];
|
|
134
|
+
const b = above[ua + i];
|
|
135
|
+
const d = above[ua + i - c];
|
|
136
|
+
const pa = b > d ? b - d : d - b;
|
|
137
|
+
const pb = a > d ? a - d : d - a;
|
|
138
|
+
const pc0 = a + b - d - d;
|
|
139
|
+
const pc = pc0 < 0 ? -pc0 : pc0;
|
|
140
|
+
raw[cur + i] = raw[cur + i] + (pa <= pb && pa <= pc ? a : pb <= pc ? b : d) & 255;
|
|
141
|
+
}
|
|
142
|
+
} else if (filter !== 0) throw new Error(`PNG row ${y} has filter ${filter}`);
|
|
143
|
+
out.set(raw.subarray(cur, cur + stride), y * stride);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
width,
|
|
147
|
+
height,
|
|
148
|
+
channels,
|
|
149
|
+
data: out
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function viaPngjs(buffer) {
|
|
153
|
+
const png = PNG.sync.read(Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength));
|
|
154
|
+
return {
|
|
155
|
+
width: png.width,
|
|
156
|
+
height: png.height,
|
|
157
|
+
data: new Uint8Array(png.data.buffer, png.data.byteOffset, png.data.byteLength)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
export { decodePngBuffer, decodePngPixels, tableCrc32 };
|
package/dist/png-utils.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface PngData {
|
|
1
|
+
export interface PngData {
|
|
3
2
|
width: number;
|
|
4
3
|
height: number;
|
|
5
4
|
data: Uint8Array;
|
|
@@ -22,7 +21,7 @@ interface PngData {
|
|
|
22
21
|
* differently — a size mismatch, not a colour change, and one the caller should
|
|
23
22
|
* see as such rather than folded into a colour statistic.
|
|
24
23
|
*/
|
|
25
|
-
interface ChangeMagnitude {
|
|
24
|
+
export interface ChangeMagnitude {
|
|
26
25
|
/** Pixels with any non-zero channel delta, however small. */
|
|
27
26
|
changedPixels: number;
|
|
28
27
|
totalPixels: number;
|
|
@@ -33,12 +32,12 @@ interface ChangeMagnitude {
|
|
|
33
32
|
/** Mean per-pixel max-channel delta over the whole image, 0-255. */
|
|
34
33
|
meanChannelDelta: number;
|
|
35
34
|
}
|
|
36
|
-
declare function measureChangeMagnitude(a: PngData, b: PngData): ChangeMagnitude;
|
|
35
|
+
export declare function measureChangeMagnitude(a: PngData, b: PngData): ChangeMagnitude;
|
|
37
36
|
/**
|
|
38
37
|
* Crop or pad an image to the target dimensions.
|
|
39
38
|
* Only handles the common region; overflow is zero-filled.
|
|
40
39
|
*/
|
|
41
|
-
declare function cropImage(img: PngData, w: number, h: number): PngData;
|
|
40
|
+
export declare function cropImage(img: PngData, w: number, h: number): PngData;
|
|
42
41
|
/**
|
|
43
42
|
* Crop an arbitrary rectangle out of an image.
|
|
44
43
|
*
|
|
@@ -47,14 +46,12 @@ declare function cropImage(img: PngData, w: number, h: number): PngData;
|
|
|
47
46
|
* clamped to the image bounds, so the returned crop may be smaller than
|
|
48
47
|
* requested when the region overruns an edge (or off the top-left).
|
|
49
48
|
*/
|
|
50
|
-
declare function cropRegion(img: PngData, x: number, y: number, w: number, h: number): PngData;
|
|
49
|
+
export declare function cropRegion(img: PngData, x: number, y: number, w: number, h: number): PngData;
|
|
51
50
|
/**
|
|
52
51
|
* Read a PNG file and return RGBA pixel data.
|
|
53
52
|
*/
|
|
54
|
-
declare function decodePng(path: string): Promise<PngData>;
|
|
53
|
+
export declare function decodePng(path: string): Promise<PngData>;
|
|
55
54
|
/**
|
|
56
55
|
* Write RGBA pixel data to a PNG file.
|
|
57
56
|
*/
|
|
58
|
-
declare function encodePng(path: string, data: PngData): Promise<void>;
|
|
59
|
-
//#endregion
|
|
60
|
-
export { ChangeMagnitude, PngData, cropImage, cropRegion, decodePng, encodePng, measureChangeMagnitude };
|
|
57
|
+
export declare function encodePng(path: string, data: PngData): Promise<void>;
|
package/dist/png-utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
|
|
2
|
+
// src/png-utils.ts
|
|
3
3
|
/**
|
|
4
4
|
* PNG I/O utilities
|
|
5
5
|
*
|
|
@@ -97,7 +97,7 @@ async function encodePng(path, data) {
|
|
|
97
97
|
height: data.height
|
|
98
98
|
});
|
|
99
99
|
Buffer.from(data.data.buffer, data.data.byteOffset, data.data.byteLength).copy(png.data);
|
|
100
|
-
|
|
100
|
+
const buffer = PNG.sync.write(png);
|
|
101
|
+
await writeFile(path, buffer);
|
|
101
102
|
}
|
|
102
|
-
//#endregion
|
|
103
103
|
export { cropImage, cropRegion, decodePng, encodePng, measureChangeMagnitude };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare const CONFIG_CANDIDATES: readonly ["vlmkit.config.json", "vlmkit.config.toml"];
|
|
1
|
+
export declare const STATE_DIR = ".vlmkit";
|
|
2
|
+
export declare const CONFIG_FILE = "vlmkit.config.json";
|
|
3
|
+
export declare const CONFIG_CANDIDATES: readonly ["vlmkit.config.json", "vlmkit.config.toml"];
|
|
5
4
|
/** Resolve a project-owned state entry below the canonical state directory. */
|
|
6
|
-
declare function resolveStatePath(cwd: string, entry: string): string;
|
|
5
|
+
export declare function resolveStatePath(cwd: string, entry: string): string;
|
|
7
6
|
/** Read a canonical VLMKIT_* environment variable. */
|
|
8
|
-
declare function readEnv(suffix: string): string | undefined;
|
|
9
|
-
declare function debugEnabled(): boolean;
|
|
10
|
-
declare const ENV_SUFFIXES: readonly ["BASE_URL", "CAPTURE_BACKEND", "CONFIG_FILE", "CONFIG_PATH", "LLM_MODEL", "LLM_PROVIDER", "PROJECT_ROOT", "VLM_MODEL"];
|
|
11
|
-
//#endregion
|
|
12
|
-
export { CONFIG_CANDIDATES, CONFIG_FILE, ENV_SUFFIXES, STATE_DIR, debugEnabled, readEnv, resolveStatePath };
|
|
7
|
+
export declare function readEnv(suffix: string): string | undefined;
|
|
8
|
+
export declare function debugEnabled(): boolean;
|
|
9
|
+
export declare const ENV_SUFFIXES: readonly ["BASE_URL", "CAPTURE_BACKEND", "CONFIG_FILE", "CONFIG_PATH", "LLM_MODEL", "LLM_PROVIDER", "PROJECT_ROOT", "VLM_MODEL"];
|
package/dist/project-config.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
|
|
2
|
+
// src/project-config.ts
|
|
3
3
|
const STATE_DIR = ".vlmkit";
|
|
4
4
|
const CONFIG_FILE = "vlmkit.config.json";
|
|
5
5
|
const CONFIG_CANDIDATES = [CONFIG_FILE, "vlmkit.config.toml"];
|
|
@@ -24,5 +24,4 @@ const ENV_SUFFIXES = [
|
|
|
24
24
|
"PROJECT_ROOT",
|
|
25
25
|
"VLM_MODEL"
|
|
26
26
|
];
|
|
27
|
-
//#endregion
|
|
28
27
|
export { CONFIG_CANDIDATES, CONFIG_FILE, ENV_SUFFIXES, STATE_DIR, debugEnabled, readEnv, resolveStatePath };
|
package/dist/rect-overlap.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/rect-overlap.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* How much two boxes overlap, in one place.
|
|
4
3
|
*
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|
* rather than the area, because they report which axis collided.
|
|
17
16
|
*/
|
|
18
17
|
/** Any box with a top-left origin. `x`/`y`-shaped callers pass `{ left: x, top: y, … }`. */
|
|
19
|
-
interface OverlapBox {
|
|
18
|
+
export interface OverlapBox {
|
|
20
19
|
left: number;
|
|
21
20
|
top: number;
|
|
22
21
|
width: number;
|
|
@@ -28,7 +27,7 @@ interface OverlapBox {
|
|
|
28
27
|
* `Math.max(0, …)` on each axis rather than an early return: boxes that touch along one edge have a
|
|
29
28
|
* zero-width intersection, and multiplying gives 0 without a special case.
|
|
30
29
|
*/
|
|
31
|
-
declare function overlapArea(a: OverlapBox, b: OverlapBox): number;
|
|
30
|
+
export declare function overlapArea(a: OverlapBox, b: OverlapBox): number;
|
|
32
31
|
/**
|
|
33
32
|
* Intersection over union, the standard box-similarity ratio: 1 for identical boxes, 0 for disjoint.
|
|
34
33
|
*
|
|
@@ -36,6 +35,4 @@ declare function overlapArea(a: OverlapBox, b: OverlapBox): number;
|
|
|
36
35
|
* hand every caller a value that fails every comparison it is put into. `NaN > threshold` is false,
|
|
37
36
|
* so the case would read as "not similar" in some callers and be silently skipped in others.
|
|
38
37
|
*/
|
|
39
|
-
declare function iou(a: OverlapBox, b: OverlapBox): number;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { OverlapBox, iou, overlapArea };
|
|
38
|
+
export declare function iou(a: OverlapBox, b: OverlapBox): number;
|
package/dist/rect-overlap.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/rect-overlap.ts
|
|
2
2
|
/**
|
|
3
3
|
* Area shared by two boxes, and 0 when they do not overlap at all.
|
|
4
4
|
*
|
|
@@ -24,5 +24,4 @@ function iou(a, b) {
|
|
|
24
24
|
const union = a.width * a.height + b.width * b.height - inter;
|
|
25
25
|
return union > 0 ? inter / union : 0;
|
|
26
26
|
}
|
|
27
|
-
//#endregion
|
|
28
27
|
export { iou, overlapArea };
|
package/dist/region-shift.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { PngData } from "./png-utils.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/region-shift.d.ts
|
|
4
|
-
interface RegionShiftEstimate {
|
|
2
|
+
export interface RegionShiftEstimate {
|
|
5
3
|
/** Content moved by +dx px horizontally in current (vs baseline). */
|
|
6
4
|
dx: number;
|
|
7
5
|
/** Content moved by +dy px vertically in current (vs baseline). */
|
|
@@ -15,6 +13,5 @@ interface RegionRect {
|
|
|
15
13
|
width: number;
|
|
16
14
|
height: number;
|
|
17
15
|
}
|
|
18
|
-
declare function estimateRegionShift(baseline: PngData, current: PngData, region: RegionRect, maxOffset?: number): RegionShiftEstimate | null;
|
|
19
|
-
|
|
20
|
-
export { RegionShiftEstimate, estimateRegionShift };
|
|
16
|
+
export declare function estimateRegionShift(baseline: PngData, current: PngData, region: RegionRect, maxOffset?: number): RegionShiftEstimate | null;
|
|
17
|
+
export {};
|
package/dist/region-shift.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/region-shift.ts
|
|
2
2
|
const MIN_REGION_EDGE = 8;
|
|
3
3
|
const MIN_PEAK = .6;
|
|
4
4
|
/** The shifted-lag peak must beat the zero-lag correlation by this much. */
|
|
@@ -124,5 +124,4 @@ function lumaAt(img, x, y) {
|
|
|
124
124
|
function clamp(value, min, max) {
|
|
125
125
|
return Math.max(min, Math.min(max, value));
|
|
126
126
|
}
|
|
127
|
-
//#endregion
|
|
128
127
|
export { estimateRegionShift };
|
package/dist/run-ledger.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface RunLedgerEntry {
|
|
1
|
+
export interface RunLedgerEntry {
|
|
3
2
|
/** Tool name, e.g. "build-page", "check-breakpoints", "verify-markup". */
|
|
4
3
|
tool: string;
|
|
5
4
|
/** Primary input (attempt HTML or URL). */
|
|
@@ -10,7 +9,7 @@ interface RunLedgerEntry {
|
|
|
10
9
|
headline: Record<string, string | number | boolean | null>;
|
|
11
10
|
}
|
|
12
11
|
/** Default location, relative to the working directory. */
|
|
13
|
-
declare const LEDGER_RELATIVE_PATH: string;
|
|
12
|
+
export declare const LEDGER_RELATIVE_PATH: string;
|
|
14
13
|
/**
|
|
15
14
|
* The directories a vlmkit run creates under the working directory. Exported so
|
|
16
15
|
* `gates init` can write them into `.gitignore` and the runner can name them in
|
|
@@ -19,14 +18,14 @@ declare const LEDGER_RELATIVE_PATH: string;
|
|
|
19
18
|
* v6's adopting agent had to discover both with `ls` and write the `.gitignore`
|
|
20
19
|
* itself: "adopting the tool dirtied the repo silently."
|
|
21
20
|
*/
|
|
22
|
-
declare const VLMKIT_IGNORE_ENTRIES: readonly [".vlmkit/", "test-results/"];
|
|
23
|
-
interface LedgerWrite {
|
|
21
|
+
export declare const VLMKIT_IGNORE_ENTRIES: readonly [".vlmkit/", "test-results/"];
|
|
22
|
+
export interface LedgerWrite {
|
|
24
23
|
/** Absolute path appended to. */
|
|
25
24
|
path: string;
|
|
26
25
|
/** True when this call brought the file into existence. */
|
|
27
26
|
created: boolean;
|
|
28
27
|
}
|
|
29
|
-
interface AppendRunLedgerOptions {
|
|
28
|
+
export interface AppendRunLedgerOptions {
|
|
30
29
|
cwd?: string;
|
|
31
30
|
/**
|
|
32
31
|
* Explicit target from `--ledger <path>`. A directory-less path is still
|
|
@@ -37,20 +36,20 @@ interface AppendRunLedgerOptions {
|
|
|
37
36
|
disabled?: boolean;
|
|
38
37
|
}
|
|
39
38
|
/** Replace the run-level settings. Called once per run; resets the first-write record. */
|
|
40
|
-
declare function configureRunLedger(options?: AppendRunLedgerOptions): void;
|
|
39
|
+
export declare function configureRunLedger(options?: AppendRunLedgerOptions): void;
|
|
41
40
|
/**
|
|
42
41
|
* The append that brought the ledger into existence this run, if any.
|
|
43
42
|
*
|
|
44
43
|
* Reported by whoever prints, so a gate that writes from inside its measurement
|
|
45
44
|
* gets the same announcement as one using the `gate.ledger` hook.
|
|
46
45
|
*/
|
|
47
|
-
declare function firstLedgerWrite(): LedgerWrite | null;
|
|
46
|
+
export declare function firstLedgerWrite(): LedgerWrite | null;
|
|
48
47
|
/**
|
|
49
48
|
* Append one entry. Returns what was written, or `null` when the ledger is off
|
|
50
49
|
* or the write failed — the caller uses that to announce a first write rather
|
|
51
50
|
* than to decide anything.
|
|
52
51
|
*/
|
|
53
|
-
declare function appendRunLedger(entry: RunLedgerEntry, options?: AppendRunLedgerOptions | string): LedgerWrite | null;
|
|
52
|
+
export declare function appendRunLedger(entry: RunLedgerEntry, options?: AppendRunLedgerOptions | string): LedgerWrite | null;
|
|
54
53
|
/**
|
|
55
54
|
* Is `target` already covered by the working directory's `.gitignore`?
|
|
56
55
|
*
|
|
@@ -61,8 +60,6 @@ declare function appendRunLedger(entry: RunLedgerEntry, options?: AppendRunLedge
|
|
|
61
60
|
* is the right trade — but it must not guess wrong in the *other* direction,
|
|
62
61
|
* which is why anything unreadable counts as "not ignored" rather than ignored.
|
|
63
62
|
*/
|
|
64
|
-
declare function isGitIgnored(cwd: string, target: string): boolean;
|
|
63
|
+
export declare function isGitIgnored(cwd: string, target: string): boolean;
|
|
65
64
|
/** Is this working directory a git repo at all? Nothing to advise if it is not. */
|
|
66
|
-
declare function isGitRepo(cwd: string): boolean;
|
|
67
|
-
//#endregion
|
|
68
|
-
export { AppendRunLedgerOptions, LEDGER_RELATIVE_PATH, LedgerWrite, RunLedgerEntry, VLMKIT_IGNORE_ENTRIES, appendRunLedger, configureRunLedger, firstLedgerWrite, isGitIgnored, isGitRepo };
|
|
65
|
+
export declare function isGitRepo(cwd: string): boolean;
|