vigiles 40.1.0 → 41.0.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/adapter.d.ts +1 -1
- package/dist/adapters/claude-code/skill-listing.d.ts +27 -5
- package/dist/adapters/claude-code/skill-listing.js +29 -1
- package/dist/adapters/codex/skill-listing.d.ts +22 -4
- package/dist/adapters/codex/skill-listing.js +30 -1
- package/dist/cli-main.d.ts +4 -3
- package/dist/cli-main.js +121 -25
- package/dist/context-creep-lint.d.ts +123 -0
- package/dist/context-creep-lint.js +397 -0
- package/dist/core/always-loaded-limits.d.ts +118 -0
- package/dist/core/always-loaded-limits.js +175 -0
- package/dist/core/always-loaded.d.ts +15 -1
- package/dist/core/always-loaded.js +9 -0
- package/dist/core/baseline-store.d.ts +183 -0
- package/dist/core/baseline-store.js +392 -0
- package/dist/core/instruction-weight.d.ts +3 -3
- package/dist/core/instruction-weight.js +3 -3
- package/dist/core/legacy-baseline.d.ts +70 -0
- package/dist/core/legacy-baseline.js +117 -0
- package/dist/core/skill-listing.d.ts +24 -0
- package/dist/core/types.d.ts +14 -6
- package/dist/local-files.js +2 -2
- package/dist/rules/index.d.ts +25 -2
- package/dist/rules/index.js +22 -9
- package/dist/scan.js +27 -1
- package/dist/vigilesrc.schema.json +32 -0
- package/hooks/session-start.sh +4 -3
- package/package.json +1 -1
- package/dist/context-creep-ratchet.d.ts +0 -88
- package/dist/context-creep-ratchet.js +0 -270
- package/dist/core/instruction-baseline.d.ts +0 -333
- package/dist/core/instruction-baseline.js +0 -570
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONSEQUENCE = exports.ALWAYS_LOADED_MEASURE = void 0;
|
|
4
|
+
exports.checkAlwaysLoadedLimits = checkAlwaysLoadedLimits;
|
|
5
|
+
exports.alwaysLoadedMeasurement = alwaysLoadedMeasurement;
|
|
6
|
+
exports.describeSource = describeSource;
|
|
7
|
+
exports.describeOver = describeOver;
|
|
8
|
+
exports.formatOverLimit = formatOverLimit;
|
|
9
|
+
exports.checkCeiling = checkCeiling;
|
|
10
|
+
exports.formatCeiling = formatCeiling;
|
|
11
|
+
exports.formatRefusal = formatRefusal;
|
|
12
|
+
const always_loaded_js_1 = require("./always-loaded.js");
|
|
13
|
+
/** The instructions' part: the committed instructions plus the selected style. */
|
|
14
|
+
function instructionsLimit(weight, loaded, overrides) {
|
|
15
|
+
const override = overrides.instructions;
|
|
16
|
+
return {
|
|
17
|
+
part: "instructions",
|
|
18
|
+
size: loaded.instructions + (0, always_loaded_js_1.partTotal)(loaded.outputStyle),
|
|
19
|
+
limit: override ?? weight.limit,
|
|
20
|
+
source: override === undefined ? { kind: "harness" } : { kind: "config" },
|
|
21
|
+
onExceed: weight.onExceed,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The listing's part, or nothing when the listing or its budget is not modelled. */
|
|
25
|
+
function listingLimit(loaded, overrides) {
|
|
26
|
+
const listing = loaded.skillListing;
|
|
27
|
+
if (listing.kind !== "counted" && listing.kind !== "none")
|
|
28
|
+
return [];
|
|
29
|
+
const override = overrides["skill-listing"];
|
|
30
|
+
const harness = loaded.skillListingLimit;
|
|
31
|
+
if (override === undefined && harness.kind === "not-modelled")
|
|
32
|
+
return [];
|
|
33
|
+
const source = (() => {
|
|
34
|
+
if (override !== undefined)
|
|
35
|
+
return { kind: "config" };
|
|
36
|
+
return harness.kind === "limit" && harness.setBy !== undefined
|
|
37
|
+
? { kind: "setting", name: harness.setBy }
|
|
38
|
+
: { kind: "harness" };
|
|
39
|
+
})();
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
part: "skill-listing",
|
|
43
|
+
size: (0, always_loaded_js_1.partTotal)(listing),
|
|
44
|
+
limit: override ?? (harness.kind === "limit" ? harness.limit : 0),
|
|
45
|
+
source,
|
|
46
|
+
onExceed: "drops-descriptions",
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
/** Check each limited part against its limit. */
|
|
51
|
+
function checkAlwaysLoadedLimits(weight, loaded, overrides = {}) {
|
|
52
|
+
const parts = [
|
|
53
|
+
instructionsLimit(weight, loaded, overrides),
|
|
54
|
+
...listingLimit(loaded, overrides),
|
|
55
|
+
];
|
|
56
|
+
return {
|
|
57
|
+
unit: weight.unit,
|
|
58
|
+
parts,
|
|
59
|
+
over: parts.filter((p) => p.size > p.limit),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Which measurement produced a recorded context-creep number — bumped whenever
|
|
64
|
+
* a release changes what counts in ANY part (chain membership, how a listing
|
|
65
|
+
* entry is rendered), so consumers see one "re-record" verdict instead of
|
|
66
|
+
* growth attributed to their own files.
|
|
67
|
+
*/
|
|
68
|
+
exports.ALWAYS_LOADED_MEASURE = 1;
|
|
69
|
+
/** A part as the store records it: its size and files, `null` when not measurable. */
|
|
70
|
+
function measuredPart(part) {
|
|
71
|
+
switch (part.kind) {
|
|
72
|
+
case "counted":
|
|
73
|
+
return {
|
|
74
|
+
value: part.total,
|
|
75
|
+
files: Object.fromEntries(part.files.map((f) => [f.path, f.size])),
|
|
76
|
+
};
|
|
77
|
+
case "none":
|
|
78
|
+
return { value: 0 };
|
|
79
|
+
case "not-supported":
|
|
80
|
+
case "not-modelled":
|
|
81
|
+
case "unresolved":
|
|
82
|
+
return { value: null };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The always-loaded context as the store records it: the scored instruction
|
|
87
|
+
* files (never a per-machine one), the selected style and the listing.
|
|
88
|
+
*/
|
|
89
|
+
function alwaysLoadedMeasurement(weight, loaded) {
|
|
90
|
+
const scored = weight.files.filter((f) => f.scope === "repo");
|
|
91
|
+
const parts = {
|
|
92
|
+
instructions: {
|
|
93
|
+
value: weight.committedTotal,
|
|
94
|
+
files: Object.fromEntries(scored.map((f) => [f.path, f.size])),
|
|
95
|
+
},
|
|
96
|
+
"output-style": measuredPart(loaded.outputStyle),
|
|
97
|
+
"skill-listing": measuredPart(loaded.skillListing),
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
unit: weight.unit,
|
|
101
|
+
measure: exports.ALWAYS_LOADED_MEASURE,
|
|
102
|
+
parts,
|
|
103
|
+
value: Object.values(parts).reduce((sum, p) => sum + (p.value ?? 0), 0),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const n = (x) => x.toLocaleString("en-US");
|
|
107
|
+
const PART_LABEL = {
|
|
108
|
+
instructions: "instructions (with the selected output style)",
|
|
109
|
+
"skill-listing": "skill listing",
|
|
110
|
+
};
|
|
111
|
+
/** What happens past a limit, as a behaviour. */
|
|
112
|
+
exports.CONSEQUENCE = {
|
|
113
|
+
warns: "the harness warns and still loads it, so every character is paid on every request",
|
|
114
|
+
truncates: "the harness silently truncates past it, so the rules after the cut never reach the model",
|
|
115
|
+
"drops-descriptions": "the harness drops skill descriptions past it, so some skills lose the text they trigger on",
|
|
116
|
+
};
|
|
117
|
+
/** Where the limit came from, in words. */
|
|
118
|
+
function describeSource(source) {
|
|
119
|
+
switch (source.kind) {
|
|
120
|
+
case "harness":
|
|
121
|
+
return "the harness's own";
|
|
122
|
+
case "setting":
|
|
123
|
+
return `set by \`${source.name}\` in the committed settings`;
|
|
124
|
+
case "config":
|
|
125
|
+
return "set in .vigilesrc.json";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** One over-limit part, as a line. */
|
|
129
|
+
function describeOver(p, unit) {
|
|
130
|
+
return (`${PART_LABEL[p.part]} ${n(p.size)} ${unit}, limit ${n(p.limit)} (${describeSource(p.source)}) — ` +
|
|
131
|
+
`${n(p.size - p.limit)} over; ${exports.CONSEQUENCE[p.onExceed]}`);
|
|
132
|
+
}
|
|
133
|
+
/** The finding text for a bundle with at least one part over its limit. */
|
|
134
|
+
function formatOverLimit(check, at) {
|
|
135
|
+
const where = at === "." ? "" : `${at}: `;
|
|
136
|
+
const lines = check.over.map((p) => describeOver(p, check.unit));
|
|
137
|
+
return `${where}always-loaded context is over the harness's limit: ${lines.join("; ")}`;
|
|
138
|
+
}
|
|
139
|
+
/** How many of the heaviest files a ceiling message names. */
|
|
140
|
+
const CEILING_NAMED_FILES = 5;
|
|
141
|
+
/** `undefined` when the weight is at or under `max`, or when no ceiling is set. */
|
|
142
|
+
function checkCeiling(weight, max) {
|
|
143
|
+
if (max === undefined || weight.committedTotal <= max)
|
|
144
|
+
return undefined;
|
|
145
|
+
return {
|
|
146
|
+
total: weight.committedTotal,
|
|
147
|
+
max,
|
|
148
|
+
unit: weight.unit,
|
|
149
|
+
largest: weight.files
|
|
150
|
+
.filter((f) => f.scope === "repo")
|
|
151
|
+
.map((f) => ({ path: f.path, size: f.size }))
|
|
152
|
+
.sort((a, b) => b.size - a.size || a.path.localeCompare(b.path))
|
|
153
|
+
.slice(0, CEILING_NAMED_FILES),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** The message for a total over the ceiling, prefixed by its bundle. */
|
|
157
|
+
function formatCeiling(verdict, at, remedy) {
|
|
158
|
+
const where = at === "." ? "" : `${at}: `;
|
|
159
|
+
const biggest = verdict.largest
|
|
160
|
+
.map((f) => `${f.path} ${n(f.size)}`)
|
|
161
|
+
.join(", ");
|
|
162
|
+
return (`${where}always-loaded instructions are ${n(verdict.total)} ${verdict.unit}, ` +
|
|
163
|
+
`max ${n(verdict.max)} — ${n(verdict.total - verdict.max)} over. ` +
|
|
164
|
+
`Largest: ${biggest}.\n${remedy}\n` +
|
|
165
|
+
`Moving text to another always-loaded file does not help, ` +
|
|
166
|
+
`and recording a baseline does not lift the ceiling.`);
|
|
167
|
+
}
|
|
168
|
+
/** Why `--update-baseline` wrote nothing: a ceiling the baseline would have sat above. */
|
|
169
|
+
function formatRefusal(verdict, at, { file, command, remedy }) {
|
|
170
|
+
const where = at === "." ? "" : `${at}: `;
|
|
171
|
+
return (`${where}refusing to record ${file}: ` +
|
|
172
|
+
`${n(verdict.total)} ${verdict.unit} is over the configured max ${n(verdict.max)} ` +
|
|
173
|
+
`(${n(verdict.total - verdict.max)} over). Get under it first, then run \`${command}\` again.\n${remedy}`);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=always-loaded-limits.js.map
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
import type { HarnessDialect } from "./dialect.js";
|
|
43
43
|
import { type HarnessUnit } from "./harness-unit.js";
|
|
44
44
|
import { type PluginLayout } from "./layout.js";
|
|
45
|
-
import type { ListedSkill } from "./skill-listing.js";
|
|
45
|
+
import type { ListedSkill, ListingLimit } from "./skill-listing.js";
|
|
46
46
|
/** The parts that join the instructions in the always-loaded context. */
|
|
47
47
|
export type LoadedPartName = "output-style" | "skill-listing";
|
|
48
48
|
/** One file's share of a part, in the harness's unit. */
|
|
@@ -78,6 +78,16 @@ export type LoadedPart = {
|
|
|
78
78
|
readonly kind: "unresolved";
|
|
79
79
|
readonly name: string;
|
|
80
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* The skill listing's budget for this commit: the harness's number with any
|
|
83
|
+
* committed setting applied, or `not-modelled` when the adapter does not say
|
|
84
|
+
* how the harness sizes its listing — not the same as "no limit".
|
|
85
|
+
*/
|
|
86
|
+
export type SkillListingLimit = ({
|
|
87
|
+
readonly kind: "limit";
|
|
88
|
+
} & ListingLimit) | {
|
|
89
|
+
readonly kind: "not-modelled";
|
|
90
|
+
};
|
|
81
91
|
export interface AlwaysLoadedContext {
|
|
82
92
|
readonly unit: HarnessUnit;
|
|
83
93
|
/** The instructions' committed total — the same number the weight scores. */
|
|
@@ -86,6 +96,8 @@ export interface AlwaysLoadedContext {
|
|
|
86
96
|
readonly skillListing: LoadedPart;
|
|
87
97
|
/** Instructions plus every `counted` part. */
|
|
88
98
|
readonly total: number;
|
|
99
|
+
/** The listing's budget on this commit, read from the committed settings. */
|
|
100
|
+
readonly skillListingLimit: SkillListingLimit;
|
|
89
101
|
}
|
|
90
102
|
type AlwaysLoadedLayout = Pick<PluginLayout, "outputStyles" | "userSurfaceRoot" | "surfaces" | "skillDiscovery" | "settings" | "settingsPath">;
|
|
91
103
|
/** The instructions' weight, as `weighInstructions` measured it. */
|
|
@@ -116,6 +128,8 @@ export declare function outputStylePart(input: LoadedPartInput, settings: Readon
|
|
|
116
128
|
export declare function sessionSkills(layout: AlwaysLoadedLayout, files: Readonly<Record<string, string>>): readonly ListedSkill[];
|
|
117
129
|
/** The skill listing's part: each listed skill's entry, sized. */
|
|
118
130
|
export declare function skillListingPart(input: LoadedPartInput, settings: Readonly<Record<string, unknown>>): LoadedPart;
|
|
131
|
+
/** The listing budget the committed settings give, or `not-modelled`. */
|
|
132
|
+
export declare function skillListingLimit(dialect: Pick<HarnessDialect, "skillListing">, settings: Readonly<Record<string, unknown>>): SkillListingLimit;
|
|
119
133
|
/** The size a part adds to the sum: its total when counted, else nothing. */
|
|
120
134
|
export declare const partTotal: (part: LoadedPart) => number;
|
|
121
135
|
/**
|
|
@@ -4,6 +4,7 @@ exports.partTotal = void 0;
|
|
|
4
4
|
exports.outputStylePart = outputStylePart;
|
|
5
5
|
exports.sessionSkills = sessionSkills;
|
|
6
6
|
exports.skillListingPart = skillListingPart;
|
|
7
|
+
exports.skillListingLimit = skillListingLimit;
|
|
7
8
|
exports.weighAlwaysLoaded = weighAlwaysLoaded;
|
|
8
9
|
const frontmatter_read_js_1 = require("./frontmatter-read.js");
|
|
9
10
|
const harness_unit_js_1 = require("./harness-unit.js");
|
|
@@ -104,6 +105,13 @@ function skillListingPart(input, settings) {
|
|
|
104
105
|
: [{ path: skill.path, size: (0, harness_unit_js_1.sizeIn)(line, input.unit) }];
|
|
105
106
|
}));
|
|
106
107
|
}
|
|
108
|
+
/** The listing budget the committed settings give, or `not-modelled`. */
|
|
109
|
+
function skillListingLimit(dialect, settings) {
|
|
110
|
+
const budget = dialect.skillListing?.budget;
|
|
111
|
+
return budget === undefined
|
|
112
|
+
? { kind: "not-modelled" }
|
|
113
|
+
: { kind: "limit", ...budget.limit(settings) };
|
|
114
|
+
}
|
|
107
115
|
/** The size a part adds to the sum: its total when counted, else nothing. */
|
|
108
116
|
const partTotal = (part) => part.kind === "counted" ? part.total : 0;
|
|
109
117
|
exports.partTotal = partTotal;
|
|
@@ -129,6 +137,7 @@ function weighAlwaysLoaded(input) {
|
|
|
129
137
|
outputStyle,
|
|
130
138
|
skillListing,
|
|
131
139
|
total: instructions + (0, exports.partTotal)(outputStyle) + (0, exports.partTotal)(skillListing),
|
|
140
|
+
skillListingLimit: skillListingLimit(input.dialect, settings),
|
|
132
141
|
};
|
|
133
142
|
}
|
|
134
143
|
//# sourceMappingURL=always-loaded.js.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BASELINE STORE: one committed file, `.vigiles/baseline.json`, holding the
|
|
3
|
+
* size each rule last ACCEPTED for each thing it measures. A rule stays
|
|
4
|
+
* stateless — it measures, compares against a fixed limit and reports what is
|
|
5
|
+
* over — and this module, applied AFTER the rule has produced its findings,
|
|
6
|
+
* decides which of those findings the repository already accepted. The shape
|
|
7
|
+
* of ESLint's bulk suppressions ("suppressions are applied after cache
|
|
8
|
+
* retrieval"), betterer's results file and the `--update-baseline` flag of
|
|
9
|
+
* several static analysers: the rule never reads the store, the store never
|
|
10
|
+
* knows how a rule measures.
|
|
11
|
+
*
|
|
12
|
+
* WHY ONE FILE FOR EVERY RULE. A second rule that ratchets (a file length, a
|
|
13
|
+
* per-file count) needs the same four things: a number per subject, a
|
|
14
|
+
* direction, a measurement version and a reviewed diff when the number moves.
|
|
15
|
+
* Keyed by rule id and then by subject, every such rule shares the reader, the
|
|
16
|
+
* writer, the schema and the messages, and a re-record of one rule never
|
|
17
|
+
* touches another's entries.
|
|
18
|
+
*
|
|
19
|
+
* WHAT AN ENTRY SAYS. `value` in `unit`, recorded by `measure` (bumped when a
|
|
20
|
+
* release changes what counts, so a vigiles change reads as "re-record", not
|
|
21
|
+
* as growth the author made), and `direction`: `shrink-only` is the one
|
|
22
|
+
* direction today — the number may hold or fall, never rise. `parts` is an
|
|
23
|
+
* optional breakdown that sums to `value`, so a message can say which part
|
|
24
|
+
* moved; each part may name its files for the same reason.
|
|
25
|
+
*
|
|
26
|
+
* THE VERDICT, per finding that carries a measurement:
|
|
27
|
+
*
|
|
28
|
+
* - no entry for the rule at all → a NOTE naming the command: a repository
|
|
29
|
+
* over a limit starts green and is told how to accept its current size;
|
|
30
|
+
* - entries for the rule, none for this subject → a finding: weight that
|
|
31
|
+
* appeared after the baseline was recorded is weight nobody signed off on;
|
|
32
|
+
* - another unit or measure → a finding asking to re-record;
|
|
33
|
+
* - at the stored value → held; below it → a finding asking to record the
|
|
34
|
+
* lower number, because a baseline above the tree is headroom that can be
|
|
35
|
+
* regrown unseen (the stale-entry rule of PHPStan, Psalm, ESLint's unpruned
|
|
36
|
+
* suppressions and `betterer ci`);
|
|
37
|
+
* above it → a finding, with what moved.
|
|
38
|
+
*
|
|
39
|
+
* And per stored entry whose subject produced no such finding: a NOTE that the
|
|
40
|
+
* entry can go (`--update-baseline` drops it), because the subject is now
|
|
41
|
+
* under its limit or is no longer measured.
|
|
42
|
+
*
|
|
43
|
+
* Pure: parsing, comparison, recording and formatting. Reading and writing the
|
|
44
|
+
* file is the caller's.
|
|
45
|
+
*/
|
|
46
|
+
import { z } from "zod";
|
|
47
|
+
/** Where the store lives, relative to the directory `.vigilesrc.json` is read from. */
|
|
48
|
+
export declare const BASELINE_FILE = ".vigiles/baseline.json";
|
|
49
|
+
/** The command that writes the store — named once, quoted by every message. */
|
|
50
|
+
export declare const UPDATE_BASELINE_COMMAND = "vigiles lint --update-baseline";
|
|
51
|
+
/** The on-disk shape this release reads and writes. */
|
|
52
|
+
export declare const BASELINE_STORE_VERSION = 1;
|
|
53
|
+
declare const entrySchema: z.ZodObject<{
|
|
54
|
+
direction: z.ZodLiteral<"shrink-only">;
|
|
55
|
+
unit: z.ZodString;
|
|
56
|
+
measure: z.ZodNumber;
|
|
57
|
+
value: z.ZodNumber;
|
|
58
|
+
parts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
59
|
+
value: z.ZodNumber;
|
|
60
|
+
files: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
61
|
+
}, z.core.$strict>>>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
declare const storeSchema: z.ZodObject<{
|
|
64
|
+
version: z.ZodLiteral<1>;
|
|
65
|
+
rules: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
66
|
+
direction: z.ZodLiteral<"shrink-only">;
|
|
67
|
+
unit: z.ZodString;
|
|
68
|
+
measure: z.ZodNumber;
|
|
69
|
+
value: z.ZodNumber;
|
|
70
|
+
parts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
71
|
+
value: z.ZodNumber;
|
|
72
|
+
files: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
73
|
+
}, z.core.$strict>>>;
|
|
74
|
+
}, z.core.$strict>>>;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
/** One accepted size. */
|
|
77
|
+
export type BaselineEntry = Readonly<z.infer<typeof entrySchema>>;
|
|
78
|
+
/** The whole committed file. */
|
|
79
|
+
export type BaselineStore = z.infer<typeof storeSchema>;
|
|
80
|
+
/** The file, read once at the boundary: absent, parsed, or refused. */
|
|
81
|
+
export type StoreOnDisk = {
|
|
82
|
+
readonly kind: "absent";
|
|
83
|
+
} | {
|
|
84
|
+
readonly kind: "ok";
|
|
85
|
+
readonly store: Readonly<BaselineStore>;
|
|
86
|
+
} | {
|
|
87
|
+
readonly kind: "invalid";
|
|
88
|
+
readonly message: string;
|
|
89
|
+
};
|
|
90
|
+
/** JSON text as a value, or `invalid` — never throws. */
|
|
91
|
+
export declare function readJson(text: string): {
|
|
92
|
+
readonly ok: true;
|
|
93
|
+
readonly value: unknown;
|
|
94
|
+
} | {
|
|
95
|
+
readonly ok: false;
|
|
96
|
+
};
|
|
97
|
+
/** Parse the file's text; never throws. */
|
|
98
|
+
export declare function parseBaselineStore(text: string): StoreOnDisk;
|
|
99
|
+
/** Stable text: two-space indent, trailing newline, no timestamp. */
|
|
100
|
+
export declare function serializeBaselineStore(store: Readonly<BaselineStore>): string;
|
|
101
|
+
/**
|
|
102
|
+
* One part of a measurement. `value: null` = this run could not measure it
|
|
103
|
+
* (the adapter does not model it, or a selection names nothing readable): NOT
|
|
104
|
+
* zero, so the stored value is carried instead of being read as a cut.
|
|
105
|
+
*/
|
|
106
|
+
export interface MeasuredPart {
|
|
107
|
+
readonly value: number | null;
|
|
108
|
+
readonly files?: Readonly<Record<string, number>>;
|
|
109
|
+
}
|
|
110
|
+
/** What a rule measured for one subject, in the shape the store records. */
|
|
111
|
+
export interface Measurement {
|
|
112
|
+
readonly unit: string;
|
|
113
|
+
readonly measure: number;
|
|
114
|
+
/** Absent: the measurement is a single number, `value`. */
|
|
115
|
+
readonly parts?: Readonly<Record<string, MeasuredPart>>;
|
|
116
|
+
/** The whole number; with parts, the sum of the parts this run measured. */
|
|
117
|
+
readonly value: number;
|
|
118
|
+
}
|
|
119
|
+
/** One finding a rule produced. Only one that carries a measurement can be accepted. */
|
|
120
|
+
export interface RuleFinding {
|
|
121
|
+
readonly subject: string;
|
|
122
|
+
readonly text: string;
|
|
123
|
+
readonly measurement?: Measurement;
|
|
124
|
+
}
|
|
125
|
+
/** Everything one rule reports for the store to act on. */
|
|
126
|
+
export interface RuleRun {
|
|
127
|
+
readonly ruleId: string;
|
|
128
|
+
readonly findings: readonly RuleFinding[];
|
|
129
|
+
/** Every subject the rule measured this run, over its limit or not. */
|
|
130
|
+
readonly measured: readonly string[];
|
|
131
|
+
/**
|
|
132
|
+
* Subjects the run looked for and found nothing to measure — the file is
|
|
133
|
+
* gone. With {@link measured}, these are the only subjects a run may drop:
|
|
134
|
+
* an entry the run never looked at (another bundle, outside a scoped run)
|
|
135
|
+
* is kept byte-identical and is not mentioned.
|
|
136
|
+
*/
|
|
137
|
+
readonly gone?: readonly string[];
|
|
138
|
+
/**
|
|
139
|
+
* Per measured subject, the parts this run could not measure (unresolved,
|
|
140
|
+
* not supported, not modelled). A run proves a subject under its limits only
|
|
141
|
+
* if it measured EVERY part the subject's entry recorded: while a recorded
|
|
142
|
+
* part is unmeasurable, the entry is kept and that part's recorded value is
|
|
143
|
+
* carried forward — never dropped or shrunk because of it.
|
|
144
|
+
*/
|
|
145
|
+
readonly unmeasured?: Readonly<Record<string, readonly string[]>>;
|
|
146
|
+
/** What a reader does about growth — the rule's own cure, printed once per growth. */
|
|
147
|
+
readonly remedy?: string;
|
|
148
|
+
}
|
|
149
|
+
/** One line of lint output. `finding` counts toward the exit code; `note` never does. */
|
|
150
|
+
export interface StoreLine {
|
|
151
|
+
readonly subject: string;
|
|
152
|
+
readonly status: "finding" | "ok" | "note";
|
|
153
|
+
readonly text: string;
|
|
154
|
+
}
|
|
155
|
+
/** The rule's entries, or none. */
|
|
156
|
+
export declare const entriesOf: (store: StoreOnDisk, ruleId: string) => Readonly<Record<string, BaselineEntry>> | undefined;
|
|
157
|
+
export declare function toEntry(m: Measurement, stored: BaselineEntry | undefined): BaselineEntry;
|
|
158
|
+
/** The parts a subject's entry recorded that this run could not measure, sorted. */
|
|
159
|
+
export declare function unmeasuredRecorded(run: RuleRun, subject: string, entry: BaselineEntry | undefined): readonly string[];
|
|
160
|
+
/** Apply the store to one rule's run: the lines lint prints, in subject order. */
|
|
161
|
+
export declare function applyBaseline(run: RuleRun, store: StoreOnDisk): readonly StoreLine[];
|
|
162
|
+
/**
|
|
163
|
+
* The store with one rule's entries replaced by `entries` — every other rule's
|
|
164
|
+
* are kept. `undefined` when nothing is left to store, so the caller deletes
|
|
165
|
+
* the file rather than committing an empty one.
|
|
166
|
+
*/
|
|
167
|
+
export declare function withEntries(previous: StoreOnDisk, ruleId: string, entries: Readonly<Record<string, BaselineEntry>>): Readonly<BaselineStore> | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* The rule's entries after recording one run: every subject the run measured
|
|
170
|
+
* or found gone becomes exactly its finding's measurement (or nothing, when it
|
|
171
|
+
* is under its limit or gone), with any part this run could not measure
|
|
172
|
+
* carried over. Every subject the run did not look at keeps its entry as is,
|
|
173
|
+
* so a scoped run never deletes another bundle's baseline — and so does one
|
|
174
|
+
* whose entry recorded a part this run could not measure, since no finding
|
|
175
|
+
* there proves nothing about that part.
|
|
176
|
+
*/
|
|
177
|
+
export declare function entriesFor(previous: StoreOnDisk, run: RuleRun): Readonly<Record<string, BaselineEntry>>;
|
|
178
|
+
/** The store after recording one rule's run ({@link withEntries} of {@link entriesFor}). */
|
|
179
|
+
export declare const recordRun: (previous: StoreOnDisk, run: RuleRun) => Readonly<BaselineStore> | undefined;
|
|
180
|
+
/** Whether the store already holds entries for a rule — `init` never overwrites them. */
|
|
181
|
+
export declare const hasEntries: (store: StoreOnDisk, ruleId: string) => boolean;
|
|
182
|
+
export {};
|
|
183
|
+
//# sourceMappingURL=baseline-store.d.ts.map
|