@roomi-fields/grillhouse 0.28.3 → 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.
Files changed (238) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +739 -0
  3. package/bin/grillhouse.mjs +128 -26
  4. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  5. package/cadre/templates/projet/CLAUDE.md +5 -1
  6. package/cadre/templates/projet/README.md +11 -11
  7. package/cadre/templates/projet/_gitignore +2 -5
  8. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  9. package/cadre/templates/projet/package.json +2 -2
  10. package/charte.md +37 -4
  11. package/dist/temporal/acte.d.ts +24 -0
  12. package/dist/temporal/acte.js +139 -0
  13. package/dist/temporal/acte.js.map +1 -0
  14. package/dist/temporal/attributs.d.ts +6 -0
  15. package/dist/temporal/attributs.js +15 -0
  16. package/dist/temporal/attributs.js.map +1 -0
  17. package/dist/temporal/circuit/activites.d.ts +13 -0
  18. package/dist/temporal/circuit/activites.js +33 -0
  19. package/dist/temporal/circuit/activites.js.map +1 -0
  20. package/dist/temporal/circuit/client.d.ts +72 -0
  21. package/dist/temporal/circuit/client.js +247 -0
  22. package/dist/temporal/circuit/client.js.map +1 -0
  23. package/dist/temporal/circuit/commande.d.ts +2 -0
  24. package/dist/temporal/circuit/commande.js +238 -0
  25. package/dist/temporal/circuit/commande.js.map +1 -0
  26. package/dist/temporal/circuit/contrat.d.ts +305 -0
  27. package/dist/temporal/circuit/contrat.js +24 -0
  28. package/dist/temporal/circuit/contrat.js.map +1 -0
  29. package/dist/temporal/circuit/deroule.d.ts +3 -0
  30. package/dist/temporal/circuit/deroule.js +540 -0
  31. package/dist/temporal/circuit/deroule.js.map +1 -0
  32. package/dist/temporal/client.d.ts +47 -0
  33. package/dist/temporal/client.js +69 -0
  34. package/dist/temporal/client.js.map +1 -0
  35. package/dist/temporal/commande.d.ts +2 -0
  36. package/dist/temporal/commande.js +95 -0
  37. package/dist/temporal/commande.js.map +1 -0
  38. package/dist/temporal/deroules.d.ts +5 -0
  39. package/dist/temporal/deroules.js +10 -0
  40. package/dist/temporal/deroules.js.map +1 -0
  41. package/dist/temporal/etat.d.ts +33 -0
  42. package/dist/temporal/etat.js +59 -0
  43. package/dist/temporal/etat.js.map +1 -0
  44. package/dist/temporal/file/activites.d.ts +10 -0
  45. package/dist/temporal/file/activites.js +25 -0
  46. package/dist/temporal/file/activites.js.map +1 -0
  47. package/dist/temporal/file/client.d.ts +4 -0
  48. package/dist/temporal/file/client.js +6 -0
  49. package/dist/temporal/file/client.js.map +1 -0
  50. package/dist/temporal/file/contrat.d.ts +158 -0
  51. package/dist/temporal/file/contrat.js +14 -0
  52. package/dist/temporal/file/contrat.js.map +1 -0
  53. package/dist/temporal/file/deroule.d.ts +15 -0
  54. package/dist/temporal/file/deroule.js +235 -0
  55. package/dist/temporal/file/deroule.js.map +1 -0
  56. package/dist/temporal/installation.d.ts +124 -0
  57. package/dist/temporal/installation.js +408 -0
  58. package/dist/temporal/installation.js.map +1 -0
  59. package/dist/temporal/places/activites.d.ts +8 -0
  60. package/dist/temporal/places/activites.js +13 -0
  61. package/dist/temporal/places/activites.js.map +1 -0
  62. package/dist/temporal/places/client.d.ts +28 -0
  63. package/dist/temporal/places/client.js +64 -0
  64. package/dist/temporal/places/client.js.map +1 -0
  65. package/dist/temporal/places/contrat.d.ts +106 -0
  66. package/dist/temporal/places/contrat.js +21 -0
  67. package/dist/temporal/places/contrat.js.map +1 -0
  68. package/dist/temporal/places/deroule.d.ts +3 -0
  69. package/dist/temporal/places/deroule.js +198 -0
  70. package/dist/temporal/places/deroule.js.map +1 -0
  71. package/dist/temporal/sonde/activites.d.ts +6 -0
  72. package/dist/temporal/sonde/activites.js +52 -0
  73. package/dist/temporal/sonde/activites.js.map +1 -0
  74. package/dist/temporal/sonde/contrat.d.ts +35 -0
  75. package/dist/temporal/sonde/contrat.js +10 -0
  76. package/dist/temporal/sonde/contrat.js.map +1 -0
  77. package/dist/temporal/sonde/deroule.d.ts +3 -0
  78. package/dist/temporal/sonde/deroule.js +39 -0
  79. package/dist/temporal/sonde/deroule.js.map +1 -0
  80. package/dist/temporal/tickets/activites.d.ts +7 -0
  81. package/dist/temporal/tickets/activites.js +81 -0
  82. package/dist/temporal/tickets/activites.js.map +1 -0
  83. package/dist/temporal/tickets/client.d.ts +10 -0
  84. package/dist/temporal/tickets/client.js +31 -0
  85. package/dist/temporal/tickets/client.js.map +1 -0
  86. package/dist/temporal/tickets/contrat.d.ts +56 -0
  87. package/dist/temporal/tickets/contrat.js +13 -0
  88. package/dist/temporal/tickets/contrat.js.map +1 -0
  89. package/dist/temporal/tickets/deroule.d.ts +3 -0
  90. package/dist/temporal/tickets/deroule.js +94 -0
  91. package/dist/temporal/tickets/deroule.js.map +1 -0
  92. package/dist/temporal/travailleur.d.ts +2 -0
  93. package/dist/temporal/travailleur.js +69 -0
  94. package/dist/temporal/travailleur.js.map +1 -0
  95. package/docs/ARCHITECTURE.md +813 -53
  96. package/docs/CADRE.md +17 -0
  97. package/docs/INTERFACE.md +161 -30
  98. package/hooks/crochet.mjs +19 -2
  99. package/hooks/hooks.json +11 -0
  100. package/package.json +16 -4
  101. package/scripts/activites.mjs +2182 -0
  102. package/scripts/aiguillage.d.mts +37 -0
  103. package/scripts/aiguillage.mjs +328 -0
  104. package/scripts/avancement.mjs +159 -64
  105. package/scripts/bilan.mjs +37 -19
  106. package/scripts/cadre.mjs +11 -2
  107. package/scripts/circuit.mjs +888 -3654
  108. package/scripts/circuits-cles.d.mts +4 -0
  109. package/scripts/circuits-cles.mjs +21 -0
  110. package/scripts/circuits-du-serveur.mjs +105 -0
  111. package/scripts/codes-de-sortie.mjs +9 -0
  112. package/scripts/commandes-composees.mjs +45 -41
  113. package/scripts/commandes-du-path.d.mts +7 -0
  114. package/scripts/commandes-du-path.mjs +25 -0
  115. package/scripts/composition-des-langages.mjs +30 -11
  116. package/scripts/conformite.mjs +19 -10
  117. package/scripts/copies-finies.mjs +188 -42
  118. package/scripts/depart-du-ticket.d.mts +53 -0
  119. package/scripts/depart-du-ticket.mjs +124 -0
  120. package/scripts/dependances-internes.mjs +115 -0
  121. package/scripts/dernier-vert.mjs +7 -15
  122. package/scripts/donnees-cles.mjs +228 -0
  123. package/scripts/droits.mjs +11 -1
  124. package/scripts/effets.mjs +352 -0
  125. package/scripts/enveloppe/enveloppe.mjs +119 -8
  126. package/scripts/enveloppe/lancer.sh +27 -32
  127. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  128. package/scripts/enveloppe/travail-de-la-copie.mjs +99 -12
  129. package/scripts/etapes.mjs +6 -3
  130. package/scripts/faits-du-circuit.mjs +493 -0
  131. package/scripts/file-des-tickets.d.mts +21 -0
  132. package/scripts/file-des-tickets.mjs +58 -0
  133. package/scripts/flux-des-paquets.mjs +187 -0
  134. package/scripts/fusion-du-changelog.mjs +0 -1
  135. package/scripts/gardes-du-cadre.mjs +12 -2
  136. package/scripts/grillhouse-maj.mjs +16 -7
  137. package/scripts/integration/file.mjs +477 -422
  138. package/scripts/integration/integrer.mjs +20 -22
  139. package/scripts/integration/rejeu.mjs +19 -4
  140. package/scripts/jointure.d.ts +168 -28
  141. package/scripts/langages/cargo/commandes.mjs +426 -119
  142. package/scripts/langages/cargo/composants.mjs +187 -3
  143. package/scripts/langages/cargo/exemples.mjs +75 -17
  144. package/scripts/langages/cargo/index.mjs +32 -13
  145. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  146. package/scripts/langages/cargo/sccache.mjs +62 -16
  147. package/scripts/langages/cargo/squelette.mjs +72 -3
  148. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  149. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  150. package/scripts/langages/python/commandes.mjs +232 -79
  151. package/scripts/langages/python/composants.mjs +65 -3
  152. package/scripts/langages/python/exemples.mjs +21 -12
  153. package/scripts/langages/python/index.mjs +25 -5
  154. package/scripts/langages/python/lot.mjs +1 -36
  155. package/scripts/langages/python/squelette.mjs +119 -17
  156. package/scripts/langages/typescript/construire.mjs +6 -163
  157. package/scripts/langages/typescript/exemples.mjs +19 -11
  158. package/scripts/langages/typescript/frontieres.mjs +1 -1
  159. package/scripts/langages/typescript/index.mjs +48 -63
  160. package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
  161. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  162. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
  163. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  164. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  165. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  166. package/scripts/langages/typescript/squelette.mjs +18 -2
  167. package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
  168. package/scripts/langages/typescript/tests-de-nuit.mjs +44 -21
  169. package/scripts/langages/typescript/tests.mjs +17 -8
  170. package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
  171. package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
  172. package/scripts/langages/typescript/verdict.mjs +1 -1
  173. package/scripts/langages/typescript/verifier.mjs +110 -296
  174. package/scripts/langages/typescript/vitest-config/base.mjs +30 -10
  175. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  176. package/scripts/langages/typescript/vitest-config/cibles.mjs +123 -62
  177. package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
  178. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  179. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
  180. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -64
  181. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -2
  182. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  183. package/scripts/langages/typescript/vitest.nuit.config.mjs +22 -13
  184. package/scripts/lecture-unique.mjs +51 -0
  185. package/scripts/mesure/pression.mjs +11 -9
  186. package/scripts/mesure-de-la-machine.d.mts +21 -0
  187. package/scripts/mesure-de-la-machine.mjs +76 -0
  188. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
  189. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
  190. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  191. package/scripts/migrations.mjs +5 -0
  192. package/scripts/nuit.sh +29 -15
  193. package/scripts/outil.mjs +72 -0
  194. package/scripts/outils-cles.d.mts +24 -0
  195. package/scripts/outils-cles.mjs +0 -1
  196. package/scripts/paquet-npm.mjs +147 -0
  197. package/scripts/paquet.mjs +112 -14
  198. package/scripts/paquets.mjs +34 -6
  199. package/scripts/passe-de-la-machine.mjs +66 -0
  200. package/scripts/places-de-la-machine.mjs +360 -0
  201. package/scripts/places-du-serveur.mjs +170 -0
  202. package/scripts/prefixe-des-tickets.mjs +68 -0
  203. package/scripts/preparation.mjs +10 -3
  204. package/scripts/registre.mjs +3 -2
  205. package/scripts/regles-des-places.d.mts +36 -0
  206. package/scripts/regles-des-places.mjs +70 -0
  207. package/scripts/reponses-du-circuit.d.mts +6 -0
  208. package/scripts/reponses-du-circuit.mjs +28 -0
  209. package/scripts/resultats.mjs +29 -14
  210. package/scripts/retirer-les-copies-finies.mjs +25 -0
  211. package/scripts/sans-reponse.d.mts +4 -0
  212. package/scripts/sans-reponse.mjs +13 -0
  213. package/scripts/seances.mjs +918 -0
  214. package/scripts/services-du-noyau.mjs +28 -11
  215. package/scripts/session-start.sh +10 -1
  216. package/scripts/sortie.mjs +23 -4
  217. package/scripts/sources.mjs +3 -3
  218. package/scripts/sous-commandes.mjs +39 -9
  219. package/scripts/style-a-l-ecriture.mjs +229 -0
  220. package/scripts/superviseur.mjs +382 -16
  221. package/scripts/tableau.mjs +329 -130
  222. package/scripts/taches-du-graphe.mjs +328 -0
  223. package/scripts/ticket-du-circuit.mjs +206 -0
  224. package/scripts/transitions.d.mts +148 -0
  225. package/scripts/transitions.mjs +901 -0
  226. package/scripts/verrou-de-fichier.mjs +2 -2
  227. package/scripts/verrou-de-machine.mjs +322 -62
  228. package/skills/developpeur/SKILL.md +11 -3
  229. package/skills/explorateur/SKILL.md +2 -1
  230. package/skills/pitmaster/SKILL.md +62 -28
  231. package/skills/pitmaster/references/consigne-agent.md +5 -1
  232. package/skills/release/SKILL.md +3 -3
  233. package/skills/relecteur/SKILL.md +22 -8
  234. package/skills/testwriter/SKILL.md +47 -39
  235. package/scripts/demon.mjs +0 -138
  236. package/scripts/integration/file-attente.mjs +0 -61
  237. package/scripts/langages/cargo/touches.mjs +0 -93
  238. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -10,11 +10,28 @@
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
- export { ecrireLaMesure, garderLeTotal, inscrireLePlan, ouvrirAvancement } from './avancement.mjs';
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';
34
+ export { luUneFois } from './lecture-unique.mjs';
18
35
  export { CHANGEMENTS, DEPUIS_LE_VERT, garderLeVert, mesure } from './dernier-vert.mjs';
19
36
  export { lireLaListe, paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
20
37
  export { AVANCEMENT, ecrireTache } from './mesure/avancement.mjs';
@@ -26,12 +43,12 @@ export {
26
43
  ouvrirBase,
27
44
  retirerALInterruption,
28
45
  } from './mesure/base-de-passe.mjs';
46
+ export { A_REPASSER } from './codes-de-sortie.mjs';
47
+ export { ecrirePression, lirePression, SEUIL_PRESSION } from './mesure/pression.mjs';
29
48
  export {
30
- A_REPASSER,
31
- attendreLeRepos,
32
- BORNE_ATTENTE_MS,
33
- ecrirePression,
34
- lirePression,
35
- SEUIL_PRESSION,
36
- } from './mesure/pression.mjs';
37
- export { attendreDeLaPlace, AttenteDeLaMachine, avecLaMachine } 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';
@@ -28,7 +28,11 @@
28
28
  # one version, with the command that aligns the one behind. An agent's copy does not read them.
29
29
  #
30
30
  # One supervisor per project (scripts/superviseur.mjs): the session takes the lock of its
31
- # repository; a second session, while the first one lives, receives first the section « Un autre
31
+ # repository, and, when its opening takes the lock (not when it keeps it, after a compaction or a
32
+ # /clear), receives the section « L'attente des questions », the wait to launch in the background,
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 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
32
36
  # superviseur tient ce dépôt », which asks it to say so to the owner and to launch no circuit. An
33
37
  # agent's copy and a session of a role the circuit launches take nothing and receive nothing.
34
38
  #
@@ -56,6 +60,11 @@ fi
56
60
  # One supervisor per project: the lock of the repository, or the section that says who holds it.
57
61
  superviseur="$(node "$ici/superviseur.mjs" "$root" 2>/dev/null)"
58
62
  [ -z "$superviseur" ] || echo "$superviseur"
63
+ # The published version that leads the repository (grillhouse.outil), when it cannot be installed:
64
+ # the orchestration runs on the code of the repository, which the session is told
65
+ # (scripts/aiguillage.mjs).
66
+ outil="$(node "$ici/aiguillage.mjs" --echec "$root" 2>/dev/null)"
67
+ [ -z "$outil" ] || echo "$outil"
59
68
 
60
69
  missing=()
61
70
 
@@ -2,8 +2,9 @@
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 the annotated tag v<version> on HEAD, the release commit
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
+ // and the gesture that leads Grillhouse with it once published
7
8
  // npx grillhouse sortie --verifier-etiquette <v> exits 0 when the tag <v> names the version of the package
8
9
  // npx grillhouse sortie --entree-du-marche the entry of the plugin in the marketplace roomi-fields
9
10
  //
@@ -38,7 +39,7 @@ export const ENTREE_DU_MARCHE = {
38
39
  name: 'grillhouse',
39
40
  source: { source: 'npm', package: '@roomi-fields/grillhouse' },
40
41
  };
41
- const CHANGELOG = 'CHANGELOG.md';
42
+ const CHANGELOG = 'packages/grillhouse/CHANGELOG.md';
42
43
  const OUVERTE = '## [Unreleased]\n';
43
44
  const SEMVER = /^(\d+)\.(\d+)\.(\d+)$/;
44
45
 
@@ -115,6 +116,23 @@ export function etiqueter(
115
116
  return etiquette;
116
117
  }
117
118
 
119
+ /**
120
+ * What follows the tag <etiquette> once its package is published: the gesture that leads Grillhouse
121
+ * with it (`npx grillhouse outil <version>`, scripts/outil.mjs, which writes `grillhouse.outil` and
122
+ * installs the version), and the update of the frame's plugin installed for the repository, at
123
+ * its local scope, as in the other projects.
124
+ * @param {string} etiquette v<x.y.z>
125
+ * @returns {string}
126
+ */
127
+ export function suiteDeLaSortie(etiquette) {
128
+ const version = etiquette.replace(/^v/, '');
129
+ return (
130
+ `Une fois ${version} publiée, Grillhouse se mène avec elle : npx grillhouse outil ${version} ` +
131
+ '(la clé grillhouse.outil, à commiter, et la version installée), puis ' +
132
+ 'claude plugin update grillhouse@roomi-fields --scope local (le greffon de Grillhouse).\n'
133
+ );
134
+ }
135
+
118
136
  const USAGE =
119
137
  'Usage : npx grillhouse sortie <x.y.z> prépare la sortie (package.json du paquet, CHANGELOG.md)\n' +
120
138
  " npx grillhouse sortie --etiqueter pose l'étiquette v<version> sur le commit de sortie\n" +
@@ -136,7 +154,8 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
136
154
  const e = etiqueter(racine);
137
155
  process.stdout.write(
138
156
  `Étiquette ${e} posée sur HEAD, en local. La poussée, que valide le responsable : git push origin ${e} ` +
139
- '(la CI joue alors le commit, puis publie le paquet sur npm)\n'
157
+ '(la CI joue alors le commit, puis publie le paquet sur npm)\n' +
158
+ suiteDeLaSortie(e)
140
159
  );
141
160
  } else if (args.length === 1 && args[0] === '--entree-du-marche') {
142
161
  process.stdout.write(`${JSON.stringify(ENTREE_DU_MARCHE, null, 2)}\n`);
@@ -24,9 +24,9 @@ const HORS = [
24
24
  '.rtfm',
25
25
  ];
26
26
 
27
- // The directories left out in the project at <racine>: the frame's, and what its language's tools
28
- // write (every language's, for a project that declares none).
29
- function hors(racine) {
27
+ /** The directories left out in the project at <racine>: the frame's, and what its language's tools
28
+ * write (every language's, for a project that declares none). */
29
+ export function hors(racine) {
30
30
  const declares = langagesDeclares(racine);
31
31
  const ecrits =
32
32
  declares.length > 0
@@ -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 but `typer` is a subcommand
14
- // by its name (`frontieres`, `index-interfaces`), as a backend of Pants brings its goals.
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.mjs',
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
- file: 'integration/file.mjs',
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',
@@ -41,6 +47,7 @@ export const SOUS_COMMANDES = {
41
47
  'ligne-etat': 'ligne-etat/ligne-etat.mjs',
42
48
  maj: 'grillhouse-maj.mjs',
43
49
  nuit: 'nuit.sh',
50
+ outil: 'outil.mjs',
44
51
  paquet: 'paquet.mjs',
45
52
  pression: 'mesure/pression.mjs',
46
53
  registre: 'registre.mjs',
@@ -48,11 +55,13 @@ export const SOUS_COMMANDES = {
48
55
  'retirer-copie': 'retirer-copie.sh',
49
56
  'session-start': 'session-start.sh',
50
57
  sortie: 'sortie.mjs',
58
+ 'style-a-l-ecriture': 'style-a-l-ecriture.mjs',
51
59
  'sous-modules': 'sous-modules.sh',
52
60
  'structure-guard': 'structure-guard.sh',
53
61
  superviseur: 'superviseur.mjs',
54
62
  tableau: 'tableau.mjs',
55
63
  temporaire: 'mesure/base-de-passe.mjs',
64
+ temporal: '../dist/temporal/commande.js',
56
65
  tests: { langage: 'tester' },
57
66
  ticket: 'ticket.sh',
58
67
  'ticket-du-sous-agent': 'verrous/ticket-du-sous-agent.mjs',
@@ -61,8 +70,8 @@ export const SOUS_COMMANDES = {
61
70
  };
62
71
 
63
72
  // The commands of the module of the language that serve the project at <racine> and are no
64
- // subcommand by their name: the ones `tests` and `verifier` run, and the typing.
65
- const DU_NOYAU = new Set(['tester', 'verifier', 'typer']);
73
+ // subcommand by their name: the ones `tests` and `verifier` run.
74
+ const DU_NOYAU = new Set(['tester', 'verifier']);
66
75
 
67
76
  /**
68
77
  * The subcommands in the project at <racine>, sorted: the core's (SOUS_COMMANDES), and the
@@ -94,10 +103,29 @@ export function commandeDe(nom, racine = process.cwd()) {
94
103
  return n !== null && Object.hasOwn(commandes, n) ? commandes[n] : null;
95
104
  }
96
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
+
97
124
  /**
98
125
  * The environment the subcommand <nom> runs under, in the project at <racine>, from <env>:
99
- * `verifier` gets the tools of the project (`grillhouse.outils`, scripts/outils-cles.mjs), each
100
- * variable set to its path, whatever <env> holds; every other subcommand gets <env>.
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>.
101
129
  * @param {string} nom the subcommand
102
130
  * @param {string} [racine] the root of the project, the working directory by default
103
131
  * @param {Record<string, string | undefined>} [env]
@@ -105,7 +133,9 @@ export function commandeDe(nom, racine = process.cwd()) {
105
133
  * @throws {Error} the faults of the key, for `verifier`
106
134
  */
107
135
  export function environnementDe(nom, racine = process.cwd(), env = process.env) {
108
- return nom === 'verifier' ? avecLesOutils(outilsDe(racine), env) : env;
136
+ return nom === 'verifier'
137
+ ? avecLesDonnees(donneesDe(racine), avecLesOutils(outilsDe(racine), env))
138
+ : env;
109
139
  }
110
140
 
111
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
+ }