@roomi-fields/grillhouse 0.45.1 → 0.47.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 +52 -0
- package/cadre/templates/c/package.json +19 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +34 -49
- package/cadre/templates/projet/.github/workflows/machine-vierge.yml +101 -0
- package/cadre/templates/projet/CLAUDE.md +28 -5
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/charte.md +61 -23
- package/dist/temporal/circuit/appel.d.ts +7 -0
- package/dist/temporal/circuit/appel.js +17 -0
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +28 -5
- package/dist/temporal/circuit/client.js +56 -13
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +16 -4
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +22 -2
- package/dist/temporal/circuit/contrat.js +76 -0
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +68 -11
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +2 -0
- package/dist/temporal/file/activites.js +7 -0
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +28 -18
- package/dist/temporal/file/contrat.js +8 -5
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.d.ts +1 -1
- package/dist/temporal/file/deroule.js +91 -42
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.d.ts +1 -0
- package/dist/temporal/tickets/activites.js +37 -11
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +14 -0
- package/dist/temporal/tickets/deroule.js +16 -3
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/docs/ARCHITECTURE.md +309 -128
- package/docs/INTERFACE.md +42 -22
- package/hooks/register.tsx +30 -0
- package/package.json +1 -1
- package/scripts/activites.mjs +60 -21
- package/scripts/arbres-juges.mjs +59 -0
- package/scripts/attente-a-l-arret.mjs +29 -52
- package/scripts/attente-au-tour.mjs +8 -26
- package/scripts/avancement.mjs +2 -38
- package/scripts/branche-de-nuit.mjs +14 -45
- package/scripts/ci-de-main.mjs +273 -0
- package/scripts/circuit.mjs +204 -64
- package/scripts/circuits-cles.d.mts +9 -0
- package/scripts/circuits-cles.mjs +38 -0
- package/scripts/coeurs-dedies.mjs +4 -3
- package/scripts/dernier-vert.mjs +78 -10
- package/scripts/enveloppe/travail-de-la-copie.mjs +5 -2
- package/scripts/etapes.mjs +7 -2
- package/scripts/faits-du-circuit.mjs +63 -28
- package/scripts/fichiers-nommes.mjs +55 -0
- package/scripts/file-des-tickets.d.mts +17 -0
- package/scripts/file-des-tickets.mjs +39 -0
- package/scripts/grillhouse-maj.mjs +20 -1
- package/scripts/integration/file.mjs +137 -592
- package/scripts/integration/integrer.mjs +10 -7
- package/scripts/langages/c/binaires.json +4 -0
- package/scripts/langages/c/binaires.mjs +83 -0
- package/scripts/langages/c/clang-format.mjs +62 -0
- package/scripts/langages/c/clang-tidy.mjs +93 -0
- package/scripts/langages/c/clang.mjs +42 -0
- package/scripts/langages/c/commandes.mjs +530 -0
- package/scripts/langages/c/composants.mjs +209 -0
- package/scripts/langages/c/exemples.mjs +250 -0
- package/scripts/langages/c/index-interfaces.mjs +77 -0
- package/scripts/langages/c/index.mjs +120 -0
- package/scripts/langages/c/lot.mjs +41 -0
- package/scripts/langages/c/mise-a-jour.mjs +70 -0
- package/scripts/langages/c/squelette.mjs +61 -0
- package/scripts/langages/c/verdict.mjs +99 -0
- package/scripts/langages/cargo/clippy.mjs +16 -9
- package/scripts/langages/cargo/commandes.mjs +7 -2
- package/scripts/langages/cargo/sccache.mjs +19 -6
- package/scripts/langages/typescript/tests.mjs +31 -5
- package/scripts/langages/typescript/turbo-des-paquets.mjs +67 -8
- package/scripts/langages/typescript/vitest-config/changements.mjs +32 -3
- package/scripts/langages/typescript/vitest-config/lances.mjs +16 -0
- package/scripts/langages-des-paquets.mjs +30 -2
- package/scripts/langages.mjs +1 -0
- package/scripts/limite-d-usage.mjs +88 -0
- package/scripts/mesure/avancement.mjs +1 -1
- package/scripts/migrations/0.47.0-ci-de-main.mjs +48 -0
- package/scripts/migrations.mjs +2 -2
- package/scripts/outils-cles.d.mts +13 -5
- package/scripts/outils-cles.mjs +157 -17
- package/scripts/passe-de-la-machine.mjs +26 -2
- package/scripts/places-de-la-machine.mjs +52 -6
- package/scripts/plafond-de-la-machine.d.mts +10 -2
- package/scripts/plafond-de-la-machine.mjs +39 -13
- package/scripts/reponses-du-circuit.d.mts +16 -0
- package/scripts/reponses-du-circuit.mjs +39 -3
- package/scripts/resultats.mjs +32 -11
- package/scripts/seances.mjs +211 -59
- package/scripts/session-start.sh +2 -11
- package/scripts/sortie.mjs +1 -1
- package/scripts/sous-commandes.mjs +5 -2
- package/scripts/superviseur.mjs +305 -295
- package/scripts/tableau.mjs +73 -45
- package/scripts/transitions.d.mts +22 -1
- package/scripts/transitions.mjs +111 -13
- package/scripts/workflows-du-cadre.mjs +21 -1
- package/skills/explorateur/SKILL.md +34 -13
- package/skills/grill/SKILL.md +6 -5
- package/skills/pitmaster/SKILL.md +33 -27
- package/skills/redacteur/references/documents-d-un-composant.md +1 -1
- package/skills/relecteur/SKILL.md +6 -0
- package/skills/testwriter/SKILL.md +4 -0
- package/scripts/ci-des-branches.mjs +0 -93
- package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +0 -31
|
@@ -78,13 +78,22 @@ export function constats(racine) {
|
|
|
78
78
|
// The rows that declare a package, each table read by its own column of the names.
|
|
79
79
|
const declarees = tableauxDesComposants(racine).flatMap(t => {
|
|
80
80
|
const lignes = t.lignes.filter(l => langageDeLaCellule(l.cellules[t.colonne]));
|
|
81
|
+
// Without a component the table names, the column of the names is the first where a cell names
|
|
82
|
+
// a folder of the project: a table of packages whose manifests all lack is still read.
|
|
81
83
|
const colonne = colonneDesNoms(lignes, tous, racine, t.colonne);
|
|
82
|
-
|
|
84
|
+
const estUnDossier = n =>
|
|
85
|
+
n !== '.' && existsSync(path.join(racine, n)) && statSync(path.join(racine, n)).isDirectory();
|
|
86
|
+
const largeur = Math.max(0, ...lignes.map(l => l.cellules.length));
|
|
87
|
+
const colonneDesDossiers = Array.from({ length: largeur }, (_, i) => i).find(
|
|
88
|
+
i => i !== t.colonne && lignes.some(l => nomsDe(l.cellules[i]).some(estUnDossier))
|
|
89
|
+
);
|
|
90
|
+
const colonneRetenue = colonne < 0 ? (colonneDesDossiers ?? -1) : colonne;
|
|
91
|
+
return colonneRetenue < 0
|
|
83
92
|
? []
|
|
84
93
|
: lignes.map(l => ({
|
|
85
94
|
index: l.index,
|
|
86
95
|
langage: langageDeLaCellule(l.cellules[t.colonne]),
|
|
87
|
-
noms: nomsDe(l.cellules[
|
|
96
|
+
noms: nomsDe(l.cellules[colonneRetenue]),
|
|
88
97
|
}));
|
|
89
98
|
});
|
|
90
99
|
const ligneDe = composants =>
|
|
@@ -116,7 +125,26 @@ export function constats(racine) {
|
|
|
116
125
|
continue;
|
|
117
126
|
}
|
|
118
127
|
vus.add(l);
|
|
128
|
+
// A package has one language: two manifests of two modules (package.json, the graph's entry
|
|
129
|
+
// of a package of another language, apart) are refused, both named.
|
|
130
|
+
const propres = avec.filter(m => m.manifeste !== 'package.json');
|
|
131
|
+
if (propres.length > 1) {
|
|
132
|
+
out.push({
|
|
133
|
+
fichier: ARCHITECTURE,
|
|
134
|
+
ligne: l.index + 1,
|
|
135
|
+
message: `${rel(dossier)} : porte ${propres.map(m => m.manifeste).join(' et ')} (${propres.map(m => m.nom).join(' et ')}) ; un paquet n'a qu'un langage, ${ou(l)} déclare ${l.langage}.`,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
119
138
|
const declare = langage(l.langage);
|
|
139
|
+
// The name of the `project()` of a package c is the name its row declares.
|
|
140
|
+
const deC = declare.nom === 'c' ? composants[modules.indexOf(declare)] : undefined;
|
|
141
|
+
if (deC && !l.noms.some(n => n === deC.nom || path.posix.basename(n) === deC.nom)) {
|
|
142
|
+
out.push({
|
|
143
|
+
fichier: ARCHITECTURE,
|
|
144
|
+
ligne: l.index + 1,
|
|
145
|
+
message: `${rel(dossier)} : son CMakeLists.txt appelle project(${deC.nom}), quand ${ou(l)} déclare ${l.noms.join(', ')} ; le nom de project() est celui de la ligne.`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
120
148
|
const autre = avec.find(m => m !== declare);
|
|
121
149
|
if (modules.includes(declare) && existsSync(path.join(dossier, declare.manifeste))) {
|
|
122
150
|
// The package follows its row.
|
package/scripts/langages.mjs
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// The usage limit of `claude -p`: its text « limit · resets <time> (<zone>) », read in the result
|
|
2
|
+
// of a session or at the end of its log. It gives the hour the usage returns, understood in the
|
|
3
|
+
// zone written, at the next instant after now. A « resets » whose time or zone does not read is a
|
|
4
|
+
// limit without a readable hour: the circuit waits an hour. A text that cites « limit » without
|
|
5
|
+
// « resets », or elsewhere than at the end of the log, is not one.
|
|
6
|
+
|
|
7
|
+
const HEURE = 3_600_000;
|
|
8
|
+
const LIGNES_DE_FIN = 20;
|
|
9
|
+
|
|
10
|
+
// The offset of <fuseau> from UTC at the instant <ms>, in ms; throws on an unknown zone.
|
|
11
|
+
function decalage(fuseau, ms) {
|
|
12
|
+
const p = Object.fromEntries(
|
|
13
|
+
new Intl.DateTimeFormat('en-US', {
|
|
14
|
+
timeZone: fuseau,
|
|
15
|
+
hourCycle: 'h23',
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
month: 'numeric',
|
|
18
|
+
day: 'numeric',
|
|
19
|
+
hour: 'numeric',
|
|
20
|
+
minute: 'numeric',
|
|
21
|
+
second: 'numeric',
|
|
22
|
+
})
|
|
23
|
+
.formatToParts(ms)
|
|
24
|
+
.map(x => [x.type, Number(x.value)])
|
|
25
|
+
);
|
|
26
|
+
return Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second) - Math.floor(ms / 1000) * 1000;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The first instant after <maintenant> at which the wall clock of <fuseau> reads <h>:<m>, or null.
|
|
30
|
+
function prochainInstant(h, m, fuseau, maintenant) {
|
|
31
|
+
try {
|
|
32
|
+
const jour = new Date(maintenant + decalage(fuseau, maintenant));
|
|
33
|
+
for (let plus = 0; plus <= 2; plus++) {
|
|
34
|
+
const local = Date.UTC(
|
|
35
|
+
jour.getUTCFullYear(),
|
|
36
|
+
jour.getUTCMonth(),
|
|
37
|
+
jour.getUTCDate() + plus,
|
|
38
|
+
h,
|
|
39
|
+
m
|
|
40
|
+
);
|
|
41
|
+
const instant = local - decalage(fuseau, local - decalage(fuseau, local));
|
|
42
|
+
if (instant > maintenant) {
|
|
43
|
+
return instant;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
// An unknown zone: no readable hour.
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The limit <texte> says, `{ reprise, lisible }`, or null.
|
|
53
|
+
function lire(texte, maintenant) {
|
|
54
|
+
const dit = /limit\s*·\s*resets\b([^\n"]*)/i.exec(texte ?? '');
|
|
55
|
+
if (!dit) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const heure =
|
|
59
|
+
/(?:[A-Za-z]{3,9}\s+\d{1,2},?\s+)?\b(\d{1,2})(?::(\d{2}))?\s*(am|pm)\s*\(([^)]+)\)/i.exec(dit[1]);
|
|
60
|
+
if (heure) {
|
|
61
|
+
const h12 = Number(heure[1]);
|
|
62
|
+
if (h12 >= 1 && h12 <= 12) {
|
|
63
|
+
const h = (h12 % 12) + (heure[3].toLowerCase() === 'pm' ? 12 : 0);
|
|
64
|
+
const reprise = prochainInstant(h, Number(heure[2] ?? 0), heure[4].trim(), maintenant);
|
|
65
|
+
if (reprise !== null) {
|
|
66
|
+
return { reprise, lisible: true };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { reprise: maintenant + HEURE, lisible: false };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The usage limit that stops a session, `{ reprise, lisible }` (<reprise> the hour it returns, in
|
|
75
|
+
* ms; one hour after <maintenant> when the text gives none that reads), or null: read in the
|
|
76
|
+
* result <resultat>, else in the last lines of <journal>.
|
|
77
|
+
*/
|
|
78
|
+
export function limiteDUsage({ resultat = null, journal = null }, maintenant = Date.now()) {
|
|
79
|
+
const dansLeResultat = lire(resultat, maintenant);
|
|
80
|
+
if (dansLeResultat) {
|
|
81
|
+
return dansLeResultat;
|
|
82
|
+
}
|
|
83
|
+
const fin = String(journal ?? '')
|
|
84
|
+
.split('\n')
|
|
85
|
+
.slice(-LIGNES_DE_FIN)
|
|
86
|
+
.join('\n');
|
|
87
|
+
return lire(fin, maintenant);
|
|
88
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The progress of a pass, as Bazel counts its actions « [1 234 / 2 000] »: the variable that names
|
|
2
2
|
// the progress directory of a pass, `GRILLHOUSE_AVANCEMENT`, and the writing of a record, which
|
|
3
3
|
// the reporter of the module of the language writes while it is set (for typescript,
|
|
4
|
-
// scripts/langages/typescript/vitest-config/avancement.reporter.mjs)
|
|
4
|
+
// scripts/langages/typescript/vitest-config/avancement.reporter.mjs). The
|
|
5
5
|
// reading, the plan and the totals kept are scripts/avancement.mjs.
|
|
6
6
|
//
|
|
7
7
|
// - Each task of a pass writes its own record to `<dossier>/taches/<nom>.json`: `{ hash, faits,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// From 0.47.0 a lot enters main on its final pass and the CI plays on main afterwards, by batches
|
|
2
|
+
// (grillhouse-3uv.121): no CI judges a ticket's branch, which the queue no longer pushes.
|
|
3
|
+
//
|
|
4
|
+
// - A workflow of the project that lists `agent/**` among the branches of its push has it taken out,
|
|
5
|
+
// its comments, its layout and its other branches kept (the library yaml's document); one that
|
|
6
|
+
// does not list it is left, and a second pass changes nothing and says nothing.
|
|
7
|
+
// - A workflow of the frame is the update's (scripts/workflows-du-cadre.mjs), which writes the
|
|
8
|
+
// frame's new CI, on the hourly schedule: the migration leaves it.
|
|
9
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { parseDocument } from 'yaml';
|
|
12
|
+
import { estDuCadre, WORKFLOWS } from '../workflows-du-cadre.mjs';
|
|
13
|
+
|
|
14
|
+
export const version = '0.47.0';
|
|
15
|
+
export const nom = 'ci de main';
|
|
16
|
+
|
|
17
|
+
const BRANCHES_DE_TICKET = 'agent/**';
|
|
18
|
+
|
|
19
|
+
/** `agent/**` taken out of the push of each workflow of the project; returns what it did. */
|
|
20
|
+
export function migrer(projet) {
|
|
21
|
+
const dossier = path.join(projet, WORKFLOWS);
|
|
22
|
+
if (!existsSync(dossier)) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const lignes = [];
|
|
26
|
+
for (const n of readdirSync(dossier).filter(f => /\.ya?ml$/.test(f)).sort()) {
|
|
27
|
+
const fichier = path.join(dossier, n);
|
|
28
|
+
const texte = readFileSync(fichier, 'utf8');
|
|
29
|
+
if (estDuCadre(texte)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const doc = parseDocument(texte);
|
|
33
|
+
const branches = doc.getIn(['on', 'push', 'branches'], true);
|
|
34
|
+
if (!branches || !Array.isArray(branches.items)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const restantes = branches.items.filter(i => (i?.value ?? i) !== BRANCHES_DE_TICKET);
|
|
38
|
+
if (restantes.length === branches.items.length || restantes.length === 0) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
branches.items = restantes;
|
|
42
|
+
writeFileSync(fichier, doc.toString());
|
|
43
|
+
lignes.push(
|
|
44
|
+
`${WORKFLOWS}/${n} : '${BRANCHES_DE_TICKET}' retirée du push, la file n'envoie plus de branche de ticket ; la CI joue sur main`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return lignes;
|
|
48
|
+
}
|
package/scripts/migrations.mjs
CHANGED
|
@@ -35,13 +35,13 @@ import * as langagesDansLArchitecture from './migrations/0.27.0-langages-dans-l-
|
|
|
35
35
|
|
|
36
36
|
import * as ciAppelleLaVerification from './migrations/0.30.0-ci-appelle-la-verification.mjs';
|
|
37
37
|
import * as paquetsDansLeGraphe from './migrations/0.31.0-paquets-dans-le-graphe.mjs';
|
|
38
|
-
import * as ciDesBranchesDeTicket from './migrations/0.33.0-ci-des-branches-de-ticket.mjs';
|
|
39
38
|
import * as node26 from './migrations/0.33.0-node-26.mjs';
|
|
40
39
|
import * as ciDuCadre from './migrations/0.33.0-ci-du-cadre.mjs';
|
|
41
40
|
import * as cacheDistant from './migrations/0.33.0-cache-distant.mjs';
|
|
42
41
|
import * as greffonMattpocockRetire from './migrations/0.35.0-greffon-mattpocock-retire.mjs';
|
|
43
42
|
import * as node26Seul from './migrations/0.44.0-node-26-seul.mjs';
|
|
44
43
|
import * as seuilDesCodesDeTickets from './migrations/0.44.0-seuil-des-codes-de-tickets.mjs';
|
|
44
|
+
import * as ciDeMain from './migrations/0.47.0-ci-de-main.mjs';
|
|
45
45
|
|
|
46
46
|
/** The migrations of the core. */
|
|
47
47
|
export const MIGRATIONS = [
|
|
@@ -56,13 +56,13 @@ export const MIGRATIONS = [
|
|
|
56
56
|
langagesDansLArchitecture,
|
|
57
57
|
ciAppelleLaVerification,
|
|
58
58
|
paquetsDansLeGraphe,
|
|
59
|
-
ciDesBranchesDeTicket,
|
|
60
59
|
node26,
|
|
61
60
|
ciDuCadre,
|
|
62
61
|
cacheDistant,
|
|
63
62
|
greffonMattpocockRetire,
|
|
64
63
|
node26Seul,
|
|
65
64
|
seuilDesCodesDeTickets,
|
|
65
|
+
ciDeMain,
|
|
66
66
|
];
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -10,15 +10,23 @@ export function lireOutils(
|
|
|
10
10
|
reel?: (p: string) => string;
|
|
11
11
|
montages?: string[];
|
|
12
12
|
}
|
|
13
|
-
): { outils: Record<string, string>; fautes: string[] };
|
|
13
|
+
): { outils: Record<string, string>; contenu: string[]; fautes: string[] };
|
|
14
|
+
/** The SHA-256 of the tool at <chemin>, a file or a directory; throws an unreadable or special file. */
|
|
15
|
+
export function empreinteDeLOutil(chemin: string, nomme?: string): string;
|
|
16
|
+
/** `<VARIABLE>_EMPREINTE` of each tool of the project that holds <dir> hashed by content. */
|
|
17
|
+
export function empreintesDe(dir: string, options?: { montages?: string[] }): Record<string, string>;
|
|
14
18
|
/** The main tree of the repository that holds <dir>. */
|
|
15
19
|
export function arbrePrincipal(dir: string): string;
|
|
16
20
|
/** The tools of the project that holds <dir>; throws the faults of the key. */
|
|
17
21
|
export function outilsDe(dir: string, options?: { montages?: string[] }): Record<string, string>;
|
|
18
|
-
/** The environment <env> of a pass with the tools <outils
|
|
22
|
+
/** The environment <env> of a pass with the tools <outils> and their fingerprints, the key winning. */
|
|
19
23
|
export function avecLesOutils<T extends Record<string, string | undefined>>(
|
|
20
24
|
outils: Record<string, string>,
|
|
21
|
-
env: T
|
|
25
|
+
env: T,
|
|
26
|
+
empreintes?: Record<string, string>
|
|
22
27
|
): T & Record<string, string>;
|
|
23
|
-
/** The shell's text that exports the tools <outils
|
|
24
|
-
export function exportsDesOutils(
|
|
28
|
+
/** The shell's text that exports the tools <outils> and the fingerprints, one line each. */
|
|
29
|
+
export function exportsDesOutils(
|
|
30
|
+
outils: Record<string, string>,
|
|
31
|
+
empreintes?: Record<string, string>
|
|
32
|
+
): string;
|
package/scripts/outils-cles.mjs
CHANGED
|
@@ -17,13 +17,27 @@
|
|
|
17
17
|
// the machine keeps its credentials, but `~/.local` and `~/.cache`; nor under or holding
|
|
18
18
|
// `~/.local/share/keyrings`, the keyrings of the machine's credentials. A path that is a link is
|
|
19
19
|
// judged by its target too, which the envelope mounts with it.
|
|
20
|
+
// - A tool is a string path (unhashed) or `{ "chemin": "<chemin>", "contenu": true }`: hashed by
|
|
21
|
+
// content, Bazel counting the tools of an action among its inputs. Its fingerprint
|
|
22
|
+
// (`empreinteDeLOutil`, `empreintesDe`) is given to every pass as `<VARIABLE>_EMPREINTE`, which
|
|
23
|
+
// the root turbo.json's `globalEnv` names so that Turborepo hashes its value. Any other object
|
|
24
|
+
// form is refused, its key named; a hashed tool absent, unreadable or special is refused too.
|
|
20
25
|
// - The key is read from the package.json of the main tree of the repository (`outilsDe`), never of
|
|
21
26
|
// a copy: an agent never opens a path for its next session.
|
|
22
27
|
// - `node outils-cles.mjs <dir>` writes one line `export VARIABLE='chemin'` per tool of the project
|
|
23
28
|
// that holds <dir>, the path resolved and quoted for the shell (`exportsDesOutils`), which the
|
|
24
29
|
// night evaluates, exit 0; a faulty key writes its faults on stderr, exit 1.
|
|
25
30
|
import { spawnSync } from 'node:child_process';
|
|
26
|
-
import {
|
|
31
|
+
import { createHash } from 'node:crypto';
|
|
32
|
+
import {
|
|
33
|
+
existsSync,
|
|
34
|
+
lstatSync,
|
|
35
|
+
readdirSync,
|
|
36
|
+
readFileSync,
|
|
37
|
+
readlinkSync,
|
|
38
|
+
realpathSync,
|
|
39
|
+
statSync,
|
|
40
|
+
} from 'node:fs';
|
|
27
41
|
import os from 'node:os';
|
|
28
42
|
import path from 'node:path';
|
|
29
43
|
import { pathToFileURL } from 'node:url';
|
|
@@ -90,11 +104,12 @@ export function lireOutils(
|
|
|
90
104
|
) {
|
|
91
105
|
const o = pkg?.grillhouse?.outils;
|
|
92
106
|
if (o === undefined || o === null) {
|
|
93
|
-
return { outils: {}, fautes: [] };
|
|
107
|
+
return { outils: {}, contenu: [], fautes: [] };
|
|
94
108
|
}
|
|
95
109
|
if (typeof o !== 'object' || Array.isArray(o)) {
|
|
96
110
|
return {
|
|
97
111
|
outils: {},
|
|
112
|
+
contenu: [],
|
|
98
113
|
fautes: [
|
|
99
114
|
`la clé grillhouse.outils vaut ${JSON.stringify(o)}, pas un objet { VARIABLE: chemin }.`,
|
|
100
115
|
],
|
|
@@ -104,9 +119,29 @@ export function lireOutils(
|
|
|
104
119
|
const fautes = [];
|
|
105
120
|
/** @type {Record<string, string>} */
|
|
106
121
|
const outils = {};
|
|
107
|
-
|
|
122
|
+
/** @type {string[]} */
|
|
123
|
+
const contenu = [];
|
|
124
|
+
for (const [nom, forme] of Object.entries(o)) {
|
|
108
125
|
const cle = `grillhouse.outils.${nom}`;
|
|
109
|
-
|
|
126
|
+
let v = forme;
|
|
127
|
+
let haché = false;
|
|
128
|
+
let faute = null;
|
|
129
|
+
if (forme !== null && typeof forme === 'object' && !Array.isArray(forme)) {
|
|
130
|
+
const inconnue = Object.keys(forme).find(k => k !== 'chemin' && k !== 'contenu');
|
|
131
|
+
if (inconnue !== undefined) {
|
|
132
|
+
faute = `la clé ${cle} nomme « ${inconnue} », une clé inconnue (seuls « chemin » et « contenu » existent).`;
|
|
133
|
+
} else if (typeof forme.chemin !== 'string') {
|
|
134
|
+
faute = `la clé ${cle}.chemin vaut ${JSON.stringify(forme.chemin)}, pas un chemin.`;
|
|
135
|
+
} else if ('contenu' in forme && typeof forme.contenu !== 'boolean') {
|
|
136
|
+
faute = `la clé ${cle}.contenu vaut ${JSON.stringify(forme.contenu)}, pas un booléen.`;
|
|
137
|
+
} else {
|
|
138
|
+
v = forme.chemin;
|
|
139
|
+
haché = forme.contenu === true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (faute) {
|
|
143
|
+
fautes.push(faute);
|
|
144
|
+
} else if (!NOM.test(nom)) {
|
|
110
145
|
fautes.push(`la clé grillhouse.outils nomme « ${nom} », pas un nom de variable.`);
|
|
111
146
|
} else if (typeof v !== 'string') {
|
|
112
147
|
fautes.push(`la clé ${cle} vaut ${JSON.stringify(v)}, pas un chemin.`);
|
|
@@ -125,12 +160,89 @@ export function lireOutils(
|
|
|
125
160
|
fautes.push(`${refusDeLaCible} (la cible du lien ${chemin})`);
|
|
126
161
|
} else if (existe(chemin)) {
|
|
127
162
|
outils[nom] = chemin;
|
|
163
|
+
if (haché) {
|
|
164
|
+
contenu.push(nom);
|
|
165
|
+
}
|
|
128
166
|
} else {
|
|
129
167
|
fautes.push(`la clé ${cle} nomme ${chemin}, qui n'existe pas.`);
|
|
130
168
|
}
|
|
131
169
|
}
|
|
132
170
|
}
|
|
133
|
-
return
|
|
171
|
+
return fautes.length ? { outils: {}, contenu: [], fautes } : { outils, contenu, fautes };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// The directories the fingerprint of a directory tool leaves out: the compilation caches an
|
|
175
|
+
// interpreter writes when used.
|
|
176
|
+
const SANS_EMPREINTE = new Set(['__pycache__']);
|
|
177
|
+
|
|
178
|
+
// The entries of the tool <racine> as lines [relative path, type, executable bit, content digest],
|
|
179
|
+
// the directory walked in the order of the bytes of the names.
|
|
180
|
+
function entreesDe(racine, rel, lignes, nomme) {
|
|
181
|
+
const dossier = path.join(racine, rel);
|
|
182
|
+
let noms;
|
|
183
|
+
try {
|
|
184
|
+
noms = readdirSync(dossier, { encoding: 'buffer' }).sort(Buffer.compare);
|
|
185
|
+
} catch (e) {
|
|
186
|
+
throw new Error(`${nomme} : ${dossier} est illisible (${/** @type {Error} */ (e).message}).`);
|
|
187
|
+
}
|
|
188
|
+
for (const buf of noms) {
|
|
189
|
+
const nom = buf.toString('utf8');
|
|
190
|
+
const r = rel ? path.join(rel, nom) : nom;
|
|
191
|
+
const p = path.join(racine, r);
|
|
192
|
+
const st = lstatSync(p);
|
|
193
|
+
if (st.isDirectory()) {
|
|
194
|
+
if (!SANS_EMPREINTE.has(nom)) {
|
|
195
|
+
entreesDe(racine, r, lignes, nomme);
|
|
196
|
+
}
|
|
197
|
+
} else if (st.isSymbolicLink()) {
|
|
198
|
+
lignes.push(['l', r, '0', readlinkSync(p)]);
|
|
199
|
+
} else if (st.isFile()) {
|
|
200
|
+
lignes.push(['f', r, st.mode & 0o111 ? '1' : '0', contenuDe(p, nomme)]);
|
|
201
|
+
} else {
|
|
202
|
+
throw new Error(`${nomme} : ${p} est un fichier spécial (ni fichier, ni dossier, ni lien).`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// The SHA-256 of the file <p>, the tool <nomme> named when it is unreadable.
|
|
208
|
+
function contenuDe(p, nomme) {
|
|
209
|
+
try {
|
|
210
|
+
return createHash('sha256').update(readFileSync(p)).digest('hex');
|
|
211
|
+
} catch (e) {
|
|
212
|
+
throw new Error(`${nomme} : ${p} est illisible (${/** @type {Error} */ (e).message}).`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The fingerprint of the tool at <chemin>: for a file, the SHA-256 of its content; for a
|
|
218
|
+
* directory, the SHA-256 of the list of its entries sorted by the bytes of their relative path,
|
|
219
|
+
* each by its path, its type, its executable bit and its content (a link by the text of its target,
|
|
220
|
+
* never followed); the `__pycache__` directories are left out; no date, owner or absolute path
|
|
221
|
+
* enters it, so a directory moved or touched keeps it.
|
|
222
|
+
* @param {string} chemin
|
|
223
|
+
* @param {string} [nomme] what an error names (the tool), the path by default
|
|
224
|
+
* @returns {string} a hex digest
|
|
225
|
+
* @throws {Error} an unreadable file or a special file, named
|
|
226
|
+
*/
|
|
227
|
+
export function empreinteDeLOutil(chemin, nomme = chemin) {
|
|
228
|
+
// The tool itself, a link or not, is read through (the envelope mounts what it leads to).
|
|
229
|
+
const st = statSync(chemin);
|
|
230
|
+
if (!st.isDirectory()) {
|
|
231
|
+
return contenuDe(chemin, nomme);
|
|
232
|
+
}
|
|
233
|
+
/** @type {string[][]} */
|
|
234
|
+
const lignes = [];
|
|
235
|
+
entreesDe(chemin, '', lignes, nomme);
|
|
236
|
+
const h = createHash('sha256');
|
|
237
|
+
for (const l of lignes) {
|
|
238
|
+
// Each field is prefixed by its length: the boundaries of names and contents count.
|
|
239
|
+
for (const champ of l) {
|
|
240
|
+
const b = Buffer.from(champ, 'utf8');
|
|
241
|
+
h.update(`${b.length}:`).update(b);
|
|
242
|
+
}
|
|
243
|
+
h.update('\n');
|
|
244
|
+
}
|
|
245
|
+
return h.digest('hex');
|
|
134
246
|
}
|
|
135
247
|
|
|
136
248
|
// The main tree of the repository that holds <dir>, from git's common directory; <dir> itself out
|
|
@@ -156,41 +268,69 @@ export function arbrePrincipal(dir) {
|
|
|
156
268
|
* @throws {Error} the faults of the key, one per line
|
|
157
269
|
*/
|
|
158
270
|
export function outilsDe(dir, { montages = [] } = {}) {
|
|
271
|
+
return lectureDuProjet(dir, montages).outils;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// The reading of the key of the project that holds <dir>: `outils` and the variables hashed by
|
|
275
|
+
// content, `contenu`; throws the faults of the key.
|
|
276
|
+
function lectureDuProjet(dir, montages = []) {
|
|
159
277
|
const racine = arbrePrincipal(dir);
|
|
160
278
|
const f = path.join(racine, 'package.json');
|
|
161
279
|
if (!existsSync(f)) {
|
|
162
|
-
return {};
|
|
280
|
+
return { outils: {}, contenu: [] };
|
|
163
281
|
}
|
|
164
282
|
const temporaires = [process.env.CLAUDE_CODE_TMPDIR, os.tmpdir(), '/tmp'].filter(Boolean);
|
|
165
|
-
const { outils, fautes } = lireOutils(JSON.parse(readFileSync(f, 'utf8')), {
|
|
283
|
+
const { outils, contenu, fautes } = lireOutils(JSON.parse(readFileSync(f, 'utf8')), {
|
|
166
284
|
montages: [racine, ...temporaires, ...montages],
|
|
167
285
|
});
|
|
168
286
|
if (fautes.length) {
|
|
169
287
|
throw new Error(fautes.join('\n'));
|
|
170
288
|
}
|
|
171
|
-
return outils;
|
|
289
|
+
return { outils, contenu };
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The fingerprints of the tools of the project that holds <dir> declared hashed by content
|
|
294
|
+
* (`{ chemin, contenu: true }`): `<VARIABLE>_EMPREINTE` and the SHA-256 of the tool
|
|
295
|
+
* (`empreinteDeLOutil`), read again at each call; none for a tool of the short form.
|
|
296
|
+
* @param {string} dir a directory of the project: its main tree or a copy
|
|
297
|
+
* @param {{ montages?: string[] }} [o]
|
|
298
|
+
* @returns {Record<string, string>}
|
|
299
|
+
* @throws {Error} the faults of the key, or a hashed tool unreadable, its variable named
|
|
300
|
+
*/
|
|
301
|
+
export function empreintesDe(dir, { montages = [] } = {}) {
|
|
302
|
+
const { outils, contenu } = lectureDuProjet(dir, montages);
|
|
303
|
+
return Object.fromEntries(
|
|
304
|
+
contenu.map(nom => [
|
|
305
|
+
`${nom}_EMPREINTE`,
|
|
306
|
+
empreinteDeLOutil(outils[nom], `la clé grillhouse.outils.${nom}`),
|
|
307
|
+
])
|
|
308
|
+
);
|
|
172
309
|
}
|
|
173
310
|
|
|
174
311
|
/**
|
|
175
|
-
* The environment <env> of a pass with the tools <outils> (`outilsDe`)
|
|
312
|
+
* The environment <env> of a pass with the tools <outils> (`outilsDe`) and the fingerprints
|
|
313
|
+
* <empreintes> (`empreintesDe`), the key winning.
|
|
176
314
|
* @param {Record<string, string>} outils
|
|
177
315
|
* @param {Record<string, string | undefined>} env
|
|
316
|
+
* @param {Record<string, string>} [empreintes]
|
|
178
317
|
*/
|
|
179
|
-
export function avecLesOutils(outils, env) {
|
|
180
|
-
return { ...env, ...outils };
|
|
318
|
+
export function avecLesOutils(outils, env, empreintes = {}) {
|
|
319
|
+
return { ...env, ...outils, ...empreintes };
|
|
181
320
|
}
|
|
182
321
|
|
|
183
|
-
// The shell's text that exports the tools <outils> (`outilsDe`)
|
|
184
|
-
// per line, each
|
|
185
|
-
|
|
186
|
-
|
|
322
|
+
// The shell's text that exports the tools <outils> (`outilsDe`) and the fingerprints
|
|
323
|
+
// <empreintes> (`empreintesDe`), one `export VARIABLE='valeur'` per line, each value quoted for
|
|
324
|
+
// the shell: what the night evaluates before its commands.
|
|
325
|
+
export const exportsDesOutils = (outils, empreintes = {}) =>
|
|
326
|
+
Object.entries({ ...outils, ...empreintes })
|
|
187
327
|
.map(([n, c]) => `export ${n}='${c.replaceAll("'", "'\\''")}'\n`)
|
|
188
328
|
.join('');
|
|
189
329
|
|
|
190
330
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
191
331
|
try {
|
|
192
|
-
const
|
|
193
|
-
process.stdout.write(exportsDesOutils(
|
|
332
|
+
const dir = path.resolve(process.argv[2] ?? '.');
|
|
333
|
+
process.stdout.write(exportsDesOutils(outilsDe(dir), empreintesDe(dir)));
|
|
194
334
|
} catch (e) {
|
|
195
335
|
process.stderr.write(`${/** @type {Error} */ (e).message}\n`);
|
|
196
336
|
process.exitCode = 1;
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
prendreUnePart,
|
|
49
49
|
sousNiceEtIonice,
|
|
50
50
|
travailleursDe,
|
|
51
|
+
VARIABLE_MESURE_D_ESSAI,
|
|
51
52
|
VARIABLE_TRAVAILLEURS,
|
|
52
53
|
} from './places-de-la-machine.mjs';
|
|
53
54
|
|
|
@@ -260,6 +261,28 @@ function jouerMesuree(jouer, { ouvert, racine, ticket, sorte, part, horloge, coe
|
|
|
260
261
|
}
|
|
261
262
|
}
|
|
262
263
|
|
|
264
|
+
/**
|
|
265
|
+
* How a pass asks whether the controller of the cores is delegated to the account: <delegation>
|
|
266
|
+
* when its caller gives one; on the machine a trial fixes (GRILLHOUSE_MESURE_D_ESSAI) a function
|
|
267
|
+
* that answers no without asking the system, so that a trial's measure is held by the affinity of
|
|
268
|
+
* its launch and moves no program of the user's machine off its cores; else undefined, the
|
|
269
|
+
* system's own answer (`attacheDesCoeurs`).
|
|
270
|
+
* @param {{ env?: Record<string, string | undefined>, delegation?: () => boolean }} o
|
|
271
|
+
* @returns {(() => boolean) | undefined}
|
|
272
|
+
*/
|
|
273
|
+
export const delegationDeLaPasse = ({ env = process.env, delegation }) =>
|
|
274
|
+
delegation ?? (env[VARIABLE_MESURE_D_ESSAI] ? () => false : undefined);
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Whether a pass judges the load of its dedicated cores while it plays: a measure of time
|
|
278
|
+
* (<dediee>) held on its cores (<voie>, a group or an affinity), on the user's machine. On the
|
|
279
|
+
* machine a trial fixes (GRILLHOUSE_MESURE_D_ESSAI) it does not: no trial reads the load of the
|
|
280
|
+
* user's machine, and its red keeps its code.
|
|
281
|
+
* @param {{ dediee?: boolean, voie?: string, env?: Record<string, string | undefined> }} o
|
|
282
|
+
*/
|
|
283
|
+
export const jugeLaChargeDuJeu = ({ dediee, voie, env = process.env }) =>
|
|
284
|
+
Boolean(dediee) && voie !== undefined && voie !== 'aucune' && !env[VARIABLE_MESURE_D_ESSAI];
|
|
285
|
+
|
|
263
286
|
/**
|
|
264
287
|
* Plays <mesure> on its part of the machine, held to it by the system, and returns what it
|
|
265
288
|
* returns; <mesure> receives the environment of its children (the mark of the part, the workers
|
|
@@ -306,10 +329,11 @@ export function avecLaPasse(
|
|
|
306
329
|
const direSansPart = direUneFois(dire);
|
|
307
330
|
// How the precise threads of the part are held: the allowed cores of a group, the affinity of
|
|
308
331
|
// the launch, or not at all; a measure of time says it once.
|
|
332
|
+
const delegationLue = delegationDeLaPasse({ env, delegation });
|
|
309
333
|
const attache = prise.fils
|
|
310
334
|
? attacheDesCoeurs({
|
|
311
335
|
env,
|
|
312
|
-
...(
|
|
336
|
+
...(delegationLue ? { delegation: delegationLue } : {}),
|
|
313
337
|
...(affinite ? { affinite } : {}),
|
|
314
338
|
})
|
|
315
339
|
: null;
|
|
@@ -361,7 +385,7 @@ export function avecLaPasse(
|
|
|
361
385
|
// A measure of time judges the load of its dedicated cores while it plays: the busy time of
|
|
362
386
|
// those cores out of its own (read from its group), a red on loaded cores « à repasser ».
|
|
363
387
|
const jugee = (jouer, ouvert) => () => {
|
|
364
|
-
if (!prise.dediee
|
|
388
|
+
if (!jugeLaChargeDuJeu({ dediee: prise.dediee, voie: attache?.voie, env })) {
|
|
365
389
|
return jouer();
|
|
366
390
|
}
|
|
367
391
|
const avant = lireLesTempsOccupes(tempsDuSysteme());
|