@roomi-fields/grillhouse 0.51.0 → 0.52.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 (60) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +20 -0
  3. package/charte/plan.md +47 -0
  4. package/charte/preuve.md +39 -0
  5. package/charte/superviseur.md +61 -0
  6. package/charte/tests.md +38 -0
  7. package/charte.md +22 -177
  8. package/dist/temporal/circuit/client.d.ts +1 -2
  9. package/dist/temporal/circuit/client.js +1 -2
  10. package/dist/temporal/circuit/client.js.map +1 -1
  11. package/docs/INTERFACE.md +4 -3
  12. package/docs/architecture/circuit.md +2 -2
  13. package/docs/architecture/entree.md +1 -1
  14. package/docs/architecture/greffon.md +43 -18
  15. package/docs/architecture/installation.md +17 -7
  16. package/docs/architecture/machine.md +30 -3
  17. package/docs/architecture/tests.md +8 -3
  18. package/docs/lexique.md +10 -1
  19. package/hooks/hooks.json +0 -10
  20. package/hooks/register.tsx +91 -3
  21. package/package.json +2 -1
  22. package/scripts/activites.mjs +20 -5
  23. package/scripts/aiguillage.mjs +0 -1
  24. package/scripts/attente-au-tour.mjs +2 -3
  25. package/scripts/bilan.mjs +116 -56
  26. package/scripts/bilans-gardes.mjs +37 -0
  27. package/scripts/circuit.mjs +3 -1
  28. package/scripts/direct.mjs +1 -1
  29. package/scripts/droits.mjs +115 -36
  30. package/scripts/entree-de-seance.mjs +35 -0
  31. package/scripts/enveloppe/enveloppe.mjs +23 -16
  32. package/scripts/enveloppe/lancer.sh +32 -22
  33. package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
  34. package/scripts/jointure.d.ts +2 -1
  35. package/scripts/langages/python/commandes.mjs +50 -7
  36. package/scripts/langages/python/squelette.mjs +2 -1
  37. package/scripts/langages/typescript/index.mjs +12 -12
  38. package/scripts/langages/typescript/turbo-des-paquets.mjs +52 -2
  39. package/scripts/langages/typescript/verifier.mjs +27 -2
  40. package/scripts/migrations/serveurs-de-l-index.mjs +1 -1
  41. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  42. package/scripts/migrations.mjs +2 -0
  43. package/scripts/nuit.sh +3 -2
  44. package/scripts/paquet.mjs +1 -1
  45. package/scripts/resultats.mjs +2 -2
  46. package/scripts/seances.mjs +53 -26
  47. package/scripts/session-start.sh +8 -6
  48. package/scripts/sortie-de-seance.mjs +70 -0
  49. package/scripts/sous-commandes.mjs +0 -1
  50. package/scripts/superviseur.mjs +373 -155
  51. package/scripts/tableau.mjs +127 -49
  52. package/skills/explorateur/SKILL.md +2 -2
  53. package/skills/grill/SKILL.md +3 -2
  54. package/skills/pitmaster/SKILL.md +68 -34
  55. package/skills/pitmaster/references/cadre.md +1 -1
  56. package/skills/pitmaster/references/tour.md +6 -5
  57. package/skills/relecteur/SKILL.md +1 -1
  58. package/skills/testwriter/SKILL.md +2 -2
  59. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  60. package/scripts/attente-a-l-arret.mjs +0 -114
@@ -28,8 +28,13 @@
28
28
  // - `tests-du-paquet <chemin>…` is the body of that task, which the `test:unit` script of a project
29
29
  // calls (`grillhouse tests-du-paquet <dossier du projet>`, written with the package): it never
30
30
  // runs Turborepo, so `tester` and the task do not loop. It plays pytest in the project:
31
- // `uv run --locked --group test pytest`, the group `test` holding pytest and what the tests
32
- // depend on, its JUnit report in the family `xunit1` (./verdict.mjs). A path, written from the
31
+ // `uv run --locked --group test <racine>/.venv/<dossier>/bin/pytest`, the pytest of the
32
+ // environment of the package by its path, the group `test` holding pytest and what the tests
33
+ // depend on, its JUnit report in the family `xunit1` (./verdict.mjs). Never `pytest` by its
34
+ // name: uv then plays the one of the PATH, without a word, when the environment holds none that
35
+ // launches. A pytest of the environment absent or broken (the interpreter of its shebang gone,
36
+ // as after the repository moved) is red, its line naming the repair, `uv sync --locked --group
37
+ // test --reinstall` on that environment. A path, written from the
33
38
  // root, chooses the project that holds it, and pytest plays that path alone; the paths of the
34
39
  // variable `GRILLHOUSE_TESTS` that lie in the project replace the folder the script names. A path
35
40
  // out of every project is refused, named, and nothing plays (code 2). The night tests
@@ -80,7 +85,7 @@
80
85
  // - The exit code: 0 when every task is green, 75 when the only reds are « à repasser », 1
81
86
  // otherwise; 2 for a path refused or a command unknown.
82
87
  import { spawnSync } from 'node:child_process';
83
- import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
88
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
84
89
  import { constants, tmpdir } from 'node:os';
85
90
  import path from 'node:path';
86
91
  import { fileURLToPath, pathToFileURL } from 'node:url';
@@ -160,6 +165,7 @@ function passe(racine, env) {
160
165
  const id = `${Date.now()}-${process.pid}`;
161
166
  const taches = [];
162
167
  const rapports = {};
168
+ let uvAbsent = false;
163
169
  // uv keeps its cache with the frame's caches of compilation, out of the temporary directory.
164
170
  const environnement = {
165
171
  ...env,
@@ -205,14 +211,14 @@ function passe(racine, env) {
205
211
  },
206
212
  // <vert>, the codes that count green beside 0.
207
213
  jouer({ t, args, cwd, programme }, vert = []) {
208
- // The environment of uv of the package, at the root (`sorties` of ./index.mjs).
209
- const venv = path.join(racine, VENV, path.relative(racine, cwd));
214
+ const venv = environnementDe(racine, cwd);
210
215
  const r = spawnSync(programme, args, {
211
216
  cwd,
212
217
  env: { ...environnement, UV_PROJECT_ENVIRONMENT: venv },
213
218
  stdio: 'inherit',
214
219
  });
215
220
  if (r.error?.code === 'ENOENT' && programme === 'uv') {
221
+ uvAbsent = true;
216
222
  process.stderr.write("⛔ uv absent du PATH : `npx grillhouse binaires` l'installe.\n");
217
223
  }
218
224
  t.code = r.error ? 127 : (r.status ?? 128 + (constants.signals[r.signal] ?? 0));
@@ -222,6 +228,8 @@ function passe(racine, env) {
222
228
  ecrire();
223
229
  return t.code;
224
230
  },
231
+ // Whether a task found no uv to run, which `jouer` said.
232
+ uvAbsent: () => uvAbsent,
225
233
  code() {
226
234
  const rouges = taches.filter(t => t.code !== 0);
227
235
  if (rouges.length === 0) {
@@ -232,6 +240,35 @@ function passe(racine, env) {
232
240
  };
233
241
  }
234
242
 
243
+ // The environment of uv of the package at <dossier>, at the root (`sorties` of ./index.mjs).
244
+ const environnementDe = (racine, dossier) =>
245
+ path.join(racine, VENV, path.relative(racine, dossier));
246
+
247
+ // Whether the script <f> of an environment launches: there, and the interpreter it names there,
248
+ // by its shebang or, for a path too long or with a space, by the `exec` of its `/bin/sh` header.
249
+ function seLance(f) {
250
+ let texte;
251
+ try {
252
+ texte = readFileSync(f, 'utf8');
253
+ } catch {
254
+ return false;
255
+ }
256
+ const [premiere, seconde = ''] = texte.split('\n');
257
+ const interpretes = [
258
+ /^#!\s*(\S+)/.exec(premiere)?.[1],
259
+ /^'''exec' '(\/[^']*)' "\$0"/.exec(seconde)?.[1],
260
+ ];
261
+ return interpretes.every(i => i === undefined || existsSync(i));
262
+ }
263
+
264
+ // The line of a red run of the package at <dossier> whose pytest <pytest> does not launch: the
265
+ // repair, on the environment of the package at the root.
266
+ function ligneDeReparation(racine, dossier, pytest) {
267
+ const venv = environnementDe(racine, dossier);
268
+ const paquet = path.relative(racine, dossier) || '.';
269
+ return `⛔ ${paquet} : pytest de son environnement absent ou cassé (${pytest}) ; le réparer, dans ${paquet} : \`UV_PROJECT_ENVIRONMENT='${venv}' uv sync --locked --group ${GROUPE} --reinstall\`\n`;
270
+ }
271
+
235
272
  const UV_RUN = ['run', '--locked'];
236
273
  // The code of pytest for « no tests collected », distinct from a failure (1).
237
274
  const AUCUN_TEST = 5;
@@ -259,7 +296,9 @@ function declareXdist(dossier) {
259
296
  function jouerLesTests(p, choix, options) {
260
297
  for (const { c, chemins } of choix) {
261
298
  const cache = path.join(p.racine, CACHE_DE_PYTEST, path.relative(p.racine, c.dossier));
262
- const args = [...UV_RUN, '--group', GROUPE, 'pytest', '-o', `cache_dir=${cache}`];
299
+ // By its path: by its name, uv falls back to the pytest of the PATH.
300
+ const pytest = path.join(environnementDe(p.racine, c.dossier), 'bin', 'pytest');
301
+ const args = [...UV_RUN, '--group', GROUPE, pytest, '-o', `cache_dir=${cache}`];
263
302
  args.push(...p.junit(c.nom, c.dossier));
264
303
  // The workers of the task (GRILLHOUSE_TRAVAILLEURS, which a session and a pass set): `-n` of
265
304
  // pytest-xdist, for a package whose test group declares it; without the variable, one process.
@@ -268,10 +307,14 @@ function jouerLesTests(p, choix, options) {
268
307
  args.push('-n', String(travailleurs));
269
308
  }
270
309
  const entier = chemins.every(ch => ch === '.');
271
- p.jouer(
310
+ const code = p.jouer(
272
311
  p.prevoir(c.nom, c.dossier, 'pytest', true, [...args, ...selection(chemins), ...options]),
273
312
  entier ? [AUCUN_TEST] : []
274
313
  );
314
+ // Read after the run: `uv run` syncs the environment first, which lays a pytest it lacks.
315
+ if (code !== 0 && !p.uvAbsent() && !seLance(pytest)) {
316
+ process.stderr.write(ligneDeReparation(p.racine, c.dossier, pytest));
317
+ }
275
318
  }
276
319
  }
277
320
 
@@ -15,7 +15,8 @@
15
15
  // grillhouse maj`, which installs it.
16
16
  // - Its files: its pyproject.toml (PEP 621: its name, its version 0.1.0, the Python it requires, no
17
17
  // dependency; its group `test` of `[dependency-groups]`, PEP 735, pytest, which the module runs
18
- // by `uv run --group test pytest`; the configuration of pytest, `[tool.pytest.ini_options]`, its
18
+ // by its path in the environment of the package (./commandes.mjs); the configuration of pytest,
19
+ // `[tool.pytest.ini_options]`, its
19
20
  // tests under `tests/` and its code importable from `src/`, as uv's layout of a library has it);
20
21
  // `src/<module>/__init__.py`, without code; `tests/.gitkeep`, its folder of tests. The typing is
21
22
  // `python -m compileall`, which needs no configuration. No build system: uv neither builds nor
@@ -37,9 +37,10 @@
37
37
  // - The migrations of a project of TypeScript (./migrations/): the base configuration of Vitest,
38
38
  // and the ones that replay a guard of this module, which the update plays with the core's
39
39
  // (scripts/migrations.mjs), as each plugin of Nx carries its own.
40
- // - No binary of the machine (`binaires`); what its tools write in a project, `.turbo`
41
- // (`ignorer`); its share of the update (./mise-a-jour.mjs, `miseAJour`): the tests by Vitest,
42
- // the frame's package declared, the typing, the turbo.json, and the generators.
40
+ // - No binary of the machine (`binaires`); what its tools write in a project, Vitest's reports
41
+ // and the cache of the tools (`ignorer`); its share of the update (./mise-a-jour.mjs,
42
+ // `miseAJour`): the tests by Vitest, the frame's package declared, the typing, the turbo.json,
43
+ // and the generators.
43
44
  // - The skeleton of a new package (./squelette.mjs, `squelette`), which `grillhouse paquet` writes.
44
45
  import { spawnSync } from 'node:child_process';
45
46
  import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
@@ -219,16 +220,15 @@ export default {
219
220
  // runs and cache (`.turbo`) are the frame's, every language playing by it: IGNORES_DU_CADRE of
220
221
  // scripts/grillhouse-maj.mjs ignores them.
221
222
  ignorer: ['.vitest-reports', '.cache-outils'],
222
- // Where its tools write: the cache of Turborepo in the main tree, shared by every copy, written;
223
- // the logs of Turborepo's tasks (`.turbo/turbo-<task>.log`, written on every run, a task replayed
224
- // from its cache included, and which no option of Turborepo sends elsewhere) and the cache of
225
- // Vite, where Vitest writes the results of a run (`.cache-outils/vite/vitest/`, the `cacheDir` of
226
- // the base configurations: a copy's `node_modules` is a link, so nothing under it is a clean
227
- // output) and whose failure fails it; and the cache of ESLint and Prettier (`.cache-outils/`),
228
- // proper to the session, an empty one costing a whole reading, as without a cache.
223
+ // Where its tools write, Turborepo's outputs being the core's (`sortiesDuLangage` of
224
+ // scripts/enveloppe/enveloppe.mjs): the cache of Vite, where Vitest writes the results of a run
225
+ // (`.cache-outils/vite/vitest/`, the `cacheDir` of the base configurations: a copy's
226
+ // `node_modules` is a link, so nothing under it is a clean output) and whose failure fails it;
227
+ // and the cache of ESLint and Prettier (`.cache-outils/`), proper to the session, an empty one
228
+ // costing a whole reading, as without a cache.
229
229
  sorties: {
230
- ecrites: ['//.turbo/cache/'],
231
- propres: ['.turbo', '.cache-outils'],
230
+ ecrites: [],
231
+ propres: ['.cache-outils'],
232
232
  lues: [],
233
233
  },
234
234
  // The test tool run directly, Vitest or Turborepo that plays it: `npm test` and `npm run
@@ -92,7 +92,9 @@
92
92
  // project's guards; a root without it plays none): each waits for the build of each package of
93
93
  // the frame that has a `build` script, sorted (`//#grillhouse:gardes`, `//#gardes` in a
94
94
  // repository of packages), or for the root's build in a repository without packages; the task
95
- // added is `{ dependsOn, outputs: [] }`;
95
+ // added is `{ dependsOn, outputs: [] }`; in a repository of packages, the `env` of each `//#…`
96
+ // names `GRILLHOUSE_INDEX_DU_DEPOT`, the fingerprint of the list of the files of the index, the
97
+ // project's entries kept;
96
98
  // - `typecheck`, cached per package: it waits for `build` and, in a repository of packages, for
97
99
  // `^build`; a package without a `typecheck` script plays none; the task added is
98
100
  // `{ dependsOn: ["build", "^build"], outputs: [] }` (`["build"]` without packages), and a
@@ -147,6 +149,10 @@ const TOPOLOGIE = ['dependencies', 'devDependencies', 'optionalDependencies'];
147
149
  const RACINES = ['turbo.json', 'turbo.jsonc'];
148
150
  // The guard tasks of the root: the frame's controls, and the project's own guards.
149
151
  export const GARDES = SCRIPTS_DE_GARDES;
152
+ // The variable that carries the fingerprint of the list of the files of the index, which the
153
+ // verification pass gives (verifier.mjs) and the guard tasks of the root hash: a guard reads the
154
+ // index.
155
+ export const INDEX_DU_DEPOT = 'GRILLHOUSE_INDEX_DU_DEPOT';
150
156
  // The controls of the root that the CI plays beside the verification: the format check and the
151
157
  // lint. A root plays those its package.json holds a script for, none demanded.
152
158
  export const CONTROLES = ['format:check', 'lint'];
@@ -908,6 +914,36 @@ function gardesEcartees(racine) {
908
914
  return { f, texte, ecarts };
909
915
  }
910
916
 
917
+ // Whether the task <cle> is written as one of the root package, in a repository of packages.
918
+ const estDeLaRacine = cle => cle.startsWith('//#');
919
+
920
+ // The guard task <cle> the generator adds to a root that lacks it.
921
+ const gardeNeuve = (cle, dependsOn) => ({
922
+ dependsOn,
923
+ ...(estDeLaRacine(cle) ? { env: [INDEX_DU_DEPOT] } : {}),
924
+ outputs: [],
925
+ });
926
+
927
+ // The guard tasks of the root's turbo.json at <racine>, in a repository of packages (`//#…`), whose
928
+ // `env` lacks INDEX_DU_DEPOT, added to the project's: [{ f, cle, attendu }]; a task absent aside,
929
+ // which `gardesEcartees` adds whole.
930
+ function gardesSansIndex(racine) {
931
+ const r = confRacine(racine);
932
+ if (!r) {
933
+ return [];
934
+ }
935
+ return [...gardesAttendues(racine).keys()].filter(estDeLaRacine).flatMap(cle => {
936
+ const tache = r.conf.tasks?.[cle];
937
+ if (!tache || typeof tache !== 'object') {
938
+ return [];
939
+ }
940
+ const actuel = Array.isArray(tache.env) ? tache.env : [];
941
+ return actuel.includes(INDEX_DU_DEPOT)
942
+ ? []
943
+ : [{ f: r.f, cle, attendu: [...actuel, INDEX_DU_DEPOT] }];
944
+ });
945
+ }
946
+
911
947
  // The typing task of the root's turbo.json at <racine> when it lacks it, or when its `dependsOn`
912
948
  // lacks one of the builds it waits for (`attenteDuTypage`): { f, chemin, valeur, manques }, the
913
949
  // path of the edit and the value it sets (the task, `{ dependsOn, outputs: [] }`; or its
@@ -1030,12 +1066,21 @@ export function ecrire(racine) {
1030
1066
  for (const { cle, attendu, present } of racineEcartee.ecarts) {
1031
1067
  const [chemin, valeur] = present
1032
1068
  ? [['tasks', cle, 'dependsOn'], attendu]
1033
- : [['tasks', cle], { dependsOn: attendu, outputs: [] }];
1069
+ : [['tasks', cle], gardeNeuve(cle, attendu)];
1034
1070
  texte = applyEdits(texte, modify(texte, chemin, valeur, MISE_EN_FORME));
1035
1071
  }
1036
1072
  writeFileSync(path.join(racine, racineEcartee.f), texte);
1037
1073
  ecrits.push(racineEcartee.f);
1038
1074
  }
1075
+ for (const { f, cle, attendu } of gardesSansIndex(racine)) {
1076
+ const abs = path.join(racine, f);
1077
+ const texte = readFileSync(abs, 'utf8');
1078
+ const chemin = ['tasks', cle, 'env'];
1079
+ writeFileSync(abs, applyEdits(texte, modify(texte, chemin, attendu, MISE_EN_FORME)));
1080
+ if (!ecrits.includes(f)) {
1081
+ ecrits.push(f);
1082
+ }
1083
+ }
1039
1084
  const typage = typageEcarte(racine);
1040
1085
  if (typage) {
1041
1086
  const abs = path.join(racine, typage.f);
@@ -1324,6 +1369,11 @@ export function verifier(racine) {
1324
1369
  : `⛔ ${f} : la tâche \`${cle}\` manque ; \`${COMMANDE}\` l'ajoute, après la construction de chaque paquet du cadre.`
1325
1370
  );
1326
1371
  }
1372
+ for (const { f, cle } of gardesSansIndex(racine)) {
1373
+ refus.push(
1374
+ `⛔ ${f} : l'\`env\` de \`${cle}\` doit nommer ${INDEX_DU_DEPOT}, l'empreinte de la liste des fichiers de l'index, qu'une garde lit ; \`${COMMANDE}\` l'ajoute.`
1375
+ );
1376
+ }
1327
1377
  for (const [f, t] of attendus(racine)) {
1328
1378
  const abs = path.join(racine, f);
1329
1379
  if (!existsSync(abs)) {
@@ -19,6 +19,8 @@
19
19
  // keeps its tree as the last green; a red one leaves it. The pass alone keeps it, for every
20
20
  // language: it plays the tasks of every package of the graph, a crate's and a Python
21
21
  // project's beside a TypeScript package's (their `test:unit` and `typecheck`).
22
+ // - Every pass gives its tasks the fingerprint of the list of the files of the index
23
+ // (`GRILLHOUSE_INDEX_DU_DEPOT`), which the guard tasks hash (./turbo-des-paquets.mjs).
22
24
  // - `--tout`, and `--force` (the night, scripts/nuit.sh), play the complete pass: each task of
23
25
  // tests for real (`GRILLHOUSE_TESTS` carries only `rejouer`, the moment of the pass, no path).
24
26
  // - The part of the budget of the machine (scripts/places-de-la-machine.mjs, `avecLaPasse`): a
@@ -73,6 +75,7 @@
73
75
  // TMPDIR, TMP and TEMP (`globalPassThroughEnv`, ./turbo-des-paquets.mjs); removed at the end,
74
76
  // green, red or interrupted (SIGINT, SIGTERM, SIGHUP).
75
77
  import { spawnSync } from 'node:child_process';
78
+ import { createHash } from 'node:crypto';
76
79
  import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from 'node:fs';
77
80
  import { availableParallelism, tmpdir } from 'node:os';
78
81
  import path from 'node:path';
@@ -112,7 +115,7 @@ import { paquets, TYPAGE } from '../../paquets.mjs';
112
115
  import { RESULTATS } from '../../resultats.mjs';
113
116
  import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
114
117
  import { garderLesResumes } from './resume-du-lanceur.mjs';
115
- import { controlesDuDepot, planifier } from './turbo-des-paquets.mjs';
118
+ import { controlesDuDepot, INDEX_DU_DEPOT, planifier } from './turbo-des-paquets.mjs';
116
119
 
117
120
  const TACHES = [...GARDES, TYPAGE, SCRIPT_DES_TESTS];
118
121
  const CONCURRENCE = /^--concurrency(?:=|$)/;
@@ -125,6 +128,17 @@ const rejeu = id => {
125
128
  return `npx turbo run ${id.slice(i + 1)} --filter=${id.slice(0, i)}`;
126
129
  };
127
130
 
131
+ // The fingerprint of the list of the files of the index of the repository at <racine>, under
132
+ // <env>: it moves when a file enters or leaves the index, whatever the contents. null when git
133
+ // gives no list.
134
+ function empreinteDeLIndex(racine, env) {
135
+ const r = spawnSync('git', ['-C', racine, 'ls-files', '-z'], {
136
+ env,
137
+ maxBuffer: 1024 * 1024 * 1024,
138
+ });
139
+ return r.status === 0 ? createHash('sha256').update(r.stdout).digest('hex') : null;
140
+ }
141
+
128
142
  const lister = dossier => (existsSync(dossier) ? readdirSync(dossier) : []);
129
143
 
130
144
  // The tasks side by side <args> ask for (`--concurrency=<n>`, `--concurrency <n>`), null without
@@ -411,7 +425,18 @@ function passe({ racine, demandes, env, dire, coeurs }) {
411
425
 
412
426
  function jouerLaPasse({ racine, demandes, args, tout, ajouts, env, dire, coeurs, taches }) {
413
427
  const { gardesSeules, sansTests, tranche } = demandes;
414
- const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, [BASE_DU_LOT]: ___, ...propre } = env;
428
+ const {
429
+ [TESTS_CIBLES]: _,
430
+ [CHANGEMENTS]: __,
431
+ [BASE_DU_LOT]: ___,
432
+ [INDEX_DU_DEPOT]: ____,
433
+ ...herite
434
+ } = env;
435
+ // The fingerprint of this repository's index, never the caller's: a guard reads the index, and
436
+ // Turborepo, which hashes an untracked file as a tracked one, plays the guards again when the
437
+ // list moves.
438
+ const index = empreinteDeLIndex(racine, herite);
439
+ const propre = index === null ? herite : { ...herite, [INDEX_DU_DEPOT]: index };
415
440
  // The environment of the run: measured against the last green; the moment of a complete pass,
416
441
  // which moves the hash of every task of tests, so that each plays for real; a tranche, with it.
417
442
  const cibles = tranche
@@ -74,6 +74,6 @@ export function restes(projet) {
74
74
  return [];
75
75
  }
76
76
  return [
77
- '.claude/settings.json : le greffon rtfm n’est pas activé, qui porte le programme rtfm-serve que .mcp.json nomme, et tient son index ; active-le (« enabledPlugins » : « rtfm@roomi-fields »: true, comme le gabarit), puis rejoue npx grillhouse maj --poste.',
77
+ '.claude/settings.json : le greffon rtfm n’est pas activé, qui porte le programme rtfm-serve que .mcp.json nomme, et tient son index ; active-le (« enabledPlugins » : « rtfm@roomi-fields »: true, comme le gabarit), puis lance npx grillhouse greffons dans l’arbre principal.',
78
78
  ];
79
79
  }
@@ -0,0 +1,56 @@
1
+ // A project holds no follow-up of its supervisor: the note of resumption replaces
2
+ // `pitmaster/SUIVI.md` (greffon.md, §5.2). The file the template placed is removed; one the project
3
+ // filled stays, left to the project. Mechanism: installation.md §5.4
4
+ // (packages/grillhouse/docs/architecture/).
5
+ import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync } from 'node:fs';
6
+ import path from 'node:path';
7
+
8
+ export const version = '0.52.0';
9
+ export const nom = 'suivi du superviseur retire';
10
+
11
+ const FICHIER = 'pitmaster/SUIVI.md';
12
+ // The file as the template of a project placed it, its one form.
13
+ const GABARIT = `# Suivi de la supervision
14
+
15
+ Tenu par la compétence \`pitmaster\`. Une question s'écrit ici dès qu'elle naît ; tranchée, elle en
16
+ sort et sa réponse va dans son ticket.
17
+
18
+ ## Dernier tour
19
+
20
+ - Date : aucun tour encore
21
+ - Agents lancés : aucun
22
+ - À vérifier au prochain tour : rien
23
+
24
+ ## R — à confirmer par le responsable
25
+
26
+ Chaque point : contexte, exemple, règle, recommandation, question, ticket.
27
+
28
+ ## S — à surveiller
29
+
30
+ Chaque point : ce qui se surveille, ce qui le fermera.
31
+
32
+ ## F — fermés
33
+
34
+ Chaque point : ce qui l'a fermé, le ticket.
35
+ `;
36
+
37
+ /** The `pitmaster/SUIVI.md` of <projet> retired; returns what it did, or leaves to the project. */
38
+ export function migrer(projet) {
39
+ const fichier = path.join(projet, FICHIER);
40
+ if (!existsSync(fichier)) {
41
+ return [];
42
+ }
43
+ if (readFileSync(fichier, 'utf8') !== GABARIT) {
44
+ return [
45
+ {
46
+ aFaire: `${FICHIER} : rempli par le projet, il n'a plus de lecteur ; reprends son contenu ouvert dans la note de reprise du superviseur (\`npx grillhouse superviseur --question <fichier>\`) ou dans des tickets, puis retire-le`,
47
+ },
48
+ ];
49
+ }
50
+ rmSync(fichier);
51
+ const dossier = path.dirname(fichier);
52
+ if (readdirSync(dossier).length === 0) {
53
+ rmdirSync(dossier);
54
+ }
55
+ return [`${FICHIER} : retiré, identique au gabarit ; la note de reprise du superviseur le remplace`];
56
+ }
@@ -54,6 +54,7 @@ import * as reservationDeTroisCoeurs from './migrations/0.49.0-reservation-de-tr
54
54
 
55
55
  import * as reglagesHorsDeLaCharte from './migrations/0.50.0-reglages-hors-de-la-charte.mjs';
56
56
  import * as serveursDeLIndex from './migrations/serveurs-de-l-index.mjs';
57
+ import * as suiviDuSuperviseurRetire from './migrations/suivi-du-superviseur-retire.mjs';
57
58
 
58
59
  /** The migrations of the core. */
59
60
  export const MIGRATIONS = [
@@ -80,6 +81,7 @@ export const MIGRATIONS = [
80
81
  reservationDeTroisCoeurs,
81
82
  reglagesHorsDeLaCharte,
82
83
  serveursDeLIndex,
84
+ suiviDuSuperviseurRetire,
83
85
  ];
84
86
 
85
87
  /**
package/scripts/nuit.sh CHANGED
@@ -210,13 +210,13 @@ repli() {
210
210
  return
211
211
  fi
212
212
  local lignes rejouer= rouges_pc2= attend= mesures_du_flux=
213
- lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write(["pc2","pc3","rouges","enAttente","enCours","mesures"].map(k=>k+"\t"+l(k)).join("\n")+"\n")})')"
213
+ lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write([...["pc2","pc3","rouges","enAttente","enCours"].map(k=>k+"\t"+l(k)),"mesures\t"+d.mesures].join("\n")+"\n")})')"
214
214
  while IFS= read -r ligne; do
215
215
  case "$ligne" in
216
216
  pc2$'\t'*) echo "relevé de la nuit : tranches jouées sur PC2 : ${ligne#pc2$'\t'}" ;;
217
217
  pc3$'\t'*) rejouer="${ligne#pc3$'\t'}"; echo "relevé de la nuit : tranches jouées sur PC3 : ${rejouer:-aucune}" ;;
218
218
  rouges$'\t'*) rouges_pc2="${ligne#rouges$'\t'}" ;;
219
- mesures$'\t'*) mesures_du_flux="${ligne#mesures$'\t'}"; echo "relevé de la nuit : mesures de temps du flux : ${mesures_du_flux}" ;;
219
+ mesures$'\t'*) mesures_du_flux="${ligne#mesures$'\t'}" ;;
220
220
  enAttente$'\t'*|enCours$'\t'*) attend="$attend ${ligne#*$'\t'}" ;;
221
221
  esac
222
222
  done <<< "$lignes"
@@ -240,6 +240,7 @@ repli() {
240
240
  # The measures of time: the flow's job plays them when its file declares one; the night of the
241
241
  # poste plays them itself otherwise (tests-de-nuit --du-poste), so no last green without them.
242
242
  if node "$ici/flux-de-la-nuit.mjs" mesures "$copie"; then
243
+ echo "relevé de la nuit : mesures de temps du flux : $mesures_du_flux"
243
244
  case "$mesures_du_flux" in
244
245
  rouge)
245
246
  echo "✗ les mesures de temps du flux sont rouges sur PC2."
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // The creation of a package, out of the circuit: the third of the four times of a package's birth
3
- // (the common charter, « La naissance d'un paquet »: the grill, the writing of its row and its
3
+ // (the common charter, module superviseur, « Un paquet naît hors du circuit »: the grill, the writing of its row and its
4
4
  // documents, this command, then a ticket of code), as the generators of Nx and `cargo new --lib`
5
5
  // write one. A skeleton has neither behaviour nor test. The mechanism is installation.md §3.1
6
6
  // (« Création d'un paquet »), tests.md §5.6, in packages/grillhouse/docs/architecture/.
@@ -6,7 +6,7 @@
6
6
  //
7
7
  // - The sheet of the end of a session (« la fiche ») of the explorateur, the questionneur, the
8
8
  // testwriter, the developpeur, the agent direct and the reviewer: the schema of each role (FICHES), which the
9
- // session receives (`claude -p --output-format json --json-schema <schéma>`) and fills as its
9
+ // session receives (`claude -p --json-schema <schéma>`) and fills as its
10
10
  // last act, in the field `structured_output` of its result. A field exists only when a reader
11
11
  // reads it:
12
12
  // - `statut` (FAIT, BLOQUÉ, BESOIN), with `raison` for BLOQUÉ and `question` for BESOIN, each
@@ -1024,7 +1024,7 @@ function manques(role, f) {
1024
1024
  return out;
1025
1025
  }
1026
1026
 
1027
- // The sheet of <role> in <sortie>, what claude prints with `--output-format json`: `{ fiche,
1027
+ // The sheet of <role> in <sortie>, the line `type: result` of claude's stream: `{ fiche,
1028
1028
  // seance }`, or `{ erreur }` naming what lacks or does not conform; with <copie>, the directory
1029
1029
  // of the copy, each file piece of the sheet stands in it, its file and its line; with <ticket>,
1030
1030
  // the description of the ticket, each piece of the ticket names a criterion or a section of it.
@@ -29,6 +29,8 @@ import os from 'node:os';
29
29
  import path from 'node:path';
30
30
  import { pathToFileURL } from 'node:url';
31
31
  import { GREFFON } from './cadre.mjs';
32
+ import { competencesDuRole } from './droits.mjs';
33
+ import { entreeDeSeance } from './entree-de-seance.mjs';
32
34
  import { avecLeFichierDuPoste, configurationDuPoste } from './fichier-du-poste.mjs';
33
35
  import {
34
36
  changements,
@@ -124,19 +126,28 @@ const OUVRIR_LE_TEMPORAIRE = `import { ouvrirBase } from ${JSON.stringify(
124
126
  )}; process.stdout.write(ouvrirBase('seance', { pid: Number(process.argv[1]) }).dossier);`;
125
127
 
126
128
  // The shell that carries a session out of the envelope (`$0` the file of its exit code, `$1` node,
127
- // `$2` the script above, then the session's command): it opens the session's temporary directory,
128
- // which it owns, so that it outlives a dead circuit, names it in TMPDIR, TMP and TEMP, whatever
129
- // CLAUDE_CODE_TMPDIR the poste holds, and removes it at its end, even interrupted.
129
+ // `$2` the script above, `$3` the sorter of its stream (scripts/sortie-de-seance.mjs), `$4` the
130
+ // file of its result, `$5` that of the lines the log takes of it, then the session's command): it
131
+ // opens the session's temporary directory, which it owns, so that it outlives a dead circuit,
132
+ // names it in TMPDIR, TMP and TEMP, whatever CLAUDE_CODE_TMPDIR the poste holds, and removes it at
133
+ // its end, even interrupted. The stream of the session is written beside that directory, then
134
+ // sorted: its result to `$4`, the lines of the log to `$5`, which the circuit adds to the log
135
+ // after the last attempt of the launch.
130
136
  const PORTER_LA_SEANCE = [
131
137
  "trap 'exit 129' HUP; trap 'exit 130' INT; trap 'exit 143' TERM",
132
138
  't=$("$1" --input-type=module -e "$2" "$$" </dev/null) || exit',
133
139
  'trap \'rm -rf -- "${t%/t}"\' EXIT',
134
- 'shift 2',
140
+ 'node=$1 tri=$3 resultat=$4 journal=$5 flux="${t%/t}/flux"',
141
+ 'shift 5',
135
142
  'export TMPDIR="$t" TMP="$t" TEMP="$t"',
136
143
  'unset CLAUDE_CODE_TMPDIR',
137
- '"$@"; c=$?; echo "$c" > "$0"; exit "$c"',
144
+ '"$@" > "$flux"; c=$?',
145
+ '"$node" "$tri" "$flux" "$resultat" > "$journal"',
146
+ 'echo "$c" > "$0"; exit "$c"',
138
147
  ].join('\n');
139
148
 
149
+ const TRIER_LE_FLUX = path.join(import.meta.dirname, 'sortie-de-seance.mjs');
150
+
140
151
  // The templates of the instructions, in the skill of the supervisor, which the frame's plugin
141
152
  // carries, read at the plugin's root (scripts/cadre.mjs).
142
153
  const GABARIT = path.join(GREFFON, 'skills', 'pitmaster', 'references', 'consigne-agent.md');
@@ -170,9 +181,10 @@ const mtime = f => {
170
181
 
171
182
  /**
172
183
  * Where the session <id> of <ctx> keeps its result, in the working directory of the ticket
173
- * (`<copie>.travail/seances/<id>/`, as lancer.sh writes it): its exit code (`fin`), claude's JSON
174
- * result (`resultat.json`), the tree the prepared copy held before it (`avant`) and the witness
175
- * that the envelope started its command (`demarree`).
184
+ * (`<copie>.travail/seances/<id>/`, as lancer.sh writes it): its exit code (`fin`), the line
185
+ * `type: result` of claude's stream (`resultat.json`), the lines the log takes of the stream of
186
+ * a session out of the envelope (`au-journal`), the tree the prepared copy held before it
187
+ * (`avant`) and the witness that the envelope started its command (`demarree`).
176
188
  */
177
189
  export function rangDeLaSeance(ctx, id) {
178
190
  const dossier = path.join(ctx.tmp, 'seances', id);
@@ -180,6 +192,7 @@ export function rangDeLaSeance(ctx, id) {
180
192
  dossier,
181
193
  fin: path.join(dossier, 'fin'),
182
194
  resultat: path.join(dossier, 'resultat.json'),
195
+ auJournal: path.join(dossier, 'au-journal'),
183
196
  avant: path.join(dossier, 'avant'),
184
197
  demarree: path.join(dossier, 'demarree'),
185
198
  };
@@ -215,10 +228,12 @@ function resultatRange(rang, id, { horsEnveloppe = false } = {}) {
215
228
  // itself, in the ticket's
216
229
  // copy (the main tree once the copy is gone), under <droits> (`horsDeLEnveloppe`), the
217
230
  // schema of its role's sheet and the options <session> names (its id, or the session it
218
- // resumes), its instruction on its standard input and its result on its standard output, in a
219
- // temporary directory of its own (PORTER_LA_SEANCE), ranged
220
- // under its id with its exit code as lancer.sh ranges them, added to the log under its header
221
- // line, then its line written to the register, as lancer.sh does.
231
+ // resumes), in stream-json both ways: the skills of its role and its instruction on its standard
232
+ // input (scripts/entree-de-seance.mjs), its stream on its standard output, in a temporary
233
+ // directory of its own (PORTER_LA_SEANCE); of that stream, its result is ranged under its id with
234
+ // its exit code as lancer.sh ranges them, and the log takes under its header line what is not the
235
+ // conversation (scripts/sortie-de-seance.mjs); then its line is written to the register, as
236
+ // lancer.sh does.
222
237
  // Its launch is kept with the circuit's results (`lancement`: its role, its session id, and the
223
238
  // <objet> of a session that is not its role's own work, `tri`), which the bilan reads to count the
224
239
  // sessions the circuit launched (scripts/bilan.mjs). Its sign of life names the session
@@ -301,6 +316,7 @@ export async function lancer(
301
316
  mkdirSync(rang.dossier, { recursive: true });
302
317
  rmSync(rang.fin, { force: true });
303
318
  rmSync(rang.resultat, { force: true });
319
+ rmSync(rang.auJournal, { force: true });
304
320
  rmSync(rang.avant, { force: true });
305
321
  rmSync(rang.demarree, { force: true });
306
322
  inscrire(ctx, {
@@ -312,22 +328,27 @@ export async function lancer(
312
328
  writeFileSync(fichier, consigne);
313
329
  // A file, not a pipe: a session whose circuit is dead writes its errors without breaking.
314
330
  const erreurs = path.join(ctx.tmp, `erreurs-${numero}.txt`);
331
+ // The input of a session out of the envelope; lancer.sh composes that of an enveloped one.
332
+ const entree = path.join(ctx.tmp, `entree-${numero}.jsonl`);
333
+ if (horsEnveloppe) {
334
+ writeFileSync(entree, entreeDeSeance({ competences: competencesDuRole(role), consigne }));
335
+ }
315
336
  let commande;
316
- // Its result ranged under its id, as lancer.sh ranges a session's: claude's output, then its
317
- // exit code once it ends, written by the shell that runs it, which outlives a dead circuit.
318
- const ouvrirLesFds = () =>
319
- horsEnveloppe
320
- ? [openSync(fichier, 'r'), openSync(rang.resultat, 'w'), openSync(ctx.journal, 'a')]
321
- : ['ignore', 'ignore', openSync(erreurs, 'w')];
337
+ // Its result ranged under its id, as lancer.sh ranges a session's: the result of claude's
338
+ // stream, then its exit code once it ends, written by the shell that runs it, which outlives a
339
+ // dead circuit.
340
+ const ouvrirLesFds = () => {
341
+ if (!horsEnveloppe) {
342
+ return ['ignore', 'ignore', openSync(erreurs, 'w')];
343
+ }
344
+ const journal = openSync(ctx.journal, 'a');
345
+ return [openSync(entree, 'r'), journal, journal];
346
+ };
322
347
  let fds = ouvrirLesFds();
323
348
  if (horsEnveloppe) {
324
349
  entete(ctx, role);
325
- const fiche = [
326
- '--output-format',
327
- 'json',
328
- '--json-schema',
329
- JSON.stringify(schemaDeFiche(sorte ?? role)),
330
- ];
350
+ const flux = ['--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose'];
351
+ const fiche = ['--json-schema', JSON.stringify(schemaDeFiche(sorte ?? role))];
331
352
  commande = {
332
353
  cmd: 'sh',
333
354
  args: [
@@ -336,8 +357,11 @@ export async function lancer(
336
357
  rang.fin,
337
358
  process.execPath,
338
359
  OUVRIR_LE_TEMPORAIRE,
360
+ TRIER_LE_FLUX,
361
+ rang.resultat,
362
+ rang.auJournal,
339
363
  process.env.CLAUDE_BIN || 'claude',
340
- ...['-p', '--agent', role, ...fiche, ...droits, '--add-dir', ctx.tmp, ...session],
364
+ ...['-p', '--agent', role, ...flux, ...fiche, ...droits, '--add-dir', ctx.tmp, ...session],
341
365
  ],
342
366
  cwd: existsSync(ctx.copie) ? ctx.copie : ctx.racine,
343
367
  };
@@ -473,6 +497,7 @@ export async function lancer(
473
497
  );
474
498
  rmSync(rang.fin, { force: true });
475
499
  rmSync(rang.resultat, { force: true });
500
+ rmSync(rang.auJournal, { force: true });
476
501
  fds = ouvrirLesFds();
477
502
  const { ANTHROPIC_API_KEY: _cle, ...sansCle } = process.env;
478
503
  r = await jouer(sansCle);
@@ -486,7 +511,9 @@ export async function lancer(
486
511
  : r.erreur === null
487
512
  ? r.code
488
513
  : null;
489
- appendFileSync(ctx.journal, `${sortie}\n`);
514
+ if (existsSync(rang.auJournal)) {
515
+ appendFileSync(ctx.journal, readFileSync(rang.auJournal));
516
+ }
490
517
  spawnSync(process.execPath, [REGISTRE, '--copie', ctx.copie], {
491
518
  cwd: ctx.racine,
492
519
  stdio: ['ignore', 'ignore', 'ignore'],