@roomi-fields/grillhouse 0.32.0 → 0.33.1

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 (131) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +32 -0
  3. package/bin/grillhouse.mjs +6 -4
  4. package/cadre/templates/projet/.github/workflows/ci.yml +169 -16
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +111 -0
  6. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +4 -4
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +8 -5
  9. package/dist/temporal/circuit/client.d.ts +10 -3
  10. package/dist/temporal/circuit/client.js +8 -4
  11. package/dist/temporal/circuit/client.js.map +1 -1
  12. package/dist/temporal/circuit/contrat.d.ts +25 -0
  13. package/dist/temporal/circuit/contrat.js +31 -0
  14. package/dist/temporal/circuit/contrat.js.map +1 -1
  15. package/dist/temporal/circuit/deroule.js +67 -38
  16. package/dist/temporal/circuit/deroule.js.map +1 -1
  17. package/dist/temporal/commande.js +13 -3
  18. package/dist/temporal/commande.js.map +1 -1
  19. package/dist/temporal/deroules.d.ts +1 -0
  20. package/dist/temporal/deroules.js +3 -1
  21. package/dist/temporal/deroules.js.map +1 -1
  22. package/dist/temporal/file/activites.d.ts +1 -0
  23. package/dist/temporal/file/activites.js +5 -2
  24. package/dist/temporal/file/activites.js.map +1 -1
  25. package/dist/temporal/file/contrat.d.ts +50 -33
  26. package/dist/temporal/file/contrat.js +2 -2
  27. package/dist/temporal/file/contrat.js.map +1 -1
  28. package/dist/temporal/file/deroule.d.ts +3 -1
  29. package/dist/temporal/file/deroule.js +128 -26
  30. package/dist/temporal/file/deroule.js.map +1 -1
  31. package/dist/temporal/installation.d.ts +15 -1
  32. package/dist/temporal/installation.js +57 -15
  33. package/dist/temporal/installation.js.map +1 -1
  34. package/dist/temporal/nuits/activites.d.ts +10 -0
  35. package/dist/temporal/nuits/activites.js +114 -0
  36. package/dist/temporal/nuits/activites.js.map +1 -0
  37. package/dist/temporal/nuits/appel.d.ts +23 -0
  38. package/dist/temporal/nuits/appel.js +40 -0
  39. package/dist/temporal/nuits/appel.js.map +1 -0
  40. package/dist/temporal/nuits/choix.d.ts +14 -0
  41. package/dist/temporal/nuits/choix.js +119 -0
  42. package/dist/temporal/nuits/choix.js.map +1 -0
  43. package/dist/temporal/nuits/client.d.ts +28 -0
  44. package/dist/temporal/nuits/client.js +83 -0
  45. package/dist/temporal/nuits/client.js.map +1 -0
  46. package/dist/temporal/nuits/commande.d.ts +2 -0
  47. package/dist/temporal/nuits/commande.js +107 -0
  48. package/dist/temporal/nuits/commande.js.map +1 -0
  49. package/dist/temporal/nuits/contrat.d.ts +98 -0
  50. package/dist/temporal/nuits/contrat.js +30 -0
  51. package/dist/temporal/nuits/contrat.js.map +1 -0
  52. package/dist/temporal/nuits/deroule.d.ts +5 -0
  53. package/dist/temporal/nuits/deroule.js +100 -0
  54. package/dist/temporal/nuits/deroule.js.map +1 -0
  55. package/dist/temporal/travailleur.js +4 -1
  56. package/dist/temporal/travailleur.js.map +1 -1
  57. package/docs/ARCHITECTURE.md +214 -49
  58. package/docs/CADRE.md +31 -1
  59. package/docs/INTERFACE.md +47 -7
  60. package/hooks/register.tsx +11 -3
  61. package/package.json +4 -1
  62. package/scripts/abi-des-dependances.mjs +105 -0
  63. package/scripts/activites.mjs +113 -42
  64. package/scripts/aiguillage.mjs +1 -0
  65. package/scripts/avancement.mjs +8 -18
  66. package/scripts/ci-des-branches.mjs +91 -0
  67. package/scripts/circuit.mjs +79 -4
  68. package/scripts/circuits-du-serveur.mjs +4 -3
  69. package/scripts/composants-affectes.mjs +24 -7
  70. package/scripts/composition-des-langages.mjs +3 -0
  71. package/scripts/crochets.mjs +4 -0
  72. package/scripts/dernier-vert.mjs +31 -10
  73. package/scripts/enveloppe/enveloppe.mjs +3 -1
  74. package/scripts/enveloppe/lancer.sh +1 -1
  75. package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
  76. package/scripts/etapes.mjs +18 -1
  77. package/scripts/faits-du-circuit.mjs +43 -20
  78. package/scripts/fichier-du-poste.mjs +87 -0
  79. package/scripts/grillhouse-maj.mjs +15 -1
  80. package/scripts/integration/file.mjs +215 -275
  81. package/scripts/integration/integrer.mjs +82 -41
  82. package/scripts/integration/rejeu.mjs +13 -64
  83. package/scripts/jointure.d.ts +26 -2
  84. package/scripts/langages/cargo/commandes.mjs +81 -19
  85. package/scripts/langages/cargo/exemples.mjs +2 -2
  86. package/scripts/langages/cargo/index.mjs +11 -5
  87. package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
  88. package/scripts/langages/python/commandes.mjs +11 -7
  89. package/scripts/langages/python/exemples.mjs +1 -1
  90. package/scripts/langages/python/index.mjs +9 -2
  91. package/scripts/langages/python/tailles-des-tests.mjs +19 -11
  92. package/scripts/langages/typescript/code-mort.mjs +41 -24
  93. package/scripts/langages/typescript/consommateurs.mjs +28 -17
  94. package/scripts/langages/typescript/exemples.mjs +2 -0
  95. package/scripts/langages/typescript/index.mjs +22 -3
  96. package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
  97. package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
  98. package/scripts/langages/typescript/resumes.mjs +17 -7
  99. package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
  100. package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
  101. package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
  102. package/scripts/langages/typescript/tests.mjs +8 -2
  103. package/scripts/langages/typescript/tranches.mjs +273 -0
  104. package/scripts/langages/typescript/verifier.mjs +140 -31
  105. package/scripts/langages/typescript/vitest-config/changements.mjs +23 -11
  106. package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
  107. package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
  108. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
  109. package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
  110. package/scripts/lint-des-scripts.mjs +23 -6
  111. package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
  112. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
  113. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
  114. package/scripts/migrations/0.33.0-node-26.mjs +58 -0
  115. package/scripts/migrations.mjs +8 -0
  116. package/scripts/newday.mjs +18 -0
  117. package/scripts/nuit.sh +35 -17
  118. package/scripts/registre.d.mts +90 -0
  119. package/scripts/registre.mjs +28 -3
  120. package/scripts/reprise.mjs +12 -8
  121. package/scripts/services-du-noyau.mjs +5 -1
  122. package/scripts/session-start.sh +40 -32
  123. package/scripts/sous-commandes.mjs +29 -10
  124. package/scripts/superviseur.mjs +72 -27
  125. package/scripts/tableau.mjs +129 -20
  126. package/scripts/taches-du-graphe.mjs +39 -6
  127. package/scripts/transitions.mjs +42 -3
  128. package/scripts/verrou-de-machine.mjs +1 -2
  129. package/scripts/workflows-du-cadre.mjs +75 -0
  130. package/skills/grill/SKILL.md +8 -6
  131. package/skills/pitmaster/SKILL.md +15 -9
@@ -29,12 +29,26 @@
29
29
  // copy brought back to HEAD, moved forward, the lot applied three ways. The lot waits in the
30
30
  // copy's own git directory (`git rev-parse --git-dir`, `grillhouse-travail.patch`) while the
31
31
  // copy moves, and goes once it is applied.
32
+ // - The lot applies file by file (one `git apply --3way` per file, its patch alone): a file that
33
+ // fails touches none of the others. A file in conflict keeps its marks; a file git refuses
34
+ // without marks (a deletion of a file main changed) stays alone in the lot kept in the git
35
+ // directory, named in the message; the untracked files stay in place.
32
36
  // - Applied without conflict: the index is left as HEAD has it; exit 0.
33
37
  // - In conflict: the copy stays as `git merge` leaves it, the conflicts marked in the files and
34
38
  // unmerged in the index; the output names the copy and each file in conflict; exit 1.
35
- // - A copy whose lot still waits in its git directory (git refused it whole, as a deletion of
36
- // a file main changed) is not touched: the output names the file and how to take it back;
37
- // exit 1. So no relaunch loses it.
39
+ // - A copy whose lot still waits in its git directory is not touched: the output names the files
40
+ // and how to take them back; exit 1. So no relaunch loses it.
41
+ // - With `--role <role>` (`ecrit`), the launch of a session of the role that writes at least one
42
+ // of the files in conflict or of the lot kept is accepted (exit 0): its session receives its
43
+ // files alone, the marks in the copy or the lot as it waits, the other role's files staying
44
+ // marked or in the lot until its own session. A role that writes none gets the refusal. The
45
+ // circuit plays the same rule before a pass (scripts/circuit.mjs `avantLaPasse`, the gesture
46
+ // `conflit-de-l-avance`): the testwriter first for a test or the shared test material
47
+ // (`estUnTest`), then the developpeur, the session of each coming back to the pass, which
48
+ // prepares the copy again (`suspects`, the files of the conflict whose marks are looked for
49
+ // even when the index no longer says them in conflict); a conflict the session of the role
50
+ // does not lift goes up to the supervisor, the stop « lancement », each file named. A file
51
+ // without marker left in the copy counts as resolved (put in the index by the circuit).
38
52
  // - A copy still in conflict (unmerged entries in its index) or whose branch has left main
39
53
  // (commits on both sides, no fast-forward) is not touched; the output says why; exit 1. A
40
54
  // fast-forward that fails after the work is set aside (an untracked file in the way) gives
@@ -53,7 +67,7 @@
53
67
  // and open-synth-descriptors, each copy moved by hand). A lot in conflict on another file is not
54
68
  // regenerated: its conflicts come first.
55
69
  import { spawnSync } from 'node:child_process';
56
- import { existsSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs';
70
+ import { existsSync, readFileSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs';
57
71
  import path from 'node:path';
58
72
  import { pathToFileURL } from 'node:url';
59
73
  import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
@@ -102,31 +116,46 @@ function lesCles(copie) {
102
116
  }
103
117
 
104
118
  /**
105
- * Applies the lot <lot> (a Buffer of `git diff --binary`) three ways to <copie>: `conflits`, the
106
- * files in conflict, null when git refuses the lot outright. With <cles> (`lesCles`), the generated
107
- * files the lot (or one of <autres>, the copy's untracked files) touches are left out, then written
108
- * again by their command once the lot applies without conflict; `refus`, a command that fails.
119
+ * Applies the lot <lot> (a Buffer of `git diff --binary`) three ways to <copie>, file by file:
120
+ * `conflits`, the files that keep their marks; `enAttente`, the files git refuses without marks (a
121
+ * deletion of a file main changed), whose patches are `restant`. With <cles> (`lesCles`), the
122
+ * generated files the lot (or one of <autres>, the copy's untracked files) touches are left out,
123
+ * then written again by their command once the lot applies without conflict; `refus`, a command
124
+ * that fails.
109
125
  * @param {string} copie
110
126
  * @param {Buffer} lot
111
127
  * @param {{ engendres: any[], env: NodeJS.ProcessEnv } | null} [cles]
112
128
  * @param {string[]} [autres]
113
- * @returns {{ conflits: string[] | null, refus?: string | null }}
129
+ * @returns {{ conflits: string[], enAttente: string[], restant: Buffer, refus?: string | null }}
114
130
  */
115
131
  function appliquer(copie, lot, cles = null, autres = []) {
116
132
  const fichiers = cles ? [...fichiersDuLot(copie, lot), ...autres] : [];
117
133
  const touches = cles ? touchesPar(cles.engendres, fichiers) : [];
118
134
  const exclus = fichiers.filter(f => touches.some(e => couvertPar(e.entiers, f)));
119
- const r = git(
120
- copie,
121
- ['apply', '--3way', '--allow-empty', ...exclus.map(f => `--exclude=${f}`), '-'],
122
- lot
123
- );
124
- const conflits = enConflit(copie);
125
- if (r.status !== 0 && !conflits.length) {
126
- return { conflits: null };
135
+ // One call of `git apply --3way` per file: a file that fails touches none of the others.
136
+ const conflits = [];
137
+ const enAttente = [];
138
+ const gardes = [];
139
+ for (const morceau of morceauxDuLot(lot)) {
140
+ const noms = fichiersDuLot(copie, morceau);
141
+ if (noms.length && noms.every(f => exclus.includes(f))) {
142
+ continue;
143
+ }
144
+ const r = git(copie, ['apply', '--3way', '--allow-empty', '-'], morceau);
145
+ if (r.status === 0) {
146
+ continue;
147
+ }
148
+ const marques = enConflit(copie).filter(f => noms.includes(f));
149
+ if (marques.length) {
150
+ conflits.push(...marques);
151
+ } else {
152
+ enAttente.push(...noms.slice(-1));
153
+ gardes.push(morceau);
154
+ }
127
155
  }
128
- if (conflits.length || !touches.length || !cles) {
129
- return { conflits };
156
+ const restant = Buffer.concat(gardes);
157
+ if (conflits.length || enAttente.length || !touches.length || !cles) {
158
+ return { conflits, enAttente, restant };
130
159
  }
131
160
  const refus = regenerer({
132
161
  refs: touches.map(e => ({ ...e, cadre: false })),
@@ -139,7 +168,73 @@ function appliquer(copie, lot, cles = null, autres = []) {
139
168
  }),
140
169
  dansCopie: (...args) => spawnSync('git', ['-C', copie, ...args], { encoding: 'utf8' }),
141
170
  });
142
- return { conflits, refus };
171
+ return { conflits, enAttente, restant, refus };
172
+ }
173
+
174
+ /**
175
+ * The lot <lot> cut into the patch of each file (`diff --git` to the next), as Buffers.
176
+ * @param {Buffer} lot
177
+ * @returns {Buffer[]}
178
+ */
179
+ function morceauxDuLot(lot) {
180
+ return String(lot.toString('latin1'))
181
+ .split(/(?=^diff --git )/m)
182
+ .filter(m => m.startsWith('diff --git '))
183
+ .map(m => Buffer.from(m, 'latin1'));
184
+ }
185
+
186
+ // Whether the file <f> of <copie> carries a conflict marker (`<<<<<<< ` or `>>>>>>> ` at the head
187
+ // of a line), as git writes them.
188
+ function porteDesMarques(copie, f) {
189
+ const chemin = path.join(copie, f);
190
+ return existsSync(chemin) && /^(<{7}|>{7}) /m.test(readFileSync(chemin, 'latin1'));
191
+ }
192
+
193
+ // The files of <copie> that carry no conflict marker any more, among those unmerged: the work of a
194
+ // session that resolved them. Each goes to the index as resolved; the index is then left as HEAD has
195
+ // it once no conflict remains.
196
+ function releverLesResolus(copie) {
197
+ const a = enConflit(copie);
198
+ const resolus = a.filter(f => existsSync(path.join(copie, f)) && !porteDesMarques(copie, f));
199
+ for (const f of resolus) {
200
+ git(copie, ['add', '--', f]);
201
+ }
202
+ if (resolus.length && resolus.length === a.length) {
203
+ git(copie, ['reset', '-q']);
204
+ }
205
+ }
206
+
207
+ /**
208
+ * The files of <fichiers> by role: `{ testwriter, developpeur, roles }`, the testwriter's those
209
+ * <estUnTest> (the rule of a test file of the module of the language) judges, the developpeur's the
210
+ * others; `roles`, the order of the sessions, the testwriter first, a role without file absent.
211
+ * @param {string[]} fichiers
212
+ * @param {(fichier: string) => unknown} estUnTest
213
+ */
214
+ export function rolesDuConflit(fichiers, estUnTest) {
215
+ const testwriter = fichiers.filter(f => Boolean(estUnTest(f)));
216
+ const developpeur = fichiers.filter(f => !estUnTest(f));
217
+ const roles = [
218
+ testwriter.length ? 'testwriter' : null,
219
+ developpeur.length ? 'developpeur' : null,
220
+ ];
221
+ return { testwriter, developpeur, roles: roles.filter(r => r !== null) };
222
+ }
223
+
224
+ /**
225
+ * Whether the role <role> writes a file, as a function of the file: the testwriter those
226
+ * <estUnTest> judges, the developpeur the others, any other role none (undefined).
227
+ * @param {string} role
228
+ * @param {(fichier: string) => unknown} estUnTest
229
+ */
230
+ export function ecritPar(role, estUnTest) {
231
+ if (role === 'testwriter') {
232
+ return f => Boolean(estUnTest(f));
233
+ }
234
+ if (role === 'developpeur') {
235
+ return f => !estUnTest(f);
236
+ }
237
+ return undefined;
143
238
  }
144
239
 
145
240
  /**
@@ -157,8 +252,11 @@ export function reporter(copie, { base, pointe }) {
157
252
  return { ok: false, message: cles.refus };
158
253
  }
159
254
  const a = appliquer(copie, d.stdout, cles);
160
- if (a.conflits === null) {
161
- return { ok: false, message: `⛔ Le lot ne s'applique pas à la copie ${copie}.` };
255
+ if (a.enAttente.length) {
256
+ return {
257
+ ok: false,
258
+ message: `⛔ Le lot ne s'applique pas à la copie ${copie} pour : ${a.enAttente.join(', ')}.`,
259
+ };
162
260
  }
163
261
  const r = git(copie, ['reset', '-q']);
164
262
  if (a.refus) {
@@ -167,34 +265,68 @@ export function reporter(copie, { base, pointe }) {
167
265
  return r.status === 0 ? { ok: true, message: '' } : { ok: false, message: texte(r) };
168
266
  }
169
267
 
268
+ const lotEnAttente = (copie, garde, fichiers) =>
269
+ `⛔ Le travail de la copie ${copie} attend dans ${garde}, que git n'a pas pu remettre en place pour :\n${fichiers.map(f => ` ${f}`).join('\n')}\nIl se reprend à la main (git apply --3way ${garde}, ou il se jette), puis le fichier se retire, avant une relance ; le circuit relance le rôle qui écrit ces fichiers.`;
270
+
170
271
  const conflit = (copie, conflits, entete) =>
171
272
  [entete, 'Fichiers en conflit :', ...conflits.map(f => ` ${f}`)].join('\n');
172
273
 
173
274
  /**
174
- * Moves <copie> forward to <cible>, its local work kept in the copy; returns `{ ok, message }`.
275
+ * Moves <copie> forward to <cible>, its local work kept in the copy; returns `{ ok, message,
276
+ * conflits, enAttente }`, the files that keep their marks and those that wait alone in the kept
277
+ * lot. With <ecrit> (whether the role relaunched writes a file), a copy that keeps conflicts or a
278
+ * lot waiting is accepted (`ok`) when that role writes one of their files. <suspects>, the files
279
+ * an earlier advance left in conflict: one that still carries its marks counts as in conflict,
280
+ * even when the index no longer says so (a session wrote it, or put it in the index, unresolved).
175
281
  * @param {string} copie
176
282
  * @param {string} cible
283
+ * @param {{ ecrit?: (fichier: string) => boolean, suspects?: string[] }} [o]
177
284
  */
178
- export function avancer(copie, cible) {
179
- const restants = enConflit(copie);
180
- if (restants.length) {
181
- return {
182
- ok: false,
183
- message: conflit(
184
- copie,
185
- restants,
186
- `⛔ La copie ${copie} garde des conflits non résolus ; ils se résolvent dans la copie avant une relance.`
187
- ),
188
- };
189
- }
285
+ export function avancer(copie, cible, { ecrit, suspects = [] } = {}) {
286
+ releverLesResolus(copie);
287
+ const restants = [
288
+ ...new Set([...enConflit(copie), ...suspects.filter(f => porteDesMarques(copie, f))]),
289
+ ];
190
290
  const garde = path.join(
191
291
  path.resolve(copie, String(git(copie, ['rev-parse', '--git-dir']).stdout).trim()),
192
292
  LOT
193
293
  );
294
+ // The deletions a session has done in the copy leave the kept lot.
194
295
  if (existsSync(garde)) {
296
+ const morceaux = morceauxDuLot(readFileSync(garde));
297
+ const reste = morceaux.filter(m =>
298
+ fichiersDuLot(copie, m).some(f => existsSync(path.join(copie, f)))
299
+ );
300
+ if (morceaux.length && reste.length < morceaux.length) {
301
+ if (reste.length) {
302
+ writeFileSync(garde, Buffer.concat(reste));
303
+ } else {
304
+ rmSync(garde, { force: true });
305
+ }
306
+ }
307
+ }
308
+ const attendus = existsSync(garde) ? fichiersDuLot(copie, readFileSync(garde)) : [];
309
+ if (restants.length || existsSync(garde)) {
310
+ const voulu = ecrit ? [...restants, ...attendus].some(f => ecrit(f)) : false;
311
+ // The role relaunched receives its files alone.
312
+ const siens = liste => (voulu ? liste.filter(f => ecrit(f)) : liste);
313
+ const message = [
314
+ restants.length
315
+ ? conflit(
316
+ copie,
317
+ restants,
318
+ `⛔ La copie ${copie} garde des conflits non résolus ; ils se résolvent dans la copie avant une relance.`
319
+ )
320
+ : null,
321
+ existsSync(garde) ? lotEnAttente(copie, garde, attendus) : null,
322
+ ]
323
+ .filter(Boolean)
324
+ .join('\n');
195
325
  return {
196
- ok: false,
197
- message: `⛔ Le travail de la copie ${copie} attend dans ${garde}, que git n'a pas pu remettre en place ; il se reprend à la main (git apply --3way ${garde}, ou il se jette), puis le fichier se retire, avant une relance.`,
326
+ ok: voulu,
327
+ message: voulu ? '' : message,
328
+ conflits: siens(restants),
329
+ enAttente: siens(attendus),
198
330
  };
199
331
  }
200
332
  const cles = lesCles(copie);
@@ -234,8 +366,12 @@ export function avancer(copie, cible) {
234
366
  const remis = git(copie, ['reset', '-q', '--hard']);
235
367
  const ff = remis.status === 0 ? git(copie, ['merge', '-q', '--ff-only', cible]) : remis;
236
368
  if (ff.status !== 0) {
237
- const rendu = appliquer(copie, d.stdout).conflits;
238
- if (rendu !== null && rendu.length === 0 && git(copie, ['reset', '-q']).status === 0) {
369
+ const rendu = appliquer(copie, d.stdout);
370
+ if (
371
+ rendu.conflits.length === 0 &&
372
+ rendu.enAttente.length === 0 &&
373
+ git(copie, ['reset', '-q']).status === 0
374
+ ) {
239
375
  rmSync(garde, { force: true });
240
376
  return {
241
377
  ok: false,
@@ -248,22 +384,35 @@ export function avancer(copie, cible) {
248
384
  };
249
385
  }
250
386
  const libres = lignes(git(copie, ['ls-files', '--others', '--exclude-standard']));
251
- const { conflits, refus } = appliquer(copie, d.stdout, cles, libres);
252
- if (conflits === null) {
253
- return {
254
- ok: false,
255
- message: `⛔ Le travail de la copie ${copie} ne s'applique pas sur main ; il reste dans ${garde}.`,
256
- };
387
+ const { conflits, enAttente, restant, refus } = appliquer(copie, d.stdout, cles, libres);
388
+ if (enAttente.length) {
389
+ writeFileSync(garde, restant);
390
+ } else {
391
+ rmSync(garde, { force: true });
257
392
  }
258
- rmSync(garde, { force: true });
259
- if (conflits.length) {
393
+ if (conflits.length || enAttente.length) {
394
+ if (!conflits.length) {
395
+ git(copie, ['reset', '-q']);
396
+ }
397
+ const message = [
398
+ conflits.length
399
+ ? conflit(
400
+ copie,
401
+ conflits,
402
+ `⛔ Le travail en cours de la copie entre en conflit avec main ; il reste dans la copie ${copie}, ses conflits marqués dans ses fichiers.`
403
+ )
404
+ : null,
405
+ enAttente.length ? lotEnAttente(copie, garde, enAttente) : null,
406
+ ]
407
+ .filter(Boolean)
408
+ .join('\n');
409
+ const voulu = ecrit ? [...conflits, ...enAttente].some(f => ecrit(f)) : false;
410
+ const siens = liste => (voulu ? liste.filter(f => ecrit(f)) : liste);
260
411
  return {
261
- ok: false,
262
- message: conflit(
263
- copie,
264
- conflits,
265
- `⛔ Le travail en cours de la copie entre en conflit avec main ; il reste dans la copie ${copie}, ses conflits marqués dans ses fichiers.`
266
- ),
412
+ ok: voulu,
413
+ message: voulu ? '' : message,
414
+ conflits: siens(conflits),
415
+ enAttente: siens(enAttente),
267
416
  };
268
417
  }
269
418
  const r = git(copie, ['reset', '-q']);
@@ -285,9 +434,10 @@ const SOUS_MODULES = path.join(import.meta.dirname, '..', 'sous-modules.sh');
285
434
  * command goes to the file descriptor <sortie>; returns `{ ok, message, partages }`.
286
435
  * @param {string} copie
287
436
  * @param {string | null} cible
288
- * @param {{ env?: NodeJS.ProcessEnv, sortie?: number }} [o]
437
+ * @param {{ env?: NodeJS.ProcessEnv, sortie?: number, ecrit?: (fichier: string) => boolean,
438
+ * suspects?: string[] }} [o]
289
439
  */
290
- export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
440
+ export function preparer(copie, cible, { env = process.env, sortie = 2, ecrit, suspects } = {}) {
291
441
  // A command of the submodules whose error output is read: kept on <sortie> as well when it
292
442
  // succeeds, as the launcher's log kept it.
293
443
  const bash = (args, stdio) => {
@@ -311,7 +461,7 @@ export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
311
461
  if (g.status !== 0) {
312
462
  return echec(g, 'La garde des sous-modules');
313
463
  }
314
- const a = avancer(copie, cible);
464
+ const a = avancer(copie, cible, { ecrit, suspects });
315
465
  if (!a.ok) {
316
466
  return { ...a, partages: '' };
317
467
  }
@@ -356,16 +506,26 @@ export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
356
506
  }
357
507
 
358
508
  if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
359
- const [geste, copie, ...reste] = process.argv.slice(2);
509
+ const [geste, copie, ...tout] = process.argv.slice(2);
510
+ // `--role <role>` (preparer): the role the session launched is, whose files a conflict or a lot
511
+ // kept may be.
512
+ const iRole = tout.indexOf('--role');
513
+ const role = iRole >= 0 ? tout[iRole + 1] : null;
514
+ const reste = iRole >= 0 ? tout.filter((_, i) => i !== iRole && i !== iRole + 1) : tout;
515
+ let ecrit;
516
+ if (geste === 'preparer' && role) {
517
+ const { langageDe } = await import('../langages.mjs');
518
+ ecrit = ecritPar(role, f => langageDe(copie).estUnTest(f, copie));
519
+ }
360
520
  const r =
361
521
  geste === 'reporter' && reste.length === 2
362
522
  ? reporter(copie, { base: reste[0], pointe: reste[1] })
363
523
  : geste === 'preparer' && reste.length <= 1
364
- ? preparer(copie, reste[0] ?? null)
524
+ ? preparer(copie, reste[0] ?? null, { ecrit })
365
525
  : {
366
526
  ok: false,
367
527
  message:
368
- 'usage: travail-de-la-copie.mjs reporter <copie> <base> <pointe> | preparer <copie> [<cible>]',
528
+ 'usage: travail-de-la-copie.mjs reporter <copie> <base> <pointe> | preparer <copie> [<cible>] [--role <role>]',
369
529
  };
370
530
  // `preparer` prints the list its pose fixes on stdout, its messages on stderr.
371
531
  if (geste === 'preparer') {
@@ -131,6 +131,11 @@ export const ARRETS = {
131
131
  'sans-livraison': 15,
132
132
  'relecture-arret': 16,
133
133
  integration: 17,
134
+ // The resumption of the integration of a lot already on main: a lot neither on main nor in the
135
+ // copy (`lot-absent`), or a copy that does not get removed (`copie-gardee`); both at the code of
136
+ // the integration stop (grillhouse-bf5.2).
137
+ 'lot-absent': 17,
138
+ 'copie-gardee': 17,
134
139
  'hors-portee': 19,
135
140
  besoin: 20,
136
141
  questionnement: 22,
@@ -197,7 +202,7 @@ export const GESTES = [
197
202
  genre: 'rejeu',
198
203
  geste: 'la commande joue une seconde fois',
199
204
  regle:
200
- 'une commande des contrôles hors de la passe finale, ou l’intégration, à 75 rejoue une fois avant l’arrêt',
205
+ 'une commande des contrôles hors de la passe finale à 75 rejoue une fois avant l’arrêt',
201
206
  cas: 'A12 : un contrôle à 75, rejoué avant de conclure à la charge',
202
207
  },
203
208
  {
@@ -229,6 +234,14 @@ export const GESTES = [
229
234
  'le plan dit le ticket mécanique, avec sa raison et sa commande (`sorte` de la fiche de l’explorateur) : un geste sans comportement neuf ; tant qu’aucun testwriter ni développeur n’a travaillé le lot, un rouge des contrôles ou un RENDU monte, sans relancer personne',
230
235
  cas: 'BP 320.16 : 38 outils déplacés par mv, 117 commentaires ; BP 320.40.1 : une variable inutilisée, 4 séances ; BP 322.11.1 : l’outil de test monté sur 31 paquets',
231
236
  },
237
+ {
238
+ genre: 'conflit-de-l-avance',
239
+ geste:
240
+ 'au rôle qui écrit les fichiers en conflit ou au lot gardé, les marques posées dans la copie : le testwriter pour un test ou la matière de test partagée, le développeur pour le code, le testwriter d’abord puis le développeur sur les fichiers des deux',
241
+ regle:
242
+ 'l’avance d’une copie sur main laisse des fichiers en conflit ou un lot gardé : le rôle que `estUnTest` du module du langage désigne pour chacun les écrit ; un conflit que la seconde séance du rôle ne lève pas monte (lancement)',
243
+ cas: 'SH-b52.2 : marques dans 2 fichiers de test, résolues à la main par le superviseur ; SH-br0.3 : 8 fichiers de test dans le lot gardé, la copie sur main sans eux',
244
+ },
232
245
  ];
233
246
 
234
247
  // The gesture of name <genre>, or null.
@@ -268,6 +281,10 @@ export const MONTEES = Object.fromEntries(
268
281
  'La relecture ne rend pas le lot à un agent (un constat sans destinataire valide, un constat au testwriter que le plan saute, un lot mécanique rendu, un critère en cause, ou la troisième relecture rendue) : que devient le plan, et qui reprend ?',
269
282
  integration:
270
283
  'L’intégration refuse le lot, ou la file rouvre le ticket : que corrige le lot, et qui le reprend ?',
284
+ 'lot-absent':
285
+ 'La reprise de l’intégration ne trouve le lot ni sur main ni dans la copie : que devient le lot, et qui le reprend ?',
286
+ 'copie-gardee':
287
+ 'Le lot est sur main, mais la copie ou son dossier de travail ne se retire pas : qu’est-ce qui la retient, et se lève-t-il pour reprendre ?',
271
288
  'hors-portee':
272
289
  'L’agent se dit bloqué hors de sa portée : le plan s’étend-il au paquet qu’il nomme, ou un autre agent lève-t-il le reste ?',
273
290
  besoin: 'Une réponse manque pour avancer : laquelle ?',
@@ -50,12 +50,13 @@
50
50
  // an effect not written has its outcome, said on the error output or the failure of its
51
51
  // activity;
52
52
  // - the acts of the queue of a project (scripts/integration/file.mjs, grillhouse-4nr.8): `situer`,
53
- // where the lot of a ticket stands (`situerLeLot`); `avancer`, main moved onto its branch
54
- // (`avancerMain`), the ticket told of a branch out of the queue or kept (`direLIssue`);
55
- // `fermer`, the ticket closed and main pushed (`fermerLEntree`); `ci`, one reading of the CI of
56
- // a commit (`lireUneFoisLaCI`); `conclure`, the CI concluded at the ticket (`conclureLaCI`);
57
- // `effet-de-la-file`, one effect they gave back, under the key of its activity. Their lines go
58
- // to the error output.
53
+ // where the lot of a ticket stands (`situerLeLot`); `brancher`, the branch made the candidate its
54
+ // CI judges and pushed (`preparerLaBranche`); `ci`, one reading of the CI of a commit
55
+ // (`lireUneFoisLaCI`); `conclure`, the CI concluded at the ticket (`conclureLaCI`); `avancer`,
56
+ // main moved onto the candidate (`avancerMain`); each of `brancher` and `avancer` telling the
57
+ // ticket of a branch out of the queue or kept (`direLIssue`); `fermer`, the ticket closed and main
58
+ // pushed (`fermerLEntree`); `effet-de-la-file`, one effect they gave back, under the key of its
59
+ // activity. Their lines go to the error output.
59
60
  import { appendFileSync, readFileSync } from 'node:fs';
60
61
  import path from 'node:path';
61
62
  import { pathToFileURL } from 'node:url';
@@ -75,6 +76,9 @@ import {
75
76
  monter,
76
77
  ouvrirJusquAuPlan,
77
78
  publierLArret,
79
+ SANS_CONFLIT,
80
+ SUR_LA_POINTE,
81
+ suiteDuConflit,
78
82
  unPasDuPlan,
79
83
  } from './circuit.mjs';
80
84
  import {
@@ -84,9 +88,10 @@ import {
84
88
  fermerLEntree,
85
89
  lireUneFoisLaCI,
86
90
  outilsDeLaFile,
91
+ preparerLaBranche,
87
92
  situerLeLot,
88
93
  } from './integration/file.mjs';
89
- import { avancementDeLaCI, avecLAvancementDuTravail } from './avancement.mjs';
94
+ import { avancementDeLaCI } from './avancement.mjs';
90
95
  import { ecrireLEffet } from './effets.mjs';
91
96
  import { Arret, geste } from './ticket-du-circuit.mjs';
92
97
 
@@ -232,10 +237,29 @@ const ACTES = {
232
237
  const { nom, rapport, piece, question } = pointe.arret;
233
238
  return { arret: { leve: { nom, rapport, piece, question } }, etat, menee };
234
239
  }
240
+ if (pointe.conflit) {
241
+ // The copy's advance left files in conflict, or a lot kept: the role that writes the first
242
+ // of them is relaunched (the decision of the workflow), then the pass prepares again.
243
+ geste(ctx, 'conflit-de-l-avance');
244
+ const { role, memoire } = suiteDuConflit(ctx, etape, pointe.conflit);
245
+ return {
246
+ conflit: { role, fichiers: pointe.conflit.fichiers, rapport: pointe.conflit.rapport },
247
+ memoire: { regeneration: pointe.regeneration ?? null, ...memoire },
248
+ etat,
249
+ menee,
250
+ };
251
+ }
235
252
  if (pointe.avancee) {
236
253
  appendFileSync(ctx.journal, 'la copie avance sur la pointe de main avant la passe.\n');
237
254
  }
238
- return { memoire: { regeneration: pointe.regeneration ?? null }, etat, menee };
255
+ return {
256
+ memoire: {
257
+ regeneration: pointe.regeneration ?? null,
258
+ ...(SUR_LA_POINTE.has(etape.etape) ? SANS_CONFLIT : {}),
259
+ },
260
+ etat,
261
+ menee,
262
+ };
239
263
  });
240
264
  },
241
265
  async fait(
@@ -394,20 +418,19 @@ Object.assign(ACTES, {
394
418
  async situer({ racine, ticket }) {
395
419
  return situerLeLot(laFile(racine), ticket);
396
420
  },
397
- // The replay of the ticket's branch on main writes the progress of its `npm run verifier` in
398
- // the working directory of the ticket, where the board reads it while the circuit waits for the
399
- // queue (`avecLAvancementDuTravail`, the kind `file`); a lot entered keeps it until the queue is done
400
- // with the ticket closed, which removes the working directory (`retirerLeTravail`).
401
- async avancer({ racine, ticket, branche }) {
421
+ async brancher({ racine, ticket, branche }) {
402
422
  const o = laFile(racine);
403
423
  const entree = { ticket, branche };
404
- const travail = path.join(racine, '.claude', 'worktrees', `${ticket}.travail`);
405
- const r = avecLAvancementDuTravail(
406
- travail,
407
- { racine, genre: 'file', garder: lu => Boolean(lu.entre) },
408
- () => avancerMain(o, entree)
409
- );
410
- return { ...(r.entre ? r : { issue: direLIssue(o, entree, r) }), effets: o.rendus };
424
+ const r = preparerLaBranche(o, entree);
425
+ return { ...(r.entre || r.candidat ? r : { issue: direLIssue(o, entree, r) }), effets: o.rendus };
426
+ },
427
+ async avancer({ racine, ticket, branche, commit }) {
428
+ const o = laFile(racine);
429
+ const r = avancerMain(o, { ticket, branche, commit });
430
+ return {
431
+ ...(r.entre || r.bouge ? r : { issue: direLIssue(o, { ticket, branche }, r) }),
432
+ effets: o.rendus,
433
+ };
411
434
  },
412
435
  async fermer({ racine, ticket, branche, commit }) {
413
436
  const o = laFile(racine);
@@ -0,0 +1,87 @@
1
+ // The variables of the poste a tool of a language reads: a file of the poste, out of every
2
+ // repository, under the frame's directory of configuration (`$XDG_CONFIG_HOME/grillhouse/`,
3
+ // `~/.config/grillhouse/` without it, as the XDG Base Directory Specification places a user's
4
+ // configuration), whose name the module of the language gives (`environnementDuPoste`,
5
+ // scripts/jointure.d.ts): the server of a remote cache, its token, which never enter a
6
+ // repository.
7
+ //
8
+ // - The file holds one `VARIABLE=valeur` per line, as a `.env` of the shell: `export ` before the
9
+ // name, a value between quotes, a blank line and a line of comment (`#`) are read too; any
10
+ // other line is passed over.
11
+ // - The caller decides: when the environment already holds one of the file's variables (a CI
12
+ // that names its own server, empty or not), the file is not applied, and the environment stays
13
+ // as it is. Otherwise the file's variables enter, then the additions of the module (the cache
14
+ // read-only).
15
+ // - A file absent or unreadable, an environment without HOME nor XDG_CONFIG_HOME (the session of
16
+ // an agent, whose home the envelope empties, has no such file): the environment stays as it
17
+ // is.
18
+ import { readFileSync } from 'node:fs';
19
+ import path from 'node:path';
20
+
21
+ const NOM = /^[A-Za-z_][A-Za-z0-9_]*$/;
22
+
23
+ /**
24
+ * The frame's directory of configuration on the poste, from <env>: `$XDG_CONFIG_HOME/grillhouse`,
25
+ * `$HOME/.config/grillhouse` without it; null without either.
26
+ * @param {Record<string, string | undefined>} env
27
+ * @returns {string | null}
28
+ */
29
+ export function configurationDuPoste(env) {
30
+ const base = env.XDG_CONFIG_HOME || (env.HOME ? path.join(env.HOME, '.config') : '');
31
+ return base ? path.join(base, 'grillhouse') : null;
32
+ }
33
+
34
+ /**
35
+ * The variables of the text <texte> of a file of the poste (see the header).
36
+ * @param {string} texte
37
+ * @returns {Record<string, string>}
38
+ */
39
+ export function variablesDuTexte(texte) {
40
+ /** @type {Record<string, string>} */
41
+ const variables = {};
42
+ for (const brute of texte.split('\n')) {
43
+ const ligne = brute.trim().replace(/^export\s+/, '');
44
+ const egal = ligne.indexOf('=');
45
+ if (ligne.startsWith('#') || egal <= 0) {
46
+ continue;
47
+ }
48
+ const nom = ligne.slice(0, egal).trim();
49
+ let valeur = ligne.slice(egal + 1).trim();
50
+ if (/^(['"]).*\1$/.test(valeur) && valeur.length >= 2) {
51
+ valeur = valeur.slice(1, -1);
52
+ }
53
+ if (NOM.test(nom)) {
54
+ variables[nom] = valeur;
55
+ }
56
+ }
57
+ return variables;
58
+ }
59
+
60
+ // The text of <fichier>, or null when it does not read.
61
+ const lireLeFichier = fichier => {
62
+ try {
63
+ return readFileSync(fichier, 'utf8');
64
+ } catch {
65
+ return null;
66
+ }
67
+ };
68
+
69
+ /**
70
+ * The environment <env> with the variables of the file <fichier> of the poste, then <ajouts>; <env>
71
+ * itself when the file is absent, holds no variable, or names one that <env> already holds (see
72
+ * the header).
73
+ * @template {Record<string, string | undefined>} T
74
+ * @param {T} env
75
+ * @param {{ fichier: string, ajouts?: Record<string, string>, lire?: (f: string) => string | null }} o
76
+ * @returns {T}
77
+ */
78
+ export function avecLeFichierDuPoste(env, { fichier, ajouts = {}, lire = lireLeFichier }) {
79
+ const dossier = configurationDuPoste(env);
80
+ const texte = dossier === null ? null : lire(path.join(dossier, fichier));
81
+ const variables = texte === null ? {} : variablesDuTexte(texte);
82
+ const noms = Object.keys(variables);
83
+ if (noms.length === 0 || noms.some(n => env[n] !== undefined)) {
84
+ return env;
85
+ }
86
+ return { ...env, ...variables, ...ajouts };
87
+ }