mandrel 2.69.0 → 2.71.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.
Files changed (76) hide show
  1. package/.agents/README.md +8 -9
  2. package/.agents/agents/acceptance-critic.md +1 -0
  3. package/.agents/agents/auditor.md +1 -0
  4. package/.agents/agents/plan-critic.md +1 -0
  5. package/.agents/agents/story-worker.md +63 -64
  6. package/.agents/docs/agentrc-reference.json +2 -1
  7. package/.agents/docs/configuration.md +7 -8
  8. package/.agents/rules/git-conventions-reference.md +2 -2
  9. package/.agents/schemas/agentrc.schema.json +19 -2
  10. package/.agents/scripts/acceptance-eval.js +194 -15
  11. package/.agents/scripts/audit-to-stories.js +39 -247
  12. package/.agents/scripts/deliver-run.js +92 -43
  13. package/.agents/scripts/lib/audit-suite/index.js +1 -1
  14. package/.agents/scripts/lib/audit-suite/story-checklist.js +65 -0
  15. package/.agents/scripts/lib/audit-to-stories/audit-label-taxonomy.js +2 -2
  16. package/.agents/scripts/lib/audit-to-stories/finding-adapter.js +1 -1
  17. package/.agents/scripts/lib/bootstrap/issue-forms-template.js +1 -1
  18. package/.agents/scripts/lib/cli-args.js +22 -0
  19. package/.agents/scripts/lib/close-validation/gates.js +17 -3
  20. package/.agents/scripts/lib/config/agent-models.js +117 -0
  21. package/.agents/scripts/lib/config-settings-schema-delivery.js +13 -1
  22. package/.agents/scripts/lib/config-settings-schema-quality.js +1 -1
  23. package/.agents/scripts/lib/findings/route-finding.js +15 -0
  24. package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
  25. package/.agents/scripts/lib/git/sync-from-base.js +89 -17
  26. package/.agents/scripts/lib/label-taxonomy.js +13 -3
  27. package/.agents/scripts/lib/notifications/notifier.js +11 -15
  28. package/.agents/scripts/lib/observability/close-telemetry.js +19 -3
  29. package/.agents/scripts/lib/observability/source-classifier.js +1 -0
  30. package/.agents/scripts/lib/orchestration/code-review.js +2 -2
  31. package/.agents/scripts/lib/orchestration/file-assumptions.js +45 -11
  32. package/.agents/scripts/lib/orchestration/plan-context.js +31 -11
  33. package/.agents/scripts/lib/orchestration/plan-persist/audit-provenance.js +35 -117
  34. package/.agents/scripts/lib/orchestration/plan-persist/changes-repair.js +130 -24
  35. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +24 -22
  36. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +1 -0
  37. package/.agents/scripts/lib/orchestration/plan-persist/summary.js +4 -3
  38. package/.agents/scripts/lib/orchestration/resolve-stories.js +10 -2
  39. package/.agents/scripts/lib/orchestration/review-providers/native.js +5 -165
  40. package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +14 -2
  41. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +151 -56
  42. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +4 -0
  43. package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +20 -4
  44. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +26 -17
  45. package/.agents/scripts/lib/orchestration/story-handoff.js +849 -0
  46. package/.agents/scripts/lib/orchestration/story-init-result.js +83 -0
  47. package/.agents/scripts/lib/orchestration/task-body-validator.js +35 -5
  48. package/.agents/scripts/lib/orchestration/ticket-validator-sizing.js +1 -1
  49. package/.agents/scripts/lib/orchestration/ticket-validator.js +20 -2
  50. package/.agents/scripts/lib/single-story/confirm-merge.js +44 -7
  51. package/.agents/scripts/lib/story-body/story-body.js +40 -5
  52. package/.agents/scripts/lib/templates/decomposer-prompts.js +33 -36
  53. package/.agents/scripts/single-story-close.js +8 -0
  54. package/.agents/scripts/single-story-init.js +17 -32
  55. package/.agents/scripts/story-handoff.js +112 -0
  56. package/.agents/scripts/sync-claude-agents.js +58 -27
  57. package/.agents/templates/docs/audit-sweep-runbook.md +29 -59
  58. package/.agents/workflows/audit-to-stories.md +40 -67
  59. package/.agents/workflows/helpers/acceptance-self-eval.md +24 -18
  60. package/.agents/workflows/helpers/code-review.md +3 -3
  61. package/.agents/workflows/helpers/deliver-digest.md +79 -80
  62. package/.agents/workflows/helpers/deliver-light.md +9 -7
  63. package/.agents/workflows/helpers/deliver-reference.md +38 -22
  64. package/.agents/workflows/helpers/deliver-story-reference.md +11 -9
  65. package/.agents/workflows/helpers/deliver-story.md +30 -23
  66. package/.agents/workflows/helpers/plan-reference.md +24 -9
  67. package/docs/CHANGELOG.md +30 -0
  68. package/lib/cli/registry.js +7 -0
  69. package/lib/migrations/index.js +2 -0
  70. package/lib/migrations/steps/2.70.0-retire-audit-ledger.js +36 -0
  71. package/package.json +4 -3
  72. package/.agents/scripts/lib/audit-to-stories/ledger-commit.js +0 -184
  73. package/.agents/scripts/lib/audit-to-stories/ledger-pr.js +0 -279
  74. package/.agents/scripts/lib/audit-to-stories/ledger-record.js +0 -88
  75. package/.agents/scripts/lib/findings/audit-ledger.js +0 -289
  76. package/.agents/scripts/lib/orchestration/review-providers/scoped-lint.js +0 -272
@@ -1,272 +0,0 @@
1
- /**
2
- * review-providers/scoped-lint.js — scoped biome + markdownlint over the
3
- * changed surface. Runners resolve on disk before spawning (`npx --no biome`
4
- * exits 0 silently when biome is absent), and each surface is classified
5
- * independently so one failure cannot become the other's verdict.
6
- */
7
-
8
- import { spawnSync } from 'node:child_process';
9
- import { existsSync } from 'node:fs';
10
- import path from 'node:path';
11
-
12
- const CODE_EXTENSIONS = /\.(js|mjs|cjs|jsx|ts|tsx|json|jsonc)$/i;
13
-
14
- /**
15
- * npx's unresolvable-bin output: the legacy message or current npm's E404.
16
- * Matching the E404 code, not any `npm error` line, keeps genuine runner
17
- * errors out.
18
- */
19
- const NPX_UNRESOLVABLE =
20
- /could not determine executable to run|npm (?:error|ERR!)\s+code\s+E404/i;
21
-
22
- /** Biome's exit-1 when every path is config-excluded: an empty scope, not a failure. */
23
- const BIOME_EMPTY_SCOPE = /No files were processed in the specified paths/i;
24
-
25
- /**
26
- * Markdown runners in preference order, each with its own argument shape:
27
- * cli2 rejects `--ignore`, which cli v1 takes.
28
- */
29
- const MARKDOWN_RUNNERS = Object.freeze([
30
- Object.freeze({ bin: 'markdownlint-cli2', extraArgs: Object.freeze([]) }),
31
- Object.freeze({
32
- bin: 'markdownlint',
33
- extraArgs: Object.freeze(['--ignore', 'node_modules']),
34
- }),
35
- ]);
36
-
37
- const CODE_RUNNERS = Object.freeze([
38
- Object.freeze({ bin: 'biome', extraArgs: Object.freeze([]) }),
39
- ]);
40
-
41
- const DEGRADATION_REASONS = Object.freeze({
42
- RUNNER_NOT_INSTALLED: 'runner-not-installed',
43
- RUNNER_NOT_RESOLVABLE: 'runner-not-resolvable',
44
- UNPARSEABLE_OUTPUT: 'unparseable-output',
45
- });
46
-
47
- /**
48
- * Spawn one lint runner through `npx --no` (never install on the fly).
49
- *
50
- * @param {string} bin
51
- * @param {string[]} args
52
- * @param {string} cwd
53
- * @returns {{ status: number, stdout: string, stderr: string }}
54
- */
55
- function spawnLintRunner(bin, args, cwd) {
56
- const result = spawnSync('npx', ['--no', bin, ...args], {
57
- cwd,
58
- encoding: 'utf-8',
59
- shell: process.platform === 'win32',
60
- });
61
- return {
62
- status: result.status ?? 1,
63
- stdout: result.stdout ?? '',
64
- stderr: result.stderr ?? '',
65
- };
66
- }
67
-
68
- /**
69
- * First candidate installed under `<cwd>/node_modules/.bin`, else `null`.
70
- * Deliberately local-only: a global runner reads as absent and degrades
71
- * honestly rather than trusting an unresolved spawn.
72
- *
73
- * @param {ReadonlyArray<{ bin: string, extraArgs: ReadonlyArray<string> }>} candidates
74
- * @param {string} cwd
75
- * @param {(p: string) => boolean} existsFn Injected for testing.
76
- * @returns {{ bin: string, extraArgs: ReadonlyArray<string> }|null}
77
- */
78
- function resolveRunner(candidates, cwd, existsFn) {
79
- for (const candidate of candidates) {
80
- const base = path.join(cwd, 'node_modules', '.bin', candidate.bin);
81
- if (existsFn(base)) return candidate;
82
- if (
83
- process.platform === 'win32' &&
84
- (existsFn(`${base}.cmd`) || existsFn(`${base}.ps1`))
85
- ) {
86
- return candidate;
87
- }
88
- }
89
- return null;
90
- }
91
-
92
- /**
93
- * Zero counts with `executionFailed: true`, so it can never read as clean.
94
- *
95
- * @returns {ReturnType<typeof parseLintOutput>}
96
- */
97
- function unresolvedRunnerSummary() {
98
- return {
99
- errors: 0,
100
- warnings: 0,
101
- parsed: false,
102
- executionFailed: true,
103
- emptyScope: false,
104
- reason: DEGRADATION_REASONS.RUNNER_NOT_INSTALLED,
105
- };
106
- }
107
-
108
- /**
109
- * Resolve one surface's runner and, only if it resolved, spawn and classify it.
110
- *
111
- * @param {{
112
- * label: string,
113
- * candidates: ReadonlyArray<{ bin: string, extraArgs: ReadonlyArray<string> }>,
114
- * buildArgs: (runner: { bin: string, extraArgs: ReadonlyArray<string> }) => string[],
115
- * cwd: string,
116
- * runnerFn: typeof spawnLintRunner,
117
- * existsFn: (p: string) => boolean,
118
- * }} args
119
- * @returns {{ surface: string, summary: ReturnType<typeof parseLintOutput> }}
120
- */
121
- function runSurface({ label, candidates, buildArgs, cwd, runnerFn, existsFn }) {
122
- const runner = resolveRunner(candidates, cwd, existsFn);
123
- if (runner === null) {
124
- return { surface: label, summary: unresolvedRunnerSummary() };
125
- }
126
- return {
127
- surface: runner.bin,
128
- summary: parseLintOutput(runnerFn(runner.bin, buildArgs(runner), cwd)),
129
- };
130
- }
131
-
132
- /**
133
- * @param {string[]} changedFiles
134
- * @returns {{ code: string[], md: string[] }}
135
- */
136
- export function partitionFilesForLint(changedFiles) {
137
- const code = [];
138
- const md = [];
139
- for (const f of changedFiles) {
140
- if (CODE_EXTENSIONS.test(f)) code.push(f);
141
- else if (/\.md$/i.test(f)) md.push(f);
142
- }
143
- return { code, md };
144
- }
145
-
146
- /**
147
- * A non-zero exit matching no reporter format is `executionFailed`, except
148
- * biome's empty-scope exit.
149
- *
150
- * @param {{ status?: number, stdout?: string, stderr?: string }} result
151
- * @returns {{ errors: number, warnings: number, parsed: boolean, executionFailed: boolean, emptyScope: boolean, reason: string|null }}
152
- */
153
- export function parseLintOutput(result) {
154
- const combined = `${result.stdout ?? ''}\n${result.stderr ?? ''}`;
155
-
156
- let errors = 0;
157
- let warnings = 0;
158
- let parsed = false;
159
-
160
- for (const m of combined.matchAll(/Found\s+(\d+)\s+error/gi)) {
161
- errors += Number(m[1]);
162
- parsed = true;
163
- }
164
- for (const m of combined.matchAll(/Found\s+(\d+)\s+warning/gi)) {
165
- warnings += Number(m[1]);
166
- parsed = true;
167
- }
168
- const mdSummary = combined.match(/Summary:\s+(\d+)\s+error/i);
169
- if (mdSummary) {
170
- errors += Number(mdSummary[1]);
171
- parsed = true;
172
- }
173
-
174
- const failedExit = !parsed && (result.status ?? 0) !== 0;
175
- const emptyScope = failedExit && BIOME_EMPTY_SCOPE.test(combined);
176
- const executionFailed = failedExit && !emptyScope;
177
- const reason = executionFailed
178
- ? NPX_UNRESOLVABLE.test(combined)
179
- ? DEGRADATION_REASONS.RUNNER_NOT_RESOLVABLE
180
- : DEGRADATION_REASONS.UNPARSEABLE_OUTPUT
181
- : null;
182
-
183
- return { errors, warnings, parsed, executionFailed, emptyScope, reason };
184
- }
185
-
186
- /**
187
- * Counts add and `executionFailed` is the OR; `surfaces[]` keeps what the
188
- * lossy OR cannot answer.
189
- *
190
- * @param {Array<{ surface: string, summary: ReturnType<typeof parseLintOutput> }>} surfaces
191
- */
192
- function mergeSurfaceSummaries(surfaces) {
193
- const rows = surfaces.map(({ surface, summary }) => ({
194
- surface,
195
- parsed: summary.parsed,
196
- errors: summary.errors,
197
- warnings: summary.warnings,
198
- executionFailed: summary.executionFailed,
199
- reason: summary.reason ?? DEGRADATION_REASONS.UNPARSEABLE_OUTPUT,
200
- }));
201
- const total = (field) => rows.reduce((sum, row) => sum + row[field], 0);
202
-
203
- return {
204
- errors: total('errors'),
205
- warnings: total('warnings'),
206
- parsed: rows.some((row) => row.parsed),
207
- executionFailed: rows.some((row) => row.executionFailed),
208
- skipped: false,
209
- mode: 'changed-only',
210
- degradations: rows
211
- .filter((row) => row.executionFailed)
212
- .map(({ surface, reason }) => ({ surface, reason })),
213
- surfaces: rows.map(({ reason, ...row }) => row),
214
- };
215
- }
216
-
217
- /**
218
- * @param {string[]} changedFiles
219
- * @param {string} cwd
220
- * @param {typeof spawnLintRunner} [runnerFn]
221
- * @param {{ existsFn?: (p: string) => boolean }} [deps]
222
- * @returns {{ errors: number, warnings: number, parsed: boolean, skipped: boolean, mode: 'changed-only'|'off', executionFailed: boolean, degradations: Array<{ surface: string, reason: string }>, surfaces: Array<{ surface: string, parsed: boolean, errors: number, warnings: number, executionFailed: boolean }> }}
223
- */
224
- export function runScopedLint(
225
- changedFiles,
226
- cwd,
227
- runnerFn = spawnLintRunner,
228
- deps = {},
229
- ) {
230
- const { existsFn = existsSync } = deps;
231
- const { code, md } = partitionFilesForLint(changedFiles);
232
- if (code.length === 0 && md.length === 0) {
233
- return {
234
- errors: 0,
235
- warnings: 0,
236
- parsed: false,
237
- skipped: true,
238
- mode: 'changed-only',
239
- executionFailed: false,
240
- degradations: [],
241
- surfaces: [],
242
- };
243
- }
244
-
245
- const surfaces = [];
246
- if (code.length > 0) {
247
- surfaces.push(
248
- runSurface({
249
- label: 'biome',
250
- candidates: CODE_RUNNERS,
251
- buildArgs: (runner) => ['lint', ...code, ...runner.extraArgs],
252
- cwd,
253
- runnerFn,
254
- existsFn,
255
- }),
256
- );
257
- }
258
- if (md.length > 0) {
259
- surfaces.push(
260
- runSurface({
261
- label: 'markdownlint',
262
- candidates: MARKDOWN_RUNNERS,
263
- buildArgs: (runner) => [...md, ...runner.extraArgs],
264
- cwd,
265
- runnerFn,
266
- existsFn,
267
- }),
268
- );
269
- }
270
-
271
- return mergeSurfaceSummaries(surfaces);
272
- }