@roomi-fields/grillhouse 0.50.3 → 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 (150) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/developpeur.md +1 -1
  4. package/agents/direct.md +1 -1
  5. package/agents/explorateur.md +1 -1
  6. package/agents/questionneur.md +1 -1
  7. package/agents/relecteur.md +1 -1
  8. package/agents/testwriter.md +1 -1
  9. package/cadre/templates/c/package.json +1 -0
  10. package/cadre/templates/cargo/package.json +1 -0
  11. package/cadre/templates/python/package.json +1 -0
  12. package/charte/plan.md +47 -0
  13. package/charte/preuve.md +39 -0
  14. package/charte/superviseur.md +61 -0
  15. package/charte/tests.md +38 -0
  16. package/charte.md +39 -189
  17. package/dist/machine/part-par-sorte.d.ts +16 -0
  18. package/dist/machine/part-par-sorte.js +36 -0
  19. package/dist/machine/part-par-sorte.js.map +1 -0
  20. package/dist/temporal/circuit/appel.js +1 -1
  21. package/dist/temporal/circuit/appel.js.map +1 -1
  22. package/dist/temporal/circuit/client.d.ts +4 -4
  23. package/dist/temporal/circuit/client.js +38 -16
  24. package/dist/temporal/circuit/client.js.map +1 -1
  25. package/dist/temporal/circuit/contrat.d.ts +11 -7
  26. package/dist/temporal/circuit/contrat.js +5 -9
  27. package/dist/temporal/circuit/contrat.js.map +1 -1
  28. package/dist/temporal/circuit/deroule.js +18 -6
  29. package/dist/temporal/circuit/deroule.js.map +1 -1
  30. package/dist/temporal/commande.js +12 -3
  31. package/dist/temporal/commande.js.map +1 -1
  32. package/dist/temporal/installation.d.ts +54 -3
  33. package/dist/temporal/installation.js +187 -17
  34. package/dist/temporal/installation.js.map +1 -1
  35. package/dist/temporal/places/client.d.ts +5 -1
  36. package/dist/temporal/places/client.js +23 -11
  37. package/dist/temporal/places/client.js.map +1 -1
  38. package/docs/ARCHITECTURE.md +23 -2700
  39. package/docs/INTERFACE.md +26 -10
  40. package/docs/architecture/circuit.md +61 -14
  41. package/docs/architecture/entree.md +21 -8
  42. package/docs/architecture/greffon.md +49 -20
  43. package/docs/architecture/installation.md +46 -17
  44. package/docs/architecture/machine.md +79 -39
  45. package/docs/architecture/tests.md +59 -16
  46. package/docs/lexique.md +163 -0
  47. package/hooks/hooks.json +0 -10
  48. package/hooks/register.tsx +92 -4
  49. package/package.json +2 -1
  50. package/scripts/activites.mjs +105 -65
  51. package/scripts/aiguillage.mjs +15 -8
  52. package/scripts/attente-au-tour.mjs +2 -3
  53. package/scripts/attente-de-la-machine.mjs +4 -8
  54. package/scripts/avancement.mjs +12 -8
  55. package/scripts/bilan.mjs +126 -63
  56. package/scripts/bilans-gardes.mjs +37 -0
  57. package/scripts/branche-de-nuit.mjs +2 -2
  58. package/scripts/ci-de-main.mjs +18 -21
  59. package/scripts/circuit.mjs +89 -44
  60. package/scripts/circuits-du-serveur.mjs +5 -5
  61. package/scripts/composants-affectes.mjs +30 -12
  62. package/scripts/composition-des-langages.mjs +5 -3
  63. package/scripts/conformite.mjs +1 -1
  64. package/scripts/consommation-des-passes.mjs +8 -6
  65. package/scripts/copies-finies.mjs +3 -14
  66. package/scripts/depart-du-ticket.d.mts +8 -2
  67. package/scripts/depart-du-ticket.mjs +26 -8
  68. package/scripts/direct.mjs +158 -72
  69. package/scripts/droits.mjs +165 -208
  70. package/scripts/engendres.mjs +3 -14
  71. package/scripts/entree-de-seance.mjs +35 -0
  72. package/scripts/enveloppe/enveloppe.mjs +98 -46
  73. package/scripts/enveloppe/lancer.sh +90 -66
  74. package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
  75. package/scripts/enveloppe/travail-de-la-copie.mjs +192 -3
  76. package/scripts/etapes.mjs +84 -22
  77. package/scripts/faits-du-circuit.mjs +8 -2
  78. package/scripts/grillhouse-maj.mjs +43 -18
  79. package/scripts/groupe-cles.d.mts +15 -0
  80. package/scripts/groupe-cles.mjs +77 -2
  81. package/scripts/init.mjs +9 -2
  82. package/scripts/integration/rejeu.mjs +8 -1
  83. package/scripts/jointure.d.ts +24 -4
  84. package/scripts/langages/c/index.mjs +5 -2
  85. package/scripts/langages/cargo/commandes.mjs +35 -15
  86. package/scripts/langages/cargo/composants.mjs +45 -3
  87. package/scripts/langages/cargo/index.mjs +6 -3
  88. package/scripts/langages/python/commandes.mjs +50 -7
  89. package/scripts/langages/python/index.mjs +5 -2
  90. package/scripts/langages/python/squelette.mjs +2 -1
  91. package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
  92. package/scripts/langages/typescript/index.mjs +16 -14
  93. package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
  94. package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
  95. package/scripts/langages/typescript/turbo-des-paquets.mjs +151 -38
  96. package/scripts/langages/typescript/verdict.mjs +29 -3
  97. package/scripts/langages/typescript/verifier.mjs +28 -3
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
  99. package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
  100. package/scripts/langages.mjs +54 -4
  101. package/scripts/matieres-lues.mjs +1 -1
  102. package/scripts/mesure/base-de-passe.mjs +32 -90
  103. package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
  104. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  105. package/scripts/migrations.mjs +23 -7
  106. package/scripts/nuit.sh +3 -2
  107. package/scripts/paquet.mjs +1 -1
  108. package/scripts/paquets.d.ts +3 -0
  109. package/scripts/paquets.mjs +88 -1
  110. package/scripts/passe-de-la-machine.mjs +109 -36
  111. package/scripts/places-de-la-machine.mjs +81 -29
  112. package/scripts/plafond-de-la-machine.d.mts +2 -5
  113. package/scripts/plafond-de-la-machine.mjs +9 -9
  114. package/scripts/reprise.mjs +42 -13
  115. package/scripts/resultats.mjs +78 -56
  116. package/scripts/retirer-les-copies-finies.mjs +1 -1
  117. package/scripts/seances.mjs +471 -133
  118. package/scripts/services-du-noyau.mjs +9 -1
  119. package/scripts/session-start.sh +22 -7
  120. package/scripts/sortie-de-seance.mjs +70 -0
  121. package/scripts/sortie.mjs +37 -6
  122. package/scripts/sous-commandes.mjs +0 -3
  123. package/scripts/superviseur.mjs +400 -162
  124. package/scripts/tableau.mjs +188 -65
  125. package/scripts/transitions.d.mts +25 -2
  126. package/scripts/transitions.mjs +137 -29
  127. package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
  128. package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
  129. package/skills/developpeur/SKILL.md +38 -15
  130. package/skills/direct/SKILL.md +29 -9
  131. package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
  132. package/skills/domain-modeling/SKILL.md +14 -12
  133. package/skills/explorateur/SKILL.md +32 -8
  134. package/skills/grill/SKILL.md +3 -2
  135. package/skills/pitmaster/SKILL.md +80 -50
  136. package/skills/pitmaster/references/cadre.md +1 -1
  137. package/skills/pitmaster/references/consigne-agent.md +12 -11
  138. package/skills/pitmaster/references/tour.md +6 -5
  139. package/skills/relecteur/SKILL.md +13 -6
  140. package/skills/systematic-debugging/SKILL.md +281 -0
  141. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  142. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  143. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  144. package/skills/systematic-debugging/find-polluter.sh +72 -0
  145. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  146. package/skills/testwriter/SKILL.md +37 -31
  147. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  148. package/scripts/attente-a-l-arret.mjs +0 -114
  149. package/scripts/verrous/commande.mjs +0 -214
  150. package/scripts/verrous/verrou.mjs +0 -311
@@ -20,12 +20,18 @@
20
20
  // the part of a manifest its tests own) are
21
21
  // played in the main tree of the repository when they throw in the copy, the paths carried from
22
22
  // one tree to the other. A session leaves such a copy between two writes of one change (cargo:
23
- // a dependency moved in the manifest of the workspace and not yet in a crate's); the lock of
24
- // its writes, its envelope and the acts of its circuit read on, as
23
+ // a dependency moved in the manifest of the workspace and not yet in a crate's); the judgment
24
+ // of its lots, its envelope and the acts of its circuit read on, as
25
25
  // rust-analyzer keeps the last graph that loaded, and the write that repairs the copy passes.
26
26
  // `langageDe` stays strict: a guard, a build and the red of a reading read the tree as it is.
27
+ // - The generator of the graph (the `turbo.json` of the packages, whose tasks hash what each
28
+ // package declares its tests read, `grillhouse.lit`) serves every language, as Turborepo hashes
29
+ // the inputs of a task whatever tool it runs. It lives in the module typescript, which the join
30
+ // asks for it in a project that declares no typescript: its command, its generated files, its
31
+ // share of the update and, in a repository of packages, its guard (docs/architecture/tests.md
32
+ // §3.1).
27
33
  // - A module is loaded once per process, synchronously (`require` of an ES module, Node 22): the
28
- // locks and the guards ask it in a hook, where nothing waits.
34
+ // hooks and the guards ask it where nothing waits.
29
35
  //
30
36
  // What the core asks of a module: docs/architecture/tests.md §3.3 and scripts/jointure.d.ts.
31
37
  import { spawnSync } from 'node:child_process';
@@ -33,6 +39,7 @@ import { createRequire } from 'node:module';
33
39
  import path from 'node:path';
34
40
  import { composer } from './composition-des-langages.mjs';
35
41
  import { matieresDeclarees, sousUneMatiere } from './matieres-lues.mjs';
42
+ import { paquets } from './paquets.mjs';
36
43
  import {
37
44
  ARCHITECTURE,
38
45
  COLONNE,
@@ -121,6 +128,49 @@ const avecLesMatieres = langage =>
121
128
  : null),
122
129
  });
123
130
 
131
+ // The name of the generator of the graph, its command and its guard, and the module that holds it.
132
+ const GRAPHE = 'turbo-des-paquets';
133
+ const PORTEUR = 'typescript';
134
+
135
+ // <composition>, the join of <modules>, with the generator of the graph when none of them holds
136
+ // it: its command, its generated files, and its guard in a repository of packages, the first of
137
+ // the languages'. The composition itself when one of them holds it.
138
+ const avecLeGraphe = (composition, modules) => {
139
+ if (modules.some(m => m.nom === PORTEUR)) {
140
+ return composition;
141
+ }
142
+ const porteur = charger(PORTEUR);
143
+ return Object.assign(Object.create(composition), {
144
+ commandes: racine => ({
145
+ ...composition.commandes(racine),
146
+ [GRAPHE]: porteur.commandes(racine)[GRAPHE],
147
+ }),
148
+ fichiersEngendres: racine => [
149
+ ...composition.fichiersEngendres(racine),
150
+ ...porteur.fichiersEngendres(racine).filter(e => e.gardes.includes(GRAPHE)),
151
+ ],
152
+ gardes: racine => [
153
+ ...(paquets(racine).length
154
+ ? porteur.gardes(racine).filter(g => path.basename(g[0], '.mjs') === GRAPHE)
155
+ : []),
156
+ ...composition.gardes(racine),
157
+ ],
158
+ });
159
+ };
160
+
161
+ /**
162
+ * The generators the update runs in a project of the modules <modules>, each with its module:
163
+ * each module's (`miseAJour.generateurs`), then the generator of the graph, which every project
164
+ * has (a generator two give is run once, by its command).
165
+ * @param {import('./jointure.js').Langage[]} modules
166
+ */
167
+ export const generateursDe = modules =>
168
+ [...modules, charger(PORTEUR)].flatMap(m =>
169
+ m.miseAJour.generateurs
170
+ .filter(g => modules.includes(m) || g.commande === GRAPHE)
171
+ .map(g => ({ g, m }))
172
+ );
173
+
124
174
  const composes = new Map();
125
175
  /**
126
176
  * The join of the modules that serve the project at <racine> (`langagesDe`): their composition
@@ -133,7 +183,7 @@ export function langageDe(racine) {
133
183
  const modules = langagesDe(racine);
134
184
  const cle = modules.map(m => m.nom).join('+');
135
185
  if (!composes.has(cle)) {
136
- composes.set(cle, avecLesMatieres(composer(modules)));
186
+ composes.set(cle, avecLesMatieres(avecLeGraphe(composer(modules), modules)));
137
187
  }
138
188
  return composes.get(cle);
139
189
  }
@@ -4,7 +4,7 @@
4
4
  // with the code (Web Platform Tests keep their cases the same way): a list of folders of the
5
5
  // repository, each from the root. The testwriter writes any file under one, as a file of shared
6
6
  // test material; the developpeur does not (`estUnTest` of the join of the languages,
7
- // scripts/langages.mjs, which the lock, the envelope and the conflicts of a copy read).
7
+ // scripts/langages.mjs, which the judgment of a lot, the envelope and the conflicts of a copy read).
8
8
  //
9
9
  // This module holds the reading itself, given the components of the project; it imports no
10
10
  // language, so that the join of the languages can use it. The reading a caller asks by a
@@ -17,19 +17,20 @@
17
17
  // beside its copy, which no sweep touches); `integration`, the working directory of an
18
18
  // integration (scripts/integration/integrer.mjs); `file`, the results of the final pass of the queue
19
19
  // (scripts/integration/file.mjs); `enveloppe`, the throwaway state of a session's envelope
20
- // (scripts/enveloppe/enveloppe.mjs).
21
- // - The owner of a base is the process that opens it, for a pass and a session out of a ticket
22
- // (the night, a verification); a ticket (`ouvrirBaseDuTicket`: `<dans>/grillhouse-ticket-<id>/`,
23
- // the temporary directory of the agents of one ticket, which the launcher gives each session of
24
- // the ticket, scripts/enveloppe/lancer.sh, and `npx grillhouse temporaire <ticket>` the
25
- // supervisor), kept from one session and one resumption to the next, removed when its ticket is
26
- // closed (`balayerLesTickets`, which the removal of the finished copies plays,
27
- // scripts/copies-finies.mjs), frozen or not; or a directory
28
- // (`cacheDeLaRacine`: the cache of a build rooted in the temporary directory), swept once that
29
- // directory is gone, from the namespace that opened it, or, from the host (the next base of a
30
- // pass, out of an envelope, where the home is read-only), untouched for 7 days whatever its
31
- // namespace. What an agent needs to resume lives in its copy or its handover, never in
32
- // the ticket's temporary directory alone, which holds what is made again.
20
+ // (scripts/enveloppe/enveloppe.mjs); `seance`, the temporary directory of one session of an
21
+ // agent that the frame launches, opened by the launcher of the envelope
22
+ // (scripts/enveloppe/lancer.sh) or by the shell that carries a session out of the envelope
23
+ // (scripts/seances.mjs), which removes it at the session's end, even interrupted. What an agent
24
+ // needs to resume lives in its copy or its handover, never in this directory, which holds what
25
+ // is made again.
26
+ // - The owner of a base is the process that opens it, or the one the call names (`pid`: the
27
+ // process that lives as long as its session); or a directory (`cacheDeLaRacine`: the cache of a
28
+ // build rooted in the temporary directory), swept once that directory is gone, from the
29
+ // namespace that opened it, or, from the host (the next base of a pass, out of an envelope,
30
+ // where the home is read-only), untouched for 7 days whatever its namespace.
31
+ // - `npx grillhouse temporaire`, without argument, writes in a session the frame launched
32
+ // (`GRILLHOUSE_ENVELOPPE`, or `GRILLHOUSE_SEANCE` out of the envelope) the directory its
33
+ // `TMPDIR` names; anywhere else, or with an argument, it says so and ends at 2.
33
34
  // - The caches of compilation never lie in the temporary directory, a disk in memory that the
34
35
  // sessions of the machine share: they go under `${XDG_CACHE_HOME:-~/.cache}/grillhouse/<outil>`
35
36
  // (`cacheDeCompilation`); a build rooted in the temporary directory (a project of trial) keeps
@@ -122,8 +123,7 @@ function proprietaire(base) {
122
123
 
123
124
  // Whether the base <base> is an orphan: its owner, a directory or a process, belongs to this
124
125
  // namespace of processes and is gone; a directory another namespace sees (an envelope's private
125
- // /tmp) or a process of another namespace is never judged here. A ticket's base goes with its
126
- // ticket (`balayerLesTickets`).
126
+ // /tmp) or a process of another namespace is never judged here.
127
127
  function orpheline(base) {
128
128
  const p = proprietaire(base);
129
129
  const ici = espace();
@@ -170,6 +170,9 @@ function vieille(base) {
170
170
  }
171
171
  }
172
172
 
173
+ /** The variable that marks a session out of the envelope that the frame launched. */
174
+ export const VARIABLE_SEANCE = 'GRILLHOUSE_SEANCE';
175
+
173
176
  // Whether <env> is an agent's envelope, where the home is read-only (scripts/enveloppe/).
174
177
  const enEnveloppe = env => Boolean(env.GRILLHOUSE_ENVELOPPE);
175
178
 
@@ -294,20 +297,21 @@ function balayerLesEssais(env) {
294
297
  * Opens the base of a pass of <genre> in <dans>, after sweeping the orphan bases there, and the
295
298
  * orphan trial directories under the home.
296
299
  * @param {string} genre what the pass is (`vitest`, `circuit`…), in the base's name
297
- * @param {{ dans?: string }} options `dans`, the directory of the base (`os.tmpdir()`)
300
+ * @param {{ dans?: string, pid?: number }} options `dans`, the directory of the base
301
+ * (`os.tmpdir()`); `pid`, the process that owns it (this one)
298
302
  * @returns {{ base: string, dossier: string, env: Record<string, string>, restes: () => string[],
299
303
  * essais: () => string[], fermer: () => void }} the base; the directory its pass writes in; the
300
304
  * variables that name it to the pass's children (TMPDIR, TMP, TEMP); what is in it, sorted; the
301
305
  * names of the `grillhouse-essais-*` directories of the home's cache whose owner file names this
302
306
  * pass, read at the call; and the removal of the base
303
307
  */
304
- export function ouvrirBase(genre, { dans = tmpdir() } = {}) {
308
+ export function ouvrirBase(genre, { dans = tmpdir(), pid = process.pid } = {}) {
305
309
  balayer(dans);
306
310
  balayerLesCaches(process.env);
307
311
  balayerLesEssais(process.env);
308
312
  mkdirSync(dans, { recursive: true });
309
313
  const base = mkdtempSync(path.join(dans, `${PREFIXE}${genre}-`));
310
- const moi = { pid: process.pid, depart: departDe(process.pid), espace: espace() };
314
+ const moi = { pid, depart: departDe(pid), espace: espace() };
311
315
  writeFileSync(path.join(base, PROPRIETAIRE), `${JSON.stringify(moi)}\n`);
312
316
  const dossier = path.join(base, 't');
313
317
  mkdirSync(dossier);
@@ -328,67 +332,6 @@ export function ouvrirBase(genre, { dans = tmpdir() } = {}) {
328
332
  };
329
333
  }
330
334
 
331
- // The prefix of the base of a ticket, and the form of a ticket's id.
332
- const DU_TICKET = `${PREFIXE}ticket-`;
333
- const ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
334
-
335
- /**
336
- * The base of the ticket <ticket> in <dans>: `<dans>/grillhouse-ticket-<ticket>/`, its owner the
337
- * ticket, made when absent and the same at each call; the temporary directory of the agents of
338
- * one ticket, kept from one session to the next, removed when it is closed (`balayerLesTickets`).
339
- * @param {string} ticket the ticket's id
340
- * @param {{ dans?: string }} options `dans`, the directory of the base (`os.tmpdir()`)
341
- * @returns {{ base: string, dossier: string }} the base, and the directory its agents write in
342
- */
343
- export function ouvrirBaseDuTicket(ticket, { dans = tmpdir() } = {}) {
344
- if (!ID.test(ticket)) {
345
- throw new Error(`⛔ « ${ticket} » n'est pas l'identifiant d'un ticket.`);
346
- }
347
- const base = path.join(dans, `${DU_TICKET}${ticket}`);
348
- const dossier = path.join(base, 't');
349
- mkdirSync(dossier, { recursive: true });
350
- if (proprietaire(base) === null) {
351
- writeFileSync(path.join(base, PROPRIETAIRE), `${JSON.stringify({ ticket })}\n`);
352
- }
353
- return { base, dossier };
354
- }
355
-
356
- /**
357
- * Removes from <dans> the base of each ticket that is closed; the ids of the tickets whose base
358
- * went. A ticket open, frozen or not, keeps its base, as a retention policy fixed in advance.
359
- * <fermes> reads the closed tickets, null when they do not read: called once, and only when a
360
- * ticket's base is there.
361
- * @param {() => Set<string> | null} fermes
362
- * @param {{ dans?: string }} options `dans`, the directory of the bases (`os.tmpdir()`)
363
- * @returns {string[]}
364
- */
365
- export function balayerLesTickets(fermes, { dans = tmpdir() } = {}) {
366
- const tickets = contenu(dans)
367
- .filter(n => n.startsWith(DU_TICKET))
368
- .map(n => ({ base: path.join(dans, n), ticket: proprietaire(path.join(dans, n))?.ticket }))
369
- .filter(b => typeof b.ticket === 'string');
370
- if (tickets.length === 0) {
371
- return [];
372
- }
373
- const clos = fermes();
374
- if (clos === null) {
375
- return [];
376
- }
377
- const retires = tickets.filter(b => clos.has(b.ticket));
378
- for (const b of retires) {
379
- rmSync(b.base, { recursive: true, force: true });
380
- }
381
- return retires.map(b => b.ticket);
382
- }
383
-
384
- /**
385
- * The ticket whose base is the entry <nom> of the temporary directory, or null.
386
- * @param {string} nom
387
- */
388
- export function ticketDeLaBase(nom) {
389
- return nom.startsWith(DU_TICKET) ? nom.slice(DU_TICKET.length) : null;
390
- }
391
-
392
335
  // Whether <chemin> lies in <dossier> or is it.
393
336
  const sous = (chemin, dossier) => {
394
337
  const rel = path.relative(dossier, chemin);
@@ -455,19 +398,18 @@ export function cacheDeLaRacine(outil, racine, env = process.env, { creer = true
455
398
  return cache;
456
399
  }
457
400
 
458
- // `npx grillhouse temporaire <ticket>`: prints the directory of the ticket's agents.
459
- function commande(argv) {
460
- if (argv.length !== 1 || argv[0].startsWith('-')) {
461
- process.stderr.write('usage: npx grillhouse temporaire <ticket>\n');
462
- return 2;
463
- }
464
- try {
465
- process.stdout.write(`${ouvrirBaseDuTicket(argv[0]).dossier}\n`);
466
- return 0;
467
- } catch (e) {
468
- process.stderr.write(`${e.message}\n`);
401
+ // `npx grillhouse temporaire`: in a session the frame launched, prints the temporary directory
402
+ // that its TMPDIR names.
403
+ function commande(argv, env = process.env) {
404
+ const enSeance = enEnveloppe(env) || Boolean(env[VARIABLE_SEANCE]);
405
+ if (argv.length > 0 || !enSeance || !env.TMPDIR) {
406
+ process.stderr.write(
407
+ '⛔ usage: npx grillhouse temporaire, sans argument, dans une séance que le cadre lance : elle écrit le dossier temporaire de cette séance. Hors d’elle, un fichier temporaire va dans le scratchpad de la séance.\n'
408
+ );
469
409
  return 2;
470
410
  }
411
+ process.stdout.write(`${env.TMPDIR}\n`);
412
+ return 0;
471
413
  }
472
414
 
473
415
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
@@ -0,0 +1,79 @@
1
+ // Every project declares the servers of the index in its .mcp.json, the one the project commits
2
+ // and the sessions of its agents read (scripts/droits.mjs): codegraph, the code knowledge graph,
3
+ // and rtfm, the search over code and documents. `grillhouse init` plays this migration on the
4
+ // project it creates. Mechanism: installation.md §5.4 (packages/grillhouse/docs/architecture/).
5
+ //
6
+ // - `version`: null until the release that brings it, which `grillhouse sortie` numbers.
7
+ // - `migrer` adds to `mcpServers` each of the two that is missing, creating the file when the
8
+ // project has none; the other entries and keys stay, in their order, with the indentation of the
9
+ // file. A file that holds both is not rewritten. A file that is not a JSON object, or whose
10
+ // `mcpServers` is not one, stays as it is, left to the project.
11
+ // - `restes(projet)`: rtfm's entry names the program `rtfm-serve`, which the plugin rtfm ships;
12
+ // one line when the project declares that entry and its settings do not enable the plugin.
13
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
14
+ import path from 'node:path';
15
+
16
+ export const version = '0.51.0';
17
+ export const nom = 'serveurs de l index';
18
+
19
+ // Each server in the form its tool publishes: codegraph's own, and the .mcp.json of rtfm.
20
+ const SERVEURS = {
21
+ codegraph: { type: 'stdio', command: 'codegraph', args: ['serve', '--mcp'], env: {} },
22
+ rtfm: { type: 'stdio', command: 'rtfm-serve', args: [], env: { RTFM_DB: '.rtfm/library.db' } },
23
+ };
24
+
25
+ const estUnObjet = v => v !== null && typeof v === 'object' && !Array.isArray(v);
26
+
27
+ // The JSON of <fichier>, or undefined when it holds none.
28
+ function lireJson(fichier) {
29
+ try {
30
+ return JSON.parse(readFileSync(fichier, 'utf8'));
31
+ } catch {
32
+ return undefined;
33
+ }
34
+ }
35
+
36
+ /** The servers of the index added to the .mcp.json of <projet>; returns what it did. */
37
+ export function migrer(projet) {
38
+ const fichier = path.join(projet, '.mcp.json');
39
+ const texte = existsSync(fichier) ? readFileSync(fichier, 'utf8') : null;
40
+ const config = texte === null ? {} : lireJson(fichier);
41
+ const declares = config?.mcpServers ?? {};
42
+ if (!estUnObjet(config) || !estUnObjet(declares)) {
43
+ return [
44
+ {
45
+ aFaire: `.mcp.json : illisible comme configuration de serveurs (un objet JSON, « mcpServers » un objet) ; corrige-le, puis rejoue la montée, qui y ajoute les serveurs de l'index (${Object.keys(SERVEURS).join(', ')})`,
46
+ },
47
+ ];
48
+ }
49
+ const ajoutes = Object.keys(SERVEURS).filter(n => !Object.hasOwn(declares, n));
50
+ if (ajoutes.length === 0) {
51
+ return [];
52
+ }
53
+ config.mcpServers = {
54
+ ...declares,
55
+ ...Object.fromEntries(ajoutes.map(n => [n, SERVEURS[n]])),
56
+ };
57
+ const indent = /^\n?(\s+)"/m.exec(texte ?? '')?.[1] ?? 2;
58
+ const fin = texte === null || texte.endsWith('\n') ? '\n' : '';
59
+ writeFileSync(fichier, `${JSON.stringify(config, null, indent)}${fin}`);
60
+ return [
61
+ `.mcp.json : serveurs de l'index ajoutés (${ajoutes.join(', ')}), que les séances des agents lisent ; commite le fichier`,
62
+ ];
63
+ }
64
+
65
+ /** One line when the rtfm of <projet> waits for a program no enabled plugin ships; none otherwise. */
66
+ export function restes(projet) {
67
+ const mcp = lireJson(path.join(projet, '.mcp.json'));
68
+ if (mcp?.mcpServers?.rtfm?.command !== SERVEURS.rtfm.command) {
69
+ return [];
70
+ }
71
+ const greffons =
72
+ lireJson(path.join(projet, '.claude', 'settings.json'))?.enabledPlugins ?? {};
73
+ if (Object.entries(greffons).some(([id, actif]) => id.startsWith('rtfm@') && actif === true)) {
74
+ return [];
75
+ }
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 lance npx grillhouse greffons dans l’arbre principal.',
78
+ ];
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
+ }
@@ -1,9 +1,10 @@
1
1
  // The migrations of a project from one version of the frame to the next, as the transforms of
2
2
  // `npx @turbo/codemod migrate`: one module per change of form, written once, in
3
- // scripts/migrations/<version>-<nom>.mjs, which `grillhouse maj` plays (scripts/grillhouse-maj.mjs).
3
+ // scripts/migrations/ (`<nom>.mjs`; the older ones `<version>-<nom>.mjs`), which `grillhouse maj` plays (scripts/grillhouse-maj.mjs).
4
4
  // The mechanism is installation.md §5.4 (packages/grillhouse/docs/architecture/).
5
5
  //
6
- // - A migration exports `version` (the version of the package that brings the change of form),
6
+ // - A migration exports `version` (the version of the package that brings the change of form;
7
+ // null until that release, which `grillhouse sortie` numbers: no one else picks it),
7
8
  // `nom` and `migrer(projet)`, which brings the project at <projet> to the new form and returns
8
9
  // the lines of what it changed: none when the project already has it. A line `{ aFaire }` is
9
10
  // what it leaves to the project (a copy of the frame the project modified), which the update
@@ -15,7 +16,10 @@
15
16
  // of Nx carries its own (`migrationsDe`); the update plays those newer than the
16
17
  // version the project recorded (`grillhouse.version` of its package.json), in the order of their
17
18
  // versions; a project that recorded none plays them all. The package carries no migration newer
18
- // than itself once released, so the range ends with the package.
19
+ // than itself, so the range ends with the package. One without a version comes after the
20
+ // others and plays for a project that recorded none or a version below the package's: one that
21
+ // recorded the package's does not play it again, and the release, numbered above, brings it to
22
+ // every project.
19
23
  // - A migration may also export `restes(projet)`: the lines of what stays to the project once the
20
24
  // update is done, which the update plays after its own update and its regeneration, for each
21
25
  // migration it played, and reports (« reste au projet ») without holding back the version, as a
@@ -23,6 +27,7 @@
23
27
  // - Each migration has its test, tests/unit/migration.<nom>.spec.ts (a module's, under its
24
28
  // folder of tests, tests/unit/langages/<nom>/).
25
29
  import semver from 'semver';
30
+ import { VERSION } from './cadre.mjs';
26
31
  import { langageDe } from './langages.mjs';
27
32
  import * as charteImportee from './migrations/0.23.0-charte-importee.mjs';
28
33
  import * as crochetsDeSeance from './migrations/0.23.0-crochets-de-seance.mjs';
@@ -48,6 +53,8 @@ import * as ciDeclencheeParLaFile from './migrations/0.48.0-ci-declenchee-par-la
48
53
  import * as reservationDeTroisCoeurs from './migrations/0.49.0-reservation-de-trois-coeurs.mjs';
49
54
 
50
55
  import * as reglagesHorsDeLaCharte from './migrations/0.50.0-reglages-hors-de-la-charte.mjs';
56
+ import * as serveursDeLIndex from './migrations/serveurs-de-l-index.mjs';
57
+ import * as suiviDuSuperviseurRetire from './migrations/suivi-du-superviseur-retire.mjs';
51
58
 
52
59
  /** The migrations of the core. */
53
60
  export const MIGRATIONS = [
@@ -73,6 +80,8 @@ export const MIGRATIONS = [
73
80
  ciDeclencheeParLaFile,
74
81
  reservationDeTroisCoeurs,
75
82
  reglagesHorsDeLaCharte,
83
+ serveursDeLIndex,
84
+ suiviDuSuperviseurRetire,
76
85
  ];
77
86
 
78
87
  /**
@@ -83,13 +92,20 @@ export const migrationsDe = projet => [...MIGRATIONS, ...langageDe(projet).migra
83
92
 
84
93
  /**
85
94
  * The migrations of <liste> newer than <depuis> (all of them when it is null), in the order of
86
- * their versions; two of one version keep their order in the list.
95
+ * their versions; two of one version keep their order in the list. One without a version, not
96
+ * released yet, comes last, and is newer than a <depuis> below <paquet>, the version of the
97
+ * package.
87
98
  */
88
- export function migrationsAJouer(depuis, liste = MIGRATIONS) {
99
+ export function migrationsAJouer(depuis, liste = MIGRATIONS, paquet = VERSION) {
89
100
  return liste
90
101
  .map((m, rang) => ({ m, rang }))
91
- .filter(({ m }) => depuis === null || semver.gt(m.version, depuis))
92
- .sort((a, b) => semver.compare(a.m.version, b.m.version) || a.rang - b.rang)
102
+ .filter(({ m }) => depuis === null || semver.gt(m.version ?? paquet, depuis))
103
+ .sort(
104
+ (a, b) =>
105
+ (a.m.version === null) - (b.m.version === null) ||
106
+ (a.m.version === null ? 0 : semver.compare(a.m.version, b.m.version)) ||
107
+ a.rang - b.rang
108
+ )
93
109
  .map(({ m }) => m);
94
110
  }
95
111
 
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,6 +6,9 @@
6
6
  export const CODE: string;
7
7
  /** The script of a package that types it, which the verification plays in each package. */
8
8
  export const TYPAGE: string;
9
+ /** The patterns the text `texte` of a test file declares it reads: the words of each line
10
+ * `// @lit` of the comment at its head, each a glob from the top of the repository. */
11
+ export function lecturesDeclarees(texte: string): string[];
9
12
  /** The names listed in `racine`'s `docs/agents/hors-cadre.txt`: empty without the file. */
10
13
  export function horsCadre(racine: string): Set<string>;
11
14
  /** Those of `chemins` (absolute, under `racine`), each as given, that git ignores in the repository
@@ -22,7 +22,7 @@
22
22
  //
23
23
  // The packages are the nodes of the graph of the tasks: docs/architecture/tests.md §2.1 and §3.1.
24
24
  import { spawnSync } from 'node:child_process';
25
- import { existsSync, globSync, readdirSync, readFileSync } from 'node:fs';
25
+ import { existsSync, globSync, readdirSync, readFileSync, statSync } from 'node:fs';
26
26
  import path from 'node:path';
27
27
 
28
28
  /** The code of `src/` (the root's, or a package's under `packages/`), as a pattern of a path from
@@ -31,6 +31,93 @@ export const CODE = '^src/|^packages/[^/]+/src/';
31
31
  /** The script of a package that types it, which the verification plays in each package. */
32
32
  export const TYPAGE = 'typecheck';
33
33
 
34
+ // The tag of a test that declares the files it reads: a line `// @lit <motif> …` of the comment at
35
+ // the head of the file, before its first line of code, as the tag `@poste`.
36
+ const ETIQUETTE_DE_LECTURE = /^\/\/\s*@lit\b(.*)$/;
37
+
38
+ /**
39
+ * The patterns the text <texte> of a test file declares it reads, as the `data` of a Bazel target:
40
+ * the words of each line `// @lit` of the comment at its head, each a glob from the top of the
41
+ * repository. The modules of the languages whose comments open with `//` read their tests by it.
42
+ * @param {string} texte the text of the file
43
+ */
44
+ export function lecturesDeclarees(texte) {
45
+ const out = [];
46
+ for (const ligne of texte.split('\n')) {
47
+ const l = ligne.trim();
48
+ const m = ETIQUETTE_DE_LECTURE.exec(l);
49
+ if (m) {
50
+ out.push(...m[1].split(/\s+/).filter(Boolean));
51
+ } else if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
52
+ break;
53
+ }
54
+ }
55
+ return out;
56
+ }
57
+
58
+ // A path a project declares it reads (`grillhouse.lit`, a generated file's `fichiers` and `lit`),
59
+ // as an input of Turborepo: a path, a directory or a file, or a glob pattern, which holds one of
60
+ // these characters.
61
+ const GLOB = /[*?[\]{}]/;
62
+
63
+ /** Whether the path read <lu> is a glob pattern.
64
+ * @param {string} lu */
65
+ export const estUnMotif = lu => GLOB.test(lu);
66
+
67
+ /** The path read <lu> as the frame compares it: without a leading `./` nor trailing slashes.
68
+ * @param {string} lu */
69
+ export const lectureNette = lu => String(lu ?? '').replace(/^\.\//, '').replace(/\/+$/, '');
70
+
71
+ /**
72
+ * Whether one of <motifs> covers the file <fichier>, both from the root, as the inputs of
73
+ * Turborepo read them: a path names that file, a directory every file under it, a glob pattern
74
+ * (`*`, `**`) the files it matches (`path.matchesGlob` of Node).
75
+ * @param {string[]} motifs
76
+ * @param {string} fichier
77
+ */
78
+ export function couvertPar(motifs, fichier) {
79
+ return motifs.some(m => {
80
+ const net = lectureNette(m);
81
+ return fichier === net || fichier.startsWith(`${net}/`) || path.matchesGlob(fichier, net);
82
+ });
83
+ }
84
+
85
+ /** The files of the repository at <racine> the pattern <motif> covers, from the root,
86
+ * `node_modules` left out.
87
+ * @param {string} racine
88
+ * @param {string} motif */
89
+ export const fichiersDuMotif = (racine, motif) =>
90
+ globSync(lectureNette(motif), {
91
+ cwd: racine,
92
+ exclude: f => path.basename(String(f)) === 'node_modules',
93
+ })
94
+ .filter(f => statSync(path.join(racine, f), { throwIfNoEntry: false })?.isFile())
95
+ .map(f => f.split(path.sep).join('/'));
96
+
97
+ /**
98
+ * Whether the path read <lu> and the directory or file <chemin> (from the root) overlap: a path
99
+ * that holds it or lies in it; a pattern that can name it or a file under it, segment by segment.
100
+ * @param {string} lu
101
+ * @param {string} chemin
102
+ */
103
+ export function recouvreLaLecture(lu, chemin) {
104
+ const net = lectureNette(lu);
105
+ if (!estUnMotif(net)) {
106
+ return net === chemin || net.startsWith(`${chemin}/`) || chemin.startsWith(`${net}/`);
107
+ }
108
+ const motif = net.split('/');
109
+ const segments = chemin.split('/');
110
+ for (const [i, segment] of segments.entries()) {
111
+ if (motif[i] === '**') {
112
+ return true;
113
+ }
114
+ if (i >= motif.length || !path.matchesGlob(segment, motif[i])) {
115
+ return false;
116
+ }
117
+ }
118
+ return true;
119
+ }
120
+
34
121
  // The list of the packages out of the frame: one line per package, « <package> <reason> », its
35
122
  // first word the name of a directory under `packages/` or `src/`; a blank line or a line starting
36
123
  // with `#` names nothing.