@roomi-fields/grillhouse 0.33.0 → 0.34.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 +73 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +35 -2
- package/cadre/templates/projet/CLAUDE.md +9 -3
- package/charte.md +23 -6
- package/dist/temporal/circuit/activites.d.ts +3 -1
- package/dist/temporal/circuit/activites.js +25 -1
- package/dist/temporal/circuit/activites.js.map +1 -1
- package/dist/temporal/circuit/appel.d.ts +19 -0
- package/dist/temporal/circuit/appel.js +93 -0
- package/dist/temporal/circuit/appel.js.map +1 -0
- package/dist/temporal/circuit/client.d.ts +17 -3
- package/dist/temporal/circuit/client.js +28 -4
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +27 -87
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +29 -0
- package/dist/temporal/circuit/contrat.js +33 -0
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +115 -34
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +13 -3
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +3 -0
- package/dist/temporal/file/activites.js +9 -0
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +58 -0
- package/dist/temporal/file/deroule.d.ts +8 -1
- package/dist/temporal/file/deroule.js +100 -2
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +15 -1
- package/dist/temporal/installation.js +57 -15
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/contrat.d.ts +2 -0
- package/dist/temporal/nuits/deroule.js +3 -0
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/activites.d.ts +8 -0
- package/dist/temporal/places/activites.js +12 -1
- package/dist/temporal/places/activites.js.map +1 -1
- package/dist/temporal/places/client.d.ts +8 -1
- package/dist/temporal/places/client.js +25 -2
- package/dist/temporal/places/client.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +35 -3
- package/dist/temporal/places/contrat.js +5 -4
- package/dist/temporal/places/contrat.js.map +1 -1
- package/dist/temporal/places/deroule.js +55 -9
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.d.ts +3 -0
- package/dist/temporal/tickets/activites.js +73 -4
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +31 -0
- package/dist/temporal/tickets/deroule.js +61 -10
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/docs/ARCHITECTURE.md +240 -60
- package/docs/CADRE.md +6 -1
- package/docs/INTERFACE.md +25 -8
- package/hooks/crochet.mjs +17 -2
- package/hooks/hooks.json +24 -0
- package/package.json +1 -1
- package/scripts/activites.mjs +96 -15
- package/scripts/aiguillage.mjs +2 -0
- package/scripts/attente-a-l-arret.mjs +141 -0
- package/scripts/attente-au-tour.mjs +32 -16
- package/scripts/avancement.mjs +5 -3
- package/scripts/branche-de-nuit.mjs +63 -3
- package/scripts/circuit.mjs +57 -4
- package/scripts/circuits-du-serveur.mjs +38 -4
- package/scripts/commandes-composees.mjs +11 -4
- package/scripts/copies-finies.mjs +43 -29
- package/scripts/crochets.mjs +1 -1
- package/scripts/dernier-vert.mjs +31 -10
- package/scripts/dette.mjs +55 -4
- package/scripts/disque-des-copies.d.mts +28 -0
- package/scripts/disque-des-copies.mjs +155 -0
- package/scripts/droits.mjs +2 -0
- package/scripts/faits-du-circuit.mjs +24 -0
- package/scripts/file-des-tickets.d.mts +16 -0
- package/scripts/file-des-tickets.mjs +65 -7
- package/scripts/gardes-du-cadre.mjs +4 -2
- package/scripts/integration/file.mjs +302 -5
- package/scripts/jointure.d.ts +33 -1
- package/scripts/langages/cargo/commandes.mjs +71 -10
- package/scripts/langages/cargo/composants.mjs +12 -4
- package/scripts/langages/cargo/executables-de-tests.mjs +118 -0
- package/scripts/langages/cargo/exemples.mjs +17 -3
- package/scripts/langages/cargo/index.mjs +8 -3
- package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +2 -2
- package/scripts/langages/cargo/migrations/0.34.0-executables-de-tests.mjs +35 -0
- package/scripts/langages/cargo/squelette.mjs +8 -3
- package/scripts/langages/cargo/tailles-des-tests.mjs +68 -6
- package/scripts/langages/cargo/tests-de-head.mjs +12 -9
- package/scripts/langages/cargo/verdict.mjs +40 -14
- package/scripts/langages/python/commandes.mjs +11 -2
- package/scripts/langages/python/index.mjs +12 -4
- package/scripts/langages/python/verdict.mjs +8 -1
- package/scripts/langages/typescript/index.mjs +9 -2
- package/scripts/langages/typescript/resume-du-lanceur.mjs +86 -0
- package/scripts/langages/typescript/tests.mjs +9 -3
- package/scripts/langages/typescript/verdict.mjs +4 -60
- package/scripts/langages/typescript/verifier.mjs +11 -4
- package/scripts/langages/typescript/vitest-config/changements.mjs +32 -15
- package/scripts/langages/typescript/vitest-config/lances.mjs +45 -0
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +1 -0
- package/scripts/messages-non-lus.mjs +166 -0
- package/scripts/mesure-de-la-machine.mjs +7 -4
- package/scripts/migrations-des-gardes.mjs +168 -0
- package/scripts/places-de-la-machine.mjs +44 -40
- package/scripts/places-du-serveur.mjs +82 -14
- package/scripts/plafond-de-la-machine.d.mts +18 -0
- package/scripts/plafond-de-la-machine.mjs +45 -0
- package/scripts/recommencer.d.mts +4 -0
- package/scripts/recommencer.mjs +29 -0
- package/scripts/regles-des-places.d.mts +35 -0
- package/scripts/regles-des-places.mjs +82 -1
- package/scripts/resultats.mjs +38 -4
- package/scripts/retirer-les-copies-finies.mjs +11 -7
- package/scripts/seances.mjs +1 -1
- package/scripts/services-du-noyau.mjs +2 -1
- package/scripts/session-start.sh +12 -0
- package/scripts/sous-commandes.mjs +2 -0
- package/scripts/superviseur.mjs +283 -59
- package/scripts/tableau.mjs +390 -250
- package/scripts/taches-du-graphe.mjs +32 -5
- package/scripts/ticket-du-circuit.mjs +25 -0
- package/scripts/transitions.d.mts +27 -1
- package/scripts/transitions.mjs +96 -4
- package/scripts/verrou-de-machine.mjs +41 -17
- package/skills/explorateur/SKILL.md +8 -2
- package/skills/pitmaster/SKILL.md +26 -18
- package/skills/pitmaster/references/tour.md +3 -1
- package/skills/questionneur/SKILL.md +5 -1
- package/skills/testwriter/SKILL.md +32 -6
|
@@ -48,7 +48,7 @@ import path from 'node:path';
|
|
|
48
48
|
import { fileURLToPath } from 'node:url';
|
|
49
49
|
import { composants as lesComposants, matieres } from './consommateurs.mjs';
|
|
50
50
|
import { elementsDuLot } from './elements-du-lot.mjs';
|
|
51
|
-
import {
|
|
51
|
+
import { estNoteDeDette, lireSarif, RESULTATS } from '../../resultats.mjs';
|
|
52
52
|
import { lecteurs } from './lecteurs.mjs';
|
|
53
53
|
import { estUnTest, manifestes, soeurDAvant } from './regle-des-tests.mjs';
|
|
54
54
|
import {
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
SCRIPT_DES_TESTS,
|
|
58
58
|
} from '../../services-du-noyau.mjs';
|
|
59
59
|
import { verdict } from './verdict.mjs';
|
|
60
|
+
import { garderLesResumes, lireLesResumes, resumesDuLancement } from './resume-du-lanceur.mjs';
|
|
60
61
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
61
62
|
import { squelette } from './squelette.mjs';
|
|
62
63
|
import { estHorsDuJour } from './vitest-config/cibles.mjs';
|
|
@@ -133,7 +134,7 @@ function constatsDe(racine, script, args) {
|
|
|
133
134
|
env: { ...process.env, [RESULTATS]: dossier },
|
|
134
135
|
encoding: 'utf8',
|
|
135
136
|
});
|
|
136
|
-
const constats = lireSarif(dossier).constats.filter(k => k
|
|
137
|
+
const constats = lireSarif(dossier).constats.filter(k => !estNoteDeDette(k));
|
|
137
138
|
if (r.status !== 0 && constats.length === 0) {
|
|
138
139
|
return [{ message: `${path.basename(script)} rouge (code ${r.status ?? r.signal}).` }];
|
|
139
140
|
}
|
|
@@ -155,6 +156,8 @@ const joueDesTests = (_racine, composant) =>
|
|
|
155
156
|
|
|
156
157
|
export default {
|
|
157
158
|
nom: 'typescript',
|
|
159
|
+
// The expected size of a copy before any is measured: its node_modules, about 0.5 to 1 GB (2026-11-11).
|
|
160
|
+
tailleDUneCopie: 1024 ** 3,
|
|
158
161
|
manifeste: 'package.json',
|
|
159
162
|
// The name a package.json gives its package; its internal dependencies are the package.json's
|
|
160
163
|
// own, so no other manifest holds any.
|
|
@@ -265,6 +268,10 @@ export default {
|
|
|
265
268
|
// A night test, a bench or a time witness (./vitest-config/cibles.mjs, `estHorsDuJour`).
|
|
266
269
|
horsDuJour: (chemin, racine) => estHorsDuJour(path.resolve(racine, chemin)),
|
|
267
270
|
soeurDAvant,
|
|
271
|
+
// The summary of a run of Turborepo, which the core serves to the other modules.
|
|
272
|
+
resumesDuLancement,
|
|
273
|
+
garderLesResumes,
|
|
274
|
+
lireLesResumes,
|
|
268
275
|
// Its tool plays HEAD's version of each test file beside it (`soeurDAvant`): no tree, no name
|
|
269
276
|
// to read.
|
|
270
277
|
arbreDAvant: () => false,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// The summary of a run of Turborepo (`turbo run … --summarize`, `.turbo/runs/<id>.json`), read and
|
|
2
|
+
// kept once, here: the module typescript drives Turborepo, and the join serves these members to the
|
|
3
|
+
// modules cargo and python through the services of the core (`tachesDuVerdict`,
|
|
4
|
+
// scripts/taches-du-graphe.mjs).
|
|
5
|
+
//
|
|
6
|
+
// - `resumesDuLancement` names the summaries present in a project before a run.
|
|
7
|
+
// - `garderLesResumes` moves the summaries a run wrote into `<dossier>/turbo/`, the results
|
|
8
|
+
// directory (`GRILLHOUSE_RESULTATS`, scripts/resultats.mjs) its environment names, or removes
|
|
9
|
+
// them without one.
|
|
10
|
+
// - `lireLesResumes` gives each task of those summaries, its package and directory, its script,
|
|
11
|
+
// its exit code, its cache status and its log file (from the root), and whether it plays the
|
|
12
|
+
// tests of its package (`test:unit`).
|
|
13
|
+
import {
|
|
14
|
+
copyFileSync,
|
|
15
|
+
existsSync,
|
|
16
|
+
mkdirSync,
|
|
17
|
+
readdirSync,
|
|
18
|
+
readFileSync,
|
|
19
|
+
rmdirSync,
|
|
20
|
+
rmSync,
|
|
21
|
+
} from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { RESULTATS } from '../../resultats.mjs';
|
|
24
|
+
import { SCRIPT_DES_TESTS } from '../../services-du-noyau.mjs';
|
|
25
|
+
|
|
26
|
+
const TURBO = 'turbo';
|
|
27
|
+
|
|
28
|
+
const lireJson = f => {
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(readFileSync(f, 'utf8'));
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// The names of the summaries of <racine> before a run; none without `.turbo/runs`.
|
|
37
|
+
export function resumesDuLancement(racine) {
|
|
38
|
+
const runs = path.join(racine, '.turbo', 'runs');
|
|
39
|
+
return new Set(existsSync(runs) ? readdirSync(runs) : []);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Moves the summaries that a run in <racine> wrote (`.turbo/runs/*.json` absent from <avant>, the
|
|
43
|
+
// names there before it) into the results directory <env> names; removes them without it.
|
|
44
|
+
// `.turbo/runs` goes too when the run created it (<avant> empty) and it is left empty.
|
|
45
|
+
export function garderLesResumes(racine, avant, env = process.env) {
|
|
46
|
+
const runs = path.join(racine, '.turbo', 'runs');
|
|
47
|
+
const neufs = (existsSync(runs) ? readdirSync(runs) : []).filter(
|
|
48
|
+
f => !avant.has(f) && f.endsWith('.json')
|
|
49
|
+
);
|
|
50
|
+
const dossier = env[RESULTATS];
|
|
51
|
+
for (const f of neufs) {
|
|
52
|
+
if (dossier) {
|
|
53
|
+
mkdirSync(path.join(dossier, TURBO), { recursive: true });
|
|
54
|
+
// The results directory may lie on another file system: a copy, then the removal.
|
|
55
|
+
copyFileSync(path.join(runs, f), path.join(dossier, TURBO, f));
|
|
56
|
+
}
|
|
57
|
+
rmSync(path.join(runs, f), { force: true });
|
|
58
|
+
}
|
|
59
|
+
if (neufs.length && !avant.size && existsSync(runs) && readdirSync(runs).length === 0) {
|
|
60
|
+
rmdirSync(runs);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// The tasks of the summaries under the results directory <dossier>, in their order:
|
|
65
|
+
// `{ tache, paquet, dossier, script, tests, code, cache, journal }`, `dossier` « . » for the root,
|
|
66
|
+
// `code` null for a task that did not run.
|
|
67
|
+
export function lireLesResumes(dossier) {
|
|
68
|
+
const d = path.join(dossier, TURBO);
|
|
69
|
+
const fichiers = existsSync(d)
|
|
70
|
+
? readdirSync(d)
|
|
71
|
+
.filter(f => f.endsWith('.json'))
|
|
72
|
+
.sort()
|
|
73
|
+
: [];
|
|
74
|
+
return fichiers.flatMap(f =>
|
|
75
|
+
(lireJson(path.join(d, f))?.tasks ?? []).map(t => ({
|
|
76
|
+
tache: t.taskId,
|
|
77
|
+
paquet: t.package,
|
|
78
|
+
dossier: t.directory || '.',
|
|
79
|
+
script: t.task,
|
|
80
|
+
tests: t.task === SCRIPT_DES_TESTS,
|
|
81
|
+
code: t.execution?.exitCode ?? null,
|
|
82
|
+
cache: t.cache?.status ?? null,
|
|
83
|
+
journal: t.logFile ?? null,
|
|
84
|
+
}))
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -66,7 +66,9 @@
|
|
|
66
66
|
// does (scripts/dernier-vert.mjs): in a package or a directory named, the tests Vitest relates to
|
|
67
67
|
// the files changed since it, every test when a change lies out of Vitest's graph; a file named
|
|
68
68
|
// itself plays, changed or not; `--force` plays them all. Without the mark, every test named
|
|
69
|
-
// plays.
|
|
69
|
+
// plays. Given the base of the lot besides (`GRILLHOUSE_BASE_DU_LOT`, in a project whose CI runs
|
|
70
|
+
// on a ticket's branch), it measures itself against that base, targeted: the tests Vitest
|
|
71
|
+
// relates to the lot, never the whole package for a file out of its graph.
|
|
70
72
|
// - While the environment names a results directory (`GRILLHOUSE_RESULTATS`,
|
|
71
73
|
// scripts/resultats.mjs), each run of Turborepo writes its summary (`--summarize`), moved there,
|
|
72
74
|
// and Vitest its JSON report there: what the circuit reads of a run.
|
|
@@ -83,6 +85,7 @@ import { accessSync, constants, existsSync, readdirSync, statSync } from 'node:f
|
|
|
83
85
|
import path from 'node:path';
|
|
84
86
|
import {
|
|
85
87
|
AVANCEMENT,
|
|
88
|
+
BASE_DU_LOT,
|
|
86
89
|
CHANGEMENTS,
|
|
87
90
|
DEPUIS_LE_VERT,
|
|
88
91
|
mesure,
|
|
@@ -96,8 +99,8 @@ import {
|
|
|
96
99
|
tracesDuPlan,
|
|
97
100
|
} from '../../services-du-noyau.mjs';
|
|
98
101
|
import { paquets } from '../../paquets.mjs';
|
|
99
|
-
import { garderLesResumes } from './verdict.mjs';
|
|
100
102
|
import { RESULTATS } from '../../resultats.mjs';
|
|
103
|
+
import { garderLesResumes } from './resume-du-lanceur.mjs';
|
|
101
104
|
import { horsTypescript, planifier } from './turbo-des-paquets.mjs';
|
|
102
105
|
|
|
103
106
|
const racine = process.cwd();
|
|
@@ -113,7 +116,9 @@ const force = args.includes('--force');
|
|
|
113
116
|
const options = args.filter(a => a.startsWith('-') && a !== '--force');
|
|
114
117
|
const chemins = args.filter(a => !a.startsWith('-'));
|
|
115
118
|
// Under the circuit's mark, the tests measured against the last green; `--force` plays them all.
|
|
116
|
-
const depuis = process.env[DEPUIS_LE_VERT]
|
|
119
|
+
const depuis = process.env[DEPUIS_LE_VERT]
|
|
120
|
+
? mesure(racine, { tout: force, lot: process.env[BASE_DU_LOT] })
|
|
121
|
+
: null;
|
|
117
122
|
if (depuis) {
|
|
118
123
|
process.stdout.write(`${depuis.ligne}\n`);
|
|
119
124
|
}
|
|
@@ -125,6 +130,7 @@ const turbo = (args, tests) => {
|
|
|
125
130
|
const env = { ...process.env };
|
|
126
131
|
delete env[TESTS_CIBLES];
|
|
127
132
|
delete env[CHANGEMENTS];
|
|
133
|
+
delete env[BASE_DU_LOT];
|
|
128
134
|
Object.assign(env, depuis?.env ?? {});
|
|
129
135
|
if (tests) {
|
|
130
136
|
env[TESTS_CIBLES] = JSON.stringify(tests);
|
|
@@ -2,30 +2,16 @@
|
|
|
2
2
|
// (scripts/jointure.d.ts, `verdict`): what a run of Turborepo and of Vitest left in the results
|
|
3
3
|
// directory of a pass (`GRILLHOUSE_RESULTATS`, scripts/resultats.mjs).
|
|
4
4
|
//
|
|
5
|
-
// - The summary of a run of Turborepo (`
|
|
6
|
-
// `garderLesResumes` moves the summaries a run wrote into `<dossier>/turbo/`, and `lireResumes`
|
|
7
|
-
// gives each task, its package and directory, its script, its exit code, its cache status and
|
|
8
|
-
// its log file (from the root), and whether it plays the tests of its package (`test:unit`).
|
|
5
|
+
// - The summary of a run of Turborepo (./resume-du-lanceur.mjs): `lireLesResumes` gives each task.
|
|
9
6
|
// - The JSON report of Vitest, which the frame's base configuration writes under
|
|
10
7
|
// `<dossier>/vitest/` while the variable is set (scripts/langages/typescript/vitest-config/resultats.mjs):
|
|
11
8
|
// `lireRapportsVitest` gives each test file, its status, the message of a file that does not
|
|
12
9
|
// load, and each test, its title, its full name, its status and its first message.
|
|
13
|
-
import {
|
|
14
|
-
copyFileSync,
|
|
15
|
-
existsSync,
|
|
16
|
-
mkdirSync,
|
|
17
|
-
readdirSync,
|
|
18
|
-
readFileSync,
|
|
19
|
-
rmdirSync,
|
|
20
|
-
rmSync,
|
|
21
|
-
} from 'node:fs';
|
|
10
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
22
11
|
import path from 'node:path';
|
|
23
|
-
import {
|
|
24
|
-
import { SCRIPT_DES_TESTS } from '../../services-du-noyau.mjs';
|
|
12
|
+
import { lireLesResumes } from './resume-du-lanceur.mjs';
|
|
25
13
|
import { VITEST } from './vitest-config/resultats.mjs';
|
|
26
14
|
|
|
27
|
-
const TURBO = 'turbo';
|
|
28
|
-
|
|
29
15
|
const fichiers = (dossier, extension) =>
|
|
30
16
|
existsSync(dossier)
|
|
31
17
|
? readdirSync(dossier)
|
|
@@ -41,48 +27,6 @@ const lireJson = f => {
|
|
|
41
27
|
}
|
|
42
28
|
};
|
|
43
29
|
|
|
44
|
-
// Moves the summaries of Turborepo that a run in <racine> wrote (`.turbo/runs/*.json` absent from
|
|
45
|
-
// <avant>, the names there before it) into the results directory <env> names; removes them
|
|
46
|
-
// without it. `.turbo/runs` goes too when the run created it (<avant> empty) and it is left empty.
|
|
47
|
-
export function garderLesResumes(racine, avant, env = process.env) {
|
|
48
|
-
const runs = path.join(racine, '.turbo', 'runs');
|
|
49
|
-
const neufs = (existsSync(runs) ? readdirSync(runs) : []).filter(
|
|
50
|
-
f => !avant.has(f) && f.endsWith('.json')
|
|
51
|
-
);
|
|
52
|
-
const dossier = env[RESULTATS];
|
|
53
|
-
for (const f of neufs) {
|
|
54
|
-
if (dossier) {
|
|
55
|
-
mkdirSync(path.join(dossier, TURBO), { recursive: true });
|
|
56
|
-
// The results directory may lie on another file system: a copy, then the removal.
|
|
57
|
-
copyFileSync(path.join(runs, f), path.join(dossier, TURBO, f));
|
|
58
|
-
rmSync(path.join(runs, f), { force: true });
|
|
59
|
-
} else {
|
|
60
|
-
rmSync(path.join(runs, f), { force: true });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (neufs.length && !avant.size && existsSync(runs) && readdirSync(runs).length === 0) {
|
|
64
|
-
rmdirSync(runs);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// The tasks of the summaries of Turborepo under the results directory <dossier>, in their order:
|
|
69
|
-
// `{ tache, paquet, dossier, script, tests, code, cache, journal }`, `dossier` « . » for the root,
|
|
70
|
-
// `code` null for a task that did not run.
|
|
71
|
-
export function lireResumes(dossier) {
|
|
72
|
-
return fichiers(path.join(dossier, TURBO), '.json').flatMap(f =>
|
|
73
|
-
(lireJson(f)?.tasks ?? []).map(t => ({
|
|
74
|
-
tache: t.taskId,
|
|
75
|
-
paquet: t.package,
|
|
76
|
-
dossier: t.directory || '.',
|
|
77
|
-
script: t.task,
|
|
78
|
-
tests: t.task === SCRIPT_DES_TESTS,
|
|
79
|
-
code: t.execution?.exitCode ?? null,
|
|
80
|
-
cache: t.cache?.status ?? null,
|
|
81
|
-
journal: t.logFile ?? null,
|
|
82
|
-
}))
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
30
|
// The test files of the reports of Vitest under the results directory <dossier>: `{ fichier,
|
|
87
31
|
// etat, message, tests }`, `fichier` its absolute path, each test `{ titre, nom, etat, message }`.
|
|
88
32
|
export function lireRapportsVitest(dossier) {
|
|
@@ -103,5 +47,5 @@ export function lireRapportsVitest(dossier) {
|
|
|
103
47
|
|
|
104
48
|
// The verdict the results directory <dossier> holds: `{ rapports, taches }`.
|
|
105
49
|
export function verdict(dossier) {
|
|
106
|
-
return { rapports: lireRapportsVitest(dossier), taches:
|
|
50
|
+
return { rapports: lireRapportsVitest(dossier), taches: lireLesResumes(dossier) };
|
|
107
51
|
}
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
// a package whose inputs did not move replays from Turborepo's cache, the guards play whole,
|
|
18
18
|
// and so do the builds. The changes reach Vitest in a variable no hash counts
|
|
19
19
|
// (`GRILLHOUSE_CHANGEMENTS`). Without a last green that counts, the pass is complete. The
|
|
20
|
-
// line `↳` says which.
|
|
20
|
+
// line `↳` says which. The final pass of a circuit gives the base of its lot
|
|
21
|
+
// (`GRILLHOUSE_BASE_DU_LOT`, scripts/dernier-vert.mjs): it measures itself against it, targeted,
|
|
22
|
+
// the tests Vitest relates to the lot, never the whole package for a file out of its graph; a
|
|
23
|
+
// `--base` given takes precedence. A pass green, restricted by no filter, keeps its tree as the last green;
|
|
21
24
|
// a red one keeps the last green as it was. The pass is the one that keeps it, for every language
|
|
22
25
|
// of the project: it plays the tasks of every package of the graph, a crate's and a Python
|
|
23
26
|
// project's beside a TypeScript package's (their `test:unit` and `typecheck`, scripts of their
|
|
@@ -106,6 +109,7 @@ import {
|
|
|
106
109
|
AttenteDeLaMachine,
|
|
107
110
|
AVANCEMENT,
|
|
108
111
|
avecLaMachineEtUnePlace,
|
|
112
|
+
BASE_DU_LOT,
|
|
109
113
|
CHANGEMENTS,
|
|
110
114
|
garderLeTotal,
|
|
111
115
|
garderLeVert,
|
|
@@ -123,8 +127,8 @@ import {
|
|
|
123
127
|
} from '../../services-du-noyau.mjs';
|
|
124
128
|
import { paquets, TYPAGE } from '../../paquets.mjs';
|
|
125
129
|
import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
|
|
130
|
+
import { garderLesResumes } from './resume-du-lanceur.mjs';
|
|
126
131
|
import { controlesDuDepot, planifier } from './turbo-des-paquets.mjs';
|
|
127
|
-
import { garderLesResumes } from './verdict.mjs';
|
|
128
132
|
|
|
129
133
|
const GARDES = ['grillhouse:gardes', 'gardes'];
|
|
130
134
|
const TACHES = [...GARDES, TYPAGE, SCRIPT_DES_TESTS];
|
|
@@ -330,7 +334,10 @@ function passe({ racine, demandes, env, dire, coeurs }) {
|
|
|
330
334
|
const lu = lireLesDemandes(demandes);
|
|
331
335
|
const { gardesSeules, sansTests, tranche, tout, base, args } = lu;
|
|
332
336
|
// The measure against the last green, or the base given: a pass without tests needs none.
|
|
333
|
-
const m =
|
|
337
|
+
const m =
|
|
338
|
+
gardesSeules || sansTests
|
|
339
|
+
? null
|
|
340
|
+
: mesure(racine, { tout, base, lot: env[BASE_DU_LOT], dans: env.TMPDIR });
|
|
334
341
|
if (m) {
|
|
335
342
|
dire(m.ligne);
|
|
336
343
|
}
|
|
@@ -373,7 +380,7 @@ function passe({ racine, demandes, env, dire, coeurs }) {
|
|
|
373
380
|
|
|
374
381
|
function jouerLaPasse({ racine, demandes, args, tout, ajouts, env, dire, coeurs, taches }) {
|
|
375
382
|
const { gardesSeules, sansTests, tranche } = demandes;
|
|
376
|
-
const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, ...propre } = env;
|
|
383
|
+
const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, [BASE_DU_LOT]: ___, ...propre } = env;
|
|
377
384
|
// The environment of the run: measured against the last green; the moment of a complete pass,
|
|
378
385
|
// which moves the hash of every task of tests, so that each plays for real; a tranche, with it.
|
|
379
386
|
const cibles = tranche
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
// the files that differ from the tree of the last green instead, which Vitest's git cannot read
|
|
8
8
|
// (a green kept on a copy whose lot is not committed).
|
|
9
9
|
//
|
|
10
|
-
// - The variable `GRILLHOUSE_CHANGEMENTS` names a JSON file, `{ racine, fichiers, supprimes }`:
|
|
11
|
-
// top of the repository, the files changed or added since the last green and the files
|
|
12
|
-
// each path from the top
|
|
10
|
+
// - The variable `GRILLHOUSE_CHANGEMENTS` names a JSON file, `{ racine, fichiers, supprimes, cible }`:
|
|
11
|
+
// the top of the repository, the files changed or added since the last green and the files
|
|
12
|
+
// removed, each path from the top, and, for a pass of the circuit measured against the base of
|
|
13
|
+
// its lot (scripts/dernier-vert.mjs), the mark `cible`. It passes through Turborepo without entering any hash (the root's
|
|
13
14
|
// `globalPassThroughEnv`, which scripts/langages/typescript/turbo-des-paquets.mjs writes and checks): a package whose
|
|
14
15
|
// inputs did not move replays its last green from Turborepo's cache, whatever the last green.
|
|
15
16
|
// The plugin takes it out of the environment once read: no process the tests start receives it.
|
|
@@ -46,12 +47,21 @@
|
|
|
46
47
|
// `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`, `.jsx`, `.tsx`, `.json`): data, a template, a
|
|
47
48
|
// script of the shell, a document, which a test reads without importing it.
|
|
48
49
|
// Vitest's own `forceRerunTriggers` (a configuration's, or its default) still apply, as with
|
|
49
|
-
// `--changed`.
|
|
50
|
+
// `--changed`. Under the mark `cible`, 5 and 7 do not play the package whole, and no test is
|
|
51
|
+
// related by the paths it reads (`testsQuiLancent`): the tests Vitest relates alone, the tests
|
|
52
|
+
// that declare their reads, and the files named, as `vitest --changed` leaves a file out of its graph to the complete pass, the
|
|
53
|
+
// CI's of the ticket's branch and the night's. Witness: grillhouse-4nr.21, whose
|
|
54
|
+
// `scripts/session-start.sh` the reads of 276 of the 282 test files of packages/grillhouse hold
|
|
55
|
+
// (a test that starts the command reads every script of its table).
|
|
50
56
|
// - Otherwise the tests played are those Vitest relates to the files changed or added (`related`,
|
|
51
57
|
// absolute), the tests that read one of them by its path, a script they launch or a file they
|
|
52
58
|
// read, with what it imports and names (`testsQuiLancent`, ./lances.mjs, as Bazel's `data`),
|
|
53
|
-
//
|
|
54
|
-
//
|
|
59
|
+
// the tests that declare they read a file changed, added or removed (`// @lit <motif>` at
|
|
60
|
+
// their head, `testsQuiDeclarent`, ./lances.mjs), targeted or not, and the files a targeted run
|
|
61
|
+
// names themselves (./cibles.mjs): a file named plays, changed or not. Witness: the tests that
|
|
62
|
+
// judge a list of the repository complete (the share of `scripts/` and `bin/`, the callers of
|
|
63
|
+
// each subcommand), which the targeted passes of grillhouse-44b.15 left red to the CI of the
|
|
64
|
+
// branch five times in one night (grillhouse-44b.17). A package where none relates plays none and passes
|
|
55
65
|
// (`passWithNoTests`), as Vitest's `--changed` has it.
|
|
56
66
|
//
|
|
57
67
|
// This module's top level uses Node alone (./cibles.mjs, scripts/langages/typescript/tests.mjs import it); a
|
|
@@ -60,7 +70,7 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
|
60
70
|
import { createRequire } from 'node:module';
|
|
61
71
|
import path from 'node:path';
|
|
62
72
|
import { fileURLToPath } from 'node:url';
|
|
63
|
-
import { testsQuiLancent } from './lances.mjs';
|
|
73
|
+
import { testsQuiDeclarent, testsQuiLancent } from './lances.mjs';
|
|
64
74
|
|
|
65
75
|
// This directory, the frame's base configuration.
|
|
66
76
|
const BASE = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -87,12 +97,18 @@ const sous = (f, dir) => {
|
|
|
87
97
|
return r === '' || (!r.startsWith('..') && !path.isAbsolute(r));
|
|
88
98
|
};
|
|
89
99
|
|
|
90
|
-
// The changes the file at <chemin> holds, `{ racine, fichiers, supprimes }`; null when it
|
|
91
|
-
// read.
|
|
100
|
+
// The changes the file at <chemin> holds, `{ racine, fichiers, supprimes, cible? }`; null when it
|
|
101
|
+
// does not read.
|
|
92
102
|
export function lireChangements(chemin) {
|
|
93
103
|
const c = lireJson(chemin);
|
|
94
104
|
const liste = l => Array.isArray(l) && l.every(x => typeof x === 'string');
|
|
95
|
-
if (
|
|
105
|
+
if (
|
|
106
|
+
!c ||
|
|
107
|
+
typeof c.racine !== 'string' ||
|
|
108
|
+
!liste(c.fichiers) ||
|
|
109
|
+
!liste(c.supprimes) ||
|
|
110
|
+
(c.cible !== undefined && typeof c.cible !== 'boolean')
|
|
111
|
+
) {
|
|
96
112
|
return null;
|
|
97
113
|
}
|
|
98
114
|
return c;
|
|
@@ -213,11 +229,11 @@ function paquetEntier(ch, dossier, test = {}) {
|
|
|
213
229
|
? 'la configuration du paquet'
|
|
214
230
|
: preparation.includes(a)
|
|
215
231
|
? 'un fichier de préparation des tests'
|
|
216
|
-
: lit.some(l => f === l || f.startsWith(`${l}/`))
|
|
232
|
+
: !ch.cible && lit.some(l => f === l || f.startsWith(`${l}/`))
|
|
217
233
|
? 'un chemin que ses tests déclarent lire (grillhouse.lit)'
|
|
218
234
|
: deps.some(d => sous(a, d) && construit(racine, d, a))
|
|
219
235
|
? 'le code d’un paquet dont il dépend, que ses tests lisent construit'
|
|
220
|
-
: sous(a, dossier) && !MODULE.test(f)
|
|
236
|
+
: !ch.cible && sous(a, dossier) && !MODULE.test(f)
|
|
221
237
|
? 'un fichier qu’aucun module n’importe, qu’un test lit sans l’importer'
|
|
222
238
|
: null;
|
|
223
239
|
if (raison) {
|
|
@@ -238,10 +254,11 @@ export function restreindre(test, dossier, ch, nommes, dire) {
|
|
|
238
254
|
return;
|
|
239
255
|
}
|
|
240
256
|
const changes = ch.fichiers.map(f => path.join(ch.racine, f));
|
|
241
|
-
const lanceurs = testsQuiLancent(dossier, ch.racine, changes);
|
|
242
|
-
|
|
257
|
+
const lanceurs = ch.cible ? [] : testsQuiLancent(dossier, ch.racine, changes);
|
|
258
|
+
const declarants = testsQuiDeclarent(dossier, [...ch.fichiers, ...ch.supprimes]);
|
|
259
|
+
test.related = [...new Set([...changes, ...nommes, ...lanceurs, ...declarants])];
|
|
243
260
|
test.passWithNoTests = true;
|
|
244
261
|
dire(
|
|
245
|
-
`↳ ${nom} : les tests que Vitest relie aux ${ch.fichiers.length} fichier(s) changé(s) depuis le dernier vert${lanceurs.length ? `, et ${lanceurs.length} test(s) qui en lisent un par son chemin` : ''}.`
|
|
262
|
+
`↳ ${nom} : les tests que Vitest relie aux ${ch.fichiers.length} fichier(s) changé(s) depuis ${ch.cible ? 'la base du lot' : 'le dernier vert'}${lanceurs.length ? `, et ${lanceurs.length} test(s) qui en lisent un par son chemin` : ''}${declarants.length ? `, et ${declarants.length} test(s) qui déclarent en lire un (@lit)` : ''}.`
|
|
246
263
|
);
|
|
247
264
|
}
|
|
@@ -32,6 +32,14 @@
|
|
|
32
32
|
// one of the files changed. ./changements.mjs adds them to the tests Vitest relates to the
|
|
33
33
|
// changes, so that a test plays when the script it launches changes, as it plays when a module it
|
|
34
34
|
// imports changes.
|
|
35
|
+
// - The tests that declare what they read (`testsQuiDeclarent`): a test that judges a list of the
|
|
36
|
+
// repository complete (every script has its share, every caller names its subcommand) reads files
|
|
37
|
+
// it neither imports nor names, and the reads of a test that launches the command hold every
|
|
38
|
+
// script, too many to follow under a targeted measure (./changements.mjs). It declares them, as a
|
|
39
|
+
// target of Bazel declares its `data`: a line `// @lit <motif> …` of the comment at its head,
|
|
40
|
+
// each pattern a glob from the top of the repository (`// @lit packages/grillhouse/scripts/**`).
|
|
41
|
+
// ./changements.mjs adds it to the tests of every pass, targeted or not, whose changes, files
|
|
42
|
+
// changed, added or removed, one of its patterns covers.
|
|
35
43
|
// - What a test names without the frame reading it (`nonDeclares`): a string of the test's code or
|
|
36
44
|
// of its material that ends the path of a module of its package (`'verrou.mjs'`,
|
|
37
45
|
// `'verrous/verrou.mjs'`), out of a directory of tests, the module out of what the test reads and
|
|
@@ -457,6 +465,43 @@ export function testsQuiLancent(dossier, racine, changes) {
|
|
|
457
465
|
});
|
|
458
466
|
}
|
|
459
467
|
|
|
468
|
+
// The tag of a test that declares the files it reads: a line `// @lit <motif> …` of the comment at
|
|
469
|
+
// the head of the file, before its first line of code, as the tag `@poste` (./cibles.mjs).
|
|
470
|
+
const ETIQUETTE_DE_LECTURE = /^\/\/\s*@lit\b(.*)$/;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* The patterns the text <texte> of a test file declares it reads: the words of each line
|
|
474
|
+
* `// @lit` of the comment at its head, each a glob from the top of the repository.
|
|
475
|
+
* @param {string} texte the text of the file
|
|
476
|
+
*/
|
|
477
|
+
export function lecturesDeclarees(texte) {
|
|
478
|
+
const out = [];
|
|
479
|
+
for (const ligne of texte.split('\n')) {
|
|
480
|
+
const l = ligne.trim();
|
|
481
|
+
const m = ETIQUETTE_DE_LECTURE.exec(l);
|
|
482
|
+
if (m) {
|
|
483
|
+
out.push(...m[1].split(/\s+/).filter(Boolean));
|
|
484
|
+
} else if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return out;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* The test files of the package at <dossier> that declare they read one of the files <chemins>
|
|
493
|
+
* (each from the top of the repository): those whose `@lit` patterns cover one; absolute, sorted.
|
|
494
|
+
*/
|
|
495
|
+
export function testsQuiDeclarent(dossier, chemins) {
|
|
496
|
+
if (chemins.length === 0) {
|
|
497
|
+
return [];
|
|
498
|
+
}
|
|
499
|
+
return testsDuPaquet(dossier).filter(t => {
|
|
500
|
+
const motifs = lecturesDeclarees(lire(t));
|
|
501
|
+
return motifs.some(m => chemins.some(c => path.matchesGlob(c, m)));
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
|
|
460
505
|
// Whether the path <rel> (from the top) lies under one of the paths <lit> (from the top).
|
|
461
506
|
const dansLit = (rel, lit) => lit.some(l => rel === l || rel.startsWith(`${l}/`));
|
|
462
507
|
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// The stop of an agent of a team with an unread message: the hooks SubagentStop and TeammateIdle
|
|
2
|
+
// of the frame's plugin run it (`grillhouse messages-non-lus`), as a consumer of a queue (SQS,
|
|
3
|
+
// Kafka) does not stop with messages it has not acknowledged. A message SendMessage leaves in the
|
|
4
|
+
// box of an agent while the agent writes its last answer is otherwise read by no one: the agent
|
|
5
|
+
// ends its turn and waits, and the instruction waits with it.
|
|
6
|
+
//
|
|
7
|
+
// - The box of an agent is `~/.claude/teams/<équipe>/inboxes/<nom>.json`, an array of entries
|
|
8
|
+
// `{ from, text, summary, timestamp, msg_id, read }`, which Claude Code writes and marks read
|
|
9
|
+
// (https://code.claude.com/docs/en/agent-teams.md, « Mailbox »). An unread message has
|
|
10
|
+
// `read: false`.
|
|
11
|
+
// - The agent's name: `teammate_name` (TeammateIdle); else the meta file of its transcript
|
|
12
|
+
// (`agent-<agent_id>.meta.json` beside `agent_transcript_path`, under the session's
|
|
13
|
+
// `subagents/`), whose `name` and `teamName` Claude Code writes for a named agent; else an
|
|
14
|
+
// `agent_id` of the form `<nom>@<équipe>`; else `agent_type`, which is a named agent's name. A
|
|
15
|
+
// sub-agent launched without a name has none of them, and no box.
|
|
16
|
+
// - The team: the meta file's `teamName`, else the one of the `agent_id`, else the team whose
|
|
17
|
+
// `config.json` names the hook's session as its lead's (`leadSessionId`): an agent of a team
|
|
18
|
+
// runs in its lead's session. The box is the file of that name in that team, when it exists: the
|
|
19
|
+
// list of the members (`members` of `config.json`) is not read, since Claude Code removes an
|
|
20
|
+
// agent from it when the agent leaves, while a message may still wait in its box.
|
|
21
|
+
// - Each unread message blocks the stop once: its `msg_id` is noted in
|
|
22
|
+
// `~/.claude/grillhouse/messages-signales/<équipe>/<nom>.json`, and a message already noted
|
|
23
|
+
// lets the stop pass, so that a message Claude Code leaves unread never holds the agent in a
|
|
24
|
+
// loop (`stop_hook_active` is not read: a message that comes during the continuation blocks in
|
|
25
|
+
// its turn). The file keeps the noted ids still in the box alone.
|
|
26
|
+
// - The block: the reason on the error stream, exit code 2, which both events read as the next
|
|
27
|
+
// instruction of the agent (hooks.md, « Exit code 2 behavior per event »; TeammateIdle has no
|
|
28
|
+
// `decision` in JSON). The reason gives each unread message, its sender and its text.
|
|
29
|
+
// - The box is never written: Claude Code keeps it. A box absent or unreadable, a team not found,
|
|
30
|
+
// a note that cannot be written, an input that is no JSON: the stop passes, exit 0.
|
|
31
|
+
import {
|
|
32
|
+
existsSync,
|
|
33
|
+
mkdirSync,
|
|
34
|
+
readFileSync,
|
|
35
|
+
readdirSync,
|
|
36
|
+
renameSync,
|
|
37
|
+
writeFileSync,
|
|
38
|
+
} from 'node:fs';
|
|
39
|
+
import os from 'node:os';
|
|
40
|
+
import path from 'node:path';
|
|
41
|
+
import { pathToFileURL } from 'node:url';
|
|
42
|
+
|
|
43
|
+
const lireJson = f => {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(readFileSync(f, 'utf8'));
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// The meta file of the sub-agent the input names, or null.
|
|
52
|
+
function metaDe(entree) {
|
|
53
|
+
const transcription =
|
|
54
|
+
entree.agent_transcript_path ??
|
|
55
|
+
(entree.agent_id && entree.transcript_path
|
|
56
|
+
? path.join(
|
|
57
|
+
entree.transcript_path.replace(/\.jsonl$/, ''),
|
|
58
|
+
'subagents',
|
|
59
|
+
`agent-${entree.agent_id}.jsonl`
|
|
60
|
+
)
|
|
61
|
+
: null);
|
|
62
|
+
return transcription ? lireJson(transcription.replace(/\.jsonl$/, '.meta.json')) : null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// The team whose lead runs the session <session>, under <equipes>; null when none does.
|
|
66
|
+
function equipeDeLaSeance(equipes, session) {
|
|
67
|
+
if (!session) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
let noms;
|
|
71
|
+
try {
|
|
72
|
+
noms = readdirSync(equipes);
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return (
|
|
77
|
+
noms.find(n => lireJson(path.join(equipes, n, 'config.json'))?.leadSessionId === session) ??
|
|
78
|
+
null
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The box of the agent the hook's input <entree> names: `{ equipe, nom, fichier }`, or null for an
|
|
84
|
+
* agent of no team (see the header).
|
|
85
|
+
* @param {Record<string, any>} entree the hook's input
|
|
86
|
+
* @param {{ maison?: string }} [options] the home whose `.claude/teams` holds the teams
|
|
87
|
+
* @returns {{ equipe: string, nom: string, fichier: string } | null}
|
|
88
|
+
*/
|
|
89
|
+
export function boiteDe(entree, { maison = os.homedir() } = {}) {
|
|
90
|
+
const equipes = path.join(maison, '.claude', 'teams');
|
|
91
|
+
const meta = entree.teammate_name ? null : metaDe(entree);
|
|
92
|
+
const id = /^([^@]+)@([^@]+)$/.exec(entree.agent_id ?? '');
|
|
93
|
+
const nom = entree.teammate_name ?? meta?.name ?? id?.[1] ?? entree.agent_type ?? null;
|
|
94
|
+
const equipe = meta?.teamName ?? id?.[2] ?? equipeDeLaSeance(equipes, entree.session_id);
|
|
95
|
+
if (!nom || !equipe || /[/\\]/.test(`${nom}${equipe}`)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const fichier = path.join(equipes, equipe, 'inboxes', `${nom}.json`);
|
|
99
|
+
return existsSync(fichier) ? { equipe, nom, fichier } : null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* What the stop of the agent the hook's input <entree> gets: the reason that blocks it, which
|
|
104
|
+
* gives each unread message not yet signalled, or null when the stop passes. The ids it gives are
|
|
105
|
+
* noted, so that each blocks once; the box is only read.
|
|
106
|
+
* @param {Record<string, any>} entree the hook's input
|
|
107
|
+
* @param {{ maison?: string }} [options] the home of `.claude/teams` and `.claude/grillhouse`
|
|
108
|
+
* @returns {string | null}
|
|
109
|
+
*/
|
|
110
|
+
export function messagesNonLus(entree, { maison = os.homedir() } = {}) {
|
|
111
|
+
const boite = boiteDe(entree, { maison });
|
|
112
|
+
if (!boite) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const messages = lireJson(boite.fichier);
|
|
116
|
+
if (!Array.isArray(messages)) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const note = path.join(
|
|
120
|
+
maison,
|
|
121
|
+
'.claude',
|
|
122
|
+
'grillhouse',
|
|
123
|
+
'messages-signales',
|
|
124
|
+
boite.equipe,
|
|
125
|
+
`${boite.nom}.json`
|
|
126
|
+
);
|
|
127
|
+
const lus = lireJson(note);
|
|
128
|
+
const signales = new Set(Array.isArray(lus) ? lus : []);
|
|
129
|
+
const nonLus = messages.filter(m => m && m.read === false && typeof m.msg_id === 'string');
|
|
130
|
+
const neufs = nonLus.filter(m => !signales.has(m.msg_id));
|
|
131
|
+
if (!neufs.length) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const presents = new Set(messages.map(m => m?.msg_id));
|
|
135
|
+
const garde = [...signales].filter(i => presents.has(i)).concat(neufs.map(m => m.msg_id));
|
|
136
|
+
try {
|
|
137
|
+
mkdirSync(path.dirname(note), { recursive: true });
|
|
138
|
+
writeFileSync(`${note}.${process.pid}`, `${JSON.stringify(garde)}\n`);
|
|
139
|
+
renameSync(`${note}.${process.pid}`, note);
|
|
140
|
+
} catch {
|
|
141
|
+
// A note that cannot be written would block at each stop: the stop passes.
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
return [
|
|
145
|
+
neufs.length > 1
|
|
146
|
+
? `Ne t'arrête pas : ${neufs.length} messages non lus attendent dans ta boîte. Traite-les, puis termine ton tour.`
|
|
147
|
+
: "Ne t'arrête pas : un message non lu attend dans ta boîte. Traite-le, puis termine ton tour.",
|
|
148
|
+
...neufs.map(
|
|
149
|
+
m =>
|
|
150
|
+
`\n## De ${m.from ?? 'inconnu'}${m.summary ? ` — ${m.summary}` : ''}\n${String(m.text ?? '')}`
|
|
151
|
+
),
|
|
152
|
+
].join('\n');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
156
|
+
let raison = null;
|
|
157
|
+
try {
|
|
158
|
+
raison = messagesNonLus(JSON.parse(readFileSync(0, 'utf8')));
|
|
159
|
+
} catch {
|
|
160
|
+
// An input that is no JSON lets the stop pass.
|
|
161
|
+
}
|
|
162
|
+
if (raison) {
|
|
163
|
+
process.stderr.write(`${raison}\n`);
|
|
164
|
+
process.exitCode = 2;
|
|
165
|
+
}
|
|
166
|
+
}
|