@roomi-fields/grillhouse 0.53.0 → 0.54.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 +48 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
- package/charte.md +12 -0
- package/dist/temporal/circuit/deroule.js +5 -9
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +15 -2
- package/dist/temporal/installation.js +69 -17
- package/dist/temporal/installation.js.map +1 -1
- package/docs/INTERFACE.md +21 -1
- package/docs/architecture/circuit.md +3 -3
- package/docs/architecture/entree.md +4 -4
- package/docs/architecture/greffon.md +19 -10
- package/docs/architecture/installation.md +11 -7
- package/docs/architecture/machine.md +1 -1
- package/docs/architecture/tests.md +1 -1
- package/hooks/register.tsx +50 -24
- package/package.json +1 -1
- package/scripts/aiguillage.mjs +4 -2
- package/scripts/bd-garde.mjs +69 -0
- package/scripts/ci-de-main.mjs +259 -56
- package/scripts/circuit.mjs +20 -5
- package/scripts/commandes-composees.mjs +1 -1
- package/scripts/droits.mjs +11 -4
- package/scripts/file-des-tickets.mjs +27 -9
- package/scripts/langages/c/commandes.mjs +1 -1
- package/scripts/langages/cargo/commandes.mjs +1 -1
- package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
- package/scripts/langages/python/commandes.mjs +1 -1
- package/scripts/langages/typescript/code-mort.mjs +36 -3
- package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +95 -24
- package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
- package/scripts/langages/typescript/parcours.mjs +5 -1
- package/scripts/langages.d.mts +6 -0
- package/scripts/langages.mjs +6 -0
- package/scripts/lire.mjs +236 -0
- package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
- package/scripts/migrations/lire-un-ticket.mjs +46 -0
- package/scripts/migrations.mjs +4 -0
- package/scripts/montee.mjs +110 -46
- package/scripts/nuit.sh +21 -12
- package/scripts/registre.d.mts +7 -1
- package/scripts/registre.mjs +114 -102
- package/scripts/resultats.mjs +15 -5
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/suiveur.mjs +12 -4
- package/scripts/superviseur.mjs +28 -17
- package/scripts/tableau.mjs +527 -119
- package/scripts/tarifs.mjs +67 -0
- package/scripts/ticket-du-circuit.mjs +3 -4
- package/scripts/transitions.d.mts +0 -5
- package/scripts/transitions.mjs +3 -13
- package/scripts/verdict-de-la-nuit.mjs +2 -2
- package/skills/explorateur/SKILL.md +10 -5
- package/skills/mesure/SKILL.md +4 -3
- package/skills/pitmaster/SKILL.md +11 -2
- package/skills/pitmaster/references/erreurs.md +4 -2
- package/skills/pitmaster/references/tour.md +11 -4
- package/types/index.d.ts +3 -1
- package/scripts/base-des-workflows.mjs +0 -58
package/scripts/ci-de-main.mjs
CHANGED
|
@@ -7,21 +7,29 @@
|
|
|
7
7
|
//
|
|
8
8
|
// - `declencherLaCiDeMain`: the start (`gh workflow run`), its delay and its fault kept in a file of
|
|
9
9
|
// the project; `alerteDeDeclenchement` tells the supervisor of a start GitHub refused.
|
|
10
|
-
// - `lireLaCiDeMain`: the latest finished pass of the flow CI (ci.yml) on the branch
|
|
10
|
+
// - `lireLaCiDeMain`: the latest finished pass of the flow CI (ci.yml) on the branch that judged
|
|
11
11
|
// (`gh run list`), the other flows judging nothing: green when it succeeded, red on any other
|
|
12
|
-
// conclusion
|
|
13
|
-
//
|
|
12
|
+
// conclusion, and not read, never silence, when gh fails, does not start, answers garbage or no
|
|
13
|
+
// judged pass. A cancelled, skipped or « à repasser » pass judged nothing, the one before it
|
|
14
|
+
// decides. A pass is « à repasser » when its only failures are passes of verification of the
|
|
15
|
+
// frame ending in 75, and the merge that follows from a tranche to repeat (`estARepasser`).
|
|
14
16
|
// - `lotsDepuisLeVert`: the lots of the circuit between the last green and the tip, by git alone
|
|
15
17
|
// (the commits whose subject ends with « (<ticket>) »), no state kept.
|
|
16
18
|
// - `alerteDeLaCiDeMain` and `ligneDeLaCiDeMain`: what is told to the supervisor and shown on the
|
|
17
|
-
// board; a green gives no alert, it clears.
|
|
19
|
+
// board; a green gives no alert, it clears, unless three passes or more are « à repasser » since.
|
|
18
20
|
// - `ouvrirLeDefautDeMain`: the defect ticket a red opens under `a-valider`, for the owner, which
|
|
19
21
|
// names the red pass and the candidate lots; the search of the culprit is that ticket, which the
|
|
20
22
|
// supervisor launches in the circuit. A lot already closed stays closed.
|
|
23
|
+
// - `composantsDuDefaut`: the components of the title of a defect ticket, this one and the
|
|
24
|
+
// night's (scripts/nuit.sh, which runs this file as `node ci-de-main.mjs composants`).
|
|
21
25
|
import { spawnSync } from 'node:child_process';
|
|
22
26
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
23
27
|
import path from 'node:path';
|
|
28
|
+
import { pathToFileURL } from 'node:url';
|
|
29
|
+
import { A_REPASSER } from './codes-de-sortie.mjs';
|
|
24
30
|
import { git, sortie } from './etat-du-depot.mjs';
|
|
31
|
+
import { composantsLisibles } from './langages.mjs';
|
|
32
|
+
import { prefixe } from './prefixe-des-tickets.mjs';
|
|
25
33
|
import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
|
|
26
34
|
|
|
27
35
|
const COURT = 7;
|
|
@@ -30,39 +38,112 @@ const uneLigne = t => String(t).replace(/\s+/g, ' ').trim();
|
|
|
30
38
|
|
|
31
39
|
const FLUX_DE_LA_CI = 'ci.yml';
|
|
32
40
|
|
|
41
|
+
// The steps of the frame's ci.yml (this repository's and the template's) that play a pass of
|
|
42
|
+
// verification, and the step of the merge of the tranches.
|
|
43
|
+
const TRANCHE = /^Tranche \d+$/;
|
|
44
|
+
const estUneVerification = nom => nom === 'Verification without the tests' || TRANCHE.test(nom);
|
|
45
|
+
const FUSION = 'Merge of the tranches';
|
|
46
|
+
const CODE_DE_SORTIE = /^Process completed with exit code (\d+)\.$/;
|
|
47
|
+
|
|
48
|
+
// What gh prints in JSON for <args>, <vide> read when it prints nothing; throws the reason when gh
|
|
49
|
+
// does not start, refuses or answers garbage.
|
|
50
|
+
function lireEnJson(gh, args, vide = '') {
|
|
51
|
+
const r = gh(args);
|
|
52
|
+
const appel = `gh ${args.slice(0, 2).join(' ')}`;
|
|
53
|
+
if (r.error) {
|
|
54
|
+
throw new Error(`gh ne se lance pas (${r.error.code ?? r.error.message}).`);
|
|
55
|
+
}
|
|
56
|
+
if (r.status !== 0) {
|
|
57
|
+
throw new Error(`${appel} refuse :\n${`${r.stderr}${r.stdout}`.trim()}`);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(r.stdout || vide);
|
|
61
|
+
} catch {
|
|
62
|
+
throw new Error(`${appel} rend une sortie illisible :\n${String(r.stdout).trim()}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The exit codes the failure annotations of the job <id> declare.
|
|
67
|
+
function codesDeSortie(gh, id) {
|
|
68
|
+
const annotations = lireEnJson(gh, [
|
|
69
|
+
'api',
|
|
70
|
+
`repos/{owner}/{repo}/check-runs/${id}/annotations?per_page=100`,
|
|
71
|
+
]);
|
|
72
|
+
if (!Array.isArray(annotations)) {
|
|
73
|
+
throw new Error(`gh api ne rend pas les annotations du job ${id}.`);
|
|
74
|
+
}
|
|
75
|
+
return annotations
|
|
76
|
+
.filter(a => a?.annotation_level === 'failure')
|
|
77
|
+
.map(a => CODE_DE_SORTIE.exec(String(a.message).trim())?.[1])
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.map(Number);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Whether the failed pass <passage> is « à repasser », by its jobs and their annotations read with
|
|
83
|
+
// <gh>: at least one job failed in passes of verification alone, each of its exit codes 75, and
|
|
84
|
+
// every other failed job is one too, or the merge failed at its own step alone after a tranche to
|
|
85
|
+
// repeat. Throws the reason when gh does not give the jobs or the annotations.
|
|
86
|
+
function estARepasser(gh, passage) {
|
|
87
|
+
const jobs = lireEnJson(gh, ['run', 'view', String(passage), '--json', 'jobs'])?.jobs;
|
|
88
|
+
if (!Array.isArray(jobs)) {
|
|
89
|
+
throw new Error(`gh run view ne rend pas les jobs du passage ${passage}.`);
|
|
90
|
+
}
|
|
91
|
+
let aRepasser = false;
|
|
92
|
+
let tranche = false;
|
|
93
|
+
let fusion = false;
|
|
94
|
+
for (const j of jobs) {
|
|
95
|
+
if (['success', 'skipped', 'cancelled'].includes(j?.conclusion)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (j?.conclusion !== 'failure') {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const enEchec = (j.steps ?? []).filter(e => e?.conclusion === 'failure').map(e => e.name);
|
|
102
|
+
if (enEchec.length === 1 && enEchec[0] === FUSION) {
|
|
103
|
+
fusion = true;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (enEchec.length === 0 || !enEchec.every(estUneVerification)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const codes = codesDeSortie(gh, j.databaseId);
|
|
110
|
+
if (codes.length === 0 || codes.some(c => c !== A_REPASSER)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
aRepasser = true;
|
|
114
|
+
tranche ||= enEchec.some(nom => TRANCHE.test(nom));
|
|
115
|
+
}
|
|
116
|
+
return aRepasser && (!fusion || tranche);
|
|
117
|
+
}
|
|
118
|
+
|
|
33
119
|
/**
|
|
34
120
|
* The CI of the branch <branche> (main by default) read with <o.gh> in <o.racine>: `{ etat: 'verte',
|
|
35
121
|
* commit, passage }`, `{ etat: 'rouge', flux, passage, commit, vert }` (the name of the flow, its
|
|
36
122
|
* red pass, the commit of that pass and the commit of its last green pass, null when none is read)
|
|
37
|
-
* or `{ etat: 'non-lue', raison }`.
|
|
123
|
+
* or `{ etat: 'non-lue', raison }`. A green or a red carries `aRepasser: { passage, nombre }` when
|
|
124
|
+
* passes « à repasser » are more recent than the one that decides: the latest and their count.
|
|
38
125
|
*/
|
|
39
126
|
export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
|
|
40
|
-
const r = o.gh([
|
|
41
|
-
'run',
|
|
42
|
-
'list',
|
|
43
|
-
'--branch',
|
|
44
|
-
branche,
|
|
45
|
-
'--workflow',
|
|
46
|
-
FLUX_DE_LA_CI,
|
|
47
|
-
'--limit',
|
|
48
|
-
'100',
|
|
49
|
-
'--json',
|
|
50
|
-
'databaseId,status,conclusion,workflowName,headSha',
|
|
51
|
-
]);
|
|
52
|
-
if (r.error) {
|
|
53
|
-
return { etat: 'non-lue', raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
|
|
54
|
-
}
|
|
55
|
-
if (r.status !== 0) {
|
|
56
|
-
return { etat: 'non-lue', raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
|
|
57
|
-
}
|
|
58
127
|
let passages;
|
|
59
128
|
try {
|
|
60
|
-
passages =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
129
|
+
passages = lireEnJson(
|
|
130
|
+
o.gh,
|
|
131
|
+
[
|
|
132
|
+
'run',
|
|
133
|
+
'list',
|
|
134
|
+
'--branch',
|
|
135
|
+
branche,
|
|
136
|
+
'--workflow',
|
|
137
|
+
FLUX_DE_LA_CI,
|
|
138
|
+
'--limit',
|
|
139
|
+
'100',
|
|
140
|
+
'--json',
|
|
141
|
+
'databaseId,status,conclusion,workflowName,headSha',
|
|
142
|
+
],
|
|
143
|
+
'[]'
|
|
144
|
+
);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
return { etat: 'non-lue', raison: e.message };
|
|
66
147
|
}
|
|
67
148
|
const finis = (Array.isArray(passages) ? passages : [])
|
|
68
149
|
.filter(
|
|
@@ -77,18 +158,53 @@ export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
|
|
|
77
158
|
if (finis.length === 0) {
|
|
78
159
|
return { etat: 'non-lue', raison: `aucun passage fini de la CI sur ${branche}.` };
|
|
79
160
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
161
|
+
const repasses = [];
|
|
162
|
+
let juge;
|
|
163
|
+
try {
|
|
164
|
+
juge = finis.find(p => {
|
|
165
|
+
const repasse = p.conclusion === 'failure' && estARepasser(o.gh, p.databaseId);
|
|
166
|
+
if (repasse) {
|
|
167
|
+
repasses.push(String(p.databaseId));
|
|
168
|
+
}
|
|
169
|
+
return !repasse;
|
|
170
|
+
});
|
|
171
|
+
} catch (e) {
|
|
172
|
+
return { etat: 'non-lue', raison: e.message };
|
|
173
|
+
}
|
|
174
|
+
if (!juge) {
|
|
175
|
+
return {
|
|
176
|
+
etat: 'non-lue',
|
|
177
|
+
raison: `aucun passage jugé de la CI sur ${branche} : passage ${repasses[0]} à repasser.`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const suite = repasses.length
|
|
181
|
+
? { aRepasser: { passage: repasses[0], nombre: repasses.length } }
|
|
182
|
+
: {};
|
|
183
|
+
if (juge.conclusion !== 'success') {
|
|
82
184
|
const vert = finis.find(p => p.conclusion === 'success');
|
|
83
185
|
return {
|
|
84
186
|
etat: 'rouge',
|
|
85
|
-
flux:
|
|
86
|
-
passage: String(
|
|
87
|
-
commit:
|
|
187
|
+
flux: juge.workflowName,
|
|
188
|
+
passage: String(juge.databaseId),
|
|
189
|
+
commit: juge.headSha,
|
|
88
190
|
vert: vert?.headSha ?? null,
|
|
191
|
+
...suite,
|
|
89
192
|
};
|
|
90
193
|
}
|
|
91
|
-
return { etat: 'verte', commit:
|
|
194
|
+
return { etat: 'verte', commit: juge.headSha, passage: String(juge.databaseId), ...suite };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Whether the pass <p> of `gh run list` is finished and « à repasser »; false when gh does not give
|
|
198
|
+
// its jobs or its annotations, which starts nothing.
|
|
199
|
+
function finiARepasser(gh, p) {
|
|
200
|
+
if (p.status !== 'completed' || p.conclusion !== 'failure') {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
return estARepasser(gh, p.databaseId);
|
|
205
|
+
} catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
92
208
|
}
|
|
93
209
|
|
|
94
210
|
const HEURE = 3_600_000;
|
|
@@ -141,8 +257,9 @@ export function alerteDeDeclenchement(faute) {
|
|
|
141
257
|
* The queue starts the CI of main itself, as the schedulers of Google's TAP and Chromium's LUCI
|
|
142
258
|
* start the pass after the submit, by batches: it reads the passes of the workflow ci.yml on main
|
|
143
259
|
* (whatever started them) with <o.gh> in <o.racine>, and starts it (`gh workflow run`) when the tip
|
|
144
|
-
* of main differs from the commit of the last pass,
|
|
145
|
-
* pass or the last start is an hour old or
|
|
260
|
+
* of main differs from the commit of the last pass, or that pass is « à repasser » and so judged
|
|
261
|
+
* nothing, no pass is running or waiting, and the last pass or the last start is an hour old or
|
|
262
|
+
* more. Without any pass known, only a lot entered
|
|
146
263
|
* (<p.apresEntree>, kept until a start succeeds) starts it, never the sole start of the queue.
|
|
147
264
|
* `{ declenche }`, with `faute` when GitHub refused: the fault is kept for the alert, the next
|
|
148
265
|
* quarter of an hour tries again, and nothing throws.
|
|
@@ -188,7 +305,7 @@ export function declencherLaCiDeMain(o, { apresEntree = false, maintenant = Date
|
|
|
188
305
|
}
|
|
189
306
|
const dernier = connus[0];
|
|
190
307
|
const pointe = sortie(racine, ['rev-parse', 'main']) || sortie(racine, ['rev-parse', 'HEAD']);
|
|
191
|
-
if (dernier ? dernier.headSha === pointe : !entree) {
|
|
308
|
+
if (dernier ? dernier.headSha === pointe && !finiARepasser(o.gh, dernier) : !entree) {
|
|
192
309
|
garder({ entree: false });
|
|
193
310
|
return { declenche: false };
|
|
194
311
|
}
|
|
@@ -212,7 +329,8 @@ export function declencherLaCiDeMain(o, { apresEntree = false, maintenant = Date
|
|
|
212
329
|
}
|
|
213
330
|
|
|
214
331
|
// The ticket a subject « … (<ticket>) » of the circuit's commits ends with, null otherwise.
|
|
215
|
-
|
|
332
|
+
// The prefix of a project may hold hyphens.
|
|
333
|
+
const TICKET = /\(([A-Za-z0-9]+(?:-[A-Za-z0-9.]+)+)\)\s*$/;
|
|
216
334
|
|
|
217
335
|
/**
|
|
218
336
|
* The lots of the circuit entered on main since the last green <vert> up to <pointe>, oldest first:
|
|
@@ -241,8 +359,13 @@ export function lotsDepuisLeVert(racine, { vert, pointe }) {
|
|
|
241
359
|
.filter(Boolean);
|
|
242
360
|
}
|
|
243
361
|
|
|
362
|
+
// From how many passes « à repasser » after a green the supervisor is told main is not judged.
|
|
363
|
+
const SERIE_QUI_ALERTE = 3;
|
|
364
|
+
|
|
244
365
|
/**
|
|
245
|
-
* What a reading tells the supervisor: `{ genre, cle, texte }`, null for a green (the alert clears)
|
|
366
|
+
* What a reading tells the supervisor: `{ genre, cle, texte }`, null for a green (the alert clears),
|
|
367
|
+
* unless three passes or more are « à repasser » since (genre `plus-juge`, one key per deciding
|
|
368
|
+
* pass).
|
|
246
369
|
* A red names the workflow, its pass, its commit and each lot <lots> entered since the last green,
|
|
247
370
|
* then its defect ticket <defaut> (`ouvrirLeDefautDeMain`): the ticket by its number, a ticket open
|
|
248
371
|
* with no number read, or the fault that kept it from opening (its own key, so that the alert with
|
|
@@ -250,7 +373,14 @@ export function lotsDepuisLeVert(racine, { vert, pointe }) {
|
|
|
250
373
|
*/
|
|
251
374
|
export function alerteDeLaCiDeMain(lecture, lots, defaut) {
|
|
252
375
|
if (lecture.etat === 'verte') {
|
|
253
|
-
|
|
376
|
+
const nombre = lecture.aRepasser?.nombre ?? 0;
|
|
377
|
+
return nombre < SERIE_QUI_ALERTE
|
|
378
|
+
? null
|
|
379
|
+
: {
|
|
380
|
+
genre: 'plus-juge',
|
|
381
|
+
cle: `plus-juge ${lecture.passage}`,
|
|
382
|
+
texte: `Main n'est plus jugé depuis le passage vert ${lecture.passage} (commit ${court(lecture.commit)}) : ${nombre} passages de la CI de main à repasser depuis. La file continue d'avancer main et relance le flux.`,
|
|
383
|
+
};
|
|
254
384
|
}
|
|
255
385
|
if (lecture.etat === 'non-lue') {
|
|
256
386
|
return {
|
|
@@ -279,24 +409,78 @@ export function alerteDeLaCiDeMain(lecture, lots, defaut) {
|
|
|
279
409
|
};
|
|
280
410
|
}
|
|
281
411
|
|
|
282
|
-
/**
|
|
412
|
+
/**
|
|
413
|
+
* The line of the board: the last green, the red with its workflow, pass and last green, or the CI
|
|
414
|
+
* not read; the latest pass « à repasser » beside the one that decides.
|
|
415
|
+
*/
|
|
283
416
|
export function ligneDeLaCiDeMain(lecture) {
|
|
284
|
-
if (lecture.etat === 'verte') {
|
|
285
|
-
return `CI de main verte (${court(lecture.commit)})`;
|
|
286
|
-
}
|
|
287
417
|
if (lecture.etat === 'non-lue') {
|
|
288
418
|
return `CI de main non lue : ${uneLigne(lecture.raison)}`;
|
|
289
419
|
}
|
|
290
|
-
|
|
420
|
+
const repasse = lecture.aRepasser ? `, passage ${lecture.aRepasser.passage} à repasser` : '';
|
|
421
|
+
if (lecture.etat === 'verte') {
|
|
422
|
+
return `CI de main verte (${court(lecture.commit)})${repasse}`;
|
|
423
|
+
}
|
|
424
|
+
return `CI de main rouge : ${lecture.flux}, passage ${lecture.passage}, dernier vert ${lecture.vert ? court(lecture.vert) : 'aucun vert'}${repasse}`;
|
|
291
425
|
}
|
|
292
426
|
|
|
293
427
|
const A_VALIDER = 'a-valider';
|
|
294
|
-
|
|
428
|
+
// The package of the frame, which takes a defect whose lots name no component.
|
|
429
|
+
const PAQUET_DU_CADRE = '@roomi-fields/grillhouse';
|
|
430
|
+
// The scope of the commit of a lot, « type(a,b): subject (ticket) ».
|
|
431
|
+
const PORTEE = /^[A-Za-z]+\(([^()]*)\)!?:/;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The components of the title of a defect ticket of main, in the repository at <racine>: the names
|
|
435
|
+
* of the components the scope of the commit of each lot of <lots> names, each once, in the order of
|
|
436
|
+
* the lots; a name that is no component of the repository is left aside. Without any, the package
|
|
437
|
+
* of the frame when the repository holds it, else the root « . », which is also what a repository
|
|
438
|
+
* whose components do not read gives: the departure of the ticket reads each of them.
|
|
439
|
+
*/
|
|
440
|
+
export function composantsDuDefaut(racine, lots) {
|
|
441
|
+
let liste = [];
|
|
442
|
+
try {
|
|
443
|
+
liste = composantsLisibles(racine);
|
|
444
|
+
} catch {
|
|
445
|
+
// components that do not read: the root, which needs none
|
|
446
|
+
}
|
|
447
|
+
const nommes = lots
|
|
448
|
+
.flatMap(l => PORTEE.exec(l.titre)?.[1].split(',') ?? [])
|
|
449
|
+
.map(n => n.trim())
|
|
450
|
+
.map(n => liste.find(p => p.pkg.name === n || p.dossier === n)?.pkg.name)
|
|
451
|
+
.filter(Boolean);
|
|
452
|
+
if (nommes.length > 0) {
|
|
453
|
+
return [...new Set(nommes)];
|
|
454
|
+
}
|
|
455
|
+
return [liste.some(p => p.pkg.name === PAQUET_DU_CADRE) ? PAQUET_DU_CADRE : '.'];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const sujetDuDefaut = l => `CI de main rouge : ${l.flux}, passage ${l.passage}`;
|
|
459
|
+
|
|
460
|
+
// The pass a title of a defect ticket holds, with or without its number and its components, the
|
|
461
|
+
// former title « CI de main rouge — <flux>, passage <n> » included.
|
|
462
|
+
const PASSAGE_TENU = /^(?:\S+ — )?CI de main rouge (?::|—) .*?, passage (\d+)(?=$| — )/;
|
|
463
|
+
const passageTenu = titre => PASSAGE_TENU.exec(String(titre ?? ''))?.[1];
|
|
464
|
+
|
|
465
|
+
// Titles the ticket <id> « number — <titre> », the number being its id without the prefix of the
|
|
466
|
+
// project. A prefix that does not read or a renaming refused leaves the ticket as created.
|
|
467
|
+
function numeroter(o, id, titre) {
|
|
468
|
+
let debut;
|
|
469
|
+
try {
|
|
470
|
+
debut = `${prefixe(o.racine)}-`;
|
|
471
|
+
} catch {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (id.startsWith(debut)) {
|
|
475
|
+
o.bd('update', id, '--title', `${id.slice(debut.length)} — ${titre}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
295
478
|
|
|
296
479
|
/**
|
|
297
480
|
* The defect ticket a red <lecture> opens under `a-valider` with the tools <o> (`bd` of the
|
|
298
|
-
* project): its title names the workflow
|
|
299
|
-
* candidate
|
|
481
|
+
* project): its title « number — subject — components » names the workflow, the red pass and the
|
|
482
|
+
* components of the candidate lots <lots> (`composantsDuDefaut`), its description the commit and
|
|
483
|
+
* each of those lots. One ticket per pass, closed or not: a pass that already has its ticket opens
|
|
300
484
|
* none. The queue and the supervisor's reading both open it through this function, and the search
|
|
301
485
|
* of a doublon and the creation are played under a file lock of the project <o.racine>, so that
|
|
302
486
|
* two openings at once make one ticket. A green or a CI not read opens none (the alert says it, no
|
|
@@ -330,12 +514,13 @@ export function ouvrirLeDefautDeMain(o, lecture, lots) {
|
|
|
330
514
|
}
|
|
331
515
|
|
|
332
516
|
function ouvrirSousVerrou(o, lecture, lots) {
|
|
333
|
-
const titre = titreDuDefaut(lecture);
|
|
334
517
|
const existants = o.bd('list', '--all', '--label', A_VALIDER, '--limit', '0', '--json');
|
|
335
518
|
if (existants.status === 0) {
|
|
336
519
|
try {
|
|
337
520
|
const l = JSON.parse(existants.stdout || '[]');
|
|
338
|
-
const deja = (Array.isArray(l) ? l : []).find(
|
|
521
|
+
const deja = (Array.isArray(l) ? l : []).find(
|
|
522
|
+
t => passageTenu(t?.title) === String(lecture.passage)
|
|
523
|
+
);
|
|
339
524
|
if (deja) {
|
|
340
525
|
return { ouvert: false, ticket: deja.id ?? null, doublon: deja.id };
|
|
341
526
|
}
|
|
@@ -354,6 +539,7 @@ function ouvrirSousVerrou(o, lecture, lots) {
|
|
|
354
539
|
'',
|
|
355
540
|
'La recherche du coupable est ce ticket, que le superviseur lance dans le circuit. Un lot fautif déjà fermé reste fermé : son correctif ou son retrait est un ticket neuf. Ce défaut reste ouvert tant que ce ticket n’est pas fermé.',
|
|
356
541
|
].join('\n');
|
|
542
|
+
const titre = `${sujetDuDefaut(lecture)} — ${composantsDuDefaut(o.racine, lots).join(', ')}`;
|
|
357
543
|
const r = o.bd(
|
|
358
544
|
'create',
|
|
359
545
|
titre,
|
|
@@ -372,8 +558,11 @@ function ouvrirSousVerrou(o, lecture, lots) {
|
|
|
372
558
|
faute: `bd create refuse : ${uneLigne(`${r.stderr ?? ''}${r.stdout ?? ''}`)}`,
|
|
373
559
|
};
|
|
374
560
|
}
|
|
375
|
-
const
|
|
376
|
-
|
|
561
|
+
const id = /^([A-Za-z0-9]+(?:-[A-Za-z0-9.]+)+)$/.exec(String(r.stdout ?? '').trim())?.[1];
|
|
562
|
+
if (id) {
|
|
563
|
+
numeroter(o, id, titre);
|
|
564
|
+
}
|
|
565
|
+
return { ouvert: true, ticket: id ?? null };
|
|
377
566
|
}
|
|
378
567
|
|
|
379
568
|
// `bd` run in the project at <racine>, found on the PATH as the project's own.
|
|
@@ -437,7 +626,7 @@ export function ciDeMainGardee(
|
|
|
437
626
|
|
|
438
627
|
/**
|
|
439
628
|
* The alert of a <lecture> of the CI of the project at <racine>, its lots named by git up to the
|
|
440
|
-
* tip of its main tree: `{ genre, cle, texte }`, null
|
|
629
|
+
* tip of its main tree: `{ genre, cle, texte }`, null when the reading tells nothing.
|
|
441
630
|
*/
|
|
442
631
|
export function alerteDuProjet(racine, lecture, defaut) {
|
|
443
632
|
return alerteDeLaCiDeMain(lecture, lotsDuProjet(racine, lecture), defaut);
|
|
@@ -454,8 +643,8 @@ export function lotsDuProjet(racine, lecture) {
|
|
|
454
643
|
|
|
455
644
|
/**
|
|
456
645
|
* The CI of main read for the supervisor at <racine>, its defect ticket opened by the same function
|
|
457
|
-
* as the queue's (`ouvrirLeDefautDeMain`, in this project, with its own Beads): the alert, null
|
|
458
|
-
*
|
|
646
|
+
* as the queue's (`ouvrirLeDefautDeMain`, in this project, with its own Beads): the alert, null
|
|
647
|
+
* when there is nothing to tell, undefined for a project with no CI to read. Only the supervisor's reading calls it, the
|
|
459
648
|
* board reads `ciDeMainGardee` alone.
|
|
460
649
|
*/
|
|
461
650
|
export function lireEtOuvrirLeDefautDeMain(racine, { gh } = {}) {
|
|
@@ -471,3 +660,17 @@ export function lireEtOuvrirLeDefautDeMain(racine, { gh } = {}) {
|
|
|
471
660
|
const faute = fauteDeDeclenchement(racine);
|
|
472
661
|
return alerte ?? (faute ? alerteDeDeclenchement(faute) : alerte);
|
|
473
662
|
}
|
|
663
|
+
|
|
664
|
+
// Run as `node ci-de-main.mjs composants <racine> <vert> <pointe>`, the night (nuit.sh) takes the
|
|
665
|
+
// components of its ticket by the same functions: those of the lots entered between its last green
|
|
666
|
+
// <vert>, empty without one, and its tip <pointe>, as its title writes them.
|
|
667
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
668
|
+
const [commande, racine, vert, pointe] = process.argv.slice(2);
|
|
669
|
+
if (commande === 'composants' && racine && pointe) {
|
|
670
|
+
const lots = lotsDepuisLeVert(racine, { vert, pointe });
|
|
671
|
+
process.stdout.write(composantsDuDefaut(racine, lots).join(', '));
|
|
672
|
+
} else {
|
|
673
|
+
process.stderr.write('Usage : node ci-de-main.mjs composants <racine> <vert> <pointe>\n');
|
|
674
|
+
process.exitCode = 2;
|
|
675
|
+
}
|
|
676
|
+
}
|
package/scripts/circuit.mjs
CHANGED
|
@@ -1058,7 +1058,11 @@ export function publierLArret(ctx, erreur, etat) {
|
|
|
1058
1058
|
// The hour a usage limit lifts is no outcome of a pass: the bilan reads none of it.
|
|
1059
1059
|
...(e.resultat && e.nom !== 'limite-d-usage' ? { resultat: e.resultat } : {}),
|
|
1060
1060
|
});
|
|
1061
|
-
const ou = ouDansLeCircuit({
|
|
1061
|
+
const ou = ouDansLeCircuit({
|
|
1062
|
+
etape: lieu,
|
|
1063
|
+
finale: etat.finale && lieu === CONTROLES,
|
|
1064
|
+
questionnement: arrete.questionnement,
|
|
1065
|
+
});
|
|
1062
1066
|
commenter(
|
|
1063
1067
|
ctx,
|
|
1064
1068
|
lieu,
|
|
@@ -1918,6 +1922,10 @@ const etatDuPlan = () => ({
|
|
|
1918
1922
|
rapport: null,
|
|
1919
1923
|
});
|
|
1920
1924
|
|
|
1925
|
+
// The state a stop of the plan is written at: the work on the plan named, which places it at
|
|
1926
|
+
// « 1 Plan » (`etapeDuCircuit`).
|
|
1927
|
+
const etatDuPlanArrete = () => ({ ...etatDuPlan(), questionnement: { objet: 'plan' } });
|
|
1928
|
+
|
|
1921
1929
|
// The session of <role> on the plan of <ctx>, its work named in the state while it runs: its
|
|
1922
1930
|
// sheet, and the session it ran (`seance`), which the answer resumes.
|
|
1923
1931
|
async function sessionDuPlan(ctx, role, texte, options) {
|
|
@@ -1982,13 +1990,14 @@ export async function unPasDuPlan(ctx, pas, e) {
|
|
|
1982
1990
|
if (!(x instanceof Arret)) {
|
|
1983
1991
|
throw x;
|
|
1984
1992
|
}
|
|
1993
|
+
inscrire(ctx, { role: AUTEUR_DU_CIRCUIT, etape: TESTS, arret: x.nom });
|
|
1985
1994
|
return {
|
|
1986
1995
|
code: monter(ctx, {
|
|
1987
1996
|
code: ARRETS[x.nom],
|
|
1988
1997
|
nom: x.nom,
|
|
1989
1998
|
rapport: x.rapport,
|
|
1990
1999
|
piece: x.piece,
|
|
1991
|
-
etat:
|
|
2000
|
+
etat: etatDuPlanArrete(),
|
|
1992
2001
|
}),
|
|
1993
2002
|
};
|
|
1994
2003
|
}
|
|
@@ -2166,15 +2175,17 @@ const PAS_DU_PLAN = {
|
|
|
2166
2175
|
nom: 'questionnement',
|
|
2167
2176
|
rapport: `Des questions du plan restent ouvertes après la réponse de l'explorateur.\n\n${liste}\n\nL'échange est au ticket (\`Circuit · … · questionnement\`).`,
|
|
2168
2177
|
piece: liste,
|
|
2169
|
-
etat:
|
|
2178
|
+
etat: etatDuPlanArrete(),
|
|
2170
2179
|
}),
|
|
2171
2180
|
};
|
|
2172
2181
|
},
|
|
2173
2182
|
};
|
|
2174
2183
|
|
|
2175
2184
|
// The circuit stopped on the supervisor's word (`--arreter`) at its state <e>, which the workflow
|
|
2176
|
-
// holds, its session ended with the act the workflow cancelled: the state keeps its step,
|
|
2177
|
-
//
|
|
2185
|
+
// holds, its session ended with the act the workflow cancelled: the state keeps its step, the work
|
|
2186
|
+
// on its plan (`questionnement`), the motive of the stop it receives (`motif`), its loops
|
|
2187
|
+
// (`boucles`) and its relaunch on the refusal (`relanceSurLeRefus`), its stop « arrete », its
|
|
2188
|
+
// question lifted, said at the ticket. Its exit code, 0.
|
|
2178
2189
|
export async function arreter(ctx, e) {
|
|
2179
2190
|
const lu = e;
|
|
2180
2191
|
ctx.circuit = ctx.circuit ?? lu.circuit;
|
|
@@ -2194,6 +2205,10 @@ export async function arreter(ctx, e) {
|
|
|
2194
2205
|
? `Le superviseur arrête le circuit : ${ctx.contexte}`
|
|
2195
2206
|
: (lu.rapport ?? null),
|
|
2196
2207
|
finale: lu.finale === true,
|
|
2208
|
+
questionnement: lu.questionnement ?? null,
|
|
2209
|
+
boucles: lu.boucles ?? null,
|
|
2210
|
+
relanceSurLeRefus: lu.relanceSurLeRefus === true,
|
|
2211
|
+
...(lu.motif ? { motif: lu.motif } : {}),
|
|
2197
2212
|
});
|
|
2198
2213
|
const pourquoi = ctx.contexte ? ` : ${ctx.contexte}` : '.';
|
|
2199
2214
|
commenter(ctx, 'arret', `le superviseur arrête le circuit${pourquoi}`);
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
import { spawnSync } from 'node:child_process';
|
|
43
43
|
import { constants } from 'node:os';
|
|
44
44
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
45
|
+
import { A_REPASSER } from './codes-de-sortie.mjs';
|
|
45
46
|
import { moduleDuFichier } from './composition-des-langages.mjs';
|
|
46
47
|
import { garderLeVert } from './dernier-vert.mjs';
|
|
47
48
|
import { etatDuDepot } from './etat-du-depot.mjs';
|
|
@@ -50,7 +51,6 @@ import { constructionDuGraphe, GRAPHE_JOUE, PASSE_ROUGE } from './taches-du-grap
|
|
|
50
51
|
|
|
51
52
|
/** This script, the one every composed command runs. */
|
|
52
53
|
export const SCRIPT = fileURLToPath(import.meta.url);
|
|
53
|
-
const A_REPASSER = 75;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* The verdict of the codes <codes> joined: 0 when every code is 0, 75 when the others are 75,
|
package/scripts/droits.mjs
CHANGED
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
// save the frame's (`grillhouse@…`), which carries the role's agent, its skills and the frame's
|
|
34
34
|
// hooks; the background tasks off and Code Mode on (`env`, ENV_DES_SEANCES: a role waits in the
|
|
35
35
|
// foreground for what it launches, and its session ends with its sheet; `claude -p` gets Code
|
|
36
|
-
// Mode, the REPL, only from this block), and, in the same block, the
|
|
36
|
+
// Mode, the REPL, only from this block), and, in the same block, the window of compaction and an
|
|
37
|
+
// empty percentage override (ENV_DES_SEANCES), the prompt cache forced to five
|
|
37
38
|
// minutes for a role that takes it (`cacheCinqMinutes`, ROLES; CINQ_MINUTES_DE_CACHE); no line of
|
|
38
39
|
// attribution of commit or pull request
|
|
39
40
|
// (`attribution`, both empty, whatever the project and the user choose: a role commits nothing);
|
|
@@ -84,10 +85,16 @@ const ECRIRE_AU_TICKET = [
|
|
|
84
85
|
// Code (the Bash tool's `run_in_background`, the background agents): `claude -p` waits for them
|
|
85
86
|
// before it ends, so a session ends with its sheet only without them. The other turns on Code Mode
|
|
86
87
|
// (the REPL): `claude -p` gets it only from the env block of `--settings`; the hooks and the
|
|
87
|
-
// permissions of the role apply to the tools the REPL calls.
|
|
88
|
+
// permissions of the role apply to the tools the REPL calls. The two others set when a session
|
|
89
|
+
// compacts: 400000 is the window of compaction, which Claude Code bounds by the window of the
|
|
90
|
+
// model, and not the threshold (on a model of 1M, Claude Code 2.1.332 compacts at 367k: the window
|
|
91
|
+
// less 20k kept for the summary, less a margin of 13k); the empty percentage override takes the
|
|
92
|
+
// place of the one the launching environment sets, so the threshold does not depend on the post.
|
|
88
93
|
const ENV_DES_SEANCES = {
|
|
89
94
|
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: '1',
|
|
90
95
|
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE: '1',
|
|
96
|
+
CLAUDE_CODE_AUTO_COMPACT_WINDOW: '400000',
|
|
97
|
+
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE: '',
|
|
91
98
|
};
|
|
92
99
|
// The variable the env block adds for a role whose prompt cache lasts five minutes
|
|
93
100
|
// (`cacheCinqMinutes`, ROLES): the explorateur, the questionneur, the testwriter and the relecteur,
|
|
@@ -348,8 +355,8 @@ function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
|
|
|
348
355
|
}
|
|
349
356
|
if (r.porteSonTicket) {
|
|
350
357
|
// The ticket its instruction carries, its description, notes and last handover.
|
|
351
|
-
for (const lecture of ['show', 'comments']) {
|
|
352
|
-
deny.push(`Bash(
|
|
358
|
+
for (const lecture of ['bd show', 'bd comments', 'npx grillhouse lire']) {
|
|
359
|
+
deny.push(`Bash(${lecture} ${ticket})`, `Bash(${lecture} ${ticket} *)`);
|
|
353
360
|
}
|
|
354
361
|
}
|
|
355
362
|
return {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
// fault (never a silent start).
|
|
34
34
|
import { spawnSync } from 'node:child_process';
|
|
35
35
|
import path from 'node:path';
|
|
36
|
+
import { bdAAppeler } from './bd-garde.mjs';
|
|
36
37
|
import { ETAPES } from './etapes.mjs';
|
|
37
38
|
import { lotSurMain } from './integration/integrer.mjs';
|
|
38
39
|
|
|
@@ -281,7 +282,9 @@ export function enFileSansArchitecture(tous, { enCours = new Set() } = {}) {
|
|
|
281
282
|
* The tickets of each provider project the tickets <tous> depend on (`external:<project>:…`), by
|
|
282
283
|
* the project's name, read through Beads' `external_projects` of the project at <racine>; a
|
|
283
284
|
* project that the configuration does not set, or whose tickets do not read, is left out (the
|
|
284
|
-
* ticket that waits for it stays held, `attentesExternes` naming the fault).
|
|
285
|
+
* ticket that waits for it stays held, `attentesExternes` naming the fault). Beads is called as
|
|
286
|
+
* the project at <racine> keeps it (`bdAAppeler`, ./bd-garde.mjs), for its configuration and for
|
|
287
|
+
* the tickets of each provider.
|
|
285
288
|
* @param {string} racine
|
|
286
289
|
* @param {Parameters<typeof ticketsAPartir>[0]} tous
|
|
287
290
|
* @returns {Record<string, typeof tous>}
|
|
@@ -289,9 +292,14 @@ export function enFileSansArchitecture(tous, { enCours = new Set() } = {}) {
|
|
|
289
292
|
export function lireLesExternes(racine, tous) {
|
|
290
293
|
const noms = new Set(tous.flatMap(t => dependancesExternes(t).map(d => d.projet)));
|
|
291
294
|
const externes = {};
|
|
295
|
+
if (noms.size === 0) {
|
|
296
|
+
return externes;
|
|
297
|
+
}
|
|
298
|
+
const bd = bdAAppeler(dossierGitCommun(racine));
|
|
292
299
|
for (const nom of noms) {
|
|
293
|
-
const r = spawnSync(
|
|
300
|
+
const r = spawnSync(bd.commande, ['config', 'get', `external_projects.${nom}`], {
|
|
294
301
|
cwd: racine,
|
|
302
|
+
env: bd.env,
|
|
295
303
|
encoding: 'utf8',
|
|
296
304
|
maxBuffer: 256 * 1024 * 1024,
|
|
297
305
|
});
|
|
@@ -300,7 +308,7 @@ export function lireLesExternes(racine, tous) {
|
|
|
300
308
|
continue;
|
|
301
309
|
}
|
|
302
310
|
try {
|
|
303
|
-
externes[nom] =
|
|
311
|
+
externes[nom] = listerLesTickets(cheminDuProjetExterne(racine, chemin), bd);
|
|
304
312
|
} catch {
|
|
305
313
|
// Left out: the project does not resolve.
|
|
306
314
|
}
|
|
@@ -321,15 +329,19 @@ export function cheminDuProjetExterne(racine, chemin) {
|
|
|
321
329
|
if (path.isAbsolute(chemin)) {
|
|
322
330
|
return chemin;
|
|
323
331
|
}
|
|
332
|
+
const commun = dossierGitCommun(racine);
|
|
333
|
+
const principal = commun ? path.dirname(commun) : path.resolve(racine);
|
|
334
|
+
return path.resolve(principal, chemin);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// The common directory of git of <racine>, absolute; null when <racine> is no git repository.
|
|
338
|
+
function dossierGitCommun(racine) {
|
|
324
339
|
const r = spawnSync(
|
|
325
340
|
'git',
|
|
326
341
|
['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
|
|
327
|
-
{
|
|
328
|
-
encoding: 'utf8',
|
|
329
|
-
}
|
|
342
|
+
{ encoding: 'utf8' }
|
|
330
343
|
);
|
|
331
|
-
|
|
332
|
-
return path.resolve(principal, chemin);
|
|
344
|
+
return r.status === 0 ? r.stdout.trim() : null;
|
|
333
345
|
}
|
|
334
346
|
|
|
335
347
|
/**
|
|
@@ -337,8 +349,14 @@ export function cheminDuProjetExterne(racine, chemin) {
|
|
|
337
349
|
* fails or a list that does not parse throws, its reason named (`bd list`), never an empty list.
|
|
338
350
|
*/
|
|
339
351
|
export function lireLesTickets(racine) {
|
|
340
|
-
|
|
352
|
+
return listerLesTickets(racine, { commande: 'bd', env: process.env });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// `lireLesTickets`, Beads called as <bd> says (`bdAAppeler`).
|
|
356
|
+
function listerLesTickets(racine, bd) {
|
|
357
|
+
const r = spawnSync(bd.commande, ['list', '--all', '--limit', '0', '--json'], {
|
|
341
358
|
cwd: racine,
|
|
359
|
+
env: bd.env,
|
|
342
360
|
encoding: 'utf8',
|
|
343
361
|
maxBuffer: 256 * 1024 * 1024,
|
|
344
362
|
});
|