vigiles 40.1.0 → 41.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/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/rule-proof/kits/eslint.d.ts +30 -0
- package/dist/core/rule-proof/kits/eslint.js +130 -0
- package/dist/core/rule-proof/kits/index.d.ts +7 -0
- package/dist/core/rule-proof/kits/index.js +12 -0
- package/dist/core/rule-proof/kits/ruff.d.ts +28 -0
- package/dist/core/rule-proof/kits/ruff.js +178 -0
- package/dist/core/rule-proof/node-install.d.ts +32 -0
- package/dist/core/rule-proof/node-install.js +117 -0
- package/dist/core/rule-proof/pair.d.ts +11 -0
- package/dist/core/rule-proof/pair.js +61 -0
- package/dist/core/rule-proof/port.d.ts +77 -0
- package/dist/core/rule-proof/port.js +3 -0
- package/dist/core/rule-proof/report.d.ts +11 -0
- package/dist/core/rule-proof/report.js +36 -0
- package/dist/core/rule-proof/run.d.ts +58 -0
- package/dist/core/rule-proof/run.js +260 -0
- package/dist/core/rule-proof/types.d.ts +119 -0
- package/dist/core/rule-proof/types.js +13 -0
- package/dist/core/skill-listing.d.ts +24 -0
- package/dist/core/types.d.ts +14 -6
- package/dist/entries/rule-proof.d.ts +18 -0
- package/dist/entries/rule-proof.js +23 -0
- package/dist/host/rule-proof.io.d.ts +4 -0
- package/dist/host/rule-proof.io.js +64 -0
- 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 +2 -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
package/dist/adapter.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type { HarnessAdapter, AdapterCapabilities } from "./core/adapter.js";
|
|
|
19
19
|
export type { HarnessDialect } from "./core/dialect.js";
|
|
20
20
|
export type { PluginLayout, SkillDiscovery, SurfaceDirs, SurfaceKind, } from "./core/layout.js";
|
|
21
21
|
export type { OutputStyle, OutputStyleRules, StyleSelection, } from "./core/output-style.js";
|
|
22
|
-
export type { ListedSkill, SkillListingRules } from "./core/skill-listing.js";
|
|
22
|
+
export type { ListedSkill, ListingLimit, SkillListingBudget, SkillListingRules, } from "./core/skill-listing.js";
|
|
23
23
|
export type { ModelRequest } from "./core/harness-driver.js";
|
|
24
24
|
export { executableSourceDirs, materializePrefix, surfaceDirs, } from "./core/layout.js";
|
|
25
25
|
/**
|
|
@@ -38,11 +38,33 @@
|
|
|
38
38
|
* binary with it; modelling them while CI runs the pinned release would leave
|
|
39
39
|
* the delivery test proving nothing.
|
|
40
40
|
*
|
|
41
|
-
* The listing as a WHOLE also has a budget
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* The listing as a WHOLE also has a budget, past which descriptions are
|
|
42
|
+
* dropped by least use. Read from the pinned 2.1.187 binary
|
|
43
|
+
* (`@anthropic-ai/claude-code-linux-x64@2.1.187`, sha256 bb02fcb3…bf361):
|
|
44
|
+
*
|
|
45
|
+
* budget = floor(contextWindowTokens × charsPerToken × fraction)
|
|
46
|
+
*
|
|
47
|
+
* - `fraction` is `skillListingBudgetFraction` from settings, default 0.01
|
|
48
|
+
* (`var FRd=0.01`);
|
|
49
|
+
* - `contextWindowTokens` defaults to 200 000 (`URd=200000`), 1 000 000 on
|
|
50
|
+
* a 1M-context model;
|
|
51
|
+
* - `charsPerToken` is 4 for the models in a fixed set (claude-3-*,
|
|
52
|
+
* opus-4-0/4-1/4-5/4-6, sonnet-4-0/4-5/4-6, haiku-4-5) and 3 for every
|
|
53
|
+
* other model (`function oA(e){if(!e)return 4;…return l3u.has(n)?4:3}`);
|
|
54
|
+
* - the env var `SLASH_COMMAND_TOOL_CHAR_BUDGET` replaces the whole number.
|
|
55
|
+
*
|
|
56
|
+
* The listing is measured against it as the sum of each entry's display width
|
|
57
|
+
* (`Bun.stringWidth`, not `.length`) plus one newline between entries, over
|
|
58
|
+
* every listed skill — bundled, user and plugin skills included, not only the
|
|
59
|
+
* repository's. Its floor is 200 000 × 3 × 0.01 = 6 000 characters, and that
|
|
60
|
+
* floor is {@link claudeCodeListingBudget}: the window and the chars per token
|
|
61
|
+
* depend on the model a person picks, so the smallest a commit can be sure of
|
|
62
|
+
* is what vigiles holds it to. A committed `skillListingBudgetFraction` moves
|
|
63
|
+
* it; the environment variable is per machine and is not read. vigiles sums
|
|
64
|
+
* entry LENGTHS without the newlines, an under-count of one character per
|
|
65
|
+
* listed skill (and more for wide characters, which `stringWidth` counts as 2).
|
|
45
66
|
*/
|
|
46
|
-
import type { SkillListingRules } from "../../core/skill-listing.js";
|
|
67
|
+
import type { SkillListingBudget, SkillListingRules } from "../../core/skill-listing.js";
|
|
68
|
+
export declare const claudeCodeListingBudget: SkillListingBudget;
|
|
47
69
|
export declare const claudeCodeSkillListing: SkillListingRules;
|
|
48
70
|
//# sourceMappingURL=skill-listing.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.claudeCodeSkillListing = void 0;
|
|
3
|
+
exports.claudeCodeSkillListing = exports.claudeCodeListingBudget = void 0;
|
|
4
4
|
/** The documented per-entry cap, in characters (UTF-16 units, as measured). */
|
|
5
5
|
const ENTRY_CAP = 1536;
|
|
6
6
|
/** What replaces the cut tail; the cap includes it. */
|
|
@@ -47,8 +47,36 @@ const entry = (skill, settings) => {
|
|
|
47
47
|
const combined = whenToUse === undefined ? description : `${description} - ${whenToUse}`;
|
|
48
48
|
return `- ${skill.dirName}: ${capped(combined, capFrom(settings))}`;
|
|
49
49
|
};
|
|
50
|
+
/** The context window the budget is computed on: the CLI's default, `URd=200000`. */
|
|
51
|
+
const FLOOR_WINDOW_TOKENS = 200_000;
|
|
52
|
+
/** Characters per token for every model outside the CLI's older-model set. */
|
|
53
|
+
const FLOOR_CHARS_PER_TOKEN = 3;
|
|
54
|
+
/** `skillListingBudgetFraction`'s default, `FRd=0.01`. */
|
|
55
|
+
const DEFAULT_FRACTION = 0.01;
|
|
56
|
+
/** The setting that moves the fraction, as the settings schema names it. */
|
|
57
|
+
const FRACTION_SETTING = "skillListingBudgetFraction";
|
|
58
|
+
/** The committed fraction when the CLI would accept it (`gt(0).lte(1)`), else none. */
|
|
59
|
+
const fractionFrom = (settings) => {
|
|
60
|
+
const v = settings[FRACTION_SETTING];
|
|
61
|
+
return typeof v === "number" && v > 0 && v <= 1 ? v : undefined;
|
|
62
|
+
};
|
|
63
|
+
/** `Math.max(1, Math.floor(window × charsPerToken × fraction))`, as the CLI computes it. */
|
|
64
|
+
const listingLimit = (settings) => {
|
|
65
|
+
const fraction = fractionFrom(settings);
|
|
66
|
+
const limit = Math.max(1, Math.floor(FLOOR_WINDOW_TOKENS *
|
|
67
|
+
FLOOR_CHARS_PER_TOKEN *
|
|
68
|
+
(fraction ?? DEFAULT_FRACTION)));
|
|
69
|
+
return fraction === undefined
|
|
70
|
+
? { limit }
|
|
71
|
+
: { limit, setBy: FRACTION_SETTING };
|
|
72
|
+
};
|
|
73
|
+
exports.claudeCodeListingBudget = {
|
|
74
|
+
limit: listingLimit,
|
|
75
|
+
capturedFrom: "claude-code 2.1.187 binary (sha256 bb02fcb3…bf361): function E2e — floor((window ?? 200000) × oA(model) × (skillListingBudgetFraction ?? 0.01)), oA = 4 for an older-model set else 3; floor at 200000 × 3",
|
|
76
|
+
};
|
|
50
77
|
exports.claudeCodeSkillListing = {
|
|
51
78
|
entry,
|
|
79
|
+
budget: exports.claudeCodeListingBudget,
|
|
52
80
|
capturedFrom: "code.claude.com/docs/en/skills (fetched 2026-10-31); measured on Claude Code 2.1.187 (VALIDATED_CC_VERSION)",
|
|
53
81
|
};
|
|
54
82
|
//# sourceMappingURL=skill-listing.js.map
|
|
@@ -33,10 +33,28 @@
|
|
|
33
33
|
* path; the size is reproducible from a commit, and each entry is off by
|
|
34
34
|
* the difference between that path and the one Codex printed.
|
|
35
35
|
*
|
|
36
|
-
* The listing as a whole has a budget
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* The listing as a whole has a budget, past which descriptions are shortened
|
|
37
|
+
* and then skills omitted ("Exceeded skills context budget …"). Read from
|
|
38
|
+
* `codex-rs/ext/skills/src/render.rs` and `extension.rs` at tag rust-v0.153.0
|
|
39
|
+
* (`skill_metadata_budget`):
|
|
40
|
+
*
|
|
41
|
+
* - a configured `max_context_tokens` wins, capped at 10 000 tokens;
|
|
42
|
+
* - else, at THREAD START (`CatalogSurface::ThreadContext`), the window is
|
|
43
|
+
* passed as `None`, so the budget is 8 000 CHARACTERS
|
|
44
|
+
* (`DEFAULT_SKILL_METADATA_CHAR_BUDGET`), each line costing its Unicode
|
|
45
|
+
* scalar count plus one newline;
|
|
46
|
+
* - on a TURN (`CatalogSurface::TurnInput`) it is 2% of the model's context
|
|
47
|
+
* window in tokens, each line costing ceil((bytes + 1) / 4).
|
|
48
|
+
*
|
|
49
|
+
* The thread-start number does not depend on the model, so it is
|
|
50
|
+
* {@link codexListingBudget}: 8 000 — compared against vigiles's Codex unit,
|
|
51
|
+
* BYTES, which is never smaller than the characters Codex counts, so a
|
|
52
|
+
* non-ASCII listing is reported over a little early, never late. A committed
|
|
53
|
+
* `[skills] max_context_tokens` in `.codex/config.toml` replaces it with that
|
|
54
|
+
* many tokens (at most 10 000), four bytes each. vigiles sums entries without
|
|
55
|
+
* the newline Codex adds to each line: one byte per listed skill under.
|
|
39
56
|
*/
|
|
40
|
-
import type { SkillListingRules } from "../../core/skill-listing.js";
|
|
57
|
+
import type { SkillListingBudget, SkillListingRules } from "../../core/skill-listing.js";
|
|
58
|
+
export declare const codexListingBudget: SkillListingBudget;
|
|
41
59
|
export declare const codexSkillListing: SkillListingRules;
|
|
42
60
|
//# sourceMappingURL=skill-listing.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codexSkillListing = void 0;
|
|
3
|
+
exports.codexSkillListing = exports.codexListingBudget = void 0;
|
|
4
4
|
/** Longer descriptions are cut, in Unicode scalar values. */
|
|
5
5
|
const DESCRIPTION_CAP = 1024;
|
|
6
6
|
/** What replaces the cut tail; the cap includes it. */
|
|
@@ -33,8 +33,37 @@ const entry = (skill) => {
|
|
|
33
33
|
}
|
|
34
34
|
return `- ${name}: ${capped(description)} (file: ${skill.path})`;
|
|
35
35
|
};
|
|
36
|
+
/** `DEFAULT_SKILL_METADATA_CHAR_BUDGET`: the thread-start budget, no window passed. */
|
|
37
|
+
const THREAD_START_BUDGET = 8000;
|
|
38
|
+
/** `MAX_CONFIGURED_SKILL_METADATA_TOKEN_BUDGET`: a configured budget is capped here. */
|
|
39
|
+
const MAX_CONFIGURED_TOKENS = 10_000;
|
|
40
|
+
/** `APPROX_BYTES_PER_TOKEN`, the conversion `approx_token_count` uses. */
|
|
41
|
+
const BYTES_PER_TOKEN = 4;
|
|
42
|
+
/** The committed setting, as `.codex/config.toml` spells it. */
|
|
43
|
+
const TOKENS_SETTING = "skills.max_context_tokens";
|
|
44
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
45
|
+
/** `[skills] max_context_tokens` when it is a positive integer (`NonZeroUsize`). */
|
|
46
|
+
const configuredTokens = (settings) => {
|
|
47
|
+
const skills = settings["skills"];
|
|
48
|
+
const v = isRecord(skills) ? skills["max_context_tokens"] : undefined;
|
|
49
|
+
return typeof v === "number" && Number.isInteger(v) && v > 0 ? v : undefined;
|
|
50
|
+
};
|
|
51
|
+
const listingLimit = (settings) => {
|
|
52
|
+
const tokens = configuredTokens(settings);
|
|
53
|
+
return tokens === undefined
|
|
54
|
+
? { limit: THREAD_START_BUDGET }
|
|
55
|
+
: {
|
|
56
|
+
limit: Math.min(tokens, MAX_CONFIGURED_TOKENS) * BYTES_PER_TOKEN,
|
|
57
|
+
setBy: TOKENS_SETTING,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.codexListingBudget = {
|
|
61
|
+
limit: listingLimit,
|
|
62
|
+
capturedFrom: "openai/codex rust-v0.153.0 codex-rs/ext/skills/src/render.rs skill_metadata_budget + extension.rs:234 (thread start passes no window → 8_000 chars; max_context_tokens capped at 10_000)",
|
|
63
|
+
};
|
|
36
64
|
exports.codexSkillListing = {
|
|
37
65
|
entry,
|
|
66
|
+
budget: exports.codexListingBudget,
|
|
38
67
|
capturedFrom: "openai/codex codex-rs/skills/src/parser.rs + codex-rs/ext/skills/src/render.rs (main, fetched 2026-10-31); measured on codex-cli 0.153.0",
|
|
39
68
|
};
|
|
40
69
|
//# sourceMappingURL=skill-listing.js.map
|
package/dist/cli-main.d.ts
CHANGED
|
@@ -87,9 +87,10 @@ interface LintReport {
|
|
|
87
87
|
contextCreepIssues: number;
|
|
88
88
|
contextCreepErrors: number;
|
|
89
89
|
/**
|
|
90
|
-
* Notes the
|
|
91
|
-
*
|
|
92
|
-
* prints them, because the session-start hook injects
|
|
90
|
+
* Notes the always-loaded check raises that never count: over a limit with
|
|
91
|
+
* no baseline recorded, and an old baseline file to migrate — each with its
|
|
92
|
+
* command. `--summary` prints them, because the session-start hook injects
|
|
93
|
+
* that output.
|
|
93
94
|
*/
|
|
94
95
|
contextCreepNotes: readonly string[];
|
|
95
96
|
deprecatedKeyFilesIssues: number;
|
package/dist/cli-main.js
CHANGED
|
@@ -49,7 +49,8 @@ const setup_plan_js_1 = require("./setup-plan.js");
|
|
|
49
49
|
const types_js_1 = require("./core/types.js");
|
|
50
50
|
const test_coverage_js_1 = require("./test-coverage.js");
|
|
51
51
|
const scan_js_1 = require("./scan.js");
|
|
52
|
-
const
|
|
52
|
+
const context_creep_lint_js_1 = require("./context-creep-lint.js");
|
|
53
|
+
const always_loaded_limits_js_1 = require("./core/always-loaded-limits.js");
|
|
53
54
|
const frame_js_1 = require("./core/frame.js");
|
|
54
55
|
const surface_discovery_js_1 = require("./core/surface-discovery.js");
|
|
55
56
|
const scan_trigger_suggest_js_1 = require("./scan-trigger-suggest.js");
|
|
@@ -117,6 +118,47 @@ const CONFIG = (0, config_schema_js_1.configFor)(index_js_1.RULES, index_js_1.RU
|
|
|
117
118
|
const INIT_POLICY = (0, rule_js_1.initPolicyOf)(index_js_1.RULES, index_js_1.RULE_GROUPS);
|
|
118
119
|
/** Every rule at its shipped default — what a missing `.vigilesrc.json` loads as. */
|
|
119
120
|
const DEFAULT_CONFIG = (0, validate_js_1.configDefaults)(CONFIG);
|
|
121
|
+
/**
|
|
122
|
+
* The always-loaded rule, asked of the set by its detector rather than by
|
|
123
|
+
* name: `lint`, `compile` and `init` read its severity and options, and the
|
|
124
|
+
* baseline store keys its entries by its id.
|
|
125
|
+
*/
|
|
126
|
+
const ALWAYS_LOADED_RULE = (() => {
|
|
127
|
+
const rule = index_js_1.RULES.find((r) => r.detector === always_loaded_limits_js_1.checkAlwaysLoadedLimits.name);
|
|
128
|
+
if (rule === undefined)
|
|
129
|
+
throw new Error("no rule reports checkAlwaysLoadedLimits");
|
|
130
|
+
return rule.id;
|
|
131
|
+
})();
|
|
132
|
+
/**
|
|
133
|
+
* The repository's files under `root`, for the baseline store — the file
|
|
134
|
+
* system I/O the context-creep module takes as a port.
|
|
135
|
+
*/
|
|
136
|
+
function repoFiles(root) {
|
|
137
|
+
return {
|
|
138
|
+
read: (path) => {
|
|
139
|
+
const abs = (0, node_path_1.join)(root, path);
|
|
140
|
+
return (0, node_fs_1.existsSync)(abs) ? (0, node_fs_1.readFileSync)(abs, "utf-8") : undefined;
|
|
141
|
+
},
|
|
142
|
+
write: (path, text) => {
|
|
143
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)((0, node_path_1.join)(root, path)), { recursive: true });
|
|
144
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, path), text);
|
|
145
|
+
},
|
|
146
|
+
remove: (path) => {
|
|
147
|
+
(0, node_fs_1.rmSync)((0, node_path_1.join)(root, path), { force: true });
|
|
148
|
+
},
|
|
149
|
+
exists: (path) => (0, node_fs_1.existsSync)((0, node_path_1.join)(root, path)),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** The always-loaded rule's limit options, as `.vigilesrc.json` sets them. */
|
|
153
|
+
function alwaysLoadedLimits(config) {
|
|
154
|
+
const value = config?.rules?.[ALWAYS_LOADED_RULE];
|
|
155
|
+
const parsed = index_js_1.contextCreepOptions.safeParse(Array.isArray(value) ? value[1] : {});
|
|
156
|
+
const opts = parsed.success ? parsed.data : undefined;
|
|
157
|
+
return {
|
|
158
|
+
...(opts?.limits === undefined ? {} : { limits: opts.limits }),
|
|
159
|
+
...(opts?.max === undefined ? {} : { max: opts.max }),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
120
162
|
/** `.vigilesrc.json` for this rule set; see `core/validate.ts` `loadConfig`. */
|
|
121
163
|
function loadConfig(searchFrom, opts) {
|
|
122
164
|
return (0, validate_js_1.loadConfig)(CONFIG, searchFrom, opts);
|
|
@@ -1870,13 +1912,15 @@ async function runLint(restArgs, flags, excludes, config) {
|
|
|
1870
1912
|
// typo, an uncompilable or unreachable MCP pattern, one too narrow for real
|
|
1871
1913
|
// server naming, or an undeclared MCP server).
|
|
1872
1914
|
const hookMatcher = overBundles(checkHookMatcher, run, lintRoots);
|
|
1873
|
-
// 7v. Context
|
|
1874
|
-
//
|
|
1875
|
-
// are keys inside it), so it runs ONCE over `lintRoots
|
|
1876
|
-
const contextCreep = (0,
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1915
|
+
// 7v. Context creep — the always-loaded context against the harness's own
|
|
1916
|
+
// limits, then the baseline store over those findings. One store for the
|
|
1917
|
+
// whole run (bundles are keys inside it), so it runs ONCE over `lintRoots`.
|
|
1918
|
+
const contextCreep = (0, context_creep_lint_js_1.checkContextCreep)({
|
|
1919
|
+
ruleId: ALWAYS_LOADED_RULE,
|
|
1920
|
+
files: repoFiles(frame.root),
|
|
1921
|
+
scope: frame.bundle(scanRoot).at,
|
|
1922
|
+
severity: (0, types_js_1.ruleSeverity)(config?.rules?.[ALWAYS_LOADED_RULE]),
|
|
1923
|
+
...alwaysLoadedLimits(config),
|
|
1880
1924
|
update: flags.includes("--update-baseline"),
|
|
1881
1925
|
silent,
|
|
1882
1926
|
measure: () => lintRoots.map((abs) => measuredBundle(frame.bundle(abs).at, abs, adapter)),
|
|
@@ -2126,8 +2170,8 @@ function printLintSummary(report) {
|
|
|
2126
2170
|
else {
|
|
2127
2171
|
console.log(`vigiles: ${parts.join(" / ")}`);
|
|
2128
2172
|
}
|
|
2129
|
-
// One extra line per note, only when there is one: the
|
|
2130
|
-
//
|
|
2173
|
+
// One extra line per note, only when there is one: the command to record or
|
|
2174
|
+
// migrate the baseline reaches the agent through the session-start hook.
|
|
2131
2175
|
report.contextCreepNotes.forEach((note) => {
|
|
2132
2176
|
console.log(`vigiles: note — ${note}`);
|
|
2133
2177
|
});
|
|
@@ -3973,13 +4017,17 @@ async function setup(args) {
|
|
|
3973
4017
|
specs: plan.scaffoldSpecs,
|
|
3974
4018
|
written,
|
|
3975
4019
|
});
|
|
4020
|
+
// The always-loaded baseline, on a repository already over a limit: the
|
|
4021
|
+
// gate starts from today's size instead of waiting for someone to find the
|
|
4022
|
+
// flag. Read after the config is written, so the harness it records is used.
|
|
4023
|
+
const baseline = plan.lint ? initBaseline() : [];
|
|
3976
4024
|
printSetupSummary({
|
|
3977
4025
|
plan,
|
|
3978
4026
|
strict,
|
|
3979
4027
|
targets,
|
|
3980
4028
|
adopted,
|
|
3981
4029
|
// The skill links the plugin step created, so the commit hint names them.
|
|
3982
|
-
written: [...written, ...linkedSkills],
|
|
4030
|
+
written: [...written, ...linkedSkills, ...baseline],
|
|
3983
4031
|
});
|
|
3984
4032
|
// Surface the OTHER mode so both directions are discoverable — the two branches
|
|
3985
4033
|
// are mutually exclusive (a run is either gate-only or full):
|
|
@@ -4013,7 +4061,10 @@ function minimalRerun(parsed, state) {
|
|
|
4013
4061
|
printDetection(detected, harnesses);
|
|
4014
4062
|
const links = plan.plugin ? linkSkillsOnly(harnesses) : [];
|
|
4015
4063
|
const devDep = plan.lint || plan.test ? addMissingVigilesDevDep() : [];
|
|
4016
|
-
|
|
4064
|
+
// A missing always-loaded baseline is missing AND local: recorded only on a
|
|
4065
|
+
// repository over a limit, never over an existing one.
|
|
4066
|
+
const baseline = plan.lint ? initBaseline() : [];
|
|
4067
|
+
const written = [...links, ...devDep, ...baseline];
|
|
4017
4068
|
if (written.length === 0)
|
|
4018
4069
|
console.log("\nNothing was missing.");
|
|
4019
4070
|
const followUps = (0, setup_plan_js_1.fullSetupFollowUps)(fullSetupGap(plan, detected, harnesses), INIT_POLICY.preset);
|
|
@@ -4022,6 +4073,60 @@ function minimalRerun(parsed, state) {
|
|
|
4022
4073
|
if (written.length > 0)
|
|
4023
4074
|
console.log(`\n Commit:\n git add ${written.join(" ")} && git commit -m "Update vigiles"`);
|
|
4024
4075
|
}
|
|
4076
|
+
/**
|
|
4077
|
+
* `compile`'s always-loaded line: the size now against each limit, and against
|
|
4078
|
+
* the baseline when over one. Report-only — `lint` is the gate.
|
|
4079
|
+
*/
|
|
4080
|
+
function printCompileWeight(projectRoot, harnessFlag, config) {
|
|
4081
|
+
const adapter = (0, adapter_registry_js_1.resolveHarnessSelection)({
|
|
4082
|
+
root: projectRoot,
|
|
4083
|
+
flag: harnessFlag,
|
|
4084
|
+
configHarness: (0, adapter_registry_js_1.declaredHarnessNames)(config.harnesses),
|
|
4085
|
+
}).adapter;
|
|
4086
|
+
const line = (0, context_creep_lint_js_1.compileWeightLine)(repoFiles(projectRoot), ALWAYS_LOADED_RULE, measuredBundle(".", projectRoot, adapter), alwaysLoadedLimits(config));
|
|
4087
|
+
if (line !== null)
|
|
4088
|
+
console.log(`\n${line}`);
|
|
4089
|
+
}
|
|
4090
|
+
/** What `init` prints about the always-loaded baseline. */
|
|
4091
|
+
function initBaselineLine(outcome) {
|
|
4092
|
+
switch (outcome.kind) {
|
|
4093
|
+
case "under-limits":
|
|
4094
|
+
return undefined;
|
|
4095
|
+
case "kept":
|
|
4096
|
+
return `✓ ${outcome.file} already holds the always-loaded baseline — left as it is`;
|
|
4097
|
+
case "legacy":
|
|
4098
|
+
return `ℹ ${outcome.file} is the old always-loaded baseline — migrate it with \`${outcome.command}\` (it keeps the recorded numbers)`;
|
|
4099
|
+
case "recorded":
|
|
4100
|
+
return (`✓ always-loaded context: ${outcome.over.join("; ")}. Recorded ${outcome.file} — commit it. ` +
|
|
4101
|
+
"CI now fails only if it grows past that size.");
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
/**
|
|
4105
|
+
* `init`'s baseline step over the repository root: record the always-loaded
|
|
4106
|
+
* baseline when the repository is over a harness limit and has none. Off when
|
|
4107
|
+
* the rule is off. Returns the file written, for the commit hint.
|
|
4108
|
+
*/
|
|
4109
|
+
function initBaseline() {
|
|
4110
|
+
const root = process.cwd();
|
|
4111
|
+
const config = loadConfig();
|
|
4112
|
+
if (!(0, types_js_1.ruleSeverity)(config.rules?.[ALWAYS_LOADED_RULE]))
|
|
4113
|
+
return [];
|
|
4114
|
+
const adapter = (0, adapter_registry_js_1.resolveHarnessSelection)({
|
|
4115
|
+
root,
|
|
4116
|
+
flag: undefined,
|
|
4117
|
+
configHarness: (0, adapter_registry_js_1.declaredHarnessNames)(config.harnesses),
|
|
4118
|
+
}).adapter;
|
|
4119
|
+
// The bundles `lint` scores, so the next `lint` finds an entry for each.
|
|
4120
|
+
const frame = (0, frame_js_1.frameFor)(root, root);
|
|
4121
|
+
const bundles = config.bundles === "all"
|
|
4122
|
+
? [root, ...discoverNestedBundles(root, (0, exclude_js_1.excludeSet)(root, config.exclude))]
|
|
4123
|
+
: [root];
|
|
4124
|
+
const outcome = (0, context_creep_lint_js_1.recordIfMissing)(repoFiles(root), ALWAYS_LOADED_RULE, bundles.map((abs) => measuredBundle(frame.bundle(abs).at, abs, adapter)), alwaysLoadedLimits(config));
|
|
4125
|
+
const line = initBaselineLine(outcome);
|
|
4126
|
+
if (line !== undefined)
|
|
4127
|
+
console.log(`\n${line}`);
|
|
4128
|
+
return outcome.kind === "recorded" ? [outcome.file] : [];
|
|
4129
|
+
}
|
|
4025
4130
|
/**
|
|
4026
4131
|
* Link the shipped skills for each harness that links them — the safe, local
|
|
4027
4132
|
* half of `installPlugins`, without the global install or config wiring.
|
|
@@ -7491,19 +7596,10 @@ async function main() {
|
|
|
7491
7596
|
if (specs.length > 0)
|
|
7492
7597
|
valid =
|
|
7493
7598
|
(await compile(specs, config, excludes, { harnessFlag })) && valid;
|
|
7494
|
-
// The always-loaded
|
|
7495
|
-
//
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
const measured = measuredBundle(".", projectRoot, (0, adapter_registry_js_1.resolveHarnessSelection)({
|
|
7499
|
-
root: projectRoot,
|
|
7500
|
-
flag: harnessFlag,
|
|
7501
|
-
configHarness: (0, adapter_registry_js_1.declaredHarnessNames)(config.harnesses),
|
|
7502
|
-
}).adapter);
|
|
7503
|
-
const weightLine = (0, context_creep_ratchet_js_1.compileWeightLine)(projectRoot, measured);
|
|
7504
|
-
if (weightLine !== null)
|
|
7505
|
-
console.log(`\n${weightLine}`);
|
|
7506
|
-
}
|
|
7599
|
+
// The always-loaded size the author just produced, against the
|
|
7600
|
+
// harness's limits — shown at the moment of change. Report-only.
|
|
7601
|
+
if (specs.length > 0)
|
|
7602
|
+
printCompileWeight(projectRoot, harnessFlag, config);
|
|
7507
7603
|
valid =
|
|
7508
7604
|
(await installHooks(hooks, harnessFlag, (0, adapter_registry_js_1.declaredHarnessNames)(config.harnesses),
|
|
7509
7605
|
// A hook-side compile is under way even when every hook was refused:
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `lint`'s side of the always-loaded check: measure each scored bundle, let
|
|
3
|
+
* the detector (`core/always-loaded-limits.ts`) say which parts are over the
|
|
4
|
+
* harness's limits, then apply the baseline store (`core/baseline-store.ts`)
|
|
5
|
+
* to those findings — and, only under the explicit `--update-baseline`, write
|
|
6
|
+
* the store.
|
|
7
|
+
*
|
|
8
|
+
* This module decides what is read, written and deleted — the store, and the
|
|
9
|
+
* file earlier releases wrote — and turns lines into lint counters and
|
|
10
|
+
* annotations. The bytes go through {@link BaselineFiles}, a port the
|
|
11
|
+
* composition root fills with the file system, so this module does no I/O of
|
|
12
|
+
* its own.
|
|
13
|
+
*
|
|
14
|
+
* WHY THE STORE IS COMMITTED, unlike `.vigiles/coverage.json`. Coverage records
|
|
15
|
+
* what tests ran on THIS machine. The store records a property of the COMMIT:
|
|
16
|
+
* every number in it is built from `committedTotal` and committed settings,
|
|
17
|
+
* which leave out per-machine files, so two clones of one commit compute
|
|
18
|
+
* byte-identical files. That is what lets CI compare against it.
|
|
19
|
+
*
|
|
20
|
+
* WHO WRITES. `lint` never does on its own — every default lint path is a read.
|
|
21
|
+
* `--update-baseline` writes the store while some bundle is over a limit and
|
|
22
|
+
* deletes it once nothing is; `init` writes it once on a repository that is
|
|
23
|
+
* over a limit and has none (`recordIfMissing`).
|
|
24
|
+
*/
|
|
25
|
+
import { type RuleRun, type StoreLine, type StoreOnDisk } from "./core/baseline-store.js";
|
|
26
|
+
import { type LimitOverrides } from "./core/always-loaded-limits.js";
|
|
27
|
+
import type { AlwaysLoadedContext } from "./core/always-loaded.js";
|
|
28
|
+
import type { InstructionWeight } from "./core/instruction-weight.js";
|
|
29
|
+
import type { RuleSeverity } from "./core/types.js";
|
|
30
|
+
/**
|
|
31
|
+
* The repository's files, by path relative to the config root. The root fills
|
|
32
|
+
* it with the file system; a test can fill it with a map.
|
|
33
|
+
*/
|
|
34
|
+
export interface BaselineFiles {
|
|
35
|
+
/** The file's text, or `undefined` when it does not exist. */
|
|
36
|
+
readonly read: (path: string) => string | undefined;
|
|
37
|
+
/** Write the file, creating its folder. */
|
|
38
|
+
readonly write: (path: string, text: string) => void;
|
|
39
|
+
/** Delete the file; nothing when it does not exist. */
|
|
40
|
+
readonly remove: (path: string) => void;
|
|
41
|
+
/** Whether a directory (a bundle) exists. */
|
|
42
|
+
readonly exists: (path: string) => boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One bundle's measurement: where it is, and either nothing to weigh or its
|
|
46
|
+
* weight WITH the always-loaded context around it.
|
|
47
|
+
*/
|
|
48
|
+
export type MeasuredBundle = readonly [at: string, weight: null] | readonly [
|
|
49
|
+
at: string,
|
|
50
|
+
weight: InstructionWeight,
|
|
51
|
+
loaded: AlwaysLoadedContext
|
|
52
|
+
];
|
|
53
|
+
/** The rule's options that change what is measured against. */
|
|
54
|
+
export interface ContextCreepLimits {
|
|
55
|
+
/** Per-part limits from `.vigilesrc.json`; each one missing keeps the harness's. */
|
|
56
|
+
readonly limits?: LimitOverrides;
|
|
57
|
+
/** The opt-in absolute ceiling on the scored instructions; no baseline lifts it. */
|
|
58
|
+
readonly max?: number;
|
|
59
|
+
}
|
|
60
|
+
export declare function readBaselineStore(files: BaselineFiles): StoreOnDisk;
|
|
61
|
+
/** The old baseline files present in this repository, newest name first. */
|
|
62
|
+
export declare function legacyFilesPresent(files: BaselineFiles, ruleId: string): readonly string[];
|
|
63
|
+
/** What the stateless rule reports for the store to act on. */
|
|
64
|
+
export declare function contextCreepRun(ruleId: string, measured: readonly MeasuredBundle[], limits: ContextCreepLimits): RuleRun;
|
|
65
|
+
/** The bundles `--update-baseline` must not record: each one over the ceiling. */
|
|
66
|
+
export declare function updateRefusals(measured: readonly MeasuredBundle[], max: number | undefined): readonly string[];
|
|
67
|
+
/** The line a repository with an old baseline file gets: a finding, naming the command. */
|
|
68
|
+
export declare function legacyLine(file: string): StoreLine;
|
|
69
|
+
/** The options {@link checkContextCreep} takes. */
|
|
70
|
+
export interface ContextCreepOptions extends ContextCreepLimits {
|
|
71
|
+
readonly ruleId: string;
|
|
72
|
+
readonly files: BaselineFiles;
|
|
73
|
+
/** The scanned bundle (`.` = the whole repository); entries outside it are never touched. */
|
|
74
|
+
readonly scope: string;
|
|
75
|
+
readonly severity: RuleSeverity;
|
|
76
|
+
readonly update: boolean;
|
|
77
|
+
readonly silent: boolean;
|
|
78
|
+
/** Called only when the rule is on or an update was asked for. */
|
|
79
|
+
readonly measure: () => readonly MeasuredBundle[];
|
|
80
|
+
readonly annotate: (level: "error" | "warning" | "notice", message: string) => void;
|
|
81
|
+
}
|
|
82
|
+
/** What {@link checkContextCreep} hands back to `lint`. */
|
|
83
|
+
export interface ContextCreepResult {
|
|
84
|
+
readonly issues: number;
|
|
85
|
+
readonly errors: number;
|
|
86
|
+
/**
|
|
87
|
+
* One-line notes `--summary` prints (the session-start hook injects them):
|
|
88
|
+
* over a limit with no baseline, and an old baseline file to migrate.
|
|
89
|
+
*/
|
|
90
|
+
readonly notes: readonly string[];
|
|
91
|
+
}
|
|
92
|
+
/** Run the check for `lint`: record if asked, then print, annotate, count. */
|
|
93
|
+
export declare function checkContextCreep(opts: ContextCreepOptions): ContextCreepResult;
|
|
94
|
+
/** What `init` did about the baseline, for its summary. */
|
|
95
|
+
export type InitBaseline = {
|
|
96
|
+
readonly kind: "under-limits";
|
|
97
|
+
} | {
|
|
98
|
+
readonly kind: "kept";
|
|
99
|
+
readonly file: string;
|
|
100
|
+
} | {
|
|
101
|
+
readonly kind: "legacy";
|
|
102
|
+
readonly file: string;
|
|
103
|
+
readonly command: string;
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: "recorded";
|
|
106
|
+
readonly file: string;
|
|
107
|
+
readonly over: readonly string[];
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* `init`'s step: record every bundle over a limit that has no entry yet, so
|
|
111
|
+
* the gate starts from today's size. An existing entry is never overwritten
|
|
112
|
+
* (a rerun adds only the bundles that are missing), and nothing is measured
|
|
113
|
+
* over an old file — that is what migrating is for, and re-measuring would
|
|
114
|
+
* accept unseen growth.
|
|
115
|
+
*/
|
|
116
|
+
export declare function recordIfMissing(files: BaselineFiles, ruleId: string, measured: readonly MeasuredBundle[], limits: ContextCreepLimits): InitBaseline;
|
|
117
|
+
/**
|
|
118
|
+
* The line `compile` prints after writing instruction files: the size now,
|
|
119
|
+
* against each limit, and against the baseline when over one. Report-only —
|
|
120
|
+
* `lint` stays the single gate. `null` when there is nothing to weigh.
|
|
121
|
+
*/
|
|
122
|
+
export declare function compileWeightLine(files: BaselineFiles, ruleId: string, measured: MeasuredBundle, limits: ContextCreepLimits): string | null;
|
|
123
|
+
//# sourceMappingURL=context-creep-lint.d.ts.map
|