@roomi-fields/grillhouse 0.50.3 → 0.52.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 (150) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/developpeur.md +1 -1
  4. package/agents/direct.md +1 -1
  5. package/agents/explorateur.md +1 -1
  6. package/agents/questionneur.md +1 -1
  7. package/agents/relecteur.md +1 -1
  8. package/agents/testwriter.md +1 -1
  9. package/cadre/templates/c/package.json +1 -0
  10. package/cadre/templates/cargo/package.json +1 -0
  11. package/cadre/templates/python/package.json +1 -0
  12. package/charte/plan.md +47 -0
  13. package/charte/preuve.md +39 -0
  14. package/charte/superviseur.md +61 -0
  15. package/charte/tests.md +38 -0
  16. package/charte.md +39 -189
  17. package/dist/machine/part-par-sorte.d.ts +16 -0
  18. package/dist/machine/part-par-sorte.js +36 -0
  19. package/dist/machine/part-par-sorte.js.map +1 -0
  20. package/dist/temporal/circuit/appel.js +1 -1
  21. package/dist/temporal/circuit/appel.js.map +1 -1
  22. package/dist/temporal/circuit/client.d.ts +4 -4
  23. package/dist/temporal/circuit/client.js +38 -16
  24. package/dist/temporal/circuit/client.js.map +1 -1
  25. package/dist/temporal/circuit/contrat.d.ts +11 -7
  26. package/dist/temporal/circuit/contrat.js +5 -9
  27. package/dist/temporal/circuit/contrat.js.map +1 -1
  28. package/dist/temporal/circuit/deroule.js +18 -6
  29. package/dist/temporal/circuit/deroule.js.map +1 -1
  30. package/dist/temporal/commande.js +12 -3
  31. package/dist/temporal/commande.js.map +1 -1
  32. package/dist/temporal/installation.d.ts +54 -3
  33. package/dist/temporal/installation.js +187 -17
  34. package/dist/temporal/installation.js.map +1 -1
  35. package/dist/temporal/places/client.d.ts +5 -1
  36. package/dist/temporal/places/client.js +23 -11
  37. package/dist/temporal/places/client.js.map +1 -1
  38. package/docs/ARCHITECTURE.md +23 -2700
  39. package/docs/INTERFACE.md +26 -10
  40. package/docs/architecture/circuit.md +61 -14
  41. package/docs/architecture/entree.md +21 -8
  42. package/docs/architecture/greffon.md +49 -20
  43. package/docs/architecture/installation.md +46 -17
  44. package/docs/architecture/machine.md +79 -39
  45. package/docs/architecture/tests.md +59 -16
  46. package/docs/lexique.md +163 -0
  47. package/hooks/hooks.json +0 -10
  48. package/hooks/register.tsx +92 -4
  49. package/package.json +2 -1
  50. package/scripts/activites.mjs +105 -65
  51. package/scripts/aiguillage.mjs +15 -8
  52. package/scripts/attente-au-tour.mjs +2 -3
  53. package/scripts/attente-de-la-machine.mjs +4 -8
  54. package/scripts/avancement.mjs +12 -8
  55. package/scripts/bilan.mjs +126 -63
  56. package/scripts/bilans-gardes.mjs +37 -0
  57. package/scripts/branche-de-nuit.mjs +2 -2
  58. package/scripts/ci-de-main.mjs +18 -21
  59. package/scripts/circuit.mjs +89 -44
  60. package/scripts/circuits-du-serveur.mjs +5 -5
  61. package/scripts/composants-affectes.mjs +30 -12
  62. package/scripts/composition-des-langages.mjs +5 -3
  63. package/scripts/conformite.mjs +1 -1
  64. package/scripts/consommation-des-passes.mjs +8 -6
  65. package/scripts/copies-finies.mjs +3 -14
  66. package/scripts/depart-du-ticket.d.mts +8 -2
  67. package/scripts/depart-du-ticket.mjs +26 -8
  68. package/scripts/direct.mjs +158 -72
  69. package/scripts/droits.mjs +165 -208
  70. package/scripts/engendres.mjs +3 -14
  71. package/scripts/entree-de-seance.mjs +35 -0
  72. package/scripts/enveloppe/enveloppe.mjs +98 -46
  73. package/scripts/enveloppe/lancer.sh +90 -66
  74. package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
  75. package/scripts/enveloppe/travail-de-la-copie.mjs +192 -3
  76. package/scripts/etapes.mjs +84 -22
  77. package/scripts/faits-du-circuit.mjs +8 -2
  78. package/scripts/grillhouse-maj.mjs +43 -18
  79. package/scripts/groupe-cles.d.mts +15 -0
  80. package/scripts/groupe-cles.mjs +77 -2
  81. package/scripts/init.mjs +9 -2
  82. package/scripts/integration/rejeu.mjs +8 -1
  83. package/scripts/jointure.d.ts +24 -4
  84. package/scripts/langages/c/index.mjs +5 -2
  85. package/scripts/langages/cargo/commandes.mjs +35 -15
  86. package/scripts/langages/cargo/composants.mjs +45 -3
  87. package/scripts/langages/cargo/index.mjs +6 -3
  88. package/scripts/langages/python/commandes.mjs +50 -7
  89. package/scripts/langages/python/index.mjs +5 -2
  90. package/scripts/langages/python/squelette.mjs +2 -1
  91. package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
  92. package/scripts/langages/typescript/index.mjs +16 -14
  93. package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
  94. package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
  95. package/scripts/langages/typescript/turbo-des-paquets.mjs +151 -38
  96. package/scripts/langages/typescript/verdict.mjs +29 -3
  97. package/scripts/langages/typescript/verifier.mjs +28 -3
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
  99. package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
  100. package/scripts/langages.mjs +54 -4
  101. package/scripts/matieres-lues.mjs +1 -1
  102. package/scripts/mesure/base-de-passe.mjs +32 -90
  103. package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
  104. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  105. package/scripts/migrations.mjs +23 -7
  106. package/scripts/nuit.sh +3 -2
  107. package/scripts/paquet.mjs +1 -1
  108. package/scripts/paquets.d.ts +3 -0
  109. package/scripts/paquets.mjs +88 -1
  110. package/scripts/passe-de-la-machine.mjs +109 -36
  111. package/scripts/places-de-la-machine.mjs +81 -29
  112. package/scripts/plafond-de-la-machine.d.mts +2 -5
  113. package/scripts/plafond-de-la-machine.mjs +9 -9
  114. package/scripts/reprise.mjs +42 -13
  115. package/scripts/resultats.mjs +78 -56
  116. package/scripts/retirer-les-copies-finies.mjs +1 -1
  117. package/scripts/seances.mjs +471 -133
  118. package/scripts/services-du-noyau.mjs +9 -1
  119. package/scripts/session-start.sh +22 -7
  120. package/scripts/sortie-de-seance.mjs +70 -0
  121. package/scripts/sortie.mjs +37 -6
  122. package/scripts/sous-commandes.mjs +0 -3
  123. package/scripts/superviseur.mjs +400 -162
  124. package/scripts/tableau.mjs +188 -65
  125. package/scripts/transitions.d.mts +25 -2
  126. package/scripts/transitions.mjs +137 -29
  127. package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
  128. package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
  129. package/skills/developpeur/SKILL.md +38 -15
  130. package/skills/direct/SKILL.md +29 -9
  131. package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
  132. package/skills/domain-modeling/SKILL.md +14 -12
  133. package/skills/explorateur/SKILL.md +32 -8
  134. package/skills/grill/SKILL.md +3 -2
  135. package/skills/pitmaster/SKILL.md +80 -50
  136. package/skills/pitmaster/references/cadre.md +1 -1
  137. package/skills/pitmaster/references/consigne-agent.md +12 -11
  138. package/skills/pitmaster/references/tour.md +6 -5
  139. package/skills/relecteur/SKILL.md +13 -6
  140. package/skills/systematic-debugging/SKILL.md +281 -0
  141. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  142. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  143. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  144. package/skills/systematic-debugging/find-polluter.sh +72 -0
  145. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  146. package/skills/testwriter/SKILL.md +37 -31
  147. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  148. package/scripts/attente-a-l-arret.mjs +0 -114
  149. package/scripts/verrous/commande.mjs +0 -214
  150. package/scripts/verrous/verrou.mjs +0 -311
package/scripts/bilan.mjs CHANGED
@@ -19,7 +19,8 @@
19
19
  // `bilan` of scripts/effets.mjs and read from the Temporal server by the command); the night
20
20
  // the project declares (`grillhouse.plageDeNuit`); the transcript of each supervisor's session
21
21
  // a stop names (`~/.claude/projects/<projet>/<séance>.jsonl`), for the origin and the time of
22
- // each message.
22
+ // each message; the transcript of each session the circuit launched, found the same way, for
23
+ // the usage of its first request, read by the board's reader (scripts/tableau.mjs).
23
24
  // - The steps and the roles are those of scripts/etapes.mjs; a register line's role is read as
24
25
  // the board reads it (`roleDeLAgent`: bare, or scoped `grillhouse:<rôle>`). Only the circuit's
25
26
  // roles count; only the sessions the circuit launched count in the window, the categories, the
@@ -56,6 +57,10 @@
56
57
  // the questions of the plan asked, the plans they changed and the questions left open, the tri
57
58
  // of the discoveries on a line of its own, the tokens, the cache reads and the cost (a session
58
59
  // without a cost counts 0); a session's tokens go to its turns by their time.
60
+ // - `premiersTours` holds one `{ seance, role }` per session the circuit launched, whether the
61
+ // register holds it or not, with the input, cache written and cache read of its first response
62
+ // of a model (`entree`, `cacheEcrit`, `cacheLu`), none of them without a readable one; the text
63
+ // gives their means by role over the sessions that have them.
59
64
  // - It is kept in the main tree, `.claude/worktrees/<ticket>.bilan.json`, and compares itself with
60
65
  // the latest other ticket of the project whose bilan is kept, recomputed by this version from
61
66
  // its sources (`precedent`), or with nothing when none is: no figure kept by an earlier version,
@@ -75,11 +80,19 @@ import os from 'node:os';
75
80
  import path from 'node:path';
76
81
  import { StringDecoder } from 'node:string_decoder';
77
82
  import { REGISTRE } from './adresse-du-registre.mjs';
83
+ import {
84
+ bilansGardes,
85
+ dollars,
86
+ dossier,
87
+ minutes,
88
+ pourcent,
89
+ SUFFIXE,
90
+ } from './bilans-gardes.mjs';
78
91
  import { lireLaConsommation } from './consommation-des-passes.mjs';
79
92
  import { lireLeJournal } from './journal-des-etats.mjs';
80
93
  import { pathToFileURL } from 'node:url';
81
94
  import {
82
- AGENTS_DU_LOT,
95
+ AUTEURS_DE_LOT,
83
96
  etapeDuCircuit,
84
97
  nomDuRole,
85
98
  QUESTIONNEUR,
@@ -87,13 +100,16 @@ import {
87
100
  roleDeLAgent,
88
101
  SUITE,
89
102
  SUPERVISEUR,
103
+ tousLesRolesDe,
90
104
  } from './etapes.mjs';
105
+ import { lireFichier } from './tableau.mjs';
106
+
107
+ export { bilansGardes, enBref } from './bilans-gardes.mjs';
91
108
 
92
109
  // The role of a register line that a step of the circuit writes, and of its results.
93
110
  const CIRCUIT = 'circuit';
94
111
  // The gap allowed between a result and the turn or step it closes.
95
112
  const JEU = 2000;
96
- const MINUTE = 60_000;
97
113
 
98
114
  // The categories, in the order the text lists them, with their names.
99
115
  const CATEGORIES = [
@@ -132,23 +148,42 @@ export function plageDeNuit(racine) {
132
148
  : NUIT;
133
149
  }
134
150
 
135
- // The parts of the interval [d, f] in the night <nuit>, each night from its start hour of a day to
136
- // its end hour, of the next day when it crosses midnight, in local time.
151
+ // The bounds [start, end] (ms) of the night <nuit> that starts the day of <jour>: from its start
152
+ // hour of that day to its end hour, of the next day when it crosses midnight, in local time.
153
+ function laNuitDu(jour, nuit) {
154
+ const a = new Date(jour);
155
+ a.setHours(nuit.debut, 0, 0, 0);
156
+ const b = new Date(a);
157
+ if (nuit.fin < nuit.debut) {
158
+ b.setDate(b.getDate() + 1);
159
+ }
160
+ b.setHours(nuit.fin, 0, 0, 0);
161
+ return [a.getTime(), b.getTime()];
162
+ }
163
+
164
+ // The start (ms) of the night <nuit> that runs at <maintenant>; null by day.
165
+ export function nuitEnCours(maintenant, nuit) {
166
+ const veille = new Date(maintenant);
167
+ veille.setDate(veille.getDate() - 1);
168
+ for (const jour of [veille, maintenant]) {
169
+ const [a, b] = laNuitDu(jour, nuit);
170
+ if (a <= maintenant && maintenant < b) {
171
+ return a;
172
+ }
173
+ }
174
+ return null;
175
+ }
176
+
177
+ // The parts of the interval [d, f] in the nights <nuit>.
137
178
  function nuits([d, f], nuit) {
138
179
  const out = [];
139
180
  const jour = new Date(d);
140
181
  jour.setHours(0, 0, 0, 0);
141
182
  jour.setDate(jour.getDate() - 1);
142
183
  while (jour.getTime() < f) {
143
- const a = new Date(jour);
144
- a.setHours(nuit.debut);
145
- const b = new Date(jour);
146
- if (nuit.fin < nuit.debut) {
147
- b.setDate(b.getDate() + 1);
148
- }
149
- b.setHours(nuit.fin);
150
- const x = Math.max(a.getTime(), d);
151
- const y = Math.min(b.getTime(), f);
184
+ const [a, b] = laNuitDu(jour, nuit);
185
+ const x = Math.max(a, d);
186
+ const y = Math.min(b, f);
152
187
  if (y > x) {
153
188
  out.push([x, y]);
154
189
  }
@@ -157,7 +192,9 @@ function nuits([d, f], nuit) {
157
192
  return out;
158
193
  }
159
194
  // The roles of the circuit, by the steps they work at.
160
- const ROLES = new Set(SUITE.flatMap(e => e.qui));
195
+ const ROLES = new Set(SUITE.flatMap(tousLesRolesDe));
196
+ // The agents who write the code (3), in any circuit.
197
+ const AUTEURS_DU_CODE = tousLesRolesDe(SUITE.find(e => e.numero === '3'));
161
198
 
162
199
  // The results the circuit kept, `{ t, …entrée }`, in their order; an entry without a time counts
163
200
  // nothing.
@@ -276,7 +313,8 @@ function tracesDuJournal(journal, ticket) {
276
313
  // The bilan of <ticket> from the register's lines <lignes> (of its project), the results the
277
314
  // circuit kept <entrees> (`<ticket>.fiches.jsonl`), the circuit's state <etat> (or null), the
278
315
  // project's night <nuit> and the times of the owner's messages in the supervisor's sessions the
279
- // stops name <duResponsable>.
316
+ // stops name <duResponsable>; `premierTour` gives the usage of the first request of the session it
317
+ // is given, or null.
280
318
  export function bilan({
281
319
  ticket,
282
320
  lignes,
@@ -285,6 +323,7 @@ export function bilan({
285
323
  nuit = NUIT,
286
324
  duResponsable = [],
287
325
  journal = [],
326
+ premierTour = () => null,
288
327
  maintenant = Date.now(),
289
328
  }) {
290
329
  // The sessions the circuit launched, by their id.
@@ -364,7 +403,7 @@ export function bilan({
364
403
  }
365
404
  return null;
366
405
  };
367
- // Whether the circuit measured that the developer's session <s> changed no file of the plan.
406
+ // Whether the circuit measured that the session of the author of the code <s> changed no file of the plan.
368
407
  const inchangee = s =>
369
408
  duCircuit.some(
370
409
  e => e.etape === 'developpeur' && e.inchange && e.t >= s.f - JEU && e.t <= s.suivant + JEU
@@ -374,7 +413,7 @@ export function bilan({
374
413
  for (const s of segments.filter(x => x.role !== CIRCUIT)) {
375
414
  if (s.role === QUESTIONNEUR) {
376
415
  s.categorie = 'questionnement';
377
- } else if (s.role === 'developpeur') {
416
+ } else if (AUTEURS_DU_CODE.includes(s.role)) {
378
417
  s.categorie = inchangee(s) ? 'sansEffet' : 'travail';
379
418
  } else if (s.role === 'testwriter') {
380
419
  const p = preuves.find(x => x.d >= s.f - JEU);
@@ -383,8 +422,8 @@ export function bilan({
383
422
  s.categorie = 'travail';
384
423
  }
385
424
  }
386
- // A session that changed the lot: the testwriter's or the developpeur's, that delivered.
387
- const livre = s => AGENTS_DU_LOT.includes(s.role) && s.categorie === 'travail';
425
+ // A session that changed the lot: of an agent who writes it, that delivered.
426
+ const livre = s => AUTEURS_DE_LOT.includes(s.role) && s.categorie === 'travail';
388
427
  for (const s of etapes) {
389
428
  if (s.etape === 'preuve') {
390
429
  s.categorie = parLaPreuve(s) ?? 'automatique';
@@ -497,11 +536,22 @@ export function bilan({
497
536
  c.cache = Math.round(c.cache);
498
537
  }
499
538
 
539
+ // One entry per session the circuit launched, by its id.
540
+ const lesLancements = new Map(
541
+ entrees
542
+ .filter(e => e.role === CIRCUIT && e.lancement)
543
+ .map(e => [e.lancement.seance, roleDeLAgent(e.lancement.role)])
544
+ );
545
+ const premiersTours = [...lesLancements].map(([seance, role]) => ({
546
+ seance,
547
+ role,
548
+ ...premierTour(seance),
549
+ }));
500
550
  const sessions = agents.filter(l => l.role !== CIRCUIT);
501
551
  // The sessions <l> by role, in the order of the steps.
502
552
  const parRoleDe = l => {
503
553
  const out = {};
504
- for (const role of new Set(SUITE.flatMap(e => e.qui))) {
554
+ for (const role of ROLES) {
505
555
  const n = l.filter(x => x.role === role).length;
506
556
  if (n) {
507
557
  out[role] = n;
@@ -595,6 +645,7 @@ export function bilan({
595
645
  arrets,
596
646
  questionnement,
597
647
  tri,
648
+ premiersTours,
598
649
  jetons: somme('jetons'),
599
650
  cache: somme('cache'),
600
651
  cout: somme('cout'),
@@ -612,15 +663,8 @@ function statutDe(etat) {
612
663
  return 'en cours';
613
664
  }
614
665
 
615
- const minutes = ms => Math.round(ms / MINUTE);
616
- const pourcent = (x, sur) => (sur ? Math.round((100 * x) / sur) : 0);
617
- const dollars = x => (x ?? 0).toFixed(2).replace('.', ',');
618
666
  const millions = x => ((x ?? 0) / 1e6).toFixed(2).replace('.', ',');
619
667
 
620
- // The key figures of the bilan <b> in one sentence, as the ticket's card shows them.
621
- export const enBref = b =>
622
- `Bilan : ${minutes(b.mur)} min, ${pourcent(b.perdu, b.mur)} % perdus, ${b.seances.total} séances, ${dollars(b.cout)} $.`;
623
-
624
668
  /**
625
669
  * The passes of <ticket> that consumed clearly more than their part, from the register of the
626
670
  * consumption of the project at <racine> (scripts/consommation-des-passes.mjs): each `{ sorte,
@@ -698,18 +742,38 @@ export function texteDuBilan(b, avant, depassent = []) {
698
742
  .map(([nom, ms]) => `${nom} ${minutes(ms)} min`)
699
743
  .join(', ');
700
744
  const reprise = `Reprise après un rouge : ${minutes(b.reprise.rejoue.ms)} min rejouées${b.reprise.rejoue.ms ? ` (${parEtape(b.reprise.rejoue)})` : ''}, ${minutes(b.reprise.relu.ms)} min relues sans rejouer${b.reprise.relu.ms ? ` (${parEtape(b.reprise.relu)})` : ''}.`;
745
+ const premiers = ligneDesPremiersTours(b.premiersTours ?? []);
701
746
  const parts = depassent.length
702
747
  ? [
703
748
  `Passes au-delà de leur part : ${depassent.length} (${depassent.map(d => `${d.sorte}, ${d.depasse}`).join(' ; ')}).`,
704
749
  ]
705
750
  : [];
706
- return [tete, ...lignes, ...tri, reprise, ...parts, `Arrêts : ${arrets || 'aucun'}.`, base].join(
707
- '\n'
708
- );
751
+ const fin = [...premiers, ...parts, `Arrêts : ${arrets || 'aucun'}.`, base];
752
+ return [tete, ...lignes, ...tri, reprise, ...fin].join('\n');
709
753
  }
710
754
 
711
- const dossier = racine => path.join(racine, '.claude', 'worktrees');
712
- const SUFFIXE = '.bilan.json';
755
+ // The line of the first requests of the sessions <tours> (`premiersTours`): by role, in the order
756
+ // of the steps, the means in whole tokens over the measured sessions and their number; no line
757
+ // without a measured session.
758
+ function ligneDesPremiersTours(tours) {
759
+ const mesures = tours.filter(t => t.entree !== undefined);
760
+ const roles = new Set([...ROLES, ...mesures.map(t => t.role)]);
761
+ const parRole = [...roles].flatMap(role => {
762
+ const l = mesures.filter(t => t.role === role);
763
+ if (!l.length) {
764
+ return [];
765
+ }
766
+ const moyennes = ['entree', 'cacheEcrit', 'cacheLu']
767
+ .map(k => Math.round(l.reduce((m, t) => m + t[k], 0) / l.length))
768
+ .join(', ');
769
+ return [`${nomDuRole(role)} ${moyennes} (${l.length} séance${l.length > 1 ? 's' : ''})`];
770
+ });
771
+ return parRole.length
772
+ ? [
773
+ `Premier tour, moyenne par rôle en jetons (entrée, cache écrit, cache lu) : ${parRole.join(' ; ')}.`,
774
+ ]
775
+ : [];
776
+ }
713
777
 
714
778
  // Keeps the bilan <b> in the main tree <racine>.
715
779
  export function garder(racine, b) {
@@ -719,31 +783,11 @@ export function garder(racine, b) {
719
783
  renameSync(provisoire, f);
720
784
  }
721
785
 
722
- // The bilans kept in the main tree <racine>, by ticket; a file that does not parse is left out.
723
- export function bilansGardes(racine) {
724
- const d = dossier(racine);
725
- const out = {};
726
- if (!existsSync(d)) {
727
- return out;
728
- }
729
- for (const n of readdirSync(d).filter(x => x.endsWith(SUFFIXE))) {
730
- try {
731
- const b = JSON.parse(readFileSync(path.join(d, n), 'utf8'));
732
- if (b?.ticket) {
733
- out[b.ticket] = b;
734
- }
735
- } catch {
736
- // A torn bilan counts nothing.
737
- }
738
- }
739
- return out;
740
- }
741
-
742
786
  // The base of the bilan of <ticket> in the main tree <racine>: the bilan of the latest other ticket
743
787
  // whose bilan is kept, computed again by this version from its sources, as a bench of time remakes
744
788
  // its base, never the figures kept by the version that wrote them; null when its sources give no
745
789
  // bilan any more. The figures a base gives (wall time, loss, sessions, cost) hold whoever waited,
746
- // the owner or the supervisor: the transcripts of its supervisor's sessions are not read.
790
+ // the owner or the supervisor: no transcript is read.
747
791
  export function precedent(racine, ticket) {
748
792
  const avant = Object.values(bilansGardes(racine))
749
793
  .filter(b => b.ticket !== ticket)
@@ -751,7 +795,7 @@ export function precedent(racine, ticket) {
751
795
  if (!avant) {
752
796
  return null;
753
797
  }
754
- const b = calculer(racine, avant.ticket, { responsable: false });
798
+ const b = calculer(racine, avant.ticket, { transcriptions: false });
755
799
  return b.mur > 0 ? b : null;
756
800
  }
757
801
 
@@ -795,15 +839,32 @@ export function messagesDuResponsable(texte) {
795
839
  // whole.
796
840
  const MORCEAU = 1_048_576;
797
841
 
798
- // The times of the owner's messages in the transcript of the supervisor's session <seance>, in any
799
- // project folder of ~/.claude/projects; none when no transcript holds it.
800
- function messagesDeLaSeance(seance) {
842
+ // The transcript of the session <seance>, in any project folder of ~/.claude/projects (the main
843
+ // tree's or a copy's); undefined when none holds it.
844
+ function transcriptionDeLaSeance(seance) {
801
845
  const projets = path.join(os.homedir(), '.claude', 'projects');
802
- const f = existsSync(projets)
846
+ return existsSync(projets)
803
847
  ? readdirSync(projets)
804
848
  .map(d => path.join(projets, d, `${seance}.jsonl`))
805
849
  .find(g => existsSync(g))
806
- : null;
850
+ : undefined;
851
+ }
852
+
853
+ // The usage of the first request of the session <seance>, read in its transcript; null without a
854
+ // transcript that reads, or without a readable usage.
855
+ function premierTourDeLaSeance(seance) {
856
+ const f = transcriptionDeLaSeance(seance);
857
+ try {
858
+ return f ? lireFichier(f).premierTour : null;
859
+ } catch {
860
+ return null;
861
+ }
862
+ }
863
+
864
+ // The times of the owner's messages in the transcript of the supervisor's session <seance>; none
865
+ // when no transcript holds it.
866
+ function messagesDeLaSeance(seance) {
867
+ const f = transcriptionDeLaSeance(seance);
807
868
  if (!f) {
808
869
  return [];
809
870
  }
@@ -828,8 +889,9 @@ function messagesDeLaSeance(seance) {
828
889
 
829
890
  // The bilan of <ticket> computed from the main tree <racine>: its register, the results its
830
891
  // circuit kept, where its circuit ended (<fin>, `{ etape, raison, code }`, null while it runs), and
831
- // the owner's messages in the supervisor's sessions its stops name unless <responsable> is false.
832
- function calculer(racine, ticket, fin, { responsable = true } = {}) {
892
+ // the owner's messages in the supervisor's sessions its stops name and the first request of each
893
+ // session it launched, unless <transcriptions> is false: then no transcript is read.
894
+ function calculer(racine, ticket, fin, { transcriptions = true } = {}) {
833
895
  const lignes = lignesDuProjet(
834
896
  existsSync(REGISTRE) ? readFileSync(REGISTRE, 'utf8') : '',
835
897
  racine
@@ -851,7 +913,8 @@ function calculer(racine, ticket, fin, { responsable = true } = {}) {
851
913
  entrees,
852
914
  etat: fin,
853
915
  nuit: plageDeNuit(racine),
854
- duResponsable: responsable ? [...seances].flatMap(s => messagesDeLaSeance(String(s))) : [],
916
+ duResponsable: transcriptions ? [...seances].flatMap(s => messagesDeLaSeance(String(s))) : [],
917
+ premierTour: transcriptions ? s => premierTourDeLaSeance(String(s)) : undefined,
855
918
  journal: lireLeJournal(racine, { ticket }).lignes,
856
919
  });
857
920
  }
@@ -0,0 +1,37 @@
1
+ // The bilans the circuit keeps in the main tree (`.claude/worktrees/<ticket>.bilan.json`, written
2
+ // by scripts/bilan.mjs) and their key figures: what the board (scripts/tableau.mjs) reads of them.
3
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
4
+ import path from 'node:path';
5
+
6
+ const MINUTE = 60_000;
7
+
8
+ export const dossier = racine => path.join(racine, '.claude', 'worktrees');
9
+ export const SUFFIXE = '.bilan.json';
10
+
11
+ export const minutes = ms => Math.round(ms / MINUTE);
12
+ export const pourcent = (x, sur) => (sur ? Math.round((100 * x) / sur) : 0);
13
+ export const dollars = x => (x ?? 0).toFixed(2).replace('.', ',');
14
+
15
+ // The key figures of the bilan <b> in one sentence, as the ticket's card shows them.
16
+ export const enBref = b =>
17
+ `Bilan : ${minutes(b.mur)} min, ${pourcent(b.perdu, b.mur)} % perdus, ${b.seances.total} séances, ${dollars(b.cout)} $.`;
18
+
19
+ // The bilans kept in the main tree <racine>, by ticket; a file that does not parse is left out.
20
+ export function bilansGardes(racine) {
21
+ const d = dossier(racine);
22
+ const out = {};
23
+ if (!existsSync(d)) {
24
+ return out;
25
+ }
26
+ for (const n of readdirSync(d).filter(x => x.endsWith(SUFFIXE))) {
27
+ try {
28
+ const b = JSON.parse(readFileSync(path.join(d, n), 'utf8'));
29
+ if (b?.ticket) {
30
+ out[b.ticket] = b;
31
+ }
32
+ } catch {
33
+ // A torn bilan counts nothing.
34
+ }
35
+ }
36
+ return out;
37
+ }
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // The judged main guard (packages/grillhouse/docs/architecture/entree.md §3.1 « Garde de main »,
3
3
  // §3.3, §5.1): a push to origin of the branch main carries only a commit whose tree a
4
- // final pass of the circuit, or the verification of a lot of the direct way, judged green
4
+ // final pass of the circuit, or the verification of the rescue way, judged green
5
5
  // (scripts/arbres-juges.mjs), as bors and the merge queues enter only a tree already judged
6
6
  // (`refusSurMain`), in every project. Run by the pre-push hook of the frame with git's arguments
7
7
  // (remote name, remote URL) and, on the standard input, the lines
@@ -40,7 +40,7 @@ export function refusSurMain(remote, refs, { jugee, tete, ecarts }) {
40
40
  .filter(r => r.distante === 'refs/heads/main' && !SUPPRESSION.test(r.sha))
41
41
  .filter(r => !jugee(r.sha))
42
42
  .map(r => {
43
- const base = `⛔ ${r.sha.slice(0, 8)} n'est jugé vert par aucune passe finale ni vérification de lot : main n'avance que sur un arbre jugé. Joue \`npm run verifier\` sur ce commit (lot direct), ou laisse la file du circuit jouer sa passe finale.`;
43
+ const base = `⛔ ${r.sha.slice(0, 8)} n'est jugé vert par aucune passe finale ni vérification de lot : main n'avance que sur un arbre jugé. Joue \`npm run verifier\` sur ce commit (vérification de la voie de secours), ou laisse la file du circuit jouer sa passe finale.`;
44
44
  const fichiers = tete === r.sha && ecarts ? ecarts() : [];
45
45
  return fichiers.length
46
46
  ? `${base} Le dossier diffère du commit par : ${fichiers.join(', ')} (commite-les ou restaure-les).`
@@ -7,12 +7,10 @@
7
7
  //
8
8
  // - `declencherLaCiDeMain`: the start (`gh workflow run`), its delay and its fault kept in a file of
9
9
  // the project; `alerteDeDeclenchement` tells the supervisor of a start GitHub refused.
10
- // - `lireLaCiDeMain`: the latest finished pass of each workflow of the branch (`gh run list`),
11
- // green when every one succeeded, red as soon as one failed (any conclusion but `success`,
12
- // `cancelled` and `skipped`: a cancelled pass is replaced by a later one, the one before it
13
- // decides, and a skipped pass judged nothing, as the flow that alerts on a red one, which skips
14
- // itself on a green), and not
15
- // read, never silence, when gh fails, does not start, answers garbage or no pass at all.
10
+ // - `lireLaCiDeMain`: the latest finished pass of the flow CI (ci.yml) on the branch
11
+ // (`gh run list`), the other flows judging nothing: green when it succeeded, red on any other
12
+ // conclusion (a cancelled or skipped pass judged nothing, the one before it decides), and not
13
+ // read, never silence, when gh fails, does not start, answers garbage or no finished pass.
16
14
  // - `lotsDepuisLeVert`: the lots of the circuit between the last green and the tip, by git alone
17
15
  // (the commits whose subject ends with « (<ticket>) »), no state kept.
18
16
  // - `alerteDeLaCiDeMain` and `ligneDeLaCiDeMain`: what is told to the supervisor and shown on the
@@ -30,11 +28,13 @@ const COURT = 7;
30
28
  const court = sha => String(sha).slice(0, COURT);
31
29
  const uneLigne = t => String(t).replace(/\s+/g, ' ').trim();
32
30
 
31
+ const FLUX_DE_LA_CI = 'ci.yml';
32
+
33
33
  /**
34
34
  * The CI of the branch <branche> (main by default) read with <o.gh> in <o.racine>: `{ etat: 'verte',
35
- * commit, passage }`, `{ etat: 'rouge', flux, passage, commit, vert }` (the workflow, its red pass,
36
- * the commit of that pass and the commit of the last green pass of the same workflow, null when it
37
- * never succeeded) or `{ etat: 'non-lue', raison }`.
35
+ * commit, passage }`, `{ etat: 'rouge', flux, passage, commit, vert }` (the name of the flow, its
36
+ * red pass, the commit of that pass and the commit of its last green pass, null when none is read)
37
+ * or `{ etat: 'non-lue', raison }`.
38
38
  */
39
39
  export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
40
40
  const r = o.gh([
@@ -42,6 +42,8 @@ export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
42
42
  'list',
43
43
  '--branch',
44
44
  branche,
45
+ '--workflow',
46
+ FLUX_DE_LA_CI,
45
47
  '--limit',
46
48
  '100',
47
49
  '--json',
@@ -75,26 +77,21 @@ export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
75
77
  if (finis.length === 0) {
76
78
  return { etat: 'non-lue', raison: `aucun passage fini de la CI sur ${branche}.` };
77
79
  }
78
- const derniers = [...new Set(finis.map(p => p.workflowName))].map(nom =>
79
- finis.find(p => p.workflowName === nom)
80
- );
81
- const rouge = derniers.find(p => p.conclusion !== 'success');
82
- if (rouge) {
83
- const vert = finis.find(p => p.workflowName === rouge.workflowName && p.conclusion === 'success');
80
+ const [dernier] = finis;
81
+ if (dernier.conclusion !== 'success') {
82
+ const vert = finis.find(p => p.conclusion === 'success');
84
83
  return {
85
84
  etat: 'rouge',
86
- flux: rouge.workflowName,
87
- passage: String(rouge.databaseId),
88
- commit: rouge.headSha,
85
+ flux: dernier.workflowName,
86
+ passage: String(dernier.databaseId),
87
+ commit: dernier.headSha,
89
88
  vert: vert?.headSha ?? null,
90
89
  };
91
90
  }
92
- const tete = derniers[0];
93
- return { etat: 'verte', commit: tete.headSha, passage: String(tete.databaseId) };
91
+ return { etat: 'verte', commit: dernier.headSha, passage: String(dernier.databaseId) };
94
92
  }
95
93
 
96
94
  const HEURE = 3_600_000;
97
- const FLUX_DE_LA_CI = 'ci.yml';
98
95
  const EN_ATTENTE = state => state !== 'completed';
99
96
 
100
97
  const etatDuDeclenchement = racine =>