bmad-method-test-architecture-enterprise 4.0.0 → 4.0.1
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/.claude-plugin/marketplace.json +1 -1
- package/cli/lib/resolve-tea-config.js +98 -35
- package/cli/lib/trace-command.js +2 -2
- package/cli/migrate-customizations.js +186 -17
- package/cli/test-review.js +5 -1
- package/package.json +1 -1
- package/skills/bmad-tea-framework/resources/hooks/tea-enforce.cjs +317 -28
- package/skills/bmad-tea-trace/steps-c/step-04-analyze-gaps.md +2 -2
- package/skills/bmad-tea-trace/steps-c/step-05-gate-decision.md +2 -2
- package/skills/bmod-tea/bmod.toml +2 -2
- package/skills/bmod-tea/migration-1.toml +1 -1
- package/skills/bmod-tea/migration-3.toml +6 -6
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"name": "bmad-method-test-architecture-enterprise",
|
|
32
32
|
"source": "./",
|
|
33
33
|
"description": "Master Test Architect module for quality strategy, test generation in red and expand modes with automatic run-and-heal, combined framework and CI setup, CI/CD quality gates, and structured testing education. Existing CI and ATDD customizations can be migrated to the new skill names. Part of the BMad Method ecosystem.",
|
|
34
|
-
"version": "4.0.
|
|
34
|
+
"version": "4.0.1",
|
|
35
35
|
"author": {
|
|
36
36
|
"name": "Murat K Ozcan (TEA Creator) & Brian (BMad) Madison"
|
|
37
37
|
},
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* 2. The consuming project's `[modules.tea]` table, merged from
|
|
12
12
|
* _bmad/config.toml, _bmad/custom/config.toml and
|
|
13
13
|
* _bmad/custom/config.user.toml (later files win), the three files
|
|
14
|
-
* BMad core merges, as `bmad setup tea` writes it.
|
|
15
|
-
* _bmad/
|
|
14
|
+
* BMad core merges, as `bmad setup tea` writes it. Each layer counts when its file exists, so custom
|
|
15
|
+
* layers apply even where the installer-owned _bmad/config.toml is not committed. Only when none of the
|
|
16
|
+
* three exists is a v6 _bmad/tea/config.yaml read instead, so older installs keep working in CI.
|
|
16
17
|
* 3. The module default declared in skills/bmod-tea/bmod.toml
|
|
17
18
|
*
|
|
18
19
|
* Step 01 of the workflow branches on these keys (Playwright Utils loading
|
|
@@ -32,7 +33,7 @@ const TOML = require('smol-toml');
|
|
|
32
33
|
const { minimatch } = require('minimatch');
|
|
33
34
|
const { globSync } = require('glob');
|
|
34
35
|
|
|
35
|
-
/** The central config layers, lowest precedence first, the three files BMad core merges.
|
|
36
|
+
/** The central config layers, lowest precedence first, the three files BMad core merges. Each applies when its file exists. */
|
|
36
37
|
const CONFIG_LAYER_RELATIVE_PATHS = [
|
|
37
38
|
path.join('_bmad', 'config.toml'),
|
|
38
39
|
path.join('_bmad', 'custom', 'config.toml'),
|
|
@@ -44,8 +45,18 @@ const LEGACY_CONFIG_RELATIVE_PATH = path.join('_bmad', 'tea', 'config.yaml');
|
|
|
44
45
|
const LEGACY_USER_CONFIG_RELATIVE_PATH = path.join('_bmad', 'config.user.toml');
|
|
45
46
|
const warnedLegacyUserConfig = new Set();
|
|
46
47
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Tell the user once per process that `[modules.tea]` keys in the legacy personal layer are ignored.
|
|
50
|
+
*
|
|
51
|
+
* The old core order was config.toml, config.user.toml, custom/config.toml, custom/config.user.toml
|
|
52
|
+
* (later wins), so the legacy file outranked only `_bmad/config.toml`. A legacy key lost its effect
|
|
53
|
+
* when neither custom layer holds it. When `_bmad/config.toml` holds the same value, nothing
|
|
54
|
+
* changed and the key stays quiet; a different value there is shown next to the legacy one.
|
|
55
|
+
*
|
|
56
|
+
* @param {object} source - Working-tree or pinned-base configuration reader.
|
|
57
|
+
* @param {{label: string, tea: object}[]} layers - The central layers in merge order, each with its own `[modules.tea]` table.
|
|
58
|
+
*/
|
|
59
|
+
function warnLegacyUserConfig(source, layers) {
|
|
49
60
|
const content = source.read(LEGACY_USER_CONFIG_RELATIVE_PATH);
|
|
50
61
|
if (content === null) return;
|
|
51
62
|
const label = source.label(LEGACY_USER_CONFIG_RELATIVE_PATH);
|
|
@@ -57,11 +68,25 @@ function warnLegacyUserConfig(source, tea) {
|
|
|
57
68
|
return;
|
|
58
69
|
}
|
|
59
70
|
if (!isPlainObject(legacyTea)) return;
|
|
60
|
-
const
|
|
71
|
+
const [base, ...custom] = layers;
|
|
72
|
+
const ignored = [];
|
|
73
|
+
const shadowed = [];
|
|
74
|
+
for (const [key, value] of Object.entries(legacyTea)) {
|
|
75
|
+
if (custom.some((layer) => Object.hasOwn(layer.tea, key))) continue;
|
|
76
|
+
if (!Object.hasOwn(base.tea, key)) {
|
|
77
|
+
ignored.push(key);
|
|
78
|
+
} else if (JSON.stringify(base.tea[key]) !== JSON.stringify(value)) {
|
|
79
|
+
ignored.push(key);
|
|
80
|
+
shadowed.push(
|
|
81
|
+
`${key} is ${JSON.stringify(value)} in ${label} and ${JSON.stringify(base.tea[key])} in ${base.label}, which TEA uses.`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
61
85
|
if (ignored.length === 0) return;
|
|
62
86
|
warnedLegacyUserConfig.add(label);
|
|
87
|
+
const detail = shadowed.length === 0 ? '' : ` ${shadowed.join(' ')}`;
|
|
63
88
|
process.stderr.write(
|
|
64
|
-
`Warning: ${label} is no longer merged. TEA ignores its [modules.tea] keys (${ignored.join(', ')})
|
|
89
|
+
`Warning: ${label} is no longer merged. TEA ignores its [modules.tea] keys (${ignored.join(', ')}).${detail} Run \`bmad migrate tea\` to move them into _bmad/custom/config.user.toml.\n`,
|
|
65
90
|
);
|
|
66
91
|
}
|
|
67
92
|
|
|
@@ -427,28 +452,38 @@ function unionEqualCustomizationValues(legacy, current) {
|
|
|
427
452
|
return result;
|
|
428
453
|
}
|
|
429
454
|
|
|
430
|
-
/**
|
|
455
|
+
/**
|
|
456
|
+
* Coerce the keys this CLI cares about out of a raw TEA config table.
|
|
457
|
+
*
|
|
458
|
+
* @param {object} table - Raw `[modules.tea]` keys.
|
|
459
|
+
* @param {string|Record<string, string>} source - One label for every key, or the label of the file that supplied each key.
|
|
460
|
+
*/
|
|
431
461
|
function pickTeaValues(table, source) {
|
|
462
|
+
const labelOf = (key) => (typeof source === 'string' ? source : (source[key] ?? 'the configuration'));
|
|
432
463
|
const values = {};
|
|
433
464
|
if ('tea_use_playwright_utils' in table) {
|
|
434
|
-
values.tea_use_playwright_utils = coerceBoolean(
|
|
465
|
+
values.tea_use_playwright_utils = coerceBoolean(
|
|
466
|
+
table.tea_use_playwright_utils,
|
|
467
|
+
'tea_use_playwright_utils',
|
|
468
|
+
labelOf('tea_use_playwright_utils'),
|
|
469
|
+
);
|
|
435
470
|
}
|
|
436
471
|
if ('tea_use_pactjs_utils' in table) {
|
|
437
|
-
values.tea_use_pactjs_utils = coerceBoolean(table.tea_use_pactjs_utils, 'tea_use_pactjs_utils',
|
|
472
|
+
values.tea_use_pactjs_utils = coerceBoolean(table.tea_use_pactjs_utils, 'tea_use_pactjs_utils', labelOf('tea_use_pactjs_utils'));
|
|
438
473
|
}
|
|
439
474
|
if ('tea_pact_mcp' in table) {
|
|
440
|
-
values.tea_pact_mcp = coercePactMcp(table.tea_pact_mcp,
|
|
475
|
+
values.tea_pact_mcp = coercePactMcp(table.tea_pact_mcp, labelOf('tea_pact_mcp'));
|
|
441
476
|
}
|
|
442
477
|
if ('tea_execution_mode' in table) {
|
|
443
|
-
values.tea_execution_mode = coerceExecutionMode(table.tea_execution_mode,
|
|
478
|
+
values.tea_execution_mode = coerceExecutionMode(table.tea_execution_mode, labelOf('tea_execution_mode'));
|
|
444
479
|
}
|
|
445
480
|
if ('tea_capability_probe' in table) {
|
|
446
|
-
values.tea_capability_probe = coerceBoolean(table.tea_capability_probe, 'tea_capability_probe',
|
|
481
|
+
values.tea_capability_probe = coerceBoolean(table.tea_capability_probe, 'tea_capability_probe', labelOf('tea_capability_probe'));
|
|
447
482
|
}
|
|
448
483
|
if ('test_stack_type' in table) {
|
|
449
484
|
const stack = typeof table.test_stack_type === 'string' ? table.test_stack_type.trim().toLowerCase() : '';
|
|
450
485
|
if (!['auto', 'frontend', 'backend', 'fullstack', 'mobile'].includes(stack)) {
|
|
451
|
-
throw configError(`test_stack_type in ${
|
|
486
|
+
throw configError(`test_stack_type in ${labelOf('test_stack_type')} must be auto, frontend, backend, fullstack or mobile`);
|
|
452
487
|
}
|
|
453
488
|
values.test_stack_type = stack;
|
|
454
489
|
}
|
|
@@ -457,31 +492,47 @@ function pickTeaValues(table, source) {
|
|
|
457
492
|
|
|
458
493
|
/**
|
|
459
494
|
* Merge the central TOML layers and return their core and TEA tables.
|
|
495
|
+
* Each layer is shape-checked before the merge, and every `[modules.tea]` key
|
|
496
|
+
* remembers the file that supplied its final value, so errors name that file.
|
|
460
497
|
*
|
|
461
498
|
* @param {object} source - Working-tree or pinned-base configuration reader.
|
|
462
|
-
* @returns {{core: object, tea: object}}
|
|
499
|
+
* @returns {{core: object, tea: object, teaSources: Record<string, string>, found: string[]}}
|
|
500
|
+
* `found` lists the labels of the layer files that exist.
|
|
463
501
|
*/
|
|
464
502
|
function readCentralConfig(source) {
|
|
465
503
|
let merged = {};
|
|
504
|
+
const layers = [];
|
|
505
|
+
const found = [];
|
|
506
|
+
const teaSources = {};
|
|
466
507
|
for (const relativePath of CONFIG_LAYER_RELATIVE_PATHS) {
|
|
508
|
+
const label = source.label(relativePath);
|
|
467
509
|
const content = source.read(relativePath);
|
|
468
|
-
if (content === null)
|
|
469
|
-
|
|
510
|
+
if (content === null) {
|
|
511
|
+
layers.push({ label, tea: {} });
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
found.push(label);
|
|
515
|
+
const parsed = parseToml(content, label);
|
|
516
|
+
const { modules, core } = parsed;
|
|
517
|
+
if (modules !== undefined && !isPlainObject(modules)) {
|
|
518
|
+
throw configError(`[modules] in ${label} must be a table`);
|
|
519
|
+
}
|
|
520
|
+
if (modules?.tea !== undefined && !isPlainObject(modules.tea)) {
|
|
521
|
+
throw configError(`[modules.tea] in ${label} must be a table of config keys`);
|
|
522
|
+
}
|
|
523
|
+
if (core !== undefined && !isPlainObject(core)) {
|
|
524
|
+
throw configError(`[core] in ${label} must be a table of config keys`);
|
|
525
|
+
}
|
|
526
|
+
layers.push({ label, tea: modules?.tea || {} });
|
|
527
|
+
for (const key of Object.keys(modules?.tea || {})) teaSources[key] = label;
|
|
470
528
|
merged = mergeTables(merged, parsed);
|
|
471
529
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
throw configError(`[modules.tea] in ${source.label(CONFIG_RELATIVE_PATH)} must be a table of config keys`);
|
|
475
|
-
}
|
|
476
|
-
warnLegacyUserConfig(source, modules?.tea || {});
|
|
477
|
-
if (merged.core !== undefined && !isPlainObject(merged.core)) {
|
|
478
|
-
throw configError(`[core] in ${source.label(CONFIG_RELATIVE_PATH)} must be a table of config keys`);
|
|
479
|
-
}
|
|
480
|
-
return { core: merged.core || {}, tea: modules?.tea || {} };
|
|
530
|
+
warnLegacyUserConfig(source, layers);
|
|
531
|
+
return { core: merged.core || {}, tea: merged.modules?.tea || {}, teaSources, found };
|
|
481
532
|
}
|
|
482
533
|
|
|
483
534
|
/**
|
|
484
|
-
* Read a v6 _bmad/tea/config.yaml, used only when
|
|
535
|
+
* Read a v6 _bmad/tea/config.yaml, used only when none of the central TOML layers exists.
|
|
485
536
|
*
|
|
486
537
|
* @param {string} configPath
|
|
487
538
|
* @param {string} content
|
|
@@ -510,17 +561,20 @@ function readLegacyTeaTable(configPath, content) {
|
|
|
510
561
|
*
|
|
511
562
|
* @param {string} projectRoot - Consuming project root.
|
|
512
563
|
* @param {string} [baseRef] - Base commit or ref; omitted for working-tree config.
|
|
513
|
-
* @returns {{present: boolean, path: string, format: 'toml'|'yaml'|null, values: object}}
|
|
564
|
+
* @returns {{present: boolean, path: string, paths: string[], format: 'toml'|'yaml'|null, values: object}}
|
|
565
|
+
* Present when any of the three central layers exists. `paths` lists the files read; `path` is the base
|
|
566
|
+
* file when it exists, else the first layer found, else the base file's expected location.
|
|
514
567
|
*/
|
|
515
568
|
function readTeaConfigFile(projectRoot, baseRef, source = configSource(projectRoot, baseRef)) {
|
|
516
569
|
const centralPath = source.label(CONFIG_RELATIVE_PATH);
|
|
517
|
-
|
|
518
|
-
|
|
570
|
+
const config = readCentralConfig(source);
|
|
571
|
+
if (config.found.length > 0) {
|
|
519
572
|
return {
|
|
520
573
|
present: true,
|
|
521
|
-
path: centralPath,
|
|
574
|
+
path: config.found.includes(centralPath) ? centralPath : config.found[0],
|
|
575
|
+
paths: config.found,
|
|
522
576
|
format: 'toml',
|
|
523
|
-
values: pickTeaValues(config.tea,
|
|
577
|
+
values: pickTeaValues(config.tea, config.teaSources),
|
|
524
578
|
core: config.core,
|
|
525
579
|
tea: config.tea,
|
|
526
580
|
};
|
|
@@ -534,9 +588,17 @@ function readTeaConfigFile(projectRoot, baseRef, source = configSource(projectRo
|
|
|
534
588
|
.filter((key) => key in table)
|
|
535
589
|
.map((key) => [key, table[key]]),
|
|
536
590
|
);
|
|
537
|
-
return {
|
|
591
|
+
return {
|
|
592
|
+
present: true,
|
|
593
|
+
path: legacyPath,
|
|
594
|
+
paths: [legacyPath],
|
|
595
|
+
format: 'yaml',
|
|
596
|
+
values: pickTeaValues(table, legacyPath),
|
|
597
|
+
core,
|
|
598
|
+
tea: table,
|
|
599
|
+
};
|
|
538
600
|
}
|
|
539
|
-
return { present: false, path: centralPath, format: null, values: {}, core: {}, tea: {} };
|
|
601
|
+
return { present: false, path: centralPath, paths: [], format: null, values: {}, core: {}, tea: {} };
|
|
540
602
|
}
|
|
541
603
|
|
|
542
604
|
/**
|
|
@@ -599,7 +661,7 @@ const KEY_TO_INSTALLED_FIELD = {
|
|
|
599
661
|
* FLAG_TO_KEY are read, and only when not undefined.
|
|
600
662
|
* @param {Set<string>} [options.inputPaths] - Receives working-tree inputs, including missing optional layers.
|
|
601
663
|
* @param {Map<string, string[]>} [options.inputPatterns] - Receives policy glob membership used during resolution.
|
|
602
|
-
* @returns {{values: object, sources: object, installed: object, configSnapshot: object, workflowCustomization: object, configCommit: string|null, configPath: string, configPresent: boolean, configFormat: string|null}}
|
|
664
|
+
* @returns {{values: object, sources: object, installed: object, configSnapshot: object, workflowCustomization: object, configCommit: string|null, configPath: string, configPaths: string[], configPresent: boolean, configFormat: string|null}}
|
|
603
665
|
* `installed` carries one boolean per library gate, read from the project
|
|
604
666
|
* manifest rather than left to the agent.
|
|
605
667
|
* @throws {Error} With code TEA_CONFIG_INVALID on unusable config content.
|
|
@@ -655,6 +717,7 @@ function resolveTeaConfig({ projectRoot, flags = {}, baseRef, skillRoot, skillNa
|
|
|
655
717
|
workflowCustomization,
|
|
656
718
|
configCommit: source.commit ?? null,
|
|
657
719
|
configPath: file.path,
|
|
720
|
+
configPaths: file.paths,
|
|
658
721
|
configPresent: file.present,
|
|
659
722
|
configFormat: file.format,
|
|
660
723
|
};
|
package/cli/lib/trace-command.js
CHANGED
|
@@ -1310,7 +1310,7 @@ function validateTraceOutputs({
|
|
|
1310
1310
|
) {
|
|
1311
1311
|
throw new Error(`Trace coverage ${name} has invalid counts.`);
|
|
1312
1312
|
}
|
|
1313
|
-
const expected = bucket.total === 0 ? 100 : Math.
|
|
1313
|
+
const expected = bucket.total === 0 ? 100 : Math.floor((bucket.covered * 100) / bucket.total);
|
|
1314
1314
|
if (bucket.pct !== expected) throw new Error(`Trace coverage ${name} percentage does not match its counts.`);
|
|
1315
1315
|
}
|
|
1316
1316
|
const priorities = ['P0', 'P1', 'P2', 'P3'].map((key) => summary.coverage.priority_breakdown[key]);
|
|
@@ -1415,7 +1415,7 @@ function validateTraceOutputs({
|
|
|
1415
1415
|
const p0 = summary.coverage.priority_breakdown.P0.pct;
|
|
1416
1416
|
const p1 = summary.coverage.priority_breakdown.P1.pct;
|
|
1417
1417
|
const overall = summary.coverage.inventory.pct;
|
|
1418
|
-
//
|
|
1418
|
+
// Displayed percentages round down, so they reach a whole-number threshold exactly when the counts do; decisions compare the source counts.
|
|
1419
1419
|
const meets = (bucket, threshold) => bucket.total === 0 || bucket.covered * 100 >= threshold * bucket.total;
|
|
1420
1420
|
const p0Met = meets(summary.coverage.priority_breakdown.P0, 100);
|
|
1421
1421
|
const p1TargetMet = meets(summary.coverage.priority_breakdown.P1, 90);
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* stems into [workflow.red] and [workflow.ci] of their owning skills, and agent menu references to current skill ids.
|
|
5
5
|
*/
|
|
6
6
|
const fs = require('node:fs');
|
|
7
|
+
const os = require('node:os');
|
|
7
8
|
const path = require('node:path');
|
|
8
9
|
const { isDeepStrictEqual } = require('node:util');
|
|
9
10
|
const TOML = require('smol-toml');
|
|
@@ -296,17 +297,31 @@ function legacyConfigNotice(root, backups) {
|
|
|
296
297
|
if (!legacy) return null;
|
|
297
298
|
const tea = tryParse(legacy.text)?.modules?.tea;
|
|
298
299
|
if (!isTable(tea)) return null;
|
|
299
|
-
|
|
300
|
-
|
|
300
|
+
// The old core order was config.toml, config.user.toml, custom/config.toml, custom/config.user.toml, so only the custom layers outranked the legacy file.
|
|
301
|
+
const teaTable = (segments) => {
|
|
301
302
|
const file = path.join(root, ...segments);
|
|
302
303
|
const text = readOptional(file);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
const layer = text === null ? undefined : parse(file, text).modules?.tea;
|
|
305
|
+
return { file, tea: isTable(layer) ? layer : {} };
|
|
306
|
+
};
|
|
307
|
+
const held = new Set();
|
|
308
|
+
for (const segments of CONFIG_LAYERS.slice(1)) for (const key of Object.keys(teaTable(segments).tea)) held.add(key);
|
|
309
|
+
const base = teaTable(CONFIG_LAYERS[0]);
|
|
310
|
+
const ignored = [];
|
|
311
|
+
const shadowed = [];
|
|
312
|
+
for (const [key, value] of Object.entries(tea)) {
|
|
313
|
+
if (held.has(key)) continue;
|
|
314
|
+
if (Object.hasOwn(base.tea, key) && JSON.stringify(base.tea[key]) === JSON.stringify(value)) continue;
|
|
315
|
+
ignored.push(key);
|
|
316
|
+
if (Object.hasOwn(base.tea, key)) {
|
|
317
|
+
shadowed.push(
|
|
318
|
+
`${key} is ${JSON.stringify(value)} in ${legacy.file} and ${JSON.stringify(base.tea[key])} in ${base.file}, which TEA uses.`,
|
|
319
|
+
);
|
|
320
|
+
}
|
|
306
321
|
}
|
|
307
|
-
const ignored = Object.keys(tea).filter((key) => !held.has(key));
|
|
308
322
|
if (ignored.length === 0) return null;
|
|
309
|
-
const
|
|
323
|
+
const detail = shadowed.length === 0 ? '' : ` ${shadowed.join(' ')}`;
|
|
324
|
+
const line = `Not migrated by this command: ${legacy.file} [modules.tea] keys ${ignored.join(', ')} are ignored by TEA.${detail} Run \`bmad migrate tea\` to move them.`;
|
|
310
325
|
return { kind: 'notice', messages: [{ done: line, check: line }] };
|
|
311
326
|
}
|
|
312
327
|
|
|
@@ -787,26 +802,179 @@ function migrate(projectRoot, { check = false, keepExisting = false, beforeActio
|
|
|
787
802
|
fs.mkdirSync(customRoot);
|
|
788
803
|
}
|
|
789
804
|
const lock = path.join(customRoot, '.tea-migration.lock');
|
|
805
|
+
const recovered = [];
|
|
806
|
+
holdSignals();
|
|
790
807
|
try {
|
|
791
|
-
|
|
808
|
+
acquireLock(lock, customRoot, recovered);
|
|
809
|
+
try {
|
|
810
|
+
const plan = preflight(root, customRoot, { keepExisting });
|
|
811
|
+
applyActions(plan.actions, customRoot, beforeAction);
|
|
812
|
+
if (!isDeepStrictEqual(plan.nextRecord, plan.record)) writeRecord(customRoot, plan.nextRecord);
|
|
813
|
+
return [...recovered.map(recoveryNotice), ...plan.actions];
|
|
814
|
+
} finally {
|
|
815
|
+
releaseLock(lock);
|
|
816
|
+
}
|
|
817
|
+
} finally {
|
|
818
|
+
releaseSignals();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
const LOCK_OWNER = 'owner.json';
|
|
823
|
+
const SIGNALS = ['SIGINT', 'SIGTERM'];
|
|
824
|
+
const signalState = { holders: 0, installed: false, exitOnSignal: false };
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* The apply phase is synchronous, so Node cannot run a signal handler until it returns. Holding a listener keeps the
|
|
828
|
+
* default kill from interrupting the apply: the run finishes, the lock and temp files are released, and only then does
|
|
829
|
+
* the deferred signal take effect.
|
|
830
|
+
*/
|
|
831
|
+
function onSignal(signal) {
|
|
832
|
+
dropSignals();
|
|
833
|
+
const code = 128 + os.constants.signals[signal];
|
|
834
|
+
if (signalState.exitOnSignal) {
|
|
835
|
+
process.stderr.write(`Received ${signal}; the migration finished its current run and released the lock.\n`);
|
|
836
|
+
process.exitCode = code;
|
|
837
|
+
} else if (process.listenerCount(signal) === 0) {
|
|
838
|
+
process.kill(process.pid, signal);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function dropSignals() {
|
|
843
|
+
for (const signal of SIGNALS) process.removeListener(signal, onSignal);
|
|
844
|
+
signalState.installed = false;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function holdSignals() {
|
|
848
|
+
signalState.holders++;
|
|
849
|
+
if (signalState.installed) return;
|
|
850
|
+
for (const signal of SIGNALS) process.on(signal, onSignal);
|
|
851
|
+
signalState.installed = true;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function releaseSignals() {
|
|
855
|
+
signalState.holders--;
|
|
856
|
+
// A signal that arrived during the synchronous run is delivered on the next event-loop pass; keep the listener until then.
|
|
857
|
+
setImmediate(() => {
|
|
858
|
+
if (signalState.holders === 0 && signalState.installed) dropSignals();
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
function readLockOwner(lock) {
|
|
863
|
+
try {
|
|
864
|
+
const owner = JSON.parse(fs.readFileSync(path.join(lock, LOCK_OWNER), 'utf8'));
|
|
865
|
+
if (Number.isInteger(owner?.pid) && owner.pid > 0 && typeof owner.hostname === 'string') return owner;
|
|
866
|
+
} catch {
|
|
867
|
+
// No readable owner record: the lock stays until a person inspects it.
|
|
868
|
+
}
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
function processIsGone(pid) {
|
|
873
|
+
try {
|
|
874
|
+
process.kill(pid, 0);
|
|
875
|
+
return false;
|
|
792
876
|
} catch (error) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
877
|
+
return error.code === 'ESRCH';
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function leftoverFiles(customRoot, pid) {
|
|
882
|
+
const own = new RegExp(`^\\.tea-migration-${pid}-\\d+\\.(tmp|bak)$`);
|
|
883
|
+
const any = /^\.tea-migration-\d+-\d+\.(tmp|bak)$/;
|
|
884
|
+
let names = [];
|
|
885
|
+
try {
|
|
886
|
+
names = fs.readdirSync(customRoot);
|
|
887
|
+
} catch {
|
|
888
|
+
// The folder is checked before the lock is taken; an unreadable listing only shortens the report.
|
|
889
|
+
}
|
|
890
|
+
return names.filter((name) => (pid === undefined ? any : own).test(name)).map((name) => path.join(customRoot, name));
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
function describeOwner(owner) {
|
|
894
|
+
return `held by pid ${owner.pid} on ${owner.hostname}${owner.started_at ? ` since ${owner.started_at}` : ''}`;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
function lockHeldMessage(lock, customRoot, owner) {
|
|
898
|
+
const leftovers = leftoverFiles(customRoot, owner?.pid);
|
|
899
|
+
const parts = [`Migration lock exists at ${lock}${owner ? ` (${describeOwner(owner)})` : ''}.`];
|
|
900
|
+
parts.push(
|
|
901
|
+
owner && owner.hostname === os.hostname()
|
|
902
|
+
? 'The owning process is still running; wait for it to finish, then retry.'
|
|
903
|
+
: 'Check for a running migration; if none is running, inspect and remove the stale lock directory, then retry.',
|
|
904
|
+
);
|
|
905
|
+
if (leftovers.length > 0) parts.push(`Files left by an interrupted run: ${leftovers.join(', ')}.`);
|
|
906
|
+
return parts.join(' ');
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function recoveryNotice({ lock, owner, removed, backups }) {
|
|
910
|
+
const line =
|
|
911
|
+
`Recovered the stale migration lock ${lock} (${describeOwner(owner)}, no longer running)` +
|
|
912
|
+
`${removed.length > 0 ? `; removed ${removed.join(', ')}` : ''}` +
|
|
913
|
+
`${backups.length > 0 ? `; left ${backups.join(', ')} holding file contents from before the interrupted run` : ''}.`;
|
|
914
|
+
return { kind: 'notice', messages: [{ done: line, check: line }] };
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function acquireLock(lock, customRoot, recovered) {
|
|
918
|
+
for (let attempt = 0; ; attempt++) {
|
|
919
|
+
try {
|
|
920
|
+
fs.mkdirSync(lock, { mode: 0o700 });
|
|
921
|
+
} catch (error) {
|
|
922
|
+
if (error.code !== 'EEXIST') throw new Error(`Cannot lock ${customRoot} for migration: ${error.message}`);
|
|
923
|
+
takeOverStaleLock(lock, customRoot, recovered, attempt);
|
|
924
|
+
continue;
|
|
925
|
+
}
|
|
926
|
+
try {
|
|
927
|
+
fs.writeFileSync(
|
|
928
|
+
path.join(lock, LOCK_OWNER),
|
|
929
|
+
`${JSON.stringify({ pid: process.pid, hostname: os.hostname(), started_at: new Date().toISOString() })}\n`,
|
|
796
930
|
);
|
|
931
|
+
} catch (error) {
|
|
932
|
+
// An ownerless lock could never be recovered automatically, so give the directory back before failing.
|
|
933
|
+
fs.rmSync(lock, { recursive: true, force: true });
|
|
934
|
+
throw new Error(`Cannot record the migration lock owner in ${lock}: ${error.message}`);
|
|
797
935
|
}
|
|
798
|
-
|
|
936
|
+
return;
|
|
799
937
|
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const isStale = (owner) => owner !== null && owner.hostname === os.hostname() && processIsGone(owner.pid);
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Clear a lock whose same-host owner process is gone, with its temp files; any other existing lock is an error.
|
|
944
|
+
*
|
|
945
|
+
* Two runs can both see the same dead owner. The recovery claim is an exclusive directory, and the owner is read
|
|
946
|
+
* again while holding it, so a run that saw the dead owner can never delete a lock another run has since acquired.
|
|
947
|
+
*/
|
|
948
|
+
function takeOverStaleLock(lock, customRoot, recovered, attempt) {
|
|
949
|
+
if (attempt > 0 || !isStale(readLockOwner(lock))) throw new Error(lockHeldMessage(lock, customRoot, readLockOwner(lock)));
|
|
950
|
+
const claim = `${lock}.recovery`;
|
|
800
951
|
try {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
if (
|
|
804
|
-
|
|
952
|
+
fs.mkdirSync(claim, { mode: 0o700 });
|
|
953
|
+
} catch (error) {
|
|
954
|
+
if (error.code !== 'EEXIST') throw new Error(`Cannot claim stale lock recovery at ${claim}: ${error.message}`);
|
|
955
|
+
throw new Error(
|
|
956
|
+
`${lockHeldMessage(lock, customRoot, readLockOwner(lock))} Another run is recovering it (${claim}); if none is running, remove that directory too.`,
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
try {
|
|
960
|
+
const owner = readLockOwner(lock);
|
|
961
|
+
if (!fs.existsSync(lock)) return;
|
|
962
|
+
if (!isStale(owner)) throw new Error(lockHeldMessage(lock, customRoot, owner));
|
|
963
|
+
const leftovers = leftoverFiles(customRoot, owner.pid);
|
|
964
|
+
const removed = leftovers.filter((file) => file.endsWith('.tmp'));
|
|
965
|
+
for (const file of removed) fs.rmSync(file, { force: true });
|
|
966
|
+
fs.rmSync(lock, { recursive: true, force: true });
|
|
967
|
+
recovered.push({ lock, owner, removed, backups: leftovers.filter((file) => file.endsWith('.bak')) });
|
|
805
968
|
} finally {
|
|
806
|
-
fs.rmdirSync(
|
|
969
|
+
fs.rmdirSync(claim);
|
|
807
970
|
}
|
|
808
971
|
}
|
|
809
972
|
|
|
973
|
+
function releaseLock(lock) {
|
|
974
|
+
fs.rmSync(path.join(lock, LOCK_OWNER), { force: true });
|
|
975
|
+
fs.rmdirSync(lock);
|
|
976
|
+
}
|
|
977
|
+
|
|
810
978
|
function describe(action, check) {
|
|
811
979
|
const lines = (action.messages ?? []).map((message) => (check ? message.check : message.done));
|
|
812
980
|
if (action.kind === 'rewrite') lines.push(`${check ? 'Would update' : 'Updated'} menu references in ${action.oldFile}`);
|
|
@@ -850,6 +1018,7 @@ function main(argv = process.argv.slice(2)) {
|
|
|
850
1018
|
}
|
|
851
1019
|
|
|
852
1020
|
if (require.main === module) {
|
|
1021
|
+
signalState.exitOnSignal = true;
|
|
853
1022
|
try {
|
|
854
1023
|
process.exitCode = main();
|
|
855
1024
|
} catch (error) {
|
package/cli/test-review.js
CHANGED
|
@@ -1117,7 +1117,11 @@ async function runReview(session) {
|
|
|
1117
1117
|
configSnapshot = resolvedTeaConfig.configSnapshot;
|
|
1118
1118
|
workflowCustomization = resolvedTeaConfig.workflowCustomization;
|
|
1119
1119
|
configCommit = resolvedTeaConfig.configCommit;
|
|
1120
|
-
console.error(
|
|
1120
|
+
console.error(
|
|
1121
|
+
resolvedTeaConfig.configPresent
|
|
1122
|
+
? `tea-test-review: config ${resolvedTeaConfig.configPaths.join(', ')}`
|
|
1123
|
+
: 'tea-test-review: no config found; using module defaults',
|
|
1124
|
+
);
|
|
1121
1125
|
} catch (error) {
|
|
1122
1126
|
if (error.code === 'TEA_CONFIG_INVALID') {
|
|
1123
1127
|
fail(EXIT.ENV_ERROR, error.message);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "bmad-method-test-architecture-enterprise",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.1",
|
|
5
5
|
"description": "Master Test Architect for quality strategy, test automation, and release gates",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"bmad",
|
|
@@ -587,13 +587,69 @@ function interpolates(text, mask, kind) {
|
|
|
587
587
|
function selfComparisons(stripped, views, pattern) {
|
|
588
588
|
const spans = [];
|
|
589
589
|
for (const match of stripped.matchAll(pattern)) {
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
590
|
+
const ranges = [1, 2].map((group) => match.indices[group] ?? [0, 0]);
|
|
591
|
+
if (operandsMatch(views, ranges)) spans.push([match.index, match.index + match[0].length]);
|
|
592
|
+
}
|
|
593
|
+
return spans;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** Whether the two `[start, end]` ranges read as the same expression. */
|
|
597
|
+
function operandsMatch(views, ranges) {
|
|
598
|
+
const operands = ranges.map(([start, end]) => ({ text: views.code.slice(start, end), mask: views.mask.slice(start, end) }));
|
|
599
|
+
if (operands.some(({ text, mask }) => interpolates(text, mask, views.kind))) return false;
|
|
600
|
+
const [left, right] = operands.map(({ text, mask }) => normalizeOperand(text, mask));
|
|
601
|
+
return left.length > 0 && left === right;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* The top-level arguments of the call whose argument list starts at `from` (the
|
|
606
|
+
* index right after the opening paren), as `[start, end]` ranges, or null when the
|
|
607
|
+
* call never closes. `()`, `[]` and `{}` nest, so a comma inside an array, an
|
|
608
|
+
* object or a nested call never splits an argument. It reads the stripped view,
|
|
609
|
+
* where a literal is blank and cannot fake a bracket or a comma. A trailing comma
|
|
610
|
+
* leaves no empty last argument.
|
|
611
|
+
*/
|
|
612
|
+
function callArguments(stripped, from) {
|
|
613
|
+
const ranges = [];
|
|
614
|
+
let depth = 0;
|
|
615
|
+
let start = from;
|
|
616
|
+
for (let index = from; index < stripped.length; index += 1) {
|
|
617
|
+
const character = stripped[index];
|
|
618
|
+
if ('([{'.includes(character)) depth += 1;
|
|
619
|
+
else if (')]}'.includes(character)) {
|
|
620
|
+
if (depth === 0) {
|
|
621
|
+
if (character !== ')') return null;
|
|
622
|
+
ranges.push([start, index]);
|
|
623
|
+
if (ranges.length > 1 && stripped.slice(...ranges.at(-1)).trim() === '') ranges.pop();
|
|
624
|
+
return ranges;
|
|
625
|
+
}
|
|
626
|
+
depth -= 1;
|
|
627
|
+
} else if (character === ',' && depth === 0) {
|
|
628
|
+
ranges.push([start, index]);
|
|
629
|
+
start = index + 1;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* `selfComparisons` for assertion calls that take the compared values as their
|
|
637
|
+
* first two arguments. `prefix` matches up to the first of them.
|
|
638
|
+
*
|
|
639
|
+
* The arguments are split at top-level commas, so `assert.deepStrictEqual([1, [1, 2]], actual)`
|
|
640
|
+
* compares `[1, [1, 2]]` against `actual`. An operand with a paren in it holds a
|
|
641
|
+
* call or a grouping, which can evaluate differently each time, and is never
|
|
642
|
+
* reported.
|
|
643
|
+
*/
|
|
644
|
+
function selfComparingCalls(stripped, views, prefix) {
|
|
645
|
+
const spans = [];
|
|
646
|
+
for (const match of stripped.matchAll(prefix)) {
|
|
647
|
+
const from = match.index + match[0].length;
|
|
648
|
+
const args = callArguments(stripped, from);
|
|
649
|
+
if (!args || args.length < 2) continue;
|
|
650
|
+
const ranges = args.slice(0, 2);
|
|
651
|
+
if (ranges.some(([start, end]) => /[()]/.test(stripped.slice(start, end)))) continue;
|
|
652
|
+
if (operandsMatch(views, ranges)) spans.push([match.index, ranges[1][1]]);
|
|
597
653
|
}
|
|
598
654
|
return spans;
|
|
599
655
|
}
|
|
@@ -603,7 +659,7 @@ function matchSpans(source, pattern) {
|
|
|
603
659
|
return [...source.matchAll(pattern)].map((match) => [match.index, match.index + match[0].length]);
|
|
604
660
|
}
|
|
605
661
|
|
|
606
|
-
const SKIP_TOKEN = /\.skip|xit|xdescribe|test\.todo|@Ignore|@Disabled|pytest\.mark\.skip/;
|
|
662
|
+
const SKIP_TOKEN = /\.skip|\.fixme|\.Skip|xit|xdescribe|test\.todo|@Ignore|@Disabled|pytest\.mark\.skip/;
|
|
607
663
|
|
|
608
664
|
/**
|
|
609
665
|
* Where this line's comment starts, or -1.
|
|
@@ -642,8 +698,39 @@ function commentIndex(line, kind) {
|
|
|
642
698
|
return -1;
|
|
643
699
|
}
|
|
644
700
|
|
|
701
|
+
/**
|
|
702
|
+
* Whether the call matched by `callPattern` on this line carries a non-empty
|
|
703
|
+
* string literal as its argument number `argIndex` (zero-based).
|
|
704
|
+
*
|
|
705
|
+
* The argument boundaries come from the stripped line, where every literal is
|
|
706
|
+
* blank, so a comma or a paren inside a test title cannot fake one. The string
|
|
707
|
+
* itself is read from the kept line (`code`) at the same offset: the stripped
|
|
708
|
+
* line has no quote left to find.
|
|
709
|
+
*/
|
|
710
|
+
function callHasStringArgument(stripped, code, callPattern, argIndex) {
|
|
711
|
+
const call = callPattern.exec(stripped);
|
|
712
|
+
if (!call) return false;
|
|
713
|
+
let depth = 0;
|
|
714
|
+
let argument = 0;
|
|
715
|
+
let start = call.index + call[0].length;
|
|
716
|
+
for (let index = start; argument < argIndex && index < stripped.length; index += 1) {
|
|
717
|
+
const character = stripped[index];
|
|
718
|
+
if ('([{'.includes(character)) depth += 1;
|
|
719
|
+
else if (')]}'.includes(character)) {
|
|
720
|
+
if (depth === 0) break;
|
|
721
|
+
depth -= 1;
|
|
722
|
+
} else if (character === ',' && depth === 0) {
|
|
723
|
+
argument += 1;
|
|
724
|
+
start = index + 1;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (argument !== argIndex) return false;
|
|
728
|
+
const opening = code.slice(start).match(/^\s*(["'`])(?!\1)/);
|
|
729
|
+
return Boolean(opening);
|
|
730
|
+
}
|
|
731
|
+
|
|
645
732
|
/** C1's escape hatch: a comment on the line or the line above documents the skip. */
|
|
646
|
-
function hasAdjacentComment(rawLines, lineIndex, kind) {
|
|
733
|
+
function hasAdjacentComment(rawLines, lineIndex, kind, stripped = '', code = '') {
|
|
647
734
|
const current = rawLines[lineIndex] || '';
|
|
648
735
|
const above = (rawLines[lineIndex - 1] || '').trim();
|
|
649
736
|
|
|
@@ -654,10 +741,18 @@ function hasAdjacentComment(rawLines, lineIndex, kind) {
|
|
|
654
741
|
// and `@Disabled("...")` are the documented forms in their languages, and the
|
|
655
742
|
// reason sits in a different argument position in each. An annotation call with
|
|
656
743
|
// any string literal in it is the honest predicate; pinning the position would
|
|
657
|
-
// pass one language and fail the other.
|
|
658
|
-
//
|
|
744
|
+
// pass one language and fail the other. This branch is scoped to the languages
|
|
745
|
+
// that have annotations.
|
|
659
746
|
if ((kind === 'py' || kind === 'java') && /@[\w.]+\s*\(/.test(current) && /["']/.test(current)) return true;
|
|
660
747
|
|
|
748
|
+
// JavaScript and Go put the reason inside the call. Playwright documents
|
|
749
|
+
// `test.skip(condition, 'reason')` and `test.fixme(condition, 'reason')`: the
|
|
750
|
+
// reason is the second argument. Go's `t.Skip("reason")` and `t.Skipf("...")`
|
|
751
|
+
// carry it as the first. Only a non-empty string counts, so `test.skip(cond)`,
|
|
752
|
+
// `test.skip(title, fn)` and an empty `""` still report.
|
|
753
|
+
if (kind === 'js' && callHasStringArgument(stripped, code, /\.(?:skip|fixme)\s*\(/, 1)) return true;
|
|
754
|
+
if (kind === 'go' && callHasStringArgument(stripped, code, /\.Skip(?:f)?\s*\(/, 0)) return true;
|
|
755
|
+
|
|
661
756
|
// A trailing comment AFTER the token. One before it documents something else.
|
|
662
757
|
const tokenIndex = current.search(SKIP_TOKEN);
|
|
663
758
|
const comment = commentIndex(current, kind);
|
|
@@ -672,6 +767,142 @@ function hasAdjacentComment(rawLines, lineIndex, kind) {
|
|
|
672
767
|
// the reason it is not a block.
|
|
673
768
|
// ---------------------------------------------------------------------------
|
|
674
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Whether the bare identifier `delay` is MSW's `delay` in this file: imported as
|
|
772
|
+
* `import { delay } from 'msw'` (also a subpath, also beside a default import) or
|
|
773
|
+
* destructured as `const { delay } = require('msw')`. Read from the kept view
|
|
774
|
+
* because the module name is a string literal. An aliased `delay as X` leaves the
|
|
775
|
+
* bare name free, and a `delay` from any other module is a real wait and still
|
|
776
|
+
* fires. Member calls such as `msw.delay(300)` never match the bare-call pattern.
|
|
777
|
+
*/
|
|
778
|
+
const MSW_MODULE = String.raw`['"]msw(?:\/[\w/-]+)?['"]`;
|
|
779
|
+
const MSW_NAMED_IMPORT = new RegExp(String.raw`\bimport\s+(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*${MSW_MODULE}`, 'g');
|
|
780
|
+
const MSW_DESTRUCTURE = new RegExp(
|
|
781
|
+
String.raw`\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*(?:await\s+)?(?:require\s*\(|import\s*\()\s*${MSW_MODULE}\s*\)`,
|
|
782
|
+
'g',
|
|
783
|
+
);
|
|
784
|
+
|
|
785
|
+
function bindsMswDelay(code) {
|
|
786
|
+
const binds = (list, separator) =>
|
|
787
|
+
list.split(',').some((entry) => {
|
|
788
|
+
const [name, local = name] = entry
|
|
789
|
+
.replace(/=.*$/s, '')
|
|
790
|
+
.trim()
|
|
791
|
+
.split(separator)
|
|
792
|
+
.map((part) => part.trim());
|
|
793
|
+
return name === 'delay' && local === 'delay';
|
|
794
|
+
});
|
|
795
|
+
return (
|
|
796
|
+
[...code.matchAll(MSW_NAMED_IMPORT)].some((match) => binds(match[1].replaceAll(/\btype\s+(?=[\w$])/g, ''), /\s+as\s+/)) ||
|
|
797
|
+
[...code.matchAll(MSW_DESTRUCTURE)].some((match) => binds(match[1], /\s*:\s*/))
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* The index just past the bracket that closes the one at `open`, or -1.
|
|
803
|
+
* `([{` nest as one family; `<` is not a bracket here.
|
|
804
|
+
*/
|
|
805
|
+
function closingIndex(source, open) {
|
|
806
|
+
let depth = 0;
|
|
807
|
+
for (let index = open; index < source.length; index += 1) {
|
|
808
|
+
const character = source[index];
|
|
809
|
+
if ('([{'.includes(character)) depth += 1;
|
|
810
|
+
else if (')]}'.includes(character)) {
|
|
811
|
+
depth -= 1;
|
|
812
|
+
if (depth === 0) return index + 1;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return -1;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Where a TypeScript return-type annotation ends, given the index of its colon on
|
|
820
|
+
* the stripped source: `'body'` when a `{` opens a function body after it,
|
|
821
|
+
* `'signature'` when the type is cut off by `;`, `,`, a closing bracket or the end
|
|
822
|
+
* of the line, and null when the shape is neither.
|
|
823
|
+
*
|
|
824
|
+
* A `{` right after `:`, `|`, `&`, `,`, `(`, `<`, `=>` or inside generics is a type
|
|
825
|
+
* literal and is skipped as a whole. Any other `{` is the body.
|
|
826
|
+
*/
|
|
827
|
+
function returnTypeEnd(source, colon) {
|
|
828
|
+
let angle = 0;
|
|
829
|
+
let previous = ':';
|
|
830
|
+
let arrow = false;
|
|
831
|
+
for (let index = colon + 1; index < source.length; index += 1) {
|
|
832
|
+
const character = source[index];
|
|
833
|
+
if (character === '\n') {
|
|
834
|
+
if (angle > 0) continue;
|
|
835
|
+
const continues = /^\s*(?:\|(?!\|)|&(?!&))/.test(source.slice(index + 1)) || '|&:,<'.includes(previous) || arrow;
|
|
836
|
+
if (continues) continue;
|
|
837
|
+
return 'signature';
|
|
838
|
+
}
|
|
839
|
+
if (/\s/.test(character)) continue;
|
|
840
|
+
const opensLiteral = angle > 0 || arrow || ':|&,(<'.includes(previous);
|
|
841
|
+
if (character === '{' && !opensLiteral) return 'body';
|
|
842
|
+
if ('([{'.includes(character)) {
|
|
843
|
+
const end = closingIndex(source, index);
|
|
844
|
+
if (end === -1) return null;
|
|
845
|
+
index = end - 1;
|
|
846
|
+
previous = source[index];
|
|
847
|
+
arrow = false;
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
if (character === '=' && source[index + 1] === '>') {
|
|
851
|
+
index += 1;
|
|
852
|
+
previous = '>';
|
|
853
|
+
arrow = true;
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
arrow = false;
|
|
857
|
+
if (character === '<') angle += 1;
|
|
858
|
+
else if (character === '>' && angle > 0) angle -= 1;
|
|
859
|
+
else if (angle === 0 && ';,)}]'.includes(character)) return 'signature';
|
|
860
|
+
else if (angle === 0 && character === '=') return null;
|
|
861
|
+
previous = character;
|
|
862
|
+
}
|
|
863
|
+
return 'signature';
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** A modifier a TypeScript member may carry before its name. */
|
|
867
|
+
const MEMBER_MODIFIERS = String.raw`(?:(?:public|private|protected|static|abstract|readonly|async|declare|override)\s+)*`;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Spans of the `sleep(...)` calls in JavaScript or TypeScript, leaving out the
|
|
871
|
+
* places that declare a helper named sleep and wait on nothing:
|
|
872
|
+
*
|
|
873
|
+
* - `function sleep(ms) {`, `declare function sleep(ms): Promise<void>;`
|
|
874
|
+
* - a method with a body: `sleep(cb: () => void) {}`, `sleep(): { ok: boolean } {}`,
|
|
875
|
+
* `async sleep(): Promise<void> {`, with the parameter list read to its balanced
|
|
876
|
+
* closing paren so parens and braces inside it do not end it early
|
|
877
|
+
* - a body-less signature in an interface, type literal, abstract class or
|
|
878
|
+
* overload list: `sleep(ms: number): Promise<void>;`, where the name starts a
|
|
879
|
+
* member (after `{`, `;`, `,`, `}`, or at the head of its line, behind any
|
|
880
|
+
* modifiers) and a `: type` follows the parameters on the same line.
|
|
881
|
+
*
|
|
882
|
+
* A ternary `cond ? sleep(1) : other` is a call: `sleep` is not at the head of a
|
|
883
|
+
* member there. Anything not recognised as one of the shapes above is a call.
|
|
884
|
+
*/
|
|
885
|
+
function sleepCalls(source) {
|
|
886
|
+
const spans = [];
|
|
887
|
+
const memberHead = new RegExp(String.raw`(?:^|[\n{;,}])[ \t]*${MEMBER_MODIFIERS}$`);
|
|
888
|
+
for (const match of source.matchAll(/(?<![\w.$])sleep\s*\(/g)) {
|
|
889
|
+
const before = source.slice(Math.max(0, match.index - 200), match.index);
|
|
890
|
+
if (/\bfunction\s*\*?\s*$/.test(before)) continue;
|
|
891
|
+
const open = match.index + match[0].length - 1;
|
|
892
|
+
const close = closingIndex(source, open);
|
|
893
|
+
if (close !== -1) {
|
|
894
|
+
if (/^\s*\{/.test(source.slice(close, close + 40))) continue;
|
|
895
|
+
const colon = source.slice(close, close + 40).match(/^[ \t]*:/);
|
|
896
|
+
if (colon) {
|
|
897
|
+
const end = returnTypeEnd(source, close + colon[0].length - 1);
|
|
898
|
+
if (end === 'body' || (end === 'signature' && memberHead.test(before))) continue;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
spans.push([match.index, match.index + match[0].length]);
|
|
902
|
+
}
|
|
903
|
+
return spans;
|
|
904
|
+
}
|
|
905
|
+
|
|
675
906
|
const RULES = [
|
|
676
907
|
{
|
|
677
908
|
id: 'C1',
|
|
@@ -685,17 +916,19 @@ const RULES = [
|
|
|
685
916
|
// fight TEA's doctrine and train users to disable the hook.
|
|
686
917
|
actionReason: 'the row is conditioned on a documented, still-true reason, which is not mechanically decidable',
|
|
687
918
|
scope: 'line',
|
|
688
|
-
kinds: ['js', 'py', 'java'],
|
|
919
|
+
kinds: ['js', 'py', 'java', 'go'],
|
|
689
920
|
fix: 'Delete the test, or document why it is skipped on the line or the line above and keep that reason true.',
|
|
690
921
|
match(line, context) {
|
|
691
922
|
const patterns = {
|
|
692
|
-
js: /(?:^|[^\w.])(?:x(?:it|describe|test)\s*\(|\w
|
|
693
|
-
py: /@pytest\.mark\.skip/,
|
|
923
|
+
js: /(?:^|[^\w.])(?:x(?:it|describe|test)\s*\(|\w+(?:\.\w+)*\.(?:skip|fixme)\s*[(.]|\w+\.todo\s*\()/,
|
|
924
|
+
py: /@(?:pytest\.mark\.skip|unittest\.skip)/,
|
|
925
|
+
// No identifier is required before the dot: `s.T().Skip()` is a skip too.
|
|
926
|
+
go: /\.Skip(?:f|Now)?\s*\(/,
|
|
694
927
|
java: /@(?:Ignore|Disabled)\b/,
|
|
695
928
|
};
|
|
696
929
|
const pattern = patterns[context.kind];
|
|
697
930
|
if (!pattern || !pattern.test(line)) return false;
|
|
698
|
-
return !hasAdjacentComment(context.rawLines, context.lineIndex, context.kind);
|
|
931
|
+
return !hasAdjacentComment(context.rawLines, context.lineIndex, context.kind, line, context.code);
|
|
699
932
|
},
|
|
700
933
|
},
|
|
701
934
|
{
|
|
@@ -729,27 +962,44 @@ const RULES = [
|
|
|
729
962
|
// `.not.` is excluded on purpose: `expect(x).not.toBe(x)` is a defect too,
|
|
730
963
|
// but it always FAILS, so it is not the "test cannot fail" failure this row
|
|
731
964
|
// is about, and blocking it would be this hook overreaching its row.
|
|
732
|
-
return
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
965
|
+
return [
|
|
966
|
+
...selfComparisons(
|
|
967
|
+
stripped,
|
|
968
|
+
context,
|
|
969
|
+
/expect\s*\(([^(),]+?)\)\s*\.\s*(?:to\s*\.\s*)?(?:toBe|toEqual|toStrictEqual|toBeCloseTo|equal|equals|eql|deep\s*\.\s*equal)\s*\(([^(),]+?)\)/dg,
|
|
970
|
+
),
|
|
971
|
+
// node:assert and chai's assert style. The optional third argument is a
|
|
972
|
+
// message, and `notStrictEqual` always fails, so it is not listed.
|
|
973
|
+
...selfComparingCalls(stripped, context, /(?<![\w$])assert\s*\.\s*(?:strictEqual|equal|deepStrictEqual|deepEqual)\s*\(/g),
|
|
974
|
+
];
|
|
737
975
|
}
|
|
738
976
|
if (context.kind === 'py') {
|
|
739
977
|
// Horizontal whitespace only: a Python statement does not continue onto the
|
|
740
978
|
// next line without a bracket or a backslash, so `\s` here would pair an
|
|
741
979
|
// `assert` with a `==` on a later, unrelated line.
|
|
742
|
-
return
|
|
980
|
+
return [
|
|
981
|
+
...selfComparisons(stripped, context, /assert[ \t]+([^=<>!\s]+)[ \t]*==[ \t]*([^=<>!\s#]+)/dg),
|
|
982
|
+
// unittest. The third argument, when present, is a message.
|
|
983
|
+
...selfComparingCalls(
|
|
984
|
+
stripped,
|
|
985
|
+
context,
|
|
986
|
+
/\bself\s*\.\s*assert(?:Equal|Equals|Is|CountEqual|ListEqual|DictEqual|TupleEqual|SetEqual|SequenceEqual|AlmostEqual)\s*\(/g,
|
|
987
|
+
),
|
|
988
|
+
// `assert True, "msg"` is as inert as `assert True`. `assert True == x` is not it.
|
|
989
|
+
...matchSpans(stripped, /^[ \t]*assert[ \t]+True[ \t]*(?=,|$)/gm),
|
|
990
|
+
];
|
|
743
991
|
}
|
|
744
992
|
if (context.kind === 'java') {
|
|
745
993
|
return [
|
|
746
994
|
...matchSpans(stripped, /assertTrue\s*\(\s*true\s*\)/g),
|
|
747
995
|
...matchSpans(stripped, /assertFalse\s*\(\s*false\s*\)/g),
|
|
748
996
|
...selfComparisons(stripped, context, /assertEquals\s*\(([^,()]+?),([^,()]+?)\)/dg),
|
|
997
|
+
// AssertJ.
|
|
998
|
+
...selfComparisons(stripped, context, /assertThat\s*\(([^,()]+?)\)\s*\.\s*(?:isEqualTo|isSameAs)\s*\(([^,()]+?)\)/dg),
|
|
749
999
|
];
|
|
750
1000
|
}
|
|
751
1001
|
if (context.kind === 'go') {
|
|
752
|
-
return selfComparisons(stripped, context, /assert\.(?:Equal|EqualValues)\s*\(\s*t\s*,([^,()]+?),([^,()]+?)\)/dg);
|
|
1002
|
+
return selfComparisons(stripped, context, /(?:assert|require)\.(?:Equal|EqualValues)\s*\(\s*t\s*,([^,()]+?),([^,()]+?)\)/dg);
|
|
753
1003
|
}
|
|
754
1004
|
return [];
|
|
755
1005
|
},
|
|
@@ -790,14 +1040,53 @@ const RULES = [
|
|
|
790
1040
|
kinds: ['js', 'py', 'java', 'go', 'maestro'],
|
|
791
1041
|
fix: 'Wait on a web-first assertion, an explicit readiness signal, `cy.wait("@alias")`, or `extendedWaitUntil` in a Maestro flow.',
|
|
792
1042
|
matchSource(source, context) {
|
|
1043
|
+
// The timer a hard wait hands to a Promise executor, ending at the delay's
|
|
1044
|
+
// first digit. It must CALL the resolver: `setTimeout(r, 1000)` and
|
|
1045
|
+
// `setTimeout(() => r(), 1000)` wait, while `setTimeout(() => reject(...), 5000)`
|
|
1046
|
+
// is a timeout guard on something else and stays silent.
|
|
1047
|
+
const timer = (resolver) => `setTimeout\\s*\\(\\s*(?:${resolver}|\\(\\s*\\)\\s*=>\\s*${resolver}\\s*\\(\\s*\\))\\s*,\\s*\\d`;
|
|
1048
|
+
// The optional `<void>` is the TypeScript type argument on `new Promise<void>(`.
|
|
1049
|
+
const promise = String.raw`\bnew\s+Promise\s*(?:<[^<>()]*>)?\s*\(\s*`;
|
|
1050
|
+
const params = String.raw`([\w$]+)\s*(?:,\s*[\w$]+\s*)?`;
|
|
1051
|
+
const firstParam = String.raw`\1`;
|
|
793
1052
|
const patterns = {
|
|
794
|
-
js:
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1053
|
+
js: [
|
|
1054
|
+
/\bwaitForTimeout\s*\(/g,
|
|
1055
|
+
/\bcy\.wait\s*\(\s*\d/g,
|
|
1056
|
+
// MSW's `delay()` simulates server latency inside a handler, so it is
|
|
1057
|
+
// left out when the bare `delay` is the one imported from msw. A member
|
|
1058
|
+
// call such as `nockScope.delay(200)` belongs to a library and is left
|
|
1059
|
+
// out too.
|
|
1060
|
+
...(bindsMswDelay(context.code) ? [] : [/(?<![\w.$])delay\s*\(\s*\d/g]),
|
|
1061
|
+
/\bawait\s+setTimeout\s*\(\s*\d/g,
|
|
1062
|
+
new RegExp(String.raw`${promise}(?:\(\s*)?${params}\)?\s*=>\s*(?:{\s*)?${timer(firstParam)}`, 'g'),
|
|
1063
|
+
new RegExp(String.raw`${promise}function\s*\(\s*${params}\)\s*{\s*${timer(firstParam)}`, 'g'),
|
|
1064
|
+
],
|
|
1065
|
+
py: [
|
|
1066
|
+
/\btime\.sleep\s*\(/g,
|
|
1067
|
+
// `def sleep(self):` defines a helper.
|
|
1068
|
+
/(?<![\w.])(?<!\bdef\s+)sleep\s*\(/g,
|
|
1069
|
+
// `asyncio.sleep(0)` is a cooperative yield, not a wait.
|
|
1070
|
+
/\basyncio\.sleep\s*\((?!\s*0(?:\.0*)?\s*\))/g,
|
|
1071
|
+
],
|
|
1072
|
+
// Kotlin's `delay()` stays out on purpose: under `runTest` it advances
|
|
1073
|
+
// virtual time and waits on nothing.
|
|
1074
|
+
java: [
|
|
1075
|
+
/\bThread\.sleep\s*\(/g,
|
|
1076
|
+
/\b(?:TimeUnit\.)?(?:NANOSECONDS|MICROSECONDS|MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)\.sleep\s*\(/g,
|
|
1077
|
+
],
|
|
1078
|
+
// A bare `<-time.After(d)` statement blocks for d. Inside a select it is
|
|
1079
|
+
// `case <-time.After(d):`, a timeout guard, and the line does not start with
|
|
1080
|
+
// the receive.
|
|
1081
|
+
go: [/\btime\.Sleep\s*\(/g, /(?:^|[;{])[ \t]*<-[ \t]*time\.After\s*\(/gm],
|
|
1082
|
+
maestro: [/^[ \t]*-[ \t]*sleep[ \t]*:/gm],
|
|
799
1083
|
};
|
|
800
|
-
return [
|
|
1084
|
+
return [
|
|
1085
|
+
...patterns[context.kind].flatMap((pattern) =>
|
|
1086
|
+
[...source.matchAll(pattern)].map((match) => [match.index, match.index + match[0].length]),
|
|
1087
|
+
),
|
|
1088
|
+
...(context.kind === 'js' ? sleepCalls(source) : []),
|
|
1089
|
+
].sort((a, b) => a[0] - b[0]);
|
|
801
1090
|
},
|
|
802
1091
|
},
|
|
803
1092
|
{
|
|
@@ -514,8 +514,8 @@ const totalRequirements = traceabilityMatrix.length;
|
|
|
514
514
|
const coveredRequirements = traceabilityMatrix.filter((r) => r.coverage === 'FULL' || r.coverage === 'PARTIAL').length;
|
|
515
515
|
const fullyCovered = traceabilityMatrix.filter((r) => r.coverage === 'FULL').length;
|
|
516
516
|
|
|
517
|
-
//
|
|
518
|
-
const safePct = (covered, total) => (total > 0 ? Math.
|
|
517
|
+
// Percentages round DOWN, so a displayed value reaches a whole-number threshold exactly when the counts do. Step 5 compares covered/total counts for every gate threshold.
|
|
518
|
+
const safePct = (covered, total) => (total > 0 ? Math.floor((covered * 100) / total) : 100);
|
|
519
519
|
const coveragePercentage = safePct(fullyCovered, totalRequirements);
|
|
520
520
|
|
|
521
521
|
// Priority-specific coverage
|
|
@@ -112,7 +112,7 @@ const p1Coverage = priorityBreakdown.P1.percentage;
|
|
|
112
112
|
const hasP1Requirements = (priorityBreakdown.P1.total || 0) > 0;
|
|
113
113
|
const effectiveP1Coverage = hasP1Requirements ? p1Coverage : 100;
|
|
114
114
|
const overallCoverage = stats.overall_coverage_percentage;
|
|
115
|
-
//
|
|
115
|
+
// Displayed percentages round down (Math.floor), so a displayed value reaches a whole-number threshold exactly when the counts do. Apply thresholds to integer counts.
|
|
116
116
|
const meetsCoverage = (covered, total, threshold) => total === 0 || covered * 100 >= threshold * total;
|
|
117
117
|
const p0Met = meetsCoverage(priorityBreakdown.P0.covered, priorityBreakdown.P0.total, 100);
|
|
118
118
|
const p1MinimumMet = meetsCoverage(priorityBreakdown.P1.covered, priorityBreakdown.P1.total, 80);
|
|
@@ -958,7 +958,7 @@ This is the only write of report content in this step. Section 6 changes the fro
|
|
|
958
958
|
- Requirements covered only by live evidence: {liveOnlyCoveredRequirements} (this run is capped at CONCERNS)
|
|
959
959
|
{endif}
|
|
960
960
|
|
|
961
|
-
⚠️ Critical Gaps: {criticalGaps
|
|
961
|
+
⚠️ Critical Gaps: {criticalGaps} (P0 criteria below FULL coverage)
|
|
962
962
|
|
|
963
963
|
{if waivers}
|
|
964
964
|
🔓 Waivers Filed: {waivers.filed} ({waivers.valid} valid, {waivers.invalid} invalid). None applied; the decision above is the derived one.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[bmod]
|
|
4
4
|
code = "tea"
|
|
5
|
-
version = "4.0.
|
|
5
|
+
version = "4.0.1"
|
|
6
6
|
update_source = "github:bmad-code-org/bmad-method-test-architecture-enterprise/skills"
|
|
7
7
|
skills = [
|
|
8
8
|
"bmad-tea",
|
|
@@ -15,7 +15,7 @@ skills = [
|
|
|
15
15
|
"bmad-tea-test-review",
|
|
16
16
|
"bmad-tea-trace",
|
|
17
17
|
]
|
|
18
|
-
required_skills = [{ skill = "bmad", version = "6.13.0-next", source = "github:bmad-code-org/BMAD-METHOD/skills" }]
|
|
18
|
+
required_skills = [{ skill = "bmad", version = "6.13.0-next", source = "github:bmad-code-org/BMAD-METHOD/skills/core-tools" }]
|
|
19
19
|
pre_install_message = ""
|
|
20
20
|
post_install_message = '''
|
|
21
21
|
TEA is ready. Talk to Murat (bmad-tea) or start with Test Design (bmad-tea-test-design).
|
|
@@ -28,7 +28,7 @@ precautions = """
|
|
|
28
28
|
- Read before writing. Show the user the plan (each key and where it goes) and wait for approval.
|
|
29
29
|
- Edit only the `[modules.tea]` tables of `_bmad/config.toml`, `_bmad/custom/config.toml` and `_bmad/custom/config.user.toml`, and the two customization files `_bmad/custom/bmad-tea-framework.toml` and `_bmad/custom/bmad-tea-evaluate.toml`. Keep every other table, key and comment in those files as it is, and merge into a customization file that already exists instead of replacing it.
|
|
30
30
|
- Never delete a file outside version control. Removing the leftovers is a commit the user chooses; offer it and stop there.
|
|
31
|
-
- Preserve `_bmad/custom/bmad-testarch-atdd.toml
|
|
31
|
+
- Preserve `_bmad/custom/bmad-testarch-atdd.toml` and `_bmad/custom/bmad-testarch-atdd.user.toml` until `bmad migrate tea` (migration-3) or `tea-migrate-customizations` moves their settings into `[workflow.red]` of `bmad-tea-automate.toml`. The combined skill reads red settings only from that table. Preserve `_bmad/custom/bmad-testarch-automate.toml` and `_bmad/custom/bmad-testarch-automate.user.toml` (expand mode) until `tea-migrate-customizations` renames them to `bmad-tea-automate.toml` and `bmad-tea-automate.user.toml` with `[workflow]` unchanged; migration-3 does not rename them, and their settings never go into `[workflow.red]`.
|
|
32
32
|
- Never run `bmad setup` from inside this migration; it owns the rest of `_bmad/`. When `[modules.tea]` is missing from every layer, stop and tell the user to run `bmad setup tea` first and to run this migration again afterwards.
|
|
33
33
|
"""
|
|
34
34
|
|
|
@@ -5,21 +5,21 @@ module = "tea"
|
|
|
5
5
|
from = "3 with separate atdd and ci customization files"
|
|
6
6
|
to = "3 with [workflow.red] and [workflow.ci] tables"
|
|
7
7
|
title = "Move TEA red and CI customizations into their owning skills"
|
|
8
|
-
summary = "Moves the settings of bmad-tea-atdd into [workflow.red] of bmad-tea-automate.toml and those of bmad-tea-ci into [workflow.ci] of bmad-tea-framework.toml, team and user layers separately, reading live files first and cleanup backups when `bmad setup` already removed a file. Also offers to move [modules.tea] keys
|
|
8
|
+
summary = "Moves the settings of bmad-tea-atdd into [workflow.red] of bmad-tea-automate.toml and those of bmad-tea-ci into [workflow.ci] of bmad-tea-framework.toml, team and user layers separately, reading live files first and cleanup backups when `bmad setup` already removed a file. Also offers to move [modules.tea] keys of the legacy _bmad/config.user.toml that neither custom layer holds into _bmad/custom/config.user.toml. Nothing is overwritten without your choice."
|
|
9
9
|
|
|
10
10
|
# Read-only signals. Any one of them makes this migration worth offering.
|
|
11
11
|
detect = """
|
|
12
12
|
- `{project-root}/_bmad/custom/` holds `bmad-tea-atdd.toml`, `bmad-tea-atdd.user.toml`, `bmad-tea-ci.toml`, `bmad-tea-ci.user.toml`, `bmad-testarch-atdd.toml`, `bmad-testarch-atdd.user.toml`, `bmad-testarch-ci.toml` or `bmad-testarch-ci.user.toml`.
|
|
13
13
|
- `bmad-tea-framework.toml` or `bmad-tea-framework.user.toml` in `{project-root}/_bmad/custom/` holds `ci_platform` directly under `[workflow]`.
|
|
14
14
|
- A `{project-root}/.v6-v7-migration-backup-*/_bmad/custom/` folder holds one of the files above, or a pre-3.0 `bmad-testarch-<skill>.toml` or `.user.toml` file, and the live `_bmad/custom/` holds neither that file nor its `bmad-tea-*` successor. `bmad setup` cleanup lists these files as unused customizations and deletes them, so a backup can be the only copy left.
|
|
15
|
-
- `{project-root}/_bmad/config.user.toml` exists with a `[modules.tea]` table, live or only as `{project-root}/.v6-v7-migration-backup-*/_bmad/config.user.toml`. Core merges
|
|
15
|
+
- `{project-root}/_bmad/config.user.toml` exists with a `[modules.tea]` table, live or only as `{project-root}/.v6-v7-migration-backup-*/_bmad/config.user.toml`. Core no longer merges this file. It ranked above `_bmad/config.toml` and below `_bmad/custom/config.toml` and `_bmad/custom/config.user.toml`, so a key is ignored when neither custom file holds it, even if `_bmad/config.toml` sets the same key.
|
|
16
16
|
A project with none of those signals, or one whose plan below is already complete, is migrated; say so and stop.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
target = """
|
|
20
20
|
- Red-mode settings are `[workflow.red]` in `_bmad/custom/bmad-tea-automate.toml` (team) and `bmad-tea-automate.user.toml` (user). CI settings, `ci_platform` included, are `[workflow.ci]` in `bmad-tea-framework.toml` and `bmad-tea-framework.user.toml`.
|
|
21
21
|
- No `bmad-tea-atdd`, `bmad-tea-ci`, `bmad-testarch-atdd` or `bmad-testarch-ci` file remains in `_bmad/custom/` once its content is verified in the target. `ci_platform` is no longer a key of `[workflow]` in the framework files.
|
|
22
|
-
- Every `[modules.tea]` key
|
|
22
|
+
- Every `[modules.tea]` key of `_bmad/config.user.toml` that neither custom file holds lives in `_bmad/custom/config.user.toml`, where it keeps its precedence over `_bmad/config.toml`.
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
25
|
precautions = """
|
|
@@ -33,8 +33,8 @@ precautions = """
|
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
35
|
guide = """
|
|
36
|
-
1. **Inventory.** List, per layer (team, user) and surface (red from atdd, CI from ci), every candidate source: the live files named in the detect signals, and for each absent live file the newest backup folder that contains it. Record each source's provenance (`live` or the backup folder). Add framework override files that set `ci_platform` directly under `[workflow]`. Add every `[modules.tea]` key of `_bmad/config.user.toml`, live or from the newest backup that contains it. A personal override is a candidate
|
|
37
|
-
2. **Plan.** Build one row per moved table or key: source file and provenance, destination file and table, and the status (`new`, `same value already present`, `conflict`). Show each conflict with both values. Retired v6 names (`bmad-testarch-atdd`, `bmad-testarch-ci`) are sources too, read before any content rewrite. Wait for approval, and for the user's choice on each conflict. For a `_bmad/config.user.toml` key
|
|
36
|
+
1. **Inventory.** List, per layer (team, user) and surface (red from atdd, CI from ci), every candidate source: the live files named in the detect signals, and for each absent live file the newest backup folder that contains it. Record each source's provenance (`live` or the backup folder). Add framework override files that set `ci_platform` directly under `[workflow]`. Add every `[modules.tea]` key of `_bmad/config.user.toml`, live or from the newest backup that contains it. The old core order was `_bmad/config.toml`, `_bmad/config.user.toml`, `_bmad/custom/config.toml`, `_bmad/custom/config.user.toml`, later files winning. A personal override is a candidate when neither `_bmad/custom/config.toml` nor `_bmad/custom/config.user.toml` holds the key, because only those two layers outranked it. `_bmad/config.toml` is ignored in that comparison, so a key it sets to a different value is still a candidate; show both values and their files. A key that either custom file holds is not a candidate, because the custom value already won before the change.
|
|
37
|
+
2. **Plan.** Build one row per moved table or key: source file and provenance, destination file and table, and the status (`new`, `same value already present`, `conflict`). Show each conflict with both values. Retired v6 names (`bmad-testarch-atdd`, `bmad-testarch-ci`) are sources too, read before any content rewrite. Wait for approval, and for the user's choice on each conflict. For a `_bmad/config.user.toml` key that `_bmad/config.toml` sets to a different value, report both values and their files, and move the legacy value unless the user keeps the `_bmad/config.toml` one.
|
|
38
38
|
3. **Apply.** For each approved row write the destination, preserving the source text (comments and order) and rewriting `[workflow]` to `[workflow.red]` or `[workflow.ci]`. Re-read and parse the destination to verify it holds every moved key, then remove the old live file. Move a top-level `ci_platform` into `[workflow.ci]` of the same framework file. Move approved legacy `config.user.toml` keys into `[modules.tea]` of `_bmad/custom/config.user.toml`. A backup source is only read.
|
|
39
39
|
4. **Resume.** A rerun recomputes the plan from disk: a source whose content is fully present in its destination changes nothing, and an interrupted run continues from the files that remain. Record each key or file restored from a backup, and each backup value the user chose to leave out, in the plan (the script uses `_bmad/custom/.tea-customization-migration.json`); a recorded item is never a conflict again, so a destination the user edited after migrating stays quiet. An unrecorded backup value that differs from the destination is a conflict.
|
|
40
40
|
5. **Report.** Show the destination tables, the files removed, any conflicts left for the user and the files that remain.
|
|
@@ -45,6 +45,6 @@ checklist = [
|
|
|
45
45
|
"`uv run _bmad/scripts/resolve_customization.py --skill <automate-skill-root> --project-root . --key workflow.red` prints the migrated red settings.",
|
|
46
46
|
"`uv run _bmad/scripts/resolve_customization.py --skill <framework-skill-root> --project-root . --key workflow.ci` prints the migrated CI settings, `ci_platform` included.",
|
|
47
47
|
"`[workflow]` of the framework override files holds no `ci_platform`.",
|
|
48
|
-
"Every `[modules.tea]` key
|
|
48
|
+
"Every `[modules.tea]` key of `_bmad/config.user.toml` that neither custom file holds is in `_bmad/custom/config.user.toml`, or the user kept the canonical value.",
|
|
49
49
|
"A second run changes nothing.",
|
|
50
50
|
]
|