@roomi-fields/grillhouse 0.30.0 → 0.32.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 (153) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +48 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/dist/temporal/circuit/client.d.ts +2 -2
  8. package/dist/temporal/circuit/client.js.map +1 -1
  9. package/dist/temporal/circuit/commande.js +4 -4
  10. package/dist/temporal/circuit/commande.js.map +1 -1
  11. package/dist/temporal/circuit/contrat.d.ts +3 -3
  12. package/dist/temporal/circuit/contrat.js +8 -2
  13. package/dist/temporal/circuit/contrat.js.map +1 -1
  14. package/dist/temporal/circuit/deroule.js +3 -3
  15. package/dist/temporal/circuit/deroule.js.map +1 -1
  16. package/dist/temporal/commande.js +5 -6
  17. package/dist/temporal/commande.js.map +1 -1
  18. package/dist/temporal/installation.d.ts +3 -6
  19. package/dist/temporal/installation.js +19 -38
  20. package/dist/temporal/installation.js.map +1 -1
  21. package/dist/temporal/tickets/activites.d.ts +1 -0
  22. package/dist/temporal/tickets/activites.js +5 -0
  23. package/dist/temporal/tickets/activites.js.map +1 -1
  24. package/dist/temporal/tickets/contrat.d.ts +10 -0
  25. package/dist/temporal/tickets/deroule.js +8 -1
  26. package/dist/temporal/tickets/deroule.js.map +1 -1
  27. package/docs/ARCHITECTURE.md +119 -27
  28. package/docs/CADRE.md +20 -0
  29. package/docs/INTERFACE.md +17 -4
  30. package/hooks/hooks.json +4 -0
  31. package/package.json +2 -2
  32. package/scripts/activites.mjs +155 -84
  33. package/scripts/aiguillage.mjs +35 -11
  34. package/scripts/attente-au-tour.mjs +99 -0
  35. package/scripts/avancement.mjs +27 -10
  36. package/scripts/base-des-workflows.mjs +57 -0
  37. package/scripts/bilan.mjs +101 -25
  38. package/scripts/cadre.mjs +5 -2
  39. package/scripts/circuit.mjs +173 -58
  40. package/scripts/composants-affectes.mjs +64 -21
  41. package/scripts/composition-des-langages.mjs +5 -3
  42. package/scripts/conformite.mjs +54 -19
  43. package/scripts/copies-finies.mjs +8 -1
  44. package/scripts/dependances-internes.mjs +9 -3
  45. package/scripts/dernier-vert.mjs +84 -23
  46. package/scripts/dette.mjs +32 -11
  47. package/scripts/donnees-cles.mjs +24 -8
  48. package/scripts/droits.mjs +40 -15
  49. package/scripts/effets.mjs +9 -0
  50. package/scripts/empreinte-d-etape.mjs +17 -0
  51. package/scripts/engendres.mjs +15 -5
  52. package/scripts/enveloppe/enveloppe.mjs +141 -48
  53. package/scripts/enveloppe/travail-de-la-copie.mjs +36 -12
  54. package/scripts/etapes.mjs +1 -1
  55. package/scripts/faits-du-circuit.mjs +1 -1
  56. package/scripts/flux-des-paquets.mjs +21 -7
  57. package/scripts/gardes-du-cadre.mjs +9 -3
  58. package/scripts/init.mjs +11 -4
  59. package/scripts/integration/file.mjs +84 -29
  60. package/scripts/integration/integrer.mjs +70 -24
  61. package/scripts/integration/rejeu.mjs +26 -9
  62. package/scripts/jointure.d.ts +10 -1
  63. package/scripts/journal-des-etats.d.mts +41 -0
  64. package/scripts/journal-des-etats.mjs +273 -0
  65. package/scripts/journal.mjs +119 -0
  66. package/scripts/langages/cargo/commandes.mjs +97 -18
  67. package/scripts/langages/cargo/composants.mjs +24 -8
  68. package/scripts/langages/cargo/index.mjs +7 -0
  69. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  70. package/scripts/langages/python/commandes.mjs +3 -1
  71. package/scripts/langages/python/index.mjs +6 -0
  72. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  73. package/scripts/langages/typescript/composants.mjs +9 -3
  74. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  75. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  76. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  77. package/scripts/langages/typescript/frontieres.mjs +112 -22
  78. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  79. package/scripts/langages/typescript/index.mjs +12 -3
  80. package/scripts/langages/typescript/interfaces-contre-code.mjs +109 -41
  81. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  82. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  83. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  84. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  85. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +3 -1
  86. package/scripts/langages/typescript/parcours.mjs +12 -4
  87. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  88. package/scripts/langages/typescript/resumes.mjs +9 -3
  89. package/scripts/langages/typescript/tailles-des-tests.mjs +58 -16
  90. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -1
  91. package/scripts/langages/typescript/tests.mjs +24 -8
  92. package/scripts/langages/typescript/titres-de-tests.mjs +35 -12
  93. package/scripts/langages/typescript/turbo-des-paquets.mjs +152 -51
  94. package/scripts/langages/typescript/verdict.mjs +3 -1
  95. package/scripts/langages/typescript/verifier.mjs +61 -14
  96. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  97. package/scripts/langages/typescript/vitest-config/base.mjs +10 -2
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  99. package/scripts/langages/typescript/vitest-config/delais.mjs +9 -3
  100. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +12 -4
  101. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +17 -6
  102. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  103. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -0
  104. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  105. package/scripts/langages.d.mts +20 -0
  106. package/scripts/lint-des-scripts.mjs +58 -0
  107. package/scripts/matiere-de-test.d.ts +11 -0
  108. package/scripts/mesure/base-de-passe.mjs +117 -25
  109. package/scripts/mesure/pression.mjs +9 -3
  110. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  111. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  112. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  113. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +48 -16
  114. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  115. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  116. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +6 -2
  117. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +7 -7
  118. package/scripts/nuit.sh +24 -0
  119. package/scripts/outil.mjs +3 -1
  120. package/scripts/outils-cles.mjs +18 -7
  121. package/scripts/paquet-npm.mjs +15 -5
  122. package/scripts/paquets.mjs +12 -4
  123. package/scripts/passe-de-la-machine.mjs +7 -2
  124. package/scripts/places-de-la-machine.mjs +72 -12
  125. package/scripts/preparation.mjs +15 -5
  126. package/scripts/registre.mjs +6 -2
  127. package/scripts/reprise.mjs +66 -0
  128. package/scripts/resultats.mjs +105 -37
  129. package/scripts/seances.mjs +22 -4
  130. package/scripts/services-du-noyau.mjs +1 -0
  131. package/scripts/sous-commandes.mjs +5 -1
  132. package/scripts/style-a-l-ecriture.mjs +48 -17
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +133 -10
  135. package/scripts/taches-du-graphe.mjs +33 -13
  136. package/scripts/ticket-du-circuit.mjs +40 -0
  137. package/scripts/transitions.mjs +159 -29
  138. package/scripts/verrou-de-fichier.mjs +6 -2
  139. package/scripts/verrou-de-machine.mjs +123 -39
  140. package/scripts/verrous/commande.mjs +50 -17
  141. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  142. package/scripts/verrous/verrou.mjs +42 -14
  143. package/skills/developpeur/SKILL.md +1 -1
  144. package/skills/explorateur/SKILL.md +8 -2
  145. package/skills/grill/SKILL.md +3 -57
  146. package/skills/grill/references/paquets.md +60 -0
  147. package/skills/mesure/SKILL.md +3 -0
  148. package/skills/pitmaster/SKILL.md +16 -27
  149. package/skills/questionneur/SKILL.md +1 -1
  150. package/skills/relecteur/SKILL.md +2 -2
  151. package/skills/testwriter/SKILL.md +19 -7
  152. package/skills/release/SKILL.md +0 -134
  153. package/skills/release/scripts/update-version.cjs +0 -92
@@ -68,7 +68,9 @@ import { langageDe } from './langages.mjs';
68
68
  */
69
69
  export function cheminsLus(dir) {
70
70
  const manifeste = path.join(dir, 'package.json');
71
- if (!existsSync(manifeste)) return [];
71
+ if (!existsSync(manifeste)) {
72
+ return [];
73
+ }
72
74
  const { grillhouse } = JSON.parse(readFileSync(manifeste, 'utf8'));
73
75
  const liste = v => (Array.isArray(v) ? v.filter(l => typeof l === 'string') : []);
74
76
  return [
@@ -83,8 +85,11 @@ function lesSections(description) {
83
85
  let dedans = false;
84
86
  for (const l of String(description ?? '').split('\n')) {
85
87
  const m = /^## (.+)$/.exec(l);
86
- if (m) dedans = /^(Architecture|Critères)\b/.test(m[1].trim());
87
- else if (dedans) out.push(l);
88
+ if (m) {
89
+ dedans = /^(Architecture|Critères)\b/.test(m[1].trim());
90
+ } else if (dedans) {
91
+ out.push(l);
92
+ }
88
93
  }
89
94
  return out.join('\n');
90
95
  }
@@ -112,7 +117,9 @@ function elementsNommes(texte) {
112
117
  const vus = new Set();
113
118
  for (const [, brut] of texte.matchAll(/`([^`\n]+)`/g)) {
114
119
  const m = /^([A-Za-z_$][\w$]*)((?:\.[A-Za-z_$][\w$]*|\([^)]*\))*)$/.exec(brut.trim());
115
- if (m) vus.add(m[1]);
120
+ if (m) {
121
+ vus.add(m[1]);
122
+ }
116
123
  }
117
124
  return [...vus];
118
125
  }
@@ -123,10 +130,16 @@ function cheminsEcrits(racine, texte) {
123
130
  const out = new Set();
124
131
  for (const [brut] of texte.matchAll(/[\w.@-]+(?:\/[\w.@-]+)*/g)) {
125
132
  const p = brut.replace(/\.+$/, '');
126
- if (!p.includes('/') && !/\.\w+$/.test(p)) continue;
133
+ if (!p.includes('/') && !/\.\w+$/.test(p)) {
134
+ continue;
135
+ }
127
136
  const net = path.normalize(p);
128
- if (net.startsWith('..') || path.isAbsolute(net)) continue;
129
- if (existsSync(path.join(racine, net))) out.add(net.split(path.sep).join('/'));
137
+ if (net.startsWith('..') || path.isAbsolute(net)) {
138
+ continue;
139
+ }
140
+ if (existsSync(path.join(racine, net))) {
141
+ out.add(net.split(path.sep).join('/'));
142
+ }
130
143
  }
131
144
  return [...out];
132
145
  }
@@ -144,9 +157,13 @@ function lecteursDesChemins(racine, tous, changes) {
144
157
  for (const brut of new Set(cheminsLus(c.dossier))) {
145
158
  const lu = brut.replace(/^\.\//, '').replace(/\/+$/, '');
146
159
  const atteints = changes.filter(ch => !recouvre(propre, ch) && recouvre(lu, ch)).sort();
147
- if (atteints.length) par.add(`lit ${lu} (${atteints.join(', ')})`);
160
+ if (atteints.length) {
161
+ par.add(`lit ${lu} (${atteints.join(', ')})`);
162
+ }
163
+ }
164
+ if (par.size) {
165
+ out.set(c, par);
148
166
  }
149
- if (par.size) out.set(c, par);
150
167
  }
151
168
  return out;
152
169
  }
@@ -184,18 +201,28 @@ export function releve(racine, description) {
184
201
  const trouves = new Set(ceuxNommes);
185
202
  for (const e of code.elements) {
186
203
  trouves.add(e.fournisseur);
187
- for (const l of e.lecteurs) trouves.add(l.composant);
204
+ for (const l of e.lecteurs) {
205
+ trouves.add(l.composant);
206
+ }
188
207
  }
189
208
  for (const e of code.types.elements) {
190
- for (const d of e.declarations) if (d.publie) trouves.add(d.composant);
191
- for (const c of e.lecteurs.keys()) trouves.add(c);
209
+ for (const d of e.declarations) {
210
+ if (d.publie) {
211
+ trouves.add(d.composant);
212
+ }
213
+ }
214
+ for (const c of e.lecteurs.keys()) {
215
+ trouves.add(c);
216
+ }
192
217
  }
193
218
  // By the paths read: the components whose tests declare they read a path the ticket changes.
194
219
  const parChemins = lecteursDesChemins(racine, tous, [
195
220
  ...cheminsEcrits(racine, texte),
196
221
  ...ceuxNommes.map(c => path.relative(racine, c.dossier).split(path.sep).join('/')),
197
222
  ]);
198
- for (const c of parChemins.keys()) trouves.add(c);
223
+ for (const c of parChemins.keys()) {
224
+ trouves.add(c);
225
+ }
199
226
  // By the architecture: the Rend of the CADRE.md of each component that publishes an element.
200
227
  const declarants = new Set([
201
228
  ...code.elements.map(e => e.fournisseur),
@@ -205,8 +232,12 @@ export function releve(racine, description) {
205
232
  for (const p of declarants) {
206
233
  for (const { regle, texte: ligne } of rendus(p)) {
207
234
  for (const c of nommes(racine, tous, ligne)) {
208
- if (c === p) continue;
209
- if (!architecture.has(c)) architecture.set(c, new Set());
235
+ if (c === p) {
236
+ continue;
237
+ }
238
+ if (!architecture.has(c)) {
239
+ architecture.set(c, new Set());
240
+ }
210
241
  architecture.get(c).add(`CADRE de ${nomAuTitre(racine, p)}, Rend ${regle}`);
211
242
  trouves.add(c);
212
243
  }
@@ -251,7 +282,9 @@ export function releve(racine, description) {
251
282
  // lines included.
252
283
  function rendus(c) {
253
284
  const f = path.join(c.dossier, 'docs', 'CADRE.md');
254
- if (!existsSync(f)) return [];
285
+ if (!existsSync(f)) {
286
+ return [];
287
+ }
255
288
  const texte = readFileSync(f, 'utf8');
256
289
  const out = [];
257
290
  let dedans = false;
@@ -261,11 +294,15 @@ function rendus(c) {
261
294
  dedans = /Rend\s*$/.test(h[1].trim());
262
295
  continue;
263
296
  }
264
- if (!dedans) continue;
297
+ if (!dedans) {
298
+ continue;
299
+ }
265
300
  if (/^[-*] /.test(l)) {
266
301
  const regle = /^[-*] \*\*(R\d+)\.?\*\*/.exec(l)?.[1] ?? `l.${i + 1}`;
267
302
  out.push({ regle, texte: l });
268
- } else if (/^\s+\S/.test(l) && out.length) out.at(-1).texte += ` ${l.trim()}`;
303
+ } else if (/^\s+\S/.test(l) && out.length) {
304
+ out.at(-1).texte += ` ${l.trim()}`;
305
+ }
269
306
  }
270
307
  return out;
271
308
  }
@@ -273,7 +310,9 @@ function rendus(c) {
273
310
  // The components of the survey <r> the title <titre> does not name (its components as written,
274
311
  // package names or paths, or `.`), in the survey's order.
275
312
  export function manquants(racine, r, titre) {
276
- if (titre.includes('.')) return [];
313
+ if (titre.includes('.')) {
314
+ return [];
315
+ }
277
316
  const tous = langageDe(racine).composants(racine);
278
317
  const couvre = c => {
279
318
  const rel = path.relative(racine, c.dossier).split(path.sep).join('/');
@@ -323,7 +362,9 @@ export function texteDuReleve(r) {
323
362
  const cle = `${ou} ; lu par ${lus || 'aucun autre'}.`;
324
363
  lignes.set(cle, [...(lignes.get(cle) ?? []), `\`${e.nom}\``]);
325
364
  }
326
- for (const [cle, noms] of lignes) out.push(` - ${noms.join(', ')} : ${cle}`);
365
+ for (const [cle, noms] of lignes) {
366
+ out.push(` - ${noms.join(', ')} : ${cle}`);
367
+ }
327
368
  }
328
369
  if (r.lit.length) {
329
370
  const lus = r.lit.map(l => `${l.composant} (${l.par.join(' ; ')})`).join(', ');
@@ -333,7 +374,9 @@ export function texteDuReleve(r) {
333
374
  const lus = r.architecture.map(l => `${l.composant} (${l.par.join(' ; ')})`).join(', ');
334
375
  out.push(`- Par l'architecture : ${lus}.`);
335
376
  }
336
- if (r.nommes.length) out.push(`- Nommés au ticket : ${r.nommes.join(', ')}.`);
377
+ if (r.nommes.length) {
378
+ out.push(`- Nommés au ticket : ${r.nommes.join(', ')}.`);
379
+ }
337
380
  if (r.sansFournisseur.length) {
338
381
  out.push(
339
382
  `- Sans interface qui les publie : ${r.sansFournisseur.map(n => `\`${n}\``).join(', ')}.`
@@ -196,6 +196,10 @@ export function composer(modules) {
196
196
  matieres: racine => modules.flatMap(m => m.matieres(racine)),
197
197
  joueDesTests: (racine, composant) =>
198
198
  moduleDuComposant(racine, composant)?.joueDesTests(racine, composant) ?? false,
199
+ empreintes(racine, noms) {
200
+ const parts = modules.map(m => m.empreintes(racine, noms));
201
+ return parts.some(p => p === null) ? null : Object.assign({}, ...parts);
202
+ },
199
203
  lecteurs(racine, o) {
200
204
  const composants = leurs(racine, o.composants);
201
205
  const nommes = leurs(racine, o.nommes);
@@ -261,9 +265,7 @@ export function composer(modules) {
261
265
  estUnTest: (chemin, racine) =>
262
266
  premiereReponse(modules, racine, chemin, m => m.estUnTest(chemin, racine)),
263
267
  horsDuJour: (chemin, racine) =>
264
- Boolean(
265
- premiereReponse(modules, racine, chemin, m => m.horsDuJour(chemin, racine))
266
- ),
268
+ Boolean(premiereReponse(modules, racine, chemin, m => m.horsDuJour(chemin, racine))),
267
269
  soeurDAvant: (chemin, racine) =>
268
270
  premiereReponse(modules, racine, chemin, m =>
269
271
  typeof m.soeurDAvant === 'function' ? m.soeurDAvant(chemin, racine) : null
@@ -42,9 +42,13 @@ import { isDeepStrictEqual } from 'node:util';
42
42
  const preparees = new WeakMap();
43
43
  // The entries of <exemples> under <dans>, prepared once.
44
44
  function entrees(exemples, dans) {
45
- if (!preparees.has(exemples)) preparees.set(exemples, new Map());
45
+ if (!preparees.has(exemples)) {
46
+ preparees.set(exemples, new Map());
47
+ }
46
48
  const parDossier = preparees.get(exemples);
47
- if (!parDossier.has(dans)) parDossier.set(dans, exemples.preparer(dans));
49
+ if (!parDossier.has(dans)) {
50
+ parDossier.set(dans, exemples.preparer(dans));
51
+ }
48
52
  return parDossier.get(dans);
49
53
  }
50
54
 
@@ -53,11 +57,16 @@ function etat(racine) {
53
57
  const out = new Map();
54
58
  const parcourir = d => {
55
59
  for (const n of readdirSync(d)) {
56
- if (n === '.git') continue;
60
+ if (n === '.git') {
61
+ continue;
62
+ }
57
63
  const f = path.join(d, n);
58
64
  const s = statSync(f);
59
- if (s.isDirectory()) parcourir(f);
60
- else out.set(f, s.mtimeMs);
65
+ if (s.isDirectory()) {
66
+ parcourir(f);
67
+ } else {
68
+ out.set(f, s.mtimeMs);
69
+ }
61
70
  }
62
71
  };
63
72
  parcourir(racine);
@@ -99,9 +108,13 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
99
108
  liste.flatMap(({ fichier, composant }) => {
100
109
  const c = langage.composantDe(e.racine, fichier);
101
110
  const rel = path.isAbsolute(fichier) ? path.relative(e.racine, fichier) : fichier;
102
- if (!c) return [`${rel} : hors de tout composant`];
111
+ if (!c) {
112
+ return [`${rel} : hors de tout composant`];
113
+ }
103
114
  const connu = langage.composants(e.racine).some(k => k.dossier === c.dossier);
104
- if (!connu) return [`${rel} : dans ${c.nom}, qui n'est pas un composant`];
115
+ if (!connu) {
116
+ return [`${rel} : dans ${c.nom}, qui n'est pas un composant`];
117
+ }
105
118
  return c.nom === composant ? [] : [`${rel} : dans ${c.nom}, attendu ${composant}`];
106
119
  }),
107
120
  lecteurs: ({ racine, noms }) => {
@@ -120,10 +133,14 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
120
133
  const avant = etat(e.racine);
121
134
  const c = langage.commandes(e.racine);
122
135
  const out = noms.flatMap(n => {
123
- if (!Object.hasOwn(c, n)) return [`${n} : absente`];
136
+ if (!Object.hasOwn(c, n)) {
137
+ return [`${n} : absente`];
138
+ }
124
139
  return decrite(c[n]) ? [] : [`${n} : pas une commande décrite`];
125
140
  });
126
- if (!isDeepStrictEqual(etat(e.racine), avant)) out.push('commandes écrit dans le dépôt');
141
+ if (!isDeepStrictEqual(etat(e.racine), avant)) {
142
+ out.push('commandes écrit dans le dépôt');
143
+ }
127
144
  return out;
128
145
  },
129
146
  verdict: dossier => {
@@ -146,20 +163,34 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
146
163
  estUnTest: chemins =>
147
164
  chemins.flatMap(chemin => {
148
165
  const c = langage.estUnTest(chemin, e.racine);
149
- if (c === null) return [];
166
+ if (c === null) {
167
+ return [];
168
+ }
150
169
  return [`${chemin} : ${['joue', 'test', 'matiere'].filter(k => c[k]).join(', ')}`];
151
170
  }),
152
171
  versionDeHead: entrees =>
153
172
  entrees.flatMap(x => {
154
173
  const { chemin, textes = {} } = typeof x === 'string' ? { chemin: x } : x;
155
- const s = typeof langage.soeurDAvant === 'function' ? langage.soeurDAvant(chemin, e.racine) : null;
156
- const arbre = typeof langage.arbreDAvant === 'function' && langage.arbreDAvant(chemin, e.racine);
174
+ const s =
175
+ typeof langage.soeurDAvant === 'function' ? langage.soeurDAvant(chemin, e.racine) : null;
176
+ const arbre =
177
+ typeof langage.arbreDAvant === 'function' && langage.arbreDAvant(chemin, e.racine);
157
178
  const noms = langage.testsDeHead(chemin, e.racine, f => textes[f] ?? null);
158
- if (s !== null && arbre) return [`${chemin} : une sœur et un arbre`];
159
- if (arbre) return [`${chemin} → un arbre`];
160
- if (s !== null && noms !== null) return [`${chemin} : une sœur et des noms lus`];
161
- if (noms !== null) return [`${chemin} : ${noms.join(', ') || 'aucun test'}`];
162
- if (s === null) return [];
179
+ if (s !== null && arbre) {
180
+ return [`${chemin} : une sœur et un arbre`];
181
+ }
182
+ if (arbre) {
183
+ return [`${chemin} → un arbre`];
184
+ }
185
+ if (s !== null && noms !== null) {
186
+ return [`${chemin} : une sœur et des noms lus`];
187
+ }
188
+ if (noms !== null) {
189
+ return [`${chemin} : ${noms.join(', ') || 'aucun test'}`];
190
+ }
191
+ if (s === null) {
192
+ return [];
193
+ }
163
194
  const aCote = s !== chemin && path.dirname(s) === path.dirname(chemin);
164
195
  return [aCote ? `${chemin} → ${s}` : `${chemin} → ${s} : pas à côté du fichier`];
165
196
  }),
@@ -178,7 +209,9 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
178
209
  },
179
210
  elementsDuLot: ({ racine, avant, apres }) => {
180
211
  const l = langage.elementsDuLot(racine, { avant, apres });
181
- if (l.etat !== 'fait') return [`impossible : ${l.raison}`];
212
+ if (l.etat !== 'fait') {
213
+ return [`impossible : ${l.raison}`];
214
+ }
182
215
  return [
183
216
  ...l.fichiers.map(f => `fichier ${f}`),
184
217
  ...l.horsDuService.map(f => `hors du service ${f}`),
@@ -215,7 +248,9 @@ export function echecs(langage, exemples, options) {
215
248
  return cas(langage, exemples, options).flatMap(c => {
216
249
  try {
217
250
  const v = c.valide();
218
- if (v.length) return [{ nom: c.nom, raison: `entrée valide : ${v.join(' ; ')}` }];
251
+ if (v.length) {
252
+ return [{ nom: c.nom, raison: `entrée valide : ${v.join(' ; ')}` }];
253
+ }
219
254
  const i = c.invalide();
220
255
  if (!isDeepStrictEqual(i, c.attendu)) {
221
256
  return [
@@ -82,6 +82,7 @@ import path from 'node:path';
82
82
  import { PILOTE } from './fusion-du-changelog.mjs';
83
83
  import { langageDe } from './langages.mjs';
84
84
  import { balayerLesTickets } from './mesure/base-de-passe.mjs';
85
+ import { nettoyerLeJournal } from './journal-des-etats.mjs';
85
86
 
86
87
  const RETIRER = path.join(import.meta.dirname, 'retirer-copie.sh');
87
88
  const PRINCIPALE = 'main';
@@ -498,5 +499,11 @@ export function retirerLesCopiesDuDepot(racine, finies = [], vivants = null) {
498
499
  ignorer: ignoresDuLangage(racine),
499
500
  });
500
501
  const retires = balayerLesTickets(() => tickets(racine, 'closed'));
501
- return [...lignes, ...retires.map(t => `✓ dossier temporaire du ticket ${t} retiré.`)];
502
+ // The journal of states, bounded as the other working files (scripts/journal-des-etats.mjs).
503
+ const segments = nettoyerLeJournal(racine).retires;
504
+ return [
505
+ ...lignes,
506
+ ...retires.map(t => `✓ dossier temporaire du ticket ${t} retiré.`),
507
+ ...segments.map(s => `✓ segment ${s} du journal des états retiré.`),
508
+ ];
502
509
  }
@@ -47,7 +47,9 @@ function nomA(langageNom, dossier) {
47
47
  for (const l of [langageNom, ...sansPackageJson()]) {
48
48
  const texte = lire(path.join(dossier, langage(l).manifeste));
49
49
  const nom = texte === null ? null : nomDuManifeste(l, texte);
50
- if (nom !== null) return nom;
50
+ if (nom !== null) {
51
+ return nom;
52
+ }
51
53
  }
52
54
  return null;
53
55
  }
@@ -64,7 +66,9 @@ export function constats(racine) {
64
66
  for (const p of sans) {
65
67
  const f = `${p.chemin}/package.json`;
66
68
  const texte = lire(path.join(racine, f));
67
- if (texte === null) continue;
69
+ if (texte === null) {
70
+ continue;
71
+ }
68
72
  let pkg;
69
73
  try {
70
74
  pkg = JSON.parse(texte);
@@ -80,7 +84,9 @@ export function constats(racine) {
80
84
  );
81
85
  const manquantes = [...duManifeste].filter(n => !duPackage.has(n)).sort();
82
86
  const enTrop = [...duPackage].filter(n => !duManifeste.has(n)).sort();
83
- if (!manquantes.length && !enTrop.length) continue;
87
+ if (!manquantes.length && !enTrop.length) {
88
+ continue;
89
+ }
84
90
  const dits = [
85
91
  ...(manquantes.length
86
92
  ? [
@@ -88,7 +88,9 @@ function brancheDeMain(racine) {
88
88
  // Whether a submodule of the repository at <racine> differs from the commit its parent records.
89
89
  function sousModuleModifie(racine) {
90
90
  const r = git(racine, ['status', '--porcelain=v2', '-z', '--ignore-submodules=none']);
91
- if (r.status !== 0) return true;
91
+ if (r.status !== 0) {
92
+ return true;
93
+ }
92
94
  // An entry of a changed path: `1 <XY> <sub> …` (or `2` for a rename), <sub> `S<c><m><u>` for a
93
95
  // submodule whose commit, tracked files or untracked files changed, `N...` for any other path.
94
96
  return r.stdout.split('\0').some(e => /^[12] \S+ S/.test(e));
@@ -99,21 +101,34 @@ function sousModuleModifie(racine) {
99
101
  // detached) and main (brancheDeMain); `{ raison }` when no last green can count.
100
102
  function etatDuDepot(racine) {
101
103
  const haut = sortie(racine, ['rev-parse', '--show-toplevel']);
102
- if (!haut) return { raison: 'hors de git' };
104
+ if (!haut) {
105
+ return { raison: 'hors de git' };
106
+ }
103
107
  const top = realpathSync(haut);
104
108
  const commit = sortie(top, ['rev-parse', '--verify', '-q', 'HEAD^{commit}']);
105
- if (!commit) return { raison: 'aucun commit' };
106
- if (sousModuleModifie(top)) return { raison: 'un sous-module diffère de son commit' };
109
+ if (!commit) {
110
+ return { raison: 'aucun commit' };
111
+ }
112
+ if (sousModuleModifie(top)) {
113
+ return { raison: 'un sous-module diffère de son commit' };
114
+ }
107
115
  const dir = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-vert-'));
108
116
  try {
109
117
  const index = path.join(dir, 'index');
110
118
  const reel = sortie(top, ['rev-parse', '--path-format=absolute', '--git-path', 'index']);
111
119
  const env = { ...process.env, GIT_INDEX_FILE: index };
112
- if (reel && existsSync(reel)) copyFileSync(reel, index);
113
- else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) return { raison: 'git échoue' };
114
- if (git(top, ['add', '-A'], env).status !== 0) return { raison: 'git échoue' };
120
+ if (reel && existsSync(reel)) {
121
+ copyFileSync(reel, index);
122
+ } else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) {
123
+ return { raison: 'git échoue' };
124
+ }
125
+ if (git(top, ['add', '-A'], env).status !== 0) {
126
+ return { raison: 'git échoue' };
127
+ }
115
128
  const arbre = sortie(top, ['write-tree'], env);
116
- if (!arbre) return { raison: 'git échoue' };
129
+ if (!arbre) {
130
+ return { raison: 'git échoue' };
131
+ }
117
132
  const branche = sortie(top, ['symbolic-ref', '--short', '-q', 'HEAD']);
118
133
  return { racine: top, commit, arbre, branche, main: brancheDeMain(top) };
119
134
  } finally {
@@ -129,7 +144,9 @@ function lireLeVert(etat) {
129
144
  let vert = { raison: 'aucun vert connu' };
130
145
  for (const branche of branches) {
131
146
  vert = lireLeVertDe(etat, branche);
132
- if (!vert.raison) return vert;
147
+ if (!vert.raison) {
148
+ return vert;
149
+ }
133
150
  }
134
151
  return vert;
135
152
  }
@@ -156,11 +173,32 @@ function lireLeVertDe(etat, branche) {
156
173
  return { commit: v.commit, arbre: v.arbre, branche };
157
174
  }
158
175
 
176
+ // The base <base> given to a pass (`verifier --base <commit>`), when it counts for a pass in the
177
+ // state <etat>: `{ commit, arbre, branche: null }`, the tree of the commit; `{ raison }` when it
178
+ // has no value, is not a commit id, is not in the repository (the zeros of a first push, a
179
+ // rewritten history) or is not an ancestor of HEAD.
180
+ function lireLaBase(etat, base) {
181
+ if (!SHA.test(base)) {
182
+ return { raison: base ? 'la base n’est pas un commit' : 'la base est sans valeur' };
183
+ }
184
+ const arbre = sortie(etat.racine, ['rev-parse', '--verify', '-q', `${base}^{tree}`]);
185
+ const commit = sortie(etat.racine, ['rev-parse', '--verify', '-q', `${base}^{commit}`]);
186
+ if (!arbre || !commit) {
187
+ return { raison: 'la base n’est pas dans le dépôt' };
188
+ }
189
+ if (git(etat.racine, ['merge-base', '--is-ancestor', commit, etat.commit]).status !== 0) {
190
+ return { raison: 'la base n’est pas un ancêtre de HEAD' };
191
+ }
192
+ return { commit, arbre, branche: null };
193
+ }
194
+
159
195
  // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached.
160
196
  export function garderLeVert(etat) {
161
197
  const branche = etat.branche ?? etat.main;
162
198
  const f = branche ? fichierDuVert(etat.racine, branche) : null;
163
- if (!f) return;
199
+ if (!f) {
200
+ return;
201
+ }
164
202
  mkdirSync(path.dirname(f), { recursive: true });
165
203
  writeFileSync(f, `${JSON.stringify({ commit: etat.commit, arbre: etat.arbre }, null, 2)}\n`);
166
204
  }
@@ -169,15 +207,21 @@ export function garderLeVert(etat) {
169
207
  // `{ fichiers, supprimes, sousModules }`, each path from its top; null when git fails.
170
208
  function difference(racine, avant, apres) {
171
209
  const r = git(racine, ['diff', '--raw', '--no-renames', '-z', avant, apres]);
172
- if (r.status !== 0) return null;
210
+ if (r.status !== 0) {
211
+ return null;
212
+ }
173
213
  const champs = r.stdout.split('\0');
174
214
  const out = { fichiers: [], supprimes: [], sousModules: [] };
175
215
  for (let i = 0; i + 1 < champs.length; i += 2) {
176
216
  const [modeAvant, modeApres, , , statut] = champs[i].replace(/^:/, '').split(' ');
177
217
  const f = champs[i + 1];
178
- if (modeAvant === '160000' || modeApres === '160000') out.sousModules.push(f);
179
- else if (statut === 'D') out.supprimes.push(f);
180
- else out.fichiers.push(f);
218
+ if (modeAvant === '160000' || modeApres === '160000') {
219
+ out.sousModules.push(f);
220
+ } else if (statut === 'D') {
221
+ out.supprimes.push(f);
222
+ } else {
223
+ out.fichiers.push(f);
224
+ }
181
225
  }
182
226
  return out;
183
227
  }
@@ -203,7 +247,7 @@ function supprimesDuCommit(racine, commit, arbre) {
203
247
  // function that removes the file of the changes. <tout> asks for the complete pass; the file lies
204
248
  // in <dans>, the base of the pass (scripts/mesure/base-de-passe.mjs), which a killed pass
205
249
  // leaves to the next one to sweep.
206
- export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
250
+ export function mesure(racine, { tout = false, base, dans = os.tmpdir() } = {}) {
207
251
  const etat = etatDuDepot(racine);
208
252
  const complete = raison => ({
209
253
  etat: etat.raison ? null : etat,
@@ -211,18 +255,33 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
211
255
  ligne: `↳ passe complète : ${raison}.`,
212
256
  retirer: () => {},
213
257
  });
214
- if (etat.raison) return complete(etat.raison);
215
- if (tout) return complete('demandée');
216
- const vert = lireLeVert(etat);
217
- if (vert.raison) return complete(vert.raison);
258
+ if (etat.raison) {
259
+ return complete(etat.raison);
260
+ }
261
+ if (tout) {
262
+ return complete('demandée');
263
+ }
264
+ // A base given takes precedence over the last green: the pass keeps no green of its own.
265
+ const donnee = base === undefined ? null : lireLaBase(etat, base);
266
+ if (donnee?.raison) {
267
+ return complete(donnee.raison);
268
+ }
269
+ const vert = donnee ?? lireLeVert(etat);
270
+ if (vert.raison) {
271
+ return complete(vert.raison);
272
+ }
218
273
  const ch = difference(etat.racine, vert.arbre, etat.arbre);
219
- if (!ch) return complete('git échoue');
274
+ if (!ch) {
275
+ return complete('git échoue');
276
+ }
220
277
  if (ch.sousModules.length) {
221
278
  return { ...complete(`un sous-module a changé (${ch.sousModules[0]})`), etat: null };
222
279
  }
223
280
  if (vert.branche !== etat.branche) {
224
281
  const suivis = supprimesDuCommit(etat.racine, vert.commit, etat.arbre);
225
- if (!suivis) return complete('git échoue');
282
+ if (!suivis) {
283
+ return complete('git échoue');
284
+ }
226
285
  ch.supprimes = ch.supprimes.filter(f => suivis.has(f));
227
286
  }
228
287
  const dir = mkdtempSync(path.join(dans, 'grillhouse-changements-'));
@@ -233,9 +292,11 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
233
292
  );
234
293
  const n = ch.fichiers.length + ch.supprimes.length;
235
294
  return {
236
- etat,
295
+ etat: donnee ? null : etat,
237
296
  env: { [CHANGEMENTS]: fichier },
238
- ligne: `↳ depuis le dernier vert de ${vert.branche} (${vert.commit.slice(0, 12)}, arbre ${vert.arbre.slice(0, 12)}) : ${n} fichier(s) changé(s) ; chaque paquet rejoué joue les tests que ses changements atteignent.`,
297
+ ligne: donnee
298
+ ? `↳ depuis la base ${vert.commit.slice(0, 7)} : ${n} fichier(s) changé(s) ; chaque paquet rejoué joue les tests que ses changements atteignent.`
299
+ : `↳ depuis le dernier vert de ${vert.branche} (${vert.commit.slice(0, 12)}, arbre ${vert.arbre.slice(0, 12)}) : ${n} fichier(s) changé(s) ; chaque paquet rejoué joue les tests que ses changements atteignent.`,
239
300
  retirer: () => rmSync(dir, { recursive: true, force: true }),
240
301
  };
241
302
  }
package/scripts/dette.mjs CHANGED
@@ -42,7 +42,9 @@ const inscriptible = c => Boolean(c.fichier && c.regle);
42
42
  function compter(constats) {
43
43
  const out = new Map();
44
44
  for (const c of constats.filter(inscriptible)) {
45
- if (!out.has(c.fichier)) out.set(c.fichier, new Map());
45
+ if (!out.has(c.fichier)) {
46
+ out.set(c.fichier, new Map());
47
+ }
46
48
  const parRegle = out.get(c.fichier);
47
49
  parRegle.set(c.regle, (parRegle.get(c.regle) ?? 0) + 1);
48
50
  }
@@ -65,7 +67,9 @@ function section(comptes) {
65
67
  // The debt written at <racine>: {} without the file. Throws, naming the file, when it is not JSON.
66
68
  export function lire(racine) {
67
69
  const f = path.join(racine, FICHIER);
68
- if (!existsSync(f)) return {};
70
+ if (!existsSync(f)) {
71
+ return {};
72
+ }
69
73
  try {
70
74
  return JSON.parse(readFileSync(f, 'utf8'));
71
75
  } catch (e) {
@@ -91,8 +95,12 @@ export function elaguer(dette, garde, constats) {
91
95
  for (const [fichier, regles] of Object.entries(ancienne)) {
92
96
  for (const [regle, { count }] of Object.entries(regles)) {
93
97
  const n = Math.min(count, comptes.get(fichier)?.get(regle) ?? 0);
94
- if (n === 0) continue;
95
- if (!garde2.has(fichier)) garde2.set(fichier, new Map());
98
+ if (n === 0) {
99
+ continue;
100
+ }
101
+ if (!garde2.has(fichier)) {
102
+ garde2.set(fichier, new Map());
103
+ }
96
104
  garde2.get(fichier).set(regle, n);
97
105
  }
98
106
  }
@@ -114,14 +122,18 @@ export function juger(dette, garde, constats) {
114
122
  for (const [fichier, regles] of comptes) {
115
123
  for (const [regle, trouve] of regles) {
116
124
  const inscrit = permis(fichier, regle);
117
- if (inscrit > 0 && trouve > inscrit) depasses.push({ fichier, regle, trouve, inscrit });
125
+ if (inscrit > 0 && trouve > inscrit) {
126
+ depasses.push({ fichier, regle, trouve, inscrit });
127
+ }
118
128
  }
119
129
  }
120
130
  const corriges = [];
121
131
  for (const [fichier, regles] of Object.entries(inscrite)) {
122
132
  for (const [regle, { count }] of Object.entries(regles)) {
123
133
  const trouve = comptes.get(fichier)?.get(regle) ?? 0;
124
- if (trouve < count) corriges.push({ fichier, regle, trouve, inscrit: count });
134
+ if (trouve < count) {
135
+ corriges.push({ fichier, regle, trouve, inscrit: count });
136
+ }
125
137
  }
126
138
  }
127
139
  return { refus, depasses, corriges, tus: constats.length - refus.length };
@@ -170,17 +182,25 @@ function abaisser(racine, notes) {
170
182
  for (const { garde, fichier, regle, trouve } of notes) {
171
183
  const parRegle = dette[garde]?.[fichier];
172
184
  const cle = parRegle?.[regle];
173
- if (!cle || !Number.isInteger(trouve) || trouve >= cle.count) continue;
185
+ if (!cle || !Number.isInteger(trouve) || trouve >= cle.count) {
186
+ continue;
187
+ }
174
188
  if (trouve > 0) {
175
189
  cle.count = trouve;
176
190
  continue;
177
191
  }
178
192
  delete parRegle[regle];
179
- if (!Object.keys(parRegle).length) delete dette[garde][fichier];
180
- if (!Object.keys(dette[garde]).length) delete dette[garde];
193
+ if (!Object.keys(parRegle).length) {
194
+ delete dette[garde][fichier];
195
+ }
196
+ if (!Object.keys(dette[garde]).length) {
197
+ delete dette[garde];
198
+ }
181
199
  }
182
200
  const change = JSON.stringify(dette) !== JSON.stringify(avant);
183
- if (change) ecrire(racine, dette);
201
+ if (change) {
202
+ ecrire(racine, dette);
203
+ }
184
204
  return change;
185
205
  }
186
206
 
@@ -217,8 +237,9 @@ function juge(racine, garde, constats, mode) {
217
237
  `⚠️ ${garde} : ${c.fichier} · ${c.regle} — ${c.trouve} constat(s) pour ${c.inscrit} inscrit(s) dans ${FICHIER} : npm run grillhouse:dette:elaguer retire ce qui est corrigé.`
218
238
  );
219
239
  }
220
- if (tus > 0)
240
+ if (tus > 0) {
221
241
  lignes.push(`ℹ️ ${garde} : ${tus} constat(s) connu(s), inscrit(s) dans ${FICHIER}.`);
242
+ }
222
243
  return { refus, lignes, corriges };
223
244
  }
224
245