@haus-tech/haus-workflow 7.1.0 → 7.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.
Files changed (30) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cli.js +395 -233
  3. package/package.json +1 -1
  4. package/packages/agents/qa-fixer.md +66 -0
  5. package/packages/agents/qa-inventory.md +36 -0
  6. package/packages/agents/qa-reviewer.md +32 -0
  7. package/packages/agents/qa-tester.md +85 -0
  8. package/packages/packages.yaml +8 -0
  9. package/packages/skills/fixing-weak-tests/SKILL.md +89 -0
  10. package/packages/skills/fixing-weak-tests/references/audit-brief.md +57 -0
  11. package/packages/skills/fixing-weak-tests/references/fix-brief.md +55 -0
  12. package/packages/skills/optimizing-test-suites/SKILL.md +157 -0
  13. package/packages/skills/optimizing-test-suites/references/affected-tests.md +46 -0
  14. package/packages/skills/optimizing-test-suites/references/levers.md +79 -0
  15. package/packages/skills/optimizing-test-suites/scripts/slowest.mjs +78 -0
  16. package/packages/skills/qa-genomklickning/SKILL.md +179 -0
  17. package/packages/skills/qa-genomklickning/drivers.md +159 -0
  18. package/packages/skills/qa-genomklickning/report.md +23 -0
  19. package/packages/skills/qa-genomklickning/scripts/android-setup.sh +26 -0
  20. package/packages/skills/qa-genomklickning/scripts/android.sh +62 -0
  21. package/packages/skills/qa-genomklickning/scripts/chrome-tab-guard.py +55 -0
  22. package/packages/skills/qa-genomklickning/scripts/env-check.sh +32 -0
  23. package/packages/skills/qa-genomklickning/scripts/ios-sim.sh +49 -0
  24. package/packages/skills/request/SKILL.md +3 -2
  25. package/packages/skills/request/scripts/compare-scores.mjs +23 -11
  26. package/packages/skills/testsammanfattning/SKILL.md +134 -0
  27. package/packages/skills/testsammanfattning/references/konfiguration.md +110 -0
  28. package/packages/skills/testsammanfattning/scripts/test-log.mjs +218 -0
  29. package/packages/skills/testsammanfattning/scripts/test-summary.mjs +495 -0
  30. package/packages/templates/agentic-workflow-standard.md +1 -1
@@ -0,0 +1,495 @@
1
+ #!/usr/bin/env node
2
+ // Writes the test summary (testsammanfattning) from the logs in the log folder.
3
+ // Generated by the testsammanfattning skill. Never edit the summary by hand.
4
+ //
5
+ // Usage: node scripts/test-summary.mjs [--no-list] [--config test-summary.config.json]
6
+ //
7
+ // Every row is one test: its title, its outcome from the latest log it appears in,
8
+ // and a link to its exact line in that log. With listing on (default), tests that
9
+ // exist but have never been logged are listed as "saknar logg".
10
+
11
+ import { execSync } from 'node:child_process'
12
+ import fs from 'node:fs'
13
+ import path from 'node:path'
14
+ import { pathToFileURL } from 'node:url'
15
+
16
+ export const SEP = ' › '
17
+
18
+ const TEXT = {
19
+ sv: {
20
+ title: 'Testsammanfattning',
21
+ generated: (script, logDir) =>
22
+ `Genereras av \`${script}\` från loggarna i [${logDir}/](${logDir}/), som \`npm run test:log\` skriver. Ändra aldrig för hand.`,
23
+ state: (n, pass, fail, skip, missing) =>
24
+ `*Läge:* ${n} tester. ${pass} godkända och ${fail} underkända vid senaste körningen` +
25
+ (skip ? `, ${skip} överhoppade` : '') +
26
+ (missing ? `, ${missing} saknar logg` : '') +
27
+ '.',
28
+ logsHeading: 'Loggar som raderna pekar på:',
29
+ failedHeading: 'Underkända vid senaste körningen',
30
+ row: (ts, line) => `${ts}, rad ${line}`,
31
+ status: {
32
+ passed: 'godkänd',
33
+ failed: '**underkänd**',
34
+ skipped: 'överhoppad',
35
+ missing: 'saknar logg',
36
+ },
37
+ other: 'Övrigt',
38
+ },
39
+ en: {
40
+ title: 'Test summary',
41
+ generated: (script, logDir) =>
42
+ `Generated by \`${script}\` from the logs in [${logDir}/](${logDir}/), written by \`npm run test:log\`. Never edit by hand.`,
43
+ state: (n, pass, fail, skip, missing) =>
44
+ `*State:* ${n} tests. ${pass} passed and ${fail} failed in the latest run` +
45
+ (skip ? `, ${skip} skipped` : '') +
46
+ (missing ? `, ${missing} without a log` : '') +
47
+ '.',
48
+ logsHeading: 'Logs the rows point to:',
49
+ failedHeading: 'Failed in the latest run',
50
+ row: (ts, line) => `${ts}, line ${line}`,
51
+ status: { passed: 'passed', failed: '**failed**', skipped: 'skipped', missing: 'no log' },
52
+ other: 'Other',
53
+ },
54
+ }
55
+
56
+ // ---------- config ----------
57
+
58
+ export function loadConfig(argv = process.argv.slice(2)) {
59
+ const i = argv.indexOf('--config')
60
+ const file = path.resolve(i >= 0 ? argv[i + 1] : 'test-summary.config.json')
61
+ if (!fs.existsSync(file)) {
62
+ throw new Error(
63
+ `Hittar inte ${file}. Skapa den enligt testsammanfattning-skillens references/konfiguration.md.`,
64
+ )
65
+ }
66
+ const cfg = JSON.parse(fs.readFileSync(file, 'utf8'))
67
+ // Test files are relative to `root` (default: the config's folder). Output and
68
+ // logs are relative to the config's folder, so a config outside the repo can
69
+ // write its summary elsewhere.
70
+ const dir = path.dirname(file)
71
+ const root = path.resolve(dir, cfg.root ?? '.')
72
+ return {
73
+ root,
74
+ language: cfg.language ?? 'sv',
75
+ output: path.resolve(dir, cfg.output ?? 'docs/testsammanfattning.md'),
76
+ logDir: path.resolve(dir, cfg.logDir ?? 'test-logs'),
77
+ keepLogs: cfg.keepLogs ?? 30,
78
+ intro: cfg.intro ?? '',
79
+ layers: cfg.layers ?? ['Frontend', 'Backend'],
80
+ groups: (cfg.groups ?? []).map((g) => ({ ...g, re: globToRegExp(g.match) })),
81
+ suites: cfg.suites ?? [],
82
+ }
83
+ }
84
+
85
+ export function globToRegExp(glob) {
86
+ let re = ''
87
+ for (let i = 0; i < glob.length; i++) {
88
+ const c = glob[i]
89
+ if (c === '*' && glob[i + 1] === '*') {
90
+ re += '.*'
91
+ i++
92
+ if (glob[i + 1] === '/') i++
93
+ } else if (c === '*') re += '[^/]*'
94
+ else if (c === '?') re += '[^/]'
95
+ else re += c.replace(/[.+^${}()|[\]\\]/g, '\\$&')
96
+ }
97
+ return new RegExp(`^${re}$`)
98
+ }
99
+
100
+ // ---------- runner output -> normalized tests ----------
101
+ // A normalized test: { file, titles: [describe..., title], status, ms, error }
102
+ // status is passed | failed | skipped.
103
+
104
+ export function relFile(root, file) {
105
+ if (!file) return '-'
106
+ const abs = path.isAbsolute(file) ? file : path.resolve(root, file)
107
+ return path.relative(root, abs).split(path.sep).join('/')
108
+ }
109
+
110
+ // Vitest (--reporter=json) and Jest (--json) share this format.
111
+ export function parseJestJson(json, root) {
112
+ const out = []
113
+ for (const fileResult of json.testResults ?? []) {
114
+ for (const a of fileResult.assertionResults ?? []) {
115
+ const status = a.status === 'passed' ? 'passed' : a.status === 'failed' ? 'failed' : 'skipped'
116
+ out.push({
117
+ file: relFile(root, fileResult.name),
118
+ titles: [...(a.ancestorTitles ?? []), a.title],
119
+ status,
120
+ ms: a.duration ?? null,
121
+ error: (a.failureMessages ?? []).join('\n'),
122
+ })
123
+ }
124
+ // A file that fails to load has no assertions but a message.
125
+ if ((fileResult.assertionResults ?? []).length === 0 && fileResult.status === 'failed') {
126
+ out.push({
127
+ file: relFile(root, fileResult.name),
128
+ titles: ['(filen kunde inte köras)'],
129
+ status: 'failed',
130
+ ms: null,
131
+ error: fileResult.message ?? '',
132
+ })
133
+ }
134
+ }
135
+ return out
136
+ }
137
+
138
+ // Playwright (--reporter=json, also with --list).
139
+ export function parsePlaywrightJson(json, root, { listOnly = false } = {}) {
140
+ const out = []
141
+ const testDir = json.config?.rootDir ?? root
142
+ const walk = (suite, titles) => {
143
+ // The top suite per file has the file name as title; skip it.
144
+ const own = suite.file && suite.title === suite.file ? titles : [...titles, suite.title]
145
+ for (const spec of suite.specs ?? []) {
146
+ for (const t of spec.tests ?? []) {
147
+ const project = t.projectName ? [`[${t.projectName}]`] : []
148
+ const last = (t.results ?? []).at(-1)
149
+ let status = 'skipped'
150
+ if (listOnly) status = 'listed'
151
+ else if (t.status === 'expected' || t.status === 'flaky') status = 'passed'
152
+ else if (t.status === 'unexpected') status = 'failed'
153
+ out.push({
154
+ file: relFile(root, path.resolve(testDir, spec.file ?? suite.file ?? '')),
155
+ titles: [...own.filter(Boolean), spec.title, ...project],
156
+ status,
157
+ ms: last?.duration ?? null,
158
+ error: (last?.errors ?? (last?.error ? [last.error] : []))
159
+ .map((e) => stripAnsi(e.message ?? e.value ?? ''))
160
+ .join('\n'),
161
+ })
162
+ }
163
+ }
164
+ for (const s of suite.suites ?? []) walk(s, own)
165
+ }
166
+ for (const s of json.suites ?? []) walk(s, [])
167
+ return out
168
+ }
169
+
170
+ // JUnit XML: PHPUnit, Pest, Playwright, Vitest, pytest and most other runners
171
+ // can write it. Parsed with regular expressions to stay free of dependencies.
172
+ export function parseJunitXml(xml, root, base = root) {
173
+ const out = []
174
+ const caseRe = /<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g
175
+ let m
176
+ while ((m = caseRe.exec(xml))) {
177
+ const a = attrs(m[1])
178
+ const body = m[2] ?? ''
179
+ const failure = /<(failure|error)\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1>)/.exec(body)
180
+ const skipped = /<skipped\b/.test(body)
181
+ // Pest writes file="tests/X.php::it does y"; PHPUnit an absolute path;
182
+ // Playwright and Vitest put the file in classname.
183
+ let file = a.file ? a.file.split('::')[0] : null
184
+ if (!file && a.classname && /[/.](spec|test)|\.[cm]?[jt]sx?$|\//.test(a.classname))
185
+ file = a.classname
186
+ const titles = (a.name ?? '').split(/ › | > /).map(humanize)
187
+ if (!file && a.classname) titles.unshift(a.classname)
188
+ out.push({
189
+ file: file ? relFile(root, path.resolve(base, file)) : '-',
190
+ titles,
191
+ status: failure ? 'failed' : skipped ? 'skipped' : 'passed',
192
+ ms: a.time ? Number(a.time) * 1000 : null,
193
+ error: failure
194
+ ? [attrs(failure[2]).message, decode(failure[3] ?? '')].filter(Boolean).join('\n')
195
+ : '',
196
+ })
197
+ }
198
+ return out
199
+ }
200
+
201
+ function attrs(s) {
202
+ const o = {}
203
+ for (const [, k, v] of s.matchAll(/([\w:-]+)="([^"]*)"/g)) o[k] = decode(v)
204
+ return o
205
+ }
206
+
207
+ function decode(s) {
208
+ return s
209
+ .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1')
210
+ .replace(/&#x([0-9a-f]+);/gi, (_, h) => String.fromCodePoint(parseInt(h, 16)))
211
+ .replace(/&#(\d+);/g, (_, d) => String.fromCodePoint(Number(d)))
212
+ .replace(/&lt;/g, '<')
213
+ .replace(/&gt;/g, '>')
214
+ .replace(/&quot;/g, '"')
215
+ .replace(/&apos;/g, "'")
216
+ .replace(/&amp;/g, '&')
217
+ }
218
+
219
+ // PHPUnit method names are titles too: test_a_wrong_password_is_flashed and
220
+ // testWrongPassword become "a wrong password is flashed" and "wrong password".
221
+ export function humanize(name) {
222
+ if (/\s/.test(name)) return name
223
+ let n = name.replace(/^test_?/, '')
224
+ if (n.includes('_')) n = n.replace(/_/g, ' ')
225
+ else n = n.replace(/([a-z0-9])([A-Z])/g, '$1 $2').toLowerCase()
226
+ return n || name
227
+ }
228
+
229
+ // vitest list --json: [{ name: "describe > test", file }]
230
+ export function parseVitestList(json, root) {
231
+ return json.map((t) => ({ file: relFile(root, t.file), titles: t.name.split(' > ') }))
232
+ }
233
+
234
+ export function stripAnsi(s) {
235
+ return String(s).replace(/\u001b\[[0-9;]*m/g, '')
236
+ }
237
+
238
+ export function testKey(suite, file, titles) {
239
+ return [suite, file, titles.join(SEP)].join('\t')
240
+ }
241
+
242
+ // ---------- logs ----------
243
+ // Log line for a test: STATUS<TAB>suite<TAB>file<TAB>title › title<TAB>ms
244
+ // Lines starting with "#" are headers, lines starting with " " are error details.
245
+
246
+ const LOG_NAME = /^(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})(\d{2})-test-log\.txt$/
247
+
248
+ export function listLogs(logDir) {
249
+ if (!fs.existsSync(logDir)) return []
250
+ return fs
251
+ .readdirSync(logDir)
252
+ .filter((f) => LOG_NAME.test(f))
253
+ .sort() // timestamp names sort chronologically
254
+ }
255
+
256
+ export function logTimestamp(name) {
257
+ const m = LOG_NAME.exec(name)
258
+ return `${m[1]}-${m[2]}-${m[3]} ${m[4]}:${m[5]}`
259
+ }
260
+
261
+ export function readLog(logDir, name) {
262
+ const lines = fs.readFileSync(path.join(logDir, name), 'utf8').split('\n')
263
+ const header = {}
264
+ const tests = []
265
+ lines.forEach((line, idx) => {
266
+ const h = /^# (\w[\w ]*): (.*)$/.exec(line)
267
+ if (h) header[h[1]] = h[2]
268
+ const m = /^(PASS|FAIL|SKIP)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t?(.*)$/.exec(line)
269
+ if (m) {
270
+ tests.push({
271
+ status: { PASS: 'passed', FAIL: 'failed', SKIP: 'skipped' }[m[1]],
272
+ suite: m[2],
273
+ file: m[3],
274
+ titles: m[4].split(SEP),
275
+ line: idx + 1,
276
+ log: name,
277
+ })
278
+ }
279
+ })
280
+ return { header, tests }
281
+ }
282
+
283
+ // ---------- inventory: which tests exist right now ----------
284
+
285
+ function listSuite(cfg, suite) {
286
+ const runner = suite.runner
287
+ const cwd = path.resolve(cfg.root, suite.cwd ?? '.')
288
+ const extra = (suite.args ?? []).join(' ')
289
+ try {
290
+ if (runner === 'vitest') {
291
+ const stdout = execSync(`npx vitest list --json ${extra}`, {
292
+ cwd,
293
+ stdio: ['ignore', 'pipe', 'ignore'],
294
+ maxBuffer: 256 * 1024 * 1024,
295
+ env: { ...process.env, ...suite.env },
296
+ }).toString()
297
+ return parseVitestList(JSON.parse(stdout.slice(stdout.indexOf('['))), cfg.root)
298
+ }
299
+ if (runner === 'playwright') {
300
+ const stdout = execSync(`npx playwright test --list --reporter=json ${extra}`, {
301
+ cwd,
302
+ stdio: ['ignore', 'pipe', 'ignore'],
303
+ maxBuffer: 256 * 1024 * 1024,
304
+ env: { ...process.env, ...suite.env },
305
+ })
306
+ return parsePlaywrightJson(JSON.parse(stdout.toString()), cfg.root, { listOnly: true })
307
+ }
308
+ } catch (e) {
309
+ console.warn(
310
+ `test-summary: kunde inte lista tester i sviten ${suite.name} (${e.message.split('\n')[0]}). Visar bara loggade tester för den.`,
311
+ )
312
+ }
313
+ return null // unknown: fall back to what the logs contain
314
+ }
315
+
316
+ // ---------- grouping ----------
317
+
318
+ function placeTest(cfg, suiteCfg, t) {
319
+ for (const g of cfg.groups) {
320
+ if ((!g.suite || g.suite === t.suite) && g.re.test(t.file)) {
321
+ return {
322
+ layer: g.layer ?? suiteCfg?.layer ?? cfg.layers[0],
323
+ section: g.section ?? null,
324
+ titles: t.titles,
325
+ }
326
+ }
327
+ }
328
+ return { layer: suiteCfg?.layer ?? cfg.layers[0], section: null, titles: t.titles }
329
+ }
330
+
331
+ function sectionFor(placed, file, text) {
332
+ if (placed.section) return { section: placed.section, rest: placed.titles }
333
+ // Outermost describe is the section, otherwise the file name.
334
+ if (placed.titles.length > 1) return { section: placed.titles[0], rest: placed.titles.slice(1) }
335
+ const base =
336
+ file === '-'
337
+ ? text.other
338
+ : path
339
+ .basename(file)
340
+ .replace(/(\.(test|spec|e2e|int|staging))*\.[cm]?[jt]sx?$/, '')
341
+ .replace(/(Test)?\.php$/, '')
342
+ return { section: base, rest: placed.titles }
343
+ }
344
+
345
+ // ---------- build ----------
346
+
347
+ export function buildSummary(cfg, { list = true } = {}) {
348
+ const text = TEXT[cfg.language] ?? TEXT.sv
349
+ const logs = listLogs(cfg.logDir)
350
+ const latest = new Map() // key -> logged test (newest wins)
351
+ const headers = new Map()
352
+ for (const name of logs) {
353
+ const { header, tests } = readLog(cfg.logDir, name)
354
+ headers.set(name, header)
355
+ for (const t of tests) latest.set(testKey(t.suite, t.file, t.titles), t)
356
+ }
357
+
358
+ // Inventory per suite. null means "unknown", then the logs decide.
359
+ const inventory = new Map()
360
+ if (list) {
361
+ for (const s of cfg.suites) {
362
+ if (s.runner === 'vitest' || s.runner === 'playwright')
363
+ inventory.set(s.name, listSuite(cfg, s))
364
+ }
365
+ }
366
+
367
+ const rows = []
368
+ const seen = new Set()
369
+ for (const s of cfg.suites) {
370
+ const inv = inventory.get(s.name)
371
+ if (inv) {
372
+ for (const t of inv) {
373
+ const key = testKey(s.name, t.file, t.titles)
374
+ if (seen.has(key)) continue
375
+ seen.add(key)
376
+ rows.push(
377
+ latest.get(key) ?? { status: 'missing', suite: s.name, file: t.file, titles: t.titles },
378
+ )
379
+ }
380
+ }
381
+ }
382
+ for (const [key, t] of latest) {
383
+ if (seen.has(key)) continue
384
+ // Listed suite: a logged test missing from the list no longer exists and is
385
+ // dropped. Exception: vitest does not list skipped tests, so a skipped test
386
+ // stays while its file exists.
387
+ const inv = inventory.get(t.suite)
388
+ if (inv && !(t.status === 'skipped' && fs.existsSync(path.resolve(cfg.root, t.file)))) continue
389
+ if (!cfg.suites.some((s) => s.name === t.suite)) continue // suite removed from config
390
+ seen.add(key)
391
+ rows.push(t)
392
+ }
393
+
394
+ // Group: layer -> section -> rows
395
+ const tree = new Map(cfg.layers.map((l) => [l, new Map()]))
396
+ for (const r of rows) {
397
+ const suiteCfg = cfg.suites.find((s) => s.name === r.suite)
398
+ const placed = placeTest(cfg, suiteCfg, r)
399
+ const { section, rest } = sectionFor(placed, r.file, text)
400
+ if (!tree.has(placed.layer)) tree.set(placed.layer, new Map())
401
+ const layer = tree.get(placed.layer)
402
+ if (!layer.has(section)) layer.set(section, [])
403
+ layer.get(section).push({ ...r, label: rest.join(SEP) })
404
+ }
405
+
406
+ const count = (st) => rows.filter((r) => r.status === st).length
407
+ const usedLogs = [...new Set(rows.filter((r) => r.log).map((r) => r.log))].sort().reverse()
408
+ const outDir = path.dirname(cfg.output)
409
+ const linkTo = (log, line) => {
410
+ const rel = path.relative(outDir, path.join(cfg.logDir, log)).split(path.sep).join('/')
411
+ return line ? `${rel}#L${line}` : rel
412
+ }
413
+ const logDirRel = path.relative(outDir, cfg.logDir).split(path.sep).join('/') || '.'
414
+ const scriptRel = path
415
+ .relative(cfg.root, path.join(cfg.root, 'scripts/test-summary.mjs'))
416
+ .split(path.sep)
417
+ .join('/')
418
+
419
+ const md = []
420
+ md.push(`# ${text.title}`, '')
421
+ if (cfg.intro) md.push(cfg.intro.trim(), '')
422
+ md.push(text.generated(scriptRel, logDirRel), '')
423
+ md.push(
424
+ text.state(rows.length, count('passed'), count('failed'), count('skipped'), count('missing')),
425
+ '',
426
+ )
427
+ if (usedLogs.length) {
428
+ md.push(text.logsHeading, '')
429
+ for (const log of usedLogs) {
430
+ const h = headers.get(log) ?? {}
431
+ const what = [h.suites, h.commit && h.commit !== '-' && `commit ${h.commit}`]
432
+ .filter(Boolean)
433
+ .join(', ')
434
+ md.push(`- [${log}](${linkTo(log)})${what ? `: ${what}` : ''}`)
435
+ }
436
+ md.push('')
437
+ }
438
+
439
+ const fmt = (r, n) => {
440
+ const status = text.status[r.status]
441
+ const where = r.log
442
+ ? ` · [${text.row(logTimestamp(r.log), r.line)}](${linkTo(r.log, r.line)})`
443
+ : ''
444
+ return `${n}. ${r.label} · ${status}${where}`
445
+ }
446
+
447
+ const failed = rows.filter((r) => r.status === 'failed')
448
+ if (failed.length) {
449
+ md.push(`## ${text.failedHeading}`, '')
450
+ failed.forEach((r, i) =>
451
+ md.push(fmt({ ...r, label: `${r.file}: ${r.titles.join(SEP)}` }, i + 1)),
452
+ )
453
+ md.push('')
454
+ }
455
+
456
+ for (const [layer, sections] of tree) {
457
+ if (sections.size === 0) continue
458
+ md.push(`## ${layer}`, '')
459
+ for (const [section, list] of sections) {
460
+ md.push(`### ${section}`, '')
461
+ list.forEach((r, i) => md.push(fmt(r, i + 1)))
462
+ md.push('')
463
+ }
464
+ }
465
+
466
+ return { markdown: md.join('\n'), usedLogs, rows }
467
+ }
468
+
469
+ // Removes old logs that no row points to, keeping the newest `keepLogs`.
470
+ export function pruneLogs(cfg, usedLogs) {
471
+ const logs = listLogs(cfg.logDir)
472
+ const keep = new Set([...logs.slice(-cfg.keepLogs), ...usedLogs])
473
+ const removed = logs.filter((l) => !keep.has(l))
474
+ for (const l of removed) fs.unlinkSync(path.join(cfg.logDir, l))
475
+ return removed
476
+ }
477
+
478
+ export function writeSummary(cfg, opts) {
479
+ const { markdown, usedLogs, rows } = buildSummary(cfg, opts)
480
+ fs.mkdirSync(path.dirname(cfg.output), { recursive: true })
481
+ fs.writeFileSync(cfg.output, markdown)
482
+ const removed = pruneLogs(cfg, usedLogs)
483
+ const failed = rows.filter((r) => r.status === 'failed').length
484
+ const missing = rows.filter((r) => r.status === 'missing').length
485
+ console.log(
486
+ `test-summary: ${path.relative(process.cwd(), cfg.output)} skriven, ${rows.length} tester, ${failed} underkända, ${missing} saknar logg` +
487
+ (removed.length ? `, ${removed.length} gamla loggar borttagna` : ''),
488
+ )
489
+ return { rows, failed }
490
+ }
491
+
492
+ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
493
+ const argv = process.argv.slice(2)
494
+ writeSummary(loadConfig(argv), { list: !argv.includes('--no-list') })
495
+ }
@@ -61,7 +61,7 @@ Apply even in unattended mode. `.claude/settings.json` already denies force push
61
61
 
62
62
  **Customer projects ship through release branches** (Haus's own repos keep `main` plus tags unless they opt in):
63
63
 
64
- 1. Branches are `main`, `release/YYYY-MM-DD` (the test environment, no merge gate), `ticket/<id>-<slug>` and `hotfix/<slug>`. `haus release init` writes the rows into `deploy.json` (the human confirms), `haus release start` cuts the release branch.
64
+ 1. Branches are `main`, `release/<n>` (the test environment, no merge gate; numbered on from the highest `release/<n>`, a dated `release/YYYY-MM-DD` with `--date`), `ticket/<id>-<slug>` and `hotfix/<slug>`. `haus release init` writes the rows into `deploy.json` (the human confirms), `haus release start` cuts the release branch.
65
65
  2. A ticket reaches the release branch with `haus release merge`, which opens the PR and squash-merges it in one step.
66
66
  3. `haus release ship` opens the release PR into `main`, the one exception to squash: `gh pr merge <n> --merge --match-head-commit <sha>`. It needs a green full-suite status and the human's go.
67
67
  4. A merge into `main` deploys nothing. Then `haus release tag`, and production is `haus release deploy <tag>`, run only with the human's go.