vigiles 39.0.0 → 39.2.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/action.yml +18 -0
- package/dist/adapters/claude-code/dialect.js +5 -0
- package/dist/audit-report.d.ts +14 -1
- package/dist/audit-report.js +21 -5
- package/dist/audit-report.template.html +33 -28
- package/dist/audit-score.d.ts +4 -1
- package/dist/audit-score.js +3 -1
- package/dist/audit-verdict.d.ts +3 -1
- package/dist/cli-flag-check.d.ts +1 -1
- package/dist/cli-flag-check.js +5 -1
- package/dist/cli-flags.d.ts +1 -1
- package/dist/cli-main.js +153 -72
- package/dist/core/CLAUDE.md.spec.js +2 -2
- package/dist/core/adopt.js +32 -8
- package/dist/core/apply-rules.d.ts +71 -0
- package/dist/core/apply-rules.js +48 -0
- package/dist/core/compile.d.ts +1 -1
- package/dist/core/compile.js +47 -14
- package/dist/core/config-migrations.d.ts +69 -0
- package/dist/core/config-migrations.js +145 -0
- package/dist/core/config-schema.d.ts +163 -187
- package/dist/core/config-schema.js +185 -345
- package/dist/core/dialect.d.ts +1 -1
- package/dist/core/dialect.js +2 -0
- package/dist/core/linter-adapter.d.ts +1 -1
- package/dist/core/presets.d.ts +31 -46
- package/dist/core/presets.js +25 -51
- package/dist/core/rule.d.ts +213 -0
- package/dist/core/rule.js +37 -0
- package/dist/core/skill-resources.d.ts +85 -15
- package/dist/core/skill-resources.js +63 -37
- package/dist/core/spec.d.ts +17 -0
- package/dist/core/types.d.ts +12 -314
- package/dist/core/validate.d.ts +13 -12
- package/dist/core/validate.js +29 -28
- package/dist/doc-commands.d.ts +2 -2
- package/dist/optimize.d.ts +2 -1
- package/dist/overrides.d.ts +13 -9
- package/dist/overrides.js +1 -1
- package/dist/rules/CLAUDE.md.spec.d.ts +3 -0
- package/dist/rules/CLAUDE.md.spec.js +22 -0
- package/dist/rules/groups.d.ts +32 -0
- package/dist/rules/groups.js +27 -0
- package/dist/rules/index.d.ts +412 -0
- package/dist/{core/rule-meta.js → rules/index.js} +301 -209
- package/dist/rules/skill-resource-resolves.d.ts +36 -0
- package/dist/rules/skill-resource-resolves.js +51 -0
- package/dist/run-hook.d.ts +1 -1
- package/dist/scan-core.d.ts +7 -9
- package/dist/scan-core.js +7 -10
- package/dist/scan-files.js +1 -4
- package/dist/scan.d.ts +11 -16
- package/dist/scan.js +31 -8
- package/dist/score-core.js +3 -9
- package/dist/setup-plan.d.ts +6 -26
- package/dist/setup-plan.js +27 -60
- package/dist/skill-harness.d.ts +3 -1
- package/dist/skill-harness.js +5 -2
- package/dist/vigilesrc.schema.json +18 -3
- package/package.json +2 -2
- package/packages/eslint-config/index.mjs +61 -0
- package/dist/core/rule-meta.d.ts +0 -94
package/dist/core/adopt.js
CHANGED
|
@@ -360,6 +360,8 @@ const SKILL_KNOWN_KEYS = new Set([
|
|
|
360
360
|
"disable-model-invocation",
|
|
361
361
|
"argument-hint",
|
|
362
362
|
"context",
|
|
363
|
+
"agent",
|
|
364
|
+
"model",
|
|
363
365
|
]);
|
|
364
366
|
const AGENT_KNOWN_KEYS = new Set([
|
|
365
367
|
"name",
|
|
@@ -407,6 +409,33 @@ function unmappedNote(kind, keys) {
|
|
|
407
409
|
}
|
|
408
410
|
const SURFACE_HEADER = (from) => `// Adopted from ${from} by \`vigiles init\` — body verbatim, standard\n` +
|
|
409
411
|
`// frontmatter mapped; no rules inferred. Review the diff, then \`compile\`.\n`;
|
|
412
|
+
/**
|
|
413
|
+
* Where a SKILL.md says it runs — `context`, `agent`, `model` — as spec fields and
|
|
414
|
+
* as the spec-source lines that write them, in compile's render order.
|
|
415
|
+
*
|
|
416
|
+
* `context: fork` is a supported skill key (a forked skill runs as a subagent);
|
|
417
|
+
* `"fork"` is the only valid value. Previously it was in SKILL_KNOWN_KEYS but
|
|
418
|
+
* never read, so an existing SKILL.md's `context: fork` was silently dropped on
|
|
419
|
+
* adopt with NO unmapped-key warning (the key was falsely marked "known"). (#107)
|
|
420
|
+
* `agent` and `model` are plain strings (#401).
|
|
421
|
+
*/
|
|
422
|
+
function adoptExecutionKeys(fm) {
|
|
423
|
+
const isFork = (0, frontmatter_read_js_1.frontmatterScalar)(fm, "context") === "fork";
|
|
424
|
+
const found = ["agent", "model"].flatMap((key) => {
|
|
425
|
+
const value = (0, frontmatter_read_js_1.frontmatterScalar)(fm, key);
|
|
426
|
+
return value ? [{ key, value }] : [];
|
|
427
|
+
});
|
|
428
|
+
return {
|
|
429
|
+
fields: {
|
|
430
|
+
...(isFork ? { context: "fork" } : {}),
|
|
431
|
+
...Object.fromEntries(found.map(({ key, value }) => [key, value])),
|
|
432
|
+
},
|
|
433
|
+
lines: [
|
|
434
|
+
...(isFork ? [` context: "fork",`] : []),
|
|
435
|
+
...found.map(({ key, value }) => ` ${key}: ${JSON.stringify(value)},`),
|
|
436
|
+
],
|
|
437
|
+
};
|
|
438
|
+
}
|
|
410
439
|
/**
|
|
411
440
|
* Adopt an existing SKILL.md into an `experimental_skill()` spec. The body is carried verbatim
|
|
412
441
|
* (skills are freeform markdown — `##` headings stay in the body), so a clean
|
|
@@ -423,11 +452,7 @@ function adoptSkill(markdown, dirName) {
|
|
|
423
452
|
const tools = (0, frontmatter_read_js_1.frontmatterList)(fm, "allowed-tools") ?? (0, frontmatter_read_js_1.frontmatterList)(fm, "tools");
|
|
424
453
|
const argumentHint = (0, frontmatter_read_js_1.frontmatterScalar)(fm, "argument-hint");
|
|
425
454
|
const disableModelInvocation = (0, frontmatter_read_js_1.frontmatterScalar)(fm, "disable-model-invocation") === "true";
|
|
426
|
-
|
|
427
|
-
// `"fork"` is the only valid value. Previously it was in SKILL_KNOWN_KEYS but
|
|
428
|
-
// never read, so an existing SKILL.md's `context: fork` was silently dropped on
|
|
429
|
-
// adopt with NO unmapped-key warning (the key was falsely marked "known"). (#107)
|
|
430
|
-
const isFork = (0, frontmatter_read_js_1.frontmatterScalar)(fm, "context") === "fork";
|
|
455
|
+
const execution = adoptExecutionKeys(fm);
|
|
431
456
|
const unmappedKeys = unmappedFrontmatterKeys(fm, SKILL_KNOWN_KEYS);
|
|
432
457
|
const lines = [
|
|
433
458
|
` name: ${JSON.stringify(name)},`,
|
|
@@ -435,8 +460,7 @@ function adoptSkill(markdown, dirName) {
|
|
|
435
460
|
];
|
|
436
461
|
if (argumentHint)
|
|
437
462
|
lines.push(` argumentHint: ${JSON.stringify(argumentHint)},`);
|
|
438
|
-
|
|
439
|
-
lines.push(` context: "fork",`);
|
|
463
|
+
lines.push(...execution.lines);
|
|
440
464
|
if (disableModelInvocation)
|
|
441
465
|
lines.push(` disableModelInvocation: true,`);
|
|
442
466
|
if (tools && tools.length > 0)
|
|
@@ -448,7 +472,7 @@ function adoptSkill(markdown, dirName) {
|
|
|
448
472
|
name,
|
|
449
473
|
description,
|
|
450
474
|
...(argumentHint ? { argumentHint } : {}),
|
|
451
|
-
...
|
|
475
|
+
...execution.fields,
|
|
452
476
|
...(disableModelInvocation ? { disableModelInvocation: true } : {}),
|
|
453
477
|
...(tools && tools.length > 0 ? { tools } : {}),
|
|
454
478
|
...(trimmedBody ? { body: trimmedBody } : {}),
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ONE ANSWER TO "IS THIS RULE ON?" FOR EVERYTHING A REPORT SHOWS.
|
|
3
|
+
*
|
|
4
|
+
* `lint` asked the resolver per rule; `audit` did not ask at all, so a rule the
|
|
5
|
+
* repo turned off still printed in the audit (`hand-written-hook`, off by
|
|
6
|
+
* default, listed every hook line vigiles did not write). `applyRules` is the
|
|
7
|
+
* one place a scan meets the resolved config: it blanks what an OFF rule found
|
|
8
|
+
* and mints the {@link FilteredScan} brand that every renderer takes — so a
|
|
9
|
+
* renderer handed a raw scan is a tsc error, not an off rule on screen.
|
|
10
|
+
*
|
|
11
|
+
* Generic machinery: it takes the rule set, the groups and the resolver as
|
|
12
|
+
* parameters (`src/rules/` and `../overrides.ts` stay outside core) and names no
|
|
13
|
+
* rule and no group. Which scan field a not-yet-migrated rule's findings sit in
|
|
14
|
+
* is that rule's own declaration (`RuleSpec.legacy.scanField`); a migrated
|
|
15
|
+
* rule's findings come from its own `findings`.
|
|
16
|
+
*
|
|
17
|
+
* UNGRADED GROUPS. A rule in a group with `graded: false` is shown and never
|
|
18
|
+
* scored: its findings go to `ungraded`, one block per group, headed by the
|
|
19
|
+
* group's own `label`/`blurb`. A scorer takes a {@link GradedView}, which has no
|
|
20
|
+
* `ungraded` — so handing one the filtered scan is a tsc error, not a coin
|
|
21
|
+
* flip moving the grade. (A migrated rule in a GRADED group would need its
|
|
22
|
+
* findings to reach the scorers; none exists yet, and `src/rules/index.test.ts`
|
|
23
|
+
* fails the day one does, until vigiles#390 wires it.)
|
|
24
|
+
*
|
|
25
|
+
* ⚠️ SCOPE, stated: only fields that are SHOWN and never scored are blanked
|
|
26
|
+
* today. Blanking a graded field when its rule is off would change a repo's
|
|
27
|
+
* audit score — a product decision, not a refactor — so a rule whose findings
|
|
28
|
+
* feed a ring declares no `scanField` yet.
|
|
29
|
+
*/
|
|
30
|
+
import type { Finding, RuleGroups, RuleSpec, ScanInput } from "./rule.js";
|
|
31
|
+
/** The part of a rule resolver this needs: whether a rule can fire anywhere. */
|
|
32
|
+
export interface RuleSwitch {
|
|
33
|
+
mayFire(rule: string): boolean;
|
|
34
|
+
}
|
|
35
|
+
/** The brand's key — module-private, so only this file can mint the brand. */
|
|
36
|
+
declare const FILTERED: unique symbol;
|
|
37
|
+
/** One rule that is on, and everything it found (possibly nothing). */
|
|
38
|
+
export interface RuleResult {
|
|
39
|
+
readonly rule: string;
|
|
40
|
+
readonly findings: readonly Finding[];
|
|
41
|
+
}
|
|
42
|
+
/** An ungraded group's block: its label and the rules of it that are on. */
|
|
43
|
+
export interface UngradedGroup {
|
|
44
|
+
readonly group: string;
|
|
45
|
+
readonly label: string;
|
|
46
|
+
readonly blurb?: string;
|
|
47
|
+
readonly rules: readonly RuleResult[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A scan with the resolved config applied. Minted ONLY by {@link applyRules}
|
|
51
|
+
* (`local/frame-mint` refuses an `as FilteredScan` anywhere else).
|
|
52
|
+
*/
|
|
53
|
+
export type FilteredScan<S extends object> = S & {
|
|
54
|
+
readonly [FILTERED]: true;
|
|
55
|
+
/** Only a renderer reads this (`no-restricted-syntax` in the scorers). */
|
|
56
|
+
readonly ungraded: readonly UngradedGroup[];
|
|
57
|
+
};
|
|
58
|
+
/** What a scorer takes: a scan that carries no ungraded findings. */
|
|
59
|
+
export type GradedView<S extends object> = S & {
|
|
60
|
+
readonly ungraded?: never;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Apply the resolved config to a scan: every rule that cannot fire anywhere
|
|
64
|
+
* has the scan field it declares emptied, and the ungraded groups' rules that
|
|
65
|
+
* are on report into `ungraded`. Pure; the scan is not mutated.
|
|
66
|
+
*/
|
|
67
|
+
export declare function applyRules<S extends ScanInput>(rules: readonly RuleSpec[], groups: RuleGroups, resolver: RuleSwitch, scan: S): FilteredScan<S>;
|
|
68
|
+
/** The scan a scorer may read: `ungraded` dropped, everything else as is. */
|
|
69
|
+
export declare function gradedView<S extends ScanInput>(scan: FilteredScan<S>): GradedView<Omit<FilteredScan<S>, "ungraded">>;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=apply-rules.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyRules = applyRules;
|
|
4
|
+
exports.gradedView = gradedView;
|
|
5
|
+
/** The brand's key — module-private, so only this file can mint the brand. */
|
|
6
|
+
const FILTERED = Symbol("filtered-scan");
|
|
7
|
+
/** `scan` with `field` emptied, when that field is a list. */
|
|
8
|
+
function blank(scan, field) {
|
|
9
|
+
return Array.isArray(Reflect.get(scan, field))
|
|
10
|
+
? { ...scan, [field]: [] }
|
|
11
|
+
: scan;
|
|
12
|
+
}
|
|
13
|
+
/** The ungraded groups' blocks: each group that has a rule on, in order. */
|
|
14
|
+
function ungradedOf(rules, groups, scan) {
|
|
15
|
+
return Object.entries(groups)
|
|
16
|
+
.filter(([, g]) => !g.graded)
|
|
17
|
+
.map(([group, g]) => ({
|
|
18
|
+
group,
|
|
19
|
+
label: g.label,
|
|
20
|
+
...(g.blurb === undefined ? {} : { blurb: g.blurb }),
|
|
21
|
+
rules: rules
|
|
22
|
+
.filter((r) => r.group === group)
|
|
23
|
+
.map((r) => ({ rule: r.id, findings: r.findings?.(scan) ?? [] })),
|
|
24
|
+
}))
|
|
25
|
+
.filter((g) => g.rules.length > 0);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Apply the resolved config to a scan: every rule that cannot fire anywhere
|
|
29
|
+
* has the scan field it declares emptied, and the ungraded groups' rules that
|
|
30
|
+
* are on report into `ungraded`. Pure; the scan is not mutated.
|
|
31
|
+
*/
|
|
32
|
+
function applyRules(rules, groups, resolver, scan) {
|
|
33
|
+
const on = rules.filter((r) => resolver.mayFire(r.id));
|
|
34
|
+
const blanked = rules
|
|
35
|
+
.filter((r) => !on.includes(r))
|
|
36
|
+
.reduce((acc, r) => (r.legacy ? blank(acc, r.legacy.scanField) : acc), scan);
|
|
37
|
+
return {
|
|
38
|
+
...blanked,
|
|
39
|
+
ungraded: ungradedOf(on, groups, scan),
|
|
40
|
+
[FILTERED]: true,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** The scan a scorer may read: `ungraded` dropped, everything else as is. */
|
|
44
|
+
function gradedView(scan) {
|
|
45
|
+
const { ungraded: _shown, ...graded } = scan;
|
|
46
|
+
return graded;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=apply-rules.js.map
|
package/dist/core/compile.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare function verifyHash(content: string): {
|
|
|
56
56
|
*/
|
|
57
57
|
/** @internal */ export declare function estimateTokens(text: string): number;
|
|
58
58
|
export interface CompileError {
|
|
59
|
-
type: "stale-file" | "stale-command" | "stale-ref" | "invalid-rule" | "budget-exceeded" | "section-too-long" | "section-has-header" | "reserved-section-key" | "spec-name-mismatch" | "unknown-tool" | "invalid-railway" | "purity-violation" | "output-without-fork" | "effect-in-skill" | "inline-code-too-long" | "entry-too-long" | "section-too-large" | "rules-too-large";
|
|
59
|
+
type: "stale-file" | "stale-command" | "stale-ref" | "invalid-rule" | "budget-exceeded" | "section-too-long" | "section-has-header" | "reserved-section-key" | "spec-name-mismatch" | "unknown-tool" | "invalid-railway" | "purity-violation" | "output-without-fork" | "agent-without-fork" | "effect-in-skill" | "inline-code-too-long" | "entry-too-long" | "section-too-large" | "rules-too-large";
|
|
60
60
|
message: string;
|
|
61
61
|
path?: string;
|
|
62
62
|
}
|
package/dist/core/compile.js
CHANGED
|
@@ -1062,6 +1062,19 @@ function yamlScalar(value) {
|
|
|
1062
1062
|
* exactly what a key set says. A harness that reads four of the seven now gets
|
|
1063
1063
|
* four, instead of falling into whichever of two buckets someone picked for it.
|
|
1064
1064
|
*/
|
|
1065
|
+
/**
|
|
1066
|
+
* The frontmatter lines that say WHERE a skill runs, in render order: `context`,
|
|
1067
|
+
* then the subagent type and the model a fork starts (`agent`, `model`, #401).
|
|
1068
|
+
* Only keys the dialect reads (`emits`) and the spec sets.
|
|
1069
|
+
*/
|
|
1070
|
+
function executionFrontmatter(spec, emits) {
|
|
1071
|
+
const set = [
|
|
1072
|
+
["context", spec.context],
|
|
1073
|
+
["agent", spec.agent === undefined ? undefined : yamlScalar(spec.agent)],
|
|
1074
|
+
["model", spec.model === undefined ? undefined : yamlScalar(spec.model)],
|
|
1075
|
+
];
|
|
1076
|
+
return set.flatMap(([key, value]) => emits(key) && value !== undefined ? [`${key}: ${value}`] : []);
|
|
1077
|
+
}
|
|
1065
1078
|
function renderSkillFrontmatter(spec, keys = dialect_js_1.RENDERABLE_SKILL_FRONTMATTER_KEYS) {
|
|
1066
1079
|
const emits = (key) => keys.includes(key);
|
|
1067
1080
|
const fm = ["---"];
|
|
@@ -1074,9 +1087,7 @@ function renderSkillFrontmatter(spec, keys = dialect_js_1.RENDERABLE_SKILL_FRONT
|
|
|
1074
1087
|
spec.disableModelInvocation !== undefined) {
|
|
1075
1088
|
fm.push(`disable-model-invocation: ${String(spec.disableModelInvocation)}`);
|
|
1076
1089
|
}
|
|
1077
|
-
|
|
1078
|
-
fm.push(`context: ${spec.context}`);
|
|
1079
|
-
}
|
|
1090
|
+
fm.push(...executionFrontmatter(spec, emits));
|
|
1080
1091
|
const argHint = spec.inputs && spec.inputs.length > 0
|
|
1081
1092
|
? renderArgumentHint(spec.inputs)
|
|
1082
1093
|
: spec.argumentHint;
|
|
@@ -1164,6 +1175,38 @@ function checkInlineCode(markdown, max) {
|
|
|
1164
1175
|
}
|
|
1165
1176
|
return warns;
|
|
1166
1177
|
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Fields that mean something only for a FORKED skill, reported when the skill is
|
|
1180
|
+
* inline. `output`: an inline skill has no call→return boundary, so a typed
|
|
1181
|
+
* outcome there is a category error (see research/spec-syntax-and-railway-scope.md).
|
|
1182
|
+
* `agent`: the subagent type a fork starts — inline, no subagent starts (#401).
|
|
1183
|
+
* `model` is NOT here: inline it sets the turn's model, which is a real meaning.
|
|
1184
|
+
*/
|
|
1185
|
+
function forkOnlyErrors(spec) {
|
|
1186
|
+
if (spec.context === "fork")
|
|
1187
|
+
return [];
|
|
1188
|
+
const output = spec.output
|
|
1189
|
+
? [
|
|
1190
|
+
{
|
|
1191
|
+
type: "output-without-fork",
|
|
1192
|
+
message: 'A skill `output` (result() contract) requires `context: "fork"` — an ' +
|
|
1193
|
+
"inline skill has no return value to type. Add context:'fork' to run it " +
|
|
1194
|
+
"as a subagent, or drop `output`.",
|
|
1195
|
+
},
|
|
1196
|
+
]
|
|
1197
|
+
: [];
|
|
1198
|
+
const agent = spec.agent === undefined
|
|
1199
|
+
? []
|
|
1200
|
+
: [
|
|
1201
|
+
{
|
|
1202
|
+
type: "agent-without-fork",
|
|
1203
|
+
message: `A skill \`agent\` ("${spec.agent}") requires \`context: "fork"\` — it ` +
|
|
1204
|
+
"names the subagent a forked skill starts, and an inline skill starts " +
|
|
1205
|
+
"none. Add context:'fork', or drop `agent`.",
|
|
1206
|
+
},
|
|
1207
|
+
];
|
|
1208
|
+
return [...output, ...agent];
|
|
1209
|
+
}
|
|
1167
1210
|
/**
|
|
1168
1211
|
* Compile a SkillSpec into SKILL.md markdown with YAML frontmatter.
|
|
1169
1212
|
*/
|
|
@@ -1197,17 +1240,7 @@ async function compileSkill(spec, options) {
|
|
|
1197
1240
|
}
|
|
1198
1241
|
}
|
|
1199
1242
|
errors.push(...(await validateRefs(collectSkillRefs(spec), basePath)));
|
|
1200
|
-
|
|
1201
|
-
// skill has no call→return boundary, so a typed outcome there is a category
|
|
1202
|
-
// error (see research/spec-syntax-and-railway-scope.md). Enforce it at compile.
|
|
1203
|
-
if (spec.output && spec.context !== "fork") {
|
|
1204
|
-
errors.push({
|
|
1205
|
-
type: "output-without-fork",
|
|
1206
|
-
message: 'A skill `output` (result() contract) requires `context: "fork"` — an ' +
|
|
1207
|
-
"inline skill has no return value to type. Add context:'fork' to run it " +
|
|
1208
|
-
"as a subagent, or drop `output`.",
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1243
|
+
errors.push(...forkOnlyErrors(spec));
|
|
1211
1244
|
// effect() is a SUBAGENT primitive. A deterministic effect REGION needs a
|
|
1212
1245
|
// structural call→return bracket to scope it; a default skill is spliced into
|
|
1213
1246
|
// the main conversation and has none (the dogfood that proved the model-emitted
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The configs that USED TO WORK — keys and rules whose shape changed, and the
|
|
3
|
+
* sentence each one gets instead of the schema's "unknown key".
|
|
4
|
+
*
|
|
5
|
+
* Read BEFORE the schema (`./validate.ts` `loadConfig`): the reader of these
|
|
6
|
+
* messages is someone whose config was valid in an earlier release, so
|
|
7
|
+
* `.strict()`'s "Unrecognized key" would be true and useless — they need the
|
|
8
|
+
* new spelling. Kept apart from `./config-schema.ts`, which describes the
|
|
9
|
+
* config as it is today; this file describes how it got here.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The two keys `harnesses` replaced, and the sentence each one gets (#240).
|
|
13
|
+
*
|
|
14
|
+
* They are listed here rather than left to `.strict()`'s "Unrecognized key"
|
|
15
|
+
* because the reader of that message is someone whose config USED to work: they
|
|
16
|
+
* need the new spelling, not the news that the old one is unknown. `.strict()`
|
|
17
|
+
* would tell them the truth in the least useful possible way.
|
|
18
|
+
*/
|
|
19
|
+
export declare const REPLACED_KEYS: ReadonlyArray<{
|
|
20
|
+
readonly key: string;
|
|
21
|
+
readonly was: string;
|
|
22
|
+
readonly now: string;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* The message a config written in the replaced shape gets.
|
|
26
|
+
*
|
|
27
|
+
* `names` are the harnesses the user's OWN config named under the removed
|
|
28
|
+
* `harness` key, so the worked example below shows THEIR migration.
|
|
29
|
+
*
|
|
30
|
+
* 🔴 IT USED TO BE A FIXED EXAMPLE — `{ "harnesses": { "claude-code": …,
|
|
31
|
+
* "codex": {} } }`, two names typed into the core. Its own comment called that
|
|
32
|
+
* debt and predicted the failure: "with a third adapter this sample goes
|
|
33
|
+
* stale". Reading the names from the config being migrated is better than
|
|
34
|
+
* reading them from the registry would have been, and it is available here:
|
|
35
|
+
* it shows the reader their own keys instead of somebody else's.
|
|
36
|
+
*/
|
|
37
|
+
export declare function replacedKeyMessage(present: ReadonlyArray<(typeof REPLACED_KEYS)[number]>, names: readonly string[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* The per-rule `exclude` options that became `overrides`, and the rules an
|
|
40
|
+
* equivalent override turns off. `untested-*` shared ONE merged option set, so
|
|
41
|
+
* an `exclude` on any of them skipped those paths for all four.
|
|
42
|
+
*/
|
|
43
|
+
export declare const MOVED_TO_OVERRIDES: ReadonlyArray<{
|
|
44
|
+
/** Where the option sat: a rule name, or the `orphans` block. */
|
|
45
|
+
readonly owner: string;
|
|
46
|
+
/** The rules the equivalent override turns off. */
|
|
47
|
+
readonly rules: readonly string[];
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* The message an old config with a per-rule `exclude` gets — the user's OWN
|
|
51
|
+
* globs, written as the `overrides` entry that does what the option did.
|
|
52
|
+
*
|
|
53
|
+
* Read BEFORE the schema, like {@link REPLACED_KEYS}: the reader's config used
|
|
54
|
+
* to work, so "unknown key exclude" would be true and useless.
|
|
55
|
+
*/
|
|
56
|
+
export declare function movedToOverridesMessages(raw: unknown): readonly string[];
|
|
57
|
+
/** Rules whose findings another rule now reports, and what changed. */
|
|
58
|
+
export declare const FOLDED_RULES: ReadonlyArray<{
|
|
59
|
+
readonly rule: string;
|
|
60
|
+
readonly into: string;
|
|
61
|
+
readonly what: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* The message a config naming a folded rule gets — in `rules` or in an
|
|
65
|
+
* `overrides` entry. Read BEFORE the schema, like {@link REPLACED_KEYS}: the
|
|
66
|
+
* reader's config used to work, so "unknown key" would be true and useless.
|
|
67
|
+
*/
|
|
68
|
+
export declare function foldedRuleMessages(raw: unknown): readonly string[];
|
|
69
|
+
//# sourceMappingURL=config-migrations.d.ts.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The configs that USED TO WORK — keys and rules whose shape changed, and the
|
|
4
|
+
* sentence each one gets instead of the schema's "unknown key".
|
|
5
|
+
*
|
|
6
|
+
* Read BEFORE the schema (`./validate.ts` `loadConfig`): the reader of these
|
|
7
|
+
* messages is someone whose config was valid in an earlier release, so
|
|
8
|
+
* `.strict()`'s "Unrecognized key" would be true and useless — they need the
|
|
9
|
+
* new spelling. Kept apart from `./config-schema.ts`, which describes the
|
|
10
|
+
* config as it is today; this file describes how it got here.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.FOLDED_RULES = exports.MOVED_TO_OVERRIDES = exports.REPLACED_KEYS = void 0;
|
|
14
|
+
exports.replacedKeyMessage = replacedKeyMessage;
|
|
15
|
+
exports.movedToOverridesMessages = movedToOverridesMessages;
|
|
16
|
+
exports.foldedRuleMessages = foldedRuleMessages;
|
|
17
|
+
/**
|
|
18
|
+
* The two keys `harnesses` replaced, and the sentence each one gets (#240).
|
|
19
|
+
*
|
|
20
|
+
* They are listed here rather than left to `.strict()`'s "Unrecognized key"
|
|
21
|
+
* because the reader of that message is someone whose config USED to work: they
|
|
22
|
+
* need the new spelling, not the news that the old one is unknown. `.strict()`
|
|
23
|
+
* would tell them the truth in the least useful possible way.
|
|
24
|
+
*/
|
|
25
|
+
exports.REPLACED_KEYS = [
|
|
26
|
+
{
|
|
27
|
+
key: "harness",
|
|
28
|
+
// The literal OLD config text this migration notice quotes back at the user:
|
|
29
|
+
// a historical artefact, not a fact about a harness, so there is no port to
|
|
30
|
+
// read it off. This is the one exemption here that is not debt.
|
|
31
|
+
// eslint-disable-next-line local/no-harness-names -- quoted legacy config
|
|
32
|
+
was: '"harness": ["claude-code", "codex"]',
|
|
33
|
+
now: "a KEY per harness",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: "surfaceRoots",
|
|
37
|
+
was: '"surfaceRoots": [".ai"]',
|
|
38
|
+
now: '"roots" INSIDE the harness that reads them',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* The message a config written in the replaced shape gets.
|
|
43
|
+
*
|
|
44
|
+
* `names` are the harnesses the user's OWN config named under the removed
|
|
45
|
+
* `harness` key, so the worked example below shows THEIR migration.
|
|
46
|
+
*
|
|
47
|
+
* 🔴 IT USED TO BE A FIXED EXAMPLE — `{ "harnesses": { "claude-code": …,
|
|
48
|
+
* "codex": {} } }`, two names typed into the core. Its own comment called that
|
|
49
|
+
* debt and predicted the failure: "with a third adapter this sample goes
|
|
50
|
+
* stale". Reading the names from the config being migrated is better than
|
|
51
|
+
* reading them from the registry would have been, and it is available here:
|
|
52
|
+
* it shows the reader their own keys instead of somebody else's.
|
|
53
|
+
*/
|
|
54
|
+
function replacedKeyMessage(present, names) {
|
|
55
|
+
// Empty when the config used only `surfaceRoots`, or named no harness — a
|
|
56
|
+
// placeholder the reader will obviously replace, never an invented name.
|
|
57
|
+
const example = (names.length > 0 ? names : ["<harness>"])
|
|
58
|
+
.map((n, i) => `"${n}": ${i === 0 ? '{ "roots": [".ai"] }' : "{}"}`)
|
|
59
|
+
.join(", ");
|
|
60
|
+
return (`.vigilesrc.json: ${present.map((k) => `"${k.key}"`).join(" and ")} ` +
|
|
61
|
+
`${present.length === 1 ? "was" : "were"} replaced by one nested key, "harnesses".\n` +
|
|
62
|
+
` Write: { "harnesses": { ${example} } }\n` +
|
|
63
|
+
present.map((k) => ` - ${k.was} → ${k.now}`).join("\n") +
|
|
64
|
+
`\n The old harness ARRAY's order silently decided what got read: one order graded the ` +
|
|
65
|
+
`skills and read no instruction file, the other read the instruction file and found no ` +
|
|
66
|
+
`skills. Scoping each root under the harness that reads it removes the order.`);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The per-rule `exclude` options that became `overrides`, and the rules an
|
|
70
|
+
* equivalent override turns off. `untested-*` shared ONE merged option set, so
|
|
71
|
+
* an `exclude` on any of them skipped those paths for all four.
|
|
72
|
+
*/
|
|
73
|
+
exports.MOVED_TO_OVERRIDES = [
|
|
74
|
+
...[
|
|
75
|
+
"untested-skill",
|
|
76
|
+
"untested-subagent",
|
|
77
|
+
"untested-hook",
|
|
78
|
+
"untested-output-style",
|
|
79
|
+
].map((owner, _i, all) => ({ owner, rules: all })),
|
|
80
|
+
{ owner: "orphans", rules: ["orphan-docs"] },
|
|
81
|
+
];
|
|
82
|
+
/** A plain JSON object, narrowed without a cast. */
|
|
83
|
+
function isRecord(v) {
|
|
84
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
85
|
+
}
|
|
86
|
+
/** The `exclude` an old config wrote under `owner`, as a glob list, if any. */
|
|
87
|
+
function movedExclude(raw, owner) {
|
|
88
|
+
if (!isRecord(raw))
|
|
89
|
+
return null;
|
|
90
|
+
const value = isRecord(raw.rules) ? raw.rules[owner] : undefined;
|
|
91
|
+
const tuple = Array.isArray(value) ? value : [];
|
|
92
|
+
const holder = owner === "orphans" ? raw.orphans : tuple[1];
|
|
93
|
+
if (!isRecord(holder) || holder.exclude === undefined)
|
|
94
|
+
return null;
|
|
95
|
+
const globs = [holder.exclude].flat();
|
|
96
|
+
return globs.filter((g) => typeof g === "string");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The message an old config with a per-rule `exclude` gets — the user's OWN
|
|
100
|
+
* globs, written as the `overrides` entry that does what the option did.
|
|
101
|
+
*
|
|
102
|
+
* Read BEFORE the schema, like {@link REPLACED_KEYS}: the reader's config used
|
|
103
|
+
* to work, so "unknown key exclude" would be true and useless.
|
|
104
|
+
*/
|
|
105
|
+
function movedToOverridesMessages(raw) {
|
|
106
|
+
return exports.MOVED_TO_OVERRIDES.flatMap(({ owner, rules }) => {
|
|
107
|
+
const globs = movedExclude(raw, owner);
|
|
108
|
+
if (globs === null)
|
|
109
|
+
return [];
|
|
110
|
+
const files = globs.map((g) => JSON.stringify(g)).join(", ");
|
|
111
|
+
const off = rules.map((r) => `"${r}": "off"`).join(", ");
|
|
112
|
+
return [
|
|
113
|
+
`.vigilesrc.json: "exclude" inside "${owner}" moved to "overrides" — skipping paths is not a rule option any more; an override turns the rule off for them.\n` +
|
|
114
|
+
` Write: "overrides": [{ "files": [${files}], "rules": { ${off} } }]\n` +
|
|
115
|
+
` and remove "exclude" from "${owner}". Paths top-level "exclude" removes are not read at all; an override only changes what a rule reports.`,
|
|
116
|
+
];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** Rules whose findings another rule now reports, and what changed. */
|
|
120
|
+
exports.FOLDED_RULES = [
|
|
121
|
+
{
|
|
122
|
+
rule: "prefer-compiled-hooks",
|
|
123
|
+
into: "hand-written-hook",
|
|
124
|
+
what: "every hook line vigiles did not write is now one hand-written-hook finding that names it",
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
/**
|
|
128
|
+
* The message a config naming a folded rule gets — in `rules` or in an
|
|
129
|
+
* `overrides` entry. Read BEFORE the schema, like {@link REPLACED_KEYS}: the
|
|
130
|
+
* reader's config used to work, so "unknown key" would be true and useless.
|
|
131
|
+
*/
|
|
132
|
+
function foldedRuleMessages(raw) {
|
|
133
|
+
if (!isRecord(raw))
|
|
134
|
+
return [];
|
|
135
|
+
const overrides = Array.isArray(raw.overrides)
|
|
136
|
+
? raw.overrides
|
|
137
|
+
: [];
|
|
138
|
+
const ruleBlocks = [
|
|
139
|
+
raw.rules,
|
|
140
|
+
...overrides.map((o) => (isRecord(o) ? o.rules : undefined)),
|
|
141
|
+
];
|
|
142
|
+
return exports.FOLDED_RULES.filter(({ rule }) => ruleBlocks.some((b) => isRecord(b) && rule in b)).map(({ rule, into, what }) => `.vigilesrc.json: rule "${rule}" was folded into "${into}": ${what}.\n` +
|
|
143
|
+
` Remove "${rule}"; set "${into}" to change how those findings report.`);
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=config-migrations.js.map
|