@roomi-fields/grillhouse 0.25.5 → 0.27.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 (83) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/agents/testwriter.md +1 -1
  3. package/bin/grillhouse.mjs +20 -3
  4. package/cadre/templates/cargo/package.json +3 -0
  5. package/cadre/templates/projet/.gitattributes +1 -0
  6. package/cadre/templates/projet/CLAUDE.md +13 -0
  7. package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
  8. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  9. package/cadre/templates/python/package.json +18 -0
  10. package/charte.md +32 -1
  11. package/docs/ARCHITECTURE.md +146 -40
  12. package/docs/CADRE.md +7 -6
  13. package/docs/INTERFACE.md +108 -32
  14. package/hooks/register.tsx +57 -16
  15. package/package.json +9 -3
  16. package/scripts/circuit.mjs +165 -27
  17. package/scripts/commande-du-langage.mjs +2 -2
  18. package/scripts/commandes-composees.mjs +156 -0
  19. package/scripts/composition-des-langages.mjs +306 -0
  20. package/scripts/conformite.mjs +1 -3
  21. package/scripts/copies-finies.mjs +167 -28
  22. package/scripts/crochets.mjs +9 -3
  23. package/scripts/dernier-vert.mjs +15 -2
  24. package/scripts/engendres.mjs +170 -0
  25. package/scripts/enveloppe/enveloppe.mjs +59 -17
  26. package/scripts/enveloppe/lancer.sh +15 -22
  27. package/scripts/enveloppe/travail-de-la-copie.mjs +262 -0
  28. package/scripts/etapes.mjs +1 -1
  29. package/scripts/fusion-du-changelog.mjs +120 -0
  30. package/scripts/gardes-du-cadre.mjs +7 -4
  31. package/scripts/grillhouse-maj.mjs +171 -99
  32. package/scripts/index-interfaces.mjs +78 -0
  33. package/scripts/init.mjs +5 -5
  34. package/scripts/integration/file.mjs +270 -117
  35. package/scripts/integration/integrer.mjs +50 -62
  36. package/scripts/jointure.d.ts +48 -14
  37. package/scripts/langages/cargo/binaires.json +2 -1
  38. package/scripts/langages/cargo/binaires.mjs +29 -6
  39. package/scripts/langages/cargo/clippy.mjs +12 -2
  40. package/scripts/langages/cargo/commandes.mjs +60 -7
  41. package/scripts/langages/cargo/composants.mjs +229 -8
  42. package/scripts/langages/cargo/exemples.mjs +1 -15
  43. package/scripts/langages/cargo/index-interfaces.mjs +20 -3
  44. package/scripts/langages/cargo/index.mjs +25 -17
  45. package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
  46. package/scripts/langages/cargo/sccache.mjs +172 -0
  47. package/scripts/langages/cargo/verdict.mjs +50 -10
  48. package/scripts/langages/python/binaires.json +3 -0
  49. package/scripts/langages/python/binaires.mjs +59 -0
  50. package/scripts/langages/python/commandes.mjs +411 -0
  51. package/scripts/langages/python/composants.mjs +272 -0
  52. package/scripts/langages/python/exemples.mjs +260 -0
  53. package/scripts/langages/python/index-interfaces.mjs +77 -0
  54. package/scripts/langages/python/index.mjs +94 -0
  55. package/scripts/langages/python/lot.mjs +76 -0
  56. package/scripts/langages/python/mise-a-jour.mjs +54 -0
  57. package/scripts/langages/python/tailles-des-tests.mjs +102 -0
  58. package/scripts/langages/python/verdict.mjs +85 -0
  59. package/scripts/langages/typescript/exemples.mjs +1 -20
  60. package/scripts/langages/typescript/index-interfaces.mjs +10 -3
  61. package/scripts/langages/typescript/index.mjs +15 -17
  62. package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
  63. package/scripts/langages-des-paquets.mjs +171 -0
  64. package/scripts/langages.mjs +60 -41
  65. package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
  66. package/scripts/migrations.mjs +2 -0
  67. package/scripts/nuit.sh +15 -1
  68. package/scripts/outils-cles.mjs +188 -0
  69. package/scripts/resultats.mjs +22 -6
  70. package/scripts/session-start.sh +34 -9
  71. package/scripts/sources.mjs +2 -1
  72. package/scripts/sous-commandes.mjs +21 -3
  73. package/scripts/tableau-des-composants.mjs +138 -0
  74. package/scripts/verrou-de-machine.mjs +14 -13
  75. package/scripts/verrous/verrou.mjs +53 -16
  76. package/skills/developpeur/SKILL.md +4 -0
  77. package/skills/explorateur/SKILL.md +3 -1
  78. package/skills/grill/SKILL.md +9 -1
  79. package/skills/pitmaster/SKILL.md +12 -3
  80. package/skills/pitmaster/references/consigne-agent.md +3 -3
  81. package/skills/redacteur/references/documents-d-un-composant.md +12 -0
  82. package/skills/relecteur/SKILL.md +6 -2
  83. package/skills/testwriter/SKILL.md +29 -6
@@ -2,13 +2,14 @@
2
2
  // The frame's git hooks, on Husky's model: the project's `prepare`, which npm runs at its install,
3
3
  // places them, and each calls the project's command, `grillhouse hook <nom>`.
4
4
  //
5
- // npx grillhouse hooks [<project>] places both hooks (the current directory by default)
5
+ // npx grillhouse hooks [<project>] places both hooks and the merge driver of the
6
+ // CHANGELOG (the current directory by default)
6
7
  // npx grillhouse hooks --absents [<project>] prints the name of each absent hook, one per line
7
8
  //
8
9
  // - commit-msg: « un ticket fermé garde sa livraison ; un ticket rouvert reçoit ses corrections » (scripts/un-commit-par-ticket.mjs).
9
10
  // - pre-push: the night branch guard (scripts/branche-de-nuit.mjs).
10
11
  // - A hook lives in the folder git reads for the project (`git rev-parse --git-path hooks`, which
11
- // follows `core.hooksPath`, Beads' `.beads/hooks` included); the configuration is never changed
12
+ // follows `core.hooksPath`, Beads' `.beads/hooks` included); `core.hooksPath` is never changed
12
13
  // here. The update of the frame (scripts/grillhouse-maj.mjs) places them by the same function.
13
14
  // - The frame's lines run `node_modules/.bin/grillhouse` of the project, the package installed;
14
15
  // without it they do nothing and let the hook go on, as Husky's lines do without Husky.
@@ -19,10 +20,14 @@
19
20
  // stay as they are. The frame's lines never end the hook early (no `exec` of a command), so the
20
21
  // lines that follow still run.
21
22
  // - A hook is absent when it is missing from that folder or lacks the current lines of the frame.
23
+ // - The merge driver of the CHANGELOG (scripts/fusion-du-changelog.mjs) is written in the
24
+ // repository's configuration by the same function, `poserCrochets`, which each `npm install`
25
+ // runs, as git asks a driver's command of the configuration, never of a versioned file.
22
26
  import { execFileSync } from 'node:child_process';
23
27
  import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
24
28
  import path from 'node:path';
25
29
  import { pathToFileURL } from 'node:url';
30
+ import { poserLePilote } from './fusion-du-changelog.mjs';
26
31
 
27
32
  // The project's command, which the frame's lines run.
28
33
  const COMMANDE = '_gh_commande="$(git rev-parse --show-toplevel)/node_modules/.bin/grillhouse"';
@@ -102,8 +107,9 @@ function poserCrochet(projet, nom) {
102
107
  return ecrit ? f : null;
103
108
  }
104
109
 
105
- /** Places both frame hooks in the project; returns the paths written. */
110
+ /** Places both frame hooks and the merge driver of the CHANGELOG in the project; returns the paths written. */
106
111
  export function poserCrochets(projet) {
112
+ poserLePilote(projet);
107
113
  return Object.keys(CROCHETS)
108
114
  .map(nom => poserCrochet(projet, nom))
109
115
  .filter(Boolean);
@@ -34,8 +34,13 @@
34
34
  // removes at its end.
35
35
  // - `npm test` measures itself against the last green under the circuit's mark,
36
36
  // `GRILLHOUSE_DEPUIS_LE_VERT` (scripts/langages/typescript/tests.mjs, scripts/circuit.mjs); it never keeps one.
37
+ // - In a project of several languages, each language's pass defers its green to the file that
38
+ // `GRILLHOUSE_VERT_DIFFERE` names (`VERT_DIFFERE`): the composed command keeps the first one once
39
+ // every language played green (scripts/commandes-composees.mjs), so that a language played after
40
+ // another does not measure itself against the green of the first.
37
41
  import { spawnSync } from 'node:child_process';
38
42
  import {
43
+ appendFileSync,
39
44
  copyFileSync,
40
45
  existsSync,
41
46
  mkdirSync,
@@ -51,6 +56,9 @@ import path from 'node:path';
51
56
  // tests of the module of the language reads in each package.
52
57
  export const CHANGEMENTS = 'GRILLHOUSE_CHANGEMENTS';
53
58
  export const DEPUIS_LE_VERT = 'GRILLHOUSE_DEPUIS_LE_VERT';
59
+ // The variable that names the file where a pass of one language among several defers its green,
60
+ // which the composed command keeps once every language played green (scripts/commandes-composees.mjs).
61
+ export const VERT_DIFFERE = 'GRILLHOUSE_VERT_DIFFERE';
54
62
  const SHA = /^[0-9a-f]{40,64}$/;
55
63
 
56
64
  const git = (racine, args, env = process.env) =>
@@ -151,8 +159,13 @@ function lireLeVertDe(etat, branche) {
151
159
  return { commit: v.commit, arbre: v.arbre, branche };
152
160
  }
153
161
 
154
- // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached.
155
- export function garderLeVert(etat) {
162
+ // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached; while
163
+ // <env> names a file of deferred greens (`VERT_DIFFERE`), adds it there instead, one line of JSON.
164
+ export function garderLeVert(etat, env = process.env) {
165
+ if (env[VERT_DIFFERE]) {
166
+ appendFileSync(env[VERT_DIFFERE], `${JSON.stringify(etat)}\n`);
167
+ return;
168
+ }
156
169
  const branche = etat.branche ?? etat.main;
157
170
  const f = branche ? fichierDuVert(etat.racine, branche) : null;
158
171
  if (!f) return;
@@ -0,0 +1,170 @@
1
+ // The generated files a project keeps committed, and their regeneration on a tree where a lot is
2
+ // applied. As npm writes package-lock.json again after a merge instead of merging it, and as a
3
+ // genrule of Bazel writes its output again on the merged tree, a derived file is never merged: its
4
+ // command writes it again from its merged sources.
5
+ //
6
+ // - The key `grillhouse.engendres` of the root package.json declares them, read from the main tree
7
+ // of the repository (`engendresDe`), never from a copy, as `grillhouse.outils`
8
+ // (scripts/outils-cles.mjs): `{ "<nom>": { "commande": "<ligne du shell>", "fichiers":
9
+ // ["<motif>"], "lit": ["<motif>"] } }`, each pattern from the root (a path, a directory or a glob
10
+ // pattern, as `couvertPar` reads it), `lit` the files it reads, empty when not given. Each one
11
+ // is read in the form of a file a module of language generates (`FichierEngendre` of
12
+ // scripts/jointure.d.ts): its command writes its `fichiers` in full (`entiers`), and no guard
13
+ // judges it (`gardes` empty). A key without a command, without files, or with a pattern out of
14
+ // the repository (absolute, or climbing above the root) is refused by its name, and gives no
15
+ // generated file: the circuit stops at its launch, the integration, the queue and the move of a
16
+ // copy onto main refuse before any work.
17
+ // - `touchesPar` gives the generated files a lot touches: one of their files, or one they read.
18
+ // - `regenerer` plays the command of each, in order, then stages every file they changed; a command
19
+ // of the project at another code than 0, one of the frame on a real failure (126, 127, a signal,
20
+ // 128 + its number), or a file changed that their `fichiers` do not cover refuses, the command,
21
+ // its code and its output named. The integration (scripts/integration/integrer.mjs), the queue
22
+ // (scripts/integration/file.mjs) and the move of a copy onto main
23
+ // (scripts/enveloppe/travail-de-la-copie.mjs) call it on the tree where they applied the lot,
24
+ // main's version of each file taken.
25
+ import { existsSync, readFileSync } from 'node:fs';
26
+ import path from 'node:path';
27
+ import { arbrePrincipal } from './outils-cles.mjs';
28
+
29
+ /**
30
+ * Whether one of <motifs> covers the file <fichier>, both from the root of the copy, as the inputs
31
+ * of Turborepo read them: a path names that file, a directory every file under it, a glob pattern
32
+ * (`*`, `**`) the files it matches (`path.matchesGlob` of Node).
33
+ * @param {string[]} motifs
34
+ * @param {string} fichier
35
+ */
36
+ export function couvertPar(motifs, fichier) {
37
+ return motifs.some(m => {
38
+ const dossier = m.replace(/\/+$/, '');
39
+ return fichier === dossier || fichier.startsWith(`${dossier}/`) || path.matchesGlob(fichier, m);
40
+ });
41
+ }
42
+
43
+ // Whether the pattern <m> leaves the repository: absolute, or climbing above the root.
44
+ const horsDuDepot = m => path.isAbsolute(m) || path.posix.normalize(m).split('/')[0] === '..';
45
+
46
+ // Whether <v> is a list of strings, non-empty ones.
47
+ const motifs = v => Array.isArray(v) && v.every(m => typeof m === 'string' && m !== '');
48
+
49
+ /**
50
+ * The generated files that the package.json <pkg> declares (`grillhouse.engendres`): `engendres`,
51
+ * none when a fault is found; `fautes`, one sentence per fault, naming its key.
52
+ * @param {any} pkg the parsed package.json
53
+ * @returns {{ engendres: { nom: string, commande: string, fichiers: string[], lit: string[], gardes: string[], entiers: string[] }[], fautes: string[] }}
54
+ */
55
+ export function lireEngendres(pkg) {
56
+ const e = pkg?.grillhouse?.engendres;
57
+ if (e === undefined || e === null) return { engendres: [], fautes: [] };
58
+ if (typeof e !== 'object' || Array.isArray(e)) {
59
+ return {
60
+ engendres: [],
61
+ fautes: [
62
+ `la clé grillhouse.engendres vaut ${JSON.stringify(e)}, pas un objet { nom: { commande, fichiers, lit } }.`,
63
+ ],
64
+ };
65
+ }
66
+ /** @type {string[]} */
67
+ const fautes = [];
68
+ const engendres = [];
69
+ for (const [nom, v] of Object.entries(e)) {
70
+ const cle = `grillhouse.engendres.${nom}`;
71
+ if (typeof v !== 'object' || v === null || Array.isArray(v)) {
72
+ fautes.push(
73
+ `la clé ${cle} vaut ${JSON.stringify(v)}, pas un objet { commande, fichiers, lit }.`
74
+ );
75
+ continue;
76
+ }
77
+ const avant = fautes.length;
78
+ if (typeof v.commande !== 'string' || v.commande.trim() === '') {
79
+ fautes.push(`la clé ${cle} n'a pas de commande, la ligne du shell qui écrit ses fichiers.`);
80
+ }
81
+ if (!motifs(v.fichiers) || v.fichiers.length === 0) {
82
+ fautes.push(`la clé ${cle} n'a pas de fichiers, les motifs depuis la racine qu'elle écrit.`);
83
+ }
84
+ if (v.lit !== undefined && !motifs(v.lit)) {
85
+ fautes.push(`la clé ${cle}.lit vaut ${JSON.stringify(v.lit)}, pas une liste de motifs.`);
86
+ }
87
+ for (const m of [...(motifs(v.fichiers) ? v.fichiers : []), ...(motifs(v.lit) ? v.lit : [])]) {
88
+ if (horsDuDepot(m)) {
89
+ fautes.push(`la clé ${cle} nomme « ${m} », hors du dépôt : un motif part de la racine.`);
90
+ }
91
+ }
92
+ if (fautes.length === avant) {
93
+ engendres.push({
94
+ nom,
95
+ commande: v.commande,
96
+ fichiers: v.fichiers,
97
+ lit: v.lit ?? [],
98
+ gardes: [],
99
+ entiers: v.fichiers,
100
+ });
101
+ }
102
+ }
103
+ return { engendres: fautes.length ? [] : engendres, fautes };
104
+ }
105
+
106
+ /**
107
+ * The generated files of the project that holds <dir>, from the package.json of its main tree,
108
+ * never of a copy, so that no lot writes the command line the integration then runs; the script
109
+ * that line launches is the one of the tree it runs in, which the lot may change. None without one.
110
+ * @param {string} dir a directory of the project: its main tree or a copy
111
+ * @throws {Error} the faults of the key, one per line
112
+ */
113
+ export function engendresDe(dir) {
114
+ const f = path.join(arbrePrincipal(dir), 'package.json');
115
+ if (!existsSync(f)) return [];
116
+ const { engendres, fautes } = lireEngendres(JSON.parse(readFileSync(f, 'utf8')));
117
+ if (fautes.length) throw new Error(fautes.join('\n'));
118
+ return engendres;
119
+ }
120
+
121
+ /**
122
+ * The generated files of <engendres> the lot of <fichiers> touches: one of the files it writes in
123
+ * full, or one it reads.
124
+ * @template {{ entiers: string[], lit: string[] }} E
125
+ * @param {E[]} engendres
126
+ * @param {string[]} fichiers
127
+ * @returns {E[]}
128
+ */
129
+ export const touchesPar = (engendres, fichiers) =>
130
+ engendres.filter(e => fichiers.some(f => couvertPar(e.entiers, f) || couvertPar(e.lit, f)));
131
+
132
+ /**
133
+ * Plays the command of each of <refs>, in order (`lancer`, which runs a line of the shell at the
134
+ * root of the tree and gives the result of spawnSync), then stages every file they changed (`dansCopie`, git in the
135
+ * tree, its strings in UTF-8). Null, or the refusal (see the header). The output of a command that
136
+ * passes goes to <ecrire>.
137
+ * @param {{ refs: { nom: string, commande: string, fichiers: string[], cadre?: boolean }[], lancer: (commande: string) => import('node:child_process').SpawnSyncReturns<string>, dansCopie: (...args: string[]) => import('node:child_process').SpawnSyncReturns<string>, ecrire?: (s: string) => void }} o
138
+ * @returns {string | null}
139
+ */
140
+ export function regenerer({ refs, lancer, dansCopie, ecrire = s => process.stdout.write(s) }) {
141
+ const etat = () => {
142
+ const r = dansCopie('status', '--porcelain=v1', '-z', '-uall', '--no-renames');
143
+ return r.status === 0 ? r.stdout.split('\0').filter(Boolean) : null;
144
+ };
145
+ const avant = etat();
146
+ if (avant === null) return "L'état de l'arbre ne se lit pas.";
147
+ for (const r of refs) {
148
+ const x = lancer(r.commande);
149
+ const sortie = `${x.stdout ?? ''}${x.stderr ?? ''}`;
150
+ const code = x.status ?? 1;
151
+ const panne =
152
+ x.signal !== null || x.error !== undefined || code === 126 || code === 127 || code > 128;
153
+ if (panne || (!r.cadre && code !== 0)) {
154
+ return `La commande de « ${r.nom} » (\`${r.commande}\`) rend le code ${code}. Sa sortie :\n${sortie.trim()}`;
155
+ }
156
+ ecrire(sortie);
157
+ }
158
+ const apres = etat();
159
+ if (apres === null) return "L'état de l'arbre ne se lit pas.";
160
+ const deja = new Set(avant);
161
+ const ecrits = apres.filter(l => !deja.has(l)).map(l => l.slice(3));
162
+ const horsDeclaration = ecrits.filter(f => !refs.some(r => couvertPar(r.fichiers, f)));
163
+ if (horsDeclaration.length) {
164
+ return `La régénération change des fichiers qu'aucune commande rejouée n'écrit :\n${horsDeclaration.map(f => ` ${f}`).join('\n')}`;
165
+ }
166
+ if (ecrits.length && dansCopie('add', '-A', '--', ...ecrits).status !== 0) {
167
+ return "Les fichiers régénérés ne s'ajoutent pas à l'index.";
168
+ }
169
+ return null;
170
+ }
@@ -33,6 +33,18 @@
33
33
  // `~/.claude`, `~/.claude.json`, the npm cache, the paths of `MAISON_EN_LECTURE` (claude, node,
34
34
  // git and the session's tools) and the repository. No socket of the session comes back. Of
35
35
  // the machine's credentials, only claude's own are in sight.
36
+ // - The tools of the project (`grillhouse.outils` of the package.json of the main tree, never of
37
+ // the copy, so that an agent never opens a path for its next session; `{ "<VARIABLE>":
38
+ // "<chemin>" }`, read by scripts/outils-cles.mjs), as Bazel declares what an action sees out of
39
+ // its sandbox and the environment it gets: each path comes back read-only after the declared
40
+ // paths of the home, before the copy and the packages of the plan, which come back in writing
41
+ // over it, and each variable reaches the session, the path resolved. A tool never covers a mount
42
+ // of the envelope: a path is refused when it is `/`, the home or holds it, holds the main tree,
43
+ // `/tmp`, the temporary directories, `~/.claude`, the scratchpads, the npm cache or a session
44
+ // directory, or lies under a hidden directory of the first level of the home (`~/.ssh`,
45
+ // `~/.gnupg`, `~/.aws`, `~/.config`…) but `~/.local` and `~/.cache`, or lies under or holds the
46
+ // keyrings `~/.local/share/keyrings`; a link is judged by its target too. A faulty key refuses the
47
+ // envelope, by its name, before anything is prepared.
36
48
  // - The session gets only the environment the envelope declares (`environnementDeLaSeance`), as
37
49
  // sudo's env_reset and bwrap's --clearenv give it: the base of a login session, claude's own
38
50
  // configuration and credentials (`ANTHROPIC_*`, `CLAUDE_CODE_OAUTH_TOKEN`), the author of its
@@ -81,6 +93,10 @@
81
93
  // the session, as Bazel writes a test's logs out of its source: what is written there leaves no
82
94
  // trace. The envelope creates each of them on disk, empty, before the session, so that bwrap
83
95
  // mounts over it inside the read-only package.
96
+ // - The lock files of the versions at the root of the copy (`manifestes.verrous` of the module of
97
+ // the language: cargo's Cargo.lock), which a run of the tests brings in line with the
98
+ // dependencies of the tests the testwriter declares, come back in writing for the `testwriter`
99
+ // alone, when the plan leaves the root read-only and the file exists.
84
100
  // - The exit codes are named in `codes.mjs`.
85
101
  import { execFileSync, spawnSync } from 'node:child_process';
86
102
  import {
@@ -106,8 +122,9 @@ import {
106
122
 
107
123
  export { paquetsDuLangage };
108
124
  import { ouvrirBase } from '../mesure/base-de-passe.mjs';
125
+ import { outilsDe } from '../outils-cles.mjs';
109
126
 
110
- // The role that writes the package of the shared test material.
127
+ // The role that writes the package of the shared test material and the lock files of the versions.
111
128
  const ROLE_MATIERE = 'testwriter';
112
129
  // The directories <sorties> of <dir>, each relative to it.
113
130
  // One that a symbolic link carries out of <dir> (a `node_modules` linked to another tree's) is
@@ -214,8 +231,10 @@ export function dossierDeTravail(copie, env = process.env) {
214
231
  // envelope mounts in writing, `npm_config_ignore_scripts` set to `true` (npm runs no lifecycle
215
232
  // script: a `prepare` that writes under the read-only `.git` would fail `npm install`; the
216
233
  // launcher installs outside the session), `TMPDIR` set to the session's working directory
217
- // <travail>, and `GRILLHOUSE_ENVELOPPE` set to the plan <paquets>. Nothing else of <env> enters.
218
- export function environnementDeLaSeance(env, { cacheNpm, paquets, travail }) {
234
+ // <travail>, and `GRILLHOUSE_ENVELOPPE` set to the plan <paquets>; with them, each tool of the
235
+ // project <outils> (`grillhouse.outils`), its variable set to its path. Nothing else of <env>
236
+ // enters.
237
+ export function environnementDeLaSeance(env, { cacheNpm, paquets, travail, outils = {} }) {
219
238
  const declare = nom =>
220
239
  ENVIRONNEMENT_DECLARE.includes(nom) ||
221
240
  VARIABLES_DE_CHEMIN.includes(nom) ||
@@ -223,6 +242,7 @@ export function environnementDeLaSeance(env, { cacheNpm, paquets, travail }) {
223
242
  const garde = Object.entries(env).filter(([nom, v]) => v !== undefined && declare(nom));
224
243
  return {
225
244
  ...Object.fromEntries(garde),
245
+ ...outils,
226
246
  npm_config_cache: cacheNpm,
227
247
  npm_config_ignore_scripts: 'true',
228
248
  TMPDIR: travail,
@@ -239,8 +259,9 @@ function commandeEprouvee(commande) {
239
259
  // The mounts outside the copy, in bwrap's order: an empty `/tmp`; the home that holds
240
260
  // `~/.claude` and the session directories, empty and sealed; the copy's scratchpads, the npm
241
261
  // cache and `~/.claude` in writing; the throwaway `~/.claude.json`; over them, what the session
242
- // reads without writing; the copy's project directory, in writing; last, the declared paths of
243
- // the home, read-only.
262
+ // reads without writing; the copy's project directory, in writing; the declared paths of the
263
+ // home, read-only; last, the path of each tool of the project <outils>, read-only (the plan mounts
264
+ // the copy and its written packages after them).
244
265
  export function montagesDeLaSeance({
245
266
  cacheNpm,
246
267
  claude,
@@ -248,6 +269,7 @@ export function montagesDeLaSeance({
248
269
  etatJetable,
249
270
  scratchpads,
250
271
  sessions = [],
272
+ outils = {},
251
273
  }) {
252
274
  const maison = path.dirname(claude);
253
275
  return [
@@ -258,6 +280,7 @@ export function montagesDeLaSeance({
258
280
  ...CLAUDE_EN_LECTURE.map(nom => ({ chemin: path.join(claude, nom), ecriture: false })),
259
281
  { chemin: projet, ecriture: true },
260
282
  ...MAISON_EN_LECTURE.map(rel => ({ chemin: path.join(maison, rel), ecriture: false })),
283
+ ...Object.values(outils).map(chemin => ({ chemin, ecriture: false })),
261
284
  ];
262
285
  }
263
286
 
@@ -396,7 +419,8 @@ export function jugerComposant({ depot, composant, paquets = [] }, fs) {
396
419
  // (`montagesDeLaSeance`); an emptied one marked `scelle` is sealed read-only once every mount
397
420
  // inside it is made. `matieres` lists the packages of the shared test material, relative to the
398
421
  // copy (`matieres` of the module of the language); `role` is the agent's role, and only the
399
- // `testwriter` writes them. `magasins` lists the stores written by every run, the agent's included
422
+ // `testwriter` writes them, and the lock files of the versions `verrous`, from the root of the copy.
423
+ // `magasins` lists the stores written by every run, the agent's included
400
424
  // (the module's, `sortiesDuLangage`: Turborepo's `<main tree>/.turbo/cache`, cargo's registry,
401
425
  // git dependencies, advisories and lock files in the home); one that does not exist is not
402
426
  // mounted. `lectures` lists what the language's tools read (cargo's home, rustup's toolchains),
@@ -414,6 +438,7 @@ export function jugerComposant({ depot, composant, paquets = [] }, fs) {
414
438
  * paquets?: string[],
415
439
  * role?: string,
416
440
  * matieres?: string[],
441
+ * verrous?: string[],
417
442
  * montages?: { chemin: string, source?: string, ecriture?: boolean, vide?: boolean, scelle?: boolean, lien?: string }[],
418
443
  * magasins?: string[],
419
444
  * lectures?: string[],
@@ -430,6 +455,7 @@ export function plan(
430
455
  paquets = [],
431
456
  role,
432
457
  matieres = [],
458
+ verrous = [],
433
459
  montages = [],
434
460
  magasins = [],
435
461
  lectures = [],
@@ -508,6 +534,11 @@ export function plan(
508
534
  const d = path.join(copie, e);
509
535
  args.push('--bind', d, d);
510
536
  }
537
+ // The lock files of the versions, which a run of the testwriter's tests brings in line with
538
+ // the dependencies of his tests, are written by him alone.
539
+ for (const v of verrous.map(v => path.join(copie, v))) {
540
+ if (role === ROLE_MATIERE && fs.existe(v)) args.push('--bind', v, v);
541
+ }
511
542
  }
512
543
  for (const m of matieres.map(m => path.join(copie, m))) {
513
544
  args.push(role === ROLE_MATIERE ? '--bind' : '--ro-bind', m, m);
@@ -547,17 +578,8 @@ function envelopper(argv) {
547
578
  // [A-Za-z0-9] turned into a dash; it is created here so that bwrap mounts it in writing.
548
579
  const enTirets = copie.replace(/[^A-Za-z0-9]/g, '-');
549
580
  const projet = path.join(claude, 'projects', enTirets);
550
- mkdirSync(projet, { recursive: true });
551
581
  const scratchpads = scratchpadsDe(copie);
552
- // The session's working directory, created here inside the scratchpads that bwrap mounts.
553
582
  const travail = dossierDeTravail(copie);
554
- mkdirSync(travail, { recursive: true });
555
- // `~/.claude.json` holds the permissions and servers of every project: it enters the session
556
- // as a throwaway copy, in a base of its own removed on exit and swept when the envelope is
557
- // killed (../mesure/base-de-passe.mjs).
558
- const temporaire = ouvrirBase('enveloppe');
559
- const etatJetable = path.join(temporaire.dossier, 'claude.json');
560
- if (existsSync(`${claude}.json`)) copyFileSync(`${claude}.json`, etatJetable);
561
583
  // The session directories of this user that exist: the XDG one and the systemd one.
562
584
  const sessions = [
563
585
  ...new Set(
@@ -566,8 +588,27 @@ function envelopper(argv) {
566
588
  .map(d => path.resolve(d))
567
589
  ),
568
590
  ];
591
+ // The tools of the project, judged before anything is prepared: none holds a mount.
592
+ let outils;
593
+ try {
594
+ outils = outilsDe(copie, {
595
+ montages: [copie, claude, scratchpads, cacheNpm, TEMPORAIRE, ...sessions],
596
+ });
597
+ } catch (e) {
598
+ process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${e.message}\n`);
599
+ return CODE_REFUS;
600
+ }
601
+ mkdirSync(projet, { recursive: true });
602
+ // The session's working directory, created here inside the scratchpads that bwrap mounts.
603
+ mkdirSync(travail, { recursive: true });
604
+ // `~/.claude.json` holds the permissions and servers of every project: it enters the session
605
+ // as a throwaway copy, in a base of its own removed on exit and swept when the envelope is
606
+ // killed (../mesure/base-de-passe.mjs).
607
+ const temporaire = ouvrirBase('enveloppe');
608
+ const etatJetable = path.join(temporaire.dossier, 'claude.json');
609
+ if (existsSync(`${claude}.json`)) copyFileSync(`${claude}.json`, etatJetable);
569
610
  const montages = avecLiens(
570
- montagesDeLaSeance({ cacheNpm, claude, projet, etatJetable, scratchpads, sessions }),
611
+ montagesDeLaSeance({ cacheNpm, claude, projet, etatJetable, scratchpads, sessions, outils }),
571
612
  lienSurDisque
572
613
  );
573
614
  const langage = langageDe(copie);
@@ -614,6 +655,7 @@ function envelopper(argv) {
614
655
  paquets,
615
656
  role,
616
657
  matieres,
658
+ verrous: langage.manifestes.verrous,
617
659
  montages,
618
660
  magasins,
619
661
  lectures,
@@ -629,7 +671,7 @@ function envelopper(argv) {
629
671
  } else {
630
672
  const r = spawnSync('bwrap', [...args, ...commandeEprouvee(commande)], {
631
673
  stdio: 'inherit',
632
- env: environnementDeLaSeance(process.env, { cacheNpm, paquets, travail }),
674
+ env: environnementDeLaSeance(process.env, { cacheNpm, paquets, travail, outils }),
633
675
  });
634
676
  if (r.error) process.stderr.write(`⛔ ENVELOPPE IMPOSSIBLE — ${r.error.message}\n`);
635
677
  code = r.error ? CODE_REFUS : (r.status ?? 1);
@@ -40,10 +40,13 @@
40
40
  # again from main. A ticket whose branch is still in the integration queue is not launched:
41
41
  # the refusal goes to the log, which names the queue, CODE_COPIE, before any copy is made.
42
42
  # Moving forward keeps
43
- # the work in progress of the copy: git stashes it, fast-forwards, and reapplies it
44
- # (`--autostash`). A refusal, such as commits of the agent on its branch, goes to the log and
45
- # stops the launch, CODE_COPIE; so does a reapplication that conflicts: the log names each file
46
- # in conflict, the work stays in git's stash, and no agent starts on a half-merged copy. Its
43
+ # the work in progress of the copy in the copy, never in git's stash, which every copy of the
44
+ # repository shares: it is set aside as a lot, the copy fast-forwards, and the lot is applied
45
+ # three ways, as the lot of a branch sent back is (scripts/enveloppe/travail-de-la-copie.mjs).
46
+ # A refusal, such as commits of the agent on its branch or conflicts left unresolved, goes to
47
+ # the log and stops the launch, CODE_COPIE; so does a reapplication that conflicts: the log
48
+ # names the copy and each file in conflict, the conflicts stay marked in the copy's files and
49
+ # unmerged in its index, and no agent starts on a half-merged copy. Its
47
50
  # submodules go through the common preparation (scripts/sous-modules.sh): before moving forward,
48
51
  # a submodule carrying local work stops the launch, CODE_COPIE, its log naming it, the work in
49
52
  # place; then every submodule is set at the commit of HEAD, before any installation, except one the
@@ -185,38 +188,28 @@ echec=$(mktemp)
185
188
  if [ ! -d "$copie" ]; then
186
189
  tete=$(git -C "$racine" rev-parse HEAD) || exit 1
187
190
  branche="agent/$ticket"
188
- lot=
191
+ base= pointe=
189
192
  if git -C "$racine" rev-parse --verify -q "refs/heads/$branche" > /dev/null; then
190
193
  # A branch already there: the queue sent it back, or it was left without a commit. Its lot,
191
194
  # when it carries one, goes back as local work on main; the branch returns to main.
192
195
  if [ "$(git -C "$racine" rev-list --count "$tete..$branche")" -gt 0 ]; then
193
196
  base=$(git -C "$racine" merge-base "$tete" "$branche") || exit 1
194
- lot=$(mktemp) || exit 1
195
- git -C "$racine" diff --binary "$base" "$branche" > "$lot" || exit 1
197
+ pointe=$(git -C "$racine" rev-parse "$branche") || exit 1
196
198
  fi
197
199
  git -C "$racine" branch -q -f "$branche" "$tete" || exit 1
198
200
  git -C "$racine" worktree add -q "$copie" "$branche" || exit 1
199
201
  else
200
202
  git -C "$racine" worktree add -q -b "$branche" "$copie" HEAD || exit 1
201
203
  fi
202
- if [ -n "$lot" ]; then
203
- # The lot is applied three ways: a conflict is marked in the file, the rest of the lot is
204
- # there. The index is left as HEAD has it, so that all of it is local work.
205
- git -C "$copie" apply --3way "$lot" || [ -n "$(git -C "$copie" ls-files -u)" ] || exit 1
206
- git -C "$copie" reset -q || exit 1
207
- rm -f "$lot"
204
+ if [ -n "$pointe" ]; then
205
+ # The lot as local work, a conflict marked in its file (travail-de-la-copie.mjs).
206
+ node "$ici/travail-de-la-copie.mjs" reporter "$copie" "$base" "$pointe" || exit 1
208
207
  fi
209
208
  else
210
209
  bash "$ici/../sous-modules.sh" garde "$copie" || exit 1
211
- git -C "$copie" merge -q --ff-only --autostash "$(git -C "$racine" rev-parse HEAD)" || exit 1
212
- # A conflicting reapplication exits 0: the unmerged files are what tells it.
213
- conflits=$(git -C "$copie" diff --name-only --diff-filter=U) || exit 1
214
- if [ -n "$conflits" ]; then
215
- echo "⛔ Le travail en cours de la copie entre en conflit avec main ; il reste dans la remise de git (git stash list)."
216
- echo "Fichiers en conflit :"
217
- sed 's/^/ /' <<<"$conflits"
218
- exit 1
219
- fi
210
+ # The work in progress moves with the copy, in the copy: a conflict stops the launch, marked
211
+ # in the files, the log naming each one (travail-de-la-copie.mjs).
212
+ node "$ici/travail-de-la-copie.mjs" avancer "$copie" "$(git -C "$racine" rev-parse HEAD)" || exit 1
220
213
  fi
221
214
  # The list the pose fixes is the one every mount gets, whatever the installation rewrites.
222
215
  partages=$(bash "$ici/../sous-modules.sh" pose "$copie") || exit 1