@roomi-fields/grillhouse 0.26.0 → 0.27.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 (60) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/cadre/templates/projet/CLAUDE.md +7 -0
  3. package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
  4. package/cadre/templates/python/package.json +18 -0
  5. package/charte.md +22 -0
  6. package/docs/ARCHITECTURE.md +58 -17
  7. package/docs/CADRE.md +7 -6
  8. package/docs/INTERFACE.md +96 -32
  9. package/package.json +1 -1
  10. package/scripts/circuit.mjs +44 -8
  11. package/scripts/commande-du-langage.mjs +2 -2
  12. package/scripts/commandes-composees.mjs +156 -0
  13. package/scripts/composition-des-langages.mjs +306 -0
  14. package/scripts/conformite.mjs +1 -3
  15. package/scripts/dernier-vert.mjs +15 -2
  16. package/scripts/engendres.mjs +170 -0
  17. package/scripts/enveloppe/travail-de-la-copie.mjs +82 -8
  18. package/scripts/gardes-du-cadre.mjs +7 -4
  19. package/scripts/grillhouse-maj.mjs +152 -99
  20. package/scripts/index-interfaces.mjs +78 -0
  21. package/scripts/init.mjs +5 -5
  22. package/scripts/integration/file.mjs +74 -13
  23. package/scripts/integration/integrer.mjs +50 -62
  24. package/scripts/jointure.d.ts +26 -13
  25. package/scripts/langages/cargo/binaires.mjs +29 -6
  26. package/scripts/langages/cargo/clippy.mjs +4 -2
  27. package/scripts/langages/cargo/commandes.mjs +45 -7
  28. package/scripts/langages/cargo/exemples.mjs +1 -15
  29. package/scripts/langages/cargo/index-interfaces.mjs +20 -3
  30. package/scripts/langages/cargo/index.mjs +9 -10
  31. package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
  32. package/scripts/langages/cargo/sccache.mjs +29 -0
  33. package/scripts/langages/python/binaires.json +3 -0
  34. package/scripts/langages/python/binaires.mjs +59 -0
  35. package/scripts/langages/python/commandes.mjs +411 -0
  36. package/scripts/langages/python/composants.mjs +272 -0
  37. package/scripts/langages/python/exemples.mjs +260 -0
  38. package/scripts/langages/python/index-interfaces.mjs +77 -0
  39. package/scripts/langages/python/index.mjs +94 -0
  40. package/scripts/langages/python/lot.mjs +76 -0
  41. package/scripts/langages/python/mise-a-jour.mjs +54 -0
  42. package/scripts/langages/python/tailles-des-tests.mjs +102 -0
  43. package/scripts/langages/python/verdict.mjs +85 -0
  44. package/scripts/langages/typescript/exemples.mjs +1 -20
  45. package/scripts/langages/typescript/index-interfaces.mjs +10 -3
  46. package/scripts/langages/typescript/index.mjs +11 -15
  47. package/scripts/langages-des-paquets.mjs +171 -0
  48. package/scripts/langages.mjs +60 -41
  49. package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
  50. package/scripts/migrations.mjs +2 -0
  51. package/scripts/outils-cles.mjs +1 -1
  52. package/scripts/session-start.sh +34 -9
  53. package/scripts/sources.mjs +2 -1
  54. package/scripts/sous-commandes.mjs +5 -3
  55. package/scripts/tableau-des-composants.mjs +138 -0
  56. package/scripts/verrous/verrou.mjs +3 -2
  57. package/skills/grill/SKILL.md +9 -1
  58. package/skills/pitmaster/SKILL.md +6 -1
  59. package/skills/redacteur/references/documents-d-un-composant.md +12 -0
  60. package/skills/testwriter/SKILL.md +6 -0
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+ // The guard of the languages of the packages: each package follows the language the architecture
3
+ // declares for it, as Bazel builds each target by the rule its BUILD file names, and refuses a
4
+ // source the rule does not take.
5
+ //
6
+ // npx grillhouse langages-des-paquets (one of the frame's guards, scripts/gardes-du-cadre.mjs)
7
+ //
8
+ // - The packages are the folders the module of every language of the frame finds (`LANGAGES`),
9
+ // not of the declared languages alone: a crate in a project whose table names typescript alone
10
+ // is a package to judge. Each manifest is read to refuse a gap, never to declare: the
11
+ // declaration stays the tables of the components of docs/ARCHITECTURE.md
12
+ // (./tableau-des-composants.mjs), their rows with a language, each table read by its own column
13
+ // of the names.
14
+ // - Refused, each finding named with its package: a package that holds the manifest of its module
15
+ // (`manifeste`: a package.json, a Cargo.toml) and that no row names, « que l'architecture ne
16
+ // déclare pas »; a package a row declares of a language whose module does not find it there,
17
+ // named with the manifest it holds; a package a row declares without the manifest of that
18
+ // language; a docs/INTERFACE.md of the package, or of
19
+ // the root for the row that names it (`.`), whose line `**Langage** : <nom>` names another
20
+ // language; a row that names a folder of the project no module finds (a package of Python
21
+ // without its pyproject.toml, grillhouse-ziy), without the manifest of its language. A folder of
22
+ // a module without its manifest and without row (a folder of `src/` of a project of one package)
23
+ // is no package; a row that names neither a component nor a folder (a package not yet created,
24
+ // a crate of another repository) is not judged.
25
+ // - Each finding is written in SARIF under the guard's name, and on the error stream after ⛔; the
26
+ // exit code is 1 when there is one, 0 otherwise.
27
+ import { existsSync, readFileSync, statSync } from 'node:fs';
28
+ import path from 'node:path';
29
+ import { fileURLToPath, pathToFileURL } from 'node:url';
30
+ import { LANGAGES, langage, langagesDe } from './langages.mjs';
31
+ import { ecrireSarif } from './resultats.mjs';
32
+ import {
33
+ ARCHITECTURE,
34
+ colonneDesNoms,
35
+ COLONNE,
36
+ langageDeLaCellule,
37
+ nomme,
38
+ nomsDe,
39
+ tableauxDesComposants,
40
+ } from './tableau-des-composants.mjs';
41
+
42
+ /** This script. */
43
+ export const SCRIPT = fileURLToPath(import.meta.url);
44
+ /** The name its findings carry. */
45
+ export const GARDE = 'langages-des-paquets';
46
+
47
+ // The language the docs/INTERFACE.md under <dossier> names (`**Langage** : <nom>`), null for none.
48
+ function langageDeLInterface(dossier) {
49
+ const f = path.join(dossier, 'docs', 'INTERFACE.md');
50
+ if (!existsSync(f)) {
51
+ return null;
52
+ }
53
+ const m = readFileSync(f, 'utf8').match(/^\*\*Langage\*\*\s*:\s*(.+)$/m);
54
+ return m ? langageDeLaCellule(m[1]) || null : null;
55
+ }
56
+
57
+ /**
58
+ * The findings of the guard on the project at <racine>: `{ fichier, ligne?, message }`, none when
59
+ * each package follows the architecture.
60
+ * @param {string} racine the root of the project
61
+ */
62
+ export function constats(racine) {
63
+ langagesDe(racine);
64
+ // Each folder a module of the frame finds, with the components and the modules that find it.
65
+ const dossiers = new Map();
66
+ for (const nom of Object.keys(LANGAGES)) {
67
+ const m = langage(nom);
68
+ for (const c of m.composants(racine)) {
69
+ const d = dossiers.get(c.dossier) ?? { composants: [], modules: [] };
70
+ d.composants.push(c);
71
+ d.modules.push(m);
72
+ dossiers.set(c.dossier, d);
73
+ }
74
+ }
75
+ // The root, which a row names `.` when no module makes a component of it.
76
+ const laRacine = { dossier: racine, nom: '.', paquet: null };
77
+ const tous = [...[...dossiers.values()].flatMap(d => d.composants), laRacine];
78
+ // The rows that declare a package, each table read by its own column of the names.
79
+ const declarees = tableauxDesComposants(racine).flatMap(t => {
80
+ const lignes = t.lignes.filter(l => langageDeLaCellule(l.cellules[t.colonne]));
81
+ const colonne = colonneDesNoms(lignes, tous, racine, t.colonne);
82
+ return colonne < 0
83
+ ? []
84
+ : lignes.map(l => ({
85
+ index: l.index,
86
+ langage: langageDeLaCellule(l.cellules[t.colonne]),
87
+ noms: nomsDe(l.cellules[colonne]),
88
+ }));
89
+ });
90
+ const ligneDe = composants =>
91
+ declarees.find(l => composants.some(c => nomme(l.noms, c, racine))) ?? null;
92
+ const rel = d => path.relative(racine, d).split(path.sep).join('/') || '.';
93
+ const ou = l => `${ARCHITECTURE}:${l.index + 1}`;
94
+ const out = [];
95
+ const interface_ = (dossier, l) => {
96
+ const lu = langageDeLInterface(dossier);
97
+ if (lu !== null && lu !== l.langage) {
98
+ const f = rel(path.join(dossier, 'docs', 'INTERFACE.md'));
99
+ out.push({
100
+ fichier: f,
101
+ message: `${f} : langage ${lu}, quand ${ou(l)} déclare ${l.langage} ; l'interface reprend le langage de l'architecture.`,
102
+ });
103
+ }
104
+ };
105
+ const vus = new Set();
106
+ for (const [dossier, { composants, modules }] of dossiers) {
107
+ const avec = modules.filter(m => existsSync(path.join(dossier, m.manifeste)));
108
+ const l = ligneDe(composants);
109
+ if (!l) {
110
+ if (avec.length) {
111
+ out.push({
112
+ fichier: ARCHITECTURE,
113
+ message: `${rel(dossier)} : paquet ${avec[0].nom} (son ${avec[0].manifeste}) que ${ARCHITECTURE} ne déclare pas ; sa ligne d'un tableau des composants nomme son langage (colonne « ${COLONNE} »).`,
114
+ });
115
+ }
116
+ continue;
117
+ }
118
+ vus.add(l);
119
+ const declare = langage(l.langage);
120
+ const autre = avec.find(m => m !== declare);
121
+ if (modules.includes(declare) && existsSync(path.join(dossier, declare.manifeste))) {
122
+ // The package follows its row.
123
+ } else if (autre) {
124
+ out.push({
125
+ fichier: ARCHITECTURE,
126
+ ligne: l.index + 1,
127
+ message: `${rel(dossier)} : déclaré ${l.langage} (${ou(l)}), mais son manifeste est celui de ${autre.nom} (${autre.manifeste}) ; un paquet ${l.langage} porte son ${declare.manifeste}.`,
128
+ });
129
+ } else {
130
+ out.push({
131
+ fichier: ARCHITECTURE,
132
+ ligne: l.index + 1,
133
+ message: `${rel(dossier)} : déclaré ${l.langage} (${ou(l)}), sans son ${declare.manifeste}.`,
134
+ });
135
+ }
136
+ interface_(dossier, l);
137
+ }
138
+ const l = ligneDe([laRacine]);
139
+ if (l && !vus.has(l)) {
140
+ interface_(racine, l);
141
+ }
142
+ // A row that names a folder of the project no module finds: the package without its manifest.
143
+ for (const d of declarees.filter(x => !vus.has(x) && x !== l)) {
144
+ const manifeste = langage(d.langage).manifeste;
145
+ for (const n of d.noms.filter(x => existsSync(path.join(racine, x)) && x !== '.')) {
146
+ if (statSync(path.join(racine, n)).isDirectory()) {
147
+ out.push({
148
+ fichier: ARCHITECTURE,
149
+ ligne: d.index + 1,
150
+ message: `${n} : déclaré ${d.langage} (${ou(d)}), sans son ${manifeste}.`,
151
+ });
152
+ }
153
+ }
154
+ }
155
+ return out;
156
+ }
157
+
158
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
159
+ const racine = process.cwd();
160
+ let refus;
161
+ try {
162
+ refus = constats(racine);
163
+ } catch (e) {
164
+ refus = [{ message: e.message.replace(/^⛔ /, '') }];
165
+ }
166
+ for (const r of refus) {
167
+ process.stderr.write(`⛔ ${r.message}\n`);
168
+ }
169
+ ecrireSarif({ garde: GARDE, racine, constats: refus });
170
+ process.exitCode = refus.length ? 1 : 0;
171
+ }
@@ -1,32 +1,45 @@
1
- // The join of the languages: the module of language that serves a project, as Pants activates the
2
- // backends its configuration names (`backend_packages`). The core asks it what docs/INTERFACE.md
1
+ // The join of the languages: the modules of language that serve a project, as Pants activates the
2
+ // backends its configuration names (`backend_packages`). The core asks them what docs/INTERFACE.md
3
3
  // writes and scripts/jointure.d.ts types, and imports no other file of a module of language.
4
4
  //
5
- // - A project declares its languages in its package.json, `grillhouse.langages`, a list of names
6
- // of the frame's closed list (`LANGAGES`), each a module under `scripts/langages/<nom>/`. The
7
- // declaration is the only reading: a project that declares none, or a directory without
8
- // package.json, is refused, named, with the command that writes it (`grillhouse maj`).
9
- // - What the update writes is what the modules find in the repository (`langagesTrouves`), as each
10
- // plugin of Nx infers its projects from its own files (`createNodes`): each module answers by
11
- // its `trouve`.
12
- // - One language is served: a declaration of several is refused, each named; a name out of the
13
- // list is refused, the list named.
5
+ // - A project declares the language of each package at its design, in the column « Langage » of
6
+ // the table of the components of its docs/ARCHITECTURE.md (./tableau-des-composants.mjs), as
7
+ // the BUILD file of Bazel names the rule of each target: nothing is guessed from the files. Its
8
+ // languages are the set of that column, in every table that holds it, each a name of the
9
+ // frame's closed list (`LANGAGES`), a module under `scripts/langages/<nom>/`. That column is the only reading (`langagesDeclares`,
10
+ // the one function that reads it): a project that declares none is refused, named, with the
11
+ // column to write. The guard of the languages (./langages-des-paquets.mjs) judges each package
12
+ // against its row.
13
+ // - A project has several languages, a package one, as Bazel and Nx run one list of targets, one
14
+ // tool per language: `langagesDe` gives the declared modules, in the order of the table, and
15
+ // `langageDe` their join (./composition-des-langages.mjs), which gives each file to the module
16
+ // of its component, the module itself when one is declared. A name out of the list is refused,
17
+ // named.
14
18
  // - A module is loaded once per process, synchronously (`require` of an ES module, Node 22): the
15
19
  // locks and the guards ask it in a hook, where nothing waits.
16
- import { readFileSync } from 'node:fs';
17
20
  import { createRequire } from 'node:module';
18
21
  import path from 'node:path';
22
+ import { composer } from './composition-des-langages.mjs';
23
+ import {
24
+ ARCHITECTURE,
25
+ COLONNE,
26
+ langageDeLaCellule,
27
+ tableauxDesComposants,
28
+ } from './tableau-des-composants.mjs';
19
29
 
20
30
  // The frame's languages, each its module, from this directory.
21
31
  export const LANGAGES = {
22
32
  typescript: './langages/typescript/index.mjs',
23
33
  cargo: './langages/cargo/index.mjs',
34
+ python: './langages/python/index.mjs',
24
35
  };
25
36
 
26
37
  const requis = createRequire(import.meta.url);
27
38
  const charges = new Map();
28
39
  const charger = nom => {
29
- if (!charges.has(nom)) {charges.set(nom, requis(LANGAGES[nom]).default);}
40
+ if (!charges.has(nom)) {
41
+ charges.set(nom, requis(LANGAGES[nom]).default);
42
+ }
30
43
  return charges.get(nom);
31
44
  };
32
45
 
@@ -37,49 +50,55 @@ const charger = nom => {
37
50
  */
38
51
  export const langage = nom => charger(nom);
39
52
 
40
- // The languages the project at <racine> declares (`grillhouse.langages` of its package.json), an
41
- // empty list when it declares none.
53
+ /**
54
+ * The languages the project at <racine> declares: the cells of the column « Langage » of the tables
55
+ * of the components of its docs/ARCHITECTURE.md (./tableau-des-composants.mjs), each once, in the
56
+ * order of the document; an empty list without document, table or language.
57
+ * @param {string} racine the root of the project
58
+ * @returns {string[]}
59
+ */
42
60
  export function langagesDeclares(racine) {
43
- let declares;
44
- try {
45
- declares = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'))?.grillhouse
46
- ?.langages;
47
- } catch {
48
- declares = undefined;
49
- }
50
- return Array.isArray(declares) ? declares.map(String) : [];
51
- }
52
-
53
- // The languages of the frame whose module finds its code in the repository at <racine>, in the
54
- // order of the list.
55
- export function langagesTrouves(racine) {
56
- return Object.keys(LANGAGES).filter(nom => charger(nom).trouve(racine));
61
+ const noms = tableauxDesComposants(racine).flatMap(t =>
62
+ t.lignes.map(l => langageDeLaCellule(l.cellules[t.colonne])).filter(Boolean)
63
+ );
64
+ return [...new Set(noms)];
57
65
  }
58
66
 
59
67
  /**
60
- * The module of the language that serves the project at <racine>. Throws when the project
61
- * declares none, a language out of the frame's list, or several.
68
+ * The modules of the languages the project at <racine> declares, in the order of the table.
69
+ * Throws when it declares none, or a language out of the frame's list.
62
70
  * @param {string} racine the root of the project
63
- * @returns {import('./jointure.js').Langage}
71
+ * @returns {import('./jointure.js').Langage[]}
64
72
  */
65
- export function langageDe(racine) {
73
+ export function langagesDe(racine) {
66
74
  const noms = langagesDeclares(racine);
67
- const fichier = path.join(racine, 'package.json');
75
+ const fichier = path.join(racine, ARCHITECTURE);
68
76
  if (noms.length === 0) {
69
77
  throw new Error(
70
- `⛔ ${fichier} ne déclare aucun langage (grillhouse.langages) ; \`npx grillhouse maj\` l'écrit d'après ce qu'il trouve (les langages du cadre : ${Object.keys(LANGAGES).join(', ')}).`
78
+ `⛔ ${fichier} ne déclare aucun langage : la colonne « ${COLONNE} » de son tableau des composants nomme le langage de chaque paquet (le grill l'écrit, branche 8 ; \`npx grillhouse maj\` y reporte la déclaration d'une version antérieure du cadre ; les langages du cadre : ${Object.keys(LANGAGES).join(', ')}).`
71
79
  );
72
80
  }
73
81
  const inconnus = noms.filter(n => !Object.hasOwn(LANGAGES, n));
74
82
  if (inconnus.length) {
75
83
  throw new Error(
76
- `⛔ langage inconnu du cadre : ${inconnus.join(', ')} (grillhouse.langages de ${fichier}) ; les langages du cadre : ${Object.keys(LANGAGES).join(', ')}.`
84
+ `⛔ langage inconnu du cadre : ${inconnus.join(', ')} (colonne « ${COLONNE} » de ${fichier}) ; les langages du cadre : ${Object.keys(LANGAGES).join(', ')}.`
77
85
  );
78
86
  }
79
- if (noms.length > 1) {
80
- throw new Error(
81
- `⛔ ${noms.join(', ')} : le cadre sert un seul langage par projet (grillhouse.langages de ${fichier}).`
82
- );
87
+ return noms.map(charger);
88
+ }
89
+
90
+ const composes = new Map();
91
+ /**
92
+ * The join of the modules that serve the project at <racine> (`langagesDe`): the module itself
93
+ * when the project declares one, else their composition, built once per list of languages.
94
+ * @param {string} racine the root of the project
95
+ * @returns {import('./jointure.js').Composition}
96
+ */
97
+ export function langageDe(racine) {
98
+ const modules = langagesDe(racine);
99
+ const cle = modules.map(m => m.nom).join('+');
100
+ if (!composes.has(cle)) {
101
+ composes.set(cle, composer(modules));
83
102
  }
84
- return charger(noms[0]);
103
+ return composes.get(cle);
85
104
  }
@@ -0,0 +1,182 @@
1
+ // From 0.27.0 the language of each package is declared at the design, in the column « Langage »
2
+ // of the table of the components of docs/ARCHITECTURE.md (decision D8 of grillhouse-1zu, as the
3
+ // BUILD file of Bazel names the rule of each target): the architecture is the one source of the
4
+ // languages, and the key `grillhouse.langages` of the package.json, which named them before,
5
+ // disappears.
6
+ //
7
+ // - A project whose package.json holds the key: the declaration is written in the column when it
8
+ // lacks, then the key is removed (the section `grillhouse` with it, when it held nothing else).
9
+ // A table whose column holds a language already: the key alone is removed.
10
+ // - The table: the first table of docs/ARCHITECTURE.md where a cell names a component of the
11
+ // modules of the key (./tableau-des-composants.mjs), as the project wrote it (BPScript's names
12
+ // the phase before the package, SyntHub's the crates of other repositories). The column is added
13
+ // at the end of its header, of its separator, in their style, and of each row: the language of
14
+ // the component the row names, empty for a row that names none. A package of the modules (its
15
+ // manifest in its folder) that no row names goes to a section « Les paquets » that ends the
16
+ // document (written when absent), a table `Paquet | Langage`, one row each: a table that says
17
+ // « each stage does a step » (BPScript's) receives no row without its step. A language of the
18
+ // key that no package carries has a row naming the root, `.`, there. The text of the document is
19
+ // kept otherwise.
20
+ // - `aReporter`: whether a project holds the former declaration, which the session start names
21
+ // with `npx grillhouse maj`, which reports it.
22
+ // - A key that names a language the frame lacks, or whose modules claim one folder twice, is left
23
+ // to the project (`aFaire`), nothing written.
24
+ // - A project without the key, or already migrated, is not written: a second pass changes nothing.
25
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
26
+ import path from 'node:path';
27
+ import { composantsRanges } from '../composition-des-langages.mjs';
28
+ import { LANGAGES, langage } from '../langages.mjs';
29
+ import {
30
+ ARCHITECTURE,
31
+ COLONNE,
32
+ colonneDesNoms,
33
+ nomme,
34
+ nomsDe,
35
+ tableauxDesComposants,
36
+ tableaux,
37
+ } from '../tableau-des-composants.mjs';
38
+
39
+ export const version = '0.27.0';
40
+ export const nom = 'langages dans l’architecture';
41
+
42
+ const lireJson = f => JSON.parse(readFileSync(f, 'utf8'));
43
+ const ecrireJson = (f, v) => writeFileSync(f, `${JSON.stringify(v, null, 2)}\n`);
44
+
45
+ // A row of Markdown of <cellules>, an empty cell a single space.
46
+ const ligne = cellules => `|${cellules.map(c => (c ? ` ${c} ` : ' ')).join('|')}|`;
47
+
48
+ // <texte> of a line of a table, <ajout> cells added at its end (each a text, empty for none),
49
+ // padded first to <largeur> cells; a separator <sep> takes its own style.
50
+ function prolonger(texte, nombre, largeur, ajout, sep = null) {
51
+ const base = texte.replace(/\s+$/, '');
52
+ const ferme = base.endsWith('|') ? base : `${base} |`;
53
+ const vides = Array.from({ length: Math.max(0, largeur - nombre) }, () => '');
54
+ const cellules = [...vides, ...ajout];
55
+ if (sep !== null) {
56
+ return ferme + cellules.map(() => `${sep}|`).join('');
57
+ }
58
+ return ferme + cellules.map(c => (c ? ` ${c} |` : ' |')).join('');
59
+ }
60
+
61
+ // Removes the key from the package.json <f>, its read <p>.
62
+ function retirerLaCle(f, p) {
63
+ const { langages: _, ...reste } = p.grillhouse;
64
+ const out = { ...p };
65
+ if (Object.keys(reste).length) {
66
+ out.grillhouse = reste;
67
+ } else {
68
+ delete out.grillhouse;
69
+ }
70
+ ecrireJson(f, out);
71
+ }
72
+
73
+ // The former declaration of the project at <projet>, the list of its package.json; null without.
74
+ function cleDe(projet) {
75
+ const f = path.join(projet, 'package.json');
76
+ if (!existsSync(f)) {
77
+ return null;
78
+ }
79
+ const cle = lireJson(f).grillhouse?.langages;
80
+ return Array.isArray(cle) ? cle : null;
81
+ }
82
+
83
+ /** Whether the project at <projet> holds the former declaration, which `maj` reports. */
84
+ export const aReporter = projet => cleDe(projet) !== null;
85
+
86
+ export function migrer(projet) {
87
+ const cle = cleDe(projet);
88
+ if (cle === null) {
89
+ return [];
90
+ }
91
+ const f = path.join(projet, 'package.json');
92
+ const p = lireJson(f);
93
+ const ecrites = tableauxDesComposants(projet).some(x =>
94
+ x.lignes.some(l => (l.cellules[x.colonne] ?? '').trim())
95
+ );
96
+ if (ecrites) {
97
+ retirerLaCle(f, p);
98
+ return [
99
+ `grillhouse.langages retiré du package.json : ${ARCHITECTURE} déclare les langages (colonne « ${COLONNE} »).`,
100
+ ];
101
+ }
102
+ const inconnus = cle.filter(n => !Object.hasOwn(LANGAGES, n));
103
+ if (inconnus.length) {
104
+ return [
105
+ {
106
+ aFaire: `grillhouse.langages nomme ${inconnus.join(', ')}, que le cadre n'a pas (ses langages : ${Object.keys(LANGAGES).join(', ')}) ; écrire le langage de chaque paquet dans la colonne « ${COLONNE} » de ${ARCHITECTURE}, puis retirer la clé.`,
107
+ },
108
+ ];
109
+ }
110
+ let ranges;
111
+ try {
112
+ ranges = composantsRanges(cle.map(langage), projet);
113
+ } catch (e) {
114
+ return [{ aFaire: e.message.replace(/^⛔ /, '') }];
115
+ }
116
+ const doc = path.join(projet, ARCHITECTURE);
117
+ const texte = existsSync(doc) ? readFileSync(doc, 'utf8') : '# Architecture\n';
118
+ const composants = ranges.map(r => r.composant);
119
+ const paquets = ranges.filter(r =>
120
+ existsSync(path.join(r.composant.dossier, r.module.manifeste))
121
+ );
122
+ const nommes = new Set();
123
+ const lignes = texte.split('\n');
124
+ const table = tableaux(texte).find(x => colonneDesNoms(x.lignes, composants, projet) >= 0);
125
+ const nomDe = c => `\`${c.nom}\``;
126
+ if (table) {
127
+ const colonne = colonneDesNoms(table.lignes, composants, projet);
128
+ const largeur = Math.max(table.entete.length, ...table.lignes.map(l => l.cellules.length));
129
+ const sep = lignes[table.ligneEntete + 1].includes(' -') ? ' --- ' : '---';
130
+ lignes[table.ligneEntete] = prolonger(lignes[table.ligneEntete], table.entete.length, largeur, [
131
+ COLONNE,
132
+ ]);
133
+ lignes[table.ligneEntete + 1] = prolonger(
134
+ lignes[table.ligneEntete + 1],
135
+ table.entete.length,
136
+ largeur,
137
+ [''],
138
+ sep
139
+ );
140
+ for (const l of table.lignes) {
141
+ const r = ranges.find(x => nomme(nomsDe(l.cellules[colonne]), x.composant, projet));
142
+ if (r) {
143
+ nommes.add(r);
144
+ }
145
+ lignes[l.index] = prolonger(lignes[l.index], l.cellules.length, largeur, [
146
+ r ? r.module.nom : '',
147
+ ]);
148
+ }
149
+ }
150
+ const ajout = [
151
+ ...paquets
152
+ .filter(r => !nommes.has(r))
153
+ .map(r => ({ nom: nomDe(r.composant), langage: r.module.nom })),
154
+ ...racines(cle, [...nommes, ...paquets]),
155
+ ];
156
+ if (ajout.length) {
157
+ while (lignes.length && lignes.at(-1).trim() === '') {
158
+ lignes.pop();
159
+ }
160
+ lignes.push(
161
+ '',
162
+ '## Les paquets',
163
+ '',
164
+ `Les paquets qu’aucun tableau ne nomme, et leur langage (colonne « ${COLONNE} »).`,
165
+ '',
166
+ ligne(['Paquet', COLONNE]),
167
+ ligne(['---', '---']),
168
+ ...ajout.map(r => ligne([r.nom, r.langage])),
169
+ ''
170
+ );
171
+ }
172
+ mkdirSync(path.dirname(doc), { recursive: true });
173
+ writeFileSync(doc, lignes.join('\n'));
174
+ retirerLaCle(f, p);
175
+ return [
176
+ `${ARCHITECTURE} : la colonne « ${COLONNE} » déclare le langage de chaque paquet (${cle.join(', ')}), grillhouse.langages retiré du package.json.`,
177
+ ];
178
+ }
179
+
180
+ // The rows naming the root, `.`, for each language of <cle> that none of <portes> carries.
181
+ const racines = (cle, portes) =>
182
+ cle.filter(n => !portes.some(r => r.module.nom === n)).map(n => ({ nom: '`.`', langage: n }));
@@ -31,6 +31,7 @@ import * as circuitSimplifie from './migrations/0.24.0-circuit-simplifie.mjs';
31
31
  import * as apiExtractorDuPaquet from './migrations/0.24.2-api-extractor-du-paquet.mjs';
32
32
  import * as triDesDecouvertes from './migrations/0.24.12-tri-des-decouvertes.mjs';
33
33
  import * as scriptDesTests from './migrations/0.25.0-script-des-tests.mjs';
34
+ import * as langagesDansLArchitecture from './migrations/0.27.0-langages-dans-l-architecture.mjs';
34
35
 
35
36
  /** The migrations of the core. */
36
37
  export const MIGRATIONS = [
@@ -42,6 +43,7 @@ export const MIGRATIONS = [
42
43
  apiExtractorDuPaquet,
43
44
  triDesDecouvertes,
44
45
  scriptDesTests,
46
+ langagesDansLArchitecture,
45
47
  ];
46
48
 
47
49
  /**
@@ -129,7 +129,7 @@ export function lireOutils(
129
129
 
130
130
  // The main tree of the repository that holds <dir>, from git's common directory; <dir> itself out
131
131
  // of a repository.
132
- function arbrePrincipal(dir) {
132
+ export function arbrePrincipal(dir) {
133
133
  const r = spawnSync(
134
134
  'git',
135
135
  ['-C', dir, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
@@ -11,8 +11,13 @@
11
11
  # written; the session start goes on. Without the key (or with null), nothing runs; a value that is
12
12
  # not a non-blank string runs nothing and adds a line that says so. An agent's copy does not play it.
13
13
  #
14
- # The project's language: a package.json without `grillhouse.langages` (scripts/langages.mjs)
15
- # joins « Manque » as « la déclaration du langage », with `npx grillhouse maj`, which writes it.
14
+ # The project's languages: a project whose docs/ARCHITECTURE.md declares none (the column
15
+ # « Langage » of its table of the components, scripts/langages.mjs) joins « Manque » as « le
16
+ # langage de chaque paquet », with the grill, which writes it, or with `npx grillhouse maj` for a
17
+ # project that holds the declaration of a former version, which it reports. A document of the project that holds
18
+ # a field <…> of its template (the template's docs/ARCHITECTURE.md declares its language, its
19
+ # other fields left to the grill) is not yet written: it stays under « Pas encore renseignés », and
20
+ # the line of the night waits for it.
16
21
  #
17
22
  # The frame's plugins: scripts/greffons.mjs --absents reads `.claude/settings.json` and
18
23
  # `claude plugin list --json` (each call stopped after 5 s). Each declared plugin not installed for
@@ -69,10 +74,23 @@ if [ -z "$copie_agent" ]; then
69
74
  [ -d "$root/.codegraph" ] || missing+=("l'index CodeGraph du code (\`codegraph init .\`)")
70
75
  fi
71
76
  [ ! -f "$root/package.json" ] || [ -d "$root/node_modules" ] || missing+=("les dépendances npm (\`npm install\`)")
72
- # The project's language (scripts/langages.mjs): a package.json without `grillhouse.langages` is
73
- # refused by the frame's scripts and locks until the update writes it.
74
- if [ -f "$root/package.json" ] && ! node -e 'const l=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"))?.grillhouse?.langages;process.exit(Array.isArray(l)&&l.length>0?0:1)' "$root/package.json" 2>/dev/null; then
75
- missing+=("la déclaration du langage (grillhouse.langages du package.json : \`npx grillhouse maj\` l'écrit)")
77
+ # The project's languages (scripts/langages.mjs): a project whose docs/ARCHITECTURE.md declares
78
+ # none (the column « Langage » of its table of the components) is refused by the frame's scripts
79
+ # and locks until the grill writes it, or, for a project that holds the declaration of a former
80
+ # version (the migration of 0.27.0, `aReporter`), until `npx grillhouse maj` reports it. The
81
+ # reading gives « declare », « maj » or « grill ».
82
+ if [ -f "$root/package.json" ]; then
83
+ langues="$(node --input-type=module -e '
84
+ const { pathToFileURL } = await import("node:url");
85
+ const { langagesDeclares } = await import(pathToFileURL(process.argv[1]).href);
86
+ const { aReporter } = await import(pathToFileURL(process.argv[2]).href);
87
+ process.stdout.write(langagesDeclares(process.argv[3]).length > 0 ? "declare" : aReporter(process.argv[3]) ? "maj" : "grill");
88
+ ' "$ici/langages.mjs" "$ici/migrations/0.27.0-langages-dans-l-architecture.mjs" "$root" 2>/dev/null)"
89
+ case "$langues" in
90
+ declare) ;;
91
+ maj) missing+=("le langage de chaque paquet (colonne « Langage » du tableau des composants de docs/ARCHITECTURE.md : \`npx grillhouse maj\` y reporte la déclaration du package.json)") ;;
92
+ *) missing+=("le langage de chaque paquet (colonne « Langage » du tableau des composants de docs/ARCHITECTURE.md : le grill l'écrit, branche 8)") ;;
93
+ esac
76
94
  fi
77
95
  # The frame's plugins not installed for the project (scripts/greffons.mjs): the plugins are the
78
96
  # machine's installation for the project, so an agent's copy does not read them.
@@ -97,12 +115,19 @@ command -v bwrap >/dev/null || missing+=("bubblewrap (bwrap), l'enveloppe des ag
97
115
 
98
116
  # The key elements the skills read; each one still empty is proposed for a grill.
99
117
  pending=()
118
+ # Whether the document <$1> holds a field <…> of its template, outside code spans.
119
+ a_des_champs() {
120
+ node -e 'const t=require("fs").readFileSync(process.argv[1],"utf8").replace(/`[^`]*`/g,"");process.exit(/<[^<>\n]+>/.test(t)?0:1)' "$1"
121
+ }
122
+ # Whether the document <$1> is written: present, without a field of its template (the template's
123
+ # docs/ARCHITECTURE.md holds the declaration of its language, its fields left to the grill).
124
+ ecrit() { [ -f "$1" ] && ! a_des_champs "$1"; }
100
125
  charter="$root/CLAUDE.md"
101
126
  if [ ! -f "$charter" ]; then
102
127
  pending+=("la charte (CLAUDE.md)")
103
128
  else
104
129
  # an unfilled field of the charter template: <…> outside code spans
105
- node -e 'const t=require("fs").readFileSync(process.argv[1],"utf8").replace(/`[^`]*`/g,"");process.exit(/<[^<>\n]+>/.test(t)?0:1)' "$charter" \
130
+ a_des_champs "$charter" \
106
131
  && pending+=("les champs <…> encore vides de la charte (CLAUDE.md)")
107
132
  # the arbitration criteria: a heading about arbitration in the charter or a reference document
108
133
  grep -qiE '^#+ .*(arbitr)' "$charter" "$root"/docs/*.md 2>/dev/null \
@@ -129,7 +154,7 @@ if ls -d "$root"/packages/*/ >/dev/null 2>&1; then
129
154
  done
130
155
  else
131
156
  for doc in ARCHITECTURE CADRE INTERFACE; do
132
- [ -f "$root/docs/$doc.md" ] || pending+=("docs/$doc.md")
157
+ ecrit "$root/docs/$doc.md" || pending+=("docs/$doc.md")
133
158
  done
134
159
  fi
135
160
  [ -f "$root/CONTEXT.md" ] || pending+=("le lexique du domaine (CONTEXT.md)")
@@ -182,7 +207,7 @@ fi
182
207
  # (the frame's script before the package, 0.24.0; a relative path after `cd <root>`), is named
183
208
  # with the line that replaces it, as brew doctor names a configuration that aims at a missing path.
184
209
  nuit_absente=
185
- if [ -f "$root/docs/ARCHITECTURE.md" ]; then
210
+ if ecrit "$root/docs/ARCHITECTURE.md"; then
186
211
  noeud="$(dirname "$(command -v node)")"
187
212
  table="$(crontab -l 2>/dev/null | grep -v '^[[:space:]]*#')"
188
213
  if ! printf '%s\n' "$table" | grep -F "cd $root && node_modules/.bin/grillhouse nuit" | grep -qF "PATH=$noeud:"; then
@@ -6,7 +6,8 @@
6
6
  // dist, coverage, .claude, .beads, .codegraph, .rtfm), and what the tools of the project's
7
7
  // language write (`ignorer` of its module, scripts/jointure.d.ts: typescript's `.turbo`, cargo's
8
8
  // `target`), as git leaves out what a `.gitignore` names. A project that declares no language
9
- // (`grillhouse.langages`) leaves out what every language of the frame writes.
9
+ // (the column « Langage » of its docs/ARCHITECTURE.md) leaves out what every language of the
10
+ // frame writes.
10
11
  import { readdirSync } from 'node:fs';
11
12
  import path from 'node:path';
12
13
  import { LANGAGES, langage, langageDe, langagesDeclares } from './langages.mjs';
@@ -7,9 +7,10 @@
7
7
  // (`circuit`, `tableau`); `maj` runs `grillhouse-maj.mjs`, whose name already says the frame's;
8
8
  // `hooks` (`crochets.mjs`, which places the git hooks) and `hook` (`crochet.mjs`, which runs one)
9
9
  // take Husky's names, which a project's `prepare` and its git hooks call.
10
- // - `tests` and `verifier` run the commands the module of the project's language describes
11
- // (`commandes`, scripts/jointure.d.ts: `tester` and `verifier`), the project being the working
12
- // directory (scripts/langages.mjs); each other command it describes but `typer` is a subcommand
10
+ // - `tests` and `verifier` run the commands the modules of the project's languages describe
11
+ // (`commandes`, scripts/jointure.d.ts: `tester` and `verifier`; for several languages, the
12
+ // composed command, scripts/commandes-composees.mjs), the project being the working directory
13
+ // (scripts/langages.mjs); each other command it describes but `typer` is a subcommand
13
14
  // by its name (`frontieres`, `index-interfaces`), as a backend of Pants brings its goals.
14
15
  import path from 'node:path';
15
16
  import { fileURLToPath } from 'node:url';
@@ -34,6 +35,7 @@ export const SOUS_COMMANDES = {
34
35
  hook: 'crochet.mjs',
35
36
  hooks: 'crochets.mjs',
36
37
  init: 'init.mjs',
38
+ 'langages-des-paquets': 'langages-des-paquets.mjs',
37
39
  integrer: 'integration/integrer.mjs',
38
40
  lancer: 'enveloppe/lancer.sh',
39
41
  'ligne-etat': 'ligne-etat/ligne-etat.mjs',