@roomi-fields/grillhouse 0.54.0 → 0.55.1

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 (237) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +75 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +4 -2
  4. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -42
  5. package/cadre/templates/projet/CONTRIBUTING.md +0 -5
  6. package/cadre/templates/projet/README.md +0 -126
  7. package/cadre/templates/projet/_npmignore +1 -6
  8. package/cadre/templates/projet/package.json +5 -32
  9. package/cadre/templates/projet/tsconfig.json +4 -4
  10. package/cadre/templates/projet/vitest.config.cjs +3 -2
  11. package/charte/tests.md +14 -0
  12. package/dist/machine/part-par-sorte.d.ts +9 -9
  13. package/dist/machine/part-par-sorte.js +20 -24
  14. package/dist/machine/part-par-sorte.js.map +1 -1
  15. package/dist/machine/table-des-consommations.d.ts +65 -0
  16. package/dist/machine/table-des-consommations.js +94 -0
  17. package/dist/machine/table-des-consommations.js.map +1 -0
  18. package/dist/temporal/circuit/activites.d.ts +2 -0
  19. package/dist/temporal/circuit/activites.js +87 -3
  20. package/dist/temporal/circuit/activites.js.map +1 -1
  21. package/dist/temporal/circuit/client.js +9 -4
  22. package/dist/temporal/circuit/client.js.map +1 -1
  23. package/dist/temporal/circuit/contrat.d.ts +32 -4
  24. package/dist/temporal/circuit/deroule.js +54 -4
  25. package/dist/temporal/circuit/deroule.js.map +1 -1
  26. package/dist/temporal/circuit/versions.d.ts +12 -0
  27. package/dist/temporal/circuit/versions.js +22 -0
  28. package/dist/temporal/circuit/versions.js.map +1 -0
  29. package/dist/temporal/consommation/activites.d.ts +2 -0
  30. package/dist/temporal/consommation/activites.js +9 -0
  31. package/dist/temporal/consommation/activites.js.map +1 -0
  32. package/dist/temporal/consommation/actualisation.d.ts +2 -0
  33. package/dist/temporal/consommation/actualisation.js +71 -0
  34. package/dist/temporal/consommation/actualisation.js.map +1 -0
  35. package/dist/temporal/consommation/client.d.ts +12 -0
  36. package/dist/temporal/consommation/client.js +28 -0
  37. package/dist/temporal/consommation/client.js.map +1 -0
  38. package/dist/temporal/consommation/commande.d.ts +5 -0
  39. package/dist/temporal/consommation/commande.js +32 -0
  40. package/dist/temporal/consommation/commande.js.map +1 -0
  41. package/dist/temporal/consommation/contrat.d.ts +15 -0
  42. package/dist/temporal/consommation/contrat.js +13 -0
  43. package/dist/temporal/consommation/contrat.js.map +1 -0
  44. package/dist/temporal/consommation/deroule.d.ts +2 -0
  45. package/dist/temporal/consommation/deroule.js +14 -0
  46. package/dist/temporal/consommation/deroule.js.map +1 -0
  47. package/dist/temporal/deroules.d.ts +2 -1
  48. package/dist/temporal/deroules.js +3 -2
  49. package/dist/temporal/deroules.js.map +1 -1
  50. package/dist/temporal/file/contrat.d.ts +2 -0
  51. package/dist/temporal/file/deroule.js +14 -4
  52. package/dist/temporal/file/deroule.js.map +1 -1
  53. package/dist/temporal/installation.d.ts +6 -0
  54. package/dist/temporal/installation.js +15 -0
  55. package/dist/temporal/installation.js.map +1 -1
  56. package/dist/temporal/nuits/activites.d.ts +2 -1
  57. package/dist/temporal/nuits/activites.js +127 -3
  58. package/dist/temporal/nuits/activites.js.map +1 -1
  59. package/dist/temporal/nuits/client.d.ts +19 -5
  60. package/dist/temporal/nuits/client.js +33 -23
  61. package/dist/temporal/nuits/client.js.map +1 -1
  62. package/dist/temporal/nuits/commande.js +16 -11
  63. package/dist/temporal/nuits/commande.js.map +1 -1
  64. package/dist/temporal/nuits/contrat.d.ts +29 -0
  65. package/dist/temporal/nuits/contrat.js +10 -0
  66. package/dist/temporal/nuits/contrat.js.map +1 -1
  67. package/dist/temporal/nuits/deroule.d.ts +5 -0
  68. package/dist/temporal/nuits/deroule.js +18 -1
  69. package/dist/temporal/nuits/deroule.js.map +1 -1
  70. package/dist/temporal/nuits/pc2.d.ts +72 -0
  71. package/dist/temporal/nuits/pc2.js +206 -0
  72. package/dist/temporal/nuits/pc2.js.map +1 -0
  73. package/dist/temporal/places/activites.d.ts +23 -1
  74. package/dist/temporal/places/activites.js +38 -2
  75. package/dist/temporal/places/activites.js.map +1 -1
  76. package/dist/temporal/places/client.d.ts +16 -0
  77. package/dist/temporal/places/client.js +25 -1
  78. package/dist/temporal/places/client.js.map +1 -1
  79. package/dist/temporal/places/contrat.d.ts +79 -14
  80. package/dist/temporal/places/contrat.js +7 -0
  81. package/dist/temporal/places/contrat.js.map +1 -1
  82. package/dist/temporal/places/deroule.js +159 -23
  83. package/dist/temporal/places/deroule.js.map +1 -1
  84. package/dist/temporal/places/reservation.d.ts +54 -0
  85. package/dist/temporal/places/reservation.js +69 -0
  86. package/dist/temporal/places/reservation.js.map +1 -0
  87. package/dist/temporal/planification.d.ts +6 -0
  88. package/dist/temporal/planification.js +26 -0
  89. package/dist/temporal/planification.js.map +1 -0
  90. package/dist/temporal/tickets/activites.d.ts +0 -2
  91. package/dist/temporal/tickets/activites.js +2 -52
  92. package/dist/temporal/tickets/activites.js.map +1 -1
  93. package/dist/temporal/tickets/contrat.d.ts +7 -26
  94. package/dist/temporal/tickets/deroule.js +35 -23
  95. package/dist/temporal/tickets/deroule.js.map +1 -1
  96. package/dist/temporal/travailleur.js +2 -0
  97. package/dist/temporal/travailleur.js.map +1 -1
  98. package/docs/ARCHITECTURE.md +2 -2
  99. package/docs/CADRE.md +1 -1
  100. package/docs/INTERFACE.md +16 -11
  101. package/docs/architecture/circuit.md +62 -58
  102. package/docs/architecture/entree.md +87 -63
  103. package/docs/architecture/greffon.md +32 -27
  104. package/docs/architecture/installation.md +43 -32
  105. package/docs/architecture/machine.md +48 -40
  106. package/docs/architecture/tests.md +37 -33
  107. package/docs/lexique.md +4 -3
  108. package/package.json +1 -1
  109. package/scripts/activites.mjs +351 -180
  110. package/scripts/aiguillage.mjs +1 -0
  111. package/scripts/attente-de-la-machine.mjs +3 -22
  112. package/scripts/avancement.mjs +21 -30
  113. package/scripts/bilan.mjs +22 -2
  114. package/scripts/branche-de-nuit.mjs +1 -1
  115. package/scripts/circuit.mjs +75 -39
  116. package/scripts/codes-de-sortie.mjs +0 -6
  117. package/scripts/consommation-des-passes.mjs +67 -31
  118. package/scripts/consommation.mjs +152 -24
  119. package/scripts/copies-finies.mjs +15 -35
  120. package/scripts/dernier-vert.mjs +4 -5
  121. package/scripts/dette.mjs +5 -3
  122. package/scripts/droits.mjs +2 -2
  123. package/scripts/echantillonneur-de-la-passe.mjs +7 -31
  124. package/scripts/engendres.mjs +5 -61
  125. package/scripts/enveloppe/enveloppe.mjs +30 -34
  126. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -0
  127. package/scripts/etapes.mjs +21 -7
  128. package/scripts/etat-du-depot.mjs +61 -0
  129. package/scripts/faits-du-circuit.mjs +7 -4
  130. package/scripts/fermeture-de-la-machine.d.mts +6 -4
  131. package/scripts/fermeture-de-la-machine.mjs +12 -16
  132. package/scripts/fichier-du-poste.d.mts +9 -0
  133. package/scripts/file-des-tickets.d.mts +0 -18
  134. package/scripts/file-des-tickets.mjs +0 -42
  135. package/scripts/fusion-du-changelog.mjs +1 -1
  136. package/scripts/greffons.mjs +282 -17
  137. package/scripts/grillhouse-maj.mjs +1 -1
  138. package/scripts/index-des-rouges.d.mts +40 -0
  139. package/scripts/index-des-rouges.mjs +104 -0
  140. package/scripts/integration/file.mjs +13 -63
  141. package/scripts/integration/integrer.mjs +157 -424
  142. package/scripts/integration/jugement.mjs +109 -0
  143. package/scripts/integration/rejeu.mjs +94 -71
  144. package/scripts/jointure.d.ts +34 -27
  145. package/scripts/journal-des-etats.d.mts +1 -1
  146. package/scripts/langages/c/commandes.mjs +27 -12
  147. package/scripts/langages/cargo/commandes.mjs +148 -94
  148. package/scripts/langages/cargo/index.mjs +2 -1
  149. package/scripts/langages/cargo/lectures-des-tests.mjs +132 -0
  150. package/scripts/langages/cargo/migrations/lectures-des-tests.mjs +31 -0
  151. package/scripts/langages/python/commandes.mjs +31 -15
  152. package/scripts/langages/python/index.mjs +2 -1
  153. package/scripts/langages/python/lectures-des-tests.mjs +148 -0
  154. package/scripts/langages/python/migrations/lectures-des-tests.mjs +31 -0
  155. package/scripts/langages/typescript/consommateurs-arbitres.mjs +2 -2
  156. package/scripts/langages/typescript/index.mjs +4 -0
  157. package/scripts/langages/typescript/lectures-des-tests.mjs +95 -0
  158. package/scripts/langages/typescript/migrations/lectures-des-tests.mjs +31 -0
  159. package/scripts/langages/typescript/tests-de-nuit.mjs +9 -15
  160. package/scripts/langages/typescript/tests.mjs +11 -37
  161. package/scripts/langages/typescript/titres-de-tests.mjs +5 -4
  162. package/scripts/langages/typescript/verifier.mjs +74 -44
  163. package/scripts/langages/typescript/vitest-config/base.mjs +3 -3
  164. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -25
  165. package/scripts/lectures-communes.mjs +234 -0
  166. package/scripts/machine.mjs +11 -18
  167. package/scripts/mesure/base-de-passe.mjs +1 -2
  168. package/scripts/mesure-de-la-machine.d.mts +40 -3
  169. package/scripts/mesure-de-la-machine.mjs +201 -11
  170. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +3 -3
  171. package/scripts/migrations/nuit-yml-retire.mjs +25 -0
  172. package/scripts/migrations/part-retiree.mjs +31 -0
  173. package/scripts/migrations.mjs +4 -0
  174. package/scripts/montee.mjs +22 -1
  175. package/scripts/nuit-de-pc2.mjs +628 -0
  176. package/scripts/nuit.sh +8 -131
  177. package/scripts/paquets.mjs +1 -1
  178. package/scripts/passe-de-la-machine.mjs +340 -103
  179. package/scripts/place-du-circuit.d.mts +15 -0
  180. package/scripts/place-du-circuit.mjs +32 -0
  181. package/scripts/places-de-la-machine.mjs +148 -626
  182. package/scripts/places-du-serveur.mjs +26 -13
  183. package/scripts/plafond-de-la-machine.d.mts +8 -13
  184. package/scripts/plafond-de-la-machine.mjs +26 -56
  185. package/scripts/registre-des-entrees.mjs +57 -0
  186. package/scripts/regles-des-places.d.mts +82 -50
  187. package/scripts/regles-des-places.mjs +192 -156
  188. package/scripts/retirer-copie.sh +9 -2
  189. package/scripts/seances.mjs +181 -63
  190. package/scripts/secours.mjs +95 -0
  191. package/scripts/services-du-noyau.mjs +11 -19
  192. package/scripts/sous-commandes.mjs +1 -0
  193. package/scripts/sous-modules.sh +1 -1
  194. package/scripts/superviseur.mjs +98 -20
  195. package/scripts/table-des-consommations.d.mts +9 -0
  196. package/scripts/table-des-consommations.mjs +35 -0
  197. package/scripts/tableau.mjs +33 -19
  198. package/scripts/taches-du-graphe.mjs +124 -2
  199. package/scripts/transitions.d.mts +27 -5
  200. package/scripts/transitions.mjs +122 -104
  201. package/scripts/verdict-de-la-nuit.d.mts +13 -0
  202. package/scripts/verdict-de-la-nuit.mjs +34 -7
  203. package/scripts/verrou-de-fichier.mjs +1 -2
  204. package/scripts/workflows-du-cadre.mjs +2 -2
  205. package/skills/developpeur/SKILL.md +8 -2
  206. package/skills/direct/SKILL.md +5 -0
  207. package/skills/explorateur/SKILL.md +10 -1
  208. package/skills/grill/SKILL.md +2 -4
  209. package/skills/pitmaster/SKILL.md +14 -7
  210. package/skills/pitmaster/references/consigne-agent.md +1 -1
  211. package/skills/relecteur/SKILL.md +4 -1
  212. package/skills/testwriter/SKILL.md +15 -2
  213. package/cadre/templates/projet/.env.example +0 -57
  214. package/cadre/templates/projet/.github/workflows/nuit.yml +0 -139
  215. package/cadre/templates/projet/deployment/README.md +0 -98
  216. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +0 -145
  217. package/cadre/templates/projet/deployment/docs/02-CONFIGURATION.md +0 -117
  218. package/cadre/templates/projet/deployment/docs/03-API.md +0 -264
  219. package/cadre/templates/projet/deployment/docs/04-TROUBLESHOOTING.md +0 -262
  220. package/cadre/templates/projet/deployment/scripts/install.ps1 +0 -100
  221. package/cadre/templates/projet/deployment/scripts/start.ps1 +0 -61
  222. package/cadre/templates/projet/deployment/scripts/stop.ps1 +0 -37
  223. package/cadre/templates/projet/deployment/scripts/test.ps1 +0 -118
  224. package/cadre/templates/projet/ecosystem.config.cjs +0 -73
  225. package/cadre/templates/projet/src/config.ts +0 -68
  226. package/cadre/templates/projet/src/errors.ts +0 -102
  227. package/cadre/templates/projet/src/index.ts +0 -46
  228. package/cadre/templates/projet/src/services/.gitkeep +0 -8
  229. package/cadre/templates/projet/src/types/index.ts +0 -24
  230. package/cadre/templates/projet/src/utils/logger.ts +0 -106
  231. package/cadre/templates/projet/tests/unit/config.spec.ts +0 -68
  232. package/cadre/templates/projet/tests/unit/errors.spec.ts +0 -132
  233. package/cadre/templates/projet/tests/unit/types.spec.ts +0 -73
  234. package/cadre/templates/projet/tsconfig.build.json +0 -14
  235. package/scripts/flux-de-la-nuit.mjs +0 -39
  236. package/scripts/garde-de-la-memoire.mjs +0 -231
  237. package/scripts/repli-de-la-nuit.mjs +0 -184
@@ -223,48 +223,6 @@ export function leReportRendLaPlace(t, maintenant) {
223
223
  return reporteJusqua(t, maintenant) !== null || (t.status === 'deferred' && !t.defer_until);
224
224
  }
225
225
 
226
- /**
227
- * The circuits of <circuits> that hold a place in the limit of the project (`grillhouse.circuits`),
228
- * as a Kanban limit of work in progress keeps a blocked card in it: a circuit that works, one
229
- * resumed and waiting for its place of the machine, and one stopped on a question to the
230
- * supervisor (no recipient, or `qui` « superviseur »). A question to the owner, a ticket deferred
231
- * (`leReportRendLaPlace` at <maintenant>) and a wait for another project release their place. Each circuit is judged by
232
- * its own memo, read again at every wake of the queue.
233
- * @param {Array<{ ticket: string, etape?: string | null, question?: { qui?: string } | null }>} circuits
234
- * the circuits alive, each with its memo
235
- * @param {Parameters<typeof ticketsAPartir>[0]} tous every ticket of the project
236
- * @param {{ externes?: Record<string, typeof tous>, maintenant?: number }} [o]
237
- * @returns {{ tenant: string[], superviseur: string[] }} the circuits that hold the limit, and
238
- * among them those that wait for the supervisor, each sorted
239
- */
240
- export function circuitsDeLaLimite(circuits, tous, { externes, maintenant = Date.now() } = {}) {
241
- const parId = new Map(tous.map(t => [t.id, t]));
242
- const tenant = [];
243
- const superviseur = [];
244
- for (const c of circuits) {
245
- const t = parId.get(c.ticket);
246
- if (
247
- t &&
248
- (leReportRendLaPlace(t, maintenant) || attendDeLAutreProjet(t, externes).length > 0)
249
- ) {
250
- continue;
251
- }
252
- // A circuit reported for the usage limit (its kept report) waits for an hour, as a ticket
253
- // deferred does: it releases its place.
254
- if (c.report) {
255
- continue;
256
- }
257
- if (c.question) {
258
- if (c.question.qui === 'responsable') {
259
- continue;
260
- }
261
- superviseur.push(c.ticket);
262
- }
263
- tenant.push(c.ticket);
264
- }
265
- return { tenant: tenant.sort(), superviseur: superviseur.sort() };
266
- }
267
-
268
226
  /**
269
227
  * The tickets of <tous> in the queue that never start for want of their section
270
228
  * « ## Architecture », their dependencies open or closed, sorted by id.
@@ -1,7 +1,7 @@
1
1
  // The frame's merge driver of the CHANGELOG (packages/grillhouse/docs/architecture/entree.md §5.1:
2
2
  // a lot enters main by a three-way application that never loses an entry), on the model of gnulib's git-merge-changelog: two
3
3
  // lots that each add an entry under the same heading both keep their entry, wherever git merges
4
- // three ways (the integration's `git apply --3way --index`, the relaunch's `git apply --3way`, the
4
+ // three ways (the queue's rebase, the relaunch's `git apply --3way`, the
5
5
  // copy's `git merge --ff-only --autostash`, a rebase, a cherry-pick).
6
6
  //
7
7
  // grillhouse fusion-du-changelog <base> <nous> <eux> git's %O %A %B; writes the result in <nous>
@@ -6,6 +6,8 @@
6
6
  //
7
7
  // npx grillhouse greffons [<project>] installs the declared plugins (the current directory by default)
8
8
  // npx grillhouse greffons --absents [<project>] prints what the project lacks, one line each (see below)
9
+ // npx grillhouse greffons --purger removes the entries whose folder is gone
10
+ // npx grillhouse greffons --oublier <copy> removes the entries of a working copy
9
11
  //
10
12
  // - The list is `enabledPlugins` of the project's `.claude/settings.json` (a plugin at `true`; one
11
13
  // at `false` or unlisted is left alone) and `extraKnownMarketplaces` for the marketplaces. A
@@ -22,7 +24,14 @@
22
24
  // claude added after), and its exact text when the JSON value is the same.
23
25
  // - A plugin is installed for the project when `claude plugin list --json` has an entry for it of
24
26
  // scope user, or of scope project or local whose `projectPath` is the project's root (both paths
25
- // resolved); the entry's state (enabled, errors) is not read.
27
+ // resolved); the entry's state (enabled, errors) is not read. That list is the account's, of every
28
+ // project, of any size, and `claude` filters none of it: a process of this script (`--lire`)
29
+ // reads it as it comes and hands over the entries that install for the project alone. A reading
30
+ // that fails says its cause (the delay, the signal, the return code and what claude wrote).
31
+ // - The registry of Claude Code (`plugins/installed_plugins.json` under `CLAUDE_CONFIG_DIR`, else
32
+ // `~/.claude`) loses entries of scope local alone, written there directly as `claude plugin
33
+ // uninstall` runs in a folder that is gone: those of a removed copy (scripts/retirer-copie.sh,
34
+ // `--oublier`) and those whose folder is gone (the montée, scripts/montee.mjs, `--purger`).
26
35
  // - A failure has its line on the error output, naming the plugin and the command that installs it
27
36
  // (a failed add: the marketplace's command, then the plugin's; a mod left at another version than
28
37
  // the package's: both versions and the command that aligns them — behind, after its update, `claude
@@ -41,11 +50,19 @@
41
50
  // montée to its version, `npx grillhouse maj <mod's version>`. A version that is not
42
51
  // x.y.z (a plugin whose manifest carries none) and a script without its package's package.json
43
52
  // beside it compare nothing.
44
- import { spawnSync } from 'node:child_process';
45
- import { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
53
+ import { spawn, spawnSync } from 'node:child_process';
54
+ import {
55
+ existsSync,
56
+ readFileSync,
57
+ realpathSync,
58
+ renameSync,
59
+ statSync,
60
+ writeFileSync,
61
+ } from 'node:fs';
62
+ import os from 'node:os';
46
63
  import path from 'node:path';
47
64
  import { isDeepStrictEqual } from 'node:util';
48
- import { pathToFileURL } from 'node:url';
65
+ import { fileURLToPath, pathToFileURL } from 'node:url';
49
66
 
50
67
  const DELAI_LECTURE_MS = 5000;
51
68
 
@@ -58,17 +75,37 @@ function resolu(p) {
58
75
  }
59
76
  }
60
77
 
61
- // Runs claude; `absent` is true when the command does not exist, `delai` when it was stopped.
78
+ // Runs claude, its output read whole, whatever its size.
62
79
  function claude(args, options = {}) {
63
- const r = spawnSync('claude', args, { encoding: 'utf8', ...options });
80
+ const r = spawnSync('claude', args, { encoding: 'utf8', maxBuffer: Infinity, ...options });
64
81
  return {
65
82
  ok: r.status === 0 && !r.error,
66
83
  absent: r.error?.code === 'ENOENT',
67
84
  delai: r.error?.code === 'ETIMEDOUT',
85
+ status: r.status,
86
+ signal: r.signal,
87
+ code: r.error?.code,
68
88
  stdout: r.stdout ?? '',
89
+ stderr: r.stderr ?? '',
69
90
  };
70
91
  }
71
92
 
93
+ // The answer of a reading that failed: its command and its true cause.
94
+ function echecDeLecture(args, r, delai) {
95
+ const dit = r.stderr.trim().split('\n').at(-1);
96
+ const cause = r.delai
97
+ ? `interrompu après ${delai / 1000} s`
98
+ : `échoue (${
99
+ r.signal
100
+ ? `signal ${r.signal}`
101
+ : typeof r.status === 'number'
102
+ ? `code ${r.status}${dit ? ` : ${dit}` : ''}`
103
+ : r.code
104
+ })`;
105
+ return { erreur: `\`claude ${args.join(' ')} --json\` ${cause}`, delai: r.delai };
106
+ }
107
+
108
+ const illisible = args => ({ erreur: `\`claude ${args.join(' ')} --json\` rend un JSON illisible` });
72
109
  // The declaration of the project: `{ plugins: [id], marches: {name: {source}} }`, or `{ erreur }`.
73
110
  function declaration(projet) {
74
111
  const f = path.join(projet, '.claude', 'settings.json');
@@ -95,10 +132,7 @@ function lireListe(args, delai) {
95
132
  return { absent: true };
96
133
  }
97
134
  if (!r.ok) {
98
- return {
99
- erreur: `\`claude ${args.join(' ')} --json\` ${r.delai ? 'interrompu' : 'échoue'}`,
100
- delai: r.delai,
101
- };
135
+ return echecDeLecture(args, r, delai);
102
136
  }
103
137
  try {
104
138
  const v = JSON.parse(r.stdout);
@@ -108,9 +142,221 @@ function lireListe(args, delai) {
108
142
  } catch {
109
143
  // unreadable, below
110
144
  }
111
- return { erreur: `\`claude ${args.join(' ')} --json\` rend un JSON illisible` };
145
+ return illisible(args);
146
+ }
147
+
148
+ // Reads the text of a JSON array of objects piece by piece, one object parsed at a time, and holds
149
+ // those `garder` accepts alone: `lire(text)` each piece, then `fin()`, the objects held, or null
150
+ // when the text is no such array.
151
+ function filtreDeListe(garder) {
152
+ const tenus = [];
153
+ let lieu = 'avant';
154
+ let objet = '';
155
+ let profondeur = 0;
156
+ let chaine = false;
157
+ let echappe = false;
158
+ let faux = false;
159
+ const dansLObjet = c => {
160
+ objet += c;
161
+ if (chaine) {
162
+ chaine = echappe || c !== '"';
163
+ echappe = !echappe && c === '\\';
164
+ } else if (c === '"') {
165
+ chaine = true;
166
+ } else if (c === '{' || c === '[') {
167
+ profondeur++;
168
+ } else if (c === '}' || c === ']') {
169
+ profondeur--;
170
+ if (profondeur === 0) {
171
+ try {
172
+ const v = JSON.parse(objet);
173
+ if (garder(v)) {
174
+ tenus.push(v);
175
+ }
176
+ } catch {
177
+ faux = true;
178
+ }
179
+ objet = '';
180
+ }
181
+ }
182
+ };
183
+ const entreLesObjets = c => {
184
+ if (c === '[' && lieu === 'avant') {
185
+ lieu = 'dans';
186
+ } else if (c === ']' && lieu === 'dans') {
187
+ lieu = 'apres';
188
+ } else if (c === '{' && lieu === 'dans') {
189
+ profondeur = 1;
190
+ objet = c;
191
+ } else if (c !== ',' && c.trim() !== '') {
192
+ faux = true;
193
+ }
194
+ };
195
+ return {
196
+ lire(texte) {
197
+ for (const c of texte) {
198
+ (profondeur > 0 ? dansLObjet : entreLesObjets)(c);
199
+ }
200
+ },
201
+ fin: () => (!faux && lieu === 'apres' && profondeur === 0 ? tenus : null),
202
+ };
203
+ }
204
+
205
+ // `greffons.mjs --lire <root> <delay>`, the process of `lireGreffons`: runs `claude plugin list
206
+ // --json`, stopped after <delay> ms (0: never), reads its output as it comes, and writes the
207
+ // answer, which holds the entries that install a plugin for the project at <root> alone.
208
+ function filtrerLaListe(racine, delai) {
209
+ const args = ['plugin', 'list'];
210
+ const filtre = filtreDeListe(e => installePourLeProjet([e], e.id, racine));
211
+ const r = { delai: false, stderr: '' };
212
+ const p = spawn('claude', [...args, '--json'], { stdio: ['ignore', 'pipe', 'pipe'] });
213
+ const minuterie =
214
+ delai > 0 &&
215
+ setTimeout(() => {
216
+ r.delai = true;
217
+ p.kill('SIGKILL');
218
+ p.stdout.destroy();
219
+ p.stderr.destroy();
220
+ }, delai);
221
+ p.stdout.setEncoding('utf8').on('data', t => filtre.lire(t));
222
+ p.stderr.setEncoding('utf8').on('data', t => {
223
+ r.stderr = `${r.stderr}${t}`.slice(-2000);
224
+ });
225
+ p.on('error', e => {
226
+ r.code = e.code;
227
+ });
228
+ p.on('close', (status, signal) => {
229
+ clearTimeout(minuterie);
230
+ const liste = filtre.fin();
231
+ let reponse;
232
+ if (r.code === 'ENOENT') {
233
+ reponse = { absent: true };
234
+ } else if (r.delai || r.code || status !== 0) {
235
+ reponse = echecDeLecture(args, { ...r, status, signal }, delai);
236
+ } else {
237
+ reponse = liste ? { liste } : illisible(args);
238
+ }
239
+ process.stdout.write(JSON.stringify(reponse));
240
+ });
241
+ }
242
+
243
+ // The entries of `claude plugin list --json` that install a plugin for the project at `racine`:
244
+ // `{ liste }`, `{ absent }` or `{ erreur, delai }`. The list is the account's, of every project, and
245
+ // `claude` filters none of it: a process apart reads it as it comes and answers the project's
246
+ // entries alone, so no script here holds the whole list.
247
+ function lireGreffons(racine, delai = 0) {
248
+ const r = spawnSync(
249
+ process.execPath,
250
+ [fileURLToPath(import.meta.url), '--lire', racine, String(delai)],
251
+ { encoding: 'utf8', maxBuffer: Infinity }
252
+ );
253
+ try {
254
+ return JSON.parse(r.stdout);
255
+ } catch {
256
+ const cause = r.error?.message || r.stderr?.trim() || `code ${r.status}`;
257
+ return { erreur: `la lecture de la liste des greffons échoue (${cause})` };
258
+ }
259
+ }
260
+
261
+ // The registry where Claude Code records the plugins installed, of the whole account.
262
+ const fichierDuRegistre = () =>
263
+ path.join(
264
+ process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'),
265
+ 'plugins',
266
+ 'installed_plugins.json'
267
+ );
268
+
269
+ // Removes from the registry the entries of scope local whose `projectPath` `retirer` accepts, and
270
+ // returns how many: `claude plugin uninstall` runs in the project's folder, which is gone here. An
271
+ // id left without entry goes; a registry with nothing to remove, or none, is not written. Throws,
272
+ // the file untouched, on one that does not read or of another version.
273
+ function retirerLesInscriptions(retirer) {
274
+ const f = fichierDuRegistre();
275
+ if (!existsSync(f)) {
276
+ return 0;
277
+ }
278
+ let registre;
279
+ try {
280
+ registre = JSON.parse(readFileSync(f, 'utf8'));
281
+ } catch {
282
+ // unreadable, below
283
+ }
284
+ if (registre?.version !== 2 || typeof registre.plugins !== 'object' || !registre.plugins) {
285
+ throw new Error(
286
+ `le registre des greffons ${f} n'a pas la forme attendue (version 2) : aucune inscription n'est retirée.`
287
+ );
288
+ }
289
+ let retirees = 0;
290
+ for (const [id, entrees] of Object.entries(registre.plugins)) {
291
+ if (!Array.isArray(entrees)) {
292
+ continue;
293
+ }
294
+ const reste = entrees.filter(
295
+ e => !(e?.scope === 'local' && typeof e.projectPath === 'string' && retirer(e.projectPath))
296
+ );
297
+ if (reste.length === entrees.length) {
298
+ continue;
299
+ }
300
+ retirees += entrees.length - reste.length;
301
+ if (reste.length === 0) {
302
+ delete registre.plugins[id];
303
+ } else {
304
+ registre.plugins[id] = reste;
305
+ }
306
+ }
307
+ if (retirees > 0) {
308
+ // Written aside then renamed, onto the file a link names: a reader never sees half of it.
309
+ const cible = realpathSync(f);
310
+ const aCote = `${cible}.${process.pid}.tmp`;
311
+ writeFileSync(aCote, JSON.stringify(registre, null, 2), { mode: statSync(cible).mode });
312
+ renameSync(aCote, cible);
313
+ }
314
+ return retirees;
315
+ }
316
+
317
+ // The path resolved through the links of the part of it that exists, a removed folder's included.
318
+ function reelMemeParti(p) {
319
+ const absolu = path.resolve(p);
320
+ try {
321
+ return realpathSync(absolu);
322
+ } catch {
323
+ const parent = path.dirname(absolu);
324
+ return parent === absolu ? absolu : path.join(reelMemeParti(parent), path.basename(absolu));
325
+ }
112
326
  }
113
327
 
328
+ // True when nothing stands at `p`; a path that does not read (rights, a mount) stands.
329
+ function disparu(p) {
330
+ try {
331
+ statSync(p);
332
+ return false;
333
+ } catch (e) {
334
+ return e.code === 'ENOENT' || e.code === 'ENOTDIR';
335
+ }
336
+ }
337
+
338
+ /**
339
+ * Removes the entries of scope local that name the working copy at `copie`, or a folder in it, and
340
+ * returns how many.
341
+ * @param {string} copie
342
+ */
343
+ export function oublierLaCopie(copie) {
344
+ const cible = reelMemeParti(copie);
345
+ return retirerLesInscriptions(p => {
346
+ const r = reelMemeParti(p);
347
+ return r === cible || r.startsWith(`${cible}${path.sep}`);
348
+ });
349
+ }
350
+
351
+ /** Removes the entries of scope local whose folder is gone, and returns how many. */
352
+ export function purgerLesInscriptions() {
353
+ return retirerLesInscriptions(p => path.isAbsolute(p) && disparu(p));
354
+ }
355
+
356
+ /** The line that says `n` entries removed. */
357
+ export const direLesRetraits = n =>
358
+ `${n} inscription${n > 1 ? 's' : ''} de greffons de portée locale retirée${n > 1 ? 's' : ''}`;
359
+
114
360
  // True when the entries hold the plugin for the project (scope user, or project/local at its root).
115
361
  function installePourLeProjet(entrees, id, racine) {
116
362
  return entrees.some(
@@ -203,7 +449,7 @@ function installer(projet, { declarations = projet, seulement, version }) {
203
449
  return [];
204
450
  }
205
451
  const lignes = [];
206
- const lecturePlugins = lireListe(['plugin', 'list'], undefined);
452
+ const lecturePlugins = lireGreffons(racine);
207
453
  if (lecturePlugins.absent) {
208
454
  return d.plugins.map(
209
455
  id =>
@@ -211,7 +457,7 @@ function installer(projet, { declarations = projet, seulement, version }) {
211
457
  );
212
458
  }
213
459
  if (lecturePlugins.erreur) {
214
- return [`${lecturePlugins.erreur} : aucun greffon n'est installé.`];
460
+ return [`${lecturePlugins.erreur} : rien n'est installé.`];
215
461
  }
216
462
  const lectureMarches = lireListe(['plugin', 'marketplace', 'list'], undefined);
217
463
  if (lectureMarches.erreur) {
@@ -259,7 +505,7 @@ function installer(projet, { declarations = projet, seulement, version }) {
259
505
  // then read again. Returns the line of a mod that stays at another version, with the command that
260
506
  // aligns it (`ecart`); none when the versions agree or compare nothing.
261
507
  function aligner(racine, declares, version) {
262
- const lecture = lireListe(['plugin', 'list'], undefined);
508
+ const lecture = lireGreffons(racine);
263
509
  const avant = lecture.liste ? ecart(lecture.liste, declares, racine, version) : null;
264
510
  if (!avant) {
265
511
  return [];
@@ -267,7 +513,7 @@ function aligner(racine, declares, version) {
267
513
  let reste = avant;
268
514
  if (avant.derriere) {
269
515
  const r = claude(['plugin', 'update', avant.id, '--scope', avant.scope], { cwd: racine });
270
- const relue = r.ok ? lireListe(['plugin', 'list'], undefined) : {};
516
+ const relue = r.ok ? lireGreffons(racine) : {};
271
517
  reste = relue.liste ? ecart(relue.liste, declares, racine, version) : avant;
272
518
  }
273
519
  if (!reste) {
@@ -299,7 +545,7 @@ export function greffonsAbsents(projet) {
299
545
  if (d.plugins.length === 0) {
300
546
  return [];
301
547
  }
302
- const lecture = lireListe(['plugin', 'list'], DELAI_LECTURE_MS);
548
+ const lecture = lireGreffons(racine, DELAI_LECTURE_MS);
303
549
  if (lecture.absent) {
304
550
  return ['claude'];
305
551
  }
@@ -364,11 +610,30 @@ function plusAncienne(a, b) {
364
610
  return false;
365
611
  }
366
612
 
613
+ // The gestures on the registry, `--purger` and `--oublier <copie>`: their line, or their failure.
614
+ function surLeRegistre(geste) {
615
+ try {
616
+ const n = geste();
617
+ if (n > 0) {
618
+ process.stdout.write(`${direLesRetraits(n)}.\n`);
619
+ }
620
+ } catch (e) {
621
+ process.stderr.write(`${e.message}\n`);
622
+ process.exitCode = 1;
623
+ }
624
+ }
625
+
367
626
  if (process.argv[1] && import.meta.url === pathToFileURL(resolu(process.argv[1])).href) {
368
627
  const args = process.argv.slice(2);
369
628
  const absents = args[0] === '--absents';
370
629
  const projet = path.resolve((absents ? args[1] : args[0]) ?? '.');
371
- if (absents) {
630
+ if (args[0] === '--lire') {
631
+ filtrerLaListe(args[1], Number(args[2]));
632
+ } else if (args[0] === '--purger') {
633
+ surLeRegistre(purgerLesInscriptions);
634
+ } else if (args[0] === '--oublier' && args[1]) {
635
+ surLeRegistre(() => oublierLaCopie(args[1]));
636
+ } else if (absents) {
372
637
  const lignes = greffonsAbsents(projet);
373
638
  if (lignes.length > 0) {
374
639
  process.stdout.write(`${lignes.join('\n')}\n`);
@@ -22,7 +22,7 @@
22
22
  // An `aFaire` goes on the error stream with its command, exit code non-zero, the version stays
23
23
  // so that the next update plays it again; the `restes` are reported last, « reste au projet »,
24
24
  // with no effect on the exit code nor on the version.
25
- // - The workflows (scripts/workflows-du-cadre.mjs): `ci.yml` and `nuit.yml` carrying the frame's
25
+ // - The workflows (scripts/workflows-du-cadre.mjs): `ci.yml` and `machine-vierge.yml` carrying the frame's
26
26
  // mark on their first line are rewritten when they differ; a missing one is written once the
27
27
  // project holds one; a workflow without the mark is the project's.
28
28
  // - `.claude/settings.json`, when it exists: the marketplace `roomi-fields`
@@ -0,0 +1,40 @@
1
+ export const BORNE_DE_L_INDEX: number;
2
+ export const BORNE_DE_LA_CAUSE: number;
3
+
4
+ /** A red as the index reads it. */
5
+ export interface RougeAIndexer {
6
+ paquet: string;
7
+ fichier: string | null;
8
+ message: string;
9
+ proprietaire: string;
10
+ dansLePlan: boolean;
11
+ test: boolean;
12
+ compte?: number;
13
+ }
14
+
15
+ /** One group of the index: package, file, normalised cause. */
16
+ export interface EntreeDIndex {
17
+ paquet: string;
18
+ fichier: string | null;
19
+ cause: string | null;
20
+ compte: number;
21
+ proprietaire: string;
22
+ dansLePlan: boolean;
23
+ test: boolean;
24
+ detail: string;
25
+ texte: string;
26
+ }
27
+
28
+ export interface IndexDesRouges {
29
+ regroupement: 'cause' | 'fichier' | 'paquet';
30
+ total: number;
31
+ entrees: EntreeDIndex[];
32
+ }
33
+
34
+ export function normaliserLaCause(message: string): string;
35
+ export function ligneDeLEntree(e: EntreeDIndex, regroupement?: string): string;
36
+ export function indexerLesRouges(
37
+ rouges: RougeAIndexer[],
38
+ options: { detail: string; borne?: number }
39
+ ): IndexDesRouges;
40
+ export function guideDeLIndex(index: IndexDesRouges, detail: string): string;
@@ -0,0 +1,104 @@
1
+ // The index of the reds of a pass of checks: one entry per group (package, file, normalised cause),
2
+ // with its count, its owner and the address of the detail, which holds each red whole. The
3
+ // circuit decides on the index (the package, the file, the owner and the counts), never on the cause
4
+ // nor on the detail; only the agents open the detail (the claim check of Temporal, the file a
5
+ // Bazel event cites by its uri). Beyond its bound the index groups by file, then by package, says so
6
+ // and keeps every red in its counts.
7
+
8
+ // The entries an index holds at most before it groups by file, then by package.
9
+ export const BORNE_DE_L_INDEX = 60;
10
+ // The characters of a normalised cause at most.
11
+ export const BORNE_DE_LA_CAUSE = 200;
12
+
13
+ // The motifs that vary from one run to the next, each replaced by a fixed marker, the first that
14
+ // matches first: a uuid, a date (and its time), a time, a path, a hexadecimal identifier, a
15
+ // duration, a run of digits.
16
+ const MOTIFS = [
17
+ [/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi, '<uuid>'],
18
+ [/\b\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?Z?)?/g, '<date>'],
19
+ [/\b\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?\b/g, '<heure>'],
20
+ [/(?:(?:\.{1,2}|~)?\/(?:[\w@.+~-]+\/?)+|(?:[\w@.+~-]+\/){2,}[\w@.+~-]*)/g, '<chemin>'],
21
+ [/\b(?=[0-9a-f]*\d)[0-9a-f]{7,64}\b/gi, '<id>'],
22
+ [/\b\d+(?:\.\d+)?\s?(?:ms|µs|ns|s|min|h)\b/g, '<durée>'],
23
+ [/\d+/g, '<n>'],
24
+ ];
25
+
26
+ // The cause of a failure message <message>: its first line, normalised, bounded.
27
+ export function normaliserLaCause(message) {
28
+ const premiere = String(message ?? '')
29
+ .split('\n')
30
+ .map(l => l.trim())
31
+ .find(Boolean);
32
+ let cause = premiere ?? '';
33
+ for (const [motif, marqueur] of MOTIFS) {
34
+ cause = cause.replace(motif, marqueur);
35
+ }
36
+ return cause.replace(/\s+/g, ' ').trim().slice(0, BORNE_DE_LA_CAUSE);
37
+ }
38
+
39
+ const nombre = r => r.compte ?? 1;
40
+
41
+ // The key of the group of a red at <niveau>: the owner and whether the plan holds it never mix.
42
+ const cleDe = (niveau, r, cause) =>
43
+ JSON.stringify([
44
+ r.paquet,
45
+ niveau === 'paquet' ? null : (r.fichier ?? null),
46
+ niveau === 'cause' ? cause : null,
47
+ r.proprietaire,
48
+ Boolean(r.dansLePlan),
49
+ Boolean(r.test),
50
+ ]);
51
+
52
+ // The line of the entry <e> of an index grouped by <regroupement>, as a report words it.
53
+ export const ligneDeLEntree = (e, regroupement = 'cause') =>
54
+ `- ${e.fichier ?? e.paquet}${e.cause ? ` — ${e.cause}` : ''} — ${e.compte} rouge(s)${
55
+ regroupement === 'cause' ? '' : `, causes regroupées par ${regroupement}`
56
+ }${e.proprietaire === 'developpeur' ? '' : ` (${e.proprietaire})`}`;
57
+
58
+ // The index of the reds <rouges> (`{ paquet, fichier, message, proprietaire, dansLePlan, test,
59
+ // compte? }`): `{ regroupement, total, entrees }`, each entry `{ paquet, fichier, cause, compte,
60
+ // proprietaire, dansLePlan, test, detail, texte }`. <detail> is the address of the file that holds
61
+ // each red whole.
62
+ export function indexerLesRouges(rouges, { detail, borne = BORNE_DE_L_INDEX }) {
63
+ const causes = rouges.map(r => normaliserLaCause(r.message));
64
+ const total = rouges.reduce((s, r) => s + nombre(r), 0);
65
+ for (const regroupement of ['cause', 'fichier', 'paquet']) {
66
+ const groupes = new Map();
67
+ rouges.forEach((r, i) => {
68
+ const cle = cleDe(regroupement, r, causes[i]);
69
+ const g = groupes.get(cle);
70
+ if (g) {
71
+ g.compte += nombre(r);
72
+ } else {
73
+ groupes.set(cle, {
74
+ paquet: r.paquet,
75
+ fichier: regroupement === 'paquet' ? null : (r.fichier ?? null),
76
+ cause: regroupement === 'cause' ? causes[i] : null,
77
+ compte: nombre(r),
78
+ proprietaire: r.proprietaire,
79
+ dansLePlan: Boolean(r.dansLePlan),
80
+ test: Boolean(r.test),
81
+ detail,
82
+ });
83
+ }
84
+ });
85
+ if (groupes.size <= borne || regroupement === 'paquet') {
86
+ return {
87
+ regroupement,
88
+ total,
89
+ entrees: [...groupes.values()].map(e => ({ ...e, texte: ligneDeLEntree(e, regroupement) })),
90
+ };
91
+ }
92
+ }
93
+ return { regroupement: 'paquet', total, entrees: [] };
94
+ }
95
+
96
+ // The sentence that opens the list of an index in a report: where the detail lies, and how the
97
+ // causes are grouped when the index is over its bound.
98
+ export function guideDeLIndex(index, detail) {
99
+ const dit =
100
+ index.regroupement === 'cause'
101
+ ? ''
102
+ : ` L'index regroupe les causes par ${index.regroupement} (plus de ${BORNE_DE_L_INDEX} groupes), ${index.total} rouge(s) au compte.`;
103
+ return `Chaque rouge est entier dans ${detail} ; ouvre ce fichier si la cause ne suffit pas, ou rejoue \`npm test -- <fichier>\`.${dit}`;
104
+ }