@roomi-fields/grillhouse 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +30 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/dist/temporal/circuit/client.d.ts +2 -2
  8. package/dist/temporal/circuit/client.js.map +1 -1
  9. package/dist/temporal/circuit/commande.js +4 -4
  10. package/dist/temporal/circuit/commande.js.map +1 -1
  11. package/dist/temporal/circuit/contrat.d.ts +3 -3
  12. package/dist/temporal/circuit/contrat.js +8 -2
  13. package/dist/temporal/circuit/contrat.js.map +1 -1
  14. package/dist/temporal/circuit/deroule.js +3 -3
  15. package/dist/temporal/circuit/deroule.js.map +1 -1
  16. package/dist/temporal/commande.js +5 -6
  17. package/dist/temporal/commande.js.map +1 -1
  18. package/dist/temporal/installation.d.ts +0 -4
  19. package/dist/temporal/installation.js +12 -34
  20. package/dist/temporal/installation.js.map +1 -1
  21. package/docs/ARCHITECTURE.md +49 -19
  22. package/docs/CADRE.md +10 -0
  23. package/docs/INTERFACE.md +8 -3
  24. package/package.json +2 -2
  25. package/scripts/activites.mjs +150 -77
  26. package/scripts/aiguillage.mjs +33 -11
  27. package/scripts/avancement.mjs +27 -10
  28. package/scripts/bilan.mjs +101 -25
  29. package/scripts/cadre.mjs +5 -2
  30. package/scripts/circuit.mjs +153 -57
  31. package/scripts/composants-affectes.mjs +64 -21
  32. package/scripts/composition-des-langages.mjs +5 -3
  33. package/scripts/conformite.mjs +54 -19
  34. package/scripts/dependances-internes.mjs +9 -3
  35. package/scripts/dernier-vert.mjs +54 -19
  36. package/scripts/dette.mjs +32 -11
  37. package/scripts/donnees-cles.mjs +24 -8
  38. package/scripts/droits.mjs +40 -15
  39. package/scripts/empreinte-d-etape.mjs +17 -0
  40. package/scripts/engendres.mjs +15 -5
  41. package/scripts/enveloppe/enveloppe.mjs +141 -48
  42. package/scripts/enveloppe/travail-de-la-copie.mjs +36 -12
  43. package/scripts/faits-du-circuit.mjs +1 -1
  44. package/scripts/flux-des-paquets.mjs +21 -7
  45. package/scripts/gardes-du-cadre.mjs +9 -3
  46. package/scripts/init.mjs +11 -4
  47. package/scripts/integration/file.mjs +84 -29
  48. package/scripts/integration/integrer.mjs +70 -24
  49. package/scripts/integration/rejeu.mjs +26 -9
  50. package/scripts/jointure.d.ts +6 -1
  51. package/scripts/langages/cargo/commandes.mjs +97 -18
  52. package/scripts/langages/cargo/composants.mjs +24 -8
  53. package/scripts/langages/cargo/index.mjs +4 -0
  54. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  55. package/scripts/langages/python/commandes.mjs +3 -1
  56. package/scripts/langages/python/index.mjs +4 -0
  57. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  58. package/scripts/langages/typescript/composants.mjs +9 -3
  59. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  60. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  61. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  62. package/scripts/langages/typescript/frontieres.mjs +66 -22
  63. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  64. package/scripts/langages/typescript/index.mjs +10 -3
  65. package/scripts/langages/typescript/interfaces-contre-code.mjs +109 -41
  66. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  67. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  68. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  69. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  70. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +3 -1
  71. package/scripts/langages/typescript/parcours.mjs +12 -4
  72. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  73. package/scripts/langages/typescript/resumes.mjs +9 -3
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +58 -16
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -1
  76. package/scripts/langages/typescript/tests.mjs +24 -8
  77. package/scripts/langages/typescript/titres-de-tests.mjs +35 -12
  78. package/scripts/langages/typescript/turbo-des-paquets.mjs +152 -51
  79. package/scripts/langages/typescript/verdict.mjs +3 -1
  80. package/scripts/langages/typescript/verifier.mjs +28 -10
  81. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  82. package/scripts/langages/typescript/vitest-config/base.mjs +7 -2
  83. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  84. package/scripts/langages/typescript/vitest-config/delais.mjs +9 -3
  85. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +12 -4
  86. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +17 -6
  87. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  88. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -0
  89. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  90. package/scripts/lint-des-scripts.mjs +58 -0
  91. package/scripts/mesure/base-de-passe.mjs +117 -25
  92. package/scripts/mesure/pression.mjs +9 -3
  93. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  94. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  95. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  96. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +48 -16
  97. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  98. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  99. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +6 -2
  100. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +7 -7
  101. package/scripts/nuit.sh +15 -0
  102. package/scripts/outil.mjs +3 -1
  103. package/scripts/outils-cles.mjs +18 -7
  104. package/scripts/paquet-npm.mjs +15 -5
  105. package/scripts/paquets.mjs +12 -4
  106. package/scripts/passe-de-la-machine.mjs +7 -2
  107. package/scripts/places-de-la-machine.mjs +66 -12
  108. package/scripts/preparation.mjs +15 -5
  109. package/scripts/registre.mjs +6 -2
  110. package/scripts/reprise.mjs +66 -0
  111. package/scripts/resultats.mjs +105 -37
  112. package/scripts/seances.mjs +22 -4
  113. package/scripts/services-du-noyau.mjs +1 -0
  114. package/scripts/sous-commandes.mjs +3 -1
  115. package/scripts/style-a-l-ecriture.mjs +48 -17
  116. package/scripts/tableau.mjs +34 -9
  117. package/scripts/taches-du-graphe.mjs +33 -13
  118. package/scripts/ticket-du-circuit.mjs +10 -0
  119. package/scripts/transitions.mjs +141 -24
  120. package/scripts/verrou-de-fichier.mjs +6 -2
  121. package/scripts/verrou-de-machine.mjs +123 -39
  122. package/scripts/verrous/commande.mjs +50 -17
  123. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  124. package/scripts/verrous/verrou.mjs +42 -14
  125. package/skills/explorateur/SKILL.md +7 -1
  126. package/skills/grill/SKILL.md +1 -1
  127. package/skills/mesure/SKILL.md +3 -0
  128. package/skills/relecteur/SKILL.md +1 -1
  129. package/skills/testwriter/SKILL.md +12 -6
@@ -196,6 +196,10 @@ export function composer(modules) {
196
196
  matieres: racine => modules.flatMap(m => m.matieres(racine)),
197
197
  joueDesTests: (racine, composant) =>
198
198
  moduleDuComposant(racine, composant)?.joueDesTests(racine, composant) ?? false,
199
+ empreintes(racine, noms) {
200
+ const parts = modules.map(m => m.empreintes(racine, noms));
201
+ return parts.some(p => p === null) ? null : Object.assign({}, ...parts);
202
+ },
199
203
  lecteurs(racine, o) {
200
204
  const composants = leurs(racine, o.composants);
201
205
  const nommes = leurs(racine, o.nommes);
@@ -261,9 +265,7 @@ export function composer(modules) {
261
265
  estUnTest: (chemin, racine) =>
262
266
  premiereReponse(modules, racine, chemin, m => m.estUnTest(chemin, racine)),
263
267
  horsDuJour: (chemin, racine) =>
264
- Boolean(
265
- premiereReponse(modules, racine, chemin, m => m.horsDuJour(chemin, racine))
266
- ),
268
+ Boolean(premiereReponse(modules, racine, chemin, m => m.horsDuJour(chemin, racine))),
267
269
  soeurDAvant: (chemin, racine) =>
268
270
  premiereReponse(modules, racine, chemin, m =>
269
271
  typeof m.soeurDAvant === 'function' ? m.soeurDAvant(chemin, racine) : null
@@ -42,9 +42,13 @@ import { isDeepStrictEqual } from 'node:util';
42
42
  const preparees = new WeakMap();
43
43
  // The entries of <exemples> under <dans>, prepared once.
44
44
  function entrees(exemples, dans) {
45
- if (!preparees.has(exemples)) preparees.set(exemples, new Map());
45
+ if (!preparees.has(exemples)) {
46
+ preparees.set(exemples, new Map());
47
+ }
46
48
  const parDossier = preparees.get(exemples);
47
- if (!parDossier.has(dans)) parDossier.set(dans, exemples.preparer(dans));
49
+ if (!parDossier.has(dans)) {
50
+ parDossier.set(dans, exemples.preparer(dans));
51
+ }
48
52
  return parDossier.get(dans);
49
53
  }
50
54
 
@@ -53,11 +57,16 @@ function etat(racine) {
53
57
  const out = new Map();
54
58
  const parcourir = d => {
55
59
  for (const n of readdirSync(d)) {
56
- if (n === '.git') continue;
60
+ if (n === '.git') {
61
+ continue;
62
+ }
57
63
  const f = path.join(d, n);
58
64
  const s = statSync(f);
59
- if (s.isDirectory()) parcourir(f);
60
- else out.set(f, s.mtimeMs);
65
+ if (s.isDirectory()) {
66
+ parcourir(f);
67
+ } else {
68
+ out.set(f, s.mtimeMs);
69
+ }
61
70
  }
62
71
  };
63
72
  parcourir(racine);
@@ -99,9 +108,13 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
99
108
  liste.flatMap(({ fichier, composant }) => {
100
109
  const c = langage.composantDe(e.racine, fichier);
101
110
  const rel = path.isAbsolute(fichier) ? path.relative(e.racine, fichier) : fichier;
102
- if (!c) return [`${rel} : hors de tout composant`];
111
+ if (!c) {
112
+ return [`${rel} : hors de tout composant`];
113
+ }
103
114
  const connu = langage.composants(e.racine).some(k => k.dossier === c.dossier);
104
- if (!connu) return [`${rel} : dans ${c.nom}, qui n'est pas un composant`];
115
+ if (!connu) {
116
+ return [`${rel} : dans ${c.nom}, qui n'est pas un composant`];
117
+ }
105
118
  return c.nom === composant ? [] : [`${rel} : dans ${c.nom}, attendu ${composant}`];
106
119
  }),
107
120
  lecteurs: ({ racine, noms }) => {
@@ -120,10 +133,14 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
120
133
  const avant = etat(e.racine);
121
134
  const c = langage.commandes(e.racine);
122
135
  const out = noms.flatMap(n => {
123
- if (!Object.hasOwn(c, n)) return [`${n} : absente`];
136
+ if (!Object.hasOwn(c, n)) {
137
+ return [`${n} : absente`];
138
+ }
124
139
  return decrite(c[n]) ? [] : [`${n} : pas une commande décrite`];
125
140
  });
126
- if (!isDeepStrictEqual(etat(e.racine), avant)) out.push('commandes écrit dans le dépôt');
141
+ if (!isDeepStrictEqual(etat(e.racine), avant)) {
142
+ out.push('commandes écrit dans le dépôt');
143
+ }
127
144
  return out;
128
145
  },
129
146
  verdict: dossier => {
@@ -146,20 +163,34 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
146
163
  estUnTest: chemins =>
147
164
  chemins.flatMap(chemin => {
148
165
  const c = langage.estUnTest(chemin, e.racine);
149
- if (c === null) return [];
166
+ if (c === null) {
167
+ return [];
168
+ }
150
169
  return [`${chemin} : ${['joue', 'test', 'matiere'].filter(k => c[k]).join(', ')}`];
151
170
  }),
152
171
  versionDeHead: entrees =>
153
172
  entrees.flatMap(x => {
154
173
  const { chemin, textes = {} } = typeof x === 'string' ? { chemin: x } : x;
155
- const s = typeof langage.soeurDAvant === 'function' ? langage.soeurDAvant(chemin, e.racine) : null;
156
- const arbre = typeof langage.arbreDAvant === 'function' && langage.arbreDAvant(chemin, e.racine);
174
+ const s =
175
+ typeof langage.soeurDAvant === 'function' ? langage.soeurDAvant(chemin, e.racine) : null;
176
+ const arbre =
177
+ typeof langage.arbreDAvant === 'function' && langage.arbreDAvant(chemin, e.racine);
157
178
  const noms = langage.testsDeHead(chemin, e.racine, f => textes[f] ?? null);
158
- if (s !== null && arbre) return [`${chemin} : une sœur et un arbre`];
159
- if (arbre) return [`${chemin} → un arbre`];
160
- if (s !== null && noms !== null) return [`${chemin} : une sœur et des noms lus`];
161
- if (noms !== null) return [`${chemin} : ${noms.join(', ') || 'aucun test'}`];
162
- if (s === null) return [];
179
+ if (s !== null && arbre) {
180
+ return [`${chemin} : une sœur et un arbre`];
181
+ }
182
+ if (arbre) {
183
+ return [`${chemin} → un arbre`];
184
+ }
185
+ if (s !== null && noms !== null) {
186
+ return [`${chemin} : une sœur et des noms lus`];
187
+ }
188
+ if (noms !== null) {
189
+ return [`${chemin} : ${noms.join(', ') || 'aucun test'}`];
190
+ }
191
+ if (s === null) {
192
+ return [];
193
+ }
163
194
  const aCote = s !== chemin && path.dirname(s) === path.dirname(chemin);
164
195
  return [aCote ? `${chemin} → ${s}` : `${chemin} → ${s} : pas à côté du fichier`];
165
196
  }),
@@ -178,7 +209,9 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
178
209
  },
179
210
  elementsDuLot: ({ racine, avant, apres }) => {
180
211
  const l = langage.elementsDuLot(racine, { avant, apres });
181
- if (l.etat !== 'fait') return [`impossible : ${l.raison}`];
212
+ if (l.etat !== 'fait') {
213
+ return [`impossible : ${l.raison}`];
214
+ }
182
215
  return [
183
216
  ...l.fichiers.map(f => `fichier ${f}`),
184
217
  ...l.horsDuService.map(f => `hors du service ${f}`),
@@ -215,7 +248,9 @@ export function echecs(langage, exemples, options) {
215
248
  return cas(langage, exemples, options).flatMap(c => {
216
249
  try {
217
250
  const v = c.valide();
218
- if (v.length) return [{ nom: c.nom, raison: `entrée valide : ${v.join(' ; ')}` }];
251
+ if (v.length) {
252
+ return [{ nom: c.nom, raison: `entrée valide : ${v.join(' ; ')}` }];
253
+ }
219
254
  const i = c.invalide();
220
255
  if (!isDeepStrictEqual(i, c.attendu)) {
221
256
  return [
@@ -47,7 +47,9 @@ function nomA(langageNom, dossier) {
47
47
  for (const l of [langageNom, ...sansPackageJson()]) {
48
48
  const texte = lire(path.join(dossier, langage(l).manifeste));
49
49
  const nom = texte === null ? null : nomDuManifeste(l, texte);
50
- if (nom !== null) return nom;
50
+ if (nom !== null) {
51
+ return nom;
52
+ }
51
53
  }
52
54
  return null;
53
55
  }
@@ -64,7 +66,9 @@ export function constats(racine) {
64
66
  for (const p of sans) {
65
67
  const f = `${p.chemin}/package.json`;
66
68
  const texte = lire(path.join(racine, f));
67
- if (texte === null) continue;
69
+ if (texte === null) {
70
+ continue;
71
+ }
68
72
  let pkg;
69
73
  try {
70
74
  pkg = JSON.parse(texte);
@@ -80,7 +84,9 @@ export function constats(racine) {
80
84
  );
81
85
  const manquantes = [...duManifeste].filter(n => !duPackage.has(n)).sort();
82
86
  const enTrop = [...duPackage].filter(n => !duManifeste.has(n)).sort();
83
- if (!manquantes.length && !enTrop.length) continue;
87
+ if (!manquantes.length && !enTrop.length) {
88
+ continue;
89
+ }
84
90
  const dits = [
85
91
  ...(manquantes.length
86
92
  ? [
@@ -88,7 +88,9 @@ function brancheDeMain(racine) {
88
88
  // Whether a submodule of the repository at <racine> differs from the commit its parent records.
89
89
  function sousModuleModifie(racine) {
90
90
  const r = git(racine, ['status', '--porcelain=v2', '-z', '--ignore-submodules=none']);
91
- if (r.status !== 0) return true;
91
+ if (r.status !== 0) {
92
+ return true;
93
+ }
92
94
  // An entry of a changed path: `1 <XY> <sub> …` (or `2` for a rename), <sub> `S<c><m><u>` for a
93
95
  // submodule whose commit, tracked files or untracked files changed, `N...` for any other path.
94
96
  return r.stdout.split('\0').some(e => /^[12] \S+ S/.test(e));
@@ -99,21 +101,34 @@ function sousModuleModifie(racine) {
99
101
  // detached) and main (brancheDeMain); `{ raison }` when no last green can count.
100
102
  function etatDuDepot(racine) {
101
103
  const haut = sortie(racine, ['rev-parse', '--show-toplevel']);
102
- if (!haut) return { raison: 'hors de git' };
104
+ if (!haut) {
105
+ return { raison: 'hors de git' };
106
+ }
103
107
  const top = realpathSync(haut);
104
108
  const commit = sortie(top, ['rev-parse', '--verify', '-q', 'HEAD^{commit}']);
105
- if (!commit) return { raison: 'aucun commit' };
106
- if (sousModuleModifie(top)) return { raison: 'un sous-module diffère de son commit' };
109
+ if (!commit) {
110
+ return { raison: 'aucun commit' };
111
+ }
112
+ if (sousModuleModifie(top)) {
113
+ return { raison: 'un sous-module diffère de son commit' };
114
+ }
107
115
  const dir = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-vert-'));
108
116
  try {
109
117
  const index = path.join(dir, 'index');
110
118
  const reel = sortie(top, ['rev-parse', '--path-format=absolute', '--git-path', 'index']);
111
119
  const env = { ...process.env, GIT_INDEX_FILE: index };
112
- if (reel && existsSync(reel)) copyFileSync(reel, index);
113
- else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) return { raison: 'git échoue' };
114
- if (git(top, ['add', '-A'], env).status !== 0) return { raison: 'git échoue' };
120
+ if (reel && existsSync(reel)) {
121
+ copyFileSync(reel, index);
122
+ } else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) {
123
+ return { raison: 'git échoue' };
124
+ }
125
+ if (git(top, ['add', '-A'], env).status !== 0) {
126
+ return { raison: 'git échoue' };
127
+ }
115
128
  const arbre = sortie(top, ['write-tree'], env);
116
- if (!arbre) return { raison: 'git échoue' };
129
+ if (!arbre) {
130
+ return { raison: 'git échoue' };
131
+ }
117
132
  const branche = sortie(top, ['symbolic-ref', '--short', '-q', 'HEAD']);
118
133
  return { racine: top, commit, arbre, branche, main: brancheDeMain(top) };
119
134
  } finally {
@@ -129,7 +144,9 @@ function lireLeVert(etat) {
129
144
  let vert = { raison: 'aucun vert connu' };
130
145
  for (const branche of branches) {
131
146
  vert = lireLeVertDe(etat, branche);
132
- if (!vert.raison) return vert;
147
+ if (!vert.raison) {
148
+ return vert;
149
+ }
133
150
  }
134
151
  return vert;
135
152
  }
@@ -160,7 +177,9 @@ function lireLeVertDe(etat, branche) {
160
177
  export function garderLeVert(etat) {
161
178
  const branche = etat.branche ?? etat.main;
162
179
  const f = branche ? fichierDuVert(etat.racine, branche) : null;
163
- if (!f) return;
180
+ if (!f) {
181
+ return;
182
+ }
164
183
  mkdirSync(path.dirname(f), { recursive: true });
165
184
  writeFileSync(f, `${JSON.stringify({ commit: etat.commit, arbre: etat.arbre }, null, 2)}\n`);
166
185
  }
@@ -169,15 +188,21 @@ export function garderLeVert(etat) {
169
188
  // `{ fichiers, supprimes, sousModules }`, each path from its top; null when git fails.
170
189
  function difference(racine, avant, apres) {
171
190
  const r = git(racine, ['diff', '--raw', '--no-renames', '-z', avant, apres]);
172
- if (r.status !== 0) return null;
191
+ if (r.status !== 0) {
192
+ return null;
193
+ }
173
194
  const champs = r.stdout.split('\0');
174
195
  const out = { fichiers: [], supprimes: [], sousModules: [] };
175
196
  for (let i = 0; i + 1 < champs.length; i += 2) {
176
197
  const [modeAvant, modeApres, , , statut] = champs[i].replace(/^:/, '').split(' ');
177
198
  const f = champs[i + 1];
178
- if (modeAvant === '160000' || modeApres === '160000') out.sousModules.push(f);
179
- else if (statut === 'D') out.supprimes.push(f);
180
- else out.fichiers.push(f);
199
+ if (modeAvant === '160000' || modeApres === '160000') {
200
+ out.sousModules.push(f);
201
+ } else if (statut === 'D') {
202
+ out.supprimes.push(f);
203
+ } else {
204
+ out.fichiers.push(f);
205
+ }
181
206
  }
182
207
  return out;
183
208
  }
@@ -211,18 +236,28 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
211
236
  ligne: `↳ passe complète : ${raison}.`,
212
237
  retirer: () => {},
213
238
  });
214
- if (etat.raison) return complete(etat.raison);
215
- if (tout) return complete('demandée');
239
+ if (etat.raison) {
240
+ return complete(etat.raison);
241
+ }
242
+ if (tout) {
243
+ return complete('demandée');
244
+ }
216
245
  const vert = lireLeVert(etat);
217
- if (vert.raison) return complete(vert.raison);
246
+ if (vert.raison) {
247
+ return complete(vert.raison);
248
+ }
218
249
  const ch = difference(etat.racine, vert.arbre, etat.arbre);
219
- if (!ch) return complete('git échoue');
250
+ if (!ch) {
251
+ return complete('git échoue');
252
+ }
220
253
  if (ch.sousModules.length) {
221
254
  return { ...complete(`un sous-module a changé (${ch.sousModules[0]})`), etat: null };
222
255
  }
223
256
  if (vert.branche !== etat.branche) {
224
257
  const suivis = supprimesDuCommit(etat.racine, vert.commit, etat.arbre);
225
- if (!suivis) return complete('git échoue');
258
+ if (!suivis) {
259
+ return complete('git échoue');
260
+ }
226
261
  ch.supprimes = ch.supprimes.filter(f => suivis.has(f));
227
262
  }
228
263
  const dir = mkdtempSync(path.join(dans, 'grillhouse-changements-'));
package/scripts/dette.mjs CHANGED
@@ -42,7 +42,9 @@ const inscriptible = c => Boolean(c.fichier && c.regle);
42
42
  function compter(constats) {
43
43
  const out = new Map();
44
44
  for (const c of constats.filter(inscriptible)) {
45
- if (!out.has(c.fichier)) out.set(c.fichier, new Map());
45
+ if (!out.has(c.fichier)) {
46
+ out.set(c.fichier, new Map());
47
+ }
46
48
  const parRegle = out.get(c.fichier);
47
49
  parRegle.set(c.regle, (parRegle.get(c.regle) ?? 0) + 1);
48
50
  }
@@ -65,7 +67,9 @@ function section(comptes) {
65
67
  // The debt written at <racine>: {} without the file. Throws, naming the file, when it is not JSON.
66
68
  export function lire(racine) {
67
69
  const f = path.join(racine, FICHIER);
68
- if (!existsSync(f)) return {};
70
+ if (!existsSync(f)) {
71
+ return {};
72
+ }
69
73
  try {
70
74
  return JSON.parse(readFileSync(f, 'utf8'));
71
75
  } catch (e) {
@@ -91,8 +95,12 @@ export function elaguer(dette, garde, constats) {
91
95
  for (const [fichier, regles] of Object.entries(ancienne)) {
92
96
  for (const [regle, { count }] of Object.entries(regles)) {
93
97
  const n = Math.min(count, comptes.get(fichier)?.get(regle) ?? 0);
94
- if (n === 0) continue;
95
- if (!garde2.has(fichier)) garde2.set(fichier, new Map());
98
+ if (n === 0) {
99
+ continue;
100
+ }
101
+ if (!garde2.has(fichier)) {
102
+ garde2.set(fichier, new Map());
103
+ }
96
104
  garde2.get(fichier).set(regle, n);
97
105
  }
98
106
  }
@@ -114,14 +122,18 @@ export function juger(dette, garde, constats) {
114
122
  for (const [fichier, regles] of comptes) {
115
123
  for (const [regle, trouve] of regles) {
116
124
  const inscrit = permis(fichier, regle);
117
- if (inscrit > 0 && trouve > inscrit) depasses.push({ fichier, regle, trouve, inscrit });
125
+ if (inscrit > 0 && trouve > inscrit) {
126
+ depasses.push({ fichier, regle, trouve, inscrit });
127
+ }
118
128
  }
119
129
  }
120
130
  const corriges = [];
121
131
  for (const [fichier, regles] of Object.entries(inscrite)) {
122
132
  for (const [regle, { count }] of Object.entries(regles)) {
123
133
  const trouve = comptes.get(fichier)?.get(regle) ?? 0;
124
- if (trouve < count) corriges.push({ fichier, regle, trouve, inscrit: count });
134
+ if (trouve < count) {
135
+ corriges.push({ fichier, regle, trouve, inscrit: count });
136
+ }
125
137
  }
126
138
  }
127
139
  return { refus, depasses, corriges, tus: constats.length - refus.length };
@@ -170,17 +182,25 @@ function abaisser(racine, notes) {
170
182
  for (const { garde, fichier, regle, trouve } of notes) {
171
183
  const parRegle = dette[garde]?.[fichier];
172
184
  const cle = parRegle?.[regle];
173
- if (!cle || !Number.isInteger(trouve) || trouve >= cle.count) continue;
185
+ if (!cle || !Number.isInteger(trouve) || trouve >= cle.count) {
186
+ continue;
187
+ }
174
188
  if (trouve > 0) {
175
189
  cle.count = trouve;
176
190
  continue;
177
191
  }
178
192
  delete parRegle[regle];
179
- if (!Object.keys(parRegle).length) delete dette[garde][fichier];
180
- if (!Object.keys(dette[garde]).length) delete dette[garde];
193
+ if (!Object.keys(parRegle).length) {
194
+ delete dette[garde][fichier];
195
+ }
196
+ if (!Object.keys(dette[garde]).length) {
197
+ delete dette[garde];
198
+ }
181
199
  }
182
200
  const change = JSON.stringify(dette) !== JSON.stringify(avant);
183
- if (change) ecrire(racine, dette);
201
+ if (change) {
202
+ ecrire(racine, dette);
203
+ }
184
204
  return change;
185
205
  }
186
206
 
@@ -217,8 +237,9 @@ function juge(racine, garde, constats, mode) {
217
237
  `⚠️ ${garde} : ${c.fichier} · ${c.regle} — ${c.trouve} constat(s) pour ${c.inscrit} inscrit(s) dans ${FICHIER} : npm run grillhouse:dette:elaguer retire ce qui est corrigé.`
218
238
  );
219
239
  }
220
- if (tus > 0)
240
+ if (tus > 0) {
221
241
  lignes.push(`ℹ️ ${garde} : ${tus} constat(s) connu(s), inscrit(s) dans ${FICHIER}.`);
242
+ }
222
243
  return { refus, lignes, corriges };
223
244
  }
224
245
 
@@ -40,7 +40,9 @@ const RELEASE = /(^|\s)--release(\s|$)/;
40
40
  // package.json when the tables declare it so, else the language of the package.json.
41
41
  function langageDuPaquet(racine, chemin) {
42
42
  const hors = paquetsSansPackageJson(racine).find(p => p.chemin === chemin);
43
- if (hors) return hors.langage;
43
+ if (hors) {
44
+ return hors.langage;
45
+ }
44
46
  return Object.keys(LANGAGES).find(n => langage(n).manifeste === 'package.json') ?? 'typescript';
45
47
  }
46
48
 
@@ -64,12 +66,16 @@ function lire(dir) {
64
66
  /** @type {Map<string, string[]>} */
65
67
  const fournisseurs = new Map();
66
68
  const racinePkg = lireJson(path.join(racine, 'package.json'));
67
- if (racinePkg === null) return { donnees, parPaquet, fournisseurs, fautes };
69
+ if (racinePkg === null) {
70
+ return { donnees, parPaquet, fournisseurs, fautes };
71
+ }
68
72
  const liste = paquets(racine);
69
73
  const consommateurs = [{ dossier: '.', pkg: racinePkg }, ...liste];
70
74
  for (const { dossier, pkg } of consommateurs) {
71
75
  const d = pkg?.grillhouse?.donnees;
72
- if (d === undefined || d === null) continue;
76
+ if (d === undefined || d === null) {
77
+ continue;
78
+ }
73
79
  const ou = dossier === '.' ? 'package.json' : `${dossier}/package.json`;
74
80
  if (typeof d !== 'object' || Array.isArray(d)) {
75
81
  fautes.push(
@@ -132,7 +138,9 @@ function lire(dir) {
132
138
  */
133
139
  export function donneesDe(dir) {
134
140
  const { donnees, fautes } = lire(dir);
135
- if (fautes.length) throw new Error(fautes.join('\n'));
141
+ if (fautes.length) {
142
+ throw new Error(fautes.join('\n'));
143
+ }
136
144
  return donnees;
137
145
  }
138
146
 
@@ -146,7 +154,9 @@ export function donneesDe(dir) {
146
154
  */
147
155
  export function donneesDuPaquet(dir, chemin) {
148
156
  const { donnees, parPaquet, fautes } = lire(dir);
149
- if (fautes.length) throw new Error(fautes.join('\n'));
157
+ if (fautes.length) {
158
+ throw new Error(fautes.join('\n'));
159
+ }
150
160
  return Object.fromEntries(
151
161
  [...parPaquet]
152
162
  .filter(([d]) => contient(d, chemin))
@@ -168,7 +178,9 @@ const contient = (dossier, chemin) =>
168
178
  */
169
179
  export function fournisseursDuPaquet(dir, chemin) {
170
180
  const { fautes, fournisseurs } = lire(dir);
171
- if (fautes.length) throw new Error(fautes.join('\n'));
181
+ if (fautes.length) {
182
+ throw new Error(fautes.join('\n'));
183
+ }
172
184
  return [
173
185
  ...new Set([...fournisseurs].filter(([d]) => contient(d, chemin)).flatMap(([, ns]) => ns)),
174
186
  ];
@@ -180,7 +192,9 @@ export function fournisseursDuPaquet(dir, chemin) {
180
192
  * @throws {Error} a build that fails
181
193
  */
182
194
  export function construireLesFournisseurs(noms) {
183
- if (!noms.length) return;
195
+ if (!noms.length) {
196
+ return;
197
+ }
184
198
  const nom = Object.keys(LANGAGES).find(n => langage(n).manifeste === 'package.json');
185
199
  const module = nom ? langage(nom) : null;
186
200
  if (!module?.construireLesPaquets) {
@@ -200,7 +214,9 @@ export function controlerLesDonnees(donnees) {
200
214
  .map(
201
215
  ([n, c]) => `la variable ${n} nomme ${c}, que la construction du fournisseur n'a pas produit.`
202
216
  );
203
- if (absents.length) throw new Error(absents.join('\n'));
217
+ if (absents.length) {
218
+ throw new Error(absents.join('\n'));
219
+ }
204
220
  }
205
221
 
206
222
  /**
@@ -114,6 +114,17 @@ const LIRE_L_INDEX = [
114
114
  const LIRE = ['Bash', 'Read', 'Skill'];
115
115
  const ECRIRE = ['Edit', 'Write'];
116
116
 
117
+ // The charter prescribes `env -C <dossier>` in place of `cd`: a command run in the copy carries
118
+ // that prefix, which a bare rule does not match. Each rule of command, out of bd, git and env -C,
119
+ // gets its twin `Bash(env -C * <commande>)`, as git has `git show` and `git -C * show`.
120
+ /** @param {string[]} regles @returns {string[]} */
121
+ function avecJumelles(regles) {
122
+ return regles.flatMap(r => {
123
+ const bash = /^Bash\((.*)\)$/.exec(r);
124
+ return bash && !/^(bd|git|env -C) /.test(bash[1]) ? [r, `Bash(env -C * ${bash[1]})`] : [r];
125
+ });
126
+ }
127
+
117
128
  // Each role the circuit launches: whether it writes (files, `ecrit`; the ticket, unless
118
129
  // `ecritAuTicket` is false), whether it uses the index, whether its skill names the frame's
119
130
  // METACADRE.md (`metacadre`, read at the root of the plugin installed), and the commands its skill
@@ -129,7 +140,7 @@ export const ROLES = {
129
140
  metacadre: true,
130
141
  index: true,
131
142
  ecritAuTicket: false,
132
- commandes: [
143
+ commandes: avecJumelles([
133
144
  'Bash(bd show *)',
134
145
  'Bash(bd comments *)',
135
146
  'Bash(git show *)',
@@ -141,7 +152,7 @@ export const ROLES = {
141
152
  'Bash(codegraph explore *)',
142
153
  'mcp__codegraph__codegraph_explore',
143
154
  'mcp__rtfm__rtfm_search',
144
- ],
155
+ ]),
145
156
  },
146
157
  // It writes the tests of the whole ticket, in the envelope of its plan, and reads the whole copy
147
158
  // by the index (charter, « L'index d'abord »).
@@ -149,14 +160,14 @@ export const ROLES = {
149
160
  metacadre: true,
150
161
  ecrit: true,
151
162
  index: true,
152
- commandes: [
163
+ commandes: avecJumelles([
153
164
  'Bash(bd update * --claim)',
154
165
  'Bash(bd comments add *)',
155
166
  'Bash(npm test *)',
156
167
  // The removal of a file of its tests, by a script of its temporary directory.
157
168
  'Bash(node $TMPDIR/*)',
158
169
  ...LIRE_L_INDEX,
159
- ],
170
+ ]),
160
171
  },
161
172
  // It writes the code of the whole ticket, in the envelope of its plan, and reads the whole copy
162
173
  // by the index.
@@ -164,7 +175,7 @@ export const ROLES = {
164
175
  metacadre: true,
165
176
  ecrit: true,
166
177
  index: true,
167
- commandes: [
178
+ commandes: avecJumelles([
168
179
  'Bash(bd update * --claim)',
169
180
  'Bash(bd update * --notes*)',
170
181
  'Bash(bd comments add *)',
@@ -173,12 +184,12 @@ export const ROLES = {
173
184
  'Bash(npm test *)',
174
185
  'Bash(npm run api*)',
175
186
  ...LIRE_L_INDEX,
176
- ],
187
+ ]),
177
188
  },
178
189
  relecteur: {
179
190
  metacadre: true,
180
191
  index: true,
181
- commandes: [
192
+ commandes: avecJumelles([
182
193
  ...LIRE_GIT,
183
194
  'Bash(npx grillhouse index-interfaces --publie *)',
184
195
  'Bash(npm test *)',
@@ -186,18 +197,18 @@ export const ROLES = {
186
197
  'Bash(codegraph explore *)',
187
198
  'mcp__codegraph__codegraph_explore',
188
199
  'mcp__rtfm__rtfm_search',
189
- ],
200
+ ]),
190
201
  },
191
202
  // It asks, and decides nothing: it reads the proposal its instruction carries and the code by
192
203
  // the index; the circuit writes its questions at the ticket.
193
204
  questionneur: {
194
205
  index: true,
195
206
  ecritAuTicket: false,
196
- commandes: [
207
+ commandes: avecJumelles([
197
208
  'Bash(codegraph explore *)',
198
209
  'mcp__codegraph__codegraph_explore',
199
210
  'mcp__rtfm__rtfm_search',
200
- ],
211
+ ]),
201
212
  },
202
213
  };
203
214
 
@@ -229,7 +240,11 @@ function greffonsDuProjet(racine) {
229
240
  const actifs = new Set();
230
241
  for (const f of ['settings.json', 'settings.local.json']) {
231
242
  const p = lireJson(path.join(racine, '.claude', f))?.enabledPlugins ?? {};
232
- for (const [nom, actif] of Object.entries(p)) if (actif) actifs.add(nom);
243
+ for (const [nom, actif] of Object.entries(p)) {
244
+ if (actif) {
245
+ actifs.add(nom);
246
+ }
247
+ }
233
248
  }
234
249
  return [...actifs].sort();
235
250
  }
@@ -268,16 +283,24 @@ function lireSaCompetence(role, { racine, copie, home }) {
268
283
  function serveursDeLIndex(racine, home) {
269
284
  const out = {};
270
285
  const projet = lireJson(path.join(racine, '.mcp.json'))?.mcpServers ?? {};
271
- for (const n of INDEX) if (projet[n]) out[n] = projet[n];
286
+ for (const n of INDEX) {
287
+ if (projet[n]) {
288
+ out[n] = projet[n];
289
+ }
290
+ }
272
291
  for (const greffon of greffonsDuProjet(racine)) {
273
292
  const dossier = cheminDuGreffon(greffon, [racine], home);
274
- if (!dossier) continue;
293
+ if (!dossier) {
294
+ continue;
295
+ }
275
296
  const serveurs =
276
297
  lireJson(path.join(dossier, '.claude-plugin', 'plugin.json'))?.mcpServers ??
277
298
  lireJson(path.join(dossier, '.mcp.json'))?.mcpServers ??
278
299
  {};
279
300
  for (const n of INDEX) {
280
- if (out[n] || !serveurs[n]) continue;
301
+ if (out[n] || !serveurs[n]) {
302
+ continue;
303
+ }
281
304
  out[n] = JSON.parse(JSON.stringify(serveurs[n]).replaceAll('${CLAUDE_PLUGIN_ROOT}', dossier));
282
305
  }
283
306
  }
@@ -288,7 +311,9 @@ function serveursDeLIndex(racine, home) {
288
311
  // project's own skills are read) and the main tree <racine>; <home> holds the plugins installed.
289
312
  function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
290
313
  const r = ROLES[role];
291
- if (!r) throw new Error(`rôle sans droits : ${role}`);
314
+ if (!r) {
315
+ throw new Error(`rôle sans droits : ${role}`);
316
+ }
292
317
  const deny = [...AUTEUR_FIXE, ...(r.ecritAuTicket === false ? ECRIRE_AU_TICKET : [])];
293
318
  if (r.ecrit) {
294
319
  // The test tool run directly (charter, « Aucun agent ne lance l'outil de test directement »),
@@ -0,0 +1,17 @@
1
+ // The fingerprint of a step, on the side of the activities (it hashes with `node:crypto`, which a
2
+ // decision of the circuit imports none of). Mature model: the cache key of a task of Turborepo.
3
+ import { createHash } from 'node:crypto';
4
+
5
+ /**
6
+ * The fingerprint of a step: the hash of its <commande> and of the content hashes <hashes> of the
7
+ * files it reads (by package, the root configuration under `//`); the same inputs give the same
8
+ * fingerprint, whatever the order of the packages.
9
+ */
10
+ export function empreinteDEtape({ commande, hashes }) {
11
+ const entrees = Object.keys(hashes)
12
+ .sort()
13
+ .map(k => [k, hashes[k]]);
14
+ return createHash('sha256')
15
+ .update(JSON.stringify([commande, entrees]))
16
+ .digest('hex');
17
+ }