@roomi-fields/grillhouse 0.50.3 → 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 +68 -0
- package/agents/developpeur.md +1 -1
- package/agents/direct.md +1 -1
- package/agents/explorateur.md +1 -1
- package/agents/questionneur.md +1 -1
- package/agents/relecteur.md +1 -1
- package/agents/testwriter.md +1 -1
- package/cadre/templates/c/package.json +1 -0
- package/cadre/templates/cargo/package.json +1 -0
- package/cadre/templates/python/package.json +1 -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 +39 -189
- package/dist/machine/part-par-sorte.d.ts +16 -0
- package/dist/machine/part-par-sorte.js +36 -0
- package/dist/machine/part-par-sorte.js.map +1 -0
- package/dist/temporal/circuit/appel.js +1 -1
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +4 -4
- package/dist/temporal/circuit/client.js +38 -16
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +11 -7
- package/dist/temporal/circuit/contrat.js +5 -9
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +18 -6
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +12 -3
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/installation.d.ts +54 -3
- package/dist/temporal/installation.js +187 -17
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/places/client.d.ts +5 -1
- package/dist/temporal/places/client.js +23 -11
- package/dist/temporal/places/client.js.map +1 -1
- package/docs/ARCHITECTURE.md +23 -2700
- package/docs/INTERFACE.md +26 -10
- package/docs/architecture/circuit.md +61 -14
- package/docs/architecture/entree.md +21 -8
- package/docs/architecture/greffon.md +49 -20
- package/docs/architecture/installation.md +46 -17
- package/docs/architecture/machine.md +79 -39
- package/docs/architecture/tests.md +59 -16
- package/docs/lexique.md +163 -0
- package/hooks/hooks.json +0 -10
- package/hooks/register.tsx +92 -4
- package/package.json +2 -1
- package/scripts/activites.mjs +105 -65
- package/scripts/aiguillage.mjs +15 -8
- package/scripts/attente-au-tour.mjs +2 -3
- package/scripts/attente-de-la-machine.mjs +4 -8
- package/scripts/avancement.mjs +12 -8
- package/scripts/bilan.mjs +126 -63
- package/scripts/bilans-gardes.mjs +37 -0
- package/scripts/branche-de-nuit.mjs +2 -2
- package/scripts/ci-de-main.mjs +18 -21
- package/scripts/circuit.mjs +89 -44
- package/scripts/circuits-du-serveur.mjs +5 -5
- package/scripts/composants-affectes.mjs +30 -12
- package/scripts/composition-des-langages.mjs +5 -3
- package/scripts/conformite.mjs +1 -1
- package/scripts/consommation-des-passes.mjs +8 -6
- package/scripts/copies-finies.mjs +3 -14
- package/scripts/depart-du-ticket.d.mts +8 -2
- package/scripts/depart-du-ticket.mjs +26 -8
- package/scripts/direct.mjs +158 -72
- package/scripts/droits.mjs +165 -208
- package/scripts/engendres.mjs +3 -14
- package/scripts/entree-de-seance.mjs +35 -0
- package/scripts/enveloppe/enveloppe.mjs +98 -46
- package/scripts/enveloppe/lancer.sh +90 -66
- package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
- package/scripts/enveloppe/travail-de-la-copie.mjs +192 -3
- package/scripts/etapes.mjs +84 -22
- package/scripts/faits-du-circuit.mjs +8 -2
- package/scripts/grillhouse-maj.mjs +43 -18
- package/scripts/groupe-cles.d.mts +15 -0
- package/scripts/groupe-cles.mjs +77 -2
- package/scripts/init.mjs +9 -2
- package/scripts/integration/rejeu.mjs +8 -1
- package/scripts/jointure.d.ts +24 -4
- package/scripts/langages/c/index.mjs +5 -2
- package/scripts/langages/cargo/commandes.mjs +35 -15
- package/scripts/langages/cargo/composants.mjs +45 -3
- package/scripts/langages/cargo/index.mjs +6 -3
- package/scripts/langages/python/commandes.mjs +50 -7
- package/scripts/langages/python/index.mjs +5 -2
- package/scripts/langages/python/squelette.mjs +2 -1
- package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
- package/scripts/langages/typescript/index.mjs +16 -14
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
- package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +151 -38
- package/scripts/langages/typescript/verdict.mjs +29 -3
- package/scripts/langages/typescript/verifier.mjs +28 -3
- package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
- package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
- package/scripts/langages.mjs +54 -4
- package/scripts/matieres-lues.mjs +1 -1
- package/scripts/mesure/base-de-passe.mjs +32 -90
- package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
- package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
- package/scripts/migrations.mjs +23 -7
- package/scripts/nuit.sh +3 -2
- package/scripts/paquet.mjs +1 -1
- package/scripts/paquets.d.ts +3 -0
- package/scripts/paquets.mjs +88 -1
- package/scripts/passe-de-la-machine.mjs +109 -36
- package/scripts/places-de-la-machine.mjs +81 -29
- package/scripts/plafond-de-la-machine.d.mts +2 -5
- package/scripts/plafond-de-la-machine.mjs +9 -9
- package/scripts/reprise.mjs +42 -13
- package/scripts/resultats.mjs +78 -56
- package/scripts/retirer-les-copies-finies.mjs +1 -1
- package/scripts/seances.mjs +471 -133
- package/scripts/services-du-noyau.mjs +9 -1
- package/scripts/session-start.sh +22 -7
- package/scripts/sortie-de-seance.mjs +70 -0
- package/scripts/sortie.mjs +37 -6
- package/scripts/sous-commandes.mjs +0 -3
- package/scripts/superviseur.mjs +400 -162
- package/scripts/tableau.mjs +188 -65
- package/scripts/transitions.d.mts +25 -2
- package/scripts/transitions.mjs +137 -29
- package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
- package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
- package/skills/developpeur/SKILL.md +38 -15
- package/skills/direct/SKILL.md +29 -9
- package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
- package/skills/domain-modeling/SKILL.md +14 -12
- package/skills/explorateur/SKILL.md +32 -8
- package/skills/grill/SKILL.md +3 -2
- package/skills/pitmaster/SKILL.md +80 -50
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/pitmaster/references/consigne-agent.md +12 -11
- package/skills/pitmaster/references/tour.md +6 -5
- package/skills/relecteur/SKILL.md +13 -6
- package/skills/systematic-debugging/SKILL.md +281 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +72 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/testwriter/SKILL.md +37 -31
- package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
- package/scripts/attente-a-l-arret.mjs +0 -114
- package/scripts/verrous/commande.mjs +0 -214
- package/scripts/verrous/verrou.mjs +0 -311
|
@@ -16,23 +16,23 @@
|
|
|
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
|
|
31
31
|
// socket of the session comes back. The file of the remote cache of the poste
|
|
32
32
|
// (`~/.config/grillhouse/`, scripts/fichier-du-poste.mjs) stays out.
|
|
33
33
|
// - A project that names its published version (`grillhouse.outil`) gets `~/.cache/grillhouse/outil`
|
|
34
|
-
// read-only, the version installed by the envelope before the session starts: the
|
|
35
|
-
//
|
|
34
|
+
// read-only, the version installed by the envelope before the session starts: the hooks of the
|
|
35
|
+
// session run on that version, never on the code of the copy.
|
|
36
36
|
// - The tools of the project (`grillhouse.outils` of the package.json of the main tree, never of
|
|
37
37
|
// the copy; `{ "<VARIABLE>": "<chemin>" }`, read by scripts/outils-cles.mjs): each path comes
|
|
38
38
|
// back read-only after the declared paths of the home, before the copy and the packages of the
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
// cache, `npm_config_ignore_scripts=true` (npm runs no lifecycle script; `npm test` and
|
|
51
51
|
// `npm run <script>` still run their script, without its `pre` or `post`), and `TMPDIR`, `TMP`
|
|
52
52
|
// and `TEMP`, the session's working directory (under a launch, the temporary directory of the
|
|
53
|
-
//
|
|
53
|
+
// session, scripts/enveloppe/lancer.sh). No other variable of the machine (`GH_TOKEN`,
|
|
54
54
|
// `NPM_TOKEN`…) enters. It also gets `GRILLHOUSE_ENVELOPPE`, the packages of the plan
|
|
55
|
-
// (`paquets-du-plan.mjs`): the frame's commands build, judge and write those packages only
|
|
56
|
-
//
|
|
55
|
+
// (`paquets-du-plan.mjs`): the frame's commands build, judge and write those packages only; the
|
|
56
|
+
// mounts refuse a write out of them. A declared variable that names a path
|
|
57
57
|
// (`VARIABLES_DE_CHEMIN`) enters only when its path is in sight inside the envelope. The
|
|
58
58
|
// session has its own process space.
|
|
59
59
|
// - A declared path that is a symbolic link, or that holds one among its components, comes back as
|
|
@@ -72,7 +72,9 @@
|
|
|
72
72
|
// A component writes itself alone, `src/parser` of a one-package project included, as does a
|
|
73
73
|
// package out of the frame (`docs/agents/hors-cadre.txt`). A path that no component holds (a
|
|
74
74
|
// folder of the root, `scripts`; `.`) writes the package that holds it, the root: the copy
|
|
75
|
-
// stays written, its `.git` read-only.
|
|
75
|
+
// stays written, its `.git` read-only. A new path of a direct (`estUnCheminNeuf`), which no
|
|
76
|
+
// package holds and the base commit of the copy lacks, is created empty by the agent direct's
|
|
77
|
+
// launch when it does not exist, and writes itself alone.
|
|
76
78
|
// - The package of the shared test material is every component of <copie> whose `package.json`
|
|
77
79
|
// exports `./test-fixtures` (`matieres` of the module of the language). It is mounted after the
|
|
78
80
|
// packages of the plan: written for the `testwriter`, read-only for every other role, in the
|
|
@@ -100,6 +102,7 @@ import { langageDeLaCopie } from '../langages.mjs';
|
|
|
100
102
|
import { CODE_REFUS, CODE_USAGE } from './codes.mjs';
|
|
101
103
|
import {
|
|
102
104
|
ecritsDuPlan,
|
|
105
|
+
estUnCheminNeuf,
|
|
103
106
|
ecrireLaListe,
|
|
104
107
|
lireLaListe,
|
|
105
108
|
paquetsDuLangage,
|
|
@@ -118,7 +121,11 @@ import {
|
|
|
118
121
|
travailleursDe,
|
|
119
122
|
VARIABLE_TENUE,
|
|
120
123
|
} from '../places-de-la-machine.mjs';
|
|
121
|
-
import {
|
|
124
|
+
import {
|
|
125
|
+
commandeDuGroupe,
|
|
126
|
+
groupeIndisponible,
|
|
127
|
+
mesureDeLaSeance,
|
|
128
|
+
} from '../passe-de-la-machine.mjs';
|
|
122
129
|
import { donneesDe } from '../donnees-cles.mjs';
|
|
123
130
|
import { matieresDeclareesDe } from '../matieres-cles.mjs';
|
|
124
131
|
import { outilsDe } from '../outils-cles.mjs';
|
|
@@ -157,8 +164,8 @@ export function matieresDeLaCopie(langage, copie) {
|
|
|
157
164
|
// The packages of the copy that the plan <paquets> does not name and that are not the shared test
|
|
158
165
|
// material, relative to the copy: where the envelope opens an empty own output to each run. The
|
|
159
166
|
// root package is the copy's own root, treated apart.
|
|
160
|
-
const paquetsHorsDuPlan = (paquets, paquetsDeLaCopie, matieres) => {
|
|
161
|
-
const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie);
|
|
167
|
+
const paquetsHorsDuPlan = (copie, paquets, paquetsDeLaCopie, matieres) => {
|
|
168
|
+
const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie, copie);
|
|
162
169
|
return paquetsDeLaCopie
|
|
163
170
|
.map(p => p.dossier)
|
|
164
171
|
.filter(d => d !== '.' && !ecrits.includes(d) && !matieres.includes(d));
|
|
@@ -167,13 +174,26 @@ const paquetsHorsDuPlan = (paquets, paquetsDeLaCopie, matieres) => {
|
|
|
167
174
|
// that are missing: in each package out of the plan, in the shared test material for a role that
|
|
168
175
|
// does not write it, and at the root of the copy when the plan does not write it. An output that a
|
|
169
176
|
// link carries out of the copy is left out. bwrap then has a directory to mount an empty one over.
|
|
177
|
+
// For the agent direct, a new path that the plan writes as itself (`ecritsDuPlan`) and that does
|
|
178
|
+
// not exist yet is created first, so that bwrap mounts it in writing inside the read-only copy; a
|
|
179
|
+
// path that exists, file or directory, stays as it is.
|
|
170
180
|
export function preparerLesSorties({ copie, paquets, paquetsDeLaCopie, matieres, role, sorties }) {
|
|
171
|
-
|
|
181
|
+
if (role === 'direct') {
|
|
182
|
+
const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie, copie);
|
|
183
|
+
for (const p of paquets.filter(estUnCheminNeuf)) {
|
|
184
|
+
const rel = path.normalize(p).replace(/\/+$/, '');
|
|
185
|
+
const chemin = path.join(copie, rel);
|
|
186
|
+
if (ecrits.includes(rel) && !existsSync(chemin)) {
|
|
187
|
+
mkdirSync(chemin, { recursive: true });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const dossiers = paquetsHorsDuPlan(copie, paquets, paquetsDeLaCopie, matieres);
|
|
172
192
|
if (!ROLES_MATIERE.includes(role)) {
|
|
173
193
|
// A declared folder of test material is no package: no run of tests writes outputs in it.
|
|
174
194
|
dossiers.push(...matieres.filter(m => paquetsDeLaCopie.some(p => p.dossier === m)));
|
|
175
195
|
}
|
|
176
|
-
if (!ecritsDuPlan(paquets, paquetsDeLaCopie).includes('.')) {
|
|
196
|
+
if (!ecritsDuPlan(paquets, paquetsDeLaCopie, copie).includes('.')) {
|
|
177
197
|
dossiers.push('.');
|
|
178
198
|
}
|
|
179
199
|
for (const d of dossiers) {
|
|
@@ -354,7 +374,8 @@ export function environnementDeLaSeance(
|
|
|
354
374
|
* @param {{ argsBwrap: string[], commande: string[], env: Record<string, string | undefined>,
|
|
355
375
|
* cacheNpm: string, paquets: string[], travail: string, outils?: Record<string, string>,
|
|
356
376
|
* donnees?: Record<string, string>, part?: { coeurs: number, memoire: number },
|
|
357
|
-
* sonde?: () => boolean }} o
|
|
377
|
+
* sonde?: () => boolean, unite?: string | null }} o <unite> names the group, which the measure
|
|
378
|
+
* of the session reads
|
|
358
379
|
* @returns {{ cmd: string, args: string[], env: Record<string, string>, sansBorne: string | null }}
|
|
359
380
|
* `sansBorne`: why the session starts without a group (null when it has one)
|
|
360
381
|
*
|
|
@@ -375,6 +396,7 @@ export function lancementDeLaSeance({
|
|
|
375
396
|
part,
|
|
376
397
|
sonde,
|
|
377
398
|
testsEtendus,
|
|
399
|
+
unite = null,
|
|
378
400
|
}) {
|
|
379
401
|
const seance = {
|
|
380
402
|
cmd: 'bwrap',
|
|
@@ -385,7 +407,14 @@ export function lancementDeLaSeance({
|
|
|
385
407
|
: 'aucune part du projet connue';
|
|
386
408
|
const lancee =
|
|
387
409
|
sansBorne === null
|
|
388
|
-
? commandeDuGroupe({
|
|
410
|
+
? commandeDuGroupe({
|
|
411
|
+
part,
|
|
412
|
+
cmd: seance.cmd,
|
|
413
|
+
args: seance.args,
|
|
414
|
+
unite,
|
|
415
|
+
plafond: true,
|
|
416
|
+
memoire: false,
|
|
417
|
+
})
|
|
389
418
|
: seance;
|
|
390
419
|
return {
|
|
391
420
|
...lancee,
|
|
@@ -506,10 +535,16 @@ const lienSurDisque = p => {
|
|
|
506
535
|
}
|
|
507
536
|
};
|
|
508
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
|
+
|
|
509
544
|
/**
|
|
510
|
-
* The outputs <s> of the module of the language (its `sorties`, scripts/jointure.d.ts)
|
|
511
|
-
* session whose home is <maison> and whose main tree
|
|
512
|
-
* 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;
|
|
513
548
|
* `magasins`, the stores written, absolute, mounted after them; `sorties`, what the copy holds,
|
|
514
549
|
* from its root: `ecrites` in writing, `propres` proper to the session; `fichiers`, the written
|
|
515
550
|
* paths of `magasins` and `sorties.ecrites` that are files (written without a trailing `/`), which
|
|
@@ -534,7 +569,7 @@ export function sortiesDuLangage(s, { maison, principal }) {
|
|
|
534
569
|
const ecrites = [];
|
|
535
570
|
/** @type {string[]} */
|
|
536
571
|
const fichiers = [];
|
|
537
|
-
for (const e of s.ecrites) {
|
|
572
|
+
for (const e of [...SORTIES_DE_TURBOREPO.ecrites, ...s.ecrites]) {
|
|
538
573
|
const a = absolu(e);
|
|
539
574
|
const p = a === null ? nu(e) : nu(a);
|
|
540
575
|
if (a === null) {
|
|
@@ -547,7 +582,8 @@ export function sortiesDuLangage(s, { maison, principal }) {
|
|
|
547
582
|
}
|
|
548
583
|
}
|
|
549
584
|
const lectures = s.lues.map(absolu).flatMap(a => (a === null ? [] : [nu(a)]));
|
|
550
|
-
|
|
585
|
+
const propres = [...new Set([...SORTIES_DE_TURBOREPO.propres, ...s.propres])];
|
|
586
|
+
return { magasins, lectures, fichiers, sorties: { ecrites, propres } };
|
|
551
587
|
}
|
|
552
588
|
|
|
553
589
|
// Creates the directory, or the empty file when <fichier>, <chemin>, when it is absent.
|
|
@@ -581,13 +617,14 @@ const inside = (child, parent) => {
|
|
|
581
617
|
// The refusal of <composant> in the repository at <depot>, or null when it is the path of a
|
|
582
618
|
// directory there (`.`, the whole repository, included). A <composant> that is the name of a
|
|
583
619
|
// component of `paquets` (`paquetsDuLangage`), or the name of its folder, is told
|
|
584
|
-
// its path, as git says « did you mean ».
|
|
620
|
+
// its path, as git says « did you mean ». A new path (`estUnCheminNeuf`) stands on a session of
|
|
621
|
+
// the agent direct (<neuf>), which creates it. `fs` gives `existe(path)`. The launcher judges the
|
|
585
622
|
// component with it before preparing the copy, in the ticket's copy when it exists, else in the
|
|
586
623
|
// main tree or in the tree of the ticket's branch, its `existe` accepting either; `plan` judges it
|
|
587
624
|
// in the copy.
|
|
588
|
-
export function jugerComposant({ depot, composant, paquets = [] }, fs) {
|
|
625
|
+
export function jugerComposant({ depot, composant, paquets = [], neuf = false }, fs) {
|
|
589
626
|
const propre = path.join(depot, composant);
|
|
590
|
-
if (fs.existe(propre)) {
|
|
627
|
+
if (fs.existe(propre) || (neuf && estUnCheminNeuf(composant))) {
|
|
591
628
|
return null;
|
|
592
629
|
}
|
|
593
630
|
const nomme =
|
|
@@ -609,8 +646,8 @@ export function jugerComposant({ depot, composant, paquets = [] }, fs) {
|
|
|
609
646
|
// copy (`matieres` of the module of the language); `role` is the agent's role, and only the
|
|
610
647
|
// `testwriter` writes them, and the lock files of the versions `verrous`, from the root of the copy.
|
|
611
648
|
// `magasins` lists the stores written by every run, the agent's included
|
|
612
|
-
// (
|
|
613
|
-
// 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
|
|
614
651
|
// mounted. `lectures` lists what the language's tools read (cargo's home, rustup's toolchains),
|
|
615
652
|
// mounted read-only before the stores, which come back in writing inside it; one that does not
|
|
616
653
|
// exist is not mounted. `sorties` lists, from the root of the copy,
|
|
@@ -664,12 +701,15 @@ export function plan(
|
|
|
664
701
|
return { refus: "Le plan ne nomme aucun paquet : l'enveloppe n'ouvre rien en écriture." };
|
|
665
702
|
}
|
|
666
703
|
for (const p of paquets) {
|
|
667
|
-
const refus = jugerComposant(
|
|
704
|
+
const refus = jugerComposant(
|
|
705
|
+
{ depot: copie, composant: p, paquets: paquetsDeLaCopie, neuf: role === 'direct' },
|
|
706
|
+
fs
|
|
707
|
+
);
|
|
668
708
|
if (refus) {
|
|
669
709
|
return { refus };
|
|
670
710
|
}
|
|
671
711
|
}
|
|
672
|
-
const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie);
|
|
712
|
+
const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie, copie);
|
|
673
713
|
const toute = ecrits.includes('.');
|
|
674
714
|
|
|
675
715
|
// /dev/shm, which /dev brings in writing, becomes an empty directory proper to the session.
|
|
@@ -759,7 +799,7 @@ export function plan(
|
|
|
759
799
|
// Each package out of the plan has its own outputs as empty directories proper to the session,
|
|
760
800
|
// as a sandbox of Bazel opens the declared outputs whatever the package; the rest stays read-only.
|
|
761
801
|
if (!toute) {
|
|
762
|
-
for (const d of paquetsHorsDuPlan(paquets, paquetsDeLaCopie, matieres)) {
|
|
802
|
+
for (const d of paquetsHorsDuPlan(copie, paquets, paquetsDeLaCopie, matieres)) {
|
|
763
803
|
for (const s of sortiesDe(path.join(copie, d), sorties.propres, fs.lien)) {
|
|
764
804
|
if (fs.existe(s)) {
|
|
765
805
|
args.push('--tmpfs', s);
|
|
@@ -789,8 +829,8 @@ export function plan(
|
|
|
789
829
|
const d = path.join(copie, e);
|
|
790
830
|
args.push('--bind', d, d);
|
|
791
831
|
}
|
|
792
|
-
// The reader packages the plan extended to their tests: the testwriter writes them (
|
|
793
|
-
// lets only their test files through), every other role reads them.
|
|
832
|
+
// The reader packages the plan extended to their tests: the testwriter writes them (the
|
|
833
|
+
// judgment of his lot lets only their test files through), every other role reads them.
|
|
794
834
|
for (const e of testsEtendus.filter(t => !ecrits.includes(t))) {
|
|
795
835
|
const d = path.join(copie, e);
|
|
796
836
|
if (fs.existe(d)) {
|
|
@@ -831,7 +871,7 @@ const disque = { existe: existsSync, lien: lienSurDisque };
|
|
|
831
871
|
// The cache of the published versions to mount when the project of <copie> names its version
|
|
832
872
|
// (`grillhouse.outil`, read in the main tree), after installing the version here, outside the
|
|
833
873
|
// session; null without the key, or when the version cannot be installed (said on the error stream:
|
|
834
|
-
// the
|
|
874
|
+
// the hooks then fall back on the code of the copy).
|
|
835
875
|
function cacheDeLaVersionPubliee(copie) {
|
|
836
876
|
const commun = execFileSync(
|
|
837
877
|
'git',
|
|
@@ -906,8 +946,8 @@ function envelopper(argv) {
|
|
|
906
946
|
return CODE_REFUS;
|
|
907
947
|
}
|
|
908
948
|
// The cache of the published versions (`grillhouse.outil` of the main tree's package.json) comes
|
|
909
|
-
// in read-only, the version installed here, outside the session: the
|
|
910
|
-
// a session cannot install it. A version that cannot be installed is said, nothing mounted.
|
|
949
|
+
// in read-only, the version installed here, outside the session: the session's hooks run on it,
|
|
950
|
+
// and a session cannot install it. A version that cannot be installed is said, nothing mounted.
|
|
911
951
|
const publie = cacheDeLaVersionPubliee(copie);
|
|
912
952
|
mkdirSync(projet, { recursive: true });
|
|
913
953
|
// The session's working directory, created here inside the scratchpads that bwrap mounts.
|
|
@@ -962,7 +1002,7 @@ function envelopper(argv) {
|
|
|
962
1002
|
preparerLesSorties({ copie, paquets, paquetsDeLaCopie, matieres, role, sorties });
|
|
963
1003
|
// For a plan that leaves the root read-only, where the language's tools write at the root of the
|
|
964
1004
|
// copy is created here, so that bwrap mounts it in writing, inside the read-only copy.
|
|
965
|
-
if (!ecritsDuPlan(paquets, paquetsDeLaCopie).includes('.')) {
|
|
1005
|
+
if (!ecritsDuPlan(paquets, paquetsDeLaCopie, copie).includes('.')) {
|
|
966
1006
|
for (const s of sortiesDe(copie, sorties.ecrites, lienSurDisque)) {
|
|
967
1007
|
creer(s, fichiers.includes(path.relative(copie, s)));
|
|
968
1008
|
}
|
|
@@ -993,26 +1033,37 @@ function envelopper(argv) {
|
|
|
993
1033
|
process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${refus}\n`);
|
|
994
1034
|
code = CODE_REFUS;
|
|
995
1035
|
} else {
|
|
996
|
-
// The session reserves its cores for its phase alone (3, a direct's
|
|
997
|
-
// the machine, and gives them back at its end; under a part already held, its cap is that part.
|
|
1036
|
+
// The session reserves its cores for its phase alone (3 by default, a direct's too) against
|
|
1037
|
+
// the budget of the machine, and gives them back at its end; under a part already held, its cap is that part.
|
|
998
1038
|
let part;
|
|
999
1039
|
let prise = null;
|
|
1000
1040
|
try {
|
|
1001
|
-
const direct = role === 'direct';
|
|
1002
1041
|
prise = prendreUnePart({
|
|
1003
1042
|
racine: copie,
|
|
1004
1043
|
ticket: path.basename(copie),
|
|
1005
1044
|
sorte: `séance ${role ?? ''}`.trim(),
|
|
1006
|
-
|
|
1045
|
+
bornee: false,
|
|
1007
1046
|
dire: l => process.stderr.write(`${l}\n`),
|
|
1008
1047
|
});
|
|
1009
|
-
part =
|
|
1048
|
+
part =
|
|
1049
|
+
prise.part ??
|
|
1050
|
+
partDeLaPasse({ racine: copie, sorte: `séance ${role ?? ''}`.trim() });
|
|
1010
1051
|
} catch (e) {
|
|
1011
1052
|
process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${e.message}\n`);
|
|
1012
1053
|
temporaire.fermer();
|
|
1013
1054
|
return CODE_REFUS;
|
|
1014
1055
|
}
|
|
1056
|
+
// The peak of the session, which its group measures, enters the register under its role.
|
|
1057
|
+
const mesure = prise.part
|
|
1058
|
+
? mesureDeLaSeance({
|
|
1059
|
+
racine: copie,
|
|
1060
|
+
role,
|
|
1061
|
+
ticket: path.basename(copie),
|
|
1062
|
+
part: { ...prise.part, id: prise.id },
|
|
1063
|
+
})
|
|
1064
|
+
: null;
|
|
1015
1065
|
const lancement = lancementDeLaSeance({
|
|
1066
|
+
unite: mesure?.unite ?? null,
|
|
1016
1067
|
argsBwrap: args,
|
|
1017
1068
|
commande,
|
|
1018
1069
|
env: process.env,
|
|
@@ -1031,6 +1082,7 @@ function envelopper(argv) {
|
|
|
1031
1082
|
try {
|
|
1032
1083
|
r = spawnSync(lancement.cmd, lancement.args, { stdio: 'inherit', env: lancement.env });
|
|
1033
1084
|
} finally {
|
|
1085
|
+
mesure?.garder(r ?? { error: true });
|
|
1034
1086
|
prise.rendre();
|
|
1035
1087
|
}
|
|
1036
1088
|
if (r.error) {
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
# mounts in writing over the real directory, so that a transcript outlives its session). The
|
|
33
33
|
# circuit gives them, so that a relaunch of an agent on its step resumes its session. The two
|
|
34
34
|
# together are refused, CODE_USAGE; each takes a value as --modele does.
|
|
35
|
-
# A resumed session receives its instruction
|
|
36
|
-
#
|
|
35
|
+
# A resumed session receives its instruction and the sections « Ton dossier de travail » (its
|
|
36
|
+
# directory is new) and « La construction échoue »: the session it resumes holds the other
|
|
37
|
+
# sections the launcher adds below.
|
|
37
38
|
# - The agent's copy is the worktree .claude/worktrees/<ticket> (branch agent/<ticket>), created
|
|
38
39
|
# from the main tree's HEAD when absent and moved forward to it otherwise. When the branch exists
|
|
39
40
|
# without a copy, it is brought back to the main tree's HEAD and the copy is made on it: the lot
|
|
@@ -72,9 +73,11 @@
|
|
|
72
73
|
# refused), the launch stops, CODE_COPIE, before any command runs. In the envelope the main
|
|
73
74
|
# repository is read-only as a whole.
|
|
74
75
|
# - The envelope receives the role: it decides who writes the package of the shared test material.
|
|
75
|
-
# - The session runs `claude -p` with the role's agent
|
|
76
|
-
# input
|
|
77
|
-
#
|
|
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
|
|
78
81
|
# followed by the section « Ce que les composants d'avant publient », for each package of the
|
|
79
82
|
# plan (one part per package when the plan holds several): for each
|
|
80
83
|
# component whose `## Consommateurs` section names the package, its line, the names of the
|
|
@@ -84,25 +87,33 @@
|
|
|
84
87
|
# CODE_COPIE), then the
|
|
85
88
|
# section « Ton dossier de travail », which names the session's working directory, where every
|
|
86
89
|
# temporary file goes (`dossierDeTravail` of enveloppe.mjs, the envelope's TMPDIR, TMP and TEMP,
|
|
87
|
-
# in the temporary directory of the
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
90
|
+
# in the temporary directory of the session), then the
|
|
91
|
+
# section « La construction échoue » when it fails. The temporary directory of the session is a
|
|
92
|
+
# base of a pass (scripts/mesure/base-de-passe.mjs) which the launcher, its owner, opens once the
|
|
93
|
+
# call is judged, empty: its TMPDIR, TMP and TEMP, those of the preparation of the copy and of
|
|
94
|
+
# the session, whatever CLAUDE_CODE_TMPDIR the poste holds. The launcher's own files (the output
|
|
95
|
+
# of a failed build, the prompt) lie in the base, beside that directory, never in it, as the
|
|
96
|
+
# runner's files of GitHub Actions lie in RUNNER_TEMP, out of the job's workspace. The base goes
|
|
97
|
+
# when the launcher ends, even interrupted, once the witness the session left
|
|
98
|
+
# there is ranged in the folder of the session; the next session sweeps the one of a launcher
|
|
99
|
+
# killed. The prompt
|
|
100
|
+
# carries « TON TICKET : <ticket> », the ticket of the session. The envelope is the sandbox, so
|
|
92
101
|
# the session runs without permission prompts, under the rights and the context of its role
|
|
93
102
|
# (scripts/droits.mjs, given the main tree, the copy and the ticket; a reading that fails stops
|
|
94
103
|
# the launch, CODE_COPIE): the user's own configuration left out, its settings on the command
|
|
95
104
|
# line (its refusals, among them the change of its author at the ticket, AUTEUR_FIXE: its
|
|
96
|
-
# comments carry the author the launch names in BEADS_ACTOR, which the envelope passes on
|
|
97
|
-
#
|
|
105
|
+
# comments carry the author the launch names in BEADS_ACTOR, which the envelope passes on), its
|
|
106
|
+
# tools and the servers of the index, for the reading of the whole copy.
|
|
98
107
|
# - A role that ends on a sheet (scripts/resultats.mjs: the testwriter, the developpeur) runs with
|
|
99
|
-
# `--
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
#
|
|
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
|
|
103
113
|
# of the session (.claude/worktrees/<ticket>.travail/seances/<id>/, <id> the session's
|
|
104
114
|
# --seance or --reprise, `courante` without one), which a launch removes first and the circuit
|
|
105
|
-
# 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.
|
|
106
117
|
# - Its output, and an envelope refusal (CODE_REFUS), are added to .claude/worktrees/<ticket>.log,
|
|
107
118
|
# the log of the ticket, which keeps every session of the ticket: each launch past the checks of
|
|
108
119
|
# its call adds a header line, `=== <time> · <rôle> · <composant> ===`, then its preparation and
|
|
@@ -113,10 +124,9 @@
|
|
|
113
124
|
# The command the envelope runs leaves a witness of its start in the working directory, which the
|
|
114
125
|
# launcher ranges beside it (`demarree`, removed first): an envelope that ends without it refused
|
|
115
126
|
# the launch before the session, whatever its code (scripts/seances.mjs `seanceLancee`).
|
|
116
|
-
#
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
# and adds it to the log. It then writes the session's line to the register
|
|
127
|
+
# Once the copy is prepared, before the session, the launcher writes the tree the copy holds to
|
|
128
|
+
# `avant` in the folder of the session (travail-de-la-copie.mjs `photographier`), which a launch
|
|
129
|
+
# removes first: the circuit reads the session's lot from it. It then writes the session's line to the register
|
|
120
130
|
# (scripts/registre.mjs --copie), and exits with the envelope's code.
|
|
121
131
|
# - The exit codes are named in scripts/enveloppe/codes.mjs; a malformed call exits CODE_USAGE.
|
|
122
132
|
# - CLAUDE_BIN replaces `claude` (the tests use it).
|
|
@@ -173,7 +183,7 @@ if [ -d "$racine/.claude/worktrees/$ticket" ]; then
|
|
|
173
183
|
elif git -C "$racine" rev-parse --verify --quiet "refs/heads/agent/$ticket" > /dev/null; then
|
|
174
184
|
branche="agent/$ticket"
|
|
175
185
|
fi
|
|
176
|
-
refus_composant=$(node --input-type=module -e "import { spawnSync } from 'node:child_process'; import { existsSync } from 'node:fs'; import path from 'node:path'; import { jugerComposant, paquetsDuLangage } from '$ici/enveloppe.mjs'; import { lireLaListe } from '$ici/paquets-du-plan.mjs'; import { langageDeLaCopie } from '$ici/../langages.mjs'; const [depot, composant, liste, branche] = process.argv.slice(1); const dansBranche = p => { const rel = path.relative(depot, p); return rel === '' || (!rel.startsWith('..') && spawnSync('git', ['-C', depot, 'cat-file', '-e', branche + ':' + rel]).status === 0); }; const existe = p => existsSync(p) || (branche !== '' && dansBranche(p)); const tous = paquetsDuLangage(langageDeLaCopie(depot), depot); process.stdout.write([composant, ...lireLaListe(liste)].map(c => jugerComposant({ depot, composant: c, paquets: tous }, { existe })).find(Boolean) ?? '');" "$juge" "$composant" "$paquets" "$branche") || exit "$CODE_USAGE"
|
|
186
|
+
refus_composant=$(node --input-type=module -e "import { spawnSync } from 'node:child_process'; import { existsSync } from 'node:fs'; import path from 'node:path'; import { jugerComposant, paquetsDuLangage } from '$ici/enveloppe.mjs'; import { lireLaListe } from '$ici/paquets-du-plan.mjs'; import { langageDeLaCopie } from '$ici/../langages.mjs'; const [depot, composant, liste, branche, role] = process.argv.slice(1); const dansBranche = p => { const rel = path.relative(depot, p); return rel === '' || (!rel.startsWith('..') && spawnSync('git', ['-C', depot, 'cat-file', '-e', branche + ':' + rel]).status === 0); }; const existe = p => existsSync(p) || (branche !== '' && dansBranche(p)); const tous = paquetsDuLangage(langageDeLaCopie(depot), depot); process.stdout.write([composant, ...lireLaListe(liste)].map(c => jugerComposant({ depot, composant: c, paquets: tous, neuf: role === 'direct' }, { existe })).find(Boolean) ?? '');" "$juge" "$composant" "$paquets" "$branche" "$role") || exit "$CODE_USAGE"
|
|
177
187
|
[ -z "$refus_composant" ] || { echo "⛔ $refus_composant" >&2; exit "$CODE_USAGE"; }
|
|
178
188
|
# The ticket is matched whole: `demo-3160` is not `demo-316`, and its dots are dots.
|
|
179
189
|
motif=$(printf '%s' "$ticket" | sed 's/[.[\*^$]/\\&/g')
|
|
@@ -186,22 +196,42 @@ journal="$copie.log"
|
|
|
186
196
|
rang="$copie.travail/seances/${seance:-${reprise:-courante}}"
|
|
187
197
|
fin="$rang/fin"
|
|
188
198
|
resultat="$rang/resultat.json"
|
|
189
|
-
|
|
190
|
-
hors_plan_fait="$rang/hors-plan.json"
|
|
199
|
+
avant="$rang/avant"
|
|
191
200
|
demarree="$rang/demarree"
|
|
192
201
|
mkdir -p "$(dirname "$copie")" "$rang"
|
|
193
|
-
rm -f "$fin" "$resultat" "$
|
|
202
|
+
rm -f "$fin" "$resultat" "$avant" "$demarree"
|
|
194
203
|
printf '=== %s · %s · %s ===\n' "$(date -Iseconds)" "$role" "$composant" >> "$journal"
|
|
195
|
-
# The temporary directory of the
|
|
196
|
-
#
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
temporaire=$(node "$ici/../mesure/base-de-passe.mjs" "$ticket" 2>> "$journal") \
|
|
200
|
-
|| { echo "⛔ Le dossier temporaire du ticket n'a pas pu s'ouvrir : voir $journal." >&2; exit "$CODE_COPIE"; }
|
|
204
|
+
# The temporary directory of the session, a base this shell owns: TMPDIR, TMP and TEMP of the rest
|
|
205
|
+
# of the launch and of the session, whose scratchpads and working directory lie in it.
|
|
206
|
+
temporaire=$(node --input-type=module -e "import { ouvrirBase } from '$ici/../mesure/base-de-passe.mjs'; process.stdout.write(ouvrirBase('seance', { pid: Number(process.argv[1]) }).dossier);" "$$" 2>> "$journal") \
|
|
207
|
+
|| { echo "⛔ Le dossier temporaire de la séance n'a pas pu s'ouvrir : voir $journal." >&2; exit "$CODE_COPIE"; }
|
|
201
208
|
export TMPDIR="$temporaire" TMP="$temporaire" TEMP="$temporaire"
|
|
209
|
+
# The launcher's own files lie in its base, beside the directory of the session, which holds what
|
|
210
|
+
# the session and the preparation of its copy write.
|
|
211
|
+
base_du_lanceur="${temporaire%/t}"
|
|
212
|
+
unset CLAUDE_CODE_TMPDIR
|
|
213
|
+
travail=
|
|
214
|
+
# What the circuit reads after the session leaves its working directory for the session's folder:
|
|
215
|
+
# the witness that the envelope started its command (a launch the envelope refuses before the
|
|
216
|
+
# session, a mount bwrap cannot make, leaves none).
|
|
217
|
+
ranger() {
|
|
218
|
+
[ -n "$travail" ] || return 0
|
|
219
|
+
if [ -f "$travail/.demarree" ]; then
|
|
220
|
+
mv "$travail/.demarree" "$demarree"
|
|
221
|
+
fi
|
|
222
|
+
}
|
|
223
|
+
# The directory goes at the end of the launcher, whatever ends it.
|
|
224
|
+
fermer() {
|
|
225
|
+
ranger || true
|
|
226
|
+
rm -rf -- "$base_du_lanceur" || true
|
|
227
|
+
}
|
|
228
|
+
trap fermer EXIT
|
|
229
|
+
trap 'exit 129' HUP
|
|
230
|
+
trap 'exit 130' INT
|
|
231
|
+
trap 'exit 143' TERM
|
|
202
232
|
# The output of the session's build, when it fails, behind its first line, which says what failed
|
|
203
233
|
# and what was built: the module's command `construire` writes it.
|
|
204
|
-
echec=$(mktemp)
|
|
234
|
+
echec=$(mktemp -p "$base_du_lanceur")
|
|
205
235
|
(
|
|
206
236
|
# Each step returns on failure: `set -e` does not act inside a subshell tested by `||`.
|
|
207
237
|
# An existing copy moves forward to main by the preparation (`cible`); a new one is made on it.
|
|
@@ -250,66 +280,60 @@ publie=$(cd "$copie" && node "$ici/../../bin/grillhouse.mjs" index-interfaces --
|
|
|
250
280
|
# The session's working directory, the one the envelope gives as TMPDIR, follows them.
|
|
251
281
|
travail=$(node --input-type=module -e "import { dossierDeTravail } from '$ici/enveloppe.mjs'; process.stdout.write(dossierDeTravail(process.argv[1]));" "$copie" 2>> "$journal") \
|
|
252
282
|
|| { rm -f "$echec"; echo "⛔ Le dossier de travail de la séance n'a pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
|
|
253
|
-
# The mark a lock leaves there when it stops the session out of the plan, and the witness the
|
|
254
|
-
# envelope's command leaves there at its start (`TEMOIN_DE_DEMARRAGE` of enveloppe.mjs): none before
|
|
255
|
-
# the session.
|
|
256
|
-
rm -f "$travail/hors-plan" "$travail/.demarree"
|
|
257
283
|
dossier=$'\n\n'"## Ton dossier de travail"$'\n\n'"Tout fichier temporaire s'écrit dans \`$travail\`, que \`\$TMPDIR\` nomme aussi."
|
|
258
284
|
construction=
|
|
259
285
|
if [ -s "$echec" ]; then
|
|
260
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```'
|
|
261
287
|
fi
|
|
262
288
|
rm -f "$echec"
|
|
263
|
-
# The prompt, assembled in a file:
|
|
264
|
-
#
|
|
265
|
-
# A resumed session holds the sections of its first instruction:
|
|
266
|
-
|
|
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.
|
|
291
|
+
# A resumed session holds the sections of its first instruction: its new working directory and a
|
|
292
|
+
# failed build alone are news.
|
|
293
|
+
prompt=$(mktemp -p "$base_du_lanceur")
|
|
267
294
|
if [ -n "$reprise" ]; then
|
|
268
|
-
printf '%s' "$(cat "$consigne")$construction" > "$prompt"
|
|
295
|
+
printf '%s' "$(cat "$consigne")$dossier$construction" > "$prompt"
|
|
269
296
|
else
|
|
270
297
|
printf '%s' "$(cat "$consigne")"$'\n\n'"$publie$dossier$construction" > "$prompt"
|
|
271
298
|
fi
|
|
272
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
|
+
|
|
273
306
|
# The rights and the context of the role's session (scripts/droits.mjs), one option per line.
|
|
274
307
|
droits=$(node "$ici/../droits.mjs" "$role" --racine "$racine" --copie "$copie" --ticket "$ticket" 2>> "$journal") \
|
|
275
|
-
|| { 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"; }
|
|
276
309
|
mapfile -t droits_du_role <<<"$droits"
|
|
277
310
|
|
|
278
311
|
# The schema of the role's end-of-session sheet (scripts/resultats.mjs), for a role that has one:
|
|
279
|
-
# 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.
|
|
280
313
|
fiche=()
|
|
281
314
|
schema=$(node "$ici/../resultats.mjs" --schema "${sorte:-$role}" 2> /dev/null) || schema=
|
|
282
|
-
[ -z "$schema" ] || fiche=(--
|
|
315
|
+
[ -z "$schema" ] || fiche=(--json-schema "$schema")
|
|
316
|
+
|
|
317
|
+
# The state of the prepared copy, which the session's lot is read from.
|
|
318
|
+
node "$ici/travail-de-la-copie.mjs" photographier "$copie" > "$avant" 2>> "$journal" \
|
|
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"; }
|
|
283
320
|
|
|
284
321
|
# An envelope in error does not stop the launcher (set -e): its code is kept for the exit.
|
|
285
322
|
code=0
|
|
286
323
|
lancer_claude() {
|
|
287
324
|
node "$ici/enveloppe.mjs" "$copie" "$paquets" "$role" -- \
|
|
288
325
|
"${CLAUDE_BIN:-claude}" -p --agent "$role" \
|
|
326
|
+
--input-format stream-json --output-format stream-json --verbose \
|
|
289
327
|
${surcharge[@]+"${surcharge[@]}"} ${fiche[@]+"${fiche[@]}"} --permission-mode bypassPermissions \
|
|
290
|
-
"${droits_du_role[@]}" < "$
|
|
328
|
+
"${droits_du_role[@]}" < "$entree"
|
|
291
329
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
# The witness that the envelope started its command goes to the circuit: a launch the envelope
|
|
300
|
-
# refuses before the session (a mount bwrap cannot make) leaves none.
|
|
301
|
-
if [ -f "$travail/.demarree" ]; then
|
|
302
|
-
mv "$travail/.demarree" "$demarree"
|
|
303
|
-
fi
|
|
304
|
-
# A session its lock stopped out of the plan (scripts/verrous/verrou.mjs): its reason goes to the
|
|
305
|
-
# circuit, and to the log.
|
|
306
|
-
if [ -f "$travail/hors-plan" ]; then
|
|
307
|
-
mv "$travail/hors-plan" "$hors_plan"
|
|
308
|
-
{ cat "$hors_plan"; echo; } >> "$journal"
|
|
309
|
-
fi
|
|
310
|
-
if [ -f "$travail/hors-plan.json" ]; then
|
|
311
|
-
mv "$travail/hors-plan.json" "$hors_plan_fait"
|
|
312
|
-
fi
|
|
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"
|
|
336
|
+
ranger
|
|
313
337
|
echo "$code" > "$fin"
|
|
314
338
|
# The envelope ended: the session's line goes to the register from outside it, whatever its end hook did.
|
|
315
339
|
node "$ici/../registre.mjs" --copie "$copie" >> "$journal" 2>&1 || true
|