@roomi-fields/grillhouse 0.51.0 → 0.52.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.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +20 -0
- package/charte/plan.md +47 -0
- package/charte/preuve.md +39 -0
- package/charte/superviseur.md +61 -0
- package/charte/tests.md +38 -0
- package/charte.md +22 -177
- package/dist/temporal/circuit/client.d.ts +1 -2
- package/dist/temporal/circuit/client.js +1 -2
- package/dist/temporal/circuit/client.js.map +1 -1
- package/docs/INTERFACE.md +4 -3
- package/docs/architecture/circuit.md +2 -2
- package/docs/architecture/entree.md +1 -1
- package/docs/architecture/greffon.md +43 -18
- package/docs/architecture/installation.md +17 -7
- package/docs/architecture/machine.md +30 -3
- package/docs/architecture/tests.md +8 -3
- package/docs/lexique.md +10 -1
- package/hooks/hooks.json +0 -10
- package/hooks/register.tsx +91 -3
- package/package.json +2 -1
- package/scripts/activites.mjs +20 -5
- package/scripts/aiguillage.mjs +0 -1
- package/scripts/attente-au-tour.mjs +2 -3
- package/scripts/bilan.mjs +116 -56
- package/scripts/bilans-gardes.mjs +37 -0
- package/scripts/circuit.mjs +3 -1
- package/scripts/direct.mjs +1 -1
- package/scripts/droits.mjs +115 -36
- package/scripts/entree-de-seance.mjs +35 -0
- package/scripts/enveloppe/enveloppe.mjs +23 -16
- package/scripts/enveloppe/lancer.sh +32 -22
- package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
- package/scripts/jointure.d.ts +2 -1
- package/scripts/langages/python/commandes.mjs +50 -7
- package/scripts/langages/python/squelette.mjs +2 -1
- package/scripts/langages/typescript/index.mjs +12 -12
- package/scripts/langages/typescript/turbo-des-paquets.mjs +52 -2
- package/scripts/langages/typescript/verifier.mjs +27 -2
- package/scripts/migrations/serveurs-de-l-index.mjs +1 -1
- package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/nuit.sh +3 -2
- package/scripts/paquet.mjs +1 -1
- package/scripts/resultats.mjs +2 -2
- package/scripts/seances.mjs +53 -26
- package/scripts/session-start.sh +8 -6
- package/scripts/sortie-de-seance.mjs +70 -0
- package/scripts/sous-commandes.mjs +0 -1
- package/scripts/superviseur.mjs +373 -155
- package/scripts/tableau.mjs +127 -49
- package/skills/explorateur/SKILL.md +2 -2
- package/skills/grill/SKILL.md +3 -2
- package/skills/pitmaster/SKILL.md +68 -34
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/pitmaster/references/tour.md +6 -5
- package/skills/relecteur/SKILL.md +1 -1
- package/skills/testwriter/SKILL.md +2 -2
- package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
- package/scripts/attente-a-l-arret.mjs +0 -114
package/scripts/droits.mjs
CHANGED
|
@@ -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
|
|
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
|
|
28
|
-
//
|
|
29
|
-
// (`
|
|
30
|
-
// hooks
|
|
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 {
|
|
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
|
-
//
|
|
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
|
|
107
|
-
// at the root of the plugin installed),
|
|
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,8 +156,10 @@ 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,
|
|
@@ -136,13 +168,17 @@ export const ROLES = {
|
|
|
136
168
|
// The agent of a ticket led out of the circuit (`npx grillhouse direct`, scripts/direct.mjs): it
|
|
137
169
|
// 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: {
|
|
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
|
-
...
|
|
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
|
|
250
|
-
//
|
|
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:
|
|
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];
|
|
@@ -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
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// written; what
|
|
23
|
-
// and `~/.rustup`) comes back read-only under
|
|
24
|
-
// come back in writing;
|
|
25
|
-
// `.cache-outils`, the cache of Vite) are empty
|
|
26
|
-
// on disk before the session, a directory or,
|
|
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)
|
|
540
|
-
* session whose home is <maison> and whose main tree
|
|
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
|
-
|
|
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
|
-
// (
|
|
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
|
|
77
|
-
# input
|
|
78
|
-
#
|
|
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
|
-
# `--
|
|
107
|
-
#
|
|
108
|
-
#
|
|
109
|
-
#
|
|
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
|
|
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:
|
|
286
|
-
#
|
|
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 "$
|
|
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
|
|
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=(--
|
|
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 "$
|
|
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[@]}" < "$
|
|
328
|
+
"${droits_du_role[@]}" < "$entree"
|
|
318
329
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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.
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
// copy brought back to HEAD, moved forward, the lot applied three ways. The lot waits in the
|
|
34
34
|
// copy's own git directory (`git rev-parse --git-dir`, `grillhouse-travail.patch`) while the
|
|
35
35
|
// copy moves, and goes once it is applied.
|
|
36
|
+
// - First, an index the circuit saved before a command of its checks, left by a killed
|
|
37
|
+
// process, is put back (`rendreLIndex`).
|
|
36
38
|
// - The lot applies file by file (one `git apply --3way` per file, its patch alone): a file that
|
|
37
39
|
// fails touches none of the others. A file in conflict keeps its marks; a file git refuses
|
|
38
40
|
// without marks (a deletion of a file main changed) stays alone in the lot kept in the git
|
|
@@ -89,6 +91,7 @@ import {
|
|
|
89
91
|
existsSync,
|
|
90
92
|
mkdtempSync,
|
|
91
93
|
readFileSync,
|
|
94
|
+
renameSync,
|
|
92
95
|
rmSync,
|
|
93
96
|
statSync,
|
|
94
97
|
utimesSync,
|
|
@@ -115,6 +118,77 @@ const lignes = r =>
|
|
|
115
118
|
.map(l => l.trim())
|
|
116
119
|
.filter(Boolean);
|
|
117
120
|
|
|
121
|
+
// The index of a copy as it was before the circuit put the lot there, in the copy's git directory.
|
|
122
|
+
const INDEX_SAUVE = 'grillhouse-index';
|
|
123
|
+
|
|
124
|
+
// The index of <copie> and the file that saves it, absolute; null out of git.
|
|
125
|
+
function indexDeLaCopie(copie) {
|
|
126
|
+
const r = git(copie, [
|
|
127
|
+
'rev-parse',
|
|
128
|
+
'--path-format=absolute',
|
|
129
|
+
'--git-path',
|
|
130
|
+
'index',
|
|
131
|
+
'--git-path',
|
|
132
|
+
INDEX_SAUVE,
|
|
133
|
+
]);
|
|
134
|
+
if (r.status !== 0) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const [index, sauve] = lignes(r);
|
|
138
|
+
return { index, sauve };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Puts back the index of <copie> that `inscrireLeLot` saved, in one rename, when one waits in its
|
|
143
|
+
* git directory: after the command, or before the next gesture that reads the index, when the
|
|
144
|
+
* process that ran the command was killed.
|
|
145
|
+
* @param {string} copie
|
|
146
|
+
*/
|
|
147
|
+
export function rendreLIndex(copie) {
|
|
148
|
+
const i = indexDeLaCopie(copie);
|
|
149
|
+
if (i && existsSync(i.sauve)) {
|
|
150
|
+
renameSync(i.sauve, i.index);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Puts the lot of <copie> in its index (`git add -A`, the ignored files left out) for a command
|
|
156
|
+
* that judges it, so that a reader of the index sees a new file as a tracked one and a deleted
|
|
157
|
+
* file no more; the index as it was, unresolved conflicts included, waits in the git directory of
|
|
158
|
+
* the copy until `rendreLIndex`. Throws, naming git, the index unchanged, when git fails.
|
|
159
|
+
* @param {string} copie
|
|
160
|
+
*/
|
|
161
|
+
export function inscrireLeLot(copie) {
|
|
162
|
+
rendreLIndex(copie);
|
|
163
|
+
const refus = r =>
|
|
164
|
+
new Error(
|
|
165
|
+
`git ne met pas le lot à l'index de la copie ${copie} (git add -A) : la commande ne joue pas.\n${texte(r)}`
|
|
166
|
+
);
|
|
167
|
+
const rev = git(copie, ['rev-parse', '--git-dir']);
|
|
168
|
+
const i = indexDeLaCopie(copie);
|
|
169
|
+
if (!i) {
|
|
170
|
+
throw refus(rev);
|
|
171
|
+
}
|
|
172
|
+
// A repository without an index file has an empty one, written so that it can be put back.
|
|
173
|
+
if (!existsSync(i.index)) {
|
|
174
|
+
const vide = git(copie, ['read-tree', '--empty']);
|
|
175
|
+
if (vide.status !== 0) {
|
|
176
|
+
throw refus(vide);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Saved whole or not at all: copied aside, then renamed. Its time with it: git reads it to
|
|
180
|
+
// judge a file written in the same instant as the index.
|
|
181
|
+
const { atime, mtime } = statSync(i.index);
|
|
182
|
+
copyFileSync(i.index, `${i.sauve}.tmp`);
|
|
183
|
+
utimesSync(`${i.sauve}.tmp`, atime, mtime);
|
|
184
|
+
renameSync(`${i.sauve}.tmp`, i.sauve);
|
|
185
|
+
const r = git(copie, ['add', '-A']);
|
|
186
|
+
if (r.status !== 0) {
|
|
187
|
+
rendreLIndex(copie);
|
|
188
|
+
throw refus(r);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
118
192
|
// The files of <copie> unmerged in its index.
|
|
119
193
|
const enConflit = copie => lignes(git(copie, ['diff', '--name-only', '--diff-filter=U']));
|
|
120
194
|
|
|
@@ -514,6 +588,7 @@ const conflit = (copie, conflits, entete) =>
|
|
|
514
588
|
* @param {{ ecrit?: (fichier: string) => boolean, suspects?: string[], duCadre?: (copie: string) => any[], dire?: (texte: string) => void }} [o]
|
|
515
589
|
*/
|
|
516
590
|
export function avancer(copie, cible, { ecrit, suspects = [], duCadre, dire = surStderr } = {}) {
|
|
591
|
+
rendreLIndex(copie);
|
|
517
592
|
releverLesResolus(copie);
|
|
518
593
|
const restants = [
|
|
519
594
|
...new Set([...enConflit(copie), ...suspects.filter(f => porteDesMarques(copie, f))]),
|
|
@@ -684,6 +759,8 @@ export function preparer(copie, cible, { env = process.env, sortie = 2, ecrit, s
|
|
|
684
759
|
}
|
|
685
760
|
return r;
|
|
686
761
|
};
|
|
762
|
+
// Before any command that reads the index, the pose of the submodules included.
|
|
763
|
+
rendreLIndex(copie);
|
|
687
764
|
const echec = (r, quoi) => ({
|
|
688
765
|
ok: false,
|
|
689
766
|
message: `⛔ ${quoi} de la copie ${copie} échoue (code ${r.status ?? r.signal}).${r.stderr?.length ? `\n${String(r.stderr).trim()}` : ''}`,
|
package/scripts/jointure.d.ts
CHANGED
|
@@ -218,7 +218,8 @@ export interface Composition {
|
|
|
218
218
|
* out, the update writes them in the project's `.gitignore`, and the removal of the finished
|
|
219
219
|
* copies removes them from a kept copy whose ticket is closed (scripts/copies-finies.mjs). */
|
|
220
220
|
ignorer: string[];
|
|
221
|
-
/** Where a run of the language's tools writes, which the envelope opens to a session
|
|
221
|
+
/** Where a run of the language's tools writes, which the envelope opens to a session;
|
|
222
|
+
* Turborepo's outputs are the core's, which no module declares. */
|
|
222
223
|
sorties: {
|
|
223
224
|
/** Opened in writing: from the root of the copy, from the home (`~/…`), or from the main
|
|
224
225
|
* tree (`//…`), a store shared by every copy; each created before the session, a directory
|