@roomi-fields/grillhouse 0.24.14 → 0.25.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/bin/grillhouse.mjs +40 -12
- package/cadre/templates/cargo/.config/nextest.toml +8 -0
- package/cadre/templates/cargo/deny.toml +36 -0
- package/cadre/templates/cargo/package.json +15 -0
- package/cadre/templates/cargo/rust-toolchain.toml +6 -0
- package/cadre/templates/projet/package.json +5 -1
- package/cadre/templates/turbo/paquets.json +1 -1
- package/cadre/templates/turbo/sans-paquets.json +1 -1
- package/charte.md +16 -0
- package/docs/ARCHITECTURE.md +167 -17
- package/docs/CADRE.md +47 -0
- package/docs/INTERFACE.md +168 -0
- package/package.json +71 -14
- package/scripts/arbitrages.mjs +23 -0
- package/scripts/avancement.mjs +15 -29
- package/scripts/circuit.mjs +89 -97
- package/scripts/commande-du-langage.mjs +56 -0
- package/scripts/composants-affectes.mjs +47 -170
- package/scripts/conformite.d.ts +27 -0
- package/scripts/conformite.mjs +226 -0
- package/scripts/demon.mjs +1 -1
- package/scripts/dernier-vert.mjs +11 -9
- package/scripts/droits.mjs +27 -21
- package/scripts/enveloppe/enveloppe.mjs +206 -64
- package/scripts/enveloppe/lancer.sh +24 -75
- package/scripts/enveloppe/paquets-du-plan.mjs +24 -2
- package/scripts/etapes.mjs +2 -2
- package/scripts/gardes-du-cadre.mjs +12 -18
- package/scripts/grillhouse-maj.mjs +246 -389
- package/scripts/init.mjs +2 -1
- package/scripts/integration/file.mjs +3 -3
- package/scripts/integration/integrer.mjs +13 -10
- package/scripts/integration/rejeu.mjs +36 -7
- package/scripts/jointure.d.ts +304 -0
- package/scripts/langages/cargo/binaires.json +4 -0
- package/scripts/langages/cargo/binaires.mjs +60 -0
- package/scripts/langages/cargo/clippy.mjs +103 -0
- package/scripts/langages/cargo/commandes.mjs +378 -0
- package/scripts/langages/cargo/composants.mjs +191 -0
- package/scripts/langages/cargo/elements-du-lot.mjs +139 -0
- package/scripts/langages/cargo/exemples.mjs +357 -0
- package/scripts/langages/cargo/frontieres.mjs +84 -0
- package/scripts/langages/cargo/index-interfaces.mjs +138 -0
- package/scripts/langages/cargo/index.mjs +115 -0
- package/scripts/langages/cargo/mise-a-jour.mjs +93 -0
- package/scripts/langages/cargo/nextest.toml +5 -0
- package/scripts/langages/cargo/touches.mjs +93 -0
- package/scripts/langages/cargo/verdict.mjs +85 -0
- package/scripts/langages/typescript/chemins-des-tests.mjs +68 -0
- package/scripts/{code-mort.mjs → langages/typescript/code-mort.mjs} +5 -5
- package/scripts/langages/typescript/composants.mjs +64 -0
- package/scripts/{consommateurs-arbitres.mjs → langages/typescript/consommateurs-arbitres.mjs} +6 -24
- package/scripts/{consommateurs.mjs → langages/typescript/consommateurs.mjs} +13 -71
- package/scripts/langages/typescript/construire.mjs +176 -0
- package/scripts/{elements-du-lot.mjs → langages/typescript/elements-du-lot.mjs} +2 -2
- package/scripts/langages/typescript/exemples.mjs +289 -0
- package/scripts/{frontieres.mjs → langages/typescript/frontieres.mjs} +3 -5
- package/scripts/{index-interfaces.mjs → langages/typescript/index-interfaces.mjs} +3 -3
- package/scripts/langages/typescript/index.mjs +335 -0
- package/scripts/{interfaces-contre-code.mjs → langages/typescript/interfaces-contre-code.mjs} +2 -2
- package/scripts/langages/typescript/lecteurs.mjs +179 -0
- package/scripts/{migrations → langages/typescript/migrations}/0.23.0-config-vitest.mjs +14 -29
- package/scripts/{migrations → langages/typescript/migrations}/0.24.4-noms-declares-inutilises.mjs +2 -2
- package/scripts/{migrations → langages/typescript/migrations}/0.24.6-lignes-mal-formees.mjs +2 -2
- package/scripts/{migrations → langages/typescript/migrations}/0.24.7-matiere-dans-les-tests.mjs +2 -2
- package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +27 -0
- package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +31 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +320 -0
- package/scripts/{references-par-les-types.mjs → langages/typescript/references-par-les-types.mjs} +3 -3
- package/scripts/langages/typescript/regle-des-tests.mjs +39 -0
- package/scripts/{resumes.mjs → langages/typescript/resumes.mjs} +4 -4
- package/scripts/langages/typescript/script-des-tests.mjs +6 -0
- package/scripts/langages/typescript/tailles-des-tests.mjs +219 -0
- package/scripts/langages/typescript/tests-de-nuit.mjs +57 -0
- package/scripts/{tests.mjs → langages/typescript/tests.mjs} +41 -32
- package/scripts/{turbo-des-paquets.mjs → langages/typescript/turbo-des-paquets.mjs} +61 -34
- package/scripts/langages/typescript/verdict.mjs +105 -0
- package/scripts/{verifier.mjs → langages/typescript/verifier.mjs} +53 -34
- package/scripts/{vitest-config → langages/typescript/vitest-config}/avancement.reporter.mjs +10 -2
- package/scripts/{vitest-config → langages/typescript/vitest-config}/base.mjs +63 -9
- package/scripts/{vitest-config → langages/typescript/vitest-config}/changements.mjs +18 -9
- package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
- package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +6 -1
- package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
- package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
- package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
- package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
- package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
- package/scripts/langages.mjs +85 -0
- package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
- package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
- package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
- package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
- package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
- package/scripts/migrations.mjs +17 -13
- package/scripts/nuit.sh +59 -63
- package/scripts/paquets.d.ts +5 -0
- package/scripts/paquets.mjs +24 -2
- package/scripts/resultats.mjs +8 -82
- package/scripts/services-du-noyau.mjs +30 -0
- package/scripts/session-start.sh +17 -9
- package/scripts/sources.mjs +35 -13
- package/scripts/sous-commandes.mjs +57 -17
- package/scripts/superviseur.mjs +1 -1
- package/scripts/tableau.mjs +1 -1
- package/scripts/un-commit-par-ticket.mjs +48 -14
- package/scripts/verrou-de-fichier.mjs +1 -1
- package/scripts/verrou-de-machine.mjs +4 -4
- package/scripts/verrous/verrou.mjs +28 -37
- package/skills/developpeur/SKILL.md +2 -2
- package/skills/explorateur/SKILL.md +13 -5
- package/skills/grill/SKILL.md +2 -2
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/pitmaster/references/consigne-agent.md +10 -3
- package/skills/redacteur/references/documents-d-un-composant.md +4 -4
- package/skills/relecteur/SKILL.md +4 -1
- package/skills/testwriter/SKILL.md +20 -6
- /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
package/scripts/droits.mjs
CHANGED
|
@@ -45,6 +45,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
|
45
45
|
import os from 'node:os';
|
|
46
46
|
import path from 'node:path';
|
|
47
47
|
import { pathToFileURL } from 'node:url';
|
|
48
|
+
import { langageDe } from './langages.mjs';
|
|
48
49
|
|
|
49
50
|
// The variable in which bd reads the author of a comment (`bd --help`: « default: $BEADS_ACTOR,
|
|
50
51
|
// git user.name, $USER »).
|
|
@@ -94,23 +95,6 @@ const LIRE_GIT = [
|
|
|
94
95
|
'Bash(git -C * ls-files*)',
|
|
95
96
|
'Bash(git -C * grep*)',
|
|
96
97
|
];
|
|
97
|
-
// The test tool run directly, Vitest or Turborepo that plays it (charter, « Aucun agent ne lance
|
|
98
|
-
// l'outil de test directement »): `npm test` and `npm run verifier` play it with what it depends on.
|
|
99
|
-
// `turbo *` ends on a word, so `npx grillhouse turbo-des-paquets` stays open.
|
|
100
|
-
const TEST_DIRECT = [
|
|
101
|
-
'Bash(vitest*)',
|
|
102
|
-
'Bash(npx vitest*)',
|
|
103
|
-
'Bash(npx * vitest*)',
|
|
104
|
-
'Bash(npm exec vitest*)',
|
|
105
|
-
'Bash(npm exec * vitest*)',
|
|
106
|
-
'Bash(node_modules/.bin/vitest*)',
|
|
107
|
-
'Bash(turbo *)',
|
|
108
|
-
'Bash(npx turbo *)',
|
|
109
|
-
'Bash(npx * turbo *)',
|
|
110
|
-
'Bash(npm exec turbo *)',
|
|
111
|
-
'Bash(npm exec * turbo *)',
|
|
112
|
-
'Bash(node_modules/.bin/turbo *)',
|
|
113
|
-
];
|
|
114
98
|
// The skills Claude Code keeps listed when its own are off (`disableBundledSkills`), measured on
|
|
115
99
|
// Claude Code 2.1.305.
|
|
116
100
|
const INTEGREES = ['design', 'doctor', 'plugin-authoring'];
|
|
@@ -137,9 +121,10 @@ const ECRIRE = ['Edit', 'Write'];
|
|
|
137
121
|
export const ROLES = {
|
|
138
122
|
// It writes no file and nothing at the ticket: it surveys the components and reads the code by
|
|
139
123
|
// the index, and ends on the plan in its sheet, which the circuit writes at the ticket. At the
|
|
140
|
-
// tri of the discoveries, it reads each one and its parent, the
|
|
141
|
-
//
|
|
142
|
-
// of types of its export; no pass (grillhouse-0yu.5).
|
|
124
|
+
// tri of the discoveries, it reads each one and its parent, the commit of main and its history
|
|
125
|
+
// (`git show`, `git log`, in its working directory, the main tree, or by `git -C`), and builds
|
|
126
|
+
// a package before it judges an error of types of its export; no pass (grillhouse-0yu.5). Its
|
|
127
|
+
// instruction of the tri lists these commands (`commandesPermises`, grillhouse-6ve).
|
|
143
128
|
explorateur: {
|
|
144
129
|
metacadre: true,
|
|
145
130
|
index: true,
|
|
@@ -147,6 +132,10 @@ export const ROLES = {
|
|
|
147
132
|
commandes: [
|
|
148
133
|
'Bash(bd show *)',
|
|
149
134
|
'Bash(bd comments *)',
|
|
135
|
+
'Bash(git show *)',
|
|
136
|
+
'Bash(git log *)',
|
|
137
|
+
'Bash(git -C * show *)',
|
|
138
|
+
'Bash(git -C * log *)',
|
|
150
139
|
'Bash(npx grillhouse composants-affectes *)',
|
|
151
140
|
'Bash(npm run build -- --filter=*)',
|
|
152
141
|
'Bash(codegraph explore *)',
|
|
@@ -212,6 +201,21 @@ export const ROLES = {
|
|
|
212
201
|
},
|
|
213
202
|
};
|
|
214
203
|
|
|
204
|
+
// The commands the rights of <role> permit (ROLES.<role>.commandes), one line each, in Markdown, as
|
|
205
|
+
// the help of a tool lists its commands: a rule of Bash as its command, `…` for its wildcard; a
|
|
206
|
+
// tool by its name. Its instruction carries them, so that it names no command its rights refuse.
|
|
207
|
+
/** @param {keyof typeof ROLES} role @returns {string} */
|
|
208
|
+
export function commandesPermises(role) {
|
|
209
|
+
return ROLES[role].commandes
|
|
210
|
+
.map(r => {
|
|
211
|
+
const bash = /^Bash\((.*)\)$/.exec(r);
|
|
212
|
+
return bash
|
|
213
|
+
? `- \`${bash[1].replaceAll('*', '…')}\``
|
|
214
|
+
: `- l'outil \`${r.split('__').at(-1)}\``;
|
|
215
|
+
})
|
|
216
|
+
.join('\n');
|
|
217
|
+
}
|
|
218
|
+
|
|
215
219
|
const lireJson = f => {
|
|
216
220
|
try {
|
|
217
221
|
return JSON.parse(readFileSync(f, 'utf8'));
|
|
@@ -287,7 +291,9 @@ function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
|
|
|
287
291
|
if (!r) throw new Error(`rôle sans droits : ${role}`);
|
|
288
292
|
const deny = [...AUTEUR_FIXE, ...(r.ecritAuTicket === false ? ECRIRE_AU_TICKET : [])];
|
|
289
293
|
if (r.ecrit) {
|
|
290
|
-
|
|
294
|
+
// The test tool run directly (charter, « Aucun agent ne lance l'outil de test directement »),
|
|
295
|
+
// as the module of the copy's language names it: `npm test` and `npm run verifier` play it.
|
|
296
|
+
deny.push(...ECRIRE_PAR_SCRIPT, ...langageDe(copie).droits);
|
|
291
297
|
// The ticket its instruction carries, its description, notes and last handover.
|
|
292
298
|
for (const lecture of ['show', 'comments']) {
|
|
293
299
|
deny.push(`Bash(bd ${lecture} ${ticket})`, `Bash(bd ${lecture} ${ticket} *)`);
|
|
@@ -15,9 +15,19 @@
|
|
|
15
15
|
// the real file does not change. The tickets base (the main tree's `.beads/`) is written: the
|
|
16
16
|
// agent claims, plans, hands over and files what it finds. Every `.git`, the copy's included,
|
|
17
17
|
// stays read-only: the agent reads the git state and delivers a patch (`git diff`, and
|
|
18
|
-
// `git diff --no-index /dev/null <file>` for a new file); it never commits.
|
|
19
|
-
//
|
|
20
|
-
//
|
|
18
|
+
// `git diff --no-index /dev/null <file>` for a new file); it never commits.
|
|
19
|
+
// - Where the tools of the project's language write is what its module declares (`sorties`,
|
|
20
|
+
// scripts/jointure.d.ts; `sortiesDuLangage`), as a sandbox of Bazel opens in writing what the
|
|
21
|
+
// action declares: its stores, in the main tree (`//…`, TypeScript's cache of Turborepo, shared
|
|
22
|
+
// by every copy) or in the home (`~/…`, cargo's registry, git dependencies, advisories and the
|
|
23
|
+
// lock and cache files at the root of `~/.cargo`), are written, so the agent's runs of `npm
|
|
24
|
+
// test` keep their work there, as every copy's runs do; what its tools read (cargo's home,
|
|
25
|
+
// `~/.cargo` with its `env`, its configuration and its binaries, and rustup's `~/.rustup`) comes
|
|
26
|
+
// back read-only under them, nothing a shell sources written; its outputs in the copy (cargo's
|
|
27
|
+
// `target`) come back in writing; and its outputs proper to the session (TypeScript's `.turbo`
|
|
28
|
+
// and `node_modules/.vite`) are below. Each written path is created on disk before the session,
|
|
29
|
+
// a directory or, without a trailing `/` in the module's list, an empty file, so that bwrap
|
|
30
|
+
// mounts it.
|
|
21
31
|
// - The home and the session directories (`$XDG_RUNTIME_DIR`, `/run/user/<uid>`) show only what
|
|
22
32
|
// the envelope declares: each starts empty and sealed read-only, and the home gets back
|
|
23
33
|
// `~/.claude`, `~/.claude.json`, the npm cache, the paths of `MAISON_EN_LECTURE` (claude, node,
|
|
@@ -51,49 +61,68 @@
|
|
|
51
61
|
// (`packages/a`, or `src/parser` in a one-package project), in the variable's form
|
|
52
62
|
// (`ecrireLaListe` of paquets-du-plan.mjs); <rôle> is the agent's role (`testwriter`,
|
|
53
63
|
// `developpeur`…).
|
|
54
|
-
// - The plan writes, for each of its paths, the
|
|
55
|
-
//
|
|
64
|
+
// - The plan writes, for each of its paths, the component of the copy that holds it (`ecritsDuPlan`,
|
|
65
|
+
// the components of the module of the language, `paquetsDuLangage`: a package of TypeScript, a
|
|
66
|
+
// crate of cargo), as a sandbox of Bazel or of Nix opens in writing only
|
|
56
67
|
// what the action declares: the rest of the copy is read-only, the folders of its root that no
|
|
57
68
|
// package holds (`libraries/`, `spec/`) included, and a write there fails on « Read-only file
|
|
58
|
-
// system », which the agent sees. Where
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
69
|
+
// system », which the agent sees. Where the language's tools write at the root of the copy is
|
|
70
|
+
// then an empty directory proper to the session, or comes back in writing, as its module
|
|
71
|
+
// declares. A component writes itself alone, a crate or a package, `src/parser` of a
|
|
72
|
+
// one-package project included (a component of the module typescript), as does a package out of
|
|
73
|
+
// the frame (`docs/agents/hors-cadre.txt`). A path that no component holds (a folder of the
|
|
74
|
+
// root, `scripts`; `.`) writes the package that holds it, the root: the copy stays written, its
|
|
75
|
+
// `.git` read-only.
|
|
63
76
|
// - The package of the shared test material is every component of <copie> whose `package.json`
|
|
64
|
-
// exports `./test-fixtures` (`matieres` of
|
|
77
|
+
// exports `./test-fixtures` (`matieres` of the module of the language). It is mounted after the
|
|
65
78
|
// packages of the plan: written for the `testwriter`, read-only for every other role, in the
|
|
66
|
-
// plan or not. For such a role, where a run of its tests writes in it (
|
|
67
|
-
// Turborepo's task logs, Vite's cache) is an empty directory proper to
|
|
68
|
-
// writes a test's logs out of its source: what is written there leaves no
|
|
69
|
-
// creates each of them on disk, empty, before the session, so that bwrap
|
|
70
|
-
// the read-only package.
|
|
79
|
+
// plan or not. For such a role, where a run of its tests writes in it (the module's outputs
|
|
80
|
+
// proper to the session: Turborepo's task logs, Vite's cache) is an empty directory proper to
|
|
81
|
+
// the session, as Bazel writes a test's logs out of its source: what is written there leaves no
|
|
82
|
+
// trace. The envelope creates each of them on disk, empty, before the session, so that bwrap
|
|
83
|
+
// mounts over it inside the read-only package.
|
|
71
84
|
// - The exit codes are named in `codes.mjs`.
|
|
72
85
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
73
|
-
import {
|
|
86
|
+
import {
|
|
87
|
+
copyFileSync,
|
|
88
|
+
existsSync,
|
|
89
|
+
mkdirSync,
|
|
90
|
+
lstatSync,
|
|
91
|
+
readlinkSync,
|
|
92
|
+
writeFileSync,
|
|
93
|
+
} from 'node:fs';
|
|
74
94
|
import os from 'node:os';
|
|
75
95
|
import path from 'node:path';
|
|
76
96
|
import { pathToFileURL } from 'node:url';
|
|
77
|
-
import {
|
|
78
|
-
import { paquets as lesPaquets } from '../paquets.mjs';
|
|
97
|
+
import { langageDe } from '../langages.mjs';
|
|
79
98
|
import { CODE_REFUS, CODE_USAGE } from './codes.mjs';
|
|
80
|
-
import {
|
|
81
|
-
|
|
99
|
+
import {
|
|
100
|
+
ecritsDuPlan,
|
|
101
|
+
ecrireLaListe,
|
|
102
|
+
lireLaListe,
|
|
103
|
+
paquetsDuLangage,
|
|
104
|
+
VARIABLE,
|
|
105
|
+
} from './paquets-du-plan.mjs';
|
|
106
|
+
|
|
107
|
+
export { paquetsDuLangage };
|
|
108
|
+
import { ouvrirBase } from '../mesure/base-de-passe.mjs';
|
|
82
109
|
|
|
83
110
|
// The role that writes the package of the shared test material.
|
|
84
111
|
const ROLE_MATIERE = 'testwriter';
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
112
|
+
// The directories <sorties> of <dir>, each relative to it.
|
|
113
|
+
// One that a symbolic link carries out of <dir> (a `node_modules` linked to another tree's) is
|
|
114
|
+
// left out: it is not the copy's, and bwrap could not mount over it. `lien(path)` gives the text
|
|
115
|
+
// of the link at <path>, or null.
|
|
116
|
+
const sortiesDe = (dir, sorties, lien = () => null) =>
|
|
117
|
+
sorties
|
|
118
|
+
.filter(s => {
|
|
119
|
+
let p = dir;
|
|
120
|
+
return s.split('/').every(segment => {
|
|
121
|
+
p = path.join(p, segment);
|
|
122
|
+
return lien(p) === null;
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
.map(s => path.join(dir, s));
|
|
97
126
|
// The machine's temporary directory: an empty one, proper to the session, replaces it.
|
|
98
127
|
const TEMPORAIRE = '/tmp';
|
|
99
128
|
// What stays read-only inside `~/.claude`: the configuration and what it loads.
|
|
@@ -166,7 +195,7 @@ const EPREUVE =
|
|
|
166
195
|
// Code keeps them under `<temporary>/claude-<uid>/<working directory in dashes>/`, every sign
|
|
167
196
|
// outside [A-Za-z0-9] a dash, <temporary> its `CLAUDE_CODE_TMPDIR`, else the system's temporary
|
|
168
197
|
// directory as `os.tmpdir()` reads it (TMPDIR, TMP, TEMP, else /tmp): under a pass, the base of
|
|
169
|
-
// the pass (scripts/
|
|
198
|
+
// the pass (scripts/mesure/base-de-passe.mjs), removed with it.
|
|
170
199
|
function scratchpadsDe(copie, env = process.env) {
|
|
171
200
|
const enTirets = path.resolve(copie).replace(/[^A-Za-z0-9]/g, '-');
|
|
172
201
|
const temporaire = env.CLAUDE_CODE_TMPDIR || env.TMPDIR || env.TMP || env.TEMP || TEMPORAIRE;
|
|
@@ -186,7 +215,7 @@ export function dossierDeTravail(copie, env = process.env) {
|
|
|
186
215
|
// script: a `prepare` that writes under the read-only `.git` would fail `npm install`; the
|
|
187
216
|
// launcher installs outside the session), `TMPDIR` set to the session's working directory
|
|
188
217
|
// <travail>, and `GRILLHOUSE_ENVELOPPE` set to the plan <paquets>. Nothing else of <env> enters.
|
|
189
|
-
function environnementDeLaSeance(env, { cacheNpm, paquets, travail }) {
|
|
218
|
+
export function environnementDeLaSeance(env, { cacheNpm, paquets, travail }) {
|
|
190
219
|
const declare = nom =>
|
|
191
220
|
ENVIRONNEMENT_DECLARE.includes(nom) ||
|
|
192
221
|
VARIABLES_DE_CHEMIN.includes(nom) ||
|
|
@@ -268,6 +297,62 @@ const lienSurDisque = p => {
|
|
|
268
297
|
}
|
|
269
298
|
};
|
|
270
299
|
|
|
300
|
+
/**
|
|
301
|
+
* The outputs <s> of the module of the language (its `sorties`, scripts/jointure.d.ts) for a
|
|
302
|
+
* session whose home is <maison> and whose main tree is <principal>: `lectures`, what its tools
|
|
303
|
+
* read, absolute (`~/…` from the home, `//…` from the main tree), mounted read-only;
|
|
304
|
+
* `magasins`, the stores written, absolute, mounted after them; `sorties`, what the copy holds,
|
|
305
|
+
* from its root: `ecrites` in writing, `propres` proper to the session; `fichiers`, the written
|
|
306
|
+
* paths of `magasins` and `sorties.ecrites` that are files (written without a trailing `/`), which
|
|
307
|
+
* the envelope creates empty when absent, the others directories.
|
|
308
|
+
* @param {{ ecrites: string[], propres: string[], lues: string[] }} s
|
|
309
|
+
* @param {{ maison: string, principal: string }} o
|
|
310
|
+
* @returns {{ magasins: string[], lectures: string[], fichiers: string[], sorties: { ecrites: string[], propres: string[] } }}
|
|
311
|
+
*/
|
|
312
|
+
export function sortiesDuLangage(s, { maison, principal }) {
|
|
313
|
+
/** @param {string} e */
|
|
314
|
+
const absolu = e =>
|
|
315
|
+
e.startsWith('~/')
|
|
316
|
+
? path.join(maison, e.slice(2))
|
|
317
|
+
: e.startsWith('//')
|
|
318
|
+
? path.join(principal, e.slice(2))
|
|
319
|
+
: null;
|
|
320
|
+
/** @param {string} e */
|
|
321
|
+
const nu = e => e.replace(/\/+$/, '');
|
|
322
|
+
/** @type {string[]} */
|
|
323
|
+
const magasins = [];
|
|
324
|
+
/** @type {string[]} */
|
|
325
|
+
const ecrites = [];
|
|
326
|
+
/** @type {string[]} */
|
|
327
|
+
const fichiers = [];
|
|
328
|
+
for (const e of s.ecrites) {
|
|
329
|
+
const a = absolu(e);
|
|
330
|
+
const p = a === null ? nu(e) : nu(a);
|
|
331
|
+
if (a === null) {
|
|
332
|
+
ecrites.push(p);
|
|
333
|
+
} else {
|
|
334
|
+
magasins.push(p);
|
|
335
|
+
}
|
|
336
|
+
if (!e.endsWith('/')) {
|
|
337
|
+
fichiers.push(p);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const lectures = s.lues.map(absolu).flatMap(a => (a === null ? [] : [nu(a)]));
|
|
341
|
+
return { magasins, lectures, fichiers, sorties: { ecrites, propres: [...s.propres] } };
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Creates the directory, or the empty file when <fichier>, <chemin>, when it is absent.
|
|
345
|
+
function creer(chemin, fichier) {
|
|
346
|
+
if (!fichier) {
|
|
347
|
+
mkdirSync(chemin, { recursive: true });
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
mkdirSync(path.dirname(chemin), { recursive: true });
|
|
351
|
+
if (!existsSync(chemin)) {
|
|
352
|
+
writeFileSync(chemin, '');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
271
356
|
// The worktrees of the repository that holds <copie>, main tree first.
|
|
272
357
|
function worktrees(copie) {
|
|
273
358
|
const out = execFileSync('git', ['-C', copie, 'worktree', 'list', '--porcelain'], {
|
|
@@ -286,7 +371,7 @@ const inside = (child, parent) => {
|
|
|
286
371
|
|
|
287
372
|
// The refusal of <composant> in the repository at <depot>, or null when it is the path of a
|
|
288
373
|
// directory there (`.`, the whole repository, included). A <composant> that is the name of a
|
|
289
|
-
//
|
|
374
|
+
// component of `paquets` (`paquetsDuLangage`), or the name of its folder, is told
|
|
290
375
|
// its path, as git says « did you mean ». `fs` gives `existe(path)`. The launcher judges the
|
|
291
376
|
// component with it before preparing the copy, in the ticket's copy when it exists, else in the
|
|
292
377
|
// main tree or in the tree of the ticket's branch, its `existe` accepting either; `plan` judges it
|
|
@@ -303,16 +388,41 @@ export function jugerComposant({ depot, composant, paquets = [] }, fs) {
|
|
|
303
388
|
}
|
|
304
389
|
|
|
305
390
|
// The bwrap arguments for this agent, or the refusal that stops its launch. `paquets` is the plan,
|
|
306
|
-
// the paths it names relative to the copy; `paquetsDeLaCopie` lists the
|
|
307
|
-
// (`
|
|
391
|
+
// the paths it names relative to the copy; `paquetsDeLaCopie` lists the components of the copy
|
|
392
|
+
// (`paquetsDuLangage`, the module's `composants`: the packages of TypeScript, the crates of cargo),
|
|
393
|
+
// which `jugerComposant` reads to judge each path and
|
|
308
394
|
// `ecritsDuPlan` to find the package that holds it. `montages` lists, in order, the paths outside
|
|
309
395
|
// the copy that are emptied, written, read back or made a symbolic link (`lien`, its text)
|
|
310
396
|
// (`montagesDeLaSeance`); an emptied one marked `scelle` is sealed read-only once every mount
|
|
311
397
|
// inside it is made. `matieres` lists the packages of the shared test material, relative to the
|
|
312
|
-
// copy (`matieres` of
|
|
313
|
-
// `testwriter` writes them. `magasins` lists the
|
|
314
|
-
//
|
|
315
|
-
//
|
|
398
|
+
// 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
|
|
400
|
+
// (the module's, `sortiesDuLangage`: Turborepo's `<main tree>/.turbo/cache`, cargo's registry,
|
|
401
|
+
// git dependencies, advisories and lock files in the home); one that does not exist is not
|
|
402
|
+
// mounted. `lectures` lists what the language's tools read (cargo's home, rustup's toolchains),
|
|
403
|
+
// mounted read-only before the stores, which come back in writing inside it; one that does not
|
|
404
|
+
// exist is not mounted. `sorties` lists, from the root of the copy,
|
|
405
|
+
// where a run of the language's tools writes (`sortiesDuLangage`): `ecrites` in writing, `propres`
|
|
406
|
+
// an empty directory proper to the session, there and in each package of the material the role
|
|
407
|
+
// does not write; one that does not exist, or that a symbolic link carries out of the copy, is not
|
|
408
|
+
// mounted. `fs` gives `existe(path)`, and `lien(path)`, the text of a link or null, so the plan is
|
|
409
|
+
// testable without disk.
|
|
410
|
+
/**
|
|
411
|
+
* @param {{
|
|
412
|
+
* trees: string[],
|
|
413
|
+
* copie: string,
|
|
414
|
+
* paquets?: string[],
|
|
415
|
+
* role?: string,
|
|
416
|
+
* matieres?: string[],
|
|
417
|
+
* montages?: { chemin: string, source?: string, ecriture?: boolean, vide?: boolean, scelle?: boolean, lien?: string }[],
|
|
418
|
+
* magasins?: string[],
|
|
419
|
+
* lectures?: string[],
|
|
420
|
+
* sorties?: { ecrites: string[], propres: string[] },
|
|
421
|
+
* paquetsDeLaCopie?: { dossier: string, pkg?: { name?: string } }[],
|
|
422
|
+
* }} o
|
|
423
|
+
* @param {{ existe(p: string): boolean, lien?: (p: string) => string | null }} fs
|
|
424
|
+
* @returns {{ args: string[], refus?: undefined } | { refus: string, args?: undefined }}
|
|
425
|
+
*/
|
|
316
426
|
export function plan(
|
|
317
427
|
{
|
|
318
428
|
trees,
|
|
@@ -322,6 +432,8 @@ export function plan(
|
|
|
322
432
|
matieres = [],
|
|
323
433
|
montages = [],
|
|
324
434
|
magasins = [],
|
|
435
|
+
lectures = [],
|
|
436
|
+
sorties = { ecrites: [], propres: [] },
|
|
325
437
|
paquetsDeLaCopie = [],
|
|
326
438
|
},
|
|
327
439
|
fs
|
|
@@ -368,13 +480,26 @@ export function plan(
|
|
|
368
480
|
}
|
|
369
481
|
// The copy is mounted after them: an emptied /tmp does not hide it. It is read-only, and the
|
|
370
482
|
// packages of the plan come back in writing below, as a sandbox of Bazel opens only what the
|
|
371
|
-
// action declares; where a run of
|
|
372
|
-
// the session
|
|
483
|
+
// action declares; where a run of the language's tools writes at the root is an empty directory
|
|
484
|
+
// proper to the session, or comes back in writing, as its module declares. A plan that writes the
|
|
485
|
+
// root writes the whole copy. Its .git stays read-only.
|
|
373
486
|
args.push(toute ? '--bind' : '--ro-bind', copie, copie);
|
|
374
|
-
if (!toute)
|
|
487
|
+
if (!toute) {
|
|
488
|
+
for (const s of sortiesDe(copie, sorties.propres, fs.lien))
|
|
489
|
+
if (fs.existe(s)) args.push('--tmpfs', s);
|
|
490
|
+
for (const s of sortiesDe(copie, sorties.ecrites, fs.lien))
|
|
491
|
+
if (fs.existe(s)) args.push('--bind', s, s);
|
|
492
|
+
}
|
|
375
493
|
const gitDeLaCopie = path.join(copie, '.git');
|
|
376
494
|
if (fs.existe(gitDeLaCopie)) args.push('--ro-bind', gitDeLaCopie, gitDeLaCopie);
|
|
377
|
-
//
|
|
495
|
+
// What the language's tools read (cargo's home) comes back read-only; then the stores inside it
|
|
496
|
+
// or beside it (Turborepo's cache, cargo's registry and locks) are written by the agent's runs,
|
|
497
|
+
// as by every copy's.
|
|
498
|
+
for (const l of lectures) {
|
|
499
|
+
if (fs.existe(l)) {
|
|
500
|
+
args.push('--ro-bind', l, l);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
378
503
|
for (const m of magasins) if (fs.existe(m)) args.push('--bind', m, m);
|
|
379
504
|
const tickets = trees.length > 0 ? path.join(trees[0], '.beads') : null;
|
|
380
505
|
if (tickets && fs.existe(tickets)) args.push('--bind', tickets, tickets);
|
|
@@ -389,7 +514,8 @@ export function plan(
|
|
|
389
514
|
// What a run of its tests writes goes, for a role that does not write it, to an empty
|
|
390
515
|
// directory proper to the session, as Bazel writes a test's logs out of its source.
|
|
391
516
|
if (role === ROLE_MATIERE) continue;
|
|
392
|
-
for (const s of
|
|
517
|
+
for (const s of sortiesDe(m, sorties.propres, fs.lien))
|
|
518
|
+
if (fs.existe(s)) args.push('--tmpfs', s);
|
|
393
519
|
}
|
|
394
520
|
// The emptied directories close behind the mounts: nothing new is written there.
|
|
395
521
|
for (const { chemin } of montages.filter(m => m.scelle)) args.push('--remount-ro', chemin);
|
|
@@ -397,7 +523,7 @@ export function plan(
|
|
|
397
523
|
return { args };
|
|
398
524
|
}
|
|
399
525
|
|
|
400
|
-
const disque = { existe: existsSync };
|
|
526
|
+
const disque = { existe: existsSync, lien: lienSurDisque };
|
|
401
527
|
|
|
402
528
|
// The command: the session of <commande> in the envelope of the plan <paquets> in <copie>; its
|
|
403
529
|
// exit code.
|
|
@@ -428,7 +554,7 @@ function envelopper(argv) {
|
|
|
428
554
|
mkdirSync(travail, { recursive: true });
|
|
429
555
|
// `~/.claude.json` holds the permissions and servers of every project: it enters the session
|
|
430
556
|
// as a throwaway copy, in a base of its own removed on exit and swept when the envelope is
|
|
431
|
-
// killed (../
|
|
557
|
+
// killed (../mesure/base-de-passe.mjs).
|
|
432
558
|
const temporaire = ouvrirBase('enveloppe');
|
|
433
559
|
const etatJetable = path.join(temporaire.dossier, 'claude.json');
|
|
434
560
|
if (existsSync(`${claude}.json`)) copyFileSync(`${claude}.json`, etatJetable);
|
|
@@ -444,29 +570,43 @@ function envelopper(argv) {
|
|
|
444
570
|
montagesDeLaSeance({ cacheNpm, claude, projet, etatJetable, scratchpads, sessions }),
|
|
445
571
|
lienSurDisque
|
|
446
572
|
);
|
|
447
|
-
const
|
|
573
|
+
const langage = langageDe(copie);
|
|
574
|
+
const matieres = langage.matieres(copie).map(m => path.relative(copie, m.dossier));
|
|
575
|
+
// The outputs of the language: its stores in the home or in the main tree (the folder of git's
|
|
576
|
+
// common directory), and where its tools write in the copy.
|
|
577
|
+
const commun = execFileSync(
|
|
578
|
+
'git',
|
|
579
|
+
['-C', copie, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
|
|
580
|
+
{ encoding: 'utf8' }
|
|
581
|
+
).trim();
|
|
582
|
+
const { magasins, lectures, fichiers, sorties } = sortiesDuLangage(langage.sorties, {
|
|
583
|
+
maison: os.homedir(),
|
|
584
|
+
principal: path.dirname(commun),
|
|
585
|
+
});
|
|
448
586
|
// For a role that does not write it, the directories where a run of the material's tests writes
|
|
449
587
|
// are created here, so that bwrap mounts an empty one over each inside the read-only package.
|
|
450
588
|
if (role !== ROLE_MATIERE) {
|
|
451
589
|
for (const m of matieres) {
|
|
452
|
-
for (const s of
|
|
590
|
+
for (const s of sortiesDe(path.join(copie, m), sorties.propres, lienSurDisque)) {
|
|
591
|
+
mkdirSync(s, { recursive: true });
|
|
592
|
+
}
|
|
453
593
|
}
|
|
454
594
|
}
|
|
455
|
-
// For a plan that leaves the root read-only, where
|
|
456
|
-
// copy is created here, so that bwrap mounts
|
|
457
|
-
const paquetsDeLaCopie =
|
|
595
|
+
// For a plan that leaves the root read-only, where the language's tools write at the root of the
|
|
596
|
+
// copy is created here, so that bwrap mounts it, empty or in writing, inside the read-only copy.
|
|
597
|
+
const paquetsDeLaCopie = paquetsDuLangage(langage, copie);
|
|
458
598
|
if (!ecritsDuPlan(paquets, paquetsDeLaCopie).includes('.')) {
|
|
459
|
-
for (const s of
|
|
599
|
+
for (const s of sortiesDe(copie, sorties.propres, lienSurDisque)) {
|
|
600
|
+
mkdirSync(s, { recursive: true });
|
|
601
|
+
}
|
|
602
|
+
for (const s of sortiesDe(copie, sorties.ecrites, lienSurDisque)) {
|
|
603
|
+
creer(s, fichiers.includes(path.relative(copie, s)));
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
// The stores, created here so that bwrap mounts them in writing.
|
|
607
|
+
for (const m of magasins) {
|
|
608
|
+
creer(m, fichiers.includes(m));
|
|
460
609
|
}
|
|
461
|
-
// The cache of Turborepo, in the main tree (the folder of git's common directory), created here
|
|
462
|
-
// so that bwrap mounts it in writing.
|
|
463
|
-
const commun = execFileSync(
|
|
464
|
-
'git',
|
|
465
|
-
['-C', copie, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
|
|
466
|
-
{ encoding: 'utf8' }
|
|
467
|
-
).trim();
|
|
468
|
-
const magasins = [path.join(path.dirname(commun), '.turbo', 'cache')];
|
|
469
|
-
for (const m of magasins) mkdirSync(m, { recursive: true });
|
|
470
610
|
const { args, refus } = plan(
|
|
471
611
|
{
|
|
472
612
|
trees: worktrees(copie),
|
|
@@ -476,6 +616,8 @@ function envelopper(argv) {
|
|
|
476
616
|
matieres,
|
|
477
617
|
montages,
|
|
478
618
|
magasins,
|
|
619
|
+
lectures,
|
|
620
|
+
sorties,
|
|
479
621
|
paquetsDeLaCopie,
|
|
480
622
|
},
|
|
481
623
|
disque
|