@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
@@ -10,11 +10,15 @@
10
10
  // prints the options of claude for that session, one per line (`optionsDuRole`):
11
11
  //
12
12
  // - `--setting-sources project,local`: the user's own configuration stays out (their hooks, the
13
- // skills of their account, their servers, their environment); the project's settings and
13
+ // skills of their account, their servers, their environment; of their settings, the settings of
14
+ // the role carry the output style alone, below); the project's settings and
14
15
  // charter, and the frame's plugin it enables (agents, skills, common charter, hooks), stay in.
15
16
  // Claude Code loads the user's charter (`~/.claude/CLAUDE.md`) whatever the sources, so the
16
17
  // settings of the role exclude it by its path (`claudeMdExcludes`), and the envelope does not
17
- // mount it.
18
+ // mount it. The common charter is cut by public: its core, `charte.md`, which each session loads,
19
+ // imports one module per public (`charte/<module>.md`, MODULES_DE_LA_CHARTE); the settings of the
20
+ // role exclude each module the role does not apply (`modules`, ROLES) by the same key, wherever
21
+ // the charter is read, the package installed or the frame's source.
18
22
  // - `--settings <json>` (the settings of the role, on the command line: no file the session could
19
23
  // change): its permissions (`allow`, every command of `Bash`, the tools of the index for a role
20
24
  // that uses it, and the reading of its skill's files, references included, of those of the
@@ -24,15 +28,23 @@
24
28
  // for a role whose instruction carries its ticket the reading of it again, for a role that
25
29
  // writes the test tool run directly, and for a role that writes nothing at the ticket every write
26
30
  // of bd, ECRIRE_AU_TICKET); no hook; the
27
- // automatic memory off; the skills of Claude Code off (`disableBundledSkills`, and the few it keeps,
28
- // INTEGREES), and the project's own skills (`.claude/skills/` of the copy) off
29
- // (`skillOverrides`); every plugin the project enables off (`enabledPlugins`: their skills,
30
- // hooks and servers are not the role's), save the frame's (`grillhouse@…`), which carries the
31
- // role's agent, its skills and the frame's hooks: Claude Code applies no `skillOverrides` to the
32
- // skills of a plugin, and the role's agent preloads its own (`skills` of its definition);
33
- // the background tasks off and Code Mode on (`env`, ENV_DES_SEANCES: a role waits in the
31
+ // automatic memory off; the skills of Claude Code off (`disableBundledSkills`); every plugin the
32
+ // project enables off (`enabledPlugins`: their skills, hooks and servers are not the role's),
33
+ // save the frame's (`grillhouse@…`), which carries the role's agent, its skills and the frame's
34
+ // hooks; the background tasks off and Code Mode on (`env`, ENV_DES_SEANCES: a role waits in the
34
35
  // foreground for what it launches, and its session ends with its sheet; `claude -p` gets Code
35
- // Mode, the REPL, only from this block).
36
+ // Mode, the REPL, only from this block), and, in the same block, the prompt cache forced to five
37
+ // minutes for a role that takes it (`cacheCinqMinutes`, ROLES; CINQ_MINUTES_DE_CACHE); no line of
38
+ // attribution of commit or pull request
39
+ // (`attribution`, both empty, whatever the project and the user choose: a role commits nothing);
40
+ // the output style the user chooses (`outputStyle` of `<home>/.claude/settings.json`), left out
41
+ // when they choose none, and when a settings file of the project chooses one (`settings.json`
42
+ // of the copy, `settings.local.json` of the main tree or of the copy), which the command line
43
+ // would override. The name of the style alone goes: a style the session cannot resolve (a file
44
+ // of `~/.claude/output-styles`, a plugin it does not load) does not apply.
45
+ // - The skills the session lists and may load are no option: they go on its standard input
46
+ // (`competencesDuRole`, scripts/entree-de-seance.mjs), the one list no setting can bound for the
47
+ // skills of a plugin.
36
48
  // - `--tools <list>`: the tools its work uses; Edit and Write for a role that writes alone, the
37
49
  // tool search for a role whose index Claude Code defers.
38
50
  // - `--strict-mcp-config --mcp-config <json>`: the servers of the index (codegraph, rtfm) for a
@@ -40,7 +52,7 @@
40
52
  // enables, at their installed path (`~/.claude/plugins/installed_plugins.json`, the project's
41
53
  // entry first, else the user's); a project's entry whose command is the bare name of the program
42
54
  // a plugin ships runs that program; none for the others.
43
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
55
+ import { readFileSync } from 'node:fs';
44
56
  import os from 'node:os';
45
57
  import path from 'node:path';
46
58
  import { pathToFileURL } from 'node:url';
@@ -77,10 +89,14 @@ const ENV_DES_SEANCES = {
77
89
  CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: '1',
78
90
  CLAUDE_CODE_EXPERIMENTAL_CODE_MODE: '1',
79
91
  };
92
+ // The variable the env block adds for a role whose prompt cache lasts five minutes
93
+ // (`cacheCinqMinutes`, ROLES): the explorateur, the questionneur, the testwriter and the relecteur,
94
+ // whose turns mostly follow each other within five minutes, and a cache write kept five minutes
95
+ // costs 1.25 times an input, against 2 times for one hour. The developpeur and the direct often
96
+ // wait longer (tests, builds) and would lose by it (simulated: developpeur −3.6 %, direct
97
+ // −11.9 %): they keep Claude Code's default, one hour on the subscription.
98
+ const CINQ_MINUTES_DE_CACHE = { FORCE_PROMPT_CACHING_5M: '1' };
80
99
 
81
- // The skills Claude Code keeps listed when its own are off (`disableBundledSkills`), measured on
82
- // Claude Code 2.1.305.
83
- const INTEGREES = ['design', 'doctor', 'plugin-authoring'];
84
100
  // The frame's plugin, by the start of its identifier (`grillhouse@<place de marché>`).
85
101
  const GREFFON_DU_CADRE = 'grillhouse@';
86
102
  // The servers of the index (charter, « L'index d'abord »), and their tools of reading: codegraph
@@ -101,24 +117,38 @@ const ECRIRE = ['Edit', 'Write'];
101
117
  const TOUTE_COMMANDE = ['Bash'];
102
118
  const TOUTE_COMMANDE_ET_L_INDEX = [...TOUTE_COMMANDE, ...LIRE_L_INDEX];
103
119
 
104
- // Each role the circuit launches: whether it writes (files, `ecrit`; the ticket, unless
120
+ // The modules of the common charter (`charte/<module>.md`, beside `charte.md`), and the folders
121
+ // that hold the charter: the package installed in a project, the frame's source in its repository.
122
+ const MODULES_DE_LA_CHARTE = ['superviseur', 'plan', 'preuve', 'tests'];
123
+ const DOSSIERS_DE_LA_CHARTE = ['node_modules/@roomi-fields/grillhouse', 'mods/grillhouse'];
124
+
125
+ // Each role the circuit launches: the modules of the common charter it applies (`modules`; the
126
+ // supervisor's is no role's), whether it writes (files, `ecrit`; the ticket, unless
105
127
  // `ecritAuTicket` is false), whether its instruction carries its ticket (`porteSonTicket`),
106
- // whether it uses the index, the rules of its commands (`commandes`), whether its skill names the frame's METACADRE.md (`metacadre`, read
107
- // at the root of the plugin installed), and whether its skill loads the debugging skill of the
108
- // plugin (`debogage`, read with its neighbouring files).
128
+ // whether it uses the index, the rules of its commands (`commandes`), whether its skill names the
129
+ // frame's METACADRE.md (`metacadre`, read at the root of the plugin installed), whether its skill
130
+ // loads the debugging skill of the plugin (`debogage`, read with its neighbouring files), the other
131
+ // skills of the plugin its skill or the common charter ask it to load (`competences`), and whether
132
+ // its prompt cache lasts five minutes (`cacheCinqMinutes`).
109
133
  export const ROLES = {
110
134
  // It writes no file and nothing at the ticket: it surveys the components and reads the code by
111
135
  // the index, and ends on the plan in its sheet, which the circuit writes at the ticket.
112
136
  explorateur: {
137
+ cacheCinqMinutes: true,
138
+ modules: ['plan', 'preuve'],
113
139
  metacadre: true,
114
140
  debogage: true,
141
+ competences: ['mesure'],
115
142
  index: true,
116
143
  ecritAuTicket: false,
117
144
  commandes: TOUTE_COMMANDE_ET_L_INDEX,
118
145
  },
119
146
  // It writes the tests of the whole ticket, in the envelope of its plan.
120
147
  testwriter: {
148
+ cacheCinqMinutes: true,
149
+ modules: ['preuve', 'tests'],
121
150
  metacadre: true,
151
+ competences: ['mesure'],
122
152
  ecrit: true,
123
153
  index: true,
124
154
  porteSonTicket: true,
@@ -126,23 +156,29 @@ export const ROLES = {
126
156
  },
127
157
  // It writes the code of the whole ticket, in the envelope of its plan.
128
158
  developpeur: {
159
+ modules: [],
129
160
  metacadre: true,
130
161
  debogage: true,
162
+ competences: ['mesure', 'redacteur', 'writing-for-agents'],
131
163
  ecrit: true,
132
164
  index: true,
133
165
  porteSonTicket: true,
134
166
  commandes: TOUTE_COMMANDE_ET_L_INDEX,
135
167
  },
136
- // The agent of a ticket led out of the circuit (`npx grillhouse direct`, scripts/direct.mjs): it
137
- // writes the tests and the code of the whole ticket together, in the envelope of its plan.
168
+ // The agent of a direct ticket, in its circuit or on the way of rescue (`npx grillhouse direct`,
169
+ // scripts/direct.mjs): it writes the tests and the code of the whole ticket together, in the envelope of its plan.
138
170
  direct: {
171
+ modules: ['preuve', 'tests'],
139
172
  debogage: true,
173
+ competences: ['mesure', 'redacteur', 'writing-for-agents'],
140
174
  ecrit: true,
141
175
  index: true,
142
176
  porteSonTicket: true,
143
177
  commandes: TOUTE_COMMANDE_ET_L_INDEX,
144
178
  },
145
179
  relecteur: {
180
+ cacheCinqMinutes: true,
181
+ modules: ['plan', 'preuve', 'tests'],
146
182
  metacadre: true,
147
183
  index: true,
148
184
  ecritAuTicket: false,
@@ -151,9 +187,34 @@ export const ROLES = {
151
187
  },
152
188
  // It asks, and decides nothing: it reads the proposal its instruction carries and the code by
153
189
  // the index; the circuit writes its questions at the ticket.
154
- questionneur: { index: true, ecritAuTicket: false, commandes: TOUTE_COMMANDE_ET_L_INDEX },
190
+ questionneur: {
191
+ cacheCinqMinutes: true,
192
+ modules: ['plan', 'preuve'],
193
+ index: true,
194
+ ecritAuTicket: false,
195
+ commandes: TOUTE_COMMANDE_ET_L_INDEX,
196
+ },
155
197
  };
156
198
 
199
+ // The skills of the plugin <role> loads: its own, then the debugging skill for a role that debugs.
200
+ const competencesDeTravail = role => [
201
+ role,
202
+ ...(ROLES[role].debogage ? ['systematic-debugging'] : []),
203
+ ];
204
+
205
+ /**
206
+ * The skills a session of `role` lists and may load, qualified by the frame's plugin: its own, the
207
+ * debugging skill for a role that debugs, and those its skill and the common charter ask of it.
208
+ */
209
+ export function competencesDuRole(role) {
210
+ if (!ROLES[role]) {
211
+ throw new Error(`rôle sans droits : ${role}`);
212
+ }
213
+ return [...competencesDeTravail(role), ...(ROLES[role].competences ?? [])].map(
214
+ c => `grillhouse:${c}`
215
+ );
216
+ }
217
+
157
218
  const lireJson = f => {
158
219
  try {
159
220
  return JSON.parse(readFileSync(f, 'utf8'));
@@ -201,9 +262,8 @@ function lireSaCompetence(role, { racine, copie, home }) {
201
262
  if (!dossier) {
202
263
  return [];
203
264
  }
204
- const competences = [role, ...(ROLES[role].debogage ? ['systematic-debugging'] : [])];
205
265
  return [
206
- ...competences.map(c => `Read(/${path.join(dossier, 'skills', c)}/**)`),
266
+ ...competencesDeTravail(role).map(c => `Read(/${path.join(dossier, 'skills', c)}/**)`),
207
267
  ...(ROLES[role].metacadre ? [`Read(/${path.join(dossier, 'METACADRE.md')})`] : []),
208
268
  ];
209
269
  }
@@ -246,8 +306,35 @@ function serveursDeLIndex(racine, home) {
246
306
  return out;
247
307
  }
248
308
 
249
- // The settings of the session of <role>, for the ticket <ticket>, its copy <copie> (where the
250
- // project's own skills are read) and the main tree <racine>; <home> holds the plugins installed.
309
+ // The output style of the session, as the settings to add: the one the user chooses in <home>,
310
+ // none when a settings file of the project that the session reads chooses one (in a copy, Claude
311
+ // Code reads `settings.json` there, and `settings.local.json` at the main tree and there).
312
+ function styleDuPoste({ racine, copie, home }) {
313
+ const style = (base, f) => lireJson(path.join(base, '.claude', f))?.outputStyle;
314
+ const duProjet = [
315
+ style(copie, 'settings.json'),
316
+ style(racine, 'settings.local.json'),
317
+ style(copie, 'settings.local.json'),
318
+ ].some(s => s !== undefined);
319
+ const duPoste = style(home, 'settings.json');
320
+ return duPoste && !duProjet ? { outputStyle: duPoste } : {};
321
+ }
322
+
323
+ // What the session of the role <r> does not load of the charters: the user's own, by its path, and
324
+ // each module of the common charter the role does not apply, by a pattern that Claude Code matches
325
+ // against the absolute path of each file it loads, an imported one too.
326
+ function chartesExclues(r, home) {
327
+ return [
328
+ path.join(home, '.claude', 'CLAUDE.md'),
329
+ ...MODULES_DE_LA_CHARTE.filter(m => !r.modules.includes(m)).flatMap(m =>
330
+ DOSSIERS_DE_LA_CHARTE.map(d => `**/${d}/charte/${m}.md`)
331
+ ),
332
+ ];
333
+ }
334
+
335
+ // The settings of the session of <role>, for the ticket <ticket>, its copy <copie> (whose
336
+ // language names the test tool, and whose settings may choose the output style) and the main tree
337
+ // <racine>; <home> holds the plugins installed and the settings of the user.
251
338
  function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
252
339
  const r = ROLES[role];
253
340
  if (!r) {
@@ -265,35 +352,27 @@ function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
265
352
  deny.push(`Bash(bd ${lecture} ${ticket})`, `Bash(bd ${lecture} ${ticket} *)`);
266
353
  }
267
354
  }
268
- const propres = path.join(copie, '.claude', 'skills');
269
- const autres = [
270
- ...INTEGREES,
271
- ...(existsSync(propres)
272
- ? readdirSync(propres, { withFileTypes: true })
273
- .filter(d => d.isDirectory())
274
- .map(d => d.name)
275
- : []),
276
- ];
277
355
  return {
278
356
  permissions: {
279
357
  allow: [...r.commandes, ...lireSaCompetence(role, { racine, copie, home })],
280
358
  deny,
281
359
  },
282
360
  autoMemoryEnabled: false,
283
- claudeMdExcludes: [path.join(home, '.claude', 'CLAUDE.md')],
361
+ claudeMdExcludes: chartesExclues(r, home),
284
362
  disableBundledSkills: true,
285
- skillOverrides: Object.fromEntries(autres.map(s => [s, 'off'])),
286
363
  enabledPlugins: Object.fromEntries(
287
364
  greffonsDuProjet(racine)
288
365
  .filter(g => !g.startsWith(GREFFON_DU_CADRE))
289
366
  .map(g => [g, false])
290
367
  ),
291
- env: ENV_DES_SEANCES,
368
+ env: { ...ENV_DES_SEANCES, ...(r.cacheCinqMinutes ? CINQ_MINUTES_DE_CACHE : {}) },
369
+ attribution: { commit: '', pr: '' },
370
+ ...styleDuPoste({ racine, copie, home }),
292
371
  };
293
372
  }
294
373
 
295
374
  // The options of claude for the session of <role> (the header's list); <home> holds the plugins
296
- // installed.
375
+ // installed and the settings of the user.
297
376
  export function optionsDuRole(role, contexte) {
298
377
  const { racine, home = os.homedir() } = contexte;
299
378
  const r = ROLES[role];
@@ -204,11 +204,12 @@ export const aRejouer = (engendres, arbre, fichiers) =>
204
204
  * Applies to the tree of <dansCopie> (git in the tree) the files <fichiers> of the lots <lots>
205
205
  * (patch files) that an earlier application left out, those of a generated file the lots remove
206
206
  * from the key: a deletion is done whatever main's version is, any other change is applied three
207
- * ways, to the index too. Null, or the refusal.
208
- * @param {{ lots: string[], fichiers: string[], dansCopie: (...args: string[]) => import('node:child_process').SpawnSyncReturns<string> }} o
207
+ * ways, to the index too. Null, or the refusal; `surNonApplique` is called when the refusal is a
208
+ * lot that does not apply.
209
+ * @param {{ lots: string[], fichiers: string[], dansCopie: (...args: string[]) => import('node:child_process').SpawnSyncReturns<string>, surNonApplique?: () => void }} o
209
210
  * @returns {string | null}
210
211
  */
211
- export function poserLesRetires({ lots, fichiers, dansCopie }) {
212
+ export function poserLesRetires({ lots, fichiers, dansCopie, surNonApplique }) {
212
213
  if (!fichiers.length) {
213
214
  return null;
214
215
  }
@@ -228,6 +229,7 @@ export function poserLesRetires({ lots, fichiers, dansCopie }) {
228
229
  if (restent.length) {
229
230
  const r = dansCopie('apply', '--3way', '--index', '--allow-empty', ...restent, p);
230
231
  if (r.status !== 0) {
232
+ surNonApplique?.();
231
233
  return `Le lot ${p} ne s'applique pas :\n${r.stdout}${r.stderr}`;
232
234
  }
233
235
  }
@@ -0,0 +1,35 @@
1
+ // The standard input of a role session, which both launchers compose here (scripts/seances.mjs
2
+ // out of the envelope, scripts/enveloppe/lancer.sh in it), as claude reads it under
3
+ // `--input-format stream-json`: the `initialize` request, whose `skills` bound the skills the
4
+ // session lists and may load by the tool Skill, then the whole instruction as one message of the
5
+ // user, one line of JSON each. No setting of `--settings` takes a skill of a plugin out of that
6
+ // list; the field `skills` is in the protocol of the Agent SDK, absent from `claude --help`, and
7
+ // the night holds it (packages/grillhouse-essais/tests/competences-de-seance.nuit.spec.ts).
8
+ // Architecture: docs/architecture/machine.md (§3.2).
9
+ //
10
+ // node entree-de-seance.mjs <rôle> < <consigne>
11
+ //
12
+ // writes the input of a session of <rôle> that carries the instruction, with the skills of the role
13
+ // (`competencesDuRole` of scripts/droits.mjs).
14
+ import { randomUUID } from 'node:crypto';
15
+ import { readFileSync } from 'node:fs';
16
+ import { pathToFileURL } from 'node:url';
17
+ import { competencesDuRole } from './droits.mjs';
18
+
19
+ /** The input of a session that lists the skills `competences` and receives `consigne`. */
20
+ export function entreeDeSeance({ competences, consigne }) {
21
+ const messages = [
22
+ {
23
+ type: 'control_request',
24
+ request_id: randomUUID(),
25
+ request: { subtype: 'initialize', skills: competences },
26
+ },
27
+ { type: 'user', message: { role: 'user', content: consigne }, parent_tool_use_id: null },
28
+ ];
29
+ return messages.map(m => `${JSON.stringify(m)}\n`).join('');
30
+ }
31
+
32
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
33
+ const competences = competencesDuRole(process.argv[2]);
34
+ process.stdout.write(entreeDeSeance({ competences, consigne: readFileSync(0, 'utf8') }));
35
+ }
@@ -16,15 +16,15 @@
16
16
  // copy. Every `.git`, the copy's included, stays read-only: the agent delivers a patch
17
17
  // (`git diff`, and `git diff --no-index /dev/null <file>` for a new file); it never commits.
18
18
  // - Where the tools of the project's language write is what its module declares (`sorties`,
19
- // scripts/jointure.d.ts; `sortiesDuLangage`): its stores, in the main tree (`//…`, TypeScript's
20
- // cache of Turborepo, shared by every copy) or in the home (`~/…`, cargo's registry, git
21
- // dependencies, advisories and the lock and cache files at the root of `~/.cargo`), are
22
- // written; what its tools read (`~/.cargo` with its `env`, its configuration and its binaries,
23
- // and `~/.rustup`) comes back read-only under them; its outputs in the copy (cargo's `target`)
24
- // come back in writing; its outputs proper to the session (TypeScript's `.turbo` and
25
- // `.cache-outils`, the cache of Vite) are empty and proper to it. Each written path is created
26
- // on disk before the session, a directory or, without a trailing `/` in the module's list, an
27
- // empty file, so that bwrap mounts it.
19
+ // scripts/jointure.d.ts), with what the core declares of Turborepo for every language
20
+ // (`sortiesDuLangage`): the stores, in the main tree (`//…`, the cache of Turborepo, shared by
21
+ // every copy) or in the home (`~/…`, cargo's registry, git dependencies, advisories and the lock
22
+ // and cache files at the root of `~/.cargo`), are written; what the tools read (`~/.cargo` with
23
+ // its `env`, its configuration and its binaries, and `~/.rustup`) comes back read-only under
24
+ // them; the outputs in the copy (cargo's `target`) come back in writing; the outputs proper to
25
+ // the session (Turborepo's `.turbo`, TypeScript's `.cache-outils`, the cache of Vite) are empty
26
+ // and proper to it. Each written path is created on disk before the session, a directory or,
27
+ // without a trailing `/` in the list, an empty file, so that bwrap mounts it.
28
28
  // - The home and the session directories (`$XDG_RUNTIME_DIR`, `/run/user/<uid>`) start empty and
29
29
  // sealed read-only; the home gets back `~/.claude`, `~/.claude.json`, the npm cache, the paths
30
30
  // of `MAISON_EN_LECTURE` (claude, node, git and the session's tools) and the repository. No
@@ -535,10 +535,16 @@ const lienSurDisque = p => {
535
535
  }
536
536
  };
537
537
 
538
+ // Where Turborepo writes, the task runner every language of the frame plays by, declared once by
539
+ // the core for every module: its cache in the main tree, shared by every copy, written; and
540
+ // `.turbo`, the logs of its tasks (`.turbo/turbo-<task>.log`, written on every run, a task replayed
541
+ // from its cache included, and which no option of Turborepo sends elsewhere), proper to the session.
542
+ const SORTIES_DE_TURBOREPO = { ecrites: ['//.turbo/cache/'], propres: ['.turbo'] };
543
+
538
544
  /**
539
- * The outputs <s> of the module of the language (its `sorties`, scripts/jointure.d.ts) for a
540
- * session whose home is <maison> and whose main tree is <principal>: `lectures`, what its tools
541
- * read, absolute (`~/…` from the home, `//…` from the main tree), mounted read-only;
545
+ * The outputs <s> of the module of the language (its `sorties`, scripts/jointure.d.ts), with
546
+ * Turborepo's (`SORTIES_DE_TURBOREPO`), for a session whose home is <maison> and whose main tree
547
+ * is <principal>: `lectures`, what its tools read, absolute (`~/…` from the home, `//…` from the main tree), mounted read-only;
542
548
  * `magasins`, the stores written, absolute, mounted after them; `sorties`, what the copy holds,
543
549
  * from its root: `ecrites` in writing, `propres` proper to the session; `fichiers`, the written
544
550
  * paths of `magasins` and `sorties.ecrites` that are files (written without a trailing `/`), which
@@ -563,7 +569,7 @@ export function sortiesDuLangage(s, { maison, principal }) {
563
569
  const ecrites = [];
564
570
  /** @type {string[]} */
565
571
  const fichiers = [];
566
- for (const e of s.ecrites) {
572
+ for (const e of [...SORTIES_DE_TURBOREPO.ecrites, ...s.ecrites]) {
567
573
  const a = absolu(e);
568
574
  const p = a === null ? nu(e) : nu(a);
569
575
  if (a === null) {
@@ -576,7 +582,8 @@ export function sortiesDuLangage(s, { maison, principal }) {
576
582
  }
577
583
  }
578
584
  const lectures = s.lues.map(absolu).flatMap(a => (a === null ? [] : [nu(a)]));
579
- return { magasins, lectures, fichiers, sorties: { ecrites, propres: [...s.propres] } };
585
+ const propres = [...new Set([...SORTIES_DE_TURBOREPO.propres, ...s.propres])];
586
+ return { magasins, lectures, fichiers, sorties: { ecrites, propres } };
580
587
  }
581
588
 
582
589
  // Creates the directory, or the empty file when <fichier>, <chemin>, when it is absent.
@@ -639,8 +646,8 @@ export function jugerComposant({ depot, composant, paquets = [], neuf = false },
639
646
  // copy (`matieres` of the module of the language); `role` is the agent's role, and only the
640
647
  // `testwriter` writes them, and the lock files of the versions `verrous`, from the root of the copy.
641
648
  // `magasins` lists the stores written by every run, the agent's included
642
- // (the module's, `sortiesDuLangage`: Turborepo's `<main tree>/.turbo/cache`, cargo's registry,
643
- // git dependencies, advisories and lock files in the home); one that does not exist is not
649
+ // (`sortiesDuLangage`: Turborepo's `<main tree>/.turbo/cache`, and the module's, as cargo's
650
+ // registry, git dependencies, advisories and lock files in the home); one that does not exist is not
644
651
  // mounted. `lectures` lists what the language's tools read (cargo's home, rustup's toolchains),
645
652
  // mounted read-only before the stores, which come back in writing inside it; one that does not
646
653
  // exist is not mounted. `sorties` lists, from the root of the copy,
@@ -73,9 +73,11 @@
73
73
  # refused), the launch stops, CODE_COPIE, before any command runs. In the envelope the main
74
74
  # repository is read-only as a whole.
75
75
  # - The envelope receives the role: it decides who writes the package of the shared test material.
76
- # - The session runs `claude -p` with the role's agent and, as its prompt, read on its standard
77
- # input from a temporary file the launcher writes and removes (an argument may not pass the
78
- # 128 KiB Linux allows one, MAX_ARG_STRLEN), the instruction file
76
+ # - The session runs `claude -p` with the role's agent, in stream-json both ways
77
+ # (`--input-format stream-json --output-format stream-json --verbose`). Its standard input,
78
+ # read from a temporary file the launcher writes and removes (an argument may not pass the
79
+ # 128 KiB Linux allows one, MAX_ARG_STRLEN), is composed by scripts/entree-de-seance.mjs: the
80
+ # skills of the role, then as its prompt, in one message of the user, the instruction file
79
81
  # followed by the section « Ce que les composants d'avant publient », for each package of the
80
82
  # plan (one part per package when the plan holds several): for each
81
83
  # component whose `## Consommateurs` section names the package, its line, the names of the
@@ -103,13 +105,15 @@
103
105
  # comments carry the author the launch names in BEADS_ACTOR, which the envelope passes on), its
104
106
  # tools and the servers of the index, for the reading of the whole copy.
105
107
  # - A role that ends on a sheet (scripts/resultats.mjs: the testwriter, the developpeur) runs with
106
- # `--output-format json --json-schema <its schema>` (`npx grillhouse resultats --schema
107
- # <rôle>`); --fiche <sorte> names the schema of a sheet that is not its role's (`geste`, the
108
- # explorateur's gesture of a mechanical ticket), taking a value as --modele does:
109
- # claude's JSON result, its sheet in `structured_output`, goes to `resultat.json` in the folder
108
+ # `--json-schema <its schema>` (`npx grillhouse resultats --schema <rôle>`); --fiche <sorte>
109
+ # names the schema of a sheet that is not its role's (`geste`, the explorateur's gesture of a
110
+ # mechanical ticket), taking a value as --modele does.
111
+ # - Once claude ends, its output stream is sorted (scripts/sortie-de-seance.mjs): the line
112
+ # `type: result`, its sheet in `structured_output`, goes to `resultat.json` in the folder
110
113
  # of the session (.claude/worktrees/<ticket>.travail/seances/<id>/, <id> the session's
111
114
  # --seance or --reprise, `courante` without one), which a launch removes first and the circuit
112
- # reads, then to the log; its errors go to the log.
115
+ # reads; the log takes that line, the lines that are no message of the stream and, without a
116
+ # result, the text of the last assistant message; its errors go to the log.
113
117
  # - Its output, and an envelope refusal (CODE_REFUS), are added to .claude/worktrees/<ticket>.log,
114
118
  # the log of the ticket, which keeps every session of the ticket: each launch past the checks of
115
119
  # its call adds a header line, `=== <time> · <rôle> · <composant> ===`, then its preparation and
@@ -282,8 +286,8 @@ if [ -s "$echec" ]; then
282
286
  construction=$'\n\n'"## La construction échoue"$'\n\n'"$(head -n 1 "$echec") La réparer fait partie de ta tâche. La fin de sa sortie :"$'\n\n```\n'"$(tail -n +2 "$echec" | tail -n 100)"$'\n```'
283
287
  fi
284
288
  rm -f "$echec"
285
- # The prompt, assembled in a file: claude reads it on its standard input, since as an argument it
286
- # may pass the size Linux allows one (MAX_ARG_STRLEN, 128 KiB).
289
+ # The prompt, assembled in a file: it may pass the size Linux allows one argument (MAX_ARG_STRLEN,
290
+ # 128 KiB), and claude reads it on its standard input, in the input composed below.
287
291
  # A resumed session holds the sections of its first instruction: its new working directory and a
288
292
  # failed build alone are news.
289
293
  prompt=$(mktemp -p "$base_du_lanceur")
@@ -293,36 +297,42 @@ else
293
297
  printf '%s' "$(cat "$consigne")"$'\n\n'"$publie$dossier$construction" > "$prompt"
294
298
  fi
295
299
 
300
+ # The input of the session: the skills of its role, then the prompt (scripts/entree-de-seance.mjs).
301
+ entree=$(mktemp -p "$base_du_lanceur")
302
+ node "$ici/../entree-de-seance.mjs" "$role" < "$prompt" > "$entree" 2>> "$journal" \
303
+ || { rm -f "$prompt" "$entree"; echo "⛔ L'entrée de la séance n'a pas pu se composer : voir $journal." >&2; exit "$CODE_COPIE"; }
304
+ rm -f "$prompt"
305
+
296
306
  # The rights and the context of the role's session (scripts/droits.mjs), one option per line.
297
307
  droits=$(node "$ici/../droits.mjs" "$role" --racine "$racine" --copie "$copie" --ticket "$ticket" 2>> "$journal") \
298
- || { rm -f "$prompt"; echo "⛔ Les droits de la séance n'ont pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
308
+ || { rm -f "$entree"; echo "⛔ Les droits de la séance n'ont pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
299
309
  mapfile -t droits_du_role <<<"$droits"
300
310
 
301
311
  # The schema of the role's end-of-session sheet (scripts/resultats.mjs), for a role that has one:
302
- # the session ends on it, which claude writes in its JSON result, on the standard output.
312
+ # the session ends on it, which claude writes in the result line of its stream.
303
313
  fiche=()
304
314
  schema=$(node "$ici/../resultats.mjs" --schema "${sorte:-$role}" 2> /dev/null) || schema=
305
- [ -z "$schema" ] || fiche=(--output-format json --json-schema "$schema")
315
+ [ -z "$schema" ] || fiche=(--json-schema "$schema")
306
316
 
307
317
  # The state of the prepared copy, which the session's lot is read from.
308
318
  node "$ici/travail-de-la-copie.mjs" photographier "$copie" > "$avant" 2>> "$journal" \
309
- || { rm -f "$prompt" "$avant"; echo "⛔ L'état de la copie avant la séance n'a pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
319
+ || { rm -f "$entree" "$avant"; echo "⛔ L'état de la copie avant la séance n'a pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
310
320
 
311
321
  # An envelope in error does not stop the launcher (set -e): its code is kept for the exit.
312
322
  code=0
313
323
  lancer_claude() {
314
324
  node "$ici/enveloppe.mjs" "$copie" "$paquets" "$role" -- \
315
325
  "${CLAUDE_BIN:-claude}" -p --agent "$role" \
326
+ --input-format stream-json --output-format stream-json --verbose \
316
327
  ${surcharge[@]+"${surcharge[@]}"} ${fiche[@]+"${fiche[@]}"} --permission-mode bypassPermissions \
317
- "${droits_du_role[@]}" < "$prompt"
328
+ "${droits_du_role[@]}" < "$entree"
318
329
  }
319
- if [ -n "$schema" ]; then
320
- lancer_claude > "$resultat" 2>> "$journal" || code=$?
321
- { cat "$resultat"; echo; } >> "$journal"
322
- else
323
- lancer_claude >> "$journal" 2>&1 || code=$?
324
- fi
325
- rm -f "$prompt"
330
+ # The stream of the session, beside its temporary directory, sorted once claude ends: its result
331
+ # to its folder, the rest of what the log takes to the log.
332
+ flux="$base_du_lanceur/flux"
333
+ lancer_claude > "$flux" 2>> "$journal" || code=$?
334
+ node "$ici/../sortie-de-seance.mjs" "$flux" "$resultat" >> "$journal" 2>&1 || true
335
+ rm -f "$entree" "$flux"
326
336
  ranger
327
337
  echo "$code" > "$fin"
328
338
  # The envelope ended: the session's line goes to the register from outside it, whatever its end hook did.