@roomi-fields/grillhouse 0.28.3 → 0.29.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 (68) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +55 -14
  3. package/cadre/templates/projet/CLAUDE.md +1 -1
  4. package/cadre/templates/projet/README.md +11 -11
  5. package/cadre/templates/projet/_gitignore +2 -5
  6. package/charte.md +13 -4
  7. package/docs/ARCHITECTURE.md +260 -29
  8. package/docs/INTERFACE.md +51 -12
  9. package/package.json +1 -1
  10. package/scripts/aiguillage.mjs +324 -0
  11. package/scripts/avancement.mjs +33 -50
  12. package/scripts/circuit.mjs +558 -146
  13. package/scripts/composition-des-langages.mjs +16 -1
  14. package/scripts/conformite.mjs +16 -0
  15. package/scripts/copies-finies.mjs +171 -30
  16. package/scripts/demon.mjs +134 -21
  17. package/scripts/enveloppe/lancer.sh +13 -14
  18. package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
  19. package/scripts/etapes.mjs +1 -1
  20. package/scripts/fusion-du-changelog.mjs +0 -1
  21. package/scripts/grillhouse-maj.mjs +16 -7
  22. package/scripts/integration/file.mjs +3 -3
  23. package/scripts/integration/integrer.mjs +3 -3
  24. package/scripts/jointure.d.ts +39 -17
  25. package/scripts/langages/cargo/commandes.mjs +152 -25
  26. package/scripts/langages/cargo/composants.mjs +90 -2
  27. package/scripts/langages/cargo/exemples.mjs +68 -1
  28. package/scripts/langages/cargo/index.mjs +17 -8
  29. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  30. package/scripts/langages/cargo/sccache.mjs +54 -2
  31. package/scripts/langages/cargo/squelette.mjs +72 -3
  32. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  33. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  34. package/scripts/langages/python/commandes.mjs +44 -7
  35. package/scripts/langages/python/composants.mjs +33 -3
  36. package/scripts/langages/python/exemples.mjs +19 -0
  37. package/scripts/langages/python/index.mjs +4 -0
  38. package/scripts/langages/python/squelette.mjs +119 -17
  39. package/scripts/langages/typescript/exemples.mjs +16 -0
  40. package/scripts/langages/typescript/index.mjs +6 -3
  41. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  42. package/scripts/langages/typescript/squelette.mjs +18 -2
  43. package/scripts/langages/typescript/tests-de-nuit.mjs +41 -21
  44. package/scripts/langages/typescript/verifier.mjs +82 -288
  45. package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
  46. package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
  47. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
  48. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +4 -2
  49. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  50. package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
  51. package/scripts/lecture-unique.mjs +51 -0
  52. package/scripts/mesure/pression.mjs +9 -7
  53. package/scripts/nuit.sh +19 -12
  54. package/scripts/outil.mjs +72 -0
  55. package/scripts/paquet.mjs +39 -10
  56. package/scripts/resultats.mjs +22 -5
  57. package/scripts/services-du-noyau.mjs +8 -9
  58. package/scripts/session-start.sh +10 -1
  59. package/scripts/sortie.mjs +20 -1
  60. package/scripts/sources.mjs +3 -3
  61. package/scripts/sous-commandes.mjs +1 -0
  62. package/scripts/superviseur.mjs +369 -14
  63. package/scripts/tableau.mjs +219 -58
  64. package/scripts/verrou-de-machine.mjs +303 -58
  65. package/skills/developpeur/SKILL.md +11 -3
  66. package/skills/pitmaster/SKILL.md +58 -23
  67. package/skills/relecteur/SKILL.md +18 -6
  68. package/skills/testwriter/SKILL.md +11 -15
@@ -12,18 +12,47 @@
12
12
  // copies, taken through scripts/verrou-de-fichier.mjs for the session's own process: the first
13
13
  // process above this one that is not a shell (sh, bash, dash, zsh), the claude of the session.
14
14
  // It holds as long as that process lives: a lock whose process is gone is taken over.
15
- // - Free, or held by a process that is gone: taken, nothing said. Held by the session itself (a
16
- // session reopened in the same process): kept, nothing said. Held by another live session: the
15
+ // - Free, or held by a process that is gone: taken, nothing said of it. Held by the session itself
16
+ // (a session reopened in the same process, by a compaction or a /clear): kept, nothing said of
17
+ // it, circuits included. Held by another live session: the
17
18
  // lock stays, and the section « ## Un autre superviseur tient ce dépôt » names its process and
18
19
  // since when it holds the lock, and asks to say so to the owner and to launch no circuit
19
20
  // (skill pitmaster, « Au lancement de la séance »).
21
+ // - The session whose opening takes the lock (not one that keeps it) receives
22
+ // (`circuitsALOuverture`) the section « ## L'attente des questions », which asks it to launch the
23
+ // wait of the questions in the background (`--attendre`, below) without waiting for the owner's
24
+ // word, then, when the repository has some (read by scripts/tableau.mjs `lireCircuits`), « ## Les
25
+ // circuits du dépôt »: each circuit that runs, named; each circuit stopped on a question, with
26
+ // its question and the command that answers it; each circuit dead without a final state, with
27
+ // the command that resumes it (`--reprendre`), which the supervisor launches without waiting for
28
+ // the owner's word; their ticket open, and the stopped and the dead ones then gone up. A circuit
29
+ // runs detached from the sessions (scripts/demon.mjs), its launch returns at once, and its
30
+ // question wakes the supervisor by the wait alone (grillhouse-mwz: SyntHub's SH-br0.1 stopped
31
+ // 27 s after a relaunch of its session, read only on a word of the owner).
20
32
  // Exit 0, whatever it finds.
33
+ //
34
+ // npx grillhouse superviseur --attendre [<dossier>]
35
+ //
36
+ // - The wait of the session of supervision (`attendreUneQuestion`), which the supervisor keeps in
37
+ // the background, one at a time, the one way a question of a circuit wakes the session (the
38
+ // owner's decision, grillhouse-pq6): it ends only when a question of a circuit appears that never
39
+ // went up (`questionsEnAttente`, the one source of the questions that wait for the supervisor,
40
+ // which the opening reads too), whatever launched the circuit (alone, in a queue, by another
41
+ // session), and writes each one, its ticket, step, question and the command that answers it;
42
+ // the end of its task wakes the session, which spends nothing while it waits (grillhouse-pq6:
43
+ // SyntHub's SH-ae6.5.2, SH-ae6.5.6 and SH-br0.1.5, launched by a queue, waited hours on their
44
+ // question). The stops gone up, by a wait or named at the opening, are kept in
45
+ // `.claude/worktrees/questions-remontees.json`, each one by its ticket, the run of its circuit
46
+ // and its stop: one never wakes the session twice, and one answered leaves them. Exit 0 on its
47
+ // questions, 1 when another wait already runs (`.claude/worktrees/attente-des-questions.lock`).
21
48
  import { spawnSync } from 'node:child_process';
22
- import { readFileSync, statSync } from 'node:fs';
49
+ import { mkdirSync, readFileSync, renameSync, statSync, watch, writeFileSync } from 'node:fs';
23
50
  import path from 'node:path';
24
51
  import { pathToFileURL } from 'node:url';
25
- import { prendreVerrou } from './verrou-de-fichier.mjs';
52
+ import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
26
53
  import { vivant } from './mesure/base-de-passe.mjs';
54
+ import { attendLeSuperviseur, lireCircuits } from './tableau.mjs';
55
+ import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
27
56
 
28
57
  const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
29
58
  const COQUILLES = new Set(['sh', 'bash', 'dash', 'zsh']);
@@ -46,13 +75,307 @@ function seance(depart = process.ppid) {
46
75
  let pid = depart;
47
76
  for (let i = 0; i < 32 && pid > 1; i++) {
48
77
  const p = processus(pid);
49
- if (!p) return depart;
50
- if (!COQUILLES.has(p.nom)) return pid;
78
+ if (!p) {
79
+ return depart;
80
+ }
81
+ if (!COQUILLES.has(p.nom)) {
82
+ return pid;
83
+ }
51
84
  pid = p.parent;
52
85
  }
53
86
  return depart;
54
87
  }
55
88
 
89
+ // Of the tickets <ids> of the repository at <racine>, those that bd gives closed; none when bd does
90
+ // not read them.
91
+ function ticketsFermes(racine, ids) {
92
+ const r = spawnSync('bd', ['show', ...ids, '--json'], {
93
+ cwd: racine,
94
+ encoding: 'utf8',
95
+ timeout: 5000,
96
+ maxBuffer: 256 * 1024 * 1024,
97
+ });
98
+ try {
99
+ return new Set(
100
+ JSON.parse(r.stdout)
101
+ .filter(t => t.status === 'closed')
102
+ .map(t => t.id)
103
+ );
104
+ } catch {
105
+ return new Set();
106
+ }
107
+ }
108
+
109
+ // One stop of the circuit <c>: its ticket, the run that wrote it (`processus`, `depart`) and its
110
+ // stop, so that the next stop of a circuit resumed is another one.
111
+ const cleDe = c =>
112
+ [c.ticket, c.processus ?? '?', c.depart ?? '?', c.arret ?? 'interrompu'].join(':');
113
+
114
+ // The step where the circuit <c> stands, in words (« 3.1 Contrôles »), else its state's.
115
+ const ou = c => {
116
+ const e = etapeDuCircuit({ ...c, raison: c.arret });
117
+ return e ? libelle(e) : c.etape;
118
+ };
119
+
120
+ // The file of the stops gone up to the session of supervision of the repository at <racine>, and
121
+ // the lock of its one wait, beside the states of the circuits.
122
+ const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
123
+ const remonteesDe = racine => path.join(etatsDe(racine), 'questions-remontees.json');
124
+ const verrouDeLAttente = racine => path.join(etatsDe(racine), 'attente-des-questions.lock');
125
+
126
+ // The stops gone up to the session of supervision of the repository at <racine>: their keys.
127
+ function lireRemontees(racine) {
128
+ try {
129
+ const lu = JSON.parse(readFileSync(remonteesDe(racine), 'utf8'));
130
+ return new Set(Array.isArray(lu?.remontees) ? lu.remontees.map(String) : []);
131
+ } catch {
132
+ return new Set();
133
+ }
134
+ }
135
+
136
+ // The stops gone up of the repository at <racine>, under the lock of their file: <faire>(<avant>,
137
+ // those gone up before) returns the keys it makes go up (`cles`) and what it gives (`rendu`); the
138
+ // file is written whole with them and those of <avant> whose stop still stands, its circuit waiting
139
+ // for the supervisor, or alive and stopped, a question its caller read on its output
140
+ // (`inscrireLaQuestionLue`) until its process ends. A question answered so leaves them. Its
141
+ // `rendu`.
142
+ function remonter(racine, faire) {
143
+ const f = remonteesDe(racine);
144
+ mkdirSync(path.dirname(f), { recursive: true });
145
+ const verrou = `${f}.verrou`;
146
+ // Held for one reading of the states: older than that, abandoned.
147
+ prendreVerrou(verrou, { attendre: true, perime: 30_000 });
148
+ try {
149
+ const avant = lireRemontees(racine);
150
+ const { cles, rendu } = faire(avant);
151
+ const debout = new Set(
152
+ lireCircuits({ racine })
153
+ .filter(c => attendLeSuperviseur(c) || (c.vivant && c.arret))
154
+ .map(cleDe)
155
+ );
156
+ const apres = new Set([...cles, ...[...avant].filter(c => debout.has(c))]);
157
+ if (avant.size !== apres.size || [...apres].some(c => !avant.has(c))) {
158
+ const provisoire = `${f}.${process.pid}`;
159
+ writeFileSync(provisoire, `${JSON.stringify({ remontees: [...apres].sort() }, null, 2)}\n`);
160
+ renameSync(provisoire, f);
161
+ }
162
+ return rendu;
163
+ } finally {
164
+ lacherVerrou(verrou);
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Inscribes as gone up the question of the circuit of <ticket>, its run (`processus`, `depart`)
170
+ * stopped on <arret>, that its caller read on its output (grillhouse-pq6.1: a launch in the
171
+ * foreground that stops before any session, scripts/circuit.mjs `monter`): the wait of the
172
+ * questions does not wake on it, by the one source of the stops gone up.
173
+ * @param {string} racine
174
+ * @param {{ ticket: string, processus: number, depart: string, arret: string }} arret
175
+ */
176
+ export function inscrireLaQuestionLue(racine, arret) {
177
+ remonter(racine, () => ({ cles: [cleDe(arret)] }));
178
+ }
179
+
180
+ // The question that waits for the supervisor from the circuit <c>: its ticket, its step, its
181
+ // question, who must answer it, the command that answers it, and its stop's key.
182
+ const enQuestion = c => ({
183
+ ticket: c.ticket,
184
+ etape: ou(c),
185
+ question:
186
+ c.question ??
187
+ `arrêt ${c.arret}${c.code === null ? '' : ` (code ${c.code})`}${c.raison ? ` : ${c.raison}` : ''}`,
188
+ qui: c.qui ?? SUPERVISEUR,
189
+ commande: c.interrompu
190
+ ? `npx grillhouse circuit ${c.ticket} --reprendre`
191
+ : `npx grillhouse circuit ${c.ticket} --reprendre\`, \`--depuis <testwriter|developpeur>\`, \`--etendre <paquet>\` ou \`--arreter`,
192
+ cle: cleDe(c),
193
+ interrompu: c.interrompu,
194
+ arret: c.arret,
195
+ });
196
+
197
+ // Of the circuits <lus> of the repository at <racine>, those whose ticket <fermes> does not give
198
+ // closed, sorted by ticket.
199
+ function enAttente(lus, racine, fermes) {
200
+ const ferme = lus.length
201
+ ? fermes(
202
+ racine,
203
+ lus.map(c => c.ticket)
204
+ )
205
+ : new Set();
206
+ return lus
207
+ .filter(c => !ferme.has(c.ticket))
208
+ .sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'));
209
+ }
210
+
211
+ /**
212
+ * The questions that wait for the supervisor in the repository at <racine>, the one source of the
213
+ * opening (`circuitsALOuverture`) and of the wait (`attendreUneQuestion`), by the rule the board's
214
+ * « ⤷ Question » reads too (scripts/tableau.mjs `attendLeSuperviseur`, beside `lireCircuits`, which
215
+ * this module imports): each circuit whose process is gone, stopped (any stop but the
216
+ * supervisor's own « arrete », « à repasser » included) or dead without a final state,
217
+ * those whose stop's key <sauf> holds left out, then those whose ticket <fermes> gives closed
218
+ * (bd is asked of the others alone), sorted by ticket. Each one says whether its circuit died
219
+ * without a final state (`interrompu`) and its stop (`arret`).
220
+ * @param {string} racine the root of the repository
221
+ * @param {{ fermes?: (racine: string, ids: string[]) => Set<string>, sauf?: Set<string> }} options
222
+ * @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, interrompu: boolean, arret: string | null }[]}
223
+ */
224
+ export function questionsEnAttente(racine, { fermes = ticketsFermes, sauf = new Set() } = {}) {
225
+ return enAttente(
226
+ lireCircuits({ racine }).filter(c => attendLeSuperviseur(c) && !sauf.has(cleDe(c))),
227
+ racine,
228
+ fermes
229
+ ).map(enQuestion);
230
+ }
231
+
232
+ // No ticket closed: the questions read without asking bd.
233
+ const aucunFerme = () => new Set();
234
+
235
+ // The questions of the repository at <racine> that never went up (`questionsEnAttente`): returned,
236
+ // and now gone up; a question answered (its circuit runs again, or ended) leaves those gone up, and
237
+ // one whose ticket <fermes> gives closed goes up without a word. bd is asked of the new ones alone.
238
+ function releverLesNeuves(racine, fermes) {
239
+ return remonter(racine, avant => ({
240
+ cles: questionsEnAttente(racine, { fermes: aucunFerme }).map(q => q.cle),
241
+ rendu: questionsEnAttente(racine, { fermes, sauf: avant }),
242
+ }));
243
+ }
244
+
245
+ /**
246
+ * The wait of the session of supervision of the repository at <racine> (`npx grillhouse
247
+ * superviseur --attendre`, which the supervisor keeps in the background, as a review requested on
248
+ * GitHub or Gerrit's attention set calls the one a change waits for): it ends only when a question
249
+ * that never went up waits for the supervisor (`questionsEnAttente`), whatever launched its
250
+ * circuit, and gives those questions, now gone up; a question already gone up (by a wait, or named
251
+ * at the opening) never ends it again, and a question answered leaves those gone up. It watches
252
+ * the directory of the states of the circuits (fs.watch, inotify on Linux), and reads them again
253
+ * every <pas> ms for a circuit killed, the one end that leaves no mark (a circuit marks its exit,
254
+ * its state touched, scripts/circuit.mjs); the session spends
255
+ * nothing while it waits. One wait at a time per repository: a second one is refused while the
256
+ * first runs. Its <signal> ends it with no question.
257
+ * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal }} options
258
+ * @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string }[]>}
259
+ * @throws {Error} another wait runs
260
+ */
261
+ export async function attendreUneQuestion({
262
+ racine,
263
+ fermes = ticketsFermes,
264
+ pas = 30_000,
265
+ signal,
266
+ }) {
267
+ const dossier = etatsDe(racine);
268
+ mkdirSync(dossier, { recursive: true });
269
+ const verrou = verrouDeLAttente(racine);
270
+ if (!prendreVerrou(verrou, { attendre: false })) {
271
+ let qui = '';
272
+ try {
273
+ qui = ` (processus ${/^(\d+)/.exec(readFileSync(verrou, 'utf8'))?.[1] ?? '?'})`;
274
+ } catch {
275
+ // the lock is gone meanwhile
276
+ }
277
+ throw new Error(
278
+ `Une attente des questions tourne déjà pour ce dépôt${qui}, ${verrou} : une seule à la fois.`
279
+ );
280
+ }
281
+ try {
282
+ return await new Promise(resolve => {
283
+ if (signal?.aborted) {
284
+ resolve([]);
285
+ return;
286
+ }
287
+ let fini = false;
288
+ let differe;
289
+ const voir = () => {
290
+ if (fini) {
291
+ return;
292
+ }
293
+ const neuves = releverLesNeuves(racine, fermes);
294
+ if (neuves.length) {
295
+ finir(neuves);
296
+ }
297
+ };
298
+ const surveillance = watch(dossier, () => {
299
+ clearTimeout(differe);
300
+ differe = setTimeout(voir, 250);
301
+ });
302
+ const minuteur = setInterval(voir, pas);
303
+ const finir = q => {
304
+ fini = true;
305
+ surveillance.close();
306
+ clearTimeout(differe);
307
+ clearInterval(minuteur);
308
+ resolve(q);
309
+ };
310
+ signal?.addEventListener('abort', () => finir([]), { once: true });
311
+ voir();
312
+ });
313
+ } finally {
314
+ lacherVerrou(verrou);
315
+ }
316
+ }
317
+
318
+ /**
319
+ * The text that wakes the session of supervision on the questions <questions>: for each one, its
320
+ * ticket, step, who must answer it, its question and the command that answers it; then the wait to
321
+ * launch again once they are answered.
322
+ * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string }[]} questions
323
+ * @returns {string}
324
+ */
325
+ export function texteDesQuestions(questions) {
326
+ return [
327
+ questions.length > 1 ? '## Questions neuves des circuits' : "## Question neuve d'un circuit",
328
+ ...questions.map(q =>
329
+ [
330
+ `- ${q.ticket}, à ${q.etape}, au ${q.qui} : ${q.question.replace(/\n/g, '\n ')}`,
331
+ ` La réponse : \`${q.commande}\`.`,
332
+ ].join('\n')
333
+ ),
334
+ "Une fois répondu, relance l'attente en arrière-plan (`run_in_background`) : `npx grillhouse superviseur --attendre`.",
335
+ ].join('\n');
336
+ }
337
+
338
+ /**
339
+ * The section a session of supervision receives at its opening in <racine>, when it takes the lock:
340
+ * the wait of the questions to launch in the background (`npx grillhouse superviseur --attendre`),
341
+ * the one way a question of a circuit wakes the session; then the circuits of the repository,
342
+ * those whose ticket <fermes> gives closed left out: each one that runs, named; each one stopped on
343
+ * a question (a stop other than the supervisor's own « arrete »), with its question and the command
344
+ * that answers it; each one dead without a final state, with the command that resumes it. The
345
+ * stopped and the dead ones are then gone up: the wait does not give them again.
346
+ * @param {string} racine the root of the repository
347
+ * @param {{ fermes?: (racine: string, ids: string[]) => Set<string> }} options
348
+ * @returns {string}
349
+ */
350
+ export function circuitsALOuverture(racine, { fermes = ticketsFermes } = {}) {
351
+ const questions = remonter(racine, () => {
352
+ const q = questionsEnAttente(racine, { fermes });
353
+ return { cles: q.map(x => x.cle), rendu: q };
354
+ });
355
+ const tournent = enAttente(
356
+ lireCircuits({ racine }).filter(c => c.vivant),
357
+ racine,
358
+ fermes
359
+ ).map(c => ({ ticket: c.ticket, ligne: `- ${c.ticket} tourne, à ${ou(c)}.` }));
360
+ const enLigne = q => ({
361
+ ticket: q.ticket,
362
+ ligne: q.interrompu
363
+ ? `- ${q.ticket} est mort sans état final (son processus parti, aucun arrêt écrit), à ${q.etape} : relance-le sans attendre le mot du responsable, \`${q.commande}\`.`
364
+ : [
365
+ `- ${q.ticket} est arrêté sur une question (${q.arret}), à ${q.etape}, au ${q.qui} : ${q.question.replace(/\n/g, '\n ')}`,
366
+ ` La réponse : \`${q.commande}\`.`,
367
+ ].join('\n'),
368
+ });
369
+ const nommes = [...tournent, ...questions.map(enLigne)].sort((a, b) =>
370
+ a.ticket.localeCompare(b.ticket, 'en')
371
+ );
372
+ return [
373
+ "## L'attente des questions",
374
+ "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.",
375
+ ...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
376
+ ].join('\n');
377
+ }
378
+
56
379
  const git = (racine, ...args) =>
57
380
  spawnSync('git', ['-C', racine, 'rev-parse', '--path-format=absolute', ...args], {
58
381
  encoding: 'utf8',
@@ -66,11 +389,17 @@ const git = (racine, ...args) =>
66
389
  * @returns {string}
67
390
  */
68
391
  function superviseur(racine, { env = process.env } = {}) {
69
- if (env.BEADS_ACTOR) return '';
392
+ if (env.BEADS_ACTOR) {
393
+ return '';
394
+ }
70
395
  const r = git(racine, '--git-dir', '--git-common-dir');
71
- if (r.status !== 0) return '';
396
+ if (r.status !== 0) {
397
+ return '';
398
+ }
72
399
  const [dossierGit, commun] = r.stdout.trim().split('\n');
73
- if (path.resolve(dossierGit) !== path.resolve(commun)) return '';
400
+ if (path.resolve(dossierGit) !== path.resolve(commun)) {
401
+ return '';
402
+ }
74
403
  const verrou = path.join(commun, VERROU_SUPERVISEUR);
75
404
  const moi = seance();
76
405
  const tenant = () => {
@@ -80,10 +409,16 @@ function superviseur(racine, { env = process.env } = {}) {
80
409
  return null;
81
410
  }
82
411
  };
83
- if (tenant() === moi) return '';
84
- if (prendreVerrou(verrou, { attendre: false, pid: moi })) return '';
412
+ if (tenant() === moi) {
413
+ return '';
414
+ }
415
+ if (prendreVerrou(verrou, { attendre: false, pid: moi })) {
416
+ return circuitsALOuverture(path.dirname(commun));
417
+ }
85
418
  const autre = tenant();
86
- if (!autre || autre === moi || !vivant(autre)) return '';
419
+ if (!autre || autre === moi || !vivant(autre)) {
420
+ return '';
421
+ }
87
422
  let depuis = '';
88
423
  try {
89
424
  depuis = `, depuis le ${statSync(verrou).mtime.toLocaleString('fr-FR')}`;
@@ -96,7 +431,27 @@ function superviseur(racine, { env = process.env } = {}) {
96
431
  ].join('\n');
97
432
  }
98
433
 
434
+ // The root of the repository at <dossier>, its main tree for a copy; <dossier> out of git.
435
+ function racineDe(dossier) {
436
+ const r = git(dossier, '--git-common-dir');
437
+ return r.status === 0 ? path.dirname(r.stdout.trim()) : dossier;
438
+ }
439
+
99
440
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
100
- const texte = superviseur(process.argv[2] ?? process.cwd());
101
- if (texte) process.stdout.write(`${texte}\n`);
441
+ if (process.argv[2] === '--attendre') {
442
+ try {
443
+ const questions = await attendreUneQuestion({
444
+ racine: racineDe(process.argv[3] ?? process.cwd()),
445
+ });
446
+ process.stdout.write(`${texteDesQuestions(questions)}\n`);
447
+ } catch (e) {
448
+ process.stderr.write(`${e.message}\n`);
449
+ process.exitCode = 1;
450
+ }
451
+ } else {
452
+ const texte = superviseur(process.argv[2] ?? process.cwd());
453
+ if (texte) {
454
+ process.stdout.write(`${texte}\n`);
455
+ }
456
+ }
102
457
  }