@roomi-fields/grillhouse 0.24.15 → 0.25.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 (124) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +40 -12
  3. package/cadre/templates/cargo/.config/nextest.toml +8 -0
  4. package/cadre/templates/cargo/deny.toml +36 -0
  5. package/cadre/templates/cargo/package.json +15 -0
  6. package/cadre/templates/cargo/rust-toolchain.toml +6 -0
  7. package/cadre/templates/projet/package.json +5 -1
  8. package/cadre/templates/turbo/paquets.json +1 -1
  9. package/cadre/templates/turbo/sans-paquets.json +1 -1
  10. package/charte.md +16 -0
  11. package/docs/ARCHITECTURE.md +157 -54
  12. package/docs/CADRE.md +47 -0
  13. package/docs/INTERFACE.md +168 -0
  14. package/package.json +62 -13
  15. package/scripts/arbitrages.mjs +23 -0
  16. package/scripts/avancement.mjs +15 -29
  17. package/scripts/circuit.mjs +89 -97
  18. package/scripts/commande-du-langage.mjs +56 -0
  19. package/scripts/composants-affectes.mjs +47 -170
  20. package/scripts/conformite.d.ts +27 -0
  21. package/scripts/conformite.mjs +226 -0
  22. package/scripts/demon.mjs +1 -1
  23. package/scripts/dernier-vert.mjs +11 -9
  24. package/scripts/droits.mjs +27 -21
  25. package/scripts/enveloppe/enveloppe.mjs +206 -64
  26. package/scripts/enveloppe/lancer.sh +20 -91
  27. package/scripts/enveloppe/paquets-du-plan.mjs +24 -2
  28. package/scripts/etapes.mjs +2 -2
  29. package/scripts/gardes-du-cadre.mjs +12 -18
  30. package/scripts/grillhouse-maj.mjs +246 -389
  31. package/scripts/init.mjs +2 -1
  32. package/scripts/integration/file.mjs +3 -3
  33. package/scripts/integration/integrer.mjs +13 -10
  34. package/scripts/integration/rejeu.mjs +36 -7
  35. package/scripts/jointure.d.ts +304 -0
  36. package/scripts/langages/cargo/binaires.json +4 -0
  37. package/scripts/langages/cargo/binaires.mjs +60 -0
  38. package/scripts/langages/cargo/clippy.mjs +103 -0
  39. package/scripts/langages/cargo/commandes.mjs +378 -0
  40. package/scripts/langages/cargo/composants.mjs +191 -0
  41. package/scripts/langages/cargo/elements-du-lot.mjs +139 -0
  42. package/scripts/langages/cargo/exemples.mjs +357 -0
  43. package/scripts/langages/cargo/frontieres.mjs +84 -0
  44. package/scripts/langages/cargo/index-interfaces.mjs +138 -0
  45. package/scripts/langages/cargo/index.mjs +115 -0
  46. package/scripts/langages/cargo/mise-a-jour.mjs +93 -0
  47. package/scripts/langages/cargo/nextest.toml +5 -0
  48. package/scripts/langages/cargo/touches.mjs +93 -0
  49. package/scripts/langages/cargo/verdict.mjs +85 -0
  50. package/scripts/langages/typescript/chemins-des-tests.mjs +68 -0
  51. package/scripts/{code-mort.mjs → langages/typescript/code-mort.mjs} +5 -5
  52. package/scripts/langages/typescript/composants.mjs +64 -0
  53. package/scripts/{consommateurs-arbitres.mjs → langages/typescript/consommateurs-arbitres.mjs} +6 -24
  54. package/scripts/{consommateurs.mjs → langages/typescript/consommateurs.mjs} +13 -71
  55. package/scripts/langages/typescript/construire.mjs +176 -0
  56. package/scripts/{elements-du-lot.mjs → langages/typescript/elements-du-lot.mjs} +2 -2
  57. package/scripts/langages/typescript/exemples.mjs +289 -0
  58. package/scripts/{frontieres.mjs → langages/typescript/frontieres.mjs} +3 -5
  59. package/scripts/{index-interfaces.mjs → langages/typescript/index-interfaces.mjs} +3 -3
  60. package/scripts/langages/typescript/index.mjs +335 -0
  61. package/scripts/{interfaces-contre-code.mjs → langages/typescript/interfaces-contre-code.mjs} +2 -2
  62. package/scripts/langages/typescript/lecteurs.mjs +179 -0
  63. package/scripts/{migrations → langages/typescript/migrations}/0.23.0-config-vitest.mjs +14 -29
  64. package/scripts/{migrations → langages/typescript/migrations}/0.24.4-noms-declares-inutilises.mjs +2 -2
  65. package/scripts/{migrations → langages/typescript/migrations}/0.24.6-lignes-mal-formees.mjs +2 -2
  66. package/scripts/{migrations → langages/typescript/migrations}/0.24.7-matiere-dans-les-tests.mjs +2 -2
  67. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +27 -0
  68. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +31 -0
  69. package/scripts/langages/typescript/mise-a-jour.mjs +320 -0
  70. package/scripts/{references-par-les-types.mjs → langages/typescript/references-par-les-types.mjs} +3 -3
  71. package/scripts/langages/typescript/regle-des-tests.mjs +39 -0
  72. package/scripts/{resumes.mjs → langages/typescript/resumes.mjs} +4 -4
  73. package/scripts/langages/typescript/script-des-tests.mjs +6 -0
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +219 -0
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +57 -0
  76. package/scripts/{tests.mjs → langages/typescript/tests.mjs} +41 -32
  77. package/scripts/{turbo-des-paquets.mjs → langages/typescript/turbo-des-paquets.mjs} +49 -23
  78. package/scripts/langages/typescript/verdict.mjs +105 -0
  79. package/scripts/{verifier.mjs → langages/typescript/verifier.mjs} +53 -34
  80. package/scripts/{vitest-config → langages/typescript/vitest-config}/avancement.reporter.mjs +10 -2
  81. package/scripts/{vitest-config → langages/typescript/vitest-config}/base.mjs +63 -9
  82. package/scripts/{vitest-config → langages/typescript/vitest-config}/changements.mjs +18 -11
  83. package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
  84. package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +6 -1
  85. package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
  86. package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
  87. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
  88. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
  89. package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
  90. package/scripts/langages.mjs +85 -0
  91. package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
  92. package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
  93. package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
  94. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
  95. package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
  96. package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
  97. package/scripts/migrations.mjs +17 -13
  98. package/scripts/nuit.sh +59 -63
  99. package/scripts/paquets.d.ts +5 -0
  100. package/scripts/paquets.mjs +24 -2
  101. package/scripts/resultats.mjs +8 -82
  102. package/scripts/services-du-noyau.mjs +30 -0
  103. package/scripts/session-start.sh +17 -9
  104. package/scripts/sources.mjs +35 -13
  105. package/scripts/sous-commandes.mjs +57 -17
  106. package/scripts/superviseur.mjs +1 -1
  107. package/scripts/tableau.mjs +1 -1
  108. package/scripts/un-commit-par-ticket.mjs +48 -14
  109. package/scripts/verrou-de-fichier.mjs +1 -1
  110. package/scripts/verrou-de-machine.mjs +4 -4
  111. package/scripts/verrous/verrou.mjs +28 -37
  112. package/skills/developpeur/SKILL.md +2 -2
  113. package/skills/explorateur/SKILL.md +13 -5
  114. package/skills/grill/SKILL.md +2 -2
  115. package/skills/pitmaster/references/cadre.md +1 -1
  116. package/skills/pitmaster/references/consigne-agent.md +10 -3
  117. package/skills/redacteur/references/documents-d-un-composant.md +4 -4
  118. package/skills/relecteur/SKILL.md +4 -1
  119. package/skills/testwriter/SKILL.md +20 -6
  120. /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
  121. /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
  122. /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
  123. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
  124. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ // The index of the interfaces of a workspace of cargo: one line per crate, from its
3
+ // `docs/INTERFACE.md`, and one for the root's, which an agent loads at start before opening an
4
+ // interface; a generated file of the module (`fichiersEngendres` of ./index.mjs), as the module
5
+ // typescript's index (../typescript/index-interfaces.mjs), whose file and form it keeps.
6
+ //
7
+ // node index-interfaces.mjs writes docs/agents/index-des-interfaces.md
8
+ // node index-interfaces.mjs --verifier refuses (exit 1) when that file is out of date, its
9
+ // finding in SARIF too (../../resultats.mjs)
10
+ //
11
+ // - An interface is found at `<crate>/docs/INTERFACE.md` for each member of the workspace
12
+ // (./composants.mjs), and at `docs/INTERFACE.md`; in their paths' order.
13
+ // - Its title and the first sentence of the paragraph under it give its line, headed by the title
14
+ // alone when it begins with the crate's name (followed by a blank or ending it), else by
15
+ // `<crate> — <title>`. The root's is the crate's at the root when there is one (a crate at the
16
+ // root, as OSC Bridge), else `(racine) — <title>`.
17
+ // - No line per element: a crate's interface has no part generated from its code, which the
18
+ // index of the module typescript reads its elements from.
19
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
20
+ import path from 'node:path';
21
+ import { fileURLToPath, pathToFileURL } from 'node:url';
22
+ import { ecrireSarif } from '../../resultats.mjs';
23
+ import { composants } from './composants.mjs';
24
+
25
+ export const SORTIE = 'docs/agents/index-des-interfaces.md';
26
+ export const GARDE = 'index-interfaces';
27
+ const ICI = fileURLToPath(import.meta.url);
28
+ const RACINE = 'docs/INTERFACE.md';
29
+
30
+ const enAvant = p => p.split(path.sep).join('/');
31
+
32
+ /**
33
+ * The interfaces of the workspace at <racine>, each `{ rel, composant }`, `composant` the crate's
34
+ * name or `(racine)`, sorted by path.
35
+ * @param {string} racine the root of the workspace
36
+ */
37
+ export function interfaces(racine) {
38
+ const parRel = new Map();
39
+ for (const c of composants(racine)) {
40
+ const rel = enAvant(path.relative(racine, path.join(c.dossier, 'docs', 'INTERFACE.md')));
41
+ if (existsSync(path.join(racine, rel))) {
42
+ parRel.set(rel, c.nom);
43
+ }
44
+ }
45
+ if (existsSync(path.join(racine, RACINE)) && !parRel.has(RACINE)) {
46
+ parRel.set(RACINE, '(racine)');
47
+ }
48
+ return [...parRel]
49
+ .map(([rel, composant]) => ({ rel, composant }))
50
+ .sort((a, b) => (a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0));
51
+ }
52
+
53
+ const premierePhrase = lignes => {
54
+ const texte = lignes.join(' ').replace(/\s+/g, ' ').trim();
55
+ const m = /^(.+?[.!?])(\s|$)/.exec(texte);
56
+ return m ? m[1] : texte;
57
+ };
58
+
59
+ // The lines of the interface <rel> of <composant>, its text <contenu>.
60
+ function entrees({ rel, composant }, contenu) {
61
+ const lignes = contenu.split('\n');
62
+ const t = lignes.findIndex(l => l.startsWith('# '));
63
+ const titre = t >= 0 ? lignes[t].slice(2).trim() : composant;
64
+ const paragraphe = [];
65
+ for (const l of lignes.slice(t + 1)) {
66
+ if (/^#{1,6} /.test(l) || (!l.trim() && paragraphe.length)) {
67
+ break;
68
+ }
69
+ if (l.trim()) {
70
+ paragraphe.push(l.trim());
71
+ }
72
+ }
73
+ const parSonNom =
74
+ composant !== '(racine)' &&
75
+ titre.startsWith(composant) &&
76
+ (titre.length === composant.length || /\s/.test(titre[composant.length]));
77
+ const tetiere = parSonNom ? titre : `${composant} — ${titre}`;
78
+ return [`## ${tetiere}`, '', `${premierePhrase(paragraphe)} (\`${rel}\`)`, ''];
79
+ }
80
+
81
+ /**
82
+ * The index of the interfaces of the workspace at <racine>, as its file holds it.
83
+ * @param {string} racine the root of the workspace
84
+ */
85
+ export function index(racine) {
86
+ const corps = interfaces(racine).flatMap(i =>
87
+ entrees(i, readFileSync(path.join(racine, i.rel), 'utf8'))
88
+ );
89
+ return [
90
+ '# Index des interfaces',
91
+ '',
92
+ 'Généré depuis les `INTERFACE.md` des crates ; ne pas éditer.',
93
+ "Une ligne par composant ; l'interface donne le détail.",
94
+ '',
95
+ ...corps,
96
+ ].join('\n');
97
+ }
98
+
99
+ /**
100
+ * The findings of the check of the index at <racine>: none when its file is up to date.
101
+ * @param {string} racine the root of the workspace
102
+ */
103
+ export function enRetard(racine) {
104
+ const cible = path.join(racine, SORTIE);
105
+ const present = existsSync(cible) ? readFileSync(cible, 'utf8') : '';
106
+ return present === index(racine)
107
+ ? []
108
+ : [
109
+ {
110
+ fichier: SORTIE,
111
+ message: `${SORTIE} n'est pas à jour avec les interfaces : sa commande le régénère (node ${JSON.stringify(ICI)}).`,
112
+ },
113
+ ];
114
+ }
115
+
116
+ /**
117
+ * Runs the command in the workspace at <racine> with <args>: its exit code.
118
+ * @param {string} racine the root of the workspace
119
+ * @param {string[]} args `--verifier` to check, nothing to write
120
+ * @param {{ env?: NodeJS.ProcessEnv }} [o] the environment (the results directory)
121
+ */
122
+ export function commande(racine, args, { env = process.env } = {}) {
123
+ if (!args.includes('--verifier')) {
124
+ mkdirSync(path.dirname(path.join(racine, SORTIE)), { recursive: true });
125
+ writeFileSync(path.join(racine, SORTIE), index(racine));
126
+ return 0;
127
+ }
128
+ const refus = enRetard(racine);
129
+ for (const r of refus) {
130
+ process.stderr.write(`⛔ ${r.message}\n`);
131
+ }
132
+ ecrireSarif({ garde: GARDE, racine, constats: refus, env });
133
+ return refus.length ? 1 : 0;
134
+ }
135
+
136
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
137
+ process.exitCode = commande(process.cwd(), process.argv.slice(2));
138
+ }
@@ -0,0 +1,115 @@
1
+ // The module of language cargo: what the core asks of a language (scripts/jointure.d.ts,
2
+ // docs/INTERFACE.md), answered for a workspace of cargo by cargo itself (`cargo metadata`,
3
+ // nextest, cargo-deny), as Pants's Rust backend and Bazel's rules_rust read a Cargo workspace.
4
+ // The core loads it by scripts/langages.mjs, and this module imports of the core its published
5
+ // entries alone.
6
+ //
7
+ // - Where it is found: a repository with a Cargo.toml at its root, the manifest of its workspace
8
+ // or of its one crate (`trouve`). Its tools are no
9
+ // package of npm (`outils` empty): cargo and its subcommands live on the machine, and the update
10
+ // installs the binaries the module runs, nextest and cargo-deny, at their versions
11
+ // (`binaires`, ./binaires.json). What cargo writes in a project: `target` (`ignorer`).
12
+ // - Where cargo writes, which the envelope opens to a session (`sorties`), and the rules that
13
+ // refuse a role that writes the test runner run directly (`droits`).
14
+ // - The components, a file's, the shared test material, the components that play tests, the
15
+ // readers of a crate and the rule of a test file (./composants.mjs).
16
+ // - The crates touched since a commit and their dependents (./touches.mjs).
17
+ // - The elements of a lot, one per crate (./elements-du-lot.mjs).
18
+ // - The commands `tester`, `verifier`, `typer` and `preparer` (./commandes.mjs), each described,
19
+ // `{ script, args }`, never run, `preparer` played by the integration before the verification;
20
+ // the verdict of a run (./verdict.mjs). The tool of a test's temporary directory, the crate
21
+ // `tempfile`, and its guard: `tester` and `verifier` play under a base of their pass, named in
22
+ // TMPDIR, TMP and TEMP, and fail naming what the tests left there (./commandes.mjs).
23
+ // - The generated file, the index of the interfaces (./index-interfaces.mjs), its command and its
24
+ // check; the guards of structure, in the order they play: clippy (./clippy.mjs), the boundaries
25
+ // between crates (./frontieres.mjs), the index of the interfaces up to date, each a command by
26
+ // its name too (./commandes.mjs), which the line of a red guard names. No migration yet.
27
+ // - Its share of the update (./mise-a-jour.mjs, `miseAJour`): the template of a project of cargo
28
+ // (`templates/cargo/`) and its test scripts.
29
+ import { existsSync, readFileSync } from 'node:fs';
30
+ import path from 'node:path';
31
+ import { fileURLToPath } from 'node:url';
32
+ import { commandes, GARDES } from './commandes.mjs';
33
+ import {
34
+ composantDans,
35
+ composants,
36
+ estUnTest,
37
+ joueDesTests,
38
+ lecteurs,
39
+ matieres,
40
+ } from './composants.mjs';
41
+ import { elementsDuLot } from './elements-du-lot.mjs';
42
+ import { enRetard, SORTIE } from './index-interfaces.mjs';
43
+ import { miseAJour } from './mise-a-jour.mjs';
44
+ import { touches } from './touches.mjs';
45
+ import { verdict } from './verdict.mjs';
46
+
47
+ // The scripts of this module, beside this file.
48
+ const ici = nom => path.join(path.dirname(fileURLToPath(import.meta.url)), nom);
49
+
50
+ // Whether the repository at <racine> holds a Cargo.toml at its root.
51
+ const trouve = racine => existsSync(path.join(racine, 'Cargo.toml'));
52
+
53
+ export default {
54
+ nom: 'cargo',
55
+ trouve,
56
+ signe: 'un Cargo.toml à la racine',
57
+ outils: [],
58
+ // The binaries the module runs, nextest and cargo-deny, each at the version the probe of
59
+ // grillhouse-pkl.1 measured.
60
+ binaires: JSON.parse(readFileSync(ici('binaires.json'), 'utf8')),
61
+ // What cargo writes in a project: its target directory.
62
+ ignorer: ['target'],
63
+ // Where cargo writes, in writing: the target directory of the workspace; in its home, the
64
+ // registry's index and sources, the git dependencies, cargo-deny's advisories, and the files of
65
+ // its locks and of the SQLite cache of its packages (`.package-cache`, `.package-cache-mutate`,
66
+ // `.global-cache`), files without a trailing `/`. What it reads, read-only: its home, `~/.cargo`
67
+ // (its binaries, its `env`, which the shells source, and its configuration stay unwritten), and
68
+ // rustup's toolchains, `~/.rustup`. Measured on 2026-10-30: `cargo fetch --locked` of
69
+ // osc-bridge in bwrap with these mounts alone, green, the cache of its packages written.
70
+ sorties: {
71
+ ecrites: [
72
+ 'target/',
73
+ '~/.cargo/registry/',
74
+ '~/.cargo/git/',
75
+ '~/.cargo/advisory-dbs/',
76
+ '~/.cargo/.package-cache',
77
+ '~/.cargo/.package-cache-mutate',
78
+ '~/.cargo/.global-cache',
79
+ ],
80
+ propres: [],
81
+ lues: ['~/.cargo/', '~/.rustup/'],
82
+ },
83
+ // The test runner run directly, cargo's or nextest: `npm test` and `npm run verifier` play it.
84
+ droits: [
85
+ 'Bash(cargo test*)',
86
+ 'Bash(cargo t)',
87
+ 'Bash(cargo t *)',
88
+ 'Bash(cargo nextest*)',
89
+ 'Bash(cargo-nextest*)',
90
+ ],
91
+ composants,
92
+ composantDe: (racine, fichier) => composantDans(composants(racine), racine, fichier),
93
+ matieres,
94
+ joueDesTests,
95
+ lecteurs,
96
+ touches,
97
+ elementsDuLot,
98
+ commandes,
99
+ verdict,
100
+ estUnTest,
101
+ fichiersEngendres: () => [
102
+ {
103
+ nom: "l'index des interfaces",
104
+ commande: `node ${JSON.stringify(ici('index-interfaces.mjs'))}`,
105
+ fichiers: [SORTIE],
106
+ lit: ['docs/INTERFACE.md', '**/docs/INTERFACE.md'],
107
+ gardes: ['index-interfaces'],
108
+ entiers: [SORTIE],
109
+ verifier: enRetard,
110
+ },
111
+ ],
112
+ gardes: () => GARDES.map(({ script, args }) => [script, ...args]),
113
+ migrations: [],
114
+ miseAJour,
115
+ };
@@ -0,0 +1,93 @@
1
+ // What the module cargo brings to the update of a project (`grillhouse maj`,
2
+ // scripts/grillhouse-maj.mjs), the demand `miseAJour` of the join (scripts/jointure.d.ts), as the
3
+ // `init` generator of a plugin of Nx brings its tool to a workspace. The core writes the root
4
+ // package.json after, and reports the lines.
5
+ //
6
+ // - The template: `templates/cargo/` of the frame's files. Its package.json gives the frame's
7
+ // scripts, which run the frame's commands (`grillhouse tests`, `grillhouse verifier`), and no
8
+ // tool of npm.
9
+ // - Each other file of the template a project lacks is copied at its path: `deny.toml`, the
10
+ // policy of cargo-deny, which refuses every licence without one (cargo-deny's code 4, the probe
11
+ // of grillhouse-pkl.1); `.config/nextest.toml`, the project's configuration of nextest, which
12
+ // leaves the frame's profile `grillhouse` to the frame (./nextest.toml); `rust-toolchain.toml`,
13
+ // the toolchain and its components clippy and rustfmt, which the guards run. A file the project
14
+ // holds is its own: never written again.
15
+ // - The root scripts `test`, `test:forcer` and `verifier` a project lacks become the template's:
16
+ // the agents run `npm test`, the integration and the night `npm run verifier`. A project's own
17
+ // script stays.
18
+ // - The generator: the index of the interfaces (./index-interfaces.mjs), run where the project
19
+ // holds it, as the module typescript's.
20
+ // - The installation of its binaries (./binaires.json): the commands of ./binaires.mjs, which list
21
+ // what cargo installed and install one binary by cargo-binstall; the core runs them.
22
+ import { copyFileSync, existsSync, mkdirSync, readdirSync } from 'node:fs';
23
+ import path from 'node:path';
24
+ import { fileURLToPath } from 'node:url';
25
+ import { SORTIE } from './index-interfaces.mjs';
26
+
27
+ const BINAIRES = path.join(path.dirname(fileURLToPath(import.meta.url)), 'binaires.mjs');
28
+
29
+ const GABARIT = 'templates/cargo';
30
+ const SCRIPTS_DES_TESTS = ['test', 'test:forcer', 'verifier'];
31
+
32
+ // The files under <dossier>, as paths from it.
33
+ const fichiers = (dossier, rel = '') =>
34
+ readdirSync(path.join(dossier, rel), { withFileTypes: true }).flatMap(e =>
35
+ e.isDirectory() ? fichiers(dossier, path.join(rel, e.name)) : [path.join(rel, e.name)]
36
+ );
37
+
38
+ /** @type {import('../../jointure.js').MiseAJour['appliquer']} */
39
+ function appliquer(projet, { p, modele, source }) {
40
+ const gabarit = path.join(source, GABARIT);
41
+ const copies = [];
42
+ if (existsSync(gabarit)) {
43
+ for (const f of fichiers(gabarit).sort()) {
44
+ if (f === 'package.json' || existsSync(path.join(projet, f))) {
45
+ continue;
46
+ }
47
+ mkdirSync(path.dirname(path.join(projet, f)), { recursive: true });
48
+ copyFileSync(path.join(gabarit, f), path.join(projet, f));
49
+ copies.push(f);
50
+ }
51
+ }
52
+ p.scripts ??= {};
53
+ const scripts = [];
54
+ for (const nom of SCRIPTS_DES_TESTS) {
55
+ const script = modele.scripts?.[nom];
56
+ if (typeof script !== 'string' || typeof p.scripts[nom] === 'string') {
57
+ continue;
58
+ }
59
+ p.scripts[nom] = script;
60
+ scripts.push(nom);
61
+ }
62
+ const lignes = [];
63
+ if (copies.length > 0) {
64
+ lignes.push(
65
+ `Gabarit cargo : ${copies.join(', ')} écrits ; ils sont au projet, la mise à jour n'y touche plus.`
66
+ );
67
+ }
68
+ if (scripts.length > 0) {
69
+ lignes.push(
70
+ `Scripts des tests : ${scripts.map(n => `${n} (\`${p.scripts[n]}\`)`).join(', ')} écrits ; les agents lancent \`npm test\`, l'intégration et la nuit \`npm run verifier\`.`
71
+ );
72
+ }
73
+ return {
74
+ bilan: {
75
+ gabarit: copies.length > 0 ? copies : null,
76
+ scripts: scripts.length > 0 ? scripts : null,
77
+ },
78
+ lignes,
79
+ installer: false,
80
+ sansVerifier: null,
81
+ };
82
+ }
83
+
84
+ /** The share of the module cargo in the update. */
85
+ export const miseAJour = {
86
+ gabarit: GABARIT,
87
+ appliquer,
88
+ generateurs: [{ commande: 'index-interfaces', args: [], sortie: SORTIE }],
89
+ installation: {
90
+ liste: { script: BINAIRES, args: ['liste'] },
91
+ installer: (nom, version) => ({ script: BINAIRES, args: ['installer', `${nom}@${version}`] }),
92
+ },
93
+ };
@@ -0,0 +1,5 @@
1
+ # The frame's profile of nextest, which ./commandes.mjs passes as a tool's configuration
2
+ # (`--tool-config-file grillhouse:<this file>`), under the project's own: its JUnit report, which
3
+ # the verdict reads (./verdict.mjs).
4
+ [profile.grillhouse.junit]
5
+ path = "junit.xml"
@@ -0,0 +1,93 @@
1
+ // The crates touched since a commit, the demand `touches` of the join (scripts/jointure.d.ts), as
2
+ // Turborepo's `--filter=...[<commit>]` reads the packages a change reaches and its global
3
+ // dependencies touch them all.
4
+ //
5
+ // - The files changed: what git sees changed since the commit, the working tree and the untracked
6
+ // files included (`git diff --name-only --no-renames <depuis>`, `git ls-files -o
7
+ // --exclude-standard`).
8
+ // - Each file in the crate of the longest folder that holds it (./composants.mjs). A file of the
9
+ // workspace itself, its Cargo.toml or its Cargo.lock at the root, reaches every build: it touches
10
+ // every crate. Any other file out of every crate is out of the graph (`horsGraphe`).
11
+ // - The dependents: the members that depend on a touched crate by its path, of any kind, the
12
+ // development dependencies included, transitively.
13
+ import { spawnSync } from 'node:child_process';
14
+ import path from 'node:path';
15
+ import { composantDans, crates } from './composants.mjs';
16
+
17
+ // The files of the workspace itself, from its root: a change to one rebuilds every crate.
18
+ export const DE_L_ESPACE = ['Cargo.toml', 'Cargo.lock'];
19
+
20
+ const lignesDeGit = (racine, args) => {
21
+ const r = spawnSync('git', ['-C', racine, ...args, '-z'], {
22
+ encoding: 'utf8',
23
+ maxBuffer: 256 * 1024 * 1024,
24
+ });
25
+ if (r.status !== 0) {
26
+ throw new Error(`⛔ git ${args.join(' ')} : ${r.stderr.trim()}`);
27
+ }
28
+ return r.stdout.split('\0').filter(Boolean);
29
+ };
30
+
31
+ /**
32
+ * The crates the files <fichiers> (from <racine>) touch, their dependents, and the files out of
33
+ * the graph: `{ touches, dependants, horsGraphe }`, each list sorted.
34
+ * @param {string} racine the root of the workspace
35
+ * @param {Iterable<string>} fichiers the files changed
36
+ */
37
+ export function touchesDesFichiers(racine, fichiers) {
38
+ const tous = crates(racine);
39
+ const liste = tous.map(c => c.composant);
40
+ const touches = new Set();
41
+ const horsGraphe = [];
42
+ for (const f of new Set(fichiers)) {
43
+ if (DE_L_ESPACE.includes(path.normalize(f))) {
44
+ for (const c of liste) {
45
+ touches.add(c);
46
+ }
47
+ continue;
48
+ }
49
+ const c = composantDans(liste, racine, f);
50
+ if (c) {
51
+ touches.add(c);
52
+ } else {
53
+ horsGraphe.push(f);
54
+ }
55
+ }
56
+ const parDossier = new Map(liste.map(c => [c.dossier, c]));
57
+ const lecteursDe = new Map(liste.map(c => [c, new Set()]));
58
+ for (const c of tous) {
59
+ for (const d of c.deps) {
60
+ const lu = parDossier.get(d.dossier);
61
+ if (lu && lu !== c.composant) {
62
+ lecteursDe.get(lu).add(c.composant);
63
+ }
64
+ }
65
+ }
66
+ const dependants = new Set();
67
+ const suivre = c => {
68
+ for (const l of lecteursDe.get(c)) {
69
+ if (touches.has(l) || dependants.has(l)) {
70
+ continue;
71
+ }
72
+ dependants.add(l);
73
+ suivre(l);
74
+ }
75
+ };
76
+ for (const c of touches) {
77
+ suivre(c);
78
+ }
79
+ const parNom = (a, b) => a.nom.localeCompare(b.nom);
80
+ return {
81
+ touches: [...touches].sort(parNom),
82
+ dependants: [...dependants].sort(parNom),
83
+ horsGraphe: horsGraphe.sort(),
84
+ };
85
+ }
86
+
87
+ /** The crates touched in <racine> since the commit <depuis>, their dependents, the files out. */
88
+ export function touches(racine, { depuis }) {
89
+ return touchesDesFichiers(racine, [
90
+ ...lignesDeGit(racine, ['diff', '--name-only', '--no-renames', depuis]),
91
+ ...lignesDeGit(racine, ['ls-files', '-o', '--exclude-standard']),
92
+ ]);
93
+ }
@@ -0,0 +1,85 @@
1
+ // The verdict of a run of the module cargo, the demand `verdict` of the join
2
+ // (scripts/jointure.d.ts): what ./commandes.mjs left in the results directory of a pass
3
+ // (`GRILLHOUSE_RESULTATS`, scripts/resultats.mjs).
4
+ //
5
+ // - `<dossier>/cargo/<run>.json`, one per run: `{ taches, cibles }`, each task as the join types
6
+ // it (`code` null for a task planned that did not run; `tests` true for the runs of nextest and
7
+ // of the doctests), and the file of each test binary of nextest by its id (`ws-core`,
8
+ // `ws-core::integ`, `ws-core::bin/outil`), its target's source.
9
+ // - `<dossier>/nextest/<run>-<crate>.xml`, the JUnit report of each run of nextest: each
10
+ // `testsuite`, a test binary, gives a test file, each `testcase` a test, failed when it holds a
11
+ // `failure` or an `error`, skipped when it holds `skipped`; its message, the failure's.
12
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
13
+ import path from 'node:path';
14
+
15
+ export const TACHES = 'cargo';
16
+ export const JUNIT = 'nextest';
17
+
18
+ const fichiers = (dossier, extension) =>
19
+ existsSync(dossier)
20
+ ? readdirSync(dossier)
21
+ .filter(f => f.endsWith(extension))
22
+ .sort()
23
+ .map(f => path.join(dossier, f))
24
+ : [];
25
+ const lireJson = f => {
26
+ try {
27
+ return JSON.parse(readFileSync(f, 'utf8'));
28
+ } catch {
29
+ return null;
30
+ }
31
+ };
32
+
33
+ const ENTITES = { lt: '<', gt: '>', amp: '&', quot: '"', apos: "'" };
34
+ // The text <t> of XML, its entities read.
35
+ const texte = t =>
36
+ t.replace(/&(#x[0-9a-f]+|#\d+|\w+);/gi, (m, e) => {
37
+ if (e[0] === '#') {
38
+ return String.fromCodePoint(e[1] === 'x' ? parseInt(e.slice(2), 16) : Number(e.slice(1)));
39
+ }
40
+ return ENTITES[e] ?? m;
41
+ });
42
+ // The attribute <nom> of the opening tag <balise>, its text, or null.
43
+ const attribut = (balise, nom) => {
44
+ const m = new RegExp(`\\s${nom}="([^"]*)"`).exec(balise);
45
+ return m ? texte(m[1]) : null;
46
+ };
47
+
48
+ // The test files of the JUnit report <xml>, each binary's file read in <cibles>.
49
+ function rapportsDe(xml, cibles) {
50
+ const out = [];
51
+ for (const s of xml.matchAll(/<testsuite\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testsuite>)/g)) {
52
+ const nom = attribut(s[1], 'name') ?? '';
53
+ const tests = [];
54
+ for (const c of (s[2] ?? '').matchAll(/<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g)) {
55
+ const corps = c[2] ?? '';
56
+ const echec = /<(failure|error)\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1>)/.exec(corps);
57
+ const etat = echec ? 'failed' : /<skipped\b/.test(corps) ? 'skipped' : 'passed';
58
+ const message = echec ? (attribut(echec[2], 'message') ?? texte(echec[3] ?? '')) : '';
59
+ const titre = attribut(c[1], 'name') ?? '';
60
+ tests.push({ titre, nom: titre, etat, message });
61
+ }
62
+ out.push({
63
+ fichier: cibles[nom] ?? nom,
64
+ etat: tests.some(t => t.etat === 'failed') ? 'failed' : 'passed',
65
+ message: '',
66
+ tests,
67
+ });
68
+ }
69
+ return out;
70
+ }
71
+
72
+ /**
73
+ * The verdict the results directory <dossier> holds: `{ rapports, taches }`.
74
+ * @param {string} dossier the results directory of a pass
75
+ */
76
+ export function verdict(dossier) {
77
+ const runs = fichiers(path.join(dossier, TACHES), '.json').map(lireJson).filter(Boolean);
78
+ const cibles = Object.assign({}, ...runs.map(r => r.cibles ?? {}));
79
+ return {
80
+ rapports: fichiers(path.join(dossier, JUNIT), '.xml').flatMap(f =>
81
+ rapportsDe(readFileSync(f, 'utf8'), cibles)
82
+ ),
83
+ taches: runs.flatMap(r => r.taches ?? []),
84
+ };
85
+ }
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ // The paths the tests launch or read, on the model of Bazel's sandbox, which fails a test that
3
+ // reads an input its target does not declare: a test's run that the frame cannot relate to a
4
+ // changed file would keep a stale green, so the guard refuses the path the frame cannot read.
5
+ //
6
+ // npx grillhouse chemins-des-tests run from the repository root (a guard of grillhouse:gardes)
7
+ //
8
+ // - A pass measured against the last green plays, in each package, the tests Vitest relates to the
9
+ // files changed, and the tests that read a changed file by its path (the scripts they launch,
10
+ // the data they read: ./vitest-config/lances.mjs, `testsQuiLancent`), or every test when a
11
+ // change lies in a path its package's tests declare they read (`grillhouse.lit`,
12
+ // ./vitest-config/changements.mjs).
13
+ // - A finding, `{ fichier, regle: 'chemin-non-declare', message }`, is a string of a test's code
14
+ // (or of the test material it imports) that ends the path of a module of its package, out of a
15
+ // directory of tests, which the frame does not find in what the test reads nor under the
16
+ // package's `grillhouse.lit` (`nonDeclares`): a script launched by a path built at run time
17
+ // (`path.join(SCRIPTS, nom)`). The test writes the path whole (`path.resolve(__dirname,
18
+ // '../scripts/verrous/verrou.mjs')`), or its package declares it in its `grillhouse.lit`.
19
+ // - The packages are those of the workspace, out of `docs/agents/hors-cadre.txt` (../../paquets.mjs);
20
+ // a repository without one is its own package. A finding inscribed in the project's debt
21
+ // (`grillhouse-dette.json`, ../../dette.mjs) passes: those that exist when the guard arrives are
22
+ // inscribed there by the update (./migrations/0.25.0-chemins-des-tests.mjs).
23
+ import { readFileSync } from 'node:fs';
24
+ import path from 'node:path';
25
+ import { pathToFileURL } from 'node:url';
26
+ import { trancher } from '../../dette.mjs';
27
+ import { paquets } from '../../paquets.mjs';
28
+ import { nonDeclares } from './vitest-config/lances.mjs';
29
+
30
+ export const GARDE = 'chemins-des-tests';
31
+ export const CHEMIN_NON_DECLARE = 'chemin-non-declare';
32
+
33
+ // The paths <dossier>'s package.json declares its tests read (`grillhouse.lit`), from the top.
34
+ function lit(dossier) {
35
+ try {
36
+ const l = JSON.parse(readFileSync(path.join(dossier, 'package.json'), 'utf8'))?.grillhouse?.lit;
37
+ return (Array.isArray(l) ? l : [])
38
+ .filter(x => typeof x === 'string')
39
+ .map(x => x.replace(/^\.\//, '').replace(/\/+$/, ''));
40
+ } catch {
41
+ return [];
42
+ }
43
+ }
44
+
45
+ /**
46
+ * The findings of the repository at <racine>: one `{ fichier, regle, message }` per module of its
47
+ * package a test names without the frame reading it, in the debt's form (../../dette.mjs).
48
+ */
49
+ export function verifier(racine) {
50
+ const liste = paquets(racine).filter(p => !p.hors);
51
+ const dossiers = liste.length ? liste.map(p => path.join(racine, p.dossier)) : [racine];
52
+ const memo = new Map();
53
+ return dossiers.flatMap(d =>
54
+ nonDeclares(d, racine, lit(d), memo).map(({ test, fichier, chaine }) => ({
55
+ fichier: test,
56
+ regle: CHEMIN_NON_DECLARE,
57
+ message: `${test} : la chaîne ${JSON.stringify(chaine)} nomme ${fichier}, que le cadre ne trouve ni dans ce que le test importe ou nomme, ni dans le grillhouse.lit de son paquet ; un changement de ${fichier} ne rejouerait pas ce test. Le test écrit le chemin entier (path.resolve(__dirname, '<chemin>')), ou son paquet le déclare dans son grillhouse.lit.`,
58
+ }))
59
+ );
60
+ }
61
+
62
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
63
+ const racine = process.cwd();
64
+ const { refus, lignes } = trancher(racine, GARDE, verifier(racine));
65
+ for (const r of refus) process.stderr.write(`⛔ ${r.message}\n`);
66
+ for (const l of lignes) process.stderr.write(`${l}\n`);
67
+ process.exitCode = refus.length ? 1 : 0;
68
+ }
@@ -33,8 +33,8 @@
33
33
  // exports and types findings are those of the first run.
34
34
  // - The test and bench files are those git does not ignore (`.gitignore`, as knip reads it): a
35
35
  // ticket copy or a build that git ignores counts for nothing. A test file is known by the
36
- // repository's rule (`isTestFile`, `verrous/verrou.mjs`), plus the benches `*.budget.*` and
37
- // `*.nuit.*`. A file the top-level or workspace `ignore` targets is not an entry: these patterns
36
+ // repository's rule (`isTestFile`, langages/typescript/regle-des-tests.mjs), plus the benches
37
+ // `*.budget.*` and `*.nuit.*`. A file the top-level or workspace `ignore` targets is not an entry: these patterns
38
38
  // become negated entry patterns, which knip matches as its own.
39
39
  import { spawnSync } from 'node:child_process';
40
40
  import { createRequire } from 'node:module';
@@ -42,9 +42,9 @@ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'no
42
42
  import { tmpdir } from 'node:os';
43
43
  import path from 'node:path';
44
44
  import { pathToFileURL } from 'node:url';
45
- import { horsCadre } from './paquets.mjs';
46
- import { trancher } from './dette.mjs';
47
- import { isTestFile } from './verrous/verrou.mjs';
45
+ import { horsCadre } from '../../paquets.mjs';
46
+ import { trancher } from '../../dette.mjs';
47
+ import { isTestFile } from './regle-des-tests.mjs';
48
48
 
49
49
  const GENRES = {
50
50
  files: 'fichier sans appelant',