@roomi-fields/grillhouse 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +739 -0
  3. package/bin/grillhouse.mjs +79 -18
  4. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  5. package/cadre/templates/projet/CLAUDE.md +5 -1
  6. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +24 -0
  9. package/dist/temporal/acte.d.ts +24 -0
  10. package/dist/temporal/acte.js +139 -0
  11. package/dist/temporal/acte.js.map +1 -0
  12. package/dist/temporal/attributs.d.ts +6 -0
  13. package/dist/temporal/attributs.js +15 -0
  14. package/dist/temporal/attributs.js.map +1 -0
  15. package/dist/temporal/circuit/activites.d.ts +13 -0
  16. package/dist/temporal/circuit/activites.js +33 -0
  17. package/dist/temporal/circuit/activites.js.map +1 -0
  18. package/dist/temporal/circuit/client.d.ts +72 -0
  19. package/dist/temporal/circuit/client.js +247 -0
  20. package/dist/temporal/circuit/client.js.map +1 -0
  21. package/dist/temporal/circuit/commande.d.ts +2 -0
  22. package/dist/temporal/circuit/commande.js +238 -0
  23. package/dist/temporal/circuit/commande.js.map +1 -0
  24. package/dist/temporal/circuit/contrat.d.ts +305 -0
  25. package/dist/temporal/circuit/contrat.js +24 -0
  26. package/dist/temporal/circuit/contrat.js.map +1 -0
  27. package/dist/temporal/circuit/deroule.d.ts +3 -0
  28. package/dist/temporal/circuit/deroule.js +540 -0
  29. package/dist/temporal/circuit/deroule.js.map +1 -0
  30. package/dist/temporal/client.d.ts +47 -0
  31. package/dist/temporal/client.js +69 -0
  32. package/dist/temporal/client.js.map +1 -0
  33. package/dist/temporal/commande.d.ts +2 -0
  34. package/dist/temporal/commande.js +95 -0
  35. package/dist/temporal/commande.js.map +1 -0
  36. package/dist/temporal/deroules.d.ts +5 -0
  37. package/dist/temporal/deroules.js +10 -0
  38. package/dist/temporal/deroules.js.map +1 -0
  39. package/dist/temporal/etat.d.ts +33 -0
  40. package/dist/temporal/etat.js +59 -0
  41. package/dist/temporal/etat.js.map +1 -0
  42. package/dist/temporal/file/activites.d.ts +10 -0
  43. package/dist/temporal/file/activites.js +25 -0
  44. package/dist/temporal/file/activites.js.map +1 -0
  45. package/dist/temporal/file/client.d.ts +4 -0
  46. package/dist/temporal/file/client.js +6 -0
  47. package/dist/temporal/file/client.js.map +1 -0
  48. package/dist/temporal/file/contrat.d.ts +158 -0
  49. package/dist/temporal/file/contrat.js +14 -0
  50. package/dist/temporal/file/contrat.js.map +1 -0
  51. package/dist/temporal/file/deroule.d.ts +15 -0
  52. package/dist/temporal/file/deroule.js +235 -0
  53. package/dist/temporal/file/deroule.js.map +1 -0
  54. package/dist/temporal/installation.d.ts +124 -0
  55. package/dist/temporal/installation.js +408 -0
  56. package/dist/temporal/installation.js.map +1 -0
  57. package/dist/temporal/places/activites.d.ts +8 -0
  58. package/dist/temporal/places/activites.js +13 -0
  59. package/dist/temporal/places/activites.js.map +1 -0
  60. package/dist/temporal/places/client.d.ts +28 -0
  61. package/dist/temporal/places/client.js +64 -0
  62. package/dist/temporal/places/client.js.map +1 -0
  63. package/dist/temporal/places/contrat.d.ts +106 -0
  64. package/dist/temporal/places/contrat.js +21 -0
  65. package/dist/temporal/places/contrat.js.map +1 -0
  66. package/dist/temporal/places/deroule.d.ts +3 -0
  67. package/dist/temporal/places/deroule.js +198 -0
  68. package/dist/temporal/places/deroule.js.map +1 -0
  69. package/dist/temporal/sonde/activites.d.ts +6 -0
  70. package/dist/temporal/sonde/activites.js +52 -0
  71. package/dist/temporal/sonde/activites.js.map +1 -0
  72. package/dist/temporal/sonde/contrat.d.ts +35 -0
  73. package/dist/temporal/sonde/contrat.js +10 -0
  74. package/dist/temporal/sonde/contrat.js.map +1 -0
  75. package/dist/temporal/sonde/deroule.d.ts +3 -0
  76. package/dist/temporal/sonde/deroule.js +39 -0
  77. package/dist/temporal/sonde/deroule.js.map +1 -0
  78. package/dist/temporal/tickets/activites.d.ts +7 -0
  79. package/dist/temporal/tickets/activites.js +81 -0
  80. package/dist/temporal/tickets/activites.js.map +1 -0
  81. package/dist/temporal/tickets/client.d.ts +10 -0
  82. package/dist/temporal/tickets/client.js +31 -0
  83. package/dist/temporal/tickets/client.js.map +1 -0
  84. package/dist/temporal/tickets/contrat.d.ts +56 -0
  85. package/dist/temporal/tickets/contrat.js +13 -0
  86. package/dist/temporal/tickets/contrat.js.map +1 -0
  87. package/dist/temporal/tickets/deroule.d.ts +3 -0
  88. package/dist/temporal/tickets/deroule.js +94 -0
  89. package/dist/temporal/tickets/deroule.js.map +1 -0
  90. package/dist/temporal/travailleur.d.ts +2 -0
  91. package/dist/temporal/travailleur.js +69 -0
  92. package/dist/temporal/travailleur.js.map +1 -0
  93. package/docs/ARCHITECTURE.md +609 -80
  94. package/docs/CADRE.md +17 -0
  95. package/docs/INTERFACE.md +134 -42
  96. package/hooks/crochet.mjs +19 -2
  97. package/hooks/hooks.json +11 -0
  98. package/package.json +16 -4
  99. package/scripts/activites.mjs +2182 -0
  100. package/scripts/aiguillage.d.mts +37 -0
  101. package/scripts/aiguillage.mjs +7 -3
  102. package/scripts/avancement.mjs +128 -16
  103. package/scripts/bilan.mjs +37 -19
  104. package/scripts/cadre.mjs +11 -2
  105. package/scripts/circuit.mjs +881 -4059
  106. package/scripts/circuits-cles.d.mts +4 -0
  107. package/scripts/circuits-cles.mjs +21 -0
  108. package/scripts/circuits-du-serveur.mjs +105 -0
  109. package/scripts/codes-de-sortie.mjs +9 -0
  110. package/scripts/commandes-composees.mjs +45 -41
  111. package/scripts/commandes-du-path.d.mts +7 -0
  112. package/scripts/commandes-du-path.mjs +25 -0
  113. package/scripts/composition-des-langages.mjs +16 -12
  114. package/scripts/conformite.mjs +6 -13
  115. package/scripts/copies-finies.mjs +52 -47
  116. package/scripts/depart-du-ticket.d.mts +53 -0
  117. package/scripts/depart-du-ticket.mjs +124 -0
  118. package/scripts/dependances-internes.mjs +115 -0
  119. package/scripts/dernier-vert.mjs +7 -15
  120. package/scripts/donnees-cles.mjs +228 -0
  121. package/scripts/droits.mjs +11 -1
  122. package/scripts/effets.mjs +352 -0
  123. package/scripts/enveloppe/enveloppe.mjs +119 -8
  124. package/scripts/enveloppe/lancer.sh +14 -18
  125. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  126. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -1
  127. package/scripts/etapes.mjs +5 -2
  128. package/scripts/faits-du-circuit.mjs +493 -0
  129. package/scripts/file-des-tickets.d.mts +21 -0
  130. package/scripts/file-des-tickets.mjs +58 -0
  131. package/scripts/flux-des-paquets.mjs +187 -0
  132. package/scripts/gardes-du-cadre.mjs +12 -2
  133. package/scripts/integration/file.mjs +475 -420
  134. package/scripts/integration/integrer.mjs +17 -19
  135. package/scripts/integration/rejeu.mjs +19 -4
  136. package/scripts/jointure.d.ts +145 -27
  137. package/scripts/langages/cargo/commandes.mjs +289 -109
  138. package/scripts/langages/cargo/composants.mjs +130 -34
  139. package/scripts/langages/cargo/exemples.mjs +12 -21
  140. package/scripts/langages/cargo/index.mjs +18 -8
  141. package/scripts/langages/cargo/sccache.mjs +8 -14
  142. package/scripts/langages/python/commandes.mjs +216 -100
  143. package/scripts/langages/python/composants.mjs +53 -21
  144. package/scripts/langages/python/exemples.mjs +6 -16
  145. package/scripts/langages/python/index.mjs +24 -8
  146. package/scripts/langages/python/lot.mjs +1 -36
  147. package/scripts/langages/typescript/construire.mjs +6 -163
  148. package/scripts/langages/typescript/exemples.mjs +3 -11
  149. package/scripts/langages/typescript/frontieres.mjs +1 -1
  150. package/scripts/langages/typescript/index.mjs +43 -61
  151. package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
  152. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  153. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
  154. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  155. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  156. package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
  157. package/scripts/langages/typescript/tests-de-nuit.mjs +12 -9
  158. package/scripts/langages/typescript/tests.mjs +17 -8
  159. package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
  160. package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
  161. package/scripts/langages/typescript/verdict.mjs +1 -1
  162. package/scripts/langages/typescript/verifier.mjs +31 -11
  163. package/scripts/langages/typescript/vitest-config/base.mjs +22 -1
  164. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  165. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  166. package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
  167. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  168. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
  169. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +49 -63
  170. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +3 -0
  171. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  172. package/scripts/mesure/pression.mjs +3 -3
  173. package/scripts/mesure-de-la-machine.d.mts +21 -0
  174. package/scripts/mesure-de-la-machine.mjs +76 -0
  175. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
  176. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
  177. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  178. package/scripts/migrations.mjs +5 -0
  179. package/scripts/nuit.sh +10 -3
  180. package/scripts/outils-cles.d.mts +24 -0
  181. package/scripts/outils-cles.mjs +0 -1
  182. package/scripts/paquet-npm.mjs +147 -0
  183. package/scripts/paquet.mjs +73 -4
  184. package/scripts/paquets.mjs +34 -6
  185. package/scripts/passe-de-la-machine.mjs +66 -0
  186. package/scripts/places-de-la-machine.mjs +360 -0
  187. package/scripts/places-du-serveur.mjs +170 -0
  188. package/scripts/prefixe-des-tickets.mjs +68 -0
  189. package/scripts/preparation.mjs +10 -3
  190. package/scripts/registre.mjs +3 -2
  191. package/scripts/regles-des-places.d.mts +36 -0
  192. package/scripts/regles-des-places.mjs +70 -0
  193. package/scripts/reponses-du-circuit.d.mts +6 -0
  194. package/scripts/reponses-du-circuit.mjs +28 -0
  195. package/scripts/resultats.mjs +7 -9
  196. package/scripts/retirer-les-copies-finies.mjs +25 -0
  197. package/scripts/sans-reponse.d.mts +4 -0
  198. package/scripts/sans-reponse.mjs +13 -0
  199. package/scripts/seances.mjs +918 -0
  200. package/scripts/services-du-noyau.mjs +26 -8
  201. package/scripts/session-start.sh +2 -2
  202. package/scripts/sortie.mjs +3 -3
  203. package/scripts/sous-commandes.mjs +38 -9
  204. package/scripts/style-a-l-ecriture.mjs +229 -0
  205. package/scripts/superviseur.mjs +122 -111
  206. package/scripts/tableau.mjs +148 -110
  207. package/scripts/taches-du-graphe.mjs +328 -0
  208. package/scripts/ticket-du-circuit.mjs +206 -0
  209. package/scripts/transitions.d.mts +148 -0
  210. package/scripts/transitions.mjs +901 -0
  211. package/scripts/verrou-de-fichier.mjs +2 -2
  212. package/scripts/verrou-de-machine.mjs +28 -13
  213. package/skills/explorateur/SKILL.md +2 -1
  214. package/skills/pitmaster/SKILL.md +17 -18
  215. package/skills/pitmaster/references/consigne-agent.md +5 -1
  216. package/skills/release/SKILL.md +3 -3
  217. package/skills/relecteur/SKILL.md +4 -2
  218. package/skills/testwriter/SKILL.md +36 -24
  219. package/scripts/demon.mjs +0 -251
  220. package/scripts/integration/file-attente.mjs +0 -61
  221. package/scripts/langages/cargo/touches.mjs +0 -93
  222. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -0,0 +1,31 @@
1
+ // From 0.30.0 the guard of the sizes of the tests (scripts/langages/typescript/tailles-des-tests.mjs)
2
+ // also sees large a test that mounts a temporary directory and starts a heavy tool of the product
3
+ // there (turbo, vitest, knip, depcruise, api-extractor), with a `cwd:`; the tests it classed medium
4
+ // become large tests of the day, and the main of a project that updates would turn red at its next
5
+ // pass. As the migration 0.25.0 does for the first rule, the update inscribes them as the project's
6
+ // known debt (scripts/dette.mjs), frozen: the count never rises and a new large test of the day is
7
+ // refused.
8
+ //
9
+ // - The migration inscribes the large tests of the day the guard finds that the debt does not hold
10
+ // yet; the debt already inscribed (the guard's, the other guards') stays.
11
+ // - It rewrites no test of the project: the project moves each one to the night (`*.nuit.test.*`)
12
+ // or reduces it, and the debt comes down with it.
13
+ // - Replayable without effect: once every finding is inscribed, nothing.
14
+ import { FICHIER, lire, trancher } from '../../../dette.mjs';
15
+ import { GARDE, verifier } from '../tailles-des-tests.mjs';
16
+
17
+ export const version = '0.30.0';
18
+ export const nom = 'tailles des outils lourds';
19
+
20
+ /** Inscribes the large tests of the day the debt of the project at <projet> lacks; what it did. */
21
+ export function migrer(projet) {
22
+ const inscrite = lire(projet)[GARDE] ?? {};
23
+ const constats = verifier(projet);
24
+ const neufs = constats.filter(c => !inscrite[c.fichier]?.[c.regle]);
25
+ if (neufs.length === 0) return [];
26
+ // Inscribed counts stay; a finding without key is added at its count.
27
+ trancher(projet, GARDE, constats, 'inscrire', {});
28
+ return [
29
+ `${FICHIER} : ${neufs.length} grand(s) test(s) de jour inscrit(s) dans la dette de ${GARDE}, gelée ; un grand test de jour neuf est refusé, et chacun passe à la nuit (*.nuit.test.*) ou se réduit`,
30
+ ];
31
+ }
@@ -0,0 +1,40 @@
1
+ // From 0.30.0 the guard of the titles of the tests (scripts/langages/typescript/titres-de-tests.mjs)
2
+ // refuses a test file whose titles name a ticket or a « critère N » beyond its debt; the titles a
3
+ // project already has would turn its main red at its next pass. As the migration of the large
4
+ // tests of the day does (./0.30.0-tailles-des-outils-lourds.mjs), the update inscribes them as the
5
+ // project's known debt (scripts/dette.mjs), frozen: the count never rises, and each title renamed
6
+ // by its behaviour lowers it.
7
+ //
8
+ // - It plays after the migration of the prefix of the tickets (./0.30.0-prefixe-des-tickets.mjs),
9
+ // whose key it reads; without the key it inscribes nothing, and the guard names the key.
10
+ // - The migration inscribes the files the debt does not hold yet; the debt already inscribed (the
11
+ // guard's, the other guards') stays.
12
+ // - It rewrites no test of the project.
13
+ // - Replayable without effect: once every finding is inscribed, nothing.
14
+ import { FICHIER, lire, trancher } from '../../../dette.mjs';
15
+ import { prefixe } from '../../../services-du-noyau.mjs';
16
+ import { GARDE, verifier } from '../titres-de-tests.mjs';
17
+
18
+ export const version = '0.30.0';
19
+ export const nom = 'titres nommant un ticket';
20
+
21
+ /** Inscribes the titles naming a ticket that the debt of the project at <projet> lacks; what it did. */
22
+ export function migrer(projet) {
23
+ let pref;
24
+ try {
25
+ pref = prefixe(projet);
26
+ } catch {
27
+ return [];
28
+ }
29
+ const inscrite = lire(projet)[GARDE] ?? {};
30
+ const constats = verifier(projet, pref);
31
+ const neufs = constats.filter(c => !inscrite[c.fichier]?.[c.regle]);
32
+ if (neufs.length === 0) {
33
+ return [];
34
+ }
35
+ trancher(projet, GARDE, constats, 'inscrire', {});
36
+ const fichiers = new Set(neufs.map(c => c.fichier)).size;
37
+ return [
38
+ `${FICHIER} : ${neufs.length} titre(s) de test nommant un ticket ou un « critère N », dans ${fichiers} fichier(s), inscrit(s) dans la dette de ${GARDE}, gelée ; chacun se renomme par son comportement, et la dette baisse avec lui`,
39
+ ];
40
+ }
@@ -50,9 +50,8 @@ import { copyFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
50
50
  import { createRequire } from 'node:module';
51
51
  import path from 'node:path';
52
52
  import { CODE, paquets, TYPAGE } from '../../paquets.mjs';
53
- import { sources } from '../../services-du-noyau.mjs';
53
+ import { SCRIPT_DES_TESTS, sources } from '../../services-du-noyau.mjs';
54
54
  import { estUnTest } from './regle-des-tests.mjs';
55
- import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
56
55
 
57
56
  // The frame's package, as a project declares it, and its base configuration of Vitest.
58
57
  const PAQUET_DU_CADRE = '@roomi-fields/grillhouse';
@@ -18,11 +18,18 @@
18
18
  // test is classed the day the rule arrives.
19
19
  // - large (`grand`): it mounts a trial repository (git's `init`, `clone` or `worktree add`) and
20
20
  // starts there something else than git (node, npm, a shell, a binary of the product);
21
+ // or it mounts a temporary directory (`mkdtemp`, `tmpdir`) and, in a process call carrying
22
+ // `cwd:` (or `-C`, `--prefix`), starts one of the heavy tools of OUTILS_LOURDS (turbo,
23
+ // vitest, knip, depcruise, api-extractor), named by a literal argument or a literal path to
24
+ // its binary, with no `git init` (grillhouse-44b.10.4, Bazel's test-encyclopedia: a test
25
+ // that runs the product in a trial project is large). A tool named by a variable, or run by
26
+ // an npm script (`npm run verifier`), escapes the reading and the test stays medium; so
27
+ // does a call without `cwd` (on the repository);
21
28
  // - medium (`moyen`): it starts a process (it imports `child_process`, `execa` or `zx`), or it
22
29
  // imports several modules of the repository;
23
30
  // - small (`petit`): it imports one module of the repository at most, and starts no process.
24
31
  // - A large test of the day is a finding, `{ fichier, regle: 'grand-de-jour', message }`; a night
25
- // test or a time budget bench (HORS_DU_JOUR, ./vitest-config/cibles.mjs) is never one. A finding
32
+ // test or a time budget bench (`deNuitOuBanc`, ./vitest-config/cibles.mjs) is never one. A finding
26
33
  // inscribed in the project's debt (`grillhouse-dette.json`, ./dette.mjs) passes: the large tests
27
34
  // of the day that exist when the rule arrives are inscribed there by the update
28
35
  // (./migrations/0.25.0-tailles-des-tests.mjs), the count never rises, and a new one is refused.
@@ -33,7 +40,7 @@ import path from 'node:path';
33
40
  import { pathToFileURL } from 'node:url';
34
41
  import { trancher } from '../../dette.mjs';
35
42
  import { matieres } from './composants.mjs';
36
- import { HORS_DU_JOUR } from './vitest-config/cibles.mjs';
43
+ import { deNuitOuBanc } from './vitest-config/cibles.mjs';
37
44
  import {
38
45
  IMPORT,
39
46
  lireLeDisque,
@@ -56,6 +63,33 @@ const APPEL =
56
63
  /(?:(?<![\w$])(?:spawnSync|spawn|execFileSync|execFile|execSync|fork|execaSync|execa)|(?<![.\w$])exec)\s*\(\s*([^,)\n]*)/g;
57
64
  // A first argument that names git.
58
65
  const GIT = /^['"`]git(?:['"`]|\s)/;
66
+ /** The heavy tools of the product: a test that starts one in a trial project is large. */
67
+ export const OUTILS_LOURDS = ['turbo', 'vitest', 'knip', 'depcruise', 'api-extractor'];
68
+ // A temporary directory mounted.
69
+ const DOSSIER_TEMPORAIRE = /\bmkdtemp(?:Sync)?\b|\btmpdir\b/;
70
+ // An option of a call that carries the directory the process runs in.
71
+ const OPTION_DE_DOSSIER = /\bcwd\b|['"`](?:-C|--prefix)['"`]/;
72
+ // A heavy tool named by a literal in a call: a name, or the end of a path to its binary.
73
+ const OUTIL_LITTERAL = new RegExp(`(?:^|[\\s'"\`/])(?:${OUTILS_LOURDS.join('|')})(?=$|[\\s'"\`])`);
74
+ // The text of the call whose `(` is at <debut> in <texte>, to its closing parenthesis.
75
+ function appelComplet(texte, debut) {
76
+ let profondeur = 0;
77
+ const fin = Math.min(texte.length, debut + 2000);
78
+ for (let i = debut; i < fin; i++) {
79
+ if (texte[i] === '(') profondeur++;
80
+ else if (texte[i] === ')' && --profondeur === 0) return texte.slice(debut, i + 1);
81
+ }
82
+ return texte.slice(debut, fin);
83
+ }
84
+ // Whether <texte> mounts a temporary directory and, in a process call carrying `cwd`, `-C` or
85
+ // `--prefix`, starts a heavy tool named by a literal.
86
+ function outilLourdEnProjetDEssai(texte) {
87
+ if (!DOSSIER_TEMPORAIRE.test(texte)) return false;
88
+ return [...texte.matchAll(APPEL)].some(m => {
89
+ const appel = appelComplet(texte, m.index + m[0].indexOf('('));
90
+ return OPTION_DE_DOSSIER.test(appel) && OUTIL_LITTERAL.test(appel);
91
+ });
92
+ }
59
93
  // A re-export of a whole module.
60
94
  const TOUT_REEXPORTE = /\bexport\s*\*\s*from\b/;
61
95
  // The names an import clause <clause> takes in braces (`import { a, b as c }` gives a and b);
@@ -90,7 +124,7 @@ function entreeDeLaMatiere(paquet) {
90
124
  // The packages of the shared test material of the repository at <racine>: `[{ nom, dir, entree }]`,
91
125
  // `nom` the name by which a test imports it, `dir` its directory and `entree` the file of its
92
126
  // entry `./test-fixtures`, absolute.
93
- function lesMatieres(racine) {
127
+ export function lesMatieres(racine) {
94
128
  return matieres(racine).flatMap(({ dir, paquet }) => {
95
129
  let pkg;
96
130
  try {
@@ -150,7 +184,7 @@ export function classer(fichier, lire, racine = path.parse(fichier).root, lesMat
150
184
  const processus = PROCESSUS.test(tout);
151
185
  const autreQueGit = [...tout.matchAll(APPEL)].some(m => !GIT.test(m[1].trim()));
152
186
  const taille =
153
- processus && autreQueGit && DEPOT_D_ESSAI.test(tout)
187
+ processus && ((autreQueGit && DEPOT_D_ESSAI.test(tout)) || outilLourdEnProjetDEssai(tout))
154
188
  ? 'grand'
155
189
  : processus || modules.size > 1
156
190
  ? 'moyen'
@@ -158,9 +192,6 @@ export function classer(fichier, lire, racine = path.parse(fichier).root, lesMat
158
192
  return { taille, modules: [...modules] };
159
193
  }
160
194
 
161
- // Whether <r>, a path from the root, is a night test or a time budget bench.
162
- const horsDuJour = r => HORS_DU_JOUR.some(p => path.matchesGlob(r, p));
163
-
164
195
  // The directories a listing out of git leaves out.
165
196
  const HORS = /(?:^|\/)(?:node_modules|dist|\.git|\.turbo|\.claude)$/;
166
197
 
@@ -186,7 +217,7 @@ export function tailles(racine) {
186
217
  return testsDuDepot(racine).map(fichier => ({
187
218
  fichier,
188
219
  taille: classer(path.join(racine, fichier), lireLeDisque, racine, m).taille,
189
- nuit: horsDuJour(fichier),
220
+ nuit: deNuitOuBanc(fichier),
190
221
  }));
191
222
  }
192
223
 
@@ -200,7 +231,7 @@ export function verifier(racine) {
200
231
  .map(({ fichier }) => ({
201
232
  fichier,
202
233
  regle: GRAND_DE_JOUR,
203
- message: `${fichier} : un grand test (il monte un dépôt d'essai et y lance le produit ou le cadre) est un test de nuit, jamais joué au fil du travail ; il se renomme en *.nuit.test.*, ou il se réduit à la plus petite taille qui prouve son critère.`,
234
+ message: `${fichier} : un grand test (il monte un dépôt ou un projet d'essai et y lance le produit ou le cadre) est un test de nuit, jamais joué au fil du travail ; il se renomme en *.nuit.test.*, ou il se réduit à la plus petite taille qui prouve son critère.`,
204
235
  }));
205
236
  }
206
237
 
@@ -26,21 +26,24 @@ import { readdirSync } from 'node:fs';
26
26
  import path from 'node:path';
27
27
  import { fileURLToPath, pathToFileURL } from 'node:url';
28
28
  import { A_REPASSER, attendreDeLaPlace } from '../../services-du-noyau.mjs';
29
- import { fichiersTemoins, NUIT_VARIABLE } from './vitest-config/cibles.mjs';
29
+ import {
30
+ estUnBanc,
31
+ estUnTestDeNuit,
32
+ fichiersTemoins,
33
+ NUIT_VARIABLE,
34
+ } from './vitest-config/cibles.mjs';
30
35
 
31
36
  const CONFIGURATION = fileURLToPath(new URL('./vitest.nuit.config.mjs', import.meta.url));
32
37
  const HORS = new Set(['node_modules', 'dist', '.git']);
33
- const DE_NUIT = /\.nuit\.(test|spec)\.(c|m)?[jt]sx?$/;
34
- const BANC = /\.budget\.(test|spec)\.(c|m)?[jt]sx?$/;
35
38
 
36
- // Whether a file whose name <motif> matches lies under <dossier>.
37
- function enTient(dossier, motif) {
39
+ // Whether a file that <est> (the rules of ./vitest-config/cibles.mjs) lies under <dossier>.
40
+ function enTient(dossier, est) {
38
41
  for (const e of readdirSync(dossier, { withFileTypes: true })) {
39
42
  if (e.isDirectory()) {
40
- if (!HORS.has(e.name) && enTient(path.join(dossier, e.name), motif)) {
43
+ if (!HORS.has(e.name) && enTient(path.join(dossier, e.name), est)) {
41
44
  return true;
42
45
  }
43
- } else if (e.isFile() && motif.test(e.name)) {
46
+ } else if (e.isFile() && est(e.name)) {
44
47
  return true;
45
48
  }
46
49
  }
@@ -54,8 +57,8 @@ function enTient(dossier, motif) {
54
57
  */
55
58
  export function testsDeNuit(racine) {
56
59
  const runs = [
57
- enTient(racine, DE_NUIT) && 'nuit',
58
- (enTient(racine, BANC) || fichiersTemoins(racine).length > 0) && 'mesures',
60
+ enTient(racine, estUnTestDeNuit) && 'nuit',
61
+ (enTient(racine, estUnBanc) || fichiersTemoins(racine).length > 0) && 'mesures',
59
62
  ].filter(Boolean);
60
63
  if (runs.length === 0) {
61
64
  return 0;
@@ -89,13 +89,16 @@ import {
89
89
  ouvrirBase,
90
90
  paquetsDeLEnveloppe,
91
91
  retirerALInterruption,
92
+ SCRIPT_DES_TESTS,
93
+ surUnePlace,
94
+ TESTS_CIBLES,
95
+ testsCibles,
96
+ tracesDuPlan,
92
97
  } from '../../services-du-noyau.mjs';
93
98
  import { paquets } from '../../paquets.mjs';
94
99
  import { garderLesResumes } from './verdict.mjs';
95
100
  import { RESULTATS } from '../../resultats.mjs';
96
- import { planifier, tracesDuPlan } from './turbo-des-paquets.mjs';
97
- import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
98
- import { VARIABLE } from './vitest-config/cibles.mjs';
101
+ import { horsTypescript, planifier } from './turbo-des-paquets.mjs';
99
102
 
100
103
  const racine = process.cwd();
101
104
  // The base of the run (scripts/mesure/base-de-passe.mjs): this process and every run of
@@ -118,10 +121,10 @@ if (depuis) process.stdout.write(`${depuis.ligne}\n`);
118
121
  // (RESULTATS), Turborepo writes its summary, which goes there.
119
122
  const turbo = (args, tests) => {
120
123
  const env = { ...process.env };
121
- delete env[VARIABLE];
124
+ delete env[TESTS_CIBLES];
122
125
  delete env[CHANGEMENTS];
123
126
  Object.assign(env, depuis?.env ?? {});
124
- if (tests) env[VARIABLE] = JSON.stringify(tests);
127
+ if (tests) env[TESTS_CIBLES] = JSON.stringify(tests);
125
128
  const resume = env[RESULTATS] ? ['--summarize'] : [];
126
129
  const runs = path.join(racine, '.turbo', 'runs');
127
130
  const avant = new Set(existsSync(runs) ? readdirSync(runs) : []);
@@ -162,7 +165,8 @@ const traces = (filtres, noms) => {
162
165
  // in an envelope, the build of the packages they name with their own traces, then the tests alone.
163
166
  // Its exit code: the first that is not 0, else the tests'.
164
167
  const cibles = (filtres, passes) => {
165
- const tests = { arguments: passes, ...(force ? { rejouer: new Date().toISOString() } : {}) };
168
+ // `testsCibles` is undefined with no path and no `--force`: the variable then stays unset.
169
+ const tests = testsCibles({ arguments: passes, force });
166
170
  if (!enveloppe) return turbo([SCRIPT_DES_TESTS, ...filtres], tests);
167
171
  // A package the envelope shows read-only arrives built: only the packages it shows in writing
168
172
  // build, as the envelope mounts them (`inscriptible`).
@@ -195,7 +199,7 @@ const dossiers = new Map(liste.map(p => [p.pkg.name, path.join(racine, p.dossier
195
199
  const lancer = () => {
196
200
  if (chemins.length === 0) {
197
201
  return turbo(
198
- [SCRIPT_DES_TESTS, ...(force ? ['--force'] : [])],
202
+ [SCRIPT_DES_TESTS, ...horsTypescript(racine), ...(force ? ['--force'] : [])],
199
203
  options.length ? { arguments: options } : undefined
200
204
  );
201
205
  }
@@ -239,7 +243,12 @@ const lancer = () => {
239
243
  };
240
244
 
241
245
  try {
242
- process.exitCode = lancer();
246
+ // The run takes a place of the machine (scripts/places-de-la-machine.mjs), whose mark every run
247
+ // of Turborepo carries to its tasks.
248
+ process.exitCode = surUnePlace(env => {
249
+ Object.assign(process.env, env);
250
+ return lancer();
251
+ });
243
252
  } finally {
244
253
  lacher();
245
254
  depuis?.retirer();
@@ -0,0 +1,297 @@
1
+ #!/usr/bin/env node
2
+ // The title of a test, on the model of Software Engineering at Google (ch. 12: « write a test for
3
+ // each behavior »): a test bears the name of the behavior it proves, never a ticket's or a
4
+ // « critère N »; a test whose title does not say its behavior ends deleted. The ticket goes to the
5
+ // commit message.
6
+ //
7
+ // npx grillhouse titres-de-tests run from the repository root (a guard of grillhouse:gardes)
8
+ //
9
+ // - The count is a union: a title counts once if it names a ticket of the project (its prefix, read
10
+ // from the key `issue-prefix` of `.beads/config.yaml`, committed, never by `bd`, which a CI does
11
+ // not have; the guard names the file or the key when it is missing), followed by an
12
+ // identifier: `grillhouse-44b.10.8`) or a « critère N » (or « critères N »), or both.
13
+ // - The guard reads the Vitest tests of the project (the files `*.test.*` and `*.spec.*` of every
14
+ // component, the night tests included, as ./tailles-des-tests.mjs lists them): the calls
15
+ // `describe`, `it` and `test` and their variants (`skip`, `only`, `each`, `todo`...). It sees the
16
+ // static text of a title: a literal, the fixed parts of a template, the format of an `each`. A
17
+ // title carried by a variable is not seen, nor a title in a comment.
18
+ // - The Rust and Python tests are out of the count: their titles are function names, without
19
+ // `describe` or `it` (a deviation written here and in each refusal).
20
+ // - A finding is `{ fichier, ligne, regle: 'titre-nommant-un-ticket', message }`. The debt
21
+ // (`grillhouse-dette.json`, ../../dette.mjs) counts them file by file: a file whose count rises
22
+ // above its debt, or absent from the debt with a title counted, is refused by its name; a debt
23
+ // above the real count is refused too, so that the lot lowers it by `npm run
24
+ // grillhouse:dette:elaguer`. A test file moved or renamed by the lot, its content kept (or
25
+ // nearly), takes the debt of its former name (`renommesDuLot`).
26
+ import { spawnSync } from 'node:child_process';
27
+ import { readFileSync, writeFileSync } from 'node:fs';
28
+ import path from 'node:path';
29
+ import { pathToFileURL } from 'node:url';
30
+ import { FICHIER, lire as lireDette, trancher } from '../../dette.mjs';
31
+ import { A_ELAGUER, ecrireSarif } from '../../resultats.mjs';
32
+ import { prefixe } from '../../services-du-noyau.mjs';
33
+ import { testsDuDepot } from './tailles-des-tests.mjs';
34
+ import { TEST } from './vitest-config/lances.mjs';
35
+
36
+ export const GARDE = 'titres-de-tests';
37
+ export const REGLE = 'titre-nommant-un-ticket';
38
+
39
+ const escape = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
40
+ const CRITERE = /(?<!\p{L})crit[èe]res?\s+\d/iu;
41
+ // The calls that carry a title: describe, it, test, a chain of variants, the arguments of an `each`
42
+ // when there are some, then the opening quote of the title.
43
+ const APPEL =
44
+ /(?<![\w$.])(?:describe|it|test)(?:\s*\.\s*(?:skip|only|todo|concurrent|sequential|fails|runIf|skipIf|each|for))*\s*(?:\([^()]*(?:\([^()]*\)[^()]*)*\)\s*)?\(\s*(['"`])/g;
45
+
46
+ // <texte> with its comments blanked (the newlines kept), the strings left as they are.
47
+ function sansCommentaires(texte) {
48
+ let out = '';
49
+ let i = 0;
50
+ while (i < texte.length) {
51
+ const c = texte[i];
52
+ const d = texte[i + 1];
53
+ if (c === '/' && d === '/') {
54
+ while (i < texte.length && texte[i] !== '\n') {
55
+ out += ' ';
56
+ i++;
57
+ }
58
+ } else if (c === '/' && d === '*') {
59
+ const fin = texte.indexOf('*/', i + 2);
60
+ const stop = fin === -1 ? texte.length : fin + 2;
61
+ out += texte.slice(i, stop).replace(/[^\n]/g, ' ');
62
+ i = stop;
63
+ } else if (c === "'" || c === '"' || c === '`') {
64
+ let j = i + 1;
65
+ while (j < texte.length && texte[j] !== c && !(c !== '`' && texte[j] === '\n')) {
66
+ j += texte[j] === '\\' ? 2 : 1;
67
+ }
68
+ out += texte.slice(i, j + 1);
69
+ i = j + 1;
70
+ } else {
71
+ out += c;
72
+ i++;
73
+ }
74
+ }
75
+ return out;
76
+ }
77
+
78
+ // The static text of the literal opened by the quote at <debut> of <texte>: the fixed parts of a
79
+ // template, its `${…}` left out.
80
+ function litteral(texte, debut) {
81
+ const guillemet = texte[debut];
82
+ let titre = '';
83
+ let i = debut + 1;
84
+ while (i < texte.length && texte[i] !== guillemet) {
85
+ if (texte[i] === '\\') {
86
+ titre += texte[i + 1] ?? '';
87
+ i += 2;
88
+ } else if (guillemet === '`' && texte[i] === '$' && texte[i + 1] === '{') {
89
+ let profondeur = 0;
90
+ do {
91
+ if (texte[i] === '{') profondeur++;
92
+ else if (texte[i] === '}') profondeur--;
93
+ i++;
94
+ } while (i < texte.length && profondeur > 0);
95
+ titre += ' ';
96
+ } else {
97
+ titre += texte[i++];
98
+ }
99
+ }
100
+ return titre;
101
+ }
102
+
103
+ /**
104
+ * The titles of <texte> (a Vitest file) that name a ticket of the prefix <prefixe> or a
105
+ * « critère N »: `[{ titre, ligne }]`, each title once, `ligne` 1-based.
106
+ */
107
+ export function titresNommantUnTicket(texte, prefixe) {
108
+ const ticket = prefixe
109
+ ? new RegExp(`(?<![\\w.-])${escape(prefixe)}-[a-z0-9]+(?:\\.[0-9]+)*(?![\\w-])`, 'i')
110
+ : null;
111
+ const propre = sansCommentaires(texte);
112
+ const out = [];
113
+ for (const m of propre.matchAll(APPEL)) {
114
+ const debut = m.index + m[0].length - 1;
115
+ const titre = litteral(propre, debut);
116
+ if (CRITERE.test(titre) || ticket?.test(titre)) {
117
+ out.push({ titre, ligne: propre.slice(0, debut).split('\n').length });
118
+ }
119
+ }
120
+ return out;
121
+ }
122
+
123
+ const MESSAGE_FIN =
124
+ "nomme le test par le comportement qu'il prouve, jamais par un ticket ni un « critère N » : le ticket va au message du commit. Les tests Rust et Python sont hors du compte (leurs titres sont des noms de fonction, sans describe ni it).";
125
+
126
+ /**
127
+ * The findings of the repository at <racine>, the prefix of the tickets <prefixe>: one
128
+ * `{ fichier, ligne, regle, message }` per title of a Vitest file that names a ticket or a
129
+ * « critère N ».
130
+ */
131
+ export function verifier(racine, prefixe) {
132
+ return testsDuDepot(racine).flatMap(fichier => {
133
+ let texte;
134
+ try {
135
+ texte = readFileSync(path.join(racine, fichier), 'utf8');
136
+ } catch {
137
+ return [];
138
+ }
139
+ return titresNommantUnTicket(texte, prefixe).map(({ titre, ligne }) => ({
140
+ fichier,
141
+ ligne,
142
+ regle: REGLE,
143
+ message: `${fichier}:${ligne} : le titre « ${titre.trim()} » nomme un ticket ou un « critère N » ; ${MESSAGE_FIN}`,
144
+ }));
145
+ });
146
+ }
147
+
148
+ const git = (racine, args) =>
149
+ spawnSync('git', ['-C', racine, ...args], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
150
+
151
+ // The share of the lines of <a> that <b> keeps, over the lines of both (0 to 1).
152
+ function ressemblance(a, b) {
153
+ const la = new Set(a.split('\n'));
154
+ const lb = new Set(b.split('\n'));
155
+ let commun = 0;
156
+ for (const l of la) if (lb.has(l)) commun++;
157
+ return commun / (la.size + lb.size - commun || 1);
158
+ }
159
+
160
+ /**
161
+ * The test files the lot of the working copy at <racine> moves or renames, against HEAD:
162
+ * `{ nouveau: ancien }`. The index is not read: a file deleted and a file added, of the same
163
+ * content (or nearly, at least half of the lines kept), are one rename.
164
+ */
165
+ export function renommesDuLot(racine) {
166
+ const supprimes = git(racine, ['diff', 'HEAD', '--name-only', '--diff-filter=D', '-z']);
167
+ const connus = git(racine, ['ls-tree', '-r', '--name-only', 'HEAD', '-z']);
168
+ if (supprimes.status !== 0 || connus.status !== 0) return {};
169
+ const anciens = supprimes.stdout.split('\0').filter(f => f && TEST.test(f));
170
+ const avant = new Set(connus.stdout.split('\0'));
171
+ const nouveaux = testsDuDepot(racine).filter(f => !avant.has(f));
172
+ const textesAnciens = new Map(
173
+ anciens.map(f => [f, git(racine, ['show', `HEAD:${f}`]).stdout ?? ''])
174
+ );
175
+ const out = {};
176
+ const pris = new Set();
177
+ const paires = nouveaux.flatMap(n => {
178
+ let texte;
179
+ try {
180
+ texte = readFileSync(path.join(racine, n), 'utf8');
181
+ } catch {
182
+ return [];
183
+ }
184
+ return anciens.map(a => ({ n, a, s: ressemblance(texte, textesAnciens.get(a)) }));
185
+ });
186
+ for (const { n, a, s } of paires.filter(p => p.s >= 0.5).sort((x, y) => y.s - x.s)) {
187
+ if (out[n] || pris.has(a)) continue;
188
+ out[n] = a;
189
+ pris.add(a);
190
+ }
191
+ return out;
192
+ }
193
+
194
+ /**
195
+ * The refusals of the findings <constats> against the <dette> read from the file: one
196
+ * `{ fichier, message }` per file whose count rises above its debt (a file absent from the debt
197
+ * has none) and per file whose debt stays above its count. <renommes> (`{ nouveau: ancien }`)
198
+ * gives a file moved or renamed the debt of its former name.
199
+ */
200
+ export function jugerLesTitres(dette, constats, renommes = {}) {
201
+ const inscrite = dette?.[GARDE] ?? {};
202
+ const permis = f => inscrite[f]?.[REGLE]?.count ?? 0;
203
+ const comptes = new Map();
204
+ for (const c of constats) comptes.set(c.fichier, (comptes.get(c.fichier) ?? 0) + 1);
205
+ const reprises = new Set(Object.values(renommes));
206
+ const refus = [];
207
+ for (const [fichier, trouve] of comptes) {
208
+ const droit = permis(fichier) + (renommes[fichier] ? permis(renommes[fichier]) : 0);
209
+ if (trouve > droit) {
210
+ refus.push({
211
+ fichier,
212
+ regle: REGLE,
213
+ message: `${fichier} : ${trouve} titre(s) nomment un ticket ou un « critère N » pour ${droit} inscrit(s) dans ${FICHIER} : ${MESSAGE_FIN}`,
214
+ });
215
+ } else if (trouve < droit) {
216
+ refus.push({
217
+ fichier,
218
+ regle: REGLE,
219
+ aElaguer: true,
220
+ trouve,
221
+ message: `${fichier} : ${trouve} titre(s) pour ${droit} inscrit(s) dans ${FICHIER} : la dette s'abaisse (npm run grillhouse:dette:elaguer), jamais à la main. ${MESSAGE_FIN}`,
222
+ });
223
+ }
224
+ }
225
+ for (const fichier of Object.keys(inscrite)) {
226
+ if (comptes.has(fichier) || reprises.has(fichier) || !permis(fichier)) continue;
227
+ refus.push({
228
+ fichier,
229
+ regle: REGLE,
230
+ aElaguer: true,
231
+ trouve: 0,
232
+ message: `${fichier} : aucun titre ne nomme plus un ticket ou un « critère N », pour ${permis(fichier)} inscrit(s) dans ${FICHIER} : la dette s'abaisse (npm run grillhouse:dette:elaguer), jamais à la main. ${MESSAGE_FIN}`,
233
+ });
234
+ }
235
+ return refus.sort((a, b) => (a.fichier < b.fichier ? -1 : a.fichier > b.fichier ? 1 : 0));
236
+ }
237
+
238
+ function main() {
239
+ const racine = process.cwd();
240
+ let pref;
241
+ try {
242
+ pref = prefixe(racine);
243
+ } catch (e) {
244
+ process.stderr.write(`⛔ ${e.message}\n`);
245
+ process.exitCode = 1;
246
+ return;
247
+ }
248
+ const constats = verifier(racine, pref);
249
+ const renommes = renommesDuLot(racine);
250
+ let refus;
251
+ let lignes = [];
252
+ if (process.env.GRILLHOUSE_DETTE) {
253
+ // A write of the debt (`inscrire`, `elaguer`): a file moved takes the debt of its former name
254
+ // first, so that the write keeps it.
255
+ const dette = lireDette(racine);
256
+ const section = dette[GARDE];
257
+ if (section) {
258
+ for (const [nouveau, ancien] of Object.entries(renommes)) {
259
+ if (section[ancien] && !section[nouveau]) section[nouveau] = section[ancien];
260
+ delete section[ancien];
261
+ }
262
+ writeFileSync(path.join(racine, FICHIER), `${JSON.stringify(dette, null, 2)}\n`);
263
+ }
264
+ const r = trancher(racine, GARDE, constats);
265
+ refus = r.refus;
266
+ lignes = r.lignes;
267
+ } else {
268
+ refus = jugerLesTitres(lireDette(racine), constats, renommes);
269
+ // Each refusal is a finding in SARIF; a debt above the count is also a note `a-elaguer`, by
270
+ // which the circuit lowers the debt d'office.
271
+ ecrireSarif({
272
+ garde: GARDE,
273
+ racine,
274
+ constats: [
275
+ ...refus.map(r => ({ fichier: r.fichier, regle: r.regle, message: r.message })),
276
+ ...refus
277
+ .filter(r => r.aElaguer)
278
+ .map(r => ({
279
+ fichier: r.fichier,
280
+ regle: r.regle,
281
+ niveau: 'note',
282
+ genre: A_ELAGUER,
283
+ trouve: r.trouve,
284
+ message: `${r.trouve} constat(s) pour une dette plus haute : la dette s'abaisse.`,
285
+ })),
286
+ ],
287
+ });
288
+ }
289
+ for (const r of refus) process.stderr.write(`⛔ ${r.message}\n`);
290
+ for (const l of lignes) process.stderr.write(`${l}\n`);
291
+ process.stderr.write(
292
+ `ℹ️ ${GARDE} : ${constats.length} titre(s) nommant un ticket ou un « critère N » ; les tests Rust et Python sont hors du compte.\n`
293
+ );
294
+ process.exitCode = refus.length ? 1 : 0;
295
+ }
296
+
297
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) main();