@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/args.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { UsageError } from "../cli-error.mjs";
|
|
2
1
|
import { readFlag, readInt, readPositionals } from "../arg-reader.mjs";
|
|
2
|
+
import { UsageError } from "../cli-error.mjs";
|
|
3
3
|
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { parseInstants } from "@mizchi/vlmkit-judge/frames.ts";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
|
-
|
|
6
|
+
// src/plugin/args.ts
|
|
6
7
|
/**
|
|
7
8
|
* Argument helpers for writing a gate — the shapes `arg-reader` does not cover.
|
|
8
9
|
*
|
|
@@ -36,6 +37,7 @@ const COMMON_VALUE_FLAGS = [
|
|
|
36
37
|
"--timeout",
|
|
37
38
|
"--wait-until",
|
|
38
39
|
"--har",
|
|
40
|
+
"--color-scheme",
|
|
39
41
|
"--storage-state",
|
|
40
42
|
"--allow",
|
|
41
43
|
"--contract",
|
|
@@ -98,6 +100,16 @@ function numberList(argv, name) {
|
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
103
|
+
* `--at 0,150,1.5s,0..1s/100ms` → instants in ms, sorted and deduplicated. Absent flag →
|
|
104
|
+
* `undefined`. The grammar is `parseInstants` (`@mizchi/vlmkit-judge/frames.ts`): bare numbers
|
|
105
|
+
* are ms, and `s`, `ms`, `f` (60fps frames), `mm:ss.sss` and ranges are accepted. Not
|
|
106
|
+
* `numberList`, whose `parseInt` read `1.5s` as 1 ms.
|
|
107
|
+
*/
|
|
108
|
+
function instantList(argv, name) {
|
|
109
|
+
const raw = readFlag(argv, name);
|
|
110
|
+
return raw === void 0 ? void 0 : parseInstants(raw, `--${name}`);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
101
113
|
* Like `numberList`, but for scales that are legitimately fractional
|
|
102
114
|
* (`--tolerance`-adjacent flags such as `--radius-scale 0,2,4.5`).
|
|
103
115
|
*/
|
|
@@ -158,5 +170,4 @@ function runOutputDir(gateDir, source, discriminator = "") {
|
|
|
158
170
|
const hash = createHash("sha1").update(resolve(source) + " " + discriminator).digest("hex").slice(0, 8);
|
|
159
171
|
return join(process.cwd(), "test-results", gateDir, name.replace(/[^A-Za-z0-9._-]+/g, "-") + "-" + hash);
|
|
160
172
|
}
|
|
161
|
-
|
|
162
|
-
export { firstPositional, firstPositionalOrUndefined, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
173
|
+
export { firstPositional, firstPositionalOrUndefined, instantList, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { withAuthState } from "../auth-state.mjs";
|
|
2
1
|
import { launchBrowser, withBrowser } from "../browser-launch.mjs";
|
|
3
|
-
import { LedgerWrite, RunLedgerEntry, appendRunLedger, configureRunLedger, firstLedgerWrite } from "../run-ledger.mjs";
|
|
4
|
-
import { describeRedirect } from "../navigation-redirect.mjs";
|
|
5
2
|
import { HarReplay, applyHar, openSource } from "../page-open.mjs";
|
|
3
|
+
import { withAuthState } from "../auth-state.mjs";
|
|
4
|
+
import { describeRedirect } from "../navigation-redirect.mjs";
|
|
5
|
+
import { LedgerWrite, RunLedgerEntry, appendRunLedger, configureRunLedger, firstLedgerWrite } from "../run-ledger.mjs";
|
|
6
6
|
export { type HarReplay, type LedgerWrite, type RunLedgerEntry, appendRunLedger, applyHar, configureRunLedger, describeRedirect, firstLedgerWrite, launchBrowser, openSource, withAuthState, withBrowser };
|
package/dist/plugin/browser.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { withAuthState } from "../auth-state.mjs";
|
|
2
1
|
import { launchBrowser, withBrowser } from "../browser-launch.mjs";
|
|
3
|
-
import { describeRedirect } from "../navigation-redirect.mjs";
|
|
4
2
|
import { applyHar, openSource } from "../page-open.mjs";
|
|
3
|
+
import { withAuthState } from "../auth-state.mjs";
|
|
4
|
+
import { describeRedirect } from "../navigation-redirect.mjs";
|
|
5
5
|
import { appendRunLedger, configureRunLedger, firstLedgerWrite } from "../run-ledger.mjs";
|
|
6
6
|
export { appendRunLedger, applyHar, configureRunLedger, describeRedirect, firstLedgerWrite, launchBrowser, openSource, withAuthState, withBrowser };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugin/cli-entry.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* @param moduleUrl always `import.meta.url` from the module asking.
|
|
4
3
|
* @param dispatcherName the module's name in `vlmkit`'s command table, when it has
|
|
@@ -6,6 +5,4 @@
|
|
|
6
5
|
* so for a dispatched command the env var is the entry signal and argv[1] is the
|
|
7
6
|
* dispatcher rather than the module.
|
|
8
7
|
*/
|
|
9
|
-
declare function isCliEntry(moduleUrl: string, dispatcherName?: string): boolean;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { isCliEntry };
|
|
8
|
+
export declare function isCliEntry(moduleUrl: string, dispatcherName?: string): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
4
|
+
// src/plugin/cli-entry.ts
|
|
5
5
|
/**
|
|
6
6
|
* "Was this module run, or imported?"
|
|
7
7
|
*
|
|
@@ -65,5 +65,4 @@ function isCliEntry(moduleUrl, dispatcherName) {
|
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
//#endregion
|
|
69
68
|
export { isCliEntry };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { RunLedgerEntry } from "../run-ledger.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/plugin/contract.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* Normalized finding severity.
|
|
6
4
|
*
|
|
@@ -10,14 +8,14 @@ import { RunLedgerEntry } from "../run-ledger.mjs";
|
|
|
10
8
|
* the normal form and adapters map into it. `info` exists for findings a
|
|
11
9
|
* gate wants to report without ever affecting a verdict.
|
|
12
10
|
*/
|
|
13
|
-
type FindingSeverity = "suspect" | "warn" | "info";
|
|
14
|
-
declare const FINDING_SEVERITIES: readonly FindingSeverity[];
|
|
11
|
+
export type FindingSeverity = "suspect" | "warn" | "info";
|
|
12
|
+
export declare const FINDING_SEVERITIES: readonly FindingSeverity[];
|
|
15
13
|
/**
|
|
16
14
|
* One normalized finding. `rule` is the gate-local rule id — the same
|
|
17
15
|
* string the gate's own report calls `kind`, so a migration is a rename
|
|
18
16
|
* rather than a re-classification.
|
|
19
17
|
*/
|
|
20
|
-
interface Finding {
|
|
18
|
+
export interface Finding {
|
|
21
19
|
/** Gate-local rule id, e.g. `text-collision`. Must exist in the gate's rule table. */
|
|
22
20
|
rule: string;
|
|
23
21
|
severity: FindingSeverity;
|
|
@@ -41,7 +39,7 @@ interface Finding {
|
|
|
41
39
|
* silence `check integrity` entirely, or append a flag the gate happened to
|
|
42
40
|
* implement).
|
|
43
41
|
*/
|
|
44
|
-
interface RuleDefinition {
|
|
42
|
+
export interface RuleDefinition {
|
|
45
43
|
/** Gate-local id. Stable — it appears in configs and reports. */
|
|
46
44
|
id: string;
|
|
47
45
|
/** One-line human name, used in `--rules` listings. */
|
|
@@ -70,7 +68,7 @@ interface RuleDefinition {
|
|
|
70
68
|
* mini-DSL, `--viewports 1280,768,375`). `inputs` is the machine-readable
|
|
71
69
|
* summary of what `parse` accepts, not a replacement for it.
|
|
72
70
|
*/
|
|
73
|
-
interface GateInput {
|
|
71
|
+
export interface GateInput {
|
|
74
72
|
/** Flag name without dashes, or `"source"` / `"target"` for positionals. */
|
|
75
73
|
name: string;
|
|
76
74
|
/**
|
|
@@ -92,7 +90,7 @@ interface GateInput {
|
|
|
92
90
|
defaultDescription?: string;
|
|
93
91
|
}
|
|
94
92
|
/** Everything the runner hands a gate that the gate should not read from globals. */
|
|
95
|
-
interface GateContext {
|
|
93
|
+
export interface GateContext {
|
|
96
94
|
cwd: string;
|
|
97
95
|
/** Raw argv after the command tokens, for gates that need a flag `parse` dropped. */
|
|
98
96
|
argv: readonly string[];
|
|
@@ -112,15 +110,15 @@ interface GateContext {
|
|
|
112
110
|
* "is the page broken", "does it behave", "does it look like our system",
|
|
113
111
|
* "is it done", "is my tooling working".
|
|
114
112
|
*/
|
|
115
|
-
declare const GATE_CATEGORIES: {
|
|
113
|
+
export declare const GATE_CATEGORIES: {
|
|
116
114
|
readonly correctness: "Is the page broken, on its own terms? No reference needed.";
|
|
117
115
|
readonly behavior: "Does it respond correctly to size, scroll, motion and input?";
|
|
118
116
|
readonly "design-system": "Does it conform to the design language the project declares?";
|
|
119
117
|
readonly verdict: "Is this attempt done? Aggregates other signals into one answer.";
|
|
120
118
|
readonly infrastructure: "Is the measurement toolchain itself working?";
|
|
121
119
|
};
|
|
122
|
-
type GateCategory = keyof typeof GATE_CATEGORIES;
|
|
123
|
-
declare const GATE_CATEGORY_ORDER: readonly GateCategory[];
|
|
120
|
+
export type GateCategory = keyof typeof GATE_CATEGORIES;
|
|
121
|
+
export declare const GATE_CATEGORY_ORDER: readonly GateCategory[];
|
|
124
122
|
/**
|
|
125
123
|
* A gate definition.
|
|
126
124
|
*
|
|
@@ -135,7 +133,7 @@ declare const GATE_CATEGORY_ORDER: readonly GateCategory[];
|
|
|
135
133
|
* needs "what is this rule worth now", and handing it the suppressed/retuned lists
|
|
136
134
|
* would invite it to re-derive the runner's decisions and disagree with them.
|
|
137
135
|
*/
|
|
138
|
-
interface RuleView {
|
|
136
|
+
export interface RuleView {
|
|
139
137
|
/**
|
|
140
138
|
* Effective setting for a rule id, after project config and `--rule`, falling back to the
|
|
141
139
|
* severity the gate DECLARED for it.
|
|
@@ -157,7 +155,7 @@ interface RuleView {
|
|
|
157
155
|
*/
|
|
158
156
|
setting(ruleId: string): "off" | FindingSeverity | undefined;
|
|
159
157
|
}
|
|
160
|
-
interface GateDefinition<Report = unknown, Options = unknown> {
|
|
158
|
+
export interface GateDefinition<Report = unknown, Options = unknown> {
|
|
161
159
|
/**
|
|
162
160
|
* Stable machine id, `<group>.<leaf>` — `check.integrity`. Used by rule
|
|
163
161
|
* settings, the ledger, and plugin conflict detection. Never localized,
|
|
@@ -246,25 +244,23 @@ interface GateDefinition<Report = unknown, Options = unknown> {
|
|
|
246
244
|
ledger?: (report: Report, options: Options) => RunLedgerEntry | null;
|
|
247
245
|
}
|
|
248
246
|
/** A definition with its type parameters erased, for registries and lists. */
|
|
249
|
-
type AnyGateDefinition = GateDefinition<any, any>;
|
|
247
|
+
export type AnyGateDefinition = GateDefinition<any, any>;
|
|
250
248
|
/**
|
|
251
249
|
* A plugin is a named bundle of gates. Built-in gates ship as plugins too
|
|
252
250
|
* (`vlmkit-markup` exports one), so "add a gate" is the same operation for
|
|
253
251
|
* this repo and for a third party — there is no privileged built-in path.
|
|
254
252
|
*/
|
|
255
|
-
interface VlmkitPlugin {
|
|
253
|
+
export interface VlmkitPlugin {
|
|
256
254
|
/** Unique plugin name, reported in conflict errors and `vlmkit rules --plugins`. */
|
|
257
255
|
name: string;
|
|
258
256
|
version?: string;
|
|
259
257
|
gates: readonly AnyGateDefinition[];
|
|
260
258
|
}
|
|
261
259
|
/** Identity helper that pins the type parameters at the definition site. */
|
|
262
|
-
declare function defineGate<Report, Options>(definition: GateDefinition<Report, Options>): GateDefinition<Report, Options>;
|
|
260
|
+
export declare function defineGate<Report, Options>(definition: GateDefinition<Report, Options>): GateDefinition<Report, Options>;
|
|
263
261
|
/** Identity helper for plugin authors; also the documented entry point. */
|
|
264
|
-
declare function definePlugin(plugin: VlmkitPlugin): VlmkitPlugin;
|
|
262
|
+
export declare function definePlugin(plugin: VlmkitPlugin): VlmkitPlugin;
|
|
265
263
|
/** `check integrity` — the human-facing form of `command`. */
|
|
266
|
-
declare function gateCommandString(gate: AnyGateDefinition): string;
|
|
264
|
+
export declare function gateCommandString(gate: AnyGateDefinition): string;
|
|
267
265
|
/** Fully-qualified rule reference used in configs: `check.integrity/text-collision`. */
|
|
268
|
-
declare function ruleRef(gateId: string, ruleId: string): string;
|
|
269
|
-
//#endregion
|
|
270
|
-
export { AnyGateDefinition, FINDING_SEVERITIES, Finding, FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GateCategory, GateContext, GateDefinition, GateInput, RuleDefinition, RuleView, VlmkitPlugin, defineGate, definePlugin, gateCommandString, ruleRef };
|
|
266
|
+
export declare function ruleRef(gateId: string, ruleId: string): string;
|
package/dist/plugin/contract.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugin/contract.ts
|
|
2
2
|
const FINDING_SEVERITIES = [
|
|
3
3
|
"suspect",
|
|
4
4
|
"warn",
|
|
@@ -47,5 +47,4 @@ function gateCommandString(gate) {
|
|
|
47
47
|
function ruleRef(gateId, ruleId) {
|
|
48
48
|
return `${gateId}/${ruleId}`;
|
|
49
49
|
}
|
|
50
|
-
//#endregion
|
|
51
50
|
export { FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, defineGate, definePlugin, gateCommandString, ruleRef };
|
package/dist/plugin/index.d.mts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { hasFlag, readAll, readChoice, readFlag, readInt, readNumber, readPositionals, tokenizeCommand } from "../arg-reader.mjs";
|
|
2
|
-
import { UsageError } from "../cli-error.mjs";
|
|
3
1
|
import { AnyGateDefinition, FINDING_SEVERITIES, Finding, FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GateCategory, GateContext, GateDefinition, GateInput, RuleDefinition, RuleView, VlmkitPlugin, defineGate, definePlugin, gateCommandString, ruleRef } from "./contract.mjs";
|
|
4
2
|
import { AppliedRules, RULE_SETTINGS, RuleSetting, RuleSettingEntry, RuleSettings } from "./rules.mjs";
|
|
5
|
-
import { DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PageLoadOptions, PageLoadWaitUntil, navigationOptions, parsePageLoad, pickPageLoad } from "../page-load.mjs";
|
|
6
|
-
import {
|
|
3
|
+
import { COLOR_SCHEMES, COLOR_SCHEME_INPUT, COLOR_SCHEME_VALUE_FLAGS, ColorScheme, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PageLoadOptions, PageLoadWaitUntil, applyColorScheme, navigationOptions, parseColorScheme, parsePageLoad, pickPageLoad } from "../page-load.mjs";
|
|
4
|
+
import { hasFlag, readAll, readChoice, readFlag, readInt, readNumber, readPositionals, tokenizeCommand } from "../arg-reader.mjs";
|
|
5
|
+
import { firstPositional, firstPositionalOrUndefined, instantList, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue } from "./args.mjs";
|
|
7
6
|
import { isCliEntry } from "./cli-entry.mjs";
|
|
7
|
+
import { UsageError } from "../cli-error.mjs";
|
|
8
8
|
import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, hr } from "../terminal-colors.mjs";
|
|
9
9
|
import { CONFIG_CANDIDATES, CONFIG_FILE, STATE_DIR, debugEnabled, readEnv, resolveStatePath } from "../project-config.mjs";
|
|
10
|
-
|
|
11
|
-
//#region src/plugin/index.d.ts
|
|
12
10
|
/**
|
|
13
11
|
* `@mizchi/vlmkit-core/plugin` — the whole surface a gate plugin needs.
|
|
14
12
|
*
|
|
@@ -77,6 +75,5 @@ import { CONFIG_CANDIDATES, CONFIG_FILE, STATE_DIR, debugEnabled, readEnv, resol
|
|
|
77
75
|
* if (PLUGIN_API_VERSION !== 1) throw new Error("built for plugin API 1");
|
|
78
76
|
* ```
|
|
79
77
|
*/
|
|
80
|
-
declare const PLUGIN_API_VERSION: 1;
|
|
81
|
-
|
|
82
|
-
export { type AnyGateDefinition, type AppliedRules, BOLD, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, type Finding, type FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, type GateCategory, type GateContext, type GateDefinition, type GateInput, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PLUGIN_API_VERSION, type PageLoadOptions, type PageLoadWaitUntil, RED, RESET, RULE_SETTINGS, type RuleDefinition, type RuleSetting, type RuleSettingEntry, type RuleSettings, type RuleView, STATE_DIR, UsageError, type VlmkitPlugin, YELLOW, debugEnabled, defineGate, definePlugin, firstPositional, firstPositionalOrUndefined, gateCommandString, hasFlag, hr, isCliEntry, navigationOptions, numberList, numberListFloat, optionalInt, parsePageLoad, pickPageLoad, readAll, readChoice, readEnv, readFlag, readInt, readNumber, readPositionals, resolveStatePath, ruleRef, runOutputDir, tokenizeCommand, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
78
|
+
export declare const PLUGIN_API_VERSION: 1;
|
|
79
|
+
export { type AnyGateDefinition, type AppliedRules, BOLD, COLOR_SCHEMES, COLOR_SCHEME_INPUT, COLOR_SCHEME_VALUE_FLAGS, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, type ColorScheme, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, type Finding, type FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, type GateCategory, type GateContext, type GateDefinition, type GateInput, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, type PageLoadOptions, type PageLoadWaitUntil, RED, RESET, RULE_SETTINGS, type RuleDefinition, type RuleSetting, type RuleSettingEntry, type RuleSettings, type RuleView, STATE_DIR, UsageError, type VlmkitPlugin, YELLOW, applyColorScheme, debugEnabled, defineGate, definePlugin, firstPositional, firstPositionalOrUndefined, gateCommandString, hasFlag, hr, instantList, isCliEntry, navigationOptions, numberList, numberListFloat, optionalInt, parseColorScheme, parsePageLoad, pickPageLoad, readAll, readChoice, readEnv, readFlag, readInt, readNumber, readPositionals, resolveStatePath, ruleRef, runOutputDir, tokenizeCommand, viewportFlag, vlmFlag, withoutOptionalValue };
|
package/dist/plugin/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, defineGate, definePlugin, gateCommandString, ruleRef } from "./contract.mjs";
|
|
2
|
+
import { RULE_SETTINGS } from "./rules.mjs";
|
|
3
|
+
import { COLOR_SCHEMES, COLOR_SCHEME_INPUT, COLOR_SCHEME_VALUE_FLAGS, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, applyColorScheme, navigationOptions, parseColorScheme, parsePageLoad, pickPageLoad } from "../page-load.mjs";
|
|
2
4
|
import { hasFlag, readAll, readChoice, readFlag, readInt, readNumber, readPositionals, tokenizeCommand } from "../arg-reader.mjs";
|
|
5
|
+
import { firstPositional, firstPositionalOrUndefined, instantList, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue } from "./args.mjs";
|
|
3
6
|
import { isCliEntry } from "./cli-entry.mjs";
|
|
7
|
+
import { UsageError } from "../cli-error.mjs";
|
|
4
8
|
import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, hr } from "../terminal-colors.mjs";
|
|
5
|
-
import { FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, defineGate, definePlugin, gateCommandString, ruleRef } from "./contract.mjs";
|
|
6
|
-
import { RULE_SETTINGS } from "./rules.mjs";
|
|
7
|
-
import { DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, navigationOptions, parsePageLoad, pickPageLoad } from "../page-load.mjs";
|
|
8
9
|
import { CONFIG_CANDIDATES, CONFIG_FILE, STATE_DIR, debugEnabled, readEnv, resolveStatePath } from "../project-config.mjs";
|
|
9
|
-
|
|
10
|
-
//#region src/plugin/index.ts
|
|
10
|
+
// src/plugin/index.ts
|
|
11
11
|
/**
|
|
12
12
|
* `@mizchi/vlmkit-core/plugin` — the whole surface a gate plugin needs.
|
|
13
13
|
*
|
|
@@ -77,5 +77,4 @@ import { firstPositional, firstPositionalOrUndefined, numberList, numberListFloa
|
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
79
|
const PLUGIN_API_VERSION = 1;
|
|
80
|
-
|
|
81
|
-
export { BOLD, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PLUGIN_API_VERSION, RED, RESET, RULE_SETTINGS, STATE_DIR, UsageError, YELLOW, debugEnabled, defineGate, definePlugin, firstPositional, firstPositionalOrUndefined, gateCommandString, hasFlag, hr, isCliEntry, navigationOptions, numberList, numberListFloat, optionalInt, parsePageLoad, pickPageLoad, readAll, readChoice, readEnv, readFlag, readInt, readNumber, readPositionals, resolveStatePath, ruleRef, runOutputDir, tokenizeCommand, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
80
|
+
export { BOLD, COLOR_SCHEMES, COLOR_SCHEME_INPUT, COLOR_SCHEME_VALUE_FLAGS, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PLUGIN_API_VERSION, RED, RESET, RULE_SETTINGS, STATE_DIR, UsageError, YELLOW, applyColorScheme, debugEnabled, defineGate, definePlugin, firstPositional, firstPositionalOrUndefined, gateCommandString, hasFlag, hr, instantList, isCliEntry, navigationOptions, numberList, numberListFloat, optionalInt, parseColorScheme, parsePageLoad, pickPageLoad, readAll, readChoice, readEnv, readFlag, readInt, readNumber, readPositionals, resolveStatePath, ruleRef, runOutputDir, tokenizeCommand, viewportFlag, vlmFlag, withoutOptionalValue };
|
package/dist/plugin/load.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { VlmkitPlugin } from "./contract.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/plugin/load.d.ts
|
|
4
|
-
interface LoadedPlugin {
|
|
2
|
+
export interface LoadedPlugin {
|
|
5
3
|
plugin: VlmkitPlugin;
|
|
6
4
|
/** Specifier as written in the config, for error messages. */
|
|
7
5
|
specifier: string;
|
|
@@ -9,28 +7,26 @@ interface LoadedPlugin {
|
|
|
9
7
|
resolved: string;
|
|
10
8
|
}
|
|
11
9
|
/** Injectable so tests do not need a module on disk. */
|
|
12
|
-
type PluginImporter = (specifier: string) => Promise<unknown>;
|
|
10
|
+
export type PluginImporter = (specifier: string) => Promise<unknown>;
|
|
13
11
|
/**
|
|
14
12
|
* Validate the imported shape before it reaches the registry. The registry's
|
|
15
13
|
* own validation covers ids and rule tables; this covers "is this even a
|
|
16
14
|
* plugin", where the useful error names the specifier and the missing member
|
|
17
15
|
* rather than surfacing as `gates is not iterable` three frames deeper.
|
|
18
16
|
*/
|
|
19
|
-
declare function asPlugin(moduleNamespace: unknown, specifier: string): VlmkitPlugin;
|
|
20
|
-
interface LoadPluginsOptions {
|
|
17
|
+
export declare function asPlugin(moduleNamespace: unknown, specifier: string): VlmkitPlugin;
|
|
18
|
+
export interface LoadPluginsOptions {
|
|
21
19
|
/** Directory relative specifiers resolve against. Defaults to cwd. */
|
|
22
20
|
baseDir?: string;
|
|
23
21
|
importer?: PluginImporter;
|
|
24
22
|
}
|
|
25
|
-
declare function loadPlugins(specifiers: readonly string[], options?: LoadPluginsOptions): Promise<LoadedPlugin[]>;
|
|
23
|
+
export declare function loadPlugins(specifiers: readonly string[], options?: LoadPluginsOptions): Promise<LoadedPlugin[]>;
|
|
26
24
|
/**
|
|
27
25
|
* Read the `plugins` array out of `vlmkit.config.json`. Absent config or
|
|
28
26
|
* absent key means no plugins — a project that declares none must not pay a
|
|
29
27
|
* config-file requirement.
|
|
30
28
|
*/
|
|
31
|
-
declare function readPluginSpecifiers(cwd?: string): {
|
|
29
|
+
export declare function readPluginSpecifiers(cwd?: string): {
|
|
32
30
|
specifiers: string[];
|
|
33
31
|
configPath: string | null;
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { LoadPluginsOptions, LoadedPlugin, PluginImporter, asPlugin, loadPlugins, readPluginSpecifiers };
|
|
32
|
+
};
|
package/dist/plugin/load.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { CONFIG_FILE } from "../project-config.mjs";
|
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { isAbsolute, resolve } from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
-
|
|
5
|
+
// src/plugin/load.ts
|
|
6
6
|
/**
|
|
7
7
|
* Loading third-party gate plugins.
|
|
8
8
|
*
|
|
@@ -94,5 +94,4 @@ function readPluginSpecifiers(cwd = process.cwd()) {
|
|
|
94
94
|
configPath
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
//#endregion
|
|
98
97
|
export { asPlugin, loadPlugins, readPluginSpecifiers };
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { AnyGateDefinition, GateCategory, VlmkitPlugin } from "./contract.mjs";
|
|
2
2
|
import { RuleSettings } from "./rules.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/plugin/registry.d.ts
|
|
5
|
-
interface RegisteredGate {
|
|
3
|
+
export interface RegisteredGate {
|
|
6
4
|
gate: AnyGateDefinition;
|
|
7
5
|
/** Plugin that supplied it — named in conflict errors and `--plugins` listings. */
|
|
8
6
|
plugin: string;
|
|
9
7
|
}
|
|
10
|
-
interface GateResolution {
|
|
8
|
+
export interface GateResolution {
|
|
11
9
|
gate: AnyGateDefinition;
|
|
12
10
|
/** Argv remaining after the matched command tokens. */
|
|
13
11
|
rest: string[];
|
|
14
12
|
}
|
|
15
|
-
interface GateRegistry {
|
|
13
|
+
export interface GateRegistry {
|
|
16
14
|
readonly plugins: readonly VlmkitPlugin[];
|
|
17
15
|
/** Every gate, in registration order. */
|
|
18
16
|
list(): readonly RegisteredGate[];
|
|
@@ -37,10 +35,10 @@ interface GateRegistry {
|
|
|
37
35
|
/** Near-miss command strings for a "did you mean" line. */
|
|
38
36
|
suggest(command: string | readonly string[], limit?: number): string[];
|
|
39
37
|
}
|
|
40
|
-
declare function createGateRegistry(plugins: readonly VlmkitPlugin[]): GateRegistry;
|
|
38
|
+
export declare function createGateRegistry(plugins: readonly VlmkitPlugin[]): GateRegistry;
|
|
41
39
|
/** Levenshtein, iterative single-row — only ever run on a failed lookup. */
|
|
42
|
-
declare function editDistance(a: string, b: string): number;
|
|
43
|
-
interface GateCommandProblem {
|
|
40
|
+
export declare function editDistance(a: string, b: string): number;
|
|
41
|
+
export interface GateCommandProblem {
|
|
44
42
|
command: string;
|
|
45
43
|
message: string;
|
|
46
44
|
}
|
|
@@ -49,12 +47,10 @@ interface GateCommandProblem {
|
|
|
49
47
|
* entry rather than throwing on the first, so a reviewer fixes the whole
|
|
50
48
|
* config in one pass.
|
|
51
49
|
*/
|
|
52
|
-
declare function validateGateCommands(registry: GateRegistry, commands: readonly string[]): GateCommandProblem[];
|
|
50
|
+
export declare function validateGateCommands(registry: GateRegistry, commands: readonly string[]): GateCommandProblem[];
|
|
53
51
|
/**
|
|
54
52
|
* Validate rule references. A bare `<ruleId>` key is only resolvable inside
|
|
55
53
|
* a gate-scoped block, so this checks the qualified forms and reports a bare
|
|
56
54
|
* key as needing a scope rather than guessing which gate it meant.
|
|
57
55
|
*/
|
|
58
|
-
declare function validateRuleSettings(registry: GateRegistry, settings: RuleSettings, scope?: AnyGateDefinition): string[];
|
|
59
|
-
//#endregion
|
|
60
|
-
export { GateCommandProblem, GateRegistry, GateResolution, RegisteredGate, createGateRegistry, editDistance, validateGateCommands, validateRuleSettings };
|
|
56
|
+
export declare function validateRuleSettings(registry: GateRegistry, settings: RuleSettings, scope?: AnyGateDefinition): string[];
|
package/dist/plugin/registry.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GATE_CATEGORY_ORDER, gateCommandString } from "./contract.mjs";
|
|
2
2
|
import { validateGateDefinition } from "./rules.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugin/registry.ts
|
|
4
4
|
var Registry = class {
|
|
5
5
|
plugins;
|
|
6
6
|
gates = [];
|
|
@@ -156,5 +156,4 @@ function validateRuleSettings(registry, settings, scope) {
|
|
|
156
156
|
}
|
|
157
157
|
return problems;
|
|
158
158
|
}
|
|
159
|
-
//#endregion
|
|
160
159
|
export { createGateRegistry, editDistance, validateGateCommands, validateRuleSettings };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { FindingSeverity, RuleView } from "./contract.mjs";
|
|
2
2
|
import { TieredRow } from "./rule-tier.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/plugin/rule-prose.d.ts
|
|
5
3
|
/** The shape all seven reports' rows already have. */
|
|
6
|
-
interface IssueLike {
|
|
4
|
+
export interface IssueLike {
|
|
7
5
|
kind: string;
|
|
8
6
|
severity: FindingSeverity;
|
|
9
7
|
}
|
|
10
|
-
interface TieredIssues<T> {
|
|
8
|
+
export interface TieredIssues<T> {
|
|
11
9
|
/** Rows whose rule is still on, each carrying the severity to print it at. */
|
|
12
10
|
shown: TieredRow<T>[];
|
|
13
11
|
/**
|
|
@@ -28,7 +26,7 @@ interface TieredIssues<T> {
|
|
|
28
26
|
* per gate and are not worth unifying — but they must read `tier` from the returned rows rather
|
|
29
27
|
* than `severity` from their own, which is the point of routing through here.
|
|
30
28
|
*/
|
|
31
|
-
declare function tierIssues<T extends IssueLike>(issues: readonly T[], rules?: RuleView): TieredIssues<T>;
|
|
29
|
+
export declare function tierIssues<T extends IssueLike>(issues: readonly T[], rules?: RuleView): TieredIssues<T>;
|
|
32
30
|
/**
|
|
33
31
|
* ` [kind re-tuned to warn]`, or `""` when the row prints at the severity it was emitted at.
|
|
34
32
|
*
|
|
@@ -36,6 +34,4 @@ declare function tierIssues<T extends IssueLike>(issues: readonly T[], rules?: R
|
|
|
36
34
|
* the reader has no way to tell a measurement from a policy. The suffix names the rule id
|
|
37
35
|
* because that is the string they would edit to change it back.
|
|
38
36
|
*/
|
|
39
|
-
declare function retuneNote<T extends IssueLike>(entry: TieredRow<T>): string;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { IssueLike, TieredIssues, retuneNote, tierIssues };
|
|
37
|
+
export declare function retuneNote<T extends IssueLike>(entry: TieredRow<T>): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { applyRuleTiers, hiddenByRuleNote } from "./rule-tier.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugin/rule-prose.ts
|
|
3
3
|
/**
|
|
4
4
|
* Tier a report's `issues[]` and derive the status word.
|
|
5
5
|
*
|
|
@@ -30,5 +30,4 @@ function tierIssues(issues, rules) {
|
|
|
30
30
|
function retuneNote(entry) {
|
|
31
31
|
return entry.tier === entry.row.severity ? "" : ` [${entry.row.kind} re-tuned to ${entry.tier}]`;
|
|
32
32
|
}
|
|
33
|
-
//#endregion
|
|
34
33
|
export { retuneNote, tierIssues };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { FindingSeverity, RuleView } from "./contract.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/plugin/rule-tier.d.ts
|
|
4
2
|
/** A rule's effective setting: a severity, or `off` when the project turned it off. */
|
|
5
|
-
type RuleTier = "off" | FindingSeverity;
|
|
3
|
+
export type RuleTier = "off" | FindingSeverity;
|
|
6
4
|
/**
|
|
7
5
|
* What to print a row as: the explicit project setting, or the severity the finding was
|
|
8
6
|
* emitted at.
|
|
@@ -19,7 +17,7 @@ type RuleTier = "off" | FindingSeverity;
|
|
|
19
17
|
* `rules` is optional in `format`, and undefined means nobody applied settings — a direct
|
|
20
18
|
* library call or a test. The emitted severity is the honest answer there too.
|
|
21
19
|
*/
|
|
22
|
-
declare function ruleTier(rules: RuleView | undefined, ruleId: string, emitted: FindingSeverity): RuleTier;
|
|
20
|
+
export declare function ruleTier(rules: RuleView | undefined, ruleId: string, emitted: FindingSeverity): RuleTier;
|
|
23
21
|
/**
|
|
24
22
|
* A `RuleView` from a plain map of explicit settings — for tests, and for anything else that
|
|
25
23
|
* needs to render prose under a hypothetical configuration.
|
|
@@ -29,12 +27,12 @@ declare function ruleTier(rules: RuleView | undefined, ruleId: string, emitted:
|
|
|
29
27
|
* severity for EVERY rule and can never see "nobody set this one", so a test built on it
|
|
30
28
|
* cannot reproduce the case the real runner hits most often — no settings at all.
|
|
31
29
|
*/
|
|
32
|
-
declare function ruleViewFrom(settings: Readonly<Record<string, RuleTier>>, fallback?: FindingSeverity): RuleView;
|
|
33
|
-
interface TieredRow<T> {
|
|
30
|
+
export declare function ruleViewFrom(settings: Readonly<Record<string, RuleTier>>, fallback?: FindingSeverity): RuleView;
|
|
31
|
+
export interface TieredRow<T> {
|
|
34
32
|
row: T;
|
|
35
33
|
tier: FindingSeverity;
|
|
36
34
|
}
|
|
37
|
-
interface TieredRows<T> {
|
|
35
|
+
export interface TieredRows<T> {
|
|
38
36
|
/** Rows whose rule is still on, each carrying its effective severity. */
|
|
39
37
|
shown: TieredRow<T>[];
|
|
40
38
|
/** Rows dropped because their rule is `off`, keyed by rule id for the disclosure line. */
|
|
@@ -49,7 +47,7 @@ interface TieredRows<T> {
|
|
|
49
47
|
* uses this to keep its own body and counts consistent with that line instead of contradicting
|
|
50
48
|
* it.
|
|
51
49
|
*/
|
|
52
|
-
declare function applyRuleTiers<T>(rows: readonly T[], ruleOf: (row: T) => {
|
|
50
|
+
export declare function applyRuleTiers<T>(rows: readonly T[], ruleOf: (row: T) => {
|
|
53
51
|
rule: string;
|
|
54
52
|
emitted: FindingSeverity;
|
|
55
53
|
}, rules?: RuleView): TieredRows<T>;
|
|
@@ -60,6 +58,4 @@ declare function applyRuleTiers<T>(rows: readonly T[], ruleOf: (row: T) => {
|
|
|
60
58
|
* palettes, and they wrap this in their own `DIM`. Deliberately not silent when the count is
|
|
61
59
|
* zero either — it returns `undefined` so a formatter cannot print an empty bullet.
|
|
62
60
|
*/
|
|
63
|
-
declare function hiddenByRuleNote(hiddenByRule: Map<string, number>): string | undefined;
|
|
64
|
-
//#endregion
|
|
65
|
-
export { RuleTier, TieredRow, TieredRows, applyRuleTiers, hiddenByRuleNote, ruleTier, ruleViewFrom };
|
|
61
|
+
export declare function hiddenByRuleNote(hiddenByRule: Map<string, number>): string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugin/rule-tier.ts
|
|
2
2
|
/**
|
|
3
3
|
* What to print a row as: the explicit project setting, or the severity the finding was
|
|
4
4
|
* emitted at.
|
|
@@ -73,5 +73,4 @@ function hiddenByRuleNote(hiddenByRule) {
|
|
|
73
73
|
if (hiddenByRule.size === 0) return void 0;
|
|
74
74
|
return `${[...hiddenByRule.values()].reduce((a, b) => a + b, 0)} finding(s) not shown — rule turned off (${[...hiddenByRule].map(([rule, n]) => `${rule} x${n}`).join(", ")})`;
|
|
75
75
|
}
|
|
76
|
-
//#endregion
|
|
77
76
|
export { applyRuleTiers, hiddenByRuleNote, ruleTier, ruleViewFrom };
|
package/dist/plugin/rules.d.mts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { AnyGateDefinition, Finding, FindingSeverity } from "./contract.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/plugin/rules.d.ts
|
|
4
2
|
/** `"off"` drops the finding; a severity re-tunes it (usually `suspect` → `warn`). */
|
|
5
|
-
type RuleSetting = "off" | FindingSeverity;
|
|
6
|
-
declare const RULE_SETTINGS: readonly RuleSetting[];
|
|
3
|
+
export type RuleSetting = "off" | FindingSeverity;
|
|
4
|
+
export declare const RULE_SETTINGS: readonly RuleSetting[];
|
|
7
5
|
/**
|
|
8
6
|
* Keys are `<gateId>/<ruleId>`, `<gateId>` (every rule of that gate), or a
|
|
9
7
|
* bare `<ruleId>` when the settings block is already scoped to one gate.
|
|
10
8
|
*/
|
|
11
|
-
type RuleSettings = Readonly<Record<string, RuleSetting>>;
|
|
9
|
+
export type RuleSettings = Readonly<Record<string, RuleSetting>>;
|
|
12
10
|
/**
|
|
13
11
|
* The long form of a rule setting: the setting plus why it is there.
|
|
14
12
|
*
|
|
@@ -29,7 +27,7 @@ type RuleSettings = Readonly<Record<string, RuleSetting>>;
|
|
|
29
27
|
* cannot carry a reason, so requiring one everywhere would make the config
|
|
30
28
|
* unable to express what the CLI does.
|
|
31
29
|
*/
|
|
32
|
-
interface RuleSettingEntry {
|
|
30
|
+
export interface RuleSettingEntry {
|
|
33
31
|
setting: RuleSetting;
|
|
34
32
|
/** Why the tool is wrong here. Required in this form — that is the point of it. */
|
|
35
33
|
reason: string;
|
|
@@ -38,14 +36,14 @@ interface RuleSettingEntry {
|
|
|
38
36
|
/** `YYYY-MM-DD`. Past it, the setting is dropped and the rule bites again. */
|
|
39
37
|
expires?: string;
|
|
40
38
|
}
|
|
41
|
-
type RuleSettingValue = RuleSetting | RuleSettingEntry;
|
|
39
|
+
export type RuleSettingValue = RuleSetting | RuleSettingEntry;
|
|
42
40
|
/** Rule settings with their annotations kept, for the inventory and expiry. */
|
|
43
|
-
interface AnnotatedRuleSettings {
|
|
41
|
+
export interface AnnotatedRuleSettings {
|
|
44
42
|
settings: RuleSettings;
|
|
45
43
|
/** Keyed by rule reference; only the entries written in the long form. */
|
|
46
44
|
annotations: Readonly<Record<string, RuleSettingEntry>>;
|
|
47
45
|
}
|
|
48
|
-
interface RuleDecision {
|
|
46
|
+
export interface RuleDecision {
|
|
49
47
|
ruleId: string;
|
|
50
48
|
/** Effective severity, or `"off"`. */
|
|
51
49
|
effective: RuleSetting;
|
|
@@ -54,24 +52,24 @@ interface RuleDecision {
|
|
|
54
52
|
/** The settings key that decided this, when a setting applied. */
|
|
55
53
|
via?: string;
|
|
56
54
|
}
|
|
57
|
-
interface ResolvedRules {
|
|
55
|
+
export interface ResolvedRules {
|
|
58
56
|
gateId: string;
|
|
59
57
|
decisions: ReadonlyMap<string, RuleDecision>;
|
|
60
58
|
/** Settings keys that matched no rule of this gate — typos, or stale entries. */
|
|
61
59
|
unmatched: readonly string[];
|
|
62
60
|
}
|
|
63
|
-
interface SuppressedFinding {
|
|
61
|
+
export interface SuppressedFinding {
|
|
64
62
|
finding: Finding;
|
|
65
63
|
/** Settings key that silenced it. */
|
|
66
64
|
via: string;
|
|
67
65
|
}
|
|
68
|
-
interface RetunedFinding {
|
|
66
|
+
export interface RetunedFinding {
|
|
69
67
|
finding: Finding;
|
|
70
68
|
from: FindingSeverity;
|
|
71
69
|
to: FindingSeverity;
|
|
72
70
|
via: string;
|
|
73
71
|
}
|
|
74
|
-
interface AppliedRules {
|
|
72
|
+
export interface AppliedRules {
|
|
75
73
|
/** Findings that survived, with severities re-tuned in place. */
|
|
76
74
|
findings: readonly Finding[];
|
|
77
75
|
suppressed: readonly SuppressedFinding[];
|
|
@@ -89,24 +87,22 @@ interface AppliedRules {
|
|
|
89
87
|
* Errors name the JSON path, matching `parseGateConfig`'s convention so a bad
|
|
90
88
|
* rules block reads like any other config defect.
|
|
91
89
|
*/
|
|
92
|
-
declare function parseAnnotatedRuleSettings(raw: unknown, path: string): AnnotatedRuleSettings;
|
|
90
|
+
export declare function parseAnnotatedRuleSettings(raw: unknown, path: string): AnnotatedRuleSettings;
|
|
93
91
|
/** The settings alone, for the many callers that never needed the annotations. */
|
|
94
|
-
declare function parseRuleSettings(raw: unknown, path: string): RuleSettings;
|
|
95
|
-
declare function resolveRules(gate: AnyGateDefinition, settings?: RuleSettings): ResolvedRules;
|
|
92
|
+
export declare function parseRuleSettings(raw: unknown, path: string): RuleSettings;
|
|
93
|
+
export declare function resolveRules(gate: AnyGateDefinition, settings?: RuleSettings): ResolvedRules;
|
|
96
94
|
/** Apply resolved settings to a gate's findings. */
|
|
97
|
-
declare function applyRuleSettings(gate: AnyGateDefinition, findings: readonly Finding[], settings?: RuleSettings): AppliedRules;
|
|
98
|
-
interface FindingCounts {
|
|
95
|
+
export declare function applyRuleSettings(gate: AnyGateDefinition, findings: readonly Finding[], settings?: RuleSettings): AppliedRules;
|
|
96
|
+
export interface FindingCounts {
|
|
99
97
|
suspect: number;
|
|
100
98
|
warn: number;
|
|
101
99
|
info: number;
|
|
102
100
|
}
|
|
103
|
-
declare function countFindings(findings: readonly Finding[]): FindingCounts;
|
|
101
|
+
export declare function countFindings(findings: readonly Finding[]): FindingCounts;
|
|
104
102
|
/**
|
|
105
103
|
* Validate a definition before it is registered. Cheap invariants, but each
|
|
106
104
|
* one is a defect that used to be discoverable only by running the gate:
|
|
107
105
|
* duplicate rule ids make a setting ambiguous, a non-slug id breaks config
|
|
108
106
|
* keys, and an empty command cannot be dispatched.
|
|
109
107
|
*/
|
|
110
|
-
declare function validateGateDefinition(gate: AnyGateDefinition): string[];
|
|
111
|
-
//#endregion
|
|
112
|
-
export { AnnotatedRuleSettings, AppliedRules, FindingCounts, RULE_SETTINGS, ResolvedRules, RetunedFinding, RuleDecision, RuleSetting, RuleSettingEntry, RuleSettingValue, RuleSettings, SuppressedFinding, applyRuleSettings, countFindings, parseAnnotatedRuleSettings, parseRuleSettings, resolveRules, validateGateDefinition };
|
|
108
|
+
export declare function validateGateDefinition(gate: AnyGateDefinition): string[];
|
package/dist/plugin/rules.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UsageError } from "../cli-error.mjs";
|
|
2
2
|
import { FINDING_SEVERITIES, ruleRef } from "./contract.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugin/rules.ts
|
|
4
4
|
/**
|
|
5
5
|
* Rule settings — the eslint-shaped layer that lets a project re-tune or
|
|
6
6
|
* switch off one rule instead of one whole gate.
|
|
@@ -184,5 +184,4 @@ function validateGateDefinition(gate) {
|
|
|
184
184
|
}
|
|
185
185
|
return problems;
|
|
186
186
|
}
|
|
187
|
-
//#endregion
|
|
188
187
|
export { RULE_SETTINGS, applyRuleSettings, countFindings, parseAnnotatedRuleSettings, parseRuleSettings, resolveRules, validateGateDefinition };
|