@roomi-fields/grillhouse 0.37.0 → 0.38.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 (46) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/charte.md +8 -1
  4. package/dist/temporal/circuit/activites.js +4 -1
  5. package/dist/temporal/circuit/activites.js.map +1 -1
  6. package/dist/temporal/places/contrat.d.ts +2 -0
  7. package/dist/temporal/tickets/activites.js +7 -2
  8. package/dist/temporal/tickets/activites.js.map +1 -1
  9. package/docs/ARCHITECTURE.md +7 -2
  10. package/docs/INTERFACE.md +8 -3
  11. package/hooks/register.tsx +95 -78
  12. package/package.json +1 -1
  13. package/scripts/activites.mjs +54 -13
  14. package/scripts/circuit.mjs +16 -5
  15. package/scripts/circuits-cles.d.mts +3 -0
  16. package/scripts/circuits-cles.mjs +20 -0
  17. package/scripts/composition-des-langages.mjs +1 -0
  18. package/scripts/dependances-internes.mjs +9 -2
  19. package/scripts/donnees-cles.mjs +0 -1
  20. package/scripts/enveloppe/enveloppe.mjs +1 -1
  21. package/scripts/file-des-tickets.d.mts +6 -0
  22. package/scripts/file-des-tickets.mjs +30 -4
  23. package/scripts/grillhouse-maj.mjs +4 -3
  24. package/scripts/groupe-cles.mjs +4 -2
  25. package/scripts/integration/integrer.mjs +31 -16
  26. package/scripts/jointure.d.ts +9 -0
  27. package/scripts/langages/cargo/index.mjs +2 -1
  28. package/scripts/langages/cargo/verdict.mjs +14 -0
  29. package/scripts/langages/python/index.mjs +2 -0
  30. package/scripts/langages/typescript/code-mort.mjs +59 -9
  31. package/scripts/langages/typescript/index.mjs +7 -4
  32. package/scripts/langages/typescript/vitest-config/base.mjs +3 -0
  33. package/scripts/langages/typescript/vitest.nuit.config.mjs +1 -0
  34. package/scripts/ligne-etat/ligne-etat.mjs +20 -4
  35. package/scripts/nuit.sh +6 -3
  36. package/scripts/prefixe-des-tickets.mjs +12 -0
  37. package/scripts/regles-des-places.d.mts +4 -0
  38. package/scripts/regles-des-places.mjs +11 -2
  39. package/scripts/services-du-noyau.mjs +1 -0
  40. package/scripts/suiveur.mjs +362 -0
  41. package/scripts/tableau.mjs +110 -75
  42. package/scripts/ticket.sh +4 -2
  43. package/scripts/transitions.d.mts +2 -0
  44. package/scripts/transitions.mjs +38 -4
  45. package/scripts/un-commit-par-ticket.mjs +21 -24
  46. package/skills/pitmaster/SKILL.md +9 -0
@@ -0,0 +1,362 @@
1
+ // The follower of the board (`grillhouse tableau --suivre`): one producer that follows the events
2
+ // and, at each measure, writes the status line's text (`grillhouse-etat.txt`) and the pane's line
3
+ // (`grillhouse-tableau.ligne`) from that one measure, in the common git directory. The status line
4
+ // and the pane are readers; as watchman or `tsc --watch` keep one watch and one state.
5
+ //
6
+ // - A measure follows an event: a change under `.beads/`, a change of the git state (HEAD, the
7
+ // references), a change of the set of circuits (a light poll of Temporal), the end of a bd or git
8
+ // command (through the first two). Events close together fold into one measure (`rebondir`).
9
+ // - Without an event, a measure every SECOURS; every AVANCEMENT while a line of progress shows.
10
+ // - One follower writes per repository: it holds the lock `grillhouse-suiveur.verrou` of the common
11
+ // directory; another follower relays the lines the writer writes, and takes the lock over when
12
+ // the writer's process is gone.
13
+ // - Each line the writer writes goes to the standard output, one JSON board per line.
14
+ import { mkdirSync, readFileSync, renameSync, rmSync, watch, writeFileSync } from 'node:fs';
15
+ import path from 'node:path';
16
+
17
+ import { vivant as processVivant } from './mesure/base-de-passe.mjs';
18
+
19
+ // The measure (the board) and the common git folder come from the command that starts the
20
+ // follower (`tableau --suivre`), which owns them: the status line imports this module for
21
+ // `lireEtat` and must start fast, and no cycle ties it to the board.
22
+
23
+ /** A status measure older than this shows nothing in the status line. */
24
+ export const PEREMPTION = 10 * 60_000;
25
+ /** The longest wait between two measures without an event. */
26
+ export const SECOURS = 5 * 60_000;
27
+ /** The wait between two measures while a line of progress shows. */
28
+ export const AVANCEMENT = 10_000;
29
+ /** Events closer than this fold into one measure. */
30
+ export const REBOND = 300;
31
+ // The light poll of Temporal.
32
+ const SONDAGE = 15_000;
33
+ // How often a relaying follower looks at the lock of the writer.
34
+ const RELEVE = 15_000;
35
+
36
+ const FICHIER_ETAT = 'grillhouse-etat.txt';
37
+ const FICHIER_LIGNE = 'grillhouse-tableau.ligne';
38
+ const FICHIER_VERROU = 'grillhouse-suiveur.verrou';
39
+
40
+ // Writes `contenu` to `fichier` whole: a reader never sees it half written.
41
+ function ecrire(fichier, contenu) {
42
+ const prive = `${fichier}.${process.pid}.tmp`;
43
+ writeFileSync(prive, contenu);
44
+ renameSync(prive, fichier);
45
+ }
46
+
47
+ /**
48
+ * Measures the board once and writes both outputs from that one call: the status text with the
49
+ * time of the measure, and the pane's line.
50
+ * @param {string} racine
51
+ * @param {{ commun: string | null, mesure: Function, projets?: string[], maintenant?: number }} o
52
+ * @returns {Promise<{ texte: string, ligne: string }>}
53
+ */
54
+ export async function mesurerUneFois(
55
+ racine,
56
+ { commun, mesure, projets = [], maintenant = Date.now() }
57
+ ) {
58
+ const t = await mesure(racine, { projets, maintenant });
59
+ const texte = t.etat ?? '';
60
+ const ligne = JSON.stringify(t);
61
+ if (commun) {
62
+ try {
63
+ ecrire(path.join(commun, FICHIER_ETAT), JSON.stringify({ texte, mesure: maintenant }));
64
+ ecrire(path.join(commun, FICHIER_LIGNE), `${ligne}\n`);
65
+ } catch {
66
+ // A read-only place keeps the follower working, without its files.
67
+ }
68
+ }
69
+ return { texte, ligne };
70
+ }
71
+
72
+ /**
73
+ * The status text a file's content holds, or '' when it is empty, unreadable, timeless or older
74
+ * than PEREMPTION at `maintenant`.
75
+ * @param {string} contenu
76
+ * @param {number} maintenant
77
+ */
78
+ export function lireEtat(contenu, maintenant) {
79
+ try {
80
+ const { texte, mesure } = JSON.parse(contenu);
81
+ if (typeof texte !== 'string' || typeof mesure !== 'number') {
82
+ return '';
83
+ }
84
+ return maintenant - mesure > PEREMPTION ? '' : texte;
85
+ } catch {
86
+ return '';
87
+ }
88
+ }
89
+
90
+ /**
91
+ * The wait, in ms, before the next measure without an event.
92
+ * @param {{ derniere: number, maintenant: number, avancement: boolean }} o
93
+ */
94
+ export const delaiAvantLaMesure = ({ derniere, maintenant, avancement }) =>
95
+ Math.max(0, derniere + (avancement ? AVANCEMENT : SECOURS) - maintenant);
96
+
97
+ /**
98
+ * A key of the set of circuits: step, attempt and life of each ticket's circuit, in any order,
99
+ * whatever its progress counters.
100
+ * @param {{ ticket: string, etape: string, tentative?: number, vivant?: boolean }[]} circuits
101
+ */
102
+ export const empreinteDesCircuits = circuits =>
103
+ JSON.stringify(
104
+ circuits
105
+ .map(c => [c.ticket, c.etape, c.tentative ?? null, c.vivant ?? null])
106
+ .sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
107
+ );
108
+
109
+ /**
110
+ * Folds the events asked within `ms` of each other into one call of `mesure`.
111
+ * @param {number} ms
112
+ * @param {() => void} mesure
113
+ */
114
+ export function rebondir(ms, mesure) {
115
+ let minuteur = null;
116
+ return {
117
+ demander() {
118
+ clearTimeout(minuteur);
119
+ minuteur = setTimeout(() => {
120
+ minuteur = null;
121
+ mesure();
122
+ }, ms);
123
+ },
124
+ annuler() {
125
+ clearTimeout(minuteur);
126
+ minuteur = null;
127
+ },
128
+ };
129
+ }
130
+
131
+ /**
132
+ * Watches the files that tell the board changed: `.beads/`, and the git state (HEAD, packed-refs,
133
+ * the references) of the common directory. Each change asks, folded by `rebond`, for `quand`.
134
+ * @param {{ racine: string, commun: string, rebond?: number, quand: () => void }} o
135
+ * @returns {{ fermer: () => void }}
136
+ */
137
+ export function veiller({ racine, commun, rebond = REBOND, quand }) {
138
+ const r = rebondir(rebond, quand);
139
+ const veilles = [];
140
+ const sur = (dossier, options, garde) => {
141
+ try {
142
+ veilles.push(
143
+ watch(dossier, options, (_evenement, nom) => {
144
+ if (garde(String(nom ?? ''))) {
145
+ r.demander();
146
+ }
147
+ })
148
+ );
149
+ } catch {
150
+ // A folder that does not exist is not watched.
151
+ }
152
+ };
153
+ sur(path.join(racine, '.beads'), { recursive: true }, () => true);
154
+ // The day's marker (`grillhouse newday`) moves the board too.
155
+ sur(commun, {}, nom => nom === 'HEAD' || nom === 'packed-refs' || nom === 'tableau-repere.json');
156
+ sur(path.join(commun, 'refs'), { recursive: true }, () => true);
157
+ return {
158
+ fermer() {
159
+ r.annuler();
160
+ for (const v of veilles) {
161
+ v.close();
162
+ }
163
+ },
164
+ };
165
+ }
166
+
167
+ /**
168
+ * Takes the lock of the writing follower of the repository whose common directory is `commun`; a
169
+ * lock of a dead process is taken over.
170
+ * @param {string} commun
171
+ * @param {{ pid?: number, vivant?: (pid: number) => boolean }} [o]
172
+ * @returns {{ pris: boolean, detenteur: number | null, liberer: () => void }}
173
+ */
174
+ export function prendreLeVerrou(commun, { pid = process.pid, vivant = processVivant } = {}) {
175
+ const verrou = path.join(commun, FICHIER_VERROU);
176
+ const lire = () => {
177
+ const n = Number(readFileSync(verrou, 'utf8').trim());
178
+ return Number.isInteger(n) && n > 0 ? n : null;
179
+ };
180
+ for (let essai = 0; essai < 5; essai++) {
181
+ try {
182
+ writeFileSync(verrou, `${pid}\n`, { flag: 'wx' });
183
+ return {
184
+ pris: true,
185
+ detenteur: pid,
186
+ liberer() {
187
+ try {
188
+ if (lire() === pid) {
189
+ rmSync(verrou, { force: true });
190
+ }
191
+ } catch {
192
+ // Already gone.
193
+ }
194
+ },
195
+ };
196
+ } catch (e) {
197
+ if (e.code !== 'EEXIST') {
198
+ break;
199
+ }
200
+ }
201
+ let detenteur = null;
202
+ try {
203
+ detenteur = lire();
204
+ } catch {
205
+ continue;
206
+ }
207
+ if (detenteur !== null && vivant(detenteur)) {
208
+ return { pris: false, detenteur, liberer() {} };
209
+ }
210
+ // The holder is gone: the lock is moved aside (one taker wins), then the taking starts again.
211
+ try {
212
+ const ecarte = `${verrou}.${pid}.reprise`;
213
+ renameSync(verrou, ecarte);
214
+ rmSync(ecarte, { force: true });
215
+ } catch {
216
+ // Another taker moved it first.
217
+ }
218
+ }
219
+ return { pris: false, detenteur: null, liberer() {} };
220
+ }
221
+
222
+ /**
223
+ * Gives each line the writer writes to `surLigne`, the line already written first, without
224
+ * measuring.
225
+ * @param {string} commun
226
+ * @param {(ligne: string) => void} surLigne
227
+ * @returns {{ fermer: () => void }}
228
+ */
229
+ export function relayer(commun, surLigne) {
230
+ const fichier = path.join(commun, FICHIER_LIGNE);
231
+ let derniere = null;
232
+ const lire = () => {
233
+ try {
234
+ const ligne = readFileSync(fichier, 'utf8').trim();
235
+ if (ligne && ligne !== derniere) {
236
+ derniere = ligne;
237
+ surLigne(ligne);
238
+ }
239
+ } catch {
240
+ // Nothing written yet.
241
+ }
242
+ };
243
+ let veille = null;
244
+ try {
245
+ veille = watch(commun, {}, (_e, nom) => {
246
+ if (String(nom ?? '') === FICHIER_LIGNE) {
247
+ lire();
248
+ }
249
+ });
250
+ } catch {
251
+ // A common directory that cannot be watched relays what it read at the start.
252
+ }
253
+ lire();
254
+ return { fermer: () => veille?.close() };
255
+ }
256
+
257
+ /**
258
+ * The follower: measures on events, writes (or relays) and gives each line to `surLigne`, until
259
+ * `fermer`.
260
+ * @param {string} racine
261
+ * @param {{ projets?: string[], surLigne: (ligne: string) => void, mesure: Function, dossierCommun: (racine: string) => string | null }} o
262
+ * @returns {Promise<{ fermer: () => void }>}
263
+ */
264
+ export async function suivre(racine, { projets = [], surLigne, mesure, dossierCommun }) {
265
+ const { circuitsDuServeur } = await import('./circuits-du-serveur.mjs');
266
+ const commun = dossierCommun(racine);
267
+ if (!commun) {
268
+ throw new Error('suivre : le dossier git commun du projet est introuvable.');
269
+ }
270
+ mkdirSync(commun, { recursive: true });
271
+ let ferme = false;
272
+ let ecrivain = null;
273
+ let relais = null;
274
+ let releve = null;
275
+
276
+ const ecrire_ = () => {
277
+ const verrou = prendreLeVerrou(commun);
278
+ if (!verrou.pris) {
279
+ return false;
280
+ }
281
+ relais?.fermer();
282
+ relais = null;
283
+ clearInterval(releve);
284
+ let derniere = 0;
285
+ let avancement = false;
286
+ let empreinte = null;
287
+ let attente = null;
288
+ let enCours = false;
289
+ let encore = false;
290
+ const mesurer = async () => {
291
+ if (ferme) {
292
+ return;
293
+ }
294
+ if (enCours) {
295
+ encore = true;
296
+ return;
297
+ }
298
+ enCours = true;
299
+ try {
300
+ do {
301
+ encore = false;
302
+ const r = await mesurerUneFois(racine, { commun, mesure, projets });
303
+ derniere = Date.now();
304
+ avancement = JSON.parse(r.ligne).lignes?.some(l => l.avancement === true) ?? false;
305
+ surLigne(r.ligne);
306
+ } while (encore && !ferme);
307
+ } catch {
308
+ // A measure that fails is tried again at the next event or the fallback.
309
+ } finally {
310
+ enCours = false;
311
+ planifier();
312
+ }
313
+ };
314
+ const rebond = rebondir(REBOND, () => void mesurer());
315
+ const planifier = () => {
316
+ clearTimeout(attente);
317
+ if (ferme) {
318
+ return;
319
+ }
320
+ attente = setTimeout(
321
+ () => void mesurer(),
322
+ delaiAvantLaMesure({ derniere, maintenant: Date.now(), avancement })
323
+ );
324
+ };
325
+ const veillee = veiller({ racine, commun, quand: () => rebond.demander() });
326
+ const sondage = setInterval(() => {
327
+ circuitsDuServeur(racine)
328
+ .then(c => {
329
+ const e = empreinteDesCircuits(c);
330
+ if (empreinte !== null && e !== empreinte) {
331
+ rebond.demander();
332
+ }
333
+ empreinte = e;
334
+ })
335
+ .catch(() => {});
336
+ }, SONDAGE);
337
+ ecrivain = {
338
+ fermer() {
339
+ clearTimeout(attente);
340
+ clearInterval(sondage);
341
+ rebond.annuler();
342
+ veillee.fermer();
343
+ verrou.liberer();
344
+ },
345
+ };
346
+ void mesurer();
347
+ return true;
348
+ };
349
+
350
+ if (!ecrire_()) {
351
+ relais = relayer(commun, surLigne);
352
+ releve = setInterval(() => void ecrire_(), RELEVE);
353
+ }
354
+ return {
355
+ fermer() {
356
+ ferme = true;
357
+ clearInterval(releve);
358
+ relais?.fermer();
359
+ ecrivain?.fermer();
360
+ },
361
+ };
362
+ }
@@ -8,8 +8,10 @@
8
8
  // npx grillhouse tableau <dossier>… the board of this project and of the projects in <dossier>…,
9
9
  // one board, each ticket prefixed by its project (`ensemble`)
10
10
  //
11
- // Each measure writes the status line (the chantier in progress) to `grillhouse-etat.txt` in the
12
- // common git directory, where the status line (`scripts/ligne-etat/`) reads it.
11
+ // npx grillhouse tableau --suivre the follower (`scripts/suiveur.mjs`): measures on events and
12
+ // writes the status line (`grillhouse-etat.txt` in the common
13
+ // git directory, which `scripts/ligne-etat/` reads) and one
14
+ // JSON board per line, from one measure.
13
15
  //
14
16
  // - Global: the work tickets of the project (a ticket without children; a mother is a grouping)
15
17
  // by state, the agents' working time and tokens of the day and in all, the alerts. The head's
@@ -147,6 +149,7 @@ import {
147
149
  nuitDuServeur,
148
150
  } from './circuits-du-serveur.mjs';
149
151
  import {
152
+ aSonArchitecture,
150
153
  attendDeLAutreProjet,
151
154
  enFileSansArchitecture,
152
155
  lireLesExternes,
@@ -181,6 +184,11 @@ export const roleDuMeta = m =>
181
184
  export const ETATS = [
182
185
  { cle: 'enCours', nom: 'en cours', sens: 'un agent y travaille' },
183
186
  { cle: 'enAttente', nom: 'en attente', sens: 'ton go, prêt à partir' },
187
+ {
188
+ cle: 'attendArchi',
189
+ nom: 'attend archi',
190
+ sens: 'ton go, sa section Architecture reste à écrire',
191
+ },
184
192
  { cle: 'fileDirecte', nom: 'en direct', sens: 'mené hors du circuit, pas encore pris' },
185
193
  { cle: 'bloques', nom: 'bloqué', sens: 'ton go, il attend un autre ticket' },
186
194
  { cle: 'sansGo', nom: 'sans go', sens: 'validé, il attend ton go' },
@@ -198,12 +206,13 @@ export const ETATS = [
198
206
  export const TONS = Object.freeze({
199
207
  // A ticket's state (ETATS).
200
208
  enCours: 'actif',
201
- enAttente: undefined,
202
- fileDirecte: undefined,
203
- bloques: undefined,
209
+ enAttente: 'discret',
210
+ attendArchi: 'discret',
211
+ fileDirecte: 'discret',
212
+ bloques: 'discret',
204
213
  sansGo: 'attention',
205
214
  aValider: 'attention',
206
- reportes: undefined,
215
+ reportes: 'discret',
207
216
  fermes: 'discret',
208
217
  // A circuit, a pass, a wait.
209
218
  attendUnePlace: 'discret',
@@ -900,7 +909,11 @@ export function assembler({
900
909
  // project by its name in Beads' `external_projects`).
901
910
  const attentesExternes = t => attendDeLAutreProjet(t, externes).map(a => a.attend);
902
911
  const prets = tous.filter(
903
- t => t.status === 'open' && blocages(t).length === 0 && attentesExternes(t).length === 0
912
+ t =>
913
+ t.status === 'open' &&
914
+ blocages(t).length === 0 &&
915
+ attentesExternes(t).length === 0 &&
916
+ aSonArchitecture(t)
904
917
  );
905
918
  const aValider = tous.filter(
906
919
  t => t.status !== 'closed' && (t.labels ?? []).includes('a-valider')
@@ -918,9 +931,17 @@ export function assembler({
918
931
  }
919
932
  // The circuits not integrated of the known tickets, open or closed (the queue closes a ticket
920
933
  // before it reads the CI, and its circuit may then wait); a ticket whose circuit runs is in
921
- // progress.
934
+ // progress. A closed ticket keeps its circuit only while it runs or waits for the supervisor:
935
+ // stopped by the supervisor, its lot entered another way, the ticket is done.
922
936
  const parCircuit = new Map(
923
- circuits.filter(c => parId.has(c.ticket) && !c.integre).map(c => [c.ticket, c])
937
+ circuits
938
+ .filter(
939
+ c =>
940
+ parId.has(c.ticket) &&
941
+ !c.integre &&
942
+ (parId.get(c.ticket).status !== 'closed' || c.vivant || attendLeSuperviseur(c))
943
+ )
944
+ .map(c => [c.ticket, c])
924
945
  );
925
946
  const actifs = new Set([
926
947
  ...enCoursMesures.map(v => v.ticket).filter(Boolean),
@@ -962,13 +983,17 @@ export function assembler({
962
983
  if (!circuit(t)) {
963
984
  return 'sansGo';
964
985
  }
965
- return pret.has(t.id) ? 'enAttente' : 'bloques';
986
+ if (pret.has(t.id)) {
987
+ return 'enAttente';
988
+ }
989
+ return bloquePar(t).length ? 'bloques' : 'attendArchi';
966
990
  };
967
991
 
968
992
  // Global.
969
993
  const compteurs = {
970
994
  enCours: 0,
971
995
  enAttente: 0,
996
+ attendArchi: 0,
972
997
  fileDirecte: 0,
973
998
  bloques: 0,
974
999
  fermes: 0,
@@ -1199,13 +1224,16 @@ export function assembler({
1199
1224
  partDuSuperviseur.set(x.id, (partDuSuperviseur.get(x.id) ?? 0) + n / tenus.length);
1200
1225
  }
1201
1226
  }
1227
+ // A finding is done only once led to its end: validated and carried by the circuit, or led
1228
+ // direct; a finding just recorded, or rejected at its sorting, is no work done.
1229
+ const menee = t => aLabel(t, 'circuit') || aLabel(t, 'direct');
1202
1230
  const faitsDuJour = tous
1203
1231
  .filter(
1204
1232
  t =>
1205
1233
  travail(t) &&
1206
1234
  !actifs.has(t.id) &&
1207
1235
  !parCircuit.has(t.id) &&
1208
- !estDecouverte(t) &&
1236
+ !(estDecouverte(t) && !menee(t)) &&
1209
1237
  !sansLivraison(t) &&
1210
1238
  t.closed_at &&
1211
1239
  Date.parse(t.closed_at) >= debutJour
@@ -1721,17 +1749,31 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1721
1749
  L(nom.toUpperCase(), TONS.titre);
1722
1750
  // The state of each ticket's line of AGENTS, which AGENTS draws and the head counts.
1723
1751
  const etats = etatsDAgents(t);
1724
- // The first line of the head, the signs of AGENTS counted (`comptesDAgents`) as AGENTS signs its
1725
- // lines, then the tickets done: « ▶ N · ⏸ N · ⛔ N · ✓ N ».
1726
- const ligneDesSignes = (a, fermes) =>
1727
- `▶ ${a.enCours} · ⏸ ${a.enAttente} · ⛔ ${a.arretes} · ✓ ${fermes}`;
1728
- // The line of the queues, under their signs: ● the tickets ready for the circuit, ✎ the direct
1729
- // queue, ⊘ the tickets blocked by an open ticket.
1730
- const ligneDeLaFile = c =>
1731
- `⏭ file : ● ${c.enAttente} · ✎ ${c.fileDirecte ?? 0} · ⊘ ${c.bloques ?? 0}`;
1752
+ // The three lines of the head, grouped by who acts, each with its tone from TONS; an absent
1753
+ // counter reads 0. « toi »: what the owner decides or validates (sans go, à valider, question: the
1754
+ // circuits of AGENTS stopped on a question, `comptesDAgents`); « file »: the queues (● ready,
1755
+ // ✎ direct, ⧗ attend archi, ⊘ blocked); « en cours »: where nobody acts (▶ in progress, ✓ done,
1756
+ // ⏸ deferred).
1757
+ const lignesDActeurs = (c, questions) => {
1758
+ const n = k => c[k] ?? 0;
1759
+ return [
1760
+ {
1761
+ texte: `toi : ${n('sansGo')} sans go · ${n('aValider')} à valider · ${questions} question`,
1762
+ ton: n('sansGo') ? TONS.sansGo : n('aValider') || questions ? TONS.aValider : TONS.fermes,
1763
+ },
1764
+ {
1765
+ texte: `file : ● ${n('enAttente')} · ✎ ${n('fileDirecte')} · ⧗ ${n('attendArchi')} · ⊘ ${n('bloques')}`,
1766
+ ton: TONS.enAttente,
1767
+ },
1768
+ {
1769
+ texte: `en cours : ▶ ${n('enCours')} · ✓ ${n('fermes')} · ⏸ ${n('reportes')}`,
1770
+ ton: n('enCours') ? TONS.enCours : TONS.fermes,
1771
+ },
1772
+ ];
1773
+ };
1732
1774
  if (plusieurs) {
1733
- // The three lines of states of each project, as one project's board says them: the first
1734
- // under its label, the two others aligned below it; or the fault that keeps its board out.
1775
+ // The three lines of each project, as one project's board says them: the first under its
1776
+ // label, the two others aligned below it; or the fault that keeps its board out.
1735
1777
  const retrait = ' '.repeat(large);
1736
1778
  for (const p of t.projets) {
1737
1779
  if (p.erreur) {
@@ -1739,21 +1781,8 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1739
1781
  continue;
1740
1782
  }
1741
1783
  const c = p.compteurs;
1742
- L(
1743
- cadre(
1744
- `${colonneDe(p.etiquette)}${ligneDesSignes(comptesDAgents(t, p.etiquette), c.fermes)}`,
1745
- '',
1746
- largeur
1747
- )
1748
- );
1749
- L(cadre(`${retrait}${ligneDeLaFile(c)}`, '', largeur));
1750
- L(
1751
- cadre(
1752
- `${retrait}${c.sansGo ?? 0} sans go · ${c.aValider ?? 0} à valider · ${c.reportes ?? 0} reportés`,
1753
- '',
1754
- largeur
1755
- ),
1756
- c.sansGo ? TONS.sansGo : c.aValider ? TONS.aValider : TONS.reportes
1784
+ lignesDActeurs(c, comptesDAgents(t, p.etiquette).arretes).forEach((x, i) =>
1785
+ L(cadre(`${i ? retrait : colonneDe(p.etiquette)}${x.texte}`, '', largeur), x.ton)
1757
1786
  );
1758
1787
  }
1759
1788
  // The discoveries of the day, summed across the projects (grillhouse-3uv.96, criterion 14).
@@ -1769,14 +1798,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1769
1798
  } else {
1770
1799
  const g = t.global;
1771
1800
  const c = g.compteurs;
1772
- // Three lines of states: the signs of AGENTS and the tickets done, the queues (the circuit's,
1773
- // the direct one, the blocked), then those that wait for the owner.
1774
- L(cadre(ligneDesSignes(comptesDAgents(t), c.fermes), '', largeur));
1775
- L(cadre(ligneDeLaFile(c), '', largeur));
1776
- L(
1777
- cadre(`${c.sansGo} sans go · ${c.aValider} à valider · ${c.reportes} reportés`, '', largeur),
1778
- c.sansGo ? TONS.sansGo : c.aValider ? TONS.aValider : TONS.reportes
1779
- );
1801
+ // Three lines of states, grouped by who acts.
1802
+ for (const x of lignesDActeurs(c, comptesDAgents(t).arretes)) {
1803
+ L(cadre(x.texte, '', largeur), x.ton);
1804
+ }
1780
1805
  // The discoveries of the day, one count per case (grillhouse-3uv.96): always shown, at 0 when
1781
1806
  // nothing counts, like the other head lines.
1782
1807
  const d = g.decouvertes ?? { new: 0, check: 0, rejetes: 0, valides: 0 };
@@ -2149,8 +2174,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2149
2174
  ? '? à valider'
2150
2175
  : n.etat === 'sansGo'
2151
2176
  ? 'sans go'
2152
- : n.etat === 'enAttente'
2153
- ? 'en attente'
2177
+ : n.etat === 'attendArchi'
2178
+ ? 'attend archi'
2179
+ : n.etat === 'enAttente'
2180
+ ? 'en attente'
2154
2181
  : n.etat === 'reportes'
2155
2182
  ? 'reporté'
2156
2183
  : n.etat === 'fermes'
@@ -2569,25 +2596,15 @@ function lire(
2569
2596
  nuit = null,
2570
2597
  }
2571
2598
  ) {
2572
- // The prefix is read once, with no delay of its own; a read that fails leaves it empty (the
2599
+ // The prefix is read once, from `.beads/config.yaml`; a read that fails leaves it empty (the
2573
2600
  // project is labelled by its folder) and its cause is named in an alert (`echecPrefixe`).
2574
2601
  let prefix = '';
2575
2602
  let echecPrefixe = null;
2576
2603
  try {
2577
- prefix = execFileSync('bd', ['config', 'get', 'issue_prefix'], {
2578
- cwd: racine,
2579
- encoding: 'utf8',
2580
- stdio: ['ignore', 'pipe', 'pipe'],
2581
- maxBuffer: 256 * 1024 * 1024,
2582
- }).trim();
2604
+ prefix = prefixeDeLaRacine(racine);
2583
2605
  } catch (e) {
2584
2606
  prefix = '';
2585
- const message = String(e?.stderr ?? '').trim() || String(e?.message ?? e);
2586
- const ligne = message.split('\n')[0];
2587
- echecPrefixe =
2588
- e?.status === null || e?.status === undefined
2589
- ? `${e?.code ?? 'échec'} ${ligne}`.trim()
2590
- : `code ${e.status} ${ligne}`.trim();
2607
+ echecPrefixe = String(e?.message ?? e);
2591
2608
  }
2592
2609
  let ps = '';
2593
2610
  try {
@@ -2876,13 +2893,6 @@ export async function tableau(
2876
2893
  ici.commun ? path.dirname(ici.commun) : null
2877
2894
  );
2878
2895
  const etat = ligneEtat(ici.t, autres.map(l => l.t).filter(Boolean));
2879
- try {
2880
- if (ici.commun) {
2881
- writeFileSync(path.join(ici.commun, 'grillhouse-etat.txt'), `${etat}\n`);
2882
- }
2883
- } catch {
2884
- // A read-only place keeps the board working, without its status line.
2885
- }
2886
2896
  const t = projets.length
2887
2897
  ? ensemble(lus.map(l => ({ etiquette: etiquette(l), t: l.t, erreur: l.erreur })))
2888
2898
  : ici.t;
@@ -2921,16 +2931,41 @@ export async function tableau(
2921
2931
  }
2922
2932
 
2923
2933
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
2924
- // The arguments other than --texte are the folders of the other projects.
2934
+ // The arguments other than --texte and --suivre are the folders of the other projects.
2925
2935
  const projets = process.argv
2926
2936
  .slice(2)
2927
- .filter(a => a !== '--texte')
2937
+ .filter(a => a !== '--texte' && a !== '--suivre')
2928
2938
  .map(d => path.resolve(d));
2929
- void tableau(process.cwd(), { projets }).then(t =>
2930
- process.stdout.write(
2931
- process.argv.includes('--texte')
2932
- ? `${t.lignes.map(l => l.texte).join('\n')}\n`
2933
- : JSON.stringify(t)
2934
- )
2935
- );
2939
+ if (process.argv.includes('--suivre')) {
2940
+ // The follower (scripts/suiveur.mjs): one JSON board per line on the standard output.
2941
+ const { suivre } = await import('./suiveur.mjs');
2942
+ const suiveur = await suivre(process.cwd(), {
2943
+ projets,
2944
+ mesure: tableau,
2945
+ dossierCommun,
2946
+ surLigne: ligne => process.stdout.write(`${ligne}\n`),
2947
+ });
2948
+ // The pane that started the follower is gone when the standard output closes or its process
2949
+ // is no longer the parent. The end closes the follower and the watch of the parent; the
2950
+ // process then ends by itself once nothing holds it.
2951
+ const parent = process.ppid;
2952
+ const veilleDuParent = setInterval(() => process.ppid !== parent && fin(), 5_000);
2953
+ const fin = () => {
2954
+ process.exitCode = 0;
2955
+ suiveur.fermer();
2956
+ clearInterval(veilleDuParent);
2957
+ };
2958
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
2959
+ process.on(signal, fin);
2960
+ }
2961
+ process.stdout.on('error', fin);
2962
+ } else {
2963
+ void tableau(process.cwd(), { projets }).then(t =>
2964
+ process.stdout.write(
2965
+ process.argv.includes('--texte')
2966
+ ? `${t.lignes.map(l => l.texte).join('\n')}\n`
2967
+ : JSON.stringify(t)
2968
+ )
2969
+ );
2970
+ }
2936
2971
  }