@roomi-fields/grillhouse 0.48.0 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +90 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +11 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +15 -6
  6. package/cadre/templates/projet/CLAUDE.md +10 -6
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/cadre/templates/turbo/paquets.json +3 -1
  9. package/cadre/templates/turbo/sans-paquets.json +3 -1
  10. package/charte.md +51 -14
  11. package/dist/temporal/acte.d.ts +9 -0
  12. package/dist/temporal/acte.js +43 -20
  13. package/dist/temporal/acte.js.map +1 -1
  14. package/dist/temporal/circuit/appel.d.ts +4 -1
  15. package/dist/temporal/circuit/appel.js +15 -1
  16. package/dist/temporal/circuit/appel.js.map +1 -1
  17. package/dist/temporal/circuit/client.d.ts +7 -1
  18. package/dist/temporal/circuit/client.js +54 -1
  19. package/dist/temporal/circuit/client.js.map +1 -1
  20. package/dist/temporal/circuit/commande.js +30 -57
  21. package/dist/temporal/circuit/commande.js.map +1 -1
  22. package/dist/temporal/circuit/contrat.d.ts +2 -1
  23. package/dist/temporal/circuit/contrat.js +2 -1
  24. package/dist/temporal/circuit/contrat.js.map +1 -1
  25. package/dist/temporal/circuit/deroule.js +9 -2
  26. package/dist/temporal/circuit/deroule.js.map +1 -1
  27. package/dist/temporal/file/contrat.d.ts +16 -2
  28. package/dist/temporal/file/contrat.js +27 -3
  29. package/dist/temporal/file/contrat.js.map +1 -1
  30. package/dist/temporal/file/deroule.js +4 -4
  31. package/dist/temporal/file/deroule.js.map +1 -1
  32. package/dist/temporal/nuits/activites.d.ts +1 -15
  33. package/dist/temporal/nuits/activites.js +3 -62
  34. package/dist/temporal/nuits/activites.js.map +1 -1
  35. package/dist/temporal/nuits/contrat.d.ts +3 -21
  36. package/dist/temporal/nuits/deroule.js +38 -74
  37. package/dist/temporal/nuits/deroule.js.map +1 -1
  38. package/dist/temporal/places/client.d.ts +3 -16
  39. package/dist/temporal/places/client.js +3 -26
  40. package/dist/temporal/places/client.js.map +1 -1
  41. package/dist/temporal/places/contrat.d.ts +15 -51
  42. package/dist/temporal/places/contrat.js +3 -13
  43. package/dist/temporal/places/contrat.js.map +1 -1
  44. package/dist/temporal/places/deroule.js +11 -61
  45. package/dist/temporal/places/deroule.js.map +1 -1
  46. package/dist/temporal/tickets/activites.js +4 -2
  47. package/dist/temporal/tickets/activites.js.map +1 -1
  48. package/dist/temporal/tickets/contrat.d.ts +2 -1
  49. package/docs/ARCHITECTURE.md +337 -120
  50. package/docs/CADRE.md +16 -13
  51. package/docs/INTERFACE.md +90 -25
  52. package/hooks/hooks.json +9 -0
  53. package/hooks/register.tsx +59 -5
  54. package/package.json +1 -1
  55. package/scripts/activites.mjs +271 -42
  56. package/scripts/aiguillage.mjs +4 -1
  57. package/scripts/bilan.mjs +125 -2
  58. package/scripts/circuit.mjs +233 -159
  59. package/scripts/circuits-cles.d.mts +3 -3
  60. package/scripts/circuits-cles.mjs +6 -5
  61. package/scripts/coeurs-dedies.mjs +4 -4
  62. package/scripts/commandes-composees.mjs +12 -5
  63. package/scripts/dette.d.ts +2 -1
  64. package/scripts/dette.mjs +49 -6
  65. package/scripts/direct.mjs +343 -0
  66. package/scripts/droits.mjs +26 -4
  67. package/scripts/effets.mjs +4 -4
  68. package/scripts/engendres.mjs +2 -1
  69. package/scripts/enveloppe/enveloppe.mjs +119 -18
  70. package/scripts/enveloppe/lancer.sh +14 -3
  71. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  72. package/scripts/enveloppe/travail-de-la-copie.mjs +119 -21
  73. package/scripts/etapes.mjs +3 -3
  74. package/scripts/faits-du-circuit.mjs +12 -11
  75. package/scripts/fermeture-de-la-machine.d.mts +4 -4
  76. package/scripts/fermeture-de-la-machine.mjs +10 -20
  77. package/scripts/fichiers-nommes.mjs +27 -1
  78. package/scripts/file-des-tickets.d.mts +18 -1
  79. package/scripts/file-des-tickets.mjs +63 -15
  80. package/scripts/flux-de-la-nuit.mjs +38 -0
  81. package/scripts/grillhouse-maj.mjs +13 -25
  82. package/scripts/groupe-cles.d.mts +6 -0
  83. package/scripts/groupe-cles.mjs +29 -1
  84. package/scripts/integration/file.mjs +148 -37
  85. package/scripts/jointure.d.ts +20 -3
  86. package/scripts/journal-des-etats.d.mts +16 -0
  87. package/scripts/journal-des-etats.mjs +44 -2
  88. package/scripts/journal.mjs +3 -0
  89. package/scripts/langages/c/commandes.mjs +5 -5
  90. package/scripts/langages/c/composants.mjs +13 -5
  91. package/scripts/langages/cargo/commandes.mjs +5 -6
  92. package/scripts/langages/python/commandes.mjs +5 -5
  93. package/scripts/langages/python/composants.mjs +10 -2
  94. package/scripts/langages/typescript/composants.mjs +10 -3
  95. package/scripts/langages/typescript/consommateurs-arbitres.mjs +15 -3
  96. package/scripts/langages/typescript/construire.mjs +2 -0
  97. package/scripts/langages/typescript/exemples.mjs +33 -1
  98. package/scripts/langages/typescript/index.mjs +19 -0
  99. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  100. package/scripts/langages/typescript/tests-de-nuit.mjs +158 -32
  101. package/scripts/langages/typescript/tests-du-poste.mjs +112 -32
  102. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  103. package/scripts/langages/typescript/turbo-des-paquets.mjs +21 -4
  104. package/scripts/langages/typescript/verifier.mjs +3 -5
  105. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  106. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  107. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  108. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  109. package/scripts/machine.mjs +1 -1
  110. package/scripts/mesure/base-de-passe.mjs +2 -1
  111. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  112. package/scripts/migrations.mjs +2 -0
  113. package/scripts/nuit.sh +129 -3
  114. package/scripts/paquet.mjs +16 -5
  115. package/scripts/paquets.d.ts +4 -0
  116. package/scripts/paquets.mjs +57 -0
  117. package/scripts/passe-de-la-machine.mjs +4 -7
  118. package/scripts/places-de-la-machine.mjs +55 -42
  119. package/scripts/places-du-serveur.mjs +2 -2
  120. package/scripts/plafond-de-la-machine.d.mts +7 -13
  121. package/scripts/plafond-de-la-machine.mjs +19 -35
  122. package/scripts/prefixe-des-tickets.mjs +1 -1
  123. package/scripts/references-changees.mjs +159 -0
  124. package/scripts/regles-des-places.d.mts +8 -31
  125. package/scripts/regles-des-places.mjs +14 -64
  126. package/scripts/repli-de-la-nuit.mjs +183 -0
  127. package/scripts/reponses-du-circuit.d.mts +2 -2
  128. package/scripts/reponses-du-circuit.mjs +21 -12
  129. package/scripts/reprise.mjs +27 -8
  130. package/scripts/resultats.mjs +21 -9
  131. package/scripts/seances.mjs +258 -40
  132. package/scripts/services-du-noyau.mjs +4 -0
  133. package/scripts/sous-commandes.mjs +24 -7
  134. package/scripts/superviseur.mjs +185 -39
  135. package/scripts/tableau.mjs +226 -94
  136. package/scripts/taches-du-graphe.mjs +84 -4
  137. package/scripts/ticket.mjs +348 -0
  138. package/scripts/transitions.d.mts +44 -0
  139. package/scripts/transitions.mjs +188 -17
  140. package/scripts/un-commit-par-ticket.mjs +4 -3
  141. package/scripts/verdict-de-la-nuit.mjs +47 -20
  142. package/scripts/verrou-de-fichier.mjs +2 -2
  143. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  144. package/scripts/verrous/verrou.mjs +17 -1
  145. package/skills/architecte/SKILL.md +203 -0
  146. package/skills/architecte/references/exemple-d-architecture.md +159 -0
  147. package/skills/developpeur/SKILL.md +1 -1
  148. package/skills/direct/SKILL.md +57 -0
  149. package/skills/explorateur/SKILL.md +10 -6
  150. package/skills/pitmaster/SKILL.md +37 -14
  151. package/skills/pitmaster/references/consigne-agent.md +7 -1
  152. package/skills/redacteur/references/documents-d-un-composant.md +2 -1
  153. package/skills/relecteur/SKILL.md +8 -0
  154. package/skills/testwriter/SKILL.md +10 -0
  155. package/scripts/ticket.sh +0 -25
@@ -23,11 +23,12 @@ export function reglageDesCircuits(pkg) {
23
23
  return { max: c, faute: null };
24
24
  }
25
25
 
26
- // The minutes between two presentations of a question of a circuit that nobody answered, by default.
27
- export const RAPPEL_PAR_DEFAUT = 5;
26
+ // The minutes between the reading of a question of a circuit that nobody answered and its
27
+ // reminder, by default.
28
+ export const RAPPEL_PAR_DEFAUT = 10;
28
29
 
29
- // The reading of the key `grillhouse.rappel` of a package.json: the minutes between two
30
- // presentations of a question not answered, a number above 0; absent or null, 5. Any other value
30
+ // The reading of the key `grillhouse.rappel` of a package.json: the minutes between the reading of
31
+ // a question and its reminder, a number above 0; absent or null, 10. Any other value
31
32
  // is a fault, named with its value.
32
33
  // Returns { minutes, faute }: `minutes` null on a fault; `faute` null when the key reads.
33
34
  export function reglageDuRappel(pkg) {
@@ -46,7 +47,7 @@ export function reglageDuRappel(pkg) {
46
47
 
47
48
  /**
48
49
  * The re-presentation interval, in minutes, of the project at <racine>, as its package.json sets
49
- * it; 5 when the package.json does not read, and 5 too on a fault (the greffon names it).
50
+ * it; 10 when the package.json does not read, and 10 too on a fault (the greffon names it).
50
51
  * @param {string} racine
51
52
  * @returns {number}
52
53
  */
@@ -4,7 +4,7 @@
4
4
  // guaranteed class cores of its own, and as Slurm binds a job to its cores. Functions with the
5
5
  // system as input (what it reads is passed in, nothing is changed here):
6
6
  // - The key `grillhouse.mesure` of a project (`{ "coeurs": <integer ≥ 1> }`) and the number of
7
- // dedicated cores: the default one is the default part of the budget (`partParDefautDe`).
7
+ // dedicated cores: the default one is 3 (`COEURS_PAR_DEFAUT`).
8
8
  // - The topology of the system (the sibling threads of a core, the memory node): a unit of
9
9
  // dedicated core is a physical core whole, its sibling threads with it. The count stays in
10
10
  // threads (« cores » of the budget), as the budget does.
@@ -18,7 +18,7 @@ import { readFileSync } from 'node:fs';
18
18
  import { availableParallelism } from 'node:os';
19
19
  import { spawnSync } from 'node:child_process';
20
20
  import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
21
- import { partParDefautDe } from './plafond-de-la-machine.mjs';
21
+ import { COEURS_PAR_DEFAUT } from './plafond-de-la-machine.mjs';
22
22
 
23
23
  /** The tool that pins a command, and its children, to cores (util-linux). */
24
24
  export const OUTIL_D_AFFINITE = 'taskset';
@@ -63,8 +63,8 @@ export function mesureDeclareeDe(pkg) {
63
63
  * places: number }} o
64
64
  * @returns {number}
65
65
  */
66
- export function coeursDeLaMesureDe({ declaree, budget, places }) {
67
- const voulus = declaree?.coeurs ?? partParDefautDe(budget, places, undefined).coeurs;
66
+ export function coeursDeLaMesureDe({ declaree, budget }) {
67
+ const voulus = declaree?.coeurs ?? COEURS_PAR_DEFAUT;
68
68
  return Math.max(1, Math.min(budget.coeurs, voulus));
69
69
  }
70
70
 
@@ -12,15 +12,18 @@
12
12
  // these, in the working directory, with this process's standard streams and environment, its
13
13
  // results directory included (`GRILLHOUSE_RESULTATS`), where each module writes under names of
14
14
  // its own. A line on the error stream names each module before it plays, so that what a
15
- // command prints on its standard output stays its own.
15
+ // command prints on its standard output stays its own. A command no module of the project
16
+ // describes plays nothing and is green, said in one line: `fusion-des-tranches`, which every
17
+ // project has (scripts/sous-commandes.mjs), in a project without the module typescript.
16
18
  // - `tester`, `tests-du-paquet`, `construire` and `typer` (the last three: one package, as the
17
19
  // scripts of its package.json call them): an argument that begins with « - » is an option, given to every module; any other is
18
20
  // a path from the root, given to the module of the component that holds it
19
21
  // (`moduleDuFichier`), or out of every component to the first module whose rule of a test file
20
22
  // judges it (`estUnTest`). With paths, the modules that receive none do not play. A path no
21
23
  // module takes is refused, named, and nothing plays (code 2).
22
- // - The launcher's `construire --echec <fichier> <plan>` is one implementation for every language
23
- // (scripts/taches-du-graphe.mjs): the first module plays it, once.
24
+ // - The launcher's `construire --echec <fichier> <plan>`, and `construire --gardes` of the checks of
25
+ // a plan, are one implementation for every language (scripts/taches-du-graphe.mjs): the first
26
+ // module plays it, once.
24
27
  // - No module is given a green to defer: the last green (scripts/dernier-vert.mjs) is kept by the
25
28
  // one pass of the verification, once, when every task of every language of the graph is green
26
29
  // (scripts/langages/typescript/verifier.mjs). A module that plays after a red one gets
@@ -43,7 +46,7 @@ import { moduleDuFichier } from './composition-des-langages.mjs';
43
46
  import { garderLeVert } from './dernier-vert.mjs';
44
47
  import { etatDuDepot } from './etat-du-depot.mjs';
45
48
  import { langagesDe } from './langages.mjs';
46
- import { GRAPHE_JOUE, PASSE_ROUGE } from './taches-du-graphe.mjs';
49
+ import { constructionDuGraphe, GRAPHE_JOUE, PASSE_ROUGE } from './taches-du-graphe.mjs';
47
50
 
48
51
  /** This script, the one every composed command runs. */
49
52
  export const SCRIPT = fileURLToPath(import.meta.url);
@@ -67,7 +70,7 @@ function repartir(nom, args, modules, racine) {
67
70
  // `construire` and `typer` name a package by its path, as `tester`.
68
71
  // The launcher's build is one implementation for every language (scripts/taches-du-graphe.mjs): it
69
72
  // plays once, by the first module, not once per module (each would build the same copy again).
70
- if (nom === 'construire' && args.includes('--echec')) {
73
+ if (nom === 'construire' && constructionDuGraphe(args)) {
71
74
  return { parts: modules.slice(0, 1).map(module => ({ module, args })) };
72
75
  }
73
76
  if (!PAR_CHEMIN.includes(nom)) {
@@ -141,6 +144,10 @@ export function jouer(
141
144
  } = {}
142
145
  ) {
143
146
  const avec = modules.filter(m => Object.hasOwn(m.commandes(racine), nom));
147
+ if (avec.length === 0) {
148
+ dire(`↳ ${nom} : aucun langage du projet ne décrit cette commande : rien à jouer.`);
149
+ return 0;
150
+ }
144
151
  const r = repartir(nom, args, avec, racine);
145
152
  if (r.refus) {
146
153
  for (const a of r.refus) {
@@ -13,7 +13,8 @@ export type Constat = {
13
13
  * Judges the findings of `garde` at `racine` against `grillhouse-dette.json`, in the mode `mode`
14
14
  * (`GRILLHOUSE_DETTE` by default): `refus` the findings to print as refusals, `lignes` the lines
15
15
  * to print after them. A guard that reads a part of the repository gives `mesure`, whether it read
16
- * a file (from the root): the keys of the other files stay as they are.
16
+ * a file (from the root): the keys of the other files stay as they are, as do, in the envelope of
17
+ * a plan (`GRILLHOUSE_ENVELOPPE` of `env`), the keys of the files out of the plan's packages.
17
18
  */
18
19
  export function trancher(
19
20
  racine: string,
package/scripts/dette.mjs CHANGED
@@ -23,12 +23,18 @@
23
23
  // drops the keys at zero, never raising a count nor adding a key. Each guard then judges against
24
24
  // the file it wrote. The npm scripts `grillhouse:dette:inscrire` and `grillhouse:dette:elaguer`
25
25
  // run every guard so.
26
+ // - A debt comes down by the lot that resorbs it, on what the run measured: a guard that reads a
27
+ // part of the repository says which files it read (`mesure`), and a run in the envelope of a
28
+ // plan measures the files of the plan's packages alone, whatever its guard reads
29
+ // (`mesureDuPlan`); the keys of the other files are neither judged corrected, nor noted, nor
30
+ // pruned, nor written again. A pass out of any envelope (the final pass) measures them.
26
31
  //
27
32
  // A project's guard imports `trancher` by the package's entry `@roomi-fields/grillhouse/dette`,
28
33
  // its types in ./dette.d.ts (docs/ARCHITECTURE.md, the package's named entries).
29
34
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
30
35
  import path from 'node:path';
31
36
  import { pathToFileURL } from 'node:url';
37
+ import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
32
38
  import { A_ELAGUER, A_INSCRIRE, ecrireSarif } from './resultats.mjs';
33
39
 
34
40
  // The environment variable that names the guards of the lot's base (main), a JSON list.
@@ -83,6 +89,33 @@ export function lire(racine) {
83
89
  // Every file is measured: the answer of a guard that reads the whole repository.
84
90
  const TOUT = () => true;
85
91
 
92
+ /**
93
+ * Whether a run at <racine> in <env> measures the file <fichier> (from the root) for the known
94
+ * debt: every file out of an envelope; in the envelope of a plan (`GRILLHOUSE_ENVELOPPE`,
95
+ * scripts/enveloppe/paquets-du-plan.mjs), a file under a path the plan names, every file when the
96
+ * plan names the root. The copy of a plan holds what its packages need, not what the others do
97
+ * (their builds, their shared test material): what a guard reads of them there is no measure of
98
+ * their debt, as `eslint --prune-suppressions` prunes the files it linted only.
99
+ * @param {string} racine
100
+ * @param {Record<string, string | undefined>} [env]
101
+ * @returns {(fichier: string) => boolean}
102
+ */
103
+ export function mesureDuPlan(racine, env = process.env) {
104
+ const plan = paquetsDeLEnveloppe(env);
105
+ if (plan === null) {
106
+ return TOUT;
107
+ }
108
+ const base = path.resolve(racine);
109
+ const dossiers = plan.map(p => path.resolve(base, p));
110
+ if (dossiers.includes(base)) {
111
+ return TOUT;
112
+ }
113
+ return fichier => {
114
+ const f = path.resolve(base, fichier);
115
+ return dossiers.some(d => f === d || f.startsWith(d + path.sep));
116
+ };
117
+ }
118
+
86
119
  // The keys of the section <ancienne> of a guard, as counts, that a run did not measure (<mesure>,
87
120
  // whether it read a file): a guard that reads a part of the repository (the components of a plan,
88
121
  // in an envelope) knows nothing of the others, as a baseline of PHPStan is pruned of the files
@@ -97,11 +130,13 @@ function nonMesurees(ancienne, mesure) {
97
130
  return out;
98
131
  }
99
132
 
100
- // <dette> with the section of <garde> replaced by what <constats> count, the keys of the files the
101
- // run did not measure (<mesure>) kept; the guard leaves the file when nothing remains.
133
+ // <dette> with the section of <garde> replaced by what <constats> count in the files the run
134
+ // measured (<mesure>), the keys of the others kept as they are, whatever the guard finds there;
135
+ // the guard leaves the file when nothing remains.
102
136
  export function inscrire(dette, garde, constats, mesure = TOUT) {
103
137
  const { [garde]: ancienne = {}, ...reste } = dette;
104
- const comptes = new Map([...nonMesurees(ancienne, mesure), ...compter(constats)]);
138
+ const mesures = constats.filter(c => !c.fichier || mesure(c.fichier));
139
+ const comptes = new Map([...compter(mesures), ...nonMesurees(ancienne, mesure)]);
105
140
  return comptes.size ? { ...reste, [garde]: section(comptes) } : reste;
106
141
  }
107
142
 
@@ -174,7 +209,8 @@ export function juger(dette, garde, constats, mesure = TOUT) {
174
209
  // each with its file, its line when the guard gives one, and its rule; beside them, each key
175
210
  // inscribed above what the guard finds is a note (`a-elaguer`, level `note`), no red, by which the
176
211
  // circuit lowers the debt d'office at the final pass (scripts/circuit.mjs, 4.2). A guard that
177
- // reads a part of the repository gives <mesure>, whether it read a file (from the root): the keys
212
+ // reads a part of the repository gives <mesure>, whether it read a file (from the root), and a run
213
+ // in the envelope of a plan measures the files of its packages alone (`mesureDuPlan`): the keys
178
214
  // of the others are neither judged corrected, nor pruned, nor written again.
179
215
  export function trancher(
180
216
  racine,
@@ -184,7 +220,15 @@ export function trancher(
184
220
  env,
185
221
  mesure = TOUT
186
222
  ) {
187
- const { refus, lignes, corriges } = juge(racine, garde, constats, mode, mesure);
223
+ const lEnv = env ?? process.env;
224
+ const duPlan = mesureDuPlan(racine, lEnv);
225
+ const { refus, lignes, corriges } = juge(
226
+ racine,
227
+ garde,
228
+ constats,
229
+ mode,
230
+ fichier => mesure(fichier) && duPlan(fichier)
231
+ );
188
232
  const notes = corriges.map(c => ({
189
233
  fichier: c.fichier,
190
234
  regle: c.regle,
@@ -193,7 +237,6 @@ export function trancher(
193
237
  trouve: c.trouve,
194
238
  message: `${c.trouve} constat(s) pour ${c.inscrit} inscrit(s) dans ${FICHIER} : la dette s'abaisse.`,
195
239
  }));
196
- const lEnv = env ?? process.env;
197
240
  ecrireSarif({
198
241
  garde,
199
242
  constats: [...refus, ...notes, ...aInscrire(garde, refus, lEnv)],
@@ -0,0 +1,343 @@
1
+ #!/usr/bin/env node
2
+ // The direct, a gesture of the frame: a ticket led out of the circuit is written by an agent in a
3
+ // copy of its own, then read by the reviewer, and the command stops there. As a fix of the tooling
4
+ // outside a merge queue is still written by an author other than its reviewer and verified before
5
+ // it lands (the « tree closer fix » of Chromium, the stage0 of rustc fixed outside bors), the
6
+ // supervisor never writes it: it reads the lot, plays the full verification, commits, advances main
7
+ // and pushes.
8
+ //
9
+ // npx grillhouse direct <ticket> [--paquet <chemin>]… [--contexte <texte>]
10
+ // npx grillhouse direct <ticket> --deverrouiller
11
+ //
12
+ // - The ticket carries the label `direct`. Its packages are the components of its title, as the
13
+ // circuit writes them (« numéro — sujet — composant, composant »), completed by each `--paquet`;
14
+ // without any, the command refuses, naming the title. A path no package holds (the skeleton of a
15
+ // package, data) is a path of the plan, written in the copy; a direct of the frame itself writes
16
+ // in its copy, never in the installed version.
17
+ // - No plan, no proof of the red, no checks, no queue: the session of the agent `direct` (tests
18
+ // and code together, rights of its own, scripts/droits.mjs), then the session of the reviewer on
19
+ // its lot (`relire` of scripts/activites.mjs, with its instruction made for a direct). It writes
20
+ // the verdict and the address of the copy.
21
+ // - It starts or resumes by the sheets of the reviewer kept for the copy (`decisionDuDirect`): no
22
+ // sheet for the lot as it stands, it starts; a verdict RENDU, it resumes the agent with the
23
+ // open findings; an ACCEPTÉ lot, it gives its verdict again; three RENDU in a row, it stops and
24
+ // goes up to the supervisor, as the circuit does.
25
+ // - The copy it creates is locked by git (`git worktree lock`), which the cleaning of the circuit
26
+ // respects while the copy holds a lot identical to main; `--deverrouiller` lifts it once the lot is
27
+ // on main.
28
+ //
29
+ // Exit code: 0 for an ACCEPTÉ lot, 1 for a RENDU lot (the same command resumes the agent), 2 for a
30
+ // usage fault or a refusal, 3 for a stop that goes up to the supervisor.
31
+ import { spawnSync } from 'node:child_process';
32
+ import { existsSync } from 'node:fs';
33
+ import { pathToFileURL } from 'node:url';
34
+ import { prendreUnePlace, VARIABLE_TENUE } from './places-de-la-machine.mjs';
35
+ import { bloquantsDeLaFiche } from './resultats.mjs';
36
+ import { consigne } from './seances.mjs';
37
+
38
+ // The RENDU verdicts in a row that stop the command, as the circuit stops its third.
39
+ const RENDUS_MAX = 3;
40
+
41
+ // The requirement of the reviewer of a direct, after the instruction of the circuit's.
42
+ const EXIGENCE_DU_DIRECT = [
43
+ 'CE LOT EST UN DIRECT, mené hors du circuit par `npx grillhouse direct` : un seul agent, le rôle `direct`, a écrit les tests et le code ensemble. Tout constat bloquant lui est adressé : son destinataire est `developpeur`.',
44
+ "La preuve du rouge n'est pas jouée : tu la tiens. Un défaut corrigé porte un test qui le reproduit, et ce test échoue sans le code du lot ; sans lui, le constat est bloquant. Un ticket de données ou le squelette d'un paquet, qui ne change aucun comportement, n'a pas de test à exiger.",
45
+ ].join('\n\n');
46
+
47
+ /**
48
+ * The instruction of the reviewer of a direct: that of the circuit's reviewer (the second template
49
+ * of the supervisor's skill), then what a direct asks of its lot.
50
+ * @param {Record<string, string>} valeurs
51
+ * @returns {string}
52
+ */
53
+ export function consigneDuRelecteurDuDirect(valeurs) {
54
+ return `${consigne(valeurs, 1).trim()}\n\n${EXIGENCE_DU_DIRECT}\n`;
55
+ }
56
+
57
+ /**
58
+ * The subject and the plan of a direct: the components of the title <titre> of the ticket <id>
59
+ * after its last « — », separated by commas, then the paths of <options>, each once, each resolved
60
+ * by <resoudre> (a name or a path, else it throws); a title without components and no option are
61
+ * refused, the title named.
62
+ * @param {{ id: string, titre: string, options?: string[], resoudre: (nom: string) => string }} o
63
+ * @returns {{ sujet: string, plan: string[] }}
64
+ */
65
+ export function planDuDirect({ id, titre, options = [], resoudre }) {
66
+ const parts = String(titre ?? '').split(' — ');
67
+ const nomme = parts.length > 1 ? parts.at(-1).split(',') : [];
68
+ const plan = [
69
+ ...new Set([...nomme, ...options].map(c => c.trim()).filter(Boolean).map(resoudre)),
70
+ ];
71
+ if (!plan.length) {
72
+ throw new Error(
73
+ `Le ticket ${id} n'a aucun paquet : son titre « ${titre} » ne nomme pas ses composants (« numéro — sujet — composant, composant »), et aucun --paquet n'en ajoute.`
74
+ );
75
+ }
76
+ return { sujet: parts.length > 2 ? parts.slice(1, -1).join(' — ') : parts[0], plan };
77
+ }
78
+
79
+ /**
80
+ * What the command does on the sheets kept for the copy <fiches> (`{ role, lot, fiche }`, the
81
+ * reviewer's carrying the lot it read) and the lot as it stands <lot>: `demarrer` without a sheet
82
+ * of the reviewer for this lot; `accepte` for an ACCEPTÉ lot; `relancer` for a RENDU lot, with its
83
+ * open blocking findings; `arreter` once the RENDU verdicts in a row since the last ACCEPTÉ reach
84
+ * RENDUS_MAX.
85
+ * @param {{ role: string, lot?: unknown, fiche: { verdict: string } }[]} fiches
86
+ * @param {unknown} lot
87
+ * @returns {{ action: 'demarrer' | 'accepte' | 'relancer' | 'arreter', constats?: object[], rendus?: number }}
88
+ */
89
+ export function decisionDuDirect(fiches, lot) {
90
+ const relectures = fiches.filter(e => e.role === 'relecteur');
91
+ const courante = relectures.findLast(e => e.lot === lot);
92
+ if (!courante) {
93
+ return { action: 'demarrer' };
94
+ }
95
+ if (courante.fiche.verdict === 'ACCEPTÉ') {
96
+ return { action: 'accepte' };
97
+ }
98
+ const apres = relectures.findLastIndex(e => e.fiche.verdict === 'ACCEPTÉ') + 1;
99
+ const rendus = relectures.length - apres;
100
+ const constats = bloquantsDeLaFiche(courante.fiche);
101
+ return rendus >= RENDUS_MAX
102
+ ? { action: 'arreter', rendus, constats }
103
+ : { action: 'relancer', rendus, constats };
104
+ }
105
+
106
+ const RAISON_DU_VERROU = "copie d'un ticket direct : son lot n'est pas encore sur main";
107
+
108
+ /**
109
+ * Locks the copy <copie> against the cleaning of the circuit, which removes a copy identical to
110
+ * main (`git worktree lock`, <git> its runner); a copy already locked stays so.
111
+ * @param {string} copie
112
+ * @param {(...args: string[]) => { status: number, stdout: string, stderr: string }} git
113
+ */
114
+ export function verrouillerLaCopie(copie, git) {
115
+ const r = git('worktree', 'lock', '--reason', RAISON_DU_VERROU, copie);
116
+ if (r.status !== 0 && !/already locked/.test(r.stderr)) {
117
+ throw new Error(`la copie ${copie} ne se verrouille pas : ${r.stderr}`.trim());
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Unlocks the copy <copie> once its lot is on main (`git worktree unlock`).
123
+ * @param {string} copie
124
+ * @param {(...args: string[]) => { status: number, stdout: string, stderr: string }} git
125
+ */
126
+ export function deverrouillerLaCopie(copie, git) {
127
+ const r = git('worktree', 'unlock', copie);
128
+ if (r.status !== 0 && !/not locked/.test(r.stderr)) {
129
+ throw new Error(`la copie ${copie} ne se déverrouille pas : ${r.stderr}`.trim());
130
+ }
131
+ }
132
+
133
+ /**
134
+ * The command: the agent, then the reviewer, and it stops. <ports> are what it launches
135
+ * (`copie`, `verrouiller`, `fiches`, `lot`, `resoudre`, `seance`, `relecture`); <options> the paths
136
+ * `--paquet` adds to the plan.
137
+ * @param {{ id: string, ticket: { title?: string, labels?: string[] }, options?: string[], ports: any }} o
138
+ * @returns {Promise<{ verdict?: string, copie?: string, constats?: object[], arret?: boolean, statut?: string, rendus?: number, fiche?: object }>}
139
+ */
140
+ export async function lancerLeDirect({ id, ticket, options = [], ports }) {
141
+ if (!(ticket.labels ?? []).includes('direct')) {
142
+ throw new Error(
143
+ `Le ticket ${id} n'est pas étiqueté direct : la commande ne mène que les tickets de la voie directe (charte, « Un ticket prend l'une de trois voies »).`
144
+ );
145
+ }
146
+ const { plan } = planDuDirect({
147
+ id,
148
+ titre: ticket.title ?? '',
149
+ options,
150
+ resoudre: ports.resoudre,
151
+ });
152
+ const copie = ports.copie();
153
+ ports.verrouiller(copie);
154
+ const decision = decisionDuDirect(ports.fiches(), ports.lot());
155
+ if (decision.action === 'accepte') {
156
+ return { verdict: 'ACCEPTÉ', copie };
157
+ }
158
+ if (decision.action === 'arreter') {
159
+ return {
160
+ arret: true,
161
+ verdict: 'RENDU',
162
+ rendus: decision.rendus,
163
+ constats: decision.constats,
164
+ copie,
165
+ };
166
+ }
167
+ const constats = decision.constats ?? [];
168
+ // A direct holds a place of circuit of the machine, counted with the circuits, from its agent to
169
+ // its review; given back at the end, whatever the end.
170
+ const rendre = ports.place();
171
+ try {
172
+ const fiche = await ports.seance('direct', { constats, paquets: plan });
173
+ if (fiche?.statut && fiche.statut !== 'FAIT') {
174
+ return { arret: true, statut: fiche.statut, fiche, copie };
175
+ }
176
+ const relue = await ports.relecture({ constats });
177
+ return { verdict: relue.verdict, constats: relue.constats ?? [], fiche: relue.fiche, copie };
178
+ } finally {
179
+ rendre();
180
+ }
181
+ }
182
+
183
+ // The task the agent of a direct reads at the head of its instruction.
184
+ const TACHE_DU_DIRECT =
185
+ "Ce ticket est mené en direct, hors du circuit : tu écris ses tests et son code ensemble, dans les paquets de ton plan. Un défaut corrigé porte un test qui le reproduit. Aucune preuve du rouge ni aucun contrôle du circuit ne suit ta séance : un relecteur juge ton lot, puis le superviseur le vérifie. Les constats ci-dessous, s'il y en a, viennent de ce relecteur.";
186
+
187
+ // The ports of the command on the project at the working directory, the circuit's own sessions.
188
+ async function portsDuProjet(id, { contexteDuSuperviseur }) {
189
+ const { contexte } = await import('./circuit.mjs');
190
+ const { seance, idDeSeance } = await import('./seances.mjs');
191
+ const { arbreDeLaCopie, relire } = await import('./activites.mjs');
192
+ const { lesFiches } = await import('./ticket-du-circuit.mjs');
193
+ const ctx = contexte({ ticket: id, arreter: true, contexte: contexteDuSuperviseur });
194
+ const git = (...a) => spawnSync('git', ['-C', ctx.racine, ...a], { encoding: 'utf8' });
195
+ const ouverts = constats =>
196
+ constats.map(c => ({ titre: c.titre, regle: c.regle, role: 'direct', corps: c.corps, piece: c.piece }));
197
+ return {
198
+ ctx,
199
+ git,
200
+ ports: {
201
+ resoudre: ctx.resoudre,
202
+ copie: () => {
203
+ if (!existsSync(ctx.copie)) {
204
+ const branche = `agent/${id}`;
205
+ const existe = git('rev-parse', '--verify', '-q', `refs/heads/${branche}`).status === 0;
206
+ const r = existe
207
+ ? (git('branch', '-q', '-f', branche, 'HEAD'),
208
+ git('worktree', 'add', '-q', ctx.copie, branche))
209
+ : git('worktree', 'add', '-q', '-b', branche, ctx.copie, 'HEAD');
210
+ if (r.status !== 0) {
211
+ throw new Error(`la copie ${ctx.copie} ne se crée pas : ${r.stderr}`.trim());
212
+ }
213
+ }
214
+ return ctx.copie;
215
+ },
216
+ // The place of circuit the direct holds for its whole run: the sessions it launches then
217
+ // hold nothing more (GRILLHOUSE_PLACE_TENUE), as under any place already held.
218
+ place: () => {
219
+ const p = prendreUnePlace({
220
+ ticket: id,
221
+ racine: ctx.racine,
222
+ dire: l => process.stdout.write(`${l}\n`),
223
+ });
224
+ const avant = process.env[VARIABLE_TENUE];
225
+ if (p.id) {
226
+ process.env[VARIABLE_TENUE] = p.id;
227
+ }
228
+ return () => {
229
+ if (avant === undefined) {
230
+ delete process.env[VARIABLE_TENUE];
231
+ } else {
232
+ process.env[VARIABLE_TENUE] = avant;
233
+ }
234
+ p.rendre();
235
+ };
236
+ },
237
+ verrouiller: copie => verrouillerLaCopie(copie, git),
238
+ fiches: () =>
239
+ lesFiches(ctx).map(e => (e.role === 'relecteur' ? { ...e, lot: e.lot?.arbre } : e)),
240
+ lot: () => arbreDeLaCopie(ctx),
241
+ seance: async (_role, { constats, paquets }) => {
242
+ ctx.paquets = paquets;
243
+ ctx.contexte = ctx.contexteDuDirect;
244
+ const r = await seance(ctx, 'direct', {
245
+ tentative: 1,
246
+ derniere: true,
247
+ seanceId: idDeSeance(ctx, 'direct'),
248
+ evenement: 'neuve',
249
+ fiche: 'developpeur',
250
+ constats: ouverts(constats),
251
+ lectures: { lots: () => [], references: () => [] },
252
+ });
253
+ return r.fiche;
254
+ },
255
+ relecture: async ({ constats }) => {
256
+ ctx.contexte = '';
257
+ const r = await relire(ctx, {
258
+ constats,
259
+ consigneDuRelecteur: consigneDuRelecteurDuDirect,
260
+ });
261
+ return { verdict: r.verdict, fiche: r.fiche, constats: bloquantsDeLaFiche(r.fiche) };
262
+ },
263
+ },
264
+ };
265
+ }
266
+
267
+ // The command's options for <argv>: the ticket, the paths added to the plan, the context, and the
268
+ // unlocking; or a usage fault.
269
+ function lireLesOptions(argv) {
270
+ const o = { id: null, paquets: [], contexte: null, deverrouiller: false };
271
+ for (let i = 0; i < argv.length; i++) {
272
+ const a = argv[i];
273
+ if (a === '--paquet' || a === '--contexte') {
274
+ if (i + 1 >= argv.length) {
275
+ return null;
276
+ }
277
+ if (a === '--paquet') {
278
+ o.paquets.push(argv[++i]);
279
+ } else {
280
+ o.contexte = argv[++i];
281
+ }
282
+ } else if (a === '--deverrouiller') {
283
+ o.deverrouiller = true;
284
+ } else if (!a.startsWith('--') && !o.id) {
285
+ o.id = a;
286
+ } else {
287
+ return null;
288
+ }
289
+ }
290
+ return o.id ? o : null;
291
+ }
292
+
293
+ const USAGE =
294
+ 'usage : npx grillhouse direct <ticket> [--paquet <chemin>]… [--contexte <texte>] | npx grillhouse direct <ticket> --deverrouiller\n';
295
+
296
+ // The command on <argv>: its exit code.
297
+ async function commande(argv) {
298
+ const o = lireLesOptions(argv);
299
+ if (!o) {
300
+ process.stderr.write(USAGE);
301
+ return 2;
302
+ }
303
+ const { ctx, ports, git } = await portsDuProjet(o.id, { contexteDuSuperviseur: '' });
304
+ ctx.contexteDuDirect = o.contexte ? `${TACHE_DU_DIRECT}\n\n${o.contexte}` : TACHE_DU_DIRECT;
305
+ if (o.deverrouiller) {
306
+ deverrouillerLaCopie(ctx.copie, git);
307
+ process.stdout.write(`copie déverrouillée : ${ctx.copie}\n`);
308
+ return 0;
309
+ }
310
+ const show = ctx.bd('show', o.id, '--json');
311
+ if (show.status !== 0) {
312
+ process.stderr.write(`⛔ ticket ${o.id} illisible : ${show.stderr ?? ''}\n`);
313
+ return 2;
314
+ }
315
+ const r = await lancerLeDirect({
316
+ id: o.id,
317
+ ticket: JSON.parse(show.stdout || '[]')[0] ?? {},
318
+ options: o.paquets,
319
+ ports,
320
+ });
321
+ const constats = (r.constats ?? [])
322
+ .map(c => `- ${c.titre} : ${c.corps}${c.piece ? ` (${c.piece})` : ''}`)
323
+ .join('\n');
324
+ if (r.statut) {
325
+ process.stdout.write(
326
+ `L'agent du direct se déclare ${r.statut} : ${r.fiche.raison ?? r.fiche.question ?? ''}\ncopie : ${r.copie}\n`
327
+ );
328
+ return 3;
329
+ }
330
+ process.stdout.write(
331
+ `verdict : ${r.verdict}${r.arret ? ` (${r.rendus} RENDU de suite : l'arrêt monte au superviseur)` : ''}\ncopie : ${r.copie}\n${constats ? `constats bloquants :\n${constats}\n` : ''}`
332
+ );
333
+ return r.arret ? 3 : r.verdict === 'ACCEPTÉ' ? 0 : 1;
334
+ }
335
+
336
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
337
+ try {
338
+ process.exitCode = await commande(process.argv.slice(2));
339
+ } catch (e) {
340
+ process.stderr.write(`⛔ ${e.message}\n`);
341
+ process.exitCode = 2;
342
+ }
343
+ }
@@ -10,10 +10,12 @@
10
10
  //
11
11
  // prints the options of claude for that session, one per line (`optionsDuRole`):
12
12
  //
13
- // - `--setting-sources project,local`: the user's own configuration stays out (their CLAUDE.md,
14
- // their hooks, the skills of their account, their servers, their environment); the project's
15
- // settings and charter, and the frame's plugin it enables (agents, skills, common charter,
16
- // hooks), stay in.
13
+ // - `--setting-sources project,local`: the user's own configuration stays out (their hooks, the
14
+ // skills of their account, their servers, their environment); the project's settings and
15
+ // charter, and the frame's plugin it enables (agents, skills, common charter, hooks), stay in.
16
+ // Claude Code loads the user's charter (`~/.claude/CLAUDE.md`) whatever the sources, so the
17
+ // settings of the role exclude it by its path (`claudeMdExcludes`), and the envelope does not
18
+ // mount it.
17
19
  // - `--settings <json>` (the settings of the role, on the command line: no file the session could
18
20
  // change): its permissions (`allow`, the commands its skill names, and the reading of its
19
21
  // skill's files, references included, and of the METACADRE.md its skill names, in the frame's
@@ -188,6 +190,25 @@ export const ROLES = {
188
190
  ...LIRE_L_INDEX,
189
191
  ]),
190
192
  },
193
+ // The agent of a ticket led out of the circuit (`npx grillhouse direct`, scripts/direct.mjs): it
194
+ // writes the tests and the code of the whole ticket together, in the envelope of its plan, and
195
+ // reads the whole copy by the index. A role of its own: the developpeur keeps the rights of the
196
+ // circuit (no test file).
197
+ direct: {
198
+ ecrit: true,
199
+ index: true,
200
+ commandes: avecJumelles([
201
+ 'Bash(bd update * --claim)',
202
+ 'Bash(bd comments add *)',
203
+ 'Bash(git -C * status*)',
204
+ 'Bash(git -C * diff*)',
205
+ 'Bash(npm test *)',
206
+ 'Bash(npm run api*)',
207
+ // The removal of a file, by a script of its temporary directory.
208
+ 'Bash(node $TMPDIR/*)',
209
+ ...LIRE_L_INDEX,
210
+ ]),
211
+ },
191
212
  relecteur: {
192
213
  metacadre: true,
193
214
  index: true,
@@ -341,6 +362,7 @@ function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
341
362
  deny,
342
363
  },
343
364
  autoMemoryEnabled: false,
365
+ claudeMdExcludes: [path.join(home, '.claude', 'CLAUDE.md')],
344
366
  disableBundledSkills: true,
345
367
  skillOverrides: Object.fromEntries(autres.map(s => [s, 'off'])),
346
368
  enabledPlugins: Object.fromEntries(
@@ -14,7 +14,7 @@
14
14
  // - `commentaire` `{ ticket, texte, auteur }`: a comment at a ticket, by its author;
15
15
  // - `fiche` `{ entree }`: a line of the ticket's sheets (`<ticket>.fiches.jsonl`), dated;
16
16
  // - `decouverte` `{ role, sujet, corps, composants }`: a discovery filed closed under the ticket
17
- // (scripts/ticket.sh, label `decouverte`), then its line among the sheets (`{ id, sujet }`);
17
+ // (scripts/ticket.mjs, label `decouverte`), then its line among the sheets (`{ id, sujet }`);
18
18
  // - `registre` `{ ligne }`: a line of the register of the steps (scripts/registre.mjs);
19
19
  // - `trace` `{ ligne }`: a line of the journal of states (scripts/journal-des-etats.mjs), whose
20
20
  // failure is said once and never stops the circuit;
@@ -65,7 +65,7 @@ export const AVEC_CLE = new Set([
65
65
  export const ACTEUR = 'BEADS_ACTOR';
66
66
  export { AUTEUR_DU_CIRCUIT };
67
67
  export const PREFIXE = 'Circuit · ';
68
- const TICKET_SH = path.join(import.meta.dirname, 'ticket.sh');
68
+ const TICKET = path.join(import.meta.dirname, 'ticket.mjs');
69
69
 
70
70
  const ok = { status: 0, stdout: '', stderr: '' };
71
71
  // A failure of a player, as bd answers one.
@@ -189,9 +189,9 @@ const JOUEURS = {
189
189
  }
190
190
  if (!id) {
191
191
  const r = spawnSync(
192
- 'bash',
192
+ process.execPath,
193
193
  [
194
- TICKET_SH,
194
+ TICKET,
195
195
  ctx.ticket,
196
196
  sujet,
197
197
  composants,
@@ -271,7 +271,8 @@ export const touchesPar = (engendres, fichiers) =>
271
271
  * Plays the command of each of <refs>, in order (`lancer`, which runs a line of the shell at the
272
272
  * root of the tree and gives the result of spawnSync), then stages every file they changed (`dansCopie`, git in the
273
273
  * tree, its strings in UTF-8). Null, or the refusal (see the header). The output of a command that
274
- * passes goes to <ecrire>.
274
+ * passes goes to <ecrire>, the standard output by default: a caller whose standard output is read
275
+ * as data gives its own (scripts/enveloppe/travail-de-la-copie.mjs).
275
276
  * @param {{ refs: { nom: string, commande: string, fichiers: string[], cadre?: boolean }[], lancer: (commande: string) => import('node:child_process').SpawnSyncReturns<string>, dansCopie: (...args: string[]) => import('node:child_process').SpawnSyncReturns<string>, ecrire?: (s: string) => void }} o
276
277
  * @returns {string | null}
277
278
  */