bmad-method-test-architecture-enterprise 3.6.1 → 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.
Files changed (55) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +10 -3
  3. package/cli/lib/automate-prompt.js +3 -7
  4. package/cli/lib/framework-setup.js +1 -2
  5. package/cli/lib/parse-report.js +1 -1
  6. package/cli/lib/resolve-tea-config.js +167 -38
  7. package/cli/lib/trace-command.js +13 -5
  8. package/cli/migrate-customizations.js +853 -77
  9. package/cli/teach.js +0 -1
  10. package/cli/test-review.js +6 -2
  11. package/package.json +3 -2
  12. package/skills/bmad-tea/SKILL.md +2 -2
  13. package/skills/bmad-tea-automate/SKILL.md +12 -11
  14. package/skills/bmad-tea-automate/customize.toml +12 -0
  15. package/skills/bmad-tea-automate/red/atdd-checklist-template.md +4 -4
  16. package/skills/bmad-tea-automate/red/checklist.md +1 -0
  17. package/skills/bmad-tea-automate/red/instructions.md +1 -1
  18. package/skills/bmad-tea-automate/red/steps-c/step-04a-subagent-api-failing.md +5 -0
  19. package/skills/bmad-tea-automate/red/steps-c/step-04b-subagent-e2e-failing.md +4 -0
  20. package/skills/bmad-tea-automate/red/steps-c/step-04c-aggregate.md +3 -2
  21. package/skills/bmad-tea-automate/red/steps-c/step-05-validate-and-complete.md +5 -4
  22. package/skills/bmad-tea-automate/red/steps-e/step-02-apply-edit.md +4 -4
  23. package/skills/bmad-tea-automate/red/steps-v/step-01-validate.md +4 -4
  24. package/skills/bmad-tea-automate/red/workflow.yaml +0 -1
  25. package/skills/bmad-tea-automate/resources/test-generation-routing.md +4 -7
  26. package/skills/bmad-tea-automate/steps-c/step-04-validate-and-summarize.md +4 -4
  27. package/skills/bmad-tea-automate/steps-e/step-02-apply-edit.md +4 -4
  28. package/skills/bmad-tea-automate/steps-v/step-01-validate.md +4 -4
  29. package/skills/bmad-tea-automate/workflow.yaml +0 -1
  30. package/skills/bmad-tea-evaluate/SKILL.md +1 -1
  31. package/skills/bmad-tea-framework/SKILL.md +3 -3
  32. package/skills/bmad-tea-framework/customize.toml +11 -2
  33. package/skills/bmad-tea-framework/resources/hooks/tea-enforce.cjs +366 -46
  34. package/skills/bmad-tea-framework/resources/setup-routing.md +6 -6
  35. package/skills/bmad-tea-framework/steps-c/step-04-docs-and-scripts.md +16 -12
  36. package/skills/bmad-tea-framework/workflow.yaml +0 -1
  37. package/skills/bmad-tea-nfr/SKILL.md +2 -2
  38. package/skills/bmad-tea-nfr/workflow.yaml +0 -1
  39. package/skills/bmad-tea-teach-me-testing/SKILL.md +2 -2
  40. package/skills/bmad-tea-test-design/SKILL.md +2 -2
  41. package/skills/bmad-tea-test-design/workflow.yaml +0 -1
  42. package/skills/bmad-tea-test-review/SKILL.md +2 -2
  43. package/skills/bmad-tea-test-review/workflow.yaml +0 -1
  44. package/skills/bmad-tea-trace/SKILL.md +2 -2
  45. package/skills/bmad-tea-trace/steps-c/step-04-analyze-gaps.md +2 -1
  46. package/skills/bmad-tea-trace/steps-c/step-05-gate-decision.md +30 -13
  47. package/skills/bmad-tea-trace/workflow.yaml +0 -1
  48. package/skills/bmod-tea/bmod.toml +3 -3
  49. package/skills/bmod-tea/help/help.md +10 -9
  50. package/skills/bmod-tea/knowledge/maestro-flows.md +1 -1
  51. package/skills/bmod-tea/migration-1.toml +7 -7
  52. package/skills/bmod-tea/migration-3.toml +50 -0
  53. package/skills/bmod-tea/retired.toml +13 -0
  54. package/skills/bmad-tea-automate/red/customize.toml +0 -38
  55. package/skills/bmad-tea-framework/ci/customize.toml +0 -10
@@ -109,6 +109,7 @@ const DEFAULT_CONFIG = {
109
109
  '**/*Test.java',
110
110
  '**/*Tests.java',
111
111
  '**/*IT.java',
112
+ '**/*{Test,Tests,IT}.kt',
112
113
  '.maestro/**/*.{yaml,yml}',
113
114
  'maestro/**/*.{yaml,yml}',
114
115
  ],
@@ -311,7 +312,7 @@ function literal(source, start, end, mode) {
311
312
  */
312
313
  const codeInMask = (character) => (character === '\n' ? '\n' : ' ');
313
314
 
314
- function stripCLike(source, literals) {
315
+ function stripCLike(source, literals, kind, kotlinRaw = false) {
315
316
  let out = '';
316
317
  let index = 0;
317
318
  // Whether a `/` at this position could open a regex literal rather than divide.
@@ -365,6 +366,24 @@ function stripCLike(source, literals) {
365
366
  }
366
367
  }
367
368
 
369
+ if (kind === 'java' && source.startsWith('"""', index)) {
370
+ let scan = index + 3;
371
+ while (scan < source.length) {
372
+ if (source.startsWith('"""', scan)) {
373
+ scan += 3;
374
+ break;
375
+ }
376
+ // Java text blocks allow escaped quotes. Kotlin raw strings close at
377
+ // the same delimiter; preserving offsets keeps the operand views aligned.
378
+ if (!kotlinRaw && source[scan] === '\\') scan += 2;
379
+ else scan += 1;
380
+ }
381
+ out += literal(source, index, scan, literals);
382
+ index = scan;
383
+ regexAllowed = false;
384
+ continue;
385
+ }
386
+
368
387
  if (character === '"' || character === "'" || character === '`') {
369
388
  const quote = character;
370
389
  let scan = index + 1;
@@ -470,13 +489,13 @@ function stripYaml(source) {
470
489
  .join('\n');
471
490
  }
472
491
 
473
- function stripNoise(source, kind) {
492
+ function stripNoise(source, kind, relativePath = '') {
474
493
  switch (kind) {
475
494
  case 'js':
476
495
  case 'java':
477
496
  case 'go':
478
497
  case 'pactconfig': {
479
- return stripCLike(source);
498
+ return stripCLike(source, undefined, kind, relativePath.endsWith('.kt'));
480
499
  }
481
500
  case 'py': {
482
501
  return stripPython(source);
@@ -501,13 +520,13 @@ function stripNoise(source, kind) {
501
520
  * view, at the same offsets; the masked view says which of those characters sit
502
521
  * inside a literal, where whitespace is part of the value.
503
522
  */
504
- function stripComments(source, kind, mode) {
523
+ function stripComments(source, kind, mode, relativePath = '') {
505
524
  switch (kind) {
506
525
  case 'js':
507
526
  case 'java':
508
527
  case 'go':
509
528
  case 'pactconfig': {
510
- return stripCLike(source, mode);
529
+ return stripCLike(source, mode, kind, relativePath.endsWith('.kt'));
511
530
  }
512
531
  case 'py': {
513
532
  return stripPython(source, mode);
@@ -568,13 +587,69 @@ function interpolates(text, mask, kind) {
568
587
  function selfComparisons(stripped, views, pattern) {
569
588
  const spans = [];
570
589
  for (const match of stripped.matchAll(pattern)) {
571
- const operands = [1, 2].map((group) => {
572
- const [start, end] = match.indices[group] ?? [0, 0];
573
- return { text: views.code.slice(start, end), mask: views.mask.slice(start, end) };
574
- });
575
- if (operands.some(({ text, mask }) => interpolates(text, mask, views.kind))) continue;
576
- const [left, right] = operands.map(({ text, mask }) => normalizeOperand(text, mask));
577
- if (left.length > 0 && left === right) spans.push([match.index, match.index + match[0].length]);
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]]);
578
653
  }
579
654
  return spans;
580
655
  }
@@ -584,7 +659,7 @@ function matchSpans(source, pattern) {
584
659
  return [...source.matchAll(pattern)].map((match) => [match.index, match.index + match[0].length]);
585
660
  }
586
661
 
587
- 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/;
588
663
 
589
664
  /**
590
665
  * Where this line's comment starts, or -1.
@@ -623,8 +698,39 @@ function commentIndex(line, kind) {
623
698
  return -1;
624
699
  }
625
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
+
626
732
  /** C1's escape hatch: a comment on the line or the line above documents the skip. */
627
- function hasAdjacentComment(rawLines, lineIndex, kind) {
733
+ function hasAdjacentComment(rawLines, lineIndex, kind, stripped = '', code = '') {
628
734
  const current = rawLines[lineIndex] || '';
629
735
  const above = (rawLines[lineIndex - 1] || '').trim();
630
736
 
@@ -635,10 +741,18 @@ function hasAdjacentComment(rawLines, lineIndex, kind) {
635
741
  // and `@Disabled("...")` are the documented forms in their languages, and the
636
742
  // reason sits in a different argument position in each. An annotation call with
637
743
  // any string literal in it is the honest predicate; pinning the position would
638
- // pass one language and fail the other. JavaScript has no such form, so this
639
- // branch is scoped rather than applied everywhere.
744
+ // pass one language and fail the other. This branch is scoped to the languages
745
+ // that have annotations.
640
746
  if ((kind === 'py' || kind === 'java') && /@[\w.]+\s*\(/.test(current) && /["']/.test(current)) return true;
641
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
+
642
756
  // A trailing comment AFTER the token. One before it documents something else.
643
757
  const tokenIndex = current.search(SKIP_TOKEN);
644
758
  const comment = commentIndex(current, kind);
@@ -653,6 +767,142 @@ function hasAdjacentComment(rawLines, lineIndex, kind) {
653
767
  // the reason it is not a block.
654
768
  // ---------------------------------------------------------------------------
655
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
+
656
906
  const RULES = [
657
907
  {
658
908
  id: 'C1',
@@ -666,17 +916,19 @@ const RULES = [
666
916
  // fight TEA's doctrine and train users to disable the hook.
667
917
  actionReason: 'the row is conditioned on a documented, still-true reason, which is not mechanically decidable',
668
918
  scope: 'line',
669
- kinds: ['js', 'py', 'java'],
919
+ kinds: ['js', 'py', 'java', 'go'],
670
920
  fix: 'Delete the test, or document why it is skipped on the line or the line above and keep that reason true.',
671
921
  match(line, context) {
672
922
  const patterns = {
673
- js: /(?:^|[^\w.])(?:x(?:it|describe|test)\s*\(|\w+\.skip\s*[(.]|\w+\.todo\s*\()/,
674
- 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*\(/,
675
927
  java: /@(?:Ignore|Disabled)\b/,
676
928
  };
677
929
  const pattern = patterns[context.kind];
678
930
  if (!pattern || !pattern.test(line)) return false;
679
- return !hasAdjacentComment(context.rawLines, context.lineIndex, context.kind);
931
+ return !hasAdjacentComment(context.rawLines, context.lineIndex, context.kind, line, context.code);
680
932
  },
681
933
  },
682
934
  {
@@ -710,27 +962,44 @@ const RULES = [
710
962
  // `.not.` is excluded on purpose: `expect(x).not.toBe(x)` is a defect too,
711
963
  // but it always FAILS, so it is not the "test cannot fail" failure this row
712
964
  // is about, and blocking it would be this hook overreaching its row.
713
- return selfComparisons(
714
- stripped,
715
- context,
716
- /expect\s*\(([^(),]+?)\)\s*\.\s*(?:to\s*\.\s*)?(?:toBe|toEqual|toStrictEqual|toBeCloseTo|equal|equals|eql|deep\s*\.\s*equal)\s*\(([^(),]+?)\)/dg,
717
- );
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
+ ];
718
975
  }
719
976
  if (context.kind === 'py') {
720
977
  // Horizontal whitespace only: a Python statement does not continue onto the
721
978
  // next line without a bracket or a backslash, so `\s` here would pair an
722
979
  // `assert` with a `==` on a later, unrelated line.
723
- return selfComparisons(stripped, context, /assert[ \t]+([^=<>!\s]+)[ \t]*==[ \t]*([^=<>!\s#]+)/dg);
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
+ ];
724
991
  }
725
992
  if (context.kind === 'java') {
726
993
  return [
727
994
  ...matchSpans(stripped, /assertTrue\s*\(\s*true\s*\)/g),
728
995
  ...matchSpans(stripped, /assertFalse\s*\(\s*false\s*\)/g),
729
996
  ...selfComparisons(stripped, context, /assertEquals\s*\(([^,()]+?),([^,()]+?)\)/dg),
997
+ // AssertJ.
998
+ ...selfComparisons(stripped, context, /assertThat\s*\(([^,()]+?)\)\s*\.\s*(?:isEqualTo|isSameAs)\s*\(([^,()]+?)\)/dg),
730
999
  ];
731
1000
  }
732
1001
  if (context.kind === 'go') {
733
- 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);
734
1003
  }
735
1004
  return [];
736
1005
  },
@@ -750,7 +1019,10 @@ const RULES = [
750
1019
  scope: 'file',
751
1020
  kinds: ['maestro'],
752
1021
  fix: 'Add `assertVisible`, `assertNotVisible`, `assertTrue`, or `extendedWaitUntil` on the destination state. A flow that only taps passes as long as the taps land.',
753
- matchFile(strippedSource) {
1022
+ matchFile(strippedSource, context) {
1023
+ // Reusable Maestro fixtures live in the documented subflows directory.
1024
+ // Other rules, including hard waits, still apply to these files.
1025
+ if (/(?:^|\/)subflows\//.test(context.relativePath.replaceAll('\\', '/'))) return false;
754
1026
  if (!/^\s*(?:-\s*)?(?:appId|tags)\s*:/m.test(strippedSource) && !/^\s*-\s*(?:launchApp|tapOn|inputText)\b/m.test(strippedSource)) {
755
1027
  // Not a Maestro flow, just a YAML file that happened to match a glob.
756
1028
  return false;
@@ -764,21 +1036,57 @@ const RULES = [
764
1036
  severity: 'HIGH',
765
1037
  gate: 'Absolute',
766
1038
  action: 'block',
767
- scope: 'line',
1039
+ scope: 'source',
768
1040
  kinds: ['js', 'py', 'java', 'go', 'maestro'],
769
- fix: 'Wait on the condition, not the clock: a web-first assertion, an explicit readiness signal, `cy.wait("@alias")`, or `extendedWaitUntil` in a Maestro flow.',
770
- match(line, context) {
1041
+ fix: 'Wait on a web-first assertion, an explicit readiness signal, `cy.wait("@alias")`, or `extendedWaitUntil` in a Maestro flow.',
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`;
771
1052
  const patterns = {
772
- js: /(?:\bwaitForTimeout\s*\(|\bcy\.wait\s*\(\s*\d|(?:^|[^\w.])sleep\s*\(|\bdelay\s*\(\s*\d)/,
773
- py: /(?:\btime\.sleep\s*\(|(?:^|[^\w.])sleep\s*\()/,
774
- java: /\bThread\.sleep\s*\(/,
775
- // The row's own catch-all — "or any bare timer used to order steps" — is
776
- // what carries Go here; `time.Sleep` is the language's only spelling of it.
777
- go: /\btime\.Sleep\s*\(/,
778
- maestro: /^\s*-\s*sleep\s*:/,
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],
779
1083
  };
780
- const pattern = patterns[context.kind];
781
- return Boolean(pattern && pattern.test(line));
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]);
782
1090
  },
783
1091
  },
784
1092
  {
@@ -820,11 +1128,18 @@ const RULES = [
820
1128
  scope: 'line',
821
1129
  kinds: ['pactconfig'],
822
1130
  fix: 'Remove the setting. Pact runs must stay serialized: no concurrent sequence, one worker, isolation on.',
823
- match(line) {
1131
+ match(line, context) {
824
1132
  if (/concurrent\s*:\s*true/.test(line)) return true;
825
1133
  if (/isolate\s*:\s*false/.test(line)) return true;
826
- const concurrency = /(?:maxConcurrency|maxWorkers|minWorkers)\s*:\s*(\d+)/.exec(line);
827
- return Boolean(concurrency && Number(concurrency[1]) > 1);
1134
+ // Match keys in code, then read a numeric literal from the kept view.
1135
+ // This accepts Vitest's quoted counts without treating string examples as settings.
1136
+ for (const key of line.matchAll(/\b(?:maxConcurrency|maxWorkers|minWorkers)\s*:\s*/g)) {
1137
+ const value = context.code
1138
+ .slice(key.index + key[0].trimEnd().length)
1139
+ .match(/^\s*(?:(\d[\d_]*(?:\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)|(['"])(\d+)\2)/);
1140
+ if (value && Number((value[1] ?? value[3]).replaceAll('_', '')) > 1) return true;
1141
+ }
1142
+ return false;
828
1143
  },
829
1144
  },
830
1145
  ];
@@ -898,12 +1213,13 @@ function scanContent(relativePath, source, config, options) {
898
1213
  const gateOpen = isPactConfig ? matchesAnyGlob(relativePath, settings.pactConfigGlobs) : matchesAnyGlob(relativePath, settings.testGlobs);
899
1214
  if (!gateOpen) return [];
900
1215
 
901
- const stripped = stripNoise(source, kind);
1216
+ const stripped = stripNoise(source, kind, relativePath);
902
1217
  const strippedLines = stripped.split('\n');
903
1218
  const rawLines = source.split('\n');
904
1219
  const lineCount = source.replace(/\n$/, '').split('\n').length;
905
1220
  const lineStarts = lineStartOffsets(stripped);
906
1221
  let views = null;
1222
+ let keptLines = null;
907
1223
  const findings = [];
908
1224
 
909
1225
  for (const rule of activeRules(settings)) {
@@ -924,7 +1240,11 @@ function scanContent(relativePath, source, config, options) {
924
1240
  continue;
925
1241
  }
926
1242
 
927
- views ??= { code: stripComments(source, kind, 'keep') ?? stripped, mask: stripComments(source, kind, 'mask') ?? '' };
1243
+ views ??= {
1244
+ code: stripComments(source, kind, 'keep', relativePath) ?? stripped,
1245
+ mask: stripComments(source, kind, 'mask', relativePath) ?? '',
1246
+ };
1247
+ keptLines ??= views.code.split('\n');
928
1248
  // What a violation IS, independent of where it sits and of the comments and
929
1249
  // layout around it: the code it spans, literals intact, whitespace outside
930
1250
  // literals dropped. `introducedFindings` compares these.
@@ -952,7 +1272,7 @@ function scanContent(relativePath, source, config, options) {
952
1272
  }
953
1273
 
954
1274
  for (const [index, line] of strippedLines.entries()) {
955
- const context = { kind, config: settings, rawLines, lineIndex: index, relativePath };
1275
+ const context = { kind, config: settings, rawLines, lineIndex: index, relativePath, code: keptLines[index] };
956
1276
  if (rule.match(line, context)) {
957
1277
  findings.push({
958
1278
  rule,
@@ -25,16 +25,16 @@ Initialize or adopt the all-scope journal through `setup-state.md` section 2 aft
25
25
 
26
26
  ## 2. Scope Activation and Settings
27
27
 
28
- Before SKILL.md executes prepend hooks or greets, resolve settings for every requested phase. Keep canonical `workflow` separately from `ci_workflow`. Scope controls hook ownership: framework-only uses canonical hooks/facts/completion; CI-only uses CI hooks/facts/completion; both uses both. CI-only may read canonical `ci_platform` overrides for platform precedence without loading canonical persistent facts or executing canonical hooks.
28
+ Before SKILL.md executes prepend hooks or greets, resolve settings for every requested phase. Keep canonical `workflow` separately from `ci_workflow`, its `ci` sub-table. Scope controls hook ownership: framework-only uses canonical hooks/facts/completion; CI-only uses CI hooks/facts/completion; both uses both. CI-only never loads canonical persistent facts or executes canonical hooks.
29
29
 
30
30
  When scope includes CI:
31
31
 
32
- 1. Read `{skill-root}/ci/customize.toml` for CI defaults: `ci_platform = auto`, empty `activation_steps_prepend`, `activation_steps_append`, `persistent_facts`, and `on_complete`.
33
- 2. Structurally merge the CI defaults, `_bmad/custom/bmad-tea-ci.toml`, and `_bmad/custom/bmad-tea-ci.user.toml`, skipping missing override files. Existing CI overrides, including migrated platform settings, remain effective.
34
- 3. Store the result as `ci_workflow`. SKILL.md executes applicable prepend entries before greeting, loads applicable facts/globs in lexical order, and executes append entries after greeting through `setup-state.md` section 3's individual durable hook protocol. On Resume, resolve current settings and reload applicable facts; skip completed hook entries and halt on uncertain started entries. Save each applicable phase in `activation_completed` only after its activation succeeds. This section resolves settings; it does not replay activation at phase or worker handoffs.
35
- 4. Framework steps use canonical `workflow`. CI steps read `ci_workflow` for their legacy hooks/facts and the effective platform below. Keep `{skill-root}` bound to the canonical directory for every CI asset.
32
+ 1. `{skill-root}/customize.toml` carries the CI defaults under `[workflow.ci]`: `ci_platform = auto`, empty `activation_steps_prepend`, `activation_steps_append`, `persistent_facts`, and `on_complete`.
33
+ 2. The Step 1 resolver call already merged those defaults with the `[workflow.ci]` tables of `_bmad/custom/bmad-tea-framework.toml` and `.user.toml`. For a CI-only run that resolves no other key, run `uv run {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --project-root {project-root} --key workflow.ci`. No other file supplies CI settings.
34
+ 3. Store the `workflow.ci` table as `ci_workflow`. SKILL.md executes applicable prepend entries before greeting, loads applicable facts/globs in lexical order, and executes append entries after greeting through `setup-state.md` section 3's individual durable hook protocol. On Resume, resolve current settings and reload applicable facts; skip completed hook entries and halt on uncertain started entries. Save each applicable phase in `activation_completed` only after its activation succeeds. This section resolves settings; it does not replay activation at phase or worker handoffs.
35
+ 4. Framework steps use canonical `workflow`. CI steps read `ci_workflow` for their hooks/facts and the effective platform below. Keep `{skill-root}` bound to the canonical directory for every CI asset.
36
36
 
37
- **Platform precedence:** An explicit `workflow.ci_platform` in canonical team/user overrides wins, including explicit `auto`. Inspect those override files to distinguish it from the shipped default. Otherwise use `ci_workflow.ci_platform`, preserving migration-1.toml's destination. If neither is present, use `auto`. Bind the result to `{workflow.ci_platform}` during CI steps without replacing the saved canonical workflow object.
37
+ **Platform:** The effective platform is `ci_workflow.ci_platform`, `auto` when the team and user layers set nothing. Bind it to `{workflow.ci_platform}` during CI steps without replacing the saved canonical workflow object.
38
38
 
39
39
  ## 3. Shared State and Contract
40
40
 
@@ -115,18 +115,22 @@ Set `hookSha256` to the sha256 of the file you copied in 3.1: `shasum -a 256 .cl
115
115
 
116
116
  Fill `testGlobs` from the frameworks selected in step 2 and the directories scaffolded in step 3:
117
117
 
118
- | Detected surface | Add to `testGlobs` |
119
- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
120
- | Playwright | `{test_dir}/**/*.spec.{ts,js}` |
121
- | Cypress | `cypress/e2e/**/*.cy.{ts,js}` |
122
- | Vitest / Jest | `**/*.test.{ts,tsx,js,jsx}`, `**/*.spec.{ts,tsx,js,jsx}` scoped to `{test_dir}` and the source tree that holds co-located unit tests |
123
- | Pact (consumer) | `**/*.pacttest.{ts,js}` |
124
- | pytest | `tests/**/test_*.py`, `**/*_test.py` |
125
- | JUnit | `src/test/java/**/*{Test,Tests,IT}.java` |
126
- | Go test | `**/*_test.go` |
127
- | Maestro | `{maestro_root}/**/*.{yaml,yml}` |
128
-
129
- Fill `pactConfigGlobs` only when a pact vitest config exists: `**/vitest.config.pact.{ts,js}`. Rows H6 and H8 are scoped to that path and cannot fire anywhere else.
118
+ | Detected surface | Add to `testGlobs` |
119
+ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
120
+ | Playwright | `{test_dir}/**/*.spec.{ts,js}` |
121
+ | Cypress | `cypress/e2e/**/*.cy.{ts,js}` |
122
+ | Vitest / Jest | `**/*.test.{ts,tsx,js,jsx}`, `**/*.spec.{ts,tsx,js,jsx}` scoped to `{test_dir}` and the source tree that holds co-located unit tests |
123
+ | Pact (consumer) | `**/*.pacttest.{ts,js}` |
124
+ | pytest | `tests/**/test_*.py`, `**/*_test.py` |
125
+ | JUnit | `src/test/java/**/*{Test,Tests,IT}.java`; for Kotlin, `{kotlin_test_root}/**/*{Test,Tests,IT}.kt` with each detected root, including Android `src/androidTest` |
126
+ | Go test | `**/*_test.go` |
127
+ | Maestro | `{maestro_root}/**/*.{yaml,yml}` |
128
+
129
+ Keep reusable Maestro fixtures in a `subflows/` directory. C4 exempts those fixtures from the assertion-presence requirement; other rules, including H1 hard waits, still apply. Top-level test flows must assert their destination state.
130
+
131
+ The hook mechanically checks JS/TS, Python, Java/Kotlin, Go, and Maestro. C# and Ruby suites use Test Review for quality checks; the hook has no mechanical language rules for them. Test Review also reads a wider set of test directories and file types so it can assess helpers and stack-specific behavior.
132
+
133
+ Fill `pactConfigGlobs` only when a pact vitest config exists: `**/vitest.config.pact.{ts,js,mts,mjs,cts,cjs}` and `**/vitest.pact.config.{ts,js,mts,mjs,cts,cjs}`. Rows H6 and H8 are scoped to that path and cannot fire anywhere else.
130
134
 
131
135
  Fill `excludeGlobs` with the k6 script directory when k6 is present, for example `k6/**` or `load-tests/**`. A k6 script's `sleep(1)` is the documented way to model think-time between iterations, so H1 firing there would be the hook wrong about the one language where the pattern is correct. Say in the summary that k6 scripts are excluded and why.
132
136
 
@@ -7,7 +7,6 @@ description: 'Initialize test framework and CI/CD setup for browser, backend or
7
7
  date: system-generated
8
8
 
9
9
  # Workflow components
10
- installed_path: "."
11
10
  instructions: "./instructions.md"
12
11
  validation: "./checklist.md"
13
12