@roomi-fields/grillhouse 0.31.0 → 0.33.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 +40 -0
  3. package/bin/grillhouse.mjs +6 -4
  4. package/cadre/templates/projet/.github/workflows/ci.yml +136 -16
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +111 -0
  6. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +4 -4
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +8 -5
  9. package/dist/temporal/circuit/contrat.d.ts +15 -0
  10. package/dist/temporal/circuit/deroule.js +37 -14
  11. package/dist/temporal/circuit/deroule.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -0
  13. package/dist/temporal/deroules.js +3 -1
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -0
  16. package/dist/temporal/file/activites.js +5 -2
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +50 -33
  19. package/dist/temporal/file/contrat.js +2 -2
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +3 -1
  22. package/dist/temporal/file/deroule.js +128 -26
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +3 -2
  25. package/dist/temporal/installation.js +7 -4
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +10 -0
  28. package/dist/temporal/nuits/activites.js +114 -0
  29. package/dist/temporal/nuits/activites.js.map +1 -0
  30. package/dist/temporal/nuits/appel.d.ts +23 -0
  31. package/dist/temporal/nuits/appel.js +40 -0
  32. package/dist/temporal/nuits/appel.js.map +1 -0
  33. package/dist/temporal/nuits/choix.d.ts +14 -0
  34. package/dist/temporal/nuits/choix.js +119 -0
  35. package/dist/temporal/nuits/choix.js.map +1 -0
  36. package/dist/temporal/nuits/client.d.ts +28 -0
  37. package/dist/temporal/nuits/client.js +83 -0
  38. package/dist/temporal/nuits/client.js.map +1 -0
  39. package/dist/temporal/nuits/commande.d.ts +2 -0
  40. package/dist/temporal/nuits/commande.js +107 -0
  41. package/dist/temporal/nuits/commande.js.map +1 -0
  42. package/dist/temporal/nuits/contrat.d.ts +98 -0
  43. package/dist/temporal/nuits/contrat.js +30 -0
  44. package/dist/temporal/nuits/contrat.js.map +1 -0
  45. package/dist/temporal/nuits/deroule.d.ts +5 -0
  46. package/dist/temporal/nuits/deroule.js +100 -0
  47. package/dist/temporal/nuits/deroule.js.map +1 -0
  48. package/dist/temporal/tickets/activites.d.ts +1 -0
  49. package/dist/temporal/tickets/activites.js +5 -0
  50. package/dist/temporal/tickets/activites.js.map +1 -1
  51. package/dist/temporal/tickets/contrat.d.ts +10 -0
  52. package/dist/temporal/tickets/deroule.js +8 -1
  53. package/dist/temporal/tickets/deroule.js.map +1 -1
  54. package/dist/temporal/travailleur.js +4 -1
  55. package/dist/temporal/travailleur.js.map +1 -1
  56. package/docs/ARCHITECTURE.md +257 -54
  57. package/docs/CADRE.md +41 -1
  58. package/docs/INTERFACE.md +54 -7
  59. package/hooks/hooks.json +4 -0
  60. package/hooks/register.tsx +11 -3
  61. package/package.json +4 -1
  62. package/scripts/abi-des-dependances.mjs +105 -0
  63. package/scripts/activites.mjs +99 -48
  64. package/scripts/aiguillage.mjs +3 -0
  65. package/scripts/attente-au-tour.mjs +99 -0
  66. package/scripts/avancement.mjs +8 -18
  67. package/scripts/base-des-workflows.mjs +57 -0
  68. package/scripts/ci-des-branches.mjs +91 -0
  69. package/scripts/circuit.mjs +99 -5
  70. package/scripts/composants-affectes.mjs +24 -7
  71. package/scripts/composition-des-langages.mjs +3 -0
  72. package/scripts/copies-finies.mjs +8 -1
  73. package/scripts/crochets.mjs +4 -0
  74. package/scripts/dernier-vert.mjs +30 -4
  75. package/scripts/effets.mjs +9 -0
  76. package/scripts/enveloppe/enveloppe.mjs +3 -1
  77. package/scripts/enveloppe/lancer.sh +1 -1
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
  79. package/scripts/etapes.mjs +19 -2
  80. package/scripts/faits-du-circuit.mjs +43 -20
  81. package/scripts/fichier-du-poste.mjs +87 -0
  82. package/scripts/grillhouse-maj.mjs +15 -1
  83. package/scripts/integration/file.mjs +215 -275
  84. package/scripts/integration/integrer.mjs +82 -41
  85. package/scripts/integration/rejeu.mjs +13 -64
  86. package/scripts/jointure.d.ts +30 -2
  87. package/scripts/journal-des-etats.d.mts +41 -0
  88. package/scripts/journal-des-etats.mjs +273 -0
  89. package/scripts/journal.mjs +119 -0
  90. package/scripts/langages/cargo/commandes.mjs +81 -19
  91. package/scripts/langages/cargo/exemples.mjs +2 -2
  92. package/scripts/langages/cargo/index.mjs +14 -5
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
  94. package/scripts/langages/python/commandes.mjs +11 -7
  95. package/scripts/langages/python/exemples.mjs +1 -1
  96. package/scripts/langages/python/index.mjs +11 -2
  97. package/scripts/langages/python/tailles-des-tests.mjs +19 -11
  98. package/scripts/langages/typescript/code-mort.mjs +41 -24
  99. package/scripts/langages/typescript/consommateurs.mjs +28 -17
  100. package/scripts/langages/typescript/exemples.mjs +2 -0
  101. package/scripts/langages/typescript/frontieres.mjs +46 -0
  102. package/scripts/langages/typescript/index.mjs +24 -3
  103. package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
  104. package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
  105. package/scripts/langages/typescript/resumes.mjs +17 -7
  106. package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
  107. package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
  108. package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
  109. package/scripts/langages/typescript/tranches.mjs +273 -0
  110. package/scripts/langages/typescript/verifier.mjs +154 -23
  111. package/scripts/langages/typescript/vitest-config/base.mjs +3 -0
  112. package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
  113. package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
  114. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
  115. package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
  116. package/scripts/langages.d.mts +20 -0
  117. package/scripts/lint-des-scripts.mjs +23 -6
  118. package/scripts/matiere-de-test.d.ts +11 -0
  119. package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
  120. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
  121. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
  122. package/scripts/migrations/0.33.0-node-26.mjs +58 -0
  123. package/scripts/migrations.mjs +8 -0
  124. package/scripts/newday.mjs +18 -0
  125. package/scripts/nuit.sh +40 -13
  126. package/scripts/places-de-la-machine.mjs +6 -0
  127. package/scripts/registre.d.mts +90 -0
  128. package/scripts/registre.mjs +28 -3
  129. package/scripts/reprise.mjs +12 -8
  130. package/scripts/services-du-noyau.mjs +4 -0
  131. package/scripts/session-start.sh +28 -32
  132. package/scripts/sous-commandes.mjs +31 -10
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +222 -17
  135. package/scripts/taches-du-graphe.mjs +39 -6
  136. package/scripts/ticket-du-circuit.mjs +37 -7
  137. package/scripts/transitions.mjs +60 -8
  138. package/scripts/verrou-de-machine.mjs +1 -2
  139. package/scripts/workflows-du-cadre.mjs +75 -0
  140. package/skills/developpeur/SKILL.md +1 -1
  141. package/skills/explorateur/SKILL.md +1 -1
  142. package/skills/grill/SKILL.md +10 -62
  143. package/skills/grill/references/paquets.md +60 -0
  144. package/skills/pitmaster/SKILL.md +21 -31
  145. package/skills/questionneur/SKILL.md +1 -1
  146. package/skills/relecteur/SKILL.md +1 -1
  147. package/skills/testwriter/SKILL.md +7 -1
  148. package/skills/release/SKILL.md +0 -134
  149. package/skills/release/scripts/update-version.cjs +0 -92
@@ -57,7 +57,14 @@ import { pathToFileURL } from 'node:url';
57
57
  import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
58
58
  import { vivant } from './mesure/base-de-passe.mjs';
59
59
  import { circuitsDuServeur, ServeurMuet } from './circuits-du-serveur.mjs';
60
- import { attendLeSuperviseur } from './tableau.mjs';
60
+ import {
61
+ attendLeSuperviseur,
62
+ cleDe,
63
+ lireLesRemontees,
64
+ RAPPEL_PAR_DEFAUT,
65
+ remonteesDe,
66
+ verrouDeLAttente,
67
+ } from './tableau.mjs';
61
68
  import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
62
69
 
63
70
  const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
@@ -94,7 +101,7 @@ function seance(depart = process.ppid) {
94
101
 
95
102
  // Of the tickets <ids> of the repository at <racine>, those that bd gives closed; none when bd does
96
103
  // not read them.
97
- function ticketsFermes(racine, ids) {
104
+ export function ticketsFermes(racine, ids) {
98
105
  const r = spawnSync('bd', ['show', ...ids, '--json'], {
99
106
  cwd: racine,
100
107
  encoding: 'utf8',
@@ -112,52 +119,77 @@ function ticketsFermes(racine, ids) {
112
119
  }
113
120
  }
114
121
 
115
- // One stop of the circuit <c>: its ticket, the run of its workflow (`run`), the rank of its
116
- // question in that run (`numero`) and its stop, so that the next stop of a circuit resumed is
117
- // another one.
118
- const cleDe = c => [c.ticket, c.run, c.numero, c.arret ?? 'interrompu'].join(':');
119
-
120
122
  // The step where the circuit <c> stands, in words (« 3.1 Contrôles »), else its state's.
121
123
  const ou = c => {
122
124
  const e = etapeDuCircuit({ ...c, raison: c.arret });
123
125
  return e ? libelle(e) : c.etape;
124
126
  };
125
127
 
126
- // The file of the stops gone up to the session of supervision of the repository at <racine>, and
127
- // the lock of its one wait, beside the states of the circuits.
128
+ // The file of the stops gone up to the session of supervision (`remonteesDe`) and the lock of its
129
+ // one wait (`verrouDeLAttente`) are beside the states of the circuits (scripts/tableau.mjs reads
130
+ // both: its alerts).
128
131
  const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
129
- const remonteesDe = racine => path.join(etatsDe(racine), 'questions-remontees.json');
130
- const verrouDeLAttente = racine => path.join(etatsDe(racine), 'attente-des-questions.lock');
132
+ export { verrouDeLAttente };
131
133
 
132
- // The stops gone up to the session of supervision of the repository at <racine>: their keys.
133
- function lireRemontees(racine) {
134
- try {
135
- const lu = JSON.parse(readFileSync(remonteesDe(racine), 'utf8'));
136
- return new Set(Array.isArray(lu?.remontees) ? lu.remontees.map(String) : []);
137
- } catch {
138
- return new Set();
139
- }
140
- }
141
-
142
- // The stops gone up of the repository at <racine>, its circuits <circuits> read, under the lock
143
- // of their file: <faire>(<avant>, those gone up before) returns the keys it makes go up (`cles`)
144
- // and what it gives (`rendu`); the file is written whole with them and those of <avant> whose stop
145
- // still stands, its circuit waiting for the supervisor. A question answered so leaves them. Its
146
- // `rendu`.
147
- function remonter(racine, circuits, faire) {
134
+ // The stops gone up of the repository at <racine>, its circuits <circuits> read, under the lock of
135
+ // their file, at <maintenant> ms. Each stop that waits for the supervisor and never went up, or
136
+ // whose last presentation is <rappelMs> ms old or more (<toutes>: every one), is given, its ticket
137
+ // <fermes> gives closed left out (bd is asked of those alone); a stop given is presented now, and
138
+ // one that goes up has its `depuis` set now. The file is written whole with the stops that still
139
+ // stand, their circuit waiting for the supervisor: a question answered so leaves it. The `rendu`
140
+ // is the questions given, each marked `representee` when it comes back.
141
+ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = false }) {
148
142
  const f = remonteesDe(racine);
149
143
  mkdirSync(path.dirname(f), { recursive: true });
150
144
  const verrou = `${f}.verrou`;
151
145
  // Held for one reading of the circuits: older than that, abandoned.
152
146
  prendreVerrou(verrou, { attendre: true, perime: 30_000 });
153
147
  try {
154
- const avant = lireRemontees(racine);
155
- const { cles, rendu } = faire(avant);
156
- const debout = new Set(circuits.filter(attendLeSuperviseur).map(cleDe));
157
- const apres = new Set([...cles, ...[...avant].filter(c => debout.has(c))]);
158
- if (avant.size !== apres.size || [...apres].some(c => !avant.has(c))) {
148
+ const avant = new Map(lireLesRemontees(racine, maintenant).map(r => [r.cle, r]));
149
+ const debout = questionsEnAttente(racine, circuits, { fermes: aucunFerme });
150
+ const aRendre = debout.filter(q => {
151
+ const r = avant.get(q.cle);
152
+ return toutes || !r || maintenant - r.presentee >= rappelMs;
153
+ });
154
+ const fermesDe = aRendre.length
155
+ ? fermes(
156
+ racine,
157
+ aRendre.map(q => q.ticket)
158
+ )
159
+ : new Set();
160
+ const rendu = aRendre
161
+ .filter(q => !fermesDe.has(q.ticket))
162
+ .map(q => (avant.has(q.cle) && !toutes ? { ...q, representee: true } : q));
163
+ const presentes = new Set(aRendre.map(q => q.cle));
164
+ const enTexte = liste =>
165
+ `${JSON.stringify(
166
+ {
167
+ remontees: liste
168
+ .map(r => ({ cle: r.cle, depuis: r.depuis, presentee: r.presentee }))
169
+ .sort((a, b) => a.cle.localeCompare(b.cle, 'en')),
170
+ },
171
+ null,
172
+ 2
173
+ )}\n`;
174
+ const ecrit = enTexte(
175
+ debout.map(q => {
176
+ const r = avant.get(q.cle);
177
+ return {
178
+ cle: q.cle,
179
+ depuis: r?.depuis ?? maintenant,
180
+ presentee: presentes.has(q.cle) ? maintenant : r.presentee,
181
+ };
182
+ })
183
+ );
184
+ let enFichier = '';
185
+ try {
186
+ enFichier = readFileSync(f, 'utf8');
187
+ } catch {
188
+ // no file yet
189
+ }
190
+ if (ecrit !== enFichier && !(debout.length === 0 && avant.size === 0)) {
159
191
  const provisoire = `${f}.${process.pid}`;
160
- writeFileSync(provisoire, `${JSON.stringify({ remontees: [...apres].sort() }, null, 2)}\n`);
192
+ writeFileSync(provisoire, ecrit);
161
193
  renameSync(provisoire, f);
162
194
  }
163
195
  return rendu;
@@ -225,39 +257,33 @@ export function questionsEnAttente(
225
257
  // No ticket closed: the questions read without asking bd.
226
258
  const aucunFerme = () => new Set();
227
259
 
228
- // The questions of the repository at <racine>, its circuits <circuits> read, that never went up
229
- // (`questionsEnAttente`): returned, and now gone up; a question answered (its circuit runs again,
230
- // or ended) leaves those gone up, and one whose ticket <fermes> gives closed goes up without a
231
- // word. bd is asked of the new ones alone.
232
- function releverLesNeuves(racine, circuits, fermes) {
233
- return remonter(racine, circuits, avant => ({
234
- cles: questionsEnAttente(racine, circuits, { fermes: aucunFerme }).map(q => q.cle),
235
- rendu: questionsEnAttente(racine, circuits, { fermes, sauf: avant }),
236
- }));
237
- }
238
-
239
260
  /**
240
261
  * The wait of the session of supervision of the repository at <racine> (`npx grillhouse
241
- * superviseur --attendre`, which the supervisor keeps in the background, as a review requested on
242
- * GitHub or Gerrit's attention set calls the one a change waits for): it ends only when a question
243
- * that never went up waits for the supervisor (`questionsEnAttente`), whatever launched its
244
- * circuit, and gives those questions, now gone up; a question already gone up (by a wait, or named
245
- * at the opening) never ends it again, a question answered leaves those gone up, and the normal end
246
- * of a circuit is never one. It reads the circuits every <pas> ms by <circuitsDe> (one call to the
247
- * Temporal server, scripts/circuits-du-serveur.mjs, by default), as the UI of Temporal refreshes
248
- * its list; a reading that fails (the server down) is tried again at the next step, the questions
249
- * gone up kept. The session spends nothing while it waits. One wait at a time per repository: a
250
- * second one is refused while the first runs. Its <signal> ends it with no question.
251
- * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} options
252
- * @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string }[]>}
262
+ * superviseur --attendre`, which the supervisor reads as a stream, as a worker of Temporal keeps its
263
+ * task queue): an asynchronous iterator that gives one batch of questions at a time and goes on
264
+ * listening by itself, with no relaunch. It gives a question that waits for the supervisor
265
+ * (`questionsEnAttente`), whatever launched its circuit, once it never went up, and again, marked
266
+ * `representee`, every <rappel> minutes (5 by default) while its circuit stands on the same stop,
267
+ * as SQS gives a message not acknowledged again after its visibility timeout; a question
268
+ * answered (its circuit left the stop) leaves those gone up and is not given again, and the normal
269
+ * end of a circuit is never one. A stop whose key changes is a new question, given at once. The
270
+ * times are those of <maintenant> (`Date.now` by default). It reads the circuits every <pas> ms by
271
+ * <circuitsDe> (one call to the Temporal server, scripts/circuits-du-serveur.mjs, by default), as
272
+ * the UI of Temporal refreshes its list; a reading that fails (the server down) is tried again at
273
+ * the next step, the questions gone up kept. One wait at a time per repository: a second one is
274
+ * refused while the first runs. Its <signal> ends it.
275
+ * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, maintenant?: () => number, rappel?: number }} options
276
+ * @returns {AsyncGenerator<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean }[], void, void>}
253
277
  * @throws {Error} another wait runs
254
278
  */
255
- export async function attendreUneQuestion({
279
+ export async function* attendreUneQuestion({
256
280
  racine,
257
281
  fermes = ticketsFermes,
258
282
  pas = 5_000,
259
283
  signal,
260
284
  circuitsDe = circuitsDuServeur,
285
+ maintenant = Date.now,
286
+ rappel = RAPPEL_PAR_DEFAUT,
261
287
  }) {
262
288
  mkdirSync(etatsDe(racine), { recursive: true });
263
289
  const verrou = verrouDeLAttente(racine);
@@ -281,14 +307,17 @@ export async function attendreUneQuestion({
281
307
  circuits = null;
282
308
  }
283
309
  if (circuits && !signal?.aborted) {
284
- const neuves = releverLesNeuves(racine, circuits, fermes);
285
- if (neuves.length) {
286
- return neuves;
310
+ const lot = relever(racine, circuits, {
311
+ fermes,
312
+ maintenant: maintenant(),
313
+ rappelMs: rappel * 60_000,
314
+ });
315
+ if (lot.length) {
316
+ yield lot;
287
317
  }
288
318
  }
289
319
  await attendre(pas, signal);
290
320
  }
291
- return [];
292
321
  } finally {
293
322
  lacherVerrou(verrou);
294
323
  }
@@ -307,21 +336,29 @@ const attendre = (ms, signal) =>
307
336
 
308
337
  /**
309
338
  * The text that wakes the session of supervision on the questions <questions>: for each one, its
310
- * ticket, step, who must answer it, its question and the command that answers it; then the wait to
311
- * launch again once they are answered.
312
- * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string }[]} questions
339
+ * ticket, step, who must answer it, its question and the command that answers it. The wait goes
340
+ * on by itself: the text asks for no relaunch. A question presented again (`representee`) says that
341
+ * it still waits for an answer.
342
+ * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean }[]} questions
313
343
  * @returns {string}
314
344
  */
315
345
  export function texteDesQuestions(questions) {
346
+ const neuves = questions.filter(q => !q.representee);
347
+ const titre = neuves.length
348
+ ? questions.length > 1
349
+ ? '## Questions neuves des circuits'
350
+ : "## Question neuve d'un circuit"
351
+ : questions.length > 1
352
+ ? '## Questions toujours sans réponse'
353
+ : '## Question toujours sans réponse';
316
354
  return [
317
- questions.length > 1 ? '## Questions neuves des circuits' : "## Question neuve d'un circuit",
355
+ titre,
318
356
  ...questions.map(q =>
319
357
  [
320
- `- ${q.ticket}, à ${q.etape}, au ${q.qui} : ${q.question.replace(/\n/g, '\n ')}`,
358
+ `- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
321
359
  ` La réponse : \`${q.commande}\`.`,
322
360
  ].join('\n')
323
361
  ),
324
- "Une fois répondu, relance l'attente en arrière-plan (`run_in_background`) : `npx grillhouse superviseur --attendre`.",
325
362
  ].join('\n');
326
363
  }
327
364
 
@@ -357,9 +394,11 @@ export async function circuitsALOuverture(
357
394
  : `Les circuits ne se lisent pas : ${message}.`;
358
395
  }
359
396
  const questions = circuits
360
- ? remonter(racine, circuits, () => {
361
- const q = questionsEnAttente(racine, circuits, { fermes });
362
- return { cles: q.map(x => x.cle), rendu: q };
397
+ ? relever(racine, circuits, {
398
+ fermes,
399
+ maintenant: Date.now(),
400
+ rappelMs: RAPPEL_PAR_DEFAUT * 60_000,
401
+ toutes: true,
363
402
  })
364
403
  : [];
365
404
  const tournent = enAttente(
@@ -381,7 +420,7 @@ export async function circuitsALOuverture(
381
420
  );
382
421
  return [
383
422
  "## L'attente des questions",
384
- "Dès ta première réponse, sans attendre le mot du responsable, lance en arrière-plan (`run_in_background`) l'attente des questions : `npx grillhouse superviseur --attendre`. Elle se termine sur la question neuve d'un circuit, quel que soit son lanceur, et te réveille ainsi ; un lancement de circuit rend la main tout de suite, et la fin normale d'un circuit ne te réveille pas : le panneau la montre.",
423
+ "Dès ta première réponse, sans attendre le mot du responsable, lance l'attente des questions en arrière-plan (`run_in_background`) et surveille sa sortie en continu (l'outil `Monitor`) : `npx grillhouse superviseur --attendre`. Elle ne se termine pas : elle imprime un lot à chaque question neuve d'un circuit, quel que soit son lanceur, et te réveille ainsi ; elle reprend l'écoute seule, sans relance. Une question sans réponse revient toutes les 5 min (`--rappel <minutes>` règle l'intervalle) jusqu'à sa réponse. Un lancement de circuit rend la main tout de suite, et la fin normale d'un circuit ne te réveille pas : le panneau la montre.",
385
424
  ...(panne ? ['', '## Les circuits du dépôt', panne] : []),
386
425
  ...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
387
426
  ].join('\n');
@@ -451,10 +490,23 @@ function racineDe(dossier) {
451
490
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
452
491
  if (process.argv[2] === '--attendre') {
453
492
  try {
454
- const questions = await attendreUneQuestion({
455
- racine: racineDe(process.argv[3] ?? process.cwd()),
456
- });
457
- process.stdout.write(`${texteDesQuestions(questions)}\n`);
493
+ const args = process.argv.slice(3);
494
+ const i = args.indexOf('--rappel');
495
+ let rappel = RAPPEL_PAR_DEFAUT;
496
+ if (i !== -1) {
497
+ rappel = Number(args[i + 1]);
498
+ if (!(rappel > 0)) {
499
+ throw new Error('--rappel attend un nombre de minutes supérieur à 0.');
500
+ }
501
+ args.splice(i, 2);
502
+ }
503
+ for await (const questions of attendreUneQuestion({
504
+ racine: racineDe(args[0] ?? process.cwd()),
505
+ rappel,
506
+ })) {
507
+ // One batch, one block ended by a blank line: a stream read line by line.
508
+ process.stdout.write(`${texteDesQuestions(questions)}\n\n`);
509
+ }
458
510
  } catch (e) {
459
511
  process.stderr.write(`${e.message}\n`);
460
512
  process.exitCode = 1;
@@ -117,6 +117,7 @@ import { verdictDe } from './integration/verdict.mjs';
117
117
  import { lireLaMesure } from './avancement.mjs';
118
118
  import { SANS_REPONSE_EN, ServeurMuet, circuitsDuServeur } from './circuits-du-serveur.mjs';
119
119
  import { etatDesPlaces } from './places-de-la-machine.mjs';
120
+ import { vivant } from './mesure/base-de-passe.mjs';
120
121
 
121
122
  const MINUTE = 60_000;
122
123
  export const SILENCE = 10 * MINUTE;
@@ -132,6 +133,9 @@ const PLACE_DU_SUJET = 10;
132
133
  // The role of a register line that a step of a circuit writes (scripts/circuit.mjs): no agent,
133
134
  // no role of the flow.
134
135
  export const ROLE_DU_CIRCUIT = 'circuit';
136
+ // The role of a register line that the workflow of the nights writes for a night it skips
137
+ // (src/temporal/nuits/): no agent, no ticket, no turn; the board counts it nowhere.
138
+ export const ROLE_DE_LA_NUIT = 'nuit';
135
139
  // A sub-agent's role from its meta file: the type it was spawned as; a named agent's `agentType`
136
140
  // is its name.
137
141
  export const roleDuMeta = m =>
@@ -612,6 +616,70 @@ export function lireVivant({ racine, home, prefix, maintenant, ps, cache = {} })
612
616
  export const attendLeSuperviseur = c =>
613
617
  !c.vivant && Boolean(c.interrompu || c.question || (c.arret && c.arret !== 'arrete'));
614
618
 
619
+ /**
620
+ * The key of one stop of the circuit <c>: its ticket, the run of its workflow, the rank of its
621
+ * question in that run and its stop, so that the next stop of a circuit resumed is another one. The
622
+ * one key of the file of the stops gone up (scripts/superviseur.mjs) and of the board's alerts.
623
+ * @param {{ ticket: string, run?: string, numero?: number, arret?: string | null }} c
624
+ * @returns {string}
625
+ */
626
+ export const cleDe = c => [c.ticket, c.run, c.numero, c.arret ?? 'interrompu'].join(':');
627
+
628
+ /** The file of the stops gone up to the supervisor of the repository at <racine>. */
629
+ export const remonteesDe = racine =>
630
+ path.join(racine, '.claude', 'worktrees', 'questions-remontees.json');
631
+
632
+ /**
633
+ * The stops gone up of the repository at <racine>, each with its key, `depuis` (the time of its
634
+ * first going up) and `presentee` (the time of its last presentation), in ms. An older file, a
635
+ * list of keys, reads without error: its stops take the time <maintenant> of the reading. A file
636
+ * that does not read holds none.
637
+ * @param {string} racine
638
+ * @param {number} maintenant
639
+ * @returns {{ cle: string, depuis: number, presentee: number }[]}
640
+ */
641
+ export function lireLesRemontees(racine, maintenant) {
642
+ try {
643
+ const lu = JSON.parse(readFileSync(remonteesDe(racine), 'utf8'));
644
+ if (!Array.isArray(lu?.remontees)) {
645
+ return [];
646
+ }
647
+ return lu.remontees.map(r =>
648
+ typeof r === 'string'
649
+ ? { cle: r, depuis: maintenant, presentee: maintenant }
650
+ : {
651
+ cle: String(r.cle),
652
+ depuis: Number.isFinite(r.depuis) ? r.depuis : maintenant,
653
+ presentee: Number.isFinite(r.presentee) ? r.presentee : maintenant,
654
+ }
655
+ );
656
+ } catch {
657
+ return [];
658
+ }
659
+ }
660
+
661
+ /** The lock of the one wait of the questions of the repository at <racine>. */
662
+ export const verrouDeLAttente = racine =>
663
+ path.join(racine, '.claude', 'worktrees', 'attente-des-questions.lock');
664
+
665
+ /**
666
+ * Whether a wait of the questions lives for the repository at <racine>: its lock names a process
667
+ * that lives (the pid is read again; a lock left by a dead process does not count).
668
+ * @param {string} racine
669
+ * @returns {boolean}
670
+ */
671
+ export function attenteVivante(racine) {
672
+ try {
673
+ const pid = Number(/^(\d+)/.exec(readFileSync(verrouDeLAttente(racine), 'utf8'))?.[1]);
674
+ return Number.isInteger(pid) && pid > 0 && vivant(pid);
675
+ } catch {
676
+ return false;
677
+ }
678
+ }
679
+
680
+ // The minutes between two presentations of a question not answered, by default.
681
+ export const RAPPEL_PAR_DEFAUT = 5;
682
+
615
683
  // The reviewer's last verdict among a ticket's comments (verdictDe: a comment of the reviewer's
616
684
  // author), or null.
617
685
  export function verdict(commentaires) {
@@ -709,10 +777,15 @@ export function assembler({
709
777
  muet = false,
710
778
  faute = null,
711
779
  echecPrefixe = null,
780
+ remontees = [],
781
+ rappel = RAPPEL_PAR_DEFAUT,
782
+ attenteVivante: attenteQuiVit = true,
712
783
  }) {
713
784
  // A circuit's lines are its steps, no agent's passage.
714
785
  const etapesFinies = lignesDuRegistre.filter(r => r.role === ROLE_DU_CIRCUIT);
715
- const registre = parAgent(lignesDuRegistre.filter(r => r.role !== ROLE_DU_CIRCUIT));
786
+ const registre = parAgent(
787
+ lignesDuRegistre.filter(r => r.role !== ROLE_DU_CIRCUIT && r.role !== ROLE_DE_LA_NUIT)
788
+ );
716
789
  // A living agent runs without an end in the register, or when an incoming message follows its
717
790
  // latest end strictly; the writings of its last turn after that end leave it finished. A running
718
791
  // agent's transcript holds its sessions already in the register.
@@ -870,7 +943,39 @@ export function assembler({
870
943
  const duJour = mesures
871
944
  .filter(m => m.quand >= jour)
872
945
  .map(m => (m.tours ? { ...m, travail: partDuJour(m.tours) } : m));
873
- const global = { compteurs, jour: somme(duJour), cumul: somme(mesures) };
946
+ // The discoveries (label `decouverte`, grillhouse-3uv.96): each counts in one case, the first that
947
+ // applies. « rejetés » and « validés » count only since the day's marker <jour>; « new » and
948
+ // « →check », states that await the owner, do not filter by it.
949
+ const aLabel = (t, ...ls) => ls.some(l => (t.labels ?? []).includes(l));
950
+ const estDecouverte = t => aLabel(t, 'decouverte');
951
+ const VERDICTS_DU_TRI = ['traitee', 'doublon', 'sans-suite', 'a-porter', 'non-confirmee'];
952
+ const caseDeLaDecouverte = t => {
953
+ const ferme = t.status === 'closed';
954
+ if (aLabel(t, 'circuit') && (Date.parse(t.updated_at ?? '') || 0) >= jour) {
955
+ return 'valides';
956
+ }
957
+ if (!ferme && aLabel(t, 'a-valider')) {
958
+ return 'check';
959
+ }
960
+ const rejete =
961
+ aLabel(t, 'traitee', 'doublon', 'sans-suite') ||
962
+ (aLabel(t, 'a-porter', 'non-confirmee') && !aLabel(t, 'circuit'));
963
+ if (ferme && rejete && (Date.parse(t.closed_at ?? '') || 0) >= jour) {
964
+ return 'rejetes';
965
+ }
966
+ if (ferme && !aLabel(t, ...VERDICTS_DU_TRI)) {
967
+ return 'new';
968
+ }
969
+ return null;
970
+ };
971
+ const decouvertes = { new: 0, check: 0, rejetes: 0, valides: 0 };
972
+ for (const t of tous.filter(estDecouverte)) {
973
+ const c = caseDeLaDecouverte(t);
974
+ if (c) {
975
+ decouvertes[c]++;
976
+ }
977
+ }
978
+ const global = { compteurs, jour: somme(duJour), cumul: somme(mesures), decouvertes };
874
979
 
875
980
  // Chantiers.
876
981
  const sous = t => [t, ...(enfants.get(t.id) ?? []).flatMap(sous)];
@@ -999,7 +1104,12 @@ export function assembler({
999
1104
  const debutJour = jour;
1000
1105
  const faitsDuJour = tous
1001
1106
  .filter(
1002
- t => travail(t) && !actifs.has(t.id) && t.closed_at && Date.parse(t.closed_at) >= debutJour
1107
+ t =>
1108
+ travail(t) &&
1109
+ !actifs.has(t.id) &&
1110
+ !estDecouverte(t) &&
1111
+ t.closed_at &&
1112
+ Date.parse(t.closed_at) >= debutJour
1003
1113
  )
1004
1114
  .sort((a, b) => Date.parse(b.closed_at) - Date.parse(a.closed_at))
1005
1115
  .map(t => ({
@@ -1050,6 +1160,34 @@ export function assembler({
1050
1160
  texte: `Outil ${outil.version} non installable : code du dépôt`,
1051
1161
  });
1052
1162
  }
1163
+ // A circuit stopped on a question to the supervisor: orange, how long it has waited (from the
1164
+ // `depuis` of its stop in the file of the stops gone up), red past two intervals of
1165
+ // re-presentation (two presentations with no answer); it falls when the circuit leaves the stop.
1166
+ // One red alert « à corriger » when some wait and no wait lives.
1167
+ const depuisDe = new Map(remontees.map(r => [r.cle, r.depuis]));
1168
+ const enAttenteDuSuperviseur = [...parCircuit.values()]
1169
+ .filter(attendLeSuperviseur)
1170
+ .sort((a, b) => ordre({ id: a.ticket }, { id: b.ticket }));
1171
+ for (const c of enAttenteDuSuperviseur) {
1172
+ const depuis = depuisDe.get(cleDe(c));
1173
+ if (depuis === undefined) {
1174
+ continue;
1175
+ }
1176
+ const attendu = Math.max(0, maintenant - depuis);
1177
+ alertes.push({
1178
+ niveau: attendu > 2 * rappel * MINUTE ? 'rouge' : 'orange',
1179
+ signe: '⏳',
1180
+ texte: `${numero(c.ticket)} attend le superviseur depuis ${Math.floor(attendu / MINUTE)} min`,
1181
+ });
1182
+ }
1183
+ if (enAttenteDuSuperviseur.length && !attenteQuiVit) {
1184
+ alertes.push({
1185
+ niveau: 'rouge',
1186
+ signe: '🔕',
1187
+ texte:
1188
+ 'À corriger : une question au superviseur reste sans réponse, aucune attente ne tourne',
1189
+ });
1190
+ }
1053
1191
  for (const b of blocs) {
1054
1192
  for (const x of b.enCours) {
1055
1193
  if (x.ligne && x.silence !== null && x.silence > SILENCE) {
@@ -1253,6 +1391,16 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1253
1391
  )
1254
1392
  );
1255
1393
  }
1394
+ // The discoveries of the day, summed across the projects (grillhouse-3uv.96, criterion 14).
1395
+ const d96 = t.decouvertes ?? { new: 0, check: 0, rejetes: 0, valides: 0 };
1396
+ L(
1397
+ cadre(
1398
+ `🔍 ${d96.new} new · ${d96.check} →check · ${d96.rejetes} rejetés · ${d96.valides} validés`,
1399
+ '',
1400
+ largeur
1401
+ ),
1402
+ 'discret'
1403
+ );
1256
1404
  } else {
1257
1405
  const g = t.global;
1258
1406
  const c = g.compteurs;
@@ -1268,6 +1416,17 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1268
1416
  cadre(`${c.sansGo} sans go · ${c.aValider} à valider · ${c.reportes} reportés`, '', largeur),
1269
1417
  c.sansGo || c.aValider ? 'attention' : undefined
1270
1418
  );
1419
+ // The discoveries of the day, one count per case (grillhouse-3uv.96): always shown, at 0 when
1420
+ // nothing counts, like the other head lines.
1421
+ const d = g.decouvertes ?? { new: 0, check: 0, rejetes: 0, valides: 0 };
1422
+ L(
1423
+ cadre(
1424
+ `🔍 ${d.new} new · ${d.check} →check · ${d.rejetes} rejetés · ${d.valides} validés`,
1425
+ '',
1426
+ largeur
1427
+ ),
1428
+ 'discret'
1429
+ );
1271
1430
  L(
1272
1431
  cadre(
1273
1432
  `jour ${duree(g.jour.travail)} · ${k(g.jour.jetons)} · cumul ${duree(g.cumul.travail)} · ${k(g.cumul.jetons)}`,
@@ -1427,7 +1586,8 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1427
1586
  const reste = avec =>
1428
1587
  largeur - (droite ? colonnes(droite) + 1 : 0) - colonnes(tete) - colonnes(avec);
1429
1588
  const place = attendUnePlace.has(c.id) ? ' · attend une place' : '';
1430
- const suite = `${
1589
+ const tag = enQuestion(c) === SUPERVISEUR ? ' · en attente du superviseur' : '';
1590
+ const suite = `${tag}${
1431
1591
  !temoin
1432
1592
  ? boucles
1433
1593
  : reste(`${boucles}${temoin.texte}`) >= Math.min(PLACE_DU_SUJET, c.sujet.length)
@@ -1838,6 +1998,48 @@ const bdJson = (racine, ...args) => {
1838
1998
  }
1839
1999
  };
1840
2000
 
2001
+ // The folder git keeps a repository's shared files in (its common dir), absolute; null when
2002
+ // <racine> is no git repository. The board's cache and the day's marker live there.
2003
+ export function dossierCommun(racine) {
2004
+ try {
2005
+ return execFileSync(
2006
+ 'git',
2007
+ ['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
2008
+ { encoding: 'utf8' }
2009
+ ).trim();
2010
+ } catch {
2011
+ return null;
2012
+ }
2013
+ }
2014
+
2015
+ // The file of the day's marker (grillhouse-3uv.96), beside the board's cache; null without a common
2016
+ // dir. Unversioned, out of the worktree: the board does not reset at midnight.
2017
+ const fichierDuRepere = commun => commun && path.join(commun, 'tableau-repere.json');
2018
+
2019
+ // The day's marker of the project whose common dir is <commun>: the number its file holds, else
2020
+ // midnight of <maintenant> (no file, or no number).
2021
+ export function lireLeRepere(commun, maintenant) {
2022
+ const minuit = new Date(maintenant);
2023
+ minuit.setHours(0, 0, 0, 0);
2024
+ try {
2025
+ const { repere } = JSON.parse(readFileSync(fichierDuRepere(commun), 'utf8'));
2026
+ return typeof repere === 'number' ? repere : minuit.getTime();
2027
+ } catch {
2028
+ return minuit.getTime();
2029
+ }
2030
+ }
2031
+
2032
+ // Sets the day's marker of the project at <racine> to <quand> (now by default), purging FAITS
2033
+ // AUJOURD'HUI and the « rejetés » and « validés » cases up to it (grillhouse-3uv.96, /newday).
2034
+ export function poserLeRepere(racine, quand = Date.now()) {
2035
+ const commun = dossierCommun(racine);
2036
+ if (!commun) {
2037
+ throw new Error('newday : le dossier git commun du projet est introuvable.');
2038
+ }
2039
+ writeFileSync(fichierDuRepere(commun), `${JSON.stringify({ repere: quand })}\n`);
2040
+ return quand;
2041
+ }
2042
+
1841
2043
  // What the board reads of the repository at <racine>, its circuits <circuits> read: its tickets,
1842
2044
  // its prefix, its running agents and its assembled board (`t`), with the folder git keeps its
1843
2045
  // shared files in (`commun`).
@@ -1894,16 +2096,7 @@ function lire(
1894
2096
  verdicts[t.id] = v;
1895
2097
  }
1896
2098
  }
1897
- let commun = null;
1898
- try {
1899
- commun = execFileSync(
1900
- 'git',
1901
- ['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
1902
- { encoding: 'utf8' }
1903
- ).trim();
1904
- } catch {
1905
- commun = null;
1906
- }
2099
+ const commun = dossierCommun(racine);
1907
2100
  const fichierCache = commun && path.join(commun, 'tableau-cache.json');
1908
2101
  let cache = {};
1909
2102
  try {
@@ -1929,8 +2122,6 @@ function lire(
1929
2122
  } catch {
1930
2123
  // A read-only place keeps the board working, without its cache.
1931
2124
  }
1932
- const minuit = new Date(maintenant);
1933
- minuit.setHours(0, 0, 0, 0);
1934
2125
  const t = assembler({
1935
2126
  tous,
1936
2127
  prefix,
@@ -1939,13 +2130,15 @@ function lire(
1939
2130
  circuits,
1940
2131
  verdicts,
1941
2132
  maintenant,
1942
- jour: minuit.getTime(),
2133
+ jour: lireLeRepere(commun, maintenant),
1943
2134
  machine,
1944
2135
  places,
1945
2136
  muet,
1946
2137
  faute,
1947
2138
  echecPrefixe,
1948
2139
  outil: echecDeLOutil(racine),
2140
+ remontees: lireLesRemontees(racine, maintenant),
2141
+ attenteVivante: attenteVivante(racine),
1949
2142
  });
1950
2143
  return { t, prefix, tous, vivants, commun };
1951
2144
  }
@@ -1994,6 +2187,18 @@ export function ensemble(lus) {
1994
2187
  machine: premier.t.machine,
1995
2188
  places: premier.t.places,
1996
2189
  faitsDuJour: tous('faitsDuJour'),
2190
+ decouvertes: lisibles.reduce(
2191
+ (s, l) => {
2192
+ const d = l.t.global.decouvertes ?? {};
2193
+ return {
2194
+ new: s.new + (d.new ?? 0),
2195
+ check: s.check + (d.check ?? 0),
2196
+ rejetes: s.rejetes + (d.rejetes ?? 0),
2197
+ valides: s.valides + (d.valides ?? 0),
2198
+ };
2199
+ },
2200
+ { new: 0, check: 0, rejetes: 0, valides: 0 }
2201
+ ),
1997
2202
  etats: premier.t.etats.map(e => ({
1998
2203
  ...e,
1999
2204
  tickets: lisibles.flatMap(l =>