@roomi-fields/grillhouse 0.51.0 → 0.53.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 (149) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/vitest.config.cjs +45 -0
  5. package/charte/plan.md +47 -0
  6. package/charte/preuve.md +39 -0
  7. package/charte/superviseur.md +60 -0
  8. package/charte/tests.md +38 -0
  9. package/charte.md +23 -178
  10. package/dist/temporal/circuit/appel.d.ts +2 -0
  11. package/dist/temporal/circuit/appel.js +24 -2
  12. package/dist/temporal/circuit/appel.js.map +1 -1
  13. package/dist/temporal/circuit/client.d.ts +15 -7
  14. package/dist/temporal/circuit/client.js +42 -11
  15. package/dist/temporal/circuit/client.js.map +1 -1
  16. package/dist/temporal/circuit/commande.js +17 -6
  17. package/dist/temporal/circuit/commande.js.map +1 -1
  18. package/dist/temporal/circuit/contrat.d.ts +9 -0
  19. package/dist/temporal/circuit/contrat.js +6 -0
  20. package/dist/temporal/circuit/contrat.js.map +1 -1
  21. package/dist/temporal/circuit/deroule.js +25 -4
  22. package/dist/temporal/circuit/deroule.js.map +1 -1
  23. package/dist/temporal/client.d.ts +35 -1
  24. package/dist/temporal/client.js +144 -1
  25. package/dist/temporal/client.js.map +1 -1
  26. package/dist/temporal/commande.js +31 -13
  27. package/dist/temporal/commande.js.map +1 -1
  28. package/dist/temporal/etat.d.ts +3 -1
  29. package/dist/temporal/etat.js +31 -17
  30. package/dist/temporal/etat.js.map +1 -1
  31. package/dist/temporal/file/activites.js +1 -1
  32. package/dist/temporal/file/activites.js.map +1 -1
  33. package/dist/temporal/file/contrat.d.ts +4 -5
  34. package/dist/temporal/file/contrat.js +2 -2
  35. package/dist/temporal/file/contrat.js.map +1 -1
  36. package/dist/temporal/file/deroule.js +7 -5
  37. package/dist/temporal/file/deroule.js.map +1 -1
  38. package/dist/temporal/installation.d.ts +103 -53
  39. package/dist/temporal/installation.js +842 -237
  40. package/dist/temporal/installation.js.map +1 -1
  41. package/dist/temporal/nuits/deroule.js +3 -1
  42. package/dist/temporal/nuits/deroule.js.map +1 -1
  43. package/dist/temporal/places/deroule.js +2 -1
  44. package/dist/temporal/places/deroule.js.map +1 -1
  45. package/dist/temporal/sonde/deroule.js +2 -1
  46. package/dist/temporal/sonde/deroule.js.map +1 -1
  47. package/dist/temporal/tickets/deroule.js +4 -3
  48. package/dist/temporal/tickets/deroule.js.map +1 -1
  49. package/dist/temporal/travailleur.d.ts +7 -1
  50. package/dist/temporal/travailleur.js +49 -25
  51. package/dist/temporal/travailleur.js.map +1 -1
  52. package/docs/INTERFACE.md +20 -14
  53. package/docs/architecture/circuit.md +19 -16
  54. package/docs/architecture/entree.md +8 -9
  55. package/docs/architecture/greffon.md +54 -20
  56. package/docs/architecture/installation.md +99 -60
  57. package/docs/architecture/machine.md +31 -4
  58. package/docs/architecture/tests.md +22 -8
  59. package/docs/lexique.md +12 -3
  60. package/hooks/hooks.json +10 -10
  61. package/hooks/register.tsx +84 -2
  62. package/package.json +4 -2
  63. package/scripts/activites.mjs +25 -9
  64. package/scripts/aiguillage.mjs +1 -1
  65. package/scripts/attente-au-tour.mjs +2 -3
  66. package/scripts/bilan.mjs +116 -56
  67. package/scripts/bilans-gardes.mjs +37 -0
  68. package/scripts/circuit.mjs +256 -42
  69. package/scripts/circuits-du-serveur.mjs +3 -2
  70. package/scripts/circuits-tenus.d.mts +7 -0
  71. package/scripts/circuits-tenus.mjs +17 -0
  72. package/scripts/copie-de-montee.mjs +354 -0
  73. package/scripts/copies-du-depot.d.mts +13 -0
  74. package/scripts/copies-du-depot.mjs +66 -0
  75. package/scripts/copies-finies.mjs +6 -40
  76. package/scripts/crochets.mjs +16 -2
  77. package/scripts/direct.mjs +2 -2
  78. package/scripts/droits.mjs +117 -38
  79. package/scripts/engendres.mjs +5 -3
  80. package/scripts/entree-de-seance.mjs +35 -0
  81. package/scripts/enveloppe/enveloppe.mjs +23 -16
  82. package/scripts/enveloppe/lancer.sh +32 -22
  83. package/scripts/enveloppe/travail-de-la-copie.mjs +154 -0
  84. package/scripts/etapes.mjs +11 -3
  85. package/scripts/faits-du-circuit.mjs +12 -5
  86. package/scripts/file-des-tickets.d.mts +13 -2
  87. package/scripts/file-des-tickets.mjs +44 -12
  88. package/scripts/greffons.mjs +42 -27
  89. package/scripts/grillhouse-maj.mjs +105 -85
  90. package/scripts/init.mjs +1 -1
  91. package/scripts/integration/file.mjs +5 -2
  92. package/scripts/integration/integrer.mjs +14 -4
  93. package/scripts/jointure.d.ts +18 -1
  94. package/scripts/langages/c/commandes.mjs +17 -7
  95. package/scripts/langages/cargo/commandes.mjs +87 -34
  96. package/scripts/langages/cargo/index.mjs +6 -3
  97. package/scripts/langages/cargo/sccache.mjs +15 -12
  98. package/scripts/langages/python/commandes.mjs +68 -15
  99. package/scripts/langages/python/squelette.mjs +4 -3
  100. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  101. package/scripts/langages/typescript/index.mjs +14 -12
  102. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +299 -0
  103. package/scripts/langages/typescript/squelette.mjs +20 -17
  104. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  105. package/scripts/langages/typescript/turbo-des-paquets.mjs +76 -39
  106. package/scripts/langages/typescript/verifier.mjs +27 -2
  107. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  108. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  109. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  110. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  111. package/scripts/mesure/pression.mjs +5 -3
  112. package/scripts/migrations/serveurs-de-l-index.mjs +1 -1
  113. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  114. package/scripts/migrations.mjs +2 -0
  115. package/scripts/montee.mjs +524 -0
  116. package/scripts/nuit.sh +3 -2
  117. package/scripts/outil.mjs +5 -3
  118. package/scripts/paquet-npm.mjs +22 -0
  119. package/scripts/paquet.mjs +5 -5
  120. package/scripts/pre-compact.mjs +25 -0
  121. package/scripts/reponses-du-circuit.d.mts +17 -2
  122. package/scripts/reponses-du-circuit.mjs +78 -20
  123. package/scripts/resultats.mjs +42 -14
  124. package/scripts/retirer-les-copies-finies.mjs +4 -7
  125. package/scripts/seances.mjs +81 -29
  126. package/scripts/services-du-noyau.mjs +7 -2
  127. package/scripts/session-start.sh +19 -10
  128. package/scripts/sortie-de-seance.mjs +70 -0
  129. package/scripts/sortie.mjs +4 -7
  130. package/scripts/sous-commandes.mjs +1 -1
  131. package/scripts/superviseur.mjs +417 -159
  132. package/scripts/tableau.mjs +249 -152
  133. package/scripts/ticket-du-circuit.mjs +22 -0
  134. package/scripts/transitions.d.mts +6 -9
  135. package/scripts/transitions.mjs +123 -36
  136. package/scripts/verrou-de-fichier.d.mts +11 -0
  137. package/skills/direct/SKILL.md +21 -11
  138. package/skills/explorateur/SKILL.md +8 -3
  139. package/skills/grill/SKILL.md +11 -8
  140. package/skills/grill/references/paquets.md +4 -4
  141. package/skills/pitmaster/SKILL.md +99 -53
  142. package/skills/pitmaster/references/cadre.md +1 -1
  143. package/skills/pitmaster/references/consigne-agent.md +1 -1
  144. package/skills/pitmaster/references/tour.md +6 -5
  145. package/skills/relecteur/SKILL.md +9 -2
  146. package/skills/testwriter/SKILL.md +3 -3
  147. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  148. package/cadre/templates/projet/vitest.config.ts +0 -44
  149. package/scripts/attente-a-l-arret.mjs +0 -114
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,6 +80,14 @@ 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';
@@ -89,12 +102,14 @@ import {
89
102
  SUPERVISEUR,
90
103
  tousLesRolesDe,
91
104
  } from './etapes.mjs';
105
+ import { lireFichier } from './tableau.mjs';
106
+
107
+ export { bilansGardes, enBref } from './bilans-gardes.mjs';
92
108
 
93
109
  // The role of a register line that a step of the circuit writes, and of its results.
94
110
  const CIRCUIT = 'circuit';
95
111
  // The gap allowed between a result and the turn or step it closes.
96
112
  const JEU = 2000;
97
- const MINUTE = 60_000;
98
113
 
99
114
  // The categories, in the order the text lists them, with their names.
100
115
  const CATEGORIES = [
@@ -133,23 +148,42 @@ export function plageDeNuit(racine) {
133
148
  : NUIT;
134
149
  }
135
150
 
136
- // The parts of the interval [d, f] in the night <nuit>, each night from its start hour of a day to
137
- // 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>.
138
178
  function nuits([d, f], nuit) {
139
179
  const out = [];
140
180
  const jour = new Date(d);
141
181
  jour.setHours(0, 0, 0, 0);
142
182
  jour.setDate(jour.getDate() - 1);
143
183
  while (jour.getTime() < f) {
144
- const a = new Date(jour);
145
- a.setHours(nuit.debut);
146
- const b = new Date(jour);
147
- if (nuit.fin < nuit.debut) {
148
- b.setDate(b.getDate() + 1);
149
- }
150
- b.setHours(nuit.fin);
151
- const x = Math.max(a.getTime(), d);
152
- 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);
153
187
  if (y > x) {
154
188
  out.push([x, y]);
155
189
  }
@@ -279,7 +313,8 @@ function tracesDuJournal(journal, ticket) {
279
313
  // The bilan of <ticket> from the register's lines <lignes> (of its project), the results the
280
314
  // circuit kept <entrees> (`<ticket>.fiches.jsonl`), the circuit's state <etat> (or null), the
281
315
  // project's night <nuit> and the times of the owner's messages in the supervisor's sessions the
282
- // stops name <duResponsable>.
316
+ // stops name <duResponsable>; `premierTour` gives the usage of the first request of the session it
317
+ // is given, or null.
283
318
  export function bilan({
284
319
  ticket,
285
320
  lignes,
@@ -288,6 +323,7 @@ export function bilan({
288
323
  nuit = NUIT,
289
324
  duResponsable = [],
290
325
  journal = [],
326
+ premierTour = () => null,
291
327
  maintenant = Date.now(),
292
328
  }) {
293
329
  // The sessions the circuit launched, by their id.
@@ -500,6 +536,17 @@ export function bilan({
500
536
  c.cache = Math.round(c.cache);
501
537
  }
502
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
+ }));
503
550
  const sessions = agents.filter(l => l.role !== CIRCUIT);
504
551
  // The sessions <l> by role, in the order of the steps.
505
552
  const parRoleDe = l => {
@@ -598,6 +645,7 @@ export function bilan({
598
645
  arrets,
599
646
  questionnement,
600
647
  tri,
648
+ premiersTours,
601
649
  jetons: somme('jetons'),
602
650
  cache: somme('cache'),
603
651
  cout: somme('cout'),
@@ -615,15 +663,8 @@ function statutDe(etat) {
615
663
  return 'en cours';
616
664
  }
617
665
 
618
- const minutes = ms => Math.round(ms / MINUTE);
619
- const pourcent = (x, sur) => (sur ? Math.round((100 * x) / sur) : 0);
620
- const dollars = x => (x ?? 0).toFixed(2).replace('.', ',');
621
666
  const millions = x => ((x ?? 0) / 1e6).toFixed(2).replace('.', ',');
622
667
 
623
- // The key figures of the bilan <b> in one sentence, as the ticket's card shows them.
624
- export const enBref = b =>
625
- `Bilan : ${minutes(b.mur)} min, ${pourcent(b.perdu, b.mur)} % perdus, ${b.seances.total} séances, ${dollars(b.cout)} $.`;
626
-
627
668
  /**
628
669
  * The passes of <ticket> that consumed clearly more than their part, from the register of the
629
670
  * consumption of the project at <racine> (scripts/consommation-des-passes.mjs): each `{ sorte,
@@ -701,18 +742,38 @@ export function texteDuBilan(b, avant, depassent = []) {
701
742
  .map(([nom, ms]) => `${nom} ${minutes(ms)} min`)
702
743
  .join(', ');
703
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 ?? []);
704
746
  const parts = depassent.length
705
747
  ? [
706
748
  `Passes au-delà de leur part : ${depassent.length} (${depassent.map(d => `${d.sorte}, ${d.depasse}`).join(' ; ')}).`,
707
749
  ]
708
750
  : [];
709
- return [tete, ...lignes, ...tri, reprise, ...parts, `Arrêts : ${arrets || 'aucun'}.`, base].join(
710
- '\n'
711
- );
751
+ const fin = [...premiers, ...parts, `Arrêts : ${arrets || 'aucun'}.`, base];
752
+ return [tete, ...lignes, ...tri, reprise, ...fin].join('\n');
712
753
  }
713
754
 
714
- const dossier = racine => path.join(racine, '.claude', 'worktrees');
715
- 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
+ }
716
777
 
717
778
  // Keeps the bilan <b> in the main tree <racine>.
718
779
  export function garder(racine, b) {
@@ -722,31 +783,11 @@ export function garder(racine, b) {
722
783
  renameSync(provisoire, f);
723
784
  }
724
785
 
725
- // The bilans kept in the main tree <racine>, by ticket; a file that does not parse is left out.
726
- export function bilansGardes(racine) {
727
- const d = dossier(racine);
728
- const out = {};
729
- if (!existsSync(d)) {
730
- return out;
731
- }
732
- for (const n of readdirSync(d).filter(x => x.endsWith(SUFFIXE))) {
733
- try {
734
- const b = JSON.parse(readFileSync(path.join(d, n), 'utf8'));
735
- if (b?.ticket) {
736
- out[b.ticket] = b;
737
- }
738
- } catch {
739
- // A torn bilan counts nothing.
740
- }
741
- }
742
- return out;
743
- }
744
-
745
786
  // The base of the bilan of <ticket> in the main tree <racine>: the bilan of the latest other ticket
746
787
  // whose bilan is kept, computed again by this version from its sources, as a bench of time remakes
747
788
  // its base, never the figures kept by the version that wrote them; null when its sources give no
748
789
  // bilan any more. The figures a base gives (wall time, loss, sessions, cost) hold whoever waited,
749
- // 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.
750
791
  export function precedent(racine, ticket) {
751
792
  const avant = Object.values(bilansGardes(racine))
752
793
  .filter(b => b.ticket !== ticket)
@@ -754,7 +795,7 @@ export function precedent(racine, ticket) {
754
795
  if (!avant) {
755
796
  return null;
756
797
  }
757
- const b = calculer(racine, avant.ticket, { responsable: false });
798
+ const b = calculer(racine, avant.ticket, { transcriptions: false });
758
799
  return b.mur > 0 ? b : null;
759
800
  }
760
801
 
@@ -798,15 +839,32 @@ export function messagesDuResponsable(texte) {
798
839
  // whole.
799
840
  const MORCEAU = 1_048_576;
800
841
 
801
- // The times of the owner's messages in the transcript of the supervisor's session <seance>, in any
802
- // project folder of ~/.claude/projects; none when no transcript holds it.
803
- 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) {
804
845
  const projets = path.join(os.homedir(), '.claude', 'projects');
805
- const f = existsSync(projets)
846
+ return existsSync(projets)
806
847
  ? readdirSync(projets)
807
848
  .map(d => path.join(projets, d, `${seance}.jsonl`))
808
849
  .find(g => existsSync(g))
809
- : 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);
810
868
  if (!f) {
811
869
  return [];
812
870
  }
@@ -831,8 +889,9 @@ function messagesDeLaSeance(seance) {
831
889
 
832
890
  // The bilan of <ticket> computed from the main tree <racine>: its register, the results its
833
891
  // circuit kept, where its circuit ended (<fin>, `{ etape, raison, code }`, null while it runs), and
834
- // the owner's messages in the supervisor's sessions its stops name unless <responsable> is false.
835
- 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 } = {}) {
836
895
  const lignes = lignesDuProjet(
837
896
  existsSync(REGISTRE) ? readFileSync(REGISTRE, 'utf8') : '',
838
897
  racine
@@ -854,7 +913,8 @@ function calculer(racine, ticket, fin, { responsable = true } = {}) {
854
913
  entrees,
855
914
  etat: fin,
856
915
  nuit: plageDeNuit(racine),
857
- 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,
858
918
  journal: lireLeJournal(racine, { ticket }).lignes,
859
919
  });
860
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
+ }