mandrel 2.86.0 → 2.87.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/.agents/docs/configuration.md +32 -12
- package/.agents/schemas/agentrc.schema.json +7 -7
- package/.agents/scripts/coverage-capture.js +23 -3
- package/.agents/scripts/lib/baselines/bundle-size-scorer.js +115 -0
- package/.agents/scripts/lib/baselines/coverage-updater-cli.js +129 -28
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +31 -10
- package/.agents/scripts/lib/baselines/duplication-scanner.js +25 -1
- package/.agents/scripts/lib/baselines/refresh-service.js +55 -19
- package/.agents/scripts/lib/config/gates/coverage.schema.js +1 -1
- package/.agents/scripts/lib/config/gates/shared.js +1 -1
- package/.agents/scripts/lib/config/quality.js +6 -2
- package/.agents/scripts/lib/coverage-baseline.js +7 -6
- package/.agents/scripts/lib/coverage-capture.js +44 -0
- package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
- package/.agents/scripts/lib/observability/source-classifier.js +1 -0
- package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +29 -2
- package/.agents/scripts/update-bundle-size-baseline.js +56 -0
- package/.agents/scripts/update-coverage-baseline.js +16 -41
- package/.agents/scripts/update-duplication-baseline.js +13 -3
- package/docs/CHANGELOG.md +7 -0
- package/package.json +7 -1
|
@@ -84,6 +84,7 @@ const FRAMEWORK_SCRIPT_BASENAMES = Object.freeze([
|
|
|
84
84
|
'sync-codex-agents.js',
|
|
85
85
|
'sync-codex-skills.js',
|
|
86
86
|
'test-wrapper.js',
|
|
87
|
+
'update-bundle-size-baseline.js',
|
|
87
88
|
'update-coverage-baseline.js',
|
|
88
89
|
'update-crap-baseline.js',
|
|
89
90
|
'update-duplication-baseline.js',
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @module lib/orchestration/check-baselines/phases/evaluate
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { groupRows, resolveComponents } from '../../../baselines/components.js';
|
|
8
9
|
import {
|
|
9
10
|
checkBaselineSemantics,
|
|
10
11
|
checkKernelVersion,
|
|
@@ -25,7 +26,7 @@ import { applyRefreshAcknowledgment } from './refresh-ack.js';
|
|
|
25
26
|
* @param {{ kind: string, baseline: { rows?: object[] }, ignoreGlobs?: string[], cwd?: string }} args
|
|
26
27
|
* @returns {object}
|
|
27
28
|
*/
|
|
28
|
-
function floorRollupOf({ kind, baseline, ignoreGlobs, cwd }) {
|
|
29
|
+
function floorRollupOf({ kind, baseline, ignoreGlobs, components, cwd }) {
|
|
29
30
|
const mod = getKindModule(kind);
|
|
30
31
|
const rows = Array.isArray(baseline?.rows) ? baseline.rows : [];
|
|
31
32
|
const filterIgnored =
|
|
@@ -38,7 +39,32 @@ function floorRollupOf({ kind, baseline, ignoreGlobs, cwd }) {
|
|
|
38
39
|
return typeof p !== 'string' || !isIgnoredByGlobs(p, ignoreGlobs, cwd);
|
|
39
40
|
})
|
|
40
41
|
: rows;
|
|
41
|
-
return mod
|
|
42
|
+
return withComponentRollups(mod, kept, components);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `*` stays the kind's own whole-repo rollup; each configured component adds
|
|
47
|
+
* the same aggregate over the rows its globs match, keyed on the kind's
|
|
48
|
+
* `keyField`. A component matching no rows is omitted — there is nothing to
|
|
49
|
+
* hold to a floor.
|
|
50
|
+
*
|
|
51
|
+
* @param {{ keyField: string, rollup: (rows: object[]) => Record<string, object> }} mod
|
|
52
|
+
* @param {object[]} rows
|
|
53
|
+
* @param {Record<string, string[]> | undefined} components
|
|
54
|
+
* @returns {Record<string, object>}
|
|
55
|
+
*/
|
|
56
|
+
function withComponentRollups(mod, rows, components) {
|
|
57
|
+
const out = mod.rollup(rows);
|
|
58
|
+
const buckets = groupRows(
|
|
59
|
+
rows,
|
|
60
|
+
resolveComponents({ components }),
|
|
61
|
+
mod.keyField,
|
|
62
|
+
);
|
|
63
|
+
for (const [name, matched] of Object.entries(buckets)) {
|
|
64
|
+
if (name === '*' || matched.length === 0) continue;
|
|
65
|
+
out[name] = mod.rollup(matched)['*'];
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
42
68
|
}
|
|
43
69
|
|
|
44
70
|
function loadHeadBaseline(kind, cwd, configPath) {
|
|
@@ -111,6 +137,7 @@ export async function evaluateKind({
|
|
|
111
137
|
kind,
|
|
112
138
|
baseline,
|
|
113
139
|
ignoreGlobs: gateBlock.ignoreGlobs,
|
|
140
|
+
components: gateBlock.components,
|
|
114
141
|
cwd,
|
|
115
142
|
});
|
|
116
143
|
const findings = applyFloors(kind, floorRollup, gateBlock.floors ?? {});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Refresh the bundle-size baseline via `refreshBaseline({ kind:
|
|
4
|
+
* 'bundle-size' })`: weigh every `gates['bundle-size'].bundles[]` artifact
|
|
5
|
+
* already on disk. Scope is always full — bundle names are not paths, so no
|
|
6
|
+
* diff can narrow it. Never builds the project.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Must be the first import: fails fast before any third-party import loads.
|
|
10
|
+
import './lib/runtime-deps/ensure-installed.js';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { refreshBaseline } from './lib/baselines/refresh-service.js';
|
|
13
|
+
import { runAsCli } from './lib/cli-utils.js';
|
|
14
|
+
import { getBaselineEpsilon } from './lib/config/quality.js';
|
|
15
|
+
import { getQuality, resolveConfig } from './lib/config-resolver.js';
|
|
16
|
+
import { Logger } from './lib/Logger.js';
|
|
17
|
+
|
|
18
|
+
const DEFAULT_BASELINE_PATH = 'baselines/bundle-size.json';
|
|
19
|
+
|
|
20
|
+
/** `runAsCli` answers `--help` before `main`, so a usage probe never writes. */
|
|
21
|
+
const USAGE = {
|
|
22
|
+
invocation: 'node .agents/scripts/update-bundle-size-baseline.js',
|
|
23
|
+
summary:
|
|
24
|
+
'Weigh → write the bundle-size baseline: one row per `delivery.quality.gates.bundle-size.bundles[]` entry, with the raw and gzipped KB of every file its `path` glob matches. Always a full refresh.',
|
|
25
|
+
notes: [
|
|
26
|
+
'Build the project first — this script never builds, and a declared bundle that matches no file fails the refresh rather than recording 0 KB.',
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
async function main() {
|
|
31
|
+
const cwd = process.cwd();
|
|
32
|
+
const gate = getQuality(resolveConfig({ cwd })).gates?.['bundle-size'] ?? {};
|
|
33
|
+
const baselinePath = gate.baselinePath ?? DEFAULT_BASELINE_PATH;
|
|
34
|
+
const writePath = path.resolve(cwd, baselinePath);
|
|
35
|
+
|
|
36
|
+
Logger.info('[BundleSize] Updating baseline...');
|
|
37
|
+
const result = await refreshBaseline({
|
|
38
|
+
kind: 'bundle-size',
|
|
39
|
+
cwd,
|
|
40
|
+
fullScope: true,
|
|
41
|
+
writePath,
|
|
42
|
+
epsilon: getBaselineEpsilon('bundle-size'),
|
|
43
|
+
});
|
|
44
|
+
Logger.info(
|
|
45
|
+
`[BundleSize] ✅ Baseline updated: ${result.envelope.rows.length} bundle(s) recorded at ${baselinePath}, wrote=${result.wrote}.`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
runAsCli(import.meta.url, main, {
|
|
50
|
+
source: 'bundle-size-baseline',
|
|
51
|
+
usage: USAGE,
|
|
52
|
+
onError: (err) => {
|
|
53
|
+
Logger.error(`[BundleSize] ❌ Fatal error: ${err?.message ?? err}`);
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Refresh the coverage baseline from the `coverage
|
|
3
|
+
* Refresh the coverage baseline from the configured `coverage.coveragePath`
|
|
4
|
+
* artifact (Istanbul `coverage-final.json`) on disk via
|
|
4
5
|
* `refreshBaseline({ kind: 'coverage' })`. Never runs the suite, so the
|
|
5
6
|
* refresh is idempotent and the output can be inspected first.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
import { createRequire } from 'node:module';
|
|
9
|
-
import path from 'node:path';
|
|
10
9
|
import { resolveUpdaterRefreshScope } from './lib/baselines/coverage-refresh-scope.js';
|
|
11
10
|
import {
|
|
12
|
-
|
|
11
|
+
buildCoverageRefreshOpts,
|
|
12
|
+
coverageUpdaterTargets,
|
|
13
|
+
loadC8ScopeConfig,
|
|
13
14
|
resolveCoverageUpdaterScope,
|
|
14
15
|
} from './lib/baselines/coverage-updater-cli.js';
|
|
15
16
|
import { refreshBaseline } from './lib/baselines/refresh-service.js';
|
|
16
17
|
import { runAsCli } from './lib/cli-utils.js';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
buildScopePredicate,
|
|
20
|
-
COVERAGE_BASELINE_PATH,
|
|
21
|
-
readCoverageFinal,
|
|
22
|
-
scoreCoverageFinal,
|
|
23
|
-
} from './lib/coverage-baseline.js';
|
|
18
|
+
import { getQuality, resolveConfig } from './lib/config-resolver.js';
|
|
24
19
|
import { Logger } from './lib/Logger.js';
|
|
25
20
|
|
|
26
21
|
/** `runAsCli` answers `--help` before `main`, so a usage probe never writes. */
|
|
@@ -28,7 +23,7 @@ const USAGE = {
|
|
|
28
23
|
invocation:
|
|
29
24
|
'node .agents/scripts/update-coverage-baseline.js [--full-scope | --diff-scope <ref>]',
|
|
30
25
|
summary:
|
|
31
|
-
'Score → write the coverage baseline from the coverage-final.json already on disk. With no scope flag the refresh is scoped to the files changed in `origin/main..HEAD`; out-of-scope rows are preserved verbatim.',
|
|
26
|
+
'Score → write the coverage baseline from the coverage artifact (`delivery.quality.gates.coverage.coveragePath`, Istanbul coverage-final.json) already on disk. With no scope flag the refresh is scoped to the files changed in `origin/main..HEAD`; out-of-scope rows are preserved verbatim.',
|
|
32
27
|
flags: [
|
|
33
28
|
[
|
|
34
29
|
'--full-scope',
|
|
@@ -45,49 +40,29 @@ const USAGE = {
|
|
|
45
40
|
],
|
|
46
41
|
};
|
|
47
42
|
|
|
48
|
-
/** CommonJS `require`, for the `.c8rc.cjs` scope config below. */
|
|
49
|
-
const require = createRequire(import.meta.url);
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Load the c8 include/exclude scope. Kept in the CLI rather than the extracted
|
|
53
|
-
* scorer because it is the one genuinely environment-bound step — a CJS
|
|
54
|
-
* `require` of a config file resolved against the working tree — and the
|
|
55
|
-
* scorer takes it as a seam so a test never touches the real `.c8rc.cjs`.
|
|
56
|
-
*/
|
|
57
|
-
function loadC8Scope(cwd) {
|
|
58
|
-
return require(path.resolve(cwd, '.c8rc.cjs'));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
43
|
function main() {
|
|
62
44
|
const cwd = process.cwd();
|
|
63
45
|
const { fullScope, diffScopeRef } = resolveCoverageUpdaterScope(
|
|
64
46
|
process.argv.slice(2),
|
|
65
47
|
);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
epsilon: getBaselineEpsilon('coverage'),
|
|
73
|
-
scorer: buildCoverageUpdaterScorer(cwd, {
|
|
74
|
-
readCoverage: readCoverageFinal,
|
|
75
|
-
loadScope: loadC8Scope,
|
|
76
|
-
buildScope: buildScopePredicate,
|
|
77
|
-
score: scoreCoverageFinal,
|
|
78
|
-
}),
|
|
79
|
-
};
|
|
48
|
+
const targets = coverageUpdaterTargets(
|
|
49
|
+
getQuality(resolveConfig({ cwd })).coverage,
|
|
50
|
+
cwd,
|
|
51
|
+
);
|
|
52
|
+
Logger.info(`[Coverage] Updating baseline from ${targets.coveragePath}...`);
|
|
53
|
+
const refreshOpts = buildCoverageRefreshOpts(cwd, targets);
|
|
80
54
|
// No flag and a full artifact -> the service derives the diff via
|
|
81
55
|
// `origin/main..HEAD` (its default baseRef/headRef).
|
|
82
56
|
return resolveUpdaterRefreshScope(cwd, {
|
|
83
57
|
fullScope,
|
|
84
58
|
diffScopeRef,
|
|
85
|
-
loadScope:
|
|
59
|
+
loadScope: loadC8ScopeConfig,
|
|
60
|
+
readCoverage: targets.readCoverage,
|
|
86
61
|
})
|
|
87
62
|
.then((scope) => refreshBaseline({ ...refreshOpts, ...scope }))
|
|
88
63
|
.then((result) => {
|
|
89
64
|
Logger.info(
|
|
90
|
-
`[Coverage] ✅ Baseline updated: ${result.envelope.rows.length} file(s) recorded at ${
|
|
65
|
+
`[Coverage] ✅ Baseline updated: ${result.envelope.rows.length} file(s) recorded at ${targets.baselinePath} (${targets.absBaselinePath}). scope=${result.scope.mode}, wrote=${result.wrote}.`,
|
|
91
66
|
);
|
|
92
67
|
});
|
|
93
68
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import './lib/runtime-deps/ensure-installed.js';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { parseDiffScopeFlag } from './lib/baselines/diff-scope-cli.js';
|
|
12
|
+
import { JSCPD_MISSING } from './lib/baselines/duplication-scanner.js';
|
|
12
13
|
import { refreshBaseline } from './lib/baselines/refresh-service.js';
|
|
13
14
|
import { runAsCli } from './lib/cli-utils.js';
|
|
14
15
|
import { getBaselineEpsilon } from './lib/config/quality.js';
|
|
@@ -172,13 +173,22 @@ async function main() {
|
|
|
172
173
|
);
|
|
173
174
|
}
|
|
174
175
|
|
|
176
|
+
/**
|
|
177
|
+
* A missing optional peer is an install step, not a crash: no stack.
|
|
178
|
+
*
|
|
179
|
+
* @param {unknown} err
|
|
180
|
+
* @returns {string}
|
|
181
|
+
*/
|
|
182
|
+
function fatalDetail(err) {
|
|
183
|
+
if (err?.code === JSCPD_MISSING) return err.message;
|
|
184
|
+
return err?.stack ?? err?.message ?? String(err);
|
|
185
|
+
}
|
|
186
|
+
|
|
175
187
|
runAsCli(import.meta.url, main, {
|
|
176
188
|
source: 'duplication-baseline',
|
|
177
189
|
usage: USAGE,
|
|
178
190
|
onError: (err) => {
|
|
179
|
-
Logger.error(
|
|
180
|
-
`[Duplication] ❌ Fatal error: ${err?.stack ?? err?.message ?? err}`,
|
|
181
|
-
);
|
|
191
|
+
Logger.error(`[Duplication] ❌ Fatal error: ${fatalDetail(err)}`);
|
|
182
192
|
process.exitCode = 1;
|
|
183
193
|
},
|
|
184
194
|
});
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,13 @@ All notable changes to this project will be documented in this file.
|
|
|
15
15
|
-->
|
|
16
16
|
<!-- markdownlint-disable-file MD004 MD012 MD037 -->
|
|
17
17
|
|
|
18
|
+
## [2.87.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.86.0...mandrel-v2.87.0) (2026-10-14)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
* make consumer quality-baseline refresh runnable from a clean install ([#5672](https://github.com/dsj1984/mandrel/issues/5672)) ([#5673](https://github.com/dsj1984/mandrel/issues/5673)) ([9bb4a71](https://github.com/dsj1984/mandrel/commit/9bb4a718c0a9765b064c83a0a11c57b71ed9a35c))
|
|
24
|
+
|
|
18
25
|
## [2.86.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.85.0...mandrel-v2.86.0) (2026-10-14)
|
|
19
26
|
|
|
20
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mandrel",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.87.0",
|
|
4
4
|
"description": "Claude Code-first opinionated workflow framework: instructions, skills, rules, and SDLC workflows that govern AI coding assistants.",
|
|
5
5
|
"files": [
|
|
6
6
|
".agents/",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"duplication:check": "node .agents/scripts/check-baselines.js --gate duplication",
|
|
66
66
|
"duplication:update": "node .agents/scripts/update-duplication-baseline.js",
|
|
67
67
|
"duplication:reanchor": "node .agents/scripts/update-duplication-baseline.js --full-scope",
|
|
68
|
+
"bundle-size:check": "node .agents/scripts/check-baselines.js --gate bundle-size",
|
|
69
|
+
"bundle-size:update": "node .agents/scripts/update-bundle-size-baseline.js",
|
|
68
70
|
"quality:preview": "node .agents/scripts/check-dead-exports.js && node .agents/scripts/quality-preview.js",
|
|
69
71
|
"quality:watch": "node .agents/scripts/quality-watch.js",
|
|
70
72
|
"sync:commands": "node bin/mandrel.js sync-commands",
|
|
@@ -129,12 +131,16 @@
|
|
|
129
131
|
},
|
|
130
132
|
"peerDependencies": {
|
|
131
133
|
"@cucumber/gherkin": ">=32.0.0",
|
|
134
|
+
"jscpd": "^4.0.0",
|
|
132
135
|
"typescript": ">=5.0.0 <7"
|
|
133
136
|
},
|
|
134
137
|
"peerDependenciesMeta": {
|
|
135
138
|
"@cucumber/gherkin": {
|
|
136
139
|
"optional": true
|
|
137
140
|
},
|
|
141
|
+
"jscpd": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
138
144
|
"typescript": {
|
|
139
145
|
"optional": true
|
|
140
146
|
}
|