@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
@@ -27,12 +27,18 @@
27
27
  // back, becomes local work of the copy: applied three ways (`git apply --3way`), a conflict
28
28
  // marked in its file, the rest of the lot there; the index is then left as HEAD has it, so that
29
29
  // all of it is local work. Exit 0, the conflicts included: the agent's session resolves them.
30
+ // - `remettreEnTravail`, for the circuit alone, the queue having reopened its branch on a
31
+ // conflict: the removed copy made again on the branch at the lot's fork point with main, the lot
32
+ // as local work (`git reset`, a new file main added too announced by `git add -N`), not moved
33
+ // onto the tip: the advance that follows meets the conflict.
30
34
  // - The advance (`avancer`, a step of `preparer`): the copy moves forward to <cible> (the main tree's HEAD) by a fast-forward, its
31
35
  // local work kept by the same application: the work as a lot (`git diff --binary HEAD`, the
32
36
  // submodules left out, which the launcher sets afterwards; untracked files stay in place), the
33
37
  // copy brought back to HEAD, moved forward, the lot applied three ways. The lot waits in the
34
38
  // copy's own git directory (`git rev-parse --git-dir`, `grillhouse-travail.patch`) while the
35
39
  // copy moves, and goes once it is applied.
40
+ // - First, an index the circuit saved before a command of its checks, left by a killed
41
+ // process, is put back (`rendreLIndex`).
36
42
  // - The lot applies file by file (one `git apply --3way` per file, its patch alone): a file that
37
43
  // fails touches none of the others. A file in conflict keeps its marks; a file git refuses
38
44
  // without marks (a deletion of a file main changed) stays alone in the lot kept in the git
@@ -89,6 +95,7 @@ import {
89
95
  existsSync,
90
96
  mkdtempSync,
91
97
  readFileSync,
98
+ renameSync,
92
99
  rmSync,
93
100
  statSync,
94
101
  utimesSync,
@@ -115,6 +122,77 @@ const lignes = r =>
115
122
  .map(l => l.trim())
116
123
  .filter(Boolean);
117
124
 
125
+ // The index of a copy as it was before the circuit put the lot there, in the copy's git directory.
126
+ const INDEX_SAUVE = 'grillhouse-index';
127
+
128
+ // The index of <copie> and the file that saves it, absolute; null out of git.
129
+ function indexDeLaCopie(copie) {
130
+ const r = git(copie, [
131
+ 'rev-parse',
132
+ '--path-format=absolute',
133
+ '--git-path',
134
+ 'index',
135
+ '--git-path',
136
+ INDEX_SAUVE,
137
+ ]);
138
+ if (r.status !== 0) {
139
+ return null;
140
+ }
141
+ const [index, sauve] = lignes(r);
142
+ return { index, sauve };
143
+ }
144
+
145
+ /**
146
+ * Puts back the index of <copie> that `inscrireLeLot` saved, in one rename, when one waits in its
147
+ * git directory: after the command, or before the next gesture that reads the index, when the
148
+ * process that ran the command was killed.
149
+ * @param {string} copie
150
+ */
151
+ export function rendreLIndex(copie) {
152
+ const i = indexDeLaCopie(copie);
153
+ if (i && existsSync(i.sauve)) {
154
+ renameSync(i.sauve, i.index);
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Puts the lot of <copie> in its index (`git add -A`, the ignored files left out) for a command
160
+ * that judges it, so that a reader of the index sees a new file as a tracked one and a deleted
161
+ * file no more; the index as it was, unresolved conflicts included, waits in the git directory of
162
+ * the copy until `rendreLIndex`. Throws, naming git, the index unchanged, when git fails.
163
+ * @param {string} copie
164
+ */
165
+ export function inscrireLeLot(copie) {
166
+ rendreLIndex(copie);
167
+ const refus = r =>
168
+ new Error(
169
+ `git ne met pas le lot à l'index de la copie ${copie} (git add -A) : la commande ne joue pas.\n${texte(r)}`
170
+ );
171
+ const rev = git(copie, ['rev-parse', '--git-dir']);
172
+ const i = indexDeLaCopie(copie);
173
+ if (!i) {
174
+ throw refus(rev);
175
+ }
176
+ // A repository without an index file has an empty one, written so that it can be put back.
177
+ if (!existsSync(i.index)) {
178
+ const vide = git(copie, ['read-tree', '--empty']);
179
+ if (vide.status !== 0) {
180
+ throw refus(vide);
181
+ }
182
+ }
183
+ // Saved whole or not at all: copied aside, then renamed. Its time with it: git reads it to
184
+ // judge a file written in the same instant as the index.
185
+ const { atime, mtime } = statSync(i.index);
186
+ copyFileSync(i.index, `${i.sauve}.tmp`);
187
+ utimesSync(`${i.sauve}.tmp`, atime, mtime);
188
+ renameSync(`${i.sauve}.tmp`, i.sauve);
189
+ const r = git(copie, ['add', '-A']);
190
+ if (r.status !== 0) {
191
+ rendreLIndex(copie);
192
+ throw refus(r);
193
+ }
194
+ }
195
+
118
196
  // The files of <copie> unmerged in its index.
119
197
  const enConflit = copie => lignes(git(copie, ['diff', '--name-only', '--diff-filter=U']));
120
198
 
@@ -494,6 +572,79 @@ export function reporter(copie, { base, pointe, duCadre, dire = surStderr }) {
494
572
  return r.status === 0 ? { ok: true, message: '' } : { ok: false, message: texte(r) };
495
573
  }
496
574
 
575
+ /**
576
+ * The ticket's copy <copie> made again on its branch <branche> at the base of its lot (its fork
577
+ * point with the HEAD of the main tree <racine>), after the integration removed it: the whole lot
578
+ * the branch committed becomes local work on that base; a new file main added too is announced to
579
+ * the index (`git add -N`), so that the next advance meets it as a conflict. The copy is
580
+ * not moved onto the tip of main. Played again, it finds the copy and leaves it so. Returns
581
+ * `{ ok, message, commande }`: the last command of git, and its output when it fails, the branch
582
+ * and its commit then kept.
583
+ * @param {{ racine: string, copie: string, branche: string }} o
584
+ */
585
+ export function remettreEnTravail({ racine, copie, branche }) {
586
+ let commande;
587
+ const jouer = (depot, ...args) => {
588
+ commande = `git -C ${depot} ${args.join(' ')}`;
589
+ return git(depot, args);
590
+ };
591
+ const refus = message => ({ ok: false, message, commande });
592
+ const base = jouer(racine, 'merge-base', 'HEAD', `refs/heads/${branche}`);
593
+ if (base.status !== 0) {
594
+ return refus(texte(base) || `${branche} n'a aucun commit commun avec main.`);
595
+ }
596
+ if (!existsSync(copie)) {
597
+ const ajout = jouer(racine, 'worktree', 'add', '-q', copie, branche);
598
+ if (ajout.status !== 0) {
599
+ return refus(texte(ajout));
600
+ }
601
+ }
602
+ // A directory that is no copy of its own would answer for the main tree around it.
603
+ const lieu = jouer(copie, 'rev-parse', '--show-prefix', '--symbolic-full-name', 'HEAD');
604
+ if (lieu.status !== 0 || String(lieu.stdout).trim() !== `refs/heads/${branche}`) {
605
+ return refus(`${copie} n'est pas une copie sur ${branche} :\n${texte(lieu)}`);
606
+ }
607
+ const fourche = String(base.stdout).trim();
608
+ const noms = r => String(r.stdout).split('\0').filter(Boolean);
609
+ const pointe = String(git(copie, ['rev-parse', 'HEAD']).stdout).trim();
610
+ const remis = jouer(copie, 'reset', '-q', fourche);
611
+ if (remis.status !== 0) {
612
+ return refus(texte(remis));
613
+ }
614
+ // The new files of the lot that main added too since the base, read from the copy and main, so
615
+ // that a gesture played again finds them: the others stay untracked.
616
+ const principal = String(git(racine, ['rev-parse', 'HEAD']).stdout).trim();
617
+ const neufs = jouer(copie, 'ls-files', '-z', '--others', '--exclude-standard');
618
+ const ajoutes = jouer(
619
+ racine,
620
+ 'diff',
621
+ '-z',
622
+ '--name-only',
623
+ '--no-renames',
624
+ '--diff-filter=A',
625
+ fourche,
626
+ principal
627
+ );
628
+ // A failure past the reset gives the branch its commit back.
629
+ const rendre = r => {
630
+ const echec = refus(texte(r));
631
+ git(copie, ['reset', '-q', pointe]);
632
+ return echec;
633
+ };
634
+ if (neufs.status !== 0 || ajoutes.status !== 0) {
635
+ return rendre(neufs.status !== 0 ? neufs : ajoutes);
636
+ }
637
+ const deMain = new Set(noms(ajoutes));
638
+ const deuxFois = noms(neufs).filter(f => deMain.has(f));
639
+ if (deuxFois.length) {
640
+ const annonce = jouer(copie, 'add', '-N', '--', ...deuxFois);
641
+ if (annonce.status !== 0) {
642
+ return rendre(annonce);
643
+ }
644
+ }
645
+ return { ok: true, message: '', commande };
646
+ }
647
+
497
648
  const lotEnAttente = (copie, garde, fichiers) =>
498
649
  `⛔ 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.`;
499
650
 
@@ -514,6 +665,7 @@ const conflit = (copie, conflits, entete) =>
514
665
  * @param {{ ecrit?: (fichier: string) => boolean, suspects?: string[], duCadre?: (copie: string) => any[], dire?: (texte: string) => void }} [o]
515
666
  */
516
667
  export function avancer(copie, cible, { ecrit, suspects = [], duCadre, dire = surStderr } = {}) {
668
+ rendreLIndex(copie);
517
669
  releverLesResolus(copie);
518
670
  const restants = [
519
671
  ...new Set([...enConflit(copie), ...suspects.filter(f => porteDesMarques(copie, f))]),
@@ -684,6 +836,8 @@ export function preparer(copie, cible, { env = process.env, sortie = 2, ecrit, s
684
836
  }
685
837
  return r;
686
838
  };
839
+ // Before any command that reads the index, the pose of the submodules included.
840
+ rendreLIndex(copie);
687
841
  const echec = (r, quoi) => ({
688
842
  ok: false,
689
843
  message: `⛔ ${quoi} de la copie ${copie} échoue (code ${r.status ?? r.signal}).${r.stderr?.length ? `\n${String(r.stderr).trim()}` : ''}`,
@@ -314,9 +314,9 @@ export const GESTES = [
314
314
  {
315
315
  genre: 'conflit-de-l-avance',
316
316
  geste:
317
- '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',
317
+ '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, quelle que soit la sorte du lot, le développeur pour le code, le testwriter d’abord puis le développeur sur les fichiers des deux ; après un lot que l’intégration (5.1) dit ne plus s’appliquer sur main, ou que la file (5.2) rend sur un conflit, le circuit revient à la passe qui juge le lot, dont la préparation joue ce geste',
318
318
  regle:
319
- '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)',
319
+ 'l’avance d’une copie sur main, avant une passe, après le refus d’application à 5.1 ou le conflit de la file à 5.2, 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)',
320
320
  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',
321
321
  },
322
322
  ];
@@ -329,10 +329,18 @@ export const gesteDe = genre => GESTES.find(g => g.genre === genre) ?? null;
329
329
  export const SUPERVISEUR = 'superviseur';
330
330
  export const RESPONSABLE = 'responsable';
331
331
 
332
+ // The motif by which the agent direct or the reviewer says that the ticket asks for a plan
333
+ // (circuit.md §4.4, §5.6): the circuit stops, and the answer `--planifier` switches it to the plan.
334
+ export const DEMANDE_UN_PLAN = 'demande-un-plan';
335
+
336
+ // The exit code of the integration (scripts/integration/integrer.mjs) for a lot that does not
337
+ // apply on main: the one refusal the gesture `conflit-de-l-avance` may settle.
338
+ export const LOT_NE_S_APPLIQUE_PAS = 3;
339
+
332
340
  // The commands by which the supervisor answers a question (scripts/circuit.mjs): resume, extend
333
341
  // the plan, stop.
334
342
  export const REPONSES =
335
- 'Le superviseur répond par une commande du circuit : `--reprendre` (avec `--contexte`) ou `--depuis <testwriter|developpeur>` (avec `--contexte`), `--depuis direct` dans un circuit direct (avec `--contexte`), `--mecanique [<commande>]` (avec `--contexte` : à l’arrêt du testwriter qui ne trouve aucun comportement à tester, ou de la preuve du rouge qui refuse le lot de tests, le ticket bascule en circuit court sur le même plan, vers 1.1 avec sa commande, vers le développeur sans elle), `--etendre <paquet>` (le plan gagne ce paquet, puis l’étape en cours reprend), `--reporter <heure>` (la question se tait jusqu’à l’heure, le circuit en attente), ou `--arreter`.';
343
+ 'Le superviseur répond par une commande du circuit : `--reprendre` (avec `--contexte`) ou `--depuis <testwriter|developpeur>` (avec `--contexte`), `--depuis direct` dans un circuit direct (avec `--contexte`), `--mecanique [<commande>]` (avec `--contexte` : à l’arrêt du testwriter qui ne trouve aucun comportement à tester, ou de la preuve du rouge qui refuse le lot de tests, le ticket bascule en circuit court sur le même plan, vers 1.1 avec sa commande, vers le développeur sans elle), `--planifier` (avec `--contexte` : à l’arrêt `besoin` ou `hors-portee` d’un circuit direct au motif `demande-un-plan`, le ticket bascule vers le plan, à 1 Plan, sa copie gardée ; `--reprendre` garde le direct), `--etendre <paquet>` (le plan gagne ce paquet, puis l’étape en cours reprend), `--reporter <heure>` (la question se tait jusqu’à l’heure, le circuit en attente), ou `--arreter`.';
336
344
 
337
345
  // The question of each stop no gesture settles, as a CI calls a person only for what no rule
338
346
  // settles (the approval of a review): every stop of ARRETS, « a-repasser » once the circuit has
@@ -185,7 +185,11 @@ const arretDeLEtat = (ctx, code, etat) => ({
185
185
  code,
186
186
  nom: ctx.courant?.raison ?? null,
187
187
  question: ctx.courant?.question ?? null,
188
- etat: { ...etat, raison: ctx.courant?.raison ?? null },
188
+ etat: {
189
+ ...etat,
190
+ raison: ctx.courant?.raison ?? null,
191
+ ...(ctx.courant?.motif ? { motif: ctx.courant.motif } : {}),
192
+ },
189
193
  });
190
194
 
191
195
  // The options of a run on the supervisor's answer <reponse>.
@@ -206,6 +210,9 @@ export const optionsDe = reponse => {
206
210
  destinataire: AUTEURS_DE_LOT.includes(reponse.role) ? reponse.role : null,
207
211
  };
208
212
  }
213
+ if (reponse.genre === 'planifier') {
214
+ return { planifier: true, contexte: contexteDuSuperviseur, destinataire: null };
215
+ }
209
216
  if (reponse.genre === 'mecanique') {
210
217
  // The gesture written by hand goes to the developpeur, who gets the reason as his context.
211
218
  return {
@@ -251,8 +258,8 @@ const ACTES = {
251
258
  return { arret: arretDeLEtat(ctx, r.code, ctx.courant ?? {}) };
252
259
  }
253
260
  if (r.passe) {
254
- finirLOuverture(ctx, plan.debut);
255
- return { ouverture: lOuverture(ctx, plan.debut) };
261
+ const { debut } = finirLOuverture(ctx, plan.debut);
262
+ return { ouverture: lOuverture(ctx, debut) };
256
263
  }
257
264
  return { plan: { ...plan, etat: r.plan, memoire: laMemoire(ctx) } };
258
265
  });
@@ -424,8 +431,8 @@ async function ouvrirSur(ctx, memoire, arrete) {
424
431
  },
425
432
  };
426
433
  }
427
- finirLOuverture(ctx, o.debut);
428
- return { ouverture: lOuverture(ctx, o.debut) };
434
+ const { debut } = finirLOuverture(ctx, o.debut);
435
+ return { ouverture: lOuverture(ctx, debut) };
429
436
  }
430
437
 
431
438
  // The opening of the run of <ctx> at the step <debut>, as the workflow keeps it.
@@ -10,6 +10,7 @@ export interface TicketDeBeads {
10
10
  created_at?: string;
11
11
  description?: string;
12
12
  dependencies?: Array<{ type: string; depends_on_id: string }>;
13
+ defer_until?: string;
13
14
  }
14
15
 
15
16
  /** Whether the description of <t> holds its section « ## Architecture ». */
@@ -51,7 +52,8 @@ export function attentesExternes(
51
52
  /**
52
53
  * The circuits that hold a place in the limit of the project: those that work, those resumed and
53
54
  * waiting for their place of the machine, and those stopped on a question to the supervisor (no
54
- * recipient, or « superviseur »); the question to the owner, the ticket deferred and the wait for
55
+ * recipient, or « superviseur »); the question to the owner, the ticket deferred (to a later time
56
+ * at `maintenant`, or with no hour) and the wait for
55
57
  * another project release it. `superviseur`: those of `tenant` that wait for the supervisor.
56
58
  */
57
59
  export function circuitsDeLaLimite(
@@ -62,9 +64,18 @@ export function circuitsDeLaLimite(
62
64
  report?: object | null;
63
65
  }>,
64
66
  tous: TicketDeBeads[],
65
- o?: { externes?: Record<string, TicketDeBeads[]> }
67
+ o?: { externes?: Record<string, TicketDeBeads[]>; maintenant?: number }
66
68
  ): { tenant: string[]; superviseur: string[] };
67
69
 
70
+ /** The instant (ms) until which the ticket `t` is deferred at `maintenant`, else null. */
71
+ export function reporteJusqua(t: { defer_until?: string }, maintenant: number): number | null;
72
+
73
+ /** Whether the deferral of `t` releases the place of its circuit in the limit of the project. */
74
+ export function leReportRendLaPlace(
75
+ t: { status?: string; defer_until?: string },
76
+ maintenant: number
77
+ ): boolean;
78
+
68
79
  /** The tickets of <tous> in the queue that never start for want of their section « ## Architecture ». */
69
80
  export function enFileSansArchitecture<T extends TicketDeBeads>(
70
81
  tous: T[],
@@ -1,19 +1,20 @@
1
1
  // The rule of the queue of the tickets of a project: the tickets the owner validated (label
2
- // `circuit`) whose dependencies are all closed start by themselves, by Beads priority, as Zuul and
2
+ // `circuit` or `direct`) whose dependencies are all closed start by themselves, by Beads priority, as Zuul and
3
3
  // the merge queues start a change once what it depends on has merged. The queue of the tickets
4
4
  // under Temporal (src/temporal/tickets/) reads the tickets and applies this rule (circuit.md
5
5
  // §5.7, « La file des tickets »; the code still asks for the section « ## Architecture » where
6
6
  // the target reads « Régi par », circuit.md §9.1).
7
7
  //
8
- // - A ticket starts when it is open, labelled `circuit`, with no circuit already on it, its
8
+ // - A ticket starts when it is open, labelled `circuit` or `direct`, with no circuit already on it, its
9
9
  // description holds its section « ## Architecture » (a line that begins so), and every
10
10
  // dependency of the type `blocks` is closed: a dependency out of the list read (an unknown
11
11
  // ticket) holds it back, a `parent-child` or `related` link does not.
12
12
  // - A ticket of the queue without its section never starts, as a merge queue admits only a change
13
13
  // that passes its checks of entry: `enFileSansArchitecture` names it, for the board and the
14
14
  // opening of the supervisor, who writes it.
15
- // - A ticket labelled `direct` is led out of the circuit, by hand: it never starts, even labelled
16
- // `circuit` too (a label `bd create --parent` copies from its epic).
15
+ // - A ticket labelled `direct` takes the direct circuit, even labelled `circuit` too (a label
16
+ // `bd create --parent` copies from its epic): the queue starts it as any other, and it counts
17
+ // in the same limits.
17
18
  // - The order is the Beads priority (0 first), then the creation (the oldest first).
18
19
  // - A circuit alive whose ticket was closed outside it (delivered directly) holds no place: the
19
20
  // queue stops it (`fermesHorsCircuit`).
@@ -39,14 +40,16 @@ import { lotSurMain } from './integration/integrer.mjs';
39
40
  // board both read.
40
41
  export const aSonArchitecture = t => /^## Architecture\b/m.test(t.description ?? '');
41
42
 
42
- // The tickets of <tous> in the queue: open, labelled `circuit` and not `direct`, those of
43
- // <enCours> aside.
43
+ // The labels that put a ticket in the queue.
44
+ const ETIQUETTES_DE_LA_FILE = ['circuit', 'direct'];
45
+
46
+ // The tickets of <tous> in the queue: open, labelled `circuit` or `direct`, those of <enCours>
47
+ // aside.
44
48
  const enFile = (tous, enCours) =>
45
49
  tous.filter(
46
50
  t =>
47
51
  t.status === 'open' &&
48
- (t.labels ?? []).includes('circuit') &&
49
- !(t.labels ?? []).includes('direct') &&
52
+ (t.labels ?? []).some(l => ETIQUETTES_DE_LA_FILE.includes(l)) &&
50
53
  !enCours.has(t.id)
51
54
  );
52
55
 
@@ -193,27 +196,56 @@ export function fermesHorsCircuit(tous, circuits) {
193
196
  .sort();
194
197
  }
195
198
 
199
+ /**
200
+ * The instant (ms) until which the ticket <t> is deferred at <maintenant> (ms), else null: its
201
+ * `defer_until` (the answer `--reporter <heure>`), strictly later. Beads writes it as the local
202
+ * wall time of the machine, followed by a « Z » it does not mean (`bd update --defer 17:30` gives
203
+ * `…T17:30:00Z`). The one reading of a deferral to an hour: the wait of the supervisor, the limit
204
+ * of the project and the board.
205
+ * @param {{ defer_until?: string }} t
206
+ * @param {number} maintenant
207
+ * @returns {number | null}
208
+ */
209
+ export function reporteJusqua(t, maintenant) {
210
+ const heure = Date.parse(String(t.defer_until ?? '').replace(/Z$/, ''));
211
+ return heure > maintenant ? heure : null;
212
+ }
213
+
214
+ /**
215
+ * Whether the deferral of the ticket <t> releases the place of its circuit in the limit of the
216
+ * project at <maintenant> (ms): deferred to a later time, or deferred with no hour.
217
+ * @param {{ status?: string, defer_until?: string }} t
218
+ * @param {number} maintenant
219
+ * @returns {boolean}
220
+ */
221
+ export function leReportRendLaPlace(t, maintenant) {
222
+ return reporteJusqua(t, maintenant) !== null || (t.status === 'deferred' && !t.defer_until);
223
+ }
224
+
196
225
  /**
197
226
  * The circuits of <circuits> that hold a place in the limit of the project (`grillhouse.circuits`),
198
227
  * as a Kanban limit of work in progress keeps a blocked card in it: a circuit that works, one
199
228
  * resumed and waiting for its place of the machine, and one stopped on a question to the
200
229
  * supervisor (no recipient, or `qui` « superviseur »). A question to the owner, a ticket deferred
201
- * (`--reporter`) and a wait for another project release their place. Each circuit is judged by
230
+ * (`leReportRendLaPlace` at <maintenant>) and a wait for another project release their place. Each circuit is judged by
202
231
  * its own memo, read again at every wake of the queue.
203
232
  * @param {Array<{ ticket: string, etape?: string | null, question?: { qui?: string } | null }>} circuits
204
233
  * the circuits alive, each with its memo
205
234
  * @param {Parameters<typeof ticketsAPartir>[0]} tous every ticket of the project
206
- * @param {{ externes?: Record<string, typeof tous> }} [o]
235
+ * @param {{ externes?: Record<string, typeof tous>, maintenant?: number }} [o]
207
236
  * @returns {{ tenant: string[], superviseur: string[] }} the circuits that hold the limit, and
208
237
  * among them those that wait for the supervisor, each sorted
209
238
  */
210
- export function circuitsDeLaLimite(circuits, tous, { externes } = {}) {
239
+ export function circuitsDeLaLimite(circuits, tous, { externes, maintenant = Date.now() } = {}) {
211
240
  const parId = new Map(tous.map(t => [t.id, t]));
212
241
  const tenant = [];
213
242
  const superviseur = [];
214
243
  for (const c of circuits) {
215
244
  const t = parId.get(c.ticket);
216
- if (t && (t.status === 'deferred' || attendDeLAutreProjet(t, externes).length > 0)) {
245
+ if (
246
+ t &&
247
+ (leReportRendLaPlace(t, maintenant) || attendDeLAutreProjet(t, externes).length > 0)
248
+ ) {
217
249
  continue;
218
250
  }
219
251
  // A circuit reported for the usage limit (its kept report) waits for an hour, as a ticket
@@ -25,8 +25,10 @@
25
25
  // resolved); the entry's state (enabled, errors) is not read.
26
26
  // - A failure has its line on the error output, naming the plugin and the command that installs it
27
27
  // (a failed add: the marketplace's command, then the plugin's; a mod left at another version than
28
- // the package's, after its update or ahead of the package: both versions and the command of its
29
- // `ecart` line); the others are still tried and the code is 1. A state reading that fails installs nothing. Without `claude`, each plugin has its line.
28
+ // the package's: both versions and the command that aligns them — behind, after its update, `claude
29
+ // plugin update <id> --scope <its scope>`, never this command itself; ahead, the command of its
30
+ // `ecart` line, with who launches it and what it does); the others are still tried and the code is
31
+ // 1. A state reading that fails installs nothing. Without `claude`, each plugin has its line.
30
32
  // - `--absents` prints `claude` (the command is missing), `greffon <id>` per declared plugin not
31
33
  // installed for the project, or `lecture <reason>` when the state cannot be read; each claude
32
34
  // call stops after 5 s. It also prints `ecart <id> <mod's version> <package's version>
@@ -35,8 +37,8 @@
35
37
  // the plugin, whose manifest receives the package's version when it is packed (scripts/cadre.mjs),
36
38
  // and the marketplace roomi-fields names the package, so a project's package and the plugin the
37
39
  // machine installed for it can drift apart. The entry read is the project's at scope local, else
38
- // project, else user; the command aligns the one behind (`claude plugin update <id> --scope <its
39
- // scope>`, or `npm install -D @roomi-fields/grillhouse@<mod's version>`). A version that is not
40
+ // project, else user; the command is `npx grillhouse greffons` for a mod behind, and for a mod ahead the
41
+ // montée to its version, `npx grillhouse maj <mod's version>`. A version that is not
40
42
  // x.y.z (a plugin whose manifest carries none) and a script without its package's package.json
41
43
  // beside it compare nothing.
42
44
  import { spawnSync } from 'node:child_process';
@@ -169,23 +171,31 @@ function restaurerReglages(fichier, avant) {
169
171
  const commandeGreffon = id => `claude plugin install ${id} --scope project`;
170
172
  const marcheDe = id => id.slice(id.indexOf('@') + 1);
171
173
 
174
+ /** The plugins the settings of the project at `projet` declare, none when they do not read. */
175
+ export const greffonsDuProjet = projet => declaration(resolu(projet)).plugins ?? [];
176
+
172
177
  /**
173
178
  * Installs the plugins the project declares, for the project. Returns the lines of failure
174
- * (empty when everything stands).
179
+ * (empty when everything stands). A montée gives `declarations`, the folder whose settings declare
180
+ * them (its copy; the project's by default), `seulement`, the ids it installs now (those the main
181
+ * tree declares already), and `version`, the one the frame's mod follows (the package's by
182
+ * default). Every call of `claude` runs in `projet`.
183
+ * @param {string} projet
184
+ * @param {{ declarations?: string, seulement?: string[], version?: string }} [options]
175
185
  */
176
- export function installerGreffons(projet) {
186
+ export function installerGreffons(projet, options = {}) {
177
187
  const fichier = path.join(resolu(projet), '.claude', 'settings.json');
178
188
  const avant = existsSync(fichier) ? readFileSync(fichier, 'utf8') : null;
179
189
  try {
180
- return installer(projet);
190
+ return installer(projet, options);
181
191
  } finally {
182
192
  restaurerReglages(fichier, avant);
183
193
  }
184
194
  }
185
195
 
186
- function installer(projet) {
196
+ function installer(projet, { declarations = projet, seulement, version }) {
187
197
  const racine = resolu(projet);
188
- const d = declaration(racine);
198
+ const d = declaration(resolu(declarations));
189
199
  if (d.erreur) {
190
200
  return [d.erreur];
191
201
  }
@@ -228,7 +238,7 @@ function installer(projet) {
228
238
  }
229
239
  }
230
240
  }
231
- for (const id of d.plugins) {
241
+ for (const id of d.plugins.filter(x => seulement?.includes(x) ?? true)) {
232
242
  if (installePourLeProjet(lecturePlugins.liste, id, racine)) {
233
243
  continue;
234
244
  }
@@ -241,16 +251,16 @@ function installer(projet) {
241
251
  lignes.push(`${id} : l'installation échoue ; lance \`${commandeGreffon(id)}\`.`);
242
252
  }
243
253
  }
244
- return [...lignes, ...aligner(racine, d.plugins)];
254
+ return [...lignes, ...aligner(racine, d.plugins, version)];
245
255
  }
246
256
 
247
257
  // Brings the frame's mod, installed for the project, to the package's version: behind it, the mod
248
258
  // is updated at its scope from the project's root (`claude plugin update`, its source's latest),
249
259
  // then read again. Returns the line of a mod that stays at another version, with the command that
250
260
  // aligns it (`ecart`); none when the versions agree or compare nothing.
251
- function aligner(racine, declares) {
261
+ function aligner(racine, declares, version) {
252
262
  const lecture = lireListe(['plugin', 'list'], undefined);
253
- const avant = lecture.liste ? ecart(lecture.liste, declares, racine) : null;
263
+ const avant = lecture.liste ? ecart(lecture.liste, declares, racine, version) : null;
254
264
  if (!avant) {
255
265
  return [];
256
266
  }
@@ -258,15 +268,23 @@ function aligner(racine, declares) {
258
268
  if (avant.derriere) {
259
269
  const r = claude(['plugin', 'update', avant.id, '--scope', avant.scope], { cwd: racine });
260
270
  const relue = r.ok ? lireListe(['plugin', 'list'], undefined) : {};
261
- reste = relue.liste ? ecart(relue.liste, declares, racine) : avant;
271
+ reste = relue.liste ? ecart(relue.liste, declares, racine, version) : avant;
272
+ }
273
+ if (!reste) {
274
+ return [];
262
275
  }
263
- return reste
264
- ? [
265
- `${reste.id} : le greffon est en ${reste.greffon}, le paquet ${NOM_DU_PAQUET} en ${reste.paquet} ; lance \`${reste.commande}\`.`,
266
- ]
267
- : [];
276
+ const geste = reste.derriere
277
+ ? `lance \`claude plugin update ${reste.id} --scope ${reste.scope}\`.`
278
+ : `lance \`${reste.commande}\`. ${NOTE_DE_LA_MONTEE}`;
279
+ return [
280
+ `${reste.id} : le greffon est en ${reste.greffon}, le paquet ${NOM_DU_PAQUET} en ${reste.paquet} ; ${geste}`,
281
+ ];
268
282
  }
269
283
 
284
+ // What the line of a mod ahead says beside its command (session-start.sh says the same).
285
+ const NOTE_DE_LA_MONTEE =
286
+ "Le superviseur la lance dans l'arbre principal (une copie la refuse) : elle monte le projet, commite, avance main et pousse. `npx grillhouse maj` sans version garde la version du projet et laisse le greffon en avance.";
287
+
270
288
  /**
271
289
  * What the project lacks of its declared plugins: `claude`, `greffon <id>` or `lecture <reason>`
272
290
  * lines, and the `ecart …` line of a mod and a package of different versions. Reads only; each
@@ -313,11 +331,10 @@ export function versionDuPaquet() {
313
331
 
314
332
  // The frame's mod, declared and installed for the project (its entry of scope local, else
315
333
  // project, else user, as Claude Code applies them), when it carries another version than the
316
- // package: `{ id, scope, greffon, paquet, derriere, commande }`, the command aligning the one
317
- // behind (the mod's update at its scope, or the package's install at the mod's version); null
318
- // otherwise.
319
- function ecart(entrees, declares, racine) {
320
- const paquet = versionDuPaquet();
334
+ // package: `{ id, scope, greffon, paquet, derriere, commande }`, the command of the reading of
335
+ // the opening (the plugins' command for a mod behind, the montée to the mod's version for one
336
+ // ahead); null otherwise.
337
+ function ecart(entrees, declares, racine, paquet = versionDuPaquet()) {
321
338
  const id = declares.find(x => x.slice(0, x.indexOf('@')) === GREFFON_DU_CADRE);
322
339
  if (!paquet || !id) {
323
340
  return null;
@@ -331,9 +348,7 @@ function ecart(entrees, declares, racine) {
331
348
  return null;
332
349
  }
333
350
  const derriere = plusAncienne(greffon, paquet);
334
- const commande = derriere
335
- ? `claude plugin update ${id} --scope ${entree.scope}`
336
- : `npm install -D ${NOM_DU_PAQUET}@${greffon}`;
351
+ const commande = derriere ? 'npx grillhouse greffons' : `npx grillhouse maj ${greffon}`;
337
352
  return { id, scope: entree.scope, greffon, paquet, derriere, commande };
338
353
  }
339
354