@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
@@ -1,14 +1,24 @@
1
- #!/usr/bin/env node
2
1
  // The removal of the working copies whose content is on main, run by the night once its steps
3
2
  // are played (scripts/nuit.sh) and at the end of each circuit (scripts/circuit.mjs,
4
3
  // `retirerLesCopiesDuDepot`), as `git worktree prune` and the workspace cleanup at the end of a
5
4
  // CI pipeline (Jenkins « Workspace Cleanup »): no copy outlives the entry of its content on main,
6
5
  // and no target directory its ticket (grillhouse-cyr: 34 GB of target/ under synthhub's copies).
7
6
  //
8
- // node scripts/copies-finies.mjs [<copie à garder>…] from the main tree of the repository
7
+ // Its command is ./retirer-les-copies-finies.mjs, which reads the circuits that run on the Temporal
8
+ // server; this module imports nothing of the built `dist/`, since the lock of the machine and the
9
+ // base configuration of the tests import it.
9
10
  //
10
11
  // - The night's copy (`.claude/worktrees/nuit`) is always left out: the night prepares and
11
12
  // removes its own.
13
+ // - A copy named on the command line (the night's, by scripts/nuit.sh once its steps are played)
14
+ // is left out too, and pruned: its owner has played its pass in it, so it loses what the tools
15
+ // of its languages wrote there (`ignorer`), its install (`node_modules`) kept, as its next
16
+ // preparation would (`git clean -x -e node_modules`). Its line names each output removed with
17
+ // the place it held (« target retiré (2,9 Go) »). The copy of the integration and that of the
18
+ // queue, kept that no lock holds, lose them the same way: a copy that lasts holds between its
19
+ // passes none of the outputs its next pass would remove anyway, and at most one pass's
20
+ // (grillhouse-k5y: 2.9 GB in the night's, 4.8 GB in the integration's of SyntHub). The night's
21
+ // copy named by no one is never touched: a night may play in it.
12
22
  // - First `git worktree prune`: a copy whose folder is gone leaves the list. Then each copy
13
23
  // `git worktree list` names, the main tree and the copies named on the command line (the
14
24
  // night's) left out, passes through scripts/retirer-copie.sh, without `--jetable`: a copy whose
@@ -18,12 +28,25 @@
18
28
  // progress (the copy's folder bears the ticket's id, `.claude/worktrees/<ticket>`, as the
19
29
  // circuit and the launcher name it; read by `bd list --status in_progress`), the working
20
30
  // directory of its circuit (`<copie>.travail`, which lives as long as the ticket,
21
- // scripts/circuit.mjs), or, for the integration copy and the queue copy
22
- // (`.claude/worktrees/integration`, `.claude/worktrees/file`), their lock in git's common
23
- // directory (`integration.lock`, `file-integration.lock`, scripts/integration/). Tickets in
31
+ // scripts/circuit.mjs), or, for the integration copy (`.claude/worktrees/integration`), its
32
+ // lock in git's common directory (`integration.lock`, scripts/integration/integrer.mjs). The
33
+ // queue copy (`.claude/worktrees/file`) always stays: the workflow of the queue plays in it
34
+ // without a lock, one entry at a time, and prepares it again before each replay. Tickets in
24
35
  // progress that do not read, or not within a minute, hold every copy: none is removed. They are
25
36
  // read only when a copy is left to judge: a repository with no copy but the night's calls no bd.
26
37
  // A locked copy (`git worktree lock`, as Claude Code locks the copy of a live agent) stays too.
38
+ // A copy whose circuit no longer runs (its `<copie>.travail` there, its ticket out of the
39
+ // circuits the Temporal server runs, which its caller gives, `vivants`), its ticket still open,
40
+ // stays, its code and commits untouched, and its line says so with the place it holds and that
41
+ // of each of its tools' outputs (« son circuit ne tourne plus ; target y tient 5,1 Go ; son code
42
+ // et ses commits restent »): 5.2 GB of SyntHub's SH-cgi.8.2 were kept so under the words of a
43
+ // running circuit (grillhouse-k5y). Without the circuits that run (the server unread, or the end
44
+ // of a circuit, whose act reads no server), its line says only that its circuit has its
45
+ // working directory.
46
+ // - The count of what holds the disk of a copy (`occupantsDesCopies`), which the wait for room of
47
+ // a heavy pass names (scripts/verrou-de-machine.mjs): the copies of its repository, the five
48
+ // largest first, each with its ticket (the copy's folder, but the frame's copies that last and
49
+ // Claude Code's `agent-*`), its place and that of its tools' outputs.
27
50
  // - A copy whose commits are not on main stays, its line naming the first path that has not
28
51
  // entered: retirer-copie.sh judges the local work alone, so the copy's HEAD is judged first, as
29
52
  // the removal judges local work: each path HEAD changed since its base with main holds the
@@ -56,7 +79,6 @@
56
79
  import { spawnSync } from 'node:child_process';
57
80
  import { existsSync, lstatSync, realpathSync, rmSync } from 'node:fs';
58
81
  import path from 'node:path';
59
- import { pathToFileURL } from 'node:url';
60
82
  import { PILOTE } from './fusion-du-changelog.mjs';
61
83
  import { langageDe } from './langages.mjs';
62
84
  import { balayerLesTickets } from './mesure/base-de-passe.mjs';
@@ -64,11 +86,19 @@ import { balayerLesTickets } from './mesure/base-de-passe.mjs';
64
86
  const RETIRER = path.join(import.meta.dirname, 'retirer-copie.sh');
65
87
  const PRINCIPALE = 'main';
66
88
  // The copies of the integration and of the queue, each held while its lock stands.
67
- const VERROUS = { integration: 'integration.lock', file: 'file-integration.lock' };
89
+ const VERROUS = { integration: 'integration.lock' };
90
+ // The queue copy, which the workflow of the queue holds without a lock (src/temporal/file/).
91
+ const DE_LA_FILE = 'file';
68
92
  // The install of a copy: a link to the main tree's, or its own directory.
69
93
  const INSTALLATION = 'node_modules';
94
+ // The folder of the copies of a repository, from its main tree.
95
+ const COPIES = path.join('.claude', 'worktrees');
70
96
  // The copy of the night, its own to prepare and to remove (scripts/nuit.sh).
71
- const NUIT = path.join('.claude', 'worktrees', 'nuit');
97
+ const NUIT = path.join(COPIES, 'nuit');
98
+ // The frame's copies that last, each prepared again before its pass, every untracked file removed
99
+ // (`git clean -x`, scripts/nuit.sh and scripts/integration/rejeu.mjs): the night's, the
100
+ // integration's, the queue's. Their folder bears no ticket.
101
+ const DURABLES = new Set(['nuit', DE_LA_FILE, ...Object.keys(VERROUS)]);
72
102
 
73
103
  const lancer = (dossier, cmd, args) =>
74
104
  spawnSync(cmd, args, { cwd: dossier, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
@@ -97,10 +127,17 @@ function lesCopies(racine) {
97
127
  }));
98
128
  }
99
129
 
100
- // What holds the copy <chemin> for a running circuit or a live process (its lock), or null.
101
- function tenue({ chemin, verrou: raison }, enCours, commun) {
130
+ // What holds the copy <chemin> for a running circuit or a live process (its lock), or null. A
131
+ // copy whose circuit no longer runs (its ticket out of <vivants>, the tickets whose circuit the
132
+ // server runs, null when unread) stays held beside its `.travail`, and its line names the place
133
+ // its tools' outputs (<ignorer>) hold there.
134
+ function tenue({ chemin, verrou: raison }, enCours, commun, ignorer, vivants) {
102
135
  const nom = path.basename(chemin);
103
136
  if (existsSync(`${chemin}.travail`)) {
137
+ if (vivants && !vivants.has(nom)) {
138
+ const sorties = placeDesSorties(chemin, ignorer).map(s => ` ; ${s}`);
139
+ return `son circuit ne tourne plus${sorties.join('')} ; son code et ses commits restent`;
140
+ }
104
141
  return `son circuit a son dossier ${nom}.travail`;
105
142
  }
106
143
  if (enCours.has(nom)) {
@@ -110,8 +147,11 @@ function tenue({ chemin, verrou: raison }, enCours, commun) {
110
147
  return `elle est verrouillée${raison ? ` (${raison})` : ''}`;
111
148
  }
112
149
  const verrou = VERROUS[nom];
113
- if (verrou && path.dirname(chemin).endsWith(path.join('.claude', 'worktrees'))) {
114
- if (existsSync(path.join(commun, verrou))) {
150
+ if (path.dirname(chemin).endsWith(path.join('.claude', 'worktrees'))) {
151
+ if (nom === DE_LA_FILE) {
152
+ return 'la file y rejoue ses entrées';
153
+ }
154
+ if (verrou && existsSync(path.join(commun, verrou))) {
115
155
  return `le verrou ${verrou} est posé`;
116
156
  }
117
157
  }
@@ -174,9 +214,15 @@ function pasEntre(racine, b) {
174
214
  return null;
175
215
  }
176
216
 
177
- // The place <chemin> holds on the disk, as `du` counts it (a link not followed): « 2,7 Go ».
178
- function place(chemin) {
179
- const ko = Number.parseInt(lancer(chemin, 'du', ['-sk', chemin]).stdout, 10);
217
+ // The kilobytes <chemin> holds on the disk, as `du -sk` counts them (a link not followed); NaN
218
+ // when it does not read.
219
+ const kilooctets = chemin => Number.parseInt(lancer(chemin, 'du', ['-sk', chemin]).stdout, 10);
220
+
221
+ // The place <chemin> holds on the disk, as `du` counts it: « 2,7 Go ».
222
+ const place = chemin => texteDePlace(kilooctets(chemin));
223
+
224
+ // The place of <ko> kilobytes in words: « 2,7 Go », « 12 Ko ».
225
+ function texteDePlace(ko) {
180
226
  if (!Number.isFinite(ko)) {
181
227
  return '? Go';
182
228
  }
@@ -197,6 +243,58 @@ function sortiesDesOutils(chemin, ignorer) {
197
243
  .filter(p => p && noms.has(path.basename(p)));
198
244
  }
199
245
 
246
+ // The tools' outputs of the copy <chemin> but its install (<ignorer>), each with its place:
247
+ // « target y tient 4,8 Go ».
248
+ const placeDesSorties = (chemin, ignorer) =>
249
+ sortiesDesOutils(chemin, ignorer)
250
+ .filter(p => path.basename(p) !== INSTALLATION)
251
+ .map(p => `${p} y tient ${place(path.join(chemin, p))}`);
252
+
253
+ // The ticket the copy at <chemin> bears by its folder (`.claude/worktrees/<ticket>`, as the
254
+ // circuit and the launcher name it); null for the frame's copies that last and for Claude Code's
255
+ // (`agent-*`).
256
+ function ticketDeLaCopie(chemin) {
257
+ const nom = path.basename(chemin);
258
+ return path.dirname(chemin).endsWith(COPIES) && !DURABLES.has(nom) && !nom.startsWith('agent-')
259
+ ? nom
260
+ : null;
261
+ }
262
+
263
+ /**
264
+ * What holds the disk of the repository whose copy or main tree is <racine>: its copies, the
265
+ * main tree left out, the five largest first, each with its ticket, its place and the place of
266
+ * its tools' outputs (<ignorer>, by default the directories the module of the project's language
267
+ * names): « .claude/worktrees/SH-ae6.2.7 (le ticket SH-ae6.2.7, 5,0 Go, dont target 4,8 Go) ».
268
+ * What the wait for room on the disk of a copy names (scripts/verrou-de-machine.mjs).
269
+ * @param {string} racine
270
+ * @param {string[]} [ignorer]
271
+ * @returns {string}
272
+ */
273
+ export function occupantsDesCopies(racine, ignorer) {
274
+ const [principale, ...copies] = lesCopies(racine);
275
+ if (!principale) {
276
+ return `aucune copie de dépôt sous ${racine}`;
277
+ }
278
+ if (!copies.length) {
279
+ return `aucune copie de ${principale.chemin} hors son arbre principal`;
280
+ }
281
+ const noms = ignorer ?? ignoresDuLangage(principale.chemin);
282
+ const ici = reel(principale.chemin);
283
+ return copies
284
+ .map(({ chemin }) => ({ chemin, ko: kilooctets(chemin) }))
285
+ .sort((a, b) => (b.ko || 0) - (a.ko || 0))
286
+ .slice(0, 5)
287
+ .map(({ chemin, ko }) => {
288
+ const vu = path.relative(ici, reel(chemin));
289
+ const ticket = ticketDeLaCopie(chemin);
290
+ const dont = sortiesDesOutils(chemin, noms)
291
+ .filter(p => path.basename(p) !== INSTALLATION)
292
+ .map(p => `${p} ${place(path.join(chemin, p))}`);
293
+ return `${vu.startsWith('..') ? chemin : vu} (${ticket ? `le ticket ${ticket}, ` : ''}${texteDePlace(ko)}${dont.length ? `, dont ${dont.join(', ')}` : ''})`;
294
+ })
295
+ .join(', ');
296
+ }
297
+
200
298
  // Whether the link `node_modules` is the only local work of the copy <chemin>, as
201
299
  // scripts/retirer-copie.sh reads it (`git status`, submodules included).
202
300
  function seulLeLien(chemin) {
@@ -204,15 +302,29 @@ function seulLeLien(chemin) {
204
302
  return r.status === 0 && r.stdout === `?? ${INSTALLATION}\0`;
205
303
  }
206
304
 
207
- // Removes from the copy <chemin> what the tools of the languages wrote there; their paths.
208
- function retirerLesSorties(chemin, ignorer) {
209
- const retirees = sortiesDesOutils(chemin, ignorer);
305
+ // Removes from the copy <chemin> what the tools of the languages wrote there, its install
306
+ // (`node_modules`) but with <installation> false; their paths.
307
+ function retirerLesSorties(chemin, ignorer, { installation = true } = {}) {
308
+ const retirees = sortiesDesOutils(chemin, ignorer).filter(
309
+ p => installation || path.basename(p) !== INSTALLATION
310
+ );
210
311
  for (const p of retirees) {
211
312
  rmSync(path.join(chemin, p), { recursive: true, force: true });
212
313
  }
213
314
  return retirees;
214
315
  }
215
316
 
317
+ // Removes from the frame's copy that lasts at <chemin> its tools' outputs, its install kept, as
318
+ // its next preparation would (`git clean -x -e node_modules`): « target retiré (4,8 Go) », each.
319
+ function elaguer(chemin, ignorer) {
320
+ const places = new Map(
321
+ sortiesDesOutils(chemin, ignorer).map(p => [p, place(path.join(chemin, p))])
322
+ );
323
+ return retirerLesSorties(chemin, ignorer, { installation: false }).map(
324
+ p => `${p} retiré (${places.get(p)})`
325
+ );
326
+ }
327
+
216
328
  /**
217
329
  * Removes the copies of the repository at <racine> whose content is on main; returns one line per
218
330
  * copy removed or kept, a kept copy's with the place it holds. <garder> names the copies left out
@@ -221,16 +333,43 @@ function retirerLesSorties(chemin, ignorer) {
221
333
  * asks nothing; <lireFermes> reads the ids of the tickets closed, called once, when a copy is kept
222
334
  * that no circuit holds. A copy kept whose ticket is closed loses what the tools of its languages
223
335
  * wrote there (<ignorer>, the directories the module of the language names, and `node_modules`).
336
+ * <elaguer> names copies left out too, whose owner has played its pass (the night's own): each
337
+ * loses its tools' outputs, its install kept; so does a copy of the integration or of the queue
338
+ * kept that no lock holds. <vivants> names the tickets whose circuit the Temporal server runs
339
+ * (null when its caller does not read them): a copy beside its `.travail` whose ticket is out of
340
+ * them stays, its line saying its circuit no longer runs, with the place of its tools' outputs.
341
+ * @param {string} racine
342
+ * @param {{ garder?: string[], elaguer?: string[], lireEnCours: () => Set<string> | null,
343
+ * lireFermes: () => Set<string> | null, ignorer: string[], vivants?: Set<string> | null }} o
344
+ * @returns {string[]}
224
345
  */
225
- export function retirerLesCopiesFinies(racine, { garder = [], lireEnCours, lireFermes, ignorer }) {
346
+ export function retirerLesCopiesFinies(
347
+ racine,
348
+ { garder = [], elaguer: aElaguer = [], lireEnCours, lireFermes, ignorer, vivants = null }
349
+ ) {
226
350
  const [principale, ...listees] = lesCopies(racine);
227
- const ecartees = new Set([principale?.chemin, ...garder].filter(Boolean).map(reel));
351
+ const ici = reel(racine);
352
+ const vu = c => (path.relative(ici, reel(c)).startsWith('..') ? c : path.relative(ici, reel(c)));
353
+ const elaguees = new Set(aElaguer.map(reel));
354
+ const lignes = [];
355
+ for (const { chemin } of listees) {
356
+ if (elaguees.has(reel(chemin))) {
357
+ const retirees = elaguer(chemin, ignorer);
358
+ if (retirees.length) {
359
+ lignes.push(`✓ copie élaguée : ${vu(chemin)} : ${retirees.join(', ')}.`);
360
+ }
361
+ }
362
+ }
363
+ const ecartees = new Set([principale?.chemin, ...garder, ...aElaguer].filter(Boolean).map(reel));
228
364
  if (listees.every(c => ecartees.has(reel(c.chemin)))) {
229
- return [];
365
+ return lignes;
230
366
  }
231
367
  const enCours = lireEnCours();
232
368
  if (enCours === null) {
233
- return ['✗ les tickets en cours ne se lisent pas (bd list) : aucune copie n’est retirée.'];
369
+ return [
370
+ ...lignes,
371
+ '✗ les tickets en cours ne se lisent pas (bd list) : aucune copie n’est retirée.',
372
+ ];
234
373
  }
235
374
  git(racine, 'worktree', 'prune');
236
375
  const commun = git(
@@ -240,15 +379,24 @@ export function retirerLesCopiesFinies(racine, { garder = [], lireEnCours, lireF
240
379
  '--git-common-dir'
241
380
  ).stdout.trim();
242
381
  const copies = lesCopies(racine).slice(1);
243
- const ici = reel(racine);
244
- const vu = c => (path.relative(ici, reel(c)).startsWith('..') ? c : path.relative(ici, reel(c)));
245
- const lignes = [];
246
382
  let fermes;
247
- // The line of the copy <chemin> kept for <raison>: what it lost when its ticket is closed, then
248
- // the place it holds.
383
+ // The line of the copy <chemin> kept for <raison>: what it lost when its ticket is closed, or,
384
+ // for the copy of the integration or of the queue, its tools' outputs, which its next
385
+ // preparation removes; then the place it holds.
249
386
  const gardee = (chemin, raison) => {
387
+ const nom = path.basename(chemin);
388
+ if (
389
+ (Object.hasOwn(VERROUS, nom) || nom === DE_LA_FILE) &&
390
+ path.dirname(chemin).endsWith(COPIES)
391
+ ) {
392
+ const retirees = elaguer(chemin, ignorer);
393
+ const perte = retirees.length
394
+ ? ` ; sa prochaine préparation l'efface : ${retirees.join(', ')}`
395
+ : '';
396
+ return `· copie gardée : ${vu(chemin)} (${place(chemin)}) : ${raison}${perte}`;
397
+ }
250
398
  fermes ??= lireFermes() ?? new Set();
251
- const perdues = fermes.has(path.basename(chemin)) ? retirerLesSorties(chemin, ignorer) : [];
399
+ const perdues = fermes.has(nom) ? retirerLesSorties(chemin, ignorer) : [];
252
400
  const perte = perdues.length ? ` ; son ticket est fermé : ${perdues.join(', ')} retirés` : '';
253
401
  return `· copie gardée : ${vu(chemin)} (${place(chemin)}) : ${raison}${perte}`;
254
402
  };
@@ -257,7 +405,7 @@ export function retirerLesCopiesFinies(racine, { garder = [], lireEnCours, lireF
257
405
  if (ecartees.has(reel(chemin))) {
258
406
  continue;
259
407
  }
260
- const raison = tenue(copie, enCours, commun);
408
+ const raison = tenue(copie, enCours, commun, ignorer, vivants);
261
409
  if (raison) {
262
410
  lignes.push(`· copie gardée : ${vu(chemin)} (${place(chemin)}) : ${raison}.`);
263
411
  continue;
@@ -330,16 +478,21 @@ function ignoresDuLangage(racine) {
330
478
 
331
479
  /**
332
480
  * The removal of the copies of the repository at <racine> (`retirerLesCopiesFinies`), the copy of
333
- * the night and the copies <garder> left out, the tickets read by bd, then of the temporary
334
- * directories of its closed tickets (`balayerLesTickets`): what the night and the end of each
335
- * circuit (scripts/circuit.mjs) run. Its lines.
481
+ * the night left out, the copies <finies> left out and pruned, their owner having played its pass
482
+ * in them (the night's own, which scripts/nuit.sh names), the tickets read by bd, the tickets
483
+ * whose circuit runs <vivants> (null when unread), then of the temporary directories of its closed
484
+ * tickets (`balayerLesTickets`): what the night and the end of each circuit (scripts/circuit.mjs)
485
+ * run. Its lines.
336
486
  * @param {string} racine the main tree
337
- * @param {string[]} [garder]
487
+ * @param {string[]} [finies]
488
+ * @param {Set<string> | null} [vivants]
338
489
  * @returns {string[]}
339
490
  */
340
- export function retirerLesCopiesDuDepot(racine, garder = []) {
491
+ export function retirerLesCopiesDuDepot(racine, finies = [], vivants = null) {
341
492
  const lignes = retirerLesCopiesFinies(racine, {
342
- garder: [path.join(racine, NUIT), ...garder],
493
+ vivants,
494
+ garder: [path.join(racine, NUIT)],
495
+ elaguer: finies,
343
496
  lireEnCours: () => tickets(racine, 'in_progress'),
344
497
  lireFermes: () => tickets(racine, 'closed'),
345
498
  ignorer: ignoresDuLangage(racine),
@@ -347,10 +500,3 @@ export function retirerLesCopiesDuDepot(racine, garder = []) {
347
500
  const retires = balayerLesTickets(() => tickets(racine, 'closed'));
348
501
  return [...lignes, ...retires.map(t => `✓ dossier temporaire du ticket ${t} retiré.`)];
349
502
  }
350
-
351
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
352
- const lignes = retirerLesCopiesDuDepot(process.cwd(), process.argv.slice(2));
353
- if (lignes.length) {
354
- process.stdout.write(`${lignes.join('\n')}\n`);
355
- }
356
- }
@@ -0,0 +1,53 @@
1
+ // The types of ./depart-du-ticket.mjs, for the frame's TypeScript (src/temporal/circuit/commande.ts).
2
+
3
+ /** A component of the repository, as `composantsDe` lists it. */
4
+ export interface Composant {
5
+ dossier: string;
6
+ pkg: { name?: string };
7
+ }
8
+
9
+ /** A ticket as Beads shows it. */
10
+ export interface TicketDeBeads {
11
+ id?: string;
12
+ title?: string;
13
+ description?: string;
14
+ issue_type?: string;
15
+ [champ: string]: unknown;
16
+ }
17
+
18
+ /** A ticket a circuit cannot start on, by its reason. */
19
+ export class DepartRefuse extends Error {}
20
+
21
+ /** The directory of the component <nom> of a title among <liste>; or a refusal. */
22
+ export function resoudreComposant(liste: Composant[], base: string, nom: string): string;
23
+
24
+ /** The ticket <id> as `bd show --json` gives it in <sortie>, refused without its architecture. */
25
+ export function ticketAuDepart(
26
+ id: string,
27
+ sortie: string,
28
+ options?: { arreter?: boolean }
29
+ ): TicketDeBeads;
30
+
31
+ /** The subject and the plan of the title <titre> of the ticket <id>; or a refusal. */
32
+ export function leTitre(
33
+ id: string,
34
+ titre: string | undefined,
35
+ resoudre: (nom: string) => string
36
+ ): { sujet: string; plan: string[] };
37
+
38
+ /** The ticket <id> of the repository at <racine>, read before any work; or a refusal. */
39
+ export function ticketAuLancement(
40
+ racine: string,
41
+ id: string,
42
+ options?: {
43
+ arreter?: boolean;
44
+ bd?: ((...a: string[]) => { status: number | null; stdout: string; stderr: string }) | null;
45
+ }
46
+ ): {
47
+ ticket: TicketDeBeads;
48
+ base: string;
49
+ liste: Composant[];
50
+ resoudre: (nom: string) => string;
51
+ sujet: string;
52
+ plan: string[];
53
+ };
@@ -0,0 +1,124 @@
1
+ // The ticket a circuit starts on, read before any work, as a CI validates its configuration before
2
+ // it runs its jobs: `npx grillhouse circuit` refuses at the door what the circuit could not run
3
+ // (src/temporal/circuit/commande.ts), and the opening of each act of the circuit reads its plan
4
+ // the same way (scripts/circuit.mjs `contexte`).
5
+ //
6
+ // - The ticket is read by `bd show <id> --json` in the main tree; one Beads cannot show is refused.
7
+ // - Its description holds a « ## Architecture » section, by the rule of the developer's lock
8
+ // (`sansArchitecture` of ./verrous/verrou.mjs): the code waits for the architecture. The
9
+ // supervisor's stop (`--arreter`) reads neither it nor the title: it does not depend on the
10
+ // ticket's content, as GitLab cancels a pipeline whatever its configuration; its plan is empty.
11
+ // - Its title names its plan after its last « — », separated by commas: each one a path
12
+ // (`packages/<nom>`, or `.`), or the name of a package, which becomes its directory, read in the
13
+ // ticket's copy when it exists, else in the main tree (`composantsDe`). A title without it, and
14
+ // a component that names neither, are refused by their name. An act after the opening is given
15
+ // the plan its workflow holds (<plan>) and reads only the subject of the title: the integration
16
+ // removes the ticket's copy while the circuit still runs, and a component the lot creates is in
17
+ // neither tree then.
18
+ // Each refusal is a `DepartRefuse`, its reason its message.
19
+ import { spawnSync } from 'node:child_process';
20
+ import { existsSync } from 'node:fs';
21
+ import path from 'node:path';
22
+ import { composantsDe } from './ticket-du-circuit.mjs';
23
+ import { sansArchitecture } from './verrous/verrou.mjs';
24
+
25
+ /** A ticket a circuit cannot start on, by its reason. */
26
+ export class DepartRefuse extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = 'DepartRefuse';
30
+ }
31
+ }
32
+
33
+ /**
34
+ * The directory of the component <nom> of a title among <liste> (`composantsDe` of the repository
35
+ * at <base>): `.` itself; a component by its path or its name; else a path of the repository; or a
36
+ * refusal.
37
+ */
38
+ export function resoudreComposant(liste, base, nom) {
39
+ const brut = path.normalize(nom);
40
+ const norme = brut.endsWith('/') ? brut.slice(0, -1) : brut;
41
+ if (norme === '.') {
42
+ return '.';
43
+ }
44
+ if (liste.some(p => p.dossier === norme)) {
45
+ return norme;
46
+ }
47
+ const parNom = liste.find(p => p.pkg.name === nom);
48
+ if (parNom) {
49
+ return parNom.dossier;
50
+ }
51
+ if (!norme.startsWith('..') && existsSync(path.join(base, norme))) {
52
+ return norme;
53
+ }
54
+ throw new DepartRefuse(
55
+ `le composant « ${nom} » du titre ne nomme ni un paquet ni un chemin du dépôt.`
56
+ );
57
+ }
58
+
59
+ /**
60
+ * The ticket <id> as `bd show --json` gives it in <sortie>, refused when its description holds no
61
+ * « ## Architecture » section, unless the call is the supervisor's stop (<arreter>).
62
+ */
63
+ export function ticketAuDepart(id, sortie, { arreter = false } = {}) {
64
+ const t = JSON.parse(sortie)[0];
65
+ const refus = arreter ? null : sansArchitecture(id, t?.description);
66
+ if (refus) {
67
+ throw new DepartRefuse(refus);
68
+ }
69
+ return t;
70
+ }
71
+
72
+ // The subject of the title cut at its « — » into <parts>: what stands between the number and the
73
+ // components, or the first part of a title of two.
74
+ const sujetDe = parts => (parts.length > 2 ? parts.slice(1, -1).join(' — ') : parts[0]);
75
+
76
+ /**
77
+ * The subject and the plan of the title <titre> of the ticket <id>, « numéro — sujet —
78
+ * composants », each component resolved by <resoudre>; or a refusal.
79
+ */
80
+ export function leTitre(id, titre, resoudre) {
81
+ const parts = String(titre ?? '').split(' — ');
82
+ if (parts.length < 2) {
83
+ throw new DepartRefuse(`le titre de ${id} ne nomme pas ses composants.`);
84
+ }
85
+ return {
86
+ sujet: sujetDe(parts),
87
+ plan: parts
88
+ .at(-1)
89
+ .split(',')
90
+ .map(c => c.trim())
91
+ .filter(Boolean)
92
+ .map(resoudre),
93
+ };
94
+ }
95
+
96
+ /**
97
+ * The ticket <id> of the repository whose main tree is <racine>, read before any work: the ticket
98
+ * as Beads shows it, the tree its components are read in (`base`, its copy when it exists), the
99
+ * components of that tree, the resolver of a component, the subject and the plan of its title (the
100
+ * title whole and no plan for the supervisor's stop, <arreter>; the plan <plan> an act after the
101
+ * opening is given, its components not resolved again); or a refusal. <bd> runs bd in the main
102
+ * tree, `bd` by default.
103
+ */
104
+ export function ticketAuLancement(racine, id, { arreter = false, bd = null, plan = null } = {}) {
105
+ const show = (
106
+ bd ??
107
+ ((...a) => spawnSync('bd', a, { cwd: racine, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 }))
108
+ )('show', id, '--json');
109
+ if (show.status !== 0) {
110
+ throw new DepartRefuse(`ticket ${id} illisible : ${show.stderr}`);
111
+ }
112
+ const ticket = ticketAuDepart(id, show.stdout, { arreter });
113
+ const copie = path.join(racine, '.claude', 'worktrees', id);
114
+ const base = existsSync(copie) ? copie : racine;
115
+ const liste = composantsDe(base);
116
+ const resoudre = nom => resoudreComposant(liste, base, nom);
117
+ // The supervisor's stop reads neither the ticket's « ## Architecture » section nor its title.
118
+ const titre = arreter
119
+ ? { sujet: String(ticket?.title ?? id), plan: [] }
120
+ : plan
121
+ ? { sujet: sujetDe(String(ticket?.title ?? '').split(' — ')), plan }
122
+ : leTitre(id, ticket?.title, resoudre);
123
+ return { ticket, base, liste, resoudre, ...titre };
124
+ }
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ // The guard of the internal dependencies of the packages of a language other than TypeScript: the
3
+ // package.json of a crate or of a project of Python names the same internal packages as its
4
+ // manifest, because Turborepo orders the tasks by the graph of the package.json
5
+ // (node_modules/turbo/docs/guides/multi-language.mdx:191) while cargo and uv build by the graph of
6
+ // the manifest, as Turborepo's own example of Rust keeps the two by hand.
7
+ //
8
+ // npx grillhouse dependances-internes (one of the frame's guards, scripts/gardes-du-cadre.mjs)
9
+ //
10
+ // - The packages are those the architecture declares of a language without package.json of its own
11
+ // (`paquetsSansPackageJson`, ./paquet-npm.mjs) that hold a package.json; one without it is the
12
+ // migration's (./migrations/0.31.0-paquets-dans-le-graphe.mjs).
13
+ // - The internal dependencies of the manifest: of a Cargo.toml, each dependency with a `path`
14
+ // (`[dependencies]`, `[dev-dependencies]`, `[build-dependencies]`, and the same under
15
+ // `[target.*]`; a `workspace = true` one takes the `path` of `[workspace.dependencies]` of the
16
+ // root), named by the `name` of the manifest at that path; of a pyproject.toml, each entry of
17
+ // `[tool.uv.sources]` with a `path` (named by the manifest there) or `workspace = true`.
18
+ // - The internal dependencies of the package.json: the names of its `dependencies`,
19
+ // `devDependencies`, `optionalDependencies` and `peerDependencies` that are the name of a package
20
+ // of the project (the ones above and the workspaces'). An external dependency, on either side,
21
+ // is no gap.
22
+ // - Refused, one finding per package, named with the dependencies in gap in each sense: the
23
+ // package.json that lacks a dependency its manifest links, or names an internal package its
24
+ // manifest does not link. Written in SARIF under the guard's name, and on the error stream after
25
+ // ⛔; the exit code is 1 when there is one, 0 otherwise.
26
+ import { existsSync, readFileSync } from 'node:fs';
27
+ import path from 'node:path';
28
+ import { fileURLToPath, pathToFileURL } from 'node:url';
29
+ import { langage } from './langages.mjs';
30
+ import { nomDuManifeste, paquetsSansPackageJson, sansPackageJson } from './paquet-npm.mjs';
31
+ import { paquets } from './paquets.mjs';
32
+ import { ecrireSarif } from './resultats.mjs';
33
+
34
+ /** This script. */
35
+ export const SCRIPT = fileURLToPath(import.meta.url);
36
+ /** The name its findings carry. */
37
+ export const GARDE = 'dependances-internes';
38
+
39
+ // The fields of a package.json that name the packages it depends on.
40
+ const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
41
+
42
+ const lire = f => (existsSync(f) ? readFileSync(f, 'utf8') : null);
43
+
44
+ // The name of the package whose manifest lies in <dossier>, the one of <langageNom> first (a crate
45
+ // may link a project of Python), null for none.
46
+ function nomA(langageNom, dossier) {
47
+ for (const l of [langageNom, ...sansPackageJson()]) {
48
+ const texte = lire(path.join(dossier, langage(l).manifeste));
49
+ const nom = texte === null ? null : nomDuManifeste(l, texte);
50
+ if (nom !== null) return nom;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ /**
56
+ * The findings of the guard on the project at <racine>: `{ fichier, message }`, none when each
57
+ * package.json and its manifest agree.
58
+ * @param {string} racine the root of the project
59
+ */
60
+ export function constats(racine) {
61
+ const sans = paquetsSansPackageJson(racine);
62
+ const internes = new Set([...sans.map(p => p.nom), ...paquets(racine).map(p => p.pkg.name)]);
63
+ const out = [];
64
+ for (const p of sans) {
65
+ const f = `${p.chemin}/package.json`;
66
+ const texte = lire(path.join(racine, f));
67
+ if (texte === null) continue;
68
+ let pkg;
69
+ try {
70
+ pkg = JSON.parse(texte);
71
+ } catch {
72
+ continue;
73
+ }
74
+ const manifeste = langage(p.langage).manifeste;
75
+ const liens = langage(p.langage).liensDuManifeste(racine, p.chemin, d => nomA(p.langage, d));
76
+ const duManifeste = new Set(liens.noms);
77
+ duManifeste.delete(p.nom);
78
+ const duPackage = new Set(
79
+ CHAMPS.flatMap(c => Object.keys(pkg[c] ?? {})).filter(n => internes.has(n) && n !== p.nom)
80
+ );
81
+ const manquantes = [...duManifeste].filter(n => !duPackage.has(n)).sort();
82
+ const enTrop = [...duPackage].filter(n => !duManifeste.has(n)).sort();
83
+ if (!manquantes.length && !enTrop.length) continue;
84
+ const dits = [
85
+ ...(manquantes.length
86
+ ? [
87
+ `${manifeste} lie ${manquantes.join(', ')} (${liens.table}), que le package.json ne nomme pas`,
88
+ ]
89
+ : []),
90
+ ...(enTrop.length
91
+ ? [`le package.json nomme ${enTrop.join(', ')}, que ${manifeste} ne lie pas`]
92
+ : []),
93
+ ];
94
+ out.push({
95
+ fichier: f,
96
+ message: `${f} : le paquet ${p.nom} diffère de son manifeste dans ses dépendances internes : ${dits.join(' ; ')} ; le graphe des tâches suit le package.json, ${liens.outil} par ${manifeste} : les deux nomment les mêmes paquets.`,
97
+ });
98
+ }
99
+ return out;
100
+ }
101
+
102
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
103
+ const racine = process.cwd();
104
+ let refus;
105
+ try {
106
+ refus = constats(racine);
107
+ } catch (e) {
108
+ refus = [{ message: e.message.replace(/^⛔ /, '') }];
109
+ }
110
+ for (const r of refus) {
111
+ process.stderr.write(`⛔ ${r.message}\n`);
112
+ }
113
+ ecrireSarif({ garde: GARDE, racine, constats: refus });
114
+ process.exitCode = refus.length ? 1 : 0;
115
+ }