@roomi-fields/grillhouse 0.30.0 → 0.31.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 (129) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +30 -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 +0 -4
  19. package/dist/temporal/installation.js +12 -34
  20. package/dist/temporal/installation.js.map +1 -1
  21. package/docs/ARCHITECTURE.md +49 -19
  22. package/docs/CADRE.md +10 -0
  23. package/docs/INTERFACE.md +8 -3
  24. package/package.json +2 -2
  25. package/scripts/activites.mjs +150 -77
  26. package/scripts/aiguillage.mjs +33 -11
  27. package/scripts/avancement.mjs +27 -10
  28. package/scripts/bilan.mjs +101 -25
  29. package/scripts/cadre.mjs +5 -2
  30. package/scripts/circuit.mjs +153 -57
  31. package/scripts/composants-affectes.mjs +64 -21
  32. package/scripts/composition-des-langages.mjs +5 -3
  33. package/scripts/conformite.mjs +54 -19
  34. package/scripts/dependances-internes.mjs +9 -3
  35. package/scripts/dernier-vert.mjs +54 -19
  36. package/scripts/dette.mjs +32 -11
  37. package/scripts/donnees-cles.mjs +24 -8
  38. package/scripts/droits.mjs +40 -15
  39. package/scripts/empreinte-d-etape.mjs +17 -0
  40. package/scripts/engendres.mjs +15 -5
  41. package/scripts/enveloppe/enveloppe.mjs +141 -48
  42. package/scripts/enveloppe/travail-de-la-copie.mjs +36 -12
  43. package/scripts/faits-du-circuit.mjs +1 -1
  44. package/scripts/flux-des-paquets.mjs +21 -7
  45. package/scripts/gardes-du-cadre.mjs +9 -3
  46. package/scripts/init.mjs +11 -4
  47. package/scripts/integration/file.mjs +84 -29
  48. package/scripts/integration/integrer.mjs +70 -24
  49. package/scripts/integration/rejeu.mjs +26 -9
  50. package/scripts/jointure.d.ts +6 -1
  51. package/scripts/langages/cargo/commandes.mjs +97 -18
  52. package/scripts/langages/cargo/composants.mjs +24 -8
  53. package/scripts/langages/cargo/index.mjs +4 -0
  54. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  55. package/scripts/langages/python/commandes.mjs +3 -1
  56. package/scripts/langages/python/index.mjs +4 -0
  57. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  58. package/scripts/langages/typescript/composants.mjs +9 -3
  59. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  60. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  61. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  62. package/scripts/langages/typescript/frontieres.mjs +66 -22
  63. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  64. package/scripts/langages/typescript/index.mjs +10 -3
  65. package/scripts/langages/typescript/interfaces-contre-code.mjs +109 -41
  66. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  67. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  68. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  69. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  70. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +3 -1
  71. package/scripts/langages/typescript/parcours.mjs +12 -4
  72. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  73. package/scripts/langages/typescript/resumes.mjs +9 -3
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +58 -16
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -1
  76. package/scripts/langages/typescript/tests.mjs +24 -8
  77. package/scripts/langages/typescript/titres-de-tests.mjs +35 -12
  78. package/scripts/langages/typescript/turbo-des-paquets.mjs +152 -51
  79. package/scripts/langages/typescript/verdict.mjs +3 -1
  80. package/scripts/langages/typescript/verifier.mjs +28 -10
  81. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  82. package/scripts/langages/typescript/vitest-config/base.mjs +7 -2
  83. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  84. package/scripts/langages/typescript/vitest-config/delais.mjs +9 -3
  85. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +12 -4
  86. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +17 -6
  87. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  88. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -0
  89. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  90. package/scripts/lint-des-scripts.mjs +58 -0
  91. package/scripts/mesure/base-de-passe.mjs +117 -25
  92. package/scripts/mesure/pression.mjs +9 -3
  93. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  94. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  95. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  96. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +48 -16
  97. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  98. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  99. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +6 -2
  100. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +7 -7
  101. package/scripts/nuit.sh +15 -0
  102. package/scripts/outil.mjs +3 -1
  103. package/scripts/outils-cles.mjs +18 -7
  104. package/scripts/paquet-npm.mjs +15 -5
  105. package/scripts/paquets.mjs +12 -4
  106. package/scripts/passe-de-la-machine.mjs +7 -2
  107. package/scripts/places-de-la-machine.mjs +66 -12
  108. package/scripts/preparation.mjs +15 -5
  109. package/scripts/registre.mjs +6 -2
  110. package/scripts/reprise.mjs +66 -0
  111. package/scripts/resultats.mjs +105 -37
  112. package/scripts/seances.mjs +22 -4
  113. package/scripts/services-du-noyau.mjs +1 -0
  114. package/scripts/sous-commandes.mjs +3 -1
  115. package/scripts/style-a-l-ecriture.mjs +48 -17
  116. package/scripts/tableau.mjs +34 -9
  117. package/scripts/taches-du-graphe.mjs +33 -13
  118. package/scripts/ticket-du-circuit.mjs +10 -0
  119. package/scripts/transitions.mjs +141 -24
  120. package/scripts/verrou-de-fichier.mjs +6 -2
  121. package/scripts/verrou-de-machine.mjs +123 -39
  122. package/scripts/verrous/commande.mjs +50 -17
  123. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  124. package/scripts/verrous/verrou.mjs +42 -14
  125. package/skills/explorateur/SKILL.md +7 -1
  126. package/skills/grill/SKILL.md +1 -1
  127. package/skills/mesure/SKILL.md +3 -0
  128. package/skills/relecteur/SKILL.md +1 -1
  129. package/skills/testwriter/SKILL.md +12 -6
@@ -89,7 +89,9 @@ export function lireOutils(
89
89
  { maison = os.homedir(), existe = existsSync, reel = realpath, montages = [] } = {}
90
90
  ) {
91
91
  const o = pkg?.grillhouse?.outils;
92
- if (o === undefined || o === null) return { outils: {}, fautes: [] };
92
+ if (o === undefined || o === null) {
93
+ return { outils: {}, fautes: [] };
94
+ }
93
95
  if (typeof o !== 'object' || Array.isArray(o)) {
94
96
  return {
95
97
  outils: {},
@@ -117,10 +119,15 @@ export function lireOutils(
117
119
  const cible = !refus && existe(chemin) ? reel(chemin) : chemin;
118
120
  const refusDeLaCible =
119
121
  cible !== chemin ? refusDuChemin(cle, cible, path.resolve(maison), montages) : null;
120
- if (refus) fautes.push(refus);
121
- else if (refusDeLaCible) fautes.push(`${refusDeLaCible} (la cible du lien ${chemin})`);
122
- else if (existe(chemin)) outils[nom] = chemin;
123
- else fautes.push(`la clé ${cle} nomme ${chemin}, qui n'existe pas.`);
122
+ if (refus) {
123
+ fautes.push(refus);
124
+ } else if (refusDeLaCible) {
125
+ fautes.push(`${refusDeLaCible} (la cible du lien ${chemin})`);
126
+ } else if (existe(chemin)) {
127
+ outils[nom] = chemin;
128
+ } else {
129
+ fautes.push(`la clé ${cle} nomme ${chemin}, qui n'existe pas.`);
130
+ }
124
131
  }
125
132
  }
126
133
  return { outils: fautes.length ? {} : outils, fautes };
@@ -151,12 +158,16 @@ export function arbrePrincipal(dir) {
151
158
  export function outilsDe(dir, { montages = [] } = {}) {
152
159
  const racine = arbrePrincipal(dir);
153
160
  const f = path.join(racine, 'package.json');
154
- if (!existsSync(f)) return {};
161
+ if (!existsSync(f)) {
162
+ return {};
163
+ }
155
164
  const temporaires = [process.env.CLAUDE_CODE_TMPDIR, os.tmpdir(), '/tmp'].filter(Boolean);
156
165
  const { outils, fautes } = lireOutils(JSON.parse(readFileSync(f, 'utf8')), {
157
166
  montages: [racine, ...temporaires, ...montages],
158
167
  });
159
- if (fautes.length) throw new Error(fautes.join('\n'));
168
+ if (fautes.length) {
169
+ throw new Error(fautes.join('\n'));
170
+ }
160
171
  return outils;
161
172
  }
162
173
 
@@ -47,11 +47,15 @@ export const nomDuManifeste = (langageNom, texte) => langage(langageNom).nomDuMa
47
47
  function avecManifeste(dossier, manifeste, langageNom, exclus) {
48
48
  const out = [];
49
49
  for (const e of readdirSync(dossier, { withFileTypes: true })) {
50
- if (!e.isDirectory() || e.name.startsWith('.') || exclus.has(e.name)) continue;
50
+ if (!e.isDirectory() || e.name.startsWith('.') || exclus.has(e.name)) {
51
+ continue;
52
+ }
51
53
  const d = path.join(dossier, e.name);
52
54
  const f = path.join(d, manifeste);
53
55
  const paquet = existsSync(f) ? nomDuManifeste(langageNom, readFileSync(f, 'utf8')) : null;
54
- if (paquet !== null) out.push({ dossier: d, nom: e.name, paquet });
56
+ if (paquet !== null) {
57
+ out.push({ dossier: d, nom: e.name, paquet });
58
+ }
55
59
  out.push(...avecManifeste(d, manifeste, langageNom, exclus));
56
60
  }
57
61
  return out;
@@ -79,11 +83,17 @@ export function paquetsSansPackageJson(racine) {
79
83
  const trouves = new Set();
80
84
  for (const t of tableauxDesComposants(racine)) {
81
85
  const colonne = colonneDesNoms(t.lignes, candidats, racine, t.colonne);
82
- if (colonne < 0) continue;
86
+ if (colonne < 0) {
87
+ continue;
88
+ }
83
89
  for (const l of t.lignes) {
84
- if (langageDeLaCellule(l.cellules[t.colonne]) !== langageNom) continue;
90
+ if (langageDeLaCellule(l.cellules[t.colonne]) !== langageNom) {
91
+ continue;
92
+ }
85
93
  for (const c of candidats) {
86
- if (nomme(nomsDe(l.cellules[colonne]), c, racine)) trouves.add(c);
94
+ if (nomme(nomsDe(l.cellules[colonne]), c, racine)) {
95
+ trouves.add(c);
96
+ }
87
97
  }
88
98
  }
89
99
  }
@@ -32,11 +32,15 @@ const HORS_CADRE = 'docs/agents/hors-cadre.txt';
32
32
  // The names listed in <racine>'s `docs/agents/hors-cadre.txt`: a Set, empty without the file.
33
33
  export function horsCadre(racine) {
34
34
  const liste = path.join(racine, HORS_CADRE);
35
- if (!existsSync(liste)) return new Set();
35
+ if (!existsSync(liste)) {
36
+ return new Set();
37
+ }
36
38
  const noms = new Set();
37
39
  for (const ligne of readFileSync(liste, 'utf8').split('\n')) {
38
40
  const mot = ligne.trim().split(/\s+/)[0];
39
- if (mot && !mot.startsWith('#')) noms.add(mot);
41
+ if (mot && !mot.startsWith('#')) {
42
+ noms.add(mot);
43
+ }
40
44
  }
41
45
  return noms;
42
46
  }
@@ -118,8 +122,12 @@ export function paquets(racine) {
118
122
  for (const motif of motifs) {
119
123
  for (const f of globSync(`${motif}/package.json`, { cwd: racine })) {
120
124
  const dossier = path.dirname(f);
121
- if (f.split(path.sep).includes('node_modules')) continue;
122
- if (nies.some(n => path.matchesGlob(dossier, n))) continue;
125
+ if (f.split(path.sep).includes('node_modules')) {
126
+ continue;
127
+ }
128
+ if (nies.some(n => path.matchesGlob(dossier, n))) {
129
+ continue;
130
+ }
123
131
  dossiers.add(dossier);
124
132
  }
125
133
  }
@@ -28,7 +28,9 @@ export function passeLourde({ args }) {
28
28
  */
29
29
  export function lancementDeLaPasse({ lourde, cmd, args, env }) {
30
30
  const { [VARIABLE_TRAVAILLEURS]: _herite, ...sansTravailleurs } = env;
31
- if (lourde) return { cmd, args, env: sansTravailleurs };
31
+ if (lourde) {
32
+ return { cmd, args, env: sansTravailleurs };
33
+ }
32
34
  const [commande, ...arguments_] = sousNiceEtIonice([cmd, ...args]);
33
35
  return {
34
36
  cmd: commande,
@@ -48,7 +50,10 @@ export function lancementDeLaPasse({ lourde, cmd, args, env }) {
48
50
  * borneMs?: number, rappelMs?: number } & Record<string, unknown>} options
49
51
  * @returns {T}
50
52
  */
51
- export function avecLaPasse(mesure, { lourde, env = process.env, racine, ticket, sorte, ...options }) {
53
+ export function avecLaPasse(
54
+ mesure,
55
+ { lourde, env = process.env, racine, ticket, sorte, ...options }
56
+ ) {
52
57
  if (lourde) {
53
58
  const { dire, borneMs, rappelMs, rang } = options;
54
59
  return avecLaMachineEtUnePlace(mesure, {
@@ -47,6 +47,8 @@ export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
47
47
  export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
48
48
  /** The mark of a place held, which the children of its holder inherit. */
49
49
  export const VARIABLE_TENUE = 'GRILLHOUSE_PLACE_TENUE';
50
+ /** The measure of the machine a trial fixes, in JSON `{ coeurs, charge, memoireLibre }`. */
51
+ export const VARIABLE_MESURE_D_ESSAI = 'GRILLHOUSE_MESURE_D_ESSAI';
50
52
  // The server of the places of a trial machine.
51
53
  const VARIABLE_ESSAI = 'GRILLHOUSE_PLACES_D_ESSAI';
52
54
 
@@ -66,11 +68,14 @@ const PONT = path.join(import.meta.dirname, 'places-du-serveur.mjs');
66
68
  */
67
69
  export function plafondDe(env = process.env) {
68
70
  const v = env[VARIABLE_PLACES];
69
- if (v === undefined || v === '') return PLAFOND_PAR_DEFAUT;
70
- if (!/^[1-9]\d*$/.test(v))
71
+ if (v === undefined || v === '') {
72
+ return PLAFOND_PAR_DEFAUT;
73
+ }
74
+ if (!/^[1-9]\d*$/.test(v)) {
71
75
  throw new Error(
72
76
  `${VARIABLE_PLACES} vaut « ${v} » : un entier positif est attendu (3 par défaut).`
73
77
  );
78
+ }
74
79
  return Number(v);
75
80
  }
76
81
 
@@ -82,11 +87,14 @@ export function plafondDe(env = process.env) {
82
87
  */
83
88
  export function espacementDe(env = process.env) {
84
89
  const v = env[VARIABLE_ESPACEMENT];
85
- if (v === undefined || v === '') return ESPACEMENT_MS;
86
- if (!/^\d+$/.test(v))
90
+ if (v === undefined || v === '') {
91
+ return ESPACEMENT_MS;
92
+ }
93
+ if (!/^\d+$/.test(v)) {
87
94
  throw new Error(
88
95
  `${VARIABLE_ESPACEMENT} vaut « ${v} » : un nombre de millisecondes est attendu.`
89
96
  );
97
+ }
90
98
  return Number(v);
91
99
  }
92
100
 
@@ -113,9 +121,12 @@ export function travailleursDe({
113
121
  */
114
122
  export function travailleursDeLaSeance(env = process.env) {
115
123
  const v = env[VARIABLE_TRAVAILLEURS];
116
- if (v === undefined || v === '') return null;
117
- if (!/^[1-9]\d*$/.test(v))
124
+ if (v === undefined || v === '') {
125
+ return null;
126
+ }
127
+ if (!/^[1-9]\d*$/.test(v)) {
118
128
  throw new Error(`${VARIABLE_TRAVAILLEURS} vaut « ${v} » : un entier positif est attendu.`);
129
+ }
119
130
  return Number(v);
120
131
  }
121
132
 
@@ -127,7 +138,9 @@ export function travailleursDeLaSeance(env = process.env) {
127
138
  * @returns {Record<string, string | undefined> | null}
128
139
  */
129
140
  function surLeServeur(env) {
130
- if (env.CI || paquetsDeLEnveloppe(env)) return null;
141
+ if (env.CI || paquetsDeLEnveloppe(env)) {
142
+ return null;
143
+ }
131
144
  if (env.GRILLHOUSE_VERROU_MACHINE) {
132
145
  return env[VARIABLE_ESSAI] ? { ...env, TEMPORAL_ADDRESS: env[VARIABLE_ESSAI] } : null;
133
146
  }
@@ -208,7 +221,9 @@ export function prendreUnePlace({
208
221
  };
209
222
  const { code, lignes } = auServeur(e, ['prendre', JSON.stringify(demande)], borneMs + 60_000);
210
223
  for (const l of lignes) {
211
- if (l.dire) dire(l.dire);
224
+ if (l.dire) {
225
+ dire(l.dire);
226
+ }
212
227
  }
213
228
  if (code === A_REPASSER) {
214
229
  throw new AttenteDeLaMachine(lignes.at(-1)?.dire ?? 'attente de place bornée', A_REPASSER);
@@ -224,7 +239,9 @@ export function prendreUnePlace({
224
239
  try {
225
240
  auServeur(e, ['rendre', place.id]);
226
241
  } catch (x) {
227
- if (!(x instanceof AttenteDeLaMachine)) throw x;
242
+ if (!(x instanceof AttenteDeLaMachine)) {
243
+ throw x;
244
+ }
228
245
  dire(
229
246
  `⚠ la place ${place.id} ne se rend pas (${x.message}) : le déroulé de la machine la libère à la fin de son processus.`
230
247
  );
@@ -286,7 +303,9 @@ export function surUnePlace(
286
303
  try {
287
304
  return avecUnePlace(place => passe(place.env), { env, dire });
288
305
  } catch (e) {
289
- if (!(e instanceof AttenteDeLaMachine)) throw e;
306
+ if (!(e instanceof AttenteDeLaMachine)) {
307
+ throw e;
308
+ }
290
309
  dire(e.message);
291
310
  return e.code;
292
311
  }
@@ -340,15 +359,50 @@ export function lirePlaces({ env = process.env } = {}) {
340
359
  : { plafond: plafondDe(env), prises: [], attentes: [] };
341
360
  }
342
361
 
362
+ /**
363
+ * The machine a trial fixes under <env> (GRILLHOUSE_MESURE_D_ESSAI, JSON `{ coeurs, charge,
364
+ * memoireLibre }`), or null without the variable.
365
+ * @param {Record<string, string | undefined>} env
366
+ * @returns {{ coeurs: number, charge: number, memoireLibre: number } | null}
367
+ * @throws {Error} naming GRILLHOUSE_MESURE_D_ESSAI when its value is not that JSON
368
+ */
369
+ function mesureDEssai(env) {
370
+ const v = env[VARIABLE_MESURE_D_ESSAI];
371
+ if (v === undefined || v === '') {
372
+ return null;
373
+ }
374
+ let m;
375
+ try {
376
+ m = JSON.parse(v);
377
+ } catch {
378
+ m = null;
379
+ }
380
+ if (
381
+ !m ||
382
+ typeof m !== 'object' ||
383
+ ['coeurs', 'charge', 'memoireLibre'].some(
384
+ c => typeof m[c] !== 'number' || !Number.isFinite(m[c])
385
+ )
386
+ ) {
387
+ throw new Error(
388
+ `${VARIABLE_MESURE_D_ESSAI} vaut « ${v} » : un JSON { coeurs, charge, memoireLibre } de nombres est attendu.`
389
+ );
390
+ }
391
+ return { coeurs: m.coeurs, charge: m.charge, memoireLibre: m.memoireLibre };
392
+ }
393
+
343
394
  /**
344
395
  * The places as the board shows them: taken and ceiling, the load over one minute and the cores,
345
- * the free memory in whole GB, and the waits (ticket, since when) in the order of arrival.
396
+ * the free memory in whole GB, and the waits (ticket, since when) in the order of arrival. The
397
+ * machine is the one GRILLHOUSE_MESURE_D_ESSAI fixes, else the real one (`mesurer`).
346
398
  * @param {{ env?: Record<string, string | undefined>, mesurer?: () => { coeurs: number,
347
399
  * charge: number, memoireLibre: number } }} [o]
400
+ * @throws {Error} naming GRILLHOUSE_MESURE_D_ESSAI when its value is faulty
348
401
  */
349
402
  export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine } = {}) {
403
+ const fixee = mesureDEssai(env);
350
404
  const { plafond, prises, attentes } = lirePlaces({ env });
351
- const m = mesurer();
405
+ const m = fixee ?? mesurer();
352
406
  return {
353
407
  prises: prises.length,
354
408
  plafond,
@@ -26,7 +26,9 @@ import { ecrireLePrefixe } from './prefixe-des-tickets.mjs';
26
26
 
27
27
  // The prefix of the tickets: the one given, else the store's own, else the directory's name.
28
28
  function prefixeDe(projet, donne) {
29
- if (donne) return donne;
29
+ if (donne) {
30
+ return donne;
31
+ }
30
32
  if (existsSync(path.join(projet, '.beads'))) {
31
33
  const r = spawnSync('bd', ['config', 'get', 'issue_prefix'], {
32
34
  cwd: projet,
@@ -34,7 +36,9 @@ function prefixeDe(projet, donne) {
34
36
  maxBuffer: 256 * 1024 * 1024,
35
37
  });
36
38
  const existant = (r.stdout ?? '').trim();
37
- if (r.status === 0 && existant !== '' && !existant.includes('(')) return existant;
39
+ if (r.status === 0 && existant !== '' && !existant.includes('(')) {
40
+ return existant;
41
+ }
38
42
  }
39
43
  return path
40
44
  .basename(projet)
@@ -49,7 +53,9 @@ const present = commande => trouverDansLePath(commande) !== null;
49
53
 
50
54
  // A global tool of the preparation, installed by npm when absent.
51
55
  function outil(commande, paquet) {
52
- if (present(commande)) return;
56
+ if (present(commande)) {
57
+ return;
58
+ }
53
59
  try {
54
60
  execFileSync('npm', ['install', '-g', paquet], { stdio: 'inherit' });
55
61
  } catch {
@@ -69,7 +75,9 @@ export function preparer(projet, prefixe) {
69
75
  }
70
76
  outil('bd', '@beads/bd');
71
77
  outil('codegraph', '@colbymchenry/codegraph');
72
- if (!existsSync(path.join(projet, '.codegraph'))) lancer(projet, 'codegraph', ['init', projet]);
78
+ if (!existsSync(path.join(projet, '.codegraph'))) {
79
+ lancer(projet, 'codegraph', ['init', projet]);
80
+ }
73
81
  const lePrefixe = prefixeDe(projet, prefixe);
74
82
  lancer(projet, 'bd', [
75
83
  'init',
@@ -86,6 +94,8 @@ export function preparer(projet, prefixe) {
86
94
  if ((r.stdout ?? '').trim() === '') {
87
95
  lancer(projet, 'git', ['config', 'core.hooksPath', '.beads/hooks']);
88
96
  }
89
- if (existsSync(path.join(projet, 'package.json'))) lancer(projet, 'npm', ['install']);
97
+ if (existsSync(path.join(projet, 'package.json'))) {
98
+ lancer(projet, 'npm', ['install']);
99
+ }
90
100
  return installerGreffons(projet);
91
101
  }
@@ -349,10 +349,14 @@ if (direct && process.argv.includes('--rattraper')) {
349
349
  } else if (direct) {
350
350
  try {
351
351
  const input = JSON.parse(readFileSync(0, 'utf8'));
352
- const retenu = Object.fromEntries(CHAMPS.filter(c => input[c] != null).map(c => [c, input[c]]));
352
+ const retenu = Object.fromEntries(
353
+ CHAMPS.filter(c => input[c] !== null && input[c] !== undefined).map(c => [c, input[c]])
354
+ );
353
355
  // The directory the session opened in: the last directory of its shell (`cwd`) may lie where
354
356
  // git finds no repository, a mount of the envelope, where git stops at the boundary.
355
- if (process.env.CLAUDE_PROJECT_DIR) retenu.projet_dir = process.env.CLAUDE_PROJECT_DIR;
357
+ if (process.env.CLAUDE_PROJECT_DIR) {
358
+ retenu.projet_dir = process.env.CLAUDE_PROJECT_DIR;
359
+ }
356
360
  spawn(process.execPath, [process.argv[1], '--ecrire', JSON.stringify(retenu)], {
357
361
  detached: true,
358
362
  stdio: 'ignore',
@@ -0,0 +1,66 @@
1
+ // The resumption of the circuit at the step that carries a red, with no input nor output (as
2
+ // scripts/transitions.mjs): the attribution of a red to the step that carries it and the step where
3
+ // `--depuis` resumes. Mature model: « Re-run failed jobs » of GitHub Actions (the red job and what
4
+ // depends on it replay). The fingerprint of a step, which hashes with `node:crypto`, is in
5
+ // scripts/empreinte-d-etape.mjs, on the side of the activities.
6
+ import { SUITE } from './etapes.mjs';
7
+
8
+ const etatDe = n => SUITE.find(e => e.numero === n).etat;
9
+
10
+ /**
11
+ * The step that carries the red whose places are <lieux> (`{ paquet, fichier, gardes }`), by the
12
+ * files the red names against what the testwriter (`portes.tests`) and the developpeur
13
+ * (`portes.code`) wrote: `{ etape, fichiers, motif? }`. A test file that a guard or the style
14
+ * refuses (`gardes` not empty) is the testwriter's, the earliest step (the developpeur replays
15
+ * after him); a test that fails (no guard) and a file of code are the developpeur's. A red that
16
+ * names no file, or a file nobody wrote, is never attributed (`etape` null, its `motif` said): it
17
+ * goes up.
18
+ */
19
+ export function attribuerLeRouge({ lieux, portes }) {
20
+ const avecFichier = (lieux ?? []).filter(l => typeof l.fichier === 'string' && l.fichier);
21
+ const nommes = [...new Set(avecFichier.map(l => l.fichier))];
22
+ if (!nommes.length) {
23
+ return { etape: null, fichiers: [], motif: 'le rouge ne nomme aucun fichier' };
24
+ }
25
+ const tests = new Set(portes.tests);
26
+ const code = new Set(portes.code);
27
+ const inconnus = nommes.filter(f => !tests.has(f) && !code.has(f));
28
+ if (inconnus.length) {
29
+ return {
30
+ etape: null,
31
+ fichiers: [],
32
+ motif: `le rouge nomme ${inconnus.join(', ')}, que ni le testwriter ni le développeur ne portent`,
33
+ };
34
+ }
35
+ const refuses = nommes.filter(
36
+ f => tests.has(f) && avecFichier.some(l => l.fichier === f && (l.gardes ?? []).length > 0)
37
+ );
38
+ return refuses.length
39
+ ? { etape: 'testwriter', fichiers: refuses.length === nommes.length ? refuses : nommes }
40
+ : { etape: 'developpeur', fichiers: nommes };
41
+ }
42
+
43
+ // The steps `--depuis` names, each with the state it resumes at.
44
+ const DEPARTS = {
45
+ testwriter: () => ({ etape: etatDe('2'), tentative: 1, finale: false }),
46
+ preuve: () => ({ etape: etatDe('2.1'), tentative: 1, finale: false }),
47
+ developpeur: () => ({ etape: etatDe('3'), tentative: 1, finale: false }),
48
+ controles: () => ({ etape: etatDe('3.1'), tentative: 0, finale: false }),
49
+ 'passe-finale': () => ({ etape: etatDe('3.1'), tentative: 0, finale: true }),
50
+ };
51
+
52
+ /** The steps `--depuis` names. */
53
+ export const ETAPES_DE_REPRISE = Object.keys(DEPARTS);
54
+
55
+ /**
56
+ * The state `--depuis <nom>` resumes at: that step and the ones after it, no fingerprint kept
57
+ * (`verts` empty), so nothing is read back.
58
+ */
59
+ export function departDepuis(nom) {
60
+ if (!Object.hasOwn(DEPARTS, nom)) {
61
+ throw new Error(
62
+ `--depuis attend une étape du ticket : ${ETAPES_DE_REPRISE.join(', ')} (reçu « ${nom} »).`
63
+ );
64
+ }
65
+ return { ...DEPARTS[nom](), rapport: null, verts: {} };
66
+ }