@roomi-fields/grillhouse 0.28.3 → 0.30.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 (238) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +739 -0
  3. package/bin/grillhouse.mjs +128 -26
  4. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  5. package/cadre/templates/projet/CLAUDE.md +5 -1
  6. package/cadre/templates/projet/README.md +11 -11
  7. package/cadre/templates/projet/_gitignore +2 -5
  8. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  9. package/cadre/templates/projet/package.json +2 -2
  10. package/charte.md +37 -4
  11. package/dist/temporal/acte.d.ts +24 -0
  12. package/dist/temporal/acte.js +139 -0
  13. package/dist/temporal/acte.js.map +1 -0
  14. package/dist/temporal/attributs.d.ts +6 -0
  15. package/dist/temporal/attributs.js +15 -0
  16. package/dist/temporal/attributs.js.map +1 -0
  17. package/dist/temporal/circuit/activites.d.ts +13 -0
  18. package/dist/temporal/circuit/activites.js +33 -0
  19. package/dist/temporal/circuit/activites.js.map +1 -0
  20. package/dist/temporal/circuit/client.d.ts +72 -0
  21. package/dist/temporal/circuit/client.js +247 -0
  22. package/dist/temporal/circuit/client.js.map +1 -0
  23. package/dist/temporal/circuit/commande.d.ts +2 -0
  24. package/dist/temporal/circuit/commande.js +238 -0
  25. package/dist/temporal/circuit/commande.js.map +1 -0
  26. package/dist/temporal/circuit/contrat.d.ts +305 -0
  27. package/dist/temporal/circuit/contrat.js +24 -0
  28. package/dist/temporal/circuit/contrat.js.map +1 -0
  29. package/dist/temporal/circuit/deroule.d.ts +3 -0
  30. package/dist/temporal/circuit/deroule.js +540 -0
  31. package/dist/temporal/circuit/deroule.js.map +1 -0
  32. package/dist/temporal/client.d.ts +47 -0
  33. package/dist/temporal/client.js +69 -0
  34. package/dist/temporal/client.js.map +1 -0
  35. package/dist/temporal/commande.d.ts +2 -0
  36. package/dist/temporal/commande.js +95 -0
  37. package/dist/temporal/commande.js.map +1 -0
  38. package/dist/temporal/deroules.d.ts +5 -0
  39. package/dist/temporal/deroules.js +10 -0
  40. package/dist/temporal/deroules.js.map +1 -0
  41. package/dist/temporal/etat.d.ts +33 -0
  42. package/dist/temporal/etat.js +59 -0
  43. package/dist/temporal/etat.js.map +1 -0
  44. package/dist/temporal/file/activites.d.ts +10 -0
  45. package/dist/temporal/file/activites.js +25 -0
  46. package/dist/temporal/file/activites.js.map +1 -0
  47. package/dist/temporal/file/client.d.ts +4 -0
  48. package/dist/temporal/file/client.js +6 -0
  49. package/dist/temporal/file/client.js.map +1 -0
  50. package/dist/temporal/file/contrat.d.ts +158 -0
  51. package/dist/temporal/file/contrat.js +14 -0
  52. package/dist/temporal/file/contrat.js.map +1 -0
  53. package/dist/temporal/file/deroule.d.ts +15 -0
  54. package/dist/temporal/file/deroule.js +235 -0
  55. package/dist/temporal/file/deroule.js.map +1 -0
  56. package/dist/temporal/installation.d.ts +124 -0
  57. package/dist/temporal/installation.js +408 -0
  58. package/dist/temporal/installation.js.map +1 -0
  59. package/dist/temporal/places/activites.d.ts +8 -0
  60. package/dist/temporal/places/activites.js +13 -0
  61. package/dist/temporal/places/activites.js.map +1 -0
  62. package/dist/temporal/places/client.d.ts +28 -0
  63. package/dist/temporal/places/client.js +64 -0
  64. package/dist/temporal/places/client.js.map +1 -0
  65. package/dist/temporal/places/contrat.d.ts +106 -0
  66. package/dist/temporal/places/contrat.js +21 -0
  67. package/dist/temporal/places/contrat.js.map +1 -0
  68. package/dist/temporal/places/deroule.d.ts +3 -0
  69. package/dist/temporal/places/deroule.js +198 -0
  70. package/dist/temporal/places/deroule.js.map +1 -0
  71. package/dist/temporal/sonde/activites.d.ts +6 -0
  72. package/dist/temporal/sonde/activites.js +52 -0
  73. package/dist/temporal/sonde/activites.js.map +1 -0
  74. package/dist/temporal/sonde/contrat.d.ts +35 -0
  75. package/dist/temporal/sonde/contrat.js +10 -0
  76. package/dist/temporal/sonde/contrat.js.map +1 -0
  77. package/dist/temporal/sonde/deroule.d.ts +3 -0
  78. package/dist/temporal/sonde/deroule.js +39 -0
  79. package/dist/temporal/sonde/deroule.js.map +1 -0
  80. package/dist/temporal/tickets/activites.d.ts +7 -0
  81. package/dist/temporal/tickets/activites.js +81 -0
  82. package/dist/temporal/tickets/activites.js.map +1 -0
  83. package/dist/temporal/tickets/client.d.ts +10 -0
  84. package/dist/temporal/tickets/client.js +31 -0
  85. package/dist/temporal/tickets/client.js.map +1 -0
  86. package/dist/temporal/tickets/contrat.d.ts +56 -0
  87. package/dist/temporal/tickets/contrat.js +13 -0
  88. package/dist/temporal/tickets/contrat.js.map +1 -0
  89. package/dist/temporal/tickets/deroule.d.ts +3 -0
  90. package/dist/temporal/tickets/deroule.js +94 -0
  91. package/dist/temporal/tickets/deroule.js.map +1 -0
  92. package/dist/temporal/travailleur.d.ts +2 -0
  93. package/dist/temporal/travailleur.js +69 -0
  94. package/dist/temporal/travailleur.js.map +1 -0
  95. package/docs/ARCHITECTURE.md +813 -53
  96. package/docs/CADRE.md +17 -0
  97. package/docs/INTERFACE.md +161 -30
  98. package/hooks/crochet.mjs +19 -2
  99. package/hooks/hooks.json +11 -0
  100. package/package.json +16 -4
  101. package/scripts/activites.mjs +2182 -0
  102. package/scripts/aiguillage.d.mts +37 -0
  103. package/scripts/aiguillage.mjs +328 -0
  104. package/scripts/avancement.mjs +159 -64
  105. package/scripts/bilan.mjs +37 -19
  106. package/scripts/cadre.mjs +11 -2
  107. package/scripts/circuit.mjs +888 -3654
  108. package/scripts/circuits-cles.d.mts +4 -0
  109. package/scripts/circuits-cles.mjs +21 -0
  110. package/scripts/circuits-du-serveur.mjs +105 -0
  111. package/scripts/codes-de-sortie.mjs +9 -0
  112. package/scripts/commandes-composees.mjs +45 -41
  113. package/scripts/commandes-du-path.d.mts +7 -0
  114. package/scripts/commandes-du-path.mjs +25 -0
  115. package/scripts/composition-des-langages.mjs +30 -11
  116. package/scripts/conformite.mjs +19 -10
  117. package/scripts/copies-finies.mjs +188 -42
  118. package/scripts/depart-du-ticket.d.mts +53 -0
  119. package/scripts/depart-du-ticket.mjs +124 -0
  120. package/scripts/dependances-internes.mjs +115 -0
  121. package/scripts/dernier-vert.mjs +7 -15
  122. package/scripts/donnees-cles.mjs +228 -0
  123. package/scripts/droits.mjs +11 -1
  124. package/scripts/effets.mjs +352 -0
  125. package/scripts/enveloppe/enveloppe.mjs +119 -8
  126. package/scripts/enveloppe/lancer.sh +27 -32
  127. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  128. package/scripts/enveloppe/travail-de-la-copie.mjs +99 -12
  129. package/scripts/etapes.mjs +6 -3
  130. package/scripts/faits-du-circuit.mjs +493 -0
  131. package/scripts/file-des-tickets.d.mts +21 -0
  132. package/scripts/file-des-tickets.mjs +58 -0
  133. package/scripts/flux-des-paquets.mjs +187 -0
  134. package/scripts/fusion-du-changelog.mjs +0 -1
  135. package/scripts/gardes-du-cadre.mjs +12 -2
  136. package/scripts/grillhouse-maj.mjs +16 -7
  137. package/scripts/integration/file.mjs +477 -422
  138. package/scripts/integration/integrer.mjs +20 -22
  139. package/scripts/integration/rejeu.mjs +19 -4
  140. package/scripts/jointure.d.ts +168 -28
  141. package/scripts/langages/cargo/commandes.mjs +426 -119
  142. package/scripts/langages/cargo/composants.mjs +187 -3
  143. package/scripts/langages/cargo/exemples.mjs +75 -17
  144. package/scripts/langages/cargo/index.mjs +32 -13
  145. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  146. package/scripts/langages/cargo/sccache.mjs +62 -16
  147. package/scripts/langages/cargo/squelette.mjs +72 -3
  148. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  149. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  150. package/scripts/langages/python/commandes.mjs +232 -79
  151. package/scripts/langages/python/composants.mjs +65 -3
  152. package/scripts/langages/python/exemples.mjs +21 -12
  153. package/scripts/langages/python/index.mjs +25 -5
  154. package/scripts/langages/python/lot.mjs +1 -36
  155. package/scripts/langages/python/squelette.mjs +119 -17
  156. package/scripts/langages/typescript/construire.mjs +6 -163
  157. package/scripts/langages/typescript/exemples.mjs +19 -11
  158. package/scripts/langages/typescript/frontieres.mjs +1 -1
  159. package/scripts/langages/typescript/index.mjs +48 -63
  160. package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
  161. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  162. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
  163. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  164. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  165. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  166. package/scripts/langages/typescript/squelette.mjs +18 -2
  167. package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
  168. package/scripts/langages/typescript/tests-de-nuit.mjs +44 -21
  169. package/scripts/langages/typescript/tests.mjs +17 -8
  170. package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
  171. package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
  172. package/scripts/langages/typescript/verdict.mjs +1 -1
  173. package/scripts/langages/typescript/verifier.mjs +110 -296
  174. package/scripts/langages/typescript/vitest-config/base.mjs +30 -10
  175. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  176. package/scripts/langages/typescript/vitest-config/cibles.mjs +123 -62
  177. package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
  178. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  179. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
  180. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -64
  181. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -2
  182. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  183. package/scripts/langages/typescript/vitest.nuit.config.mjs +22 -13
  184. package/scripts/lecture-unique.mjs +51 -0
  185. package/scripts/mesure/pression.mjs +11 -9
  186. package/scripts/mesure-de-la-machine.d.mts +21 -0
  187. package/scripts/mesure-de-la-machine.mjs +76 -0
  188. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
  189. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
  190. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  191. package/scripts/migrations.mjs +5 -0
  192. package/scripts/nuit.sh +29 -15
  193. package/scripts/outil.mjs +72 -0
  194. package/scripts/outils-cles.d.mts +24 -0
  195. package/scripts/outils-cles.mjs +0 -1
  196. package/scripts/paquet-npm.mjs +147 -0
  197. package/scripts/paquet.mjs +112 -14
  198. package/scripts/paquets.mjs +34 -6
  199. package/scripts/passe-de-la-machine.mjs +66 -0
  200. package/scripts/places-de-la-machine.mjs +360 -0
  201. package/scripts/places-du-serveur.mjs +170 -0
  202. package/scripts/prefixe-des-tickets.mjs +68 -0
  203. package/scripts/preparation.mjs +10 -3
  204. package/scripts/registre.mjs +3 -2
  205. package/scripts/regles-des-places.d.mts +36 -0
  206. package/scripts/regles-des-places.mjs +70 -0
  207. package/scripts/reponses-du-circuit.d.mts +6 -0
  208. package/scripts/reponses-du-circuit.mjs +28 -0
  209. package/scripts/resultats.mjs +29 -14
  210. package/scripts/retirer-les-copies-finies.mjs +25 -0
  211. package/scripts/sans-reponse.d.mts +4 -0
  212. package/scripts/sans-reponse.mjs +13 -0
  213. package/scripts/seances.mjs +918 -0
  214. package/scripts/services-du-noyau.mjs +28 -11
  215. package/scripts/session-start.sh +10 -1
  216. package/scripts/sortie.mjs +23 -4
  217. package/scripts/sources.mjs +3 -3
  218. package/scripts/sous-commandes.mjs +39 -9
  219. package/scripts/style-a-l-ecriture.mjs +229 -0
  220. package/scripts/superviseur.mjs +382 -16
  221. package/scripts/tableau.mjs +329 -130
  222. package/scripts/taches-du-graphe.mjs +328 -0
  223. package/scripts/ticket-du-circuit.mjs +206 -0
  224. package/scripts/transitions.d.mts +148 -0
  225. package/scripts/transitions.mjs +901 -0
  226. package/scripts/verrou-de-fichier.mjs +2 -2
  227. package/scripts/verrou-de-machine.mjs +322 -62
  228. package/skills/developpeur/SKILL.md +11 -3
  229. package/skills/explorateur/SKILL.md +2 -1
  230. package/skills/pitmaster/SKILL.md +62 -28
  231. package/skills/pitmaster/references/consigne-agent.md +5 -1
  232. package/skills/release/SKILL.md +3 -3
  233. package/skills/relecteur/SKILL.md +22 -8
  234. package/skills/testwriter/SKILL.md +47 -39
  235. package/scripts/demon.mjs +0 -138
  236. package/scripts/integration/file-attente.mjs +0 -61
  237. package/scripts/langages/cargo/touches.mjs +0 -93
  238. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -34,13 +34,13 @@
34
34
  // removes at its end.
35
35
  // - `npm test` measures itself against the last green under the circuit's mark,
36
36
  // `GRILLHOUSE_DEPUIS_LE_VERT` (scripts/langages/typescript/tests.mjs, scripts/circuit.mjs); it never keeps one.
37
- // - In a project of several languages, each language's pass defers its green to the file that
38
- // `GRILLHOUSE_VERT_DIFFERE` names (`VERT_DIFFERE`): the composed command keeps the first one once
39
- // every language played green (scripts/commandes-composees.mjs), so that a language played after
40
- // another does not measure itself against the green of the first.
37
+ // - Only the measure of the changed files and the keeping of the green live here: the files go to
38
+ // `vitest --changed`, and no module of language chooses the packages it plays by the last green
39
+ // (the tests of a crate or a Python project are tasks of Turborepo, which its cache selects).
40
+ // The green is kept by the one pass of the verification (scripts/langages/typescript/verifier.mjs),
41
+ // once, when every task of every language of the graph is green, and never when one is red.
41
42
  import { spawnSync } from 'node:child_process';
42
43
  import {
43
- appendFileSync,
44
44
  copyFileSync,
45
45
  existsSync,
46
46
  mkdirSync,
@@ -56,9 +56,6 @@ import path from 'node:path';
56
56
  // tests of the module of the language reads in each package.
57
57
  export const CHANGEMENTS = 'GRILLHOUSE_CHANGEMENTS';
58
58
  export const DEPUIS_LE_VERT = 'GRILLHOUSE_DEPUIS_LE_VERT';
59
- // The variable that names the file where a pass of one language among several defers its green,
60
- // which the composed command keeps once every language played green (scripts/commandes-composees.mjs).
61
- export const VERT_DIFFERE = 'GRILLHOUSE_VERT_DIFFERE';
62
59
  const SHA = /^[0-9a-f]{40,64}$/;
63
60
 
64
61
  const git = (racine, args, env = process.env) =>
@@ -159,13 +156,8 @@ function lireLeVertDe(etat, branche) {
159
156
  return { commit: v.commit, arbre: v.arbre, branche };
160
157
  }
161
158
 
162
- // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached; while
163
- // <env> names a file of deferred greens (`VERT_DIFFERE`), adds it there instead, one line of JSON.
164
- export function garderLeVert(etat, env = process.env) {
165
- if (env[VERT_DIFFERE]) {
166
- appendFileSync(env[VERT_DIFFERE], `${JSON.stringify(etat)}\n`);
167
- return;
168
- }
159
+ // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached.
160
+ export function garderLeVert(etat) {
169
161
  const branche = etat.branche ?? etat.main;
170
162
  const f = branche ? fichierDuVert(etat.racine, branche) : null;
171
163
  if (!f) return;
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env node
2
+ // The reading of the `grillhouse.donnees` key of a package.json, the data of a package, as Bazel's
3
+ // `data` declare the output of another target that a test runs (`data = ["//crates/service:bin"]`):
4
+ // `{ "<VARIABLE>": "<paquet>#<sortie>" }`. The consumer lists the provider in its `devDependencies`,
5
+ // so that Turborepo builds the provider before the consumer's tests (`^build`,
6
+ // scripts/langages/typescript/turbo-des-paquets.mjs), even when the provider is out of the plan; the
7
+ // variable carries the absolute path of the built output, which `npm test`, `npm run verifier`
8
+ // (bin/grillhouse.mjs), the circuit (scripts/circuit.mjs), the envelope, the integration and the
9
+ // night pass to the tests as they pass `grillhouse.outils` (scripts/outils-cles.mjs).
10
+ //
11
+ // - The key is absent, null or an object; each name is a variable's (`[A-Za-z_][A-Za-z0-9_]*`),
12
+ // each value of the form `<paquet>#<sortie>`: a package of the repository by its package.json
13
+ // name, in the `devDependencies` of the consumer, and an output its language knows. Every fault is
14
+ // named with its key (`grillhouse.donnees.<VARIABLE>`), one per line; a faulty key gives no
15
+ // variable, before any work.
16
+ // - The output is asked of the language of the provider (`sortieDuPaquet`, scripts/jointure.d.ts):
17
+ // for a crate, a binary (target of kind `bin`) of `cargo metadata`, in its target directory, under
18
+ // `release` when the `build` script of the provider's package.json carries `--release`, `debug`
19
+ // otherwise; another language is refused, « sortie non prise en charge pour <langage> ».
20
+ // - The consumers are the root and the packages of the main tree of the repository (`arbrePrincipal`,
21
+ // scripts/outils-cles.mjs); the paths are resolved from the directory given, the copy.
22
+ // - `controlerLesDonnees` runs after the build: an output absent at its path is refused, the
23
+ // variable and the path named.
24
+ // - `node donnees-cles.mjs <dir>` writes one line `export VARIABLE='chemin'` per datum of the
25
+ // project that holds <dir> (`exportsDesDonnees`), which the night evaluates, exit 0; a faulty key
26
+ // writes its faults on stderr, exit 1.
27
+ import { existsSync, readFileSync } from 'node:fs';
28
+ import path from 'node:path';
29
+ import { pathToFileURL } from 'node:url';
30
+ import { LANGAGES, langage } from './langages.mjs';
31
+ import { arbrePrincipal } from './outils-cles.mjs';
32
+ import { paquets } from './paquets.mjs';
33
+ import { paquetsSansPackageJson } from './paquet-npm.mjs';
34
+
35
+ const NOM = /^[A-Za-z_][A-Za-z0-9_]*$/;
36
+ const FORME = /^([^#\s]+)#([^#\s]+)$/;
37
+ const RELEASE = /(^|\s)--release(\s|$)/;
38
+
39
+ // The language of the package at <chemin> (from <racine>): the one whose manifest is not the
40
+ // package.json when the tables declare it so, else the language of the package.json.
41
+ function langageDuPaquet(racine, chemin) {
42
+ const hors = paquetsSansPackageJson(racine).find(p => p.chemin === chemin);
43
+ if (hors) return hors.langage;
44
+ return Object.keys(LANGAGES).find(n => langage(n).manifeste === 'package.json') ?? 'typescript';
45
+ }
46
+
47
+ const lireJson = f => {
48
+ try {
49
+ return JSON.parse(readFileSync(f, 'utf8'));
50
+ } catch {
51
+ return null;
52
+ }
53
+ };
54
+
55
+ // The data the project of <dir> declares: { donnees, parPaquet, fautes }, `parPaquet` the variables
56
+ // of each consumer by its folder from the root.
57
+ function lire(dir) {
58
+ const racine = arbrePrincipal(dir);
59
+ const fautes = [];
60
+ /** @type {Record<string, string>} */
61
+ const donnees = {};
62
+ /** @type {Map<string, string[]>} */
63
+ const parPaquet = new Map();
64
+ /** @type {Map<string, string[]>} */
65
+ const fournisseurs = new Map();
66
+ const racinePkg = lireJson(path.join(racine, 'package.json'));
67
+ if (racinePkg === null) return { donnees, parPaquet, fournisseurs, fautes };
68
+ const liste = paquets(racine);
69
+ const consommateurs = [{ dossier: '.', pkg: racinePkg }, ...liste];
70
+ for (const { dossier, pkg } of consommateurs) {
71
+ const d = pkg?.grillhouse?.donnees;
72
+ if (d === undefined || d === null) continue;
73
+ const ou = dossier === '.' ? 'package.json' : `${dossier}/package.json`;
74
+ if (typeof d !== 'object' || Array.isArray(d)) {
75
+ fautes.push(
76
+ `${ou} : la clé grillhouse.donnees vaut ${JSON.stringify(d)}, pas un objet { VARIABLE: "<paquet>#<sortie>" }.`
77
+ );
78
+ continue;
79
+ }
80
+ for (const [nom, v] of Object.entries(d)) {
81
+ const cle = `grillhouse.donnees.${nom}`;
82
+ const faute = f => fautes.push(`${ou} : la clé ${cle} ${f}`);
83
+ if (!NOM.test(nom)) {
84
+ fautes.push(`${ou} : la clé grillhouse.donnees nomme « ${nom} », pas un nom de variable.`);
85
+ continue;
86
+ }
87
+ const forme = typeof v === 'string' ? FORME.exec(v) : null;
88
+ if (!forme) {
89
+ faute(`vaut ${JSON.stringify(v)}, pas de la forme <paquet>#<sortie>.`);
90
+ continue;
91
+ }
92
+ const [, nomDuPaquet, sortie] = forme;
93
+ const fournisseur = liste.find(p => p.pkg?.name === nomDuPaquet);
94
+ if (!fournisseur) {
95
+ faute(`nomme le paquet « ${nomDuPaquet} », qu'aucun paquet du dépôt ne porte.`);
96
+ continue;
97
+ }
98
+ if (!Object.hasOwn(pkg.devDependencies ?? {}, nomDuPaquet)) {
99
+ faute(
100
+ `nomme le paquet « ${nomDuPaquet} », absent des devDependencies de ${ou} : la construction du fournisseur avant les tests passe par cette dépendance.`
101
+ );
102
+ continue;
103
+ }
104
+ const langageNom = langageDuPaquet(racine, fournisseur.dossier);
105
+ const release = RELEASE.test(String(fournisseur.pkg.scripts?.build ?? ''));
106
+ let chemin;
107
+ try {
108
+ chemin = langage(langageNom).sortieDuPaquet(dir, fournisseur.dossier, sortie, { release });
109
+ } catch (e) {
110
+ faute(`nomme ${v} : ${e.message.replace(/^⛔ /, '')}`);
111
+ continue;
112
+ }
113
+ if (Object.hasOwn(donnees, nom) && donnees[nom] !== chemin) {
114
+ faute(`est déclarée deux fois, pour deux sorties différentes.`);
115
+ continue;
116
+ }
117
+ donnees[nom] = chemin;
118
+ parPaquet.set(dossier, [...(parPaquet.get(dossier) ?? []), nom]);
119
+ fournisseurs.set(dossier, [...(fournisseurs.get(dossier) ?? []), nomDuPaquet]);
120
+ }
121
+ }
122
+ return { donnees: fautes.length ? {} : donnees, parPaquet, fournisseurs, fautes };
123
+ }
124
+
125
+ /**
126
+ * The data of the project that holds <dir>: each variable and the absolute path of the output it
127
+ * names, none without `grillhouse.donnees`. Nothing exists yet: the paths are those the build will
128
+ * write.
129
+ * @param {string} dir a directory of the project: its main tree or a copy
130
+ * @returns {Record<string, string>}
131
+ * @throws {Error} the faults of the key, one per line
132
+ */
133
+ export function donneesDe(dir) {
134
+ const { donnees, fautes } = lire(dir);
135
+ if (fautes.length) throw new Error(fautes.join('\n'));
136
+ return donnees;
137
+ }
138
+
139
+ /**
140
+ * The variables of the consumer at <chemin> (from the root) with their paths, to be checked once
141
+ * the build is done.
142
+ * @param {string} dir
143
+ * @param {string} chemin
144
+ * @returns {Record<string, string>}
145
+ * @throws {Error} the faults of the key, one per line
146
+ */
147
+ export function donneesDuPaquet(dir, chemin) {
148
+ const { donnees, parPaquet, fautes } = lire(dir);
149
+ if (fautes.length) throw new Error(fautes.join('\n'));
150
+ return Object.fromEntries(
151
+ [...parPaquet]
152
+ .filter(([d]) => contient(d, chemin))
153
+ .flatMap(([, ns]) => ns.map(n => [n, donnees[n]]))
154
+ );
155
+ }
156
+
157
+ // Whether the consumer folder <dossier> is <chemin> or holds it (a file or a folder in the package).
158
+ const contient = (dossier, chemin) =>
159
+ dossier === '.' ? chemin === '.' : chemin === dossier || chemin.startsWith(`${dossier}/`);
160
+
161
+ /**
162
+ * The names of the providers of the consumer that holds <chemin> (the package folder, or a file or
163
+ * folder in it), which a run of its tests builds first.
164
+ * @param {string} dir
165
+ * @param {string} chemin
166
+ * @returns {string[]}
167
+ * @throws {Error} the faults of the key, one per line
168
+ */
169
+ export function fournisseursDuPaquet(dir, chemin) {
170
+ const { fautes, fournisseurs } = lire(dir);
171
+ if (fautes.length) throw new Error(fautes.join('\n'));
172
+ return [
173
+ ...new Set([...fournisseurs].filter(([d]) => contient(d, chemin)).flatMap(([, ns]) => ns)),
174
+ ];
175
+ }
176
+
177
+ /**
178
+ * Builds the providers <noms> by the module of the language whose manifest is the package.json.
179
+ * @param {string[]} noms
180
+ * @throws {Error} a build that fails
181
+ */
182
+ export function construireLesFournisseurs(noms) {
183
+ if (!noms.length) return;
184
+ const nom = Object.keys(LANGAGES).find(n => langage(n).manifeste === 'package.json');
185
+ const module = nom ? langage(nom) : null;
186
+ if (!module?.construireLesPaquets) {
187
+ throw new Error('aucun langage du projet ne construit les paquets par leur nom.');
188
+ }
189
+ module.construireLesPaquets(noms);
190
+ }
191
+
192
+ /**
193
+ * Refuses an output absent after the build, its variable and its path named, one per line.
194
+ * @param {Record<string, string>} donnees
195
+ * @throws {Error}
196
+ */
197
+ export function controlerLesDonnees(donnees) {
198
+ const absents = Object.entries(donnees)
199
+ .filter(([, c]) => !existsSync(c))
200
+ .map(
201
+ ([n, c]) => `la variable ${n} nomme ${c}, que la construction du fournisseur n'a pas produit.`
202
+ );
203
+ if (absents.length) throw new Error(absents.join('\n'));
204
+ }
205
+
206
+ /**
207
+ * The environment <env> of a pass with the data <donnees> (`donneesDe`), the data winning.
208
+ * @param {Record<string, string>} donnees
209
+ * @param {Record<string, string | undefined>} env
210
+ */
211
+ export function avecLesDonnees(donnees, env) {
212
+ return { ...env, ...donnees };
213
+ }
214
+
215
+ // The shell's text that exports the data <donnees>, one `export VARIABLE='chemin'` per line.
216
+ export const exportsDesDonnees = donnees =>
217
+ Object.entries(donnees)
218
+ .map(([n, c]) => `export ${n}='${c.replaceAll("'", "'\\''")}'\n`)
219
+ .join('');
220
+
221
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
222
+ try {
223
+ process.stdout.write(exportsDesDonnees(donneesDe(path.resolve(process.argv[2] ?? '.'))));
224
+ } catch (e) {
225
+ process.stderr.write(`${/** @type {Error} */ (e).message}\n`);
226
+ process.exitCode = 1;
227
+ }
228
+ }
@@ -323,6 +323,16 @@ function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
323
323
  ),
324
324
  env: SANS_TACHE_DE_FOND,
325
325
  };
326
+ // The write lock runs the frame of the main tree, never the copy's; a copy that is the root keeps
327
+ // the project's own command.
328
+ const distincte = path.resolve(copie) !== path.resolve(racine);
329
+ const cadre = distincte ? racine : '$CLAUDE_PROJECT_DIR';
330
+ const commande = `"${cadre}/node_modules/.bin/grillhouse"`;
331
+ // Fails closed (a firewall's rule): a missing command makes the shell exit 127, which Claude Code
332
+ // reads as an error that does not block, so a copy with a main tree lacking the frame refuses (2).
333
+ const verrou = distincte
334
+ ? `[ -x ${commande} ] || { echo "⛔ verrou : le cadre de l'arbre principal manque ou n'est pas exécutable : ${cadre}/node_modules/.bin/grillhouse (écriture refusée)" >&2; exit 2; }; exec ${commande} verrou ${role}`
335
+ : `${commande} verrou ${role}`;
326
336
  if (r.ecrit) {
327
337
  reglages.hooks = {
328
338
  PreToolUse: [
@@ -331,7 +341,7 @@ function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
331
341
  hooks: [
332
342
  {
333
343
  type: 'command',
334
- command: `"$CLAUDE_PROJECT_DIR/node_modules/.bin/grillhouse" verrou ${role}`,
344
+ command: verrou,
335
345
  },
336
346
  ],
337
347
  },
@@ -0,0 +1,352 @@
1
+ // The external effects of the circuit, as data, and their one writer (docs/ARCHITECTURE.md, the
2
+ // workflow of a ticket: « une activité, un effet, une clé »), as a functional core hands its
3
+ // imperative shell what to write. The code of the circuit that the workflow of a ticket runs
4
+ // (scripts/circuit.mjs, scripts/seances.mjs, scripts/activites.mjs, scripts/ticket-du-circuit.mjs),
5
+ // and the queue of a project its comments (scripts/integration/file.mjs), write nothing outside
6
+ // themselves: it emits each effect (`emettre`). An effect emitted outside an act is played
7
+ // at once (`jouerLEffet`, without a key); an act of the workflow gathers
8
+ // them in `ctx.rendus` and gives them back with its outcome (scripts/faits-du-circuit.mjs), its
9
+ // own readings seeing those it already emitted (`rendusDe`), and the workflow plays each one in an
10
+ // activity of its own, under the key of that activity (src/temporal/acte.ts `cleDeLActivite`).
11
+ //
12
+ // The effects, `{ genre, ... }`:
13
+ //
14
+ // - `commentaire` `{ ticket, texte, auteur }`: a comment at a ticket, by its author;
15
+ // - `fiche` `{ entree }`: a line of the ticket's sheets (`<ticket>.fiches.jsonl`), dated;
16
+ // - `decouverte` `{ role, sujet, corps, composants }`: a discovery filed closed under the ticket
17
+ // (scripts/ticket.sh, label `decouverte`), then its line among the sheets (`{ id, sujet }`);
18
+ // - `registre` `{ ligne }`: a line of the register of the steps (scripts/registre.mjs);
19
+ // - `etat` `{ etat }`: the circuit's state, which the workflow of a ticket holds and no player writes
20
+ // (src/temporal/circuit/deroule.ts);
21
+ // - `plan` `{ titre, description }`: the plan written at the ticket (its title, its description);
22
+ // - `bilan` `{ ticket }`: the bilan of the ticket computed when it is written, once the effects
23
+ // before it are, kept in the main tree, and its text at the ticket (scripts/bilan.mjs
24
+ // `ecrireLeBilan`), its key in the comment;
25
+ // - `resume-du-tri` `{ ticket, debut, ecritures }`: the line of the tri at the ticket, which reads
26
+ // each discovery's writings when it is written (`{ decouverte, verdict, etiquettes, rouvre }`:
27
+ // its comment, its labels, its reopening), its key in the comment;
28
+ // - `etiquettes` `{ ticket, etiquettes }`: labels added to a ticket;
29
+ // - `reouverture` `{ ticket }`: a ticket reopened.
30
+ //
31
+ // An effect that does not replay without harm carries the key it is played under (`AVEC_CLE`),
32
+ // and is read before it is written: a comment holds it in a line of HTML comment, a line of the
33
+ // sheets or of the register in a field `cle`, a discovery in its body. Every other effect writes
34
+ // the same thing however often it is played: it takes no key. Each player returns `{ status,
35
+ // stderr }`, as bd does; an effect not written has one outcome
36
+ // (`ecrireLEffet`): said on the error output, or a stop.
37
+ import { spawnSync } from 'node:child_process';
38
+ import { appendFileSync, existsSync, readFileSync } from 'node:fs';
39
+ import path from 'node:path';
40
+ import { stripVTControlCharacters } from 'node:util';
41
+ import { ecrireLeBilan } from './bilan.mjs';
42
+ import { ecrire as ecrireAuRegistre } from './registre.mjs';
43
+
44
+ /** The line of HTML comment that carries the key <cle> in a text at a ticket. */
45
+ export const marqueDeCle = cle => `<!-- grillhouse : ${cle} -->`;
46
+
47
+ /** The effects that do not replay without harm: each carries its key. */
48
+ export const AVEC_CLE = new Set([
49
+ 'commentaire',
50
+ 'fiche',
51
+ 'decouverte',
52
+ 'registre',
53
+ 'bilan',
54
+ 'resume-du-tri',
55
+ ]);
56
+
57
+ // The variable in which bd reads the author of a comment (`bd --help`: « default: $BEADS_ACTOR,
58
+ // git user.name, $USER »), each session's its role; the author of the circuit's own lines, and
59
+ // the start of each of them at a ticket.
60
+ export const ACTEUR = 'BEADS_ACTOR';
61
+ export const AUTEUR_DU_CIRCUIT = 'circuit';
62
+ export const PREFIXE = 'Circuit · ';
63
+ const TICKET_SH = path.join(import.meta.dirname, 'ticket.sh');
64
+
65
+ const ok = { status: 0, stdout: '', stderr: '' };
66
+ // A failure of a player, as bd answers one.
67
+ const echec = stderr => ({ status: 1, stdout: '', stderr });
68
+
69
+ /** <t> without its colours. */
70
+ export const sansCouleurs = t => stripVTControlCharacters(String(t ?? ''));
71
+ /** The first line of <t>, without its colours, 300 characters at most. */
72
+ export const premiereLigne = t => sansCouleurs(t).trim().split('\n')[0].slice(0, 300);
73
+
74
+ /** An effect not written that Temporal tries again: its activity's failure is retryable. */
75
+ export class EffetNonEcrit extends Error {
76
+ constructor(message) {
77
+ super(message);
78
+ this.reessayable = true;
79
+ }
80
+ }
81
+
82
+ // The JSON answer of bd <r>, or the failure of its reading: bd that fails, or answers what does
83
+ // not parse.
84
+ function lu(r, quoi) {
85
+ if (r.status !== 0) {
86
+ return { echec: echec(`${quoi} illisibles : ${r.stderr ?? ''}`.trim()) };
87
+ }
88
+ try {
89
+ return { valeur: JSON.parse(r.stdout || '[]') };
90
+ } catch (e) {
91
+ return { echec: echec(`${quoi} illisibles : ${e.message}`) };
92
+ }
93
+ }
94
+
95
+ /**
96
+ * The effect <effet> of <ctx> emitted: gathered in `ctx.rendus` under an act of the workflow,
97
+ * else played at once (`jouerLEffet`, without a key). What its player returns (`{ status }`), and
98
+ * success when it is gathered.
99
+ */
100
+ export function emettre(ctx, effet) {
101
+ if (ctx.rendus) {
102
+ ctx.rendus.push(effet);
103
+ return ok;
104
+ }
105
+ return ecrireLEffet(ctx, effet, null);
106
+ }
107
+
108
+ /** The effects of the sort <genre> <ctx> emitted and not yet played, in their order. */
109
+ export const rendusDe = (ctx, genre) => (ctx.rendus ?? []).filter(e => e.genre === genre);
110
+
111
+ // bd under the author <auteur>, in the main tree of <ctx>.
112
+ const bdSous = (ctx, auteur, ...a) => (ctx.bdSous ? ctx.bdSous(auteur, ...a) : ctx.bd(...a));
113
+
114
+ // The lines of the file <f> parsed, a torn one left out.
115
+ const lignes = f =>
116
+ (existsSync(f) ? readFileSync(f, 'utf8') : '').split('\n').flatMap(l => {
117
+ try {
118
+ return l ? [JSON.parse(l)] : [];
119
+ } catch {
120
+ return [];
121
+ }
122
+ });
123
+
124
+ // Whether a comment at <ticket> of <ctx> already holds the mark of <cle>, or the failure of its
125
+ // reading.
126
+ function dejaCommente(ctx, ticket, cle) {
127
+ const r = lu(ctx.bd('comments', ticket, '--json'), `commentaires de ${ticket}`);
128
+ if (r.echec) {
129
+ return r.echec;
130
+ }
131
+ const marque = marqueDeCle(cle);
132
+ return (r.valeur ?? []).some(c => String(c?.text ?? '').includes(marque));
133
+ }
134
+
135
+ // The id of the discovery filed under the ticket of <ctx> whose body holds the mark of <cle>, '',
136
+ // or the failure of its reading.
137
+ function decouverteDeLaCle(ctx, cle) {
138
+ const r = lu(
139
+ ctx.bd('list', '--parent', ctx.ticket, '--all', '--desc-contains', marqueDeCle(cle), '--json'),
140
+ `découvertes de ${ctx.ticket}`
141
+ );
142
+ if (r.echec) {
143
+ return r.echec;
144
+ }
145
+ return r.valeur?.[0]?.id ?? '';
146
+ }
147
+
148
+ // The line <entree> among the sheets of <ctx>, under the key <cle> (null without one), once.
149
+ function ficheUneFois(ctx, entree, cle) {
150
+ if (cle && lignes(ctx.fiches).some(e => e.cle === cle)) {
151
+ return ok;
152
+ }
153
+ appendFileSync(ctx.fiches, `${JSON.stringify({ ...entree, ...(cle ? { cle } : {}) })}\n`);
154
+ return ok;
155
+ }
156
+
157
+ // The comment <texte> at <ticket> of <ctx> by <auteur>, under the key <cle> (null without one),
158
+ // once.
159
+ function commenterUneFois(ctx, { ticket, texte, auteur }, cle) {
160
+ const deja = cle ? dejaCommente(ctx, ticket, cle) : false;
161
+ if (deja) {
162
+ return deja === true ? ok : deja;
163
+ }
164
+ return bdSous(
165
+ ctx,
166
+ auteur ?? AUTEUR_DU_CIRCUIT,
167
+ 'comments',
168
+ 'add',
169
+ ticket,
170
+ cle ? `${texte}\n\n${marqueDeCle(cle)}` : texte
171
+ );
172
+ }
173
+
174
+ // The players, by sort, each on <ctx>, the effect and its key (null without one).
175
+ const JOUEURS = {
176
+ commentaire: commenterUneFois,
177
+ fiche(ctx, { entree }, cle) {
178
+ return ficheUneFois(ctx, entree, cle);
179
+ },
180
+ decouverte(ctx, { role, sujet, corps, composants }, cle) {
181
+ let id = cle ? decouverteDeLaCle(ctx, cle) : '';
182
+ if (typeof id !== 'string') {
183
+ return id;
184
+ }
185
+ if (!id) {
186
+ const r = spawnSync(
187
+ 'bash',
188
+ [
189
+ TICKET_SH,
190
+ ctx.ticket,
191
+ sujet,
192
+ composants,
193
+ cle ? `${corps}\n\n${marqueDeCle(cle)}` : corps,
194
+ 'decouverte',
195
+ ],
196
+ { cwd: ctx.racine, encoding: 'utf8', env: { ...process.env, [ACTEUR]: AUTEUR_DU_CIRCUIT } }
197
+ );
198
+ id = r.status === 0 ? r.stdout.trim().split('\n').at(-1) : '';
199
+ if (!id) {
200
+ return { status: r.status || 1, stdout: '', stderr: r.stderr ?? '' };
201
+ }
202
+ }
203
+ // Filed, its line among the sheets not written stops (a writing of the sheets).
204
+ return ficheUneFois(
205
+ ctx,
206
+ { date: new Date().toISOString(), role, decouverte: { id, sujet } },
207
+ cle
208
+ );
209
+ },
210
+ registre(_ctx, { ligne }, cle) {
211
+ try {
212
+ ecrireAuRegistre({ ...ligne, ...(cle ? { cle } : {}) });
213
+ return ok;
214
+ } catch (e) {
215
+ return echec(e.message);
216
+ }
217
+ },
218
+ plan(ctx, { titre, description }) {
219
+ const options = [
220
+ ...(titre === null ? [] : ['--title', titre]),
221
+ ...(description === null ? [] : ['-d', description]),
222
+ ];
223
+ return options.length ? ctx.bd('update', ctx.ticket, ...options) : ok;
224
+ },
225
+ bilan(ctx, { ticket, fin }, cle) {
226
+ let texte;
227
+ try {
228
+ texte = ecrireLeBilan(ctx.racine, ticket, fin ?? null);
229
+ } catch (e) {
230
+ return echec(e.message);
231
+ }
232
+ return commenterUneFois(
233
+ ctx,
234
+ { ticket, texte: `${PREFIXE}bilan : ${texte}`, auteur: AUTEUR_DU_CIRCUIT },
235
+ cle
236
+ );
237
+ },
238
+ // The line of the tri, written once its writings are: each discovery read now (its comments,
239
+ // its labels, its status), a writing absent named among those that failed, a ticket to reopen
240
+ // not open not counted, so that the line says what the tickets are.
241
+ 'resume-du-tri'(ctx, { ticket, debut, ecritures }, cle) {
242
+ const rouvertes = [];
243
+ const rates = [];
244
+ // The cause bd gave for a writing of <genre> at <decouverte> that failed (`ecrireLEffet`).
245
+ const echecs = lignes(ctx.fiches).filter(e => e.echec);
246
+ const cause = (genre, decouverte) =>
247
+ echecs.findLast(e => e.echec.genre === genre && e.echec.ticket === decouverte)?.echec.raison;
248
+ for (const { decouverte, verdict, etiquettes, rouvre } of ecritures) {
249
+ const ici = [];
250
+ const montre = lu(ctx.bd('show', decouverte, '--json'), `ticket ${decouverte}`);
251
+ const t = montre.valeur?.[0] ?? null;
252
+ const dits = lu(ctx.bd('comments', decouverte, '--json'), `commentaires de ${decouverte}`);
253
+ if (dits.echec) {
254
+ ici.push(`verdict (${premiereLigne(dits.echec.stderr)})`);
255
+ } else if (!(dits.valeur ?? []).some(c => String(c?.text ?? '').startsWith(verdict))) {
256
+ ici.push(`verdict (${cause('commentaire', decouverte) ?? 'absent'})`);
257
+ }
258
+ if (montre.echec) {
259
+ ici.push(`étiquette (${premiereLigne(montre.echec.stderr)})`);
260
+ } else if (!etiquettes.every(e => (t?.labels ?? []).includes(e))) {
261
+ ici.push(`étiquette (${cause('etiquettes', decouverte) ?? 'absente'})`);
262
+ }
263
+ if (rouvre) {
264
+ if (t?.status && t.status !== 'closed') {
265
+ rouvertes.push(decouverte);
266
+ } else {
267
+ const pourquoi = montre.echec
268
+ ? premiereLigne(montre.echec.stderr)
269
+ : (cause('reouverture', decouverte) ?? 'toujours fermée');
270
+ ici.push(`réouverture (${pourquoi})`);
271
+ }
272
+ }
273
+ if (ici.length) {
274
+ rates.push(`${decouverte} : ${ici.join(', ')}`);
275
+ }
276
+ }
277
+ const texte = `${debut} ; ${rouvertes.length ? `rouvertes sous a-valider : ${rouvertes.join(', ')}` : 'aucune rouverte'}${rates.length ? ` ; écritures en échec : ${rates.join(' ; ')}` : ''}.`;
278
+ return commenterUneFois(ctx, { ticket, texte, auteur: AUTEUR_DU_CIRCUIT }, cle);
279
+ },
280
+ etiquettes(ctx, { ticket, etiquettes }) {
281
+ return ctx.bd('update', ticket, ...etiquettes.flatMap(e => ['--add-label', e]));
282
+ },
283
+ reouverture(ctx, { ticket }) {
284
+ const r = ctx.bd('show', ticket, '--json');
285
+ const statut = lu(r, `ticket ${ticket}`).valeur?.[0]?.status ?? null;
286
+ return statut && statut !== 'closed' ? ok : ctx.bd('reopen', ticket);
287
+ },
288
+ };
289
+
290
+ /**
291
+ * The effect <effet> written for <ctx>, under the key <cle> when its sort takes one (`AVEC_CLE`;
292
+ * null plays it without, as an effect emitted outside an act): what its player returns,
293
+ * `{ status, stderr }`.
294
+ */
295
+ export function jouerLEffet(ctx, effet, cle) {
296
+ const joueur = JOUEURS[effet?.genre];
297
+ if (!joueur) {
298
+ throw new Error(`effet inconnu du circuit : ${effet?.genre}`);
299
+ }
300
+ return joueur(ctx, effet, AVEC_CLE.has(effet.genre) ? (cle ?? null) : null);
301
+ }
302
+
303
+ // The effects whose failure the circuit goes on past: what the line on the error output says is
304
+ // not written. Every other effect not written stops (the state, a line of the sheets, the plan, a
305
+ // question read).
306
+ const DIT_SANS_ARRETER = {
307
+ commentaire: e => `commentaire non écrit au ticket ${e.ticket}`,
308
+ decouverte: e => `découverte « ${e.sujet} » non consignée`,
309
+ registre: () => 'registre non écrit',
310
+ bilan: e => `bilan non écrit au ticket ${e.ticket}`,
311
+ etiquettes: e => `étiquettes non posées sur ${e.ticket}`,
312
+ 'resume-du-tri': e => `ligne du tri non écrite au ticket ${e.ticket}`,
313
+ reouverture: e => `${e.ticket} non rouvert`,
314
+ };
315
+
316
+ /**
317
+ * The effect <effet> written for <ctx> under the key <cle> (`jouerLEffet`), with one outcome,
318
+ * emitted outside an act (`emettre`) or played by an activity of the workflow: an effect the
319
+ * circuit goes on past (`DIT_SANS_ARRETER`) not written is said on the error output, its cause kept among
320
+ * the sheets of the ticket (`echec`, which the line of the tri reads), and its `{ status, stderr }`
321
+ * returned; any other not written throws. Under an activity Temporal tries again
322
+ * (<reessayer>, before its last attempt), an effect not written throws, so that a passing
323
+ * failure is tried again, and it is said at the last attempt only.
324
+ */
325
+ export function ecrireLEffet(ctx, effet, cle, { reessayer = false } = {}) {
326
+ const r = jouerLEffet(ctx, effet, cle);
327
+ if (r.status === 0) {
328
+ return r;
329
+ }
330
+ const raison = String(r.stderr ?? '').trim() || `code ${r.status}`;
331
+ const dit = DIT_SANS_ARRETER[effet.genre];
332
+ if (!dit) {
333
+ throw new Error(`effet ${effet.genre} non écrit : ${raison}`);
334
+ }
335
+ if (reessayer) {
336
+ throw new EffetNonEcrit(`effet ${effet.genre} non écrit : ${raison}`);
337
+ }
338
+ process.stderr.write(`⚠️ ${dit(effet)} : ${raison}\n`);
339
+ // Its cause kept among the sheets of the ticket, which the line of the tri names.
340
+ if (ctx.fiches) {
341
+ ficheUneFois(
342
+ ctx,
343
+ {
344
+ date: new Date().toISOString(),
345
+ role: AUTEUR_DU_CIRCUIT,
346
+ echec: { genre: effet.genre, ticket: effet.ticket ?? null, raison: premiereLigne(raison) },
347
+ },
348
+ null
349
+ );
350
+ }
351
+ return r;
352
+ }