@roomi-fields/grillhouse 0.52.0 → 0.54.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 (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +96 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
  5. package/cadre/templates/projet/vitest.config.cjs +45 -0
  6. package/charte/superviseur.md +36 -37
  7. package/charte.md +13 -1
  8. package/dist/temporal/circuit/appel.d.ts +2 -0
  9. package/dist/temporal/circuit/appel.js +24 -2
  10. package/dist/temporal/circuit/appel.js.map +1 -1
  11. package/dist/temporal/circuit/client.d.ts +14 -5
  12. package/dist/temporal/circuit/client.js +41 -9
  13. package/dist/temporal/circuit/client.js.map +1 -1
  14. package/dist/temporal/circuit/commande.js +17 -6
  15. package/dist/temporal/circuit/commande.js.map +1 -1
  16. package/dist/temporal/circuit/contrat.d.ts +9 -0
  17. package/dist/temporal/circuit/contrat.js +6 -0
  18. package/dist/temporal/circuit/contrat.js.map +1 -1
  19. package/dist/temporal/circuit/deroule.js +29 -12
  20. package/dist/temporal/circuit/deroule.js.map +1 -1
  21. package/dist/temporal/client.d.ts +35 -1
  22. package/dist/temporal/client.js +144 -1
  23. package/dist/temporal/client.js.map +1 -1
  24. package/dist/temporal/commande.js +31 -13
  25. package/dist/temporal/commande.js.map +1 -1
  26. package/dist/temporal/etat.d.ts +3 -1
  27. package/dist/temporal/etat.js +31 -17
  28. package/dist/temporal/etat.js.map +1 -1
  29. package/dist/temporal/file/activites.js +1 -1
  30. package/dist/temporal/file/activites.js.map +1 -1
  31. package/dist/temporal/file/contrat.d.ts +4 -5
  32. package/dist/temporal/file/contrat.js +2 -2
  33. package/dist/temporal/file/contrat.js.map +1 -1
  34. package/dist/temporal/file/deroule.js +7 -5
  35. package/dist/temporal/file/deroule.js.map +1 -1
  36. package/dist/temporal/installation.d.ts +116 -53
  37. package/dist/temporal/installation.js +898 -241
  38. package/dist/temporal/installation.js.map +1 -1
  39. package/dist/temporal/nuits/deroule.js +3 -1
  40. package/dist/temporal/nuits/deroule.js.map +1 -1
  41. package/dist/temporal/places/deroule.js +2 -1
  42. package/dist/temporal/places/deroule.js.map +1 -1
  43. package/dist/temporal/sonde/deroule.js +2 -1
  44. package/dist/temporal/sonde/deroule.js.map +1 -1
  45. package/dist/temporal/tickets/deroule.js +4 -3
  46. package/dist/temporal/tickets/deroule.js.map +1 -1
  47. package/dist/temporal/travailleur.d.ts +7 -1
  48. package/dist/temporal/travailleur.js +49 -25
  49. package/dist/temporal/travailleur.js.map +1 -1
  50. package/docs/INTERFACE.md +37 -12
  51. package/docs/architecture/circuit.md +21 -18
  52. package/docs/architecture/entree.md +10 -11
  53. package/docs/architecture/greffon.md +45 -27
  54. package/docs/architecture/installation.md +92 -59
  55. package/docs/architecture/machine.md +2 -2
  56. package/docs/architecture/tests.md +15 -6
  57. package/docs/lexique.md +2 -2
  58. package/hooks/hooks.json +10 -0
  59. package/hooks/register.tsx +59 -39
  60. package/package.json +3 -2
  61. package/scripts/activites.mjs +5 -4
  62. package/scripts/aiguillage.mjs +5 -2
  63. package/scripts/bd-garde.mjs +69 -0
  64. package/scripts/ci-de-main.mjs +259 -56
  65. package/scripts/circuit.mjs +274 -47
  66. package/scripts/circuits-du-serveur.mjs +3 -2
  67. package/scripts/circuits-tenus.d.mts +7 -0
  68. package/scripts/circuits-tenus.mjs +17 -0
  69. package/scripts/commandes-composees.mjs +1 -1
  70. package/scripts/copie-de-montee.mjs +354 -0
  71. package/scripts/copies-du-depot.d.mts +13 -0
  72. package/scripts/copies-du-depot.mjs +66 -0
  73. package/scripts/copies-finies.mjs +6 -40
  74. package/scripts/crochets.mjs +16 -2
  75. package/scripts/direct.mjs +2 -2
  76. package/scripts/droits.mjs +13 -6
  77. package/scripts/engendres.mjs +5 -3
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
  79. package/scripts/etapes.mjs +11 -3
  80. package/scripts/faits-du-circuit.mjs +12 -5
  81. package/scripts/file-des-tickets.d.mts +13 -2
  82. package/scripts/file-des-tickets.mjs +71 -21
  83. package/scripts/greffons.mjs +42 -27
  84. package/scripts/grillhouse-maj.mjs +105 -85
  85. package/scripts/init.mjs +1 -1
  86. package/scripts/integration/file.mjs +5 -2
  87. package/scripts/integration/integrer.mjs +14 -4
  88. package/scripts/jointure.d.ts +16 -0
  89. package/scripts/langages/c/commandes.mjs +18 -8
  90. package/scripts/langages/cargo/commandes.mjs +88 -35
  91. package/scripts/langages/cargo/index.mjs +6 -3
  92. package/scripts/langages/cargo/sccache.mjs +15 -12
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
  94. package/scripts/langages/python/commandes.mjs +19 -9
  95. package/scripts/langages/python/squelette.mjs +2 -2
  96. package/scripts/langages/typescript/code-mort.mjs +36 -3
  97. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  98. package/scripts/langages/typescript/index.mjs +2 -0
  99. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +370 -0
  100. package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
  101. package/scripts/langages/typescript/parcours.mjs +5 -1
  102. package/scripts/langages/typescript/squelette.mjs +20 -17
  103. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  104. package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
  105. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  106. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  107. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  108. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  109. package/scripts/langages.d.mts +6 -0
  110. package/scripts/langages.mjs +6 -0
  111. package/scripts/lire.mjs +236 -0
  112. package/scripts/mesure/pression.mjs +5 -3
  113. package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
  114. package/scripts/migrations/lire-un-ticket.mjs +46 -0
  115. package/scripts/migrations.mjs +4 -0
  116. package/scripts/montee.mjs +588 -0
  117. package/scripts/nuit.sh +21 -12
  118. package/scripts/outil.mjs +5 -3
  119. package/scripts/paquet-npm.mjs +22 -0
  120. package/scripts/paquet.mjs +5 -5
  121. package/scripts/pre-compact.mjs +25 -0
  122. package/scripts/registre.d.mts +7 -1
  123. package/scripts/registre.mjs +114 -102
  124. package/scripts/reponses-du-circuit.d.mts +17 -2
  125. package/scripts/reponses-du-circuit.mjs +78 -20
  126. package/scripts/resultats.mjs +55 -17
  127. package/scripts/retirer-les-copies-finies.mjs +4 -7
  128. package/scripts/seances.mjs +28 -3
  129. package/scripts/services-du-noyau.mjs +7 -2
  130. package/scripts/session-start.sh +18 -11
  131. package/scripts/sortie.mjs +4 -7
  132. package/scripts/sous-commandes.mjs +2 -0
  133. package/scripts/suiveur.mjs +12 -4
  134. package/scripts/superviseur.mjs +135 -84
  135. package/scripts/tableau.mjs +651 -224
  136. package/scripts/tarifs.mjs +67 -0
  137. package/scripts/ticket-du-circuit.mjs +25 -4
  138. package/scripts/transitions.d.mts +6 -14
  139. package/scripts/transitions.mjs +126 -49
  140. package/scripts/verdict-de-la-nuit.mjs +2 -2
  141. package/scripts/verrou-de-fichier.d.mts +11 -0
  142. package/skills/direct/SKILL.md +21 -11
  143. package/skills/explorateur/SKILL.md +16 -6
  144. package/skills/grill/SKILL.md +9 -7
  145. package/skills/grill/references/paquets.md +4 -4
  146. package/skills/mesure/SKILL.md +4 -3
  147. package/skills/pitmaster/SKILL.md +56 -35
  148. package/skills/pitmaster/references/consigne-agent.md +1 -1
  149. package/skills/pitmaster/references/erreurs.md +4 -2
  150. package/skills/pitmaster/references/tour.md +11 -4
  151. package/skills/relecteur/SKILL.md +8 -1
  152. package/skills/testwriter/SKILL.md +1 -1
  153. package/types/index.d.ts +3 -1
  154. package/cadre/templates/projet/vitest.config.ts +0 -44
  155. package/scripts/base-des-workflows.mjs +0 -58
@@ -27,6 +27,10 @@
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
@@ -568,6 +572,79 @@ export function reporter(copie, { base, pointe, duCadre, dire = surStderr }) {
568
572
  return r.status === 0 ? { ok: true, message: '' } : { ok: false, message: texte(r) };
569
573
  }
570
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
+
571
648
  const lotEnAttente = (copie, garde, fichiers) =>
572
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.`;
573
650
 
@@ -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`).
@@ -32,6 +33,7 @@
32
33
  // fault (never a silent start).
33
34
  import { spawnSync } from 'node:child_process';
34
35
  import path from 'node:path';
36
+ import { bdAAppeler } from './bd-garde.mjs';
35
37
  import { ETAPES } from './etapes.mjs';
36
38
  import { lotSurMain } from './integration/integrer.mjs';
37
39
 
@@ -39,14 +41,16 @@ import { lotSurMain } from './integration/integrer.mjs';
39
41
  // board both read.
40
42
  export const aSonArchitecture = t => /^## Architecture\b/m.test(t.description ?? '');
41
43
 
42
- // The tickets of <tous> in the queue: open, labelled `circuit` and not `direct`, those of
43
- // <enCours> aside.
44
+ // The labels that put a ticket in the queue.
45
+ const ETIQUETTES_DE_LA_FILE = ['circuit', 'direct'];
46
+
47
+ // The tickets of <tous> in the queue: open, labelled `circuit` or `direct`, those of <enCours>
48
+ // aside.
44
49
  const enFile = (tous, enCours) =>
45
50
  tous.filter(
46
51
  t =>
47
52
  t.status === 'open' &&
48
- (t.labels ?? []).includes('circuit') &&
49
- !(t.labels ?? []).includes('direct') &&
53
+ (t.labels ?? []).some(l => ETIQUETTES_DE_LA_FILE.includes(l)) &&
50
54
  !enCours.has(t.id)
51
55
  );
52
56
 
@@ -193,27 +197,56 @@ export function fermesHorsCircuit(tous, circuits) {
193
197
  .sort();
194
198
  }
195
199
 
200
+ /**
201
+ * The instant (ms) until which the ticket <t> is deferred at <maintenant> (ms), else null: its
202
+ * `defer_until` (the answer `--reporter <heure>`), strictly later. Beads writes it as the local
203
+ * wall time of the machine, followed by a « Z » it does not mean (`bd update --defer 17:30` gives
204
+ * `…T17:30:00Z`). The one reading of a deferral to an hour: the wait of the supervisor, the limit
205
+ * of the project and the board.
206
+ * @param {{ defer_until?: string }} t
207
+ * @param {number} maintenant
208
+ * @returns {number | null}
209
+ */
210
+ export function reporteJusqua(t, maintenant) {
211
+ const heure = Date.parse(String(t.defer_until ?? '').replace(/Z$/, ''));
212
+ return heure > maintenant ? heure : null;
213
+ }
214
+
215
+ /**
216
+ * Whether the deferral of the ticket <t> releases the place of its circuit in the limit of the
217
+ * project at <maintenant> (ms): deferred to a later time, or deferred with no hour.
218
+ * @param {{ status?: string, defer_until?: string }} t
219
+ * @param {number} maintenant
220
+ * @returns {boolean}
221
+ */
222
+ export function leReportRendLaPlace(t, maintenant) {
223
+ return reporteJusqua(t, maintenant) !== null || (t.status === 'deferred' && !t.defer_until);
224
+ }
225
+
196
226
  /**
197
227
  * The circuits of <circuits> that hold a place in the limit of the project (`grillhouse.circuits`),
198
228
  * as a Kanban limit of work in progress keeps a blocked card in it: a circuit that works, one
199
229
  * resumed and waiting for its place of the machine, and one stopped on a question to the
200
230
  * 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
231
+ * (`leReportRendLaPlace` at <maintenant>) and a wait for another project release their place. Each circuit is judged by
202
232
  * its own memo, read again at every wake of the queue.
203
233
  * @param {Array<{ ticket: string, etape?: string | null, question?: { qui?: string } | null }>} circuits
204
234
  * the circuits alive, each with its memo
205
235
  * @param {Parameters<typeof ticketsAPartir>[0]} tous every ticket of the project
206
- * @param {{ externes?: Record<string, typeof tous> }} [o]
236
+ * @param {{ externes?: Record<string, typeof tous>, maintenant?: number }} [o]
207
237
  * @returns {{ tenant: string[], superviseur: string[] }} the circuits that hold the limit, and
208
238
  * among them those that wait for the supervisor, each sorted
209
239
  */
210
- export function circuitsDeLaLimite(circuits, tous, { externes } = {}) {
240
+ export function circuitsDeLaLimite(circuits, tous, { externes, maintenant = Date.now() } = {}) {
211
241
  const parId = new Map(tous.map(t => [t.id, t]));
212
242
  const tenant = [];
213
243
  const superviseur = [];
214
244
  for (const c of circuits) {
215
245
  const t = parId.get(c.ticket);
216
- if (t && (t.status === 'deferred' || attendDeLAutreProjet(t, externes).length > 0)) {
246
+ if (
247
+ t &&
248
+ (leReportRendLaPlace(t, maintenant) || attendDeLAutreProjet(t, externes).length > 0)
249
+ ) {
217
250
  continue;
218
251
  }
219
252
  // A circuit reported for the usage limit (its kept report) waits for an hour, as a ticket
@@ -249,7 +282,9 @@ export function enFileSansArchitecture(tous, { enCours = new Set() } = {}) {
249
282
  * The tickets of each provider project the tickets <tous> depend on (`external:<project>:…`), by
250
283
  * the project's name, read through Beads' `external_projects` of the project at <racine>; a
251
284
  * project that the configuration does not set, or whose tickets do not read, is left out (the
252
- * ticket that waits for it stays held, `attentesExternes` naming the fault).
285
+ * ticket that waits for it stays held, `attentesExternes` naming the fault). Beads is called as
286
+ * the project at <racine> keeps it (`bdAAppeler`, ./bd-garde.mjs), for its configuration and for
287
+ * the tickets of each provider.
253
288
  * @param {string} racine
254
289
  * @param {Parameters<typeof ticketsAPartir>[0]} tous
255
290
  * @returns {Record<string, typeof tous>}
@@ -257,9 +292,14 @@ export function enFileSansArchitecture(tous, { enCours = new Set() } = {}) {
257
292
  export function lireLesExternes(racine, tous) {
258
293
  const noms = new Set(tous.flatMap(t => dependancesExternes(t).map(d => d.projet)));
259
294
  const externes = {};
295
+ if (noms.size === 0) {
296
+ return externes;
297
+ }
298
+ const bd = bdAAppeler(dossierGitCommun(racine));
260
299
  for (const nom of noms) {
261
- const r = spawnSync('bd', ['config', 'get', `external_projects.${nom}`], {
300
+ const r = spawnSync(bd.commande, ['config', 'get', `external_projects.${nom}`], {
262
301
  cwd: racine,
302
+ env: bd.env,
263
303
  encoding: 'utf8',
264
304
  maxBuffer: 256 * 1024 * 1024,
265
305
  });
@@ -268,7 +308,7 @@ export function lireLesExternes(racine, tous) {
268
308
  continue;
269
309
  }
270
310
  try {
271
- externes[nom] = lireLesTickets(cheminDuProjetExterne(racine, chemin));
311
+ externes[nom] = listerLesTickets(cheminDuProjetExterne(racine, chemin), bd);
272
312
  } catch {
273
313
  // Left out: the project does not resolve.
274
314
  }
@@ -289,15 +329,19 @@ export function cheminDuProjetExterne(racine, chemin) {
289
329
  if (path.isAbsolute(chemin)) {
290
330
  return chemin;
291
331
  }
332
+ const commun = dossierGitCommun(racine);
333
+ const principal = commun ? path.dirname(commun) : path.resolve(racine);
334
+ return path.resolve(principal, chemin);
335
+ }
336
+
337
+ // The common directory of git of <racine>, absolute; null when <racine> is no git repository.
338
+ function dossierGitCommun(racine) {
292
339
  const r = spawnSync(
293
340
  'git',
294
341
  ['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
295
- {
296
- encoding: 'utf8',
297
- }
342
+ { encoding: 'utf8' }
298
343
  );
299
- const principal = r.status === 0 ? path.dirname(r.stdout.trim()) : path.resolve(racine);
300
- return path.resolve(principal, chemin);
344
+ return r.status === 0 ? r.stdout.trim() : null;
301
345
  }
302
346
 
303
347
  /**
@@ -305,8 +349,14 @@ export function cheminDuProjetExterne(racine, chemin) {
305
349
  * fails or a list that does not parse throws, its reason named (`bd list`), never an empty list.
306
350
  */
307
351
  export function lireLesTickets(racine) {
308
- const r = spawnSync('bd', ['list', '--all', '--limit', '0', '--json'], {
352
+ return listerLesTickets(racine, { commande: 'bd', env: process.env });
353
+ }
354
+
355
+ // `lireLesTickets`, Beads called as <bd> says (`bdAAppeler`).
356
+ function listerLesTickets(racine, bd) {
357
+ const r = spawnSync(bd.commande, ['list', '--all', '--limit', '0', '--json'], {
309
358
  cwd: racine,
359
+ env: bd.env,
310
360
  encoding: 'utf8',
311
361
  maxBuffer: 256 * 1024 * 1024,
312
362
  });
@@ -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