vigiles 39.2.0 → 40.1.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/README.md +9 -8
- package/dist/adapter.d.ts +3 -2
- package/dist/adapters/claude-code/dialect.js +4 -0
- package/dist/adapters/claude-code/output-style.js +15 -0
- package/dist/adapters/claude-code/skill-listing.d.ts +48 -0
- package/dist/adapters/claude-code/skill-listing.js +54 -0
- package/dist/adapters/codex/dialect.js +4 -0
- package/dist/adapters/codex/layout.js +5 -0
- package/dist/adapters/codex/mock-model.d.ts +7 -0
- package/dist/adapters/codex/mock-model.js +1 -0
- package/dist/adapters/codex/skill-listing.d.ts +42 -0
- package/dist/adapters/codex/skill-listing.js +40 -0
- package/dist/audit-html.js +7 -2
- package/dist/audit-report.d.ts +51 -0
- package/dist/audit-report.js +54 -8
- package/dist/audit-report.template.html +33 -38
- package/dist/cli-main.d.ts +9 -3
- package/dist/cli-main.js +32 -17
- package/dist/{instruction-weight-ratchet.d.ts → context-creep-ratchet.d.ts} +34 -12
- package/dist/context-creep-ratchet.js +270 -0
- package/dist/core/always-loaded.d.ts +128 -0
- package/dist/core/always-loaded.js +134 -0
- package/dist/core/compile.js +1 -1
- package/dist/core/dialect.d.ts +9 -0
- package/dist/core/harness-unit.d.ts +20 -0
- package/dist/core/harness-unit.js +24 -0
- package/dist/core/instruction-baseline.d.ts +179 -11
- package/dist/core/instruction-baseline.js +349 -47
- package/dist/core/instruction-weight.d.ts +2 -11
- package/dist/core/instruction-weight.js +6 -16
- package/dist/core/layout.d.ts +40 -0
- package/dist/core/layout.js +25 -1
- package/dist/core/output-style.d.ts +20 -0
- package/dist/core/skill-listing.d.ts +49 -0
- package/dist/core/skill-listing.js +23 -0
- package/dist/core/types.d.ts +2 -2
- package/dist/deprecated-key-files.d.ts +1 -1
- package/dist/deprecated-key-files.js +1 -1
- package/dist/fs-walk.d.ts +31 -0
- package/dist/fs-walk.js +49 -0
- package/dist/local-files.js +2 -1
- package/dist/plugin-loader.js +40 -19
- package/dist/rules/index.d.ts +4 -4
- package/dist/rules/index.js +7 -7
- package/dist/scan-files.js +24 -3
- package/dist/scan.d.ts +30 -1
- package/dist/scan.js +69 -3
- package/dist/surface-discovery-fs.d.ts +15 -0
- package/dist/surface-discovery-fs.js +55 -0
- package/dist/vigilesrc.schema.json +2 -2
- package/hooks/session-start.sh +3 -1
- package/package.json +1 -1
- package/dist/instruction-weight-ratchet.js +0 -181
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.partTotal = void 0;
|
|
4
|
+
exports.outputStylePart = outputStylePart;
|
|
5
|
+
exports.sessionSkills = sessionSkills;
|
|
6
|
+
exports.skillListingPart = skillListingPart;
|
|
7
|
+
exports.weighAlwaysLoaded = weighAlwaysLoaded;
|
|
8
|
+
const frontmatter_read_js_1 = require("./frontmatter-read.js");
|
|
9
|
+
const harness_unit_js_1 = require("./harness-unit.js");
|
|
10
|
+
const layout_js_1 = require("./layout.js");
|
|
11
|
+
const output_style_js_1 = require("./output-style.js");
|
|
12
|
+
/** The committed settings object; `{}` when absent or not parseable. */
|
|
13
|
+
function committedSettings(layout, files) {
|
|
14
|
+
const text = files[layout.settingsPath];
|
|
15
|
+
if (text === undefined)
|
|
16
|
+
return {};
|
|
17
|
+
try {
|
|
18
|
+
return layout.settings.parse(text);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const counted = (files) => files.length === 0
|
|
25
|
+
? { kind: "none" }
|
|
26
|
+
: {
|
|
27
|
+
kind: "counted",
|
|
28
|
+
total: files.reduce((sum, f) => sum + f.size, 0),
|
|
29
|
+
files,
|
|
30
|
+
};
|
|
31
|
+
/** The style files in the folder a session at the repository root reads. */
|
|
32
|
+
function sessionStyles(layout, files) {
|
|
33
|
+
const rules = layout.outputStyles;
|
|
34
|
+
const home = (0, output_style_js_1.outputStyleHomes)(layout).at(-1);
|
|
35
|
+
if (rules === undefined || home === undefined)
|
|
36
|
+
return [];
|
|
37
|
+
// Direct children only — the folder the disk reader lists, one level.
|
|
38
|
+
const nameIn = (path) => {
|
|
39
|
+
const rest = path.startsWith(`${home}/`) ? path.slice(home.length + 1) : "";
|
|
40
|
+
return rest === "" || rest.includes("/") ? null : rest;
|
|
41
|
+
};
|
|
42
|
+
return Object.entries(files)
|
|
43
|
+
.filter(([path]) => {
|
|
44
|
+
const name = nameIn(path);
|
|
45
|
+
return name !== null && rules.isStyleFile(name);
|
|
46
|
+
})
|
|
47
|
+
.map(([path, text]) => rules.read(path, text));
|
|
48
|
+
}
|
|
49
|
+
/** The selected output style's part. */
|
|
50
|
+
function outputStylePart(input, settings) {
|
|
51
|
+
const rules = input.layout.outputStyles;
|
|
52
|
+
if (rules === undefined)
|
|
53
|
+
return { kind: "not-supported" };
|
|
54
|
+
if (rules.selected === undefined)
|
|
55
|
+
return { kind: "not-modelled" };
|
|
56
|
+
const selection = rules.selected(settings);
|
|
57
|
+
if (selection.kind !== "named")
|
|
58
|
+
return { kind: "none" };
|
|
59
|
+
const style = sessionStyles(input.layout, input.files).find((s) => s.name === selection.name);
|
|
60
|
+
return style === undefined
|
|
61
|
+
? { kind: "unresolved", name: selection.name }
|
|
62
|
+
: counted([{ path: style.path, size: (0, harness_unit_js_1.sizeIn)(style.body, input.unit) }]);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Every SKILL.md the session's skills folder holds at a depth the harness
|
|
66
|
+
* reads ({@link skillDiscoveryOf}), read once.
|
|
67
|
+
*/
|
|
68
|
+
function sessionSkills(layout, files) {
|
|
69
|
+
const home = (0, layout_js_1.skillsHome)(layout);
|
|
70
|
+
if (home === null)
|
|
71
|
+
return [];
|
|
72
|
+
const discovery = (0, layout_js_1.skillDiscoveryOf)(layout);
|
|
73
|
+
// A SKILL.md directly in the folder takes the folder's own name.
|
|
74
|
+
const homeName = home.split("/").at(-1) ?? home;
|
|
75
|
+
const found = Object.entries(files).flatMap(([path, text]) => {
|
|
76
|
+
if (!path.startsWith(`${home}/`))
|
|
77
|
+
return [];
|
|
78
|
+
const dirs = (0, layout_js_1.sessionSkillDirs)(path.slice(home.length + 1), discovery);
|
|
79
|
+
return dirs === null
|
|
80
|
+
? []
|
|
81
|
+
: [{ path, dirName: dirs.at(-1) ?? homeName, text }];
|
|
82
|
+
});
|
|
83
|
+
return [...found]
|
|
84
|
+
.sort((a, b) => a.path.localeCompare(b.path))
|
|
85
|
+
.map(({ path, dirName, text }) => {
|
|
86
|
+
const fm = (0, frontmatter_read_js_1.readFrontmatter)(text);
|
|
87
|
+
return {
|
|
88
|
+
path,
|
|
89
|
+
dirName,
|
|
90
|
+
frontmatter: fm.malformed ? null : (fm.data ?? {}),
|
|
91
|
+
body: (0, frontmatter_read_js_1.frontmatterBody)(text),
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** The skill listing's part: each listed skill's entry, sized. */
|
|
96
|
+
function skillListingPart(input, settings) {
|
|
97
|
+
const rules = input.dialect.skillListing;
|
|
98
|
+
if (rules === undefined)
|
|
99
|
+
return { kind: "not-modelled" };
|
|
100
|
+
return counted(sessionSkills(input.layout, input.files).flatMap((skill) => {
|
|
101
|
+
const line = rules.entry(skill, settings);
|
|
102
|
+
return line === null
|
|
103
|
+
? []
|
|
104
|
+
: [{ path: skill.path, size: (0, harness_unit_js_1.sizeIn)(line, input.unit) }];
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
/** The size a part adds to the sum: its total when counted, else nothing. */
|
|
108
|
+
const partTotal = (part) => part.kind === "counted" ? part.total : 0;
|
|
109
|
+
exports.partTotal = partTotal;
|
|
110
|
+
/**
|
|
111
|
+
* Weigh the always-loaded context: the instructions' committed total (already
|
|
112
|
+
* measured by the instruction weight) plus the selected output style and the
|
|
113
|
+
* skill listing, each in the same unit by the same `sizeIn`.
|
|
114
|
+
*/
|
|
115
|
+
function weighAlwaysLoaded(input) {
|
|
116
|
+
const part = {
|
|
117
|
+
files: input.files,
|
|
118
|
+
layout: input.layout,
|
|
119
|
+
dialect: input.dialect,
|
|
120
|
+
unit: input.weight.unit,
|
|
121
|
+
};
|
|
122
|
+
const settings = committedSettings(input.layout, input.files);
|
|
123
|
+
const outputStyle = outputStylePart(part, settings);
|
|
124
|
+
const skillListing = skillListingPart(part, settings);
|
|
125
|
+
const instructions = input.weight.committedTotal;
|
|
126
|
+
return {
|
|
127
|
+
unit: part.unit,
|
|
128
|
+
instructions,
|
|
129
|
+
outputStyle,
|
|
130
|
+
skillListing,
|
|
131
|
+
total: instructions + (0, exports.partTotal)(outputStyle) + (0, exports.partTotal)(skillListing),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=always-loaded.js.map
|
package/dist/core/compile.js
CHANGED
|
@@ -482,7 +482,7 @@ exports.DEFAULT_MAX_RULES_CHARS = 20000;
|
|
|
482
482
|
*
|
|
483
483
|
* 🔴 WHAT THIS RULE DOES NOT MEASURE, ON PURPOSE — each has one owner already:
|
|
484
484
|
* - the whole always-loaded size, in the harness's unit (Claude Code chars,
|
|
485
|
-
* Codex bytes) — `
|
|
485
|
+
* Codex bytes) — `context-creep` and its `max`, which sums the whole
|
|
486
486
|
* chain, so moving text into a rules file does not fool it;
|
|
487
487
|
* - `keyFiles` — deprecated (`deprecated-key-files`); budgeting a section the
|
|
488
488
|
* reader is told to delete would be a second, contradicting instruction.
|
package/dist/core/dialect.d.ts
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import type { HarnessVocabulary } from "./vocabulary.js";
|
|
22
22
|
import type { EventCapabilityTable } from "./event-capability.js";
|
|
23
23
|
import type { InstructionBudget } from "./instruction-weight.js";
|
|
24
|
+
import type { SkillListingRules } from "./skill-listing.js";
|
|
24
25
|
/**
|
|
25
26
|
* Every SKILL.md frontmatter key the COMPILER knows how to render, in the order
|
|
26
27
|
* it renders them. A property of `renderSkillFrontmatter`, not of any harness:
|
|
@@ -167,6 +168,14 @@ export interface HarnessDialect {
|
|
|
167
168
|
* answer for a harness whose limits nobody has read.
|
|
168
169
|
*/
|
|
169
170
|
readonly instructionBudget?: InstructionBudget;
|
|
171
|
+
/**
|
|
172
|
+
* How this harness renders a skill into the listing it loads at session
|
|
173
|
+
* start — {@link SkillListingRules}. Beside `instructionBudget` for the same
|
|
174
|
+
* two reasons: it is a FORMAT fact, and the browser engine is handed a
|
|
175
|
+
* dialect. Optional: absent ⇒ the always-loaded report says the listing is
|
|
176
|
+
* not modelled for this harness, never that it is empty.
|
|
177
|
+
*/
|
|
178
|
+
readonly skillListing?: SkillListingRules;
|
|
170
179
|
/**
|
|
171
180
|
* What each hook event CARRIES and HONOURS — {@link EventCapabilityTable}.
|
|
172
181
|
*
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text sized in a harness's OWN unit — characters for Claude Code, bytes for
|
|
3
|
+
* Codex, never tokens (`InstructionBudget.unit` says why). One function, so
|
|
4
|
+
* every part of an always-loaded sum is sized the same way and the sum is one
|
|
5
|
+
* number in one unit, reproducible from a commit.
|
|
6
|
+
*/
|
|
7
|
+
/** The units harnesses count always-loaded text in. */
|
|
8
|
+
export type HarnessUnit = "chars" | "bytes";
|
|
9
|
+
/**
|
|
10
|
+
* Size in the harness's own unit. Bytes and chars differ on any non-ASCII text.
|
|
11
|
+
*
|
|
12
|
+
* Line endings are counted as `\n`. A checkout with `core.autocrlf` holds the
|
|
13
|
+
* same commit with one more character per line, and a number that differs
|
|
14
|
+
* between two clones of one commit cannot be committed and compared — a
|
|
15
|
+
* 1 000-line file read +1 000 on Windows with no content change. The harness
|
|
16
|
+
* may count the CR itself; reproducibility is worth more here than that
|
|
17
|
+
* fidelity.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sizeIn(text: string, unit: HarnessUnit): number;
|
|
20
|
+
//# sourceMappingURL=harness-unit.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Text sized in a harness's OWN unit — characters for Claude Code, bytes for
|
|
4
|
+
* Codex, never tokens (`InstructionBudget.unit` says why). One function, so
|
|
5
|
+
* every part of an always-loaded sum is sized the same way and the sum is one
|
|
6
|
+
* number in one unit, reproducible from a commit.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.sizeIn = sizeIn;
|
|
10
|
+
/**
|
|
11
|
+
* Size in the harness's own unit. Bytes and chars differ on any non-ASCII text.
|
|
12
|
+
*
|
|
13
|
+
* Line endings are counted as `\n`. A checkout with `core.autocrlf` holds the
|
|
14
|
+
* same commit with one more character per line, and a number that differs
|
|
15
|
+
* between two clones of one commit cannot be committed and compared — a
|
|
16
|
+
* 1 000-line file read +1 000 on Windows with no content change. The harness
|
|
17
|
+
* may count the CR itself; reproducibility is worth more here than that
|
|
18
|
+
* fidelity.
|
|
19
|
+
*/
|
|
20
|
+
function sizeIn(text, unit) {
|
|
21
|
+
const lf = text.replaceAll("\r\n", "\n");
|
|
22
|
+
return unit === "chars" ? lf.length : Buffer.byteLength(lf, "utf8");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=harness-unit.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The context-creep RATCHET: the always-loaded weight may not grow past
|
|
3
3
|
* what the repository itself last recorded.
|
|
4
4
|
*
|
|
5
5
|
* WHY A RATCHET AND NOT THE BUDGET. `./instruction-weight.ts` explains why the
|
|
@@ -32,17 +32,76 @@
|
|
|
32
32
|
* baseline is allowed and is the point: growth is not forbidden, it is made
|
|
33
33
|
* visible as a reviewed diff of a committed file.
|
|
34
34
|
*
|
|
35
|
+
* VERSION 2 — THE ALWAYS-LOADED CONTEXT. The output style the committed settings select
|
|
36
|
+
* and the skill listing load at session start exactly as the instructions do
|
|
37
|
+
* (`./always-loaded.ts`), so a section moved from `CLAUDE.md` into either is
|
|
38
|
+
* the same relocation the sum above exists to see. A version-2 entry carries
|
|
39
|
+
* them as `parts`, each with its own `measure`, and the verdict is decided on
|
|
40
|
+
* the SUM of the instructions and every recorded part. Per part, so a change
|
|
41
|
+
* to how one part is measured asks to re-record that part by name.
|
|
42
|
+
*
|
|
43
|
+
* ⚠️ THE TRADE-OFF OF A STRICT FILE, stated rather than hidden. Version 1 was
|
|
44
|
+
* read with `.strict()` and `z.literal(1)`, so there is no extension of it an
|
|
45
|
+
* OLDER vigiles accepts: it reads a version-2 file as "cannot be read", which
|
|
46
|
+
* is a finding at the rule's severity — red CI wherever lint still runs the old
|
|
47
|
+
* release, the moment one teammate re-records. Loud, never silent, but red. The
|
|
48
|
+
* alternative, a sibling file old readers ignore, would split one gated sum
|
|
49
|
+
* across two files, so that a move from one to the other read as a shrink in
|
|
50
|
+
* each. What keeps the cost small:
|
|
51
|
+
*
|
|
52
|
+
* - a repo still on version 1 is read as before — the instructions gate as
|
|
53
|
+
* they did, and each new part that is not zero is a NOTE, never a finding,
|
|
54
|
+
* so upgrading vigiles never turns CI red;
|
|
55
|
+
* - `--update-baseline` writes version 2 only when some part is not zero, so
|
|
56
|
+
* a repo with no output style and no listed skill keeps a version-1 file
|
|
57
|
+
* every release reads — and, once a file is version 2, keeps it there even
|
|
58
|
+
* when every part drops to zero, so re-adding a part is growth, not a note;
|
|
59
|
+
* - the note and the rule doc say to upgrade vigiles wherever lint runs
|
|
60
|
+
* BEFORE re-recording.
|
|
61
|
+
*
|
|
35
62
|
* Pure: parsing, comparison and formatting only. Reading and writing the file
|
|
36
|
-
* is the caller's (`src/
|
|
63
|
+
* is the caller's (`src/context-creep-ratchet.ts`).
|
|
37
64
|
*/
|
|
38
65
|
import { z } from "zod";
|
|
39
66
|
import type { InstructionWeight } from "./instruction-weight.js";
|
|
67
|
+
import type { AlwaysLoadedContext, LoadedPart, LoadedPartName } from "./always-loaded.js";
|
|
40
68
|
/** Where the baseline lives, relative to the directory `.vigilesrc.json` is read from. */
|
|
41
|
-
export declare const INSTRUCTION_BASELINE_FILE = ".vigiles/
|
|
69
|
+
export declare const INSTRUCTION_BASELINE_FILE = ".vigiles/context-creep.json";
|
|
70
|
+
/**
|
|
71
|
+
* The name this baseline had before the rule became `context-creep`. Still
|
|
72
|
+
* READ when the new file is absent (a repo upgrading keeps its ratchet), never
|
|
73
|
+
* written; {@link legacyBaselineNote} tells the author how to move it.
|
|
74
|
+
*/
|
|
75
|
+
export declare const LEGACY_INSTRUCTION_BASELINE_FILE = ".vigiles/instruction-weight.json";
|
|
76
|
+
/** Which of the two baseline files exist: neither/only the new one, the old one alone, or both. */
|
|
77
|
+
export type LegacyBaseline = "none" | "only" | "both";
|
|
78
|
+
/** The command that renames the old baseline — quoted verbatim by the note. */
|
|
79
|
+
export declare const RENAME_BASELINE_COMMAND = "git mv .vigiles/instruction-weight.json .vigiles/context-creep.json";
|
|
80
|
+
/** The command that drops a stale old baseline once the new one exists. */
|
|
81
|
+
export declare const REMOVE_LEGACY_BASELINE_COMMAND = "git rm .vigiles/instruction-weight.json";
|
|
82
|
+
/**
|
|
83
|
+
* The one-sentence NOTE (never a finding) for a repo that still has the old
|
|
84
|
+
* file, or `undefined` when it has not. The exact command is in the text: the
|
|
85
|
+
* session-start hook injects `lint --summary` into the agent, and the agent
|
|
86
|
+
* runs the command.
|
|
87
|
+
*/
|
|
88
|
+
export declare function legacyBaselineNote(legacy: LegacyBaseline): string | undefined;
|
|
42
89
|
/** The command that writes the baseline — named once, quoted by every message. */
|
|
43
90
|
export declare const UPDATE_BASELINE_COMMAND = "vigiles lint --update-baseline";
|
|
44
|
-
/**
|
|
45
|
-
|
|
91
|
+
/**
|
|
92
|
+
* The newest on-disk shape this release reads and writes. Bumped only on an
|
|
93
|
+
* incompatible change. Version 1 is still read, and still WRITTEN when no
|
|
94
|
+
* always-loaded part has anything in it — see the header for why.
|
|
95
|
+
*/
|
|
96
|
+
export declare const INSTRUCTION_BASELINE_VERSION = 2;
|
|
97
|
+
/**
|
|
98
|
+
* Which measurement produced a recorded PART — the same job as
|
|
99
|
+
* {@link INSTRUCTION_WEIGHT_MEASURE}, per part, so a change to how the skill
|
|
100
|
+
* listing is rendered re-records the listing and names it.
|
|
101
|
+
*/
|
|
102
|
+
export declare const LOADED_PART_MEASURE = 1;
|
|
103
|
+
/** The parts a version-2 entry may carry, in the order they are printed. */
|
|
104
|
+
export declare const LOADED_PART_NAMES: readonly LoadedPartName[];
|
|
46
105
|
/**
|
|
47
106
|
* Which MEASUREMENT produced a recorded number — bumped whenever a release
|
|
48
107
|
* changes what counts (chain membership in any adapter, how a file is sized),
|
|
@@ -55,6 +114,11 @@ export declare const INSTRUCTION_BASELINE_VERSION = 1;
|
|
|
55
114
|
* describes the file, not the number in it.
|
|
56
115
|
*/
|
|
57
116
|
export declare const INSTRUCTION_WEIGHT_MEASURE = 1;
|
|
117
|
+
declare const partSchema: z.ZodObject<{
|
|
118
|
+
measure: z.ZodNumber;
|
|
119
|
+
total: z.ZodNumber;
|
|
120
|
+
files: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
121
|
+
}, z.core.$strict>;
|
|
58
122
|
declare const entrySchema: z.ZodObject<{
|
|
59
123
|
unit: z.ZodEnum<{
|
|
60
124
|
chars: "chars";
|
|
@@ -63,9 +127,21 @@ declare const entrySchema: z.ZodObject<{
|
|
|
63
127
|
measure: z.ZodNumber;
|
|
64
128
|
total: z.ZodNumber;
|
|
65
129
|
files: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
130
|
+
parts: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
"output-style": z.ZodOptional<z.ZodObject<{
|
|
132
|
+
measure: z.ZodNumber;
|
|
133
|
+
total: z.ZodNumber;
|
|
134
|
+
files: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
135
|
+
}, z.core.$strict>>;
|
|
136
|
+
"skill-listing": z.ZodOptional<z.ZodObject<{
|
|
137
|
+
measure: z.ZodNumber;
|
|
138
|
+
total: z.ZodNumber;
|
|
139
|
+
files: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
140
|
+
}, z.core.$strict>>;
|
|
141
|
+
}, z.core.$strict>>;
|
|
66
142
|
}, z.core.$strict>;
|
|
67
143
|
declare const baselineSchema: z.ZodObject<{
|
|
68
|
-
version: z.ZodLiteral<1>;
|
|
144
|
+
version: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
69
145
|
bundles: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
70
146
|
unit: z.ZodEnum<{
|
|
71
147
|
chars: "chars";
|
|
@@ -74,10 +150,24 @@ declare const baselineSchema: z.ZodObject<{
|
|
|
74
150
|
measure: z.ZodNumber;
|
|
75
151
|
total: z.ZodNumber;
|
|
76
152
|
files: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
153
|
+
parts: z.ZodOptional<z.ZodObject<{
|
|
154
|
+
"output-style": z.ZodOptional<z.ZodObject<{
|
|
155
|
+
measure: z.ZodNumber;
|
|
156
|
+
total: z.ZodNumber;
|
|
157
|
+
files: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
158
|
+
}, z.core.$strict>>;
|
|
159
|
+
"skill-listing": z.ZodOptional<z.ZodObject<{
|
|
160
|
+
measure: z.ZodNumber;
|
|
161
|
+
total: z.ZodNumber;
|
|
162
|
+
files: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
163
|
+
}, z.core.$strict>>;
|
|
164
|
+
}, z.core.$strict>>;
|
|
77
165
|
}, z.core.$strict>>;
|
|
78
166
|
}, z.core.$strict>;
|
|
79
167
|
/** One bundle's recorded weight. */
|
|
80
|
-
export type BaselineEntry = z.infer<typeof entrySchema
|
|
168
|
+
export type BaselineEntry = Readonly<z.infer<typeof entrySchema>>;
|
|
169
|
+
/** One recorded always-loaded part. */
|
|
170
|
+
export type BaselinePart = Readonly<z.infer<typeof partSchema>>;
|
|
81
171
|
/** The whole committed file. */
|
|
82
172
|
export type InstructionBaseline = z.infer<typeof baselineSchema>;
|
|
83
173
|
/** The file's contents, parsed once at the boundary. */
|
|
@@ -89,8 +179,11 @@ export type ParsedBaseline = {
|
|
|
89
179
|
readonly message: string;
|
|
90
180
|
};
|
|
91
181
|
export declare function parseInstructionBaseline(text: string): ParsedBaseline;
|
|
92
|
-
/**
|
|
93
|
-
|
|
182
|
+
/**
|
|
183
|
+
* What a measured weight would be recorded as: the SCORED files only, plus
|
|
184
|
+
* every always-loaded part that is not zero when one is handed in.
|
|
185
|
+
*/
|
|
186
|
+
export declare function entryFor(weight: InstructionWeight, loaded?: AlwaysLoadedContext): BaselineEntry;
|
|
94
187
|
/** One file whose recorded size differs. `null` = absent on that side. */
|
|
95
188
|
export interface FileChange {
|
|
96
189
|
readonly path: string;
|
|
@@ -114,6 +207,8 @@ export type RatchetVerdict = {
|
|
|
114
207
|
readonly kind: "measure-changed";
|
|
115
208
|
readonly recorded: number;
|
|
116
209
|
readonly current: number;
|
|
210
|
+
/** Set when it is one always-loaded PART whose measurement changed. */
|
|
211
|
+
readonly part?: LoadedPartName;
|
|
117
212
|
} | {
|
|
118
213
|
readonly kind: "held";
|
|
119
214
|
readonly total: number;
|
|
@@ -127,6 +222,66 @@ export type RatchetVerdict = {
|
|
|
127
222
|
readonly changes: readonly FileChange[];
|
|
128
223
|
};
|
|
129
224
|
export declare function compareToBaseline(weight: InstructionWeight, recorded: BaselineEntry | undefined): RatchetVerdict;
|
|
225
|
+
/** One part's recorded and current size, for the line that says where weight moved. */
|
|
226
|
+
export interface PartMove {
|
|
227
|
+
readonly part: "instructions" | LoadedPartName;
|
|
228
|
+
readonly from: number;
|
|
229
|
+
readonly to: number;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The ratchet's verdict for one bundle with its always-loaded context:
|
|
233
|
+
*
|
|
234
|
+
* - `instructions-only` — decided on the instructions as before. A version-1
|
|
235
|
+
* file, or a repo with no part to add and no file yet. Each part that is
|
|
236
|
+
* not zero is listed so the caller can print it as a NOTE.
|
|
237
|
+
* - `always-loaded` — decided on the SUM of the instructions and the parts: a
|
|
238
|
+
* version-2 file, or no file yet and something to add (recording then
|
|
239
|
+
* writes version 2). `byPart` says where weight moved, also on `held`,
|
|
240
|
+
* because a held sum can hide a listing that doubled while the
|
|
241
|
+
* instructions halved.
|
|
242
|
+
*/
|
|
243
|
+
export type BaselineVerdict = {
|
|
244
|
+
readonly kind: "instructions-only";
|
|
245
|
+
readonly verdict: RatchetVerdict;
|
|
246
|
+
readonly unrecordedParts: readonly {
|
|
247
|
+
readonly part: LoadedPartName;
|
|
248
|
+
readonly total: number;
|
|
249
|
+
}[];
|
|
250
|
+
} | {
|
|
251
|
+
readonly kind: "always-loaded";
|
|
252
|
+
readonly verdict: RatchetVerdict;
|
|
253
|
+
readonly byPart: readonly PartMove[];
|
|
254
|
+
/** Recorded parts this run cannot measure, carried rather than compared. */
|
|
255
|
+
readonly unmeasured: readonly UnmeasuredPart[];
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* A part the baseline records and this run cannot measure: the adapter no
|
|
259
|
+
* longer models it (`not-modelled`), the harness has no such part
|
|
260
|
+
* (`not-supported`), or the selected style names no repository file
|
|
261
|
+
* (`unresolved`). None of these is ZERO (`./always-loaded.ts` keeps them apart
|
|
262
|
+
* for that reason), so the recorded size is carried into the comparison and
|
|
263
|
+
* into a re-record instead of being read as a cut. Reading it as 0 would print
|
|
264
|
+
* "shrank … lock the cut in", and following that advice would delete the part
|
|
265
|
+
* — and, with no part left, turn the file back into version 1, silently
|
|
266
|
+
* returning the gate to the instructions alone.
|
|
267
|
+
*/
|
|
268
|
+
export interface UnmeasuredPart {
|
|
269
|
+
readonly part: LoadedPartName;
|
|
270
|
+
readonly kind: Exclude<LoadedPart["kind"], "counted" | "none">;
|
|
271
|
+
readonly recorded: number;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* `current` with every recorded part this run cannot measure carried over from
|
|
275
|
+
* `recorded`, and the list of those parts. `counted` and `none` are measured —
|
|
276
|
+
* `none` is a real zero — so they are never carried.
|
|
277
|
+
*/
|
|
278
|
+
export declare function carryUnmeasured(current: BaselineEntry, loaded: AlwaysLoadedContext, recorded: BaselineEntry | undefined): {
|
|
279
|
+
readonly entry: BaselineEntry;
|
|
280
|
+
readonly unmeasured: readonly UnmeasuredPart[];
|
|
281
|
+
};
|
|
282
|
+
/** Which version of the file the verdict is read against; `absent` = no file. */
|
|
283
|
+
export type BaselineFileVersion = 1 | typeof INSTRUCTION_BASELINE_VERSION | "absent";
|
|
284
|
+
export declare function compareAlwaysLoadedToBaseline(weight: InstructionWeight, loaded: AlwaysLoadedContext, recorded: BaselineEntry | undefined, file: BaselineFileVersion): BaselineVerdict;
|
|
130
285
|
/** One file's size, for naming where the weight is. */
|
|
131
286
|
export interface FileWeight {
|
|
132
287
|
readonly path: string;
|
|
@@ -154,12 +309,25 @@ export declare function recordEntries(previous: InstructionBaseline | undefined,
|
|
|
154
309
|
/** Stable text: sorted keys, two-space indent, trailing newline, no timestamp. */
|
|
155
310
|
export declare function serializeBaseline(baseline: InstructionBaseline): string;
|
|
156
311
|
/** The one-paragraph message a verdict prints as, prefixed by its bundle. */
|
|
157
|
-
export declare function formatVerdict(verdict: RatchetVerdict, at: string): string;
|
|
312
|
+
export declare function formatVerdict(verdict: RatchetVerdict, at: string, subject?: string): string;
|
|
313
|
+
/** The message for one bundle's {@link BaselineVerdict}, prefixed by its bundle. */
|
|
314
|
+
export declare function formatBaselineVerdict(verdict: BaselineVerdict, at: string): string;
|
|
315
|
+
/** Why a recorded part was carried: the run could not measure it, not a cut. */
|
|
316
|
+
export declare function describeUnmeasured(u: UnmeasuredPart): string;
|
|
317
|
+
/**
|
|
318
|
+
* The NOTE a version-1 file gets for each part that is not zero: always
|
|
319
|
+
* loaded, not yet in the baseline, and what recording it does — including the
|
|
320
|
+
* one cost of recording, an older vigiles reading the new file as unreadable.
|
|
321
|
+
*/
|
|
322
|
+
export declare function formatUnrecordedParts(parts: readonly {
|
|
323
|
+
readonly part: LoadedPartName;
|
|
324
|
+
readonly total: number;
|
|
325
|
+
}[], unit: BaselineEntry["unit"], at: string): string;
|
|
158
326
|
/** The message for a total over the ceiling, prefixed by its bundle. */
|
|
159
327
|
export declare function formatCeiling(verdict: CeilingVerdict, at: string): string;
|
|
160
328
|
/** Why `--update-baseline` wrote nothing: the ceiling it would have been recorded above. */
|
|
161
329
|
export declare function formatRefusal(verdict: CeilingVerdict, at: string): string;
|
|
162
330
|
/** The compile-time one-liner: weight now, against the baseline when there is one. */
|
|
163
|
-
export declare function formatWeightLine(verdict: RatchetVerdict): string;
|
|
331
|
+
export declare function formatWeightLine(verdict: RatchetVerdict, label?: string): string;
|
|
164
332
|
export {};
|
|
165
333
|
//# sourceMappingURL=instruction-baseline.d.ts.map
|