@roomi-fields/grillhouse 0.25.5 → 0.27.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 (83) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/agents/testwriter.md +1 -1
  3. package/bin/grillhouse.mjs +20 -3
  4. package/cadre/templates/cargo/package.json +3 -0
  5. package/cadre/templates/projet/.gitattributes +1 -0
  6. package/cadre/templates/projet/CLAUDE.md +13 -0
  7. package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
  8. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  9. package/cadre/templates/python/package.json +18 -0
  10. package/charte.md +32 -1
  11. package/docs/ARCHITECTURE.md +146 -40
  12. package/docs/CADRE.md +7 -6
  13. package/docs/INTERFACE.md +108 -32
  14. package/hooks/register.tsx +57 -16
  15. package/package.json +9 -3
  16. package/scripts/circuit.mjs +165 -27
  17. package/scripts/commande-du-langage.mjs +2 -2
  18. package/scripts/commandes-composees.mjs +156 -0
  19. package/scripts/composition-des-langages.mjs +306 -0
  20. package/scripts/conformite.mjs +1 -3
  21. package/scripts/copies-finies.mjs +167 -28
  22. package/scripts/crochets.mjs +9 -3
  23. package/scripts/dernier-vert.mjs +15 -2
  24. package/scripts/engendres.mjs +170 -0
  25. package/scripts/enveloppe/enveloppe.mjs +59 -17
  26. package/scripts/enveloppe/lancer.sh +15 -22
  27. package/scripts/enveloppe/travail-de-la-copie.mjs +262 -0
  28. package/scripts/etapes.mjs +1 -1
  29. package/scripts/fusion-du-changelog.mjs +120 -0
  30. package/scripts/gardes-du-cadre.mjs +7 -4
  31. package/scripts/grillhouse-maj.mjs +171 -99
  32. package/scripts/index-interfaces.mjs +78 -0
  33. package/scripts/init.mjs +5 -5
  34. package/scripts/integration/file.mjs +270 -117
  35. package/scripts/integration/integrer.mjs +50 -62
  36. package/scripts/jointure.d.ts +48 -14
  37. package/scripts/langages/cargo/binaires.json +2 -1
  38. package/scripts/langages/cargo/binaires.mjs +29 -6
  39. package/scripts/langages/cargo/clippy.mjs +12 -2
  40. package/scripts/langages/cargo/commandes.mjs +60 -7
  41. package/scripts/langages/cargo/composants.mjs +229 -8
  42. package/scripts/langages/cargo/exemples.mjs +1 -15
  43. package/scripts/langages/cargo/index-interfaces.mjs +20 -3
  44. package/scripts/langages/cargo/index.mjs +25 -17
  45. package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
  46. package/scripts/langages/cargo/sccache.mjs +172 -0
  47. package/scripts/langages/cargo/verdict.mjs +50 -10
  48. package/scripts/langages/python/binaires.json +3 -0
  49. package/scripts/langages/python/binaires.mjs +59 -0
  50. package/scripts/langages/python/commandes.mjs +411 -0
  51. package/scripts/langages/python/composants.mjs +272 -0
  52. package/scripts/langages/python/exemples.mjs +260 -0
  53. package/scripts/langages/python/index-interfaces.mjs +77 -0
  54. package/scripts/langages/python/index.mjs +94 -0
  55. package/scripts/langages/python/lot.mjs +76 -0
  56. package/scripts/langages/python/mise-a-jour.mjs +54 -0
  57. package/scripts/langages/python/tailles-des-tests.mjs +102 -0
  58. package/scripts/langages/python/verdict.mjs +85 -0
  59. package/scripts/langages/typescript/exemples.mjs +1 -20
  60. package/scripts/langages/typescript/index-interfaces.mjs +10 -3
  61. package/scripts/langages/typescript/index.mjs +15 -17
  62. package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
  63. package/scripts/langages-des-paquets.mjs +171 -0
  64. package/scripts/langages.mjs +60 -41
  65. package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
  66. package/scripts/migrations.mjs +2 -0
  67. package/scripts/nuit.sh +15 -1
  68. package/scripts/outils-cles.mjs +188 -0
  69. package/scripts/resultats.mjs +22 -6
  70. package/scripts/session-start.sh +34 -9
  71. package/scripts/sources.mjs +2 -1
  72. package/scripts/sous-commandes.mjs +21 -3
  73. package/scripts/tableau-des-composants.mjs +138 -0
  74. package/scripts/verrou-de-machine.mjs +14 -13
  75. package/scripts/verrous/verrou.mjs +53 -16
  76. package/skills/developpeur/SKILL.md +4 -0
  77. package/skills/explorateur/SKILL.md +3 -1
  78. package/skills/grill/SKILL.md +9 -1
  79. package/skills/pitmaster/SKILL.md +12 -3
  80. package/skills/pitmaster/references/consigne-agent.md +3 -3
  81. package/skills/redacteur/references/documents-d-un-composant.md +12 -0
  82. package/skills/relecteur/SKILL.md +6 -2
  83. package/skills/testwriter/SKILL.md +29 -6
@@ -4,9 +4,9 @@
4
4
  // circuit of a ticket (scripts/circuit.mjs), once it has put the ticket's branch in the queue, and
5
5
  // by the supervisor by hand.
6
6
  //
7
- // npx grillhouse file
7
+ // npx grillhouse file [--ci <ticket>]
8
8
  //
9
- // No argument (exit 2 and the usage otherwise). It takes the branches waiting one by one until none is
9
+ // No argument, or `--ci <ticket>` (below; exit 2 and the usage otherwise). It takes the branches waiting one by one until none is
10
10
  // left, then exits 0, whatever became of each branch. A queue launched while another runs exits 0 at
11
11
  // once, refusing nothing: the running queue takes the branch that arrived (it reads the entries
12
12
  // again before it lets go of its lock, `.git/file-integration.lock`).
@@ -22,7 +22,15 @@
22
22
  // `npm run verifier` (Turborepo: the build, then the guards and every test of the day beside
23
23
  // each other, each task replayed from the cache of the main tree when its inputs are
24
24
  // unchanged), every command of the project run in the copy leaving its index up to date
25
- // (rejeu.mjs); main moves forward onto the replaced branch when `npm run verifier` is green;
25
+ // (rejeu.mjs); main moves forward onto the replaced branch when `npm run verifier` is green.
26
+ // A generated file the project declares (`grillhouse.engendres`, scripts/engendres.mjs, read
27
+ // from the main tree, a faulty key keeping the branch in the queue, named) is never merged, as
28
+ // npm writes package-lock.json again after a merge: a conflict on such files only takes main's
29
+ // version, and once the branch is replaced and installed, the command of each one whose files,
30
+ // or the files it reads, the branch touches writes it again, with the tools of the project,
31
+ // and what it writes enters the branch's commit; a command that fails makes the branch leave
32
+ // the queue, the command and its output named (OSC Bridge, 2026-10-31: four conflicts in one
33
+ // day on the generated files of synthhub and open-synth-descriptors);
26
34
  // - a branch with nothing ahead of main does not enter: it leaves the queue, its ticket loses
27
35
  // `en-file` and takes a comment, and stays as it is;
28
36
  // - a branch that does not replace (the files in conflict) or whose `npm run verifier` is red once
@@ -58,7 +66,16 @@
58
66
  // `npm run verifier` play out of it. A red CI reopens the ticket (`bd reopen`), its comment giving the
59
67
  // address of the run (`gh run view <id> --json url`) and the end of `gh run view <id>
60
68
  // --log-failed`. Without `gh`, without a run found, with `gh` refusing or past the 30 min, the
61
- // ticket is told that the CI was not read, and why, and stays closed.
69
+ // ticket is told that the CI was not read, and why, and stays closed. The run is read at its current
70
+ // attempt (`gh run view <id>` without `--attempt`), as a merge queue judges the last attempt of a
71
+ // commit's checks.
72
+ // `--ci <ticket>` reads again the CI of a ticket a red CI reopened, which the circuit runs at 5.2
73
+ // on `--reprendre` (scripts/circuit.mjs, `argumentsDeLaFile`), once the supervisor had the failed
74
+ // jobs run again (`gh run rerun <id> --failed`): the commit of main that delivers the ticket, its
75
+ // CI read as above (`relireCI`); green, the ticket closes « intégré : <commit> », the run named at
76
+ // it; red or not read, it stays open, the reading at the ticket. A flaky test has no path of its
77
+ // own: the red comment gives the charter's rule, a test known red goes into quarantine in the test
78
+ // itself, with the ticket that fixes it. It takes no lock: it does not move main.
62
79
  // Every comment and change of the queue at a ticket is written under the author `file`, which bd
63
80
  // reads in BEADS_ACTOR, as the circuit writes its own lines under `circuit`.
64
81
  import { spawnSync } from 'node:child_process';
@@ -66,7 +83,10 @@ import { existsSync, rmSync } from 'node:fs';
66
83
  import { createRequire } from 'node:module';
67
84
  import path from 'node:path';
68
85
  import { pathToFileURL } from 'node:url';
86
+ import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
87
+ import { avecLesOutils, outilsDe } from '../outils-cles.mjs';
69
88
  import { lireCommit } from '../poussee-cles.mjs';
89
+ import { commitsDelivering, gitLog } from '../un-commit-par-ticket.mjs';
70
90
  import { attendreUnPeu, lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
71
91
  import { dossierCommun, lireEntrees, retirerEntree } from './file-attente.mjs';
72
92
  import { ouvrirCopie } from './rejeu.mjs';
@@ -193,9 +213,185 @@ export function fluxDeLaBranche(fichiers, branche) {
193
213
  .map(({ chemin }) => chemin);
194
214
  }
195
215
 
216
+ // The verdicts of a reading of the CI (`lireCI`).
217
+ const VERTE = 'verte';
218
+ const ROUGE = 'rouge';
219
+ const SANS_CI = 'sans-ci';
220
+ const NON_LUE = 'non-lue';
221
+
222
+ // The workflows of the commit <sha> of the repository <racine> that run on a push to <branche>:
223
+ // their paths.
224
+ function fluxDuCommit(racine, sha, branche) {
225
+ const git = (...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
226
+ const l = git('ls-tree', '--name-only', `${sha}:${DOSSIER_DES_FLUX}`);
227
+ const noms = l.status === 0 ? l.stdout.split('\n').filter(n => EXTENSIONS_DES_FLUX.test(n)) : [];
228
+ const fichiers = noms.map(n => {
229
+ const chemin = `${DOSSIER_DES_FLUX}/${n}`;
230
+ const f = git('show', `${sha}:${chemin}`);
231
+ return { chemin, texte: f.status === 0 ? f.stdout : null };
232
+ });
233
+ return fluxDeLaBranche(fichiers, branche);
234
+ }
235
+
236
+ // The GitHub CLI run in the main tree <racine>.
237
+ const ghDans =
238
+ racine =>
239
+ (args, options = {}) =>
240
+ spawnSync('gh', args, {
241
+ cwd: racine,
242
+ encoding: 'utf8',
243
+ maxBuffer: 64 * 1024 * 1024,
244
+ ...options,
245
+ });
246
+
247
+ // The CI of the commit <sha> pushed to <branche>, for the ticket <ticket>, read with the tools <o>
248
+ // (`{ racine, principale, bd, gh, dire, avancement }`: the main tree, its branch, bd, the GitHub
249
+ // CLI, a line of the output, the progress directory or null): `{ verdict, passage }`, the verdict
250
+ // VERTE, ROUGE, SANS_CI or NON_LUE, and the id of the run read. The run is read by `gh run view
251
+ // <id>`, which gives its current attempt: a run whose failed jobs were run again
252
+ // (`gh run rerun <id> --failed`) is judged on that attempt, as a merge queue judges the last
253
+ // attempt of a commit's checks. No CI, red or not read, the ticket is told so; green, nothing is
254
+ // written to it.
255
+ function lireCI(o, ticket, sha, branche) {
256
+ const court = sha.slice(0, 7);
257
+ const commenter = texte => o.bd('comments', 'add', ticket, texte);
258
+ if (fluxDuCommit(o.racine, sha, branche).length === 0) {
259
+ const texte = `Aucune CI pour origin/${branche} : aucun flux de ${DOSSIER_DES_FLUX} de ${court} ne se lance sur la branche ${branche}, la file n'en attend pas.`;
260
+ commenter(texte);
261
+ o.dire(`✓ ${texte}`);
262
+ return { verdict: SANS_CI, passage: null };
263
+ }
264
+ const { gh } = o;
265
+ const nonLue = raison => {
266
+ commenter(`## CI non lue\n\nLa CI de ${court} n'a pas été lue : ${raison}`);
267
+ o.dire(`⚠ CI de ${court} non lue : ${raison}`);
268
+ return { verdict: NON_LUE, passage: null };
269
+ };
270
+ const recherche = delai('GRILLHOUSE_CI_RECHERCHE_MS', RECHERCHE_CI_MS);
271
+ const debut = Date.now();
272
+ let passage = null;
273
+ for (;;) {
274
+ const r = gh(['run', 'list', '--commit', sha, '--json', 'databaseId,status,conclusion']);
275
+ if (r.error) return nonLue(`gh ne se lance pas (${r.error.code ?? r.error.message}).`);
276
+ if (r.status !== 0) return nonLue(`gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}`);
277
+ let passages = [];
278
+ try {
279
+ passages = JSON.parse(r.stdout || '[]');
280
+ } catch {
281
+ return nonLue(`gh run list rend une sortie illisible :\n${r.stdout.trim()}`);
282
+ }
283
+ passage = passages.find(x => x?.databaseId);
284
+ const reste = recherche - (Date.now() - debut);
285
+ if (passage || reste <= 0) break;
286
+ attendreUnPeu(Math.min(10_000, reste));
287
+ }
288
+ if (!passage) {
289
+ return nonLue(`aucun passage de la CI pour ce commit en ${Math.round(recherche / 1000)} s.`);
290
+ }
291
+ const id = String(passage.databaseId);
292
+ const attente = delai('GRILLHOUSE_CI_ATTENTE_MS', ATTENTE_CI_MS);
293
+ const pas = delai('GRILLHOUSE_CI_PAS_MS', PAS_CI_MS);
294
+ const limite = Date.now() + attente;
295
+ let vue = null;
296
+ for (;;) {
297
+ const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
298
+ timeout: 60_000,
299
+ killSignal: 'SIGKILL',
300
+ });
301
+ if (v.error) return nonLue(`gh ne se lance pas (${v.error.code ?? v.error.message}).`);
302
+ if (v.status !== 0) return nonLue(`gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}`);
303
+ try {
304
+ vue = JSON.parse(v.stdout || '{}');
305
+ } catch {
306
+ return nonLue(`gh run view rend une sortie illisible :\n${v.stdout.trim()}`);
307
+ }
308
+ ecrireLesEtapes(o.avancement, vue);
309
+ if (vue?.status === 'completed') break;
310
+ const reste = limite - Date.now();
311
+ if (reste <= 0) {
312
+ return nonLue(`le passage ${id} n'a pas fini en ${Math.round(attente / 60_000)} min.`);
313
+ }
314
+ attendreUnPeu(Math.min(pas, reste));
315
+ }
316
+ if (vue.conclusion === 'success') {
317
+ o.dire(`✓ CI de ${court} verte (passage ${id})`);
318
+ return { verdict: VERTE, passage: id };
319
+ }
320
+ const url = gh(['run', 'view', id, '--json', 'url', '--jq', '.url']).stdout?.trim() || id;
321
+ const journal = `${gh(['run', 'view', id, '--log-failed']).stdout ?? ''}`
322
+ .trim()
323
+ .split('\n')
324
+ .slice(-60)
325
+ .join('\n');
326
+ commenter(
327
+ `## CI rouge\n\nLa CI de ${court} sur ${o.principale} est rouge : ${url}\n\nLa fin de gh run view ${id} --log-failed :\n\n${journal}\n\nLe ticket est rouvert : sa correction entre sous son numéro. Un rejeu vert de la même CI (\`gh run rerun ${id} --failed\`), puis \`--reprendre\` du circuit, le ferme ; un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`
328
+ );
329
+ o.dire(`✗ CI de ${court} rouge (passage ${id}) : ${ticket} rouvert`);
330
+ return { verdict: ROUGE, passage: id };
331
+ }
332
+
333
+ /**
334
+ * The CI of the ticket's commit on main read again, with the tools <o> (`{ racine, principale,
335
+ * ticket, bd, gh, dire, avancement }`, as `lireCI`), for a ticket a red CI reopened: as a merge
336
+ * queue judges the last attempt of a commit's checks, a run whose failed jobs were run again green
337
+ * is green. The commit is the last of main that delivers the ticket (its title line names it,
338
+ * `commitsDelivering` of ../un-commit-par-ticket.mjs, the prefix read from bd); green, or no CI
339
+ * for the branch pushed to, the ticket closes as an entry closes it (« intégré : <commit> »), its
340
+ * run named at the ticket; red or not read, it stays open, the reading at the ticket. No commit of
341
+ * main delivering it, or its branch `agent/<ticket>` still ahead of main (a lot not yet on main),
342
+ * the ticket is told that the CI is not read again. Exit 0.
343
+ */
344
+ export function relireCI(o) {
345
+ const { racine, principale, ticket } = o;
346
+ const git = (...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
347
+ const nonRelue = raison => {
348
+ o.bd('comments', 'add', ticket, `## CI non relue\n\n${raison}`);
349
+ o.dire(`⚠ CI non relue : ${raison}`);
350
+ return 0;
351
+ };
352
+ const refPrincipale = `refs/heads/${principale}`;
353
+ const branche = `agent/${ticket}`;
354
+ const enAvance = git('rev-list', '--count', `${refPrincipale}..refs/heads/${branche}`);
355
+ if (enAvance.status === 0 && Number(enAvance.stdout.trim()) > 0) {
356
+ return nonRelue(
357
+ `La branche ${branche} a des commits hors de ${principale} : son lot n'est pas sur ${principale}, la file n'en relit pas la CI.`
358
+ );
359
+ }
360
+ const prefixe = o.bd('config', 'get', 'issue_prefix').stdout?.trim() ?? '';
361
+ const sha = commitsDelivering(ticket, prefixe, gitLog(racine))
362
+ .map(c => git('rev-parse', '--verify', '-q', `${c}^{commit}`).stdout.trim())
363
+ .find(c => c && git('merge-base', '--is-ancestor', c, refPrincipale).status === 0);
364
+ if (!sha) {
365
+ return nonRelue(
366
+ `Aucun commit de ${principale} ne livre ${ticket} : la file n'a pas de CI à relire.`
367
+ );
368
+ }
369
+ const court = sha.slice(0, 7);
370
+ const paquet = git('show', `${refPrincipale}:package.json`);
371
+ const { commit, faute } = lireCommit(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
372
+ if (faute) {
373
+ return nonRelue(`grillhouse.poussee.commit vaut ${faute}, pas un nom de branche.`);
374
+ }
375
+ const ci = lireCI(o, ticket, sha, commit);
376
+ if (ci.verdict === VERTE || ci.verdict === SANS_CI) {
377
+ o.bd('close', ticket, '--reason', `${INTEGRE}${court}`);
378
+ if (ci.passage) {
379
+ o.bd(
380
+ 'comments',
381
+ 'add',
382
+ ticket,
383
+ `## CI relue\n\nLa CI de ${court} sur ${principale} est verte au dernier essai du passage ${ci.passage} : le ticket se ferme.`
384
+ );
385
+ }
386
+ o.dire(`✓ ${ticket} fermé : ${court} est sur ${principale}`);
387
+ }
388
+ return 0;
389
+ }
390
+
196
391
  function main(argv) {
197
- if (argv.length) {
198
- process.stderr.write('usage: file.mjs (sans argument)\n');
392
+ const relecture = argv.length === 2 && argv[0] === '--ci' && argv[1] ? argv[1] : null;
393
+ if (argv.length && !relecture) {
394
+ process.stderr.write('usage: file.mjs [--ci <ticket>]\n');
199
395
  return 2;
200
396
  }
201
397
  // The progress directory of the circuit's step (scripts/avancement.mjs), where the queue writes
@@ -227,6 +423,9 @@ function main(argv) {
227
423
  process.stderr.write("⛔ L'arbre principal n'est pas sur une branche.\n");
228
424
  return 1;
229
425
  }
426
+ // The tools of the reading of the CI, the queue's and its reading again.
427
+ const lecture = { racine, principale, bd, gh: ghDans(racine), dire, avancement };
428
+ if (relecture) return relireCI({ ...lecture, ticket: relecture });
230
429
  const refPrincipale = `refs/heads/${principale}`;
231
430
  const copie = path.join(racine, '.claude', 'worktrees', 'file');
232
431
  const verrou = path.join(dossierCommun(racine), 'file-integration.lock');
@@ -263,30 +462,81 @@ function main(argv) {
263
462
  const rejouer = (tip, tete) => {
264
463
  if (existsSync(copie))
265
464
  spawnSync('git', ['-C', copie, 'rebase', '--abort'], { encoding: 'utf8' });
465
+ // The keys of the project, before any work: its generated files and its tools.
466
+ let engendres;
467
+ let env;
468
+ try {
469
+ engendres = engendresDe(racine);
470
+ env = avecLesOutils(outilsDe(racine), process.env);
471
+ } catch (e) {
472
+ return { garde: `une clé grillhouse du package.json est refusée :\n${e.message}` };
473
+ }
266
474
  const ouverte = ouvrirCopie({ racine, copie, ref: tete, dire });
267
475
  if (ouverte.refus) return { garde: ouverte.refus };
268
- const { dansCopie, installer, tester } = ouverte;
476
+ const { dansCopie, monter, installer, tester } = ouverte;
269
477
  if (dansCopie('checkout', '-q', '--detach', tip).status !== 0)
270
478
  return { garde: `la copie ne prend pas ${tip.slice(0, 7)}` };
271
- const rebase = dansCopie('rebase', tete);
272
- if (rebase.status !== 0) {
479
+ // A conflict on generated files the project declares only is no conflict: main's version is
480
+ // taken, and their command writes them again once the branch is replaced (below).
481
+ let rebase = dansCopie('rebase', tete);
482
+ let tours = Number(dansCopie('rev-list', '--count', `${tete}..${tip}`).stdout.trim()) || 1;
483
+ while (rebase.status !== 0) {
273
484
  const conflits = dansCopie('diff', '--name-only', '--diff-filter=U')
274
485
  .stdout.split('\n')
275
486
  .filter(Boolean);
276
- dansCopie('rebase', '--abort');
277
- return {
278
- sortie: [
279
- 'elle ne se replace pas sur main.',
280
- conflits.length
281
- ? `Fichiers en conflit :\n${conflits.map(f => ` ${f}`).join('\n')}`
282
- : `Sortie de git :\n${rebase.stdout}${rebase.stderr}`,
283
- ],
284
- };
487
+ const engendresSeuls =
488
+ tours-- > 0 &&
489
+ conflits.length > 0 &&
490
+ conflits.every(f => engendres.some(e => couvertPar(e.entiers, f))) &&
491
+ dansCopie('checkout', '--ours', '--', ...conflits).status === 0 &&
492
+ dansCopie('add', '--', ...conflits).status === 0;
493
+ if (!engendresSeuls) {
494
+ dansCopie('rebase', '--abort');
495
+ return {
496
+ sortie: [
497
+ 'elle ne se replace pas sur main.',
498
+ conflits.length
499
+ ? `Fichiers en conflit :\n${conflits.map(f => ` ${f}`).join('\n')}`
500
+ : `Sortie de git :\n${rebase.stdout}${rebase.stderr}`,
501
+ ],
502
+ };
503
+ }
504
+ rebase = dansCopie('-c', 'core.editor=true', 'rebase', '--continue');
285
505
  }
286
506
  const installation = installer();
287
507
  if (installation) {
288
508
  return { sortie: [installation, "Le verrou de la branche replacée ne s'installe pas."] };
289
509
  }
510
+ const touches = touchesPar(
511
+ engendres,
512
+ dansCopie('diff', '--name-only', '--no-renames', '-z', tete, 'HEAD')
513
+ .stdout.split('\0')
514
+ .filter(Boolean)
515
+ );
516
+ if (touches.length) {
517
+ const refus = regenerer({
518
+ refs: touches.map(e => ({ ...e, cadre: false })),
519
+ dansCopie,
520
+ lancer: commande =>
521
+ spawnSync('bash', monter('sh', '-c', commande), {
522
+ cwd: copie,
523
+ encoding: 'utf8',
524
+ maxBuffer: 256 * 1024 * 1024,
525
+ env,
526
+ }),
527
+ });
528
+ if (refus)
529
+ return { sortie: ['ses fichiers engendrés ne se régénèrent pas sur main.', refus] };
530
+ if (dansCopie('diff', '--cached', '--quiet').status !== 0) {
531
+ const corrige = dansCopie('commit', '-q', '--amend', '--no-edit', '--no-verify');
532
+ if (corrige.status !== 0) {
533
+ return {
534
+ garde: `ses fichiers régénérés n'entrent pas dans son commit :\n${corrige.stderr}`,
535
+ };
536
+ }
537
+ }
538
+ dire(`✓ fichiers engendrés régénérés sur main : ${touches.map(e => e.nom).join(', ')}`);
539
+ }
290
540
  dire('— npm run verifier (construction, gardes, tests)');
291
541
  const t = tester();
292
542
  if (t.status === A_REPASSER) {
@@ -342,106 +592,9 @@ function main(argv) {
342
592
  dire(`⚠ poussée de ${court} refusée`);
343
593
  } else {
344
594
  dire(`✓ poussée : ${court} est sur origin/${commit}`);
345
- lireCI(entree, nouveau, commit);
346
- }
347
- };
348
-
349
- // The workflows of the commit <sha> that run on a push to <branche>: their paths.
350
- const fluxDuCommit = (sha, branche) => {
351
- const l = git('ls-tree', '--name-only', `${sha}:${DOSSIER_DES_FLUX}`);
352
- const noms =
353
- l.status === 0 ? l.stdout.split('\n').filter(n => EXTENSIONS_DES_FLUX.test(n)) : [];
354
- const fichiers = noms.map(n => {
355
- const chemin = `${DOSSIER_DES_FLUX}/${n}`;
356
- const f = git('show', `${sha}:${chemin}`);
357
- return { chemin, texte: f.status === 0 ? f.stdout : null };
358
- });
359
- return fluxDeLaBranche(fichiers, branche);
360
- };
361
-
362
- // The CI of the commit <sha> pushed to <branche>: none, the ticket is told so in one line; green,
363
- // the ticket stays closed; red, it reopens; not read, the ticket is told why.
364
- const lireCI = (entree, sha, branche) => {
365
- const court = sha.slice(0, 7);
366
- if (fluxDuCommit(sha, branche).length === 0) {
367
- const texte = `Aucune CI pour origin/${branche} : aucun flux de ${DOSSIER_DES_FLUX} de ${court} ne se lance sur la branche ${branche}, la file n'en attend pas.`;
368
- commenter(entree.ticket, texte);
369
- dire(`✓ ${texte}`);
370
- return;
595
+ const ci = lireCI(lecture, entree.ticket, nouveau, commit);
596
+ if (ci.verdict === ROUGE) bd('reopen', entree.ticket);
371
597
  }
372
- const gh = (args, options = {}) =>
373
- spawnSync('gh', args, {
374
- cwd: racine,
375
- encoding: 'utf8',
376
- maxBuffer: 64 * 1024 * 1024,
377
- ...options,
378
- });
379
- const nonLue = raison => {
380
- commenter(entree.ticket, `## CI non lue\n\nLa CI de ${court} n'a pas été lue : ${raison}`);
381
- dire(`⚠ CI de ${court} non lue : ${raison}`);
382
- };
383
- const recherche = delai('GRILLHOUSE_CI_RECHERCHE_MS', RECHERCHE_CI_MS);
384
- const debut = Date.now();
385
- let passage = null;
386
- for (;;) {
387
- const r = gh(['run', 'list', '--commit', sha, '--json', 'databaseId,status,conclusion']);
388
- if (r.error) return nonLue(`gh ne se lance pas (${r.error.code ?? r.error.message}).`);
389
- if (r.status !== 0) return nonLue(`gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}`);
390
- let passages = [];
391
- try {
392
- passages = JSON.parse(r.stdout || '[]');
393
- } catch {
394
- return nonLue(`gh run list rend une sortie illisible :\n${r.stdout.trim()}`);
395
- }
396
- passage = passages.find(x => x?.databaseId);
397
- const reste = recherche - (Date.now() - debut);
398
- if (passage || reste <= 0) break;
399
- attendreUnPeu(Math.min(10_000, reste));
400
- }
401
- if (!passage) {
402
- return nonLue(`aucun passage de la CI pour ce commit en ${Math.round(recherche / 1000)} s.`);
403
- }
404
- const id = String(passage.databaseId);
405
- const attente = delai('GRILLHOUSE_CI_ATTENTE_MS', ATTENTE_CI_MS);
406
- const pas = delai('GRILLHOUSE_CI_PAS_MS', PAS_CI_MS);
407
- const limite = Date.now() + attente;
408
- let vue = null;
409
- for (;;) {
410
- const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
411
- timeout: 60_000,
412
- killSignal: 'SIGKILL',
413
- });
414
- if (v.error) return nonLue(`gh ne se lance pas (${v.error.code ?? v.error.message}).`);
415
- if (v.status !== 0) return nonLue(`gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}`);
416
- try {
417
- vue = JSON.parse(v.stdout || '{}');
418
- } catch {
419
- return nonLue(`gh run view rend une sortie illisible :\n${v.stdout.trim()}`);
420
- }
421
- ecrireLesEtapes(avancement, vue);
422
- if (vue?.status === 'completed') break;
423
- const reste = limite - Date.now();
424
- if (reste <= 0) {
425
- return nonLue(`le passage ${id} n'a pas fini en ${Math.round(attente / 60_000)} min.`);
426
- }
427
- attendreUnPeu(Math.min(pas, reste));
428
- }
429
- if (vue.conclusion === 'success') {
430
- dire(`✓ CI de ${court} verte (passage ${id})`);
431
- return;
432
- }
433
- const url = gh(['run', 'view', id, '--json', 'url', '--jq', '.url']).stdout?.trim() || id;
434
- const journal = `${gh(['run', 'view', id, '--log-failed']).stdout ?? ''}`
435
- .trim()
436
- .split('\n')
437
- .slice(-60)
438
- .join('\n');
439
- bd('reopen', entree.ticket);
440
- commenter(
441
- entree.ticket,
442
- `## CI rouge\n\nLa CI de ${court} sur ${principale} est rouge : ${url}\n\nLa fin de gh run view ${id} --log-failed :\n\n${journal}\n\nLe ticket est rouvert : sa correction entre sous son numéro.`
443
- );
444
- dire(`✗ CI de ${court} rouge (passage ${id}) : ${entree.ticket} rouvert`);
445
598
  };
446
599
 
447
600
  // One branch of the queue, against the main of the moment.
@@ -12,6 +12,9 @@
12
12
  // One delivery is one ticket: the ticket gives its branch `agent/<ticket>` and its copy
13
13
  // (`.claude/worktrees/<ticket>`, the one the lot was written in, when it exists); a second
14
14
  // --ticket is a usage error, named. In order, each step refusing stops the run:
15
+ // 0. the keys of the project, read from the package.json of the main tree: its generated files
16
+ // (`grillhouse.engendres`, scripts/engendres.mjs) and its tools (`grillhouse.outils`,
17
+ // scripts/outils-cles.mjs), a faulty key refused by its name before any work;
15
18
  // 1. the verdict: the ticket has `ACCEPTÉ` as its last reviewer verdict (`ACCEPTÉ` or
16
19
  // `RENDU` at the start of a comment of the author `relecteur`; another author's is none) and, when labelled `arbitrage`, each arbitrage
17
20
  // (`estArbitrage`: a « ## Arbitrage » comment, the supervisor's) is settled
@@ -56,17 +59,21 @@
56
59
  // `en-file` and the branch takes its place at the end of the queue
57
60
  // (scripts/integration/file-attente.mjs). main does not move here.
58
61
  //
59
- // The references are the circuit's (`--references`, a JSON file the circuit writes from its one
60
- // list, `lesReferences` of scripts/circuit.mjs): each `{ nom, commande, fichiers, entiers, cadre }`,
61
- // `entiers` the files of `fichiers` its command writes in full (paths, directories or glob
62
- // patterns, as `couvertPar` reads them). As a genrule of Bazel writes its output again on the
63
- // merged tree, and npm install writes package-lock.json again after a merge, a file of the lot a
64
- // reference writes in full is not applied: the reference that writes it plays in the copy, on main
65
- // of the moment, after the install and before the tests, through the mounts, and what it writes
66
- // enters the commit (BPScript 320.30: refused twice for the one conflict on the index of the
67
- // interfaces, which another ticket had regenerated on main in the meantime). A command of the
68
- // project at another code than 0, one of the frame on a real failure (126, 127, a signal), or a
69
- // file it changes that its `fichiers` do not cover, refuses the lot. A conflict on any other file
62
+ // The references written in full are the generated files the project declares
63
+ // (`grillhouse.engendres`), then the frame's the circuit hands over (`--references`, a JSON file the
64
+ // circuit writes from its one list, `lesReferences` of scripts/circuit.mjs): each `{ nom, commande,
65
+ // fichiers, lit, entiers, cadre }`, `entiers` the files of `fichiers` its command writes in full,
66
+ // `lit` the files it reads (paths, directories or glob patterns, as `couvertPar` of
67
+ // scripts/engendres.mjs reads them). As a genrule of Bazel writes its output again on the merged
68
+ // tree, and npm install writes package-lock.json again after a merge, a file of the lot a reference
69
+ // writes in full is not applied: main's version stays, and each reference whose files or reads the
70
+ // lot touches plays in the copy, on main of the moment, after the install and before the tests,
71
+ // through the mounts, with the tools of the project, and what it writes enters the commit
72
+ // (`regenerer` of scripts/engendres.mjs; BPScript 320.30: refused twice for the one conflict on the
73
+ // index of the interfaces; OSC Bridge, 2026-10-31: four conflicts in one day on the generated files
74
+ // of synthhub and open-synth-descriptors). A command of the project at another code than 0, one of
75
+ // the frame on a real failure (126, 127, a signal), or a file it changes that its `fichiers` do not
76
+ // cover, refuses the lot, the command, its code and its output named. A conflict on any other file
70
77
  // refuses it, as the three-way application says.
71
78
  //
72
79
  // What steps 2, 3 and 5 read of a lot is its files: each file added, modified or deleted, a
@@ -84,7 +91,9 @@ import { existsSync, readFileSync } from 'node:fs';
84
91
  import path from 'node:path';
85
92
  import { pathToFileURL } from 'node:url';
86
93
  import { arbitrageTranche, estArbitrage } from '../arbitrages.mjs';
94
+ import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
87
95
  import { langageDe } from '../langages.mjs';
96
+ import { avecLesOutils, outilsDe } from '../outils-cles.mjs';
88
97
  import { lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
89
98
  import { dossierCommun, inscrireEntree } from './file-attente.mjs';
90
99
  import { ouvrirCopie, RETIRER_COPIE } from './rejeu.mjs';
@@ -118,16 +127,6 @@ function nomDeGit(ecrit) {
118
127
  return Buffer.from(octets).toString('utf8');
119
128
  }
120
129
 
121
- // Whether one of <motifs> covers the file <fichier>, both from the root of the copy, as the
122
- // inputs of Turborepo read them: a path names that file, a directory every file under it, a glob
123
- // pattern (`*`, `**`) the files it matches (`path.matchesGlob` of Node).
124
- export function couvertPar(motifs, fichier) {
125
- return motifs.some(m => {
126
- const dossier = m.replace(/\/+$/, '');
127
- return fichier === dossier || fichier.startsWith(`${dossier}/`) || path.matchesGlob(fichier, m);
128
- });
129
- }
130
-
131
130
  // The refusal for the verdicts of one ticket, or null. `ticket` and `comments` are Beads' JSON.
132
131
  export function refusVerdicts(ticket, comments) {
133
132
  const id = ticket.id;
@@ -241,42 +240,6 @@ function differents(copieTicket, lots, fichiers, tmp) {
241
240
  return r.stdout.split('\0').filter(Boolean);
242
241
  }
243
242
 
244
- // The regeneration of the references <refs> in the integration copy <copie>, each command run by
245
- // the shell at its root through the mounts (`monter`), its output written; then every file they
246
- // changed staged. Null, or the refusal: a command of the project at another code than 0, one of
247
- // the frame on a real failure (126, 127, a signal, 128 + its number), a file changed that their
248
- // `fichiers` do not cover.
249
- function regenerer(copie, refs, monter, dansCopie) {
250
- for (const r of refs) {
251
- const x = spawnSync('bash', monter('sh', '-c', r.commande), {
252
- cwd: copie,
253
- encoding: 'utf8',
254
- maxBuffer: 256 * 1024 * 1024,
255
- });
256
- process.stdout.write(`${x.stdout ?? ''}${x.stderr ?? ''}`);
257
- const code = x.status ?? 1;
258
- const panne =
259
- x.signal !== null || x.error !== undefined || code === 126 || code === 127 || code > 128;
260
- if (panne || (!r.cadre && code !== 0)) {
261
- return `La référence « ${r.nom} » (\`${r.commande}\`) rend le code ${code} dans la copie d'intégration.`;
262
- }
263
- }
264
- const etat = dansCopie('status', '--porcelain=v1', '-z', '-uall', '--no-renames');
265
- if (etat.status !== 0) return "L'état de la copie d'intégration ne se lit pas.";
266
- const ecrits = etat.stdout
267
- .split('\0')
268
- .filter(l => l && (l[1] !== ' ' || l.startsWith('??')))
269
- .map(l => l.slice(3));
270
- const horsDeclaration = ecrits.filter(f => !refs.some(r => couvertPar(r.fichiers, f)));
271
- if (horsDeclaration.length) {
272
- return `La régénération des références change des fichiers qu'aucune n'écrit :\n${horsDeclaration.map(f => ` ${f}`).join('\n')}`;
273
- }
274
- if (ecrits.length && dansCopie('add', '-A', '--', ...ecrits).status !== 0) {
275
- return "Les fichiers des références ne s'ajoutent pas au commit.";
276
- }
277
- return null;
278
- }
279
-
280
243
  function main(argv) {
281
244
  const o = lire(argv);
282
245
  if ('faute' in o) {
@@ -312,6 +275,16 @@ function main(argv) {
312
275
  const base = ouvrirBase('integration');
313
276
  const tmp = base.dossier;
314
277
  try {
278
+ // 0. The keys of the project, before any work.
279
+ let engendres;
280
+ let outils;
281
+ try {
282
+ engendres = engendresDe(racine);
283
+ outils = outilsDe(racine);
284
+ } catch (e) {
285
+ return refuser(`Une clé grillhouse du package.json est refusée :\n${e.message}`);
286
+ }
287
+
315
288
  // 1. The verdict.
316
289
  const show = bd('show', o.ticket, '--json');
317
290
  const comments = bd('comments', o.ticket, '--json');
@@ -344,17 +317,21 @@ function main(argv) {
344
317
  if (r2) return refuser(r2);
345
318
  const fichiers = [...new Set([...tests, ...code])];
346
319
  dire(`✓ lots : ${fichiers.length} fichiers`);
347
- let references = [];
320
+ let duCircuit = [];
348
321
  if (o.references) {
349
322
  try {
350
- references = JSON.parse(readFileSync(absolu(o.references), 'utf8'));
323
+ duCircuit = JSON.parse(readFileSync(absolu(o.references), 'utf8'));
351
324
  } catch (e) {
352
325
  return refuser(`Les références ${o.references} ne se lisent pas : ${e.message}`);
353
326
  }
354
327
  }
355
- // The files of the lot a reference writes in full, and the references that write them.
328
+ const references = [
329
+ ...engendres.map(e => ({ ...e, cadre: false })),
330
+ ...duCircuit.map(r => ({ ...r, lit: r.lit ?? [] })),
331
+ ];
332
+ // The files of the lot a reference writes in full, and the references the lot touches.
356
333
  const entiers = fichiers.filter(f => references.some(r => couvertPar(r.entiers, f)));
357
- const aRegenerer = references.filter(r => entiers.some(f => couvertPar(r.entiers, f)));
334
+ const aRegenerer = touchesPar(references, fichiers);
358
335
 
359
336
  // 3. The main tree: the lots' files are free there, so the queue can bring them. The ticket's
360
337
  // copy holds the lot and nothing else.
@@ -408,7 +385,18 @@ function main(argv) {
408
385
  const installation = installer();
409
386
  if (installation) return refuser(installation);
410
387
  if (aRegenerer.length) {
411
- const refus = regenerer(copie, aRegenerer, monter, dansCopie);
388
+ const env = avecLesOutils(outils, process.env);
389
+ const refus = regenerer({
390
+ refs: aRegenerer,
391
+ dansCopie,
392
+ lancer: commande =>
393
+ spawnSync('bash', monter('sh', '-c', commande), {
394
+ cwd: copie,
395
+ encoding: 'utf8',
396
+ maxBuffer: 256 * 1024 * 1024,
397
+ env,
398
+ }),
399
+ });
412
400
  if (refus) return refuser(refus);
413
401
  dire(`✓ références régénérées sur main à jour : ${aRegenerer.map(r => r.nom).join(', ')}`);
414
402
  }