@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
@@ -0,0 +1,58 @@
1
+ // The rule of the queue of the tickets of a project: the tickets the owner validated (label
2
+ // `circuit`) whose dependencies are all closed start by themselves, by Beads priority, as Zuul and
3
+ // the merge queues start a change once what it depends on has merged. The queue of the tickets
4
+ // under Temporal (src/temporal/tickets/) reads the tickets and applies this rule.
5
+ //
6
+ // - A ticket starts when it is open, labelled `circuit`, with no circuit already on it, and when
7
+ // every dependency of the type `blocks` is closed: a dependency out of the list read (an unknown
8
+ // ticket) holds it back, a `parent-child` or `related` link does not.
9
+ // - The order is the Beads priority (0 first), then the creation (the oldest first).
10
+ // - A ticket whose dependency is open stays: the board says « attend <ticket> » (scripts/tableau.mjs).
11
+ import { spawnSync } from 'node:child_process';
12
+
13
+ /**
14
+ * The tickets of <tous> that start now, in the order they start.
15
+ * @param {Array<{ id: string, status: string, priority?: number, labels?: string[],
16
+ * created_at?: string, dependencies?: Array<{ type: string, depends_on_id: string }> }>} tous
17
+ * every ticket of the project, the closed ones too
18
+ * @param {{ enCours?: Set<string> }} [o] `enCours`, the tickets whose circuit already runs
19
+ * @returns {typeof tous}
20
+ */
21
+ export function ticketsAPartir(tous, { enCours = new Set() } = {}) {
22
+ const fermes = new Set(tous.filter(t => t.status === 'closed').map(t => t.id));
23
+ return tous
24
+ .filter(
25
+ t =>
26
+ t.status === 'open' &&
27
+ (t.labels ?? []).includes('circuit') &&
28
+ !enCours.has(t.id) &&
29
+ (t.dependencies ?? []).every(d => d.type !== 'blocks' || fermes.has(d.depends_on_id))
30
+ )
31
+ .sort(
32
+ (a, b) =>
33
+ (a.priority ?? 2) - (b.priority ?? 2) ||
34
+ Date.parse(a.created_at ?? '') - Date.parse(b.created_at ?? '') ||
35
+ a.id.localeCompare(b.id, 'en')
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Every ticket of the project at <racine>, the closed ones too, as Beads gives them; a Beads that
41
+ * fails or a list that does not parse throws, its reason named (`bd list`), never an empty list.
42
+ */
43
+ export function lireLesTickets(racine) {
44
+ const r = spawnSync('bd', ['list', '--all', '--limit', '0', '--json'], {
45
+ cwd: racine,
46
+ encoding: 'utf8',
47
+ maxBuffer: 256 * 1024 * 1024,
48
+ });
49
+ if (r.status !== 0) {
50
+ const raison = `${r.stderr ?? ''}`.trim() || r.error?.message || `code ${r.status}`;
51
+ throw new Error(`les tickets ne se lisent pas (bd list) : ${raison}`);
52
+ }
53
+ try {
54
+ return JSON.parse(r.stdout);
55
+ } catch (e) {
56
+ throw new Error(`les tickets ne se lisent pas (bd list) : ${e.message}`);
57
+ }
58
+ }
@@ -0,0 +1,201 @@
1
+ #!/usr/bin/env node
2
+ // The guard of the flows of the CI: each flow declares the packages it exercises, and the reviewer
3
+ // reads it when a lot touches one of them, as a CODEOWNERS file names who reads a path.
4
+ //
5
+ // npx grillhouse flux-des-paquets (one of the frame's guards, scripts/gardes-du-cadre.mjs)
6
+ //
7
+ // - The key `grillhouse.flux` of the root package.json declares them, read from the main tree of
8
+ // the repository (`fluxDe`), as `grillhouse.engendres` and `grillhouse.outils` are:
9
+ // `{ ".github/workflows/<flux>.yml": ["<paquet>", …] }`, each package named by its name in the
10
+ // graph (the `name` of its package.json, whatever its language: a crate and a project of Python
11
+ // have one, scripts/paquets.mjs).
12
+ // - The key is absent, null or an object; each key is a path under .github/workflows, each value a
13
+ // list of strings. Every fault is named with its key; a faulty key gives no flow.
14
+ // - Refused, each finding named: a file of .github/workflows (.yml, .yaml) the key does not
15
+ // declare, a declared flow whose file does not exist, a package name the graph does not carry.
16
+ // A project without .github/workflows and without the key has nothing to say.
17
+ // - A lot touches a package when one of its files changes under the folder of the package; neither
18
+ // its dependents nor its dependencies count, the flow declares each package it exercises.
19
+ // `consigneDesFlux` gives the reviewer's line per flow the lot touches (the flow itself, or a
20
+ // package it declares), « aucun » for none.
21
+ // - Each finding is written in SARIF under the guard's name, and on the error stream after ⛔; the
22
+ // exit code is 1 when there is one, 0 otherwise.
23
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
24
+ import path from 'node:path';
25
+ import { fileURLToPath, pathToFileURL } from 'node:url';
26
+ import { arbrePrincipal } from './outils-cles.mjs';
27
+ import { paquets } from './paquets.mjs';
28
+ import { ecrireSarif } from './resultats.mjs';
29
+
30
+ /** This script. */
31
+ export const SCRIPT = fileURLToPath(import.meta.url);
32
+ /** The name its findings carry. */
33
+ export const GARDE = 'flux-des-paquets';
34
+
35
+ const DOSSIER = '.github/workflows';
36
+ const CLE = 'grillhouse.flux';
37
+
38
+ /**
39
+ * The flows that the package.json <pkg> declares (`grillhouse.flux`): `flux`, each `{ fichier,
40
+ * paquets }`, and `fautes`, each fault named with its key (no flow with a fault).
41
+ * @param {Record<string, any> | null | undefined} pkg
42
+ * @returns {{ flux: { fichier: string, paquets: string[] }[], fautes: string[] }}
43
+ */
44
+ export function lireFlux(pkg) {
45
+ const f = pkg?.grillhouse?.flux;
46
+ if (f === undefined || f === null) {
47
+ return { flux: [], fautes: [] };
48
+ }
49
+ if (typeof f !== 'object' || Array.isArray(f)) {
50
+ return {
51
+ flux: [],
52
+ fautes: [
53
+ `la clé ${CLE} vaut ${JSON.stringify(f)}, pas un objet { "${DOSSIER}/<flux>.yml": ["<paquet>", …] }.`,
54
+ ],
55
+ };
56
+ }
57
+ const fautes = [];
58
+ const flux = [];
59
+ for (const [fichier, liste] of Object.entries(f)) {
60
+ const cle = `${CLE}.${fichier}`;
61
+ const sain = fichier.startsWith(`${DOSSIER}/`) && !fichier.split('/').includes('..');
62
+ if (!sain) {
63
+ fautes.push(`${cle} : la clé n'est pas un fichier sous ${DOSSIER}/.`);
64
+ continue;
65
+ }
66
+ if (!Array.isArray(liste) || liste.some(p => typeof p !== 'string')) {
67
+ fautes.push(`${cle} vaut ${JSON.stringify(liste)}, pas une liste de noms de paquets.`);
68
+ continue;
69
+ }
70
+ flux.push({ fichier, paquets: liste });
71
+ }
72
+ return { flux: fautes.length ? [] : flux, fautes };
73
+ }
74
+
75
+ const lireJson = f => {
76
+ try {
77
+ return JSON.parse(readFileSync(f, 'utf8'));
78
+ } catch {
79
+ return null;
80
+ }
81
+ };
82
+
83
+ /**
84
+ * The flows of the project that holds <dir>, from the package.json of its main tree, never of a
85
+ * copy; none without one.
86
+ * @param {string} dir a directory of the project: its main tree or a copy
87
+ * @throws {Error} the faults of the key, one per line
88
+ */
89
+ export function fluxDe(dir) {
90
+ const f = path.join(arbrePrincipal(dir), 'package.json');
91
+ if (!existsSync(f)) {
92
+ return [];
93
+ }
94
+ const { flux, fautes } = lireFlux(lireJson(f));
95
+ if (fautes.length) {
96
+ throw new Error(fautes.join('\n'));
97
+ }
98
+ return flux;
99
+ }
100
+
101
+ // The workflow files of <racine>: the .yml and .yaml under .github/workflows, from the root.
102
+ function fichiersDeFlux(racine) {
103
+ const d = path.join(racine, DOSSIER);
104
+ if (!existsSync(d)) {
105
+ return [];
106
+ }
107
+ return readdirSync(d, { withFileTypes: true })
108
+ .filter(e => e.isFile() && /\.ya?ml$/.test(e.name))
109
+ .map(e => `${DOSSIER}/${e.name}`)
110
+ .sort();
111
+ }
112
+
113
+ /**
114
+ * The findings of the guard on the project at <racine>: `{ fichier, message }`, none when each
115
+ * workflow is declared with packages the graph carries.
116
+ * @param {string} racine the root of the project
117
+ */
118
+ export function constats(racine) {
119
+ const pkg = lireJson(path.join(racine, 'package.json'));
120
+ const { flux, fautes } = lireFlux(pkg);
121
+ const out = fautes.map(message => ({ fichier: 'package.json', message }));
122
+ if (fautes.length) {
123
+ return out;
124
+ }
125
+ const connus = new Set(paquets(racine).map(p => p.pkg.name));
126
+ const declares = new Set(flux.map(f => f.fichier));
127
+ for (const f of fichiersDeFlux(racine)) {
128
+ if (!declares.has(f)) {
129
+ out.push({
130
+ fichier: f,
131
+ message: `${f} : flux de la CI sans entrée dans ${CLE} du package.json ; chaque flux déclare les paquets qu'il exerce, le relecteur le lit.`,
132
+ });
133
+ }
134
+ }
135
+ for (const { fichier, paquets: noms } of flux) {
136
+ if (!existsSync(path.join(racine, fichier))) {
137
+ out.push({
138
+ fichier: 'package.json',
139
+ message: `${fichier} : déclaré dans ${CLE}, mais le fichier n'existe pas.`,
140
+ });
141
+ }
142
+ for (const n of noms.filter(x => !connus.has(x))) {
143
+ out.push({
144
+ fichier: 'package.json',
145
+ message: `${fichier} : le paquet ${n} que ${CLE} déclare est inconnu du graphe ; un paquet s'écrit par son nom (le « name » de son package.json), non par son dossier.`,
146
+ });
147
+ }
148
+ }
149
+ return out;
150
+ }
151
+
152
+ /**
153
+ * The reviewer's lines for the lot of <fichiers> (from the root): one `- lis <flux> : <raison>` per
154
+ * flow it touches, « aucun … » for none.
155
+ * @param {string} racine the root of the project
156
+ * @param {string[]} fichiers
157
+ */
158
+ export function consigneDesFlux(racine, fichiers) {
159
+ let flux;
160
+ try {
161
+ flux = fluxDe(racine);
162
+ } catch (e) {
163
+ return `aucun : la clé ${CLE} est refusée (${e.message.split('\n')[0]}).`;
164
+ }
165
+ const dossiers = new Map(
166
+ paquets(racine).map(p => [p.pkg.name, p.dossier.split(path.sep).join('/')])
167
+ );
168
+ const sous = (f, d) => d === '.' || f.startsWith(`${d}/`);
169
+ const lignes = [];
170
+ for (const { fichier, paquets: noms } of flux) {
171
+ const raisons = [];
172
+ if (fichiers.includes(fichier)) {
173
+ raisons.push('le lot change le flux');
174
+ }
175
+ for (const n of noms) {
176
+ const d = dossiers.get(n);
177
+ if (d !== undefined && fichiers.some(f => sous(f, d))) {
178
+ raisons.push(`le lot touche le paquet ${n}`);
179
+ }
180
+ }
181
+ if (raisons.length) {
182
+ lignes.push(`- lis ${fichier} : ${raisons.join(' ; ')}`);
183
+ }
184
+ }
185
+ return lignes.length ? lignes.join('\n') : 'aucun : le lot ne touche aucun flux de la CI.';
186
+ }
187
+
188
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
189
+ const racine = process.cwd();
190
+ let refus;
191
+ try {
192
+ refus = constats(racine);
193
+ } catch (e) {
194
+ refus = [{ message: e.message.replace(/^⛔ /, '') }];
195
+ }
196
+ for (const r of refus) {
197
+ process.stderr.write(`⛔ ${r.message}\n`);
198
+ }
199
+ ecrireSarif({ garde: GARDE, racine, constats: refus });
200
+ process.exitCode = refus.length ? 1 : 0;
201
+ }
@@ -4,7 +4,10 @@
4
4
  // npx grillhouse gardes-du-cadre (npm run grillhouse:gardes, a task of Turborepo)
5
5
  //
6
6
  // - The guards are the core's, the languages of the packages first (./langages-des-paquets.mjs:
7
- // each package follows the language the architecture declares for it), then those of the
7
+ // each package follows the language the architecture declares for it; ./dependances-internes.mjs:
8
+ // the package.json of a crate or of a project of Python names the internal packages its
9
+ // manifest links; ./flux-des-paquets.mjs: each flow of the CI declares the packages it exercises),
10
+ // then those of the
8
11
  // modules of the project's languages (`gardes`, scripts/jointure.d.ts, scripts/langages.mjs),
9
12
  // each module's in their order, the modules in the order of the declaration.
10
13
  // - Each guard is a script of the package, and plays in the working directory, under the environment of the run
@@ -20,14 +23,21 @@
20
23
  import { spawnSync } from 'node:child_process';
21
24
  import path from 'node:path';
22
25
  import { pathToFileURL } from 'node:url';
26
+ import { SCRIPT as DEPENDANCES_INTERNES } from './dependances-internes.mjs';
23
27
  import { SCRIPT as LANGAGES_DES_PAQUETS } from './langages-des-paquets.mjs';
28
+ import { SCRIPT as FLUX_DES_PAQUETS } from './flux-des-paquets.mjs';
24
29
  import { langageDe } from './langages.mjs';
25
30
  import { A_ELAGUER, ecrireSarif, lireSarif, RESULTATS } from './resultats.mjs';
26
31
 
27
32
  // The guards of the frame in the repository at <racine>, each its script and its arguments, in
28
33
  // the order they play: the core's, then the languages'.
29
34
  export function gardesDuCadre(racine) {
30
- return [[LANGAGES_DES_PAQUETS], ...langageDe(racine).gardes(racine)];
35
+ return [
36
+ [LANGAGES_DES_PAQUETS],
37
+ [DEPENDANCES_INTERNES],
38
+ [FLUX_DES_PAQUETS],
39
+ ...langageDe(racine).gardes(racine),
40
+ ];
31
41
  }
32
42
 
33
43
  // The name of each guard of the frame, as its findings carry it: its script's, without extension.
@@ -49,7 +59,9 @@ export function jouerLesGardes({
49
59
  for (const garde of gardes) {
50
60
  const avant = env[RESULTATS] ? nombre() : 0;
51
61
  const r = spawnSync(process.execPath, garde, { cwd: racine, env, stdio: 'inherit' });
52
- if (r.status === 0) continue;
62
+ if (r.status === 0) {
63
+ continue;
64
+ }
53
65
  const code = `code ${r.status ?? r.signal}`;
54
66
  rouges.push(`${libelle(garde)} (${code})`);
55
67
  if (env[RESULTATS] && nombre() === avant) {
@@ -61,8 +73,12 @@ export function jouerLesGardes({
61
73
  });
62
74
  }
63
75
  }
64
- if (rouges.length === 0) return 0;
65
- for (const r of rouges) dire(`⛔ garde rouge : ${r}`);
76
+ if (rouges.length === 0) {
77
+ return 0;
78
+ }
79
+ for (const r of rouges) {
80
+ dire(`⛔ garde rouge : ${r}`);
81
+ }
66
82
  return 1;
67
83
  }
68
84
 
package/scripts/init.mjs CHANGED
@@ -55,8 +55,11 @@ function copierLeGabarit(projet) {
55
55
  const renommer = dossier => {
56
56
  for (const e of readdirSync(dossier, { withFileTypes: true })) {
57
57
  const f = path.join(dossier, e.name);
58
- if (e.isDirectory()) renommer(f);
59
- else if (Object.hasOwn(RENOMMES, e.name)) renameSync(f, path.join(dossier, RENOMMES[e.name]));
58
+ if (e.isDirectory()) {
59
+ renommer(f);
60
+ } else if (Object.hasOwn(RENOMMES, e.name)) {
61
+ renameSync(f, path.join(dossier, RENOMMES[e.name]));
62
+ }
60
63
  }
61
64
  };
62
65
  renommer(projet);
@@ -105,11 +108,15 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
105
108
  } else {
106
109
  try {
107
110
  const lignes = initialiser(dossier, prefixe);
108
- for (const l of lignes) process.stderr.write(`${l}\n`);
111
+ for (const l of lignes) {
112
+ process.stderr.write(`${l}\n`);
113
+ }
109
114
  process.stdout.write(
110
115
  `Projet créé dans ${dossier}. Ouvre Claude Code dans ce dossier : la première séance propose le grill d'initialisation.\n`
111
116
  );
112
- if (lignes.length > 0) process.exitCode = 1;
117
+ if (lignes.length > 0) {
118
+ process.exitCode = 1;
119
+ }
113
120
  } catch (e) {
114
121
  process.stderr.write(`⛔ ${e.message}\n`);
115
122
  process.exitCode = 1;