@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
package/scripts/superviseur.mjs
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
// comments at the ticket), nothing is taken and nothing is said.
|
|
11
11
|
// - The lock is `<git common dir>/grillhouse-superviseur.lock`, one for the repository and its
|
|
12
12
|
// copies, taken through scripts/verrou-de-fichier.mjs for the session's own process: the first
|
|
13
|
-
// process above this one
|
|
13
|
+
// process above this one named `claude`, whatever stands between them (the hook of the greffon,
|
|
14
|
+
// the frame's command, a shell); without one, the first that is not a shell (sh, bash, dash, zsh).
|
|
14
15
|
// It holds as long as that process lives: a lock whose process is gone is taken over.
|
|
15
16
|
// - Free, or held by a process that is gone: taken, nothing said of it. Held by the session itself
|
|
16
17
|
// (a session reopened in the same process, by a compaction or a /clear): kept, nothing said of
|
|
@@ -19,11 +20,11 @@
|
|
|
19
20
|
// since when it holds the lock, and asks to say so to the owner and to launch no circuit
|
|
20
21
|
// (skill pitmaster, « Au lancement de la séance »).
|
|
21
22
|
// - The session whose opening takes the lock (not one that keeps it) receives
|
|
22
|
-
// (`circuitsALOuverture`) the section « ##
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// scripts/circuits-du-serveur.mjs), « ## Les circuits du dépôt »: each circuit that runs,
|
|
26
|
-
// each circuit stopped on a question, with its question and the command that answers it; each
|
|
23
|
+
// (`circuitsALOuverture`) the section « ## Les questions des circuits », which says that the
|
|
24
|
+
// greffon of the session pushes the questions into its queue of messages and that the answer
|
|
25
|
+
// acknowledges them, then, when the repository has some (read from the Temporal server in one
|
|
26
|
+
// call, scripts/circuits-du-serveur.mjs), « ## Les circuits du dépôt »: each circuit that runs,
|
|
27
|
+
// named; each circuit stopped on a question, with its question and the command that answers it; each
|
|
27
28
|
// circuit ended without its issue, with the command that resumes it (`--reprendre` from its last
|
|
28
29
|
// state written, else `--depuis <testwriter|developpeur> --contexte <texte>`), which the
|
|
29
30
|
// supervisor launches without waiting for the owner's word; their ticket open, and the stopped
|
|
@@ -31,40 +32,40 @@
|
|
|
31
32
|
// tickets », the tickets of the queue without their section « ## Architecture », which the
|
|
32
33
|
// queue never starts (scripts/file-des-tickets.mjs), for the supervisor to write it. A circuit
|
|
33
34
|
// runs on the worker of the project, apart from the sessions, its launch returns at once, and its
|
|
34
|
-
// question
|
|
35
|
-
// 27 s after a relaunch of its session, read only on a word of the owner). The queue of the
|
|
35
|
+
// question reaches the supervisor by the push of the greffon (below). The queue of the
|
|
36
36
|
// tickets under Temporal (src/temporal/tickets/) launches the tickets `circuit`, not the opening.
|
|
37
37
|
// Exit 0, whatever it finds.
|
|
38
38
|
//
|
|
39
|
-
// npx grillhouse superviseur --
|
|
39
|
+
// npx grillhouse superviseur --relever [<dossier>]
|
|
40
40
|
//
|
|
41
|
-
// -
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// `.claude/worktrees/integrations-rendues.json
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
41
|
+
// - One reading of the circuits for the greffon of the session of supervision (mods/grillhouse/
|
|
42
|
+
// hooks/register.tsx), which runs it at each period and submits what it writes to the session,
|
|
43
|
+
// in the queue of its messages (`$.prompt.submit`): the questions of a circuit are given as a
|
|
44
|
+
// queue gives its messages, and the answer acknowledges them. It reads nothing and writes
|
|
45
|
+
// nothing unless the session that runs it holds the lock of the supervisor (the one above); a
|
|
46
|
+
// lock whose process is gone is taken over by the session that reads, as the opening does. It
|
|
47
|
+
// writes the message of the reading (`texteDesQuestions`) when `relever` gives something,
|
|
48
|
+
// nothing otherwise; exit 1 and the fault on the error stream when `grillhouse.rappel` is at
|
|
49
|
+
// fault. A reading is one reading: no process waits.
|
|
50
|
+
// - `relever` is the one function of the reading, of the re-presentation and of the file of the
|
|
51
|
+
// stops gone up: each question of a circuit that never went up or whose last presentation is
|
|
52
|
+
// <rappelMs> old (`grillhouse.rappel` minutes, 5 by default, scripts/circuits-cles.mjs) is given,
|
|
53
|
+
// once per due time, whatever the state of the session, while its circuit stands on the same stop,
|
|
54
|
+
// as SQS gives a message not acknowledged again after its visibility timeout; one answered (its
|
|
55
|
+
// circuit left the stop) leaves the file `.claude/worktrees/questions-remontees.json` and is not
|
|
56
|
+
// given again. The stops are kept there each by its ticket, the run of its workflow, the rank of
|
|
57
|
+
// its question in that run and its stop, with the time of the first going up and of the last
|
|
58
|
+
// presentation. The end of a circuit integrated is given once (`integre`), kept in
|
|
59
|
+
// `.claude/worktrees/integrations-rendues.json`, and the alert of the CI of main (a red, or a CI
|
|
60
|
+
// not read, scripts/ci-de-main.mjs) once per passage (`.claude/worktrees/ci-de-main-rendue.json`),
|
|
61
|
+
// cleared at the next green.
|
|
62
|
+
// - The reading covers the project and each other project of its group (`grillhouse.groupe`) that
|
|
63
|
+
// no other live session of supervision holds, each under its name and its folder.
|
|
64
|
+
import { spawnSync } from 'node:child_process';
|
|
65
|
+
import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
66
66
|
import path from 'node:path';
|
|
67
67
|
import { pathToFileURL } from 'node:url';
|
|
68
|
+
import { alerteDuProjet, ciDeMainGardee } from './ci-de-main.mjs';
|
|
68
69
|
import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
|
|
69
70
|
import { vivant } from './mesure/base-de-passe.mjs';
|
|
70
71
|
import { circuitsDuServeur, ServeurMuet } from './circuits-du-serveur.mjs';
|
|
@@ -72,15 +73,17 @@ import {
|
|
|
72
73
|
attendLeSuperviseur,
|
|
73
74
|
cleDe,
|
|
74
75
|
lireLesRemontees,
|
|
75
|
-
RAPPEL_PAR_DEFAUT,
|
|
76
76
|
remonteesDe,
|
|
77
|
-
verrouDeLAttente,
|
|
78
77
|
} from './tableau.mjs';
|
|
78
|
+
import { rappelDuProjet, reglageDuRappel } from './circuits-cles.mjs';
|
|
79
|
+
import { lireGroupe } from './groupe-cles.mjs';
|
|
79
80
|
import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
|
|
80
81
|
import { enFileSansArchitecture, lireLesTickets } from './file-des-tickets.mjs';
|
|
81
82
|
|
|
82
83
|
const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
|
|
83
84
|
const COQUILLES = new Set(['sh', 'bash', 'dash', 'zsh']);
|
|
85
|
+
// The name of the process of a session of the engine.
|
|
86
|
+
const MOTEUR = 'claude';
|
|
84
87
|
|
|
85
88
|
// The parent and the name of the process <pid>, from /proc; null when it does not read.
|
|
86
89
|
function processus(pid) {
|
|
@@ -95,20 +98,49 @@ function processus(pid) {
|
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
/**
|
|
102
|
+
* The session's process above <depart>: the first process named `claude`, whatever stands between
|
|
103
|
+
* it and the command (the hook of the greffon, the frame's command, a shell), all gone at the end
|
|
104
|
+
* of the command; without one (another engine), the first process that is not a shell. <lire>
|
|
105
|
+
* gives the parent and the name of a process, null when it does not read.
|
|
106
|
+
* @param {number} [depart]
|
|
107
|
+
* @param {(pid: number) => { nom: string, parent: number } | null} [lire]
|
|
108
|
+
* @returns {number}
|
|
109
|
+
*/
|
|
110
|
+
export function seance(depart = process.ppid, lire = processus) {
|
|
111
|
+
let horsCoquille = null;
|
|
100
112
|
let pid = depart;
|
|
101
113
|
for (let i = 0; i < 32 && pid > 1; i++) {
|
|
102
|
-
const p =
|
|
114
|
+
const p = lire(pid);
|
|
103
115
|
if (!p) {
|
|
104
|
-
|
|
116
|
+
break;
|
|
105
117
|
}
|
|
106
|
-
if (
|
|
118
|
+
if (p.nom === MOTEUR) {
|
|
107
119
|
return pid;
|
|
108
120
|
}
|
|
121
|
+
if (horsCoquille === null && !COQUILLES.has(p.nom)) {
|
|
122
|
+
horsCoquille = pid;
|
|
123
|
+
}
|
|
109
124
|
pid = p.parent;
|
|
110
125
|
}
|
|
111
|
-
return depart;
|
|
126
|
+
return horsCoquille ?? depart;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Whether the process <pid> is above this one: the session that runs the command, whatever the
|
|
130
|
+
// processes between them (the `grillhouse` command's own, a shell).
|
|
131
|
+
function estAuDessus(pid) {
|
|
132
|
+
let courant = process.ppid;
|
|
133
|
+
for (let i = 0; i < 32 && courant > 1; i++) {
|
|
134
|
+
if (courant === pid) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
const p = processus(courant);
|
|
138
|
+
if (!p) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
courant = p.parent;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
112
144
|
}
|
|
113
145
|
|
|
114
146
|
// The time in ms of <texte>, a `defer_until` as Beads writes it: the local wall time of the
|
|
@@ -156,11 +188,9 @@ const ou = c => {
|
|
|
156
188
|
return e ? libelle(e) : c.etape;
|
|
157
189
|
};
|
|
158
190
|
|
|
159
|
-
// The file of the stops gone up to the session of supervision (`remonteesDe`)
|
|
160
|
-
//
|
|
161
|
-
// both: its alerts).
|
|
191
|
+
// The file of the stops gone up to the session of supervision (`remonteesDe`) is beside the states
|
|
192
|
+
// of the circuits (scripts/tableau.mjs reads it: its alerts).
|
|
162
193
|
const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
|
|
163
|
-
export { verrouDeLAttente };
|
|
164
194
|
|
|
165
195
|
// The integrations given by the waits of the repository at <racine>: `depuis`, the time (ms) of
|
|
166
196
|
// the last reading of the last wait, from which an integration is new; `rendues`, the keys of the
|
|
@@ -177,83 +207,63 @@ function lireLesIntegrations(racine, maintenant) {
|
|
|
177
207
|
}
|
|
178
208
|
return { depuis: maintenant, rendues: new Set() };
|
|
179
209
|
}
|
|
180
|
-
// The
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const bd = async (...a) =>
|
|
189
|
-
(
|
|
190
|
-
await promisify(execFile)('bd', a, {
|
|
191
|
-
cwd: racine,
|
|
192
|
-
encoding: 'utf8',
|
|
193
|
-
timeout: 5000,
|
|
194
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
195
|
-
})
|
|
196
|
-
).stdout;
|
|
197
|
-
try {
|
|
198
|
-
const l = JSON.parse(await bd('list', '--label', 'flux-rouge', '--status', 'open', '--json'));
|
|
199
|
-
const lots = await Promise.all(
|
|
200
|
-
l.map(async t => {
|
|
201
|
-
const dits = JSON.parse((await bd('comments', t.id, '--json')) || '[]');
|
|
202
|
-
const c = dits.findLast(x => String(x?.text ?? '').startsWith('## Flux de main rouge'));
|
|
203
|
-
return c ? [{ ticket: t.id, adresse: String(c.text).split('\n\n')[1] ?? '' }] : [];
|
|
204
|
-
})
|
|
205
|
-
);
|
|
206
|
-
return lots.flat();
|
|
207
|
-
} catch {
|
|
208
|
-
// A reading that fails says nothing of the reds: null, never « none ».
|
|
209
|
-
return null;
|
|
210
|
+
// The alert of the CI of main of the project at <racine> (scripts/ci-de-main.mjs), read for the
|
|
211
|
+
// supervisor: `{ cle, texte }` for a red or a CI not read, null for a green (the alert clears),
|
|
212
|
+
// undefined for a project with no CI to read. The lots entered since the last green are named by
|
|
213
|
+
// git; nothing is kept but the reading, for five minutes.
|
|
214
|
+
export function ciDeMainDe(racine) {
|
|
215
|
+
const lecture = ciDeMainGardee(racine);
|
|
216
|
+
if (!lecture) {
|
|
217
|
+
return undefined;
|
|
210
218
|
}
|
|
219
|
+
const a = alerteDuProjet(racine, lecture);
|
|
220
|
+
return a ? { cle: a.cle, texte: a.texte } : null;
|
|
211
221
|
}
|
|
212
222
|
|
|
213
|
-
// The
|
|
214
|
-
//
|
|
215
|
-
const
|
|
216
|
-
function
|
|
223
|
+
// The alert of the CI of main given by the waits of the repository at <racine>, its key: kept while
|
|
224
|
+
// it stands, so that one is given once, cleared at the next green and given again if it comes back.
|
|
225
|
+
const ciDeMainRendue = racine => path.join(etatsDe(racine), 'ci-de-main-rendue.json');
|
|
226
|
+
function lireLaCiDeMainRendue(racine) {
|
|
217
227
|
try {
|
|
218
|
-
const lu = JSON.parse(readFileSync(
|
|
219
|
-
return
|
|
228
|
+
const lu = JSON.parse(readFileSync(ciDeMainRendue(racine), 'utf8'));
|
|
229
|
+
return typeof lu?.cle === 'string' ? lu.cle : null;
|
|
220
230
|
} catch {
|
|
221
|
-
return
|
|
231
|
+
return null;
|
|
222
232
|
}
|
|
223
233
|
}
|
|
224
|
-
function
|
|
225
|
-
const f =
|
|
234
|
+
function ecrireLaCiDeMainRendue(racine, cle) {
|
|
235
|
+
const f = ciDeMainRendue(racine);
|
|
226
236
|
try {
|
|
227
237
|
mkdirSync(path.dirname(f), { recursive: true });
|
|
228
238
|
const provisoire = `${f}.${process.pid}`;
|
|
229
|
-
writeFileSync(provisoire, `${JSON.stringify({
|
|
239
|
+
writeFileSync(provisoire, `${JSON.stringify({ cle })}\n`);
|
|
230
240
|
renameSync(provisoire, f);
|
|
231
241
|
} catch {
|
|
232
242
|
// kept as it was
|
|
233
243
|
}
|
|
234
244
|
}
|
|
235
245
|
|
|
236
|
-
// The
|
|
237
|
-
//
|
|
238
|
-
function
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
ticket:
|
|
246
|
+
// The alert of the CI of main <alerte> (`{ cle, texte }`, null at a green) as a question, when it is
|
|
247
|
+
// not the one already given; the file keeps the key that stands.
|
|
248
|
+
function releverLaCiDeMain(racine, alerte, toutes) {
|
|
249
|
+
const avant = lireLaCiDeMainRendue(racine);
|
|
250
|
+
const cle = alerte?.cle ?? null;
|
|
251
|
+
if (cle !== avant) {
|
|
252
|
+
ecrireLaCiDeMainRendue(racine, cle);
|
|
253
|
+
}
|
|
254
|
+
if (!alerte || (cle === avant && !toutes)) {
|
|
255
|
+
return [];
|
|
256
|
+
}
|
|
257
|
+
return [
|
|
258
|
+
{
|
|
259
|
+
ticket: 'CI de main',
|
|
250
260
|
etape: '5 Intégration',
|
|
251
|
-
question:
|
|
261
|
+
question: alerte.texte,
|
|
252
262
|
qui: SUPERVISEUR,
|
|
253
|
-
commande:
|
|
254
|
-
cle: `
|
|
255
|
-
|
|
256
|
-
|
|
263
|
+
commande: 'gh run list --branch main',
|
|
264
|
+
cle: `ci-de-main ${alerte.cle}`,
|
|
265
|
+
},
|
|
266
|
+
];
|
|
257
267
|
}
|
|
258
268
|
|
|
259
269
|
// A file that cannot be written never costs the batch: the next wait reads the former one.
|
|
@@ -269,20 +279,49 @@ function ecrireLesIntegrations(racine, depuis, rendues) {
|
|
|
269
279
|
}
|
|
270
280
|
}
|
|
271
281
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
282
|
+
/**
|
|
283
|
+
* One reading of the circuits <circuits> (those integrated included) of the repository at <racine>,
|
|
284
|
+
* at <maintenant> ms, under the lock of the file of the stops gone up; what the greffon of the
|
|
285
|
+
* session of supervision submits, and the opening lists. Each stop that waits for the supervisor
|
|
286
|
+
* and never went up, or whose last presentation is <rappelMs> ms old or more (<toutes>: every
|
|
287
|
+
* one), is given, its ticket <fermes> gives closed left out (bd is asked of those alone); a stop
|
|
288
|
+
* given is presented now, and one that goes up has its `depuis` set now. The file is written whole
|
|
289
|
+
* with the stops that still stand, their circuit waiting for the supervisor: a question answered
|
|
290
|
+
* so leaves it, and the next stop of its circuit is new. The end of a circuit integrated since the
|
|
291
|
+
* last reading is given once (`integre`; the file of the integrations holds the time of that
|
|
292
|
+
* reading), and the alert of the CI of main <ciDeMain> (`{ cle, texte }`; null at a green, which
|
|
293
|
+
* clears it; undefined when it is not read, which keeps what was given) once per passage. The
|
|
294
|
+
* result is the questions given, each marked `representee` when it comes back, then the ends, then
|
|
295
|
+
* the alert of the CI of main.
|
|
296
|
+
* @param {string} racine
|
|
297
|
+
* @param {import('./circuits-du-serveur.mjs').CircuitDuServeur[]} circuits
|
|
298
|
+
* @param {{ fermes: (racine: string, ids: string[]) => Set<string> | null, maintenant: number, rappelMs: number, toutes?: boolean, ciDeMain?: { cle: string, texte: string } | null }} options
|
|
299
|
+
* @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean, integre?: boolean }[]}
|
|
300
|
+
*/
|
|
301
|
+
export function relever(
|
|
302
|
+
racine,
|
|
303
|
+
circuits,
|
|
304
|
+
{ fermes, maintenant, rappelMs, toutes = false, ciDeMain }
|
|
305
|
+
) {
|
|
280
306
|
const f = remonteesDe(racine);
|
|
281
307
|
mkdirSync(path.dirname(f), { recursive: true });
|
|
282
308
|
const verrou = `${f}.verrou`;
|
|
283
309
|
// Held for one reading of the circuits: older than that, abandoned.
|
|
284
310
|
prendreVerrou(verrou, { attendre: true, perime: 30_000 });
|
|
285
311
|
try {
|
|
312
|
+
const { depuis: depuisIntegrations, rendues } = lireLesIntegrations(racine, maintenant);
|
|
313
|
+
const integres = circuits
|
|
314
|
+
.filter(c => c.integre && c.fin !== null && c.fin >= depuisIntegrations && !rendues.has(cleDe(c)))
|
|
315
|
+
.map(enFin)
|
|
316
|
+
.sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'));
|
|
317
|
+
const fins = new Map(circuits.map(c => [cleDe(c), c.fin]));
|
|
318
|
+
ecrireLesIntegrations(
|
|
319
|
+
racine,
|
|
320
|
+
maintenant,
|
|
321
|
+
[...rendues, ...integres.map(i => i.cle)].filter(k => (fins.get(k) ?? -Infinity) >= maintenant)
|
|
322
|
+
);
|
|
323
|
+
const rouges = ciDeMain === undefined ? [] : releverLaCiDeMain(racine, ciDeMain, toutes);
|
|
324
|
+
circuits = circuits.filter(c => !c.integre);
|
|
286
325
|
const avant = new Map(lireLesRemontees(racine, maintenant).map(r => [r.cle, r]));
|
|
287
326
|
const debout = questionsEnAttente(racine, circuits, { fermes: aucunFerme });
|
|
288
327
|
const aRendre = debout.filter(q => {
|
|
@@ -303,7 +342,9 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
|
|
|
303
342
|
.filter(q => !fermesDe.has(q.ticket))
|
|
304
343
|
.map(q => (avant.has(q.cle) && !toutes ? { ...q, representee: true } : q))
|
|
305
344
|
: [];
|
|
306
|
-
|
|
345
|
+
// A question whose ticket is closed is not given, so not counted presented: it is given once
|
|
346
|
+
// its ticket waits again.
|
|
347
|
+
const presentes = new Set(rendu.map(q => q.cle));
|
|
307
348
|
const enTexte = liste =>
|
|
308
349
|
`${JSON.stringify(
|
|
309
350
|
{
|
|
@@ -338,7 +379,7 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
|
|
|
338
379
|
writeFileSync(provisoire, ecrit);
|
|
339
380
|
renameSync(provisoire, f);
|
|
340
381
|
}
|
|
341
|
-
return rendu;
|
|
382
|
+
return [...rendu, ...integres, ...rouges];
|
|
342
383
|
} finally {
|
|
343
384
|
lacherVerrou(verrou);
|
|
344
385
|
}
|
|
@@ -392,7 +433,7 @@ function enAttente(lus, racine, fermes) {
|
|
|
392
433
|
/**
|
|
393
434
|
* The questions that wait for the supervisor among the circuits <circuits> of the repository at
|
|
394
435
|
* <racine> (scripts/circuits-du-serveur.mjs), the one source of the opening
|
|
395
|
-
* (`circuitsALOuverture`) and of the
|
|
436
|
+
* (`circuitsALOuverture`) and of the reading (`relever`), by the rule the board's
|
|
396
437
|
* « ⤷ Question » reads too (scripts/tableau.mjs `attendLeSuperviseur`): each circuit stopped on a
|
|
397
438
|
* question (any stop but the supervisor's own « arrete », « à repasser » included) or ended
|
|
398
439
|
* without its issue, those whose stop's key <sauf> holds left out, then those whose ticket
|
|
@@ -418,152 +459,20 @@ export function questionsEnAttente(
|
|
|
418
459
|
// No ticket closed: the questions read without asking bd.
|
|
419
460
|
const aucunFerme = () => new Set();
|
|
420
461
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
* again after its visibility timeout; a question answered (its circuit left the stop) leaves those
|
|
429
|
-
* gone up and is not given again. A stop whose key changes is a new question, given at once. The
|
|
430
|
-
* end of a circuit integrated after the last reading of the previous wait (the file of the
|
|
431
|
-
* integrations given; none, the start of this one) is given once, marked `integre`, never again
|
|
432
|
-
* (the circuits integrated read too, by `{ integres: true }`); the supervisor's own « arrete » is
|
|
433
|
-
* never one. The times are those of <maintenant> (`Date.now` by default). It reads the circuits
|
|
434
|
-
* every <pas> ms by <circuitsDe> (one call to the Temporal server, scripts/circuits-du-serveur.mjs,
|
|
435
|
-
* by default), as the UI of Temporal refreshes its list; a reading that fails (the server down) is
|
|
436
|
-
* tried again at the next step, the questions gone up kept. One wait at a time per repository: a
|
|
437
|
-
* second one is refused while the first runs. Its <signal> ends it with an empty batch. A ticket
|
|
438
|
-
* the queue reopened for a red workflow of main (label `flux-rouge`, waiting open, read by
|
|
439
|
-
* <fluxRouges>: bd by default) is given as a batch of its own, once per run (`adresse`: the
|
|
440
|
-
* workflow, the URL of the run, the commit), and again at another run; taken up or closed, it is
|
|
441
|
-
* no longer given.
|
|
442
|
-
* @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string> | null, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, fluxRouges?: (racine: string) => { ticket: string, adresse: string }[] | null | Promise<{ ticket: string, adresse: string }[] | null>, maintenant?: () => number, rappel?: number }} options
|
|
443
|
-
* @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean, integre?: boolean }[]>}
|
|
444
|
-
* @throws {Error} another wait runs
|
|
445
|
-
*/
|
|
446
|
-
export async function attendreUneQuestion({
|
|
447
|
-
racine,
|
|
448
|
-
fermes = ticketsHorsAttente,
|
|
449
|
-
pas = 5_000,
|
|
450
|
-
signal,
|
|
451
|
-
circuitsDe = circuitsDuServeur,
|
|
452
|
-
fluxRouges = fluxRougesDe,
|
|
453
|
-
maintenant = Date.now,
|
|
454
|
-
rappel = RAPPEL_PAR_DEFAUT,
|
|
455
|
-
}) {
|
|
456
|
-
mkdirSync(etatsDe(racine), { recursive: true });
|
|
457
|
-
const verrou = verrouDeLAttente(racine);
|
|
458
|
-
if (!prendreVerrou(verrou, { attendre: false })) {
|
|
459
|
-
let qui = '';
|
|
460
|
-
try {
|
|
461
|
-
qui = ` (processus ${/^(\d+)/.exec(readFileSync(verrou, 'utf8'))?.[1] ?? '?'})`;
|
|
462
|
-
} catch {
|
|
463
|
-
// the lock is gone meanwhile
|
|
464
|
-
}
|
|
465
|
-
throw new Error(
|
|
466
|
-
`Une attente des questions tourne déjà pour ce dépôt${qui}, ${verrou} : une seule à la fois.`
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
// The integrations new since the last reading of the previous wait, each given once.
|
|
470
|
-
const { depuis: debut, rendues } = lireLesIntegrations(racine, maintenant());
|
|
471
|
-
let lue = debut;
|
|
472
|
-
let lectureDesRouges = null;
|
|
473
|
-
// The reds read: undefined while the reading runs, null when it failed.
|
|
474
|
-
let rougesLus;
|
|
475
|
-
try {
|
|
476
|
-
while (!signal?.aborted) {
|
|
477
|
-
const avant = maintenant();
|
|
478
|
-
let circuits = null;
|
|
479
|
-
// Read beside the circuits, never awaited: a slow bd never delays a step, and a reading not
|
|
480
|
-
// yet ended is taken at the next one.
|
|
481
|
-
lectureDesRouges ??= Promise.resolve()
|
|
482
|
-
.then(() => fluxRouges(racine))
|
|
483
|
-
.then(
|
|
484
|
-
r => (rougesLus = Array.isArray(r) ? r : null),
|
|
485
|
-
() => (rougesLus = null)
|
|
486
|
-
);
|
|
487
|
-
try {
|
|
488
|
-
circuits = await circuitsDe(racine, { integres: true });
|
|
489
|
-
} catch {
|
|
490
|
-
circuits = null;
|
|
491
|
-
}
|
|
492
|
-
await new Promise(resolve => setImmediate(resolve));
|
|
493
|
-
let rouges = [];
|
|
494
|
-
if (rougesLus !== undefined) {
|
|
495
|
-
// A failed reading leaves the reds given as they are: the next one judges them.
|
|
496
|
-
if (rougesLus) {
|
|
497
|
-
rouges = releverLesFluxRouges(racine, rougesLus);
|
|
498
|
-
}
|
|
499
|
-
rougesLus = undefined;
|
|
500
|
-
lectureDesRouges = null;
|
|
501
|
-
}
|
|
502
|
-
if (signal?.aborted) {
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
if (rouges.length && !circuits) {
|
|
506
|
-
return rouges;
|
|
507
|
-
}
|
|
508
|
-
if (circuits && !signal?.aborted) {
|
|
509
|
-
lue = avant;
|
|
510
|
-
const integres = circuits
|
|
511
|
-
.filter(c => c.integre && c.fin !== null && c.fin >= debut && !rendues.has(cleDe(c)))
|
|
512
|
-
.map(enFin);
|
|
513
|
-
const lot = [
|
|
514
|
-
...relever(
|
|
515
|
-
racine,
|
|
516
|
-
circuits.filter(c => !c.integre),
|
|
517
|
-
{
|
|
518
|
-
fermes,
|
|
519
|
-
maintenant: maintenant(),
|
|
520
|
-
rappelMs: rappel * 60_000,
|
|
521
|
-
}
|
|
522
|
-
),
|
|
523
|
-
...integres,
|
|
524
|
-
...rouges,
|
|
525
|
-
];
|
|
526
|
-
if (lot.length) {
|
|
527
|
-
// The integrations given, those ended since this reading kept, so that the next wait
|
|
528
|
-
// gives none of them again.
|
|
529
|
-
const fins = new Map(circuits.map(c => [cleDe(c), c.fin]));
|
|
530
|
-
ecrireLesIntegrations(
|
|
531
|
-
racine,
|
|
532
|
-
lue,
|
|
533
|
-
[...rendues, ...integres.map(i => i.cle)].filter(k => (fins.get(k) ?? -Infinity) >= lue)
|
|
534
|
-
);
|
|
535
|
-
return lot;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
await attendre(pas, signal);
|
|
539
|
-
}
|
|
540
|
-
return [];
|
|
541
|
-
} finally {
|
|
542
|
-
lacherVerrou(verrou);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// Waits <ms> ms, or until <signal> ends the wait.
|
|
547
|
-
const attendre = (ms, signal) =>
|
|
548
|
-
new Promise(resolve => {
|
|
549
|
-
const fin = () => {
|
|
550
|
-
clearTimeout(minuteur);
|
|
551
|
-
resolve();
|
|
552
|
-
};
|
|
553
|
-
const minuteur = setTimeout(fin, ms);
|
|
554
|
-
signal?.addEventListener('abort', fin, { once: true });
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
// The relaunch of the wait, which ends on each batch: the last line of a batch.
|
|
558
|
-
const RELANCE =
|
|
559
|
-
"Ce lot traité, relance l'attente en arrière-plan (`run_in_background`), sans tube ni veille à durée : `npx grillhouse superviseur --attendre`. Sa fin te réveille au lot suivant.";
|
|
462
|
+
// The lines of one question in the one rendering of the questions, shared by the message of the
|
|
463
|
+
// greffon, the opening and the hooks of the session.
|
|
464
|
+
export const ligneDeQuestion = q =>
|
|
465
|
+
[
|
|
466
|
+
`- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
|
|
467
|
+
` La réponse : \`${q.commande}\`.`,
|
|
468
|
+
].join('\n');
|
|
560
469
|
|
|
561
470
|
/**
|
|
562
|
-
* The
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
471
|
+
* The message the greffon submits to the session of supervision for the questions <questions> of
|
|
472
|
+
* one reading (`relever`), and the lines of the opening: for each one, its ticket, step, who must
|
|
473
|
+
* answer it, its question and the command that answers it; then each end of a circuit integrated
|
|
474
|
+
* (`integre`), its ticket and its step. A question presented again (`representee`) says that it
|
|
475
|
+
* still waits for an answer.
|
|
567
476
|
* @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean, integre?: boolean }[]} questions
|
|
568
477
|
* @returns {string}
|
|
569
478
|
*/
|
|
@@ -581,12 +490,7 @@ export function texteDesQuestions(questions) {
|
|
|
581
490
|
const enQuestions = attente.length
|
|
582
491
|
? [
|
|
583
492
|
titre,
|
|
584
|
-
...attente.map(
|
|
585
|
-
[
|
|
586
|
-
`- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
|
|
587
|
-
` La réponse : \`${q.commande}\`.`,
|
|
588
|
-
].join('\n')
|
|
589
|
-
),
|
|
493
|
+
...attente.map(ligneDeQuestion),
|
|
590
494
|
]
|
|
591
495
|
: [];
|
|
592
496
|
const enFins = fins.length
|
|
@@ -599,19 +503,19 @@ export function texteDesQuestions(questions) {
|
|
|
599
503
|
...enQuestions,
|
|
600
504
|
...(enQuestions.length && enFins.length ? [''] : []),
|
|
601
505
|
...enFins,
|
|
602
|
-
'',
|
|
603
|
-
RELANCE,
|
|
604
506
|
].join('\n');
|
|
605
507
|
}
|
|
606
508
|
|
|
607
509
|
/**
|
|
608
510
|
* The section a session of supervision receives at its opening in <racine>, when it takes the lock:
|
|
609
|
-
* the
|
|
610
|
-
*
|
|
511
|
+
* what the greffon does (it pushes the questions into the queue of the session, the answer
|
|
512
|
+
* acknowledges them); then the circuits of the repository,
|
|
611
513
|
* those whose ticket <fermes> gives closed left out: each one that runs, named; each one stopped on
|
|
612
514
|
* a question (a stop other than the supervisor's own « arrete »), with its question and the command
|
|
613
|
-
* that answers it
|
|
614
|
-
*
|
|
515
|
+
* that answers it, in the lines of the shared rendering (`ligneDeQuestion`); each one ended without
|
|
516
|
+
* its issue, with the command that resumes it. All the questions that wait are listed, those
|
|
517
|
+
* already pushed included, and counted presented: the greffon does not give them again before
|
|
518
|
+
* their re-presentation. Last, « ## La
|
|
615
519
|
* file des tickets » names the tickets of the queue without their section « ## Architecture »
|
|
616
520
|
* (`enFileSansArchitecture` of scripts/file-des-tickets.mjs, the tickets read by <ticketsDe>,
|
|
617
521
|
* `lireLesTickets` by default; a Beads that fails says nothing), which the queue never starts.
|
|
@@ -644,9 +548,10 @@ export async function circuitsALOuverture(
|
|
|
644
548
|
? relever(racine, circuits, {
|
|
645
549
|
fermes,
|
|
646
550
|
maintenant: Date.now(),
|
|
647
|
-
rappelMs:
|
|
551
|
+
rappelMs: rappelDuProjet(racine) * 60_000,
|
|
648
552
|
toutes: true,
|
|
649
|
-
|
|
553
|
+
ciDeMain: ciDeMainDe(racine),
|
|
554
|
+
}).filter(q => !q.integre)
|
|
650
555
|
: [];
|
|
651
556
|
const tournent = enAttente(
|
|
652
557
|
(circuits ?? []).filter(c => c.vivant),
|
|
@@ -657,10 +562,7 @@ export async function circuitsALOuverture(
|
|
|
657
562
|
ticket: q.ticket,
|
|
658
563
|
ligne: q.interrompu
|
|
659
564
|
? `- ${q.ticket} a fini sans son issue (aucun arrêt écrit), à ${q.etape} : relance-le sans attendre le mot du responsable, \`${q.commande}\`.`
|
|
660
|
-
:
|
|
661
|
-
`- ${q.ticket} est arrêté sur une question (${q.arret}), à ${q.etape}, au ${q.qui} : ${q.question.replace(/\n/g, '\n ')}`,
|
|
662
|
-
` La réponse : \`${q.commande}\`.`,
|
|
663
|
-
].join('\n'),
|
|
565
|
+
: ligneDeQuestion(q),
|
|
664
566
|
});
|
|
665
567
|
let sansArchitecture = [];
|
|
666
568
|
try {
|
|
@@ -674,8 +576,8 @@ export async function circuitsALOuverture(
|
|
|
674
576
|
a.ticket.localeCompare(b.ticket, 'en')
|
|
675
577
|
);
|
|
676
578
|
return [
|
|
677
|
-
|
|
678
|
-
"
|
|
579
|
+
'## Les questions des circuits',
|
|
580
|
+
"Le greffon de ta séance pousse dans la file de tes messages chaque question neuve d'un circuit du dépôt, quel que soit son lanceur, et chaque fin de circuit, une fois ; il n'y a aucune attente à lancer. Une question sans réponse revient à intervalle réglable (`grillhouse.rappel`, 5 min par défaut) : ta réponse au circuit l'acquitte, et répondue elle ne revient plus. Tu ne te mets pas en attente du responsable tant qu'une question d'un circuit attend ta réponse : le crochet de fin de tour te le rappelle. Les questions en attente sont listées ci-dessous.",
|
|
679
581
|
...(panne ? ['', '## Les circuits du dépôt', panne] : []),
|
|
680
582
|
...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
|
|
681
583
|
...(sansArchitecture.length
|
|
@@ -743,6 +645,125 @@ async function superviseur(racine, { env = process.env } = {}) {
|
|
|
743
645
|
].join('\n');
|
|
744
646
|
}
|
|
745
647
|
|
|
648
|
+
/**
|
|
649
|
+
* One reading for the greffon of the session of supervision of the repository at <racine>
|
|
650
|
+
* (`npx grillhouse superviseur --relever`): the message of what `relever` gives (the questions of
|
|
651
|
+
* the circuits due, the ends of circuits, the reds of main), empty when it gives nothing, when the
|
|
652
|
+
* circuits do not read, or when the session that runs it is not the one that holds the lock of the
|
|
653
|
+
* supervisor (a role's session, an agent's copy, another project's, a session that took no lock).
|
|
654
|
+
* The interval of the re-presentation is the key `grillhouse.rappel` of the project, applied at
|
|
655
|
+
* each reading. The session reads too each other project of its group (`grillhouse.groupe`) that
|
|
656
|
+
* no other live session of supervision holds (`voisinsSansSuperviseur`): its part follows, under
|
|
657
|
+
* the name and the folder of that project, where its answers are played, with that project's own
|
|
658
|
+
* interval and state.
|
|
659
|
+
* @param {string} racine
|
|
660
|
+
* @param {{ env?: Record<string, string | undefined>, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} [options]
|
|
661
|
+
* @returns {Promise<string>}
|
|
662
|
+
* @throws {Error} `grillhouse.rappel` is at fault, named with its value
|
|
663
|
+
*/
|
|
664
|
+
export async function releverPourLeGreffon(
|
|
665
|
+
racine,
|
|
666
|
+
{ env = process.env, circuitsDe = circuitsDuServeur } = {}
|
|
667
|
+
) {
|
|
668
|
+
if (env.BEADS_ACTOR) {
|
|
669
|
+
return '';
|
|
670
|
+
}
|
|
671
|
+
const r = git(racine, '--git-dir', '--git-common-dir');
|
|
672
|
+
if (r.status !== 0) {
|
|
673
|
+
return '';
|
|
674
|
+
}
|
|
675
|
+
const [dossierGit, commun] = r.stdout.trim().split('\n');
|
|
676
|
+
if (path.resolve(dossierGit) !== path.resolve(commun)) {
|
|
677
|
+
return '';
|
|
678
|
+
}
|
|
679
|
+
const verrou = path.join(commun, VERROU_SUPERVISEUR);
|
|
680
|
+
let tenant = null;
|
|
681
|
+
try {
|
|
682
|
+
tenant = Number(/^(\d+)/.exec(readFileSync(verrou, 'utf8'))?.[1]);
|
|
683
|
+
} catch {
|
|
684
|
+
return '';
|
|
685
|
+
}
|
|
686
|
+
// A lock whose process is gone is taken over, as the opening does: the session that reads holds it.
|
|
687
|
+
if (Number.isInteger(tenant) && !estAuDessus(tenant) && !vivant(tenant)) {
|
|
688
|
+
const moi = seance();
|
|
689
|
+
tenant = prendreVerrou(verrou, { attendre: false, pid: moi }) ? moi : null;
|
|
690
|
+
}
|
|
691
|
+
if (!Number.isInteger(tenant) || !estAuDessus(tenant)) {
|
|
692
|
+
return '';
|
|
693
|
+
}
|
|
694
|
+
const parts = [await leReleveDe(racine, circuitsDe)];
|
|
695
|
+
for (const p of voisinsSansSuperviseur(racine)) {
|
|
696
|
+
const texte = await leReleveDe(p.chemin, circuitsDe);
|
|
697
|
+
if (texte) {
|
|
698
|
+
parts.push(
|
|
699
|
+
[
|
|
700
|
+
`# Projet ${p.nom} (${p.chemin})`,
|
|
701
|
+
`Ses réponses se jouent dans son dossier : \`env -C ${p.chemin} <la réponse>\`.`,
|
|
702
|
+
texte,
|
|
703
|
+
].join('\n')
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return parts.filter(Boolean).join('\n\n');
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// The package.json of the project at <racine>; empty when it does not read.
|
|
711
|
+
function paquetDe(racine) {
|
|
712
|
+
try {
|
|
713
|
+
return JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
|
|
714
|
+
} catch {
|
|
715
|
+
return {};
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// The message of one reading of the project at <racine>, under its own interval
|
|
720
|
+
// (`grillhouse.rappel`) and its own state of the questions presented; empty when it gives nothing
|
|
721
|
+
// or when its circuits do not read. A faulty interval throws, the project named.
|
|
722
|
+
async function leReleveDe(racine, circuitsDe) {
|
|
723
|
+
const { minutes, faute } = reglageDuRappel(paquetDe(racine));
|
|
724
|
+
if (faute) {
|
|
725
|
+
throw new Error(`${path.basename(racine)} : ${faute}`);
|
|
726
|
+
}
|
|
727
|
+
let circuits;
|
|
728
|
+
try {
|
|
729
|
+
circuits = await circuitsDe(racine, { integres: true });
|
|
730
|
+
} catch {
|
|
731
|
+
return '';
|
|
732
|
+
}
|
|
733
|
+
const lot = relever(racine, circuits, {
|
|
734
|
+
fermes: ticketsHorsAttente,
|
|
735
|
+
maintenant: Date.now(),
|
|
736
|
+
rappelMs: minutes * 60_000,
|
|
737
|
+
ciDeMain: ciDeMainDe(racine),
|
|
738
|
+
});
|
|
739
|
+
return lot.length ? texteDesQuestions(lot) : '';
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// The other projects of the group of the project at <racine> (`grillhouse.groupe`) that no other
|
|
743
|
+
// live session of supervision holds: one session supervises them with its own, and reads them
|
|
744
|
+
// too; a project whose lock another live session holds is read by that session.
|
|
745
|
+
function voisinsSansSuperviseur(racine) {
|
|
746
|
+
const soi = path.resolve(racine);
|
|
747
|
+
const { groupe } = lireGroupe(paquetDe(racine), racine);
|
|
748
|
+
return (groupe?.projets ?? [])
|
|
749
|
+
.filter(p => p.chemin !== soi)
|
|
750
|
+
.filter(p => {
|
|
751
|
+
const r = git(p.chemin, '--git-common-dir');
|
|
752
|
+
if (r.status !== 0) {
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
let tenant;
|
|
756
|
+
try {
|
|
757
|
+
tenant = Number(
|
|
758
|
+
/^(\d+)/.exec(readFileSync(path.join(r.stdout.trim(), VERROU_SUPERVISEUR), 'utf8'))?.[1]
|
|
759
|
+
);
|
|
760
|
+
} catch {
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
return !Number.isInteger(tenant) || estAuDessus(tenant) || !vivant(tenant);
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
|
|
746
767
|
// The root of the repository at <dossier>, its main tree for a copy; <dossier> out of git.
|
|
747
768
|
function racineDe(dossier) {
|
|
748
769
|
const r = git(dossier, '--git-common-dir');
|
|
@@ -750,23 +771,12 @@ function racineDe(dossier) {
|
|
|
750
771
|
}
|
|
751
772
|
|
|
752
773
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
753
|
-
if (process.argv[2] === '--
|
|
774
|
+
if (process.argv[2] === '--relever') {
|
|
754
775
|
try {
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
if (i !== -1) {
|
|
759
|
-
rappel = Number(args[i + 1]);
|
|
760
|
-
if (!(rappel > 0)) {
|
|
761
|
-
throw new Error('--rappel attend un nombre de minutes supérieur à 0.');
|
|
762
|
-
}
|
|
763
|
-
args.splice(i, 2);
|
|
776
|
+
const texte = await releverPourLeGreffon(racineDe(process.argv[3] ?? process.cwd()));
|
|
777
|
+
if (texte) {
|
|
778
|
+
process.stdout.write(`${texte}\n`);
|
|
764
779
|
}
|
|
765
|
-
const lot = await attendreUneQuestion({
|
|
766
|
-
racine: racineDe(args[0] ?? process.cwd()),
|
|
767
|
-
rappel,
|
|
768
|
-
});
|
|
769
|
-
process.stdout.write(`${texteDesQuestions(lot)}\n`);
|
|
770
780
|
} catch (e) {
|
|
771
781
|
process.stderr.write(`${e.message}\n`);
|
|
772
782
|
process.exitCode = 1;
|