@roomi-fields/grillhouse 0.29.0 → 0.31.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 (263) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +769 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/bin/grillhouse.mjs +79 -18
  8. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  9. package/cadre/templates/projet/CLAUDE.md +5 -1
  10. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  11. package/cadre/templates/projet/package.json +2 -2
  12. package/charte.md +24 -0
  13. package/dist/temporal/acte.d.ts +24 -0
  14. package/dist/temporal/acte.js +139 -0
  15. package/dist/temporal/acte.js.map +1 -0
  16. package/dist/temporal/attributs.d.ts +6 -0
  17. package/dist/temporal/attributs.js +15 -0
  18. package/dist/temporal/attributs.js.map +1 -0
  19. package/dist/temporal/circuit/activites.d.ts +13 -0
  20. package/dist/temporal/circuit/activites.js +33 -0
  21. package/dist/temporal/circuit/activites.js.map +1 -0
  22. package/dist/temporal/circuit/client.d.ts +72 -0
  23. package/dist/temporal/circuit/client.js +247 -0
  24. package/dist/temporal/circuit/client.js.map +1 -0
  25. package/dist/temporal/circuit/commande.d.ts +2 -0
  26. package/dist/temporal/circuit/commande.js +238 -0
  27. package/dist/temporal/circuit/commande.js.map +1 -0
  28. package/dist/temporal/circuit/contrat.d.ts +305 -0
  29. package/dist/temporal/circuit/contrat.js +30 -0
  30. package/dist/temporal/circuit/contrat.js.map +1 -0
  31. package/dist/temporal/circuit/deroule.d.ts +3 -0
  32. package/dist/temporal/circuit/deroule.js +540 -0
  33. package/dist/temporal/circuit/deroule.js.map +1 -0
  34. package/dist/temporal/client.d.ts +47 -0
  35. package/dist/temporal/client.js +69 -0
  36. package/dist/temporal/client.js.map +1 -0
  37. package/dist/temporal/commande.d.ts +2 -0
  38. package/dist/temporal/commande.js +94 -0
  39. package/dist/temporal/commande.js.map +1 -0
  40. package/dist/temporal/deroules.d.ts +5 -0
  41. package/dist/temporal/deroules.js +10 -0
  42. package/dist/temporal/deroules.js.map +1 -0
  43. package/dist/temporal/etat.d.ts +33 -0
  44. package/dist/temporal/etat.js +59 -0
  45. package/dist/temporal/etat.js.map +1 -0
  46. package/dist/temporal/file/activites.d.ts +10 -0
  47. package/dist/temporal/file/activites.js +25 -0
  48. package/dist/temporal/file/activites.js.map +1 -0
  49. package/dist/temporal/file/client.d.ts +4 -0
  50. package/dist/temporal/file/client.js +6 -0
  51. package/dist/temporal/file/client.js.map +1 -0
  52. package/dist/temporal/file/contrat.d.ts +158 -0
  53. package/dist/temporal/file/contrat.js +14 -0
  54. package/dist/temporal/file/contrat.js.map +1 -0
  55. package/dist/temporal/file/deroule.d.ts +15 -0
  56. package/dist/temporal/file/deroule.js +235 -0
  57. package/dist/temporal/file/deroule.js.map +1 -0
  58. package/dist/temporal/installation.d.ts +120 -0
  59. package/dist/temporal/installation.js +386 -0
  60. package/dist/temporal/installation.js.map +1 -0
  61. package/dist/temporal/places/activites.d.ts +8 -0
  62. package/dist/temporal/places/activites.js +13 -0
  63. package/dist/temporal/places/activites.js.map +1 -0
  64. package/dist/temporal/places/client.d.ts +28 -0
  65. package/dist/temporal/places/client.js +64 -0
  66. package/dist/temporal/places/client.js.map +1 -0
  67. package/dist/temporal/places/contrat.d.ts +106 -0
  68. package/dist/temporal/places/contrat.js +21 -0
  69. package/dist/temporal/places/contrat.js.map +1 -0
  70. package/dist/temporal/places/deroule.d.ts +3 -0
  71. package/dist/temporal/places/deroule.js +198 -0
  72. package/dist/temporal/places/deroule.js.map +1 -0
  73. package/dist/temporal/sonde/activites.d.ts +6 -0
  74. package/dist/temporal/sonde/activites.js +52 -0
  75. package/dist/temporal/sonde/activites.js.map +1 -0
  76. package/dist/temporal/sonde/contrat.d.ts +35 -0
  77. package/dist/temporal/sonde/contrat.js +10 -0
  78. package/dist/temporal/sonde/contrat.js.map +1 -0
  79. package/dist/temporal/sonde/deroule.d.ts +3 -0
  80. package/dist/temporal/sonde/deroule.js +39 -0
  81. package/dist/temporal/sonde/deroule.js.map +1 -0
  82. package/dist/temporal/tickets/activites.d.ts +7 -0
  83. package/dist/temporal/tickets/activites.js +81 -0
  84. package/dist/temporal/tickets/activites.js.map +1 -0
  85. package/dist/temporal/tickets/client.d.ts +10 -0
  86. package/dist/temporal/tickets/client.js +31 -0
  87. package/dist/temporal/tickets/client.js.map +1 -0
  88. package/dist/temporal/tickets/contrat.d.ts +56 -0
  89. package/dist/temporal/tickets/contrat.js +13 -0
  90. package/dist/temporal/tickets/contrat.js.map +1 -0
  91. package/dist/temporal/tickets/deroule.d.ts +3 -0
  92. package/dist/temporal/tickets/deroule.js +94 -0
  93. package/dist/temporal/tickets/deroule.js.map +1 -0
  94. package/dist/temporal/travailleur.d.ts +2 -0
  95. package/dist/temporal/travailleur.js +69 -0
  96. package/dist/temporal/travailleur.js.map +1 -0
  97. package/docs/ARCHITECTURE.md +646 -87
  98. package/docs/CADRE.md +27 -0
  99. package/docs/INTERFACE.md +139 -42
  100. package/hooks/crochet.mjs +19 -2
  101. package/hooks/hooks.json +11 -0
  102. package/package.json +16 -4
  103. package/scripts/activites.mjs +2255 -0
  104. package/scripts/aiguillage.d.mts +37 -0
  105. package/scripts/aiguillage.mjs +40 -14
  106. package/scripts/avancement.mjs +155 -26
  107. package/scripts/bilan.mjs +137 -43
  108. package/scripts/cadre.mjs +16 -4
  109. package/scripts/circuit.mjs +993 -4075
  110. package/scripts/circuits-cles.d.mts +4 -0
  111. package/scripts/circuits-cles.mjs +21 -0
  112. package/scripts/circuits-du-serveur.mjs +105 -0
  113. package/scripts/codes-de-sortie.mjs +9 -0
  114. package/scripts/commandes-composees.mjs +45 -41
  115. package/scripts/commandes-du-path.d.mts +7 -0
  116. package/scripts/commandes-du-path.mjs +25 -0
  117. package/scripts/composants-affectes.mjs +64 -21
  118. package/scripts/composition-des-langages.mjs +18 -12
  119. package/scripts/conformite.mjs +56 -28
  120. package/scripts/copies-finies.mjs +52 -47
  121. package/scripts/depart-du-ticket.d.mts +53 -0
  122. package/scripts/depart-du-ticket.mjs +124 -0
  123. package/scripts/dependances-internes.mjs +121 -0
  124. package/scripts/dernier-vert.mjs +61 -34
  125. package/scripts/dette.mjs +32 -11
  126. package/scripts/donnees-cles.mjs +244 -0
  127. package/scripts/droits.mjs +51 -16
  128. package/scripts/effets.mjs +352 -0
  129. package/scripts/empreinte-d-etape.mjs +17 -0
  130. package/scripts/engendres.mjs +15 -5
  131. package/scripts/enveloppe/enveloppe.mjs +259 -55
  132. package/scripts/enveloppe/lancer.sh +14 -18
  133. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  134. package/scripts/enveloppe/travail-de-la-copie.mjs +41 -13
  135. package/scripts/etapes.mjs +5 -2
  136. package/scripts/faits-du-circuit.mjs +493 -0
  137. package/scripts/file-des-tickets.d.mts +21 -0
  138. package/scripts/file-des-tickets.mjs +58 -0
  139. package/scripts/flux-des-paquets.mjs +201 -0
  140. package/scripts/gardes-du-cadre.mjs +21 -5
  141. package/scripts/init.mjs +11 -4
  142. package/scripts/integration/file.mjs +544 -434
  143. package/scripts/integration/integrer.mjs +87 -43
  144. package/scripts/integration/rejeu.mjs +45 -13
  145. package/scripts/jointure.d.ts +151 -28
  146. package/scripts/langages/cargo/commandes.mjs +383 -124
  147. package/scripts/langages/cargo/composants.mjs +154 -42
  148. package/scripts/langages/cargo/exemples.mjs +12 -21
  149. package/scripts/langages/cargo/index.mjs +22 -8
  150. package/scripts/langages/cargo/sccache.mjs +8 -14
  151. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  152. package/scripts/langages/python/commandes.mjs +218 -100
  153. package/scripts/langages/python/composants.mjs +53 -21
  154. package/scripts/langages/python/exemples.mjs +6 -16
  155. package/scripts/langages/python/index.mjs +28 -8
  156. package/scripts/langages/python/lot.mjs +1 -36
  157. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  158. package/scripts/langages/typescript/composants.mjs +9 -3
  159. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  160. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  161. package/scripts/langages/typescript/construire.mjs +6 -163
  162. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  163. package/scripts/langages/typescript/exemples.mjs +3 -11
  164. package/scripts/langages/typescript/frontieres.mjs +66 -22
  165. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  166. package/scripts/langages/typescript/index.mjs +50 -61
  167. package/scripts/langages/typescript/interfaces-contre-code.mjs +113 -45
  168. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  169. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  170. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  171. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  172. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  173. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +33 -0
  174. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  175. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  176. package/scripts/langages/typescript/parcours.mjs +12 -4
  177. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  178. package/scripts/langages/typescript/resumes.mjs +9 -3
  179. package/scripts/langages/typescript/tailles-des-tests.mjs +93 -20
  180. package/scripts/langages/typescript/tests-de-nuit.mjs +15 -10
  181. package/scripts/langages/typescript/tests.mjs +40 -15
  182. package/scripts/langages/typescript/titres-de-tests.mjs +320 -0
  183. package/scripts/langages/typescript/turbo-des-paquets.mjs +327 -81
  184. package/scripts/langages/typescript/verdict.mjs +4 -2
  185. package/scripts/langages/typescript/verifier.mjs +58 -20
  186. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  187. package/scripts/langages/typescript/vitest-config/base.mjs +29 -3
  188. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  189. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  190. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  191. package/scripts/langages/typescript/vitest-config/delais.mjs +60 -0
  192. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  193. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +108 -0
  194. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -59
  195. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  196. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +10 -0
  197. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  198. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  199. package/scripts/lint-des-scripts.mjs +58 -0
  200. package/scripts/mesure/base-de-passe.mjs +117 -25
  201. package/scripts/mesure/pression.mjs +12 -6
  202. package/scripts/mesure-de-la-machine.d.mts +21 -0
  203. package/scripts/mesure-de-la-machine.mjs +76 -0
  204. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  205. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  206. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  207. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +56 -18
  208. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  209. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  210. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +124 -0
  211. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  212. package/scripts/migrations.mjs +5 -0
  213. package/scripts/nuit.sh +25 -3
  214. package/scripts/outil.mjs +3 -1
  215. package/scripts/outils-cles.d.mts +24 -0
  216. package/scripts/outils-cles.mjs +18 -8
  217. package/scripts/paquet-npm.mjs +157 -0
  218. package/scripts/paquet.mjs +73 -4
  219. package/scripts/paquets.mjs +46 -10
  220. package/scripts/passe-de-la-machine.mjs +71 -0
  221. package/scripts/places-de-la-machine.mjs +414 -0
  222. package/scripts/places-du-serveur.mjs +170 -0
  223. package/scripts/prefixe-des-tickets.mjs +68 -0
  224. package/scripts/preparation.mjs +25 -8
  225. package/scripts/registre.mjs +9 -4
  226. package/scripts/regles-des-places.d.mts +36 -0
  227. package/scripts/regles-des-places.mjs +70 -0
  228. package/scripts/reponses-du-circuit.d.mts +6 -0
  229. package/scripts/reponses-du-circuit.mjs +28 -0
  230. package/scripts/reprise.mjs +66 -0
  231. package/scripts/resultats.mjs +112 -46
  232. package/scripts/retirer-les-copies-finies.mjs +25 -0
  233. package/scripts/sans-reponse.d.mts +4 -0
  234. package/scripts/sans-reponse.mjs +13 -0
  235. package/scripts/seances.mjs +936 -0
  236. package/scripts/services-du-noyau.mjs +27 -8
  237. package/scripts/session-start.sh +2 -2
  238. package/scripts/sortie.mjs +3 -3
  239. package/scripts/sous-commandes.mjs +41 -10
  240. package/scripts/style-a-l-ecriture.mjs +260 -0
  241. package/scripts/superviseur.mjs +122 -111
  242. package/scripts/tableau.mjs +180 -117
  243. package/scripts/taches-du-graphe.mjs +348 -0
  244. package/scripts/ticket-du-circuit.mjs +216 -0
  245. package/scripts/transitions.d.mts +148 -0
  246. package/scripts/transitions.mjs +1018 -0
  247. package/scripts/verrou-de-fichier.mjs +8 -4
  248. package/scripts/verrou-de-machine.mjs +150 -51
  249. package/scripts/verrous/commande.mjs +50 -17
  250. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  251. package/scripts/verrous/verrou.mjs +42 -14
  252. package/skills/explorateur/SKILL.md +9 -2
  253. package/skills/grill/SKILL.md +1 -1
  254. package/skills/mesure/SKILL.md +3 -0
  255. package/skills/pitmaster/SKILL.md +17 -18
  256. package/skills/pitmaster/references/consigne-agent.md +5 -1
  257. package/skills/release/SKILL.md +3 -3
  258. package/skills/relecteur/SKILL.md +5 -3
  259. package/skills/testwriter/SKILL.md +49 -31
  260. package/scripts/demon.mjs +0 -251
  261. package/scripts/integration/file-attente.mjs +0 -61
  262. package/scripts/langages/cargo/touches.mjs +0 -93
  263. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -1,6 +1,6 @@
1
1
  // The lock of a file shared between processes: the file `<verrou>` stands while someone holds it.
2
- // Taken by the integration (`.git/integration.lock`, `.git/file-integration.lock`) and by the
3
- // register (`registre.jsonl.verrou`).
2
+ // Taken by the integration (`.git/integration.lock`) and by the register
3
+ // (`registre.jsonl.verrou`).
4
4
  //
5
5
  // - A lock is created whole and exclusively: its mark (the owner's process number, then a token
6
6
  // unique to the taking) is written to a private file that is linked to `<verrou>`; the link
@@ -64,7 +64,9 @@ function creer(verrou, marque) {
64
64
  linkSync(prive, verrou);
65
65
  return true;
66
66
  } catch (e) {
67
- if (e.code !== 'EEXIST') throw e;
67
+ if (e.code !== 'EEXIST') {
68
+ throw e;
69
+ }
68
70
  return false;
69
71
  } finally {
70
72
  rmSync(prive, { force: true });
@@ -112,7 +114,9 @@ export function prendreVerrou(verrou, { attendre, perime = null, pid = process.p
112
114
  reprendre(verrou, perime);
113
115
  continue;
114
116
  }
115
- if (!attendre) return false;
117
+ if (!attendre) {
118
+ return false;
119
+ }
116
120
  attendreUnPeu(perime === null ? 200 : 20);
117
121
  }
118
122
  }
@@ -50,7 +50,8 @@
50
50
  // « Blocking waiting for file lock » says what a wait waits for. Whoever takes it, a pass out of
51
51
  // a ticket or the circuit of a ticket, of any project of the machine, names itself beside it in
52
52
  // `<lock>.detenteur.json`: its mark, its process, its project, its ticket or null, its kind
53
- // (`sorte`: « Mesure » by default, a step's title for a circuit), since when, and its progress
53
+ // (`sorte`: « Vérification » by default, or GRILLHOUSE_VERIFICATION_SORTE and
54
+ // GRILLHOUSE_VERIFICATION_TICKET from the caller, a step's title for a circuit), since when, and its progress
54
55
  // directory once it names it (`nommerLAvancement`); the name goes with the lock. Each measure
55
56
  // that waits, for the lock or for room in the temporary directory, names itself in the
56
57
  // directory `<lock>.attentes/`, one file per waiting process (its process, its rank, its
@@ -102,10 +103,12 @@ import { paquets } from './paquets.mjs';
102
103
  import { attendreUnPeu, lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
103
104
  import { ecrireAtomique } from './mesure/avancement.mjs';
104
105
  import { ticketDeLaBase, vivant } from './mesure/base-de-passe.mjs';
105
- import { A_REPASSER } from './mesure/pression.mjs';
106
+ import { A_REPASSER } from './codes-de-sortie.mjs';
106
107
 
107
108
  const VARIABLE_VERROU = 'GRILLHOUSE_VERROU_MACHINE';
108
109
  const VARIABLE_TENUE = 'GRILLHOUSE_MESURE_TENUE';
110
+ const VARIABLE_VERIFICATION_SORTE = 'GRILLHOUSE_VERIFICATION_SORTE';
111
+ const VARIABLE_VERIFICATION_TICKET = 'GRILLHOUSE_VERIFICATION_TICKET';
109
112
  const VARIABLE_ATTENTE = 'GRILLHOUSE_ATTENTE_MACHINE_MS';
110
113
  const VARIABLE_LIBRE = 'GRILLHOUSE_TEMPORAIRE_LIBRE';
111
114
  const VARIABLE_COPIE = 'GRILLHOUSE_COPIE_LIBRE';
@@ -150,7 +153,9 @@ export class AttenteDeLaMachine extends Error {
150
153
  // The lock file of the machine under <env>, beside which its holder and its waits name
151
154
  // themselves.
152
155
  export function verrouDeMachine(env = process.env) {
153
- if (env[VARIABLE_VERROU]) return env[VARIABLE_VERROU];
156
+ if (env[VARIABLE_VERROU]) {
157
+ return env[VARIABLE_VERROU];
158
+ }
154
159
  const cache = env.XDG_CACHE_HOME || path.join(env.HOME || homedir(), '.cache');
155
160
  return path.join(cache, 'grillhouse', 'mesure-lourde.lock');
156
161
  }
@@ -197,7 +202,9 @@ function processus(pid) {
197
202
  // (« le processus 12 (dans /d) : node x, depuis 10:04:31 (3 min) »).
198
203
  function qui(verrou) {
199
204
  const pid = detenteur(verrou);
200
- if (pid === null) return 'une autre mesure';
205
+ if (pid === null) {
206
+ return 'une autre mesure';
207
+ }
201
208
  let depuis = '';
202
209
  try {
203
210
  const t = statSync(verrou).mtimeMs;
@@ -237,7 +244,12 @@ const dossierDesAttentes = verrou => `${verrou}.attentes`;
237
244
 
238
245
  // Who a measure is, from its options: `{ depot, ticket, sorte }`, the root of its repository
239
246
  // read when first asked.
240
- function identite({ racine, ticket = null, sorte = 'Mesure' }) {
247
+ // The kind and the ticket come from the option of the caller (the circuit) when it gives one,
248
+ // else from the caller's environment (GRILLHOUSE_VERIFICATION_SORTE, GRILLHOUSE_VERIFICATION_TICKET,
249
+ // empty as absent), else « Vérification » and null.
250
+ function identite({ racine, env = {}, ticket, sorte }) {
251
+ ticket = ticket ?? (env[VARIABLE_VERIFICATION_TICKET] || null);
252
+ sorte = sorte ?? (env[VARIABLE_VERIFICATION_SORTE] || 'Vérification');
241
253
  let depot = null;
242
254
  return {
243
255
  get depot() {
@@ -287,7 +299,9 @@ function attentesDe(verrou) {
287
299
  continue;
288
300
  }
289
301
  const a = nom.endsWith('.json') ? lireJson(path.join(dossier, nom)) : null;
290
- if (a?.pid === pid) out.push(a);
302
+ if (a?.pid === pid) {
303
+ out.push(a);
304
+ }
291
305
  }
292
306
  return out.sort((a, b) => (a.depuis ?? 0) - (b.depuis ?? 0));
293
307
  }
@@ -317,7 +331,9 @@ function nommerLeDetenteur(verrou, id) {
317
331
  return () => {};
318
332
  }
319
333
  return () => {
320
- if (lireJson(f)?.marque === marque) rmSync(f, { force: true });
334
+ if (lireJson(f)?.marque === marque) {
335
+ rmSync(f, { force: true });
336
+ }
321
337
  };
322
338
  }
323
339
 
@@ -334,7 +350,9 @@ export function nommerLAvancement({ env = process.env, dossier }) {
334
350
  const marque = env[VARIABLE_TENUE];
335
351
  const ecrire = d => {
336
352
  const n = lireJson(f);
337
- if (!marque || n?.marque !== marque) return false;
353
+ if (!marque || n?.marque !== marque) {
354
+ return false;
355
+ }
338
356
  try {
339
357
  ecrireAtomique(f, { ...n, dossier: d });
340
358
  return true;
@@ -368,7 +386,9 @@ export function lireLeVerrou(env = process.env) {
368
386
  }));
369
387
  const marque = lire(verrou);
370
388
  const pid = detenteur(verrou);
371
- if (marque === null || pid === null || !vivant(pid)) return { detenteur: null, attentes };
389
+ if (marque === null || pid === null || !vivant(pid)) {
390
+ return { detenteur: null, attentes };
391
+ }
372
392
  const n = lireJson(fichierDuDetenteur(verrou));
373
393
  if (n?.marque === marque) {
374
394
  const { depot, ticket, sorte, depuis, dossier } = n;
@@ -425,7 +445,11 @@ function parent(pid) {
425
445
 
426
446
  // Whether <pid> is this process or one of its ancestors.
427
447
  function ancetre(pid) {
428
- for (let p = process.pid; p !== null; p = parent(p)) if (p === pid) return true;
448
+ for (let p = process.pid; p !== null; p = parent(p)) {
449
+ if (p === pid) {
450
+ return true;
451
+ }
452
+ }
429
453
  return false;
430
454
  }
431
455
 
@@ -460,7 +484,9 @@ function occupants(dossier) {
460
484
  } catch {
461
485
  return 'illisible';
462
486
  }
463
- if (noms.length === 0) return 'rien';
487
+ if (noms.length === 0) {
488
+ return 'rien';
489
+ }
464
490
  let budget = ENTREES_LUES;
465
491
  const taille = racine => {
466
492
  let octets = 0;
@@ -476,7 +502,9 @@ function occupants(dossier) {
476
502
  octets += e.blocks * 512;
477
503
  if (e.isDirectory()) {
478
504
  try {
479
- for (const n of readdirSync(p)) pile.push(path.join(p, n));
505
+ for (const n of readdirSync(p)) {
506
+ pile.push(path.join(p, n));
507
+ }
480
508
  } catch {
481
509
  // an unreadable directory counts for itself alone
482
510
  }
@@ -531,29 +559,48 @@ function attendreLaPlace(dossier, { inscrire, ...o }) {
531
559
 
532
560
  function attendreLaPlaceEnNommant(
533
561
  dossier,
534
- { disque, plancher, libre, occupe, dire, borneMs, rappelMs, nommer, debut = Date.now() }
562
+ {
563
+ disque,
564
+ plancher,
565
+ libre,
566
+ occupe,
567
+ dire,
568
+ borneMs,
569
+ rappelMs,
570
+ nommer,
571
+ maintenant = Date.now,
572
+ dormir = attendreUnPeu,
573
+ debut = maintenant(),
574
+ }
535
575
  ) {
536
576
  let dit = null;
537
577
  for (;;) {
538
578
  const l = libre(dossier);
539
579
  if (l >= plancher) {
540
- if (dit !== null) dire(`✓ place ${disque.ou} après ${duree(Date.now() - debut)}.`);
580
+ if (dit !== null) {
581
+ dire(`✓ place ${disque.ou} après ${duree(maintenant() - debut)}.`);
582
+ }
541
583
  return;
542
584
  }
543
585
  nommer();
544
- const t = Date.now();
586
+ const t = maintenant();
545
587
  const etat = () =>
546
588
  `${disque.nom} (${dossier}) n'a que ${go(l)} libres, moins des ${go(plancher)} qu'une passe lourde demande (${disque.variable}) ; l'occupent : ${occupe(dossier)}`;
547
- if (t - debut >= borneMs)
589
+ if (t - debut >= borneMs) {
548
590
  throw new AttenteDeLaMachine(
549
591
  `⏱ attente de place bornée à ${duree(borneMs)} (${VARIABLE_ATTENTE}) : ${etat()} ; à repasser (code ${A_REPASSER}).`,
550
592
  A_REPASSER
551
593
  );
552
- if (dit === null) dire(`⏳ ${etat()} ; attente de place, ${duree(borneMs)} au plus.`);
553
- else if (t - dit >= rappelMs)
594
+ }
595
+ if (dit === null) {
596
+ dire(`⏳ ${etat()} ; attente de place, ${duree(borneMs)} au plus.`);
597
+ } else if (t - dit >= rappelMs) {
554
598
  dire(`⏳ attente de place depuis ${duree(t - debut)} : ${etat()}.`);
555
- if (dit === null || t - dit >= rappelMs) dit = t;
556
- attendreUnPeu(Math.max(1, Math.min(200, borneMs - (Date.now() - debut))));
599
+ }
600
+ if (dit === null || t - dit >= rappelMs) {
601
+ dit = t;
602
+ }
603
+ dormir(Math.max(1, Math.min(200, borneMs - (maintenant() - debut))));
557
604
  }
558
605
  }
559
606
 
@@ -564,7 +611,9 @@ function attendreLaPlaceEnNommant(
564
611
  * @param {{ env?: Record<string, string | undefined>, dire?: (l: string) => void, borneMs?: number,
565
612
  * rappelMs?: number, libre?: (dossier: string) => number, occupe?: (dossier: string) => string,
566
613
  * occupeLaCopie?: (racine: string) => string, racine?: string, ticket?: string | null,
567
- * sorte?: string }} [o] `libre` reads the room of each disk, `occupe` what holds the temporary
614
+ * sorte?: string, maintenant?: () => number, dormir?: (ms: number) => void }} [o]
615
+ * `maintenant` and `dormir` are the clock (Date.now) and the sleep of the wait, the real ones
616
+ * when left out; `libre` reads the room of each disk, `occupe` what holds the temporary
568
617
  * directory, `occupeLaCopie` the copies that hold the disk of the copy; the wait names its
569
618
  * project <racine>, its ticket and its kind among the waits of the lock of the machine under
570
619
  * <env> while it waits
@@ -579,14 +628,16 @@ export function attendreDeLaPlace({
579
628
  occupe = occupants,
580
629
  occupeLaCopie = occupantsDesCopies,
581
630
  racine = process.cwd(),
582
- ticket = null,
583
- sorte = 'Mesure',
631
+ ticket,
632
+ sorte,
633
+ maintenant = Date.now,
634
+ dormir = attendreUnPeu,
584
635
  } = {}) {
585
636
  const temporaire = env.TMPDIR || env.TMP || env.TEMP || tmpdir();
586
- const id = identite({ racine, ticket, sorte });
637
+ const id = identite({ racine, env, ticket, sorte });
587
638
  const inscrire = () => inscrireLAttente(verrouDeMachine(env), id, 'place');
588
- const debut = Date.now();
589
- const commun = { libre, dire, borneMs, rappelMs, inscrire, debut };
639
+ const debut = maintenant();
640
+ const commun = { libre, dire, borneMs, rappelMs, inscrire, debut, maintenant, dormir };
590
641
  attendreLaPlace(temporaire, {
591
642
  ...commun,
592
643
  disque: DISQUES.temporaire,
@@ -601,8 +652,13 @@ export function attendreDeLaPlace({
601
652
  });
602
653
  }
603
654
 
604
- // The bound of the wait under <env>, in ms.
605
- function borneDe(env) {
655
+ /**
656
+ * The bound of the wait under <env>, in ms (GRILLHOUSE_ATTENTE_MACHINE_MS, else ATTENTE_MACHINE_MS);
657
+ * the wait for a place of the machine (scripts/places-de-la-machine.mjs) has the same.
658
+ * @param {Record<string, string | undefined>} env
659
+ * @returns {number}
660
+ */
661
+ export function borneDe(env) {
606
662
  const n = Number(env[VARIABLE_ATTENTE]);
607
663
  return env[VARIABLE_ATTENTE] && Number.isFinite(n) && n >= 0 ? n : ATTENTE_MACHINE_MS;
608
664
  }
@@ -611,43 +667,52 @@ function borneDe(env) {
611
667
  // <rappelMs>; returns the time waited, in ms. Throws an AttenteDeLaMachine at once when an ancestor
612
668
  // holds the lock, and at the bound <borneMs>. The measure, <id>, names itself among the waits,
613
669
  // with its rank, while it waits.
614
- function attendreLaMachine(verrou, { id, rang, dire, borneMs, rappelMs }) {
670
+ function attendreLaMachine(verrou, { id, rang, dire, borneMs, rappelMs, maintenant, dormir }) {
615
671
  const retirer = inscrireLAttente(verrou, id, 'verrou', rang);
616
672
  try {
617
- return attendreAuRang(verrou, { rang, dire, borneMs, rappelMs });
673
+ return attendreAuRang(verrou, { rang, dire, borneMs, rappelMs, maintenant, dormir });
618
674
  } finally {
619
675
  retirer();
620
676
  }
621
677
  }
622
678
 
623
- function attendreAuRang(verrou, { rang, dire, borneMs, rappelMs }) {
624
- const debut = Date.now();
679
+ function attendreAuRang(
680
+ verrou,
681
+ { rang, dire, borneMs, rappelMs, maintenant = Date.now, dormir = attendreUnPeu }
682
+ ) {
683
+ const debut = maintenant();
625
684
  let dit = null;
626
685
  for (;;) {
627
686
  const pid = detenteur(verrou);
628
- if (pid !== null && ancetre(pid))
687
+ if (pid !== null && ancetre(pid)) {
629
688
  throw new AttenteDeLaMachine(
630
689
  `✗ blocage : le verrou de la mesure lourde (${verrou}) est tenu par un ancêtre de ce processus (${process.pid}), ${qui(verrou)} ; il attend la fin de ce processus, qui attendrait la sienne. L'environnement a perdu la marque de la prise (${VARIABLE_TENUE}) ; un essai nomme son propre verrou (${VARIABLE_VERROU}).`,
631
690
  1
632
691
  );
633
- const t = Date.now();
634
- if (t - debut >= borneMs)
692
+ }
693
+ const t = maintenant();
694
+ if (t - debut >= borneMs) {
635
695
  throw new AttenteDeLaMachine(
636
696
  `⏱ attente du verrou de la machine bornée à ${duree(borneMs)} (${VARIABLE_ATTENTE}), ${RANGS[rang]} : ${attendus(verrou, rang)} ; à repasser (code ${A_REPASSER}).`,
637
697
  A_REPASSER
638
698
  );
639
- if (dit === null)
699
+ }
700
+ if (dit === null) {
640
701
  dire(
641
702
  `⏳ ${RANGS[rang]}, la machine mesure déjà : ${attendus(verrou, rang)} ; attente de son tour, ${duree(borneMs)} au plus.`
642
703
  );
643
- else if (t - dit >= rappelMs)
704
+ } else if (t - dit >= rappelMs) {
644
705
  dire(
645
706
  `⏳ ${RANGS[rang]}, attente du verrou de la machine depuis ${duree(t - debut)} : ${attendus(verrou, rang)}.`
646
707
  );
647
- if (dit === null || t - dit >= rappelMs) dit = t;
648
- if (peutPrendre(verrou, rang) && prendreVerrou(verrou, { attendre: false }))
649
- return Date.now() - debut;
650
- attendreUnPeu(Math.max(1, Math.min(200, borneMs - (Date.now() - debut))));
708
+ }
709
+ if (dit === null || t - dit >= rappelMs) {
710
+ dit = t;
711
+ }
712
+ if (peutPrendre(verrou, rang) && prendreVerrou(verrou, { attendre: false })) {
713
+ return maintenant() - debut;
714
+ }
715
+ dormir(Math.max(1, Math.min(200, borneMs - (maintenant() - debut))));
651
716
  }
652
717
  }
653
718
 
@@ -658,13 +723,16 @@ function attendreAuRang(verrou, { rang, dire, borneMs, rappelMs }) {
658
723
  * @param {{ env?: Record<string, string | undefined>, racine?: string,
659
724
  * dire?: (ligne: string) => void, borneMs?: number, rappelMs?: number,
660
725
  * libre?: (dossier: string) => number, occupe?: (dossier: string) => string,
661
- * ticket?: string | null, sorte?: string }} options `racine`, the
726
+ * ticket?: string | null, sorte?: string, maintenant?: () => number,
727
+ * dormir?: (ms: number) => void }} options `maintenant` and `dormir`, the clock and the sleep of
728
+ * the wait (Date.now and the real sleep when left out); `racine`, the
662
729
  * root of the repository the measure plays in, which gives its rank (`rangDeLaMesure`; the
663
730
  * working directory by default); `borneMs`, the bound of the wait
664
731
  * (GRILLHOUSE_ATTENTE_MACHINE_MS, else ATTENTE_MACHINE_MS); `rappelMs`, the gap between two
665
732
  * lines that say the wait goes on (30 s); `libre`, the room free in a directory, in bytes
666
733
  * (`statfs`, at each turn); `occupe`, what holds it, counted when a line of the wait is written;
667
- * `ticket` (null out of a ticket) and `sorte` (« Mesure » by default), who the measure is,
734
+ * `ticket` (null out of a ticket) and `sorte` (« Vérification » by default), who the measure is;
735
+ * an option left out is read from GRILLHOUSE_VERIFICATION_TICKET and GRILLHOUSE_VERIFICATION_SORTE,
668
736
  * named beside the lock while it waits and while it holds it, with its project
669
737
  * @returns {T}
670
738
  * @throws {AttenteDeLaMachine} at the bound of the wait (code 75), or at once when an ancestor
@@ -681,25 +749,56 @@ export function avecLaMachine(
681
749
  rappelMs = RAPPEL_MS,
682
750
  libre = libreDans,
683
751
  occupe = occupants,
684
- ticket = null,
685
- sorte = 'Mesure',
752
+ ticket,
753
+ sorte,
754
+ maintenant = Date.now,
755
+ dormir = attendreUnPeu,
686
756
  } = {}
687
757
  ) {
688
- if (paquetsDeLEnveloppe(env)) return mesure(env);
758
+ if (paquetsDeLEnveloppe(env)) {
759
+ return mesure(env);
760
+ }
689
761
  const verrou = verrouDeMachine(env);
690
- if (env[VARIABLE_TENUE] && lire(verrou) === env[VARIABLE_TENUE]) return mesure(env);
691
- attendreDeLaPlace({ env, libre, occupe, dire, borneMs, rappelMs, racine, ticket, sorte });
692
- const id = identite({ racine, ticket, sorte });
762
+ if (env[VARIABLE_TENUE] && lire(verrou) === env[VARIABLE_TENUE]) {
763
+ return mesure(env);
764
+ }
765
+ attendreDeLaPlace({
766
+ env,
767
+ libre,
768
+ occupe,
769
+ dire,
770
+ borneMs,
771
+ rappelMs,
772
+ racine,
773
+ ticket,
774
+ sorte,
775
+ maintenant,
776
+ dormir,
777
+ });
778
+ const id = identite({ racine, env, ticket, sorte });
693
779
  mkdirSync(path.dirname(verrou), { recursive: true });
694
780
  const rang = rangDeLaMesure(racine);
695
781
  if (!(peutPrendre(verrou, rang) && prendreVerrou(verrou, { attendre: false }))) {
696
- const attendu = attendreLaMachine(verrou, { id, rang, dire, borneMs, rappelMs });
782
+ const attendu = attendreLaMachine(verrou, {
783
+ id,
784
+ rang,
785
+ dire,
786
+ borneMs,
787
+ rappelMs,
788
+ maintenant,
789
+ dormir,
790
+ });
697
791
  dire(`✓ verrou de la machine pris après ${Math.round(attendu / 1000)} s.`);
698
792
  }
699
793
  let oublier = () => {};
700
794
  try {
701
795
  oublier = nommerLeDetenteur(verrou, id);
702
- return mesure({ ...env, [VARIABLE_TENUE]: lire(verrou) ?? '' });
796
+ const {
797
+ [VARIABLE_VERIFICATION_SORTE]: _s,
798
+ [VARIABLE_VERIFICATION_TICKET]: _t,
799
+ ...enfant
800
+ } = env;
801
+ return mesure({ ...enfant, [VARIABLE_TENUE]: lire(verrou) ?? '' });
703
802
  } finally {
704
803
  oublier();
705
804
  lacherVerrou(verrou);
@@ -35,7 +35,9 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
35
35
  const mot = j => {
36
36
  let texte = '';
37
37
  let inconnu = false;
38
- while (j < n && /\s/.test(commande[j]) && commande[j] !== '\n') j++;
38
+ while (j < n && /\s/.test(commande[j]) && commande[j] !== '\n') {
39
+ j++;
40
+ }
39
41
  while (j < n && !/[\s;&|<>()]/.test(commande[j])) {
40
42
  const c = commande[j];
41
43
  if (c === "'") {
@@ -45,8 +47,11 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
45
47
  } else if (c === '"') {
46
48
  let k = j + 1;
47
49
  while (k < n && commande[k] !== '"') {
48
- if (commande[k] === '\\') k++;
49
- else if (commande[k] === '$' || commande[k] === '`') inconnu = true;
50
+ if (commande[k] === '\\') {
51
+ k++;
52
+ } else if (commande[k] === '$' || commande[k] === '`') {
53
+ inconnu = true;
54
+ }
50
55
  texte += commande[k] ?? '';
51
56
  k++;
52
57
  }
@@ -55,7 +60,9 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
55
60
  texte += commande[j + 1] ?? '';
56
61
  j += 2;
57
62
  } else {
58
- if (c === '$' || c === '`') inconnu = true;
63
+ if (c === '$' || c === '`') {
64
+ inconnu = true;
65
+ }
59
66
  texte += c;
60
67
  j++;
61
68
  }
@@ -64,7 +71,9 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
64
71
  };
65
72
  const cible = w => {
66
73
  const variable = /^\$(\{TMPDIR\}|TMPDIR)(\/.*)?$/.exec(w.texte);
67
- if (variable) return { cible: path.join(tmp, variable[2] ?? ''), brute: w.texte };
74
+ if (variable) {
75
+ return { cible: path.join(tmp, variable[2] ?? ''), brute: w.texte };
76
+ }
68
77
  return { cible: w.inconnu ? null : w.texte, brute: w.texte };
69
78
  };
70
79
  while (i < n) {
@@ -77,7 +86,9 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
77
86
  const e = commande.indexOf('\n', j);
78
87
  const ligne = commande.slice(j, e < 0 ? n : e);
79
88
  j = e < 0 ? n : e + 1;
80
- if (ligne.replace(/^\t+/, '') === fin) break;
89
+ if (ligne.replace(/^\t+/, '') === fin) {
90
+ break;
91
+ }
81
92
  }
82
93
  }
83
94
  documents = [];
@@ -91,7 +102,9 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
91
102
  }
92
103
  if (c === '"') {
93
104
  let k = i + 1;
94
- while (k < n && commande[k] !== '"') k += commande[k] === '\\' ? 2 : 1;
105
+ while (k < n && commande[k] !== '"') {
106
+ k += commande[k] === '\\' ? 2 : 1;
107
+ }
95
108
  i = k + 1;
96
109
  continue;
97
110
  }
@@ -101,26 +114,34 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
101
114
  }
102
115
  if (c === '<' && commande[i + 1] === '<' && commande[i + 2] !== '<') {
103
116
  const w = mot(i + (commande[i + 2] === '-' ? 3 : 2));
104
- if (w.texte) documents.push(w.texte);
117
+ if (w.texte) {
118
+ documents.push(w.texte);
119
+ }
105
120
  i = w.fin;
106
121
  continue;
107
122
  }
108
123
  if (c === '>') {
109
124
  let j = i + 1;
110
- if (commande[j] === '>' || commande[j] === '|') j++;
125
+ if (commande[j] === '>' || commande[j] === '|') {
126
+ j++;
127
+ }
111
128
  // A duplication of a descriptor, `>&2`, writes no file.
112
129
  if (commande[j] === '&') {
113
130
  i = j + 1;
114
131
  continue;
115
132
  }
116
133
  const w = mot(j);
117
- if (w.texte) out.push(cible(w));
134
+ if (w.texte) {
135
+ out.push(cible(w));
136
+ }
118
137
  i = w.fin;
119
138
  continue;
120
139
  }
121
140
  if (c === '&' && commande[i + 1] === '>') {
122
141
  const w = mot(i + (commande[i + 2] === '>' ? 3 : 2));
123
- if (w.texte) out.push(cible(w));
142
+ if (w.texte) {
143
+ out.push(cible(w));
144
+ }
124
145
  i = w.fin;
125
146
  continue;
126
147
  }
@@ -131,8 +152,12 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
131
152
  let j = w.fin;
132
153
  for (;;) {
133
154
  const a = mot(j);
134
- if (!a.texte) break;
135
- if (!a.texte.startsWith('-')) out.push(cible(a));
155
+ if (!a.texte) {
156
+ break;
157
+ }
158
+ if (!a.texte.startsWith('-')) {
159
+ out.push(cible(a));
160
+ }
136
161
  j = a.fin;
137
162
  }
138
163
  i = j;
@@ -148,7 +173,9 @@ function ecrituresDuShell(commande, tmp = tmpdir()) {
148
173
 
149
174
  // The reason the command of this hook input is refused, or null when it passes.
150
175
  export function refusDeCommande(input, { tmp = tmpdir() } = {}) {
151
- if (input?.tool_name !== 'Bash') return null;
176
+ if (input?.tool_name !== 'Bash') {
177
+ return null;
178
+ }
152
179
  const commande = String(input.tool_input?.command ?? '');
153
180
  const cwd = input.cwd ?? process.cwd();
154
181
  const interieur = f => {
@@ -156,12 +183,18 @@ export function refusDeCommande(input, { tmp = tmpdir() } = {}) {
156
183
  return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
157
184
  };
158
185
  const enTrop = ecrituresDuShell(commande, tmp).filter(({ cible }) => {
159
- if (cible === null) return true;
160
- if (PERIPHERIQUES.test(cible)) return false;
186
+ if (cible === null) {
187
+ return true;
188
+ }
189
+ if (PERIPHERIQUES.test(cible)) {
190
+ return false;
191
+ }
161
192
  const absolu = path.resolve(cwd, cible);
162
193
  return !interieur(absolu);
163
194
  });
164
- if (!enTrop.length) return null;
195
+ if (!enTrop.length) {
196
+ return null;
197
+ }
165
198
  return `Le shell n'écrit pas les fichiers du dépôt (${enTrop.map(e => e.brute).join(', ')}) : un fichier s'écrit par l'outil Write ou Edit, que le verrou de ton rôle juge ; un fichier temporaire va dans ${tmp}.`;
166
199
  }
167
200
 
@@ -15,10 +15,16 @@ const TICKET = /TON TICKET\s*:\s*[A-Za-z0-9_.-]+/;
15
15
 
16
16
  // The refusal for this launch, or null. `isRole(name)` says whether the frame defines that agent.
17
17
  export function refusal(input, isRole) {
18
- if (input.tool_name !== 'Agent' && input.tool_name !== 'Task') return null;
18
+ if (input.tool_name !== 'Agent' && input.tool_name !== 'Task') {
19
+ return null;
20
+ }
19
21
  const role = input.tool_input?.subagent_type;
20
- if (!role || !isRole(role)) return null;
21
- if (TICKET.test(input.tool_input?.prompt ?? '')) return null;
22
+ if (!role || !isRole(role)) {
23
+ return null;
24
+ }
25
+ if (TICKET.test(input.tool_input?.prompt ?? '')) {
26
+ return null;
27
+ }
22
28
  return `L'agent ${role} part sans son ticket : sa consigne porte la ligne « TON TICKET : <id> ». Ainsi le tableau rattache l'agent, son temps et ses jetons à son ticket.`;
23
29
  }
24
30