@roomi-fields/grillhouse 0.31.0 → 0.33.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 +40 -0
  3. package/bin/grillhouse.mjs +6 -4
  4. package/cadre/templates/projet/.github/workflows/ci.yml +136 -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/contrat.d.ts +15 -0
  10. package/dist/temporal/circuit/deroule.js +37 -14
  11. package/dist/temporal/circuit/deroule.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -0
  13. package/dist/temporal/deroules.js +3 -1
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -0
  16. package/dist/temporal/file/activites.js +5 -2
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +50 -33
  19. package/dist/temporal/file/contrat.js +2 -2
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +3 -1
  22. package/dist/temporal/file/deroule.js +128 -26
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +3 -2
  25. package/dist/temporal/installation.js +7 -4
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +10 -0
  28. package/dist/temporal/nuits/activites.js +114 -0
  29. package/dist/temporal/nuits/activites.js.map +1 -0
  30. package/dist/temporal/nuits/appel.d.ts +23 -0
  31. package/dist/temporal/nuits/appel.js +40 -0
  32. package/dist/temporal/nuits/appel.js.map +1 -0
  33. package/dist/temporal/nuits/choix.d.ts +14 -0
  34. package/dist/temporal/nuits/choix.js +119 -0
  35. package/dist/temporal/nuits/choix.js.map +1 -0
  36. package/dist/temporal/nuits/client.d.ts +28 -0
  37. package/dist/temporal/nuits/client.js +83 -0
  38. package/dist/temporal/nuits/client.js.map +1 -0
  39. package/dist/temporal/nuits/commande.d.ts +2 -0
  40. package/dist/temporal/nuits/commande.js +107 -0
  41. package/dist/temporal/nuits/commande.js.map +1 -0
  42. package/dist/temporal/nuits/contrat.d.ts +98 -0
  43. package/dist/temporal/nuits/contrat.js +30 -0
  44. package/dist/temporal/nuits/contrat.js.map +1 -0
  45. package/dist/temporal/nuits/deroule.d.ts +5 -0
  46. package/dist/temporal/nuits/deroule.js +100 -0
  47. package/dist/temporal/nuits/deroule.js.map +1 -0
  48. package/dist/temporal/tickets/activites.d.ts +1 -0
  49. package/dist/temporal/tickets/activites.js +5 -0
  50. package/dist/temporal/tickets/activites.js.map +1 -1
  51. package/dist/temporal/tickets/contrat.d.ts +10 -0
  52. package/dist/temporal/tickets/deroule.js +8 -1
  53. package/dist/temporal/tickets/deroule.js.map +1 -1
  54. package/dist/temporal/travailleur.js +4 -1
  55. package/dist/temporal/travailleur.js.map +1 -1
  56. package/docs/ARCHITECTURE.md +257 -54
  57. package/docs/CADRE.md +41 -1
  58. package/docs/INTERFACE.md +54 -7
  59. package/hooks/hooks.json +4 -0
  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 +99 -48
  64. package/scripts/aiguillage.mjs +3 -0
  65. package/scripts/attente-au-tour.mjs +99 -0
  66. package/scripts/avancement.mjs +8 -18
  67. package/scripts/base-des-workflows.mjs +57 -0
  68. package/scripts/ci-des-branches.mjs +91 -0
  69. package/scripts/circuit.mjs +99 -5
  70. package/scripts/composants-affectes.mjs +24 -7
  71. package/scripts/composition-des-langages.mjs +3 -0
  72. package/scripts/copies-finies.mjs +8 -1
  73. package/scripts/crochets.mjs +4 -0
  74. package/scripts/dernier-vert.mjs +30 -4
  75. package/scripts/effets.mjs +9 -0
  76. package/scripts/enveloppe/enveloppe.mjs +3 -1
  77. package/scripts/enveloppe/lancer.sh +1 -1
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
  79. package/scripts/etapes.mjs +19 -2
  80. package/scripts/faits-du-circuit.mjs +43 -20
  81. package/scripts/fichier-du-poste.mjs +87 -0
  82. package/scripts/grillhouse-maj.mjs +15 -1
  83. package/scripts/integration/file.mjs +215 -275
  84. package/scripts/integration/integrer.mjs +82 -41
  85. package/scripts/integration/rejeu.mjs +13 -64
  86. package/scripts/jointure.d.ts +30 -2
  87. package/scripts/journal-des-etats.d.mts +41 -0
  88. package/scripts/journal-des-etats.mjs +273 -0
  89. package/scripts/journal.mjs +119 -0
  90. package/scripts/langages/cargo/commandes.mjs +81 -19
  91. package/scripts/langages/cargo/exemples.mjs +2 -2
  92. package/scripts/langages/cargo/index.mjs +14 -5
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
  94. package/scripts/langages/python/commandes.mjs +11 -7
  95. package/scripts/langages/python/exemples.mjs +1 -1
  96. package/scripts/langages/python/index.mjs +11 -2
  97. package/scripts/langages/python/tailles-des-tests.mjs +19 -11
  98. package/scripts/langages/typescript/code-mort.mjs +41 -24
  99. package/scripts/langages/typescript/consommateurs.mjs +28 -17
  100. package/scripts/langages/typescript/exemples.mjs +2 -0
  101. package/scripts/langages/typescript/frontieres.mjs +46 -0
  102. package/scripts/langages/typescript/index.mjs +24 -3
  103. package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
  104. package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
  105. package/scripts/langages/typescript/resumes.mjs +17 -7
  106. package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
  107. package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
  108. package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
  109. package/scripts/langages/typescript/tranches.mjs +273 -0
  110. package/scripts/langages/typescript/verifier.mjs +154 -23
  111. package/scripts/langages/typescript/vitest-config/base.mjs +3 -0
  112. package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
  113. package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
  114. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
  115. package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
  116. package/scripts/langages.d.mts +20 -0
  117. package/scripts/lint-des-scripts.mjs +23 -6
  118. package/scripts/matiere-de-test.d.ts +11 -0
  119. package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
  120. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
  121. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
  122. package/scripts/migrations/0.33.0-node-26.mjs +58 -0
  123. package/scripts/migrations.mjs +8 -0
  124. package/scripts/newday.mjs +18 -0
  125. package/scripts/nuit.sh +40 -13
  126. package/scripts/places-de-la-machine.mjs +6 -0
  127. package/scripts/registre.d.mts +90 -0
  128. package/scripts/registre.mjs +28 -3
  129. package/scripts/reprise.mjs +12 -8
  130. package/scripts/services-du-noyau.mjs +4 -0
  131. package/scripts/session-start.sh +28 -32
  132. package/scripts/sous-commandes.mjs +31 -10
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +222 -17
  135. package/scripts/taches-du-graphe.mjs +39 -6
  136. package/scripts/ticket-du-circuit.mjs +37 -7
  137. package/scripts/transitions.mjs +60 -8
  138. package/scripts/verrou-de-machine.mjs +1 -2
  139. package/scripts/workflows-du-cadre.mjs +75 -0
  140. package/skills/developpeur/SKILL.md +1 -1
  141. package/skills/explorateur/SKILL.md +1 -1
  142. package/skills/grill/SKILL.md +10 -62
  143. package/skills/grill/references/paquets.md +60 -0
  144. package/skills/pitmaster/SKILL.md +21 -31
  145. package/skills/questionneur/SKILL.md +1 -1
  146. package/skills/relecteur/SKILL.md +1 -1
  147. package/skills/testwriter/SKILL.md +7 -1
  148. package/skills/release/SKILL.md +0 -134
  149. package/skills/release/scripts/update-version.cjs +0 -92
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ // The signal of the supervisor's turn: the hook UserPromptSubmit of the mod runs it at each turn
3
+ // of a session of supervision (`npx grillhouse attente-au-tour`), and what it writes reaches the
4
+ // session. A question of a circuit must never stay mute because the wait in the background died
5
+ // unseen, as a review requested on GitHub is named again until it is answered.
6
+ //
7
+ // - It names each circuit that waits for the supervisor (`questionsEnAttente`, the one source of
8
+ // the opening and of the wait), a circuit ended without its issue included: its ticket, its
9
+ // question, the command that answers it, then the wait to launch again.
10
+ // - A question already gone up to the wait is named again: the file of the stops gone up is not
11
+ // read.
12
+ // - A wait that lives says it all: its lock (`attente-des-questions.lock`) names a live process,
13
+ // and nothing is said. A lock whose process is dead counts as no wait.
14
+ // - Out of a git repository, in an agent's copy (a worktree) and in the session of a role that
15
+ // the circuit launches (BEADS_ACTOR set), nothing is said.
16
+ // Exit 0, whatever it finds.
17
+ import { spawnSync } from 'node:child_process';
18
+ import { readFileSync } from 'node:fs';
19
+ import path from 'node:path';
20
+ import { pathToFileURL } from 'node:url';
21
+ import { circuitsDuServeur } from './circuits-du-serveur.mjs';
22
+ import { vivant } from './mesure/base-de-passe.mjs';
23
+ import { questionsEnAttente, ticketsFermes, verrouDeLAttente } from './superviseur.mjs';
24
+
25
+ // The process that the lock of the wait of the repository at <racine> names; null without a lock.
26
+ function tenant(racine) {
27
+ try {
28
+ return Number(/^(\d+)/.exec(readFileSync(verrouDeLAttente(racine), 'utf8'))?.[1]) || null;
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * What the session of supervision in <dossier> reads at its turn: the circuits that wait for the
36
+ * supervisor, each with its ticket, its question and the command that answers it, then the wait to
37
+ * launch again; empty when a wait lives, when no circuit waits, or out of a session of supervision.
38
+ * @param {string} dossier the directory the session works in
39
+ * @param {{ env?: Record<string, string | undefined>,
40
+ * fermes?: (racine: string, ids: string[]) => Set<string>,
41
+ * circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} options
42
+ * @returns {Promise<string>}
43
+ */
44
+ export async function attenteAuTour(
45
+ dossier,
46
+ { env = process.env, fermes = ticketsFermes, circuitsDe = circuitsDuServeur } = {}
47
+ ) {
48
+ if (env.BEADS_ACTOR) {
49
+ return '';
50
+ }
51
+ const r = spawnSync(
52
+ 'git',
53
+ ['-C', dossier, 'rev-parse', '--path-format=absolute', '--git-dir', '--git-common-dir'],
54
+ { encoding: 'utf8' }
55
+ );
56
+ if (r.status !== 0) {
57
+ return '';
58
+ }
59
+ const [dossierGit, commun] = r.stdout.trim().split('\n');
60
+ if (path.resolve(dossierGit) !== path.resolve(commun)) {
61
+ return '';
62
+ }
63
+ const racine = path.dirname(commun);
64
+ const vit = tenant(racine);
65
+ if (vit && vivant(vit)) {
66
+ return '';
67
+ }
68
+ let circuits;
69
+ try {
70
+ circuits = await circuitsDe(racine);
71
+ } catch {
72
+ return '';
73
+ }
74
+ const questions = questionsEnAttente(racine, circuits, { fermes });
75
+ if (!questions.length) {
76
+ return '';
77
+ }
78
+ return [
79
+ questions.length > 1
80
+ ? '## Circuits en attente du superviseur'
81
+ : "## Circuit en attente du superviseur",
82
+ ...questions.map(q =>
83
+ q.interrompu
84
+ ? `- ${q.ticket} a fini sans son issue, à ${q.etape} : \`${q.commande}\`.`
85
+ : [
86
+ `- ${q.ticket}, à ${q.etape} : ${q.question.replace(/\n/g, '\n ')}`,
87
+ ` La réponse : \`${q.commande}\`.`,
88
+ ].join('\n')
89
+ ),
90
+ "Aucune attente de fond ne vit : lance-la en arrière-plan (`run_in_background`) et surveille son flux (l'outil `Monitor`) : `npx grillhouse superviseur --attendre`.",
91
+ ].join('\n');
92
+ }
93
+
94
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
95
+ const texte = await attenteAuTour(process.cwd());
96
+ if (texte) {
97
+ process.stdout.write(`${texte}\n`);
98
+ }
99
+ }
@@ -30,7 +30,7 @@
30
30
  // total of the last pass of each kind and the files planned of each task by its hash (the
31
31
  // latest TACHES_GARDEES); each pass keeps its own at its end (`garderLeTotal`).
32
32
  // - The holder of the lock of the machine (scripts/verrou-de-machine.mjs: a measure out of a
33
- // ticket, `npm run verifier` of a supervisor or of an integration, or a heavy pass of the
33
+ // ticket, `npm run verifier` of a supervisor, or a heavy pass of the
34
34
  // circuit of a ticket) names its progress directory beside the lock (`nommerLAvancement`); the
35
35
  // board reads the holder with its progress, and the waits for the lock or for room
36
36
  // (`lireLaMesure`).
@@ -231,23 +231,18 @@ export function avancementDeLaCI(travail, { nouvelle = false, debut = Date.now()
231
231
  /**
232
232
  * Runs <passe> under a progress directory of the kind <genre> (null: none kept) opened in the
233
233
  * working directory <travail> of a ticket's circuit, where the board reads it
234
- * (`avancementDuTravail`): each automatic pass of the circuit (scripts/activites.mjs) and the
235
- * replay of the ticket's branch by the queue (scripts/faits-du-circuit.mjs `avancer`), one pass at
236
- * a time. The directories a killed pass left there go first, a lot that goes through the queue
237
- * again included. The directory is given to <passe> and named to it and its children by
234
+ * (`avancementDuTravail`): each automatic pass of the circuit (scripts/activites.mjs), one pass
235
+ * at a time. The directories a killed pass left there go first. The directory is given to <passe> and named to it and its children by
238
236
  * GRILLHOUSE_AVANCEMENT (`AVANCEMENT`); then its total is kept in the repository at <racine> and
239
- * it is removed, unless <garder> holds for what <passe> returns: a lot entered on main keeps it
240
- * until the queue is done with the ticket closed, which removes the working directory whole
241
- * (`retirerLeTravail` of scripts/integration/file.mjs), as the circuit kept its progress for its
242
- * whole step of the queue. Without the working directory, <passe> runs without one (null).
237
+ * it is removed. Without the working directory, <passe> runs without one (null).
243
238
  * Returns what <passe> returns.
244
239
  * @template T
245
240
  * @param {string} travail
246
- * @param {{ racine: string, genre: string | null, garder?: (valeur: T) => boolean }} o
241
+ * @param {{ racine: string, genre: string | null }} o
247
242
  * @param {(dossier: string | null) => T} passe
248
243
  * @returns {T}
249
244
  */
250
- export function avecLAvancementDuTravail(travail, { racine, genre, garder = () => false }, passe) {
245
+ export function avecLAvancementDuTravail(travail, { racine, genre }, passe) {
251
246
  if (!existsSync(travail)) {
252
247
  return passe(null);
253
248
  }
@@ -257,11 +252,8 @@ export function avecLAvancementDuTravail(travail, { racine, genre, garder = () =
257
252
  const dossier = ouvrirAvancement({ racine, genre, dans: travail });
258
253
  const avant = process.env[AVANCEMENT];
259
254
  process.env[AVANCEMENT] = dossier;
260
- let garde = false;
261
255
  try {
262
- const valeur = passe(dossier);
263
- garde = garder(valeur);
264
- return valeur;
256
+ return passe(dossier);
265
257
  } finally {
266
258
  if (avant === undefined) {
267
259
  delete process.env[AVANCEMENT];
@@ -269,9 +261,7 @@ export function avecLAvancementDuTravail(travail, { racine, genre, garder = () =
269
261
  process.env[AVANCEMENT] = avant;
270
262
  }
271
263
  garderLeTotal(dossier);
272
- if (!garde) {
273
- rmSync(dossier, { recursive: true, force: true });
274
- }
264
+ rmSync(dossier, { recursive: true, force: true });
275
265
  }
276
266
  }
277
267
 
@@ -0,0 +1,57 @@
1
+ // The base of a pass in the workflows: a workflow that plays `verifier` gives it a base
2
+ // (`--base <commit>`, scripts/dernier-vert.mjs) for a push alone. A pull request, the call of the
3
+ // workflow by the release (workflow_call), the nightly schedule and any run without a push event play
4
+ // the complete pass, as `turbo --affected` takes its base (`TURBO_SCM_BASE`) from a push event.
5
+ //
6
+ // The control reads the text of each workflow of `.github/workflows`: a step that plays `verifier`
7
+ // with a base names, in its condition or in its own line, the event `push`, and, when it reads
8
+ // `github.event.before`, that this commit is not empty (the zeros of a first push are no base).
9
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
10
+ import path from 'node:path';
11
+ import { parse } from 'yaml';
12
+
13
+ const PUSH = /github\.event_name\s*==\s*'push'/;
14
+ const AVANT_NON_VIDE = /github\.event\.before\s*!=\s*''/;
15
+
16
+ // The faults of the base in the workflow of text <texte>, one line each; none when no step gives
17
+ // a base, or when each step that does is conditioned on a push.
18
+ export function erreursDeBase(texte) {
19
+ let flux;
20
+ try {
21
+ flux = parse(texte);
22
+ } catch (e) {
23
+ return [`le workflow ne se lit pas : ${e.message}`];
24
+ }
25
+ const erreurs = [];
26
+ for (const [nomDuJob, job] of Object.entries(flux?.jobs ?? {})) {
27
+ for (const etape of job?.steps ?? []) {
28
+ const run = String(etape.run ?? '');
29
+ if (!/\bverifier\b/.test(run) || !/--base\b/.test(run)) {
30
+ continue;
31
+ }
32
+ const t = `${job.if ?? ''}\n${etape.if ?? ''}\n${run}`;
33
+ const nom = `${nomDuJob} : ${etape.name ?? run.trim()}`;
34
+ if (!PUSH.test(t)) {
35
+ erreurs.push(`${nom} : la base se donne pour un push seulement (github.event_name == 'push')`);
36
+ } else if (/github\.event\.before/.test(t) && !AVANT_NON_VIDE.test(t)) {
37
+ erreurs.push(`${nom} : la base github.event.before se donne non vide (!= '')`);
38
+ }
39
+ }
40
+ }
41
+ return erreurs;
42
+ }
43
+
44
+ // The faults of the base in each workflow of `.github/workflows` of the repository at <racine>,
45
+ // each line led by the file.
46
+ export function erreursDesWorkflows(racine) {
47
+ const dossier = path.join(racine, '.github', 'workflows');
48
+ if (!existsSync(dossier)) {
49
+ return [];
50
+ }
51
+ return readdirSync(dossier)
52
+ .filter(f => /\.ya?ml$/.test(f))
53
+ .sort()
54
+ .flatMap(f =>
55
+ erreursDeBase(readFileSync(path.join(dossier, f), 'utf8')).map(e => `${f} : ${e}`)
56
+ );
57
+ }
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env node
2
+ // The CI of a project's ticket branches: the queue enters a lot on main only once the CI of its
3
+ // branch `agent/<ticket>` judged it green (scripts/integration/file.mjs), so the project's CI must
4
+ // run on a push to `agent/**`, as bors needs a status on its staging branch.
5
+ //
6
+ // node ci-des-branches.mjs --absente <project> prints one line when no workflow of the project
7
+ // runs on a push to a ticket's branch
8
+ //
9
+ // - Whether a workflow runs on a push to a ticket's branch is the queue's own reading of the
10
+ // workflows (`fluxDeLaBranche` of scripts/integration/file.mjs), here on the working tree's
11
+ // `.github/workflows/*.yml` and `*.yaml`, for the branch `agent/ticket`.
12
+ // - `ajouterLesBranchesDeTicket` adds `agent/**` to the `on.push.branches` list of each workflow
13
+ // that runs on a push to the branch main is pushed to (`grillhouse.poussee.commit`, `main` by
14
+ // default), the CI of the lots, its comments and its layout kept (the library yaml's document);
15
+ // a project already listening, or none to judge, is left as it is, `GESTE` the line left to it.
16
+ import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
17
+ import path from 'node:path';
18
+ import { pathToFileURL } from 'node:url';
19
+ import { parseDocument } from 'yaml';
20
+ import { fluxDeLaBranche } from './integration/file.mjs';
21
+ import { lireCommit } from './poussee-cles.mjs';
22
+
23
+ /** The pattern of the ticket branches the queue pushes. */
24
+ export const BRANCHES_DE_TICKET = 'agent/**';
25
+ // A branch of a ticket, which the pattern matches.
26
+ const TEMOIN = 'agent/ticket';
27
+ const DOSSIER = '.github/workflows';
28
+ /** The gesture left to a project none of whose workflows runs on a push to `agent/**`. */
29
+ export const GESTE = `aucun flux de ${DOSSIER} ne se lance sur un push vers les branches de ticket : la file n'entre un lot sur main qu'une fois la CI de sa branche verte ; ajoute '${BRANCHES_DE_TICKET}' aux branches du push du flux de la CI du projet.`;
30
+
31
+ // The workflows of the working tree of <racine>: `{ chemin, texte }`.
32
+ function lesFlux(racine) {
33
+ const dossier = path.join(racine, DOSSIER);
34
+ if (!existsSync(dossier)) {
35
+ return [];
36
+ }
37
+ return readdirSync(dossier)
38
+ .filter(n => /\.ya?ml$/.test(n))
39
+ .sort()
40
+ .map(n => ({ chemin: `${DOSSIER}/${n}`, texte: readFileSync(path.join(dossier, n), 'utf8') }));
41
+ }
42
+
43
+ /** Whether a workflow of the project at <racine> runs on a push to a ticket's branch. */
44
+ export function ecouteLesBranchesDeTicket(racine) {
45
+ return fluxDeLaBranche(lesFlux(racine), TEMOIN).length > 0;
46
+ }
47
+
48
+ // The branch main is pushed to, from the package.json of <racine>; `main` without it.
49
+ function principale(racine) {
50
+ const f = path.join(racine, 'package.json');
51
+ try {
52
+ return lireCommit(JSON.parse(readFileSync(f, 'utf8'))).commit ?? 'main';
53
+ } catch {
54
+ return 'main';
55
+ }
56
+ }
57
+
58
+ /**
59
+ * `agent/**` added to the push of the CI of the lots of the project at <racine>: the workflows
60
+ * written, none when the project already listens or has no workflow that runs on a push to main
61
+ * with a list of branches to add it to.
62
+ */
63
+ export function ajouterLesBranchesDeTicket(racine) {
64
+ const flux = lesFlux(racine);
65
+ if (fluxDeLaBranche(flux, TEMOIN).length > 0) {
66
+ return [];
67
+ }
68
+ const surMain = new Set(fluxDeLaBranche(flux, principale(racine)));
69
+ const ajoutes = [];
70
+ for (const { chemin, texte } of flux.filter(f => surMain.has(f.chemin))) {
71
+ const doc = parseDocument(texte);
72
+ const branches = doc.getIn(['on', 'push', 'branches'], true);
73
+ if (!branches || typeof branches.add !== 'function') {
74
+ continue;
75
+ }
76
+ branches.add(doc.createNode(BRANCHES_DE_TICKET));
77
+ writeFileSync(path.join(racine, chemin), doc.toString());
78
+ ajoutes.push(chemin);
79
+ }
80
+ return ajoutes;
81
+ }
82
+
83
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
84
+ const [option, racine] = process.argv.slice(2);
85
+ if (option !== '--absente' || !racine) {
86
+ process.stderr.write('usage: ci-des-branches.mjs --absente <projet>\n');
87
+ process.exitCode = 2;
88
+ } else if (!ecouteLesBranchesDeTicket(racine)) {
89
+ process.stdout.write(`${BRANCHES_DE_TICKET}\n`);
90
+ }
91
+ }
@@ -260,7 +260,10 @@
260
260
  // of its paths and the content of each file it lists, taken before and after the session; the
261
261
  // sheet and the handover do not count) has nothing to deliver, the gesture `rien-a-livrer`, as a
262
262
  // CI skips a job without object: the checks judge the lot; green, the run goes on; red, the
263
- // circuit stops at « sans-livraison », its report sending to the developpeur's handover. A
263
+ // circuit stops at « sans-livraison », its report sending to the developpeur's handover; but the
264
+ // red of a reference the lot lowers, the debt of the guards (its notes `a-elaguer`), is
265
+ // regenerated (4.2) instead of stopping, and the checks of the plan play again on the
266
+ // regenerated tree. A
264
267
  // developpeur that `--depuis developpeur` launches on the lot the integration refused (`refus`,
265
268
  // the fingerprint of its plan), as a merge queue lets a lot it sends back pass again only with a
266
269
  // change, a session that changes nothing does not go to the checks of the copy, which do not see
@@ -592,7 +595,9 @@
592
595
  // the developpeur's same sending to the testwriter twice in a row, on the same red output of the
593
596
  // checks, no green checks between them), 16 relecture-arret (a finding without a valid agent, one to the testwriter the plan skips,
594
597
  // one on a criterion, the third RENDU), 17 integration (the integration script refuses the lot, or the queue reopens the
595
- // ticket), 19 hors-portee (a testwriter or developpeur whose sheet says BLOQUÉ, without a
598
+ // ticket; at the same code, two stops of the resumption of the integration under their own
599
+ // names: lot-absent, a lot neither on main nor in the copy, and copie-gardee, a lot on main
600
+ // whose copy does not get removed), 19 hors-portee (a testwriter or developpeur whose sheet says BLOQUÉ, without a
596
601
  // sending to the testwriter, or a developpeur's FAIT with criteria out of the plan), 20 besoin (a testwriter or developpeur whose sheet says BESOIN, a
597
602
  // reviewer whose sheet carries a `question`, or a ticket labelled `arbitrage` whose arbitrage
598
603
  // `refusArbitrage` of scripts/integration/integrer.mjs refuses, at the launch or a resumption,
@@ -691,6 +696,7 @@ import {
691
696
  sansCouleurs,
692
697
  } from './ticket-du-circuit.mjs';
693
698
  import { emettre } from './effets.mjs';
699
+ import { heureLocale } from './journal-des-etats.mjs';
694
700
  import { consigne, auLancement, idDeSeance, jusquALaFiche, seance } from './seances.mjs';
695
701
  import { releve } from './composants-affectes.mjs';
696
702
  import { ligneDEtape, transcriptionsDeLaCopie } from './registre.mjs';
@@ -700,7 +706,7 @@ import {
700
706
  reponsesAuxQuestions,
701
707
  sorteDuPlan,
702
708
  } from './resultats.mjs';
703
- import { preparer } from './enveloppe/travail-de-la-copie.mjs';
709
+ import { preparer, rolesDuConflit } from './enveloppe/travail-de-la-copie.mjs';
704
710
  import { refusArbitrage } from './integration/integrer.mjs';
705
711
  import { prendreUnRang } from './places-de-la-machine.mjs';
706
712
  import { langageDe } from './langages.mjs';
@@ -876,6 +882,21 @@ export function ecrireEtat(ctx, etat) {
876
882
  rang: ctx.rang ?? null,
877
883
  };
878
884
  emettre(ctx, { genre: 'etat', etat: { ...ctx.courant, journal: ctx.journal } });
885
+ // The same transition, dated, in the journal of states (scripts/journal-des-etats.mjs): its
886
+ // loop the first counted, its reason the stop's name or the cause of the return, empty for a
887
+ // normal transition.
888
+ emettre(ctx, {
889
+ genre: 'trace',
890
+ ligne: {
891
+ ts: heureLocale(),
892
+ genre: 'circuit',
893
+ ticket: ctx.ticket,
894
+ etape: etat.etape,
895
+ boucle: Object.values(etat.boucles ?? {})[0] ?? null,
896
+ place: null,
897
+ raison: etat.raison ?? '',
898
+ },
899
+ });
879
900
  }
880
901
 
881
902
  // The register's line of the step <etape> the circuit led itself from <debut> (an ISO date) to
@@ -893,6 +914,18 @@ function inscrireEtape(ctx, { etape, debut }) {
893
914
  });
894
915
  }
895
916
 
917
+ // The rule of a test file of the module of the language of the copy of <ctx> (`estUnTest`); a copy
918
+ // the module does not read judges every file the developpeur's.
919
+ function rouleDeTest(ctx) {
920
+ return fichier => {
921
+ try {
922
+ return langageDe(ctx.copie).estUnTest(fichier, ctx.copie);
923
+ } catch {
924
+ return null;
925
+ }
926
+ };
927
+ }
928
+
896
929
  // The steps whose pass judges the lot, 3.1 and 4.1 (one state, `finale` apart): the copy is
897
930
  // prepared on the tip of main before each of them.
898
931
  export const SUR_LA_POINTE = new Set([CONTROLES]);
@@ -911,7 +944,8 @@ export function avantLaPasse(
911
944
  ctx,
912
945
  etape,
913
946
  regeneration,
914
- env = environnementDeLaPasse(ctx, process.env)
947
+ env = environnementDeLaPasse(ctx, process.env),
948
+ { estUnTest = rouleDeTest(ctx) } = {}
915
949
  ) {
916
950
  if (!SUR_LA_POINTE.has(etape)) {
917
951
  return { avancee: false, regeneration };
@@ -929,7 +963,11 @@ export function avantLaPasse(
929
963
  );
930
964
  const fd = openSync(ctx.journal, 'a');
931
965
  try {
932
- r = preparer(ctx.copie, cible.stdout.trim(), { env, sortie: fd });
966
+ r = preparer(ctx.copie, cible.stdout.trim(), {
967
+ env,
968
+ sortie: fd,
969
+ suspects: ctx.fichiersDuConflit ?? [],
970
+ });
933
971
  } finally {
934
972
  closeSync(fd);
935
973
  }
@@ -940,6 +978,30 @@ export function avantLaPasse(
940
978
  const avancee = tete(ctx.copie).stdout.trim() !== avant.stdout.trim();
941
979
  return { avancee, regeneration: avancee ? null : regeneration };
942
980
  }
981
+ const fichiers = [...(r.conflits ?? []), ...(r.enAttente ?? [])];
982
+ if (fichiers.length) {
983
+ // The files in conflict, or kept in the lot, go to the role that writes them, the testwriter
984
+ // first; a role already relaunched for them that left one of its files is not relaunched: the
985
+ // stop goes up.
986
+ const { testwriter, developpeur, roles } = rolesDuConflit(fichiers, estUnTest);
987
+ const relances = ctx.conflitsRelances ?? [];
988
+ const restants = roles.filter(role => !relances.includes(role));
989
+ if (restants.length && restants.length === roles.length) {
990
+ const deRestants = restants.flatMap(role =>
991
+ role === 'testwriter' ? testwriter : developpeur
992
+ );
993
+ const siens = restants[0] === 'testwriter' ? testwriter : developpeur;
994
+ return {
995
+ avancee: false,
996
+ regeneration,
997
+ conflit: {
998
+ fichiers: deRestants,
999
+ roles: restants,
1000
+ rapport: `${r.message}\n\nL'avance de la copie sur la pointe de main a laissé ces fichiers à ton rôle : ${siens.join(', ')}.\nLes marques de conflit sont dans la copie (\`<<<<<<<\`, \`=======\`, \`>>>>>>>\`) : tu résous chaque fichier, marques retirées ; un fichier du lot gardé (\`grillhouse-travail.patch\`, dans le dossier git de la copie) se reprend à la main dans la copie, un fichier supprimé par le lot se supprime. Les fichiers de l'autre rôle restent à sa séance.`,
1001
+ },
1002
+ };
1003
+ }
1004
+ }
943
1005
  return {
944
1006
  arret: {
945
1007
  nom: 'lancement',
@@ -950,6 +1012,35 @@ export function avantLaPasse(
950
1012
  };
951
1013
  }
952
1014
 
1015
+ /**
1016
+ * What the circuit keeps of the conflict <conflit> (`avantLaPasse`) its pass at the state <etat>
1017
+ * met: the role relaunched, the first of `conflit.roles`, and the memory: the roles relaunched,
1018
+ * the files of the conflict, whose marks the next advance looks for again (`fichiersDuConflit`),
1019
+ * and the state of the pass the role's session comes back to (`retourDuConflit`), not the step
1020
+ * that follows the role, so no build plays while a file carries marks.
1021
+ * @param {{ conflitsRelances?: string[] | null, fichiersDuConflit?: string[] | null }} ctx
1022
+ * @param {object} etat
1023
+ * @param {{ fichiers: string[], roles: string[] }} conflit
1024
+ */
1025
+ export function suiteDuConflit(ctx, etat, conflit) {
1026
+ const [role] = conflit.roles;
1027
+ return {
1028
+ role,
1029
+ memoire: {
1030
+ conflitsRelances: [...(ctx.conflitsRelances ?? []), role],
1031
+ fichiersDuConflit: [...new Set([...(ctx.fichiersDuConflit ?? []), ...conflit.fichiers])],
1032
+ retourDuConflit: etat,
1033
+ },
1034
+ };
1035
+ }
1036
+
1037
+ // The memory of a conflict once its pass prepares the copy without one: dropped.
1038
+ export const SANS_CONFLIT = Object.freeze({
1039
+ conflitsRelances: null,
1040
+ fichiersDuConflit: null,
1041
+ retourDuConflit: null,
1042
+ });
1043
+
953
1044
  // The tools of the project whose main tree is <racine>, read at the launch of a run:
954
1045
  // `{ outils }`, or `{ arret }`, the stop « lancement » that goes up to the supervisor before any
955
1046
  // session (its code, name, report, piece and question), the faults of the key named.
@@ -1263,6 +1354,9 @@ export const MEMOIRE = [
1263
1354
  'verts',
1264
1355
  'reprise',
1265
1356
  'relancesTestwriter',
1357
+ 'conflitsRelances',
1358
+ 'fichiersDuConflit',
1359
+ 'retourDuConflit',
1266
1360
  ];
1267
1361
 
1268
1362
  // The fact <fait> of the circuit of <ctx>, with its <parametres>, the facts <faits> of the step
@@ -385,23 +385,40 @@ export function texteDuReleve(r) {
385
385
  return out.join('\n');
386
386
  }
387
387
 
388
- // The command: its exit code.
389
- function commande(racine, args) {
388
+ // The survey of the draft description in the file <fichier> (from <racine>), as text; the command
389
+ // `--description` writes it on its standard output.
390
+ export function rapportDescription(racine, fichier) {
391
+ return texteDuReleve(releve(racine, readFileSync(path.resolve(racine, fichier), 'utf8')));
392
+ }
393
+
394
+ const USAGE = 'usage: npx grillhouse composants-affectes <ticket> | --description <fichier>\n';
395
+
396
+ // The command: its exit code. `-h`/`--help` writes the usage, exit 0; any other option than
397
+ // `--description`, the usage on the error stream, exit 2.
398
+ export function commande(racine, args) {
399
+ if (args.includes('-h') || args.includes('--help')) {
400
+ process.stdout.write(USAGE);
401
+ return 0;
402
+ }
403
+ const inconnue = args.find(
404
+ (a, k) => a.startsWith('-') && a !== '--description' && args[k - 1] !== '--description'
405
+ );
406
+ if (inconnue) {
407
+ process.stderr.write(`⛔ option inconnue : ${inconnue}\n${USAGE}`);
408
+ return 2;
409
+ }
390
410
  const i = args.indexOf('--description');
391
411
  if (i >= 0) {
392
412
  if (!args[i + 1]) {
393
413
  process.stderr.write('usage: npx grillhouse composants-affectes --description <fichier>\n');
394
414
  return 2;
395
415
  }
396
- const r = releve(racine, readFileSync(path.resolve(racine, args[i + 1]), 'utf8'));
397
- process.stdout.write(`${texteDuReleve(r)}\n`);
416
+ process.stdout.write(`${rapportDescription(racine, args[i + 1])}\n`);
398
417
  return 0;
399
418
  }
400
419
  const [ticket] = args;
401
420
  if (!ticket) {
402
- process.stderr.write(
403
- 'usage: npx grillhouse composants-affectes <ticket> | --description <fichier>\n'
404
- );
421
+ process.stderr.write(USAGE);
405
422
  return 2;
406
423
  }
407
424
  const show = spawnSync('bd', ['show', ticket, '--json'], {
@@ -18,6 +18,8 @@
18
18
  // when one module cannot read it, its reason named with its language.
19
19
  // - The verdict of a run is every module's, read in the same results directory, where each module
20
20
  // writes under names of its own (scripts/resultats.mjs).
21
+ // - The environment of the poste is each module's, applied one after the other: a module that
22
+ // finds its file's variables already set (by the one before) leaves the environment as it is.
21
23
  // - Each command a module describes is the composed command by its name
22
24
  // (./commandes-composees.mjs), which plays it in each module that describes it and joins their
23
25
  // codes.
@@ -196,6 +198,7 @@ export function composer(modules) {
196
198
  matieres: racine => modules.flatMap(m => m.matieres(racine)),
197
199
  joueDesTests: (racine, composant) =>
198
200
  moduleDuComposant(racine, composant)?.joueDesTests(racine, composant) ?? false,
201
+ environnementDuPoste: env => modules.reduce((e, m) => m.environnementDuPoste(e), env),
199
202
  empreintes(racine, noms) {
200
203
  const parts = modules.map(m => m.empreintes(racine, noms));
201
204
  return parts.some(p => p === null) ? null : Object.assign({}, ...parts);
@@ -82,6 +82,7 @@ import path from 'node:path';
82
82
  import { PILOTE } from './fusion-du-changelog.mjs';
83
83
  import { langageDe } from './langages.mjs';
84
84
  import { balayerLesTickets } from './mesure/base-de-passe.mjs';
85
+ import { nettoyerLeJournal } from './journal-des-etats.mjs';
85
86
 
86
87
  const RETIRER = path.join(import.meta.dirname, 'retirer-copie.sh');
87
88
  const PRINCIPALE = 'main';
@@ -498,5 +499,11 @@ export function retirerLesCopiesDuDepot(racine, finies = [], vivants = null) {
498
499
  ignorer: ignoresDuLangage(racine),
499
500
  });
500
501
  const retires = balayerLesTickets(() => tickets(racine, 'closed'));
501
- return [...lignes, ...retires.map(t => `✓ dossier temporaire du ticket ${t} retiré.`)];
502
+ // The journal of states, bounded as the other working files (scripts/journal-des-etats.mjs).
503
+ const segments = nettoyerLeJournal(racine).retires;
504
+ return [
505
+ ...lignes,
506
+ ...retires.map(t => `✓ dossier temporaire du ticket ${t} retiré.`),
507
+ ...segments.map(s => `✓ segment ${s} du journal des états retiré.`),
508
+ ];
502
509
  }
@@ -23,10 +23,13 @@
23
23
  // - The merge driver of the CHANGELOG (scripts/fusion-du-changelog.mjs) is written in the
24
24
  // repository's configuration by the same function, `poserCrochets`, which each `npm install`
25
25
  // runs, as git asks a driver's command of the configuration, never of a versioned file.
26
+ // - Under `npm ci`, the same `prepare` writes the mark of the Node the dependencies were installed
27
+ // under (scripts/abi-des-dependances.mjs), which the session start compares with the current one.
26
28
  import { execFileSync } from 'node:child_process';
27
29
  import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
28
30
  import path from 'node:path';
29
31
  import { pathToFileURL } from 'node:url';
32
+ import { marquerApresInstallation } from './abi-des-dependances.mjs';
30
33
  import { poserLePilote } from './fusion-du-changelog.mjs';
31
34
 
32
35
  // The project's command, which the frame's lines run.
@@ -137,5 +140,6 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
137
140
  }
138
141
  } else {
139
142
  poserCrochets(projet);
143
+ marquerApresInstallation(projet);
140
144
  }
141
145
  }
@@ -173,6 +173,25 @@ function lireLeVertDe(etat, branche) {
173
173
  return { commit: v.commit, arbre: v.arbre, branche };
174
174
  }
175
175
 
176
+ // The base <base> given to a pass (`verifier --base <commit>`), when it counts for a pass in the
177
+ // state <etat>: `{ commit, arbre, branche: null }`, the tree of the commit; `{ raison }` when it
178
+ // has no value, is not a commit id, is not in the repository (the zeros of a first push, a
179
+ // rewritten history) or is not an ancestor of HEAD.
180
+ function lireLaBase(etat, base) {
181
+ if (!SHA.test(base)) {
182
+ return { raison: base ? 'la base n’est pas un commit' : 'la base est sans valeur' };
183
+ }
184
+ const arbre = sortie(etat.racine, ['rev-parse', '--verify', '-q', `${base}^{tree}`]);
185
+ const commit = sortie(etat.racine, ['rev-parse', '--verify', '-q', `${base}^{commit}`]);
186
+ if (!arbre || !commit) {
187
+ return { raison: 'la base n’est pas dans le dépôt' };
188
+ }
189
+ if (git(etat.racine, ['merge-base', '--is-ancestor', commit, etat.commit]).status !== 0) {
190
+ return { raison: 'la base n’est pas un ancêtre de HEAD' };
191
+ }
192
+ return { commit, arbre, branche: null };
193
+ }
194
+
176
195
  // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached.
177
196
  export function garderLeVert(etat) {
178
197
  const branche = etat.branche ?? etat.main;
@@ -228,7 +247,7 @@ function supprimesDuCommit(racine, commit, arbre) {
228
247
  // function that removes the file of the changes. <tout> asks for the complete pass; the file lies
229
248
  // in <dans>, the base of the pass (scripts/mesure/base-de-passe.mjs), which a killed pass
230
249
  // leaves to the next one to sweep.
231
- export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
250
+ export function mesure(racine, { tout = false, base, dans = os.tmpdir() } = {}) {
232
251
  const etat = etatDuDepot(racine);
233
252
  const complete = raison => ({
234
253
  etat: etat.raison ? null : etat,
@@ -242,7 +261,12 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
242
261
  if (tout) {
243
262
  return complete('demandée');
244
263
  }
245
- const vert = lireLeVert(etat);
264
+ // A base given takes precedence over the last green: the pass keeps no green of its own.
265
+ const donnee = base === undefined ? null : lireLaBase(etat, base);
266
+ if (donnee?.raison) {
267
+ return complete(donnee.raison);
268
+ }
269
+ const vert = donnee ?? lireLeVert(etat);
246
270
  if (vert.raison) {
247
271
  return complete(vert.raison);
248
272
  }
@@ -268,9 +292,11 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
268
292
  );
269
293
  const n = ch.fichiers.length + ch.supprimes.length;
270
294
  return {
271
- etat,
295
+ etat: donnee ? null : etat,
272
296
  env: { [CHANGEMENTS]: fichier },
273
- ligne: `↳ depuis le dernier vert de ${vert.branche} (${vert.commit.slice(0, 12)}, arbre ${vert.arbre.slice(0, 12)}) : ${n} fichier(s) changé(s) ; chaque paquet rejoué joue les tests que ses changements atteignent.`,
297
+ ligne: donnee
298
+ ? `↳ depuis la base ${vert.commit.slice(0, 7)} : ${n} fichier(s) changé(s) ; chaque paquet rejoué joue les tests que ses changements atteignent.`
299
+ : `↳ depuis le dernier vert de ${vert.branche} (${vert.commit.slice(0, 12)}, arbre ${vert.arbre.slice(0, 12)}) : ${n} fichier(s) changé(s) ; chaque paquet rejoué joue les tests que ses changements atteignent.`,
274
300
  retirer: () => rmSync(dir, { recursive: true, force: true }),
275
301
  };
276
302
  }