@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
package/scripts/demon.mjs DELETED
@@ -1,251 +0,0 @@
1
- // A command run as a daemon, as daemon(3) and `setsid --fork` make one, in a unit of its own as
2
- // `systemd-run --user` starts one: the circuit of a ticket (scripts/circuit.mjs) runs so, and goes
3
- // on to its end when the session that launched it ends, or when the group of control that holds
4
- // that session is killed (grillhouse-mwz: on 2026-11-01, systemd-oomd killed the scope of the tmux
5
- // pane of BPScript's supervisor, 94 processes, two circuits among them, daemons apart from the
6
- // session's tree; BP 320.8 before: the circuit, a background command of the session, died with it).
7
- //
8
- // - `executerEnDemon(script, argv, main, { unite })` is the entry of the script <script>, run with
9
- // the arguments <argv>; it returns the exit code of its process. It plays one of three roles,
10
- // which the variable DETACHE carries from one to the next. <unite> names the daemon's unit.
11
- // - The caller (no variable): it launches a relay, its own script again, in a session of its own,
12
- // and waits for it; then it reads the daemon's output in a directory of its own
13
- // (`<tmpdir>/grillhouse-sortie-du-circuit-XXXXXX`, apart from the bases of the runs, which a sweep
14
- // reads) and relays it to its own streams while it waits, every PAS_MS; once the daemon's code is
15
- // there, written after its last line, it reads the output to its end, then ends on that code. A
16
- // daemon gone without a code ends the caller at 1, said. A daemon that gives the hand back
17
- // (`rendreLaMain`, as `systemctl start` returns once its unit has started) ends the caller at 0
18
- // once its output so far is relayed, and goes on alone (grillhouse-pq6: the supervisor's launch
19
- // of a circuit returns at once, and the circuit's question wakes it by the wait of the
20
- // questions, scripts/superviseur.mjs). A caller that dies leaves the daemon running.
21
- // - The relay: it launches the daemon, its own script again, in a session of its own (setsid), its
22
- // output to the directory, writes its pid there and ends at once: the daemon's parent becomes the
23
- // system's, so that the daemon is neither in the caller's process group nor under it in the tree
24
- // of processes, which the end of a session of Claude Code kills. When the user's systemd answers
25
- // (`systemdUtilisateur`), the daemon starts through `systemd-run --user --scope`, which runs it
26
- // in place, its process and environment kept, in a scope of its own
27
- // (`<unite>-<pid of the relay>.scope`, under app.slice), out of the group of control of its
28
- // caller (the scope of a terminal or of a tmux pane), which systemd stops whole; without it, as
29
- // in the envelope of the agents, it starts as it is.
30
- // - The daemon: it runs <main>(<argv>); at its exit, its code is written for the caller, or the
31
- // directory removed when the caller is gone or has the hand back.
32
- import { spawn, spawnSync } from 'node:child_process';
33
- import {
34
- existsSync,
35
- mkdtempSync,
36
- openSync,
37
- readFileSync,
38
- renameSync,
39
- rmSync,
40
- writeFileSync,
41
- } from 'node:fs';
42
- import os from 'node:os';
43
- import path from 'node:path';
44
- import { vivant } from './mesure/base-de-passe.mjs';
45
-
46
- // The variable that carries, to the relay and then to the daemon, its role, the directory of the
47
- // daemon's output and the caller's process.
48
- const DETACHE = 'GRILLHOUSE_CIRCUIT_DETACHE';
49
- // How often the caller reads the daemon's output and end.
50
- const PAS_MS = 100;
51
-
52
- const lire = f => (existsSync(f) ? readFileSync(f, 'utf8') : '');
53
-
54
- // The directory of the caller of this daemon while it waits, null once the hand is given back or
55
- // out of a daemon.
56
- let aRendre = null;
57
- // The caller of this daemon, null out of a daemon.
58
- let appelantDuDemon = null;
59
-
60
- // The environment in which systemd-run reaches the user's systemd: the directory of the user's
61
- // runtime, `/run/user/<uid>` as pam_systemd sets it, when the environment does not give it (a task
62
- // of Turborepo passes on neither it nor the address of the bus).
63
- const pourSystemd = () => ({
64
- ...process.env,
65
- XDG_RUNTIME_DIR: process.env.XDG_RUNTIME_DIR ?? `/run/user/${process.getuid?.()}`,
66
- });
67
-
68
- let systemd = null;
69
- /** Whether the user's systemd starts a scope (`systemd-run --user --scope true` ends at 0), read once. */
70
- export function systemdUtilisateur() {
71
- systemd ??=
72
- spawnSync('systemd-run', ['--user', '--scope', '--quiet', '--collect', '--', 'true'], {
73
- stdio: 'ignore',
74
- timeout: 5000,
75
- env: pourSystemd(),
76
- }).status === 0;
77
- return systemd;
78
- }
79
-
80
- // A name of unit of systemd from <nom>: each character it refuses becomes `_`.
81
- const nomDUnite = nom => String(nom).replace(/[^A-Za-z0-9:_.-]/g, '_');
82
-
83
- // The caller: see the header.
84
- async function appeler(script, argv, unite) {
85
- const dossier = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-sortie-du-circuit-'));
86
- const f = nom => path.join(dossier, nom);
87
- try {
88
- const relais = spawn(process.execPath, [script, ...argv], {
89
- detached: true,
90
- stdio: 'ignore',
91
- env: {
92
- ...process.env,
93
- [DETACHE]: JSON.stringify({ role: 'relais', dossier, appelant: process.pid, unite }),
94
- },
95
- });
96
- await new Promise(r => {
97
- relais.on('error', r);
98
- relais.on('close', r);
99
- });
100
- const pid = Number(lire(f('pid')));
101
- const lus = { sortie: 0, erreurs: 0 };
102
- const recopier = () => {
103
- for (const [nom, flux] of [
104
- ['sortie', process.stdout],
105
- ['erreurs', process.stderr],
106
- ]) {
107
- if (!existsSync(f(nom))) {
108
- continue;
109
- }
110
- const tout = readFileSync(f(nom));
111
- if (tout.length > lus[nom]) {
112
- flux.write(tout.subarray(lus[nom]));
113
- }
114
- lus[nom] = tout.length;
115
- }
116
- };
117
- for (;;) {
118
- // The code is written after the last line: once it is there, the output is read to its end;
119
- // the hand given back (`rendreLaMain`) is written after the daemon's line that says so.
120
- const fini = existsSync(f('code'));
121
- const rendue = existsSync(f('rendu'));
122
- recopier();
123
- if (fini) {
124
- return Number(lire(f('code')));
125
- }
126
- if (rendue) {
127
- return 0;
128
- }
129
- if (!pid || !vivant(pid)) {
130
- recopier();
131
- if (existsSync(f('code'))) {
132
- return Number(lire(f('code')));
133
- }
134
- process.stderr.write(`⛔ le circuit (processus ${pid || '?'}) finit sans code de fin.\n`);
135
- return 1;
136
- }
137
- await new Promise(r => setTimeout(r, PAS_MS));
138
- }
139
- } finally {
140
- rmSync(dossier, { recursive: true, force: true });
141
- }
142
- }
143
-
144
- // The relay: see the header.
145
- function relayer(script, argv, { dossier, appelant, unite }) {
146
- const sortie = openSync(path.join(dossier, 'sortie'), 'a');
147
- const erreurs = openSync(path.join(dossier, 'erreurs'), 'a');
148
- const commande = [process.execPath, script, ...argv];
149
- const aPart = systemdUtilisateur();
150
- const [programme, ...args] = aPart
151
- ? [
152
- 'systemd-run',
153
- '--user',
154
- '--scope',
155
- '--quiet',
156
- '--collect',
157
- `--unit=${nomDUnite(`${unite}-${process.pid}`)}`,
158
- '--',
159
- ...commande,
160
- ]
161
- : commande;
162
- const demon = spawn(programme, args, {
163
- detached: true,
164
- stdio: ['ignore', sortie, erreurs],
165
- env: {
166
- ...(aPart ? pourSystemd() : process.env),
167
- [DETACHE]: JSON.stringify({ role: 'demon', dossier, appelant }),
168
- },
169
- });
170
- writeFileSync(path.join(dossier, 'pid'), String(demon.pid ?? ''));
171
- demon.unref();
172
- return 0;
173
- }
174
-
175
- // The daemon: see the header.
176
- async function demon(argv, main, { dossier, appelant }) {
177
- aRendre = dossier;
178
- appelantDuDemon = appelant;
179
- process.on('exit', code => {
180
- if (!vivant(appelant) || !existsSync(dossier)) {
181
- rmSync(dossier, { recursive: true, force: true });
182
- return;
183
- }
184
- const provisoire = path.join(dossier, `code.${process.pid}`);
185
- writeFileSync(provisoire, String(code ?? 1));
186
- renameSync(provisoire, path.join(dossier, 'code'));
187
- });
188
- return await main(argv);
189
- }
190
-
191
- /**
192
- * Whether this process is the daemon of a script run by `executerEnDemon`, read before it runs.
193
- * @returns {boolean}
194
- */
195
- export function estLeDemon() {
196
- try {
197
- return JSON.parse(process.env[DETACHE] ?? 'null')?.role === 'demon';
198
- } catch {
199
- return false;
200
- }
201
- }
202
-
203
- /**
204
- * Whether what this process writes on its error stream now reaches a reader: in a daemon, while
205
- * it has not given the hand back (`rendreLaMain`) and its caller, which relays it, lives; out of a
206
- * daemon, always, its output its caller's own (grillhouse-pq6.1: the circuit inscribes the
207
- * question it says there as gone up, scripts/superviseur.mjs).
208
- * @returns {boolean}
209
- */
210
- export function sortieLue() {
211
- return appelantDuDemon === null || (aRendre !== null && vivant(appelantDuDemon));
212
- }
213
-
214
- /**
215
- * Gives the hand back to the caller of this daemon, as `systemctl start` returns once its unit has
216
- * started: <message> on the daemon's error stream, which the caller relays, then the caller ends
217
- * at 0, and the daemon goes on alone, its output no longer read. Once per daemon; nothing out of
218
- * a daemon (a run in its caller's own process).
219
- * @param {string} message the line the caller relays last
220
- * @returns {boolean} whether a caller got the hand back
221
- */
222
- export function rendreLaMain(message) {
223
- if (aRendre === null) {
224
- return false;
225
- }
226
- const dossier = aRendre;
227
- aRendre = null;
228
- process.stderr.write(message);
229
- try {
230
- writeFileSync(path.join(dossier, 'rendu'), '');
231
- } catch {
232
- return false;
233
- }
234
- return true;
235
- }
236
-
237
- /**
238
- * The entry of <script> run with <argv> as a daemon, <main> its run, in the unit <unite>: the exit
239
- * code.
240
- */
241
- export async function executerEnDemon(script, argv, main, { unite = path.basename(script) } = {}) {
242
- const lu = process.env[DETACHE] ? JSON.parse(process.env[DETACHE]) : null;
243
- delete process.env[DETACHE];
244
- if (lu?.role === 'relais') {
245
- return relayer(script, argv, lu);
246
- }
247
- if (lu?.role === 'demon') {
248
- return await demon(argv, main, lu);
249
- }
250
- return await appeler(script, argv, unite);
251
- }
@@ -1,61 +0,0 @@
1
- // The waiting side of the integration, kept in git's common directory: the queue's entries, and
2
- // the git directory the integration's locks live in (taken through scripts/verrou-de-fichier.mjs).
3
- // The integration writes an entry when it commits a ticket on its branch; the queue
4
- // (scripts/integration/file.mjs) reads them in their order of arrival.
5
- //
6
- // - An entry is one JSON file `<arrival>-<process>.json` under `file-integration/` holding the
7
- // branch and its one ticket; the name sorts in the order of arrival. One branch has one
8
- // entry: writing it again replaces the earlier one.
9
- import { spawnSync } from 'node:child_process';
10
- import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
11
- import path from 'node:path';
12
-
13
- // The git common directory of the repository at <racine>, absolute.
14
- export function dossierCommun(racine) {
15
- return spawnSync(
16
- 'git',
17
- ['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
18
- { encoding: 'utf8' }
19
- ).stdout.trim();
20
- }
21
-
22
- const dossierEntrees = racine => path.join(dossierCommun(racine), 'file-integration');
23
-
24
- // The entries waiting, in their order of arrival: { fichier, branche, ticket }.
25
- export function lireEntrees(racine) {
26
- const dossier = dossierEntrees(racine);
27
- let noms = [];
28
- try {
29
- noms = readdirSync(dossier)
30
- .filter(n => n.endsWith('.json'))
31
- .sort();
32
- } catch {
33
- return [];
34
- }
35
- const entrees = [];
36
- for (const n of noms) {
37
- try {
38
- const e = JSON.parse(readFileSync(path.join(dossier, n), 'utf8'));
39
- entrees.push({ fichier: path.join(dossier, n), branche: e.branche, ticket: e.ticket });
40
- } catch {
41
- // an entry being written is read at the next turn
42
- }
43
- }
44
- return entrees;
45
- }
46
-
47
- // Puts the branch at the end of the queue, replacing its earlier entry.
48
- export function inscrireEntree(racine, branche, ticket) {
49
- for (const e of lireEntrees(racine)) {
50
- if (e.branche === branche) rmSync(e.fichier, { force: true });
51
- }
52
- const dossier = dossierEntrees(racine);
53
- mkdirSync(dossier, { recursive: true });
54
- const arrivee = String(Date.now()).padStart(15, '0');
55
- const fichier = path.join(dossier, `${arrivee}-${String(process.pid).padStart(8, '0')}.json`);
56
- writeFileSync(fichier, JSON.stringify({ branche, ticket }), { flag: 'wx' });
57
- }
58
-
59
- export function retirerEntree(entree) {
60
- rmSync(entree.fichier, { force: true });
61
- }
@@ -1,93 +0,0 @@
1
- // The crates touched since a commit, the demand `touches` of the join (scripts/jointure.d.ts), as
2
- // Turborepo's `--filter=...[<commit>]` reads the packages a change reaches and its global
3
- // dependencies touch them all.
4
- //
5
- // - The files changed: what git sees changed since the commit, the working tree and the untracked
6
- // files included (`git diff --name-only --no-renames <depuis>`, `git ls-files -o
7
- // --exclude-standard`).
8
- // - Each file in the crate of the longest folder that holds it (./composants.mjs). A file of the
9
- // workspace itself, its Cargo.toml or its Cargo.lock at the root, reaches every build: it touches
10
- // every crate. Any other file out of every crate is out of the graph (`horsGraphe`).
11
- // - The dependents: the members that depend on a touched crate by its path, of any kind, the
12
- // development dependencies included, transitively.
13
- import { spawnSync } from 'node:child_process';
14
- import path from 'node:path';
15
- import { composantDans, crates } from './composants.mjs';
16
-
17
- // The files of the workspace itself, from its root: a change to one rebuilds every crate.
18
- export const DE_L_ESPACE = ['Cargo.toml', 'Cargo.lock'];
19
-
20
- const lignesDeGit = (racine, args) => {
21
- const r = spawnSync('git', ['-C', racine, ...args, '-z'], {
22
- encoding: 'utf8',
23
- maxBuffer: 256 * 1024 * 1024,
24
- });
25
- if (r.status !== 0) {
26
- throw new Error(`⛔ git ${args.join(' ')} : ${r.stderr.trim()}`);
27
- }
28
- return r.stdout.split('\0').filter(Boolean);
29
- };
30
-
31
- /**
32
- * The crates the files <fichiers> (from <racine>) touch, their dependents, and the files out of
33
- * the graph: `{ touches, dependants, horsGraphe }`, each list sorted.
34
- * @param {string} racine the root of the workspace
35
- * @param {Iterable<string>} fichiers the files changed
36
- */
37
- export function touchesDesFichiers(racine, fichiers) {
38
- const tous = crates(racine);
39
- const liste = tous.map(c => c.composant);
40
- const touches = new Set();
41
- const horsGraphe = [];
42
- for (const f of new Set(fichiers)) {
43
- if (DE_L_ESPACE.includes(path.normalize(f))) {
44
- for (const c of liste) {
45
- touches.add(c);
46
- }
47
- continue;
48
- }
49
- const c = composantDans(liste, racine, f);
50
- if (c) {
51
- touches.add(c);
52
- } else {
53
- horsGraphe.push(f);
54
- }
55
- }
56
- const parDossier = new Map(liste.map(c => [c.dossier, c]));
57
- const lecteursDe = new Map(liste.map(c => [c, new Set()]));
58
- for (const c of tous) {
59
- for (const d of c.deps) {
60
- const lu = parDossier.get(d.dossier);
61
- if (lu && lu !== c.composant) {
62
- lecteursDe.get(lu).add(c.composant);
63
- }
64
- }
65
- }
66
- const dependants = new Set();
67
- const suivre = c => {
68
- for (const l of lecteursDe.get(c)) {
69
- if (touches.has(l) || dependants.has(l)) {
70
- continue;
71
- }
72
- dependants.add(l);
73
- suivre(l);
74
- }
75
- };
76
- for (const c of touches) {
77
- suivre(c);
78
- }
79
- const parNom = (a, b) => a.nom.localeCompare(b.nom);
80
- return {
81
- touches: [...touches].sort(parNom),
82
- dependants: [...dependants].sort(parNom),
83
- horsGraphe: horsGraphe.sort(),
84
- };
85
- }
86
-
87
- /** The crates touched in <racine> since the commit <depuis>, their dependents, the files out. */
88
- export function touches(racine, { depuis }) {
89
- return touchesDesFichiers(racine, [
90
- ...lignesDeGit(racine, ['diff', '--name-only', '--no-renames', depuis]),
91
- ...lignesDeGit(racine, ['ls-files', '-o', '--exclude-standard']),
92
- ]);
93
- }
@@ -1,6 +0,0 @@
1
- // The script of the tests of a package of the module typescript, and its task of Turborepo: the one
2
- // name the module reads and runs (`joueDesTests` of ./index.mjs, ./tests.mjs, ./verifier.mjs,
3
- // ./verdict.mjs, ./turbo-des-paquets.mjs), neutral for every language (decision 4 of grillhouse-pkl).
4
-
5
- /** The name of the script and of the task of the tests. */
6
- export const SCRIPT_DES_TESTS = 'test:unit';