@roomi-fields/grillhouse 0.29.0 → 0.30.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 +739 -0
- package/bin/grillhouse.mjs +79 -18
- package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
- package/cadre/templates/projet/CLAUDE.md +5 -1
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/projet/package.json +2 -2
- package/charte.md +24 -0
- package/dist/temporal/acte.d.ts +24 -0
- package/dist/temporal/acte.js +139 -0
- package/dist/temporal/acte.js.map +1 -0
- package/dist/temporal/attributs.d.ts +6 -0
- package/dist/temporal/attributs.js +15 -0
- package/dist/temporal/attributs.js.map +1 -0
- package/dist/temporal/circuit/activites.d.ts +13 -0
- package/dist/temporal/circuit/activites.js +33 -0
- package/dist/temporal/circuit/activites.js.map +1 -0
- package/dist/temporal/circuit/client.d.ts +72 -0
- package/dist/temporal/circuit/client.js +247 -0
- package/dist/temporal/circuit/client.js.map +1 -0
- package/dist/temporal/circuit/commande.d.ts +2 -0
- package/dist/temporal/circuit/commande.js +238 -0
- package/dist/temporal/circuit/commande.js.map +1 -0
- package/dist/temporal/circuit/contrat.d.ts +305 -0
- package/dist/temporal/circuit/contrat.js +24 -0
- package/dist/temporal/circuit/contrat.js.map +1 -0
- package/dist/temporal/circuit/deroule.d.ts +3 -0
- package/dist/temporal/circuit/deroule.js +540 -0
- package/dist/temporal/circuit/deroule.js.map +1 -0
- package/dist/temporal/client.d.ts +47 -0
- package/dist/temporal/client.js +69 -0
- package/dist/temporal/client.js.map +1 -0
- package/dist/temporal/commande.d.ts +2 -0
- package/dist/temporal/commande.js +95 -0
- package/dist/temporal/commande.js.map +1 -0
- package/dist/temporal/deroules.d.ts +5 -0
- package/dist/temporal/deroules.js +10 -0
- package/dist/temporal/deroules.js.map +1 -0
- package/dist/temporal/etat.d.ts +33 -0
- package/dist/temporal/etat.js +59 -0
- package/dist/temporal/etat.js.map +1 -0
- package/dist/temporal/file/activites.d.ts +10 -0
- package/dist/temporal/file/activites.js +25 -0
- package/dist/temporal/file/activites.js.map +1 -0
- package/dist/temporal/file/client.d.ts +4 -0
- package/dist/temporal/file/client.js +6 -0
- package/dist/temporal/file/client.js.map +1 -0
- package/dist/temporal/file/contrat.d.ts +158 -0
- package/dist/temporal/file/contrat.js +14 -0
- package/dist/temporal/file/contrat.js.map +1 -0
- package/dist/temporal/file/deroule.d.ts +15 -0
- package/dist/temporal/file/deroule.js +235 -0
- package/dist/temporal/file/deroule.js.map +1 -0
- package/dist/temporal/installation.d.ts +124 -0
- package/dist/temporal/installation.js +408 -0
- package/dist/temporal/installation.js.map +1 -0
- package/dist/temporal/places/activites.d.ts +8 -0
- package/dist/temporal/places/activites.js +13 -0
- package/dist/temporal/places/activites.js.map +1 -0
- package/dist/temporal/places/client.d.ts +28 -0
- package/dist/temporal/places/client.js +64 -0
- package/dist/temporal/places/client.js.map +1 -0
- package/dist/temporal/places/contrat.d.ts +106 -0
- package/dist/temporal/places/contrat.js +21 -0
- package/dist/temporal/places/contrat.js.map +1 -0
- package/dist/temporal/places/deroule.d.ts +3 -0
- package/dist/temporal/places/deroule.js +198 -0
- package/dist/temporal/places/deroule.js.map +1 -0
- package/dist/temporal/sonde/activites.d.ts +6 -0
- package/dist/temporal/sonde/activites.js +52 -0
- package/dist/temporal/sonde/activites.js.map +1 -0
- package/dist/temporal/sonde/contrat.d.ts +35 -0
- package/dist/temporal/sonde/contrat.js +10 -0
- package/dist/temporal/sonde/contrat.js.map +1 -0
- package/dist/temporal/sonde/deroule.d.ts +3 -0
- package/dist/temporal/sonde/deroule.js +39 -0
- package/dist/temporal/sonde/deroule.js.map +1 -0
- package/dist/temporal/tickets/activites.d.ts +7 -0
- package/dist/temporal/tickets/activites.js +81 -0
- package/dist/temporal/tickets/activites.js.map +1 -0
- package/dist/temporal/tickets/client.d.ts +10 -0
- package/dist/temporal/tickets/client.js +31 -0
- package/dist/temporal/tickets/client.js.map +1 -0
- package/dist/temporal/tickets/contrat.d.ts +56 -0
- package/dist/temporal/tickets/contrat.js +13 -0
- package/dist/temporal/tickets/contrat.js.map +1 -0
- package/dist/temporal/tickets/deroule.d.ts +3 -0
- package/dist/temporal/tickets/deroule.js +94 -0
- package/dist/temporal/tickets/deroule.js.map +1 -0
- package/dist/temporal/travailleur.d.ts +2 -0
- package/dist/temporal/travailleur.js +69 -0
- package/dist/temporal/travailleur.js.map +1 -0
- package/docs/ARCHITECTURE.md +609 -80
- package/docs/CADRE.md +17 -0
- package/docs/INTERFACE.md +134 -42
- package/hooks/crochet.mjs +19 -2
- package/hooks/hooks.json +11 -0
- package/package.json +16 -4
- package/scripts/activites.mjs +2182 -0
- package/scripts/aiguillage.d.mts +37 -0
- package/scripts/aiguillage.mjs +7 -3
- package/scripts/avancement.mjs +128 -16
- package/scripts/bilan.mjs +37 -19
- package/scripts/cadre.mjs +11 -2
- package/scripts/circuit.mjs +881 -4059
- package/scripts/circuits-cles.d.mts +4 -0
- package/scripts/circuits-cles.mjs +21 -0
- package/scripts/circuits-du-serveur.mjs +105 -0
- package/scripts/codes-de-sortie.mjs +9 -0
- package/scripts/commandes-composees.mjs +45 -41
- package/scripts/commandes-du-path.d.mts +7 -0
- package/scripts/commandes-du-path.mjs +25 -0
- package/scripts/composition-des-langages.mjs +16 -12
- package/scripts/conformite.mjs +6 -13
- package/scripts/copies-finies.mjs +52 -47
- package/scripts/depart-du-ticket.d.mts +53 -0
- package/scripts/depart-du-ticket.mjs +124 -0
- package/scripts/dependances-internes.mjs +115 -0
- package/scripts/dernier-vert.mjs +7 -15
- package/scripts/donnees-cles.mjs +228 -0
- package/scripts/droits.mjs +11 -1
- package/scripts/effets.mjs +352 -0
- package/scripts/enveloppe/enveloppe.mjs +119 -8
- package/scripts/enveloppe/lancer.sh +14 -18
- package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
- package/scripts/enveloppe/travail-de-la-copie.mjs +5 -1
- package/scripts/etapes.mjs +5 -2
- package/scripts/faits-du-circuit.mjs +493 -0
- package/scripts/file-des-tickets.d.mts +21 -0
- package/scripts/file-des-tickets.mjs +58 -0
- package/scripts/flux-des-paquets.mjs +187 -0
- package/scripts/gardes-du-cadre.mjs +12 -2
- package/scripts/integration/file.mjs +475 -420
- package/scripts/integration/integrer.mjs +17 -19
- package/scripts/integration/rejeu.mjs +19 -4
- package/scripts/jointure.d.ts +145 -27
- package/scripts/langages/cargo/commandes.mjs +289 -109
- package/scripts/langages/cargo/composants.mjs +130 -34
- package/scripts/langages/cargo/exemples.mjs +12 -21
- package/scripts/langages/cargo/index.mjs +18 -8
- package/scripts/langages/cargo/sccache.mjs +8 -14
- package/scripts/langages/python/commandes.mjs +216 -100
- package/scripts/langages/python/composants.mjs +53 -21
- package/scripts/langages/python/exemples.mjs +6 -16
- package/scripts/langages/python/index.mjs +24 -8
- package/scripts/langages/python/lot.mjs +1 -36
- package/scripts/langages/typescript/construire.mjs +6 -163
- package/scripts/langages/typescript/exemples.mjs +3 -11
- package/scripts/langages/typescript/frontieres.mjs +1 -1
- package/scripts/langages/typescript/index.mjs +43 -61
- package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
- package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
- package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
- package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
- package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
- package/scripts/langages/typescript/tests-de-nuit.mjs +12 -9
- package/scripts/langages/typescript/tests.mjs +17 -8
- package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
- package/scripts/langages/typescript/verdict.mjs +1 -1
- package/scripts/langages/typescript/verifier.mjs +31 -11
- package/scripts/langages/typescript/vitest-config/base.mjs +22 -1
- package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
- package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
- package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
- package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
- package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +49 -63
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +3 -0
- package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
- package/scripts/mesure/pression.mjs +3 -3
- package/scripts/mesure-de-la-machine.d.mts +21 -0
- package/scripts/mesure-de-la-machine.mjs +76 -0
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
- package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
- package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
- package/scripts/migrations.mjs +5 -0
- package/scripts/nuit.sh +10 -3
- package/scripts/outils-cles.d.mts +24 -0
- package/scripts/outils-cles.mjs +0 -1
- package/scripts/paquet-npm.mjs +147 -0
- package/scripts/paquet.mjs +73 -4
- package/scripts/paquets.mjs +34 -6
- package/scripts/passe-de-la-machine.mjs +66 -0
- package/scripts/places-de-la-machine.mjs +360 -0
- package/scripts/places-du-serveur.mjs +170 -0
- package/scripts/prefixe-des-tickets.mjs +68 -0
- package/scripts/preparation.mjs +10 -3
- package/scripts/registre.mjs +3 -2
- package/scripts/regles-des-places.d.mts +36 -0
- package/scripts/regles-des-places.mjs +70 -0
- package/scripts/reponses-du-circuit.d.mts +6 -0
- package/scripts/reponses-du-circuit.mjs +28 -0
- package/scripts/resultats.mjs +7 -9
- package/scripts/retirer-les-copies-finies.mjs +25 -0
- package/scripts/sans-reponse.d.mts +4 -0
- package/scripts/sans-reponse.mjs +13 -0
- package/scripts/seances.mjs +918 -0
- package/scripts/services-du-noyau.mjs +26 -8
- package/scripts/session-start.sh +2 -2
- package/scripts/sortie.mjs +3 -3
- package/scripts/sous-commandes.mjs +38 -9
- package/scripts/style-a-l-ecriture.mjs +229 -0
- package/scripts/superviseur.mjs +122 -111
- package/scripts/tableau.mjs +148 -110
- package/scripts/taches-du-graphe.mjs +328 -0
- package/scripts/ticket-du-circuit.mjs +206 -0
- package/scripts/transitions.d.mts +148 -0
- package/scripts/transitions.mjs +901 -0
- package/scripts/verrou-de-fichier.mjs +2 -2
- package/scripts/verrou-de-machine.mjs +28 -13
- package/skills/explorateur/SKILL.md +2 -1
- package/skills/pitmaster/SKILL.md +17 -18
- package/skills/pitmaster/references/consigne-agent.md +5 -1
- package/skills/release/SKILL.md +3 -3
- package/skills/relecteur/SKILL.md +4 -2
- package/skills/testwriter/SKILL.md +36 -24
- package/scripts/demon.mjs +0 -251
- package/scripts/integration/file-attente.mjs +0 -61
- package/scripts/langages/cargo/touches.mjs +0 -93
- package/scripts/langages/typescript/script-des-tests.mjs +0 -6
|
@@ -10,11 +10,27 @@
|
|
|
10
10
|
export * from './langages.mjs';
|
|
11
11
|
|
|
12
12
|
// The services of the core to a module of language: the plan of an envelope, the progress of a
|
|
13
|
-
// pass and its measure, the base of a pass, the pressure of the machine and its lock, the last
|
|
14
|
-
// green, the arbitrages of a ticket, the source files of a project
|
|
13
|
+
// pass and its measure, the tasks of the graph of the packages, the base of a pass, the pressure of the machine, its place and its lock, the last
|
|
14
|
+
// green, the arbitrages of a ticket, the source files of a project, the search of a command in the
|
|
15
|
+
// PATH.
|
|
15
16
|
export { arbitrageTranche, estArbitrage } from './arbitrages.mjs';
|
|
16
17
|
export { garderLeTotal, inscrireLePlan, ouvrirAvancement } from './avancement.mjs';
|
|
17
18
|
export { sources } from './sources.mjs';
|
|
19
|
+
export { trouverDansLePath } from './commandes-du-path.mjs';
|
|
20
|
+
export { paquetsSansPackageJson } from './paquet-npm.mjs';
|
|
21
|
+
export {
|
|
22
|
+
cheminsDeLaTache,
|
|
23
|
+
construireDepuisLesArguments,
|
|
24
|
+
GRAPHE_JOUE,
|
|
25
|
+
lancerLesTaches,
|
|
26
|
+
nomDuPaquet,
|
|
27
|
+
PASSE_ROUGE,
|
|
28
|
+
SCRIPT_DES_TESTS,
|
|
29
|
+
TESTS_CIBLES,
|
|
30
|
+
testsCibles,
|
|
31
|
+
TRACE,
|
|
32
|
+
tracesDuPlan,
|
|
33
|
+
} from './taches-du-graphe.mjs';
|
|
18
34
|
export { luUneFois } from './lecture-unique.mjs';
|
|
19
35
|
export { CHANGEMENTS, DEPUIS_LE_VERT, garderLeVert, mesure } from './dernier-vert.mjs';
|
|
20
36
|
export { lireLaListe, paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
|
|
@@ -27,10 +43,12 @@ export {
|
|
|
27
43
|
ouvrirBase,
|
|
28
44
|
retirerALInterruption,
|
|
29
45
|
} from './mesure/base-de-passe.mjs';
|
|
30
|
-
export { A_REPASSER
|
|
46
|
+
export { A_REPASSER } from './codes-de-sortie.mjs';
|
|
47
|
+
export { ecrirePression, lirePression, SEUIL_PRESSION } from './mesure/pression.mjs';
|
|
31
48
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} from './verrou-de-machine.mjs';
|
|
49
|
+
avecLaMachineEtUnePlace,
|
|
50
|
+
surUnePlace,
|
|
51
|
+
travailleursDeLaSeance,
|
|
52
|
+
} from './places-de-la-machine.mjs';
|
|
53
|
+
export { attendreDeLaPlace, AttenteDeLaMachine, nommerLAvancement } from './verrou-de-machine.mjs';
|
|
54
|
+
export { CONFIG_BEADS, ecrireLePrefixe, prefixe } from './prefixe-des-tickets.mjs';
|
package/scripts/session-start.sh
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
# repository, and, when its opening takes the lock (not when it keeps it, after a compaction or a
|
|
32
32
|
# /clear), receives the section « L'attente des questions », the wait to launch in the background,
|
|
33
33
|
# then « Les circuits du dépôt » when there are some: each circuit that runs, each one stopped on a
|
|
34
|
-
# question with its question and the command that answers it, each one
|
|
35
|
-
# with the command that resumes it; a second session, while the first one lives, receives first the section « Un autre
|
|
34
|
+
# question with its question and the command that answers it, each one whose workflow ended
|
|
35
|
+
# without its issue with the command that resumes it; a second session, while the first one lives, receives first the section « Un autre
|
|
36
36
|
# superviseur tient ce dépôt », which asks it to say so to the owner and to launch no circuit. An
|
|
37
37
|
# agent's copy and a session of a role the circuit launches take nothing and receive nothing.
|
|
38
38
|
#
|
package/scripts/sortie.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// A release of Grillhouse, its package npm, which carries the frame's plugin: Grillhouse's own
|
|
3
3
|
// script, which no project runs (`grillhouse init` installs the template of a project alone).
|
|
4
4
|
//
|
|
5
|
-
// npx grillhouse sortie <x.y.z> the release's files: the package's package.json, CHANGELOG.md
|
|
6
|
-
// npx grillhouse sortie --etiqueter
|
|
5
|
+
// npx grillhouse sortie <x.y.z> the release's files: the package's package.json, packages/grillhouse/CHANGELOG.md
|
|
6
|
+
// npx grillhouse sortie --etiqueter the annotated tag v<version> on HEAD, the release commit
|
|
7
7
|
// and the gesture that leads Grillhouse with it once published
|
|
8
8
|
// npx grillhouse sortie --verifier-etiquette <v> exits 0 when the tag <v> names the version of the package
|
|
9
9
|
// npx grillhouse sortie --entree-du-marche the entry of the plugin in the marketplace roomi-fields
|
|
@@ -39,7 +39,7 @@ export const ENTREE_DU_MARCHE = {
|
|
|
39
39
|
name: 'grillhouse',
|
|
40
40
|
source: { source: 'npm', package: '@roomi-fields/grillhouse' },
|
|
41
41
|
};
|
|
42
|
-
const CHANGELOG = 'CHANGELOG.md';
|
|
42
|
+
const CHANGELOG = 'packages/grillhouse/CHANGELOG.md';
|
|
43
43
|
const OUVERTE = '## [Unreleased]\n';
|
|
44
44
|
const SEMVER = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
45
45
|
|
|
@@ -10,11 +10,16 @@
|
|
|
10
10
|
// - `tests` and `verifier` run the commands the modules of the project's languages describe
|
|
11
11
|
// (`commandes`, scripts/jointure.d.ts: `tester` and `verifier`; for several languages, the
|
|
12
12
|
// composed command, scripts/commandes-composees.mjs), the project being the working directory
|
|
13
|
-
// (scripts/langages.mjs); each other command it describes
|
|
14
|
-
//
|
|
13
|
+
// (scripts/langages.mjs); each other command it describes is a subcommand by its name
|
|
14
|
+
// (`frontieres`, `index-interfaces`, `typer`, `construire`), as a backend of Pants brings its
|
|
15
|
+
// goals.
|
|
16
|
+
// - `temporal` runs the build of src/temporal/commande.ts (dist/temporal/commande.js), the
|
|
17
|
+
// package's TypeScript, which Turborepo builds before the tests and the package publishes.
|
|
18
|
+
import { existsSync } from 'node:fs';
|
|
15
19
|
import path from 'node:path';
|
|
16
20
|
import { fileURLToPath } from 'node:url';
|
|
17
21
|
import { langageDe } from './langages.mjs';
|
|
22
|
+
import { avecLesDonnees, donneesDe } from './donnees-cles.mjs';
|
|
18
23
|
import { avecLesOutils, outilsDe } from './outils-cles.mjs';
|
|
19
24
|
|
|
20
25
|
const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -23,12 +28,13 @@ const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
|
|
|
23
28
|
// that runs it (`{ langage }`, its name in `commandes`).
|
|
24
29
|
export const SOUS_COMMANDES = {
|
|
25
30
|
bilan: 'bilan.mjs',
|
|
26
|
-
circuit: 'circuit.
|
|
31
|
+
circuit: '../dist/temporal/circuit/commande.js',
|
|
27
32
|
commande: 'verrous/commande.mjs',
|
|
28
33
|
'composants-affectes': 'composants-affectes.mjs',
|
|
34
|
+
'dependances-internes': 'dependances-internes.mjs',
|
|
29
35
|
droits: 'droits.mjs',
|
|
30
36
|
enveloppe: 'enveloppe/enveloppe.mjs',
|
|
31
|
-
|
|
37
|
+
'flux-des-paquets': 'flux-des-paquets.mjs',
|
|
32
38
|
'fusion-du-changelog': 'fusion-du-changelog.mjs',
|
|
33
39
|
'gardes-du-cadre': 'gardes-du-cadre.mjs',
|
|
34
40
|
greffons: 'greffons.mjs',
|
|
@@ -49,11 +55,13 @@ export const SOUS_COMMANDES = {
|
|
|
49
55
|
'retirer-copie': 'retirer-copie.sh',
|
|
50
56
|
'session-start': 'session-start.sh',
|
|
51
57
|
sortie: 'sortie.mjs',
|
|
58
|
+
'style-a-l-ecriture': 'style-a-l-ecriture.mjs',
|
|
52
59
|
'sous-modules': 'sous-modules.sh',
|
|
53
60
|
'structure-guard': 'structure-guard.sh',
|
|
54
61
|
superviseur: 'superviseur.mjs',
|
|
55
62
|
tableau: 'tableau.mjs',
|
|
56
63
|
temporaire: 'mesure/base-de-passe.mjs',
|
|
64
|
+
temporal: '../dist/temporal/commande.js',
|
|
57
65
|
tests: { langage: 'tester' },
|
|
58
66
|
ticket: 'ticket.sh',
|
|
59
67
|
'ticket-du-sous-agent': 'verrous/ticket-du-sous-agent.mjs',
|
|
@@ -62,8 +70,8 @@ export const SOUS_COMMANDES = {
|
|
|
62
70
|
};
|
|
63
71
|
|
|
64
72
|
// The commands of the module of the language that serve the project at <racine> and are no
|
|
65
|
-
// subcommand by their name: the ones `tests` and `verifier` run
|
|
66
|
-
const DU_NOYAU = new Set(['tester', 'verifier'
|
|
73
|
+
// subcommand by their name: the ones `tests` and `verifier` run.
|
|
74
|
+
const DU_NOYAU = new Set(['tester', 'verifier']);
|
|
67
75
|
|
|
68
76
|
/**
|
|
69
77
|
* The subcommands in the project at <racine>, sorted: the core's (SOUS_COMMANDES), and the
|
|
@@ -95,10 +103,29 @@ export function commandeDe(nom, racine = process.cwd()) {
|
|
|
95
103
|
return n !== null && Object.hasOwn(commandes, n) ? commandes[n] : null;
|
|
96
104
|
}
|
|
97
105
|
|
|
106
|
+
/**
|
|
107
|
+
* The refusal of the subcommand <nom> whose script <script> is missing, or null when it exists: a
|
|
108
|
+
* script of the package's TypeScript (under `dist/`) is named with the command that builds it,
|
|
109
|
+
* as a fresh clone has it unbuilt.
|
|
110
|
+
* @param {string} nom the subcommand
|
|
111
|
+
* @param {string} script its script, absolute
|
|
112
|
+
* @returns {string | null}
|
|
113
|
+
*/
|
|
114
|
+
export function scriptAbsent(nom, script) {
|
|
115
|
+
if (existsSync(script)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const construit = script.split(path.sep).includes('dist')
|
|
119
|
+
? ' : la construction du paquet le pose, `npm run build --workspace @roomi-fields/grillhouse`'
|
|
120
|
+
: '';
|
|
121
|
+
return `⛔ grillhouse ${nom} : ${script} n'existe pas${construit}.`;
|
|
122
|
+
}
|
|
123
|
+
|
|
98
124
|
/**
|
|
99
125
|
* The environment the subcommand <nom> runs under, in the project at <racine>, from <env>:
|
|
100
|
-
* `verifier` gets the tools of the project (`grillhouse.outils`, scripts/outils-cles.mjs)
|
|
101
|
-
* variable set to its path, whatever
|
|
126
|
+
* `verifier` gets the tools of the project (`grillhouse.outils`, scripts/outils-cles.mjs) and its
|
|
127
|
+
* data (`grillhouse.donnees`, scripts/donnees-cles.mjs), each variable set to its path, whatever
|
|
128
|
+
* <env> holds; every other subcommand gets <env>.
|
|
102
129
|
* @param {string} nom the subcommand
|
|
103
130
|
* @param {string} [racine] the root of the project, the working directory by default
|
|
104
131
|
* @param {Record<string, string | undefined>} [env]
|
|
@@ -106,7 +133,9 @@ export function commandeDe(nom, racine = process.cwd()) {
|
|
|
106
133
|
* @throws {Error} the faults of the key, for `verifier`
|
|
107
134
|
*/
|
|
108
135
|
export function environnementDe(nom, racine = process.cwd(), env = process.env) {
|
|
109
|
-
return nom === 'verifier'
|
|
136
|
+
return nom === 'verifier'
|
|
137
|
+
? avecLesDonnees(donneesDe(racine), avecLesOutils(outilsDe(racine), env))
|
|
138
|
+
: env;
|
|
110
139
|
}
|
|
111
140
|
|
|
112
141
|
// The script of each subcommand in the project at <racine>, where a former copy of the frame lay
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The hook of the agents' writes (PostToolUse of Write, Edit and MultiEdit, hooks.json): it applies
|
|
3
|
+
// the format and the lint's automatic fixes to the file just written, as an editor's
|
|
4
|
+
// format-on-save and lint-staged do, and gives the agent the findings nothing fixes.
|
|
5
|
+
//
|
|
6
|
+
// npx grillhouse style-a-l-ecriture reads the hook's input (JSON) on its standard input
|
|
7
|
+
//
|
|
8
|
+
// - The file written alone is touched. The package that holds it is the nearest `package.json`
|
|
9
|
+
// above it (the project's root when none lies between); the package's `format:check` and `lint`
|
|
10
|
+
// scripts say what the format and the lint cover (their patterns, from the package's folder),
|
|
11
|
+
// and the configurations of Prettier and ESLint are found upward from the file, up to the root.
|
|
12
|
+
// A file the patterns of its package do not name stays as it is; a package without a script has
|
|
13
|
+
// no such control for its files.
|
|
14
|
+
// - The order is the one of lint-staged: ESLint's fixes, then Prettier, then the findings of
|
|
15
|
+
// ESLint on the result. A finding (an ESLint error that no fix lifts, a file Prettier or ESLint
|
|
16
|
+
// cannot read) is written as `<file>:<line>:<column> <rule> — <message>`, from the project's
|
|
17
|
+
// root, in the `additionalContext` of the hook's output; it comes back at each write while it
|
|
18
|
+
// stands, and nothing blocks.
|
|
19
|
+
// - It never fails on the tool: without Prettier or ESLint installed in the project, an input that
|
|
20
|
+
// is no JSON, a file absent or out of the project, it exits 0 and writes nothing.
|
|
21
|
+
import { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import { createRequire } from 'node:module';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
|
|
25
|
+
// Node's glob matching is experimental and says so on the error stream; the hook writes none.
|
|
26
|
+
process.emitWarning = () => {};
|
|
27
|
+
|
|
28
|
+
// The flags of the two tools whose next argument is a value, not a pattern.
|
|
29
|
+
const AVEC_VALEUR = new Set([
|
|
30
|
+
'--cache-location',
|
|
31
|
+
'--config',
|
|
32
|
+
'-c',
|
|
33
|
+
'--ignore-path',
|
|
34
|
+
'--log-level',
|
|
35
|
+
'--ext',
|
|
36
|
+
'--parser',
|
|
37
|
+
'--resolve-plugins-relative-to',
|
|
38
|
+
'--rulesdir',
|
|
39
|
+
'--format',
|
|
40
|
+
'-f',
|
|
41
|
+
'--max-warnings',
|
|
42
|
+
'--plugin',
|
|
43
|
+
'--env',
|
|
44
|
+
'--global',
|
|
45
|
+
'--report-unused-disable-directives-severity',
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
// The patterns and the extensions the script <script> names for the tool <outil> (`prettier` or
|
|
49
|
+
// `eslint`), or null when the script does not run it.
|
|
50
|
+
function motifsDuScript(script, outil) {
|
|
51
|
+
if (typeof script !== 'string') return null;
|
|
52
|
+
const mots = (script.match(/"[^"]*"|'[^']*'|\S+/g) ?? []).map(m =>
|
|
53
|
+
m.replace(/^(["'])(.*)\1$/, '$2')
|
|
54
|
+
);
|
|
55
|
+
const i = mots.findIndex(m => m === outil || m.endsWith(`/${outil}`));
|
|
56
|
+
if (i < 0) return null;
|
|
57
|
+
const motifs = [];
|
|
58
|
+
const ext = [];
|
|
59
|
+
for (let j = i + 1; j < mots.length; j++) {
|
|
60
|
+
const m = mots[j];
|
|
61
|
+
if (['&&', '||', ';', '|'].includes(m)) break;
|
|
62
|
+
if (m === '--ext') ext.push(...String(mots[++j] ?? '').split(','));
|
|
63
|
+
else if (m.startsWith('--ext=')) ext.push(...m.slice(6).split(','));
|
|
64
|
+
else if (AVEC_VALEUR.has(m)) j++;
|
|
65
|
+
else if (!m.startsWith('-')) motifs.push(m.replace(/^\.\//, ''));
|
|
66
|
+
}
|
|
67
|
+
return { motifs, ext: ext.filter(Boolean).map(e => (e.startsWith('.') ? e : `.${e}`)) };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Whether the file <rel> (from the package's folder) is named by <motifs>: a pattern with a glob
|
|
71
|
+
// matches it as such, one without names the file or a folder that holds it (then <extension>
|
|
72
|
+
// decides, when given, which files of a folder count).
|
|
73
|
+
function couvre(rel, motifs, extension) {
|
|
74
|
+
return motifs.some(m => {
|
|
75
|
+
if (/[*?[\]{}]/.test(m)) return path.matchesGlob(rel, m);
|
|
76
|
+
const net = m.replace(/\/+$/, '');
|
|
77
|
+
if (net === '.' || net === '') return extension(rel);
|
|
78
|
+
return rel === net || (rel.startsWith(`${net}/`) && extension(rel));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The package.json nearest above <fichier> in <projet>: its folder and its scripts, or null.
|
|
83
|
+
function paquetDe(projet, fichier) {
|
|
84
|
+
let dossier = path.dirname(fichier);
|
|
85
|
+
for (;;) {
|
|
86
|
+
const pj = path.join(dossier, 'package.json');
|
|
87
|
+
if (existsSync(pj)) {
|
|
88
|
+
try {
|
|
89
|
+
return { dossier, scripts: JSON.parse(readFileSync(pj, 'utf8')).scripts ?? {} };
|
|
90
|
+
} catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (dossier === projet || path.dirname(dossier) === dossier) return null;
|
|
95
|
+
dossier = path.dirname(dossier);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const ligneDe = (e, defaut = 1) => e?.loc?.start?.line ?? e?.loc?.line ?? e?.line ?? defaut;
|
|
100
|
+
const premiereLigne = t => String(t ?? '').split('\n')[0];
|
|
101
|
+
|
|
102
|
+
async function main() {
|
|
103
|
+
let entree;
|
|
104
|
+
try {
|
|
105
|
+
entree = JSON.parse(readFileSync(0, 'utf8'));
|
|
106
|
+
} catch {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
if (!['Write', 'Edit', 'MultiEdit'].includes(entree?.tool_name)) return [];
|
|
110
|
+
const brut = entree.tool_input?.file_path;
|
|
111
|
+
if (typeof brut !== 'string') return [];
|
|
112
|
+
const projet = realpathSync(process.env.CLAUDE_PROJECT_DIR || process.cwd());
|
|
113
|
+
let fichier;
|
|
114
|
+
try {
|
|
115
|
+
fichier = realpathSync(path.resolve(projet, brut));
|
|
116
|
+
} catch {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
if (!fichier.startsWith(`${projet}${path.sep}`)) return [];
|
|
120
|
+
const paquet = paquetDe(projet, fichier);
|
|
121
|
+
if (!paquet) return [];
|
|
122
|
+
const rel = path.relative(paquet.dossier, fichier).split(path.sep).join('/');
|
|
123
|
+
const depuisRacine = path.relative(projet, fichier).split(path.sep).join('/');
|
|
124
|
+
|
|
125
|
+
const exigerDuProjet = createRequire(path.join(projet, 'package.json'));
|
|
126
|
+
const charger = nom => {
|
|
127
|
+
try {
|
|
128
|
+
return exigerDuProjet(nom);
|
|
129
|
+
} catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// What the scripts of the package cover.
|
|
135
|
+
const formatage = motifsDuScript(paquet.scripts['format:check'], 'prettier');
|
|
136
|
+
const lint = motifsDuScript(paquet.scripts.lint, 'eslint');
|
|
137
|
+
const prettier = formatage ? charger('prettier') : null;
|
|
138
|
+
const eslintModule = lint ? charger('eslint') : null;
|
|
139
|
+
const ESLint = eslintModule?.ESLint;
|
|
140
|
+
const constats = [];
|
|
141
|
+
const dit = (ligne, colonne, regle, message) =>
|
|
142
|
+
constats.push(`${depuisRacine}:${ligne}:${colonne} ${regle} — ${premiereLigne(message)}`);
|
|
143
|
+
|
|
144
|
+
// 1. ESLint's fixes.
|
|
145
|
+
let fatale = false;
|
|
146
|
+
const lintCouvert =
|
|
147
|
+
ESLint &&
|
|
148
|
+
couvre(rel, lint.motifs, f => (lint.ext.length ? lint.ext : ['.js']).some(e => f.endsWith(e)));
|
|
149
|
+
const eslint = fix => new ESLint({ cwd: paquet.dossier, fix });
|
|
150
|
+
const juger = async fix => {
|
|
151
|
+
const moteur = eslint(fix);
|
|
152
|
+
if (await moteur.isPathIgnored(fichier)) return null;
|
|
153
|
+
const [resultat] = await moteur.lintFiles([fichier]);
|
|
154
|
+
if (fix) await ESLint.outputFixes([resultat]);
|
|
155
|
+
return resultat;
|
|
156
|
+
};
|
|
157
|
+
let dernier = null;
|
|
158
|
+
if (lintCouvert) {
|
|
159
|
+
try {
|
|
160
|
+
dernier = await juger(true);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
dit(ligneDe(e), 1, 'eslint', e?.message);
|
|
163
|
+
fatale = true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 2. Prettier.
|
|
168
|
+
let modifie = false;
|
|
169
|
+
let erreurFormat = null;
|
|
170
|
+
if (prettier) {
|
|
171
|
+
const info = await prettier.getFileInfo(fichier, {
|
|
172
|
+
ignorePath: path.join(projet, '.prettierignore'),
|
|
173
|
+
resolveConfig: true,
|
|
174
|
+
});
|
|
175
|
+
const couvert =
|
|
176
|
+
!info.ignored && info.inferredParser && couvre(rel, formatage.motifs, f => f.length > 0);
|
|
177
|
+
if (couvert) {
|
|
178
|
+
try {
|
|
179
|
+
const texte = readFileSync(fichier, 'utf8');
|
|
180
|
+
const config = (await prettier.resolveConfig(fichier, { editorconfig: true })) ?? {};
|
|
181
|
+
const formate = await prettier.format(texte, { ...config, filepath: fichier });
|
|
182
|
+
if (formate !== texte) {
|
|
183
|
+
writeFileSync(fichier, formate);
|
|
184
|
+
modifie = true;
|
|
185
|
+
}
|
|
186
|
+
} catch (e) {
|
|
187
|
+
erreurFormat = e;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 3. ESLint's findings on the result.
|
|
193
|
+
if (lintCouvert && !fatale) {
|
|
194
|
+
try {
|
|
195
|
+
const resultat = modifie || !dernier ? await juger(false) : dernier;
|
|
196
|
+
for (const m of resultat?.messages ?? []) {
|
|
197
|
+
if (m.severity === 2) {
|
|
198
|
+
dit(m.line ?? 1, m.column ?? 1, m.ruleId ?? 'erreur', m.message);
|
|
199
|
+
if (m.fatal) fatale = true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
} catch (e) {
|
|
203
|
+
dit(ligneDe(e), 1, 'eslint', e?.message);
|
|
204
|
+
fatale = true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (erreurFormat && !fatale) {
|
|
208
|
+
dit(
|
|
209
|
+
ligneDe(erreurFormat),
|
|
210
|
+
erreurFormat?.loc?.start?.column ?? 1,
|
|
211
|
+
'prettier',
|
|
212
|
+
erreurFormat.message
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return constats;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let constats = [];
|
|
219
|
+
try {
|
|
220
|
+
constats = await main();
|
|
221
|
+
} catch {
|
|
222
|
+
constats = [];
|
|
223
|
+
}
|
|
224
|
+
if (constats.length) {
|
|
225
|
+
const texte = `Constats de style sur le fichier que tu viens d'écrire (rien ne les corrige seul ; corrige-les dans cette séance) :\n${constats.join('\n')}`;
|
|
226
|
+
process.stdout.write(
|
|
227
|
+
`${JSON.stringify({ hookSpecificOutput: { hookEventName: 'PostToolUse', additionalContext: texte } })}\n`
|
|
228
|
+
);
|
|
229
|
+
}
|