@roomi-fields/grillhouse 0.25.2 → 0.25.4
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/cadre/templates/cargo/deny.toml +2 -0
- package/docs/ARCHITECTURE.md +14 -6
- package/docs/INTERFACE.md +4 -2
- package/package.json +1 -1
- package/scripts/circuit.mjs +64 -32
- package/scripts/enveloppe/paquets-du-plan.mjs +14 -7
- package/scripts/grillhouse-maj.mjs +12 -3
- package/scripts/jointure.d.ts +6 -3
- package/scripts/langages/cargo/commandes.mjs +33 -1
- package/scripts/langages/cargo/exemples.mjs +38 -0
- package/scripts/langages/cargo/mise-a-jour.mjs +6 -0
- package/scripts/langages/typescript/consommateurs-arbitres.mjs +57 -25
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -0
- package/scripts/sortie.mjs +8 -4
- package/scripts/un-commit-par-ticket.mjs +51 -21
- package/scripts/verrous/verrou.mjs +11 -5
- package/skills/pitmaster/SKILL.md +2 -1
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -52,7 +52,9 @@ nomme (les paquets du titre), la base des tickets et les sorties du module de so
|
|
|
52
52
|
cache de Turborepo ; le `target/` et les magasins de cargo, sa maison `~/.cargo` et `~/.rustup`
|
|
53
53
|
en lecture) ; `.git` reste en lecture seule, et la matière de test partagée s'écrit par le seul
|
|
54
54
|
testwriter. Le plan se juge sur les composants du module (un paquet TypeScript, un crate, un
|
|
55
|
-
paquet hors cadre) : un chemin du plan hors de tout composant écrit la racine, toute la copie.
|
|
55
|
+
paquet hors cadre) : un chemin du plan hors de tout composant écrit la racine, toute la copie. Le
|
|
56
|
+
circuit résout les composants du titre sur la même liste (`paquetsDuLangage`) : un crate racine
|
|
57
|
+
est le composant `.`, nommé par son crate (osc-bridge). `GRILLHOUSE_ENVELOPPE` porte la liste aux commandes du
|
|
56
58
|
cadre, qui construisent, jugent et écrivent ses seuls paquets. Une écriture hors du plan échoue
|
|
57
59
|
au montage, et le verrou de l'agent arrête sa séance en nommant le paquet ; le circuit s'arrête à
|
|
58
60
|
« hors-plan », une question pour le superviseur, qui étend le plan (`--etendre`) ou refuse. Comme la visibilité de Bazel et
|
|
@@ -349,10 +351,13 @@ jamais ; les grands tests de jour d'un projet s'inscrivent dans sa dette à la m
|
|
|
349
351
|
apporte la garde (`npx grillhouse maj`, migration 0.25.0), sans qu'un test se réécrive. Un grand
|
|
350
352
|
test de jour qui ne vérifie qu'un module en sort ainsi : ses cas se réécrivent en petits tests par
|
|
351
353
|
l'interface du module (le plan de l'enveloppe, les options qu'un greffon laisse à Vitest, la
|
|
352
|
-
configuration du jour et celle de la nuit, la fonction qui lit l'avancement),
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
configuration du jour et celle de la nuit, la fonction qui lit l'avancement), le module recevant
|
|
355
|
+
en argument ce qu'il lit au dehors (la lecture de l'historique et les réponses de Beads du crochet
|
|
356
|
+
d'un commit par ticket, le git qui pose l'étiquette d'une sortie, les textes des interfaces et les
|
|
357
|
+
lecteurs du ticket de la garde des consommateurs), et ses cas que seul un grand test prouve (bwrap
|
|
358
|
+
réel, une passe réelle de Turborepo et de Vitest, un crochet ou une commande lancés dans un dépôt
|
|
359
|
+
git) se déplacent tels quels en tests de nuit dans `packages/grillhouse-essais`. Ainsi le jour ne
|
|
360
|
+
joue que des tests courts, et la dette des grands ne fait que baisser.
|
|
356
361
|
|
|
357
362
|
**Les chemins des tests** (`packages/grillhouse/scripts/langages/typescript/chemins-des-tests.mjs`, une
|
|
358
363
|
garde du cadre) : comme le bac à sable de Bazel, qui fait échouer un test qui lit une entrée non
|
|
@@ -512,7 +517,10 @@ les fichiers sources laissent de côté et que `maj` écrit dans le `.gitignore`
|
|
|
512
517
|
`scripts/langages/typescript/` (`tests/temoins/repartition.json` range chaque fichier), ses tests
|
|
513
518
|
sous `tests/unit/langages/typescript/` ; le module cargo sous `scripts/langages/cargo/` (les crates
|
|
514
519
|
de `cargo metadata`, les tests par nextest puis les doctests, la vérification par cargo-deny,
|
|
515
|
-
sous le verrou de la machine ;
|
|
520
|
+
sous le verrou de la machine ; le refus, avant tout lancement de cargo, d'un espace dont git ne
|
|
521
|
+
suit pas le Cargo.lock, comme `npm ci` refuse un projet sans package-lock.json : les tests, la
|
|
522
|
+
vérification et la préparation le nomment en une ligne avec son geste (`git add Cargo.lock`), et
|
|
523
|
+
`maj` le laisse au projet (`aFaire` de sa part), sans jouer la vérification ; ses gardes, clippy, les frontières entre crates contre la liste
|
|
516
524
|
permise du manifeste de l'espace de travail, `[workspace.metadata.grillhouse.frontieres]`, comme
|
|
517
525
|
les `depConstraints` de Nx, et l'index des interfaces, qu'il engendre, chacune aussi une
|
|
518
526
|
commande de son nom, que la ligne d'une garde rouge nomme), ses
|
package/docs/INTERFACE.md
CHANGED
|
@@ -52,8 +52,10 @@ noyau, et chaque réponse décrit sans agir, sauf `verifier` d'un fichier engend
|
|
|
52
52
|
`init`. `gabarit`, le dossier du gabarit d'un projet du langage, dont le `package.json` donne les
|
|
53
53
|
scripts du cadre et les versions des outils (`templates/projet`, `templates/cargo`) ;
|
|
54
54
|
`appliquer`, qui met le projet à la forme du langage, son `package.json` racine, que le noyau
|
|
55
|
-
écrit après, et ses autres fichiers, et rend sa part du bilan, les lignes du rapport,
|
|
56
|
-
|
|
55
|
+
écrit après, et ses autres fichiers, et rend sa part du bilan, les lignes du rapport, ce qu'il
|
|
56
|
+
laisse au projet (`aFaire`, chaque ligne avec son geste, que `maj` écrit sur la sortie d'erreur
|
|
57
|
+
avant tout outil du langage, son code 1, sans jouer la vérification ; `cargo`, un Cargo.lock que
|
|
58
|
+
git ne suit pas), s'il faut `npm install` avant la vérification et la ligne qui dit pourquoi un projet n'a pas de script
|
|
57
59
|
`verifier` ; `generateurs`, les générateurs que `maj` lance ensuite, chacun avec le fichier qu'il
|
|
58
60
|
écrit ; `installation`, null sans binaires, sinon la commande qui liste les binaires installés
|
|
59
61
|
(`{ <nom>: <version> }` en JSON) et celle qui en installe un, que le noyau lance par Node.
|
package/package.json
CHANGED
package/scripts/circuit.mjs
CHANGED
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
// separated by commas: each one a path (`packages/<nom>`, or `.`), or the name of a package,
|
|
48
48
|
// which becomes its directory (scripts/paquets.mjs), read in the ticket's copy when it exists,
|
|
49
49
|
// else in the main tree. A name that names neither stops the call, exit 2, named.
|
|
50
|
+
// - A ticket whose description holds no « ## Architecture » section stops the call, exit 2, before
|
|
51
|
+
// step 1, with the reason of the developer's lock (`sansArchitecture`, scripts/verrous/
|
|
52
|
+
// verrou.mjs), the one rule both read: the code waits for the architecture, and the steps before
|
|
53
|
+
// it would be sessions lost. `--arreter` passes, the stop not depending on the ticket's content.
|
|
50
54
|
// - Before the testwriter (a run that starts there), the plan (step 1 of scripts/etapes.mjs), as
|
|
51
55
|
// an RFC: its author writes it after surveying what exists, a review reads it once, the author
|
|
52
56
|
// answers once, and what stays open goes to who decides. One session of the explorateur out of
|
|
@@ -547,7 +551,11 @@ import { stripVTControlCharacters } from 'node:util';
|
|
|
547
551
|
import { ecrireLeBilan } from './bilan.mjs';
|
|
548
552
|
import { DEPUIS_LE_VERT } from './dernier-vert.mjs';
|
|
549
553
|
import { commandesPermises, optionsDuRole } from './droits.mjs';
|
|
550
|
-
import {
|
|
554
|
+
import {
|
|
555
|
+
ecrireLaListe,
|
|
556
|
+
paquetsDuLangage,
|
|
557
|
+
VARIABLE as VARIABLE_ENVELOPPE,
|
|
558
|
+
} from './enveloppe/paquets-du-plan.mjs';
|
|
551
559
|
import {
|
|
552
560
|
AGENTS_DU_LOT,
|
|
553
561
|
ARRETS,
|
|
@@ -564,7 +572,6 @@ import {
|
|
|
564
572
|
RESPONSABLE,
|
|
565
573
|
SUITE,
|
|
566
574
|
} from './etapes.mjs';
|
|
567
|
-
import { paquets } from './paquets.mjs';
|
|
568
575
|
import { releve } from './composants-affectes.mjs';
|
|
569
576
|
import { ecrire as ecrireAuRegistre, ligneDEtape, transcriptionsDeLaCopie } from './registre.mjs';
|
|
570
577
|
import { FICHIER as DETTE } from './dette.mjs';
|
|
@@ -593,6 +600,7 @@ import { garderLeTotal, ouvrirAvancement } from './avancement.mjs';
|
|
|
593
600
|
import { AVANCEMENT } from './mesure/avancement.mjs';
|
|
594
601
|
import { nomsDesGardes } from './gardes-du-cadre.mjs';
|
|
595
602
|
import { langageDe } from './langages.mjs';
|
|
603
|
+
import { sansArchitecture } from './verrous/verrou.mjs';
|
|
596
604
|
import { A_REPASSER } from './mesure/pression.mjs';
|
|
597
605
|
import { departDe, leMemeVivant, ouvrirBase, vivant } from './mesure/base-de-passe.mjs';
|
|
598
606
|
import { GREFFON } from './cadre.mjs';
|
|
@@ -795,6 +803,39 @@ function arbrePrincipal() {
|
|
|
795
803
|
return path.dirname(r.stdout.trim());
|
|
796
804
|
}
|
|
797
805
|
|
|
806
|
+
// The components of the repository at <racine> as the module of its language gives them, and the
|
|
807
|
+
// packages out of the frame a plan may name (`paquetsDuLangage`, as the envelope reads them):
|
|
808
|
+
// `{ dossier, pkg: { name }, hors }`, `dossier` relative to <racine>, `.` for a component at its
|
|
809
|
+
// root (a crate whose workspace is its own, as OSC Bridge's).
|
|
810
|
+
export const composantsDe = racine => paquetsDuLangage(langageDe(racine), racine);
|
|
811
|
+
|
|
812
|
+
// The directory of the component <nom> of a title among <liste> (`composantsDe` of the repository
|
|
813
|
+
// at <base>): `.` itself; a component by its path or its name; else a path of the repository; or a
|
|
814
|
+
// Usage.
|
|
815
|
+
export function resoudreComposant(liste, base, nom) {
|
|
816
|
+
const brut = path.normalize(nom);
|
|
817
|
+
const norme = brut.endsWith('/') ? brut.slice(0, -1) : brut;
|
|
818
|
+
if (norme === '.') return '.';
|
|
819
|
+
if (liste.some(p => p.dossier === norme)) return norme;
|
|
820
|
+
const parNom = liste.find(p => p.pkg.name === nom);
|
|
821
|
+
if (parNom) return parNom.dossier;
|
|
822
|
+
if (!norme.startsWith('..') && existsSync(path.join(base, norme))) return norme;
|
|
823
|
+
throw new Usage(`le composant « ${nom} » du titre ne nomme ni un paquet ni un chemin du dépôt.`);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// The ticket <id> as `bd show --json` gives it in <sortie>, refused by a Usage when its description
|
|
827
|
+
// holds no « ## Architecture » section, by the rule of the developer's lock (`sansArchitecture`):
|
|
828
|
+
// the code waits for the architecture, so the circuit stops before its first session, as a CI
|
|
829
|
+
// validates its configuration before it runs its jobs. The supervisor's stop (<arreter>,
|
|
830
|
+
// `--arreter`) passes: it does not depend on the ticket's content, as GitLab cancels a pipeline
|
|
831
|
+
// whatever its configuration; `--reprendre` and `--etendre` keep the check.
|
|
832
|
+
export function ticketAuDepart(id, sortie, { arreter = false } = {}) {
|
|
833
|
+
const t = JSON.parse(sortie)[0];
|
|
834
|
+
const refus = arreter ? null : sansArchitecture(id, t?.description);
|
|
835
|
+
if (refus) throw new Usage(refus);
|
|
836
|
+
return t;
|
|
837
|
+
}
|
|
838
|
+
|
|
798
839
|
// The context of one run: the paths of the ticket, its plan, how the circuit speaks to bd.
|
|
799
840
|
function contexte(o) {
|
|
800
841
|
const racine = arbrePrincipal();
|
|
@@ -811,22 +852,10 @@ function contexte(o) {
|
|
|
811
852
|
const bd = (...a) => bdSous(AUTEUR_DU_CIRCUIT, ...a);
|
|
812
853
|
const show = bd('show', o.ticket, '--json');
|
|
813
854
|
if (show.status !== 0) throw new Usage(`ticket ${o.ticket} illisible : ${show.stderr}`);
|
|
814
|
-
const t =
|
|
855
|
+
const t = ticketAuDepart(o.ticket, show.stdout, { arreter: Boolean(o.arreter) });
|
|
815
856
|
const base = existsSync(copie) ? copie : racine;
|
|
816
|
-
const liste =
|
|
817
|
-
const resoudre = nom =>
|
|
818
|
-
if (nom === '.') return '.';
|
|
819
|
-
const norme = path.normalize(nom).endsWith('/')
|
|
820
|
-
? path.normalize(nom).slice(0, -1)
|
|
821
|
-
: path.normalize(nom);
|
|
822
|
-
if (liste.some(p => p.dossier === norme)) return norme;
|
|
823
|
-
const parNom = liste.find(p => p.pkg.name === nom);
|
|
824
|
-
if (parNom) return parNom.dossier;
|
|
825
|
-
if (!norme.startsWith('..') && existsSync(path.join(base, norme))) return norme;
|
|
826
|
-
throw new Usage(
|
|
827
|
-
`le composant « ${nom} » du titre ne nomme ni un paquet ni un chemin du dépôt.`
|
|
828
|
-
);
|
|
829
|
-
};
|
|
857
|
+
const liste = composantsDe(base);
|
|
858
|
+
const resoudre = nom => resoudreComposant(liste, base, nom);
|
|
830
859
|
// The subject of the title <titre>, « numéro — sujet — composants », and the packages of its
|
|
831
860
|
// plan, its components, each a directory of the repository; or a Usage.
|
|
832
861
|
const duTitre = titre => {
|
|
@@ -1450,10 +1479,10 @@ const lireSaFiche = (ctx, sorte, sortie) =>
|
|
|
1450
1479
|
ticket: leTicket(ctx).description,
|
|
1451
1480
|
});
|
|
1452
1481
|
|
|
1453
|
-
// The name of
|
|
1454
|
-
function
|
|
1455
|
-
const liste =
|
|
1456
|
-
return liste.find(p => p.dossier ===
|
|
1482
|
+
// The name of each package of <dossiers> as a title writes it: its component's name, or its path.
|
|
1483
|
+
function nomsDe(ctx, dossiers) {
|
|
1484
|
+
const liste = composantsDe(existsSync(ctx.copie) ? ctx.copie : ctx.racine);
|
|
1485
|
+
return dossiers.map(d => liste.find(p => p.dossier === d)?.pkg.name ?? d);
|
|
1457
1486
|
}
|
|
1458
1487
|
|
|
1459
1488
|
// The sheet <fiche> of <role>, kept with the ticket's sheets, <avec> joined to its entry, each of
|
|
@@ -1462,7 +1491,7 @@ function nomDe(ctx, dossier) {
|
|
|
1462
1491
|
// and its subject), which the tri reads; returns it.
|
|
1463
1492
|
function garder(ctx, role, fiche, avec = {}) {
|
|
1464
1493
|
inscrire(ctx, { role, fiche, ...avec });
|
|
1465
|
-
const composants =
|
|
1494
|
+
const composants = nomsDe(ctx, ctx.paquets).join(', ');
|
|
1466
1495
|
for (const d of fiche.decouvertes ?? []) {
|
|
1467
1496
|
const r = spawnSync(
|
|
1468
1497
|
'bash',
|
|
@@ -2347,10 +2376,11 @@ const TYPES_DE_COMMIT = { bug: 'fix', chore: 'chore', docs: 'docs' };
|
|
|
2347
2376
|
// plan by their name; then the message the sheets of the developpeur and of the reviewer give, in
|
|
2348
2377
|
// their order, written once from the final state (`messageDuLot`).
|
|
2349
2378
|
function messageDeCommit(ctx) {
|
|
2350
|
-
const liste =
|
|
2351
|
-
const noms = ctx.paquets
|
|
2352
|
-
.
|
|
2353
|
-
|
|
2379
|
+
const liste = composantsDe(existsSync(ctx.copie) ? ctx.copie : ctx.racine);
|
|
2380
|
+
const noms = ctx.paquets.flatMap(c => {
|
|
2381
|
+
const nom = liste.find(p => p.dossier === c)?.pkg.name;
|
|
2382
|
+
return nom ? [nom] : c === '.' ? [] : [path.basename(c)];
|
|
2383
|
+
});
|
|
2354
2384
|
const type = TYPES_DE_COMMIT[ctx.type] ?? 'feat';
|
|
2355
2385
|
const portee = noms.length ? `(${noms.join(',')})` : '';
|
|
2356
2386
|
return messageDuLot({
|
|
@@ -2613,7 +2643,7 @@ function preuve(ctx) {
|
|
|
2613
2643
|
const injustifies = [];
|
|
2614
2644
|
const casses = [];
|
|
2615
2645
|
const neufs = [];
|
|
2616
|
-
const liste =
|
|
2646
|
+
const liste = composantsDe(ctx.copie).filter(p => !p.hors);
|
|
2617
2647
|
let anciens = 0;
|
|
2618
2648
|
const reportes = [];
|
|
2619
2649
|
const mesure = mesureDeLaPreuve(ctx, liste, fichiers);
|
|
@@ -2887,7 +2917,7 @@ const ligneDeCommande = c =>
|
|
|
2887
2917
|
// at the final pass, each key of the debt a guard wrote inscribed above what it finds, `{ garde,
|
|
2888
2918
|
// fichier, regle, trouve }`.
|
|
2889
2919
|
function controles(ctx, finale, restreinte = null, reportes = null) {
|
|
2890
|
-
const liste =
|
|
2920
|
+
const liste = composantsDe(ctx.copie).filter(p => !p.hors);
|
|
2891
2921
|
const filtres = restreinte
|
|
2892
2922
|
? ['--', `--filter=...[${restreinte.avant}...${restreinte.apres}]`, '--filter=//']
|
|
2893
2923
|
: [];
|
|
@@ -3083,7 +3113,7 @@ function paquetsDuPlan(ctx, liste) {
|
|
|
3083
3113
|
// packages plays its tests at its root: each plan has them.
|
|
3084
3114
|
function sansTests(ctx) {
|
|
3085
3115
|
const racine = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
|
|
3086
|
-
const liste =
|
|
3116
|
+
const liste = composantsDe(racine).filter(p => !p.hors);
|
|
3087
3117
|
if (liste.length === 0) return false;
|
|
3088
3118
|
const touche = (c, d) => c === '.' || d === c || d.startsWith(`${c}/`) || c.startsWith(`${d}/`);
|
|
3089
3119
|
return !liste.some(p => ctx.paquets.some(c => touche(c, p.dossier)) && joueDesTests(racine, p));
|
|
@@ -3914,7 +3944,7 @@ function decrireLePlan(description, criteres, questions) {
|
|
|
3914
3944
|
function ecrireLePlan(ctx, plan, description = null) {
|
|
3915
3945
|
const t = leTicket(ctx);
|
|
3916
3946
|
const parts = t.titre.split(' — ');
|
|
3917
|
-
const titre = [...parts.slice(0, -1),
|
|
3947
|
+
const titre = [...parts.slice(0, -1), nomsDe(ctx, plan).join(', ')].join(' — ');
|
|
3918
3948
|
const options = [
|
|
3919
3949
|
...(titre === t.titre ? [] : ['--title', titre]),
|
|
3920
3950
|
...(description === null || description === t.description ? [] : ['-d', description]),
|
|
@@ -4236,8 +4266,10 @@ async function arreter(ctx, e) {
|
|
|
4236
4266
|
// from.
|
|
4237
4267
|
function etendre(ctx, e) {
|
|
4238
4268
|
const gagnes = [...new Set(ctx.etendre.map(ctx.resoudre))].filter(c => !ctx.paquets.includes(c));
|
|
4239
|
-
const
|
|
4240
|
-
const
|
|
4269
|
+
const base = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
|
|
4270
|
+
const liste = composantsDe(base);
|
|
4271
|
+
const pkg = c =>
|
|
4272
|
+
liste.some(p => p.dossier === c) ? lireJson(path.join(base, c, 'package.json')) : null;
|
|
4241
4273
|
const lit = (lecteur, fournisseur) => {
|
|
4242
4274
|
const nom = pkg(fournisseur)?.name;
|
|
4243
4275
|
const p = pkg(lecteur);
|
|
@@ -33,20 +33,27 @@ export const paquetsDeLEnveloppe = (env = process.env) =>
|
|
|
33
33
|
* The components of the copy <copie>, as the module of its language <langage> gives them
|
|
34
34
|
* (`composants`, scripts/jointure.d.ts), and the packages out of the frame
|
|
35
35
|
* (`docs/agents/hors-cadre.txt`, `paquets` of scripts/paquets.mjs), which no module counts but a
|
|
36
|
-
* plan may name, in the form the plan reads: each `dossier` relative to the copy
|
|
37
|
-
*
|
|
36
|
+
* plan may name, in the form the plan reads: each `dossier` relative to the copy (`.` for a
|
|
37
|
+
* component at its root, as a crate whose workspace is its own), its `pkg.name` the package's
|
|
38
|
+
* name, else the component's, `hors` whether it is out of the frame.
|
|
38
39
|
* @param {{ composants(racine: string): { dossier: string, nom: string, paquet: string | null }[] }} langage
|
|
39
40
|
* @param {string} copie
|
|
40
|
-
* @returns {{ dossier: string, pkg: { name: string } }[]}
|
|
41
|
+
* @returns {{ dossier: string, pkg: { name: string }, hors: boolean }[]}
|
|
41
42
|
*/
|
|
42
43
|
export function paquetsDuLangage(langage, copie) {
|
|
43
|
-
const composants = langage
|
|
44
|
-
.
|
|
45
|
-
|
|
44
|
+
const composants = langage.composants(copie).map(c => ({
|
|
45
|
+
dossier: path.relative(copie, c.dossier) || '.',
|
|
46
|
+
pkg: { name: c.paquet ?? c.nom },
|
|
47
|
+
hors: false,
|
|
48
|
+
}));
|
|
46
49
|
const connus = new Set(composants.map(c => c.dossier));
|
|
47
50
|
const hors = paquets(copie)
|
|
48
51
|
.filter(p => p.hors && !connus.has(p.dossier))
|
|
49
|
-
.map(p => ({
|
|
52
|
+
.map(p => ({
|
|
53
|
+
dossier: p.dossier,
|
|
54
|
+
pkg: { name: p.pkg?.name ?? path.basename(p.dossier) },
|
|
55
|
+
hors: true,
|
|
56
|
+
}));
|
|
50
57
|
return [...composants, ...hors];
|
|
51
58
|
}
|
|
52
59
|
|
|
@@ -63,7 +63,9 @@
|
|
|
63
63
|
// its tests, the frame's package declared where the code or the tests read it, the typing of
|
|
64
64
|
// each package, the project's first configuration of its task runner. Cargo
|
|
65
65
|
// (scripts/langages/cargo/mise-a-jour.mjs): the files of its template a project lacks, and its
|
|
66
|
-
// test scripts.
|
|
66
|
+
// test scripts. What the share leaves to the project (`aFaire`: for cargo, a Cargo.lock that git
|
|
67
|
+
// does not track) is written on the error stream, the exit code 1, and the verification is not
|
|
68
|
+
// played.
|
|
67
69
|
// - The languages first (`declarerLangages`): a project that declares none (`grillhouse.langages`
|
|
68
70
|
// of its package.json) receives the languages the modules of the frame find in it
|
|
69
71
|
// (`langagesTrouves` of scripts/langages.mjs: typescript, a tsconfig.json at its root or in a
|
|
@@ -279,7 +281,7 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
279
281
|
gardes: null,
|
|
280
282
|
ligneEtat: false,
|
|
281
283
|
greffon: false,
|
|
282
|
-
duLangage: { lignes: [], installer: false, sansVerifier: null },
|
|
284
|
+
duLangage: { lignes: [], aFaire: [], installer: false, sansVerifier: null },
|
|
283
285
|
};
|
|
284
286
|
const pkg = path.join(projet, 'package.json');
|
|
285
287
|
if (existsSync(pkg)) {
|
|
@@ -357,6 +359,7 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
357
359
|
Object.assign(bilan, part.bilan);
|
|
358
360
|
bilan.duLangage = {
|
|
359
361
|
lignes: part.lignes,
|
|
362
|
+
aFaire: part.aFaire,
|
|
360
363
|
installer: part.installer,
|
|
361
364
|
sansVerifier: part.sansVerifier,
|
|
362
365
|
};
|
|
@@ -575,6 +578,12 @@ function mettreAJourLeProjet(projet, langages) {
|
|
|
575
578
|
}
|
|
576
579
|
}
|
|
577
580
|
process.stdout.write(rapport(b));
|
|
581
|
+
// What the language leaves to the project comes first, before any of its tools runs.
|
|
582
|
+
const duLangage = b.duLangage.aFaire;
|
|
583
|
+
for (const l of duLangage) {
|
|
584
|
+
process.stderr.write(`${l}\n`);
|
|
585
|
+
process.exitCode = 1;
|
|
586
|
+
}
|
|
578
587
|
const binaires = installerBinaires(projet);
|
|
579
588
|
if (binaires.installes.length > 0) {
|
|
580
589
|
process.stdout.write(`Binaires installés : ${binaires.installes.join(', ')}.\n`);
|
|
@@ -590,7 +599,7 @@ function mettreAJourLeProjet(projet, langages) {
|
|
|
590
599
|
);
|
|
591
600
|
}
|
|
592
601
|
const v = verifier(projet, {
|
|
593
|
-
fichiersAFinir: resteAFaire || echecsDesGeneres.length > 0,
|
|
602
|
+
fichiersAFinir: resteAFaire || duLangage.length > 0 || echecsDesGeneres.length > 0,
|
|
594
603
|
installer: aInstaller(b),
|
|
595
604
|
sansVerifier: b.duLangage.sansVerifier,
|
|
596
605
|
});
|
package/scripts/jointure.d.ts
CHANGED
|
@@ -136,9 +136,11 @@ export interface MiseAJour {
|
|
|
136
136
|
/** Brings the project at `projet` to the form the module asks: its root package.json `p`, which
|
|
137
137
|
* the core writes after, and its other files, from the frame's files at `source` (its template's
|
|
138
138
|
* package.json `modele`; `version`, the frame's). Its share of the update: `bilan`, the changes by
|
|
139
|
-
* name, each null when nothing changes; `lignes`, the lines of the report; `
|
|
140
|
-
*
|
|
141
|
-
*
|
|
139
|
+
* name, each null when nothing changes; `lignes`, the lines of the report; `aFaire`, what the
|
|
140
|
+
* update leaves to the project, each line naming its gesture, written on the error stream, the
|
|
141
|
+
* code 1 and the verification not played; `installer`, whether `npm install` comes before the
|
|
142
|
+
* verification; `sansVerifier`, the line that says why the project has no script `verifier`,
|
|
143
|
+
* null for the core's. */
|
|
142
144
|
appliquer(
|
|
143
145
|
projet: string,
|
|
144
146
|
o: {
|
|
@@ -150,6 +152,7 @@ export interface MiseAJour {
|
|
|
150
152
|
): {
|
|
151
153
|
bilan: Record<string, unknown>;
|
|
152
154
|
lignes: string[];
|
|
155
|
+
aFaire: string[];
|
|
153
156
|
installer: boolean;
|
|
154
157
|
sansVerifier: string | null;
|
|
155
158
|
};
|
|
@@ -45,8 +45,15 @@
|
|
|
45
45
|
// there what ./verdict.mjs reads: its tasks, each planned before it plays (`code` null until it
|
|
46
46
|
// ran), and the JUnit report of each run of nextest. A task of the workspace is named after its
|
|
47
47
|
// root, `//`, as Turborepo names the root's tasks.
|
|
48
|
+
// - `tester`, `verifier` and `preparer` refuse, before any run of cargo, a workspace whose
|
|
49
|
+
// Cargo.lock git does not track (grillhouse-rph), in one line that names the file and the
|
|
50
|
+
// gesture: `git add Cargo.lock`, or `cargo generate-lockfile` first when it is absent. Cargo
|
|
51
|
+
// recommends committing it for every project, and the verification plays the exact versions of
|
|
52
|
+
// the repository (`--locked`, as `npm ci` refuses a project without package-lock.json): a lock
|
|
53
|
+
// ignored passes in the main repository, where it lies on disk, and fails in a copy taken from
|
|
54
|
+
// git, the integration's.
|
|
48
55
|
// - The exit code: 0 when every task is green, 75 when the only reds are « à repasser », 1
|
|
49
|
-
// otherwise; 2 for a path refused or a command unknown.
|
|
56
|
+
// otherwise; 2 for a path refused, a Cargo.lock not tracked or a command unknown.
|
|
50
57
|
import { spawnSync } from 'node:child_process';
|
|
51
58
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
52
59
|
import { constants, tmpdir } from 'node:os';
|
|
@@ -74,6 +81,9 @@ const PROFIL = 'grillhouse';
|
|
|
74
81
|
export const NOMS = ['tester', 'verifier', 'typer', 'preparer'];
|
|
75
82
|
const A_REPASSER = 75;
|
|
76
83
|
const RACINE = '//';
|
|
84
|
+
const VERROU = 'Cargo.lock';
|
|
85
|
+
// The commands that play the exact versions of the repository, refused without its Cargo.lock.
|
|
86
|
+
const VERROUILLEES = ['tester', 'verifier', 'preparer'];
|
|
77
87
|
|
|
78
88
|
/** The guards of structure of the module, in the order they play: each its name, its script beside
|
|
79
89
|
* this one, and its arguments as a guard. */
|
|
@@ -295,6 +305,23 @@ function sousLaBase(genre, env, jouer) {
|
|
|
295
305
|
}
|
|
296
306
|
}
|
|
297
307
|
|
|
308
|
+
/**
|
|
309
|
+
* The line that refuses the workspace at <racine> whose Cargo.lock git does not track, the
|
|
310
|
+
* gesture named; null when git tracks it.
|
|
311
|
+
* @param {string} racine
|
|
312
|
+
* @returns {string | null}
|
|
313
|
+
*/
|
|
314
|
+
export function verrouNonVersionne(racine) {
|
|
315
|
+
if (!existsSync(path.join(racine, VERROU))) {
|
|
316
|
+
return `⛔ ${VERROU} absent : cargo generate-lockfile, puis git add ${VERROU}`;
|
|
317
|
+
}
|
|
318
|
+
const r = spawnSync('git', ['ls-files', '--error-unmatch', '--', VERROU], {
|
|
319
|
+
cwd: racine,
|
|
320
|
+
stdio: 'ignore',
|
|
321
|
+
});
|
|
322
|
+
return r.status === 0 ? null : `⛔ ${VERROU} non versionné : git add ${VERROU}`;
|
|
323
|
+
}
|
|
324
|
+
|
|
298
325
|
/**
|
|
299
326
|
* Runs the command <nom> with <args> in the workspace at <racine>: its exit code.
|
|
300
327
|
* @param {string} nom one of NOMS
|
|
@@ -302,6 +329,11 @@ function sousLaBase(genre, env, jouer) {
|
|
|
302
329
|
* @param {{ racine?: string, env?: NodeJS.ProcessEnv }} [o]
|
|
303
330
|
*/
|
|
304
331
|
export function lancer(nom, args, { racine = process.cwd(), env = process.env } = {}) {
|
|
332
|
+
const refus = VERROUILLEES.includes(nom) ? verrouNonVersionne(racine) : null;
|
|
333
|
+
if (refus) {
|
|
334
|
+
process.stderr.write(`${refus}\n`);
|
|
335
|
+
return 2;
|
|
336
|
+
}
|
|
305
337
|
const p = passe(racine, env);
|
|
306
338
|
if (nom === 'typer') {
|
|
307
339
|
p.jouer(p.prevoir(RACINE, racine, 'check', false, ['check', '--all-targets']));
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
// out of every crate added: `change`, measured from its commit; the same with a second commit
|
|
13
13
|
// that changes `ws-core`, adds the crate `ws-neuf` and removes `ws-outil`: `lot`; the same, the
|
|
14
14
|
// interface of `ws-core` then changed, its index late: `enRetard`.
|
|
15
|
+
// - Each workspace commits its Cargo.lock, the one cargo writes (grillhouse-rph): the commands
|
|
16
|
+
// tester, verifier and preparer refuse a workspace whose Cargo.lock git does not track.
|
|
15
17
|
// - A crate at the root, its workspace `members = ["."]`, with its tests, as OSC Bridge: `seul`;
|
|
16
18
|
// a crate at the root holding a second crate, `crates/aide`, none with tests: `imbrique`.
|
|
17
19
|
// - A directory without Cargo.toml: `vide`; one with a tsconfig.json alone: `typescript`.
|
|
@@ -82,6 +84,35 @@ export const INDEX = [
|
|
|
82
84
|
'',
|
|
83
85
|
].join('\n');
|
|
84
86
|
|
|
87
|
+
// The Cargo.lock that cargo writes for the crates <paquets> (`[nom, [dépendance…]]`), each at
|
|
88
|
+
// 0.1.0, sorted by name, as `cargo generate-lockfile` writes it: every trial commits its own, as
|
|
89
|
+
// Cargo recommends for every project (grillhouse-rph).
|
|
90
|
+
const verrou = paquets =>
|
|
91
|
+
[
|
|
92
|
+
'# This file is automatically @generated by Cargo.',
|
|
93
|
+
'# It is not intended for manual editing.',
|
|
94
|
+
'version = 4',
|
|
95
|
+
...[...paquets]
|
|
96
|
+
.sort(([a], [b]) => (a < b ? -1 : 1))
|
|
97
|
+
.map(([nom, deps = []]) =>
|
|
98
|
+
[
|
|
99
|
+
'',
|
|
100
|
+
'[[package]]',
|
|
101
|
+
`name = "${nom}"`,
|
|
102
|
+
'version = "0.1.0"',
|
|
103
|
+
...(deps.length ? ['dependencies = [', ...deps.map(x => ` "${x}",`), ']'] : []),
|
|
104
|
+
].join('\n')
|
|
105
|
+
),
|
|
106
|
+
'',
|
|
107
|
+
].join('\n');
|
|
108
|
+
// The lock of the four crates of the workspace, and its dependencies by crate.
|
|
109
|
+
const DEPENDANCES = {
|
|
110
|
+
'ws-app': ['ws-core'],
|
|
111
|
+
'ws-core': [],
|
|
112
|
+
'ws-matiere': [],
|
|
113
|
+
'ws-outil': ['ws-app', 'ws-core'],
|
|
114
|
+
};
|
|
115
|
+
|
|
85
116
|
const membres = noms =>
|
|
86
117
|
`[workspace]\nresolver = "2"\nmembers = [${noms.map(n => `"crates/${n}"`).join(', ')}]\n`;
|
|
87
118
|
|
|
@@ -90,6 +121,7 @@ function espace(dans) {
|
|
|
90
121
|
const racine = mkdtempSync(path.join(dans, 'espace-'));
|
|
91
122
|
const ecrire = ecrireDans(racine);
|
|
92
123
|
ecrire('Cargo.toml', membres(Object.keys(CRATES)));
|
|
124
|
+
ecrire('Cargo.lock', verrou(Object.entries(DEPENDANCES)));
|
|
93
125
|
ecrire('.gitignore', '/target\n');
|
|
94
126
|
ecrire('README.md', "# L'espace d'essai\n");
|
|
95
127
|
for (const [n, m] of Object.entries(CRATES)) {
|
|
@@ -121,6 +153,7 @@ function aLaRacine(dans, nom, membresEnPlus, fichiers) {
|
|
|
121
153
|
'Cargo.toml',
|
|
122
154
|
`[workspace]\nmembers = [${['.', ...membresEnPlus].map(m => `"${m}"`).join(', ')}]\n\n${manifeste(nom)}`
|
|
123
155
|
);
|
|
156
|
+
ecrire('Cargo.lock', verrou([nom, ...membresEnPlus.map(m => path.basename(m))].map(n => [n])));
|
|
124
157
|
ecrire('.gitignore', '/target\n');
|
|
125
158
|
for (const [f, t] of Object.entries(fichiers)) {
|
|
126
159
|
ecrire(f, t);
|
|
@@ -197,6 +230,10 @@ export default {
|
|
|
197
230
|
ecrireLot('crates/neuf/Cargo.toml', manifeste('ws-neuf'));
|
|
198
231
|
ecrireLot('crates/neuf/src/lib.rs', 'pub fn neuf() {}\n');
|
|
199
232
|
ecrireLot('Cargo.toml', membres(['core', 'app', 'matiere', 'neuf']));
|
|
233
|
+
ecrireLot(
|
|
234
|
+
'Cargo.lock',
|
|
235
|
+
verrou([...Object.entries(DEPENDANCES).filter(([n]) => n !== 'ws-outil'), ['ws-neuf']])
|
|
236
|
+
);
|
|
200
237
|
rmSync(path.join(lot, 'crates/outil'), { recursive: true, force: true });
|
|
201
238
|
git(lot, 'add', '-A');
|
|
202
239
|
git(lot, 'commit', '-q', '-m', 'lot');
|
|
@@ -319,6 +356,7 @@ export default {
|
|
|
319
356
|
valide: { racine: aJour, avant: 'HEAD', apres: 'HEAD' },
|
|
320
357
|
invalide: { racine: lot, avant: avantLeLot, apres: 'HEAD' },
|
|
321
358
|
attendu: [
|
|
359
|
+
'fichier Cargo.lock',
|
|
322
360
|
'fichier Cargo.toml',
|
|
323
361
|
'fichier crates/core/src/lib.rs',
|
|
324
362
|
'fichier crates/neuf/Cargo.toml',
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
// - The root scripts `test`, `test:forcer` and `verifier` a project lacks become the template's:
|
|
16
16
|
// the agents run `npm test`, the integration and the night `npm run verifier`. A project's own
|
|
17
17
|
// script stays.
|
|
18
|
+
// - A Cargo.lock that git does not track is left to the project (`aFaire`, grillhouse-rph): the
|
|
19
|
+
// line of ./commandes.mjs (`verrouNonVersionne`), the gesture named; the core writes it on the
|
|
20
|
+
// error stream and plays no verification, which `--locked` would fail in a copy taken from git.
|
|
18
21
|
// - The generator: the index of the interfaces (./index-interfaces.mjs), run where the project
|
|
19
22
|
// holds it, as the module typescript's.
|
|
20
23
|
// - The installation of its binaries (./binaires.json): the commands of ./binaires.mjs, which list
|
|
@@ -22,6 +25,7 @@
|
|
|
22
25
|
import { copyFileSync, existsSync, mkdirSync, readdirSync } from 'node:fs';
|
|
23
26
|
import path from 'node:path';
|
|
24
27
|
import { fileURLToPath } from 'node:url';
|
|
28
|
+
import { verrouNonVersionne } from './commandes.mjs';
|
|
25
29
|
import { SORTIE } from './index-interfaces.mjs';
|
|
26
30
|
|
|
27
31
|
const BINAIRES = path.join(path.dirname(fileURLToPath(import.meta.url)), 'binaires.mjs');
|
|
@@ -70,12 +74,14 @@ function appliquer(projet, { p, modele, source }) {
|
|
|
70
74
|
`Scripts des tests : ${scripts.map(n => `${n} (\`${p.scripts[n]}\`)`).join(', ')} écrits ; les agents lancent \`npm test\`, l'intégration et la nuit \`npm run verifier\`.`
|
|
71
75
|
);
|
|
72
76
|
}
|
|
77
|
+
const verrou = verrouNonVersionne(projet);
|
|
73
78
|
return {
|
|
74
79
|
bilan: {
|
|
75
80
|
gabarit: copies.length > 0 ? copies : null,
|
|
76
81
|
scripts: scripts.length > 0 ? scripts : null,
|
|
77
82
|
},
|
|
78
83
|
lignes,
|
|
84
|
+
aFaire: verrou ? [verrou] : [],
|
|
79
85
|
installer: false,
|
|
80
86
|
sansVerifier: null,
|
|
81
87
|
};
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
// refusal inscribed in the project's debt (`grillhouse-dette.json`, see `dette.mjs`) passes,
|
|
33
33
|
// keyed by the interface and `consommateur-sans-arbitrage`. Comments that cannot be read refuse,
|
|
34
34
|
// never inscribed.
|
|
35
|
+
// - The judgement (`juger`) takes the interfaces' texts and the readers of the ticket passed in;
|
|
36
|
+
// `verifier` reads them from git and bd.
|
|
35
37
|
import { spawnSync } from 'node:child_process';
|
|
36
38
|
import { existsSync, readFileSync } from 'node:fs';
|
|
37
39
|
import path from 'node:path';
|
|
@@ -87,24 +89,70 @@ function nonNommes(texte, noms) {
|
|
|
87
89
|
|
|
88
90
|
const git = (racine, ...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
/** The ticket of the branch <branche>: <ticket> of `agent/<ticket>`, or null. */
|
|
93
|
+
export function ticketDeLaBranche(branche) {
|
|
94
|
+
return /^agent\/(.+)$/.exec(branche)?.[1] ?? null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// The ticket of the copy at <racine>, by its branch, or null.
|
|
91
98
|
function ticketDeLaCopie(racine) {
|
|
92
99
|
const r = git(racine, 'rev-parse', '--abbrev-ref', 'HEAD');
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
return r.status === 0 ? ticketDeLaBranche(r.stdout.trim()) : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// What `bd <args>` prints, run from <principal>, parsed as JSON; throws with what it says when it
|
|
104
|
+
// fails.
|
|
105
|
+
function bdJson(principal, args) {
|
|
106
|
+
const r = spawnSync('bd', args, {
|
|
107
|
+
cwd: principal,
|
|
108
|
+
encoding: 'utf8',
|
|
109
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
110
|
+
});
|
|
111
|
+
if (r.status !== 0) throw new Error(r.stderr || r.error?.message || `code ${r.status}`);
|
|
112
|
+
return JSON.parse(r.stdout || '[]');
|
|
95
113
|
}
|
|
96
114
|
|
|
97
|
-
// The findings of the copy <racine> under <env>, in the debt's form (`dette.mjs`)
|
|
115
|
+
// The findings of the copy <racine> under <env>, in the debt's form (`dette.mjs`): its ticket,
|
|
116
|
+
// read from its branch, its interfaces at HEAD and in its working tree, and the ticket's comments
|
|
117
|
+
// and plan read by bd from the main tree, judged by `juger`.
|
|
98
118
|
export function verifier(racine, env = process.env) {
|
|
99
119
|
const ticket = ticketDeLaCopie(racine);
|
|
100
120
|
if (!ticket) return [];
|
|
101
|
-
const
|
|
121
|
+
const interfaces = [];
|
|
102
122
|
for (const c of aVerifier(racine, env)) {
|
|
103
123
|
const iface = path.join(c.dir, 'docs', 'INTERFACE.md');
|
|
104
124
|
if (!existsSync(iface)) continue;
|
|
105
125
|
const rel = path.relative(racine, iface);
|
|
106
126
|
const head = git(racine, 'show', `HEAD:${rel}`);
|
|
107
|
-
|
|
127
|
+
interfaces.push({
|
|
128
|
+
rel,
|
|
129
|
+
avant: head.status === 0 ? head.stdout : null,
|
|
130
|
+
apres: readFileSync(iface, 'utf8'),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const principal = () =>
|
|
134
|
+
path.dirname(
|
|
135
|
+
git(racine, 'rev-parse', '--path-format=absolute', '--git-common-dir').stdout.trim()
|
|
136
|
+
);
|
|
137
|
+
return juger(
|
|
138
|
+
ticket,
|
|
139
|
+
interfaces,
|
|
140
|
+
() => bdJson(principal(), ['comments', ticket, '--json']),
|
|
141
|
+
() => bdJson(principal(), ['show', ticket, '--json'])?.[0]
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The findings on the lot of <ticket>, in the debt's form (`dette.mjs`): <interfaces>
|
|
147
|
+
* `[{ rel, avant, apres }]`, each interface's path from the root, its text at HEAD (null when
|
|
148
|
+
* absent) and in the working tree; `commentaires()` the ticket's comments (`[{ text }]`) and
|
|
149
|
+
* `ticketLu()` the ticket (`{ title, description }`), each read only when a changed line needs it,
|
|
150
|
+
* throwing when it does not read.
|
|
151
|
+
*/
|
|
152
|
+
export function juger(ticket, interfaces, commentaires, ticketLu) {
|
|
153
|
+
const changees = [];
|
|
154
|
+
for (const { rel, avant: texteAvant, apres } of interfaces) {
|
|
155
|
+
const lignesAvant = texteAvant === null ? [] : lignesConsommateurs(texteAvant);
|
|
108
156
|
const avant = new Set(lignesAvant);
|
|
109
157
|
// The names each consumer of HEAD's section reads (`lireLigne` of scripts/langages/typescript/consommateurs.mjs,
|
|
110
158
|
// the one reading of such a line: a line that is no list of names gives none).
|
|
@@ -112,7 +160,7 @@ export function verifier(racine, env = process.env) {
|
|
|
112
160
|
for (const l of lignesAvant.map(lireLigne).filter(l => l?.noms)) {
|
|
113
161
|
nomsAvant.set(l.consommateur, new Set([...(nomsAvant.get(l.consommateur) ?? []), ...l.noms]));
|
|
114
162
|
}
|
|
115
|
-
for (const ligne of lignesConsommateurs(
|
|
163
|
+
for (const ligne of lignesConsommateurs(apres)) {
|
|
116
164
|
if (avant.has(ligne)) continue;
|
|
117
165
|
const l = lireLigne(ligne);
|
|
118
166
|
const lue = l?.noms ? l : null;
|
|
@@ -122,17 +170,9 @@ export function verifier(racine, env = process.env) {
|
|
|
122
170
|
}
|
|
123
171
|
}
|
|
124
172
|
if (changees.length === 0) return [];
|
|
125
|
-
const commun = git(racine, 'rev-parse', '--path-format=absolute', '--git-common-dir');
|
|
126
|
-
const principal = path.dirname(commun.stdout.trim());
|
|
127
|
-
const r = spawnSync('bd', ['comments', ticket, '--json'], {
|
|
128
|
-
cwd: principal,
|
|
129
|
-
encoding: 'utf8',
|
|
130
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
131
|
-
});
|
|
132
173
|
let comments;
|
|
133
174
|
try {
|
|
134
|
-
|
|
135
|
-
comments = (JSON.parse(r.stdout || '[]') ?? []).map(x => ({ text: String(x.text ?? '') }));
|
|
175
|
+
comments = (commentaires() ?? []).map(x => ({ text: String(x.text ?? '') }));
|
|
136
176
|
} catch (e) {
|
|
137
177
|
return [
|
|
138
178
|
{
|
|
@@ -148,17 +188,9 @@ export function verifier(racine, env = process.env) {
|
|
|
148
188
|
if (restantes.length === 0) return [];
|
|
149
189
|
// The lines no arbitrage settles: the ticket's plan, its title and its sections « Architecture »
|
|
150
190
|
// and « Noms publiés ».
|
|
151
|
-
const show = spawnSync('bd', ['show', ticket, '--json'], {
|
|
152
|
-
cwd: principal,
|
|
153
|
-
encoding: 'utf8',
|
|
154
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
155
|
-
});
|
|
156
191
|
let plan;
|
|
157
192
|
try {
|
|
158
|
-
|
|
159
|
-
throw new Error(show.stderr || show.error?.message || `code ${show.status}`);
|
|
160
|
-
}
|
|
161
|
-
const t = JSON.parse(show.stdout || '[]')?.[0];
|
|
193
|
+
const t = ticketLu();
|
|
162
194
|
plan = [
|
|
163
195
|
t?.title ?? '',
|
|
164
196
|
section(t?.description, /^Architecture\b/),
|
package/scripts/sortie.mjs
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
// the working tree holds no change. Nothing is pushed: the owner validates the push, whose
|
|
20
20
|
// command the script names; `.github/workflows/release.yml` then plays the CI on the tagged
|
|
21
21
|
// commit and, once it is green, checks the tag (`--verifier-etiquette`), publishes the package
|
|
22
|
-
// on the npm registry (trusted publishing, no token stored) and the release on GitHub.
|
|
22
|
+
// on the npm registry (trusted publishing, no token stored) and the release on GitHub. The git
|
|
23
|
+
// it runs is passed in (`etiqueter`'s `git`): the command runs git in the repository.
|
|
23
24
|
// - The marketplace roomi-fields (GitHub, roomi-fields/claude-plugins, a repository of its own)
|
|
24
25
|
// lists the plugin by its source npm, ENTREE_DU_MARCHE: the package, without a subdirectory (a
|
|
25
26
|
// source npm has none: the package's root is the plugin's) and without a version, so the machine
|
|
@@ -95,9 +96,12 @@ export function preparerSortie(racine, version, date) {
|
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
// Creates the annotated tag of the release at <racine> on HEAD, and returns its name
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
// Creates the annotated tag of the release at <racine> on HEAD, and returns its name; <git> runs
|
|
100
|
+
// git in <racine> (its arguments, its output as text).
|
|
101
|
+
export function etiqueter(
|
|
102
|
+
racine,
|
|
103
|
+
git = (...args) => execFileSync('git', ['-C', racine, ...args], { encoding: 'utf8' })
|
|
104
|
+
) {
|
|
101
105
|
const etiquette = `v${versionDuCadre(racine)}`;
|
|
102
106
|
if (git('status', '--porcelain').trim() !== '') {
|
|
103
107
|
throw new Error(
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
// reference, no tag. The branch `agent/<ticket>` of the ticket itself does not count for that
|
|
31
31
|
// ticket: the integration commits there before the queue brings the commit onto main, which
|
|
32
32
|
// then holds the one delivery; the branch of another ticket counts.
|
|
33
|
+
// - The reading of the history and the answers of Beads are passed in (`controle`, `commitsDelivering`,
|
|
34
|
+
// `gitLog`, `lireBeads`): the hook wires git and bd, a test passes its own.
|
|
33
35
|
import { execFileSync } from 'node:child_process';
|
|
34
36
|
import { readFileSync } from 'node:fs';
|
|
35
37
|
import { pathToFileURL } from 'node:url';
|
|
@@ -108,6 +110,11 @@ function beads(id) {
|
|
|
108
110
|
} catch (e) {
|
|
109
111
|
out = typeof e?.stdout === 'string' ? e.stdout : '';
|
|
110
112
|
}
|
|
113
|
+
return lireBeads(out, id);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// What the output <out> of `bd show <id> --json` answers on <id>: as `beads`.
|
|
117
|
+
export function lireBeads(out, id) {
|
|
111
118
|
let answer;
|
|
112
119
|
try {
|
|
113
120
|
answer = JSON.parse(out);
|
|
@@ -121,15 +128,16 @@ function beads(id) {
|
|
|
121
128
|
return answer && typeof answer === 'object' && 'error' in answer ? 'unknown' : null;
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
/** `git log` in the repository at <racine>: its arguments, its output as text. */
|
|
132
|
+
export const gitLog =
|
|
133
|
+
racine =>
|
|
134
|
+
(...args) =>
|
|
135
|
+
execFileSync('git', ['-C', racine, 'log', ...args], { encoding: 'utf8' });
|
|
128
136
|
|
|
129
137
|
// The reverting commits of the history, over the branches, as a map from a commit's full sha to the
|
|
130
138
|
// full sha it reverts. Git keeps the commits whose message holds a `This reverts commit` line and a
|
|
131
139
|
// `Revert "` or `Reapply "` line; the output grows with those commits alone.
|
|
132
|
-
function revertingCommits() {
|
|
140
|
+
function revertingCommits(log) {
|
|
133
141
|
const out = log(
|
|
134
142
|
'--branches',
|
|
135
143
|
'--all-match',
|
|
@@ -152,8 +160,8 @@ function revertingCommits() {
|
|
|
152
160
|
// The commits among `candidates` (`{ full, short }`) that no effective reverting commit names, and
|
|
153
161
|
// that are not reverting commits themselves. A reverting commit is effective when no effective
|
|
154
162
|
// reverting commit names it.
|
|
155
|
-
function withoutWithdrawn(candidates) {
|
|
156
|
-
const reverts = revertingCommits();
|
|
163
|
+
function withoutWithdrawn(candidates, log) {
|
|
164
|
+
const reverts = revertingCommits(log);
|
|
157
165
|
const namedBy = new Map();
|
|
158
166
|
for (const [hash, target] of reverts) {
|
|
159
167
|
namedBy.set(target, [...(namedBy.get(target) ?? []), hash]);
|
|
@@ -177,7 +185,7 @@ function withoutWithdrawn(candidates) {
|
|
|
177
185
|
// of its subject (`%<(N,trunc)%B`), which keeps its first line whole; that line decides. The output
|
|
178
186
|
// grows with the commits quoting the id: by their first paragraphs, and by one byte per line of
|
|
179
187
|
// their bodies, since the cut keeps every line break.
|
|
180
|
-
function commitsDelivering(id, prefix) {
|
|
188
|
+
export function commitsDelivering(id, prefix, log) {
|
|
181
189
|
const subjects = log(
|
|
182
190
|
`--exclude=agent/${id}`,
|
|
183
191
|
'--branches',
|
|
@@ -207,16 +215,22 @@ function commitsDelivering(id, prefix) {
|
|
|
207
215
|
.filter(([, first = '']) => named(first, prefix).includes(id))
|
|
208
216
|
.map(([hash]) => hash);
|
|
209
217
|
return withoutWithdrawn(
|
|
210
|
-
delivering.map(short => ({ short, full: subjects.find(c => c.hash === short).full }))
|
|
218
|
+
delivering.map(short => ({ short, full: subjects.find(c => c.hash === short).full })),
|
|
219
|
+
log
|
|
211
220
|
).map(c => c.short);
|
|
212
221
|
}
|
|
213
222
|
|
|
214
|
-
|
|
215
|
-
|
|
223
|
+
/**
|
|
224
|
+
* The verdict of the hook on the message <message>, the prefix <prefix> read from Beads,
|
|
225
|
+
* `commitsOf(id)` the earlier commits delivering the id, `answer(id)` what Beads answers on it (as
|
|
226
|
+
* `beads`, each id asked once): `{ lignes, code }`, the lines the hook writes on its error output
|
|
227
|
+
* and its exit code (1 on a refusal).
|
|
228
|
+
*/
|
|
229
|
+
export function controle(message, prefix, commitsOf, answer) {
|
|
216
230
|
const answers = new Map();
|
|
217
|
-
const
|
|
231
|
+
const answerOf = id => {
|
|
218
232
|
if (!answers.has(id)) {
|
|
219
|
-
answers.set(id,
|
|
233
|
+
answers.set(id, answer(id));
|
|
220
234
|
}
|
|
221
235
|
return answers.get(id);
|
|
222
236
|
};
|
|
@@ -224,23 +238,39 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
224
238
|
const reason =
|
|
225
239
|
prefix && !prefix.includes(' ')
|
|
226
240
|
? refusal(
|
|
227
|
-
|
|
241
|
+
message,
|
|
228
242
|
prefix,
|
|
229
|
-
|
|
243
|
+
commitsOf,
|
|
230
244
|
id => {
|
|
231
|
-
const status =
|
|
245
|
+
const status = answerOf(id)?.status;
|
|
232
246
|
return typeof status === 'string' && status !== 'closed';
|
|
233
247
|
},
|
|
234
|
-
id =>
|
|
248
|
+
id => answerOf(id) !== 'unknown'
|
|
235
249
|
)
|
|
236
250
|
: null;
|
|
251
|
+
const lignes = [];
|
|
237
252
|
if ([...answers.values()].includes(null)) {
|
|
238
|
-
|
|
239
|
-
`Beads injoignable : chaque mot ${prefix}-… du titre compte pour un ticket, connu ou non
|
|
253
|
+
lignes.push(
|
|
254
|
+
`Beads injoignable : chaque mot ${prefix}-… du titre compte pour un ticket, connu ou non.`
|
|
240
255
|
);
|
|
241
256
|
}
|
|
242
257
|
if (reason) {
|
|
243
|
-
|
|
244
|
-
|
|
258
|
+
lignes.push(`⛔ ${reason}`);
|
|
259
|
+
}
|
|
260
|
+
return { lignes, code: reason ? 1 : 0 };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
264
|
+
const prefix = prefixe();
|
|
265
|
+
const log = gitLog(process.cwd());
|
|
266
|
+
const { lignes, code } = controle(
|
|
267
|
+
readFileSync(process.argv[2], 'utf8'),
|
|
268
|
+
prefix,
|
|
269
|
+
id => commitsDelivering(id, prefix, log),
|
|
270
|
+
beads
|
|
271
|
+
);
|
|
272
|
+
for (const l of lignes) {
|
|
273
|
+
process.stderr.write(`${l}\n`);
|
|
245
274
|
}
|
|
275
|
+
process.exitCode = code;
|
|
246
276
|
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// A project that declares no language (`grillhouse.langages`) is refused, exit code 2, the
|
|
14
14
|
// update named: the lock cannot judge its writes, and a hook that throws would let them pass.
|
|
15
15
|
// - developpeur writes none of the testwriter's files, and no other file until its ticket's
|
|
16
|
-
// description holds a "## Architecture" section
|
|
16
|
+
// description holds a "## Architecture" section (`sansArchitecture`, which the start of the
|
|
17
|
+
// circuit reads too). The ticket is the "TON TICKET : <id>" line of the agent's
|
|
17
18
|
// launch prompt, read from its transcript.
|
|
18
19
|
// - In an envelope (`GRILLHOUSE_ENVELOPPE`, the packages of the plan, scripts/enveloppe/
|
|
19
20
|
// paquets-du-plan.mjs), a write in the copy out of the packages the plan writes (`ecritsDuPlan`
|
|
@@ -46,6 +47,14 @@ function isInside(file, dir) {
|
|
|
46
47
|
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
// The refusal of the ticket <id> whose <description> holds no "## Architecture" section, or null:
|
|
51
|
+
// the one rule the developer's lock and the start of the circuit (scripts/circuit.mjs) read.
|
|
52
|
+
export function sansArchitecture(id, description) {
|
|
53
|
+
return /^##\s+Architecture\b/m.test(String(description ?? ''))
|
|
54
|
+
? null
|
|
55
|
+
: `Le ticket ${id} n'a pas sa section « ## Architecture » : le code attend l'architecture. Rends la question au superviseur.`;
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
const isScratch = (file, tmp = tmpdir()) => isInside(file, tmp);
|
|
50
59
|
|
|
51
60
|
// The root of the git repository (or worktree) that holds the absolute path <file>, read from its
|
|
@@ -172,10 +181,7 @@ export function refusal(role, input, { tmp = tmpdir(), describe = ticketDescript
|
|
|
172
181
|
if (description === null) {
|
|
173
182
|
return `Le ticket ${id} est illisible par bd.`;
|
|
174
183
|
}
|
|
175
|
-
|
|
176
|
-
return `Le ticket ${id} n'a pas sa section « ## Architecture » : le code attend l'architecture. Rends la question au superviseur.`;
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
184
|
+
return sansArchitecture(id, description);
|
|
179
185
|
}
|
|
180
186
|
return `Rôle inconnu du verrou : ${role}.`;
|
|
181
187
|
}
|
|
@@ -302,7 +302,8 @@ Le circuit du ticket fait chaque commit après le verdict `ACCEPTÉ` du relecteu
|
|
|
302
302
|
## L'architecture tranche d'abord
|
|
303
303
|
|
|
304
304
|
- **Un ticket part avec sa section « Architecture »** (charte, « Le flux d'une tâche ») : je
|
|
305
|
-
l'écris avant de le proposer
|
|
305
|
+
l'écris avant de le proposer ; le circuit refuse dès son départ un ticket qui ne l'a pas, avec
|
|
306
|
+
la raison du verrou du développeur. Un mécanisme manquant devient le travail, jamais une compensation
|
|
306
307
|
locale.
|
|
307
308
|
- **Les critères naissent avec le ticket** : je crée chaque ticket de réalisation avec ses
|
|
308
309
|
critères d'acceptation numérotés (`docs/agents/issue-tracker.md`, « Conventions »). Un cas
|