@roomi-fields/grillhouse 0.29.0 → 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 (222) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +739 -0
  3. package/bin/grillhouse.mjs +79 -18
  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/docs/agents/issue-tracker.md +1 -1
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +24 -0
  9. package/dist/temporal/acte.d.ts +24 -0
  10. package/dist/temporal/acte.js +139 -0
  11. package/dist/temporal/acte.js.map +1 -0
  12. package/dist/temporal/attributs.d.ts +6 -0
  13. package/dist/temporal/attributs.js +15 -0
  14. package/dist/temporal/attributs.js.map +1 -0
  15. package/dist/temporal/circuit/activites.d.ts +13 -0
  16. package/dist/temporal/circuit/activites.js +33 -0
  17. package/dist/temporal/circuit/activites.js.map +1 -0
  18. package/dist/temporal/circuit/client.d.ts +72 -0
  19. package/dist/temporal/circuit/client.js +247 -0
  20. package/dist/temporal/circuit/client.js.map +1 -0
  21. package/dist/temporal/circuit/commande.d.ts +2 -0
  22. package/dist/temporal/circuit/commande.js +238 -0
  23. package/dist/temporal/circuit/commande.js.map +1 -0
  24. package/dist/temporal/circuit/contrat.d.ts +305 -0
  25. package/dist/temporal/circuit/contrat.js +24 -0
  26. package/dist/temporal/circuit/contrat.js.map +1 -0
  27. package/dist/temporal/circuit/deroule.d.ts +3 -0
  28. package/dist/temporal/circuit/deroule.js +540 -0
  29. package/dist/temporal/circuit/deroule.js.map +1 -0
  30. package/dist/temporal/client.d.ts +47 -0
  31. package/dist/temporal/client.js +69 -0
  32. package/dist/temporal/client.js.map +1 -0
  33. package/dist/temporal/commande.d.ts +2 -0
  34. package/dist/temporal/commande.js +95 -0
  35. package/dist/temporal/commande.js.map +1 -0
  36. package/dist/temporal/deroules.d.ts +5 -0
  37. package/dist/temporal/deroules.js +10 -0
  38. package/dist/temporal/deroules.js.map +1 -0
  39. package/dist/temporal/etat.d.ts +33 -0
  40. package/dist/temporal/etat.js +59 -0
  41. package/dist/temporal/etat.js.map +1 -0
  42. package/dist/temporal/file/activites.d.ts +10 -0
  43. package/dist/temporal/file/activites.js +25 -0
  44. package/dist/temporal/file/activites.js.map +1 -0
  45. package/dist/temporal/file/client.d.ts +4 -0
  46. package/dist/temporal/file/client.js +6 -0
  47. package/dist/temporal/file/client.js.map +1 -0
  48. package/dist/temporal/file/contrat.d.ts +158 -0
  49. package/dist/temporal/file/contrat.js +14 -0
  50. package/dist/temporal/file/contrat.js.map +1 -0
  51. package/dist/temporal/file/deroule.d.ts +15 -0
  52. package/dist/temporal/file/deroule.js +235 -0
  53. package/dist/temporal/file/deroule.js.map +1 -0
  54. package/dist/temporal/installation.d.ts +124 -0
  55. package/dist/temporal/installation.js +408 -0
  56. package/dist/temporal/installation.js.map +1 -0
  57. package/dist/temporal/places/activites.d.ts +8 -0
  58. package/dist/temporal/places/activites.js +13 -0
  59. package/dist/temporal/places/activites.js.map +1 -0
  60. package/dist/temporal/places/client.d.ts +28 -0
  61. package/dist/temporal/places/client.js +64 -0
  62. package/dist/temporal/places/client.js.map +1 -0
  63. package/dist/temporal/places/contrat.d.ts +106 -0
  64. package/dist/temporal/places/contrat.js +21 -0
  65. package/dist/temporal/places/contrat.js.map +1 -0
  66. package/dist/temporal/places/deroule.d.ts +3 -0
  67. package/dist/temporal/places/deroule.js +198 -0
  68. package/dist/temporal/places/deroule.js.map +1 -0
  69. package/dist/temporal/sonde/activites.d.ts +6 -0
  70. package/dist/temporal/sonde/activites.js +52 -0
  71. package/dist/temporal/sonde/activites.js.map +1 -0
  72. package/dist/temporal/sonde/contrat.d.ts +35 -0
  73. package/dist/temporal/sonde/contrat.js +10 -0
  74. package/dist/temporal/sonde/contrat.js.map +1 -0
  75. package/dist/temporal/sonde/deroule.d.ts +3 -0
  76. package/dist/temporal/sonde/deroule.js +39 -0
  77. package/dist/temporal/sonde/deroule.js.map +1 -0
  78. package/dist/temporal/tickets/activites.d.ts +7 -0
  79. package/dist/temporal/tickets/activites.js +81 -0
  80. package/dist/temporal/tickets/activites.js.map +1 -0
  81. package/dist/temporal/tickets/client.d.ts +10 -0
  82. package/dist/temporal/tickets/client.js +31 -0
  83. package/dist/temporal/tickets/client.js.map +1 -0
  84. package/dist/temporal/tickets/contrat.d.ts +56 -0
  85. package/dist/temporal/tickets/contrat.js +13 -0
  86. package/dist/temporal/tickets/contrat.js.map +1 -0
  87. package/dist/temporal/tickets/deroule.d.ts +3 -0
  88. package/dist/temporal/tickets/deroule.js +94 -0
  89. package/dist/temporal/tickets/deroule.js.map +1 -0
  90. package/dist/temporal/travailleur.d.ts +2 -0
  91. package/dist/temporal/travailleur.js +69 -0
  92. package/dist/temporal/travailleur.js.map +1 -0
  93. package/docs/ARCHITECTURE.md +609 -80
  94. package/docs/CADRE.md +17 -0
  95. package/docs/INTERFACE.md +134 -42
  96. package/hooks/crochet.mjs +19 -2
  97. package/hooks/hooks.json +11 -0
  98. package/package.json +16 -4
  99. package/scripts/activites.mjs +2182 -0
  100. package/scripts/aiguillage.d.mts +37 -0
  101. package/scripts/aiguillage.mjs +7 -3
  102. package/scripts/avancement.mjs +128 -16
  103. package/scripts/bilan.mjs +37 -19
  104. package/scripts/cadre.mjs +11 -2
  105. package/scripts/circuit.mjs +881 -4059
  106. package/scripts/circuits-cles.d.mts +4 -0
  107. package/scripts/circuits-cles.mjs +21 -0
  108. package/scripts/circuits-du-serveur.mjs +105 -0
  109. package/scripts/codes-de-sortie.mjs +9 -0
  110. package/scripts/commandes-composees.mjs +45 -41
  111. package/scripts/commandes-du-path.d.mts +7 -0
  112. package/scripts/commandes-du-path.mjs +25 -0
  113. package/scripts/composition-des-langages.mjs +16 -12
  114. package/scripts/conformite.mjs +6 -13
  115. package/scripts/copies-finies.mjs +52 -47
  116. package/scripts/depart-du-ticket.d.mts +53 -0
  117. package/scripts/depart-du-ticket.mjs +124 -0
  118. package/scripts/dependances-internes.mjs +115 -0
  119. package/scripts/dernier-vert.mjs +7 -15
  120. package/scripts/donnees-cles.mjs +228 -0
  121. package/scripts/droits.mjs +11 -1
  122. package/scripts/effets.mjs +352 -0
  123. package/scripts/enveloppe/enveloppe.mjs +119 -8
  124. package/scripts/enveloppe/lancer.sh +14 -18
  125. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  126. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -1
  127. package/scripts/etapes.mjs +5 -2
  128. package/scripts/faits-du-circuit.mjs +493 -0
  129. package/scripts/file-des-tickets.d.mts +21 -0
  130. package/scripts/file-des-tickets.mjs +58 -0
  131. package/scripts/flux-des-paquets.mjs +187 -0
  132. package/scripts/gardes-du-cadre.mjs +12 -2
  133. package/scripts/integration/file.mjs +475 -420
  134. package/scripts/integration/integrer.mjs +17 -19
  135. package/scripts/integration/rejeu.mjs +19 -4
  136. package/scripts/jointure.d.ts +145 -27
  137. package/scripts/langages/cargo/commandes.mjs +289 -109
  138. package/scripts/langages/cargo/composants.mjs +130 -34
  139. package/scripts/langages/cargo/exemples.mjs +12 -21
  140. package/scripts/langages/cargo/index.mjs +18 -8
  141. package/scripts/langages/cargo/sccache.mjs +8 -14
  142. package/scripts/langages/python/commandes.mjs +216 -100
  143. package/scripts/langages/python/composants.mjs +53 -21
  144. package/scripts/langages/python/exemples.mjs +6 -16
  145. package/scripts/langages/python/index.mjs +24 -8
  146. package/scripts/langages/python/lot.mjs +1 -36
  147. package/scripts/langages/typescript/construire.mjs +6 -163
  148. package/scripts/langages/typescript/exemples.mjs +3 -11
  149. package/scripts/langages/typescript/frontieres.mjs +1 -1
  150. package/scripts/langages/typescript/index.mjs +43 -61
  151. package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
  152. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  153. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
  154. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  155. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  156. package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
  157. package/scripts/langages/typescript/tests-de-nuit.mjs +12 -9
  158. package/scripts/langages/typescript/tests.mjs +17 -8
  159. package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
  160. package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
  161. package/scripts/langages/typescript/verdict.mjs +1 -1
  162. package/scripts/langages/typescript/verifier.mjs +31 -11
  163. package/scripts/langages/typescript/vitest-config/base.mjs +22 -1
  164. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  165. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  166. package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
  167. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  168. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
  169. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +49 -63
  170. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +3 -0
  171. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  172. package/scripts/mesure/pression.mjs +3 -3
  173. package/scripts/mesure-de-la-machine.d.mts +21 -0
  174. package/scripts/mesure-de-la-machine.mjs +76 -0
  175. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
  176. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
  177. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  178. package/scripts/migrations.mjs +5 -0
  179. package/scripts/nuit.sh +10 -3
  180. package/scripts/outils-cles.d.mts +24 -0
  181. package/scripts/outils-cles.mjs +0 -1
  182. package/scripts/paquet-npm.mjs +147 -0
  183. package/scripts/paquet.mjs +73 -4
  184. package/scripts/paquets.mjs +34 -6
  185. package/scripts/passe-de-la-machine.mjs +66 -0
  186. package/scripts/places-de-la-machine.mjs +360 -0
  187. package/scripts/places-du-serveur.mjs +170 -0
  188. package/scripts/prefixe-des-tickets.mjs +68 -0
  189. package/scripts/preparation.mjs +10 -3
  190. package/scripts/registre.mjs +3 -2
  191. package/scripts/regles-des-places.d.mts +36 -0
  192. package/scripts/regles-des-places.mjs +70 -0
  193. package/scripts/reponses-du-circuit.d.mts +6 -0
  194. package/scripts/reponses-du-circuit.mjs +28 -0
  195. package/scripts/resultats.mjs +7 -9
  196. package/scripts/retirer-les-copies-finies.mjs +25 -0
  197. package/scripts/sans-reponse.d.mts +4 -0
  198. package/scripts/sans-reponse.mjs +13 -0
  199. package/scripts/seances.mjs +918 -0
  200. package/scripts/services-du-noyau.mjs +26 -8
  201. package/scripts/session-start.sh +2 -2
  202. package/scripts/sortie.mjs +3 -3
  203. package/scripts/sous-commandes.mjs +38 -9
  204. package/scripts/style-a-l-ecriture.mjs +229 -0
  205. package/scripts/superviseur.mjs +122 -111
  206. package/scripts/tableau.mjs +148 -110
  207. package/scripts/taches-du-graphe.mjs +328 -0
  208. package/scripts/ticket-du-circuit.mjs +206 -0
  209. package/scripts/transitions.d.mts +148 -0
  210. package/scripts/transitions.mjs +901 -0
  211. package/scripts/verrou-de-fichier.mjs +2 -2
  212. package/scripts/verrou-de-machine.mjs +28 -13
  213. package/skills/explorateur/SKILL.md +2 -1
  214. package/skills/pitmaster/SKILL.md +17 -18
  215. package/skills/pitmaster/references/consigne-agent.md +5 -1
  216. package/skills/release/SKILL.md +3 -3
  217. package/skills/relecteur/SKILL.md +4 -2
  218. package/skills/testwriter/SKILL.md +36 -24
  219. package/scripts/demon.mjs +0 -251
  220. package/scripts/integration/file-attente.mjs +0 -61
  221. package/scripts/langages/cargo/touches.mjs +0 -93
  222. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -0,0 +1,53 @@
1
+ // The types of ./depart-du-ticket.mjs, for the frame's TypeScript (src/temporal/circuit/commande.ts).
2
+
3
+ /** A component of the repository, as `composantsDe` lists it. */
4
+ export interface Composant {
5
+ dossier: string;
6
+ pkg: { name?: string };
7
+ }
8
+
9
+ /** A ticket as Beads shows it. */
10
+ export interface TicketDeBeads {
11
+ id?: string;
12
+ title?: string;
13
+ description?: string;
14
+ issue_type?: string;
15
+ [champ: string]: unknown;
16
+ }
17
+
18
+ /** A ticket a circuit cannot start on, by its reason. */
19
+ export class DepartRefuse extends Error {}
20
+
21
+ /** The directory of the component <nom> of a title among <liste>; or a refusal. */
22
+ export function resoudreComposant(liste: Composant[], base: string, nom: string): string;
23
+
24
+ /** The ticket <id> as `bd show --json` gives it in <sortie>, refused without its architecture. */
25
+ export function ticketAuDepart(
26
+ id: string,
27
+ sortie: string,
28
+ options?: { arreter?: boolean }
29
+ ): TicketDeBeads;
30
+
31
+ /** The subject and the plan of the title <titre> of the ticket <id>; or a refusal. */
32
+ export function leTitre(
33
+ id: string,
34
+ titre: string | undefined,
35
+ resoudre: (nom: string) => string
36
+ ): { sujet: string; plan: string[] };
37
+
38
+ /** The ticket <id> of the repository at <racine>, read before any work; or a refusal. */
39
+ export function ticketAuLancement(
40
+ racine: string,
41
+ id: string,
42
+ options?: {
43
+ arreter?: boolean;
44
+ bd?: ((...a: string[]) => { status: number | null; stdout: string; stderr: string }) | null;
45
+ }
46
+ ): {
47
+ ticket: TicketDeBeads;
48
+ base: string;
49
+ liste: Composant[];
50
+ resoudre: (nom: string) => string;
51
+ sujet: string;
52
+ plan: string[];
53
+ };
@@ -0,0 +1,124 @@
1
+ // The ticket a circuit starts on, read before any work, as a CI validates its configuration before
2
+ // it runs its jobs: `npx grillhouse circuit` refuses at the door what the circuit could not run
3
+ // (src/temporal/circuit/commande.ts), and the opening of each act of the circuit reads its plan
4
+ // the same way (scripts/circuit.mjs `contexte`).
5
+ //
6
+ // - The ticket is read by `bd show <id> --json` in the main tree; one Beads cannot show is refused.
7
+ // - Its description holds a « ## Architecture » section, by the rule of the developer's lock
8
+ // (`sansArchitecture` of ./verrous/verrou.mjs): the code waits for the architecture. The
9
+ // supervisor's stop (`--arreter`) reads neither it nor the title: it does not depend on the
10
+ // ticket's content, as GitLab cancels a pipeline whatever its configuration; its plan is empty.
11
+ // - Its title names its plan after its last « — », separated by commas: each one a path
12
+ // (`packages/<nom>`, or `.`), or the name of a package, which becomes its directory, read in the
13
+ // ticket's copy when it exists, else in the main tree (`composantsDe`). A title without it, and
14
+ // a component that names neither, are refused by their name. An act after the opening is given
15
+ // the plan its workflow holds (<plan>) and reads only the subject of the title: the integration
16
+ // removes the ticket's copy while the circuit still runs, and a component the lot creates is in
17
+ // neither tree then.
18
+ // Each refusal is a `DepartRefuse`, its reason its message.
19
+ import { spawnSync } from 'node:child_process';
20
+ import { existsSync } from 'node:fs';
21
+ import path from 'node:path';
22
+ import { composantsDe } from './ticket-du-circuit.mjs';
23
+ import { sansArchitecture } from './verrous/verrou.mjs';
24
+
25
+ /** A ticket a circuit cannot start on, by its reason. */
26
+ export class DepartRefuse extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = 'DepartRefuse';
30
+ }
31
+ }
32
+
33
+ /**
34
+ * The directory of the component <nom> of a title among <liste> (`composantsDe` of the repository
35
+ * at <base>): `.` itself; a component by its path or its name; else a path of the repository; or a
36
+ * refusal.
37
+ */
38
+ export function resoudreComposant(liste, base, nom) {
39
+ const brut = path.normalize(nom);
40
+ const norme = brut.endsWith('/') ? brut.slice(0, -1) : brut;
41
+ if (norme === '.') {
42
+ return '.';
43
+ }
44
+ if (liste.some(p => p.dossier === norme)) {
45
+ return norme;
46
+ }
47
+ const parNom = liste.find(p => p.pkg.name === nom);
48
+ if (parNom) {
49
+ return parNom.dossier;
50
+ }
51
+ if (!norme.startsWith('..') && existsSync(path.join(base, norme))) {
52
+ return norme;
53
+ }
54
+ throw new DepartRefuse(
55
+ `le composant « ${nom} » du titre ne nomme ni un paquet ni un chemin du dépôt.`
56
+ );
57
+ }
58
+
59
+ /**
60
+ * The ticket <id> as `bd show --json` gives it in <sortie>, refused when its description holds no
61
+ * « ## Architecture » section, unless the call is the supervisor's stop (<arreter>).
62
+ */
63
+ export function ticketAuDepart(id, sortie, { arreter = false } = {}) {
64
+ const t = JSON.parse(sortie)[0];
65
+ const refus = arreter ? null : sansArchitecture(id, t?.description);
66
+ if (refus) {
67
+ throw new DepartRefuse(refus);
68
+ }
69
+ return t;
70
+ }
71
+
72
+ // The subject of the title cut at its « — » into <parts>: what stands between the number and the
73
+ // components, or the first part of a title of two.
74
+ const sujetDe = parts => (parts.length > 2 ? parts.slice(1, -1).join(' — ') : parts[0]);
75
+
76
+ /**
77
+ * The subject and the plan of the title <titre> of the ticket <id>, « numéro — sujet —
78
+ * composants », each component resolved by <resoudre>; or a refusal.
79
+ */
80
+ export function leTitre(id, titre, resoudre) {
81
+ const parts = String(titre ?? '').split(' — ');
82
+ if (parts.length < 2) {
83
+ throw new DepartRefuse(`le titre de ${id} ne nomme pas ses composants.`);
84
+ }
85
+ return {
86
+ sujet: sujetDe(parts),
87
+ plan: parts
88
+ .at(-1)
89
+ .split(',')
90
+ .map(c => c.trim())
91
+ .filter(Boolean)
92
+ .map(resoudre),
93
+ };
94
+ }
95
+
96
+ /**
97
+ * The ticket <id> of the repository whose main tree is <racine>, read before any work: the ticket
98
+ * as Beads shows it, the tree its components are read in (`base`, its copy when it exists), the
99
+ * components of that tree, the resolver of a component, the subject and the plan of its title (the
100
+ * title whole and no plan for the supervisor's stop, <arreter>; the plan <plan> an act after the
101
+ * opening is given, its components not resolved again); or a refusal. <bd> runs bd in the main
102
+ * tree, `bd` by default.
103
+ */
104
+ export function ticketAuLancement(racine, id, { arreter = false, bd = null, plan = null } = {}) {
105
+ const show = (
106
+ bd ??
107
+ ((...a) => spawnSync('bd', a, { cwd: racine, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 }))
108
+ )('show', id, '--json');
109
+ if (show.status !== 0) {
110
+ throw new DepartRefuse(`ticket ${id} illisible : ${show.stderr}`);
111
+ }
112
+ const ticket = ticketAuDepart(id, show.stdout, { arreter });
113
+ const copie = path.join(racine, '.claude', 'worktrees', id);
114
+ const base = existsSync(copie) ? copie : racine;
115
+ const liste = composantsDe(base);
116
+ const resoudre = nom => resoudreComposant(liste, base, nom);
117
+ // The supervisor's stop reads neither the ticket's « ## Architecture » section nor its title.
118
+ const titre = arreter
119
+ ? { sujet: String(ticket?.title ?? id), plan: [] }
120
+ : plan
121
+ ? { sujet: sujetDe(String(ticket?.title ?? '').split(' — ')), plan }
122
+ : leTitre(id, ticket?.title, resoudre);
123
+ return { ticket, base, liste, resoudre, ...titre };
124
+ }
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ // The guard of the internal dependencies of the packages of a language other than TypeScript: the
3
+ // package.json of a crate or of a project of Python names the same internal packages as its
4
+ // manifest, because Turborepo orders the tasks by the graph of the package.json
5
+ // (node_modules/turbo/docs/guides/multi-language.mdx:191) while cargo and uv build by the graph of
6
+ // the manifest, as Turborepo's own example of Rust keeps the two by hand.
7
+ //
8
+ // npx grillhouse dependances-internes (one of the frame's guards, scripts/gardes-du-cadre.mjs)
9
+ //
10
+ // - The packages are those the architecture declares of a language without package.json of its own
11
+ // (`paquetsSansPackageJson`, ./paquet-npm.mjs) that hold a package.json; one without it is the
12
+ // migration's (./migrations/0.31.0-paquets-dans-le-graphe.mjs).
13
+ // - The internal dependencies of the manifest: of a Cargo.toml, each dependency with a `path`
14
+ // (`[dependencies]`, `[dev-dependencies]`, `[build-dependencies]`, and the same under
15
+ // `[target.*]`; a `workspace = true` one takes the `path` of `[workspace.dependencies]` of the
16
+ // root), named by the `name` of the manifest at that path; of a pyproject.toml, each entry of
17
+ // `[tool.uv.sources]` with a `path` (named by the manifest there) or `workspace = true`.
18
+ // - The internal dependencies of the package.json: the names of its `dependencies`,
19
+ // `devDependencies`, `optionalDependencies` and `peerDependencies` that are the name of a package
20
+ // of the project (the ones above and the workspaces'). An external dependency, on either side,
21
+ // is no gap.
22
+ // - Refused, one finding per package, named with the dependencies in gap in each sense: the
23
+ // package.json that lacks a dependency its manifest links, or names an internal package its
24
+ // manifest does not link. Written in SARIF under the guard's name, and on the error stream after
25
+ // ⛔; the exit code is 1 when there is one, 0 otherwise.
26
+ import { existsSync, readFileSync } from 'node:fs';
27
+ import path from 'node:path';
28
+ import { fileURLToPath, pathToFileURL } from 'node:url';
29
+ import { langage } from './langages.mjs';
30
+ import { nomDuManifeste, paquetsSansPackageJson, sansPackageJson } from './paquet-npm.mjs';
31
+ import { paquets } from './paquets.mjs';
32
+ import { ecrireSarif } from './resultats.mjs';
33
+
34
+ /** This script. */
35
+ export const SCRIPT = fileURLToPath(import.meta.url);
36
+ /** The name its findings carry. */
37
+ export const GARDE = 'dependances-internes';
38
+
39
+ // The fields of a package.json that name the packages it depends on.
40
+ const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
41
+
42
+ const lire = f => (existsSync(f) ? readFileSync(f, 'utf8') : null);
43
+
44
+ // The name of the package whose manifest lies in <dossier>, the one of <langageNom> first (a crate
45
+ // may link a project of Python), null for none.
46
+ function nomA(langageNom, dossier) {
47
+ for (const l of [langageNom, ...sansPackageJson()]) {
48
+ const texte = lire(path.join(dossier, langage(l).manifeste));
49
+ const nom = texte === null ? null : nomDuManifeste(l, texte);
50
+ if (nom !== null) return nom;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ /**
56
+ * The findings of the guard on the project at <racine>: `{ fichier, message }`, none when each
57
+ * package.json and its manifest agree.
58
+ * @param {string} racine the root of the project
59
+ */
60
+ export function constats(racine) {
61
+ const sans = paquetsSansPackageJson(racine);
62
+ const internes = new Set([...sans.map(p => p.nom), ...paquets(racine).map(p => p.pkg.name)]);
63
+ const out = [];
64
+ for (const p of sans) {
65
+ const f = `${p.chemin}/package.json`;
66
+ const texte = lire(path.join(racine, f));
67
+ if (texte === null) continue;
68
+ let pkg;
69
+ try {
70
+ pkg = JSON.parse(texte);
71
+ } catch {
72
+ continue;
73
+ }
74
+ const manifeste = langage(p.langage).manifeste;
75
+ const liens = langage(p.langage).liensDuManifeste(racine, p.chemin, d => nomA(p.langage, d));
76
+ const duManifeste = new Set(liens.noms);
77
+ duManifeste.delete(p.nom);
78
+ const duPackage = new Set(
79
+ CHAMPS.flatMap(c => Object.keys(pkg[c] ?? {})).filter(n => internes.has(n) && n !== p.nom)
80
+ );
81
+ const manquantes = [...duManifeste].filter(n => !duPackage.has(n)).sort();
82
+ const enTrop = [...duPackage].filter(n => !duManifeste.has(n)).sort();
83
+ if (!manquantes.length && !enTrop.length) continue;
84
+ const dits = [
85
+ ...(manquantes.length
86
+ ? [
87
+ `${manifeste} lie ${manquantes.join(', ')} (${liens.table}), que le package.json ne nomme pas`,
88
+ ]
89
+ : []),
90
+ ...(enTrop.length
91
+ ? [`le package.json nomme ${enTrop.join(', ')}, que ${manifeste} ne lie pas`]
92
+ : []),
93
+ ];
94
+ out.push({
95
+ fichier: f,
96
+ message: `${f} : le paquet ${p.nom} diffère de son manifeste dans ses dépendances internes : ${dits.join(' ; ')} ; le graphe des tâches suit le package.json, ${liens.outil} par ${manifeste} : les deux nomment les mêmes paquets.`,
97
+ });
98
+ }
99
+ return out;
100
+ }
101
+
102
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
103
+ const racine = process.cwd();
104
+ let refus;
105
+ try {
106
+ refus = constats(racine);
107
+ } catch (e) {
108
+ refus = [{ message: e.message.replace(/^⛔ /, '') }];
109
+ }
110
+ for (const r of refus) {
111
+ process.stderr.write(`⛔ ${r.message}\n`);
112
+ }
113
+ ecrireSarif({ garde: GARDE, racine, constats: refus });
114
+ process.exitCode = refus.length ? 1 : 0;
115
+ }
@@ -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
  },