mandrel 2.97.0 → 2.98.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/scripts/lib/orchestration/single-story-close/phases/pre-gate-steps.js +3 -1
- package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +1 -1
- package/.agents/scripts/lib/orchestration/story-close/commit-body.js +100 -0
- package/.agents/scripts/lib/orchestration/story-close/context-budget-writeback.js +1 -1
- package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +1 -1
- package/.agents/scripts/lib/orchestration/story-close/ratchet-shrink-writeback.js +1 -1
- package/docs/CHANGELOG.md +7 -0
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { Logger } from '../../../Logger.js';
|
|
12
12
|
import { runBaselineUpwardWriteback as defaultRunBaselineUpwardWriteback } from '../../story-close/baseline-upward-writeback.js';
|
|
13
|
+
import { refusalMark } from '../../story-close/commit-body.js';
|
|
13
14
|
import { runContextBudgetWriteback as defaultRunContextBudgetWriteback } from '../../story-close/context-budget-writeback.js';
|
|
14
15
|
import { runDuplicationCloseRescore as defaultRunDuplicationCloseRescore } from '../../story-close/duplication-close-rescore.js';
|
|
15
16
|
import { runScopedFormatAutofix as defaultRunScopedFormatAutofix } from '../../story-close/format-autofix.js';
|
|
@@ -74,7 +75,7 @@ async function writebackStep(
|
|
|
74
75
|
tag,
|
|
75
76
|
writeback?.committed
|
|
76
77
|
? `✅ ${describe(writeback)} as ${writeback.sha} on ${storyBranch}.`
|
|
77
|
-
:
|
|
78
|
+
: `${refusalMark(tag, writeback?.reason)} No ${noun} (${writeback?.reason ?? 'nothing to write'}).`,
|
|
78
79
|
);
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -88,6 +89,7 @@ async function bestEffort({ tag, label, progress, run }) {
|
|
|
88
89
|
try {
|
|
89
90
|
await run();
|
|
90
91
|
} catch (err) {
|
|
92
|
+
refusalMark(tag, err?.message);
|
|
91
93
|
progress(
|
|
92
94
|
tag,
|
|
93
95
|
`⚠️ ${label} failed (close continues; the gate chain is authoritative): ${err?.message ?? err}`,
|
|
@@ -28,10 +28,10 @@ import {
|
|
|
28
28
|
resolveDefaultScorer,
|
|
29
29
|
} from '../../baselines/refresh-service.js';
|
|
30
30
|
import { getQuality } from '../../config-resolver.js';
|
|
31
|
-
import { gitSync as defaultGitSync } from '../../git-utils.js';
|
|
32
31
|
import { Logger as DefaultLogger } from '../../Logger.js';
|
|
33
32
|
import { isScorableSourceFile } from '../../source-extensions.js';
|
|
34
33
|
import { toPosix } from '../../util/paths.js';
|
|
34
|
+
import { closeGitSync as defaultGitSync } from './commit-body.js';
|
|
35
35
|
import {
|
|
36
36
|
currentBranch,
|
|
37
37
|
listChangedFiles,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* commit-body.js — the git close-time baseline write-backs commit with: each
|
|
3
|
+
* body line bounded to commitlint's `body-max-line-length` (100), never by
|
|
4
|
+
* bypassing the consumer's hook; a refusal names the rule and warns.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { gitSync } from '../../git-utils.js';
|
|
8
|
+
import { Logger } from '../../Logger.js';
|
|
9
|
+
|
|
10
|
+
const BODY_LINE_MAX = 100;
|
|
11
|
+
|
|
12
|
+
/** Survives each writer's own `<label>: <message>` skip reason. */
|
|
13
|
+
const COMMIT_REFUSED = 'commit-refused:';
|
|
14
|
+
|
|
15
|
+
const ROW_PREFIX = '- ';
|
|
16
|
+
const CONTINUATION = ' ';
|
|
17
|
+
const LEFT_ELLIPSIS = '…/';
|
|
18
|
+
|
|
19
|
+
/** Keep the path's tail, cut at a segment boundary. */
|
|
20
|
+
function truncatePathLeft(rowPath, max) {
|
|
21
|
+
if (rowPath.length <= max) return rowPath;
|
|
22
|
+
const tail = rowPath.slice(rowPath.length - (max - LEFT_ELLIPSIS.length));
|
|
23
|
+
const cut = tail.indexOf('/');
|
|
24
|
+
const kept = cut >= 0 && cut < tail.length - 1 ? tail.slice(cut + 1) : tail;
|
|
25
|
+
return `${LEFT_ELLIPSIS}${kept}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function truncateRight(text, max) {
|
|
29
|
+
return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** `- <path>: <detail>`, or the path then an indented detail line. */
|
|
33
|
+
function formatBodyRow(rowPath, detail) {
|
|
34
|
+
const oneLine = `${ROW_PREFIX}${rowPath}: ${detail}`;
|
|
35
|
+
if (oneLine.length <= BODY_LINE_MAX) return [oneLine];
|
|
36
|
+
return [
|
|
37
|
+
`${ROW_PREFIX}${truncatePathLeft(rowPath, BODY_LINE_MAX - ROW_PREFIX.length)}`,
|
|
38
|
+
`${CONTINUATION}${truncateRight(detail, BODY_LINE_MAX - CONTINUATION.length)}`,
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Re-flow over-long rows (split at the last `: `); cut other long lines. */
|
|
43
|
+
function boundBody(body) {
|
|
44
|
+
return body
|
|
45
|
+
.split('\n')
|
|
46
|
+
.flatMap((line) => {
|
|
47
|
+
if (line.length <= BODY_LINE_MAX) return [line];
|
|
48
|
+
const split = line.lastIndexOf(': ');
|
|
49
|
+
if (!line.startsWith(ROW_PREFIX) || split < 0) {
|
|
50
|
+
return [truncateRight(line, BODY_LINE_MAX)];
|
|
51
|
+
}
|
|
52
|
+
return formatBodyRow(
|
|
53
|
+
line.slice(ROW_PREFIX.length, split),
|
|
54
|
+
line.slice(split + 2),
|
|
55
|
+
);
|
|
56
|
+
})
|
|
57
|
+
.join('\n');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The commitlint rule(s) from hook stderr — not the message, which echoes argv. */
|
|
61
|
+
function describeCommitRefusal(err) {
|
|
62
|
+
const text = String(err?.stderr || err?.message || err || '');
|
|
63
|
+
const rules = [
|
|
64
|
+
...new Set([...text.matchAll(/\[([a-z][a-z0-9-]*)\]/g)].map((m) => m[1])),
|
|
65
|
+
];
|
|
66
|
+
if (rules.length > 0)
|
|
67
|
+
return `commit-msg hook refused it [${rules.join(', ')}]`;
|
|
68
|
+
const lines = text.split('\n').map((l) => l.trim());
|
|
69
|
+
return truncateRight(lines.filter(Boolean).at(-1) ?? 'unknown', 200);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** `git commit` itself failed (a hook refused it), not a write or `git add`. */
|
|
73
|
+
class CommitRefusedError extends Error {
|
|
74
|
+
constructor(cause) {
|
|
75
|
+
super(`${COMMIT_REFUSED} ${describeCommitRefusal(cause)}`, { cause });
|
|
76
|
+
this.name = 'CommitRefusedError';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Drop-in `gitSync`: a `git commit` gets bounded `-m` paragraphs. */
|
|
81
|
+
export function closeGitSync(cwd, ...args) {
|
|
82
|
+
if (args[0] !== 'commit') return gitSync(cwd, ...args);
|
|
83
|
+
const bounded = args.map((arg, i) =>
|
|
84
|
+
args[i - 1] === '-m' ? boundBody(arg) : arg,
|
|
85
|
+
);
|
|
86
|
+
try {
|
|
87
|
+
return gitSync(cwd, ...bounded);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
throw new CommitRefusedError(err);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** `⚠️` plus a warn-level log for a refused commit, else `⏭`. */
|
|
94
|
+
export function refusalMark(tag, reason) {
|
|
95
|
+
if (!String(reason ?? '').includes(COMMIT_REFUSED)) return '⏭';
|
|
96
|
+
Logger.warn(
|
|
97
|
+
`[${tag}] baseline commit refused; its rows stay stale: ${reason}`,
|
|
98
|
+
);
|
|
99
|
+
return '⚠️';
|
|
100
|
+
}
|
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
loadBaseline as defaultLoadBaseline,
|
|
23
23
|
} from '../../../check-context-budget.js';
|
|
24
24
|
import { resolveDocTiers as defaultResolveDocTiers } from '../../doc-tiers.js';
|
|
25
|
-
import { gitSync as defaultGitSync } from '../../git-utils.js';
|
|
26
25
|
import { Logger as DefaultLogger } from '../../Logger.js';
|
|
26
|
+
import { closeGitSync as defaultGitSync } from './commit-body.js';
|
|
27
27
|
|
|
28
28
|
const TAG = '[context-budget-writeback]';
|
|
29
29
|
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
} from '../../baselines/refresh-service.js';
|
|
20
20
|
import { getBaselineEpsilon } from '../../config/quality.js';
|
|
21
21
|
import { getQuality } from '../../config-resolver.js';
|
|
22
|
-
import { gitSync as defaultGitSync } from '../../git-utils.js';
|
|
23
22
|
import { Logger as DefaultLogger } from '../../Logger.js';
|
|
23
|
+
import { closeGitSync as defaultGitSync } from './commit-body.js';
|
|
24
24
|
import {
|
|
25
25
|
currentBranch,
|
|
26
26
|
listChangedFiles,
|
|
@@ -28,9 +28,9 @@ import {
|
|
|
28
28
|
extractRowsFromKnip,
|
|
29
29
|
} from '../../dead-exports-knip.js';
|
|
30
30
|
import { resolveDeadExportsMode } from '../../dead-exports-mode.js';
|
|
31
|
-
import { gitSync as defaultGitSync } from '../../git-utils.js';
|
|
32
31
|
import { Logger as DefaultLogger } from '../../Logger.js';
|
|
33
32
|
import { toPosix } from '../../util/paths.js';
|
|
33
|
+
import { closeGitSync as defaultGitSync } from './commit-body.js';
|
|
34
34
|
import { currentBranch, listDirtyPaths } from './format-autofix.js';
|
|
35
35
|
|
|
36
36
|
const TAG = '[ratchet-shrink]';
|
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.98.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.97.0...mandrel-v2.98.0) (2026-10-22)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
* close-time baseline commits stay under commitlint's 100-char body line limit, so a deep file path no longer silently drops the re-score ([#5859](https://github.com/dsj1984/mandrel/issues/5859)) ([#5860](https://github.com/dsj1984/mandrel/issues/5860)) ([3f85ed8](https://github.com/dsj1984/mandrel/commit/3f85ed88a0f6a0f8eafbb3d328f0353e1f4f00ed))
|
|
24
|
+
|
|
18
25
|
## [2.97.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.96.0...mandrel-v2.97.0) (2026-10-22)
|
|
19
26
|
|
|
20
27
|
|
package/package.json
CHANGED