@roomi-fields/grillhouse 0.51.0 → 0.53.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 (149) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/vitest.config.cjs +45 -0
  5. package/charte/plan.md +47 -0
  6. package/charte/preuve.md +39 -0
  7. package/charte/superviseur.md +60 -0
  8. package/charte/tests.md +38 -0
  9. package/charte.md +23 -178
  10. package/dist/temporal/circuit/appel.d.ts +2 -0
  11. package/dist/temporal/circuit/appel.js +24 -2
  12. package/dist/temporal/circuit/appel.js.map +1 -1
  13. package/dist/temporal/circuit/client.d.ts +15 -7
  14. package/dist/temporal/circuit/client.js +42 -11
  15. package/dist/temporal/circuit/client.js.map +1 -1
  16. package/dist/temporal/circuit/commande.js +17 -6
  17. package/dist/temporal/circuit/commande.js.map +1 -1
  18. package/dist/temporal/circuit/contrat.d.ts +9 -0
  19. package/dist/temporal/circuit/contrat.js +6 -0
  20. package/dist/temporal/circuit/contrat.js.map +1 -1
  21. package/dist/temporal/circuit/deroule.js +25 -4
  22. package/dist/temporal/circuit/deroule.js.map +1 -1
  23. package/dist/temporal/client.d.ts +35 -1
  24. package/dist/temporal/client.js +144 -1
  25. package/dist/temporal/client.js.map +1 -1
  26. package/dist/temporal/commande.js +31 -13
  27. package/dist/temporal/commande.js.map +1 -1
  28. package/dist/temporal/etat.d.ts +3 -1
  29. package/dist/temporal/etat.js +31 -17
  30. package/dist/temporal/etat.js.map +1 -1
  31. package/dist/temporal/file/activites.js +1 -1
  32. package/dist/temporal/file/activites.js.map +1 -1
  33. package/dist/temporal/file/contrat.d.ts +4 -5
  34. package/dist/temporal/file/contrat.js +2 -2
  35. package/dist/temporal/file/contrat.js.map +1 -1
  36. package/dist/temporal/file/deroule.js +7 -5
  37. package/dist/temporal/file/deroule.js.map +1 -1
  38. package/dist/temporal/installation.d.ts +103 -53
  39. package/dist/temporal/installation.js +842 -237
  40. package/dist/temporal/installation.js.map +1 -1
  41. package/dist/temporal/nuits/deroule.js +3 -1
  42. package/dist/temporal/nuits/deroule.js.map +1 -1
  43. package/dist/temporal/places/deroule.js +2 -1
  44. package/dist/temporal/places/deroule.js.map +1 -1
  45. package/dist/temporal/sonde/deroule.js +2 -1
  46. package/dist/temporal/sonde/deroule.js.map +1 -1
  47. package/dist/temporal/tickets/deroule.js +4 -3
  48. package/dist/temporal/tickets/deroule.js.map +1 -1
  49. package/dist/temporal/travailleur.d.ts +7 -1
  50. package/dist/temporal/travailleur.js +49 -25
  51. package/dist/temporal/travailleur.js.map +1 -1
  52. package/docs/INTERFACE.md +20 -14
  53. package/docs/architecture/circuit.md +19 -16
  54. package/docs/architecture/entree.md +8 -9
  55. package/docs/architecture/greffon.md +54 -20
  56. package/docs/architecture/installation.md +99 -60
  57. package/docs/architecture/machine.md +31 -4
  58. package/docs/architecture/tests.md +22 -8
  59. package/docs/lexique.md +12 -3
  60. package/hooks/hooks.json +10 -10
  61. package/hooks/register.tsx +84 -2
  62. package/package.json +4 -2
  63. package/scripts/activites.mjs +25 -9
  64. package/scripts/aiguillage.mjs +1 -1
  65. package/scripts/attente-au-tour.mjs +2 -3
  66. package/scripts/bilan.mjs +116 -56
  67. package/scripts/bilans-gardes.mjs +37 -0
  68. package/scripts/circuit.mjs +256 -42
  69. package/scripts/circuits-du-serveur.mjs +3 -2
  70. package/scripts/circuits-tenus.d.mts +7 -0
  71. package/scripts/circuits-tenus.mjs +17 -0
  72. package/scripts/copie-de-montee.mjs +354 -0
  73. package/scripts/copies-du-depot.d.mts +13 -0
  74. package/scripts/copies-du-depot.mjs +66 -0
  75. package/scripts/copies-finies.mjs +6 -40
  76. package/scripts/crochets.mjs +16 -2
  77. package/scripts/direct.mjs +2 -2
  78. package/scripts/droits.mjs +117 -38
  79. package/scripts/engendres.mjs +5 -3
  80. package/scripts/entree-de-seance.mjs +35 -0
  81. package/scripts/enveloppe/enveloppe.mjs +23 -16
  82. package/scripts/enveloppe/lancer.sh +32 -22
  83. package/scripts/enveloppe/travail-de-la-copie.mjs +154 -0
  84. package/scripts/etapes.mjs +11 -3
  85. package/scripts/faits-du-circuit.mjs +12 -5
  86. package/scripts/file-des-tickets.d.mts +13 -2
  87. package/scripts/file-des-tickets.mjs +44 -12
  88. package/scripts/greffons.mjs +42 -27
  89. package/scripts/grillhouse-maj.mjs +105 -85
  90. package/scripts/init.mjs +1 -1
  91. package/scripts/integration/file.mjs +5 -2
  92. package/scripts/integration/integrer.mjs +14 -4
  93. package/scripts/jointure.d.ts +18 -1
  94. package/scripts/langages/c/commandes.mjs +17 -7
  95. package/scripts/langages/cargo/commandes.mjs +87 -34
  96. package/scripts/langages/cargo/index.mjs +6 -3
  97. package/scripts/langages/cargo/sccache.mjs +15 -12
  98. package/scripts/langages/python/commandes.mjs +68 -15
  99. package/scripts/langages/python/squelette.mjs +4 -3
  100. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  101. package/scripts/langages/typescript/index.mjs +14 -12
  102. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +299 -0
  103. package/scripts/langages/typescript/squelette.mjs +20 -17
  104. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  105. package/scripts/langages/typescript/turbo-des-paquets.mjs +76 -39
  106. package/scripts/langages/typescript/verifier.mjs +27 -2
  107. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  108. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  109. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  110. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  111. package/scripts/mesure/pression.mjs +5 -3
  112. package/scripts/migrations/serveurs-de-l-index.mjs +1 -1
  113. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  114. package/scripts/migrations.mjs +2 -0
  115. package/scripts/montee.mjs +524 -0
  116. package/scripts/nuit.sh +3 -2
  117. package/scripts/outil.mjs +5 -3
  118. package/scripts/paquet-npm.mjs +22 -0
  119. package/scripts/paquet.mjs +5 -5
  120. package/scripts/pre-compact.mjs +25 -0
  121. package/scripts/reponses-du-circuit.d.mts +17 -2
  122. package/scripts/reponses-du-circuit.mjs +78 -20
  123. package/scripts/resultats.mjs +42 -14
  124. package/scripts/retirer-les-copies-finies.mjs +4 -7
  125. package/scripts/seances.mjs +81 -29
  126. package/scripts/services-du-noyau.mjs +7 -2
  127. package/scripts/session-start.sh +19 -10
  128. package/scripts/sortie-de-seance.mjs +70 -0
  129. package/scripts/sortie.mjs +4 -7
  130. package/scripts/sous-commandes.mjs +1 -1
  131. package/scripts/superviseur.mjs +417 -159
  132. package/scripts/tableau.mjs +249 -152
  133. package/scripts/ticket-du-circuit.mjs +22 -0
  134. package/scripts/transitions.d.mts +6 -9
  135. package/scripts/transitions.mjs +123 -36
  136. package/scripts/verrou-de-fichier.d.mts +11 -0
  137. package/skills/direct/SKILL.md +21 -11
  138. package/skills/explorateur/SKILL.md +8 -3
  139. package/skills/grill/SKILL.md +11 -8
  140. package/skills/grill/references/paquets.md +4 -4
  141. package/skills/pitmaster/SKILL.md +99 -53
  142. package/skills/pitmaster/references/cadre.md +1 -1
  143. package/skills/pitmaster/references/consigne-agent.md +1 -1
  144. package/skills/pitmaster/references/tour.md +6 -5
  145. package/skills/relecteur/SKILL.md +9 -2
  146. package/skills/testwriter/SKILL.md +3 -3
  147. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  148. package/cadre/templates/projet/vitest.config.ts +0 -44
  149. package/scripts/attente-a-l-arret.mjs +0 -114
@@ -0,0 +1,524 @@
1
+ // The montée of a project by one command, `grillhouse maj [<x.y.z>]`, as `nx migrate` and
2
+ // `brew upgrade` bring everything to the version wanted. The mechanism is installation.md §5.2 and
3
+ // §5.3, under packages/grillhouse/docs/architecture/.
4
+ //
5
+ // - Launched in the main tree (`monter`), it lays the copy of the montée on the tip of main
6
+ // (scripts/copie-de-montee.mjs), installs there the package at the version wanted (`npm install -D`;
7
+ // the repository of the frame, which holds the package's sources, installs its dependencies
8
+ // alone), then hands the rest (`suivre`) to the command of the package so installed, or plays it
9
+ // itself in the repository of the frame. Without a version, the one the tip of main holds is kept
10
+ // (the key `grillhouse.outil` in the repository of the frame). The child learns it plays the
11
+ // rest from the variable `GRILLHOUSE_MONTEE`.
12
+ // - The rest, up to five passes: the files the frame writes (scripts/grillhouse-maj.mjs), the
13
+ // machine's part once (the published tool, the plugins, the binaries, the units and workers, the
14
+ // schedule of the nights), the verification of the sort « Montée » on the content of the commit
15
+ // alone; green, the commit, its tree kept as judged (scripts/arbres-juges.mjs), main advanced by
16
+ // fast-forward and pushed; main advanced meanwhile, the next pass writes everything again from
17
+ // its tip. Main advanced, the main tree installs its dependencies and the plugins the lot adds.
18
+ // - Exit code: 0; 1 for a failure, a refusal or a montée not entered; 75 for a verification to play
19
+ // again; 2 for the usage (scripts/grillhouse-maj.mjs).
20
+ import { spawnSync } from 'node:child_process';
21
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
22
+ import path from 'node:path';
23
+ import { installer, NOM_DU_PAQUET, versionDeLOutil } from './aiguillage.mjs';
24
+ import { garderLArbreJuge } from './arbres-juges.mjs';
25
+ import { installerBinaires } from './binaires.mjs';
26
+ import { poserCrochets } from './crochets.mjs';
27
+ import {
28
+ arbreDe,
29
+ brancheDeLaMontee,
30
+ changements,
31
+ conflits,
32
+ fichiersEcrits,
33
+ garderLEtat,
34
+ git,
35
+ preparerLaCopie,
36
+ remettreSur,
37
+ restaurer,
38
+ retirerLaCopie,
39
+ } from './copie-de-montee.mjs';
40
+ import { greffonsDuProjet, installerGreffons } from './greffons.mjs';
41
+ import { paquets } from './paquets.mjs';
42
+
43
+ /** The variable by which the command of the package installed in the copy plays the rest. */
44
+ export const VARIABLE_DE_LA_MONTEE = 'GRILLHOUSE_MONTEE';
45
+ const PASSES_MAX = 5;
46
+ // The root of the package that runs: this script's.
47
+ const PAQUET = path.resolve(import.meta.dirname, '..');
48
+ const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies'];
49
+
50
+ const dire = l => process.stdout.write(`${l}\n`);
51
+ const signaler = l => process.stderr.write(`${l}\n`);
52
+
53
+ const lireJson = f => {
54
+ try {
55
+ return JSON.parse(readFileSync(f, 'utf8'));
56
+ } catch {
57
+ return null;
58
+ }
59
+ };
60
+
61
+ const resultatDeGit = (racine, args) =>
62
+ spawnSync('git', ['-C', racine, ...args], { encoding: 'utf8' });
63
+
64
+ // The JSON of the file `f` at the commit `commit`, or null.
65
+ function auCommit(racine, commit, f) {
66
+ const r = resultatDeGit(racine, ['show', `${commit}:${f}`]);
67
+ try {
68
+ return r.status === 0 ? JSON.parse(r.stdout) : null;
69
+ } catch {
70
+ return null;
71
+ }
72
+ }
73
+
74
+ /**
75
+ * The main tree `cwd` is the root of, its branch: `{ principal, branche }`; `{ refus }` in a copy,
76
+ * out of git, in a folder that is no root, or on a detached HEAD.
77
+ */
78
+ export function arbreDeLaMontee(cwd) {
79
+ const r = resultatDeGit(cwd, [
80
+ 'rev-parse',
81
+ '--path-format=absolute',
82
+ '--git-dir',
83
+ '--git-common-dir',
84
+ '--show-toplevel',
85
+ ]);
86
+ const refus = raison => ({
87
+ refus: `⛔ grillhouse maj se lance à la racine de l'arbre principal d'un dépôt git : ${raison}. Rien n'est fait.`,
88
+ });
89
+ if (r.status !== 0) {
90
+ return refus(`${cwd} n'est pas dans un dépôt git`);
91
+ }
92
+ const [dossier, commun, racine] = r.stdout.trim().split('\n');
93
+ if (dossier !== commun) {
94
+ return refus(`${racine} est une copie`);
95
+ }
96
+ if (realpathSync(cwd) !== realpathSync(racine)) {
97
+ return refus(`la racine du dépôt est ${racine}, pas ${cwd}`);
98
+ }
99
+ if (!existsSync(path.join(racine, 'package.json'))) {
100
+ return refus(`${racine} n'a pas de package.json`);
101
+ }
102
+ const branche = resultatDeGit(racine, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
103
+ if (branche.status !== 0) {
104
+ return refus('aucune branche n’y est extraite (HEAD détaché)');
105
+ }
106
+ return { principal: realpathSync(racine), branche: branche.stdout.trim() };
107
+ }
108
+
109
+ // The folder of the package's sources in the repository at `racine`, or null: the repository of
110
+ // the frame.
111
+ function sourcesDuCadre(racine) {
112
+ return paquets(racine).find(p => p.pkg.name === NOM_DU_PAQUET)?.dossier ?? null;
113
+ }
114
+
115
+ const declareLePaquet = pkg => CHAMPS.some(c => pkg?.[c]?.[NOM_DU_PAQUET] !== undefined);
116
+ const versionVerrouillee = verrou =>
117
+ verrou?.packages?.[`node_modules/${NOM_DU_PAQUET}`]?.version ?? null;
118
+ const versionInstallee = racine =>
119
+ lireJson(path.join(racine, 'node_modules', NOM_DU_PAQUET, 'package.json'))?.version ?? null;
120
+
121
+ // The version the tip of main holds, which `maj` without argument keeps.
122
+ function versionDeLaPointe(principal, pointe, sources) {
123
+ const pkg = auCommit(principal, pointe, 'package.json');
124
+ if (sources !== null) {
125
+ return (
126
+ pkg?.grillhouse?.outil ?? auCommit(principal, pointe, `${sources}/package.json`)?.version
127
+ );
128
+ }
129
+ if (!declareLePaquet(pkg)) {
130
+ return null;
131
+ }
132
+ const declaree = CHAMPS.map(c => pkg[c]?.[NOM_DU_PAQUET]).find(Boolean);
133
+ return (
134
+ versionVerrouillee(auCommit(principal, pointe, 'package-lock.json')) ??
135
+ versionInstallee(principal) ??
136
+ /\d+\.\d+\.\d+/.exec(declaree)?.[0] ??
137
+ null
138
+ );
139
+ }
140
+
141
+ // npm in `dossier`, its output the command's; whether it succeeded, its failure said.
142
+ function npm(dossier, args) {
143
+ const r = spawnSync('npm', args, { cwd: dossier, stdio: 'inherit' });
144
+ if (r.status === 0) {
145
+ return true;
146
+ }
147
+ signaler(
148
+ `⛔ \`npm ${args.join(' ')}\` dans ${dossier} échoue (${r.error?.message ?? `code ${r.status}`}).`
149
+ );
150
+ return false;
151
+ }
152
+
153
+ // The installation of a montée in its copy: the package at `version` when the tip does not hold it
154
+ // there, else the declared dependencies alone.
155
+ function installerDansLaCopie({ copie, version, duCadre }) {
156
+ const aJour =
157
+ duCadre ||
158
+ (declareLePaquet(lireJson(path.join(copie, 'package.json'))) &&
159
+ versionVerrouillee(lireJson(path.join(copie, 'package-lock.json'))) === version);
160
+ return npm(copie, aJour ? ['install'] : ['install', '-D', `${NOM_DU_PAQUET}@${version}`]);
161
+ }
162
+
163
+ // What the report says of a montée that did not enter main: its copy, the versions, the commands.
164
+ function nonEntree({ copie, version, principal, pointe, duCadre }, poste) {
165
+ const sources = duCadre ? sourcesDuCadre(principal) : null;
166
+ const duProjet = versionDeLaPointe(principal, pointe, sources) ?? 'inconnue';
167
+ signaler(
168
+ `Montée non entrée : main reste tel quel, sa copie reste, ${copie} (branche ${brancheDeLaMontee(version)}).`
169
+ );
170
+ signaler(
171
+ `${
172
+ poste
173
+ ? `Le poste est mené par ${version} (sa part est jouée)`
174
+ : 'La part du poste n’est pas jouée'
175
+ }, le projet est en ${duProjet} : \`npx grillhouse maj ${version}\` reprend la montée, \`npx grillhouse maj\` revient à la version du projet.`
176
+ );
177
+ }
178
+
179
+ /**
180
+ * What the montée receives of the files the frame writes (scripts/grillhouse-maj.mjs, which calls
181
+ * it): `ecrireLeProjet` and `verifier`.
182
+ * @typedef {{
183
+ * ecrireLeProjet: (copie: string, o: { version: string, duCadre: boolean,
184
+ * noterSansVerifier?: (ligne: string | null) => void }) => boolean,
185
+ * verifier: (copie: string, o: { fichiersAFinir: boolean, installer: boolean,
186
+ * sansVerifier?: string | null }) => { code: number | null, ligne: string, erreur: boolean }
187
+ * }} Fichiers
188
+ */
189
+
190
+ /**
191
+ * `grillhouse maj [<voulue>]` launched in `cwd` (see the header): the exit code.
192
+ * @param {string | null} voulue the version x.y.z wanted, null to keep the tip's
193
+ * @param {Fichiers} deLaMaj
194
+ * @param {string} [cwd]
195
+ */
196
+ export function monter(voulue, deLaMaj, cwd = process.cwd()) {
197
+ const arbre = arbreDeLaMontee(cwd);
198
+ if (arbre.refus) {
199
+ signaler(arbre.refus);
200
+ return 1;
201
+ }
202
+ const { principal, branche } = arbre;
203
+ const pointe = git(principal, 'rev-parse', 'HEAD');
204
+ const sources = sourcesDuCadre(principal);
205
+ const duCadre = sources !== null;
206
+ const tenue = versionDeLaPointe(principal, pointe, sources);
207
+ const version = voulue ?? tenue;
208
+ if (!version) {
209
+ signaler(
210
+ `⛔ la pointe de ${branche} ne déclare pas ${NOM_DU_PAQUET} : nomme la version, \`npx grillhouse maj <x.y.z>\`.`
211
+ );
212
+ return 1;
213
+ }
214
+ let copie;
215
+ try {
216
+ ({ copie } = preparerLaCopie(principal, version, pointe));
217
+ } catch (e) {
218
+ signaler(`⛔ Montée ${version} : ${e.message}`);
219
+ return 1;
220
+ }
221
+ const montee = { principal, branche, copie, version, pointe, duCadre };
222
+ const abandonner = () => {
223
+ restaurer(copie, version);
224
+ nonEntree(montee, false);
225
+ return 1;
226
+ };
227
+ if (existsSync(path.join(copie, '.gitmodules'))) {
228
+ const r = spawnSync('bash', [path.join(PAQUET, 'scripts', 'sous-modules.sh'), 'pose', copie], {
229
+ cwd: principal,
230
+ stdio: 'inherit',
231
+ });
232
+ if (r.status !== 0) {
233
+ return abandonner();
234
+ }
235
+ }
236
+ if (!installerDansLaCopie(montee)) {
237
+ signaler(`⛔ Montée ${version} : l'installation échoue ; aucun autre geste, aucun commit.`);
238
+ return abandonner();
239
+ }
240
+ if (duCadre) {
241
+ return suivre(montee, deLaMaj);
242
+ }
243
+ const paquet = path.join(copie, 'node_modules', NOM_DU_PAQUET);
244
+ if (existsSync(path.join(paquet, 'scripts', 'montee.mjs'))) {
245
+ const r = spawnSync(
246
+ process.execPath,
247
+ [path.join(paquet, 'bin', 'grillhouse.mjs'), 'maj', version],
248
+ {
249
+ cwd: copie,
250
+ stdio: 'inherit',
251
+ env: { ...process.env, [VARIABLE_DE_LA_MONTEE]: JSON.stringify(montee) },
252
+ }
253
+ );
254
+ return r.status ?? 1;
255
+ }
256
+ // A version from before the montée in one command: the machine alone goes back to the project's.
257
+ restaurer(copie, version);
258
+ if (version !== tenue) {
259
+ signaler(
260
+ `⛔ ${NOM_DU_PAQUET}@${version} ne connaît pas la montée en une commande : rien n'est écrit.`
261
+ );
262
+ nonEntree(montee, false);
263
+ return 1;
264
+ }
265
+ const echecs = jouerLePoste(montee);
266
+ echecs.push(...apresLAvance(montee, false));
267
+ retirerOuDire(montee);
268
+ return echecs.length > 0 ? 1 : 0;
269
+ }
270
+
271
+ // Runs a command of the frame in the main tree; the line of its failure, which names `geste`.
272
+ function duPoste(principal, geste, script, args) {
273
+ const r = spawnSync(process.execPath, [path.join(PAQUET, script), ...args], {
274
+ cwd: principal,
275
+ encoding: 'utf8',
276
+ });
277
+ if (r.status === 0) {
278
+ dire(`Part du poste : ${r.stdout.trim()}`);
279
+ return [];
280
+ }
281
+ return [
282
+ `Part du poste : \`${geste}\` échoue : ${`${r.stdout ?? ''}${r.stderr ?? ''}`.trim() || r.error?.message || `code ${r.status}`}`,
283
+ ];
284
+ }
285
+
286
+ // The machine's part (installation.md §5.3), at the version and by the declarations the copy
287
+ // holds, with the paths and names of the main tree: the lines of failure, each said.
288
+ function jouerLePoste({ principal, copie, version }) {
289
+ const echecs = [];
290
+ const essayer = (geste, jouer) => {
291
+ try {
292
+ echecs.push(...jouer());
293
+ } catch (e) {
294
+ echecs.push(`Part du poste : \`${geste}\` échoue : ${e.message}`);
295
+ }
296
+ };
297
+ essayer('npx grillhouse outil', () => {
298
+ const publiee = versionDeLOutil(copie) ?? version;
299
+ const r = installer(publiee, { retenue: 0 });
300
+ dire(`Part du poste : outil publié ${publiee} ${r.installe ? 'installé' : 'déjà là'}.`);
301
+ return [];
302
+ });
303
+ essayer('npx grillhouse greffons', () =>
304
+ installerGreffons(principal, {
305
+ declarations: copie,
306
+ seulement: greffonsDuProjet(principal),
307
+ version,
308
+ })
309
+ );
310
+ essayer('npx grillhouse binaires', () => {
311
+ const r = installerBinaires(copie);
312
+ if (r.installes.length > 0) {
313
+ dire(`Binaires installés : ${r.installes.join(', ')}.`);
314
+ }
315
+ return r.lignes;
316
+ });
317
+ essayer('npx grillhouse temporal installer', () =>
318
+ duPoste(principal, 'npx grillhouse temporal installer', 'dist/temporal/commande.js', [
319
+ 'installer',
320
+ '--racine',
321
+ principal,
322
+ '--declarations',
323
+ copie,
324
+ ])
325
+ );
326
+ essayer('npx grillhouse nuit --planifier', () =>
327
+ duPoste(principal, 'npx grillhouse nuit --planifier', 'dist/temporal/nuits/commande.js', [
328
+ '--planifier',
329
+ ])
330
+ );
331
+ echecs.forEach(signaler);
332
+ if (echecs.length > 0) {
333
+ signaler(
334
+ `Part du poste en échec : \`npx grillhouse maj ${version}\` la rejoue, \`npx grillhouse maj\` revient à la version du projet.`
335
+ );
336
+ }
337
+ return echecs;
338
+ }
339
+
340
+ // Whether a dependency of the main tree is not installed, or the frame's package not at the version
341
+ // its lock names.
342
+ function perime(principal) {
343
+ const pkg = lireJson(path.join(principal, 'package.json'));
344
+ const noms = CHAMPS.filter(c => c !== 'optionalDependencies').flatMap(c =>
345
+ Object.keys(pkg?.[c] ?? {})
346
+ );
347
+ const verrou = versionVerrouillee(lireJson(path.join(principal, 'package-lock.json')));
348
+ return (
349
+ noms.some(n => !existsSync(path.join(principal, 'node_modules', n, 'package.json'))) ||
350
+ (verrou !== null && declareLePaquet(pkg) && versionInstallee(principal) !== verrou)
351
+ );
352
+ }
353
+
354
+ // What follows the advance of main (`avance`) in the main tree: its dependencies, then the plugins
355
+ // it declares; the lines of failure, each said.
356
+ function apresLAvance({ principal, version }, avance) {
357
+ const echecs = [];
358
+ if ((avance || perime(principal)) && !npm(principal, ['install'])) {
359
+ echecs.push(
360
+ `Arbre principal : \`npm install\` reste à jouer ; \`npx grillhouse maj ${version}\` le rejoue.`
361
+ );
362
+ signaler(echecs[0]);
363
+ }
364
+ poserCrochets(principal);
365
+ const greffons = installerGreffons(principal, { version });
366
+ greffons.forEach(signaler);
367
+ return [...echecs, ...greffons];
368
+ }
369
+
370
+ // Removes the copy, or says why it stays.
371
+ function retirerOuDire({ principal, copie, version }) {
372
+ if (!retirerLaCopie(principal, copie, version)) {
373
+ dire(
374
+ `La copie de la montée reste, ${copie} : elle porte un changement non commité d'un autre (${changements(copie).join(', ')}).`
375
+ );
376
+ }
377
+ }
378
+
379
+ // Main advanced to `commit` by fast-forward in the main tree: `{ avance }`, `{ bouge }` when main
380
+ // moved off `base`, else the files that hold it.
381
+ function avancer({ principal, branche }, base, commit, fichiers) {
382
+ const pointe = () => git(principal, 'rev-parse', `refs/heads/${branche}`);
383
+ if (pointe() !== base) {
384
+ return { bouge: true };
385
+ }
386
+ const r = resultatDeGit(principal, ['merge', '-q', '--ff-only', commit]);
387
+ if (r.status === 0) {
388
+ return { avance: true };
389
+ }
390
+ if (pointe() !== base) {
391
+ return { bouge: true };
392
+ }
393
+ const retenus = changements(principal).filter(f => fichiers.includes(f));
394
+ return { retenus, raison: r.stderr.trim() };
395
+ }
396
+
397
+ /**
398
+ * The rest of the montée `montee`, its copy installed (see the header): the exit code.
399
+ * @param {{ principal: string, branche: string, copie: string, version: string, pointe: string,
400
+ * duCadre: boolean }} montee
401
+ * @param {Fichiers} deLaMaj
402
+ */
403
+ export function suivre(montee, { ecrireLeProjet, verifier }) {
404
+ const { principal, branche, copie, version, duCadre } = montee;
405
+ let { pointe } = montee;
406
+ let echecs = null;
407
+ let entree = false;
408
+ // Lays back what was set aside, says the montée did not enter, and gives the exit code.
409
+ const arreter = (cause, code = 1) => {
410
+ const enConflit = restaurer(copie, version);
411
+ if (cause) {
412
+ signaler(cause);
413
+ }
414
+ if (enConflit.length > 0) {
415
+ signaler(`Le changement d'un autre reste tel quel dans la copie : ${enConflit.join(', ')}.`);
416
+ }
417
+ if (!entree) {
418
+ nonEntree({ ...montee, pointe }, echecs !== null);
419
+ }
420
+ return code;
421
+ };
422
+ try {
423
+ for (let passe = 1; passe <= PASSES_MAX; passe++) {
424
+ if (passe > 1) {
425
+ pointe = git(principal, 'rev-parse', `refs/heads/${branche}`);
426
+ dire(`main a avancé : la montée se réécrit depuis ${pointe.slice(0, 7)} (passe ${passe}).`);
427
+ remettreSur(copie, pointe);
428
+ if (!installerDansLaCopie(montee)) {
429
+ return arreter(`⛔ Montée ${version} : l'installation échoue ; aucun commit.`);
430
+ }
431
+ }
432
+ let sansVerifier = null;
433
+ const aFaire = ecrireLeProjet(copie, {
434
+ version,
435
+ duCadre,
436
+ noterSansVerifier: ligne => {
437
+ sansVerifier = ligne;
438
+ },
439
+ });
440
+ const fichiers = fichiersEcrits(copie);
441
+ garderLEtat(copie, version, fichiers);
442
+ echecs ??= jouerLePoste(montee);
443
+ const enConflit = conflits(copie, version);
444
+ if (aFaire || enConflit.length > 0) {
445
+ const v = aFaire
446
+ ? verifier(copie, { fichiersAFinir: true, installer: false })
447
+ : {
448
+ ligne: `⛔ Conflit avec un changement non commité d'un autre : ${enConflit.join(', ')}.`,
449
+ };
450
+ return arreter(`${v.ligne}\nAucun commit.`);
451
+ }
452
+ if (fichiers.length === 0) {
453
+ dire(`Montée ${version} : rien à commiter, le projet est à jour ; aucun commit.`);
454
+ restaurer(copie, version);
455
+ const apres = apresLAvance(montee, false);
456
+ retirerOuDire(montee);
457
+ return echecs.length + apres.length > 0 ? 1 : 0;
458
+ }
459
+ const arbre = arbreDe(copie, pointe, fichiers);
460
+ const v = verifier(copie, { fichiersAFinir: false, installer: false, sansVerifier });
461
+ // What the verification wrote besides the montée's files goes.
462
+ const deLaVerification = changements(copie).filter(f => !fichiers.includes(f));
463
+ for (const f of deLaVerification) {
464
+ if (resultatDeGit(copie, ['checkout', '-q', 'HEAD', '--', f]).status !== 0) {
465
+ resultatDeGit(copie, ['clean', '-q', '-f', '--', f]);
466
+ }
467
+ }
468
+ (v.erreur ? signaler : dire)(v.ligne);
469
+ if (v.code !== 0) {
470
+ return arreter('Aucun commit.', v.code === 75 ? 75 : 1);
471
+ }
472
+ const commit = git(
473
+ copie,
474
+ 'commit-tree',
475
+ arbre,
476
+ '-p',
477
+ pointe,
478
+ '-m',
479
+ `Montée du cadre à ${version}`
480
+ );
481
+ garderLArbreJuge(copie, arbre);
482
+ garderLEtat(copie, version, fichiers, commit);
483
+ git(copie, 'reset', '-q', '--soft', commit);
484
+ git(copie, 'reset', '-q');
485
+ const a = avancer(montee, pointe, commit, fichiers);
486
+ if (a.bouge) {
487
+ continue;
488
+ }
489
+ if (!a.avance) {
490
+ return arreter(
491
+ `⛔ main n'avance pas : l'arbre principal porte un changement non commité sur un fichier du lot (${a.retenus.join(', ')}). ${a.raison}`
492
+ );
493
+ }
494
+ entree = true;
495
+ dire(
496
+ `Commit ${commit.slice(0, 7)} « Montée du cadre à ${version} » : ${fichiers.join(', ')} ; ${branche} avancée.`
497
+ );
498
+ const apres = [];
499
+ if (resultatDeGit(principal, ['remote', 'get-url', 'origin']).status === 0) {
500
+ const p = resultatDeGit(principal, ['push', '-q', 'origin', branche]);
501
+ if (p.status !== 0) {
502
+ apres.push(`⛔ \`git push origin ${branche}\` échoue : ${p.stderr.trim()}`);
503
+ signaler(apres[0]);
504
+ }
505
+ }
506
+ apres.push(...apresLAvance(montee, true));
507
+ restaurer(copie, version);
508
+ retirerOuDire(montee);
509
+ return echecs.length + apres.length > 0 ? 1 : 0;
510
+ }
511
+ return arreter(
512
+ `⛔ main a avancé à chacune des ${PASSES_MAX} passes : la montée s'arrête sans avancer main.`
513
+ );
514
+ } catch (e) {
515
+ return arreter(`⛔ Montée ${version} : ${e.message}`);
516
+ }
517
+ }
518
+
519
+ /** The montée this process plays the rest of, from the variable of the launching command, or null. */
520
+ export function monteeRecue(env = process.env) {
521
+ const recue = env[VARIABLE_DE_LA_MONTEE];
522
+ delete env[VARIABLE_DE_LA_MONTEE];
523
+ return recue ? JSON.parse(recue) : null;
524
+ }
package/scripts/nuit.sh CHANGED
@@ -210,13 +210,13 @@ repli() {
210
210
  return
211
211
  fi
212
212
  local lignes rejouer= rouges_pc2= attend= mesures_du_flux=
213
- lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write(["pc2","pc3","rouges","enAttente","enCours","mesures"].map(k=>k+"\t"+l(k)).join("\n")+"\n")})')"
213
+ lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write([...["pc2","pc3","rouges","enAttente","enCours"].map(k=>k+"\t"+l(k)),"mesures\t"+d.mesures].join("\n")+"\n")})')"
214
214
  while IFS= read -r ligne; do
215
215
  case "$ligne" in
216
216
  pc2$'\t'*) echo "relevé de la nuit : tranches jouées sur PC2 : ${ligne#pc2$'\t'}" ;;
217
217
  pc3$'\t'*) rejouer="${ligne#pc3$'\t'}"; echo "relevé de la nuit : tranches jouées sur PC3 : ${rejouer:-aucune}" ;;
218
218
  rouges$'\t'*) rouges_pc2="${ligne#rouges$'\t'}" ;;
219
- mesures$'\t'*) mesures_du_flux="${ligne#mesures$'\t'}"; echo "relevé de la nuit : mesures de temps du flux : ${mesures_du_flux}" ;;
219
+ mesures$'\t'*) mesures_du_flux="${ligne#mesures$'\t'}" ;;
220
220
  enAttente$'\t'*|enCours$'\t'*) attend="$attend ${ligne#*$'\t'}" ;;
221
221
  esac
222
222
  done <<< "$lignes"
@@ -240,6 +240,7 @@ repli() {
240
240
  # The measures of time: the flow's job plays them when its file declares one; the night of the
241
241
  # poste plays them itself otherwise (tests-de-nuit --du-poste), so no last green without them.
242
242
  if node "$ici/flux-de-la-nuit.mjs" mesures "$copie"; then
243
+ echo "relevé de la nuit : mesures de temps du flux : $mesures_du_flux"
243
244
  case "$mesures_du_flux" in
244
245
  rouge)
245
246
  echo "✗ les mesures de temps du flux sont rouges sur PC2."
package/scripts/outil.mjs CHANGED
@@ -16,9 +16,11 @@ import path from 'node:path';
16
16
  import { pathToFileURL } from 'node:url';
17
17
  import { CLE, installer, NOM_DU_PAQUET, versionDeLOutil, X_Y_Z } from './aiguillage.mjs';
18
18
 
19
- // Writes <version> as the key of the package.json at <racine>, its other fields and its
20
- // indentation kept.
21
- function ecrireLaCle(racine, version) {
19
+ /**
20
+ * Writes `version` as the key of the package.json at `racine`, its other fields and its
21
+ * indentation kept.
22
+ */
23
+ export function ecrireLaCle(racine, version) {
22
24
  const f = path.join(racine, 'package.json');
23
25
  const texte = readFileSync(f, 'utf8');
24
26
  const pkg = JSON.parse(texte);
@@ -134,6 +134,28 @@ export function packageJsonDuPaquet(nom, chemin) {
134
134
  return `${JSON.stringify(p, null, 2)}\n`;
135
135
  }
136
136
 
137
+ /**
138
+ * The gesture by hand that makes the package <nom> of the folder <dossier> (absolute) a package of
139
+ * the graph of the project at <racine>: its package.json, given in full (`packageJsonDuPaquet`),
140
+ * and its entry in the `workspaces` of the root when no pattern selects it. Null for the root
141
+ * itself, which no entry makes a package of the graph.
142
+ * @param {string} racine
143
+ * @param {string} dossier
144
+ * @param {string} nom
145
+ */
146
+ export function gesteDuPackageJson(racine, dossier, nom) {
147
+ const chemin = path.relative(racine, dossier).split(path.sep).join('/');
148
+ if (chemin === '') {
149
+ return null;
150
+ }
151
+ const f = path.join(racine, 'package.json');
152
+ const inscrit = existsSync(f) && selectionne(JSON.parse(readFileSync(f, 'utf8')), chemin);
153
+ const espaces = inscrit
154
+ ? ''
155
+ : `, puis inscris \`${chemin}\` aux \`workspaces\` du package.json de la racine (aucun motif ne le sélectionne)`;
156
+ return `à la main, écris \`${chemin}/package.json\`${espaces}. Son contenu :\n${packageJsonDuPaquet(nom, chemin)}`;
157
+ }
158
+
137
159
  /**
138
160
  * The text of the root package.json <texte> with <chemin> entered in its `workspaces`; null when
139
161
  * its patterns select the folder already.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- // The creation of a package, out of the circuit: the third of the four times of a package's birth
3
- // (the common charter, « La naissance d'un paquet »: the grill, the writing of its row and its
4
- // documents, this command, then a ticket of code), as the generators of Nx and `cargo new --lib`
5
- // write one. A skeleton has neither behaviour nor test. The mechanism is installation.md §3.1
2
+ // The creation of a package: the third of the four times of a package's birth (the common charter,
3
+ // module superviseur, « Un paquet naît en quatre temps »: the grill, the writing of its row and its
4
+ // documents, this command, played by the agent of a direct ticket, then a ticket of code), as the
5
+ // generators of Nx and `cargo new --lib` write one. A skeleton has neither behaviour nor test. The mechanism is installation.md §3.1
6
6
  // (« Création d'un paquet »), tests.md §5.6, in packages/grillhouse/docs/architecture/.
7
7
  //
8
8
  // npx grillhouse paquet <chemin> from the root of the project, <chemin> from it
@@ -314,7 +314,7 @@ export function creerPaquet(racine, chemin, { source = CADRE, executer = lancer,
314
314
  const code = executer(commande, args, path.join(racine, dossier));
315
315
  if (code !== 0) {
316
316
  echecs.push(
317
- `\`${[commande, ...args].join(' ')}\` (${dossier}) échoue, code ${code} ; lance-le, puis \`npx grillhouse maj\`.`
317
+ `\`${[commande, ...args].join(' ')}\` (${dossier}) échoue, code ${code} ; relance-la dans ${dossier}.`
318
318
  );
319
319
  }
320
320
  };
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ // The PreCompact hook of the frame's plugin (`grillhouse pre-compact`): what it writes on its
3
+ // standard output joins the instructions of the summary of a compaction, manual, automatic or asked
4
+ // by a plugin. For the session that holds the lock of the supervisor of the project, with a note of
5
+ // resumption, it writes them (`consignesDuResume`, scripts/superviseur.mjs). It exits 0 and writes
6
+ // nothing otherwise, on the compaction of a subagent (an input that bears `agent_id`) and on an
7
+ // input it cannot read. Mechanism: greffon.md, §5.2.
8
+ import { readFileSync } from 'node:fs';
9
+ import { consignesDuResume } from './superviseur.mjs';
10
+
11
+ function entree() {
12
+ try {
13
+ return JSON.parse(readFileSync(0, 'utf8'));
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ const e = entree();
20
+ if (e && !e.agent_id) {
21
+ const texte = consignesDuResume(process.env.CLAUDE_PROJECT_DIR || process.cwd());
22
+ if (texte) {
23
+ process.stdout.write(`${texte}\n`);
24
+ }
25
+ }
@@ -4,8 +4,13 @@
4
4
  export const SANS_ISSUE: Set<string>;
5
5
  /** The answers accepted for the circuit of <ticket> whose workflow has the status <statut>. */
6
6
  export function lesReponses(ticket: string, statut: string, ecrit: boolean): string;
7
- /** The hour `bd update --defer` receives for `--reporter <heure>`, and the phrase of its texts. */
8
- export function heureDuReport(heure: string, maintenant: Date): { defer: string; quand: string };
7
+ /** The refusal of an hour of deferral, which cites the forms accepted. */
8
+ export const REFUS_DE_L_HEURE: string;
9
+ /** The hour `bd update --defer` receives for `--reporter <heure>`, and the phrase of its texts; null refused. */
10
+ export function heureDuReport(
11
+ heure: string,
12
+ maintenant: Date
13
+ ): { defer: string; quand: string } | null;
9
14
  /** The stops `--mecanique` answers, by the step they stand at: the testwriter's, the proof's. */
10
15
  export const ARRETS_DE_LA_BASCULE: Record<string, string[]>;
11
16
  /** The sort of a ticket, as the plan says it (scripts/resultats.mjs `sorteDuPlan`). */
@@ -15,6 +20,16 @@ export interface SorteDuTicket {
15
20
  comportement?: 'changé' | 'tests-adaptés' | 'inchangé';
16
21
  commande?: string;
17
22
  }
23
+ /** The answer `--planifier` to the stop <etat>: a refusal, or nothing. */
24
+ export function reponsePlanifier(o: {
25
+ etat: {
26
+ etape: string;
27
+ raison?: string | null;
28
+ motif?: string | null;
29
+ circuit?: string | null;
30
+ } | null;
31
+ contexte: string | null;
32
+ }): { refus?: string };
18
33
  /** The answer `--mecanique` to the stop <etat> of a ticket of sort <sorte>: a refusal, or its new sort and step. */
19
34
  export function reponseMecanique(o: {
20
35
  etat: { etape: string; raison?: string | null } | null;