@roomi-fields/grillhouse 0.34.0 → 0.34.2

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 (37) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +34 -2
  3. package/cadre/templates/projet/_gitignore +1 -0
  4. package/cadre/templates/projet/package.json +2 -2
  5. package/dist/temporal/acte.d.ts +7 -0
  6. package/dist/temporal/acte.js +19 -2
  7. package/dist/temporal/acte.js.map +1 -1
  8. package/dist/temporal/circuit/appel.d.ts +2 -0
  9. package/dist/temporal/circuit/appel.js +12 -0
  10. package/dist/temporal/circuit/appel.js.map +1 -1
  11. package/dist/temporal/circuit/commande.js +10 -1
  12. package/dist/temporal/circuit/commande.js.map +1 -1
  13. package/docs/ARCHITECTURE.md +12 -0
  14. package/package.json +1 -1
  15. package/scripts/adresse-du-registre.mjs +10 -0
  16. package/scripts/attente-a-l-arret.mjs +2 -2
  17. package/scripts/attente-au-tour.mjs +2 -2
  18. package/scripts/bilan.mjs +5 -4
  19. package/scripts/branche-de-nuit.mjs +15 -6
  20. package/scripts/ci-des-branches.mjs +4 -2
  21. package/scripts/etapes.mjs +7 -5
  22. package/scripts/integration/file.mjs +7 -6
  23. package/scripts/jointure.d.ts +10 -3
  24. package/scripts/langages/cargo/commandes.mjs +10 -2
  25. package/scripts/langages/cargo/sccache.mjs +22 -16
  26. package/scripts/langages/python/commandes.mjs +3 -0
  27. package/scripts/langages/typescript/index.mjs +8 -4
  28. package/scripts/langages/typescript/migrations/0.34.1-cache-des-outils.mjs +53 -0
  29. package/scripts/langages/typescript/resume-du-lanceur.mjs +8 -2
  30. package/scripts/langages/typescript/vitest-config/base.mjs +10 -0
  31. package/scripts/langages/typescript/vitest-config/registre.setup.mjs +35 -0
  32. package/scripts/migrations-des-gardes.mjs +15 -4
  33. package/scripts/registre.mjs +3 -3
  34. package/scripts/reponses-du-circuit.mjs +1 -1
  35. package/scripts/superviseur.mjs +24 -11
  36. package/scripts/tableau.mjs +164 -39
  37. package/scripts/taches-du-graphe.mjs +22 -8
@@ -121,6 +121,7 @@ import {
121
121
  } from './etapes.mjs';
122
122
  import { echecDeLOutil } from './aiguillage.mjs';
123
123
  import { bilansGardes, enBref } from './bilan.mjs';
124
+ import { REGISTRE } from './adresse-du-registre.mjs';
124
125
  import { lireLaMesure } from './avancement.mjs';
125
126
  import {
126
127
  SANS_REPONSE_EN,
@@ -157,6 +158,7 @@ export const roleDuMeta = m =>
157
158
  export const ETATS = [
158
159
  { cle: 'enCours', nom: 'en cours', sens: 'un agent y travaille' },
159
160
  { cle: 'enAttente', nom: 'en attente', sens: 'ton go, prêt à partir' },
161
+ { cle: 'fileDirecte', nom: 'en direct', sens: 'mené hors du circuit, pas encore pris' },
160
162
  { cle: 'bloques', nom: 'bloqué', sens: 'ton go, il attend un autre ticket' },
161
163
  { cle: 'sansGo', nom: 'sans go', sens: 'validé, il attend ton go' },
162
164
  { cle: 'aValider', nom: 'à valider', sens: 'une trouvaille attend ton accord' },
@@ -174,6 +176,7 @@ export const TONS = Object.freeze({
174
176
  // A ticket's state (ETATS).
175
177
  enCours: 'actif',
176
178
  enAttente: undefined,
179
+ fileDirecte: undefined,
177
180
  bloques: undefined,
178
181
  sansGo: 'attention',
179
182
  aValider: 'attention',
@@ -259,6 +262,7 @@ const etatNeuf = () => ({
259
262
  tours: [],
260
263
  recu: false,
261
264
  vus: [],
265
+ minutes: {},
262
266
  });
263
267
 
264
268
  // The union of intervals, ordered by date: no instant is in two of them.
@@ -348,8 +352,15 @@ function avancer(etat, texte) {
348
352
  if (id) {
349
353
  vus.add(id);
350
354
  }
351
- etat.jetons +=
352
- (u.input_tokens ?? 0) + (u.output_tokens ?? 0) + (u.cache_creation_input_tokens ?? 0);
355
+ const n = (u.input_tokens ?? 0) + (u.output_tokens ?? 0) + (u.cache_creation_input_tokens ?? 0);
356
+ etat.jetons += n;
357
+ // The tokens by minute of their message, which share the supervisor's among the tickets he
358
+ // leads directly (`jetonsDuSuperviseur`); a state kept before them starts its own.
359
+ if (!Number.isNaN(t)) {
360
+ etat.minutes ??= {};
361
+ const minute = Math.floor(t / 60_000);
362
+ etat.minutes[minute] = (etat.minutes[minute] ?? 0) + n;
363
+ }
353
364
  etat.cache += u.cache_read_input_tokens ?? 0;
354
365
  // The usage of the message's model: a write of the cache by its duration, one without them
355
366
  // of five minutes, the default of the API.
@@ -392,6 +403,7 @@ const mesurer = etat => ({
392
403
  role: etat.role,
393
404
  cout: etat.cout,
394
405
  modeles: structuredClone(etat.modeles),
406
+ minutes: { ...(etat.minutes ?? {}) },
395
407
  });
396
408
 
397
409
  // The measures of the transcript text `texte` held in memory.
@@ -570,6 +582,25 @@ const metaDe = f => {
570
582
  }
571
583
  };
572
584
 
585
+ /**
586
+ * The tokens of the supervisor's sessions of the repository at <racine> by minute (`{ <minute>:
587
+ * <tokens> }`, the minute since the epoch): its main transcripts touched since the day's marker
588
+ * <jour>, read through <cache>; the sub-agents' are counted by their tickets.
589
+ */
590
+ export function jetonsDuSuperviseur({ racine, home, jour, cache = {} }) {
591
+ const lire = lecteur(cache);
592
+ const out = {};
593
+ for (const f of fichiers(path.join(home, '.claude', 'projects', enTirets(racine)), '.jsonl')) {
594
+ if (statSync(f).mtimeMs < jour) {
595
+ continue;
596
+ }
597
+ for (const [minute, n] of Object.entries(lire(f)?.minutes ?? {})) {
598
+ out[minute] = (out[minute] ?? 0) + n;
599
+ }
600
+ }
601
+ return out;
602
+ }
603
+
573
604
  // The agents running now, each with its measures so far. `ps` is the process list
574
605
  // (`pid etimes args` per line); `cache` keeps the readings of unchanged transcripts. A role agent
575
606
  // launched in a shell shows by the envelope lancer.sh starts for it,
@@ -774,7 +805,8 @@ export function lecture(t, prefix) {
774
805
  * places'; `muet`, the Temporal
775
806
  * server did not answer the reading of the circuits, which the first alert says; `faute`, any
776
807
  * other fault of that reading, said in the first alert as it is; `echecPrefixe`, the cause of a
777
- * ticket prefix that did not read, named in an alert.
808
+ * ticket prefix that did not read, named in an alert; `voies`, the way of each circuit done
809
+ * (`voiesDesCircuits`), whose sign FAITS AUJOURD'HUI shows.
778
810
  * @param {{ tous: any[], prefix?: string, registre: any[], vivants: any[], circuits?: any[],
779
811
  * maintenant: number, jour: number,
780
812
  * machine?: Machine | null, outil?: { version: string, raison: string } | null,
@@ -782,7 +814,7 @@ export function lecture(t, prefix) {
782
814
  * coeurs: number, memoireGo: number, memoireTotaleGo: number, attentes: { ticket: string,
783
815
  * depuis: number, disque?: string | null }[] } | null,
784
816
  * nuit?: { racine: string, depuis: number | null } | null, muet?: boolean, faute?: string | null,
785
- * echecPrefixe?: string | null }} lu
817
+ * echecPrefixe?: string | null, voies?: Record<string, 'complet' | 'court'> }} lu
786
818
  */
787
819
  export function assembler({
788
820
  tous,
@@ -801,6 +833,8 @@ export function assembler({
801
833
  echecPrefixe = null,
802
834
  remontees = [],
803
835
  attenteVivante: attenteQuiVit = true,
836
+ voies = {},
837
+ superviseur = {},
804
838
  }) {
805
839
  // A circuit's lines are its steps, no agent's passage.
806
840
  const etapesFinies = lignesDuRegistre.filter(r => r.role === ROLE_DU_CIRCUIT);
@@ -876,6 +910,10 @@ export function assembler({
876
910
  if (avalider.has(t.id)) {
877
911
  return 'aValider';
878
912
  }
913
+ // A ticket led out of the circuit, not yet claimed: the direct queue.
914
+ if ((t.labels ?? []).includes('direct')) {
915
+ return 'fileDirecte';
916
+ }
879
917
  if (!circuit(t)) {
880
918
  return 'sansGo';
881
919
  }
@@ -886,6 +924,7 @@ export function assembler({
886
924
  const compteurs = {
887
925
  enCours: 0,
888
926
  enAttente: 0,
927
+ fileDirecte: 0,
889
928
  bloques: 0,
890
929
  fermes: 0,
891
930
  sansGo: 0,
@@ -1084,22 +1123,72 @@ export function assembler({
1084
1123
  });
1085
1124
  }
1086
1125
  const debutJour = jour;
1126
+ // The way of a ticket done (grillhouse-592): `direct` when labelled so; else the way its kept
1127
+ // results give (`voies`, `voiesDesCircuits`: `court` through 1.1, else `complet`); else
1128
+ // `complet` when a circuit led a step of it (the register) or is read for it; else `direct`,
1129
+ // closed with no circuit.
1130
+ const parUnCircuit = new Set([...etapesFinies.map(r => r.ticket), ...parCircuit.keys()]);
1131
+ const voieDe = t =>
1132
+ (t.labels ?? []).includes('direct')
1133
+ ? 'direct'
1134
+ : (voies[t.id] ?? (parUnCircuit.has(t.id) ? 'complet' : 'direct'));
1135
+ // A ticket closed with no delivery: a duplicate, superseded (`bd duplicate`, `bd supersede`), or
1136
+ // labelled `sans-suite`.
1137
+ const sansLivraison = t =>
1138
+ (t.dependencies ?? []).some(d => d.type === 'duplicates' || d.type === 'supersedes') ||
1139
+ aLabel(t, 'sans-suite');
1140
+ // The supervisor leads a direct ticket from its claim to its close (now while it runs): each
1141
+ // minute of his tokens is shared among the direct tickets he holds at that minute.
1142
+ const tenusEnDirect = tous
1143
+ .filter(t => voieDe(t) === 'direct' && Number.isFinite(Date.parse(t.started_at ?? '')))
1144
+ .map(t => ({
1145
+ id: t.id,
1146
+ debut: Math.floor(Date.parse(t.started_at) / 60_000),
1147
+ fin: Math.floor((t.closed_at ? Date.parse(t.closed_at) : maintenant) / 60_000),
1148
+ }));
1149
+ const partDuSuperviseur = new Map();
1150
+ for (const [cle, n] of Object.entries(superviseur)) {
1151
+ const minute = Number(cle);
1152
+ const tenus = tenusEnDirect.filter(x => x.debut <= minute && minute <= x.fin);
1153
+ for (const x of tenus) {
1154
+ partDuSuperviseur.set(x.id, (partDuSuperviseur.get(x.id) ?? 0) + n / tenus.length);
1155
+ }
1156
+ }
1087
1157
  const faitsDuJour = tous
1088
1158
  .filter(
1089
1159
  t =>
1090
1160
  travail(t) &&
1091
1161
  !actifs.has(t.id) &&
1092
1162
  !estDecouverte(t) &&
1163
+ !sansLivraison(t) &&
1093
1164
  t.closed_at &&
1094
1165
  Date.parse(t.closed_at) >= debutJour
1095
1166
  )
1096
1167
  .sort((a, b) => Date.parse(b.closed_at) - Date.parse(a.closed_at))
1097
- .map(t => ({
1098
- id: t.id,
1099
- numero: numero(t.id),
1100
- sujet: titre(t).sujet,
1101
- ...mesure(new Set([t.id])),
1102
- }));
1168
+ .map(t => {
1169
+ const m = mesure(new Set([t.id]));
1170
+ const voie = voieDe(t);
1171
+ // A circuit's time is its agents' and steps' working time; a direct ticket's runs from its
1172
+ // claim to its close, null without a claim.
1173
+ const pris = Date.parse(t.started_at ?? '');
1174
+ const dure =
1175
+ voie !== 'direct'
1176
+ ? m.travail
1177
+ : Number.isFinite(pris)
1178
+ ? Date.parse(t.closed_at) - pris
1179
+ : null;
1180
+ const jetons =
1181
+ m.jetons + Math.round(voie === 'direct' ? (partDuSuperviseur.get(t.id) ?? 0) : 0);
1182
+ return {
1183
+ id: t.id,
1184
+ numero: numero(t.id),
1185
+ sujet: titre(t).sujet,
1186
+ voie,
1187
+ duree: dure,
1188
+ ...m,
1189
+ jetons,
1190
+ };
1191
+ });
1103
1192
 
1104
1193
  // Alerts, each with its state (`etat`) and the tone of that state (TONS).
1105
1194
  const alertes = [];
@@ -1217,7 +1306,7 @@ export function assembler({
1217
1306
  // The tickets worked out of a circuit: claimed (`in_progress`), no circuit on the server that
1218
1307
  // holds them, a mother of theirs or a ticket under them (a circuit holds its ticket's mothers and
1219
1308
  // children): one that runs or waits for an answer (`attendLeSuperviseur`), never one the
1220
- // supervisor stopped; or labelled `direct`, open or claimed (led out of the circuit); and no role
1309
+ // supervisor stopped; or labelled `direct` and claimed (led out of the circuit); and no role
1221
1310
  // agent shown at a step. None while the circuits do not read (a
1222
1311
  // silent server, a fault), when no ticket can be told out of a circuit.
1223
1312
  const aUneEtape = new Set(blocs.flatMap(b => b.enCours.map(x => x.id)));
@@ -1241,16 +1330,14 @@ export function assembler({
1241
1330
  t =>
1242
1331
  travail(t) &&
1243
1332
  !aUneEtape.has(t.id) &&
1244
- ((t.status === 'in_progress' && !dansUnCircuit(t)) ||
1245
- ((t.labels ?? []).includes('direct') &&
1246
- (t.status === 'open' || t.status === 'in_progress')))
1333
+ t.status === 'in_progress' &&
1334
+ (!dansUnCircuit(t) || (t.labels ?? []).includes('direct'))
1247
1335
  )
1248
1336
  .sort(ordre)
1249
1337
  .map(t => ({
1250
1338
  id: t.id,
1251
1339
  numero: numero(t.id),
1252
1340
  sujet: titre(t).sujet,
1253
- qui: t.assignee || null,
1254
1341
  }));
1255
1342
  // The circuits, in the tickets' order; a ticket worked in direct has its line alone.
1256
1343
  const enDirect = new Set(horsCircuit.map(x => x.id));
@@ -1330,6 +1417,41 @@ function temoinDe(c, maintenant) {
1330
1417
  }
1331
1418
 
1332
1419
  // A ticket's time and tokens, « 12 min · 310 k »; nothing when both are zero.
1420
+ // The sign of a ticket done by its way (grillhouse-592): a full circuit, a short one (1.1 Geste
1421
+ // mécanique), a ticket led directly.
1422
+ export const SIGNE_DE_LA_VOIE = Object.freeze({ complet: '●', court: '○', direct: '✎' });
1423
+
1424
+ /**
1425
+ * The way of the circuit each ticket of <tickets> went, read from its kept results in the main tree
1426
+ * <racine> (`.claude/worktrees/<ticket>.fiches.jsonl`, which the circuit writes and keeps once the
1427
+ * ticket is done): `court` when the launch of a session carries the object `geste` (1.1 Geste
1428
+ * mécanique), else `complet`; a ticket without the file has no entry. A line that does not parse
1429
+ * counts nothing.
1430
+ * @param {string} racine
1431
+ * @param {string[]} tickets
1432
+ * @returns {Record<string, 'complet' | 'court'>}
1433
+ */
1434
+ export function voiesDesCircuits(racine, tickets) {
1435
+ const out = {};
1436
+ for (const id of tickets) {
1437
+ let texte;
1438
+ try {
1439
+ texte = readFileSync(path.join(racine, '.claude', 'worktrees', `${id}.fiches.jsonl`), 'utf8');
1440
+ } catch {
1441
+ continue;
1442
+ }
1443
+ const geste = texte.split('\n').some(l => {
1444
+ try {
1445
+ return JSON.parse(l)?.lancement?.objet === 'geste';
1446
+ } catch {
1447
+ return false;
1448
+ }
1449
+ });
1450
+ out[id] = geste ? 'court' : 'complet';
1451
+ }
1452
+ return out;
1453
+ }
1454
+
1333
1455
  const conso = (ms, jetons) =>
1334
1456
  Math.round(ms / MINUTE) === 0 && !jetons ? '' : `${duree(ms)} · ${k(jetons)}`;
1335
1457
 
@@ -1412,7 +1534,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1412
1534
  const c = p.compteurs;
1413
1535
  L(
1414
1536
  cadre(
1415
- `${colonneDe(p.etiquette)}▶ ${c.enCours} en cours · ${c.enAttente} en attente · ${c.fermes} faits`,
1537
+ `${colonneDe(p.etiquette)}▶ ${c.enCours} en cours · ⏭ ${c.enAttente} · ✎ ${c.fileDirecte ?? 0} · ${c.fermes} faits`,
1416
1538
  '',
1417
1539
  largeur
1418
1540
  )
@@ -1431,14 +1553,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1431
1553
  } else {
1432
1554
  const g = t.global;
1433
1555
  const c = g.compteurs;
1434
- // Two lines of states: those of the circuit, then those that wait for the owner.
1435
- L(
1436
- cadre(
1437
- `▶ ${c.enCours} en cours · ${c.enAttente} en attente · ${c.bloques} bloqués · ${c.fermes} faits`,
1438
- '',
1439
- largeur
1440
- )
1441
- );
1556
+ // Three lines of states: the work, the queues (the circuit's, the direct one), then those that
1557
+ // wait for the owner.
1558
+ L(cadre(`▶ ${c.enCours} en cours · ${c.bloques} bloqués · ${c.fermes} faits`, '', largeur));
1559
+ L(cadre(`⏭ file : ${c.enAttente} en circuit · ${c.fileDirecte} en direct`, '', largeur));
1442
1560
  L(
1443
1561
  cadre(`${c.sansGo} sans go · ${c.aValider} à valider · ${c.reportes} reportés`, '', largeur),
1444
1562
  c.sansGo ? TONS.sansGo : c.aValider ? TONS.aValider : TONS.reportes
@@ -1754,15 +1872,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1754
1872
  plein ? TONS.titre : TONS.vide
1755
1873
  );
1756
1874
  // The tickets worked out of a circuit, once each, before the steps, from their claim to their
1757
- // close: « ✎ <numéro> <sujet> · en direct · <assignee> ».
1875
+ // close: « ✎ <numéro> <sujet> · en direct ».
1758
1876
  for (const x of t.horsCircuit ?? []) {
1759
1877
  poser({
1760
- texte: couperAvant(
1761
- `${teteDe('✎', x)}${x.sujet}`,
1762
- ` · en direct${x.qui ? ` · ${x.qui}` : ''}`,
1763
- droiteDe('✎', ''),
1764
- largeur
1765
- ),
1878
+ texte: couperAvant(`${teteDe('✎', x)}${x.sujet}`, ' · en direct', droiteDe('✎', ''), largeur),
1766
1879
  ton: TONS.enDirect,
1767
1880
  ticket: x.id,
1768
1881
  });
@@ -1943,8 +2056,14 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1943
2056
  ),
1944
2057
  TONS.titre
1945
2058
  );
2059
+ // Each line: the sign of its way, then « <durée> · <jetons> », « — » for a direct ticket never
2060
+ // claimed.
1946
2061
  const fait = x => ({
1947
- texte: cadre(`✓ ${duProjet(x)}${x.numero} ${x.sujet}`, conso(x.travail, x.jetons), largeur),
2062
+ texte: cadre(
2063
+ `${SIGNE_DE_LA_VOIE[x.voie] ?? SIGNE_DE_LA_VOIE.direct} ${duProjet(x)}${x.numero} ${x.sujet}`,
2064
+ `${x.duree === null || x.duree === undefined ? '—' : duree(x.duree)} · ${k(x.jetons)}`,
2065
+ largeur
2066
+ ),
1948
2067
  ton: TONS.fermes,
1949
2068
  ticket: x.id,
1950
2069
  });
@@ -2099,7 +2218,7 @@ export function ligneEtat(t) {
2099
2218
  const ch = t.chantiers[0];
2100
2219
  const c = t.global.compteurs;
2101
2220
  if (!ch) {
2102
- return `${alerte}Grillhouse : ${c.enCours} en cours · ${c.enAttente} en attente · ${c.fermes} faits`;
2221
+ return `${alerte}Grillhouse : ${c.enCours} en cours · ⏭ ${c.enAttente} · ✎ ${c.fileDirecte} · ${c.fermes} faits`;
2103
2222
  }
2104
2223
  return `${alerte}${ch.numero} ${ch.faits}/${ch.total} · ▶ ${c.enCours} en cours · ${k(t.global.jour.jetons)} aujourd'hui`;
2105
2224
  }
@@ -2214,11 +2333,7 @@ function lire(
2214
2333
  } catch {
2215
2334
  ps = '';
2216
2335
  }
2217
- const fichierRegistre =
2218
- process.env.GRILLHOUSE_REGISTRE ?? path.join(home, '.claude', 'grillhouse', 'registre.jsonl');
2219
- const registre = existsSync(fichierRegistre)
2220
- ? lireRegistre(readFileSync(fichierRegistre, 'utf8'), racine)
2221
- : [];
2336
+ const registre = existsSync(REGISTRE) ? lireRegistre(readFileSync(REGISTRE, 'utf8'), racine) : [];
2222
2337
  const tous = bdJson(racine, 'list', '--all', '--limit', '0');
2223
2338
  const commun = dossierCommun(racine);
2224
2339
  const fichierCache = commun && path.join(commun, 'tableau-cache.json');
@@ -2236,6 +2351,8 @@ function lire(
2236
2351
  ps,
2237
2352
  cache,
2238
2353
  });
2354
+ const jourLu = lireLeRepere(commun, maintenant);
2355
+ const superviseur = jetonsDuSuperviseur({ racine, home, jour: jourLu, cache });
2239
2356
  try {
2240
2357
  if (fichierCache) {
2241
2358
  writeFileSync(
@@ -2246,6 +2363,12 @@ function lire(
2246
2363
  } catch {
2247
2364
  // A read-only place keeps the board working, without its cache.
2248
2365
  }
2366
+ const jour = jourLu;
2367
+ // The kept results of the circuits of the tickets done since the day's marker, in the main tree.
2368
+ const voies = voiesDesCircuits(
2369
+ commun ? path.dirname(commun) : racine,
2370
+ tous.filter(x => x.closed_at && Date.parse(x.closed_at) >= jour).map(x => x.id)
2371
+ );
2249
2372
  const t = assembler({
2250
2373
  tous,
2251
2374
  prefix,
@@ -2253,7 +2376,8 @@ function lire(
2253
2376
  vivants,
2254
2377
  circuits,
2255
2378
  maintenant,
2256
- jour: lireLeRepere(commun, maintenant),
2379
+ jour,
2380
+ voies,
2257
2381
  machine,
2258
2382
  places,
2259
2383
  nuit,
@@ -2263,6 +2387,7 @@ function lire(
2263
2387
  outil: echecDeLOutil(racine),
2264
2388
  remontees: lireLesRemontees(racine, maintenant),
2265
2389
  attenteVivante: attenteVivante(racine),
2390
+ superviseur,
2266
2391
  });
2267
2392
  return { t, prefix, tous, vivants, commun };
2268
2393
  }
@@ -39,7 +39,6 @@ import { closeSync, openSync, readFileSync, writeFileSync } from 'node:fs';
39
39
  import path from 'node:path';
40
40
  import { lireLaListe } from './enveloppe/paquets-du-plan.mjs';
41
41
  import { paquets } from './paquets.mjs';
42
- import { RESULTATS } from './resultats.mjs';
43
42
  import { langage } from './langages.mjs';
44
43
 
45
44
  /** The name of the script and of the task of the tests of a package, the same for every language. */
@@ -104,21 +103,31 @@ export function nomDuPaquet(racine, dossier) {
104
103
  * Runs the tasks <taches> of the packages <noms> (all of them when <noms> is empty) with <outil> in
105
104
  * <racine>, each task whose dependencies succeed played to its end: its exit code, the runner's.
106
105
  * <tests>, when given, is the content of the variable `TESTS_CIBLES` of the run (`{ arguments,
107
- * rejouer? }`); the variable of <env> never passes on.
106
+ * rejouer? }`); the variable of <env> never passes on. A red run names, through <dire>, each task
107
+ * whose code is not 0, « ⛔ <tâche> (code N) », as the pass of the module typescript does.
108
108
  * @param {{ outil: string, racine: string, taches: string[], noms?: Iterable<string>,
109
- * tests?: { arguments: string[], rejouer?: string }, env?: NodeJS.ProcessEnv }} o
109
+ * tests?: { arguments: string[], rejouer?: string }, env?: NodeJS.ProcessEnv,
110
+ * dire?: (ligne: string) => void }} o
110
111
  * @returns {number}
111
112
  */
112
- export function lancerLesTaches({ outil, racine, taches, noms = [], tests, env = process.env }) {
113
+ export function lancerLesTaches({
114
+ outil,
115
+ racine,
116
+ taches,
117
+ noms = [],
118
+ tests,
119
+ env = process.env,
120
+ dire = l => process.stderr.write(`${l}\n`),
121
+ }) {
113
122
  const e = { ...env };
114
123
  delete e[TESTS_CIBLES];
115
124
  if (tests) {
116
125
  e[TESTS_CIBLES] = JSON.stringify(tests);
117
126
  }
118
127
  const filtres = [...new Set(noms)].sort().map(n => `--filter=${n}`);
119
- // A named results directory asks the runner for its summary, kept there; the summaries of a run
120
- // are never left in the project.
121
- const resume = e[RESULTATS] ? ['--summarize'] : [];
128
+ // The runner's summary gives each task's verdict; kept in a named results directory, never left
129
+ // in the project.
130
+ const resume = ['--summarize'];
122
131
  const lanceur = langage('typescript');
123
132
  const avant = lanceur.resumesDuLancement(racine);
124
133
  const r = spawnSync(
@@ -126,7 +135,12 @@ export function lancerLesTaches({ outil, racine, taches, noms = [], tests, env =
126
135
  ['run', ...taches, ...filtres, '--continue=dependencies-successful', ...resume],
127
136
  { cwd: racine, stdio: 'inherit', env: e }
128
137
  );
129
- lanceur.garderLesResumes(racine, avant, e);
138
+ const verdicts = lanceur.garderLesResumes(racine, avant, e);
139
+ if (r.status !== 0) {
140
+ for (const t of verdicts.filter(x => x.code !== 0)) {
141
+ dire(`⛔ ${t.tache} (code ${t.code ?? 'absent'})`);
142
+ }
143
+ }
130
144
  return r.status ?? 1;
131
145
  }
132
146